From 9123ea9ff5bcdfdb89f7ad6f8efc56f2ca55a071 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:12:39 +0000 Subject: ASoC: ak4613: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4613.c | 73 ++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 36 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/ak4613.c b/sound/soc/codecs/ak4613.c index 3d1cf4784e87..a7b1e3a1ec58 100644 --- a/sound/soc/codecs/ak4613.c +++ b/sound/soc/codecs/ak4613.c @@ -243,9 +243,9 @@ static const struct snd_soc_dapm_route ak4613_intercon[] = { static void ak4613_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); - struct device *dev = codec->dev; + struct snd_soc_component *component = dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); + struct device *dev = component->dev; mutex_lock(&priv->lock); priv->cnt--; @@ -305,8 +305,8 @@ static void ak4613_hw_constraints(struct ak4613_priv *priv, static int ak4613_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); priv->cnt++; @@ -318,8 +318,8 @@ static int ak4613_dai_startup(struct snd_pcm_substream *substream, static int ak4613_dai_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); priv->sysclk = freq; @@ -328,8 +328,8 @@ static int ak4613_dai_set_sysclk(struct snd_soc_dai *codec_dai, static int ak4613_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); fmt &= SND_SOC_DAIFMT_FORMAT_MASK; @@ -366,10 +366,10 @@ static int ak4613_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 ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); const struct ak4613_interface *iface; - struct device *dev = codec->dev; + struct device *dev = component->dev; unsigned int width = params_width(params); unsigned int fmt = priv->fmt; unsigned int rate; @@ -434,11 +434,11 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream, fmt_ctrl = AUDIO_IFACE_TO_VAL(iface); - snd_soc_update_bits(codec, CTRL1, FMT_MASK, fmt_ctrl); - snd_soc_update_bits(codec, CTRL2, DFS_MASK, ctrl2); + snd_soc_component_update_bits(component, CTRL1, FMT_MASK, fmt_ctrl); + snd_soc_component_update_bits(component, CTRL2, DFS_MASK, ctrl2); - snd_soc_update_bits(codec, ICTRL, ICTRL_MASK, priv->ic); - snd_soc_update_bits(codec, OCTRL, OCTRL_MASK, priv->oc); + snd_soc_component_update_bits(component, ICTRL, ICTRL_MASK, priv->ic); + snd_soc_component_update_bits(component, OCTRL, OCTRL_MASK, priv->oc); hw_params_end: if (ret < 0) @@ -447,7 +447,7 @@ hw_params_end: return ret; } -static int ak4613_set_bias_level(struct snd_soc_codec *codec, +static int ak4613_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { u8 mgmt1 = 0; @@ -467,7 +467,7 @@ static int ak4613_set_bias_level(struct snd_soc_codec *codec, break; } - snd_soc_write(codec, PW_MGMT1, mgmt1); + snd_soc_component_write(component, PW_MGMT1, mgmt1); return 0; } @@ -504,8 +504,8 @@ static void ak4613_dummy_write(struct work_struct *work) static int ak4613_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); /* * FIXME @@ -537,7 +537,7 @@ static int ak4613_dai_trigger(struct snd_pcm_substream *substream, int cmd, if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) return 0; - priv->component = &codec->component; + priv->component = component; schedule_work(&priv->dummy_write_work); return 0; @@ -582,35 +582,37 @@ static struct snd_soc_dai_driver ak4613_dai = { .symmetric_rates = 1, }; -static int ak4613_suspend(struct snd_soc_codec *codec) +static int ak4613_suspend(struct snd_soc_component *component) { - struct regmap *regmap = dev_get_regmap(codec->dev, NULL); + struct regmap *regmap = dev_get_regmap(component->dev, NULL); regcache_cache_only(regmap, true); regcache_mark_dirty(regmap); return 0; } -static int ak4613_resume(struct snd_soc_codec *codec) +static int ak4613_resume(struct snd_soc_component *component) { - struct regmap *regmap = dev_get_regmap(codec->dev, NULL); + struct regmap *regmap = dev_get_regmap(component->dev, NULL); regcache_cache_only(regmap, false); return regcache_sync(regmap); } -static const struct snd_soc_codec_driver soc_codec_dev_ak4613 = { +static const struct snd_soc_component_driver soc_component_dev_ak4613 = { .suspend = ak4613_suspend, .resume = ak4613_resume, .set_bias_level = ak4613_set_bias_level, - .component_driver = { - .controls = ak4613_snd_controls, - .num_controls = ARRAY_SIZE(ak4613_snd_controls), - .dapm_widgets = ak4613_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4613_dapm_widgets), - .dapm_routes = ak4613_intercon, - .num_dapm_routes = ARRAY_SIZE(ak4613_intercon), - }, + .controls = ak4613_snd_controls, + .num_controls = ARRAY_SIZE(ak4613_snd_controls), + .dapm_widgets = ak4613_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4613_dapm_widgets), + .dapm_routes = ak4613_intercon, + .num_dapm_routes = ARRAY_SIZE(ak4613_intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static void ak4613_parse_of(struct ak4613_priv *priv, @@ -677,13 +679,12 @@ static int ak4613_i2c_probe(struct i2c_client *i2c, if (IS_ERR(regmap)) return PTR_ERR(regmap); - return snd_soc_register_codec(dev, &soc_codec_dev_ak4613, + return devm_snd_soc_register_component(dev, &soc_component_dev_ak4613, &ak4613_dai, 1); } static int ak4613_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } -- cgit v1.2.3 From 43c5d0f05ec55aa71680744ffcaa1aa6fd8a9bab Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:13:07 +0000 Subject: ASoC: ak4642: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4642.c | 105 ++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 55 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 29530c567bd9..9c35e91d412d 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -178,19 +178,19 @@ static const struct snd_kcontrol_new ak4642_lout_mixer_controls[] = { static int ak4642_lout_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 snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMU: /* Power save mode ON */ - snd_soc_update_bits(codec, SG_SL2, LOPS, LOPS); + snd_soc_component_update_bits(component, SG_SL2, LOPS, LOPS); break; case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMD: /* Power save mode OFF */ msleep(300); - snd_soc_update_bits(codec, SG_SL2, LOPS, 0); + snd_soc_component_update_bits(component, SG_SL2, LOPS, 0); break; } @@ -282,7 +282,7 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (is_play) { /* @@ -295,8 +295,8 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, * This operation came from example code of * "ASAHI KASEI AK4642" (japanese) manual p97. */ - snd_soc_write(codec, L_IVC, 0x91); /* volume */ - snd_soc_write(codec, R_IVC, 0x91); /* volume */ + snd_soc_component_write(component, L_IVC, 0x91); /* volume */ + snd_soc_component_write(component, R_IVC, 0x91); /* volume */ } else { /* * start stereo input @@ -311,11 +311,11 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, * This operation came from example code of * "ASAHI KASEI AK4642" (japanese) manual p94. */ - snd_soc_update_bits(codec, SG_SL1, PMMP | MGAIN0, PMMP | MGAIN0); - snd_soc_write(codec, TIMER, ZTM(0x3) | WTM(0x3)); - snd_soc_write(codec, ALC_CTL1, ALC | LMTH0); - snd_soc_update_bits(codec, PW_MGMT1, PMADL, PMADL); - snd_soc_update_bits(codec, PW_MGMT3, PMADR, PMADR); + snd_soc_component_update_bits(component, SG_SL1, PMMP | MGAIN0, PMMP | MGAIN0); + snd_soc_component_write(component, TIMER, ZTM(0x3) | WTM(0x3)); + snd_soc_component_write(component, ALC_CTL1, ALC | LMTH0); + snd_soc_component_update_bits(component, PW_MGMT1, PMADL, PMADL); + snd_soc_component_update_bits(component, PW_MGMT3, PMADR, PMADR); } return 0; @@ -325,22 +325,22 @@ static void ak4642_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (is_play) { } else { /* stop stereo input */ - snd_soc_update_bits(codec, PW_MGMT1, PMADL, 0); - snd_soc_update_bits(codec, PW_MGMT3, PMADR, 0); - snd_soc_update_bits(codec, ALC_CTL1, ALC, 0); + snd_soc_component_update_bits(component, PW_MGMT1, PMADL, 0); + snd_soc_component_update_bits(component, PW_MGMT3, PMADR, 0); + snd_soc_component_update_bits(component, ALC_CTL1, ALC, 0); } } static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ak4642_priv *priv = snd_soc_component_get_drvdata(component); u8 pll; int extended_freq = 0; @@ -382,14 +382,14 @@ static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai, if (extended_freq && !priv->drvdata->extended_frequencies) return -EINVAL; - snd_soc_update_bits(codec, MD_CTL1, PLL_MASK, pll); + snd_soc_component_update_bits(component, MD_CTL1, PLL_MASK, pll); return 0; } static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 data; u8 bcko; @@ -407,8 +407,8 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) default: return -EINVAL; } - snd_soc_update_bits(codec, PW_MGMT2, MS | MCKO | PMPLL, data); - snd_soc_update_bits(codec, MD_CTL1, BCKO_MASK, bcko); + snd_soc_component_update_bits(component, PW_MGMT2, MS | MCKO | PMPLL, data); + snd_soc_component_update_bits(component, MD_CTL1, BCKO_MASK, bcko); /* format type */ data = 0; @@ -425,12 +425,12 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) default: return -EINVAL; } - snd_soc_update_bits(codec, MD_CTL1, DIF_MASK, data); + snd_soc_component_update_bits(component, MD_CTL1, DIF_MASK, data); return 0; } -static int ak4642_set_mcko(struct snd_soc_codec *codec, +static int ak4642_set_mcko(struct snd_soc_component *component, u32 frequency) { static const u32 fs_list[] = { @@ -458,7 +458,7 @@ static int ak4642_set_mcko(struct snd_soc_codec *codec, for (ps = 0; ps < ARRAY_SIZE(ps_list); ps++) { for (fs = 0; fs < ARRAY_SIZE(fs_list); fs++) { if (frequency == ps_list[ps] * fs_list[fs]) { - snd_soc_write(codec, MD_CTL2, + snd_soc_component_write(component, MD_CTL2, PSs(ps) | FSs(fs)); return 0; } @@ -472,25 +472,25 @@ static int ak4642_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 ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4642_priv *priv = snd_soc_component_get_drvdata(component); u32 rate = clk_get_rate(priv->mcko); if (!rate) rate = params_rate(params) * 256; - return ak4642_set_mcko(codec, rate); + return ak4642_set_mcko(component, rate); } -static int ak4642_set_bias_level(struct snd_soc_codec *codec, +static int ak4642_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_OFF: - snd_soc_write(codec, PW_MGMT1, 0x00); + snd_soc_component_write(component, PW_MGMT1, 0x00); break; default: - snd_soc_update_bits(codec, PW_MGMT1, PMVCM, PMVCM); + snd_soc_component_update_bits(component, PW_MGMT1, PMVCM, PMVCM); break; } @@ -523,46 +523,48 @@ static struct snd_soc_dai_driver ak4642_dai = { .symmetric_rates = 1, }; -static int ak4642_suspend(struct snd_soc_codec *codec) +static int ak4642_suspend(struct snd_soc_component *component) { - struct regmap *regmap = dev_get_regmap(codec->dev, NULL); + struct regmap *regmap = dev_get_regmap(component->dev, NULL); regcache_cache_only(regmap, true); regcache_mark_dirty(regmap); return 0; } -static int ak4642_resume(struct snd_soc_codec *codec) +static int ak4642_resume(struct snd_soc_component *component) { - struct regmap *regmap = dev_get_regmap(codec->dev, NULL); + struct regmap *regmap = dev_get_regmap(component->dev, NULL); regcache_cache_only(regmap, false); regcache_sync(regmap); return 0; } -static int ak4642_probe(struct snd_soc_codec *codec) +static int ak4642_probe(struct snd_soc_component *component) { - struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); + struct ak4642_priv *priv = snd_soc_component_get_drvdata(component); if (priv->mcko) - ak4642_set_mcko(codec, clk_get_rate(priv->mcko)); + ak4642_set_mcko(component, clk_get_rate(priv->mcko)); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_ak4642 = { +static const struct snd_soc_component_driver soc_component_dev_ak4642 = { .probe = ak4642_probe, .suspend = ak4642_suspend, .resume = ak4642_resume, .set_bias_level = ak4642_set_bias_level, - .component_driver = { - .controls = ak4642_snd_controls, - .num_controls = ARRAY_SIZE(ak4642_snd_controls), - .dapm_widgets = ak4642_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), - .dapm_routes = ak4642_intercon, - .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), - }, + .controls = ak4642_snd_controls, + .num_controls = ARRAY_SIZE(ak4642_snd_controls), + .dapm_widgets = ak4642_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), + .dapm_routes = ak4642_intercon, + .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ak4642_regmap = { @@ -675,14 +677,8 @@ static int ak4642_i2c_probe(struct i2c_client *i2c, if (IS_ERR(regmap)) return PTR_ERR(regmap); - return snd_soc_register_codec(dev, - &soc_codec_dev_ak4642, &ak4642_dai, 1); -} - -static int ak4642_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; + return devm_snd_soc_register_component(dev, + &soc_component_dev_ak4642, &ak4642_dai, 1); } static const struct of_device_id ak4642_of_match[] = { @@ -707,7 +703,6 @@ static struct i2c_driver ak4642_i2c_driver = { .of_match_table = ak4642_of_match, }, .probe = ak4642_i2c_probe, - .remove = ak4642_i2c_remove, .id_table = ak4642_i2c_id, }; -- cgit v1.2.3 From 57188d8875894b14f6cdd21c7ee6e96ab66c1f2b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:13:39 +0000 Subject: ASoC: ak4671: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4671.c | 67 ++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 36 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/ak4671.c b/sound/soc/codecs/ak4671.c index dcfdff56fc5a..7133fd69c641 100644 --- a/sound/soc/codecs/ak4671.c +++ b/sound/soc/codecs/ak4671.c @@ -163,15 +163,15 @@ static const struct snd_kcontrol_new ak4671_snd_controls[] = { static int ak4671_out2_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 snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, AK4671_LOUT2_POWER_MANAGERMENT, + snd_soc_component_update_bits(component, AK4671_LOUT2_POWER_MANAGERMENT, AK4671_MUTEN, AK4671_MUTEN); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, AK4671_LOUT2_POWER_MANAGERMENT, + snd_soc_component_update_bits(component, AK4671_LOUT2_POWER_MANAGERMENT, AK4671_MUTEN, 0); break; } @@ -427,10 +427,10 @@ static int ak4671_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 snd_soc_component *component = dai->component; u8 fs; - fs = snd_soc_read(codec, AK4671_PLL_MODE_SELECT0); + fs = snd_soc_component_read32(component, AK4671_PLL_MODE_SELECT0); fs &= ~AK4671_FS; switch (params_rate(params)) { @@ -465,7 +465,7 @@ static int ak4671_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_write(codec, AK4671_PLL_MODE_SELECT0, fs); + snd_soc_component_write(component, AK4671_PLL_MODE_SELECT0, fs); return 0; } @@ -473,10 +473,10 @@ static int ak4671_hw_params(struct snd_pcm_substream *substream, static int ak4671_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 pll; - pll = snd_soc_read(codec, AK4671_PLL_MODE_SELECT0); + pll = snd_soc_component_read32(component, AK4671_PLL_MODE_SELECT0); pll &= ~AK4671_PLL; switch (freq) { @@ -511,19 +511,19 @@ static int ak4671_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, return -EINVAL; } - snd_soc_write(codec, AK4671_PLL_MODE_SELECT0, pll); + snd_soc_component_write(component, AK4671_PLL_MODE_SELECT0, pll); return 0; } static int ak4671_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 mode; u8 format; /* set master/slave audio interface */ - mode = snd_soc_read(codec, AK4671_PLL_MODE_SELECT1); + mode = snd_soc_component_read32(component, AK4671_PLL_MODE_SELECT1); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -537,7 +537,7 @@ static int ak4671_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) } /* interface format */ - format = snd_soc_read(codec, AK4671_FORMAT_SELECT); + format = snd_soc_component_read32(component, AK4671_FORMAT_SELECT); format &= ~AK4671_DIF; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -557,24 +557,24 @@ static int ak4671_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) } /* set mode and format */ - snd_soc_write(codec, AK4671_PLL_MODE_SELECT1, mode); - snd_soc_write(codec, AK4671_FORMAT_SELECT, format); + snd_soc_component_write(component, AK4671_PLL_MODE_SELECT1, mode); + snd_soc_component_write(component, AK4671_FORMAT_SELECT, format); return 0; } -static int ak4671_set_bias_level(struct snd_soc_codec *codec, +static int ak4671_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_STANDBY: - snd_soc_update_bits(codec, AK4671_AD_DA_POWER_MANAGEMENT, + snd_soc_component_update_bits(component, AK4671_AD_DA_POWER_MANAGEMENT, AK4671_PMVCM, AK4671_PMVCM); break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, AK4671_AD_DA_POWER_MANAGEMENT, 0x00); + snd_soc_component_write(component, AK4671_AD_DA_POWER_MANAGEMENT, 0x00); break; } return 0; @@ -610,16 +610,18 @@ static struct snd_soc_dai_driver ak4671_dai = { .ops = &ak4671_dai_ops, }; -static const struct snd_soc_codec_driver soc_codec_dev_ak4671 = { - .set_bias_level = ak4671_set_bias_level, - .component_driver = { - .controls = ak4671_snd_controls, - .num_controls = ARRAY_SIZE(ak4671_snd_controls), - .dapm_widgets = ak4671_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4671_dapm_widgets), - .dapm_routes = ak4671_intercon, - .num_dapm_routes = ARRAY_SIZE(ak4671_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_ak4671 = { + .set_bias_level = ak4671_set_bias_level, + .controls = ak4671_snd_controls, + .num_controls = ARRAY_SIZE(ak4671_snd_controls), + .dapm_widgets = ak4671_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4671_dapm_widgets), + .dapm_routes = ak4671_intercon, + .num_dapm_routes = ARRAY_SIZE(ak4671_intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ak4671_regmap = { @@ -645,17 +647,11 @@ static int ak4671_i2c_probe(struct i2c_client *client, return ret; } - ret = snd_soc_register_codec(&client->dev, - &soc_codec_dev_ak4671, &ak4671_dai, 1); + ret = devm_snd_soc_register_component(&client->dev, + &soc_component_dev_ak4671, &ak4671_dai, 1); return ret; } -static int ak4671_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id ak4671_i2c_id[] = { { "ak4671", 0 }, { } @@ -667,7 +663,6 @@ static struct i2c_driver ak4671_i2c_driver = { .name = "ak4671-codec", }, .probe = ak4671_i2c_probe, - .remove = ak4671_i2c_remove, .id_table = ak4671_i2c_id, }; -- cgit v1.2.3 From 2b5c3e43cb0c5d9f6ab66baabb3dc08ee9f23e7b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:14:32 +0000 Subject: ASoC: ak4641: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4641.c | 91 ++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 45 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/ak4641.c b/sound/soc/codecs/ak4641.c index 60142ff32d4f..05869beff26e 100644 --- a/sound/soc/codecs/ak4641.c +++ b/sound/soc/codecs/ak4641.c @@ -70,9 +70,9 @@ static const struct reg_default ak4641_reg_defaults[] = { static const int deemph_settings[] = {44100, 0, 48000, 32000}; -static int ak4641_set_deemph(struct snd_soc_codec *codec) +static int ak4641_set_deemph(struct snd_soc_component *component) { - struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); int i, best = 0; for (i = 0 ; i < ARRAY_SIZE(deemph_settings); i++) { @@ -86,16 +86,16 @@ static int ak4641_set_deemph(struct snd_soc_codec *codec) best = i; } - dev_dbg(codec->dev, "Set deemphasis %d\n", best); + dev_dbg(component->dev, "Set deemphasis %d\n", best); - return snd_soc_update_bits(codec, AK4641_DAC, 0x3, best); + return snd_soc_component_update_bits(component, AK4641_DAC, 0x3, best); } static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); int deemph = ucontrol->value.integer.value[0]; if (deemph > 1) @@ -103,14 +103,14 @@ static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, ak4641->deemph = deemph; - return ak4641_set_deemph(codec); + return ak4641_set_deemph(component); } static int ak4641_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = ak4641->deemph; return 0; @@ -307,8 +307,8 @@ static const struct snd_soc_dapm_route ak4641_audio_map[] = { static int ak4641_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 ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); ak4641->sysclk = freq; return 0; @@ -318,8 +318,8 @@ static int ak4641_i2s_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 ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); int rate = params_rate(params), fs = 256; u8 mode2; @@ -340,16 +340,16 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, mode2 = (0x0 << 5); break; default: - dev_err(codec->dev, "Error: unsupported fs=%d\n", fs); + dev_err(component->dev, "Error: unsupported fs=%d\n", fs); return -EINVAL; } - snd_soc_update_bits(codec, AK4641_MODE2, (0x3 << 5), mode2); + snd_soc_component_update_bits(component, AK4641_MODE2, (0x3 << 5), mode2); /* Update de-emphasis filter for the new rate */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { ak4641->playback_fs = rate; - ak4641_set_deemph(codec); + ak4641_set_deemph(component); } return 0; @@ -358,7 +358,7 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u8 btif; int ret; @@ -380,7 +380,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - ret = snd_soc_update_bits(codec, AK4641_BTIF, (0x3 << 5), btif); + ret = snd_soc_component_update_bits(component, AK4641_BTIF, (0x3 << 5), btif); if (ret < 0) return ret; @@ -390,7 +390,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u8 mode1 = 0; /* interface format */ @@ -405,34 +405,34 @@ static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - return snd_soc_write(codec, AK4641_MODE1, mode1); + return snd_soc_component_write(component, AK4641_MODE1, mode1); } static int ak4641_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - return snd_soc_update_bits(codec, AK4641_DAC, 0x20, mute ? 0x20 : 0); + return snd_soc_component_update_bits(component, AK4641_DAC, 0x20, mute ? 0x20 : 0); } -static int ak4641_set_bias_level(struct snd_soc_codec *codec, +static int ak4641_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); - struct ak4641_platform_data *pdata = codec->dev->platform_data; + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); + struct ak4641_platform_data *pdata = component->dev->platform_data; int ret; switch (level) { case SND_SOC_BIAS_ON: /* unmute */ - snd_soc_update_bits(codec, AK4641_DAC, 0x20, 0); + snd_soc_component_update_bits(component, AK4641_DAC, 0x20, 0); break; case SND_SOC_BIAS_PREPARE: /* mute */ - snd_soc_update_bits(codec, AK4641_DAC, 0x20, 0x20); + snd_soc_component_update_bits(component, AK4641_DAC, 0x20, 0x20); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { if (pdata && gpio_is_valid(pdata->gpio_power)) gpio_set_value(pdata->gpio_power, 1); mdelay(1); @@ -442,16 +442,16 @@ static int ak4641_set_bias_level(struct snd_soc_codec *codec, ret = regcache_sync(ak4641->regmap); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } } - snd_soc_update_bits(codec, AK4641_PM1, 0x80, 0x80); - snd_soc_update_bits(codec, AK4641_PM2, 0x80, 0); + snd_soc_component_update_bits(component, AK4641_PM1, 0x80, 0x80); + snd_soc_component_update_bits(component, AK4641_PM2, 0x80, 0); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, AK4641_PM1, 0x80, 0); + snd_soc_component_update_bits(component, AK4641_PM1, 0x80, 0); if (pdata && gpio_is_valid(pdata->gpio_npdn)) gpio_set_value(pdata->gpio_npdn, 0); if (pdata && gpio_is_valid(pdata->gpio_power)) @@ -524,17 +524,19 @@ static struct snd_soc_dai_driver ak4641_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_ak4641 = { - .component_driver = { - .controls = ak4641_snd_controls, - .num_controls = ARRAY_SIZE(ak4641_snd_controls), - .dapm_widgets = ak4641_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4641_dapm_widgets), - .dapm_routes = ak4641_audio_map, - .num_dapm_routes = ARRAY_SIZE(ak4641_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_ak4641 = { + .controls = ak4641_snd_controls, + .num_controls = ARRAY_SIZE(ak4641_snd_controls), + .dapm_widgets = ak4641_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4641_dapm_widgets), + .dapm_routes = ak4641_audio_map, + .num_dapm_routes = ARRAY_SIZE(ak4641_audio_map), .set_bias_level = ak4641_set_bias_level, - .suspend_bias_off = true, + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ak4641_regmap = { @@ -583,7 +585,8 @@ static int ak4641_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, ak4641); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_ak4641, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_ak4641, ak4641_dai, ARRAY_SIZE(ak4641_dai)); if (ret != 0) goto err_gpio2; @@ -608,8 +611,6 @@ static int ak4641_i2c_remove(struct i2c_client *i2c) { struct ak4641_platform_data *pdata = i2c->dev.platform_data; - snd_soc_unregister_codec(&i2c->dev); - if (pdata) { if (gpio_is_valid(pdata->gpio_power)) { gpio_set_value(pdata->gpio_power, 0); -- cgit v1.2.3 From 5aea27d59f764e346cb93923b0af6a94567cb95b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:14:50 +0000 Subject: ASoC: ak4554: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4554.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/ak4554.c b/sound/soc/codecs/ak4554.c index 0bb4fe5c122a..b7ee13406d93 100644 --- a/sound/soc/codecs/ak4554.c +++ b/sound/soc/codecs/ak4554.c @@ -64,28 +64,24 @@ static struct snd_soc_dai_driver ak4554_dai = { .symmetric_rates = 1, }; -static const struct snd_soc_codec_driver soc_codec_dev_ak4554 = { - .component_driver = { - .dapm_widgets = ak4554_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4554_dapm_widgets), - .dapm_routes = ak4554_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(ak4554_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ak4554 = { + .dapm_widgets = ak4554_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4554_dapm_widgets), + .dapm_routes = ak4554_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(ak4554_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ak4554_soc_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_ak4554, + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_ak4554, &ak4554_dai, 1); } -static int ak4554_soc_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static const struct of_device_id ak4554_of_match[] = { { .compatible = "asahi-kasei,ak4554" }, {}, @@ -98,7 +94,6 @@ static struct platform_driver ak4554_driver = { .of_match_table = ak4554_of_match, }, .probe = ak4554_soc_probe, - .remove = ak4554_soc_remove, }; module_platform_driver(ak4554_driver); -- cgit v1.2.3 From 36372922847c8686971bd714f24ca64558dff467 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 14 Feb 2018 03:01:24 +0000 Subject: ASoC: ak4613: don't have .use_pmdown_time snd_soc_runtime_ignore_pmdown_time() returns "ignore pmdown time" decision. Then, it collects each component driver's .use_pmdown_time settings by using AND operation. But, ak4613 has no reason to ignore/use pmdown time. Thus, It should has use_pmdown_time=0, it means it doesn't have decision right of "ignore pmdown time". Otherwise, ak4613 paired driver's pmdown_time settings doesn't have meaning. In other words, "ignore pmdown time" is determined irrespective of the value of paired driver's settings (= ignore will be 0 by ak4613). Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4613.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/ak4613.c b/sound/soc/codecs/ak4613.c index a7b1e3a1ec58..8523ff9351cf 100644 --- a/sound/soc/codecs/ak4613.c +++ b/sound/soc/codecs/ak4613.c @@ -610,7 +610,6 @@ static const struct snd_soc_component_driver soc_component_dev_ak4613 = { .dapm_routes = ak4613_intercon, .num_dapm_routes = ARRAY_SIZE(ak4613_intercon), .idle_bias_on = 1, - .use_pmdown_time = 1, .endianness = 1, .non_legacy_dai_naming = 1, }; -- cgit v1.2.3 From fe439c7c377920d608678db9a6724d6ec91f4cda Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 14 Feb 2018 03:01:46 +0000 Subject: ASoC: ak4642: don't have .use_pmdown_time snd_soc_runtime_ignore_pmdown_time() returns "ignore pmdown time" decision. Then, it collects each component driver's .use_pmdown_time settings by using AND operation. But, ak4613 has no reason to ignore/use pmdown time. Thus, It should has use_pmdown_time=0, it means it doesn't have decision right of "ignore pmdown time". Otherwise, ak4642 paired driver's pmdown_time settings doesn't have meaning. In other words, "ignore pmdown time" is determined irrespective of the value of paired driver's settings (= ignore will be 0 by ak4642). Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4642.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 9c35e91d412d..605055964529 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -562,7 +562,6 @@ static const struct snd_soc_component_driver soc_component_dev_ak4642 = { .dapm_routes = ak4642_intercon, .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), .idle_bias_on = 1, - .use_pmdown_time = 1, .endianness = 1, .non_legacy_dai_naming = 1, }; -- cgit v1.2.3