Merge remote-tracking branches 'asoc/topic/sh', 'asoc/topic/sigmadsp', 'asoc/topic...
authorMark Brown <broonie@kernel.org>
Mon, 8 Dec 2014 13:12:12 +0000 (13:12 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 8 Dec 2014 13:12:12 +0000 (13:12 +0000)
1  2  3  4  5  6 
sound/soc/codecs/adau1761.c
sound/soc/codecs/adau1781.c
sound/soc/codecs/adau17x1.c

index 16093dc8944197e4c5e2fad2210721fe81f32bf7,5518ebd6947c5f28329fb474b4b313920f5e94ec,4c018c575b01c024506bf456ab0ff12850e84e8d,5518ebd6947c5f28329fb474b4b313920f5e94ec,5518ebd6947c5f28329fb474b4b313920f5e94ec,5518ebd6947c5f28329fb474b4b313920f5e94ec..a1baeee160f43b35780a7914c428e3b886e55c01
@@@@@@@ -255,8 -255,7 -255,7 -255,7 -255,7 -255,7 +255,8 @@@@@@@ static const struct snd_kcontrol_new ad
      static int adau1761_dejitter_fixup(struct snd_soc_dapm_widget *w,
        struct snd_kcontrol *kcontrol, int event)
      {
 -----  struct adau *adau = snd_soc_codec_get_drvdata(w->codec);
 +++++  struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
 +++++  struct adau *adau = snd_soc_codec_get_drvdata(codec);
      
        /* After any power changes have been made the dejitter circuit
         * has to be reinitialized. */
@@@@@@@ -406,7 -405,6 -405,6 -405,6 -405,6 -405,6 +406,7 @@@@@@@ static const struct snd_soc_dapm_widge
                2, 0, NULL, 0),
      
        SND_SOC_DAPM_SUPPLY("Slew Clock", ADAU1761_CLK_ENABLE0, 6, 0, NULL, 0),
 +++++  SND_SOC_DAPM_SUPPLY("ALC Clock", ADAU1761_CLK_ENABLE0, 5, 0, NULL, 0),
      
        SND_SOC_DAPM_SUPPLY_S("Digital Clock 0", 1, ADAU1761_CLK_ENABLE1,
                0, 0, NULL, 0),
@@@@@@@ -438,9 -436,6 -436,6 -436,6 -436,6 -436,6 +438,9 @@@@@@@ static const struct snd_soc_dapm_route 
        { "Right Playback Mixer", NULL, "Slew Clock" },
        { "Left Playback Mixer", NULL, "Slew Clock" },
      
 +++++  { "Left Input Mixer", NULL, "ALC Clock" },
 +++++  { "Right Input Mixer", NULL, "ALC Clock" },
 +++++
        { "Digital Clock 0", NULL, "SYSCLK" },
        { "Digital Clock 1", NULL, "SYSCLK" },
      };
@@@@@@@ -703,11 -698,11 -698,6 -698,11 -698,11 -698,11 +703,6 @@@@@@@ static int adau1761_codec_probe(struct 
                        ARRAY_SIZE(adau1761_dapm_routes));
                if (ret)
                        return ret;
-- ---
-- ---          ret = adau17x1_load_firmware(adau, codec->dev,
-- ---                  ADAU1761_FIRMWARE);
-- ---          if (ret)
-- ---                  dev_warn(codec->dev, "Failed to firmware\n");
        }
      
        ret = adau17x1_add_routes(codec);
