全志H713红外IR遥控配置方法

篇头

  • 全志H713 Soc是一颗 A53四核心,支持MAX 2GB DDR, 支持1920x1080P LVDS接口, 支持梯形校正功能的芯片,非常适合用于开发投影仪,尤其是低成本的LCD投影。
  • 本文详细介绍此平台,配置一个新的红外遥控器的方法。

一、遥控器规格

  • 先拿到遥控器的规格书,获取用户码(头码)及其他按键的硬件码值
  • 确认IR的红外协议,此案例IR为NEC协议

全志H713红外IR遥控配置方法_第1张图片

二、NEC IR 配置方法

2.1 驱动开启NEC协议

  • 全志H713已默认开启NEC IR驱动
  • 可在menuconfig中查找下图【Remote controller support】配置的位置,进入后开启相关IR驱动

全志H713红外IR遥控配置方法_第2张图片

2.2 添加key-map文件

  • 根据IR规格书,用户码(头码)为0x807f为例,则新建如下文件,头码字节序要颠倒一下

  • vendor\aw\homlet\hardware\input\multi_ir\keylayout\customer_ir_7f80.kl

  • 如下,根据IR规格,填写键值映射关系

key 6   BACK
key 4   MENU
key 8   DPAD_CENTER
key 27   DPAD_DOWN
key 5   DPAD_UP
key 1   HOME
key 7   DPAD_LEFT
key 9   DPAD_RIGHT
key 12   VOLUME_UP
key 14   VOLUME_DOWN
key 18   POWER
key 61   TV_INPUT

2.3 将.kl文件追加到编译系统

  • 编辑 aw/homlet/hardware/input/multi_ir/multiir.mk
diff --git a/vendor/aw/homlet/hardware/input/multi_ir/multiir.mk b/vendor/aw/homlet/hardware/input/multi_ir/multiir.mk
index 9e700162ab..5aefa94f73 100644
--- a/vendor/aw/homlet/hardware/input/multi_ir/multiir.mk
+++ b/vendor/aw/homlet/hardware/input/multi_ir/multiir.mk
@@ -13,6 +13,7 @@ BASE_KL_COPY_LIST := virtual-remote.kl \
        customer_rc5_ir_04.kl \
 
 BASE_KL_COPY_LIST += customer_ir_9f00.kl \
+       customer_ir_7f80.kl \                ###<--- 添加自己的.kl到这里
        customer_ir_dd22.kl \
        customer_ir_fb04.kl \
        customer_ir_ff00.kl \

2.4 配置dts

  • 此处配置主要影响到待机后的电源键的响应,需分别配置borad.dts和uboot-board.dts
  • longan\device\config\chips\h713\configs\tuna_p3\linux-5.4\board.dts
  • longan\device\config\chips\h713\configs\tuna_p3\uboot-board.dts
  • 如下图,添加DC ON按键,其中ir_addr为IR用户码(头码)

全志H713红外IR遥控配置方法_第3张图片

1)board.dts
diff --git a/longan/device/config/chips/h713/configs/tuna_p3/linux-5.4/board.dts b/longan/device/config/chips/h713/configs/tuna_p3/linux-5.4/board.dts
index af9d8b7e2f..38baa35c8f 100755
--- a/longan/device/config/chips/h713/configs/tuna_p3/linux-5.4/board.dts
+++ b/longan/device/config/chips/h713/configs/tuna_p3/linux-5.4/board.dts
@@ -62,7 +62,7 @@
                gpio_group = "PL";
                gpio_pin = <9>;
                gpio_function = <3>;
-               count = <14>;
+               count = <15>;                    #### <-- 1. 增加1个按键的count数
                ir_power_key_code0 = <0x40>;
                ir_addr_code0 = <0xfe01>;
                ir_power_key_code1 = <0x1a>;
@@ -91,6 +91,8 @@
                ir_addr_code12 = <0xfb04>;
                ir_power_key_code13 = <0x42>;
                ir_addr_code13 = <0xbf00>;
