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

ASoC: cs4265: 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
...@@ -322,12 +322,12 @@ static int cs4265_get_clk_index(int mclk, int rate) ...@@ -322,12 +322,12 @@ static int cs4265_get_clk_index(int mclk, int rate)
static int cs4265_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, static int cs4265_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id,
unsigned int freq, int dir) unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); struct cs4265_private *cs4265 = snd_soc_component_get_drvdata(component);
int i; int i;
if (clk_id != 0) { if (clk_id != 0) {
dev_err(codec->dev, "Invalid clk_id %d\n", clk_id); dev_err(component->dev, "Invalid clk_id %d\n", clk_id);
return -EINVAL; return -EINVAL;
} }
for (i = 0; i < ARRAY_SIZE(clk_map_table); i++) { for (i = 0; i < ARRAY_SIZE(clk_map_table); i++) {
...@@ -337,24 +337,24 @@ static int cs4265_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, ...@@ -337,24 +337,24 @@ static int cs4265_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id,
} }
} }
cs4265->sysclk = 0; cs4265->sysclk = 0;
dev_err(codec->dev, "Invalid freq parameter %d\n", freq); dev_err(component->dev, "Invalid freq parameter %d\n", freq);
return -EINVAL; return -EINVAL;
} }
static int cs4265_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int cs4265_set_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;
struct cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); struct cs4265_private *cs4265 = snd_soc_component_get_drvdata(component);
u8 iface = 0; u8 iface = 0;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFM:
snd_soc_update_bits(codec, CS4265_ADC_CTL, snd_soc_component_update_bits(component, CS4265_ADC_CTL,
CS4265_ADC_MASTER, CS4265_ADC_MASTER,
CS4265_ADC_MASTER); CS4265_ADC_MASTER);
break; break;
case SND_SOC_DAIFMT_CBS_CFS: case SND_SOC_DAIFMT_CBS_CFS:
snd_soc_update_bits(codec, CS4265_ADC_CTL, snd_soc_component_update_bits(component, CS4265_ADC_CTL,
CS4265_ADC_MASTER, CS4265_ADC_MASTER,
0); 0);
break; break;
...@@ -383,20 +383,20 @@ static int cs4265_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -383,20 +383,20 @@ static int cs4265_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
static int cs4265_digital_mute(struct snd_soc_dai *dai, int mute) static int cs4265_digital_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
if (mute) { if (mute) {
snd_soc_update_bits(codec, CS4265_DAC_CTL, snd_soc_component_update_bits(component, CS4265_DAC_CTL,
CS4265_DAC_CTL_MUTE, CS4265_DAC_CTL_MUTE,
CS4265_DAC_CTL_MUTE); CS4265_DAC_CTL_MUTE);
snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2,
CS4265_SPDIF_CTL2_MUTE, CS4265_SPDIF_CTL2_MUTE,
CS4265_SPDIF_CTL2_MUTE); CS4265_SPDIF_CTL2_MUTE);
} else { } else {
snd_soc_update_bits(codec, CS4265_DAC_CTL, snd_soc_component_update_bits(component, CS4265_DAC_CTL,
CS4265_DAC_CTL_MUTE, CS4265_DAC_CTL_MUTE,
0); 0);
snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2,
CS4265_SPDIF_CTL2_MUTE, CS4265_SPDIF_CTL2_MUTE,
0); 0);
} }
...@@ -407,8 +407,8 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -407,8 +407,8 @@ static int cs4265_pcm_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 cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); struct cs4265_private *cs4265 = snd_soc_component_get_drvdata(component);
int index; int index;
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
...@@ -418,45 +418,45 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -418,45 +418,45 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream,
index = cs4265_get_clk_index(cs4265->sysclk, params_rate(params)); index = cs4265_get_clk_index(cs4265->sysclk, params_rate(params));
if (index >= 0) { if (index >= 0) {
snd_soc_update_bits(codec, CS4265_ADC_CTL, snd_soc_component_update_bits(component, CS4265_ADC_CTL,
CS4265_ADC_FM, clk_map_table[index].fm_mode << 6); CS4265_ADC_FM, clk_map_table[index].fm_mode << 6);
snd_soc_update_bits(codec, CS4265_MCLK_FREQ, snd_soc_component_update_bits(component, CS4265_MCLK_FREQ,
CS4265_MCLK_FREQ_MASK, CS4265_MCLK_FREQ_MASK,
clk_map_table[index].mclkdiv << 4); clk_map_table[index].mclkdiv << 4);
} else { } else {
dev_err(codec->dev, "can't get correct mclk\n"); dev_err(component->dev, "can't get correct mclk\n");
return -EINVAL; return -EINVAL;
} }
switch (cs4265->format & SND_SOC_DAIFMT_FORMAT_MASK) { switch (cs4265->format & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_I2S:
snd_soc_update_bits(codec, CS4265_DAC_CTL, snd_soc_component_update_bits(component, CS4265_DAC_CTL,
CS4265_DAC_CTL_DIF, (1 << 4)); CS4265_DAC_CTL_DIF, (1 << 4));
snd_soc_update_bits(codec, CS4265_ADC_CTL, snd_soc_component_update_bits(component, CS4265_ADC_CTL,
CS4265_ADC_DIF, (1 << 4)); CS4265_ADC_DIF, (1 << 4));
snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2,
CS4265_SPDIF_CTL2_DIF, (1 << 6)); CS4265_SPDIF_CTL2_DIF, (1 << 6));
break; break;
case SND_SOC_DAIFMT_RIGHT_J: case SND_SOC_DAIFMT_RIGHT_J:
if (params_width(params) == 16) { if (params_width(params) == 16) {
snd_soc_update_bits(codec, CS4265_DAC_CTL, snd_soc_component_update_bits(component, CS4265_DAC_CTL,
CS4265_DAC_CTL_DIF, (2 << 4)); CS4265_DAC_CTL_DIF, (2 << 4));
snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2,
CS4265_SPDIF_CTL2_DIF, (2 << 6)); CS4265_SPDIF_CTL2_DIF, (2 << 6));
} else { } else {
snd_soc_update_bits(codec, CS4265_DAC_CTL, snd_soc_component_update_bits(component, CS4265_DAC_CTL,
CS4265_DAC_CTL_DIF, (3 << 4)); CS4265_DAC_CTL_DIF, (3 << 4));
snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2,
CS4265_SPDIF_CTL2_DIF, (3 << 6)); CS4265_SPDIF_CTL2_DIF, (3 << 6));
} }
break; break;
case SND_SOC_DAIFMT_LEFT_J: case SND_SOC_DAIFMT_LEFT_J:
snd_soc_update_bits(codec, CS4265_DAC_CTL, snd_soc_component_update_bits(component, CS4265_DAC_CTL,
CS4265_DAC_CTL_DIF, 0); CS4265_DAC_CTL_DIF, 0);
snd_soc_update_bits(codec, CS4265_ADC_CTL, snd_soc_component_update_bits(component, CS4265_ADC_CTL,
CS4265_ADC_DIF, 0); CS4265_ADC_DIF, 0);
snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2,
CS4265_SPDIF_CTL2_DIF, 0); CS4265_SPDIF_CTL2_DIF, 0);
break; break;
...@@ -466,23 +466,23 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -466,23 +466,23 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream,
return 0; return 0;
} }
static int cs4265_set_bias_level(struct snd_soc_codec *codec, static int cs4265_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: case SND_SOC_BIAS_ON:
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
snd_soc_update_bits(codec, CS4265_PWRCTL, snd_soc_component_update_bits(component, CS4265_PWRCTL,
CS4265_PWRCTL_PDN, 0); CS4265_PWRCTL_PDN, 0);
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
snd_soc_update_bits(codec, CS4265_PWRCTL, snd_soc_component_update_bits(component, CS4265_PWRCTL,
CS4265_PWRCTL_PDN, CS4265_PWRCTL_PDN,
CS4265_PWRCTL_PDN); CS4265_PWRCTL_PDN);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
snd_soc_update_bits(codec, CS4265_PWRCTL, snd_soc_component_update_bits(component, CS4265_PWRCTL,
CS4265_PWRCTL_PDN, CS4265_PWRCTL_PDN,
CS4265_PWRCTL_PDN); CS4265_PWRCTL_PDN);
break; break;
...@@ -544,17 +544,18 @@ static struct snd_soc_dai_driver cs4265_dai[] = { ...@@ -544,17 +544,18 @@ static struct snd_soc_dai_driver cs4265_dai[] = {
}, },
}; };
static const struct snd_soc_codec_driver soc_codec_cs4265 = { static const struct snd_soc_component_driver soc_component_cs4265 = {
.set_bias_level = cs4265_set_bias_level, .set_bias_level = cs4265_set_bias_level,
.component_driver = {
.controls = cs4265_snd_controls, .controls = cs4265_snd_controls,
.num_controls = ARRAY_SIZE(cs4265_snd_controls), .num_controls = ARRAY_SIZE(cs4265_snd_controls),
.dapm_widgets = cs4265_dapm_widgets, .dapm_widgets = cs4265_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(cs4265_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(cs4265_dapm_widgets),
.dapm_routes = cs4265_audio_map, .dapm_routes = cs4265_audio_map,
.num_dapm_routes = ARRAY_SIZE(cs4265_audio_map), .num_dapm_routes = ARRAY_SIZE(cs4265_audio_map),
}, .idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config cs4265_regmap = { static const struct regmap_config cs4265_regmap = {
...@@ -616,18 +617,12 @@ static int cs4265_i2c_probe(struct i2c_client *i2c_client, ...@@ -616,18 +617,12 @@ static int cs4265_i2c_probe(struct i2c_client *i2c_client,
regmap_write(cs4265->regmap, CS4265_PWRCTL, 0x0F); regmap_write(cs4265->regmap, CS4265_PWRCTL, 0x0F);
ret = snd_soc_register_codec(&i2c_client->dev, ret = devm_snd_soc_register_component(&i2c_client->dev,
&soc_codec_cs4265, cs4265_dai, &soc_component_cs4265, cs4265_dai,
ARRAY_SIZE(cs4265_dai)); ARRAY_SIZE(cs4265_dai));
return ret; return ret;
} }
static int cs4265_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct of_device_id cs4265_of_match[] = { static const struct of_device_id cs4265_of_match[] = {
{ .compatible = "cirrus,cs4265", }, { .compatible = "cirrus,cs4265", },
{ } { }
...@@ -647,7 +642,6 @@ static struct i2c_driver cs4265_i2c_driver = { ...@@ -647,7 +642,6 @@ static struct i2c_driver cs4265_i2c_driver = {
}, },
.id_table = cs4265_id, .id_table = cs4265_id,
.probe = cs4265_i2c_probe, .probe = cs4265_i2c_probe,
.remove = cs4265_i2c_remove,
}; };
module_i2c_driver(cs4265_i2c_driver); module_i2c_driver(cs4265_i2c_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