Merge branch 'for-3.5' into for-3.6
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / sound / soc / codecs / tlv320aic3x.c
index e9b62b5ea637580ea7e8904ec2c68662ed1471fc..dc78f5a4bcbf8922bb9690452f4e4e99c0a3ec18 100644 (file)
@@ -118,7 +118,9 @@ static const u8 aic3x_reg[AIC3X_CACHEREGNUM] = {
        0x00, 0x00, 0x00, 0x00, /* 88 */
        0x00, 0x00, 0x00, 0x00, /* 92 */
        0x00, 0x00, 0x00, 0x00, /* 96 */
-       0x00, 0x00, 0x02,       /* 100 */
+       0x00, 0x00, 0x02, 0x00, /* 100 */
+       0x00, 0x00, 0x00, 0x00, /* 104 */
+       0x00, 0x00,             /* 108 */
 };
 
 #define SOC_DAPM_SINGLE_AIC3X(xname, reg, shift, mask, invert) \
@@ -229,6 +231,25 @@ static const struct soc_enum aic3x_enum[] = {
        SOC_ENUM_DOUBLE(AIC3X_CODEC_DFILT_CTRL, 6, 4, 4, aic3x_adc_hpf),
 };
 
+static const char *aic3x_agc_level[] =
+       { "-5.5dB", "-8dB", "-10dB", "-12dB", "-14dB", "-17dB", "-20dB", "-24dB" };
+static const struct soc_enum aic3x_agc_level_enum[] = {
+       SOC_ENUM_SINGLE(LAGC_CTRL_A, 4, 8, aic3x_agc_level),
+       SOC_ENUM_SINGLE(RAGC_CTRL_A, 4, 8, aic3x_agc_level),
+};
+
+static const char *aic3x_agc_attack[] = { "8ms", "11ms", "16ms", "20ms" };
+static const struct soc_enum aic3x_agc_attack_enum[] = {
+       SOC_ENUM_SINGLE(LAGC_CTRL_A, 2, 4, aic3x_agc_attack),
+       SOC_ENUM_SINGLE(RAGC_CTRL_A, 2, 4, aic3x_agc_attack),
+};
+
+static const char *aic3x_agc_decay[] = { "100ms", "200ms", "400ms", "500ms" };
+static const struct soc_enum aic3x_agc_decay_enum[] = {
+       SOC_ENUM_SINGLE(LAGC_CTRL_A, 0, 4, aic3x_agc_decay),
+       SOC_ENUM_SINGLE(RAGC_CTRL_A, 0, 4, aic3x_agc_decay),
+};
+
 /*
  * DAC digital volumes. From -63.5 to 0 dB in 0.5 dB steps
  */
@@ -353,6 +374,15 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = {
         * adjust PGA to max value when ADC is on and will never go back.
        */
        SOC_DOUBLE_R("AGC Switch", LAGC_CTRL_A, RAGC_CTRL_A, 7, 0x01, 0),
+       SOC_ENUM("Left AGC Target level", aic3x_agc_level_enum[0]),
+       SOC_ENUM("Right AGC Target level", aic3x_agc_level_enum[1]),
+       SOC_ENUM("Left AGC Attack time", aic3x_agc_attack_enum[0]),
+       SOC_ENUM("Right AGC Attack time", aic3x_agc_attack_enum[1]),
+       SOC_ENUM("Left AGC Decay time", aic3x_agc_decay_enum[0]),
+       SOC_ENUM("Right AGC Decay time", aic3x_agc_decay_enum[1]),
+
+       /* De-emphasis */
+       SOC_DOUBLE("De-emphasis Switch", AIC3X_CODEC_DFILT_CTRL, 2, 0, 0x01, 0),
 
        /* Input */
        SOC_DOUBLE_R_TLV("PGA Capture Volume", LADC_VOL, RADC_VOL,
@@ -368,7 +398,7 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = {
 static DECLARE_TLV_DB_SCALE(classd_amp_tlv, 0, 600, 0);
 
 static const struct snd_kcontrol_new aic3x_classd_amp_gain_ctrl =
-       SOC_DOUBLE_TLV("Class-D Amplifier Gain", CLASSD_CTRL, 6, 4, 3, 0, classd_amp_tlv);
+       SOC_DOUBLE_TLV("Class-D Playback Volume", CLASSD_CTRL, 6, 4, 3, 0, classd_amp_tlv);
 
 /* Left DAC Mux */
 static const struct snd_kcontrol_new aic3x_left_dac_mux_controls =
@@ -970,6 +1000,12 @@ static int aic3x_set_dai_sysclk(struct snd_soc_dai *codec_dai,
        struct snd_soc_codec *codec = codec_dai->codec;
        struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
 
+       /* set clock on MCLK or GPIO2 or BCLK */
+       snd_soc_update_bits(codec, AIC3X_CLKGEN_CTRL_REG, PLLCLK_IN_MASK,
+                               clk_id << PLLCLK_IN_SHIFT);
+       snd_soc_update_bits(codec, AIC3X_CLKGEN_CTRL_REG, CLKDIV_IN_MASK,
+                               clk_id << CLKDIV_IN_SHIFT);
+
        aic3x->sysclk = freq;
        return 0;
 }