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: Mon, 4 Jul 2022 22:04:38 +0300 [thread overview]
Message-ID: <YsM5xhEXb6rzl1X9@jyty> (raw)
In-Reply-To: <YsK6Rlk/ODYUE2/F@gofer.mess.org>
[-- Attachment #1: Type: text/plain, Size: 4931 bytes --]
Hi Sean,
Mon, Jul 04, 2022 at 11:00:38AM +0100, Sean Young wrote:
>Hi Marko,
>
>On Mon, Jul 04, 2022 at 12:20:01PM +0300, Marko Mäkelä wrote:
>> Mon, Jul 04, 2022 at 08:21:39AM +0100, Sean Young wrote:
>> > On Sun, Jul 03, 2022 at 08:02:14PM +0300, Marko Mäkelä wrote:
>> > > 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.
>> >
>> > Toggle and repeat are distinct concepts.
>> >
>> > rc_repeat() is for protocols which have a special repeat message, which
>> > carry no information other that "repeat the last message". However,
>> > all protocols repeat. Whether they use a special repeat message or not.
>> >
>> > It's right that if a protocol repeats a message, LIRC_SCANCODE_FLAG_REPEAT
>> > is set.
>>
>> Is it right to set the flag when a message is being repeated due to user
>> effort (repeatedly pressing and releasing a button, instead of holding the
>> button down)?
>
>The problem here is that the nec repeat is used by some remotes, but
>not others. Some nec remotes repeat the entire code every time. Our
>generic nec decoder cannot distinguish between the two. So, our nec
>decoder interprets both a nec repeat and a repeated code as "button
>being held down".
I see. My experience of remote control protocols is mostly limited to
RC5.
>> As far as I understand, the change that you suggested would set the
>> LIRC_SCANCODE_FLAG_REPEAT if I repeatedly press a button on the NEC protocol
>> remote control, but not on an RC5 remote control.
>
>RC5 too.
I think that it is depends on the implementation of the firmware that
runs on the remote control unit. If the button is released and quickly
pressed again so that no keyboard matrix scan was scheduled to run in
between, then the firmware could report it as a repeat event.
Alternatively, every second IR message could be lost, so that the
receiver would observe the same toggle bit value for every IR message
that it receives.
>>I tested the attached patch (which was created on 5.19-rc5, which
>>failed to boot on my system for unrelated reasons) on Linux 5.17, on
>>top of your fixes to rtl28xxu and rc-core.
>
>You'll need to fix this.
The 5.19-rc5 boot failure could have been related to LUKS setup on that
machine, because a kernel panic message was displayed before I was being
prompted for an encryption key. The modules would not have been loaded
at that point, so I do not think that it is related to my modifications.
When compiled for the v5.17 kernel release tag on another computer, the
patch that implements rc_keydown_or_repeat() worked for me.
It does not look like there are many changes in drivers/media/rc between
5.17 and 5.19.
>>If the user wants to quickly switch to channel 111 by quickly pressing
>>the button three times, it should not be misreported as an
>>auto-repeated event, but reported as 3 LIRC events without the
>>"repeat" flag, and as 3 pairs of keydown and keyup events.
>
>Ideally yes, if we can distinguish between the two.
Okay, I understand that we indeed cannot always do that.
>See https://github.com/seanyoung/cir/
This could open up many possibilities. Would the decoded events also be
available via some low-level interface to user-space programs, in
addition to the input event driver?
>>On the other hand, there should be no reason for an application to not
>>honor repeat events for a volume button. That is of course up to the
>>application to decide, not the kernel.
>
>Well, that's not the way things work. Keys have autorepeats which are
>generated kernel-side. I think libinput wants to change this to user
>space but certainly not application side.
It is how https://tvdr.de works. I have been using it via two
interfaces: a built-in LIRC interface, and vdr-plugin-remote for the
Linux input device driver. In http://git.tvdr.de/vdr.git you can find
that in some cases, normal key-presses are being distinguished from
repeat events (git grep -w k_Repeat). This is the reason why I brought
up the missing LIRC_SCANCODE_FLAG_REPEAT in the RC5 protocol decoder:
VDR with the LIRC interface would observe that the user is repeatedly
pressing a button even when the button is being held down.
>> If you agree that this patch is on the right track, an interface for the new
>> function rc_keydown_or_repeat() may have to be exposed to the BPF interface
>> as well.
>
>I'm not sure why that is needed.
I am attaching a minimal version of the patch, just one hunk, like you
suggested earlier. I did not observe any bad effects with either remote
control unit I tested it with: RC5 and NEC, again, on the rtl28xxu and
with your two commits, on the v5.17 tag.
Best regards,
Marko
[-- Attachment #2: 0001-media-rc-Always-report-LIRC-repeat-flag.patch --]
[-- Type: text/x-diff, Size: 1064 bytes --]
From 7bdda9eccd704076297a0d0802c8638b4562c703 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= <marko.makela@mariadb.com>
Date: Mon, 4 Jul 2022 21:56:08 +0300
Subject: [PATCH] media: rc: Always report LIRC repeat flag
The flag LIRC_SCANCODE_FLAG_REPEAT was never set by rc_keydown().
Previously it was only set by rc_repeat(), but not all protocol
decoders invoke that function.
---
drivers/media/rc/rc-main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index f27f6b383816..d875d84ea221 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -786,7 +786,8 @@ static void ir_do_keydown(struct rc_dev *dev, enum rc_proto protocol,
dev->last_toggle != toggle);
struct lirc_scancode sc = {
.scancode = scancode, .rc_proto = protocol,
- .flags = toggle ? LIRC_SCANCODE_FLAG_TOGGLE : 0,
+ .flags = (toggle ? LIRC_SCANCODE_FLAG_TOGGLE : 0) |
+ (!new_event ? LIRC_SCANCODE_FLAG_REPEAT : 0),
.keycode = keycode
};
--
2.36.1
next prev parent reply other threads:[~2022-07-04 19:04 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ä
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ä [this message]
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=YsM5xhEXb6rzl1X9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox