Merge branch 'for-2.6.38' into for-2.6.39
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 1 Mar 2011 23:29:04 +0000 (23:29 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 1 Mar 2011 23:29:04 +0000 (23:29 +0000)
1  2 
sound/soc/codecs/wm8994.c
sound/soc/codecs/wm9081.c

index 0dc14115f109675e61aadba2471c9bf0968c8a1f,4afbe3b2e443689c22e920874b67eb0d17879805..b17ac1971b0d6b57c55a656b301575f5662ef8bd
@@@ -102,16 -102,20 +102,19 @@@ struct wm8994_priv 
  
        wm8958_micdet_cb jack_cb;
        void *jack_cb_data;
 -      bool jack_is_mic;
 -      bool jack_is_video;
 +      int micdet_irq;
  
        int revision;
        struct wm8994_pdata *pdata;
  
        unsigned int aif1clk_enable:1;
        unsigned int aif2clk_enable:1;
+       unsigned int aif1clk_disable:1;
+       unsigned int aif2clk_disable:1;
  };
  
 -static int wm8994_readable(unsigned int reg)
 +static int wm8994_readable(struct snd_soc_codec *codec, unsigned int reg)
  {
        switch (reg) {
        case WM8994_GPIO_1:
        return wm8994_access_masks[reg].readable != 0;
  }
  
 -static int wm8994_volatile(unsigned int reg)
 +static int wm8994_volatile(struct snd_soc_codec *codec, unsigned int reg)
  {
        if (reg >= WM8994_CACHE_SIZE)
                return 1;
@@@ -166,7 -170,7 +169,7 @@@ static int wm8994_write(struct snd_soc_
  
        BUG_ON(reg > WM8994_MAX_REGISTER);
  
 -      if (!wm8994_volatile(reg)) {
 +      if (!wm8994_volatile(codec, reg)) {
                ret = snd_soc_cache_write(codec, reg, value);
                if (ret != 0)
                        dev_err(codec->dev, "Cache write to %x failed: %d\n",
@@@ -184,7 -188,7 +187,7 @@@ static unsigned int wm8994_read(struct 
  
        BUG_ON(reg > WM8994_MAX_REGISTER);
  
 -      if (!wm8994_volatile(reg) && wm8994_readable(reg) &&
 +      if (!wm8994_volatile(codec, reg) && wm8994_readable(codec, reg) &&
            reg < codec->driver->reg_cache_size) {
                ret = snd_soc_cache_read(codec, reg, &val);
                if (ret >= 0)
@@@ -525,7 -529,7 +528,7 @@@ static int wm8994_get_retune_mobile_enu
                                         struct snd_ctl_elem_value *ucontrol)
  {
        struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
 -      struct wm8994_priv *wm8994 =snd_soc_codec_get_drvdata(codec);
 +      struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        int block = wm8994_get_retune_mobile_block(kcontrol->id.name);
  
        ucontrol->value.enumerated.item[0] = wm8994->retune_mobile_cfg[block];
@@@ -1014,14 -1018,18 +1017,18 @@@ static int late_enable_ev(struct snd_so
  
        switch (event) {
        case SND_SOC_DAPM_PRE_PMU:
-               if (wm8994->aif1clk_enable)
+               if (wm8994->aif1clk_enable) {
                        snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
                                            WM8994_AIF1CLK_ENA_MASK,
                                            WM8994_AIF1CLK_ENA);
-               if (wm8994->aif2clk_enable)
+                       wm8994->aif1clk_enable = 0;
+               }
+               if (wm8994->aif2clk_enable) {
                        snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
                                            WM8994_AIF2CLK_ENA_MASK,
                                            WM8994_AIF2CLK_ENA);
+                       wm8994->aif2clk_enable = 0;
+               }
                break;
        }
  
@@@ -1036,15 -1044,15 +1043,15 @@@ static int late_disable_ev(struct snd_s
  
        switch (event) {
        case SND_SOC_DAPM_POST_PMD:
-               if (wm8994->aif1clk_enable) {
+               if (wm8994->aif1clk_disable) {
                        snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
                                            WM8994_AIF1CLK_ENA_MASK, 0);
-                       wm8994->aif1clk_enable = 0;
+                       wm8994->aif1clk_disable = 0;
                }
-               if (wm8994->aif2clk_enable) {
+               if (wm8994->aif2clk_disable) {
                        snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1,
                                            WM8994_AIF2CLK_ENA_MASK, 0);
-                       wm8994->aif2clk_enable = 0;
+                       wm8994->aif2clk_disable = 0;
                }
                break;
        }
@@@ -1062,6 -1070,9 +1069,9 @@@ static int aif1clk_ev(struct snd_soc_da
        case SND_SOC_DAPM_PRE_PMU:
                wm8994->aif1clk_enable = 1;
                break;
+       case SND_SOC_DAPM_POST_PMD:
+               wm8994->aif1clk_disable = 1;
+               break;
        }
  
        return 0;
@@@ -1077,11 -1088,21 +1087,21 @@@ static int aif2clk_ev(struct snd_soc_da
        case SND_SOC_DAPM_PRE_PMU:
                wm8994->aif2clk_enable = 1;
                break;
+       case SND_SOC_DAPM_POST_PMD:
+               wm8994->aif2clk_disable = 1;
+               break;
        }
  
        return 0;
  }
  
+ static int adc_mux_ev(struct snd_soc_dapm_widget *w,
+                     struct snd_kcontrol *kcontrol, int event)
+ {
+       late_enable_ev(w, kcontrol, event);
+       return 0;
+ }
  static int dac_ev(struct snd_soc_dapm_widget *w,
                  struct snd_kcontrol *kcontrol, int event)
  {
@@@ -1402,6 -1423,18 +1422,18 @@@ SND_SOC_DAPM_DAC("DAC1L", NULL, WM8994_
  SND_SOC_DAPM_DAC("DAC1R", NULL, WM8994_POWER_MANAGEMENT_5, 0, 0),
  };
  
+ static const struct snd_soc_dapm_widget wm8994_adc_revd_widgets[] = {
+ SND_SOC_DAPM_MUX_E("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux,
+                  adc_mux_ev, SND_SOC_DAPM_PRE_PMU),
+ SND_SOC_DAPM_MUX_E("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux,
+                  adc_mux_ev, SND_SOC_DAPM_PRE_PMU),
+ };
+ static const struct snd_soc_dapm_widget wm8994_adc_widgets[] = {
+ SND_SOC_DAPM_MUX("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux),
+ SND_SOC_DAPM_MUX("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux),
+ };
  static const struct snd_soc_dapm_widget wm8994_dapm_widgets[] = {
  SND_SOC_DAPM_INPUT("DMIC1DAT"),
  SND_SOC_DAPM_INPUT("DMIC2DAT"),
@@@ -1496,9 -1529,6 +1528,6 @@@ SND_SOC_DAPM_ADC("DMIC1R", NULL, WM8994
  SND_SOC_DAPM_ADC("ADCL", NULL, SND_SOC_NOPM, 1, 0),
  SND_SOC_DAPM_ADC("ADCR", NULL, SND_SOC_NOPM, 0, 0),
  
- SND_SOC_DAPM_MUX("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux),
- SND_SOC_DAPM_MUX("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux),
  SND_SOC_DAPM_MUX("Left Headphone Mux", SND_SOC_NOPM, 0, 0, &hpl_mux),
  SND_SOC_DAPM_MUX("Right Headphone Mux", SND_SOC_NOPM, 0, 0, &hpr_mux),
  
@@@ -2853,13 -2883,6 +2882,13 @@@ static void wm8994_handle_pdata(struct 
        else
                snd_soc_add_controls(wm8994->codec, wm8994_eq_controls,
                                     ARRAY_SIZE(wm8994_eq_controls));
 +
 +      for (i = 0; i < ARRAY_SIZE(pdata->micbias); i++) {
 +              if (pdata->micbias[i]) {
 +                      snd_soc_write(codec, WM8958_MICBIAS1 + i,
 +                              pdata->micbias[i] & 0xffff);
 +              }
 +      }
  }
  
  /**
@@@ -2970,18 -2993,46 +2999,18 @@@ static void wm8958_default_micdet(u16 s
        int report = 0;
  
        /* If nothing present then clear our statuses */
 -      if (!(status & WM8958_MICD_STS)) {
 -              wm8994->jack_is_video = false;
 -              wm8994->jack_is_mic = false;
 +      if (!(status & WM8958_MICD_STS))
                goto done;
 -      }
 -
 -      /* Assume anything over 475 ohms is a microphone and remember
 -       * that we've seen one (since buttons override it) */
 -      if (status & 0x600)
 -              wm8994->jack_is_mic = true;
 -      if (wm8994->jack_is_mic)
 -              report |= SND_JACK_MICROPHONE;
  
 -      /* Video has an impedence of approximately 75 ohms; assume
 -       * this isn't used as a button and remember it since buttons
 -       * override it. */
 -      if (status & 0x40)
 -              wm8994->jack_is_video = true;
 -      if (wm8994->jack_is_video)
 -              report |= SND_JACK_VIDEOOUT;
 +      report = SND_JACK_MICROPHONE;
  
        /* Everything else is buttons; just assign slots */
 -      if (status & 0x4)
 +      if (status & 0x1c0)
                report |= SND_JACK_BTN_0;
 -      if (status & 0x8)
 -              report |= SND_JACK_BTN_1;
 -      if (status & 0x10)
 -              report |= SND_JACK_BTN_2;
 -      if (status & 0x20)
 -              report |= SND_JACK_BTN_3;
 -      if (status & 0x80)
 -              report |= SND_JACK_BTN_4;
 -      if (status & 0x100)
 -              report |= SND_JACK_BTN_5;
  
  done:
        snd_soc_jack_report(wm8994->micdet[0].jack, report,
 -                          SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 |
 -                          SND_JACK_BTN_3 | SND_JACK_BTN_4 | SND_JACK_BTN_5 |
 -                          SND_JACK_MICROPHONE | SND_JACK_VIDEOOUT);
 +                          SND_JACK_BTN_0 | SND_JACK_MICROPHONE);
  }
  
  /**
@@@ -3080,19 -3131,13 +3109,19 @@@ static int wm8994_codec_probe(struct sn
        wm8994->pdata = dev_get_platdata(codec->dev->parent);
        wm8994->codec = codec;
  
 +      if (wm8994->pdata && wm8994->pdata->micdet_irq)
 +              wm8994->micdet_irq = wm8994->pdata->micdet_irq;
 +      else if (wm8994->pdata && wm8994->pdata->irq_base)
 +              wm8994->micdet_irq = wm8994->pdata->irq_base +
 +                                   WM8994_IRQ_MIC1_DET;
 +
        pm_runtime_enable(codec->dev);
        pm_runtime_resume(codec->dev);
  
        /* Read our current status back from the chip - we don't want to
         * reset as this may interfere with the GPIO or LDO operation. */
        for (i = 0; i < WM8994_CACHE_SIZE; i++) {
 -              if (!wm8994_readable(i) || wm8994_volatile(i))
 +              if (!wm8994_readable(codec, i) || wm8994_volatile(codec, i))
                        continue;
  
                ret = wm8994_reg_read(codec->control_data, i);
  
        switch (control->type) {
        case WM8994:
 -              ret = wm8994_request_irq(codec->control_data,
 -                                       WM8994_IRQ_MIC1_DET,
 -                                       wm8994_mic_irq, "Mic 1 detect",
 -                                       wm8994);
 -              if (ret != 0)
 -                      dev_warn(codec->dev,
 -                               "Failed to request Mic1 detect IRQ: %d\n",
 -                               ret);
 +              if (wm8994->micdet_irq) {
 +                      ret = request_threaded_irq(wm8994->micdet_irq, NULL,
 +                                                 wm8994_mic_irq,
 +                                                 IRQF_TRIGGER_RISING,
 +                                                 "Mic1 detect",
 +                                                 wm8994);
 +                      if (ret != 0)
 +                              dev_warn(codec->dev,
 +                                       "Failed to request Mic1 detect IRQ: %d\n",
 +                                       ret);
 +              }
  
                ret = wm8994_request_irq(codec->control_data,
                                         WM8994_IRQ_MIC1_SHRT,
                break;
  
        case WM8958:
 -              ret = wm8994_request_irq(codec->control_data,
 -                                       WM8994_IRQ_MIC1_DET,
 -                                       wm8958_mic_irq, "Mic detect",
 -                                       wm8994);
 -              if (ret != 0)
 -                      dev_warn(codec->dev,
 -                               "Failed to request Mic detect IRQ: %d\n",
 -                               ret);
 -              break;
 +              if (wm8994->micdet_irq) {
 +                      ret = request_threaded_irq(wm8994->micdet_irq, NULL,
 +                                                 wm8958_mic_irq,
 +                                                 IRQF_TRIGGER_RISING,
 +                                                 "Mic detect",
 +                                                 wm8994);
 +                      if (ret != 0)
 +                              dev_warn(codec->dev,
 +                                       "Failed to request Mic detect IRQ: %d\n",
 +                                       ret);
 +              }
        }
  
        /* Remember if AIFnLRCLK is configured as a GPIO.  This should be
                if (wm8994->revision < 4) {
                        snd_soc_dapm_new_controls(dapm, wm8994_lateclk_revd_widgets,
                                                  ARRAY_SIZE(wm8994_lateclk_revd_widgets));
+                       snd_soc_dapm_new_controls(dapm, wm8994_adc_revd_widgets,
+                                                 ARRAY_SIZE(wm8994_adc_revd_widgets));
                        snd_soc_dapm_new_controls(dapm, wm8994_dac_revd_widgets,
                                                  ARRAY_SIZE(wm8994_dac_revd_widgets));
                } else {
                        snd_soc_dapm_new_controls(dapm, wm8994_lateclk_widgets,
                                                  ARRAY_SIZE(wm8994_lateclk_widgets));
+                       snd_soc_dapm_new_controls(dapm, wm8994_adc_widgets,
+                                                 ARRAY_SIZE(wm8994_adc_widgets));
                        snd_soc_dapm_new_controls(dapm, wm8994_dac_widgets,
                                                  ARRAY_SIZE(wm8994_dac_widgets));
                }
@@@ -3317,8 -3361,7 +3350,8 @@@ err_irq
        wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT, wm8994);
        wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET, wm8994);
        wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT, wm8994);
 -      wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_DET, wm8994);
 +      if (wm8994->micdet_irq)
 +              free_irq(wm8994->micdet_irq, wm8994);
  err:
        kfree(wm8994);
        return ret;
@@@ -3335,8 -3378,8 +3368,8 @@@ static int  wm8994_codec_remove(struct 
  
        switch (control->type) {
        case WM8994:
 -              wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT,
 -                              wm8994);
 +              if (wm8994->micdet_irq)
 +                      free_irq(wm8994->micdet_irq, wm8994);
                wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET,
                                wm8994);
                wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT,
                break;
  
        case WM8958:
 -              wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_DET,
 -                              wm8994);
 +              if (wm8994->micdet_irq)
 +                      free_irq(wm8994->micdet_irq, wm8994);
                break;
        }
        kfree(wm8994->retune_mobile_texts);
index b62e98942cf833c791f96731129645f2cf209426,cce704c275c61df460d7056c6beca250e530525f..2103623a07767a95b4d899a437e866ee5a3839b3
@@@ -15,6 -15,7 +15,7 @@@
  #include <linux/moduleparam.h>
  #include <linux/init.h>
  #include <linux/delay.h>
+ #include <linux/device.h>
  #include <linux/pm.h>
  #include <linux/i2c.h>
  #include <linux/platform_device.h>
@@@ -169,7 -170,7 +170,7 @@@ struct wm9081_priv 
        struct wm9081_retune_mobile_config *retune;
  };
  
 -static int wm9081_volatile_register(unsigned int reg)
 +static int wm9081_volatile_register(struct snd_soc_codec *codec, unsigned int reg)
  {
        switch (reg) {
        case WM9081_SOFTWARE_RESET:
@@@ -1341,6 -1342,10 +1342,10 @@@ static __devinit int wm9081_i2c_probe(s
        wm9081->control_type = SND_SOC_I2C;
        wm9081->control_data = i2c;
  
+       if (dev_get_platdata(&i2c->dev))
+               memcpy(&wm9081->retune, dev_get_platdata(&i2c->dev),
+                      sizeof(wm9081->retune));
        ret = snd_soc_register_codec(&i2c->dev,
                        &soc_codec_dev_wm9081, &wm9081_dai, 1);
        if (ret < 0)
@@@ -1363,7 -1368,7 +1368,7 @@@ MODULE_DEVICE_TABLE(i2c, wm9081_i2c_id)
  
  static struct i2c_driver wm9081_i2c_driver = {
        .driver = {
 -              .name = "wm9081-codec",
 +              .name = "wm9081",
                .owner = THIS_MODULE,
        },
        .probe =    wm9081_i2c_probe,