IR
Update time:2018-05-02 Views:3322
IR Configuration
The Firefly-RK3399 development board comes with IR sensor (between the USB OTG and headset jack) . This article describes how to use and configure the IR to work properly.
You can do this in two parts:
Modify the IR kernel driver. Works on both Linux and Android, which is low level hacking.
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 kernel/drivers/input/remotectl/rockchip_pwm_remotectl.c
Define Data Structure
Do as follows:
Add a array as follow:
&pwm3 { status = "okay"; interrupts = ; compatible = "rockchip,remotectl-pwm"; remote_pwm_id = ; handle_cpu_id = ; ir_key1{rockchip,usercode = ;rockchip,key_table =,,,,,,,,,,,;};};
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 period) &&(ddata->period scandata |= (0x01 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;}}}
使用下面命令可以使能DBG_CODE打印:
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/ff420030_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 使用
如下图是通过按红外遥控器按钮,所产生的波形,主要由head,Control,information,signed free这四部分组成,具体可以参考RC6 Protocol