Khadas VIM2 Basic为安卓系统匹配红外遥控器

作者: 可乐丸子
上传时间为: 2018-03-05 09:35 AM
2018-03-05
阅读:

Khadas VIM2 Basic刷好安卓固件后可以安装各种影音播放软件,使用鼠标操作体验没有使用红外遥控器好,下面介绍具体实现方法

下载安卓源码后

repo init -u <a href="https://github.com/khadas/android_manifest.git">https://github.com/khadas/android_manifest.git</a> -b Nougat
修改下面文件
PROJECT/common/drivers/amlogic/input/remote/remote_meson.c
下面位置加入debug代码
@@ -147,6 +147,7 @@ static u32 getkeycode(struct remote_dev *dev, u32 scancode)
                pr_err("cur_custom is nulll\n");
                return KEY_RESERVED;
        }
+       printk("%s,scancode=0xx\n",__func__, scancode);
        index = ir_lookup_by_scancode(&ct->tab, scancode);
        if (index < 0) {
                remote_printk(2, "scancode %d undefined\n", scancode);
@@ -163,6 +164,7 @@ static bool is_valid_custom(struct remote_dev *dev)
                return true;
        custom_code = chip->ir_contr[chip->ir_work].get_custom_code(chip);
        chip->cur_tab = seek_map_tab(chip, custom_code);
+       printk("%s,custom_code=0xx\n",__func__, custom_code);
        if (chip->cur_tab) {
                dev->keyup_delay = chip->cur_tab->tab.release_delay;
                return true;
然后使用下面命令编译内核
source device/khadas/kvim/mkern.sh
然后参考官方文档里面的tftp法替换内核

http://docs.khadas.com/develop/SetupTFTPServer/

然后启动安卓系统后使用无线ADB或者串口登陆,输入下面命令

dmesg -c
然后使用红外遥控器(建议NEC协议的红外遥控器)对准开发板一一按键,终端里面会显示红外遥控器的factory code、红外按键的scancode信息,

出厂默认固件包含的factory code为<1> 0xfb04 <2> 0xfe01 <3> 0xbd02 <4> 0xff00,如果你的遥控器为0xfc02,debug信息只会出现一条

is_valid_custom,custom_code=0xfc02
如果你的红外遥控器factory code不在出厂的四种里面还需要修改下面内核源码
PROJECT/common/arch/arm64/boot/dts/amlogic/mesongxm.dtsi
加入下面位置,例如amlogic-remote-5
        custom_maps:custom_maps {
-               mapnum = <4>;
+               mapnum = <5>;
                map0 = <&map_0>;
                map1 = <&map_1>;
                map2 = <&map_2>;
                map3 = <&map_3>;
+               map4 = <&map_4>;
                map_0: map_0{
                        mapname = "amlogic-remote-1";
                        customcode = <0xfb04>;
@@ -852,6 +853,13 @@
                                REMOTE_KEY(0x01,158)
                                REMOTE_KEY(0x48,102)>;
                };
+               map_4: map_4{
+                       mapname = "amlogic-remote-5";
+                       customcode = <0xfc02>;
+                       release_delay = <80>;
+                       size  = <0>;
+                       keymap = <>;
+               }
        };
修改后按上面编译内核然后使用tftp法替换内核,再使用串口或者无线adb登陆后运行dmesg -c,再次使用红外遥控器对准开发板按键会出现两条诊断信息
is_valid_custom,custom_code=0xfc02
getkeycode,scancode=0x0009
如果你的红外遥控器在出厂的四种工厂代码里面,就可以免去上面修改dtsi文件的那一步,直接记下factory code和各个按键的scancode,然后参照下面的安装按键码一一对应
key 399   GRAVE
key 1     BACK
key 2     1
key 3     2
key 4     3
key 5     4
key 6     5
key 7     6
key 8     7
key 9     8
key 10    9
key 11    0
key 15    BACK
key 158   BACK
key 58    SOFT_RIGHT
key 107   ENDCALL
key 62    ENDCALL
key 139    MENU
key 125    MENU
key 60    NOTIFICATION
key 127   SEARCH
key 217   SEARCH
key 228   POUND
key 227   STAR
key 231   CALL
key 61    CALL
key 97    DPAD_CENTER
key 232   DPAD_CENTER
key 108   DPAD_DOWN
key 103   DPAD_UP
key 102   HOME
key 105   DPAD_LEFT
key 106   DPAD_RIGHT
key 115   VOLUME_UP
key 114   VOLUME_DOWN
key 104   VOLUME_UP
key 109   VOLUME_DOWN
key 212   CAMERA

key 16    Q
key 17    W
key 18    E
key 19    R
key 20    T
key 21    Y
key 22    U
key 23    I
key 24    O
key 25    P
key 26    LEFT_BRACKET
key 27    RIGHT_BRACKET
key 43    BACKSLASH

key 30    A
key 31    S
key 32    D
key 33    F
key 34    G
key 35    H
key 36    J
key 37    K
key 38    L
key 39    SEMICOLON
key 40    APOSTROPHE
key 14    DEL

key 44    Z
key 45    X
key 46    C
key 47    V
key 48    B
key 49    N
key 50    M
key 51    COMMA
key 52    PERIOD
key 53    SLASH
key 28    ENTER

key 75		F3
key 76		F4
key 77		F5
key 64		F6
key 65		F7
key 66		F8
key 67		F9
key 68		F10
key 69		F11

key 56    ALT_LEFT
key 100   ALT_RIGHT
key 42    SHIFT_LEFT
key 54    SHIFT_RIGHT
#key 15    TAB
key 57    SPACE
key 70    EXPLORER
key 155   ENVELOPE

key 12    MINUS
key 13    EQUALS
key 215   AT
key 119   MEDIA_PLAY_PAUSE
key 122   MEDIA_PREVIOUS
key 123   MEDIA_NEXT
key 120   MEDIA_FAST_FORWARD
key 121   MEDIA_REWIND
key 116   POWER
#key 116   POWER	WAKE
key 113   VOLUME_MUTE
key 128   MEDIA_STOP
key 130   ZOOM_IN
key 131   ZOOM_OUT
#key 133   NETFLIX
key 140   F10
#key 132   TV_REPEAT
#key 134   TV_SHORTCUTKEY_DISPAYMODE
#key 135   TV_SUBTITLE
#key 136   TV_SHORTCUTKEY_VOICEMODE
#key 137   TV_SWITCH
例如上面的音量+键的scancode是09,对应的安卓功能键应该是115,修改内核源码的
PROJECT/common/arch/arm64/boot/dts/amlogic/mesongxm.dtsi
加入音量+键的scancode和安卓功能键码
@@ -857,8 +857,8 @@
                        mapname = "amlogic-remote-5";
                        customcode = <0xfc02>;
                        release_delay = <80>;
-                       size  = <0>;
-                       keymap = <>;
+                       size  = <1>;
+                       keymap = <REMOTE_KEY(0x09,115)>;
                }
        };
然后编译后替换内核即可使用音量+键控制开发板音量增加了,其他按键同理可以在keymap下面添加,完成后编译内核替换即可使用

笔者的红外遥控器使用效果如下

全部评论 ()
条评论
写评论

创建讨论帖子

登录 后参与评论
系统提示