From: Sean Young <sean@mess.org>
To: "Marko Mäkelä" <marko.makela@iki.fi>
Cc: linux-media@vger.kernel.org,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Subject: Re: Inconsistent RC5 ir-keytable events
Date: Mon, 3 Jan 2022 11:07:43 +0000 [thread overview]
Message-ID: <20220103110743.GA22001@gofer.mess.org> (raw)
In-Reply-To: <YdLRa86ddm2T4xew@jyty>
Hi Marko,
On Mon, Jan 03, 2022 at 12:35:23PM +0200, Marko Mäkelä wrote:
> Hi Sean,
>
> Thank you for your prompt and helpful reply.
>
> Mon, Jan 03, 2022 at 09:21:23AM +0000, Sean Young wrote:
> > On Mon, Jan 03, 2022 at 08:52:46AM +0200, Marko Mäkelä wrote:
> > > Hi,
> > >
> > > Years ago, I was using the Hauppauge Nova-T PCI 90002 card that bundles a
> > > remote control unit that uses RC5 codes.
> >
> > Would you mind sending the lspci output for this device? Then we know
> > exactly how the driver is handling this.
>
> I am no longer using the PCI (not PCIe) card, but only the remote control
> unit. I still have the hardware sitting unused, but I do not think that it
> is relevant to the problem when attempting to use the remote control unit
> with the Astrometa DVB-T2 USB adapter.
Ah yes.
> > That's not the way things should work. The speed at which the IR message
> > gets repeated depends on the IR protocol. You don't want a key down/up
> > event for each of those.
>
> There is a use case where I actually want that. When I press and hold the
> volume-up button, or a button to scroll a list in a menu, I would the user
> interface to update as frequently as possible.
There is a balance to be struck here. If the button gets repeated too
quickly, it becomes impossible to go up/down one item, for example.
The way to do this, is to set the autorepeat period/delay to settings to
what suits your likes/dislikes; it should not depend on the lower-level
IR message.
> > You've turned off autorepeat with those options, so that's not going to
> > change anything. If you press a key, hold it for some time, and then
> > release you should get one key down, one key up and a few autorepeats
> > depending on the --delay/--period settings.
>
> You are right. I tested the bundled RCU of the adapter, and I am indeed
> seeing such output. Here is the dmesg from 5.15.5:
>
> [17984.345840] usb 2-6: Manufacturer: astrometadvbt2
> [17984.352731] usb 2-6: dvb_usb_v2: found a 'Astrometa DVB-T2' in warm state
> [17984.514105] dvbdev: DVB: registering new adapter (Astrometa DVB-T2)
> [17984.545328] Registered IR keymap rc-astrometa-t2hybrid
>
> And here is the ir-keymap -t output. It looks like what I would expect
> (except maybe the key_up event should be sent after the sequence of repeat
> events, not before them).
>
> 18022.134140: lirc protocol(nec): scancode = 0x40
> 18022.134157: event type EV_MSC(0x04): scancode = 0x40
> 18022.134157: event type EV_KEY(0x01) key_down: KEY_FULL_SCREEN(0x0174)
> 18022.134157: event type EV_SYN(0x00).
> 18022.260014: event type EV_KEY(0x01) key_up: KEY_FULL_SCREEN(0x0174)
> 18022.260014: event type EV_SYN(0x00).
So the delay for the keyup is 125857us or about 125ms.
> 18022.345513: lirc protocol(nec): scancode = 0x40 repeat
> 18022.345524: event type EV_MSC(0x04): scancode = 0x40
> 18022.345524: event type EV_SYN(0x00).
However here the repeat gets reported too late. It gets reported 211373us
after the first scancode (about 211ms).
> 18022.561538: lirc protocol(nec): scancode = 0x40 repeat
> 18022.561549: event type EV_MSC(0x04): scancode = 0x40
> 18022.561549: event type EV_SYN(0x00).
> ...
> 18024.057680: lirc protocol(nec): scancode = 0x40 repeat
> 18024.057694: event type EV_MSC(0x04): scancode = 0x40
> 18024.057694: event type EV_SYN(0x00).
> ^C
>
> > I think this is the issue you are having. Somehow there are gaps in
> > reading the IR, which are long enough to cause key up/down events.
>
> I watched the IR LED in the live viewfinder of a digital camera while
> pressing a button, and you may be right: instead of seeing a constant stream
> of pulses, I saw a few pulses followed by a pause, then again a few pulses.
> After I replaced the batteries, I only saw a short pause every couple of
> seconds, which probably was a sampling artifact of the camera. But, this did
> not improve the situation on Linux yet.
I am not sure if the naked eye can observe a delay of 200ms rather than 100ms.
> > Each rc device has a timeout which determines how long after keydown
> > event, a key up event is sent as long as the same IR is not received
> > again. This is usually IR_DEFAULT_TIMEOUT (125ms). You can see the value
> > with
> > `ir-ctl -f -d /dev/lirc0`
> >
> > I think the problem is that the gaps in your IR is greater than this timeout.
>
> Again, you seem to be right:
>
> sudo apt install v4l-utils
> ir-ctl -f -d /dev/lirc0 Receive features /dev/lirc0:
> - Device can receive raw IR
> - Can report decoded scancodes and protocol
> - Receiving timeout 9741 microseconds
> Send features /dev/lirc0:
> - Device cannot send
>
> How to increase the timeout from this less than 10ms to something closer to
> 125ms?
This is the timeout field on rcdev. I think it is set here:
https://git.linuxtv.org/media_tree.git/tree/drivers/media/usb/dvb-usb-v2/rtl28xxu.c#n1810
I think the interval is to set to value which is much to high; I think the
211 ms comes from this 200 value here. So, I think if you lower this to
100 then your problems might go away.
I had forgotten that that for the delay between key down and key up, this
also adds the repeat period for the protocol, see
https://git.linuxtv.org/media_tree.git/tree/drivers/media/rc/rc-main.c#n857
So actually that is 110ms + 9741us ≈ 119m, which is near enough the values seen
above. I suspect the issue is the interval but please experiment.
Sean
next prev parent reply other threads:[~2022-01-03 11:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <YdKdPosyzj2urFpS@jyty>
2022-01-03 9:21 ` Inconsistent RC5 ir-keytable events Sean Young
2022-01-03 10:35 ` Marko Mäkelä
2022-01-03 11:07 ` Sean Young [this message]
2022-01-03 12:21 ` Marko Mäkelä
2022-01-04 16:07 ` Marko Mäkelä
2022-01-05 9:53 ` Sean Young
2022-01-06 11:41 ` Marko Mäkelä
2022-01-13 16:55 ` Sean Young
2022-01-14 6:31 ` Marko Mäkelä
2022-01-29 17:15 ` Marko Mäkelä
2022-02-08 16:46 ` Sean Young
2022-02-09 8:12 ` Marko Mäkelä
2022-02-12 11:16 ` Sean Young
2022-02-12 16:34 ` Sean Young
2022-02-13 17:12 ` Marko Mäkelä
2022-03-26 18:44 ` Marko Mäkelä
2022-04-10 14:07 ` Marko Mäkelä
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=20220103110743.GA22001@gofer.mess.org \
--to=sean@mess.org \
--cc=linux-media@vger.kernel.org \
--cc=marko.makela@iki.fi \
--cc=mchehab+huawei@kernel.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.