Ejemplo n.º 1
0
static int lge_hsd_remove(struct platform_device *pdev)
{
    struct hsd_info *hi = (struct hsd_info *)platform_get_drvdata(pdev);

    HSD_DBG("lge_hsd_remove");

    if (switch_get_state(&hi->sdev))
        remove_headset(hi);

    input_unregister_device(hi->input);
    switch_dev_unregister(&hi->sdev);

    free_irq(hi->irq_key, 0);
    free_irq(hi->irq_detect, 0);
    gpio_free(hi->gpio_det);
    gpio_free(hi->gpio_swd);
    gpio_free(hi->gpio_mode);

//LGE_CHANGE_S 20130710 ilda.jung[Audio] Disable not using GPIO
#if !defined(CONFIG_MACH_APQ8064_AWIFI)
    if( hi->external_ldo_mic_bias > 0 )
        gpio_free(hi->external_ldo_mic_bias);
#endif
//LGE_CHANGE_E 20130710 ilda.jung[Audio] Disable not using GPIO

    mutex_destroy(&hi->mutex_lock);

    kfree(hi);

    return 0;
}
Ejemplo n.º 2
0
void cable_ins_det_work_func(struct work_struct *work)
	{
	unsigned long irq_flags;

	headset_data.jack_status  = gpio_get_value(headset_data.jack_gpio);

	if( 0 == headset_data.jack_status)
	{
		HEADSET_INFO("lock headset wakelock when doing headset insert detection");

		wake_lock_timeout(&headset_data.headset_det_wakelock, (2*HZ) );
		insert_headset();
	}
	else
	{
		HEADSET_INFO("lock headset wakelock when doing headset remove detection");
		wake_lock_timeout(&headset_data.headset_det_wakelock, HZ );
		remove_headset();
	}

	if ( HSD_IRQ_DISABLE == headset_data.jack_irq_status)
	{
		local_irq_save(irq_flags);

		enable_irq(headset_data.jack_irq);
		headset_data.jack_irq_status = HSD_IRQ_ENABLE;
		local_irq_restore(irq_flags);
	}
	switch_set_state(&headset_data.sdev, g_headset_type);
	
}
static void detection_work(struct work_struct *work)
{
	int cable_in;

	H2W_DBG("");

	  H2W_DBG("%d %d", gpio_get_value(hi->cable_in1), HS_PLUG_IN); /* FIH-SW2-MM-AY-TAP_headset_00 */
	if (gpio_get_value(hi->cable_in1) != HS_PLUG_IN) { /* FIH-SW2-MM-AY-TAP_headset_00 */
		/* Headset plugged out */
		if ( (switch_get_state(&hi->sdev) == HEADSET) || (switch_get_state(&hi->sdev) == NOMIC_HEADSET) || (switch_get_state(&hi->sdev) == NOT_SUPPORT) || (switch_get_state(&hi->sdev) == UNKNOWN_DEVICE)) { /* FIH-SW2-MM-AY-hsed_type-02 */
			H2W_DBG("Headset is plugged out.\n");
			remove_headset();
		}
		return;
	}

	/* Something plugged in, lets make sure its a headset */
	cable_in = gpio_get_value(hi->cable_in1); /* FIH-SW2-MM-AY-TAP_headset_00 */
       
    if (cable_in == HS_PLUG_IN ) {
       	if (switch_get_state(&hi->sdev) == NO_DEVICE) {
       		H2W_DBG("Headset is plugged in.\n");
       		insert_headset();
       	}
    } else {
       	H2W_DBG("WARN: AUD_PIN_HEADSET_DET be triggered, but not a headset ");
    }

}
Ejemplo n.º 4
0
/**********************************************************
**  Function: Jack detection-in gpio configuration function
**  Parameter: none
**  Return value: if sucess, then returns 0
**
************************************************************/
static int jack_config_gpio()
{
	int ret;

	printk("HEADSET: Config Jack-in detection gpio\n");
	hs_micbias_power(ON);
	tegra_gpio_enable(JACK_GPIO);
	ret = gpio_request(JACK_GPIO, "h2w_detect");
	ret = gpio_direction_input(JACK_GPIO);

	hs_data->irq = gpio_to_irq(JACK_GPIO);
	ret = request_irq(hs_data->irq, detect_irq_handler,
			  IRQF_TRIGGER_FALLING|IRQF_TRIGGER_RISING, "h2w_detect", NULL);

	ret = irq_set_irq_wake(hs_data->irq, 1);
	msleep(1);
	if (gpio_get_value(JACK_GPIO) == 0){
		insert_headset();
	}else {
		hs_micbias_power(OFF);
		headset_alive = false;
		remove_headset();
	}

	return 0;
}
Ejemplo n.º 5
0
static void detection_work(struct work_struct *work)
{
	unsigned long irq_flags;
	int cable_in1;

	/* Disable headset interrupt while detecting.*/
	local_irq_save(irq_flags);
	disable_irq(hs_data->irq);
	local_irq_restore(irq_flags);

	/* Delay 500ms for pin stable. */
	msleep(500);

	/* Restore IRQs */
	local_irq_save(irq_flags);
	enable_irq(hs_data->irq);
	local_irq_restore(irq_flags);

	if (gpio_get_value(JACK_GPIO) != 0) {
		/* Headset not plugged in */
		if (switch_get_state(&hs_data->sdev) == HEADSET)
			remove_headset();
		return;
	}

	cable_in1 = gpio_get_value(JACK_GPIO);

	if (cable_in1 == 0) {
		if(switch_get_state(&hs_data->sdev) == NO_DEVICE)
			insert_headset();
	} else{
		printk("HEADSET: Jack-in GPIO is low, but not a headset \n");
	}
}
Ejemplo n.º 6
0
static void detection_work(struct work_struct *work)
{
	int cable_in1;

	H2W_DBG("");

	if (gpio_get_value(hi->gpio_detect) == 1) {
		/* Headset not plugged in */
		if (switch_get_state(&hi->sdev) == LGE_HEADSET
 			|| switch_get_state(&hi->sdev) == LGE_NO_MIC_HEADSET
		)
			remove_headset();

		H2W_DBG("detection_work-remove_headset \n");
		wake_unlock(&hi->wake_lock);
		return;
	}

	cable_in1 = gpio_get_value(hi->gpio_detect);

	if (cable_in1 == 0) {
		if (switch_get_state(&hi->sdev) == NO_DEVICE)
			{
				H2W_DBG("detection_work-insert_headset \n");
				insert_headset();
			}
	}
	wake_unlock(&hi->wake_lock);
}
Ejemplo n.º 7
0
static int lge_hsd_remove(struct platform_device *pdev)
{
    struct hsd_info *hi = (struct hsd_info *)platform_get_drvdata(pdev);

    HSD_DBG("lge_hsd_remove");

    if (switch_get_state(&hi->sdev))
        remove_headset(hi);

    input_unregister_device(hi->input);
    switch_dev_unregister(&hi->sdev);

    free_irq(hi->irq_key, 0);
    free_irq(hi->irq_detect, 0);

    gpio_free(hi->gpio_mic_en);
    gpio_free(hi->gpio_key);
    gpio_free(hi->gpio_jpole);
    gpio_free(hi->gpio_detect);

    mutex_destroy(&hi->mutex_lock);

    kfree(hi);

    return 0;
}
Ejemplo n.º 8
0
static int lge_hsd_remove(struct platform_device *pdev)
{
	struct hsd_info *hi = (struct hsd_info *)platform_get_drvdata(pdev);

	HSD_DBG("lge_hsd_remove");

	if (switch_get_state(&hi->sdev))
#ifdef CONFIG_LGE_AUDIO_FSA8008_MODIFY
		queue_delayed_work(local_fsa8008_workqueue, &(hi->work_for_remove), 0 );
#else
		remove_headset(hi);
#endif

	input_unregister_device(hi->input);
	switch_dev_unregister(&hi->sdev);

	free_irq(hi->irq_key, 0);
	free_irq(hi->irq_detect, 0);

	gpio_free(hi->gpio_mic_en);
	gpio_free(hi->gpio_key);
	gpio_free(hi->gpio_jpole);
	gpio_free(hi->gpio_detect);

	mutex_destroy(&hi->mutex_lock);

	kfree(hi);

	return 0;
}
Ejemplo n.º 9
0
static void detect_work(struct work_struct *work)
{
	int state;
	struct hsd_info *hi = container_of(work, struct hsd_info, work);

	HSD_DBG("detect_work\n");

	state = hi->gpio_get_value_func(hi->gpio_detect);

	if (state == 1) {
		if (switch_get_state(&hi->sdev) != NO_DEVICE) {
			HSD_DBG("LGE headset removing\n");
			remove_headset(hi);
		} else {
			HSD_DBG("err_invalid_state remove state = %d\n", state);
		}
	} else {

		if (switch_get_state(&hi->sdev) == NO_DEVICE) {
			HSD_DBG("LGE headset inserting\n");
			insert_headset(hi);
		} else {
			HSD_DBG("err_invalid_state insert state = %d\n", state);
		}
	}
}
static void detect_work(struct work_struct *work)
{
    int state;
    unsigned long irq_flags;

    local_irq_save(irq_flags);
    disable_irq(hi->irq);
    local_irq_restore(irq_flags);

    state = gpio_get_value(hi->gpio);

    HSD_DBG("hs:%d\n", state);

    local_irq_save(irq_flags);
    enable_irq(hi->irq);
    local_irq_restore(irq_flags);

    if (state != 1) {
        if (switch_get_state(&hi->sdev) == LGE_HEADSET) {
            HSD_DBG("==== LGE headset removing\n");
            remove_headset();
        }
        return;
    }

    if (state == 1) {
        if (switch_get_state(&hi->sdev) == NO_DEVICE) {
            HSD_DBG("==== LGE headset inserting\n");
            insert_headset();
        }
    }
    else {
        HSD_ERR("Invalid state\n");
    }
}
Ejemplo n.º 11
0
static int h2w_remove(struct platform_device *pdev)
{
    /* yl_debug(""); */
    if (switch_get_state(&hi->sdev))
        remove_headset();
    input_unregister_device(hi->input);
    switch_dev_unregister(&hi->sdev);
    kfree(hi);

    return 0;
}
Ejemplo n.º 12
0
static int acer_hs_remove(struct platform_device *pdev)
{
	ACER_HS_DBG("");
	if (switch_get_state(&hr->sdev))
		remove_headset();
	gpio_free(hr->det);
	free_irq(hr->irq, 0);
	switch_dev_unregister(&hr->sdev);

	return 0;
}
Ejemplo n.º 13
0
static void detection_work(struct work_struct *work)
{
	unsigned long irq_flags;
	int cable_in1;
	int mic_in = 0;

	wake_lock(&hp_detect_wakelock);
	hs_micbias_power(ON);
	isHpDetecting = true;

	/* Disable headset interrupt while detecting.*/
	local_irq_save(irq_flags);
	disable_irq(hs_data->irq);
	local_irq_restore(irq_flags);

	/* Delay 1000ms for pin stable. */
	msleep(1000);

	/* Restore IRQs */
	local_irq_save(irq_flags);
	enable_irq(hs_data->irq);
	local_irq_restore(irq_flags);

	if (gpio_get_value(JACK_GPIO) != 0) {
		/* Headset not plugged in */
		if (switch_get_state(&hs_data->sdev) == HEADSET_WITH_MIC || switch_get_state(&hs_data->sdev) == HEADSET_WITHOUT_MIC)
			remove_headset();
		goto closed_micbias;
	}

	cable_in1 = gpio_get_value(JACK_GPIO);
	mic_in = gpio_get_value(HOOK_GPIO);
	if (cable_in1 == 0) {
		printk("HOOK_GPIO value: %d\n", mic_in);
		if(switch_get_state(&hs_data->sdev) == NO_DEVICE)
			insert_headset();
		else if ( mic_in == 1)
			goto closed_micbias;
	} else{
		printk("HEADSET: Jack-in GPIO is low, but not a headset \n");
		goto closed_micbias;
	}
	isHpDetecting = false;
	wake_unlock(&hp_detect_wakelock);
	return;

closed_micbias:
	isHpDetecting = false;
	hs_micbias_power(OFF);
	wake_unlock(&hp_detect_wakelock);
	return;
}
static int lge_hsd_remove(struct platform_device *pdev)
{
    if (switch_get_state(&hi->sdev))
        remove_headset();

    input_unregister_device(hi->input);
    gpio_free(hi->gpio);
    free_irq(hi->irq, 0);
    destroy_workqueue(hs_detect_work_queue);
    switch_dev_unregister(&hi->sdev);

    return 0;
}
Ejemplo n.º 15
0
/**********************************************************
**  Function: Headset driver exit function
**  Parameter: none
**  Return value: none
**
************************************************************/
static void __exit headset_exit(void)
{
	printk("HEADSET: Headset exit\n");
	if (switch_get_state(&hs_data->sdev))
		remove_headset();
	gpio_free(JACK_GPIO);
	gpio_free(HOOK_GPIO);
	gpio_free(LINEOUT_GPIO);

	free_irq(hs_data->irq, 0);
	destroy_workqueue(g_detection_work_queue);
	switch_dev_unregister(&hs_data->sdev);
}
Ejemplo n.º 16
0
static void detection_work(struct work_struct *work)
{
	unsigned long irq_flags;
	int cable_in1;
	int mic_in = 0;
	/* Disable headset interrupt while detecting.*/
	local_irq_save(irq_flags);
	disable_irq(hs_data->hp_det_irq);
	local_irq_restore(irq_flags);

	irq_set_irq_type(hs_data->hook_det_irq, IRQF_TRIGGER_NONE);

	set_hs_micbias(ON);

	if (switch_get_state(&hs_data->sdev) != NO_DEVICE) {
		/* Delay for pin stable when being removed. */
		msleep(110);
	} else {
		/* Delay for pin stable when plugged. */
		msleep(1000);
	}

	/* Restore IRQs */
	local_irq_save(irq_flags);
	enable_irq(hs_data->hp_det_irq);
	local_irq_restore(irq_flags);

	if (gpio_get_value(JACK_GPIO) != 0) {
		/* Headset not plugged in */
		remove_headset();
		goto closed_micbias;
	}

	cable_in1 = gpio_get_value(JACK_GPIO);
	mic_in  = gpio_get_value(HS_HOOK_DET);
	if (cable_in1 == 0) {
		printk(KERN_INFO "HOOK_GPIO value: %d\n", mic_in);
		if (switch_get_state(&hs_data->sdev) == NO_DEVICE)
			insert_headset();
		else if (mic_in == 1)
			goto closed_micbias;
	} else{
		printk(KERN_INFO "HEADSET: Jack-in GPIO is low, but not a headset\n");
		goto closed_micbias;
	}
	return;

closed_micbias:
	set_hs_micbias(OFF);
	return;
}
Ejemplo n.º 17
0
static int h2w_remove(struct platform_device *pdev)
{
	pr_info("h2w_remove\n");
	if (switch_get_state(&hi->sdev))
		remove_headset();
	input_unregister_device(hi->input);
	gpio_free(MSM_GPIO_EAR_SEND_END);
	gpio_free(MSM_GPIO_EAR_DET);
	free_irq(hi->irq_btn, 0);
	free_irq(hi->irq, 0);
	destroy_workqueue(g_earbutton_work_queue);
	switch_dev_unregister(&hi->sdev);

	return 0;
}
static int sapphire_h2w_remove(struct platform_device *pdev)
{
	H2W_DBG("");
	if (switch_get_state(&hi->sdev))
		remove_headset();
	input_unregister_device(hi->input);
	gpio_free(SAPPHIRE_GPIO_CABLE_IN2);
	gpio_free(SAPPHIRE_GPIO_CABLE_IN1);
	free_irq(hi->irq_btn, 0);
	free_irq(hi->irq, 0);
	destroy_workqueue(g_detection_work_queue);
	switch_dev_unregister(&hi->sdev);

	return 0;
}
Ejemplo n.º 19
0
/**********************************************************
 ** Function: Jack detection-in gpio configuration function
 ** Parameter: none
 ** Return value: if sucess, then returns 0
 **
 ************************************************************/
