amlogic遥控器鼠标按键适配

首先描述一下功能,遥控器上配置预留鼠标键的按键后,功能实现的状态是按一下鼠标键,TV屏幕上类似出现鼠标左键的图标,方向导航上下左右控制移动方向,再次点击鼠标按键,恢复遥控器默认功能.

以下我这边是随便找了一款遥控器,改按键为mouse button按键

kernel 相应的遥控器适配dts下适配遥控器
dts上的代码添加

map_1: map_1{
	mapname = "amlogic-remote-2";
	customcode = <0xf708>;
	release_delay = <80>;
	fn_key_scancode = <0x66>;//给鼠标按键设置一个键值
	//方向键的适配
	cursor_left_scancode = <0x03>;
	cursor_right_scancode = <0x02>;
	cursor_up_scancode = <0x00>;
	cursor_down_scancode = <0x01>;
	cursor_ok_scancode = <0x1f>;
	//方向键的适配
	size  = <17>;
	

	keymap = <REMOTE_KEY(0x00,103)  // DPAD_UP
		REMOTE_KEY(0x01,108)	// DPAD_DOWN
		REMOTE_KEY(0x03,105)	// DPAD_LEFT
		REMOTE_KEY(0x02,106)	// DPAD_RIGHT
		REMOTE_KEY(0x1f,97)     // DPAD_CENTER
		REMOTE_KEY(0x66,580)	// ALL_APPS
		REMOTE_KEY(0x74,582)	// VOICE_ASSIST
		REMOTE_KEY(0x0c,102)	// HOME
		REMOTE_KEY(0x0a,116)	// POWER
		REMOTE_KEY(0x1c,15)     // BACK
		REMOTE_KEY(0xd6,125)    // MENU
		REMOTE_KEY(0x58,104)    // VOLUME_UP
		REMOTE_KEY(0x5d,109)	// VOLUME_DOWN
		REMOTE_KEY(0x0d,113)	// VOLUME_MUTE
		REMOTE_KEY(0x4d,600)	// YOUTUBE
		REMOTE_KEY(0x4e,601)	// NETFLIX
		REMOTE_KEY(0x4f,602)>;	// GOOGLEPLAY

};

amlogic平台提供的适配补丁
补丁二:

diff --git a/drivers/amlogic/input/remote/remote_meson.c b/drivers/amlogic/input/remote/remote_meson.c
index 43a360d..95061d6 100644
--- a/drivers/amlogic/input/remote/remote_meson.c
+++ b/drivers/amlogic/input/remote/remote_meson.c
@@ -125,6 +125,7 @@ static int ir_lookup_by_scancode(struct ir_map_tab *ir_map,
 
while (start <= end) {
    
    
     mid = (start + end) >> 1;
+    pr_info("ir_lookup_by_scancode mid %d  ccode 0x%x  scancode 0x%x \n", mid , ir_map->codemap[mid].map.scancode , scancode );
     if (ir_map->codemap[mid].map.scancode < scancode)
                        start = mid + 1;
                else if (ir_map->codemap[mid].map.scancode > scancode)
@@ -209,6 +210,7 @@ static u32 getkeycode(struct remote_dev *dev, u32 scancode)
        }
 index = ir_lookup_by_scancode(&ct->tab, scancode);
+       dev_err(chip->dev, " getkeycode index %d  scancode 0x%x \n", index , scancode);
        if (index < 0) {
    
    
                dev_err(chip->dev, "scancode %d undefined\n", scancode);
                return KEY_RESERVED;
@@ -450,6 +452,42 @@ static int get_custom_tables(struct device_node *node,
 memset(&ptable->tab.cursor_code, 0xff,sizeof(struct cursor_codemap));

+//merge amlogic patch for mouse button
+if(index == 1){
    
    //配置的遥控器对应的index
+       ret = of_property_read_u32(map, "fn_key_scancode" ,&value);
+       ptable->tab.cursor_code.fn_key_scancode = (__u16)value;
+
+       ret = of_property_read_u32(map, "cursor_left_scancode", &value);
+       ptable->tab.cursor_code.cursor_left_scancode = (__u16)value;
+
+       ret = of_property_read_u32(map, "cursor_right_scancode", &value);
+       ptable->tab.cursor_code.cursor_right_scancode = (__u16)value;

+       ret = of_property_read_u32(map, "cursor_up_scancode", &value);
+       ptable->tab.cursor_code.cursor_up_scancode = (__u16)value;

+
+       ret = of_property_read_u32(map, "cursor_down_scancode", &value);
+       ptable->tab.cursor_code.cursor_down_scancode = (__u16)value;
+       dev_err(chip->dev, " dhflog 666 get_custom_tables cursor_down_scancode 0x%x\n " ,value);
+
+       ret = of_property_read_u32(map, "cursor_ok_scancode", &value);
+       ptable->tab.cursor_code.cursor_ok_scancode = (__u16)value;      

+
+}
+//merge amlogic patch for mouse button
+
ir_scancode_sort(&ptable->tab);
 /*insert list*/
spin_lock_irqsave(&chip->slock, flags);
(END)

猜你喜欢

转载自blog.csdn.net/jeephao/article/details/103465378
今日推荐