User Tools

Site Tools


ir_receiver_setup_on_le_potato

Setting up lirc and evdev on Le Potato

  • Make sure that the kernel module is loaded meson_ir (Its in their kernel by default and if you use their config for a custom kernel)
  • Install Dependencies
    emerge --ask media-tv/v4l-utils app-misc/lirc dev-python/python-evdev app-misc/evtest
  • Modprobe kernel modules
    modprobe -a ir-nec-decoder ir-rc5-decoder ir-rc6-decoder ir-jvc-decoder ir-sony-decoder ir-rc5-sz-decoder ir-sanyo-decoder ir-mce_kbd-decoder ir-lirc-codec
  • Get keycodes for each button on your remote
    ir-keytable -c -p NEC,RC-5,RC-6,JVC,SONY -t
  • press buttons and make a list of buttons, keycodes and protocol from output similar to below
    lirc protocol(nec): scancode = 0x40
  • using the information you gathered created make remote definition https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h:Valid Keycodes
    austin@mobilemouse ~/mocp_i2c_lcd_ir_remote $ cat /lib/udev/rc_keymaps/my_remote.toml
    [[protocols]]
    name = "My_Remote"
    protocol = "nec"
    variant = "nec32"
    
    [protocols.scancodes]
    0x45 = "KEY_POWER"
    0x46 = "KEY_MODE"
    0x47 = "KEY_MUTE"
    
    0x44 = "KEY_PLAYPAUSE"
    0x40 = "KEY_BACK"
    0x43 = "KEY_FORWARD"
    
    0x07 = ""
    0x15 = "KEY_VOLUMEDOWN"
    0x09 = "KEY_VOLUMEUP"
    
    0x16 = "KEY_0"
    0x19 = "KEY_SHUFFLE"
    0x0d = ""
    
    0x0c = "KEY_1"
    0x18 = "KEY_2"
    0x5e = "KEY_3"
    0x08 = "KEY_4"
    0x1c = "KEY_5"
    0x5a = "KEY_6"
    0x42 = "KEY_7"
    0x52 = "KEY_8"
    0x4a = "KEY_9"
  • Clear the keytable and test with your config file
    ir-keytable -c -w /lib/udev/rc_keymaps/my_remote.toml -t
  • Add the remote def to /etc/rc_maps.cfg
    #driver table                    file
    *       *                        my_remote.toml
  • Load it on boot
    • create service
      mobilemouse /etc/init.d # cat irkeytable
      #!/sbin/openrc-run
      # Copyright 2023 Gentoo Authors
      # Distributed under the terms of the GNU General Public License v2
      
      name="irkeytable"
      description="add irkeytable config"
      
      start() {
          /usr/bin/ir-keytable -a /etc/rc_maps.cfg -s rc0
      }
    • add to default run level
      rc-update add irkeytable default
  • Add any modules that you might need to autoload (my case was: ir-nec-decoder and ir-lirc-codec)
    echo "ir-nec-decoder\nir-lirc-codec" >> /etc/modprobe.d/lirc.conf
  • Reboot to verify its good and test with evtest
    austin@mobilemouse ~/mocp_i2c_lcd_ir_remote $ evtest
    No device specified, trying to scan all of /dev/input/event*
    Not running as root, no devices may be available.
    Available devices:
    /dev/input/event0:      Solid State System Co.,Ltd. USB PnP Audio Device
    /dev/input/event5:      meson_ao_cec
    /dev/input/event6:      meson-ir
    Select the device event number [0-6]: 6
    Input driver version is 1.0.1
    Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0
    Input device name: "meson-ir"
    Supported events:
      Event type 0 (EV_SYN)
      Event type 1 (EV_KEY)
        Event code 2 (KEY_1)
        Event code 3 (KEY_2)
        Event code 4 (KEY_3)
        Event code 5 (KEY_4)
        Event code 6 (KEY_5)
        Event code 7 (KEY_6)
        Event code 8 (KEY_7)
        Event code 9 (KEY_8)
        Event code 10 (KEY_9)
        Event code 11 (KEY_0)
        Event code 113 (KEY_MUTE)
        Event code 114 (KEY_VOLUMEDOWN)
        Event code 115 (KEY_VOLUMEUP)
        Event code 116 (KEY_POWER)
        Event code 158 (KEY_BACK)
        Event code 159 (KEY_FORWARD)
        Event code 164 (KEY_PLAYPAUSE)
        Event code 373 (KEY_MODE)
        Event code 410 (KEY_SHUFFLE)
      Event type 2 (EV_REL)
        Event code 0 (REL_X)
        Event code 1 (REL_Y)
      Event type 4 (EV_MSC)
        Event code 4 (MSC_SCAN)
    Key repeat handling:
      Repeat type 20 (EV_REP)
        Repeat code 0 (REP_DELAY)
          Value    400
        Repeat code 1 (REP_PERIOD)
          Value     80
    Properties:
      Property type 5 (INPUT_PROP_POINTING_STICK)
    Testing ... (interrupt to exit)
  • Once evtest is working you can code against it: My Example controlling moc
ir_receiver_setup_on_le_potato.txt · Last modified: 2024/09/22 22:08 by 127.0.0.1