Merge remote-tracking branch 'asoc/topic/da9055' into asoc-next
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 9 Dec 2012 15:22:06 +0000 (00:22 +0900)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 9 Dec 2012 15:22:06 +0000 (00:22 +0900)
1  2 
sound/soc/codecs/da9055.c

  #define DA9055_AIF_FORMAT_I2S_MODE    (0 << 0)
  #define DA9055_AIF_FORMAT_LEFT_J      (1 << 0)
  #define DA9055_AIF_FORMAT_RIGHT_J     (2 << 0)
+ #define DA9055_AIF_FORMAT_DSP         (3 << 0)
  #define DA9055_AIF_WORD_S16_LE                (0 << 2)
  #define DA9055_AIF_WORD_S20_3LE               (1 << 2)
  #define DA9055_AIF_WORD_S24_LE                (2 << 2)
  #define DA9055_AIF_WORD_S32_LE                (3 << 2)
  
 +/* MIC_L_CTRL bit fields */
 +#define DA9055_MIC_L_MUTE_EN          (1 << 6)
 +
 +/* MIC_R_CTRL bit fields */
 +#define DA9055_MIC_R_MUTE_EN          (1 << 6)
 +
  /* MIXIN_L_CTRL bit fields */
  #define DA9055_MIXIN_L_MIX_EN         (1 << 3)
  
@@@ -482,7 -477,7 +483,7 @@@ static int da9055_put_alc_sw(struct snd
                             struct snd_ctl_elem_value *ucontrol)
  {
        struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
 -      u8 reg_val, adc_left, adc_right;
 +      u8 reg_val, adc_left, adc_right, mic_left, mic_right;
        int avg_left_data, avg_right_data, offset_l, offset_r;
  
        if (ucontrol->value.integer.value[0]) {
                 * offsets must be done first
                 */
  
 +              /* Save current values from Mic control registers */
 +              mic_left = snd_soc_read(codec, DA9055_MIC_L_CTRL);
 +              mic_right = snd_soc_read(codec, DA9055_MIC_R_CTRL);
 +
 +              /* Mute Mic PGA Left and Right */
 +              snd_soc_update_bits(codec, DA9055_MIC_L_CTRL,
 +                                  DA9055_MIC_L_MUTE_EN, DA9055_MIC_L_MUTE_EN);
 +              snd_soc_update_bits(codec, DA9055_MIC_R_CTRL,
 +                                  DA9055_MIC_R_MUTE_EN, DA9055_MIC_R_MUTE_EN);
 +
                /* Save current values from ADC control registers */
                adc_left = snd_soc_read(codec, DA9055_ADC_L_CTRL);
                adc_right = snd_soc_read(codec, DA9055_ADC_R_CTRL);
                /* Restore original values of ADC control registers */
                snd_soc_write(codec, DA9055_ADC_L_CTRL, adc_left);
                snd_soc_write(codec, DA9055_ADC_R_CTRL, adc_right);
 +
 +              /* Restore original values of Mic control registers */
 +              snd_soc_write(codec, DA9055_MIC_L_CTRL, mic_left);
 +              snd_soc_write(codec, DA9055_MIC_R_CTRL, mic_right);
        }
  
        return snd_soc_put_volsw(kcontrol, ucontrol);
@@@ -752,6 -733,17 +753,17 @@@ static const struct snd_kcontrol_new da
                        6, 1, 0),
  };
  
+ /* Headphone Output Enable */
+ static const struct snd_kcontrol_new da9055_dapm_hp_l_control =
+ SOC_DAPM_SINGLE("Switch", DA9055_HP_L_CTRL, 3, 1, 0);
+ static const struct snd_kcontrol_new da9055_dapm_hp_r_control =
+ SOC_DAPM_SINGLE("Switch", DA9055_HP_R_CTRL, 3, 1, 0);
+ /* Lineout Output Enable */
+ static const struct snd_kcontrol_new da9055_dapm_lineout_control =
+ SOC_DAPM_SINGLE("Switch", DA9055_LINE_CTRL, 3, 1, 0);
  /* DAPM widgets */
  static const struct snd_soc_dapm_widget da9055_dapm_widgets[] = {
        /* Input Side */
                           &da9055_dapm_mixoutr_controls[0],
                           ARRAY_SIZE(da9055_dapm_mixoutr_controls)),
  
