static int tegra_set_jack(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);

	if (tegra_jack_func == ucontrol->value.integer.value[0])
		return 0;

	tegra_jack_func = ucontrol->value.integer.value[0];
	tegra_ext_control(codec);
	return 1;
}
Exemplo n.º 2
0
static int tegra_codec_init(struct snd_soc_codec *codec)
{
	struct tegra_audio_data* audio_data = codec->socdev->codec_data;
	int err = 0;
#ifdef CONFIG_MACH_ACER_VANGOGH
	int ret = 0;
#endif

	if (!audio_data->init_done) {
		audio_data->dap_mclk = tegra_das_get_dap_mclk();
		if (!audio_data->dap_mclk) {
			pr_err("Failed to get dap mclk \n");
			err = -ENODEV;
			return err;
		}

		/* Add tegra specific widgets */
		snd_soc_dapm_new_controls(codec, tegra_dapm_widgets,
					ARRAY_SIZE(tegra_dapm_widgets));

		/* Set up tegra specific audio path audio_map */
		snd_soc_dapm_add_routes(codec, audio_map,
					ARRAY_SIZE(audio_map));

		/* Add jack detection */
		err = tegra_jack_init(codec);
		if (err < 0) {
			pr_err("Failed in jack init \n");
			return err;
		}

		/* Default to OFF */
		tegra_ext_control(codec, TEGRA_AUDIO_OFF);

		err = tegra_controls_init(codec);
		if (err < 0) {
			pr_err("Failed in controls init \n");
			return err;
		}

#ifdef CONFIG_MACH_ACER_VANGOGH
		ret = wm8903_cdc_irq_init(codec);
		if (ret < 0) {
			pr_err("Failed in cdc irq init \n");
		}
#endif

		audio_data->codec = codec;
		audio_data->init_done = 1;
	}

	return err;
}
Exemplo n.º 3
0
static int tegra_mic_mode_put(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
{
	struct tegra_audio_data* audio_data = snd_kcontrol_chip(kcontrol);
	int codec_con = audio_data->codec_con;
	audio_data->isMicMuted = ucontrol->value.integer.value[0];

	if (audio_data->isMicMuted) {
		codec_con |= TEGRA_MIC_MUTE;
	} else {
		codec_con &= ~TEGRA_MIC_MUTE;
	}

	tegra_ext_control(audio_data->codec, codec_con);
	return 1;
}
Exemplo n.º 4
0
static int tegra_ringtone_mode_put(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_value *ucontrol)
{
	struct tegra_audio_data* audio_data = snd_kcontrol_chip(kcontrol);
	int codec_con = audio_data->codec_con;
	audio_data->isRingtone = ucontrol->value.integer.value[0];

	if (audio_data->isRingtone) {
		codec_con |= TEGRA_VOIP_RINGTONE;
	} else {
		codec_con &= ~TEGRA_VOIP_RINGTONE;
	}

	tegra_ext_control(audio_data->codec, codec_con);
	return 1;
}
Exemplo n.º 5
0
static int tegra_speech_mode_put(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
{
	struct tegra_audio_data* audio_data = snd_kcontrol_chip(kcontrol);
	int codec_con = audio_data->codec_con;
	audio_data->is_speech_mode = ucontrol->value.integer.value[0];

	if (audio_data->is_speech_mode) {
		codec_con |= TEGRA_SPEECH_MODE;
	} else {
		codec_con &= ~TEGRA_SPEECH_MODE;
	}

	pr_err("set speech mode: %d", audio_data->is_speech_mode);

	tegra_ext_control(audio_data->codec, codec_con);

	return 1;
}
Exemplo n.º 6
0
static int tegra_video_call_mode_put(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
{
	struct tegra_audio_data* audio_data = snd_kcontrol_chip(kcontrol);
	int codec_con = audio_data->codec_con;
	audio_data->is_video_call_mode = ucontrol->value.integer.value[0];

	if (audio_data->is_video_call_mode) {
		codec_con |= TEGRA_VOIP_CALL;
	} else {
		codec_con &= ~TEGRA_VOIP_CALL;
	}

	pr_err("set video call mode: %d", audio_data->is_video_call_mode);

	tegra_ext_control(audio_data->codec, codec_con);

	return 1;
}
int tegra_controls_init(struct snd_soc_codec *codec)
{
	int err;

	if (!audio_data) {
		audio_data = kzalloc(sizeof(*audio_data), GFP_KERNEL);
		if (!audio_data) {
			pr_err("failed to allocate tegra_audio_data \n");
			return -ENOMEM;
		}

		/* Add tegra specific controls */
		err = snd_soc_add_controls(codec, tegra_controls,
						ARRAY_SIZE(tegra_controls));
		if (err < 0)
			goto fail;

		/* Add tegra specific widgets */
		snd_soc_dapm_new_controls(codec, tegra_dapm_widgets,
						ARRAY_SIZE(tegra_dapm_widgets));

		/* Set up tegra specific audio path audio_map */
		snd_soc_dapm_add_routes(codec, audio_map,
				ARRAY_SIZE(audio_map));

		audio_data->codec = codec;
		/* Add play route control */
		err = snd_ctl_add(codec->card,
			snd_ctl_new1(&tegra_play_route_control, NULL));
		if (err < 0)
			goto fail;

		/* Add capture route control */
		err = snd_ctl_add(codec->card,
			snd_ctl_new1(&tegra_capture_route_control, NULL));
		if (err < 0)
			goto fail;

		/* Add call mode switch control */
		err = snd_ctl_add(codec->card,
			snd_ctl_new1(&tegra_call_mode_control, NULL));
		if (err < 0)
			goto fail;

#ifndef CONFIG_MACH_SAMSUNG_VARIATION_TEGRA
		/* Add jack detection */
		err = tegra_jack_init(codec);
		if (err < 0)
			goto fail;
#endif

		/* Default to HP output */
		tegra_jack_func = TEGRA_HP;
		tegra_spk_func = TEGRA_SPK_ON;
		tegra_ext_control(codec);

		snd_soc_dapm_sync(codec);
	}

	return 0;

fail:
	if (audio_data) {
		kfree(audio_data);
		audio_data = 0;
	}
	return err;
}
static void tegra_audio_route(int device_new, int is_call_mode_new)
{
	int play_device_new = device_new & TEGRA_AUDIO_DEVICE_OUT_ALL;
	int capture_device_new = device_new & TEGRA_AUDIO_DEVICE_IN_ALL;
	int is_bt_sco_mode =
		(play_device_new & TEGRA_AUDIO_DEVICE_OUT_BT_SCO) ||
		(capture_device_new & TEGRA_AUDIO_DEVICE_OUT_BT_SCO);
	int was_bt_sco_mode =
		(audio_data->play_device & TEGRA_AUDIO_DEVICE_OUT_BT_SCO) ||
		(audio_data->capture_device & TEGRA_AUDIO_DEVICE_OUT_BT_SCO);

	if (play_device_new != audio_data->play_device) {
		if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_HEADPHONE) {
			tegra_jack_func = TEGRA_HP;
		}
		else if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_HEADSET) {
			tegra_jack_func = TEGRA_HEADSET;
		}
		else if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_LINE) {
			tegra_jack_func = TEGRA_LINE;
		}

		if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_SPEAKER) {
			tegra_spk_func = TEGRA_SPK_ON;
		}
		else if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_EAR_SPEAKER) {
			tegra_spk_func = TEGRA_SPK_ON;
		}
		else {
			tegra_spk_func = TEGRA_SPK_OFF;
		}
		tegra_ext_control(audio_data->codec);
		audio_data->play_device = play_device_new;
	}

	if (capture_device_new != audio_data->capture_device) {
		if (capture_device_new & (TEGRA_AUDIO_DEVICE_IN_BUILTIN_MIC |
					TEGRA_AUDIO_DEVICE_IN_MIC |
					TEGRA_AUDIO_DEVICE_IN_BACK_MIC)) {
			if ((tegra_jack_func != TEGRA_HP) &&
				(tegra_jack_func != TEGRA_HEADSET)) {
				tegra_jack_func = TEGRA_MIC;
			}
		}
		else if (capture_device_new & TEGRA_AUDIO_DEVICE_IN_HEADSET) {
			tegra_jack_func = TEGRA_HEADSET;
		}
		else if (capture_device_new & TEGRA_AUDIO_DEVICE_IN_LINE) {
			tegra_jack_func = TEGRA_LINE;
		}
		tegra_ext_control(audio_data->codec);
		audio_data->capture_device = capture_device_new;
	}

	if ((is_call_mode_new != audio_data->is_call_mode) ||
		(is_bt_sco_mode != was_bt_sco_mode)) {
		if (is_call_mode_new && is_bt_sco_mode) {
			tegra_das_set_connection
				(tegra_das_port_con_id_voicecall_with_bt);
		}
		else if (is_call_mode_new && !is_bt_sco_mode) {
			tegra_das_set_connection
				(tegra_das_port_con_id_voicecall_no_bt);
		}
		else if (!is_call_mode_new && is_bt_sco_mode) {
			tegra_das_set_connection
				(tegra_das_port_con_id_bt_codec);
		}
		else {
			tegra_das_set_connection
				(tegra_das_port_con_id_hifi);
		}
		audio_data->is_call_mode = is_call_mode_new;
	}
}
Exemplo n.º 9
0
static void tegra_audio_route(struct tegra_audio_data* audio_data,
			      int device_new, int is_call_mode_new)
{
	int play_device_new = device_new & TEGRA_AUDIO_DEVICE_OUT_ALL;
	int capture_device_new = device_new & TEGRA_AUDIO_DEVICE_IN_ALL;
	int codec_con = audio_data->codec_con;
	int is_bt_sco_mode =
		(play_device_new & TEGRA_AUDIO_DEVICE_OUT_BT_SCO) ||
		(capture_device_new & TEGRA_AUDIO_DEVICE_IN_BT_SCO);
	int was_bt_sco_mode =
		(audio_data->play_device & TEGRA_AUDIO_DEVICE_OUT_BT_SCO) ||
		(audio_data->capture_device & TEGRA_AUDIO_DEVICE_IN_BT_SCO);

	if (play_device_new != audio_data->play_device) {
		codec_con &= ~(TEGRA_HEADPHONE | TEGRA_LINEOUT |
			TEGRA_SPK | TEGRA_EAR_SPK | TEGRA_HEADSET);

		if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_HEADPHONE)
			codec_con |= TEGRA_HEADPHONE;

		if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_LINE)
			codec_con |= TEGRA_LINEOUT;

		if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_SPEAKER)
			codec_con |= TEGRA_SPK;

		if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_EAR_SPEAKER)
			codec_con |= TEGRA_EAR_SPK;

		if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_HEADSET)
			codec_con |= TEGRA_HEADSET;

		tegra_ext_control(audio_data->codec, codec_con);
		audio_data->play_device = play_device_new;
	}

	if (capture_device_new != audio_data->capture_device) {
		codec_con &= ~(TEGRA_INT_MIC | TEGRA_EXT_MIC |
			TEGRA_LINEIN | TEGRA_HEADSET_MIC);

		if (capture_device_new & (TEGRA_AUDIO_DEVICE_IN_BUILTIN_MIC |
			TEGRA_AUDIO_DEVICE_IN_BACK_MIC))
			codec_con |= TEGRA_INT_MIC;

		if (capture_device_new & TEGRA_AUDIO_DEVICE_IN_MIC)
			codec_con |= TEGRA_EXT_MIC;

		if (capture_device_new & TEGRA_AUDIO_DEVICE_IN_LINE)
			codec_con |= TEGRA_LINEIN;

		if (capture_device_new & TEGRA_AUDIO_DEVICE_IN_HEADSET)
			codec_con |= TEGRA_HEADSET_MIC;

		tegra_ext_control(audio_data->codec, codec_con);
		audio_data->capture_device = capture_device_new;

		tegra_drc_config(audio_data->codec);
		tegra_hpf_config(audio_data->codec);
	}

	if ((is_call_mode_new != audio_data->is_call_mode) ||
		(is_bt_sco_mode != was_bt_sco_mode)) {
		if (is_call_mode_new && is_bt_sco_mode) {
			tegra_das_set_connection
				(tegra_das_port_con_id_voicecall_with_bt);
		}
		else if (is_call_mode_new && !is_bt_sco_mode) {
			tegra_das_set_connection
				(tegra_das_port_con_id_voicecall_no_bt);
		}
		else if (!is_call_mode_new && is_bt_sco_mode) {
			tegra_das_set_connection
				(tegra_das_port_con_id_bt_codec);
		}
		else {
			tegra_das_set_connection
				(tegra_das_port_con_id_hifi);
		}
		audio_data->is_call_mode = is_call_mode_new;

		tegra_drc_config(audio_data->codec);
		tegra_hpf_config(audio_data->codec);
	}

	tegra_fm34_config(audio_data->codec);
}
Exemplo n.º 10
0
static void tegra_audio_route(int device_new, int is_call_mode_new)
{
	int play_device_new = device_new & TEGRA_AUDIO_DEVICE_OUT_ALL;
	int capture_device_new = device_new & TEGRA_AUDIO_DEVICE_IN_ALL;
	int is_bt_sco_mode =
		(play_device_new & TEGRA_AUDIO_DEVICE_OUT_BT_SCO) ||
		(capture_device_new & TEGRA_AUDIO_DEVICE_OUT_BT_SCO);
	int was_bt_sco_mode =
		(audio_data->play_device & TEGRA_AUDIO_DEVICE_OUT_BT_SCO) ||
		(audio_data->capture_device & TEGRA_AUDIO_DEVICE_OUT_BT_SCO);

	if (play_device_new) {	
		if ((play_device_new & TEGRA_AUDIO_DEVICE_OUT_HEADPHONE)&&(play_device_new & TEGRA_AUDIO_DEVICE_OUT_SPEAKER)) {
			/*tegra_jack_func = TEGRA_HP;*/
			printk("Routing to Headphone and Speaker output\n");
			need_spk = true;
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_4, 0x0003); /* MIXSPK Enable*/
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_5, 0x0003); /* SPK Enable*/
			snd_soc_write(audio_data->codec, WM8903_GPIO_CONTROL_3, 0x0033); /* GPIO3 configure: EN_SPK*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_SPK_MIX_LEFT_0, 0x0008); /* DACR_TO_MIXSPK Enable*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_SPK_MIX_RIGHT_0, 0x0004); /* DACL_TO_MIXSPK Enable*/
			if(PRJ_ID == EP_101){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_LEFT,audio_params[EP101].analog_speaker_volume | 0x80); /* SPKL Volume: 4dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_RIGHT,audio_params[EP101].analog_speaker_volume | 0x80); /* SPKR Volume: 4dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_LEFT,audio_params[EP101].analog_headset_volume | 0x80); /* HPOUTL Volume: -2dB */
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_RIGHT,audio_params[EP101].analog_headset_volume | 0x80); /* HPOUTR Volume: -2dB */
			}else if(PRJ_ID == EP_102){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_LEFT,audio_params[EP102].analog_speaker_volume | 0x80); /* SPKL Volume: 0dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_RIGHT,audio_params[EP102].analog_speaker_volume | 0x80); /* SPKR Volume: 0dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_LEFT,audio_params[EP102].analog_headset_volume | 0x80); /* HPOUTL Volume: -16dB */
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_RIGHT, audio_params[EP102].analog_headset_volume | 0x80); /* HPOUTR Volume: -16dB */
			}else if(PRJ_ID == EP_103){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_LEFT,audio_params[EP103].analog_speaker_volume | 0x80); /* SPKL Volume: 0dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_RIGHT,audio_params[EP103].analog_speaker_volume | 0x80); /* SPKR Volume: 0dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_LEFT,audio_params[EP103].analog_headset_volume | 0x80); /* HPOUTL Volume: -16dB */
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_RIGHT, audio_params[EP103].analog_headset_volume | 0x80); /* HPOUTR Volume: -16dB */
			}
		}
		else if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_HEADPHONE) {
			/*tegra_jack_func = TEGRA_HP;*/
			printk("Routing to Headphone output\n");
			need_spk = false;
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_4, 0x0000); /* MIXSPK Disable*/
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_5, 0x0000); /* SPK Disable*/
			snd_soc_write(audio_data->codec, WM8903_GPIO_CONTROL_3, 0x0000); /* Media stream, Mute the speaker */
			if(PRJ_ID == EP_101){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_LEFT, audio_params[EP101].analog_headset_volume | 0x80); /* HPOUTL Volume: -2dB */
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_RIGHT,audio_params[EP101].analog_headset_volume | 0x80); /* HPOUTR Volume: -2dB */
			}else if(PRJ_ID == EP_102){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_LEFT,audio_params[EP102].analog_headset_volume | 0x80); /* HPOUTL Volume: -16dB */
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_RIGHT,audio_params[EP102].analog_headset_volume | 0x80); /* HPOUTR Volume: -16dB */
			}else if(PRJ_ID == EP_103){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_LEFT,audio_params[EP103].analog_headset_volume | 0x80); /* HPOUTL Volume: -16dB */
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_RIGHT,audio_params[EP103].analog_headset_volume | 0x80); /* HPOUTR Volume: -16dB */
			}
		}
		else if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_HEADSET) {
			/*tegra_jack_func = TEGRA_HEADSET;*/
			printk("Routing to Headset output\n");
			need_spk = false;
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_4, 0x0000); /* MIXSPK Disable*/
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_5, 0x0000); /* SPK Disable*/
			snd_soc_write(audio_data->codec, WM8903_GPIO_CONTROL_3, 0x0000); /* Media stream, Mute the speaker */
			if(PRJ_ID == EP_101){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_LEFT,audio_params[EP101].analog_headset_volume | 0x80); /* HPOUTL Volume: -2dB */
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_RIGHT,audio_params[EP101].analog_headset_volume | 0x80); /* HPOUTR Volume: -2dB */
			}else if(PRJ_ID == EP_102){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_LEFT,audio_params[EP102].analog_headset_volume | 0x80); /* HPOUTL Volume: -16dB */
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_RIGHT,audio_params[EP102].analog_headset_volume | 0x80); /* HPOUTR Volume: -16dB */
			}else if(PRJ_ID == EP_103){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_LEFT,audio_params[EP103].analog_headset_volume | 0x80); /* HPOUTL Volume: -16dB */
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT1_RIGHT,audio_params[EP103].analog_headset_volume | 0x80); /* HPOUTR Volume: -16dB */
			}
		}
		else if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_LINE) {
			/*tegra_jack_func = TEGRA_LINE;*/
			printk("Routing to Line output\n");
			need_spk = false;
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_4, 0x0000); /* MIXSPK Disable*/
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_5, 0x0000); /* SPK Disable*/
			snd_soc_write(audio_data->codec, WM8903_GPIO_CONTROL_3, 0x0000); /* Media stream, Mute the speaker */
		}

		if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_SPEAKER) {
			/*tegra_spk_func = TEGRA_SPK_ON;*/
			printk("Routing to Speaker output\n");
			need_spk = true;
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_4, 0x0003); /* MIXSPK Enable*/
			if(PRJ_ID == EP_101){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_LEFT,audio_params[EP101].analog_speaker_volume | 0x80); /* SPKL Volume: 4dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_RIGHT,audio_params[EP101].analog_speaker_volume | 0x80); /* SPKR Volume: 4dB*/
			}else if(PRJ_ID == EP_102){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_LEFT,audio_params[EP102].analog_speaker_volume | 0x80); /* SPKL Volume: 0dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_RIGHT,audio_params[EP102].analog_speaker_volume | 0x80); /* SPKR Volume: 0dB*/
			}else if(PRJ_ID == EP_103){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_LEFT,audio_params[EP103].analog_speaker_volume | 0x80); /* SPKL Volume: 0dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_RIGHT,audio_params[EP103].analog_speaker_volume | 0x80); /* SPKR Volume: 0dB*/
			}
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_5, 0x0003); /* SPK Enable*/
			snd_soc_write(audio_data->codec, WM8903_GPIO_CONTROL_3, 0x0033); /* GPIO3 configure: EN_SPK*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_SPK_MIX_LEFT_0, 0x0008); /* DACR_TO_MIXSPK Enable*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_SPK_MIX_RIGHT_0, 0x0004); /* DACL_TO_MIXSPK Enable*/
		}
		else if (play_device_new & TEGRA_AUDIO_DEVICE_OUT_EAR_SPEAKER) {
			/*tegra_spk_func = TEGRA_SPK_ON;*/
			printk("Routing to Ear Speaker output\n");
			need_spk = true;
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_4, 0x0003); /* MIXSPK Enable*/
			if(PRJ_ID == EP_101){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_LEFT,audio_params[EP101].analog_speaker_volume | 0x80); /* SPKL Volume: 4dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_RIGHT,audio_params[EP101].analog_speaker_volume | 0x80); /* SPKR Volume: 4dB*/
			}else if(PRJ_ID == EP_102){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_LEFT,audio_params[EP102].analog_speaker_volume | 0x80); /* SPKL Volume: 0dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_RIGHT,audio_params[EP102].analog_speaker_volume | 0x80); /* SPKR Volume: 0dB*/
			}else if(PRJ_ID == EP_103){
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_LEFT,audio_params[EP103].analog_speaker_volume | 0x80); /* SPKL Volume: 0dB*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_OUT3_RIGHT,audio_params[EP103].analog_speaker_volume | 0x80); /* SPKR Volume: 0dB*/
			}
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_5, 0x0003); /* SPK Enable*/
			snd_soc_write(audio_data->codec, WM8903_GPIO_CONTROL_3, 0x0033); /* GPIO3 configure: EN_SPK*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_SPK_MIX_LEFT_0, 0x0008); /* DACR_TO_MIXSPK Enable*/
			snd_soc_write(audio_data->codec, WM8903_ANALOGUE_SPK_MIX_RIGHT_0, 0x0004); /* DACL_TO_MIXSPK Enable*/
		}
		else {
			/*tegra_spk_func = TEGRA_SPK_OFF;*/
			printk("Routing to unknown output\n");
			need_spk = false;
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_4, 0x0000); /* MIXSPK Disable*/
			snd_soc_write(audio_data->codec, WM8903_POWER_MANAGEMENT_5, 0x0000); /* SPK Disable*/
			snd_soc_write(audio_data->codec, WM8903_GPIO_CONTROL_3, 0x0000); /* Mute the speaker */
		}

		tegra_ext_control(audio_data->codec);
		audio_data->play_device = play_device_new;
	}

	if (capture_device_new != audio_data->capture_device) {
		if (capture_device_new & (TEGRA_AUDIO_DEVICE_IN_BUILTIN_MIC |
					TEGRA_AUDIO_DEVICE_IN_MIC |
					TEGRA_AUDIO_DEVICE_IN_BACK_MIC)) {
			if ((tegra_jack_func != TEGRA_HP) &&
				(tegra_jack_func != TEGRA_HEADSET)) {
				/*tegra_jack_func = TEGRA_MIC;*/
			}
		}
		else if (capture_device_new & TEGRA_AUDIO_DEVICE_IN_HEADSET) {
			/*tegra_jack_func = TEGRA_HEADSET;*/
		}
		else if (capture_device_new & TEGRA_AUDIO_DEVICE_IN_LINE) {
			/*tegra_jack_func = TEGRA_LINE;*/
		}
		tegra_ext_control(audio_data->codec);
		audio_data->capture_device = capture_device_new;
	}

	if ((is_call_mode_new != audio_data->is_call_mode) ||
		(is_bt_sco_mode != was_bt_sco_mode)) {
		if (is_call_mode_new && is_bt_sco_mode) {
			tegra_das_set_connection
				(tegra_das_port_con_id_voicecall_with_bt);
		}
		else if (is_call_mode_new && !is_bt_sco_mode) {
			tegra_das_set_connection
				(tegra_das_port_con_id_voicecall_no_bt);
		}
		else if (!is_call_mode_new && is_bt_sco_mode) {
			tegra_das_set_connection
				(tegra_das_port_con_id_bt_codec);
		}
		else {
			tegra_das_set_connection
				(tegra_das_port_con_id_hifi);
		}
		audio_data->is_call_mode = is_call_mode_new;
	}
}