这个修改是我在全志6.0上增加的 , 当时的需求是 屏幕3分钟灭屏后可以通过触摸TP从而唤醒屏幕。原理是通过TP接收到触摸上报了个power key 灰常简单 思路万古不变 希望能帮到有需要的人。
这个修改主要对 Android 系统的触摸屏和显示驱动进行了优化,包括对触摸屏的睡眠唤醒功能的改进,以及对显示驱动的运行时挂起和恢复的优化。
修改的文件:
android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
lichee/linux-3.10/drivers/input/touchscreen/gt9xx_new/gt9xx.c
lichee/linux-3.10/drivers/input/touchscreen/gt9xx_new/gt9xx_ts.h
lichee/linux-3.10/drivers/video/sunxi/disp2/disp/dev_disp.c
文件修改说明:
defaults.xml
: 修改了默认的屏幕关闭超时时间,从无限制改为180000毫秒。gt9xx.c
: 添加了触摸屏的睡眠唤醒功能,当触摸屏处于睡眠状态时,可以通过触摸屏来唤醒设备。同时,也在驱动的初始化和挂起恢复过程中添加了相关的打印信息。gt9xx_ts.h
: 在头文件中定义了一个宏GTP_WAKEUP_SLEEP_ENABLE
,用于控制触摸屏的睡眠唤醒功能是否启用。dev_disp.c
: 在显示驱动的运行时挂起和恢复过程中,添加了一个全局变量g_sleep_flag_for_tp
,用于标记设备的睡眠状态。当设备处于睡眠状态时,g_sleep_flag_for_tp
被设置为1,当设备恢复运行时,g_sleep_flag_for_tp
被设置为0。这个变量的值可以通过函数get_sleep_state
获取,从而在触摸屏驱动中判断设备是否处于睡眠状态。
--- .../SettingsProvider/res/values/defaults.xml | 2 +- .../drivers/input/touchscreen/gt9xx_new/gt9xx.c | 15 ++++++++++++--- .../input/touchscreen/gt9xx_new/gt9xx_ts.h | 2 +- .../drivers/video/sunxi/disp2/disp/dev_disp.c | 14 +++++++++++--- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml index 98291007a0..d8fece99cd 100755 --- a/android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml +++ b/android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml @@ -18,7 +18,7 @@ --> <resources> <bool name="def_dim_screen">true</bool> - <integer name="def_screen_off_timeout">-1</integer> + <integer name="def_screen_off_timeout">180000</integer> <integer name="def_sleep_timeout">-1</integer> <bool name="def_airplane_mode_on">false</bool> <bool name="def_theater_mode_on">false</bool> diff --git a/lichee/linux-3.10/drivers/input/touchscreen/gt9xx_new/gt9xx.c b/lichee/linux-3.10/drivers/input/touchscreen/gt9xx_new/gt9xx.c index babdd7e72b..96ce48b5e8 100755 --- a/lichee/linux-3.10/drivers/input/touchscreen/gt9xx_new/gt9xx.c +++ b/lichee/linux-3.10/drivers/input/touchscreen/gt9xx_new/gt9xx.c @@ -463,6 +463,7 @@ static void gtp_touch_down(struct goodix_ts_data* ts,s32 id,s32 x,s32 y,s32 w) } +extern int get_sleep_state(void); /******************************************************* Function: Touch up report function. @@ -484,6 +485,12 @@ static void gtp_touch_up(struct goodix_ts_data* ts, s32 id) input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); input_mt_sync(ts->input_dev); #endif +#if GTP_WAKEUP_SLEEP_ENABLE == 1 + if(get_sleep_state()) { + input_report_key(ts->input_dev, KEY_POWER, 1); + input_report_key(ts->input_dev, KEY_POWER, 0); + } +#endif } /******************************************************* @@ -998,7 +1005,9 @@ static s8 gtp_request_input_dev(struct goodix_ts_data *ts) input_set_capability(ts->input_dev,EV_KEY,touch_key_array[index]); } #endif - +#if GTP_WAKEUP_SLEEP_ENABLE == 1 + input_set_capability(ts->input_dev,EV_KEY,KEY_POWER); +#endif //#if GTP_CHANGE_X2Y // GTP_SWAP(ts->abs_x_max, ts->abs_y_max); //#endif @@ -1214,7 +1223,7 @@ static void goodix_ts_early_suspend(struct early_suspend *h) struct goodix_ts_data *ts; s8 ret = -1; ts = container_of(h, struct goodix_ts_data, early_suspend); - + printk(" goodix_ts_early_suspend\n"); #if GTP_ESD_PROTECT ts->gtp_is_suspend = 1; cancel_delayed_work_sync(>p_esd_check_work); @@ -1248,7 +1257,7 @@ static void goodix_ts_late_resume(struct early_suspend *h) { struct goodix_ts_data *ts; ts = container_of(h, struct goodix_ts_data, early_suspend); - + printk(" goodix_ts_late_resume\n"); queue_work(goodix_resume_wq, &goodix_resume_work);//gandy #if GTP_ESD_PROTECT diff --git a/lichee/linux-3.10/drivers/input/touchscreen/gt9xx_new/gt9xx_ts.h b/lichee/linux-3.10/drivers/input/touchscreen/gt9xx_new/gt9xx_ts.h index a766d628b9..fccb141cb4 100755 --- a/lichee/linux-3.10/drivers/input/touchscreen/gt9xx_new/gt9xx_ts.h +++ b/lichee/linux-3.10/drivers/input/touchscreen/gt9xx_new/gt9xx_ts.h @@ -106,7 +106,7 @@ extern struct ctp_config_info config_info; #define GTP_DEBUG_ON 0 #define GTP_DEBUG_ARRAY_ON 0 #define GTP_DEBUG_FUNC_ON 0 - +#define GTP_WAKEUP_SLEEP_ENABLE 1 //***************************PART2:TODO define********************************** //STEP_1(REQUIRED):Change config table. /*TODO: puts the config info corresponded to your TP here, the following is just diff --git a/lichee/linux-3.10/drivers/video/sunxi/disp2/disp/dev_disp.c b/lichee/linux-3.10/drivers/video/sunxi/disp2/disp/dev_disp.c index 2c6fc65b25..b7a95bbf95 100755 --- a/lichee/linux-3.10/drivers/video/sunxi/disp2/disp/dev_disp.c +++ b/lichee/linux-3.10/drivers/video/sunxi/disp2/disp/dev_disp.c @@ -36,6 +36,14 @@ static struct device *display_dev; static unsigned int g_disp = 0, g_enhance_mode = 0, g_cvbs_enhance_mode = 0; static u32 DISP_print = 0xffff; //print cmd which eq DISP_print static bool g_pm_runtime_enable = 0; //when open the CONFIG_PM_RUNTIME,this bool can also control if use the PM_RUNTIME. + +static int g_sleep_flag_for_tp = 0; + +int get_sleep_state(void) +{ + return g_sleep_flag_for_tp; +} +EXPORT_SYMBOL(get_sleep_state); #ifndef CONFIG_OF static struct sunxi_disp_mod disp_mod[] = { {DISP_MOD_DE , "de" }, @@ -1437,7 +1445,7 @@ static int disp_runtime_suspend(struct device *dev) struct list_head* disp_list= NULL; pr_info("%s\n", __func__); - + if (!g_pm_runtime_enable) return 0; @@ -1481,7 +1489,7 @@ static int disp_runtime_resume(struct device *dev) struct list_head* disp_list= NULL; pr_info("%s\n", __func__); - + g_sleep_flag_for_tp = 0; if (!g_pm_runtime_enable) return 0; @@ -1531,7 +1539,7 @@ static int disp_runtime_resume(struct device *dev) static int disp_runtime_idle(struct device *dev) { pr_info("%s\n", __func__); - + g_sleep_flag_for_tp = 1; if (g_disp_drv.dev) { pm_runtime_mark_last_busy(g_disp_drv.dev); pm_request_autosuspend(g_disp_drv.dev); -- 2.25.1