+       /* Output Enable Switches */
+       SND_SOC_DAPM_SWITCH("Headphone Left Enable", SND_SOC_NOPM, 0, 0,
+                           &da9055_dapm_hp_l_control),
+       SND_SOC_DAPM_SWITCH("Headphone Right Enable", SND_SOC_NOPM, 0, 0,
+                           &da9055_dapm_hp_r_control),
+       SND_SOC_DAPM_SWITCH("Lineout Enable", SND_SOC_NOPM, 0, 0,
+                           &da9055_dapm_lineout_control),
        /* Output PGAs */
        SND_SOC_DAPM_PGA("MIXOUT Left", DA9055_MIXOUT_L_CTRL, 7, 0, NULL, 0),
        SND_SOC_DAPM_PGA("MIXOUT Right", DA9055_MIXOUT_R_CTRL, 7, 0, NULL, 0),
@@@ -901,17 -901,20 +921,20 @@@ static const struct snd_soc_dapm_route 
        {"Out Mixer Right", "DAC Right Switch", "DAC Right"},
  
        {"MIXOUT Left", NULL, "Out Mixer Left"},
-       {"Headphone Left", NULL, "MIXOUT Left"},
+       {"Headphone Left Enable", "Switch", "MIXOUT Left"},
+       {"Headphone Left", NULL, "Headphone Left Enable"},
        {"Headphone Left", NULL, "Charge Pump"},
        {"HPL", NULL, "Headphone Left"},
  
        {"MIXOUT Right", NULL, "Out Mixer Right"},
-       {"Headphone Right", NULL, "MIXOUT Right"},
+       {"Headphone Right Enable", "Switch", "MIXOUT Right"},
+       {"Headphone Right", NULL, "Headphone Right Enable"},
        {"Headphone Right", NULL, "Charge Pump"},
        {"HPR", NULL, "Headphone Right"},
  
        {"MIXOUT Right", NULL, "Out Mixer Right"},
-       {"Lineout", NULL, "MIXOUT Right"},
+       {"Lineout Enable", "Switch", "MIXOUT Right"},
+       {"Lineout", NULL, "Lineout Enable"},
        {"LINE", NULL, "Lineout"},
  };
  
@@@ -1175,6 -1178,9 +1198,9 @@@ static int da9055_set_dai_fmt(struct sn
        case SND_SOC_DAIFMT_RIGHT_J:
                aif_ctrl = DA9055_AIF_FORMAT_RIGHT_J;
                break;
+       case SND_SOC_DAIFMT_DSP_A:
+               aif_ctrl = DA9055_AIF_FORMAT_DSP;
+               break;
        default:
                return -EINVAL;
        }
@@@ -1390,8 -1396,7 +1416,7 @@@ static int da9055_probe(struct snd_soc_
                            DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
  
        /*
-        * There are two separate control bits for input and output mixers as
-        * well as headphone and line outs.
+        * There are two separate control bits for input and output mixers.
         * One to enable corresponding amplifier and other to enable its
         * output. As amplifier bits are related to power control, they are
         * being managed by DAPM while other (non power related) bits are
        snd_soc_update_bits(codec, DA9055_MIXOUT_R_CTRL,
                            DA9055_MIXOUT_R_MIX_EN, DA9055_MIXOUT_R_MIX_EN);
  
-       snd_soc_update_bits(codec, DA9055_HP_L_CTRL,
-                           DA9055_HP_L_AMP_OE, DA9055_HP_L_AMP_OE);
-       snd_soc_update_bits(codec, DA9055_HP_R_CTRL,
-                           DA9055_HP_R_AMP_OE, DA9055_HP_R_AMP_OE);
-       snd_soc_update_bits(codec, DA9055_LINE_CTRL,
-                           DA9055_LINE_AMP_OE, DA9055_LINE_AMP_OE);
        /* Set this as per your system configuration */
        snd_soc_write(codec, DA9055_PLL_CTRL, DA9055_PLL_INDIV_10_20_MHZ);