static int jack_config_gpio()
{
	int ret;

	printk("HEADSET: Config Jack-in detection gpio\n");
	hs_micbias_power(ON);
	ret = gpio_request(JACK_GPIO, "h2w_detect");
	ret = gpio_direction_input(JACK_GPIO);

	hs_data->irq = gpio_to_irq(JACK_GPIO);
	ret = request_irq(hs_data->irq, detect_irq_handler,
			IRQF_TRIGGER_FALLING|IRQF_TRIGGER_RISING, "h2w_detect", NULL);

	ret = irq_set_irq_wake(hs_data->irq, 1);

	switch (project_info) {
		case TEGRA3_PROJECT_TF201:
		case TEGRA3_PROJECT_TF300T:
		case TEGRA3_PROJECT_TF300TG:
		case TEGRA3_PROJECT_TF300TL:
		case TEGRA3_PROJECT_TF500T:
		case TEGRA3_PROJECT_TF700T:
		case TEGRA3_PROJECT_ME301T:
		case TEGRA3_PROJECT_ME301TL:
			/* delay 100ms to wait hook_det stable */
			msleep(100);
			break;
		case TEGRA3_PROJECT_P1801:
			/* delay 230ms to wait hook_det stable */
			msleep(230);
			break;
		default:
			/* delay 100ms to wait hook_det stable */
			msleep(100);
			break;
	}

	if (gpio_get_value(JACK_GPIO) == 0){
		insert_headset();
	}else {
		hs_micbias_power(OFF);
		headset_alive = false;
		switch_set_state(&hs_data->sdev, NO_DEVICE);
		remove_headset();
	}

	return 0;
}
static void detection_work(struct work_struct *work)
{
	unsigned long irq_flags;
	int clk, cable_in1;

	H2W_DBG("");

	if (gpio_get_value(SAPPHIRE_GPIO_CABLE_IN1) != 0) {
		/*                        */
		if (switch_get_state(&hi->sdev) == HTC_HEADSET)
			remove_headset();
		return;
	}

	/*                                                    */

	/*                                     */
	configure_cpld(GPIO);
	/*                                           */
	local_irq_save(irq_flags);
	disable_irq(hi->irq);
	local_irq_restore(irq_flags);

	/*                                   */
	gpio_direction_output(SAPPHIRE_GPIO_CABLE_IN1, 1);
	/*                            */
	msleep(10);
	/*              */
	clk = gpio_get_value(SAPPHIRE_GPIO_H2W_CLK_GPI);
	/*                             */
	gpio_direction_input(SAPPHIRE_GPIO_CABLE_IN1);

	/*              */
	local_irq_save(irq_flags);
	enable_irq(hi->irq);
	local_irq_restore(irq_flags);

	cable_in1 = gpio_get_value(SAPPHIRE_GPIO_CABLE_IN1);

	if (cable_in1 == 0 && clk == 0) {
		if (switch_get_state(&hi->sdev) == NO_DEVICE)
			insert_headset();
	} else {
		configure_cpld(UART3);
		H2W_DBG("CABLE_IN1 was low, but not a headset "
			"(recent cable_in1 = %d, clk = %d)", cable_in1, clk);
	}
}
Ejemplo n.º 21
0
static int gpio_h2w_remove(struct platform_device *pdev)
{
	H2W_DBG("");
	if (switch_get_state(&hi->sdev))
		remove_headset();
	input_unregister_device(hi->input);
	gpio_free(hi->gpio_button_detect);
	gpio_free(hi->gpio_detect);
	free_irq(hi->irq_btn, 0);
	free_irq(hi->irq, 0);
	destroy_workqueue(g_detection_work_queue);
	switch_dev_unregister(&hi->sdev);
	ip_dev_reg = 0;
	wake_lock_destroy(&hi->wake_lock);
	return 0;
}
Ejemplo n.º 22
0
/**********************************************************
**  Function: Headset driver exit function
**  Parameter: none
**  Return value: none
**
************************************************************/
static void __exit headset_exit(void)
{
	printk(KERN_INFO "HEADSET: Headset exit\n");
	if (switch_get_state(&hs_data->sdev))
		remove_headset();
	gpio_free(JACK_GPIO);
	gpio_free(DB_DET_GPIO);
	gpio_free(HS_HOOK_DET);
	free_irq(hs_data->hp_det_irq, 0);
	free_irq(hs_data->hook_det_irq, 0);
	destroy_workqueue(g_detection_work_queue);
	destroy_workqueue(g_button_press_work_queue);
	destroy_workqueue(g_button_release_work_queue);
	switch_dev_unregister(&hs_data->sdev);
	input_unregister_device(hs_data->input);
	kfree(hs_data);
}
static int hds_remove(struct platform_device *pdev)
{
	HDSI("Removing 3.5mm headset driver\n");
	if (switch_get_state(&hi->sdev))
		remove_headset();
	input_unregister_device(hi->input);
	if (hi->gpio_detect)
		gpio_free(hi->gpio_detect);
	if (hi->gpio_headset_mic) {
		gpio_free(hi->gpio_headset_mic);
		free_irq(hi->irq_btn_35mm, 0);
	}
	destroy_workqueue(g_detection_work_queue);
	switch_dev_unregister(&hi->sdev);

	return 0;
}
static int htc_headset_mgr_remove(struct platform_device *pdev)
{
#if 0
	if ((switch_get_state(&hi->sdev) & MASK_HEADSET) != 0)
		remove_headset();
#endif

	unregister_attributes();
	input_unregister_device(hi->input);
	destroy_workqueue(button_wq);
	destroy_workqueue(detect_wq);
	switch_dev_unregister(&hi->sdev);
	mutex_destroy(&hi->mutex_lock);
	wake_lock_destroy(&hi->hs_wake_lock);
	kfree(hi);

	return 0;
}
Ejemplo n.º 25
0
static void detect_work(struct work_struct *work)
{
	int state;
	#if 0
	unsigned long irq_flags;
	#endif
	struct delayed_work *dwork = container_of(work, struct delayed_work, work);
	struct hsd_info *hi = container_of(dwork, struct hsd_info, work);

	HSD_DBG("detect_work");

	#if 0
	local_irq_save(irq_flags);
	disable_irq(hi->irq_detect);
	local_irq_restore(irq_flags);
#endif

	printk(KERN_INFO " dev=0x%x\n",(unsigned int)hi);

	state = gpio_get_value_cansleep(hi->gpio_detect);

	if (state == 1) {
		if (switch_get_state(&hi->sdev) != NO_DEVICE) {
			HSD_DBG("==== LGE headset removing\n");
			remove_headset(hi);
		} else {
			HSD_DBG("err_invalid_state state = %d\n", state);
		}
	} else {

		if (switch_get_state(&hi->sdev) == NO_DEVICE) {
			HSD_DBG("==== LGE headset inserting\n");
			insert_headset(hi);
		} else {
			HSD_DBG("err_invalid_state state = %d\n", state);
		}
	}

	#if 0
	local_irq_save(irq_flags);
	enable_irq(hi->irq_detect);
	local_irq_restore(irq_flags);
#endif
}
Ejemplo n.º 26
0
static void detection_work(struct work_struct *work)
{
	/*Headset detach*/
	H2W_DBG("");

	if (gpio_get_value(hi->gpio_detect) == 1) {
		if (switch_get_state(&hi->sdev) == BIT_HEADSET
			|| switch_get_state(&hi->sdev) == BIT_HEADSET_SPEAKER_ONLY
		){
			remove_headset();
	}
	}
	/*Headset attach*/
	else{
		if (switch_get_state(&hi->sdev) == BIT_NO_DEVICE){
				insert_headset();
			}
	} 
}
Ejemplo n.º 27
0
void simulate_hs_report(struct snd_soc_jack *jack, int status, int mask)
{
    struct snd_soc_codec *codec;
    int oldstatus;

    if (!jack)
        return;
    pr_info("%s: id=[%s]; name=[%s]\n",
            __func__, jack->jack->id, jack->jack->name);
    codec = jack->codec;
    /* delet by youjin to avaid deadlock 2012-11-19
    mutex_lock(&codec->mutex);
    */

    oldstatus = jack->status;
    jack->status &= ~mask;
    jack->status |= status & mask;
    if (mask && (jack->status == oldstatus))
        return;

    if (!strncmp("Headset Jack", jack->jack->id, sizeof("Headset Jack"))) {
        pr_debug("[%s] oldstatus:%d, newstatus:%d\n",
                 jack->jack->id, oldstatus, jack->status);
        if (jack->status)
            insert_headset();
        else
            remove_headset();
    } else if (!strncmp("Button Jack",
                        jack->jack->id, sizeof("Button Jack"))) {
        pr_debug("[%s] oldstatus:%d, newstatus:%d\n",
                 jack->jack->id, oldstatus, jack->status);
        if (jack->status)
            button_pressed();
        else
            button_released();
    }
    /*delet by youjin to avaid deadlock 2012-11-19
    out:
    	mutex_unlock(&codec->mutex);
    */
}
Ejemplo n.º 28
0
static irqreturn_t button_irq_handler(int irq, void *dev_id)
{
	struct hsd_info *hi = (struct hsd_info *) dev_id;

	int value;

	wake_lock_timeout(&ear_hook_wake_lock, 2 * HZ);
	HSD_DBG("button_irq_handler\n");

	value = hi->gpio_get_value_func(hi->gpio_key);
	HSD_DBG("hi->gpio_get_value_func(hi->gpio_key) : %d\n", value);

#ifdef CONFIG_SWITCH_MAX1462X_WA
	HSD_DBG("hi->gpio_get_value_func(hi->gpio_key) %d hi->hook_disable : %d\n", value, hook_disable);
#endif

	if(atomic_read(&hi->is_3_pole_or_not) == 0)
	{
#ifdef CONFIG_SWITCH_MAX1462X_WA
		if (hook_disable)
			return IRQ_HANDLED;
#endif
		if (value)
			queue_delayed_work(local_max1462x_workqueue, &(hi->work_for_key_released), hi->latency_for_key );
		else
			queue_delayed_work(local_max1462x_workqueue, &(hi->work_for_key_pressed), hi->latency_for_key );
	}
#ifdef CONFIG_SWITCH_MAX1462X_WA
	else
	{
		msleep(10);
		HSD_DBG("3 pole wrong detection -> 4 pole");
		if (value && hi->gpio_get_value_func(hi->gpio_detect) == 0)
		{
			remove_headset(hi);
			insert_headset(hi);
		}
	}
#endif
	return IRQ_HANDLED;
}
static int trout_h2w_remove(struct platform_device *pdev)
{
	H2W_DBG("");
	
	if (switch_get_state(&hi->sdev))
		remove_headset();

    #ifdef FEATURE_AUD_HOOK_BTN
	input_unregister_device(hi->input);
	gpio_free(hi->cable_in2); /* FIH-SW2-MM-AY-TAP_headset_00 */
	free_irq(hi->irq_btn, 0);	
    #endif   
	
	gpio_free(hi->cable_in1); /* FIH-SW2-MM-AY-TAP_headset_00 */
	free_irq(hi->irq, 0);
	 	
	destroy_workqueue(g_detection_work_queue);
	switch_dev_unregister(&hi->sdev);

	return 0;
}
Ejemplo n.º 30
0
static void detect_work(struct work_struct *work)
{
    int state = 0;
    struct delayed_work *dwork = container_of(work, struct delayed_work, work);
    struct hsd_info *hi = container_of(dwork, struct hsd_info, work);

    HSD_DBG("detect_work");

    if( gpio_cansleep(hi->gpio_det) )
        state = gpio_get_value_cansleep(hi->gpio_det);
    else
        state = gpio_get_value(hi->gpio_det);

    if( state == 1 ) {  // gpio_det high - jack out
        if( switch_get_state(&hi->sdev) != HEADSET_NO_DEVICE ) {
            HSD_DBG("======= LGE headset removing =======");
            remove_headset(hi);
#ifdef CONFIG_LGE_BROADCAST_ONESEG
            isdbt_hw_antenna_switch(0);
            ear_state = 0;
#endif
        } else {
            HSD_DBG("err_invalid_state state = %d\n", state);
        }
    } else {    // gpio_det low - jack in
        if( switch_get_state(&hi->sdev) == HEADSET_NO_DEVICE ) {
            HSD_DBG("********** LGE headset inserting **********");
            insert_headset(hi);

#ifdef CONFIG_LGE_BROADCAST_ONESEG
            isdbt_hw_antenna_switch(1);
            ear_state = 1;
#endif
        } else {
            HSD_DBG("err_invalid_state state = %d\n", state);
        }
    }
}