Exemplo n.º 1
0
static void twl6040_hs_hook_detect_work(struct work_struct *work)
{
	struct twl6040_data *priv;
	struct snd_soc_codec *codec;
	struct twl6040_jack_data *jack;
	struct input_dev *ip_dev;

	priv = container_of(work, struct twl6040_data, hook_work.work);
	codec = priv->codec;
	jack = &priv->hs_jack;
	ip_dev = jack->headset_input;

	if (jack->jack)
	{
		if(jack->longkey_cnt == 0){
			input_report_key(ip_dev, KEY_HOOK, 1);
			input_sync(ip_dev);
		}
		if(is_without_mic()){
			if(jack->longkey_cnt < 6000){//10 min.
				schedule_delayed_work(&priv->hook_work, msecs_to_jiffies(100));
				jack->longkey_cnt++;
			}
			else{//long key event
				input_report_key(ip_dev, KEY_HOOK, 0);
				input_sync(ip_dev);
				jack->longkey_cnt = 0;
				if(get_test_mode() == 1)
				{
					write_gkpd_value(KEY_HOOK);
				}
			}
		}
		else{//short key event
			input_report_key(ip_dev, KEY_HOOK, 0);
			input_sync(ip_dev);
			jack->longkey_cnt = 0;

			if(get_test_mode() == 1)
			{
				write_gkpd_value(KEY_HOOK);
			}
		}
	}
}
static void hook_det_work(struct work_struct *work)
{
	//printk("[JIWON] hook_det_work start\n");

#if 0/*  20110121 : no hook event skip */
	if(headset_sw_data->is_suspend == 1 && get_twl4030_status() == 0)
	{
		printk("[LUCKYJUN77] suspend status \n");	
		return;
	}
#endif
	
    if(headset_type == HUB_HEADPHONE)	//detect type error case
    {
    	//printk("[JIWON] hook_det_work : headphone -> headset\n");
//		schedule_delayed_work(&headset_sw_data->delayed_work,	msecs_to_jiffies(type_detection_tim*3));
		headset_type = HUB_HEADSET;
		switch_set_state(&headset_sw_data->sdev, headset_type);
    }


    if(headset_type != HUB_HEADSET)
		return;

	if(hook_status == HOOK_RELEASED){
			//printk("[JIWON] threshold area for hook key glitch1\n");		
		if(gpio_get_value(headset_sw_data->hook_gpio) == 0){ 	//threshold area for hook key glitch
			//printk("[JIWON] threshold area for hook key glitch2\n");		
		    hook_status = HOOK_PRESSED; 
//		    input_report_key(headset_sw_data->ip_dev, KEY_HOOK, 1);
			schedule_delayed_work(&headset_sw_data->hook_delayed_work,	msecs_to_jiffies(10 /*type_detection_tim/8*/)); /* 20110215  for EarJack & Hook Action */
		}
	}
	else{
		if(gpio_get_value(headset_sw_data->hook_gpio) == 0){ 
			printk("[JIWON] HOOK_PRESSED\n");
		    input_report_key(headset_sw_data->ip_dev, KEY_HOOK, 1);		    
			input_sync(headset_sw_data->ip_dev);		    
			schedule_delayed_work(&headset_sw_data->hook_delayed_work,	msecs_to_jiffies(hook_detection_tim)); /* 20110215  for EarJack & Hook Action */			
		}
		else {
			    input_report_key(headset_sw_data->ip_dev, KEY_HOOK, 0);	
				input_sync(headset_sw_data->ip_dev);
				printk("[JIWON] HOOK_RELEASED\n");				
			    hook_status = HOOK_RELEASED;	
// 20100831  for TEST MODE [START_LGE]
#if 0 //rajesh
			if(get_test_mode())
			{
				write_gkpd_value(KEY_HOOK);
			}
#endif
// 20100831  for TEST MODE [END_LGE]				
		}
	}
}
/*
 * tuple format: (key_code, key_param)
 *
 * old-architecture:
 * key-press = (key_code, 0)
 * key-release = (0xff, key_code)
 *
 * new-architecutre:
 * key-press = (key_code, 0)
 * key-release = (key_code, 0xff)
 */
