Merge remote-tracking branches 'asoc/topic/adsp' and 'asoc/topic/atmel' into asoc...
authorMark Brown <broonie@kernel.org>
Mon, 22 Jun 2015 09:24:28 +0000 (10:24 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 22 Jun 2015 09:24:28 +0000 (10:24 +0100)
1  2  3 
sound/soc/codecs/wm5102.c
sound/soc/codecs/wm5110.c

@@@@ -42,7 -42,7 -42,7 +42,7 @@@@ struct wm5102_priv 
   static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0);
   static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
   static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
 --static DECLARE_TLV_DB_SCALE(noise_tlv, 0, 600, 0);
 ++static DECLARE_TLV_DB_SCALE(noise_tlv, -13200, 600, 0);
   static DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0);
   
   static const struct wm_adsp_region wm5102_dsp1_regions[] = {
@@@@ -605,56 -605,56 -605,12 +605,56 @@@@ static int wm5102_sysclk_ev(struct snd_
                                regmap_write_async(regmap, patch[i].reg,
                                                   patch[i].def);
                break;
  +     case SND_SOC_DAPM_PRE_PMD:
  +             break;
  +     default:
  +             return 0;
  +     }
  +
  +     return arizona_dvfs_sysclk_ev(w, kcontrol, event);
  +}
  +
  +static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w,
  +                struct snd_kcontrol *kcontrol, int event)
  +{
  +     struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  +     struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
  +     unsigned int v;
  +     int ret;
  +
  +     switch (event) {
  +     case SND_SOC_DAPM_PRE_PMU:
  +             ret = regmap_read(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, &v);
  +             if (ret != 0) {
  +                     dev_err(codec->dev,
  +                             "Failed to read SYSCLK state: %d\n", ret);
  +                     return -EIO;
  +             }
  +
  +             v = (v & ARIZONA_SYSCLK_FREQ_MASK) >> ARIZONA_SYSCLK_FREQ_SHIFT;
  +
  +             if (v >= 3) {
  +                     ret = arizona_dvfs_up(codec, ARIZONA_DVFS_ADSP1_RQ);
  +                     if (ret) {
  +                             dev_err(codec->dev,
  +                                     "Failed to raise DVFS: %d\n", ret);
  +                             return ret;
  +                     }
  +             }
  +             break;
  +
  +     case SND_SOC_DAPM_POST_PMD:
  +             ret = arizona_dvfs_down(codec, ARIZONA_DVFS_ADSP1_RQ);
  +             if (ret)
  +                     dev_warn(codec->dev,
  +                              "Failed to lower DVFS: %d\n", ret);
  +             break;
   
        default:
                break;
        }
   
  -     return 0;
  +     return wm_adsp2_early_event(w, kcontrol, event);
   }
   
   static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
@@@@ -1080,8 -1080,8 -1036,7 +1080,8 @@@@ static const struct snd_kcontrol_new wm
   
   static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = {
   SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
  -                 0, wm5102_sysclk_ev, SND_SOC_DAPM_POST_PMU),
  +                 0, wm5102_sysclk_ev,
  +                 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
   SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
                    ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0),
   SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
@@@@ -1412,7 -1412,7 -1367,7 +1412,7 @@@@ ARIZONA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DE
   ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"),
   ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"),
   
  -WM_ADSP2("DSP1", 0),
  +WM_ADSP2_E("DSP1", 0, wm5102_adsp_power_ev),
   
   SND_SOC_DAPM_OUTPUT("HPOUT1L"),
   SND_SOC_DAPM_OUTPUT("HPOUT1R"),
@@@@ -1872,20 -1872,19 -1827,19 +1872,20 @@@@ static struct snd_soc_dai_driver wm5102
   
   static int wm5102_codec_probe(struct snd_soc_codec *codec)
   {
 ++     struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
        struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec);
        int ret;
   
