From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kuninori Morimoto Subject: [PATCH v2 136/186] ASoC: ad1980: replace codec to component Date: Mon, 29 Jan 2018 04:26:20 +0000 Message-ID: <871si9xpew.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 relmlie1.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa0.perex.cz (Postfix) with ESMTP id BCD53267BD8 for ; Mon, 29 Jan 2018 05:26:24 +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/ad1980.c | 87 ++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 47 deletions(-) diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c index ce89bfb..16dab3f 100644 --- a/sound/soc/codecs/ad1980.c +++ b/sound/soc/codecs/ad1980.c @@ -205,9 +205,9 @@ static SOC_ENUM_DOUBLE_DECL(ad1980_cap_src, #define AD1980_VENDOR_ID 0x41445300 #define AD1980_VENDOR_MASK 0xffffff00 -static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) +static int ad1980_reset(struct snd_soc_component *component, int try_warm) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component); unsigned int retry_cnt = 0; int ret; @@ -223,16 +223,16 @@ static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) * case the first nibble of data is eaten by the addr. (Tag is * always 16 bit) */ - snd_soc_write(codec, AC97_AD_SERIAL_CFG, 0x9900); + snd_soc_component_write(component, AC97_AD_SERIAL_CFG, 0x9900); } while (retry_cnt++ < 10); - dev_err(codec->dev, "Failed to reset: AC97 link error\n"); + dev_err(component->dev, "Failed to reset: AC97 link error\n"); return -EIO; } -static int ad1980_soc_probe(struct snd_soc_codec *codec) +static int ad1980_soc_probe(struct snd_soc_component *component) { struct snd_ac97 *ac97; struct regmap *regmap; @@ -240,10 +240,10 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec) u16 vendor_id2; u16 ext_status; - ac97 = snd_soc_new_ac97_codec(codec, 0, 0); + ac97 = snd_soc_new_ac97_component(component, 0, 0); if (IS_ERR(ac97)) { ret = PTR_ERR(ac97); - dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); + dev_err(component->dev, "Failed to register AC97 component: %d\n", ret); return ret; } @@ -253,72 +253,66 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec) goto err_free_ac97; } - snd_soc_codec_init_regmap(codec, regmap); - snd_soc_codec_set_drvdata(codec, ac97); + snd_soc_component_init_regmap(component, regmap); + snd_soc_component_set_drvdata(component, ac97); - ret = ad1980_reset(codec, 0); + ret = ad1980_reset(component, 0); if (ret < 0) goto reset_err; - vendor_id2 = snd_soc_read(codec, AC97_VENDOR_ID2); + vendor_id2 = snd_soc_component_read32(component, AC97_VENDOR_ID2); if (vendor_id2 == 0x5374) { - dev_warn(codec->dev, + dev_warn(component->dev, "Found AD1981 - only 2/2 IN/OUT Channels supported\n"); } /* unmute captures and playbacks volume */ - snd_soc_write(codec, AC97_MASTER, 0x0000); - snd_soc_write(codec, AC97_PCM, 0x0000); - snd_soc_write(codec, AC97_REC_GAIN, 0x0000); - snd_soc_write(codec, AC97_CENTER_LFE_MASTER, 0x0000); - snd_soc_write(codec, AC97_SURROUND_MASTER, 0x0000); + snd_soc_component_write(component, AC97_MASTER, 0x0000); + snd_soc_component_write(component, AC97_PCM, 0x0000); + snd_soc_component_write(component, AC97_REC_GAIN, 0x0000); + snd_soc_component_write(component, AC97_CENTER_LFE_MASTER, 0x0000); + snd_soc_component_write(component, AC97_SURROUND_MASTER, 0x0000); /*power on LFE/CENTER/Surround DACs*/ - ext_status = snd_soc_read(codec, AC97_EXTENDED_STATUS); - snd_soc_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); + ext_status = snd_soc_component_read32(component, AC97_EXTENDED_STATUS); + snd_soc_component_write(component, AC97_EXTENDED_STATUS, ext_status&~0x3800); return 0; reset_err: - snd_soc_codec_exit_regmap(codec); + snd_soc_component_exit_regmap(component); err_free_ac97: - snd_soc_free_ac97_codec(ac97); + snd_soc_free_ac97_component(ac97); return ret; } -static int ad1980_soc_remove(struct snd_soc_codec *codec) +static void ad1980_soc_remove(struct snd_soc_component *component) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component); - snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(ac97); - return 0; + snd_soc_component_exit_regmap(component); + snd_soc_free_ac97_component(ac97); } -static const struct snd_soc_codec_driver soc_codec_dev_ad1980 = { - .probe = ad1980_soc_probe, - .remove = ad1980_soc_remove, - - .component_driver = { - .controls = ad1980_snd_ac97_controls, - .num_controls = ARRAY_SIZE(ad1980_snd_ac97_controls), - .dapm_widgets = ad1980_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ad1980_dapm_widgets), - .dapm_routes = ad1980_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(ad1980_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ad1980 = { + .probe = ad1980_soc_probe, + .remove = ad1980_soc_remove, + .controls = ad1980_snd_ac97_controls, + .num_controls = ARRAY_SIZE(ad1980_snd_ac97_controls), + .dapm_widgets = ad1980_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ad1980_dapm_widgets), + .dapm_routes = ad1980_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(ad1980_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ad1980_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_ad1980, &ad1980_dai, 1); -} - -static int ad1980_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_ad1980, &ad1980_dai, 1); } static struct platform_driver ad1980_codec_driver = { @@ -327,7 +321,6 @@ static int ad1980_remove(struct platform_device *pdev) }, .probe = ad1980_probe, - .remove = ad1980_remove, }; module_platform_driver(ad1980_codec_driver); -- 1.9.1