CHROMIUM: ALSA: hda/ca0132 - configure DMIC gain block.
authorChee Kin Cheong <chee_kin@ctl.creative.com>
Wed, 23 Jan 2013 12:44:28 +0000 (04:44 -0800)
committerChromeBot <chrome-bot@google.com>
Thu, 24 Jan 2013 20:55:53 +0000 (12:55 -0800)
Configure the DMIC input gain block when switching to use DMIC.  This
provides 20dB of additional input gain when using the built-in digital
microphone.

This should be changed to export a control to user-space, but keep it
simple for the R25 release.

BUG=chrome-os-partner:16865
TEST=arecord a reference signal and check that there is now 20dB of
gain applied.  Hangout and check that the participant on the other
side can hear you.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: I2a748f5774e50e513b1107fc3119641aa227453b
Reviewed-on: https://gerrit.chromium.org/gerrit/41816
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
sound/pci/hda/patch_ca0132.c

index 81a6553..54f4431 100644 (file)
@@ -4071,6 +4071,18 @@ static void refresh_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir)
        snd_hda_override_amp_caps(codec, nid, dir, caps);
 }
 
+static void ca0132_set_dmic_gain(struct hda_codec *codec, unsigned int gain)
+{
+       unsigned int mic_gain_reg;
+       chipio_read(codec, 0x18B098, &mic_gain_reg);
+       mic_gain_reg = (mic_gain_reg & ~0x1F) | gain;
+       chipio_write(codec, 0x18B098, mic_gain_reg);
+
+       chipio_read(codec, 0x18B09C, &mic_gain_reg);
+       mic_gain_reg = (mic_gain_reg & ~0x1F) | gain;
+       chipio_write(codec, 0x18B09C, mic_gain_reg);
+}
+
 static void ca0132_set_dmic(struct hda_codec *codec, int enable)
 {
        struct ca0132_spec *spec = codec->spec;
@@ -4094,6 +4106,8 @@ static void ca0132_set_dmic(struct hda_codec *codec, int enable)
 
                if (!(spec->dmic_ctl & 0x20))
                        chipio_set_control_flag(codec, CONTROL_FLAG_DMIC, 1);
+
+               ca0132_set_dmic_gain(codec, 0x14);
        } else {
                /* set AMic input as mono */
                tmp = FLOAT_ONE;
@@ -4107,6 +4121,8 @@ static void ca0132_set_dmic(struct hda_codec *codec, int enable)
 
                if (!(spec->dmic_ctl & 0x20))
                        chipio_set_control_flag(codec, CONTROL_FLAG_DMIC, 0);
+
+               ca0132_set_dmic_gain(codec, 0x0);
        }
        ca0132_set_vipsource(codec, 1);
        resume_mic1(codec, oldval);