Commit 2b5c3e43 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: ak4641: 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
...@@ -70,9 +70,9 @@ static const struct reg_default ak4641_reg_defaults[] = { ...@@ -70,9 +70,9 @@ static const struct reg_default ak4641_reg_defaults[] = {
static const int deemph_settings[] = {44100, 0, 48000, 32000}; static const int deemph_settings[] = {44100, 0, 48000, 32000};
static int ak4641_set_deemph(struct snd_soc_codec *codec) static int ak4641_set_deemph(struct snd_soc_component *component)
{ {
struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
int i, best = 0; int i, best = 0;
for (i = 0 ; i < ARRAY_SIZE(deemph_settings); i++) { for (i = 0 ; i < ARRAY_SIZE(deemph_settings); i++) {
...@@ -86,16 +86,16 @@ static int ak4641_set_deemph(struct snd_soc_codec *codec) ...@@ -86,16 +86,16 @@ static int ak4641_set_deemph(struct snd_soc_codec *codec)
best = i; best = i;
} }
dev_dbg(codec->dev, "Set deemphasis %d\n", best); dev_dbg(component->dev, "Set deemphasis %d\n", best);
return snd_soc_update_bits(codec, AK4641_DAC, 0x3, best); return snd_soc_component_update_bits(component, AK4641_DAC, 0x3, best);
} }
static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, static int ak4641_put_deemph(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
int deemph = ucontrol->value.integer.value[0]; int deemph = ucontrol->value.integer.value[0];
if (deemph > 1) if (deemph > 1)
...@@ -103,14 +103,14 @@ static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, ...@@ -103,14 +103,14 @@ static int ak4641_put_deemph(struct snd_kcontrol *kcontrol,
ak4641->deemph = deemph; ak4641->deemph = deemph;
return ak4641_set_deemph(codec); return ak4641_set_deemph(component);
} }
static int ak4641_get_deemph(struct snd_kcontrol *kcontrol, static int ak4641_get_deemph(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = ak4641->deemph; ucontrol->value.integer.value[0] = ak4641->deemph;
return 0; return 0;
...@@ -307,8 +307,8 @@ static const struct snd_soc_dapm_route ak4641_audio_map[] = { ...@@ -307,8 +307,8 @@ static const struct snd_soc_dapm_route ak4641_audio_map[] = {
static int ak4641_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int ak4641_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 ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
ak4641->sysclk = freq; ak4641->sysclk = freq;
return 0; return 0;
...@@ -318,8 +318,8 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -318,8 +318,8 @@ static int ak4641_i2s_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 ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
int rate = params_rate(params), fs = 256; int rate = params_rate(params), fs = 256;
u8 mode2; u8 mode2;
...@@ -340,16 +340,16 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -340,16 +340,16 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream,
mode2 = (0x0 << 5); mode2 = (0x0 << 5);
break; break;
default: default:
dev_err(codec->dev, "Error: unsupported fs=%d\n", fs); dev_err(component->dev, "Error: unsupported fs=%d\n", fs);
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, AK4641_MODE2, (0x3 << 5), mode2); snd_soc_component_update_bits(component, AK4641_MODE2, (0x3 << 5), mode2);
/* Update de-emphasis filter for the new rate */ /* Update de-emphasis filter for the new rate */
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
ak4641->playback_fs = rate; ak4641->playback_fs = rate;
ak4641_set_deemph(codec); ak4641_set_deemph(component);
} }
return 0; return 0;
...@@ -358,7 +358,7 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -358,7 +358,7 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream,
static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
u8 btif; u8 btif;
int ret; int ret;
...@@ -380,7 +380,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -380,7 +380,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
ret = snd_soc_update_bits(codec, AK4641_BTIF, (0x3 << 5), btif); ret = snd_soc_component_update_bits(component, AK4641_BTIF, (0x3 << 5), btif);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -390,7 +390,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -390,7 +390,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai,
static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
u8 mode1 = 0; u8 mode1 = 0;
/* interface format */ /* interface format */
...@@ -405,34 +405,34 @@ static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -405,34 +405,34 @@ static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
return snd_soc_write(codec, AK4641_MODE1, mode1); return snd_soc_component_write(component, AK4641_MODE1, mode1);
} }
static int ak4641_mute(struct snd_soc_dai *dai, int mute) static int ak4641_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
return snd_soc_update_bits(codec, AK4641_DAC, 0x20, mute ? 0x20 : 0); return snd_soc_component_update_bits(component, AK4641_DAC, 0x20, mute ? 0x20 : 0);
} }
static int ak4641_set_bias_level(struct snd_soc_codec *codec, static int ak4641_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component);
struct ak4641_platform_data *pdata = codec->dev->platform_data; struct ak4641_platform_data *pdata = component->dev->platform_data;
int ret; int ret;
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
/* unmute */ /* unmute */
snd_soc_update_bits(codec, AK4641_DAC, 0x20, 0); snd_soc_component_update_bits(component, AK4641_DAC, 0x20, 0);
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* mute */ /* mute */
snd_soc_update_bits(codec, AK4641_DAC, 0x20, 0x20); snd_soc_component_update_bits(component, AK4641_DAC, 0x20, 0x20);
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) {
if (pdata && gpio_is_valid(pdata->gpio_power)) if (pdata && gpio_is_valid(pdata->gpio_power))
gpio_set_value(pdata->gpio_power, 1); gpio_set_value(pdata->gpio_power, 1);
mdelay(1); mdelay(1);
...@@ -442,16 +442,16 @@ static int ak4641_set_bias_level(struct snd_soc_codec *codec, ...@@ -442,16 +442,16 @@ static int ak4641_set_bias_level(struct snd_soc_codec *codec,
ret = regcache_sync(ak4641->regmap); ret = regcache_sync(ak4641->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;
} }
} }
snd_soc_update_bits(codec, AK4641_PM1, 0x80, 0x80); snd_soc_component_update_bits(component, AK4641_PM1, 0x80, 0x80);
snd_soc_update_bits(codec, AK4641_PM2, 0x80, 0); snd_soc_component_update_bits(component, AK4641_PM2, 0x80, 0);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
snd_soc_update_bits(codec, AK4641_PM1, 0x80, 0); snd_soc_component_update_bits(component, AK4641_PM1, 0x80, 0);
if (pdata && gpio_is_valid(pdata->gpio_npdn)) if (pdata && gpio_is_valid(pdata->gpio_npdn))
gpio_set_value(pdata->gpio_npdn, 0); gpio_set_value(pdata->gpio_npdn, 0);
if (pdata && gpio_is_valid(pdata->gpio_power)) if (pdata && gpio_is_valid(pdata->gpio_power))
...@@ -524,17 +524,19 @@ static struct snd_soc_dai_driver ak4641_dai[] = { ...@@ -524,17 +524,19 @@ static struct snd_soc_dai_driver ak4641_dai[] = {
}, },
}; };
static const struct snd_soc_codec_driver soc_codec_dev_ak4641 = { static const struct snd_soc_component_driver soc_component_dev_ak4641 = {
.component_driver = {
.controls = ak4641_snd_controls, .controls = ak4641_snd_controls,
.num_controls = ARRAY_SIZE(ak4641_snd_controls), .num_controls = ARRAY_SIZE(ak4641_snd_controls),
.dapm_widgets = ak4641_dapm_widgets, .dapm_widgets = ak4641_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(ak4641_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(ak4641_dapm_widgets),
.dapm_routes = ak4641_audio_map, .dapm_routes = ak4641_audio_map,
.num_dapm_routes = ARRAY_SIZE(ak4641_audio_map), .num_dapm_routes = ARRAY_SIZE(ak4641_audio_map),
},
.set_bias_level = ak4641_set_bias_level, .set_bias_level = ak4641_set_bias_level,
.suspend_bias_off = true, .suspend_bias_off = 1,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config ak4641_regmap = { static const struct regmap_config ak4641_regmap = {
...@@ -583,7 +585,8 @@ static int ak4641_i2c_probe(struct i2c_client *i2c, ...@@ -583,7 +585,8 @@ static int ak4641_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, ak4641); i2c_set_clientdata(i2c, ak4641);
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_ak4641, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_component_dev_ak4641,
ak4641_dai, ARRAY_SIZE(ak4641_dai)); ak4641_dai, ARRAY_SIZE(ak4641_dai));
if (ret != 0) if (ret != 0)
goto err_gpio2; goto err_gpio2;
...@@ -608,8 +611,6 @@ static int ak4641_i2c_remove(struct i2c_client *i2c) ...@@ -608,8 +611,6 @@ static int ak4641_i2c_remove(struct i2c_client *i2c)
{ {
struct ak4641_platform_data *pdata = i2c->dev.platform_data; struct ak4641_platform_data *pdata = i2c->dev.platform_data;
snd_soc_unregister_codec(&i2c->dev);
if (pdata) { if (pdata) {
if (gpio_is_valid(pdata->gpio_power)) { if (gpio_is_valid(pdata->gpio_power)) {
gpio_set_value(pdata->gpio_power, 0); gpio_set_value(pdata->gpio_power, 0);
......
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