From: kfx Date: Mon, 28 Mar 2011 06:48:57 +0000 (+0800) Subject: update keys driver: adc key's gpio_value = INVALID_GPIO X-Git-Tag: firefly_0821_release~10617 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=37c10cfe0c3b3c93196a3ab68a09f9c8aef06a88;p=firefly-linux-kernel-4.4.55.git update keys driver: adc key's gpio_value = INVALID_GPIO --- diff --git a/arch/arm/mach-rk29/board-rk29sdk-key.c b/arch/arm/mach-rk29/board-rk29sdk-key.c index 59d7f762c291..aa92c486f5b0 100755 --- a/arch/arm/mach-rk29/board-rk29sdk-key.c +++ b/arch/arm/mach-rk29/board-rk29sdk-key.c @@ -1,5 +1,6 @@ #include #include +#include #define EV_ENCALL KEY_F4 #define EV_MENU KEY_F1 @@ -55,6 +56,7 @@ static struct rk29_keys_button key_button[] = { .code = KEY_POWER, .gpio = RK29_PIN6_PA7, .active_low = PRESS_LEV_LOW, + //.code_long_press = EV_ENCALL, .wakeup = 1, }, #if 0 @@ -62,18 +64,21 @@ static struct rk29_keys_button key_button[] = { .desc = "vol+", .code = KEY_VOLUMEDOWN, .adc_value = 95, + .gpio = INVALID_GPIO, .active_low = PRESS_LEV_LOW, }, { .desc = "vol-", .code = KEY_VOLUMEUP, .adc_value = 249, + .gpio = INVALID_GPIO, .active_low = PRESS_LEV_LOW, }, { .desc = "menu", .code = EV_MENU, .adc_value = 406, + .gpio = INVALID_GPIO, .active_low = PRESS_LEV_LOW, }, { @@ -81,12 +86,14 @@ static struct rk29_keys_button key_button[] = { .code = KEY_HOME, .code_long_press = KEY_F4, .adc_value = 561, + .gpio = INVALID_GPIO, .active_low = PRESS_LEV_LOW, }, { .desc = "esc", .code = KEY_ESC, .adc_value = 726, + .gpio = INVALID_GPIO, .active_low = PRESS_LEV_LOW, }, { @@ -94,6 +101,7 @@ static struct rk29_keys_button key_button[] = { .code = KEY_BACK, .code_long_press = EV_ENCALL, .adc_value = 899, + .gpio = INVALID_GPIO, .active_low = PRESS_LEV_LOW, }, #endif diff --git a/drivers/input/keyboard/rk29_keys.c b/drivers/input/keyboard/rk29_keys.c index 09d230792c82..bf4dd4bb4996 100755 --- a/drivers/input/keyboard/rk29_keys.c +++ b/drivers/input/keyboard/rk29_keys.c @@ -25,6 +25,8 @@ #include #include +#include + #define EMPTY_ADVALUE 950 #define DRIFT_ADVALUE 70 @@ -62,7 +64,7 @@ static void keys_long_press_timer(unsigned long _data) struct rk29_keys_button *button = bdata->button; struct input_dev *input = bdata->input; unsigned int type = EV_KEY; - if(button->gpio) + if(button->gpio != INVALID_GPIO ) state = !!((gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low); else state = !!button->adc_state; @@ -70,13 +72,13 @@ static void keys_long_press_timer(unsigned long _data) if(bdata->long_press_count != 0) { if(bdata->long_press_count % (LONG_PRESS_COUNT+ONE_SEC_COUNT) == 0){ key_dbg(bdata, "%skey[%s]: report ev[%d] state[0]\n", - (!button->gpio)?"ad":"io", button->desc, button->code_long_press); + (button->gpio == INVALID_GPIO)?"ad":"io", button->desc, button->code_long_press); input_event(input, type, button->code_long_press, 0); input_sync(input); } else if(bdata->long_press_count%LONG_PRESS_COUNT == 0) { key_dbg(bdata, "%skey[%s]: report ev[%d] state[1]\n", - (!button->gpio)?"ad":"io", button->desc, button->code_long_press); + (button->gpio == INVALID_GPIO)?"ad":"io", button->desc, button->code_long_press); input_event(input, type, button->code_long_press, 1); input_sync(input); } @@ -89,16 +91,15 @@ static void keys_long_press_timer(unsigned long _data) if(bdata->long_press_count <= LONG_PRESS_COUNT) { bdata->long_press_count = 0; key_dbg(bdata, "%skey[%s]: report ev[%d] state[1], report ev[%d] state[0]\n", - (!button->gpio)?"ad":"io", button->desc, button->code, button->code); + (button->gpio == INVALID_GPIO)?"ad":"io", button->desc, button->code, button->code); input_event(input, type, button->code, 1); input_sync(input); input_event(input, type, button->code, 0); input_sync(input); } - else { - if(bdata->state != state) + else if(bdata->state != state) { key_dbg(bdata, "%skey[%s]: report ev[%d] state[0]\n", - (!button->gpio)?"ad":"io", button->desc, button->code_long_press); + (button->gpio == INVALID_GPIO)?"ad":"io", button->desc, button->code_long_press); input_event(input, type, button->code_long_press, 0); input_sync(input); } @@ -113,14 +114,14 @@ static void keys_timer(unsigned long _data) struct input_dev *input = bdata->input; unsigned int type = EV_KEY; - if(button->gpio) + if(button->gpio != INVALID_GPIO) state = !!((gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low); else state = !!button->adc_state; if(bdata->state != state) { bdata->state = state; key_dbg(bdata, "%skey[%s]: report ev[%d] state[%d]\n", - (!button->gpio)?"ad":"io", button->desc, button->code, bdata->state); + (button->gpio == INVALID_GPIO)?"ad":"io", button->desc, button->code, bdata->state); input_event(input, type, button->code, bdata->state); input_sync(input); } @@ -237,7 +238,7 @@ static int __devinit keys_probe(struct platform_device *pdev) else if(button->code) setup_timer(&bdata->timer, keys_timer, (unsigned long)bdata); - if(button->gpio) { + if(button->gpio != INVALID_GPIO) { error = gpio_request(button->gpio, button->desc ?: "keys"); if (error < 0) { pr_err("gpio-keys: failed to request GPIO %d,"