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. */
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),
{ "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" },
};
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);
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);
}
.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);
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
{
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;
}
.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;
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)) {
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;
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);
}
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:
}
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);
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);