@@@@@@@ -776,16 -771,16 -766,20 -771,16 -771,16 -771,16 +771,20 @@@@@@@ int adau1761_probe(struct device *dev, 
        enum adau17x1_type type, void (*switch_mode)(struct device *dev))
      {
        struct snd_soc_dai_driver *dai_drv;
++ +++  const char *firmware_name;
        int ret;
      
-- ---  ret = adau17x1_probe(dev, regmap, type, switch_mode);
-- ---  if (ret)
-- ---          return ret;
-- ---
-- ---  if (type == ADAU1361)
++ +++  if (type == ADAU1361) {
                dai_drv = &adau1361_dai_driver;
-- ---  else
++ +++          firmware_name = NULL;
++ +++  } else {
                dai_drv = &adau1761_dai_driver;
++ +++          firmware_name = ADAU1761_FIRMWARE;
++ +++  }
++ +++
++ +++  ret = adau17x1_probe(dev, regmap, type, switch_mode, firmware_name);
++ +++  if (ret)
++ +++          return ret;
      
        return snd_soc_register_codec(dev, &adau1761_codec_driver, dai_drv, 1);
      }
@@@@@@@ -799,6 -794,6 -793,7 -794,6 -794,6 -794,6 +798,7 @@@@@@@ const struct regmap_config adau1761_reg
        .num_reg_defaults = ARRAY_SIZE(adau1761_reg_defaults),
        .readable_reg = adau1761_readable_register,
        .volatile_reg = adau17x1_volatile_register,
++ +++  .precious_reg = adau17x1_precious_register,
        .cache_type = REGCACHE_RBTREE,
      };
      EXPORT_SYMBOL_GPL(adau1761_regmap_config);
