diff options
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/max98927.c | 82 | ||||
-rw-r--r-- | sound/soc/codecs/max98927.h | 2 | ||||
-rw-r--r-- | sound/soc/codecs/mc13783.c | 68 | ||||
-rw-r--r-- | sound/soc/codecs/ml26124.c | 103 | ||||
-rw-r--r-- | sound/soc/codecs/msm8916-wcd-analog.c | 207 | ||||
-rw-r--r-- | sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 2 |
6 files changed, 227 insertions, 237 deletions
diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index f701fdc81175..065303a46535 100644 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -142,14 +142,14 @@ static struct reg_default max98927_reg[] = { static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); unsigned int mode = 0; unsigned int format = 0; bool use_pdm = false; unsigned int invert = 0; - dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt); + dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: @@ -160,7 +160,7 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) mode = MAX98927_PCM_MASTER_MODE_MASTER; break; default: - dev_err(codec->dev, "DAI clock mode unsupported\n"); + dev_err(component->dev, "DAI clock mode unsupported\n"); return -EINVAL; } @@ -176,7 +176,7 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) invert = MAX98927_PCM_MODE_CFG_PCM_BCLKEDGE; break; default: - dev_err(codec->dev, "DAI invert mode unsupported\n"); + dev_err(component->dev, "DAI invert mode unsupported\n"); return -EINVAL; } @@ -268,7 +268,7 @@ static int max98927_get_bclk_sel(int bclk) static int max98927_set_clock(struct max98927_priv *max98927, struct snd_pcm_hw_params *params) { - struct snd_soc_codec *codec = max98927->codec; + struct snd_soc_component *component = max98927->component; /* BCLK/LRCLK ratio calculation */ int blr_clk_ratio = params_channels(params) * max98927->ch_size; int value; @@ -281,7 +281,7 @@ static int max98927_set_clock(struct max98927_priv *max98927, break; } if (i == ARRAY_SIZE(rate_table)) { - dev_err(codec->dev, "failed to find proper clock rate.\n"); + dev_err(component->dev, "failed to find proper clock rate.\n"); return -EINVAL; } regmap_update_bits(max98927->regmap, @@ -294,7 +294,7 @@ static int max98927_set_clock(struct max98927_priv *max98927, /* BCLK configuration */ value = max98927_get_bclk_sel(blr_clk_ratio); if (!value) { - dev_err(codec->dev, "format unsupported %d\n", + dev_err(component->dev, "format unsupported %d\n", params_format(params)); return -EINVAL; } @@ -311,8 +311,8 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); unsigned int sampling_rate = 0; unsigned int chan_sz = 0; @@ -328,7 +328,7 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream, chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_32; break; default: - dev_err(codec->dev, "format unsupported %d\n", + dev_err(component->dev, "format unsupported %d\n", params_format(params)); goto err; } @@ -339,7 +339,7 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream, MAX98927_R0020_PCM_MODE_CFG, MAX98927_PCM_MODE_CFG_CHANSZ_MASK, chan_sz); - dev_dbg(codec->dev, "format supported %d", + dev_dbg(component->dev, "format supported %d", params_format(params)); /* sampling rate configuration */ @@ -372,7 +372,7 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream, sampling_rate = MAX98927_PCM_SR_SET1_SR_48000; break; default: - dev_err(codec->dev, "rate %d not supported\n", + dev_err(component->dev, "rate %d not supported\n", params_rate(params)); goto err; } @@ -407,8 +407,8 @@ static int max98927_dai_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); int bsel = 0; unsigned int chan_sz = 0; @@ -417,7 +417,7 @@ static int max98927_dai_tdm_slot(struct snd_soc_dai *dai, /* BCLK configuration */ bsel = max98927_get_bclk_sel(slots * slot_width); if (bsel == 0) { - dev_err(codec->dev, "BCLK %d not supported\n", + dev_err(component->dev, "BCLK %d not supported\n", slots * slot_width); return -EINVAL; } @@ -439,7 +439,7 @@ static int max98927_dai_tdm_slot(struct snd_soc_dai *dai, chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_32; break; default: - dev_err(codec->dev, "format unsupported %d\n", + dev_err(component->dev, "format unsupported %d\n", slot_width); return -EINVAL; } @@ -483,8 +483,8 @@ static int max98927_dai_tdm_slot(struct snd_soc_dai *dai, static int max98927_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); max98927->sysclk = freq; return 0; @@ -500,8 +500,8 @@ static const struct snd_soc_dai_ops max98927_dai_ops = { static int max98927_dac_event(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 max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -677,11 +677,11 @@ static struct snd_soc_dai_driver max98927_dai[] = { } }; -static int max98927_probe(struct snd_soc_codec *codec) +static int max98927_probe(struct snd_soc_component *component) { - struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); - max98927->codec = codec; + max98927->component = component; /* Software Reset */ regmap_write(max98927->regmap, @@ -823,16 +823,18 @@ static const struct dev_pm_ops max98927_pm = { SET_SYSTEM_SLEEP_PM_OPS(max98927_suspend, max98927_resume) }; -static const struct snd_soc_codec_driver soc_codec_dev_max98927 = { - .probe = max98927_probe, - .component_driver = { - .controls = max98927_snd_controls, - .num_controls = ARRAY_SIZE(max98927_snd_controls), - .dapm_widgets = max98927_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98927_dapm_widgets), - .dapm_routes = max98927_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98927_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_max98927 = { + .probe = max98927_probe, + .controls = max98927_snd_controls, + .num_controls = ARRAY_SIZE(max98927_snd_controls), + .dapm_widgets = max98927_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98927_dapm_widgets), + .dapm_routes = max98927_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98927_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config max98927_regmap = { @@ -914,20 +916,15 @@ static int max98927_i2c_probe(struct i2c_client *i2c, max98927_slot_config(i2c, max98927); /* codec registeration */ - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98927, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_max98927, max98927_dai, ARRAY_SIZE(max98927_dai)); if (ret < 0) - dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); + dev_err(&i2c->dev, "Failed to register component: %d\n", ret); return ret; } -static int max98927_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max98927_i2c_id[] = { { "max98927", 0}, { }, @@ -959,7 +956,6 @@ static struct i2c_driver max98927_i2c_driver = { .pm = &max98927_pm, }, .probe = max98927_i2c_probe, - .remove = max98927_i2c_remove, .id_table = max98927_i2c_id, }; diff --git a/sound/soc/codecs/max98927.h b/sound/soc/codecs/max98927.h index 9ea839735433..42a9a244a9db 100644 --- a/sound/soc/codecs/max98927.h +++ b/sound/soc/codecs/max98927.h @@ -258,7 +258,7 @@ struct max98927_priv { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct max98927_pdata *pdata; unsigned int spk_gain; unsigned int sysclk; diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index be7a45f05bbf..7b0d2610cd27 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c @@ -107,13 +107,13 @@ static int mc13783_pcm_hw_params_dac(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int rate = params_rate(params); int i; for (i = 0; i < ARRAY_SIZE(mc13783_rates); i++) { if (rate == mc13783_rates[i]) { - snd_soc_update_bits(codec, MC13783_AUDIO_DAC, + snd_soc_component_update_bits(component, MC13783_AUDIO_DAC, 0xf << 17, i << 17); return 0; } @@ -126,7 +126,7 @@ static int mc13783_pcm_hw_params_codec(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int rate = params_rate(params); unsigned int val; @@ -141,7 +141,7 @@ static int mc13783_pcm_hw_params_codec(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, MC13783_AUDIO_CODEC, AUDIO_CODEC_CDCFS8K16K, + snd_soc_component_update_bits(component, MC13783_AUDIO_CODEC, AUDIO_CODEC_CDCFS8K16K, val); return 0; @@ -160,7 +160,7 @@ static int mc13783_pcm_hw_params_sync(struct snd_pcm_substream *substream, static int mc13783_set_fmt(struct snd_soc_dai *dai, unsigned int fmt, unsigned int reg) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val = 0; unsigned int mask = AUDIO_CFS(3) | AUDIO_BCL_INV | AUDIO_CFS_INV | AUDIO_CSM | AUDIO_C_CLK_EN | AUDIO_C_RESET; @@ -208,7 +208,7 @@ static int mc13783_set_fmt(struct snd_soc_dai *dai, unsigned int fmt, val |= AUDIO_C_RESET; - snd_soc_update_bits(codec, reg, mask, val); + snd_soc_component_update_bits(component, reg, mask, val); return 0; } @@ -255,7 +255,7 @@ static int mc13783_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir, unsigned int reg) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int clk; unsigned int val = 0; unsigned int mask = AUDIO_CLK(0x7) | AUDIO_CLK_SEL; @@ -275,7 +275,7 @@ static int mc13783_set_sysclk(struct snd_soc_dai *dai, val |= AUDIO_CLK(clk); - snd_soc_update_bits(codec, reg, mask, val); + snd_soc_component_update_bits(component, reg, mask, val); return 0; } @@ -308,7 +308,7 @@ static int mc13783_set_tdm_slot_dac(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val = 0; unsigned int mask = SSI_NETWORK_DAC_SLOT_MASK | SSI_NETWORK_DAC_RXSLOT_MASK; @@ -344,7 +344,7 @@ static int mc13783_set_tdm_slot_dac(struct snd_soc_dai *dai, return -EINVAL; } - snd_soc_update_bits(codec, MC13783_SSI_NETWORK, mask, val); + snd_soc_component_update_bits(component, MC13783_SSI_NETWORK, mask, val); return 0; } @@ -353,7 +353,7 @@ static int mc13783_set_tdm_slot_codec(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val = 0; unsigned int mask = 0x3f; @@ -366,7 +366,7 @@ static int mc13783_set_tdm_slot_codec(struct snd_soc_dai *dai, val |= (0x00 << 2); /* primary timeslot RX/TX(?) is 0 */ val |= (0x01 << 4); /* secondary timeslot TX is 1 */ - snd_soc_update_bits(codec, MC13783_SSI_NETWORK, mask, val); + snd_soc_component_update_bits(component, MC13783_SSI_NETWORK, mask, val); return 0; } @@ -606,12 +606,12 @@ static struct snd_kcontrol_new mc13783_control_list[] = { SOC_SINGLE("MC2 Capture Bias Switch", MC13783_AUDIO_TX, 1, 1, 0), }; -static int mc13783_probe(struct snd_soc_codec *codec) +static int mc13783_probe(struct snd_soc_component *component) { - struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); + struct mc13783_priv *priv = snd_soc_component_get_drvdata(component); - snd_soc_codec_init_regmap(codec, - dev_get_regmap(codec->dev->parent, NULL)); + snd_soc_component_init_regmap(component, + dev_get_regmap(component->dev->parent, NULL)); /* these are the reset values */ mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893); @@ -638,14 +638,12 @@ static int mc13783_probe(struct snd_soc_codec *codec) return 0; } -static int mc13783_remove(struct snd_soc_codec *codec) +static void mc13783_remove(struct snd_soc_component *component) { - struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); + struct mc13783_priv *priv = snd_soc_component_get_drvdata(component); /* Make sure VAUDIOON is off */ mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_RX0, 0x3, 0); - - return 0; } #define MC13783_RATES_RECORD (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000) @@ -731,17 +729,19 @@ static struct snd_soc_dai_driver mc13783_dai_sync[] = { } }; -static const struct snd_soc_codec_driver soc_codec_dev_mc13783 = { - .probe = mc13783_probe, - .remove = mc13783_remove, - .component_driver = { - .controls = mc13783_control_list, - .num_controls = ARRAY_SIZE(mc13783_control_list), - .dapm_widgets = mc13783_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(mc13783_dapm_widgets), - .dapm_routes = mc13783_routes, - .num_dapm_routes = ARRAY_SIZE(mc13783_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_mc13783 = { + .probe = mc13783_probe, + .remove = mc13783_remove, + .controls = mc13783_control_list, + .num_controls = ARRAY_SIZE(mc13783_control_list), + .dapm_widgets = mc13783_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(mc13783_dapm_widgets), + .dapm_routes = mc13783_routes, + .num_dapm_routes = ARRAY_SIZE(mc13783_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int __init mc13783_codec_probe(struct platform_device *pdev) @@ -782,10 +782,10 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) priv->mc13xxx = dev_get_drvdata(pdev->dev.parent); if (priv->adc_ssi_port == priv->dac_ssi_port) - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_mc13783, + ret = devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_mc13783, mc13783_dai_sync, ARRAY_SIZE(mc13783_dai_sync)); else - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_mc13783, + ret = devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_mc13783, mc13783_dai_async, ARRAY_SIZE(mc13783_dai_async)); return ret; @@ -793,8 +793,6 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) static int mc13783_codec_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); - return 0; } diff --git a/sound/soc/codecs/ml26124.c b/sound/soc/codecs/ml26124.c index 5cc960d8211e..a5fa490dc145 100644 --- a/sound/soc/codecs/ml26124.c +++ b/sound/soc/codecs/ml26124.c @@ -338,8 +338,8 @@ static int ml26124_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); int i = get_coeff(priv->mclk, params_rate(hw_params)); int srate; @@ -351,23 +351,23 @@ static int ml26124_hw_params(struct snd_pcm_substream *substream, if (priv->clk_in) { switch (priv->mclk / params_rate(hw_params)) { case 256: - snd_soc_update_bits(codec, ML26124_CLK_CTL, + snd_soc_component_update_bits(component, ML26124_CLK_CTL, BIT(0) | BIT(1), 1); break; case 512: - snd_soc_update_bits(codec, ML26124_CLK_CTL, + snd_soc_component_update_bits(component, ML26124_CLK_CTL, BIT(0) | BIT(1), 2); break; case 1024: - snd_soc_update_bits(codec, ML26124_CLK_CTL, + snd_soc_component_update_bits(component, ML26124_CLK_CTL, BIT(0) | BIT(1), 3); break; default: - dev_err(codec->dev, "Unsupported MCLKI\n"); + dev_err(component->dev, "Unsupported MCLKI\n"); break; } } else { - snd_soc_update_bits(codec, ML26124_CLK_CTL, + snd_soc_component_update_bits(component, ML26124_CLK_CTL, BIT(0) | BIT(1), 0); } @@ -375,35 +375,35 @@ static int ml26124_hw_params(struct snd_pcm_substream *substream, if (srate < 0) return srate; - snd_soc_update_bits(codec, ML26124_SMPLING_RATE, 0xf, srate); - snd_soc_update_bits(codec, ML26124_PLLNL, 0xff, coeff_div[i].pllnl); - snd_soc_update_bits(codec, ML26124_PLLNH, 0x1, coeff_div[i].pllnh); - snd_soc_update_bits(codec, ML26124_PLLML, 0xff, coeff_div[i].pllml); - snd_soc_update_bits(codec, ML26124_PLLMH, 0x3f, coeff_div[i].pllmh); - snd_soc_update_bits(codec, ML26124_PLLDIV, 0x1f, coeff_div[i].plldiv); + snd_soc_component_update_bits(component, ML26124_SMPLING_RATE, 0xf, srate); + snd_soc_component_update_bits(component, ML26124_PLLNL, 0xff, coeff_div[i].pllnl); + snd_soc_component_update_bits(component, ML26124_PLLNH, 0x1, coeff_div[i].pllnh); + snd_soc_component_update_bits(component, ML26124_PLLML, 0xff, coeff_div[i].pllml); + snd_soc_component_update_bits(component, ML26124_PLLMH, 0x3f, coeff_div[i].pllmh); + snd_soc_component_update_bits(component, ML26124_PLLDIV, 0x1f, coeff_div[i].plldiv); return 0; } static int ml26124_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); switch (priv->substream->stream) { case SNDRV_PCM_STREAM_CAPTURE: - snd_soc_update_bits(codec, ML26124_REC_PLYBAK_RUN, BIT(0), 1); + snd_soc_component_update_bits(component, ML26124_REC_PLYBAK_RUN, BIT(0), 1); break; case SNDRV_PCM_STREAM_PLAYBACK: - snd_soc_update_bits(codec, ML26124_REC_PLYBAK_RUN, BIT(1), 2); + snd_soc_component_update_bits(component, ML26124_REC_PLYBAK_RUN, BIT(1), 2); break; } if (mute) - snd_soc_update_bits(codec, ML26124_DVOL_CTL, BIT(4), + snd_soc_component_update_bits(component, ML26124_DVOL_CTL, BIT(4), DVOL_CTL_DVMUTE_ON); else - snd_soc_update_bits(codec, ML26124_DVOL_CTL, BIT(4), + snd_soc_component_update_bits(component, ML26124_DVOL_CTL, BIT(4), DVOL_CTL_DVMUTE_OFF); return 0; @@ -413,7 +413,7 @@ static int ml26124_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { unsigned char mode; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -426,7 +426,7 @@ static int ml26124_set_dai_fmt(struct snd_soc_dai *codec_dai, default: return -EINVAL; } - snd_soc_update_bits(codec, ML26124_SAI_MODE_SEL, BIT(0), mode); + snd_soc_component_update_bits(component, ML26124_SAI_MODE_SEL, BIT(0), mode); /* interface format */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -450,8 +450,8 @@ static int ml26124_set_dai_fmt(struct snd_soc_dai *codec_dai, static int ml26124_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); switch (clk_id) { case ML26124_USE_PLLOUT: @@ -469,17 +469,17 @@ static int ml26124_set_dai_sysclk(struct snd_soc_dai *codec_dai, return 0; } -static int ml26124_set_bias_level(struct snd_soc_codec *codec, +static int ml26124_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec); + struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: - snd_soc_update_bits(codec, ML26124_PW_SPAMP_PW_MNG, + snd_soc_component_update_bits(component, ML26124_PW_SPAMP_PW_MNG, ML26124_R26_MASK, ML26124_BLT_PREAMP_ON); msleep(100); - snd_soc_update_bits(codec, ML26124_PW_SPAMP_PW_MNG, + snd_soc_component_update_bits(component, ML26124_PW_SPAMP_PW_MNG, ML26124_R26_MASK, ML26124_MICBEN_ON | ML26124_BLT_ALL_ON); break; @@ -487,8 +487,8 @@ static int ml26124_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: /* VMID ON */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_update_bits(codec, ML26124_PW_REF_PW_MNG, + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_update_bits(component, ML26124_PW_REF_PW_MNG, ML26124_VMID, ML26124_VMID); msleep(500); regcache_sync(priv->regmap); @@ -496,7 +496,7 @@ static int ml26124_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: /* VMID OFF */ - snd_soc_update_bits(codec, ML26124_PW_REF_PW_MNG, + snd_soc_component_update_bits(component, ML26124_PW_REF_PW_MNG, ML26124_VMID, 0); break; } @@ -528,27 +528,29 @@ static struct snd_soc_dai_driver ml26124_dai = { .symmetric_rates = 1, }; -static int ml26124_probe(struct snd_soc_codec *codec) +static int ml26124_probe(struct snd_soc_component *component) { /* Software Reset */ - snd_soc_update_bits(codec, ML26124_SW_RST, 0x01, 1); - snd_soc_update_bits(codec, ML26124_SW_RST, 0x01, 0); + snd_soc_component_update_bits(component, ML26124_SW_RST, 0x01, 1); + snd_soc_component_update_bits(component, ML26124_SW_RST, 0x01, 0); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_ml26124 = { - .probe = ml26124_probe, - .set_bias_level = ml26124_set_bias_level, - .suspend_bias_off = true, - .component_driver = { - .controls = ml26124_snd_controls, - .num_controls = ARRAY_SIZE(ml26124_snd_controls), - .dapm_widgets = ml26124_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ml26124_dapm_widgets), - .dapm_routes = ml26124_intercon, - .num_dapm_routes = ARRAY_SIZE(ml26124_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_ml26124 = { + .probe = ml26124_probe, + .set_bias_level = ml26124_set_bias_level, + .controls = ml26124_snd_controls, + .num_controls = ARRAY_SIZE(ml26124_snd_controls), + .dapm_widgets = ml26124_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ml26124_dapm_widgets), + .dapm_routes = ml26124_intercon, + .num_dapm_routes = ARRAY_SIZE(ml26124_intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ml26124_i2c_regmap = { @@ -580,14 +582,8 @@ static int ml26124_i2c_probe(struct i2c_client *i2c, return ret; } - return snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_ml26124, &ml26124_dai, 1); -} - -static int ml26124_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; + return devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_ml26124, &ml26124_dai, 1); } static const struct i2c_device_id ml26124_i2c_id[] = { @@ -601,7 +597,6 @@ static struct i2c_driver ml26124_i2c_driver = { .name = "ml26124", }, .probe = ml26124_i2c_probe, - .remove = ml26124_i2c_remove, .id_table = ml26124_i2c_id, }; diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index 44062bb7bf2f..12ee83d52405 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -288,7 +288,7 @@ struct pm8916_wcd_analog_priv { int mbhc_btn0_released; bool detect_accessory_type; struct clk *mclk; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; struct snd_soc_jack *jack; bool hphl_jack_type_normally_open; @@ -338,18 +338,18 @@ static const struct snd_kcontrol_new pm8916_wcd_analog_snd_controls[] = { SOC_SINGLE_TLV("ADC3 Volume", CDC_A_TX_3_EN, 3, 8, 0, analog_gain), }; -static void pm8916_wcd_analog_micbias_enable(struct snd_soc_codec *codec) +static void pm8916_wcd_analog_micbias_enable(struct snd_soc_component *component) { - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); - snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, + snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL, MICB_1_CTL_EXT_PRECHARG_EN_MASK | MICB_1_CTL_INT_PRECHARG_BYP_MASK, MICB_1_CTL_INT_PRECHARG_BYP_EXT_PRECHRG_SEL | MICB_1_CTL_EXT_PRECHARG_EN_ENABLE); if (wcd->micbias_mv) { - snd_soc_update_bits(codec, CDC_A_MICB_1_VAL, + snd_soc_component_update_bits(component, CDC_A_MICB_1_VAL, MICB_1_VAL_MICB_OUT_VAL_MASK, MICB_VOLTAGE_REGVAL(wcd->micbias_mv)); /* @@ -360,20 +360,20 @@ static void pm8916_wcd_analog_micbias_enable(struct snd_soc_codec *codec) msleep(50); } - snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, + snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL, MICB_1_CTL_EXT_PRECHARG_EN_MASK | MICB_1_CTL_INT_PRECHARG_BYP_MASK, 0); } -static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_codec - *codec, int event, +static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_component + *component, int event, int reg, unsigned int cap_mode) { switch (event) { case SND_SOC_DAPM_POST_PMU: - pm8916_wcd_analog_micbias_enable(codec); - snd_soc_update_bits(codec, CDC_A_MICB_1_EN, + pm8916_wcd_analog_micbias_enable(component); + snd_soc_component_update_bits(component, CDC_A_MICB_1_EN, MICB_1_EN_BYP_CAP_MASK, cap_mode); break; } @@ -381,25 +381,25 @@ static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_codec return 0; } -static int pm8916_wcd_analog_enable_micbias_int(struct snd_soc_codec - *codec, int event, +static int pm8916_wcd_analog_enable_micbias_int(struct snd_soc_component + *component, int event, int reg, u32 cap_mode) { switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, CDC_A_MICB_1_INT_RBIAS, + snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS, MICB_1_INT_TX2_INT_RBIAS_EN_MASK, MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE); - snd_soc_update_bits(codec, reg, MICB_1_EN_PULL_DOWN_EN_MASK, 0); - snd_soc_update_bits(codec, CDC_A_MICB_1_EN, + snd_soc_component_update_bits(component, reg, MICB_1_EN_PULL_DOWN_EN_MASK, 0); + snd_soc_component_update_bits(component, CDC_A_MICB_1_EN, MICB_1_EN_OPA_STG2_TAIL_CURR_MASK, MICB_1_EN_OPA_STG2_TAIL_CURR_1_60UA); break; case SND_SOC_DAPM_POST_PMU: - pm8916_wcd_analog_micbias_enable(codec); - snd_soc_update_bits(codec, CDC_A_MICB_1_EN, + pm8916_wcd_analog_micbias_enable(component); + snd_soc_component_update_bits(component, CDC_A_MICB_1_EN, MICB_1_EN_BYP_CAP_MASK, cap_mode); break; } @@ -412,10 +412,10 @@ static int pm8916_wcd_analog_enable_micbias_ext1(struct *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); - return pm8916_wcd_analog_enable_micbias_ext(codec, event, w->reg, + return pm8916_wcd_analog_enable_micbias_ext(component, event, w->reg, wcd->micbias1_cap_mode); } @@ -424,10 +424,10 @@ static int pm8916_wcd_analog_enable_micbias_ext2(struct *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); - return pm8916_wcd_analog_enable_micbias_ext(codec, event, w->reg, + return pm8916_wcd_analog_enable_micbias_ext(component, event, w->reg, wcd->micbias2_cap_mode); } @@ -437,35 +437,35 @@ static int pm8916_wcd_analog_enable_micbias_int1(struct *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); - return pm8916_wcd_analog_enable_micbias_int(codec, event, w->reg, + return pm8916_wcd_analog_enable_micbias_int(component, event, w->reg, wcd->micbias1_cap_mode); } static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, bool micbias2_enabled) { - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; u32 coarse, fine, reg_val, reg_addr; int *vrefs, i; if (!micbias2_enabled) { /* use internal 100uA Current source */ /* Enable internal 2.2k Internal Rbias Resistor */ - snd_soc_update_bits(codec, CDC_A_MICB_1_INT_RBIAS, + snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS, MICB_1_INT_TX2_INT_RBIAS_EN_MASK, MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE); /* Remove pull down on MIC BIAS2 */ - snd_soc_update_bits(codec, CDC_A_MICB_2_EN, + snd_soc_component_update_bits(component, CDC_A_MICB_2_EN, CDC_A_MICB_2_PULL_DOWN_EN_MASK, 0); /* enable 100uA internal current source */ - snd_soc_update_bits(codec, CDC_A_MBHC_FSM_CTL, + snd_soc_component_update_bits(component, CDC_A_MBHC_FSM_CTL, CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_MASK, CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_I_100UA); } - snd_soc_update_bits(codec, CDC_A_MBHC_FSM_CTL, + snd_soc_component_update_bits(component, CDC_A_MBHC_FSM_CTL, CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK, CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN); @@ -482,7 +482,7 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, fine = ((vrefs[i] % 100) / 12); reg_val = (coarse << CDC_A_MBHC_BTN_VREF_COARSE_SHIFT) | (fine << CDC_A_MBHC_BTN_VREF_FINE_SHIFT); - snd_soc_update_bits(codec, reg_addr, + snd_soc_component_update_bits(component, reg_addr, CDC_A_MBHC_BTN_VREF_MASK, reg_val); reg_addr++; @@ -493,12 +493,12 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd) { - struct snd_soc_codec *codec = wcd->codec; + struct snd_soc_component *component = wcd->component; bool micbias_enabled = false; u32 plug_type = 0; u32 int_en_mask; - snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1, + snd_soc_component_write(component, CDC_A_MBHC_DET_CTL_1, CDC_A_MBHC_DET_CTL_L_DET_EN | CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION | CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO | @@ -510,23 +510,23 @@ static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd) if (wcd->gnd_jack_type_normally_open) plug_type |= CDC_A_GND_PLUG_TYPE_NO; - snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2, + snd_soc_component_write(component, CDC_A_MBHC_DET_CTL_2, CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 | CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD | plug_type | CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN); - snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER, + snd_soc_component_write(component, CDC_A_MBHC_DBNC_TIMER, CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS | CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS); /* enable MBHC clock */ - snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_DIG_CLK_CTL, DIG_CLK_CTL_D_MBHC_CLK_EN_MASK, DIG_CLK_CTL_D_MBHC_CLK_EN); - if (snd_soc_read(codec, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE) + if (snd_soc_component_read32(component, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE) micbias_enabled = true; pm8916_mbhc_configure_bias(wcd, micbias_enabled); @@ -535,8 +535,8 @@ static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd) if (wcd->mbhc_btn_enabled) int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET; - snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0); - snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask); + snd_soc_component_update_bits(component, CDC_D_INT_EN_CLR, int_en_mask, 0); + snd_soc_component_update_bits(component, CDC_D_INT_EN_SET, int_en_mask, int_en_mask); wcd->mbhc_btn0_released = false; wcd->detect_accessory_type = true; } @@ -546,8 +546,8 @@ static int pm8916_wcd_analog_enable_micbias_int2(struct *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -558,7 +558,7 @@ static int pm8916_wcd_analog_enable_micbias_int2(struct break; } - return pm8916_wcd_analog_enable_micbias_int(codec, event, w->reg, + return pm8916_wcd_analog_enable_micbias_int(component, event, w->reg, wcd->micbias2_cap_mode); } @@ -566,7 +566,7 @@ static int pm8916_wcd_analog_enable_adc(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 snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); u16 adc_reg = CDC_A_TX_1_2_TEST_CTL_2; u8 init_bit_shift; @@ -578,7 +578,7 @@ static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: if (w->reg == CDC_A_TX_2_EN) - snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, + snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL, MICB_1_CTL_CFILT_REF_SEL_MASK, MICB_1_CTL_CFILT_REF_SEL_HPF_REF); /* @@ -587,17 +587,17 @@ static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w, * happen when the input voltage is changing too much. */ usleep_range(10000, 10010); - snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, + snd_soc_component_update_bits(component, adc_reg, 1 << init_bit_shift, 1 << init_bit_shift); switch (w->reg) { case CDC_A_TX_1_EN: - snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX1_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX1_CTL, CONN_TX1_SERIAL_TX1_MUX, CONN_TX1_SERIAL_TX1_ADC_1); break; case CDC_A_TX_2_EN: case CDC_A_TX_3_EN: - snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX2_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX2_CTL, CONN_TX2_SERIAL_TX2_MUX, CONN_TX2_SERIAL_TX2_ADC_2); break; @@ -609,21 +609,21 @@ static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w, * to reduce the tx pop */ usleep_range(12000, 12010); - snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 0x00); + snd_soc_component_update_bits(component, adc_reg, 1 << init_bit_shift, 0x00); break; case SND_SOC_DAPM_POST_PMD: switch (w->reg) { case CDC_A_TX_1_EN: - snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX1_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX1_CTL, CONN_TX1_SERIAL_TX1_MUX, CONN_TX1_SERIAL_TX1_ZERO); break; case CDC_A_TX_2_EN: - snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, + snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL, MICB_1_CTL_CFILT_REF_SEL_MASK, 0); /* fall through */ case CDC_A_TX_3_EN: - snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX2_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX2_CTL, CONN_TX2_SERIAL_TX2_MUX, CONN_TX2_SERIAL_TX2_ZERO); break; @@ -639,11 +639,11 @@ static int pm8916_wcd_analog_enable_spk_pa(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 snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, CDC_A_SPKR_PWRSTG_CTL, + snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL, SPKR_PWRSTG_CTL_DAC_EN_MASK | SPKR_PWRSTG_CTL_BBM_MASK | SPKR_PWRSTG_CTL_HBRDGE_EN_MASK | @@ -653,29 +653,29 @@ static int pm8916_wcd_analog_enable_spk_pa(struct snd_soc_dapm_widget *w, SPKR_PWRSTG_CTL_HBRDGE_EN | SPKR_PWRSTG_CTL_CLAMP_EN); - snd_soc_update_bits(codec, CDC_A_RX_EAR_CTL, + snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL, RX_EAR_CTL_SPK_VBAT_LDO_EN_MASK, RX_EAR_CTL_SPK_VBAT_LDO_EN_ENABLE); break; case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, CDC_A_SPKR_DRV_CTL, + snd_soc_component_update_bits(component, CDC_A_SPKR_DRV_CTL, SPKR_DRV_CTL_DEF_MASK, SPKR_DRV_CTL_DEF_VAL); - snd_soc_update_bits(codec, w->reg, + snd_soc_component_update_bits(component, w->reg, SPKR_DRV_CLASSD_PA_EN_MASK, SPKR_DRV_CLASSD_PA_EN_ENABLE); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, CDC_A_SPKR_PWRSTG_CTL, + snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL, SPKR_PWRSTG_CTL_DAC_EN_MASK| SPKR_PWRSTG_CTL_BBM_MASK | SPKR_PWRSTG_CTL_HBRDGE_EN_MASK | SPKR_PWRSTG_CTL_CLAMP_EN_MASK, 0); - snd_soc_update_bits(codec, CDC_A_SPKR_DAC_CTL, + snd_soc_component_update_bits(component, CDC_A_SPKR_DAC_CTL, SPKR_DAC_CTL_DAC_RESET_MASK, SPKR_DAC_CTL_DAC_RESET_NORMAL); - snd_soc_update_bits(codec, CDC_A_RX_EAR_CTL, + snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL, RX_EAR_CTL_SPK_VBAT_LDO_EN_MASK, 0); break; } @@ -701,36 +701,36 @@ static const struct reg_default wcd_reg_defaults_2_0[] = { {CDC_A_MASTER_BIAS_CTL, 0x30}, }; -static int pm8916_wcd_analog_probe(struct snd_soc_codec *codec) +static int pm8916_wcd_analog_probe(struct snd_soc_component *component) { - struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(codec->dev); + struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(component->dev); int err, reg; err = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); if (err != 0) { - dev_err(codec->dev, "failed to enable regulators (%d)\n", err); + dev_err(component->dev, "failed to enable regulators (%d)\n", err); return err; } - snd_soc_codec_init_regmap(codec, - dev_get_regmap(codec->dev->parent, NULL)); - snd_soc_codec_set_drvdata(codec, priv); - priv->pmic_rev = snd_soc_read(codec, CDC_D_REVISION1); - priv->codec_version = snd_soc_read(codec, CDC_D_PERPH_SUBTYPE); + snd_soc_component_init_regmap(component, + dev_get_regmap(component->dev->parent, NULL)); + snd_soc_component_set_drvdata(component, priv); + priv->pmic_rev = snd_soc_component_read32(component, CDC_D_REVISION1); + priv->codec_version = snd_soc_component_read32(component, CDC_D_PERPH_SUBTYPE); - dev_info(codec->dev, "PMIC REV: %d\t CODEC Version: %d\n", + dev_info(component->dev, "PMIC REV: %d\t CODEC Version: %d\n", priv->pmic_rev, priv->codec_version); - snd_soc_write(codec, CDC_D_PERPH_RESET_CTL4, 0x01); - snd_soc_write(codec, CDC_A_PERPH_RESET_CTL4, 0x01); + snd_soc_component_write(component, CDC_D_PERPH_RESET_CTL4, 0x01); + snd_soc_component_write(component, CDC_A_PERPH_RESET_CTL4, 0x01); for (reg = 0; reg < ARRAY_SIZE(wcd_reg_defaults_2_0); reg++) - snd_soc_write(codec, wcd_reg_defaults_2_0[reg].reg, + snd_soc_component_write(component, wcd_reg_defaults_2_0[reg].reg, wcd_reg_defaults_2_0[reg].def); - priv->codec = codec; + priv->component = component; - snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_RST_CTL, RST_CTL_DIG_SW_RST_N_MASK, RST_CTL_DIG_SW_RST_N_REMOVE_RESET); @@ -739,14 +739,14 @@ static int pm8916_wcd_analog_probe(struct snd_soc_codec *codec) return 0; } -static int pm8916_wcd_analog_remove(struct snd_soc_codec *codec) +static void pm8916_wcd_analog_remove(struct snd_soc_component *component) { - struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(codec->dev); + struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(component->dev); - snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_RST_CTL, RST_CTL_DIG_SW_RST_N_MASK, 0); - return regulator_bulk_disable(ARRAY_SIZE(priv->supplies), + regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); } @@ -934,11 +934,11 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("A_MCLK2", CDC_D_CDC_TOP_CLK_CTL, 3, 0, NULL, 0), }; -static int pm8916_wcd_analog_set_jack(struct snd_soc_codec *codec, +static int pm8916_wcd_analog_set_jack(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data) { - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); wcd->jack = jack; @@ -950,8 +950,8 @@ static irqreturn_t mbhc_btn_release_irq_handler(int irq, void *arg) struct pm8916_wcd_analog_priv *priv = arg; if (priv->detect_accessory_type) { - struct snd_soc_codec *codec = priv->codec; - u32 val = snd_soc_read(codec, CDC_A_MBHC_RESULT_1); + struct snd_soc_component *component = priv->component; + u32 val = snd_soc_component_read32(component, CDC_A_MBHC_RESULT_1); /* check if its BTN0 thats released */ if ((val != -1) && !(val & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK)) @@ -967,10 +967,10 @@ static irqreturn_t mbhc_btn_release_irq_handler(int irq, void *arg) static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg) { struct pm8916_wcd_analog_priv *priv = arg; - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; u32 btn_result; - btn_result = snd_soc_read(codec, CDC_A_MBHC_RESULT_1) & + btn_result = snd_soc_component_read32(component, CDC_A_MBHC_RESULT_1) & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK; switch (btn_result) { @@ -993,7 +993,7 @@ static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg) SND_JACK_BTN_0, btn_mask); break; default: - dev_err(codec->dev, + dev_err(component->dev, "Unexpected button press result (%x)", btn_result); break; } @@ -1004,15 +1004,15 @@ static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg) static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg) { struct pm8916_wcd_analog_priv *priv = arg; - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; bool ins = false; - if (snd_soc_read(codec, CDC_A_MBHC_DET_CTL_1) & + if (snd_soc_component_read32(component, CDC_A_MBHC_DET_CTL_1) & CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK) ins = true; /* Set the detection type appropriately */ - snd_soc_update_bits(codec, CDC_A_MBHC_DET_CTL_1, + snd_soc_component_update_bits(component, CDC_A_MBHC_DET_CTL_1, CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK, (!ins << CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_SHIFT)); @@ -1020,7 +1020,7 @@ static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg) if (ins) { /* hs insertion */ bool micbias_enabled = false; - if (snd_soc_read(codec, CDC_A_MICB_2_EN) & + if (snd_soc_component_read32(component, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE) micbias_enabled = true; @@ -1075,18 +1075,20 @@ static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { }, }; -static const struct snd_soc_codec_driver pm8916_wcd_analog = { - .probe = pm8916_wcd_analog_probe, - .remove = pm8916_wcd_analog_remove, - .set_jack = pm8916_wcd_analog_set_jack, - .component_driver = { - .controls = pm8916_wcd_analog_snd_controls, - .num_controls = ARRAY_SIZE(pm8916_wcd_analog_snd_controls), - .dapm_widgets = pm8916_wcd_analog_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(pm8916_wcd_analog_dapm_widgets), - .dapm_routes = pm8916_wcd_analog_audio_map, - .num_dapm_routes = ARRAY_SIZE(pm8916_wcd_analog_audio_map), - }, +static const struct snd_soc_component_driver pm8916_wcd_analog = { + .probe = pm8916_wcd_analog_probe, + .remove = pm8916_wcd_analog_remove, + .set_jack = pm8916_wcd_analog_set_jack, + .controls = pm8916_wcd_analog_snd_controls, + .num_controls = ARRAY_SIZE(pm8916_wcd_analog_snd_controls), + .dapm_widgets = pm8916_wcd_analog_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pm8916_wcd_analog_dapm_widgets), + .dapm_routes = pm8916_wcd_analog_audio_map, + .num_dapm_routes = ARRAY_SIZE(pm8916_wcd_analog_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int pm8916_wcd_analog_parse_dt(struct device *dev, @@ -1223,7 +1225,7 @@ static int pm8916_wcd_analog_spmi_probe(struct platform_device *pdev) dev_set_drvdata(dev, priv); - return snd_soc_register_codec(dev, &pm8916_wcd_analog, + return devm_snd_soc_register_component(dev, &pm8916_wcd_analog, pm8916_wcd_analog_dai, ARRAY_SIZE(pm8916_wcd_analog_dai)); } @@ -1232,7 +1234,6 @@ static int pm8916_wcd_analog_spmi_remove(struct platform_device *pdev) { struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_codec(&pdev->dev); clk_disable_unprepare(priv->mclk); return 0; diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index 43837a3bf1ca..73cce33fa439 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -343,7 +343,7 @@ static int mt2701_btmrg_hw_params(struct snd_pcm_substream *substream, stream_fs = params_rate(params); if ((stream_fs != 8000) && (stream_fs != 16000)) { - dev_err(afe->dev, "%s() btmgr not supprt this stream_fs %d\n", + dev_err(afe->dev, "%s() btmgr not support this stream_fs %d\n", __func__, stream_fs); return -EINVAL; } |