- -     ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 2);
- -     if (ret != 0)
+ +     ret = wm_adsp2_codec_probe(&priv->core.adsp[0], codec);
+ +     if (ret)
                return ret;
   
        arizona_init_spk(codec);
        arizona_init_gpio(codec);
   
 --     snd_soc_dapm_disable_pin(&codec->dapm, "HAPTICS");
 ++     snd_soc_dapm_disable_pin(dapm, "HAPTICS");
   
 --     priv->core.arizona->dapm = &codec->dapm;
 ++     priv->core.arizona->dapm = dapm;
   
        return 0;
   }
@@@@ -1894,6 -1893,8 -1848,6 +1894,8 @@@@ static int wm5102_codec_remove(struct s
   {
        struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec);
   
+ +     wm_adsp2_codec_remove(&priv->core.adsp[0], codec);
+ +
        priv->core.arizona->dapm = NULL;
   
        return 0;
@@@@ -1955,8 -1956,8 -1909,6 +1957,8 @@@@ static int wm5102_probe(struct platform
        wm5102->core.arizona = arizona;
        wm5102->core.num_inputs = 6;
   
  +     arizona_init_dvfs(&wm5102->core);
  +
        wm5102->core.adsp[0].part = "wm5102";
        wm5102->core.adsp[0].num = 1;
        wm5102->core.adsp[0].type = WMFW_ADSP2;
        wm5102->core.adsp[0].mem = wm5102_dsp1_regions;
        wm5102->core.adsp[0].num_mems = ARRAY_SIZE(wm5102_dsp1_regions);
   
  -     ret = wm_adsp2_init(&wm5102->core.adsp[0], true);
  +     ret = wm_adsp2_init(&wm5102->core.adsp[0]);
        if (ret != 0)
                return ret;
   
@@@@ -167,7 -167,7 -167,7 +167,7 @@@@ static int wm5110_sysclk_ev(struct snd_
   static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0);
   static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
   static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
 --static DECLARE_TLV_DB_SCALE(noise_tlv, 0, 600, 0);
 ++static DECLARE_TLV_DB_SCALE(noise_tlv, -13200, 600, 0);
   static DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0);
   
   #define WM5110_NG_SRC(name, base) \
@@@@ -1598,21 -1598,24 -1598,22 +1598,23 @@@@ static struct snd_soc_dai_driver wm5110
   
   static int wm5110_codec_probe(struct snd_soc_codec *codec)
   {
 ++     struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
        struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec);
- -     int ret;
+ +     int i, ret;
   
 --     priv->core.arizona->dapm = &codec->dapm;
 ++     priv->core.arizona->dapm = dapm;
   
        arizona_init_spk(codec);
        arizona_init_gpio(codec);
        arizona_init_mono(codec);
   
- -     ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 8);
- -     if (ret != 0)
- -             return ret;
  -
  -     snd_soc_dapm_disable_pin(&codec->dapm, "HAPTICS");
+ +     for (i = 0; i < WM5110_NUM_ADSP; ++i) {
+ +             ret = wm_adsp2_codec_probe(&priv->core.adsp[i], codec);
+ +             if (ret)
+ +                     return ret;
+ +     }
   
 -      snd_soc_dapm_disable_pin(&codec->dapm, "HAPTICS");
 - 
 --     priv->core.arizona->dapm = &codec->dapm;
 ++     snd_soc_dapm_disable_pin(dapm, "HAPTICS");
   
        return 0;
   }
   static int wm5110_codec_remove(struct snd_soc_codec *codec)
   {
        struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec);
+ +     int i;
+ +
+ +     for (i = 0; i < WM5110_NUM_ADSP; ++i)
+ +             wm_adsp2_codec_remove(&priv->core.adsp[i], codec);
   
        priv->core.arizona->dapm = NULL;
   
@@@@ -1696,7 -1703,7 -1697,7 +1702,7 @@@@ static int wm5110_probe(struct platform
                wm5110->core.adsp[i].num_mems
                        = ARRAY_SIZE(wm5110_dsp1_regions);
   
  -             ret = wm_adsp2_init(&wm5110->core.adsp[i], false);
  +             ret = wm_adsp2_init(&wm5110->core.adsp[i]);
                if (ret != 0)
                        return ret;
        }