[ARM] mfd: cpcap-audio: disable unused audio hardware
authorChris Fries <C.Fries@motorola.com>
Thu, 21 Oct 2010 04:20:49 +0000 (23:20 -0500)
committerIliyan Malchev <malchev@google.com>
Fri, 22 Oct 2010 19:56:23 +0000 (12:56 -0700)
Disable unused audio hardware, and decouple the STDAC and CODEC states.

- While controlling output, don't touch CODEC state/mute
- While controlling input, don't touch STDAC state/mute
- Don't enable external input gains, it's not connected.

Signed-off-by: Iliyan Malchev <malchev@google.com>
drivers/mfd/cpcap-audio-core.c
drivers/mfd/tegra-cpcap-audio.c

index 8393fdda2da607aeb597f4dc795a490fba73bca3..c3027cdef21e4e84a7ef282e8042bc5de8c006e9 100644 (file)
@@ -787,9 +787,9 @@ static void cpcap_audio_configure_output_gains(
                unsigned int temp_output_gain = state->output_gain & 0x0000000F;
 
                reg_changes.value |=
-                   ((temp_output_gain << 2) | (temp_output_gain << 8) |
-                    (temp_output_gain << 12));
-
+                   ((temp_output_gain << 2) | (temp_output_gain << 8));
+               /* VOL_EXTx is disabled, it's not connected, disable to reduce noise. */
+               /* If you need it, add | (temp_output_gain << 12) */
                reg_changes.mask = 0xFF3C;
 
                logged_cpcap_write(state->cpcap, CPCAP_REG_RXVC,
index ba150ad40131bb6f9c981c92b95e5fe8ab070079..77249dc083d8e1f65d1d37a2d4b729bc9c33a332 100644 (file)
@@ -62,12 +62,8 @@ static void tegra_setup_audio_output_off(void)
        gpio_direction_output(pdata->speaker_gpio, 0);
        gpio_direction_output(pdata->headset_gpio, 0);
 
-       if (!current_input.on) {
-               pdata->state->codec_mute = CPCAP_AUDIO_CODEC_MUTE;
-               pdata->state->stdac_mute = CPCAP_AUDIO_STDAC_MUTE;
-               pdata->state->codec_mode = CPCAP_AUDIO_CODEC_OFF;
-               pdata->state->stdac_mode = CPCAP_AUDIO_STDAC_OFF;
-       }
+       pdata->state->stdac_mute = CPCAP_AUDIO_STDAC_MUTE;
+       pdata->state->stdac_mode = CPCAP_AUDIO_STDAC_OFF;
 
        pdata->state->stdac_primary_speaker = CPCAP_AUDIO_OUT_NONE;
        pdata->state->stdac_secondary_speaker = CPCAP_AUDIO_OUT_NONE;
@@ -80,10 +76,10 @@ static void tegra_setup_audio_out_speaker_on(void)
        gpio_direction_output(pdata->speaker_gpio, 0);
        gpio_direction_output(pdata->headset_gpio, 0);
 
-       pdata->state->codec_mode = CPCAP_AUDIO_CODEC_ON;
        pdata->state->stdac_mode = CPCAP_AUDIO_STDAC_ON;
-       pdata->state->stdac_primary_speaker = CPCAP_AUDIO_OUT_LOUDSPEAKER;
-       pdata->state->stdac_secondary_speaker = CPCAP_AUDIO_OUT_LINEOUT;
+       /* Using an external amp, lineout is the loudspeaker. */
+       pdata->state->stdac_primary_speaker = CPCAP_AUDIO_OUT_LINEOUT;
+       pdata->state->stdac_secondary_speaker = CPCAP_AUDIO_OUT_NONE;
        cpcap_audio_set_audio_state(pdata->state);
 
        /* turn on the amplifier */
@@ -97,10 +93,9 @@ static void tegra_setup_audio_out_headset_on(void)
        gpio_direction_output(pdata->speaker_gpio, 0);
        gpio_direction_output(pdata->headset_gpio, 0);
 
-       pdata->state->codec_mode = CPCAP_AUDIO_CODEC_ON;
        pdata->state->stdac_mode = CPCAP_AUDIO_STDAC_ON;
        pdata->state->stdac_primary_speaker = CPCAP_AUDIO_OUT_STEREO_HEADSET;
-       pdata->state->stdac_secondary_speaker = CPCAP_AUDIO_OUT_LINEOUT;
+       pdata->state->stdac_secondary_speaker = CPCAP_AUDIO_OUT_NONE;
        cpcap_audio_set_audio_state(pdata->state);
 
        /* turn on the amplifier */
@@ -114,7 +109,6 @@ static void tegra_setup_audio_out_headset_and_speaker_on(void)
        gpio_direction_output(pdata->speaker_gpio, 0);
        gpio_direction_output(pdata->headset_gpio, 0);
 
-       pdata->state->codec_mode = CPCAP_AUDIO_CODEC_ON;
        pdata->state->stdac_mode = CPCAP_AUDIO_STDAC_ON;
        pdata->state->stdac_primary_speaker = CPCAP_AUDIO_OUT_STEREO_HEADSET;
        pdata->state->stdac_secondary_speaker = CPCAP_AUDIO_OUT_LINEOUT;
@@ -127,12 +121,8 @@ static void tegra_setup_audio_out_headset_and_speaker_on(void)
 
 static void tegra_setup_audio_in_mute(void)
 {
-       if (!current_output.on) {
-               pdata->state->codec_mute = CPCAP_AUDIO_CODEC_MUTE;
-               pdata->state->stdac_mute = CPCAP_AUDIO_STDAC_MUTE;
-               pdata->state->codec_mode = CPCAP_AUDIO_CODEC_OFF;
-               pdata->state->stdac_mode = CPCAP_AUDIO_STDAC_OFF;
-       }
+       pdata->state->codec_mute = CPCAP_AUDIO_CODEC_MUTE;
+       pdata->state->codec_mode = CPCAP_AUDIO_CODEC_OFF;
 
        pdata->state->microphone = CPCAP_AUDIO_IN_NONE;
 
@@ -142,9 +132,7 @@ static void tegra_setup_audio_in_mute(void)
 static void tegra_setup_audio_in_handset_on(void)
 {
        pdata->state->codec_mute = CPCAP_AUDIO_CODEC_UNMUTE;
-       pdata->state->stdac_mute = CPCAP_AUDIO_STDAC_UNMUTE;
        pdata->state->codec_mode = CPCAP_AUDIO_CODEC_ON;
-       pdata->state->stdac_mode = CPCAP_AUDIO_STDAC_ON;
 
        pdata->state->microphone = CPCAP_AUDIO_IN_HANDSET;
        cpcap_audio_set_audio_state(pdata->state);
@@ -153,9 +141,7 @@ static void tegra_setup_audio_in_handset_on(void)
 static void tegra_setup_audio_in_headset_on(void)
 {
        pdata->state->codec_mute = CPCAP_AUDIO_CODEC_UNMUTE;
-       pdata->state->stdac_mute = CPCAP_AUDIO_STDAC_UNMUTE;
        pdata->state->codec_mode = CPCAP_AUDIO_CODEC_ON;
-       pdata->state->stdac_mode = CPCAP_AUDIO_STDAC_ON;
 
        pdata->state->microphone = CPCAP_AUDIO_IN_HEADSET;
        cpcap_audio_set_audio_state(pdata->state);