#include <mach/key.h>
#include <mach/gpio.h>
+#include <mach/board.h>
#define EV_ENCALL KEY_F4
#define EV_MENU KEY_F1
.code = KEY_POWER,
.gpio = RK29_PIN6_PA7,
.active_low = PRESS_LEV_LOW,
+ //.code_long_press = EV_ENCALL,
.wakeup = 1,
},
#if 0
.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,
},
{
.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,
},
{
.code = KEY_BACK,
.code_long_press = EV_ENCALL,
.adc_value = 899,
+ .gpio = INVALID_GPIO,
.active_low = PRESS_LEV_LOW,
},
#endif
#include <asm/gpio.h>
#include <mach/key.h>
+#include <mach/board.h>
+
#define EMPTY_ADVALUE 950
#define DRIFT_ADVALUE 70
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;
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);
}
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);
}
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);
}
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,"