+               ir_power_key_code14 = <0x12>;    #### <-- 2. 增加客制化的电源按键HW按键值
+               ir_addr_code14 = <0x7f80>;       #### <-- 3. 增加客制化IR的用户头码,注意字节序颠倒
        };2)uboot-board.dts (同理,修改此文件)
diff --git a/longan/device/config/chips/h713/configs/tuna_p3/uboot-board.dts b/longan/device/config/chips/h713/configs/tuna_p3/uboot-board.dts
index d166e3fa05..71adc28d51 100644
--- a/longan/device/config/chips/h713/configs/tuna_p3/uboot-board.dts
+++ b/longan/device/config/chips/h713/configs/tuna_p3/uboot-board.dts
@@ -62,7 +62,7 @@
                gpio_group = "PL";
                gpio_pin = <9>;
                gpio_function = <3>;
-               count = <14>;
+               count = <15>;                   
                ir_power_key_code0 = <0x40>;

@@ -73,7 +73,7 @@
                ir_power_key_code13 = <0x42>;
                ir_addr_code13 = <0xbf00>;
+               ir_power_key_code14 = <0x12>;
+               ir_addr_code14 = <0x7f80>;
        };
 };

三、其他IR协议

  • 以customer_rc5_ir_04.kl举例,将对应的协议名称追加在文件名中即可
  • 其余与NEC配置方法相同

四、附录

4.1 头码配置无效

  • 规格所写头码为0x807f,系统无法识别,将出现下面的现象
  • getevent 命令显示:按键无效,所有按键皆为0000
console:/ # getevent   

/dev/input/event1: 0004 0004 017f801b
/dev/input/event1: 0000 0000 00000000
/dev/input/event1: 0004 0004 007f801b
/dev/input/event1: 0000 0000 00000000

4.2 头码配置有效

  • 将头码的字节序做一下颠倒,变为0x7f80
  • 按键生效的打印情况:
console:/ # getevent                                                           
add device 1: /dev/input/event4
  name:     "soc@2900000:gpio_keys"
add device 2: /dev/input/event3
  name:     "sunxi-ir-uinput"
add device 3: /dev/input/event0
  name:     "sunxi-gpadc0"
add device 4: /dev/input/event1
  name:     "sunxi-ir"
add device 5: /dev/input/event2
  name:     "audiocodec sunxi Audio Jack"


(1)上
/dev/input/event3: 0001 0013 00000001
/dev/input/event1: 0004 0004 017f8005    ###### 数据分解: 01-7f80-05  ,0x05为 UP key
/dev/input/event3: 0000 0000 00000000
/dev/input/event1: 0000 0000 00000000

/dev/input/event3: 0001 0013 00000000
/dev/input/event1: 0004 0004 007f8005
/dev/input/event3: 0000 0000 00000000
/dev/input/event1: 0000 0000 00000000


(2)下
/dev/input/event1: 0004 0004 017f801b     ###### 数据分解: 01-7f80-1b  ,0x1b为 DOWN key
/dev/input/event3: 0001 0014 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event3: 0000 0000 00000000
/dev/input/event3: 0001 0014 00000000
/dev/input/event1: 0000 0000 00000000
/dev/input/event3: 0000 0000 00000000

(3)左
/dev/input/event1: 0004 0004 017f8007
/dev/input/event3: 0001 0015 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event3: 0000 0000 00000000

/dev/input/event1: 0004 0004 007f8007
/dev/input/event1: 0000 0000 00000000
/dev/input/event3: 0001 0015 00000000
/dev/input/event3: 0000 0000 00000000

(4)右
/dev/input/event1: 0004 0004 017f8009
/dev/input/event3: 0001 0016 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event3: 0000 0000 00000000

/dev/input/event1: 0004 0004 007f8009
/dev/input/event3: 0001 0016 00000000
/dev/input/event1: 0000 0000 00000000
/dev/input/event3: 0000 0000 00000000

