AIO-3399J Buy Specs

Uses RK3399 Six-Core ( A72x2+A53x4 ) 64-Bit CPU, up to 2.0Ghz , integrated Quad-Core Mali-T864 GPU. Onboard M.2 PCIe, 4G LTE interface, multiple display interface and serial port. Support Android/Linux/Ubuntu system.

IR

Update time:2018-04-13 Views:3106


IR Configuration

The AIO-3399J development board comes with IR sensor ( Between the mic interface and the speaker interface) . This article describes how to use and configure the IR to work properly.

You can do this in two parts:

  1. Modify the IR kernel driver. Works on both Linux and Android, which is low level hacking.

  2. Modify the key mapping if you are using Android, which is user space hacking.

Kernel Driver

The IR driver only supports NEC encode format. Below is the instructions of how to add your IR remote to send the right key code in Linux kernel.

There is two file related::

kernel/arch/arm64/boot/dts/rockchip/rk3399-firefly-port.dtsi
drivers/input/remotectl/rockchip_pwm_remotectl.c

Define Data Structure

Do as follows:

Add a array as follow:


&pwm3 {
	status = "okay";
	interrupts = <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH 0>;
	compatible = "rockchip,remotectl-pwm";
	remote_pwm_id = <3>;
	handle_cpu_id = <0>; 
    ir_key1{
        rockchip,usercode = <0xff00>;
        rockchip,key_table =<0xeb   KEY_POWER>,
                            <0xec   KEY_MENU>,
                            <0xfe   KEY_BACK>,
                            <0xb7   KEY_HOME>,
                            <0xa3   KEY_WWW>,
                            <0xf4   KEY_VOLUMEUP>,
                            <0xa7   KEY_VOLUMEDOWN>,
                            <0xf8   KEY_REPLY>,
                            <0xfc   KEY_UP>,
                            <0xfd   KEY_DOWN>,
                            <0xf1   KEY_LEFT>,
                            <0xe5   KEY_RIGHT>;
                            };
            };

Note: interrupts mean interrupts num

Note: remote_pwm_id mean select which PWM

Note: ir_key1 first is key value ,the second is key code

Get User Code and Key Value

You can get the answer in the remotectl_do_something func:

case RMC_USERCODE: {
    if ((RK_PWM_TIME_BIT1_MIN < ddata->period) &&(ddata->period < RK_PWM_TIME_BIT1_MAX))
	ddata->scandata |= (0x01 << ddata->count);
	ddata->count++;
	if (ddata->count == 0x10) {
	    DBG_CODE("USERCODE=0x%x\n", ddata->scandata);
	    if (remotectl_keybd_num_lookup(ddata)) {
		ddata->state = RMC_GETDATA;
		ddata->scandata = 0;
		ddata->count = 0;
	} else {
	    if (rk_remote_print_code){
		ddata->state = RMC_GETDATA;
		ddata->scandata = 0;
		ddata->count = 0;
		} else
		    ddata->state = RMC_PRELOAD;
		}
	}
    }

             

The following command can be used to make the DBG_CODE print:

echo 1 > /sys/module/rockchip_pwm_remotectl/parameters/code_print

Add the Driver to Kernel

Add the driver to kernel as the following steps:

(1) Make sure the config option is written in the file drivers/input/remotectl/Kconfig, as following:

config ROCKCHIP_REMOTECTL_PWM
    bool "rockchip remoctrl pwm capture"
default n

(2) Edit drivers/input/remotectl/Makefile. Add object file as following:

obj-$(CONFIG_ROCKCHIP_REMOTECTL_PWM)+= rockchip_pwm_remotectl.o

(3) Use make menuconfig, and select in the IR support:

Device Drivers
  --->Input device support
  ----->  [*]   rockchip remotectl
  ------->[*]   rockchip remoctrl pwm capture

保存后编译烧写内核IMG文件。

Android Key Remapping

/system/usr/keylayout/ff680030_pwm.kl is a file mapping scancodes in kernel to keycodes in Android. You can add or modify it to match your IR remote's keys.

You can modify this file via adb and reboot to take effect.

IR Usage

As shown below, the waveform generated by the button of infrared remote control is mainly composed of four parts, head, Control, information and signed free, which can refer to RC6 Protocol.

Rk3399 ir 1.png