加入一个工作队列(patch)

mac2024-04-13  30

diff --git a/drivers/input/keyboard/aw9523.c b/drivers/input/keyboard/aw9523.c index ea2daa7…244ce12 100644 — a/drivers/input/keyboard/aw9523.c +++ b/drivers/input/keyboard/aw9523.c @@ -33,6 +33,8 @@ #include <linux/pinctrl/consumer.h> #include <linux/regulator/consumer.h> #include <linux/hrtimer.h> +#include <linux/jiffies.h> +#include <linux/timer.h> #include <linux/input/aw9523_cfg.h > @@ -170,7 +172,14 @@ static unsigned char keyst_def[KEYST_MAX][P1_NUM_MAX]; struct aw9523_kpad_platform_data g_aw9523_data; //EXPORT_SYMBOL_GPL(aw9523_led_store); +u32 bl_level_bakup = 0; +bool btn_leds_timer_onoff =false; +struct timer_list btn_leds_ms_timer; +static struct work_struct leds_work; +void aw9523_buttonleds_set(enum led_brightness value); +void aw9523_buttonleds_set_timer_on(void); +void btn_leds_ms_timer_func_handler(unsigned long data); +/****************************************************************

after 5s no button is pressed,and the button light is off ***************************************************************/

/* void aw9523_buttonleds_set_timer_on(void)

{

if(btn_leds_timer_onoff == true) { printk("---hyl---timer[%s][%d]--33333-start to restart timer\n",__func__,__LINE__); mod_timer(&btn_leds_ms_timer,jiffies+msecs_to_jiffies(1000*5)); } else { printk("---hyl---timer[%s][%d]--------22222----------start timer\n",__func__,__LINE__); aw9523_buttonleds_set(bl_level_bakup); btn_leds_ms_timer.expires = jiffies + msecs_to_jiffies(1000*5); btn_leds_ms_timer.function = btn_leds_ms_timer_func_handler; add_timer(&btn_leds_ms_timer); } btn_leds_timer_onoff = true;

} */ static void aw9523_key_work(struct work_struct *work) { struct aw9523_kpad_platform_data *pdata; @@ -358,13 +391,15 @@ static void aw9523_key_work(struct work_struct *work) unsigned char val; int keymap_len;

pdata = g_aw9523_data; client = pdata->client;

keymap = pdata->keymap; keymap_len = pdata->keymap_len;

//aw9523_buttonleds_set_timer_on(); if (P1_KCOL_MASK & (1<<i)) { @@ -436,7 +471,7 @@ static void aw9523_key_work(struct work_struct *work) } hrtimer_start(&pdata->key_timer, ktime_set(0,(1000/HRTIMER_FRAME)*1000000), HRTIMER_MODE_REL); }

static enum hrtimer_restart aw9523_key_timer_func(struct hrtimer *timer) @@ -448,6 +483,20 @@ static enum hrtimer_restart aw9523_key_timer_func(struct hrtimer *timer) return HRTIMER_NORESTART; }

+/*static void leds_work_handler(struct work_struct *data) +{

printk("---hyl---timer[%s][%d]--55555--timer end,start turn off leds\n",__func__,__LINE__); aw9523_buttonleds_set(0); // close button leds btn_leds_timer_onoff = false;// 清除定时器开关标志位 +}*/ 定义定时器处理函数 , 定时器时间到后只负表 让CPU调度leds_work_handler() +void btn_leds_ms_timer_func_handler(unsigned long data) +{ printk("---hyl---timer[%s][%d]--44444--timer end,start turn off leds\n",__func__,__LINE__); schedule_work(&leds_work);// 让CPU 调度工作队列, cpu 会创建线程执行leds_work_handler()这个函数+}

static int aw9523_probe(struct i2c_client client, const struct i2c_device_id id) { INIT_WORK(&pdata->key_work, aw9523_key_work); hrtimer_init(&pdata->key_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); pdata->key_timer.function = aw9523_key_timer_func; + /init_timer(&btn_leds_ms_timer); + btn_leds_ms_timer.expires = jiffies + msecs_to_jiffies(10005); + btn_leds_ms_timer.function = btn_leds_ms_timer_func_handler; + printk("—hyl—timer[%s][%d]----------11111-------add timer success\n",func,LINE); // 这个代码,在初始化定时器后面增加 + INIT_WORK(&leds_work,leds_work_handler);///初始化工作队列,绑定 leds_work_handler() 这个函数 / hrtimer end */ i2c_set_clientdata(client, pdata); @@ -854,6 +908,7 @@ static int aw9523_remove(struct i2c_client *client) cancel_work_sync(&pdata->key_work); input_unregister_device(pdata->input); kfree(pdata); + del_timer(&btn_leds_ms_timer); return 0; } /drivers/video/msm/mdss/mdss_dsi_panel.c +extern u32 bl_level_bakup; +extern void aw9523_buttonleds_set_timer_on(void); static void mdss_dsi_panel_bl_ctrl(struct mdss_panel_data *pdata, u32 bl_level) @@ -798,7 +800,8 @@ static void mdss_dsi_panel_bl_ctrl(struct mdss_panel_data *pdata, bl_level = pdata->panel_info.bl_min; aw9523_buttonleds_set(bl_level); //set button leds + //bl_level_bakup = bl_level; + //aw9523_buttonleds_set_timer_on(); switch (ctrl_pdata->bklt_ctrl) { case BL_WLED: aw9523_backlight_set(bl_level); /include/linux/input/aw9523_cfg.h @@ -41,6 +41,8 @@ struct aw9523_kpad_platform_data { s32 irq_is_disabled; spinlock_t irq_lock; struct hrtimer key_timer; + //struct hrtimer key_timer_btn_leds; + //struct timer_list btn_leds_ms_timer; struct work_struct key_work; };

最新回复(0)