(5)关机
/dev/input/event1: 0004 0004 017f8012
/dev/input/event3: 0001 0074 00000001
/dev/input/event1: 0000 0000 00000000
/dev/input/event3: 0000 0000 00000000
/dev/input/event1: 0004 0004 007f8012
/dev/input/event3: 0001 0074 00000000
/dev/input/event1: 0000 0000 00000000
/dev/input/event3: 0000 0000 00000000

4.3 dumpsys input

130|console:/ # dumpsys input                                                  
INPUT MANAGER (dumpsys input)

Input Manager State:
  Interactive: true
  System UI Visibility: 0x8008
  Pointer Speed: 0
  Pointer Gestures Enabled: true
  Show Touches: false
  Pointer Capture Enabled: false

Event Hub State:
  BuiltInKeyboardId: -2
  Devices:
    -1: Virtual
      Classes: 0x40000023
      Path: 
      Enabled: true
      Descriptor: a718a782d34bc767f4689c232d64d527998ea7fd
      Location: 
      ControllerNumber: 0
      UniqueId: 
      Identifier: bus=0x0000, vendor=0x0000, product=0x0000, version=0x0000
      KeyLayoutFile: /system/usr/keylayout/Generic.kl
      KeyCharacterMapFile: /system/usr/keychars/Virtual.kcm
      ConfigurationFile: 
      HaveKeyboardLayoutOverlay: false
      VideoDevice: 
    1: sunxi-ir-uinput
      Classes: 0x0000002b
      Path: /dev/input/event3
      Enabled: true
      Descriptor: 0a253e777d1b2169367be63d7c9054e7991953a6
      Location: 
      ControllerNumber: 0
      UniqueId: 
      Identifier: bus=0x0019, vendor=0x0000, product=0x0000, version=0x0004
      KeyLayoutFile: /vendor/usr/keylayout/sunxi-ir-uinput.kl
      KeyCharacterMapFile: /system/usr/keychars/Generic.kcm
      ConfigurationFile: 
      HaveKeyboardLayoutOverlay: false
      VideoDevice: 
    2: sunxi-ir
      Classes: 0x00000001
      Path: /dev/input/event1
      Enabled: true
      Descriptor: 485d69228e24f5e46da1598745890b214130dbc4
      Location: sunxi-ir/input0
      ControllerNumber: 0
      UniqueId: 
      Identifier: bus=0x0019, vendor=0x0001, product=0x0001, version=0x0100
      KeyLayoutFile: /vendor/usr/keylayout/sunxi-ir.kl
      KeyCharacterMapFile: /system/usr/keychars/Generic.kcm
      ConfigurationFile: 
      HaveKeyboardLayoutOverlay: false
      VideoDevice: 
    4: audiocodec sunxi Audio Jack
      Classes: 0x00000081
      Path: /dev/input/event2
      Enabled: true
      Descriptor: d6a59aa863179ab43a39346203ca02f7639be982
      Location: ALSA
      ControllerNumber: 0
      UniqueId: 
      Identifier: bus=0x0000, vendor=0x0000, product=0x0000, version=0x0000
      KeyLayoutFile: /system/usr/keylayout/Generic.kl
      KeyCharacterMapFile: /system/usr/keychars/Generic.kcm
      ConfigurationFile: 
      HaveKeyboardLayoutOverlay: false
      VideoDevice: 
    5: soc@2900000:gpio_keys
      Classes: 0x00000001
      Path: /dev/input/event4
      Enabled: true
      Descriptor: d2c52ff0f656fac4cd7b7a118d575e0109a9fe1c
      Location: gpio-keys/input0
      ControllerNumber: 0
      UniqueId: 
      Identifier: bus=0x0019, vendor=0x0001, product=0x0001, version=0x0100
      KeyLayoutFile: /system/usr/keylayout/Generic.kl
      KeyCharacterMapFile: /system/usr/keychars/Generic.kcm
      ConfigurationFile: 
      HaveKeyboardLayoutOverlay: false
      VideoDevice: 
  Unattached video devices:
    

你可能感兴趣的:(全志H713平台定制开发,android)