ADAU1977_REG_DC_HPF_CAL, (x) - 1, 1, 0)
#define ADAU1977_DC_SUB_SWITCH(x) \
- --- SOC_SINGLE("ADC" #x " DC Substraction Capture Switch", \
+ +++ SOC_SINGLE("ADC" #x " DC Subtraction Capture Switch", \
ADAU1977_REG_DC_HPF_CAL, (x) + 3, 1, 0)
static const struct snd_kcontrol_new adau1977_snd_controls[] = {
case SND_SOC_BIAS_PREPARE:
break;
case SND_SOC_BIAS_STANDBY:
---- if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
++++ if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
ret = adau1977_power_enable(adau1977);
break;
case SND_SOC_BIAS_OFF:
break;
}
---- if (ret)
---- return ret;
----
---- codec->dapm.bias_level = level;
----
---- return 0;
++++ return ret;
}
static int adau1977_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
static int adau1977_codec_probe(struct snd_soc_codec *codec)
{
++++ struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(codec);
int ret;
switch (adau1977->type) {
case ADAU1977:
---- ret = snd_soc_dapm_new_controls(&codec->dapm,
++++ ret = snd_soc_dapm_new_controls(dapm,
adau1977_micbias_dapm_widgets,
ARRAY_SIZE(adau1977_micbias_dapm_widgets));
if (ret < 0)
unsigned int freq, int dir)
{
struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
-- -- struct snd_soc_dapm_context *dapm = &codec->dapm;
++ ++ struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
if (dir == SND_SOC_CLOCK_IN) {
switch (clk_id) {
static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id,
int source, unsigned int freq_in, unsigned int freq_out)
{
++ ++ struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
unsigned int pll_ctrl1 = 0;
unsigned int pll_ctrl2 = 0;
adav80x->pll_src = source;
-- -- snd_soc_dapm_sync(&codec->dapm);
++ ++ snd_soc_dapm_sync(dapm);
}
return 0;
break;
}
---- codec->dapm.bias_level = level;
return 0;
}
static int adav80x_probe(struct snd_soc_codec *codec)
{
++ ++ struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
/* Force PLLs on for SYSCLK output */
-- -- snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL1");
-- -- snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL2");
++ ++ snd_soc_dapm_force_enable_pin(dapm, "PLL1");
++ ++ snd_soc_dapm_force_enable_pin(dapm, "PLL2");
/* Power down S/PDIF receiver, since it is currently not supported */
regmap_write(adav80x->regmap, ADAV80X_PLL_OUTE, 0x20);
int arizona_init_spk(struct snd_soc_codec *codec)
{
++++ struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
struct arizona *arizona = priv->arizona;
int ret;
---- ret = snd_soc_dapm_new_controls(&codec->dapm, &arizona_spkl, 1);
++++ ret = snd_soc_dapm_new_controls(dapm, &arizona_spkl, 1);
if (ret != 0)
return ret;
case WM8997:
break;
default:
---- ret = snd_soc_dapm_new_controls(&codec->dapm,
---- &arizona_spkr, 1);
++++ ret = snd_soc_dapm_new_controls(dapm, &arizona_spkr, 1);
if (ret != 0)
return ret;
break;
int arizona_init_mono(struct snd_soc_codec *codec)
{
++++ struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
struct arizona *arizona = priv->arizona;
int i;
for (i = 0; i < ARIZONA_MAX_OUTPUT; ++i) {
if (arizona->pdata.out_mono[i])
---- snd_soc_dapm_add_routes(&codec->dapm,
++++ snd_soc_dapm_add_routes(dapm,
&arizona_mono_routes[i], 1);
}
int arizona_init_gpio(struct snd_soc_codec *codec)
{
++++ struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
struct arizona *arizona = priv->arizona;
int i;
switch (arizona->type) {
case WM5110:
case WM8280:
---- snd_soc_dapm_disable_pin(&codec->dapm, "DRC2 Signal Activity");
++++ snd_soc_dapm_disable_pin(dapm, "DRC2 Signal Activity");
break;
default:
break;
}
---- snd_soc_dapm_disable_pin(&codec->dapm, "DRC1 Signal Activity");
++++ snd_soc_dapm_disable_pin(dapm, "DRC1 Signal Activity");
for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) {
switch (arizona->pdata.gpio_defaults[i] & ARIZONA_GPN_FN_MASK) {
case ARIZONA_GP_FN_DRC1_SIGNAL_DETECT:
---- snd_soc_dapm_enable_pin(&codec->dapm,
---- "DRC1 Signal Activity");
++++ snd_soc_dapm_enable_pin(dapm, "DRC1 Signal Activity");
break;
case ARIZONA_GP_FN_DRC2_SIGNAL_DETECT:
---- snd_soc_dapm_enable_pin(&codec->dapm,
---- "DRC2 Signal Activity");
++++ snd_soc_dapm_enable_pin(dapm, "DRC2 Signal Activity");
break;
default:
break;
}
EXPORT_SYMBOL_GPL(arizona_hp_ev);
+++ +static int arizona_dvfs_enable(struct snd_soc_codec *codec)
+++ +{
+++ + const struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
+++ + struct arizona *arizona = priv->arizona;
+++ + int ret;
+++ +
+++ + ret = regulator_set_voltage(arizona->dcvdd, 1800000, 1800000);
+++ + if (ret) {
+++ + dev_err(codec->dev, "Failed to boost DCVDD: %d\n", ret);
+++ + return ret;
+++ + }
+++ +
+++ + ret = regmap_update_bits(arizona->regmap,
+++ + ARIZONA_DYNAMIC_FREQUENCY_SCALING_1,
+++ + ARIZONA_SUBSYS_MAX_FREQ,
+++ + ARIZONA_SUBSYS_MAX_FREQ);
+++ + if (ret) {
+++ + dev_err(codec->dev, "Failed to enable subsys max: %d\n", ret);
+++ + regulator_set_voltage(arizona->dcvdd, 1200000, 1800000);
+++ + return ret;
+++ + }
+++ +
+++ + return 0;
+++ +}
+++ +
+++ +static int arizona_dvfs_disable(struct snd_soc_codec *codec)
+++ +{
+++ + const struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
+++ + struct arizona *arizona = priv->arizona;
+++ + int ret;
+++ +
+++ + ret = regmap_update_bits(arizona->regmap,
+++ + ARIZONA_DYNAMIC_FREQUENCY_SCALING_1,
+++ + ARIZONA_SUBSYS_MAX_FREQ, 0);
+++ + if (ret) {
+++ + dev_err(codec->dev, "Failed to disable subsys max: %d\n", ret);
+++ + return ret;
+++ + }
+++ +
+++ + ret = regulator_set_voltage(arizona->dcvdd, 1200000, 1800000);
+++ + if (ret) {
+++ + dev_err(codec->dev, "Failed to unboost DCVDD: %d\n", ret);
+++ + return ret;
+++ + }
+++ +
+++ + return 0;
+++ +}
+++ +
+++ +int arizona_dvfs_up(struct snd_soc_codec *codec, unsigned int flags)
+++ +{
+++ + struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
+++ + int ret = 0;
+++ +
+++ + mutex_lock(&priv->dvfs_lock);
+++ +
+++ + if (!priv->dvfs_cached && !priv->dvfs_reqs) {
+++ + ret = arizona_dvfs_enable(codec);
+++ + if (ret)
+++ + goto err;
+++ + }
+++ +
+++ + priv->dvfs_reqs |= flags;
+++ +err:
+++ + mutex_unlock(&priv->dvfs_lock);
+++ + return ret;
+++ +}
+++ +EXPORT_SYMBOL_GPL(arizona_dvfs_up);
+++ +
+++ +int arizona_dvfs_down(struct snd_soc_codec *codec, unsigned int flags)
+++ +{
+++ + struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
+++ + unsigned int old_reqs;
+++ + int ret = 0;
+++ +
+++ + mutex_lock(&priv->dvfs_lock);
+++ +
+++ + old_reqs = priv->dvfs_reqs;
+++ + priv->dvfs_reqs &= ~flags;
+++ +
+++ + if (!priv->dvfs_cached && old_reqs && !priv->dvfs_reqs)
+++ + ret = arizona_dvfs_disable(codec);
+++ +
+++ + mutex_unlock(&priv->dvfs_lock);
+++ + return ret;
+++ +}
+++ +EXPORT_SYMBOL_GPL(arizona_dvfs_down);
+++ +
+++ +int arizona_dvfs_sysclk_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_priv *priv = snd_soc_codec_get_drvdata(codec);
+++ + int ret = 0;
+++ +
+++ + mutex_lock(&priv->dvfs_lock);
+++ +
+++ + switch (event) {
+++ + case SND_SOC_DAPM_POST_PMU:
+++ + if (priv->dvfs_reqs)
+++ + ret = arizona_dvfs_enable(codec);
+++ +
+++ + priv->dvfs_cached = false;
+++ + break;
+++ + case SND_SOC_DAPM_PRE_PMD:
+++ + /* We must ensure DVFS is disabled before the codec goes into
+++ + * suspend so that we are never in an illegal state of DVFS
+++ + * enabled without enough DCVDD
+++ + */
+++ + priv->dvfs_cached = true;
+++ +
+++ + if (priv->dvfs_reqs)
+++ + ret = arizona_dvfs_disable(codec);
+++ + break;
+++ + default:
+++ + break;
+++ + }
+++ +
+++ + mutex_unlock(&priv->dvfs_lock);
+++ + return ret;
+++ +}
+++ +EXPORT_SYMBOL_GPL(arizona_dvfs_sysclk_ev);
+++ +
+++ +void arizona_init_dvfs(struct arizona_priv *priv)
+++ +{
+++ + mutex_init(&priv->dvfs_lock);
+++ +}
+++ +EXPORT_SYMBOL_GPL(arizona_init_dvfs);
+++ +
static unsigned int arizona_sysclk_48k_rates[] = {
6144000,
12288000,
struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1];
int base = dai->driver->base;
--- - int i, sr_val;
+++ + int i, sr_val, ret;
/*
* We will need to be more flexible than this in future,
}
sr_val = i;
+++ + switch (priv->arizona->type) {
+++ + case WM5102:
+++ + case WM8997:
+++ + if (arizona_sr_vals[sr_val] >= 88200)
+++ + ret = arizona_dvfs_up(codec, ARIZONA_DVFS_SR1_RQ);
+++ + else
+++ + ret = arizona_dvfs_down(codec, ARIZONA_DVFS_SR1_RQ);
+++ +
+++ + if (ret) {
+++ + arizona_aif_err(dai, "Failed to change DVFS %d\n", ret);
+++ + return ret;
+++ + }
+++ + break;
+++ + default:
+++ + break;
+++ + }
+++ +
switch (dai_priv->clk) {
case ARIZONA_CLK_SYSCLK:
switch (priv->arizona->type) {
int clk_id, unsigned int freq, int dir)
{
struct snd_soc_codec *codec = dai->codec;
++++ struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1];
struct snd_soc_dapm_route routes[2];
routes[0].source = arizona_dai_clk_str(dai_priv->clk);
routes[1].source = arizona_dai_clk_str(dai_priv->clk);
---- snd_soc_dapm_del_routes(&codec->dapm, routes, ARRAY_SIZE(routes));
++++ snd_soc_dapm_del_routes(dapm, routes, ARRAY_SIZE(routes));
routes[0].source = arizona_dai_clk_str(clk_id);
routes[1].source = arizona_dai_clk_str(clk_id);
---- snd_soc_dapm_add_routes(&codec->dapm, routes, ARRAY_SIZE(routes));
++++ snd_soc_dapm_add_routes(dapm, routes, ARRAY_SIZE(routes));
dai_priv->clk = clk_id;
---- return snd_soc_dapm_sync(&codec->dapm);
++++ return snd_soc_dapm_sync(dapm);
}
static int arizona_set_tristate(struct snd_soc_dai *dai, int tristate)
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[] = {
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,
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,
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"),
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;
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;
}
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;
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) \
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;
---- priv->core.arizona->dapm = &codec->dapm;
++++ priv->core.arizona->dapm = dapm;
arizona_init_spk(codec);
arizona_init_gpio(codec);
if (ret != 0)
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;
}
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;
}
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 reg_default wm8997_sysclk_reva_patch[] = {
regmap_write_async(regmap, patch[i].reg,
patch[i].def);
break;
--- - default:
+++ + case SND_SOC_DAPM_PRE_PMD:
break;
+++ + default:
+++ + return 0;
}
--- - return 0;
+++ + return arizona_dvfs_sysclk_ev(w, kcontrol, event);
}
static const char *wm8997_osr_text[] = {
static const struct snd_soc_dapm_widget wm8997_dapm_widgets[] = {
SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
--- - 0, wm8997_sysclk_ev, SND_SOC_DAPM_POST_PMU),
+++ + 0, wm8997_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,
static int wm8997_codec_probe(struct snd_soc_codec *codec)
{
++++ struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec);
arizona_init_spk(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;
}
wm8997->core.arizona = arizona;
wm8997->core.num_inputs = 4;
+++ + arizona_init_dvfs(&wm8997->core);
+++ +
for (i = 0; i < ARRAY_SIZE(wm8997->fll); i++)
wm8997->fll[i].vco_mult = 1;