index aa6a37cc44b70096fcc1998e848187d1d19be908,e9fc00fb13ddf65597513fe58652183776b71d99,926fc99c1dda59682d667f58b82d13c01d1bd3e9,e9fc00fb13ddf65597513fe58652183776b71d99,e9fc00fb13ddf65597513fe58652183776b71d99,e9fc00fb13ddf65597513fe58652183776b71d99..35581f43fa6d5e212d3d2c6735b70a8b3f0e2c3a
@@@@@@@ -174,7 -174,7 -174,7 -174,7 -174,7 -174,7 +174,7 @@@@@@@ static const struct snd_kcontrol_new ad
      static int adau1781_dejitter_fixup(struct snd_soc_dapm_widget *w,
        struct snd_kcontrol *kcontrol, int event)
      {
 -----  struct snd_soc_codec *codec = w->codec;
 +++++  struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
        struct adau *adau = snd_soc_codec_get_drvdata(codec);
      
        /* After any power changes have been made the dejitter circuit
@@@@@@@ -385,7 -385,7 -385,6 -385,7 -385,7 -385,7 +385,6 @@@@@@@ static int adau1781_codec_probe(struct 
      {
        struct adau1781_platform_data *pdata = dev_get_platdata(codec->dev);
        struct adau *adau = snd_soc_codec_get_drvdata(codec);
-- ---  const char *firmware;
        int ret;
      
        ret = adau17x1_add_widgets(codec);
                        return ret;
        }
      
-- ---  switch (adau->type) {
-- ---  case ADAU1381:
-- ---          firmware = ADAU1381_FIRMWARE;
-- ---          break;
-- ---  case ADAU1781:
-- ---          firmware = ADAU1781_FIRMWARE;
-- ---          break;
-- ---  default:
-- ---          return -EINVAL;
-- ---  }
-- ---
        ret = adau17x1_add_routes(codec);
        if (ret < 0)
                return ret;
      
-- ---  ret = adau17x1_load_firmware(adau, codec->dev, firmware);
-- ---  if (ret)
-- ---          dev_warn(codec->dev, "Failed to load firmware\n");
-- ---
        return 0;
      }
      
@@@@@@@ -488,6 -488,6 -472,7 -488,6 -488,6 -488,6 +472,7 @@@@@@@ const struct regmap_config adau1781_reg
        .num_reg_defaults       = ARRAY_SIZE(adau1781_reg_defaults),
        .readable_reg           = adau1781_readable_register,
        .volatile_reg           = adau17x1_volatile_register,
++ +++  .precious_reg           = adau17x1_precious_register,
        .cache_type             = REGCACHE_RBTREE,
      };
      EXPORT_SYMBOL_GPL(adau1781_regmap_config);
      int adau1781_probe(struct device *dev, struct regmap *regmap,
        enum adau17x1_type type, void (*switch_mode)(struct device *dev))
      {
++ +++  const char *firmware_name;
        int ret;
      
-- ---  ret = adau17x1_probe(dev, regmap, type, switch_mode);
++ +++  switch (type) {
++ +++  case ADAU1381:
++ +++          firmware_name = ADAU1381_FIRMWARE;
++ +++          break;
++ +++  case ADAU1781:
++ +++          firmware_name = ADAU1781_FIRMWARE;
++ +++          break;
++ +++  default:
++ +++          return -EINVAL;
++ +++  }
++ +++
++ +++  ret = adau17x1_probe(dev, regmap, type, switch_mode, firmware_name);
        if (ret)
                return ret;
      
index 427ad77bfe561acff435ed12a81d9fcc7597638f,3e16c1c641156d428e1759956191f418a1edcd03,50000477dc2a0913d114ab7028843b8600614a0d,3e16c1c641156d428e1759956191f418a1edcd03,3e16c1c641156d428e1759956191f418a1edcd03,3e16c1c641156d428e1759956191f418a1edcd03..fa2e690e51c8b5292ff690480b996c9cea14c610
@@@@@@@ -61,8 -61,7 -61,7 -61,7 -61,7 -61,7 +61,8 @@@@@@@ static const struct snd_kcontrol_new ad
      static int adau17x1_pll_event(struct snd_soc_dapm_widget *w,
        struct snd_kcontrol *kcontrol, int event)
      {
 -----  struct adau *adau = snd_soc_codec_get_drvdata(w->codec);
 +++++  struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
 +++++  struct adau *adau = snd_soc_codec_get_drvdata(codec);
        int ret;
      
        if (SND_SOC_DAPM_EVENT_ON(event)) {
@@@@@@@ -308,6 -307,6 -307,7 -307,6 -307,6 -307,6 +308,7 @@@@@@@ static int adau17x1_hw_params(struct sn
        struct adau *adau = snd_soc_codec_get_drvdata(codec);
        unsigned int val, div, dsp_div;
        unsigned int freq;
++ +++  int ret;
      
        if (adau->clk_src == ADAU17X1_CLK_SRC_PLL)
                freq = adau->pll_freq;
                regmap_write(adau->regmap, ADAU17X1_DSP_SAMPLING_RATE, dsp_div);
        }
      
++ +++  if (adau->sigmadsp) {
++ +++          ret = adau17x1_setup_firmware(adau, params_rate(params));
++ +++          if (ret < 0)
++ +++                  return ret;
++ +++  }
++ +++
        if (adau->dai_fmt != SND_SOC_DAIFMT_RIGHT_J)
                return 0;
      
@@@@@@@ -662,12 -661,12 -668,24 -661,12 -661,12 -661,12 +669,24 @@@@@@@ static int adau17x1_set_dai_tdm_slot(st
        return 0;
      }
      
++ +++static int adau17x1_startup(struct snd_pcm_substream *substream,
++ +++  struct snd_soc_dai *dai)
++ +++{
++ +++  struct adau *adau = snd_soc_codec_get_drvdata(dai->codec);
++ +++
++ +++  if (adau->sigmadsp)
++ +++          return sigmadsp_restrict_params(adau->sigmadsp, substream);
++ +++
++ +++  return 0;
++ +++}
++ +++
      const struct snd_soc_dai_ops adau17x1_dai_ops = {
        .hw_params      = adau17x1_hw_params,
        .set_sysclk     = adau17x1_set_dai_sysclk,
        .set_fmt        = adau17x1_set_dai_fmt,
        .set_pll        = adau17x1_set_dai_pll,
        .set_tdm_slot   = adau17x1_set_dai_tdm_slot,
++ +++  .startup        = adau17x1_startup,
      };
      EXPORT_SYMBOL_GPL(adau17x1_dai_ops);
      
@@@@@@@ -688,8 -687,8 -706,22 -687,8 -687,8 -687,8 +707,22 @@@@@@@ int adau17x1_set_micbias_voltage(struc
      }
      EXPORT_SYMBOL_GPL(adau17x1_set_micbias_voltage);
      
++ +++bool adau17x1_precious_register(struct device *dev, unsigned int reg)
++ +++{
++ +++  /* SigmaDSP parameter memory */
++ +++  if (reg < 0x400)
++ +++          return true;
++ +++
++ +++  return false;
++ +++}
++ +++EXPORT_SYMBOL_GPL(adau17x1_precious_register);
++ +++
      bool adau17x1_readable_register(struct device *dev, unsigned int reg)
      {
++ +++  /* SigmaDSP parameter memory */
++ +++  if (reg < 0x400)
++ +++          return true;
++ +++
        switch (reg) {
        case ADAU17X1_CLOCK_CONTROL:
        case ADAU17X1_PLL_CONTROL:
@@@@@@@ -746,8 -745,8 -778,7 -745,8 -745,8 -745,8 +779,7 @@@@@@@ bool adau17x1_volatile_register(struct 
      }
      EXPORT_SYMBOL_GPL(adau17x1_volatile_register);
      
-- ---int adau17x1_load_firmware(struct adau *adau, struct device *dev,
-- ---  const char *firmware)
++ +++int adau17x1_setup_firmware(struct adau *adau, unsigned int rate)
      {
        int ret;
        int dspsr;
        regmap_write(adau->regmap, ADAU17X1_DSP_ENABLE, 1);
        regmap_write(adau->regmap, ADAU17X1_DSP_SAMPLING_RATE, 0xf);
      
-- ---  ret = process_sigma_firmware_regmap(dev, adau->regmap, firmware);
++ +++  ret = sigmadsp_setup(adau->sigmadsp, rate);
        if (ret) {
                regmap_write(adau->regmap, ADAU17X1_DSP_ENABLE, 0);
                return ret;
      
        return 0;
      }
-- ---EXPORT_SYMBOL_GPL(adau17x1_load_firmware);
++ +++EXPORT_SYMBOL_GPL(adau17x1_setup_firmware);
      
      int adau17x1_add_widgets(struct snd_soc_codec *codec)
      {
                ret = snd_soc_dapm_new_controls(&codec->dapm,
                        adau17x1_dsp_dapm_widgets,
                        ARRAY_SIZE(adau17x1_dsp_dapm_widgets));
++ +++          if (ret)
++ +++                  return ret;
++ +++
++ +++          if (!adau->sigmadsp)
++ +++                  return 0;
++ +++
++ +++          ret = sigmadsp_attach(adau->sigmadsp, &codec->component);
++ +++          if (ret) {
++ +++                  dev_err(codec->dev, "Failed to attach firmware: %d\n",
++ +++                          ret);
++ +++                  return ret;
++ +++          }
        }
-- ---  return ret;
++ +++
++ +++  return 0;
      }
      EXPORT_SYMBOL_GPL(adau17x1_add_widgets);
      
@@@@@@@ -830,7 -829,7 -874,8 -829,7 -829,7 -829,7 +875,8 @@@@@@@ int adau17x1_resume(struct snd_soc_code
      EXPORT_SYMBOL_GPL(adau17x1_resume);
      
      int adau17x1_probe(struct device *dev, struct regmap *regmap,
-- ---  enum adau17x1_type type, void (*switch_mode)(struct device *dev))
++ +++  enum adau17x1_type type, void (*switch_mode)(struct device *dev),
++ +++  const char *firmware_name)
      {
        struct adau *adau;
      
      
        dev_set_drvdata(dev, adau);
      
++ +++  if (firmware_name) {
++ +++          adau->sigmadsp = devm_sigmadsp_init_regmap(dev, regmap, NULL,
++ +++                  firmware_name);
++ +++          if (IS_ERR(adau->sigmadsp)) {
++ +++                  dev_warn(dev, "Could not find firmware file: %ld\n",
++ +++                          PTR_ERR(adau->sigmadsp));
++ +++                  adau->sigmadsp = NULL;
++ +++          }
++ +++  }
++ +++
        if (switch_mode)
                switch_mode(dev);