Exemple #1
0
static void remove_headset(struct hsd_info *hi)
{

	HSD_DBG("remove_headset\n");
	if(atomic_read(&hi->is_3_pole_or_not) == 1)
		spmi_write(0x80);
	if(atomic_read(&hi->is_3_pole_or_not) == 0)
		gpio_direction_output(hi->gpio_mic_en, 0);

	atomic_set(&hi->is_3_pole_or_not, 1);
	mutex_lock(&hi->mutex_lock);
	switch_set_state(&hi->sdev, NO_DEVICE);
	mutex_unlock(&hi->mutex_lock);

	if (atomic_read(&hi->irq_key_enabled)) {
		atomic_set(&hi->irq_key_enabled, FALSE);
	}

	if (atomic_read(&hi->btn_state))
#ifdef CONFIG_MAX1462X_USE_LOCAL_WORK_QUEUE
		queue_delayed_work(local_max1462x_workqueue,
				&(hi->work_for_key_released), hi->latency_for_key );
#else
	schedule_delayed_work(&(hi->work_for_key_released),
			hi->latency_for_key );
#endif
	atomic_set(&hi->isdetect,FALSE);
}
static void remove_headset(struct hsd_info *hi)
{

	int has_mic = switch_get_state(&hi->sdev);

	HSD_DBG("remove_headset\n");
	if(atomic_read(&hi->is_3_pole_or_not) == 1)
		spmi_write(0x80);
	if(atomic_read(&hi->is_3_pole_or_not) == 0)
		gpio_direction_output(hi->gpio_mic_en, 0);

	atomic_set(&hi->is_3_pole_or_not, 1);
	mutex_lock(&hi->mutex_lock);
	switch_set_state(&hi->sdev, NO_DEVICE);
	mutex_unlock(&hi->mutex_lock);

	input_report_switch(hi->input, SW_HEADPHONE_INSERT, 0);
	if (has_mic == LGE_HEADSET)
		input_report_switch(hi->input, SW_MICROPHONE_INSERT, 0);
	input_sync(hi->input);

	if (atomic_read(&hi->irq_key_enabled)) {
		atomic_set(&hi->irq_key_enabled, FALSE);
	}

	if (atomic_read(&hi->btn_state))
		schedule_delayed_work(&(hi->work_for_key_released_remove),
				hi->latency_for_key );
	atomic_set(&hi->isdetect,FALSE);
}
static void insert_headset(struct hsd_info *hi)
{
	int earjack_type;

	HSD_DBG("insert_headset\n");
	if (atomic_read(&hi->isdetect)) {
		HSD_DBG("duplicate irq\n");
		return;
	}

	atomic_set(&hi->isdetect, TRUE);
	irq_set_irq_wake(hi->irq_key, 1);
	gpio_direction_output(hi->gpio_mic_en, 1);
	msleep(40);
	HSD_DBG("insert delay 40\n");
	/*                          
                    
                                
                                                           
                                            
                                                                */

	earjack_type = hi->gpio_get_value_func(hi->gpio_key);

	if (earjack_type == 1) {

		HSD_DBG("4 polarity earjack\n");

		atomic_set(&hi->is_3_pole_or_not, 0);

		mutex_lock(&hi->mutex_lock);
		switch_set_state(&hi->sdev, LGE_HEADSET);
		mutex_unlock(&hi->mutex_lock);

		if (!atomic_read(&hi->irq_key_enabled)) {
			HSD_DBG("irq_key_enabled = FALSE\n");
			atomic_set(&hi->irq_key_enabled, TRUE);
		}

		input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1);
		input_report_switch(hi->input, SW_MICROPHONE_INSERT, 1);
		input_sync(hi->input);

	} else {
		gpio_direction_output(hi->gpio_mic_en, 0);
		spmi_write(0x00);
		HSD_DBG("3 polarity earjack\n");
		atomic_set(&hi->is_3_pole_or_not, 1);

		mutex_lock(&hi->mutex_lock);
		switch_set_state(&hi->sdev, LGE_HEADSET_NO_MIC);
		mutex_unlock(&hi->mutex_lock);

		irq_set_irq_wake(hi->irq_key, 0);

		input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1);
		input_sync(hi->input);
	}
}
static void insert_headset(struct hsd_info *hi)
{
	int earjack_type;

	HSD_DBG("insert_headset\n");
	if (atomic_read(&hi->isdetect)) {
		HSD_DBG("duplicate irq\n");
		return;
	}

	atomic_set(&hi->isdetect, TRUE);
	irq_set_irq_wake(hi->irq_key, 1);
	gpio_direction_output(hi->gpio_mic_en, 1);
	msleep(40);
	HSD_DBG("insert delay 40\n");
	/* check if 3-pole or 4-pole
	   1. read gpio_key
	   2. check if 3-pole or 4-pole
	   3-1. NOT regiter irq with gpio_key if 3-pole. complete.
	   3-2. regiter irq with gpio_key if 4-pole
	   4. read MPP6 and decide a pressed key when interrupt occurs */

	earjack_type = hi->gpio_get_value_func(hi->gpio_key);

	if (earjack_type == 1) {

		HSD_DBG("4 polarity earjack\n");

		atomic_set(&hi->is_3_pole_or_not, 0);

		mutex_lock(&hi->mutex_lock);
		switch_set_state(&hi->sdev, LGE_HEADSET);
		mutex_unlock(&hi->mutex_lock);

		if (!atomic_read(&hi->irq_key_enabled)) {
			HSD_DBG("irq_key_enabled = FALSE\n");
			atomic_set(&hi->irq_key_enabled, TRUE);
		}

		input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1);
		input_report_switch(hi->input, SW_MICROPHONE_INSERT, 1);
		input_sync(hi->input);

	} else {
		gpio_direction_output(hi->gpio_mic_en, 0);
		spmi_write(0x00);
		HSD_DBG("3 polarity earjack\n");
		atomic_set(&hi->is_3_pole_or_not, 1);

		mutex_lock(&hi->mutex_lock);
		switch_set_state(&hi->sdev, LGE_HEADSET_NO_MIC);
		mutex_unlock(&hi->mutex_lock);

		irq_set_irq_wake(hi->irq_key, 0);

		input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1);
		input_sync(hi->input);
	}
}
static void remove_headset(struct hsd_info *hi)
{

	int has_mic = switch_get_state(&hi->sdev);

	HSD_DBG("remove_headset\n");
	if (atomic_read(&hi->is_3_pole_or_not) == 1)
		spmi_write(0x80);
	if (atomic_read(&hi->is_3_pole_or_not) == 0)
		gpio_direction_output(hi->gpio_mic_en, 0);

	atomic_set(&hi->is_3_pole_or_not, 1);
	mutex_lock(&hi->mutex_lock);
	switch_set_state(&hi->sdev, NO_DEVICE);
	mutex_unlock(&hi->mutex_lock);

	input_report_switch(hi->input, SW_HEADPHONE_INSERT, 0);
	if (has_mic == LGE_HEADSET) {
		input_report_switch(hi->input, SW_MICROPHONE_INSERT, 0);
#ifdef CONFIG_LGE_HEADSET_MIC_NOISE_WA
		taiko_dec5_vol_mute();
#endif
	}
	input_sync(hi->input);

	if (atomic_read(&hi->irq_key_enabled)) {
		atomic_set(&hi->irq_key_enabled, FALSE);
	}

	if (atomic_read(&hi->btn_state))
#ifdef CONFIG_MAX1462X_USE_LOCAL_WORK_QUEUE
		queue_delayed_work(local_max1462x_workqueue,
				&(hi->work_for_key_released), hi->latency_for_key);
#else
	schedule_delayed_work(&(hi->work_for_key_released),
			hi->latency_for_key);
#endif
	atomic_set(&hi->isdetect, FALSE);
}
Exemple #6
0
static void insert_headset(struct hsd_info *hi)
{
	int earjack_type;

	HSD_DBG("insert_headset\n");
	if(atomic_read(&hi->isdetect))
	{
		HSD_DBG("duplicate irq\n");
		return;
	}

	atomic_set(&hi->isdetect,TRUE);
	irq_set_irq_wake(hi->irq_key, 1);
	gpio_direction_output(hi->gpio_mic_en, 1);
#ifdef CONFIG_SWITCH_MAX1462X_WA
	#ifdef CONFIG_MACH_MSM8974_G2_TMO_US
		msleep(600);
		HSD_DBG("insert delay 600\n");
	#else
		msleep(500);
		HSD_DBG("insert delay 500\n");
	#endif
#else
	msleep(40);
	HSD_DBG("insert delay 40\n");
#endif
	/* check if 3-pole or 4-pole
	   1. read gpio_key
	   2. check if 3-pole or 4-pole
	   3-1. NOT regiter irq with gpio_key if 3-pole. complete.
	   3-2. regiter irq with gpio_key if 4-pole
	   4. read MPP6 and decide a pressed key when interrupt occurs */

	earjack_type = hi->gpio_get_value_func(hi->gpio_key);

	if ( earjack_type == 1 ) {

		HSD_DBG("4 polarity earjack\n");

		atomic_set(&hi->is_3_pole_or_not, 0);

		mutex_lock(&hi->mutex_lock);
		switch_set_state(&hi->sdev, LGE_HEADSET);
		mutex_unlock(&hi->mutex_lock);

		if (!atomic_read(&hi->irq_key_enabled)) {
			HSD_DBG("irq_key_enabled = FALSE\n");
			atomic_set(&hi->irq_key_enabled, TRUE);
		}

	} else {
		gpio_direction_output(hi->gpio_mic_en, 0);
		spmi_write(0x00);
		HSD_DBG("3 polarity earjack\n");
		atomic_set(&hi->is_3_pole_or_not, 1);

		mutex_lock(&hi->mutex_lock);
		switch_set_state(&hi->sdev, LGE_HEADSET_NO_MIC);
		mutex_unlock(&hi->mutex_lock);

		irq_set_irq_wake(hi->irq_key, 0);
	}
}