VMA317 (1838) infrared receiver on RockpiS with kernel 4.4.143-52-rockchip

Diagram

A NPN transistor inverter circuit is added to have the right pulse/space times.
The inverter implies GPIO_ACTIVE_HIGH configuration instead of GPIO_ACTIVE_LOW.

 3v3             GPIO2_A4               GND   --> RockpiS pins
  |                 |                    |
  O                 O                    O    --> Inverter pins
  |                 |                    |
  |                 \                    |
  |                 / 1k                 |
  |                 \                    |
  |       10k       |     NPN            |
  |------/\/\/\-----+-----\_/------------|
  |                        |             |
  |                        \             |
  |                        / 100k        |
  |                        \             |
  |                        |             |
  O                        O             O    --> VMA317 pins
  |     LED       1k       |             |
  |-----|>|-----/\/\/\-----|             |
  |                        |             |
  |          47k           |      C      |
  |---------/\/\/\---------+-----| |-----|
  |                        |             |
  O                        O             O    --> 1838 pins
  |          100k          |     NPN     |
  |---------/\/\/\---------+-----\_/-----|
  |                               |      |

Compiler

sudo apt-get install device-tree-compiler
sudo apt-get install u-boot-tools
git clone https://github.com/radxa/kernel.git -b stable-4.4-rockpis
wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
sudo tar xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C /usr/local/  # https://wiki.radxa.com/RockpiS/dev/kernel-4.4
export ARCH=arm64
export CROSS_COMPILE=/usr/local/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

Modules

cd kernel
make rk3308_linux_defconfig
ssh rock@rps uname -r  # 4.4.143-52-rockchip-g7ed61b60d176
make EXTRAVERSION=-52-rockchip-g7ed61b60d176 LOCALVERSION= drivers/media/rc/gpio-ir-recv.ko obj-m=gpio-ir-recv.o
make EXTRAVERSION=-52-rockchip-g7ed61b60d176 LOCALVERSION= drivers/media/rc/ir-nec-decoder.ko obj-m=ir-nec-decoder.o
scp drivers/media/rc/gpio-ir-recv.ko rock@rps:/home/rock/
scp drivers/media/rc/ir-nec-decoder.ko rock@rps:/home/rock/
ssh rock@rps
sudo mkdir /lib/modules/$(uname -r)/kernel/drivers/media/rc
sudo cp gpio-ir-recv.ko /lib/modules/$(uname -r)/kernel/drivers/media/rc/
sudo cp ir-nec-decoder.ko /lib/modules/$(uname -r)/kernel/drivers/media/rc/
sudo /sbin/depmod

Device tree overlay

cd
vi rockpis-gpio-ir-recv.dts
/dts-v1/;
/plugin/;

/ {
    model = "Radxa ROCK Pi S";
    compatible = "radxa,rockpis-rk3308", "rockchip,rk3308";

    fragment@0 {
        target-path = "/";
        __overlay__ {
            ir_recv: ir-receiver {
                status = "okay";
                compatible = "gpio-ir-receiver";
                gpios = <&gpio2 4 0>;  /* GPIO2_A4 0=GPIO_ACTIVE_HIGH */
            };
        };
    };

    fragment@1 {
        target = <&pdm_8ch>;
        __overlay__ {
            status = "disable";
        };
    };

};

cd kernel
cp ../rockpis-gpio-ir-recv.dts arch/arm64/boot/dts/rockchip/overlay/rockpis-gpio-ir-recv.dts
vi arch/arm64/boot/dts/rockchip/overlay/Makefile  # rockpis-gpio-ir-recv.dtbo
make dtbs
scp arch/arm64/boot/dts/rockchip/overlay/rockpis-gpio-ir-recv.dtbo rock@rps:/home/rock/rockpis-gpio-ir-recv.dtbo.GPIO_ACTIVE_HIGH
ssh rock@rps
sudo mount -o remount,rw /boot
sudo cp rockpis-gpio-ir-recv.dtbo.GPIO_ACTIVE_HIGH /boot/dtbs/$(uname -r)/rockchip/overlay/rockpis-gpio-ir-recv.dtbo
sudo vi /boot/uEnv.txt +/overlays  # " rockpis-gpio-ir-recv"
sudo mount -o remount,ro /boot
sudo reboot

mode2 + ir-keytable

ssh rock@rps
sudo apt-get install lirc
mode2 -d /dev/lirc0 -H default  # tests (nec protocol: 9000 4500 563 ...)
 Using driver default on device /dev/lirc0
 Trying device: /dev/lirc0
 Using device: /dev/lirc0
 space 16777215
 pulse 9066
 space 4545
 pulse 503
 space 663
 pulse 571
 space 589
 ^C
sudo apt-get install ir-keytable
sudo ir-keytable -p nec -t  # tests (ex: KEY_PLAYPAUSE)
 Protocols changed to nec 
 Testing events. Please, press CTRL-C to abort.
 590.676132: lirc protocol(nec): scancode = 0x46
 ^C

irw

vi joyit_nec.toml
[[protocols]]
name = "joyit"
protocol = "nec"
[protocols.scancodes]
0x0d = "KEY_BACK"
0x19 = "KEY_DOWN"
0x07 = "KEY_LEFT"
0x43 = "KEY_MODE"
0x15 = "KEY_OK"
0x46 = "KEY_PLAYPAUSE"
0x09 = "KEY_RIGHT"
0x44 = "KEY_SETUP"
0x40 = "KEY_UP"

scp joyit_nec.toml rock@rps:/home/rock/
ssh rock@rps
sudo cp joyit_nec.toml /lib/udev/rc_keymaps/
sudo ir-keytable -c -w /lib/udev/rc_keymaps/joyit_nec.toml
irw  # tests
 00000000800100a4 00 KEY_PLAYPAUSE devinput-32
 ^C

irexec

vi irexec.lircrc
begin
    prog   = irexec
    button = KEY_PLAYPAUSE
    config = sudo -u rock /usr/bin/xmms2 toggle
end

scp irexec.lircrc rock@rps:/home/rock/
ssh rock@rps
sudo cp irexec.lircrc /etc/lirc/irexec.lircrc
sudo systemctl --now enable irexec
xmms2 addpls 00.m3u
xmms2 play
xmms2 status  # tests

joy-it-rc service

vi joy-it-rc.service
[Unit]
Description=Joy-IT Remote Control
Wants=lircd.service
After=lircd.service

[Service]
Type=oneshot
ExecStart=/usr/bin/ir-keytable -c -w /lib/udev/rc_keymaps/joyit_nec.toml

[Install]
WantedBy=multi-user.target

scp joy-it-rc.service rock@rps:/home/rock/
ssh rock@rps
sudo cp joy-it-rc.service /usr/lib/systemd/system/
sudo systemctl enable joy-it-rc

Questions

  • Do you have any suggestions ?
  • I2S is not disabled in device tree overlay. Can we disable i2s (I2S0_8CH_MCLK) but keep LINEOUT_R LINEOUT_L enabled ?

I2S0 isn’t enabled by default?

I2s2 the inner I2S of the ADC and dac is enabled as the norm is GPIO2_A4 with DAC & ADC working?
Haven’t tried the above overlay but have been having to hack the dtb to get I2S0 working.