Sharp IR Remote on Intel NUC 2820 double presses

  • I just installed LibreElec 8.2.4 on an Intel NUC 2820. I previously had Kodi on top of Fedora on this same box, but when the SSD died I decided to try LibreElec as it boots a lot faster. In order to get spouse approval, this new config needs to look pretty much the same as the old one.

    Everything was humming along until I got to the IR Remote config. We have been using a the stock SHARP remote control that came with the TV for years which I manually configured with LIRC on Fedora....worked great. Now I am trying to reproduce that same working remote on LibreElec

    I found that setting the ir-keytable protocol to "sharp" and manually creating the /storage/.config/rc_keymaps/sharp_remote and updating /storage/.config/rc_maps.cfg to point to my new keymap was fairly easy and straight forward to get the keys to map like I had them before.

    But I am not suffering from the dreaded double keypress which will be a deal breaker with the spouse.

    I have been debugging it and it appears that the double presses are coming out of the Kernel input module. From what I understand the path of a keypress from remote to Kodi is something like:

    1. Keypress is received at builtin Intel NUC Optical receiver (ITE8713 CIR transceiver). Note that the remote control continually repeats the button as long as it is pressed. Every press of a button results in multiple repeats of the button

    2. The Kernel Module "ite-cir" receives the signal and demodulates it.

    3. The demodulated signal then goes to Kernel Module "ir_sharp_decoder" which looks for the bits and spaces and eventually calls rc_keydown() with a scancode.

    4. rc_keydown() in the rc_core Kernel module calls ir_do_keydown() which calls input_event() which handles /dev/input and eventually lands in the keyboard driver.

    5. the keyboard driver and the rc_core module do a little dance to translate the scancode into a keycode.

    6. The autorepeat stuff apparently is handled in the keyboard/input kernel module. Eventually something is emitted to all processes via the /dev/input/event10 character device (event10 is my rc input device)

    7. eventlircd opens that /dev/input/event10 device to receive the events from the Kernel. I also note that Xorg process has this device opened as well although I am not sure how or if Kodi interacts with Xorg in LibreElec.

    8. If my understanding is correct, eventlircd process takes the event and puts it into the LIRC socket /run/lirc/lircd

    9. Kodi listens to the lirc socket to receive the inputs.


    When I run "ir-keytable -t" (after shutting down Kodi and eventlircd) I see that it too opens /dev/input/event10 and reports what it sees.

    In my case, I see double keypresses in ir-keytable -t no matter what I set for the DELAY or PERIOD. (-D and -P options to ir-keytable).

    At this point I am stumped. I looked through the Kernel modules trying to determine where DELAY and PERIOD come into play but didn't find what I was looking for. I see that eventlircd also has a -R option to enable "repeat filtering" but this is said to be defaulted to "true". Unfortunately the "verbose" options of eventlircd don't work like the -t option to ir-keytable...I can't see what events eventlircd is sending to the lircd socket.

    I haven't looked at the sourcecode to eventlircd yet, but I suppose that is the next step. If anybody has advice I would love to hear it.

    I know that a lot of people saw the double keypresses because lircd process was also enabled. In 8.2.4 this is not enabled and I don't see any lircd process.

  • Could you please post the output of "ir-keytable" and then run "ir-ctl -r", press a button and post the output you got on the console (a sequence of "pulse" and "space" lines).

    so long,

    Hias

  • Hias,

    Thanks for trying to help. I am a relative novice at IR, but willing to learn. I didn't realize that rc_core still puts output on /dev/lirc0. A single keypress will result in output on both /dev/lirc0 (raw IR pulse/spaces) and /dev/input/event10 (keyboard presses).

    Below is the output you asked for, plus output you didn't ask for that hopefully will help.

    As another test, I turned off eventlircd (systemctl stop eventlircd) and enabled lircd daemon using LibreElec Services program (after putting my original Fedora lircd.conf in /storage/.config/lircd.conf). I still see double presses, although it doesn't seem as bad of a problem. 'irw /run/lirc/lirc.socket' with lircd running also shows double presses (see bottom of this post).

    One subjective observation is that the problem seems to get worse with more button presses...when I first boot LibreElec double button presses are less frequent. But they get worse over time.

    Here are the outputs you requested:

    ir-keytable

    Found /sys/class/rc/rc0/ (/dev/input/event10) with:

    Driver ite-cir, table rc-rc6-mce

    Supported protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp

    Enabled protocols: lirc sharp

    Name: ITE8713 CIR transceiver

    bus: 25, vendor/product: 1283:0000, version: 0x0000

    Repeat delay = 500 ms, repeat period = 125 ms


    ir-ctl -f

    Receive features /dev/lirc0:

    - Device can receive raw IR

    - Resolution 8 nanoseconds

    - Set receive carrier

    - Can set recording timeout min:100000 microseconds max:1000000 microseconds

    Send features /dev/lirc0:

    - Device can send raw IR

    - Set carrier

    - Set duty cycle


    I ran this command:

    ir-ctl -r & ir-keytable -t &

    Both commands run together in background to get this output for a single press of the KEY_ENTER:

    pulse 199

    space 4961394

    pulse 199

    space 6022081

    pulse 286

    space 1805

    pulse 260

    space 781

    pulse 286

    space 746

    pulse 286

    space 755

    pulse 286

    space 746

    pulse 286

    space 1805

    pulse 286

    space 1805

    pulse 286

    space 1805

    pulse 286

    space 746

    pulse 286

    space 1805

    pulse 286

    space 1805

    pulse 286

    space 1805

    pulse 286

    space 1805

    pulse 286

    space 1805

    pulse 286

    space 746

    pulse 286

    space 42002

    pulse 286

    space 1805

    pulse 286

    space 755

    pulse 286

    space 746

    pulse 286

    space 746

    pulse 286

    space 755

    pulse 286

    space 755

    pulse 286

    space 746

    pulse 286

    space 746

    pulse 286

    space 1805

    pulse 286

    space 755

    pulse 286

    space 755

    pulse 286

    space 746

    pulse 286

    space 755

    pulse 286

    space 755

    pulse 286

    space 1805

    pulse 286

    space 48321

    pulse 260

    1521459160.538043: event type EV_MSC(0x04): scancode = 0x1f7

    1521459160.538043: event type EV_KEY(0x01) key_down: KEY_ENTER(0x001c)

    1521459160.538043: event type EV_SYN(0x00).

    space 1831

    pulse 286

    space 755

    pulse 286

    space 755

    pulse 286

    space 746

    pulse 286

    space 746

    pulse 286

    space 1805

    pulse 286

    space 1805

    pulse 286

    space 1805

    pulse 286

    space 755

    pulse 286

    pulse 286

    space 1805

    pulse 286

    space 1805

    pulse 286

    space 755

    pulse 286

    space 42002

    pulse 286

    space 1805

    pulse 286

    space 755

    pulse 286

    space 755

    pulse 286

    space 746

    pulse 260

    space 781

    pulse 286

    space 746

    pulse 286

    space 755

    pulse 286

    space 746

    pulse 260

    space 1831

    pulse 260

    space 781

    pulse 260

    space 781

    pulse 286

    space 746

    pulse 260

    space 781

    pulse 286

    space 746

    pulse 260

    space 1831

    pulse 286

    1521459160.807549: event type EV_KEY(0x01) key_up: KEY_ENTER(0x001c)

    1521459160.807549: event type EV_SYN(0x00).

    1521459160.823221: event type EV_MSC(0x04): scancode = 0x1f7

    1521459160.823221: event type EV_KEY(0x01) key_down: KEY_ENTER(0x001c)

    1521459160.823221: event type EV_SYN(0x00).

    1521459161.074215: event type EV_KEY(0x01) key_up: KEY_ENTER(0x001c)

    1521459161.074215: event type EV_SYN(0x00).

    space 14557013

    pulse 182

    space 3038315

    pulse 451

    NOTE that the timedifference between the two "key_down" events above is 0.285 seconds. Double presses are always very close to this time difference (see test below).


    ir-keytable -t

    In this test I pressed each button only once, This was one of my earlier tests and double presses are less frequent. As can be seen, most keys gave only a single press, but KEY_REWIND, KEY_PLAY, KEY_FASTFORWARD, KEY_PAUSE and KEY_STOP gave double presses.

    Testing events. Please, press CTRL-C to abort.

    1521456857.831435: event type EV_MSC(0x04): scancode = 0x157

    1521456857.831435: event type EV_KEY(0x01) key_down: KEY_UP(0x0067)

    1521456857.831435: event type EV_SYN(0x00).

    1521456858.087783: event type EV_KEY(0x01) key_up: KEY_UP(0x0067)

    1521456858.087783: event type EV_SYN(0x00).

    1521456858.655837: event type EV_MSC(0x04): scancode = 0x158

    1521456858.655837: event type EV_KEY(0x01) key_down: KEY_DOWN(0x006c)

    1521456858.655837: event type EV_SYN(0x00).

    1521456858.914448: event type EV_KEY(0x01) key_up: KEY_DOWN(0x006c)

    1521456858.914448: event type EV_SYN(0x00).

    1521456859.374624: event type EV_MSC(0x04): scancode = 0x1f5

    1521456859.374624: event type EV_KEY(0x01) key_down: KEY_LEFT(0x0069)

    1521456859.374624: event type EV_SYN(0x00).

    1521456859.634457: event type EV_KEY(0x01) key_up: KEY_LEFT(0x0069)

    1521456859.634457: event type EV_SYN(0x00).

    1521456859.970473: event type EV_MSC(0x04): scancode = 0x1f6

    1521456859.970473: event type EV_KEY(0x01) key_down: KEY_RIGHT(0x006a)

    1521456859.970473: event type EV_SYN(0x00).

    1521456860.221114: event type EV_KEY(0x01) key_up: KEY_RIGHT(0x006a)

    1521456860.221114: event type EV_SYN(0x00).

    1521456860.600405: event type EV_MSC(0x04): scancode = 0x1f7

    1521456860.600405: event type EV_KEY(0x01) key_down: KEY_ENTER(0x001c)

    1521456860.600405: event type EV_SYN(0x00).

    1521456860.861114: event type EV_KEY(0x01) key_up: KEY_ENTER(0x001c)

    1521456860.861114: event type EV_SYN(0x00).

    1521456864.111615: event type EV_MSC(0x04): scancode = 0x323

    1521456864.111615: event type EV_KEY(0x01) key_down: KEY_REWIND(0x00a8)

    1521456864.111615: event type EV_SYN(0x00).

    1521456864.381111: event type EV_KEY(0x01) key_up: KEY_REWIND(0x00a8)

    1521456864.381111: event type EV_SYN(0x00).

    1521456864.402817: event type EV_MSC(0x04): scancode = 0x323

    1521456864.402817: event type EV_KEY(0x01) key_down: KEY_REWIND(0x00a8)

    1521456864.402817: event type EV_SYN(0x00).

    1521456864.674447: event type EV_KEY(0x01) key_up: KEY_REWIND(0x00a8)

    1521456864.674447: event type EV_SYN(0x00).

    1521456864.781919: event type EV_MSC(0x04): scancode = 0x322

    1521456864.781919: event type EV_KEY(0x01) key_down: KEY_PLAY(0x00cf)

    1521456864.781919: event type EV_SYN(0x00).

    1521456865.047786: event type EV_KEY(0x01) key_up: KEY_PLAY(0x00cf)

    1521456865.047786: event type EV_SYN(0x00).

    1521456865.074285: event type EV_MSC(0x04): scancode = 0x322

    1521456865.074285: event type EV_KEY(0x01) key_down: KEY_PLAY(0x00cf)

    1521456865.074285: event type EV_SYN(0x00).

    1521456865.341109: event type EV_KEY(0x01) key_up: KEY_PLAY(0x00cf)

    1521456865.341109: event type EV_SYN(0x00).

    1521456865.373252: event type EV_MSC(0x04): scancode = 0x321

    1521456865.373252: event type EV_KEY(0x01) key_down: KEY_FASTFORWARD(0x00d0)

    1521456865.373252: event type EV_SYN(0x00).

    1521456865.634443: event type EV_KEY(0x01) key_up: KEY_FASTFORWARD(0x00d0)

    1521456865.634443: event type EV_SYN(0x00).

    1521456865.665651: event type EV_MSC(0x04): scancode = 0x321

    1521456865.665651: event type EV_KEY(0x01) key_down: KEY_FASTFORWARD(0x00d0)

    1521456865.665651: event type EV_SYN(0x00).

    1521456865.927784: event type EV_KEY(0x01) key_up: KEY_FASTFORWARD(0x00d0)

    1521456865.927784: event type EV_SYN(0x00).

    1521456865.996023: event type EV_MSC(0x04): scancode = 0x325

    1521456865.996023: event type EV_KEY(0x01) key_down: KEY_PAUSE(0x0077)

    1521456865.996023: event type EV_SYN(0x00).

    1521456866.130409: event type EV_MSC(0x04): scancode = 0x325

    1521456866.130409: event type EV_SYN(0x00).

    1521456866.381109: event type EV_KEY(0x01) key_up: KEY_PAUSE(0x0077)

    1521456866.381109: event type EV_SYN(0x00).

    1521456866.421615: event type EV_MSC(0x04): scancode = 0x325

    1521456866.421615: event type EV_KEY(0x01) key_down: KEY_PAUSE(0x0077)

    1521456866.421615: event type EV_SYN(0x00).

    1521456866.674445: event type EV_KEY(0x01) key_up: KEY_PAUSE(0x0077)

    1521456866.674445: event type EV_SYN(0x00).

    1521456868.010800: event type EV_MSC(0x04): scancode = 0x327

    1521456868.010800: event type EV_KEY(0x01) key_down: KEY_STOP(0x0080)

    1521456868.010800: event type EV_SYN(0x00).

    1521456868.274443: event type EV_KEY(0x01) key_up: KEY_STOP(0x0080)

    1521456868.274443: event type EV_SYN(0x00).

    1521456868.300840: event type EV_MSC(0x04): scancode = 0x327

    1521456868.300840: event type EV_KEY(0x01) key_down: KEY_STOP(0x0080)

    1521456868.300840: event type EV_SYN(0x00).

    1521456868.567780: event type EV_KEY(0x01) key_up: KEY_STOP(0x0080)

    1521456868.567780: event type EV_SYN(0x00).

    1521456871.606002: event type EV_MSC(0x04): scancode = 0x10a

    1521456871.606002: event type EV_KEY(0x01) key_down: KEY_0(0x000b)

    1521456871.606002: event type EV_SYN(0x00).

    1521456871.874449: event type EV_KEY(0x01) key_up: KEY_0(0x000b)

    1521456871.874449: event type EV_SYN(0x00).

    1521456872.245146: event type EV_MSC(0x04): scancode = 0x101

    1521456872.245146: event type EV_KEY(0x01) key_down: KEY_1(0x0002)

    1521456872.245146: event type EV_SYN(0x00).

    1521456872.514447: event type EV_KEY(0x01) key_up: KEY_1(0x0002)

    1521456872.514447: event type EV_SYN(0x00).

    1521456872.751155: event type EV_MSC(0x04): scancode = 0x102

    1521456872.751155: event type EV_KEY(0x01) key_down: KEY_2(0x0003)

    1521456872.751155: event type EV_SYN(0x00).

    1521456873.021115: event type EV_KEY(0x01) key_up: KEY_2(0x0003)

    1521456873.501112: event type EV_SYN(0x00).

    1521456873.813115: event type EV_MSC(0x04): scancode = 0x104

    1521456873.813115: event type EV_KEY(0x01) key_down: KEY_4(0x0005)

    1521456873.813115: event type EV_SYN(0x00).

    1521456874.087779: event type EV_KEY(0x01) key_up: KEY_4(0x0005)

    1521456874.087779: event type EV_SYN(0x00).

    1521456874.304459: event type EV_MSC(0x04): scancode = 0x105

    1521456874.304459: event type EV_KEY(0x01) key_down: KEY_5(0x0006)

    1521456874.304459: event type EV_SYN(0x00).

    1521456874.567779: event type EV_KEY(0x01) key_up: KEY_5(0x0006)

    1521456874.567779: event type EV_SYN(0x00).

    1521456874.834096: event type EV_MSC(0x04): scancode = 0x106

    1521456874.834096: event type EV_KEY(0x01) key_down: KEY_6(0x0007)

    1521456874.834096: event type EV_SYN(0x00).

    1521456875.101113: event type EV_KEY(0x01) key_up: KEY_6(0x0007)

    1521456875.101113: event type EV_SYN(0x00).

    1521456875.376924: event type EV_MSC(0x04): scancode = 0x107

    1521456875.376924: event type EV_KEY(0x01) key_down: KEY_7(0x0008)

    1521456875.376924: event type EV_SYN(0x00).

    1521456875.634446: event type EV_KEY(0x01) key_up: KEY_7(0x0008)

    1521456875.634446: event type EV_SYN(0x00).

    1521456875.850593: event type EV_MSC(0x04): scancode = 0x108

    1521456875.850593: event type EV_KEY(0x01) key_down: KEY_8(0x0009)

    1521456875.850593: event type EV_SYN(0x00).

    1521456876.114445: event type EV_KEY(0x01) key_up: KEY_8(0x0009)

    1521456876.114445: event type EV_SYN(0x00).

    1521456876.356196: event type EV_MSC(0x04): scancode = 0x109

    1521456876.356196: event type EV_KEY(0x01) key_down: KEY_9(0x000a)

    1521456876.356196: event type EV_SYN(0x00).

    1521456876.621112: event type EV_KEY(0x01) key_up: KEY_9(0x000a)

    Another test where I grep out the 'key_down' lines. I went around the circle (UP, RIGHT, DOWN, LEFT) 4 times with a single press to each button. The majority of keypresses were double presses although some were not. The difference in timestamps between the double presses are always very close to .29 seconds:

    grep key_down /tmp/ir-keytable.out

    1521457354.775483: event type EV_KEY(0x01) key_down: KEY_UP(0x0067)

    1521457355.063078: event type EV_KEY(0x01) key_down: KEY_UP(0x0067)

    1521457355.390885: event type EV_KEY(0x01) key_down: KEY_RIGHT(0x006a)

    1521457355.677328: event type EV_KEY(0x01) key_down: KEY_RIGHT(0x006a)

    1521457356.069767: event type EV_KEY(0x01) key_down: KEY_DOWN(0x006c)

    1521457356.359763: event type EV_KEY(0x01) key_down: KEY_DOWN(0x006c)

    1521457356.932706: event type EV_KEY(0x01) key_down: KEY_LEFT(0x0069)

    1521457357.714832: event type EV_KEY(0x01) key_down: KEY_UP(0x0067)

    1521457358.002486: event type EV_KEY(0x01) key_down: KEY_UP(0x0067)

    1521457358.412021: event type EV_KEY(0x01) key_down: KEY_RIGHT(0x006a)

    1521457359.180218: event type EV_KEY(0x01) key_down: KEY_DOWN(0x006c)

    1521457359.957358: event type EV_KEY(0x01) key_down: KEY_LEFT(0x0069)

    1521457360.243787: event type EV_KEY(0x01) key_down: KEY_LEFT(0x0069)

    1521457360.592230: event type EV_KEY(0x01) key_down: KEY_UP(0x0067)

    1521457360.879829: event type EV_KEY(0x01) key_down: KEY_UP(0x0067)

    1521457361.460692: event type EV_KEY(0x01) key_down: KEY_RIGHT(0x006a)

    1521457361.799043: event type EV_KEY(0x01) key_down: KEY_DOWN(0x006c)

    1521457362.089031: event type EV_KEY(0x01) key_down: KEY_DOWN(0x006c)

    1521457362.549846: event type EV_KEY(0x01) key_down: KEY_LEFT(0x0069)

    1521457362.836312: event type EV_KEY(0x01) key_down: KEY_LEFT(0x0069)

    1521457363.164010: event type EV_KEY(0x01) key_down: KEY_UP(0x0067)

    1521457363.451644: event type EV_KEY(0x01) key_down: KEY_UP(0x0067)

    1521457363.717081: event type EV_KEY(0x01) key_down: KEY_RIGHT(0x006a)

    1521457364.319912: event type EV_KEY(0x01) key_down: KEY_DOWN(0x006c)

    1521457364.609917: event type EV_KEY(0x01) key_down: KEY_DOWN(0x006c)

    1521457364.980493: event type EV_KEY(0x01) key_down: KEY_LEFT(0x0069)

    1521457365.266934: event type EV_KEY(0x01) key_down: KEY_LEFT(0x0069)

    Going through the list above, the difference in timestamp when double presses are close to .29 seconds

    TIMEDIFF KEY

    0.287595 KEY_UP(0x0067)

    0.286443 KEY_RIGHT(0x006a)

    0.289996 KEY_DOWN(0x006c)

    0.000000 KEY_LEFT(0x0069) << single press

    0.287654 KEY_UP(0x0067)

    0.000000 KEY_RIGHT(0x006a) << single press

    0.000000 KEY_DOWN(0x006c) << single press

    0.286429 KEY_LEFT(0x0069)

    0.287599 KEY_UP(0x0067)

    0.000000 KEY_RIGHT(0x006a) << single press

    0.289988 KEY_DOWN(0x006c)

    0.286466 KEY_LEFT(0x0069)

    0.287634 KEY_UP(0x0067)

    0.000000 KEY_RIGHT(0x006a) << single press

    0.290005 KEY_DOWN(0x006c)

    0.286441 KEY_LEFT(0x0069)


    WIth lircd running I used irw to get the output from the socket:

    irw /run/lirc/lircd.socket

    lircd-0.9.4d[1294]: Notice: accepted new client on /run/lirc/lircd.socket

    lircd-0.9.4d[1294]: Info: [lirc] protocol is enabled

    \

    00000000000043be 00 KEY_ENTER sharp_remote

    00000000000043be 01 KEY_ENTER sharp_remote

    00000000000043be 00 KEY_ENTER_EVUP sharp_remote

    00000000000043aa 00 KEY_UP sharp_remote

    00000000000043aa 01 KEY_UP sharp_remote

    000000000000406a 01 KEY_DOWN sharp_remote

    000000000000406a 00 KEY_DOWN_EVUP sharp_remote

    00000000000042be 00 KEY_LEFT sharp_remote

    00000000000042be 01 KEY_LEFT sharp_remote

    00000000000042be 00 KEY_LEFT_EVUP sharp_remote

    00000000000043be 00 KEY_ENTER sharp_remote

    00000000000043be 01 KEY_ENTER sharp_remote

    00000000000043be 02 KEY_ENTER sharp_remote

    00000000000043be 00 KEY_ENTER_EVUP sharp_remote


    Thanks again,

    David.

  • Wow, thanks a lot David, this must have been the most detailled bug report I've received here so far! And it contained more than enough info to reproduce and understand the issue.

    The problem stems from the combination of using a Sharp remote with an ite-cir receiver. The Sharp IR remote messages are rather long (about 86ms in the sample you provided) and the default idle timeout of the ite-cir driver is also rather high (200ms). So what is happening is that when you release the button (no matter if it's a short or a long button press) the sum of that - 286ms - exceeds the default kernel "key release" timeout of 250ms - and the last message (which is delayed to the timeout) is seen as another button press.

    With other remotes, like for example MCE remotes, this does not occur because the sum of message time (about 40ms in case of rc-6 MCE) and 200ms timeout is just below that magical 250ms limit.

    I've recently discussed these issues with long timeouts with the kernel developer and hopefully there'll be a good solution in the future - it could take a bit, though, it's all a bit tricky.

    Fortunately, there's an easy workaround you can use for now, you can manually configure the driver to use a lower timeout. The minimum timeout of ite-cir is 100ms, I'd use that and if that causes other problems I'd try a bit longer values (125-150ms).

    You can set the timeout with ir-ctl -t TIMEOUT, but keep in mind that ir-ctl expects the value to be in microseconds, not milliseconds. So use eg "ir-ctl -t 100000" to set a 100ms timeout. You can either add that to autostart.sh or add an udev rule for that. I've posted info how to do that in the Amlogic IR remote thread here: LE9.0 remote configs ir-keytable Amlogic devices (replace "meson-ir" with "ite-cir" to make this work).

    With the rather long messages you could run into key repeat more easily, you can change that with "ir-keytable -D DELAY" - that's the delay before repeat starts, default is 500ms. Ah, and here the delay is in milliseconds, so use eg "ir-keytable -D 700" to use a slightly longer delay.

    so long,

    Hias

  • Hias,

    "it-ctl -t 100000" worked perfect.

    I must admit that it was fun watching my wife do battle with the keypresses though!

    It is now safely added to autostart.sh and there shall be peace in the household again.

    Thanks!

    David.