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

ASoC: stac9766: 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 be4b1c09
...@@ -168,58 +168,58 @@ static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = { ...@@ -168,58 +168,58 @@ static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = {
static int ac97_analog_prepare(struct snd_pcm_substream *substream, static int ac97_analog_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
unsigned short reg; unsigned short reg;
/* enable variable rate audio, disable SPDIF output */ /* enable variable rate audio, disable SPDIF output */
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x5, 0x1); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x5, 0x1);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
else else
reg = AC97_PCM_LR_ADC_RATE; reg = AC97_PCM_LR_ADC_RATE;
return snd_soc_write(codec, reg, runtime->rate); return snd_soc_component_write(component, reg, runtime->rate);
} }
static int ac97_digital_prepare(struct snd_pcm_substream *substream, static int ac97_digital_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
unsigned short reg; unsigned short reg;
snd_soc_write(codec, AC97_SPDIF, 0x2002); snd_soc_component_write(component, AC97_SPDIF, 0x2002);
/* Enable VRA and SPDIF out */ /* Enable VRA and SPDIF out */
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x5, 0x5); snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x5, 0x5);
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
return snd_soc_write(codec, reg, runtime->rate); return snd_soc_component_write(component, reg, runtime->rate);
} }
static int stac9766_set_bias_level(struct snd_soc_codec *codec, static int stac9766_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: /* full On */ case SND_SOC_BIAS_ON: /* full On */
case SND_SOC_BIAS_PREPARE: /* partial On */ case SND_SOC_BIAS_PREPARE: /* partial On */
case SND_SOC_BIAS_STANDBY: /* Off, with power */ case SND_SOC_BIAS_STANDBY: /* Off, with power */
snd_soc_write(codec, AC97_POWERDOWN, 0x0000); snd_soc_component_write(component, AC97_POWERDOWN, 0x0000);
break; break;
case SND_SOC_BIAS_OFF: /* Off, without power */ case SND_SOC_BIAS_OFF: /* Off, without power */
/* disable everything including AC link */ /* disable everything including AC link */
snd_soc_write(codec, AC97_POWERDOWN, 0xffff); snd_soc_component_write(component, AC97_POWERDOWN, 0xffff);
break; break;
} }
return 0; return 0;
} }
static int stac9766_codec_resume(struct snd_soc_codec *codec) static int stac9766_component_resume(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);
return snd_ac97_reset(ac97, true, STAC9766_VENDOR_ID, return snd_ac97_reset(ac97, true, STAC9766_VENDOR_ID,
STAC9766_VENDOR_ID_MASK); STAC9766_VENDOR_ID_MASK);
...@@ -272,13 +272,13 @@ static struct snd_soc_dai_driver stac9766_dai[] = { ...@@ -272,13 +272,13 @@ static struct snd_soc_dai_driver stac9766_dai[] = {
} }
}; };
static int stac9766_codec_probe(struct snd_soc_codec *codec) static int stac9766_component_probe(struct snd_soc_component *component)
{ {
struct snd_ac97 *ac97; struct snd_ac97 *ac97;
struct regmap *regmap; struct regmap *regmap;
int ret; int ret;
ac97 = snd_soc_new_ac97_codec(codec, STAC9766_VENDOR_ID, ac97 = snd_soc_new_ac97_component(component, STAC9766_VENDOR_ID,
STAC9766_VENDOR_ID_MASK); STAC9766_VENDOR_ID_MASK);
if (IS_ERR(ac97)) if (IS_ERR(ac97))
return PTR_ERR(ac97); return PTR_ERR(ac97);
...@@ -289,46 +289,42 @@ static int stac9766_codec_probe(struct snd_soc_codec *codec) ...@@ -289,46 +289,42 @@ static int stac9766_codec_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);
return 0; return 0;
err_free_ac97: err_free_ac97:
snd_soc_free_ac97_codec(ac97); snd_soc_free_ac97_component(ac97);
return ret; return ret;
} }
static int stac9766_codec_remove(struct snd_soc_codec *codec) static void stac9766_component_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_stac9766 = { static const struct snd_soc_component_driver soc_component_dev_stac9766 = {
.component_driver = { .controls = stac9766_snd_ac97_controls,
.controls = stac9766_snd_ac97_controls, .num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls),
.num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls), .set_bias_level = stac9766_set_bias_level,
}, .probe = stac9766_component_probe,
.set_bias_level = stac9766_set_bias_level, .remove = stac9766_component_remove,
.suspend_bias_off = true, .resume = stac9766_component_resume,
.probe = stac9766_codec_probe, .suspend_bias_off = 1,
.remove = stac9766_codec_remove, .idle_bias_on = 1,
.resume = stac9766_codec_resume, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int stac9766_probe(struct platform_device *pdev) static int stac9766_probe(struct platform_device *pdev)
{ {
return snd_soc_register_codec(&pdev->dev, return devm_snd_soc_register_component(&pdev->dev,
&soc_codec_dev_stac9766, stac9766_dai, ARRAY_SIZE(stac9766_dai)); &soc_component_dev_stac9766, stac9766_dai, ARRAY_SIZE(stac9766_dai));
}
static int stac9766_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
} }
static struct platform_driver stac9766_codec_driver = { static struct platform_driver stac9766_codec_driver = {
...@@ -337,7 +333,6 @@ static struct platform_driver stac9766_codec_driver = { ...@@ -337,7 +333,6 @@ static struct platform_driver stac9766_codec_driver = {
}, },
.probe = stac9766_probe, .probe = stac9766_probe,
.remove = stac9766_remove,
}; };
module_platform_driver(stac9766_codec_driver); module_platform_driver(stac9766_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