Ejemplo n.º 1
0
static void update_work_func(struct work_struct *work)
{
	struct kp *kp_data = container_of(work, struct kp, work_update);

	kp_work(kp_data);
}
void kp_timer_sr(unsigned long data)
{
    struct kp *kp_data=(struct kp *)data;

#if 1
    kp_work(kp_data);

    if (kp_data->led_control ){
	if (timer_count>0)
	{
		timer_count++;
	}
	if (50 == timer_count){
		kp_data->led_control_param[0] = 0;
		timer_count = kp_data->led_control(kp_data->led_control_param);
	}
    }
#else
    unsigned int result;
    result = get_adc_sample();
    if (result>=0x3e0){
        if (kp_data->cur_keycode != 0){
            input_report_key(kp_data->input,kp_data->cur_keycode, 0);	
            kp_data->cur_keycode = 0;
		        printk("adc ch4 sample = %x, keypad released.\n", result);
        }
    }
	else if (result>=0x0 && result<0x60 ) {
		if (kp_data->cur_keycode!=KEY_HOME){
    	  kp_data->cur_keycode = KEY_HOME;
    	  input_report_key(kp_data->input,kp_data->cur_keycode, 1);	
    	  printk("adc ch4 sample = %x, keypad pressed.\n", result);
		}
    }
	else if (result>=0x110 && result<0x170 ) {
		if (kp_data->cur_keycode!=KEY_ENTER){
    	  kp_data->cur_keycode = KEY_ENTER;
    	  input_report_key(kp_data->input,kp_data->cur_keycode, 1);	
    	  printk("adc ch4 sample = %x, keypad pressed.\n", result);
		}
    }
	else if (result>=0x240 && result<0x290 ) {
		if (kp_data->cur_keycode!= KEY_LEFTMETA ){
    	  kp_data->cur_keycode = KEY_LEFTMETA;
    	  input_report_key(kp_data->input,kp_data->cur_keycode, 1);	
    	  printk("adc ch4 sample = %x, keypad pressed.\n", result);
		}
    }
	else if (result>=0x290 && result<0x380 ) {
		if (kp_data->cur_keycode!= KEY_TAB ){
    	  kp_data->cur_keycode = KEY_TAB;
    	  input_report_key(kp_data->input,kp_data->cur_keycode, 1);	
    	  printk("adc ch4 sample = %x, keypad pressed.\n", result);
    }
    }
    else{
		printk("adc ch4 sample = unknown key %x, pressed.\n", result);
    }
#endif
    mod_timer(&kp_data->timer,jiffies+msecs_to_jiffies(25));
}