static void report_hs_key(uint32_t key_code, uint32_t key_parm)
{
	int key, temp_key_code;

	printk(KERN_INFO "%In report_hs_key, key_code:%d, key_parm:%d \n", key_code, key_parm);
	if (key_code == HS_REL_K)
		key = hs_find_key(key_parm);
	else
		key = hs_find_key(key_code);

	temp_key_code = key_code;

	if (key_parm == HS_REL_K)
		key_code = key_parm;

	switch (key) {
	case KEY_POWER:
	case KEY_MEDIA:
		input_report_key(hs->ipdev, key, (key_code != HS_REL_K));
		break;
	case KEY_END:
		if ((key_code != HS_REL_K)) {
			disable_irq(102);
			write_gkpd_value(80);
		} else {
			enable_irq(102);
		}

		if ((ts_key_event == 1 || keypad_event == 1) && (key_code != HS_REL_K)) {
			printk(KERN_INFO "gpio keypad is just enabled\n");
		} else {
			input_report_key(hs->ipdev, key, (key_code != HS_REL_K));
		}
		break;
	case SW_HEADPHONE_INSERT:
		//report_headset_switch(hs->ipdev, key, (key_code != HS_REL_K));
		break;
	case KEY_HP:
		if(gpio_get_value(GPIO_EAR_SENSE_BIAS) == 1)
		{
			if (!hs->ipdev) {
				printk(KERN_ERR "%s: No input device for reporting "
						"pwr/end key press\n", __func__);
				return;
			}
			printk(KERN_INFO "HOOK OK!!!!!!\n");
			//write_gkpd_value(72);
//			input_report_key(hs->ipdev, key, 0);//(key_code != HS_REL_K));

			if ((key_code != HS_REL_K))
				write_gkpd_value(72);

			input_report_key(hs->ipdev, key, (key_code != HS_REL_K));
			//input_sync(hs->ipdev);
		}
		break;
	case -1:
		printk(KERN_ERR "%s: No mapping for remote handset event %d\n",
				 __func__, temp_key_code);
		return;
	}
	input_sync(hs->ipdev);
}
Exemplo n.º 4
0
static void omap_kp_tasklet(unsigned long data)
{
	struct omap_kp *omap_kp_data = (struct omap_kp *) data;
	unsigned char new_state[8], changed, key_down = 0;
	long irq = omap_kp_data->irq;
	int col, row;
	int spurious = 0;

	/* check for any changes */
	omap_kp_scan_keypad(omap_kp_data, new_state);

	/* check for changes and print those */
	for (col = 0; col < omap_kp_data->cols; col++) {
		changed = new_state[col] ^ keypad_state[col];
		key_down |= new_state[col];
		if (changed == 0)
			continue;

		for (row = 0; row < omap_kp_data->rows; row++) {
			int key;
			if (!(changed & (1 << row)))
				continue;
#ifdef NEW_BOARD_LEARNING_MODE
			printk(KERN_INFO "[omap_kp:]omap-keypad: key %d-%d %s\n", col,
			       row, (new_state[col] & (1 << row)) ?
			       "pressed" : "released");
#else
			/* Keymappings have changed in omap4.*/
			if (cpu_is_omap44xx())
				key = omap_kp_find_key(row, col);
			else
				key = omap_kp_find_key(col, row);

			if (key < 0) {
				printk(KERN_WARNING
				      "omap-keypad: Spurious key event %d-%d\n",
				       col, row);
				/* We scan again after a couple of seconds */
				spurious = 1;
				continue;
			}

			if (!(kp_cur_group == (key & GROUP_MASK) ||
			      kp_cur_group == -1))
				continue;

			kp_cur_group = key & GROUP_MASK;
			input_report_key(omap_kp_data->input,
				key & ~GROUP_MASK, new_state[col]
					 & (1 << row));
			input_sync(omap_kp_data->input);
			#ifdef FACTORY_AT_COMMAND_GKPD
			
			if(test_mode == 1 && ((new_state[col] & (1 << row)) == 0))
			{
				test_code = key & ~GROUP_MASK;
				write_gkpd_value(test_code);
			}			
			#endif
#endif
		}
	}
	memcpy(keypad_state, new_state, sizeof(keypad_state));

	if (key_down) {
                int delay = HZ / 20;
		/* some key is pressed - keep irq disabled and use timer
		 * to poll the keypad */
		if (spurious)
			delay = 2 * HZ;
		mod_timer(&omap_kp_data->timer, jiffies + delay);
	} else {
		/* enable interrupts */
		if (cpu_is_omap24xx()) {
			int i;
			for (i = 0; i < omap_kp_data->rows; i++)
				enable_irq(gpio_to_irq(row_gpios[i]));
		} else if (cpu_is_omap44xx()) {
				omap_writel(OMAP4_KBD_IRQENABLE_EVENTEN |
					OMAP4_KBD_IRQENABLE_LONGKEY,
					OMAP4_KBDOCP_BASE +
					OMAP4_KBD_IRQENABLE);
				kp_cur_group = -1;
		} else {
			omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
			kp_cur_group = -1;
		}
	}
	enable_irq(irq);
	/* now clear any pending interrupts */
	omap_writel(omap_readl(OMAP4_KBDOCP_BASE + OMAP4_KBD_IRQSTATUS),
				OMAP4_KBDOCP_BASE + OMAP4_KBD_IRQSTATUS);
}
Exemplo n.º 5
0
static void hook_det_work(struct work_struct *work)
{
	//DBG("[JIWON] hook_det_work start\n");

#if 0/* [email protected] 20110121 : no hook event skip */
	if(headset_sw_data->is_suspend == 1 && get_twl4030_status() == 0)
	{
		DBG("[LUCKYJUN77] suspend status \n");	
		return;
	}
#endif
	
    if(headset_type == HUB_HEADPHONE)	//detect type error case
    {
    	DBG("[JIWON] hook_det_work : headphone -> headset\n");
//		schedule_delayed_work(&headset_sw_data->delayed_work,	msecs_to_jiffies(type_detection_tim*3));
		headset_type = HUB_HEADSET;
		switch_set_state(&headset_sw_data->sdev, headset_type);
    }


    if(headset_type != HUB_HEADSET)
		return;

	if(hook_status == HOOK_RELEASED){
		if(gpio_get_value(headset_sw_data->hook_gpio) == 0){ 	//threshold area for hook key glitch
			//DBG("[JIWON] threshold area for hook key glitch2\n");		
		    hook_status = HOOK_PRESSED; 
//		    input_report_key(headset_sw_data->ip_dev, KEY_HOOK, 1);
#if defined(CONFIG_PRODUCT_LGE_LU6800) || defined(CONFIG_PRODUCT_LGE_KU5900)||defined(CONFIG_PRODUCT_LGE_P970) //20110404 [email protected] B HW Request.roll back the delay time.
			schedule_delayed_work(&headset_sw_data->hook_delayed_work,	msecs_to_jiffies(10 /*type_detection_tim/8*/)); //20110401 [email protected]  Not   B-prj case
#elif defined(CONFIG_PRODUCT_LGE_HUB)
			schedule_delayed_work(&headset_sw_data->hook_delayed_work,	msecs_to_jiffies(type_detection_tim/8)); 
#endif
		}
	}
	else{
		if(gpio_get_value(headset_sw_data->hook_gpio) == 0){ 
			DBG("[JIWON] HOOK_PRESSED\n");
		    input_report_key(headset_sw_data->ip_dev, KEY_HOOK, 1);		    
			input_sync(headset_sw_data->ip_dev);		    
#if defined(CONFIG_PRODUCT_LGE_LU6800) || defined(CONFIG_PRODUCT_LGE_KU5900)||defined(CONFIG_PRODUCT_LGE_P970)			
			schedule_delayed_work(&headset_sw_data->hook_delayed_work,	msecs_to_jiffies(hook_detection_tim)); /* 20110215 [email protected] for EarJack & Hook Action */			
#elif defined(CONFIG_PRODUCT_LGE_HUB)
			schedule_delayed_work(&headset_sw_data->hook_delayed_work,	msecs_to_jiffies(type_detection_tim));
#endif
		}
		else {
			    input_report_key(headset_sw_data->ip_dev, KEY_HOOK, 0);	
				input_sync(headset_sw_data->ip_dev);
				DBG("[JIWON] HOOK_RELEASED\n");				
			    hook_status = HOOK_RELEASED;	
// 20100831 [email protected] for TEST MODE [START_LGE]
			if(get_test_mode())
			{
				write_gkpd_value(KEY_HOOK);
			}
// 20100831 [email protected] for TEST MODE [END_LGE]				
		}
	}
}