Commit ac6267e3 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: ad1980: 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: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 28f89849
...@@ -205,9 +205,9 @@ static struct snd_soc_dai_driver ad1980_dai = { ...@@ -205,9 +205,9 @@ static struct snd_soc_dai_driver ad1980_dai = {
#define AD1980_VENDOR_ID 0x41445300 #define AD1980_VENDOR_ID 0x41445300
#define AD1980_VENDOR_MASK 0xffffff00 #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; unsigned int retry_cnt = 0;
int ret; int ret;
...@@ -223,16 +223,16 @@ static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) ...@@ -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 * case the first nibble of data is eaten by the addr. (Tag is
* always 16 bit) * 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); } 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; 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 snd_ac97 *ac97;
struct regmap *regmap; struct regmap *regmap;
...@@ -240,10 +240,10 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec) ...@@ -240,10 +240,10 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)
u16 vendor_id2; u16 vendor_id2;
u16 ext_status; 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)) { if (IS_ERR(ac97)) {
ret = PTR_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; return ret;
} }
...@@ -253,72 +253,66 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec) ...@@ -253,72 +253,66 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)
goto err_free_ac97; goto err_free_ac97;
} }
snd_soc_codec_init_regmap(codec, regmap); snd_soc_component_init_regmap(component, regmap);
snd_soc_codec_set_drvdata(codec, ac97); snd_soc_component_set_drvdata(component, ac97);
ret = ad1980_reset(codec, 0); ret = ad1980_reset(component, 0);
if (ret < 0) if (ret < 0)
goto reset_err; 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) { if (vendor_id2 == 0x5374) {
dev_warn(codec->dev, dev_warn(component->dev,
"Found AD1981 - only 2/2 IN/OUT Channels supported\n"); "Found AD1981 - only 2/2 IN/OUT Channels supported\n");
} }
/* unmute captures and playbacks volume */ /* unmute captures and playbacks volume */
snd_soc_write(codec, AC97_MASTER, 0x0000); snd_soc_component_write(component, AC97_MASTER, 0x0000);
snd_soc_write(codec, AC97_PCM, 0x0000); snd_soc_component_write(component, AC97_PCM, 0x0000);
snd_soc_write(codec, AC97_REC_GAIN, 0x0000); snd_soc_component_write(component, AC97_REC_GAIN, 0x0000);
snd_soc_write(codec, AC97_CENTER_LFE_MASTER, 0x0000); snd_soc_component_write(component, AC97_CENTER_LFE_MASTER, 0x0000);
snd_soc_write(codec, AC97_SURROUND_MASTER, 0x0000); snd_soc_component_write(component, AC97_SURROUND_MASTER, 0x0000);
/*power on LFE/CENTER/Surround DACs*/ /*power on LFE/CENTER/Surround DACs*/
ext_status = snd_soc_read(codec, AC97_EXTENDED_STATUS); ext_status = snd_soc_component_read32(component, AC97_EXTENDED_STATUS);
snd_soc_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); snd_soc_component_write(component, AC97_EXTENDED_STATUS, ext_status&~0x3800);
return 0; return 0;
reset_err: reset_err:
snd_soc_codec_exit_regmap(codec); snd_soc_component_exit_regmap(component);
err_free_ac97: err_free_ac97:
snd_soc_free_ac97_codec(ac97); snd_soc_free_ac97_component(ac97);
return ret; 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_component_exit_regmap(component);
snd_soc_free_ac97_codec(ac97); snd_soc_free_ac97_component(ac97);
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_ad1980 = { static const struct snd_soc_component_driver soc_component_dev_ad1980 = {
.probe = ad1980_soc_probe, .probe = ad1980_soc_probe,
.remove = ad1980_soc_remove, .remove = ad1980_soc_remove,
.controls = ad1980_snd_ac97_controls,
.component_driver = { .num_controls = ARRAY_SIZE(ad1980_snd_ac97_controls),
.controls = ad1980_snd_ac97_controls, .dapm_widgets = ad1980_dapm_widgets,
.num_controls = ARRAY_SIZE(ad1980_snd_ac97_controls), .num_dapm_widgets = ARRAY_SIZE(ad1980_dapm_widgets),
.dapm_widgets = ad1980_dapm_widgets, .dapm_routes = ad1980_dapm_routes,
.num_dapm_widgets = ARRAY_SIZE(ad1980_dapm_widgets), .num_dapm_routes = ARRAY_SIZE(ad1980_dapm_routes),
.dapm_routes = ad1980_dapm_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(ad1980_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int ad1980_probe(struct platform_device *pdev) static int ad1980_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_ad1980, &ad1980_dai, 1); &soc_component_dev_ad1980, &ad1980_dai, 1);
}
static int ad1980_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver ad1980_codec_driver = { static struct platform_driver ad1980_codec_driver = {
...@@ -327,7 +321,6 @@ static struct platform_driver ad1980_codec_driver = { ...@@ -327,7 +321,6 @@ static struct platform_driver ad1980_codec_driver = {
}, },
.probe = ad1980_probe, .probe = ad1980_probe,
.remove = ad1980_remove,
}; };
module_platform_driver(ad1980_codec_driver); module_platform_driver(ad1980_codec_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment