static void timeout(void *arg) { struct ui_st *st = arg; /* Emulate key-release */ report_key(st, 0x00); }
static void mqueue_handler(int id, void *data, void *arg) { struct ui_st *st = arg; (void)data; tmr_start(&st->tmr, RELEASE_VAL, timeout, st); report_key(st, id); }
void timer_handle(unsigned long data) { int osd_key; dbg("bitstimes=%d\n", BlsKey->bitstimes); if (learning_status & WAIT_LEARN_COMPLETE) { lock_data_protect(); osd_key=get_osd_key(); unlock_data_protect(); if (!osd_key ) { disable_irq(IRQ_TINT1_TINT34); TIMER1_TCR &= ~(3<<22); //disable timer1 34 TIMER1_TGCR &= ~(1<<1); //reset timer1 34 report_key(LEARNING_COMPLETE_KEY); //report_key(UP_KEY); } learning_status |= WAIT_RELEASE_REMOTE; learning_status &= ~WAIT_LEARN_COMPLETE; learning_key_timer.function = timer_handle; mod_timer(&learning_key_timer, jiffies + POLL_RELEASE_DELAY); } else if (learning_status & WAIT_RELEASE_REMOTE) { if (learning_status & KEY_WAVE_PRESENT) { learning_status &= ~KEY_WAVE_PRESENT; learning_key_timer.function = timer_handle; mod_timer(&learning_key_timer, jiffies + POLL_RELEASE_DELAY); } else { disable_learning(); lock_data_protect(); osd_key = get_osd_key(); unlock_data_protect(); if (!osd_key ) { report_key(RELEASE_REMOTE_KEY); //report_key(UP_KEY); } } } }
/*interrupt code */ static irqreturn_t button_interrupt(int irq, void* dev_id) { struct button_irq_desc *button_irqs = (struct button_irq_desc*)dev_id; unsigned int gpio_value = 0; int status, retval; disable_irq(IRQ_EINT(0)); disable_irq(IRQ_EINT(1)); disable_irq(IRQ_EINT(2)); disable_irq(IRQ_EINT(3)); spin_lock(&keypad_lock); status = readl(S3C64XX_GPNDAT) & ( 0x1 << button_irqs->number); retval = status ? 0 : 1; if(retval == 1){ save_irq = button_irqs->irq; scan_keypad(); set_keynum(col_value, row_value, retval); report_key(key_num, retval); } else if( (retval == 0) && (button_irqs->irq == save_irq)){ report_key(key_num, retval); } gpio_value = readl(S3C64XX_GPNCON); gpio_value &= ~(0xffffffff); gpio_value |= ( (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | ( 1 << 10) | (1 << 12) | (1 << 18) | (1 << 20) | (1 << 24) ); writel(gpio_value, S3C64XX_GPNCON); spin_unlock(&keypad_lock); enable_irq(IRQ_EINT(0)); enable_irq(IRQ_EINT(1)); enable_irq(IRQ_EINT(2)); enable_irq(IRQ_EINT(3)); return IRQ_RETVAL(IRQ_HANDLED); }
static enum hrtimer_restart gpio_keypad_timer_func(struct hrtimer *timer) { int out=0, in; int key_index; int gpio; struct gpio_kp *kp = container_of(timer, struct gpio_kp, timer); struct gpio_event_matrix_info *mi = kp->keypad_info; unsigned gpio_keypad_flags = mi->flags; unsigned polarity = !!(gpio_keypad_flags & GPIOKPF_ACTIVE_HIGH); kp->last_key_state_changed = kp->key_state_changed; kp->key_state_changed = 0; kp->some_keys_pressed = 0; key_index = 0; for (in = 0; in < mi->ninputs; in++, key_index++) { gpio = mi->input_gpios[in]; if (gpio_get_value(gpio) ^ !polarity) { if (kp->some_keys_pressed < 3) kp->some_keys_pressed++; kp->key_state_changed |= !__test_and_set_bit( key_index, kp->keys_pressed); } else kp->key_state_changed |= __test_and_clear_bit( key_index, kp->keys_pressed); } if (gpio_keypad_flags & GPIOKPF_DEBOUNCE) { if (kp->key_state_changed) { hrtimer_start(&kp->timer, mi->debounce_delay, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } kp->key_state_changed = kp->last_key_state_changed; } if (kp->key_state_changed) { if (gpio_keypad_flags & GPIOKPF_REMOVE_SOME_PHANTOM_KEYS) remove_phantom_keys(kp); key_index = 0; for (in = 0; in < mi->ninputs; in++, key_index++) report_key(kp, key_index, out, in); } if (!kp->use_irq || kp->some_keys_pressed) { hrtimer_start(timer, mi->poll_time, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } /* No keys are pressed, reenable interrupt */ for (in = 0; in < mi->ninputs; in++) enable_irq(gpio_to_irq(mi->input_gpios[in])); wake_unlock(&kp->wake_lock); return HRTIMER_NORESTART; }
static void ui_fd_handler(int flags, void *arg) { struct ui_st *st = arg; char key; (void)flags; if (1 != read(STDIN_FILENO, &key, 1)) { return; } tmr_start(&st->tmr, RELEASE_VAL, timeout, st); report_key(st, key); }
static int capture_key(struct blaster_data_type* blsdat) { static int times = 0; static int old_counter; static int old_int_counter; int counter; int td; if (!(learning_status & WAIT_RELEASE_REMOTE)) { counter = TIMER1_TIM34; if (old_int_counter == timer_int_counter) td = counter - old_counter; else td = MAX_COUNTER - old_counter - INT_CAPTURE_TIME_WASTE + counter ; old_counter = counter; old_int_counter = timer_int_counter; if (learning_status == 0) { times = 0; learning_key_timer.function = timer_handle; mod_timer(&learning_key_timer, jiffies + LEANRING_COMPLETE_DELAY); learning_status |= WAIT_LEARN_COMPLETE; } if (0 == times++) { if ((GPIO01_IN_DATA & GIO_CAP) == 0) blsdat->bitstimes |= FIRST_LEVEL_BIT_MASK; return 0; } blsdat->bits[times-2] = td; blsdat->bitstimes++; if (times == BLASTER_MAX_CHANGE+1) { disable_irq(IRQ_TINT1_TINT34); TIMER1_TCR &= ~(3<<22); //disable timer1 34 TIMER1_TGCR &= ~(1<<1); //reset timer1 34 report_key(LEARNING_COMPLETE_KEY); learning_status |= WAIT_RELEASE_REMOTE; learning_status &= ~WAIT_LEARN_COMPLETE; learning_key_timer.function = timer_handle; mod_timer(&learning_key_timer, jiffies + POLL_RELEASE_DELAY); } } else learning_status |= KEY_WAVE_PRESENT; return(0); }
/* * IRQ handler */ static void cm109_urb_irq_callback(struct urb *urb) { struct cm109_dev *dev = urb->context; const int status = urb->status; int error; dev_dbg(&urb->dev->dev, "### URB IRQ: [0x%02x 0x%02x 0x%02x 0x%02x] keybit=0x%02x\n", dev->irq_data->byte[0], dev->irq_data->byte[1], dev->irq_data->byte[2], dev->irq_data->byte[3], dev->keybit); if (status) { if (status == -ESHUTDOWN) return; err("%s: urb status %d", __func__, status); } /* Special keys */ if (dev->irq_data->byte[HID_IR0] & 0x0f) { const int code = (dev->irq_data->byte[HID_IR0] & 0x0f); report_key(dev, dev->keymap[0xff + code]); } /* Scan key column */ if (dev->keybit == 0xf) { /* Any changes ? */ if ((dev->gpi & 0xf0) == (dev->irq_data->byte[HID_IR1] & 0xf0)) goto out; dev->gpi = dev->irq_data->byte[HID_IR1] & 0xf0; dev->keybit = 0x1; } else { report_key(dev, dev->keymap[dev->irq_data->byte[HID_IR1]]); dev->keybit <<= 1; if (dev->keybit > 0x8) dev->keybit = 0xf; } out: spin_lock(&dev->ctl_submit_lock); dev->irq_urb_pending = 0; if (likely(!dev->shutdown)) { if (dev->buzzer_state) dev->ctl_data->byte[HID_OR0] |= BUZZER_ON; else dev->ctl_data->byte[HID_OR0] &= ~BUZZER_ON; dev->ctl_data->byte[HID_OR1] = dev->keybit; dev->ctl_data->byte[HID_OR2] = dev->keybit; dev->buzzer_pending = 0; dev->ctl_urb_pending = 1; error = usb_submit_urb(dev->urb_ctl, GFP_ATOMIC); if (error) err("%s: usb_submit_urb (urb_ctl) failed %d", __func__, error); } spin_unlock(&dev->ctl_submit_lock); }
static enum hrtimer_restart gpio_keypad_timer_func(struct hrtimer *timer) { int out, in; int key_index; int gpio; struct gpio_kp *kp = container_of(timer, struct gpio_kp, timer); struct gpio_event_matrix_info *mi = kp->keypad_info; unsigned gpio_keypad_flags = mi->flags; #ifdef CONFIG_ZTE_PLATFORM unsigned polarity = !!(gpio_keypad_flags & !GPIOKPF_ACTIVE_HIGH); #else unsigned polarity = !!(gpio_keypad_flags & GPIOKPF_ACTIVE_HIGH); #endif out = kp->current_output; if (out == mi->noutputs) { out = 0; kp->last_key_state_changed = kp->key_state_changed; kp->key_state_changed = 0; kp->some_keys_pressed = 0; } else { key_index = out * mi->ninputs; for (in = 0; in < mi->ninputs; in++, key_index++) { gpio = mi->input_gpios[in]; if (gpio_get_value(gpio) ^ !polarity) { if (kp->some_keys_pressed < 3) kp->some_keys_pressed++; kp->key_state_changed |= !__test_and_set_bit( key_index, kp->keys_pressed); } else kp->key_state_changed |= __test_and_clear_bit( key_index, kp->keys_pressed); } gpio = mi->output_gpios[out]; if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(gpio, !polarity); else gpio_direction_input(gpio); out++; } kp->current_output = out; if (out < mi->noutputs) { gpio = mi->output_gpios[out]; if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(gpio, polarity); else gpio_direction_output(gpio, polarity); hrtimer_start(timer, mi->settle_time, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } if (gpio_keypad_flags & GPIOKPF_DEBOUNCE) { if (kp->key_state_changed) { hrtimer_start(&kp->timer, mi->debounce_delay, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } kp->key_state_changed = kp->last_key_state_changed; } if (kp->key_state_changed) { if (gpio_keypad_flags & GPIOKPF_REMOVE_SOME_PHANTOM_KEYS) remove_phantom_keys(kp); key_index = 0; for (out = 0; out < mi->noutputs; out++) for (in = 0; in < mi->ninputs; in++, key_index++) report_key(kp, key_index, out, in); } if (!kp->use_irq || kp->some_keys_pressed) { hrtimer_start(timer, mi->poll_time, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } /* No keys are pressed, reenable interrupt */ for (out = 0; out < mi->noutputs; out++) { if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(mi->output_gpios[out], polarity); else gpio_direction_output(mi->output_gpios[out], polarity); } for (in = 0; in < mi->ninputs; in++) enable_irq(gpio_to_irq(mi->input_gpios[in])); wake_unlock(&kp->wake_lock); return HRTIMER_NORESTART; }
static enum hrtimer_restart gpio_keypad_timer_func(struct hrtimer *timer) { int out, in; int pout; // multikey int key_index; int gpio; unsigned int irq; struct gpio_kp *kp = container_of(timer, struct gpio_kp, timer); struct gpio_event_matrix_info *mi = kp->keypad_info; unsigned gpio_keypad_flags = mi->flags; unsigned polarity = !!(gpio_keypad_flags & GPIOKPF_ACTIVE_HIGH); out = kp->current_output; if (out == mi->noutputs) { out = 0; kp->last_key_state_changed = kp->key_state_changed; kp->key_state_changed = 0; kp->some_keys_pressed = 0; } else { key_index = out * mi->ninputs; for (in = 0; in < mi->ninputs; in++, key_index++) { gpio = mi->input_gpios[in]; if (gpio_get_value(gpio) ^ !polarity) { if (kp->some_keys_pressed < 3) kp->some_keys_pressed++; kp->key_state_changed |= !__test_and_set_bit( key_index, kp->keys_pressed); } else kp->key_state_changed |= __test_and_clear_bit( key_index, kp->keys_pressed); } gpio = mi->output_gpios[out]; // multikey for( pout = 0; pout < mi->noutputs; pout++ ) { if( out != pout ) gpio_direction_output(mi->output_gpios[pout], !polarity); } if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(gpio, !polarity); else gpio_direction_input(gpio); out++; } kp->current_output = out; if (out < mi->noutputs) { gpio = mi->output_gpios[out]; // multikey for( pout = 0; pout < mi->noutputs; pout++ ) if( out != pout ) gpio_direction_input(mi->output_gpios[pout]); if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(gpio, polarity); else gpio_direction_output(gpio, polarity); hrtimer_start(timer, mi->settle_time, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } if (gpio_keypad_flags & GPIOKPF_DEBOUNCE) { if (kp->key_state_changed) { hrtimer_start(&kp->timer, mi->debounce_delay, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } kp->key_state_changed = kp->last_key_state_changed; } #if defined(CONFIG_MACH_COOPER_BASE_KOR) if(long_key_state == LONG_KEY_CHECK_ACTIVE) { if(key_press_count++ > MAX_KEY_PRESS_COUNT) { gpio_set_value(GPIO_KEY_SCAN, 0); // kbc0 gpio_direction_output(GPIO_KEY_SCAN, 0); #if defined(CONFIG_MACH_JUNO_SKT) || defined(CONFIG_MACH_JUNO_KT) gpio_set_value(GPIO_KEY_SCAN1, 0); // kbc1 gpio_direction_output(GPIO_KEY_SCAN1, 0); #endif if(!gpio_get_value(GPIO_VOLUME_UP) && !gpio_get_value(GPIO_VOLUME_DOWN)) { irq = gpio_to_irq(GPIO_VOLUME_UP); set_irq_type(irq , IRQ_TYPE_LEVEL_HIGH); irq = gpio_to_irq(GPIO_VOLUME_DOWN); set_irq_type(irq , IRQ_TYPE_LEVEL_HIGH); } else if (!gpio_get_value(GPIO_VOLUME_UP)) // volume-up { irq = gpio_to_irq(GPIO_VOLUME_UP); set_irq_type(irq , IRQ_TYPE_LEVEL_HIGH); } else if(!gpio_get_value(GPIO_VOLUME_DOWN)) // volume-down { irq = gpio_to_irq(GPIO_VOLUME_DOWN); set_irq_type(irq , IRQ_TYPE_LEVEL_HIGH); } for (in = 0; in < mi->ninputs; in++) enable_irq(gpio_to_irq(mi->input_gpios[in])); wake_unlock(&kp->wake_lock); key_press_count = 0; long_key_state = LONG_KEY_PRESSED; return HRTIMER_NORESTART; } } #endif if (kp->key_state_changed) { if (gpio_keypad_flags & GPIOKPF_REMOVE_SOME_PHANTOM_KEYS) remove_phantom_keys(kp); key_index = 0; for (out = 0; out < mi->noutputs; out++) for (in = 0; in < mi->ninputs; in++, key_index++) report_key(kp, key_index, out, in); } if (!kp->use_irq || kp->some_keys_pressed) { hrtimer_start(timer, mi->poll_time, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } /* No keys are pressed, reenable interrupt */ for (out = 0; out < mi->noutputs; out++) { if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(mi->output_gpios[out], polarity); else gpio_direction_output(mi->output_gpios[out], polarity); } for (in = 0; in < mi->ninputs; in++) enable_irq(gpio_to_irq(mi->input_gpios[in])); wake_unlock(&kp->wake_lock); return HRTIMER_NORESTART; }
static enum hrtimer_restart gpio_keypad_timer_func(struct hrtimer *timer) { int out, in; int key_index; int gpio; struct gpio_kp *kp = container_of(timer, struct gpio_kp, timer); struct gpio_event_matrix_info *mi = kp->keypad_info; unsigned gpio_keypad_flags = mi->flags; unsigned polarity = !!(gpio_keypad_flags & GPIOKPF_ACTIVE_HIGH); out = kp->current_output; if (out == mi->noutputs) { out = 0; kp->last_key_state_changed = kp->key_state_changed; kp->key_state_changed = 0; kp->some_keys_pressed = 0; } else { key_index = out * mi->ninputs; #if defined (CONFIG_MACH_ROOKIE) || defined(CONFIG_MACH_ESCAPE) || defined(CONFIG_MACH_GIO) for (in = 0; in < mi->ninputs-2; in++, key_index++) { gpio = mi->input_gpios[in]; if (gpio_get_value(gpio) ^ !polarity) { if (kp->some_keys_pressed < 3) kp->some_keys_pressed++; #if defined (CONFIG_MACH_ROOKIE) //MB ysahn 2011.04.17 - Main Key Overlap Handling if(key_index == BACK_KEY_INDEX && test_bit(HOME_KEY_INDEX,kp->keys_pressed)) { kp->key_state_changed |= __test_and_set_bit(HOME_KEY_INDEX, kp->keys_pressed); } else if(key_index == HOME_KEY_INDEX && test_bit(BACK_KEY_INDEX,kp->keys_pressed)) { kp->key_state_changed |= __test_and_set_bit(BACK_KEY_INDEX, kp->keys_pressed); } else #endif //MB ysahn 2011.04.17 - Main Key Overlap Handling { kp->key_state_changed |= !__test_and_set_bit(key_index, kp->keys_pressed); //printk("kp->keys_pressed[0] : %d\n",in,kp->keys_pressed[0]); //printk("key event (key gpio:%d pressed, !polarity : %d)\n", gpio, !polarity); } } else kp->key_state_changed |= __test_and_clear_bit(key_index, kp->keys_pressed); } gpio = mi->output_gpios[out]; if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) { gpio_set_value(gpio, !polarity); } else gpio_direction_input(gpio); if (out == 0) // for volume up/down key { static unsigned int volume_pressed = 0 ; for (in ; in < mi->ninputs; in++, key_index++) { gpio = mi->input_gpios[in]; if (gpio_get_value(gpio) == 0) { /* pressed */ if (volume_pressed == (1 << in) || !volume_pressed) /* only this key */ { if (kp->some_keys_pressed < 3) kp->some_keys_pressed++; kp->key_state_changed |= !__test_and_set_bit(key_index, kp->keys_pressed); volume_pressed |= (1 << in) ; //printk("key event (key gpio:%d, pressed)\n", gpio); } } else { kp->key_state_changed |= __test_and_clear_bit(key_index, kp->keys_pressed); volume_pressed &= ~(1 << in) ; } } } #else for (in = 0; in < mi->ninputs; in++, key_index++) { gpio = mi->input_gpios[in]; if (gpio_get_value(gpio) ^ !polarity) { if (kp->some_keys_pressed < 3) kp->some_keys_pressed++; kp->key_state_changed |= !__test_and_set_bit( key_index, kp->keys_pressed); //printk("key event (key gpio:%d pressed, polarity : %d)\n", gpio, polarity); } else kp->key_state_changed |= __test_and_clear_bit( key_index, kp->keys_pressed); } gpio = mi->output_gpios[out]; if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(gpio, !polarity); else gpio_direction_input(gpio); #endif out++; } kp->current_output = out; if (out < mi->noutputs) { gpio = mi->output_gpios[out]; if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(gpio, polarity); else gpio_direction_output(gpio, polarity); hrtimer_start(timer, mi->settle_time, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } if (gpio_keypad_flags & GPIOKPF_DEBOUNCE) { if (kp->key_state_changed) { hrtimer_start(&kp->timer, mi->debounce_delay, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } kp->key_state_changed = kp->last_key_state_changed; } if (kp->key_state_changed) { if (gpio_keypad_flags & GPIOKPF_REMOVE_SOME_PHANTOM_KEYS) remove_phantom_keys(kp); key_index = 0; for (out = 0; out < mi->noutputs; out++) for (in = 0; in < mi->ninputs; in++, key_index++) { report_key(kp, key_index, out, in); } } if (!kp->use_irq || kp->some_keys_pressed) { hrtimer_start(timer, mi->poll_time, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } /* No keys are pressed, reenable interrupt */ for (out = 0; out < mi->noutputs; out++) { if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(mi->output_gpios[out], polarity); else gpio_direction_output(mi->output_gpios[out], polarity); } for (in = 0; in < mi->ninputs; in++) enable_irq(gpio_to_irq(mi->input_gpios[in])); wake_unlock(&kp->wake_lock); return HRTIMER_NORESTART; }
static enum hrtimer_restart gpio_keypad_timer_func(struct hrtimer *timer) { int out, in; int key_index; int gpio; struct gpio_kp *kp = container_of(timer, struct gpio_kp, timer); struct gpio_event_matrix_info *mi = kp->keypad_info; unsigned gpio_keypad_flags = mi->flags; unsigned polarity = !!(gpio_keypad_flags & GPIOKPF_ACTIVE_HIGH); if (kp->timer_starter == ES209RA_KEYPAD_STARTER_IRQ_HANDLER) { for (out = 0; out < mi->noutputs; out++) gpio_keypad_direction_input(mi->output_gpios[out]); kp->timer_starter = ES209RA_KEYPAD_STARTER_OTHER; } out = kp->current_output; if (out == mi->noutputs) { out = 0; kp->last_key_state_changed = kp->key_state_changed; kp->key_state_changed = 0; kp->some_keys_pressed = 0; } else { key_index = out * mi->ninputs; for (in = 0; in < mi->ninputs; in++, key_index++) { gpio = mi->input_gpios[in]; if (gpio_get_value(gpio) ^ !polarity) { if (kp->some_keys_pressed < 3) kp->some_keys_pressed++; kp->key_state_changed |= !__test_and_set_bit( key_index, kp->keys_pressed); } else kp->key_state_changed |= __test_and_clear_bit( key_index, kp->keys_pressed); } gpio = mi->output_gpios[out]; if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(gpio, !polarity); else gpio_keypad_direction_input(gpio); out++; } kp->current_output = out; if (out < mi->noutputs) { gpio = mi->output_gpios[out]; if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(gpio, polarity); else gpio_keypad_direction_output(gpio, polarity); hrtimer_start(timer, mi->settle_time, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } if (gpio_keypad_flags & GPIOKPF_DEBOUNCE) { if (kp->key_state_changed) { hrtimer_start(&kp->timer, mi->debounce_delay, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } kp->key_state_changed = kp->last_key_state_changed; } if (kp->key_state_changed) { if (gpio_keypad_flags & GPIOKPF_REMOVE_SOME_PHANTOM_KEYS) remove_phantom_keys(kp); key_index = 0; for (out = 0; out < mi->noutputs; out++) for (in = 0; in < mi->ninputs; in++, key_index++) report_key(kp, key_index, out, in); } if (kp->use_irq && kp->some_keys_pressed) { if ((kp->keys_pressed_time / NSEC_PER_SEC) >= ES209RA_KEYPAD_PRESS_TIMEOUT) { /* * Pretend that all keys was released and notify. * This is necessary to suspend. */ key_index = 0; for (out = 0; out < mi->noutputs; out++) { for (in = 0; in < mi->ninputs; in++, key_index++) { __clear_bit(key_index, kp->keys_pressed); report_key(kp, key_index, out, in); } } /* Run timeout process. */ schedule_work(&kp->work); } else { kp->keys_pressed_time = kp->keys_pressed_time + (mi->poll_time.tv.sec * NSEC_PER_SEC) + mi->poll_time.tv.nsec; hrtimer_start(timer, mi->poll_time, HRTIMER_MODE_REL); } return HRTIMER_NORESTART; } if (!kp->use_irq) { hrtimer_start(timer, mi->poll_time, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } /* No keys are pressed, reenable interrupt */ for (out = 0; out < mi->noutputs; out++) { if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(mi->output_gpios[out], polarity); else gpio_keypad_direction_output(mi->output_gpios[out], polarity); } for (in = 0; in < mi->ninputs; in++) enable_irq(gpio_to_irq(mi->input_gpios[in])); wake_unlock(&kp->wake_lock); return HRTIMER_NORESTART; }
static enum hrtimer_restart gpio_keypad_timer_func(struct hrtimer *timer) { int out, in; int key_index; int gpio; struct gpio_kp *kp = container_of(timer, struct gpio_kp, timer); struct gpio_event_matrix_info *mi = kp->keypad_info; unsigned gpio_keypad_flags = mi->flags; unsigned polarity = !!(gpio_keypad_flags & GPIOKPF_ACTIVE_HIGH); #if defined(SLEEP_STATE_SKIP_LONGKEY) unsigned int irq; #endif out = kp->current_output; if (out == mi->noutputs) { out = 0; kp->last_key_state_changed = kp->key_state_changed; kp->key_state_changed = 0; kp->some_keys_pressed = 0; } else { key_index = out * mi->ninputs; for (in = 0; in < mi->ninputs; in++, key_index++) { gpio = mi->input_gpios[in]; if (gpio_get_value(gpio) ^ !polarity) { if (kp->some_keys_pressed < 3) kp->some_keys_pressed++; kp->key_state_changed |= !__test_and_set_bit( key_index, kp->keys_pressed); } else kp->key_state_changed |= __test_and_clear_bit( key_index, kp->keys_pressed); } gpio = mi->output_gpios[out]; if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(gpio, !polarity); else gpio_direction_input(gpio); out++; } kp->current_output = out; if (out < mi->noutputs) { gpio = mi->output_gpios[out]; if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(gpio, polarity); else gpio_direction_output(gpio, polarity); hrtimer_start(timer, mi->settle_time, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } if (gpio_keypad_flags & GPIOKPF_DEBOUNCE) { if (kp->key_state_changed) { hrtimer_start(&kp->timer, mi->debounce_delay, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } kp->key_state_changed = kp->last_key_state_changed; } #if defined(SLEEP_STATE_SKIP_LONGKEY) if(long_key_state == LONG_KEY_CHECK_ACTIVE) { //printk("key event (key_press_count:%d, current_pressed_key:%d)\n", key_press_count, current_pressed_key); // GOPEACE iskim ED25 -- remove log for google security approval if(key_press_count++ > MAX_KEY_PRESS_COUNT) { key_press_count = 0; if(lcd_wake_flag==0) // LCD off { gpio_set_value(33, 0); // keyscan_0 gpio_direction_output(33, 0); gpio_set_value(34, 0); // keyscan_1 gpio_direction_output(34, 0); //gpio_set_value(35, 0); // keyscan_2 //gpio_direction_output(35, 0); if(current_pressed_key == KEY_VOLUMEDOWN) { printk("******** volume down long key **********\n"); irq = gpio_to_irq(42); // keysense_0 set_irq_type(irq , IRQ_TYPE_LEVEL_HIGH); } if(current_pressed_key == KEY_VOLUMEUP) { printk("******** volume up long key **********\n"); irq = gpio_to_irq(41); // keysense_1 set_irq_type(irq , IRQ_TYPE_LEVEL_HIGH); } if(current_pressed_key == KEY_END/* || current_pressed_key == KEY_HOME*/) { printk("******** power long key **********\n"); irq = gpio_to_irq(40); // keysense_2 set_irq_type(irq , IRQ_TYPE_LEVEL_HIGH); } for (in = 0; in < mi->ninputs; in++) enable_irq(gpio_to_irq(mi->input_gpios[in])); wake_unlock(&kp->wake_lock); long_key_state = LONG_KEY_PRESSED; return HRTIMER_NORESTART; } } } #endif if (kp->key_state_changed) { if (gpio_keypad_flags & GPIOKPF_REMOVE_SOME_PHANTOM_KEYS) remove_phantom_keys(kp); key_index = 0; for (out = 0; out < mi->noutputs; out++) for (in = 0; in < mi->ninputs; in++, key_index++) report_key(kp, key_index, out, in); } if (!kp->use_irq || kp->some_keys_pressed) { hrtimer_start(timer, mi->poll_time, HRTIMER_MODE_REL); return HRTIMER_NORESTART; } /* No keys are pressed, reenable interrupt */ for (out = 0; out < mi->noutputs; out++) { if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE) gpio_set_value(mi->output_gpios[out], polarity); else gpio_direction_output(mi->output_gpios[out], polarity); } for (in = 0; in < mi->ninputs; in++) enable_irq(gpio_to_irq(mi->input_gpios[in])); wake_unlock(&kp->wake_lock); return HRTIMER_NORESTART; }