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

ASoC: tas5720: 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
...@@ -49,7 +49,7 @@ static const char * const tas5720_supply_names[] = { ...@@ -49,7 +49,7 @@ static const char * const tas5720_supply_names[] = {
#define TAS5720_NUM_SUPPLIES ARRAY_SIZE(tas5720_supply_names) #define TAS5720_NUM_SUPPLIES ARRAY_SIZE(tas5720_supply_names)
struct tas5720_data { struct tas5720_data {
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct regmap *regmap; struct regmap *regmap;
struct i2c_client *tas5720_client; struct i2c_client *tas5720_client;
enum tas572x_type devtype; enum tas572x_type devtype;
...@@ -62,7 +62,7 @@ static int tas5720_hw_params(struct snd_pcm_substream *substream, ...@@ -62,7 +62,7 @@ static int tas5720_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;
unsigned int rate = params_rate(params); unsigned int rate = params_rate(params);
bool ssz_ds; bool ssz_ds;
int ret; int ret;
...@@ -77,14 +77,14 @@ static int tas5720_hw_params(struct snd_pcm_substream *substream, ...@@ -77,14 +77,14 @@ static int tas5720_hw_params(struct snd_pcm_substream *substream,
ssz_ds = true; ssz_ds = true;
break; break;
default: default:
dev_err(codec->dev, "unsupported sample rate: %u\n", rate); dev_err(component->dev, "unsupported sample rate: %u\n", rate);
return -EINVAL; return -EINVAL;
} }
ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL1_REG, ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL1_REG,
TAS5720_SSZ_DS, ssz_ds); TAS5720_SSZ_DS, ssz_ds);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "error setting sample rate: %d\n", ret); dev_err(component->dev, "error setting sample rate: %d\n", ret);
return ret; return ret;
} }
...@@ -93,12 +93,12 @@ static int tas5720_hw_params(struct snd_pcm_substream *substream, ...@@ -93,12 +93,12 @@ static int tas5720_hw_params(struct snd_pcm_substream *substream,
static int tas5720_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int tas5720_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u8 serial_format; u8 serial_format;
int ret; int ret;
if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) { if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) {
dev_vdbg(codec->dev, "DAI Format master is not found\n"); dev_vdbg(component->dev, "DAI Format master is not found\n");
return -EINVAL; return -EINVAL;
} }
...@@ -132,15 +132,15 @@ static int tas5720_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -132,15 +132,15 @@ static int tas5720_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
serial_format = TAS5720_SAIF_LEFTJ; serial_format = TAS5720_SAIF_LEFTJ;
break; break;
default: default:
dev_vdbg(codec->dev, "DAI Format is not found\n"); dev_vdbg(component->dev, "DAI Format is not found\n");
return -EINVAL; return -EINVAL;
} }
ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL1_REG, ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL1_REG,
TAS5720_SAIF_FORMAT_MASK, TAS5720_SAIF_FORMAT_MASK,
serial_format); serial_format);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "error setting SAIF format: %d\n", ret); dev_err(component->dev, "error setting SAIF format: %d\n", ret);
return ret; return ret;
} }
...@@ -151,12 +151,12 @@ static int tas5720_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -151,12 +151,12 @@ static int tas5720_set_dai_tdm_slot(struct snd_soc_dai *dai,
unsigned int tx_mask, unsigned int rx_mask, unsigned int tx_mask, unsigned int rx_mask,
int slots, int slot_width) int slots, int slot_width)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
unsigned int first_slot; unsigned int first_slot;
int ret; int ret;
if (!tx_mask) { if (!tx_mask) {
dev_err(codec->dev, "tx masks must not be 0\n"); dev_err(component->dev, "tx masks must not be 0\n");
return -EINVAL; return -EINVAL;
} }
...@@ -168,39 +168,39 @@ static int tas5720_set_dai_tdm_slot(struct snd_soc_dai *dai, ...@@ -168,39 +168,39 @@ static int tas5720_set_dai_tdm_slot(struct snd_soc_dai *dai,
first_slot = __ffs(tx_mask); first_slot = __ffs(tx_mask);
if (first_slot > 7) { if (first_slot > 7) {
dev_err(codec->dev, "slot selection out of bounds (%u)\n", dev_err(component->dev, "slot selection out of bounds (%u)\n",
first_slot); first_slot);
return -EINVAL; return -EINVAL;
} }
/* Enable manual TDM slot selection (instead of I2C ID based) */ /* Enable manual TDM slot selection (instead of I2C ID based) */
ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL1_REG, ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL1_REG,
TAS5720_TDM_CFG_SRC, TAS5720_TDM_CFG_SRC); TAS5720_TDM_CFG_SRC, TAS5720_TDM_CFG_SRC);
if (ret < 0) if (ret < 0)
goto error_snd_soc_update_bits; goto error_snd_soc_component_update_bits;
/* Configure the TDM slot to process audio from */ /* Configure the TDM slot to process audio from */
ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL2_REG, ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL2_REG,
TAS5720_TDM_SLOT_SEL_MASK, first_slot); TAS5720_TDM_SLOT_SEL_MASK, first_slot);
if (ret < 0) if (ret < 0)
goto error_snd_soc_update_bits; goto error_snd_soc_component_update_bits;
return 0; return 0;
error_snd_soc_update_bits: error_snd_soc_component_update_bits:
dev_err(codec->dev, "error configuring TDM mode: %d\n", ret); dev_err(component->dev, "error configuring TDM mode: %d\n", ret);
return ret; return ret;
} }
static int tas5720_mute(struct snd_soc_dai *dai, int mute) static int tas5720_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
int ret; int ret;
ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL2_REG, ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL2_REG,
TAS5720_MUTE, mute ? TAS5720_MUTE : 0); TAS5720_MUTE, mute ? TAS5720_MUTE : 0);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "error (un-)muting device: %d\n", ret); dev_err(component->dev, "error (un-)muting device: %d\n", ret);
return ret; return ret;
} }
...@@ -211,7 +211,7 @@ static void tas5720_fault_check_work(struct work_struct *work) ...@@ -211,7 +211,7 @@ static void tas5720_fault_check_work(struct work_struct *work)
{ {
struct tas5720_data *tas5720 = container_of(work, struct tas5720_data, struct tas5720_data *tas5720 = container_of(work, struct tas5720_data,
fault_check_work.work); fault_check_work.work);
struct device *dev = tas5720->codec->dev; struct device *dev = tas5720->component->dev;
unsigned int curr_fault; unsigned int curr_fault;
int ret; int ret;
...@@ -267,18 +267,18 @@ static void tas5720_fault_check_work(struct work_struct *work) ...@@ -267,18 +267,18 @@ static void tas5720_fault_check_work(struct work_struct *work)
msecs_to_jiffies(TAS5720_FAULT_CHECK_INTERVAL)); msecs_to_jiffies(TAS5720_FAULT_CHECK_INTERVAL));
} }
static int tas5720_codec_probe(struct snd_soc_codec *codec) static int tas5720_codec_probe(struct snd_soc_component *component)
{ {
struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec); struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
unsigned int device_id, expected_device_id; unsigned int device_id, expected_device_id;
int ret; int ret;
tas5720->codec = codec; tas5720->component = component;
ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies),
tas5720->supplies); tas5720->supplies);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "failed to enable supplies: %d\n", ret); dev_err(component->dev, "failed to enable supplies: %d\n", ret);
return ret; return ret;
} }
...@@ -289,7 +289,7 @@ static int tas5720_codec_probe(struct snd_soc_codec *codec) ...@@ -289,7 +289,7 @@ static int tas5720_codec_probe(struct snd_soc_codec *codec)
*/ */
ret = regmap_read(tas5720->regmap, TAS5720_DEVICE_ID_REG, &device_id); ret = regmap_read(tas5720->regmap, TAS5720_DEVICE_ID_REG, &device_id);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "failed to read device ID register: %d\n", dev_err(component->dev, "failed to read device ID register: %d\n",
ret); ret);
goto probe_fail; goto probe_fail;
} }
...@@ -302,19 +302,19 @@ static int tas5720_codec_probe(struct snd_soc_codec *codec) ...@@ -302,19 +302,19 @@ static int tas5720_codec_probe(struct snd_soc_codec *codec)
expected_device_id = TAS5722_DEVICE_ID; expected_device_id = TAS5722_DEVICE_ID;
break; break;
default: default:
dev_err(codec->dev, "unexpected private driver data\n"); dev_err(component->dev, "unexpected private driver data\n");
return -EINVAL; return -EINVAL;
} }
if (device_id != expected_device_id) if (device_id != expected_device_id)
dev_warn(codec->dev, "wrong device ID. expected: %u read: %u\n", dev_warn(component->dev, "wrong device ID. expected: %u read: %u\n",
expected_device_id, device_id); expected_device_id, device_id);
/* Set device to mute */ /* Set device to mute */
ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL2_REG, ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL2_REG,
TAS5720_MUTE, TAS5720_MUTE); TAS5720_MUTE, TAS5720_MUTE);
if (ret < 0) if (ret < 0)
goto error_snd_soc_update_bits; goto error_snd_soc_component_update_bits;
/* /*
* Enter shutdown mode - our default when not playing audio - to * Enter shutdown mode - our default when not playing audio - to
...@@ -322,17 +322,17 @@ static int tas5720_codec_probe(struct snd_soc_codec *codec) ...@@ -322,17 +322,17 @@ static int tas5720_codec_probe(struct snd_soc_codec *codec)
* side doing so as all device registers are preserved and the wakeup * side doing so as all device registers are preserved and the wakeup
* of the codec is rather quick which we do using a dapm widget. * of the codec is rather quick which we do using a dapm widget.
*/ */
ret = snd_soc_update_bits(codec, TAS5720_POWER_CTRL_REG, ret = snd_soc_component_update_bits(component, TAS5720_POWER_CTRL_REG,
TAS5720_SDZ, 0); TAS5720_SDZ, 0);
if (ret < 0) if (ret < 0)
goto error_snd_soc_update_bits; goto error_snd_soc_component_update_bits;
INIT_DELAYED_WORK(&tas5720->fault_check_work, tas5720_fault_check_work); INIT_DELAYED_WORK(&tas5720->fault_check_work, tas5720_fault_check_work);
return 0; return 0;
error_snd_soc_update_bits: error_snd_soc_component_update_bits:
dev_err(codec->dev, "error configuring device registers: %d\n", ret); dev_err(component->dev, "error configuring device registers: %d\n", ret);
probe_fail: probe_fail:
regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies), regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies),
...@@ -340,9 +340,9 @@ static int tas5720_codec_probe(struct snd_soc_codec *codec) ...@@ -340,9 +340,9 @@ static int tas5720_codec_probe(struct snd_soc_codec *codec)
return ret; return ret;
} }
static int tas5720_codec_remove(struct snd_soc_codec *codec) static void tas5720_codec_remove(struct snd_soc_component *component)
{ {
struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec); struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
int ret; int ret;
cancel_delayed_work_sync(&tas5720->fault_check_work); cancel_delayed_work_sync(&tas5720->fault_check_work);
...@@ -350,24 +350,22 @@ static int tas5720_codec_remove(struct snd_soc_codec *codec) ...@@ -350,24 +350,22 @@ static int tas5720_codec_remove(struct snd_soc_codec *codec)
ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies), ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies),
tas5720->supplies); tas5720->supplies);
if (ret < 0) if (ret < 0)
dev_err(codec->dev, "failed to disable supplies: %d\n", ret); dev_err(component->dev, "failed to disable supplies: %d\n", ret);
return ret;
}; };
static int tas5720_dac_event(struct snd_soc_dapm_widget *w, static int tas5720_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec); struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
int ret; int ret;
if (event & SND_SOC_DAPM_POST_PMU) { if (event & SND_SOC_DAPM_POST_PMU) {
/* Take TAS5720 out of shutdown mode */ /* Take TAS5720 out of shutdown mode */
ret = snd_soc_update_bits(codec, TAS5720_POWER_CTRL_REG, ret = snd_soc_component_update_bits(component, TAS5720_POWER_CTRL_REG,
TAS5720_SDZ, TAS5720_SDZ); TAS5720_SDZ, TAS5720_SDZ);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "error waking codec: %d\n", ret); dev_err(component->dev, "error waking component: %d\n", ret);
return ret; return ret;
} }
...@@ -390,10 +388,10 @@ static int tas5720_dac_event(struct snd_soc_dapm_widget *w, ...@@ -390,10 +388,10 @@ static int tas5720_dac_event(struct snd_soc_dapm_widget *w,
cancel_delayed_work_sync(&tas5720->fault_check_work); cancel_delayed_work_sync(&tas5720->fault_check_work);
/* Place TAS5720 in shutdown mode to minimize current draw */ /* Place TAS5720 in shutdown mode to minimize current draw */
ret = snd_soc_update_bits(codec, TAS5720_POWER_CTRL_REG, ret = snd_soc_component_update_bits(component, TAS5720_POWER_CTRL_REG,
TAS5720_SDZ, 0); TAS5720_SDZ, 0);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "error shutting down codec: %d\n", dev_err(component->dev, "error shutting down component: %d\n",
ret); ret);
return ret; return ret;
} }
...@@ -403,9 +401,9 @@ static int tas5720_dac_event(struct snd_soc_dapm_widget *w, ...@@ -403,9 +401,9 @@ static int tas5720_dac_event(struct snd_soc_dapm_widget *w,
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int tas5720_suspend(struct snd_soc_codec *codec) static int tas5720_suspend(struct snd_soc_component *component)
{ {
struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec); struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
int ret; int ret;
regcache_cache_only(tas5720->regmap, true); regcache_cache_only(tas5720->regmap, true);
...@@ -414,20 +412,20 @@ static int tas5720_suspend(struct snd_soc_codec *codec) ...@@ -414,20 +412,20 @@ static int tas5720_suspend(struct snd_soc_codec *codec)
ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies), ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies),
tas5720->supplies); tas5720->supplies);
if (ret < 0) if (ret < 0)
dev_err(codec->dev, "failed to disable supplies: %d\n", ret); dev_err(component->dev, "failed to disable supplies: %d\n", ret);
return ret; return ret;
} }
static int tas5720_resume(struct snd_soc_codec *codec) static int tas5720_resume(struct snd_soc_component *component)
{ {
struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec); struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component);
int ret; int ret;
ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies),
tas5720->supplies); tas5720->supplies);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "failed to enable supplies: %d\n", ret); dev_err(component->dev, "failed to enable supplies: %d\n", ret);
return ret; return ret;
} }
...@@ -435,7 +433,7 @@ static int tas5720_resume(struct snd_soc_codec *codec) ...@@ -435,7 +433,7 @@ static int tas5720_resume(struct snd_soc_codec *codec)
ret = regcache_sync(tas5720->regmap); ret = regcache_sync(tas5720->regmap);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "failed to sync regcache: %d\n", ret); dev_err(component->dev, "failed to sync regcache: %d\n", ret);
return ret; return ret;
} }
...@@ -512,20 +510,21 @@ static const struct snd_soc_dapm_route tas5720_audio_map[] = { ...@@ -512,20 +510,21 @@ static const struct snd_soc_dapm_route tas5720_audio_map[] = {
{ "OUT", NULL, "DAC" }, { "OUT", NULL, "DAC" },
}; };
static const struct snd_soc_codec_driver soc_codec_dev_tas5720 = { static const struct snd_soc_component_driver soc_component_dev_tas5720 = {
.probe = tas5720_codec_probe, .probe = tas5720_codec_probe,
.remove = tas5720_codec_remove, .remove = tas5720_codec_remove,
.suspend = tas5720_suspend, .suspend = tas5720_suspend,
.resume = tas5720_resume, .resume = tas5720_resume,
.controls = tas5720_snd_controls,
.component_driver = { .num_controls = ARRAY_SIZE(tas5720_snd_controls),
.controls = tas5720_snd_controls, .dapm_widgets = tas5720_dapm_widgets,
.num_controls = ARRAY_SIZE(tas5720_snd_controls), .num_dapm_widgets = ARRAY_SIZE(tas5720_dapm_widgets),
.dapm_widgets = tas5720_dapm_widgets, .dapm_routes = tas5720_audio_map,
.num_dapm_widgets = ARRAY_SIZE(tas5720_dapm_widgets), .num_dapm_routes = ARRAY_SIZE(tas5720_audio_map),
.dapm_routes = tas5720_audio_map, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(tas5720_audio_map), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
/* PCM rates supported by the TAS5720 driver */ /* PCM rates supported by the TAS5720 driver */
...@@ -614,26 +613,17 @@ static int tas5720_probe(struct i2c_client *client, ...@@ -614,26 +613,17 @@ static int tas5720_probe(struct i2c_client *client,
dev_set_drvdata(dev, data); dev_set_drvdata(dev, data);
ret = snd_soc_register_codec(&client->dev, ret = devm_snd_soc_register_component(&client->dev,
&soc_codec_dev_tas5720, &soc_component_dev_tas5720,
tas5720_dai, ARRAY_SIZE(tas5720_dai)); tas5720_dai, ARRAY_SIZE(tas5720_dai));
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to register codec: %d\n", ret); dev_err(dev, "failed to register component: %d\n", ret);
return ret; return ret;
} }
return 0; return 0;
} }
static int tas5720_remove(struct i2c_client *client)
{
struct device *dev = &client->dev;
snd_soc_unregister_codec(dev);
return 0;
}
static const struct i2c_device_id tas5720_id[] = { static const struct i2c_device_id tas5720_id[] = {
{ "tas5720", TAS5720 }, { "tas5720", TAS5720 },
{ "tas5722", TAS5722 }, { "tas5722", TAS5722 },
...@@ -656,7 +646,6 @@ static struct i2c_driver tas5720_i2c_driver = { ...@@ -656,7 +646,6 @@ static struct i2c_driver tas5720_i2c_driver = {
.of_match_table = of_match_ptr(tas5720_of_match), .of_match_table = of_match_ptr(tas5720_of_match),
}, },
.probe = tas5720_probe, .probe = tas5720_probe,
.remove = tas5720_remove,
.id_table = tas5720_id, .id_table = tas5720_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