static void insert_11pin_35mm(int *state)
{
	/* support 3.5mm earphone with mic */
	printk(KERN_INFO "11pin_3.5mm_headset plug in\n");

	/* Turn On Mic Bias */
	if (!hi->mic_bias_state) {
		turn_mic_bias_on(1);
		hi->mic_bias_state = 1;
		/* Wait pin be stable */
		msleep(300);
	}

	/* Detect headset with or without microphone */
	if (microp_notify_mic_value() == HEADSET_NO_MIC) {
		/* without microphone */
		*state |= BIT_HEADSET_NO_MIC;
		hi->h2w_35mm_status = HTC_35MM_NO_MIC;
		printk(KERN_INFO "11pin_3.5mm without microphone\n");
	} else { /* with microphone */
		*state |= BIT_HEADSET;
		hi->h2w_35mm_status = HTC_35MM_MIC;
		printk(KERN_INFO "11pin_3.5mm with microphone\n");
	}

	if (hi->key_int_shutdown_gpio)
		gpio_set_value(hi->key_int_shutdown_gpio, 1);
}
static int update_hw_audio_path(void __user * arg)
{
	struct msm_audio_path audio_path;

	if (copy_from_user(&audio_path, arg, sizeof(audio_path))) {
		ERR_COPY_FROM_USER();
		return -EFAULT;
	}

	D("%s: mic=%d, dual_mic=%d, speaker=%d, headset = %d\n",
			__func__,
	       audio_path.enable_mic, audio_path.enable_dual_mic,
	       audio_path.enable_speaker, audio_path.enable_headset);

	/* Switch microphone on/off */
	turn_mic_bias_on(audio_path.enable_mic, audio_path.enable_dual_mic);

	/* Switch headset HW on/off */
	headphone_amp_power(audio_path.enable_headset);

	/* Switch Speaker HW on/off */
	speaker_amp_power(audio_path.enable_speaker);

	return 0;
}
示例#3
0
static void remove_35mm_do_work(struct work_struct *work)
{
	wake_lock_timeout(&hi->headset_wake_lock, 2.5*HZ);

	H2W_DBG("");
	/*To solve the insert, remove, insert headset problem*/
	if (time_before_eq(jiffies, hi->insert_jiffies))
		msleep(800);

	if (hi->is_ext_insert) {
		H2WI("Skip 3.5mm headset plug out!!!");
		if (hi->is_hpin_stable)
			*(hi->is_hpin_stable) = 1;
		return;
	}

	pr_info("3.5mm_headset plug out\n");

	if (pd->key_event_disable != NULL)
		pd->key_event_disable();

	if (hi->mic_bias_state) {
		turn_mic_bias_on(0);
		hi->mic_bias_state = 0;
	}
	hi->ext_35mm_status = 0;
	if (hi->is_hpin_stable)
		*(hi->is_hpin_stable) = 0;

	/* Notify framework via switch class */
	mutex_lock(&hi->mutex_lock);
	switch_set_state(&hi->hs_change, hi->ext_35mm_status);
	mutex_unlock(&hi->mutex_lock);
}
static void remove_35mm_do_work(struct work_struct *work)
{
	int state;

	if (hi->is_wake_lock_ready)
		wake_lock_timeout(&hi->headset_wake_lock, 2.5*HZ);

	H2W_DBG("");
	/*To solve the insert, remove, insert headset problem*/
	if (time_before_eq(jiffies, hi->insert_jiffies))
		msleep(800);
	if (hi->is_ext_insert) {
		H2WI("Skip 3.5mm headset plug out!!!");
		return;
	}

	printk(KERN_INFO "3.5mm_headset plug out\n");
	mutex_lock(&hi->mutex_lock);
	state = switch_get_state(&hi->sdev);

	if (hi->mic_bias_state) {
		turn_mic_bias_on(0);
		hi->mic_bias_state = 0;
	}

	/* For HW Metrico lab test */
	if (hi->metrico_status)
		enable_metrico_headset(0);

	microp_notify_unplug_mic();

	if (atomic_read(&hi->btn_state))
		button_released(atomic_read(&hi->btn_state));
	hi->ext_35mm_status = HTC_35MM_UNPLUG;

	if (hi->key_int_shutdown_gpio)
		gpio_set_value(hi->key_int_shutdown_gpio, 0);

	if (hi->ext_mic_sel)
		gpio_direction_output(hi->ext_mic_sel, 0);

	if (hi->h2w_dev_type == H2W_TVOUT) {
		state &= ~(BIT_HEADSET | BIT_35MM_HEADSET);
		state |= BIT_HEADSET_NO_MIC;
		switch_set_state(&hi->sdev, state);
	} else if (hi->cable_in1 && !gpio_get_value(hi->cable_in1)) {
		state &= ~BIT_35MM_HEADSET;
		switch_set_state(&hi->sdev, state);
		queue_delayed_work(detect_wq, &detect_h2w_work, H2W_NO_DELAY);
	} else {
		state &= ~(BIT_HEADSET | BIT_HEADSET_NO_MIC |
			BIT_35MM_HEADSET);
		switch_set_state(&hi->sdev, state);
	}

	mutex_unlock(&hi->mutex_lock);
}
static void remove_11pin_35mm(void)
{
	if (hi->mic_bias_state) {
		turn_mic_bias_on(0);
		hi->mic_bias_state = 0;
		msleep(300);
	}

	microp_notify_unplug_mic();
	if (atomic_read(&hi->btn_state))
		button_released(atomic_read(&hi->btn_state));
	hi->h2w_35mm_status = HTC_35MM_UNPLUG;
	if (hi->key_int_shutdown_gpio)
		gpio_set_value(hi->key_int_shutdown_gpio, 0);
	printk(KERN_INFO "remove 11pin 3.5mm headset\n");
}
示例#6
0
static void insert_35mm_do_work(struct work_struct *work)
{
	H2W_DBG("");
	hi->insert_jiffies = jiffies + 1*HZ;

	wake_lock_timeout(&hi->headset_wake_lock, 1.5*HZ);

	if (hi->is_ext_insert) {
		pr_info("3.5mm_headset plug in\n");

	if (pd->key_event_enable != NULL)
		pd->key_event_enable();

		/* Turn On Mic Bias */
		if (!hi->mic_bias_state) {
			turn_mic_bias_on(1);
			hi->mic_bias_state = 1;
			/* Wait for pin stable */
			msleep(300);
		}

		/* Detect headset with or without microphone */
		if(pd->headset_has_mic) {
			if (pd->headset_has_mic() == 0) {
				/* without microphone */
				pr_info("3.5mm without microphone\n");
				hi->ext_35mm_status = BIT_HEADSET_NO_MIC;
			} else { /* with microphone */
				pr_info("3.5mm with microphone\n");
				hi->ext_35mm_status = BIT_HEADSET;
			}
		} else {
			/* Assume no mic */
			pr_info("3.5mm without microphone\n");
			hi->ext_35mm_status = BIT_HEADSET_NO_MIC;
		}
		hi->ext_35mm_status |= BIT_35MM_HEADSET;

		/* Notify framework via switch class */
		mutex_lock(&hi->mutex_lock);
		switch_set_state(&hi->hs_change, hi->ext_35mm_status);
		mutex_unlock(&hi->mutex_lock);

		if (hi->is_hpin_stable)
			*(hi->is_hpin_stable) = 1;
	}
}
static void insert_35mm_do_work(struct work_struct *work)
{
	int state;
	int i, mic1, mic2;

	H2W_DBG("");
	hi->insert_jiffies = jiffies + 1*HZ;

	if (hi->is_wake_lock_ready)
		wake_lock_timeout(&hi->headset_wake_lock, 1.5*HZ);

	if (hi->h2w_dev_type && hi->is_ext_insert &&
		hi->h2w_dev_type != H2W_TVOUT)
		remove_headset();

	mutex_lock(&hi->mutex_lock);
	state = switch_get_state(&hi->sdev);

	if (hi->is_ext_insert) {
		printk(KERN_INFO "3.5mm_headset plug in\n");
		hi->ignore_btn = 0;
		state &= ~(BIT_HEADSET | BIT_HEADSET_NO_MIC);
		if (hi->ext_mic_sel)
			gpio_direction_output(hi->ext_mic_sel, 1);

		/* Turn On Mic Bias */
		if (!hi->mic_bias_state) {
			turn_mic_bias_on(1);
			hi->mic_bias_state = 1;
			/* Wait for pin stable */
			msleep(300);
		}

		/* Detect headset with or without microphone */
		for (i = 0; i < 10; i++) {
			mic1 = microp_notify_mic_value();
			msleep(600);
			mic2 = microp_notify_mic_value();
			if (mic1 == mic2)
				break;
		}

		/* For HW Metrico lab test */
		if (mic2 == HEADSET_METRICO && !hi->metrico_status)
			enable_metrico_headset(1);

		if (mic2 == HEADSET_NO_MIC || mic1 != mic2) {
			/* without microphone */
			state |= BIT_HEADSET_NO_MIC;
			printk(KERN_INFO "3.5mm_headset without microphone\n");
		} else {
			/* with microphone */
			state |= BIT_HEADSET;
			printk(KERN_INFO "3.5mm_headset with microphone\n");
		}

		if (hi->key_int_shutdown_gpio)
			gpio_set_value(hi->key_int_shutdown_gpio, 1);

		state |= BIT_35MM_HEADSET;
		switch_set_state(&hi->sdev, state);
		if (state & BIT_HEADSET_NO_MIC)
			hi->ext_35mm_status = HTC_35MM_NO_MIC;
		else
			hi->ext_35mm_status = HTC_35MM_MIC;

	}

	mutex_unlock(&hi->mutex_lock);
}