From 9be5c3c72eef6b1f04f0a81ce4b58294d86c8de1 Mon Sep 17 00:00:00 2001 From: namarta Date: Tue, 3 Apr 2012 14:02:23 +0530 Subject: Audio: Add control to enable/disable the loudspeaker amplifier whenever speaker trun ON/OFF. BZ: 26047 IHF speaker buzzing noise caused by loudspeaker amplifier being active all the time. Loudspeaker amplifier is enabled when audio played to loudspeaker and disabled when audio not played to loudspeaker. Change-Id: Icd3f7a74e40ccf33395562609b0d81a6e7e224d5 Signed-off-by: namarta Reviewed-on: http://android.intel.com:8080/38133 Reviewed-by: Kp, Jeeja Reviewed-by: Koul, Vinod Reviewed-by: Gupta, ArvindX K Reviewed-by: Noziska, PatrickX J Reviewed-by: Hibare, PramodX Tested-by: Hibare, PramodX Reviewed-by: buildbot Tested-by: buildbot --- sound/soc/mid-x86/clv_machine.c | 43 ++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/mid-x86/clv_machine.c b/sound/soc/mid-x86/clv_machine.c index ca9c80c404a..5c479e0c127 100644 --- a/sound/soc/mid-x86/clv_machine.c +++ b/sound/soc/mid-x86/clv_machine.c @@ -44,6 +44,9 @@ #define C42L73_DEFAULT_MCLK 19200000 #define CS42L73_HPSENSE_GPIO 34 #define CS42L73_BUTTON_GPIO 32 +#define GPIO_AMP_ON 0x3d +#define GPIO_AMP_OFF 0x0 +#define GPIOHVCTL 0x70 static unsigned int vsp_mode; @@ -295,11 +298,33 @@ undo: return ret; } + +static int clv_amp_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + int ret; + + if (SND_SOC_DAPM_EVENT_ON(event)) { + /*Enable IHFAMP_SD_N GPIO */ + ret = intel_scu_ipc_iowrite8(GPIOHVCTL, GPIO_AMP_ON); + if (ret) + pr_err("write of failed, err %d\n", ret); + } else { + /*Disable IHFAMP_SD_N GPIO */ + ret = intel_scu_ipc_iowrite8(GPIOHVCTL, GPIO_AMP_OFF); + if (ret) + pr_err("write of failed, err %d\n", ret); + } + return 0; +} + + /* CDB42L73 widgets */ static const struct snd_soc_dapm_widget clv_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_SPK("Ext Spk", clv_amp_event), }; /* CDB42L73 Audio Map */ @@ -309,9 +334,10 @@ static const struct snd_soc_dapm_route clv_audio_map[] = { /* Headphone (L+R)-> HPOUTA, HPOUTB */ {"Headphone", NULL, "HPOUTA"}, {"Headphone", NULL, "HPOUTB"}, + {"Ext Spk", NULL, "SPKLINEOUT"}, + {"Ext Spk", NULL, "SPKOUT"}, }; - /* Board specific codec bias level control */ static int clv_set_bias_level(struct snd_soc_card *card, enum snd_soc_bias_level level) @@ -342,10 +368,6 @@ static int clv_init(struct snd_soc_pcm_runtime *runtime) int ret; struct snd_soc_card *card = runtime->card; - /*Enable IHFAMP_SD_N GPIO */ - ret = intel_scu_ipc_iowrite8(0x70, 0x3d); - if (ret) - pr_err("write of failed, err %d\n", ret); /* Set codec bias level */ clv_set_bias_level(card, SND_SOC_BIAS_OFF); @@ -359,13 +381,16 @@ static int clv_init(struct snd_soc_pcm_runtime *runtime) /* Set up Jack specific audio path audio_map */ snd_soc_dapm_add_routes(dapm, clv_audio_map, - ARRAY_SIZE(clv_audio_map)); - + ARRAY_SIZE(clv_audio_map)); + /*In VV board SPKOUT is connected and SPKLINEOUT on PR board*/ /*In VV board MIC1 is connected and MIC2 is PR boards */ - if (ctp_board_id() == CTP_BID_VV) + if (ctp_board_id() == CTP_BID_VV) { snd_soc_dapm_disable_pin(dapm, "MIC1"); - else + snd_soc_dapm_disable_pin(dapm, "SPKOUT"); + } else { snd_soc_dapm_disable_pin(dapm, "MIC2"); + snd_soc_dapm_disable_pin(dapm, "SPKLINEOUT"); + } mutex_lock(&codec->mutex); snd_soc_dapm_sync(dapm); mutex_unlock(&codec->mutex); -- cgit v1.2.3