From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kuninori Morimoto Subject: [PATCH v2 118/186] ASoC: pcm1681: replace codec to component Date: Mon, 29 Jan 2018 04:18:12 +0000 Message-ID: <87r2q9xpsk.wl%kuninori.morimoto.gx@renesas.com> References: <87607l8k9i.wl%kuninori.morimoto.gx@renesas.com> <87inbl5q6q.wl%kuninori.morimoto.gx@renesas.com> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from relmlie2.idc.renesas.com (relmlor3.renesas.com [210.160.252.173]) by alsa0.perex.cz (Postfix) with ESMTP id 9EBA22678E3 for ; Mon, 29 Jan 2018 05:18:15 +0100 (CET) In-Reply-To: <87inbl5q6q.wl%kuninori.morimoto.gx@renesas.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Mark Brown Cc: Linux-ALSA List-Id: alsa-devel@alsa-project.org From: Kuninori Morimoto 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 --- sound/soc/codecs/pcm1681.c | 62 ++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/sound/soc/codecs/pcm1681.c b/sound/soc/codecs/pcm1681.c index c7e28dd..84777d3 100644 --- a/sound/soc/codecs/pcm1681.c +++ b/sound/soc/codecs/pcm1681.c @@ -90,9 +90,9 @@ struct pcm1681_private { static const int pcm1681_deemph[] = { 44100, 48000, 32000 }; -static int pcm1681_set_deemph(struct snd_soc_codec *codec) +static int pcm1681_set_deemph(struct snd_soc_component *component) { - struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); int i = 0, val = -1, enable = 0; if (priv->deemph) { @@ -120,8 +120,8 @@ static int pcm1681_set_deemph(struct snd_soc_codec *codec) static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = priv->deemph; @@ -131,23 +131,23 @@ static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, static int pcm1681_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); priv->deemph = ucontrol->value.integer.value[0]; - return pcm1681_set_deemph(codec); + return pcm1681_set_deemph(component); } static int pcm1681_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { - struct snd_soc_codec *codec = codec_dai->codec; - struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); /* The PCM1681 can only be slave to all clocks */ if ((format & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) { - dev_err(codec->dev, "Invalid clocking mode\n"); + dev_err(component->dev, "Invalid clocking mode\n"); return -EINVAL; } @@ -158,8 +158,8 @@ static int pcm1681_set_dai_fmt(struct snd_soc_dai *codec_dai, static int pcm1681_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); int val; if (mute) @@ -174,8 +174,8 @@ static int pcm1681_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 pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); int val = 0, ret; priv->rate = params_rate(params); @@ -200,7 +200,7 @@ static int pcm1681_hw_params(struct snd_pcm_substream *substream, val = 0x05; break; default: - dev_err(codec->dev, "Invalid DAI format\n"); + dev_err(component->dev, "Invalid DAI format\n"); return -EINVAL; } @@ -208,7 +208,7 @@ static int pcm1681_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - return pcm1681_set_deemph(codec); + return pcm1681_set_deemph(component); } static const struct snd_soc_dai_ops pcm1681_dai_ops = { @@ -288,15 +288,17 @@ static int pcm1681_hw_params(struct snd_pcm_substream *substream, .readable_reg = pcm1681_accessible_reg, }; -static const struct snd_soc_codec_driver soc_codec_dev_pcm1681 = { - .component_driver = { - .controls = pcm1681_controls, - .num_controls = ARRAY_SIZE(pcm1681_controls), - .dapm_widgets = pcm1681_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(pcm1681_dapm_widgets), - .dapm_routes = pcm1681_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(pcm1681_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_pcm1681 = { + .controls = pcm1681_controls, + .num_controls = ARRAY_SIZE(pcm1681_controls), + .dapm_widgets = pcm1681_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pcm1681_dapm_widgets), + .dapm_routes = pcm1681_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(pcm1681_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct i2c_device_id pcm1681_i2c_id[] = { @@ -324,16 +326,11 @@ static int pcm1681_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, priv); - return snd_soc_register_codec(&client->dev, &soc_codec_dev_pcm1681, + return devm_snd_soc_register_component(&client->dev, + &soc_component_dev_pcm1681, &pcm1681_dai, 1); } -static int pcm1681_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static struct i2c_driver pcm1681_i2c_driver = { .driver = { .name = "pcm1681", @@ -341,7 +338,6 @@ static int pcm1681_i2c_remove(struct i2c_client *client) }, .id_table = pcm1681_i2c_id, .probe = pcm1681_i2c_probe, - .remove = pcm1681_i2c_remove, }; module_i2c_driver(pcm1681_i2c_driver); -- 1.9.1