Commit 0b3eda28 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: max9850: 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 7928b2cb
...@@ -130,8 +130,8 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, ...@@ -130,8 +130,8 @@ static int max9850_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
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 max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component);
u64 lrclk_div; u64 lrclk_div;
u8 sf, da; u8 sf, da;
...@@ -139,14 +139,14 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, ...@@ -139,14 +139,14 @@ static int max9850_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
/* lrclk_div = 2^22 * rate / iclk with iclk = mclk / sf */ /* lrclk_div = 2^22 * rate / iclk with iclk = mclk / sf */
sf = (snd_soc_read(codec, MAX9850_CLOCK) >> 2) + 1; sf = (snd_soc_component_read32(component, MAX9850_CLOCK) >> 2) + 1;
lrclk_div = (1 << 22); lrclk_div = (1 << 22);
lrclk_div *= params_rate(params); lrclk_div *= params_rate(params);
lrclk_div *= sf; lrclk_div *= sf;
do_div(lrclk_div, max9850->sysclk); do_div(lrclk_div, max9850->sysclk);
snd_soc_write(codec, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f); snd_soc_component_write(component, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f);
snd_soc_write(codec, MAX9850_LRCLK_LSB, lrclk_div & 0xff); snd_soc_component_write(component, MAX9850_LRCLK_LSB, lrclk_div & 0xff);
switch (params_width(params)) { switch (params_width(params)) {
case 16: case 16:
...@@ -161,7 +161,7 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, ...@@ -161,7 +161,7 @@ static int max9850_hw_params(struct snd_pcm_substream *substream,
default: default:
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, MAX9850_DIGITAL_AUDIO, 0x3, da); snd_soc_component_update_bits(component, MAX9850_DIGITAL_AUDIO, 0x3, da);
return 0; return 0;
} }
...@@ -169,16 +169,16 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, ...@@ -169,16 +169,16 @@ static int max9850_hw_params(struct snd_pcm_substream *substream,
static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component);
/* calculate mclk -> iclk divider */ /* calculate mclk -> iclk divider */
if (freq <= 13000000) if (freq <= 13000000)
snd_soc_write(codec, MAX9850_CLOCK, 0x0); snd_soc_component_write(component, MAX9850_CLOCK, 0x0);
else if (freq <= 26000000) else if (freq <= 26000000)
snd_soc_write(codec, MAX9850_CLOCK, 0x4); snd_soc_component_write(component, MAX9850_CLOCK, 0x4);
else if (freq <= 40000000) else if (freq <= 40000000)
snd_soc_write(codec, MAX9850_CLOCK, 0x8); snd_soc_component_write(component, MAX9850_CLOCK, 0x8);
else else
return -EINVAL; return -EINVAL;
...@@ -188,7 +188,7 @@ static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -188,7 +188,7 @@ static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int max9850_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 da = 0; u8 da = 0;
/* set master/slave audio interface */ /* set master/slave audio interface */
...@@ -234,15 +234,15 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -234,15 +234,15 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
} }
/* set da */ /* set da */
snd_soc_write(codec, MAX9850_DIGITAL_AUDIO, da); snd_soc_component_write(component, MAX9850_DIGITAL_AUDIO, da);
return 0; return 0;
} }
static int max9850_set_bias_level(struct snd_soc_codec *codec, static int max9850_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component);
int ret; int ret;
switch (level) { switch (level) {
...@@ -251,10 +251,10 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec, ...@@ -251,10 +251,10 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
break; break;
case SND_SOC_BIAS_STANDBY: 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) {
ret = regcache_sync(max9850->regmap); ret = regcache_sync(max9850->regmap);
if (ret) { if (ret) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to sync cache: %d\n", ret); "Failed to sync cache: %d\n", ret);
return ret; return ret;
} }
...@@ -289,31 +289,32 @@ static struct snd_soc_dai_driver max9850_dai = { ...@@ -289,31 +289,32 @@ static struct snd_soc_dai_driver max9850_dai = {
.ops = &max9850_dai_ops, .ops = &max9850_dai_ops,
}; };
static int max9850_probe(struct snd_soc_codec *codec) static int max9850_probe(struct snd_soc_component *component)
{ {
/* enable zero-detect */ /* enable zero-detect */
snd_soc_update_bits(codec, MAX9850_GENERAL_PURPOSE, 1, 1); snd_soc_component_update_bits(component, MAX9850_GENERAL_PURPOSE, 1, 1);
/* enable slew-rate control */ /* enable slew-rate control */
snd_soc_update_bits(codec, MAX9850_VOLUME, 0x40, 0x40); snd_soc_component_update_bits(component, MAX9850_VOLUME, 0x40, 0x40);
/* set slew-rate 125ms */ /* set slew-rate 125ms */
snd_soc_update_bits(codec, MAX9850_CHARGE_PUMP, 0xff, 0xc0); snd_soc_component_update_bits(component, MAX9850_CHARGE_PUMP, 0xff, 0xc0);
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_max9850 = { static const struct snd_soc_component_driver soc_component_dev_max9850 = {
.probe = max9850_probe, .probe = max9850_probe,
.set_bias_level = max9850_set_bias_level, .set_bias_level = max9850_set_bias_level,
.suspend_bias_off = true, .controls = max9850_controls,
.num_controls = ARRAY_SIZE(max9850_controls),
.component_driver = { .dapm_widgets = max9850_dapm_widgets,
.controls = max9850_controls, .num_dapm_widgets = ARRAY_SIZE(max9850_dapm_widgets),
.num_controls = ARRAY_SIZE(max9850_controls), .dapm_routes = max9850_dapm_routes,
.dapm_widgets = max9850_dapm_widgets, .num_dapm_routes = ARRAY_SIZE(max9850_dapm_routes),
.num_dapm_widgets = ARRAY_SIZE(max9850_dapm_widgets), .suspend_bias_off = 1,
.dapm_routes = max9850_dapm_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(max9850_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int max9850_i2c_probe(struct i2c_client *i2c, static int max9850_i2c_probe(struct i2c_client *i2c,
...@@ -333,17 +334,11 @@ static int max9850_i2c_probe(struct i2c_client *i2c, ...@@ -333,17 +334,11 @@ static int max9850_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, max9850); i2c_set_clientdata(i2c, max9850);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_max9850, &max9850_dai, 1); &soc_component_dev_max9850, &max9850_dai, 1);
return ret; return ret;
} }
static int max9850_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id max9850_i2c_id[] = { static const struct i2c_device_id max9850_i2c_id[] = {
{ "max9850", 0 }, { "max9850", 0 },
{ } { }
...@@ -355,7 +350,6 @@ static struct i2c_driver max9850_i2c_driver = { ...@@ -355,7 +350,6 @@ static struct i2c_driver max9850_i2c_driver = {
.name = "max9850", .name = "max9850",
}, },
.probe = max9850_i2c_probe, .probe = max9850_i2c_probe,
.remove = max9850_i2c_remove,
.id_table = max9850_i2c_id, .id_table = max9850_i2c_id,
}; };
......
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