All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marko Mäkelä" <marko.makela@iki.fi>
To: Sean Young <sean@mess.org>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 2/2] media: rtl28xxu: improve IR receiver
Date: Sun, 3 Jul 2022 20:02:14 +0300	[thread overview]
Message-ID: <YsHLlg9CccrEzOjL@jyty> (raw)
In-Reply-To: <Yr/+g/j20kb5kzki@gofer.mess.org>

Sat, Jul 02, 2022 at 09:14:59AM +0100, Sean Young wrote:
>Hi,
>
>On Tue, Jun 28, 2022 at 09:27:26AM +0300, Marko Mäkelä wrote:
>> Mon, Jun 27, 2022 at 11:53:52AM +0100, Sean Young wrote:
>> > Hi Marko,
>> >
>> > On Sun, Jun 26, 2022 at 03:33:47PM +0300, Marko Mäkelä wrote:
>> > > I finally took the time to get a deeper understanding of the infrared remote
>> > > control subsystem. I think that I now understand the translation into
>> > > key-down, key-up, and key-repeat events. For the RC5 protocol, rc_repeat()
>> > > will not be called by ir-rc5-decoder.c but instead, ir_do_keydown() will
>> > > handle the repeat. For lirc_scancode_event() it will never set the
>> > > LIRC_SCANCODE_FLAG_REPEAT bit, even if !new_event and the protocol does
>> > > support the toggle bit. That might qualify as a bug.
>> >
>> > You are right, this was missed. Patches welcome.
>>
>> Attached (for 5.19.0-rc3, on top of the two commits of this patch series).
>>
>> I thought that it would be the least amount of trouble to slightly change
>> the interpretation of the "toggle" parameter of
>> rc_keydown(). My intention was to use the values 1 and 2 when the toggle
>> flag is present. Any nonzero values would work.
>
>I don't understand why this is needed.

For protocols that do not use a toggle bit, the last parameter of 
rc_keydown() will usually be toggle=0, and explicit calls to rc_repeat() 
will be issued when needed. For those protocols, I thought that we would 
not want rc_keydown() to set any LIRC_SCANCODE_FLAG_REPEAT flag under 
any circumstances.

>A patch needs to be tested. Just rebuild the entire kernel and boot 
>from that.

Yes, I will do that for revising my patch.

>> -	rc_keydown(cec->ir, RC_PROTO_RC5, RC_SCANCODE_RC5(addr, key), toggle);
>> +	rc_keydown(cec->ir, RC_PROTO_RC5, RC_SCANCODE_RC5(addr, key),
>> +		   1 + toggle);
>
>You can't change the toggle value because you want a repeat flag. This makes
>no sense.
[snip]
>> --- a/drivers/media/rc/rc-main.c
>> +++ b/drivers/media/rc/rc-main.c
>> @@ -782,18 +782,19 @@ static void ir_do_keydown(struct rc_dev *dev, enum rc_proto protocol,
>>  {
>>  	bool new_event = (!dev->keypressed		 ||
>>  			  dev->last_protocol != protocol ||
>> -			  dev->last_scancode != scancode ||
>> -			  dev->last_toggle   != toggle);
>> +			  dev->last_scancode != scancode);
>> +	bool repeat_event = !new_event && toggle && dev->last_toggle == toggle;
>
>Why this change?
>
>>  	struct lirc_scancode sc = {
>>  		.scancode = scancode, .rc_proto = protocol,
>> -		.flags = toggle ? LIRC_SCANCODE_FLAG_TOGGLE : 0,
>> +		.flags = (toggle > 1 ? LIRC_SCANCODE_FLAG_TOGGLE : 0) |
>> +			 (repeat_event ? LIRC_SCANCODE_FLAG_REPEAT : 0),
>
>Why not simply (!new_event ? LIRC_SCANCODE_FLAG_REPEAT : 0) and be done with it?

Drivers that invoke rc_repeat() do not want rc_keydown() to ever set 
LIRC_SCANCODE_FLAG_REPEAT. The patch slightly changed the meaning of 
toggle: it *must* be 0 if and only if the protocol does not implement a 
toggle bit. If it does, the values must alternate between 1 and some 
greater-than-1 value.

A cleaner alternative could be to retain the interface of rc_keydown() 
as is, and add a new function, say, rc_keydown_or_repeat(), which would 
generate key-repeat events from the toggle bit.

Best regards,

	Marko

  reply	other threads:[~2022-07-03 17:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-12 16:32 [PATCH 0/2] Fix rtl28xxu nec/rc5 receiver Sean Young
2022-02-12 16:32 ` [PATCH 1/2] media: rc-core: split IR timeout into rawir timeout and keyup delay Sean Young
2022-02-12 16:32 ` [PATCH 2/2] media: rtl28xxu: improve IR receiver Sean Young
2022-06-26 12:33   ` Marko Mäkelä
2022-06-27  5:00     ` Marko Mäkelä
2022-07-02  8:17       ` Sean Young
2022-06-27 10:53     ` Sean Young
2022-06-28  6:27       ` Marko Mäkelä
2022-07-02  8:14         ` Sean Young
2022-07-03 17:02           ` Marko Mäkelä [this message]
2022-07-04  7:21             ` Sean Young
2022-07-04  9:20               ` Marko Mäkelä
2022-07-04 10:00                 ` Sean Young
2022-07-04 19:04                   ` Marko Mäkelä
2022-07-05  7:25                     ` Sean Young
2022-07-05  8:48                       ` Marko Mäkelä
2022-07-05  9:26                         ` Sean Young

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YsHLlg9CccrEzOjL@jyty \
    --to=marko.makela@iki.fi \
    --cc=linux-media@vger.kernel.org \
    --cc=sean@mess.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.