来自Firefly wiki
跳转至: 导航搜索

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:

  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::


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>;
        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:

		if ((RK_PWM_TIME_BIT1_MIN < ddata->period) &&
		    (ddata->period < RK_PWM_TIME_BIT1_MAX))
			ddata->scandata |= (0x01 << 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;


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:

    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


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 使用

如下图是通过按红外遥控器按钮,所产生的波形,主要由head,Control,information,signed free这四部分组成,具体可以参考RC6 Protocol

Rk3399 ir 1.png