Commit 1dfdbe73 authored by Codrin Ciubotariu's avatar Codrin Ciubotariu Committed by Mark Brown

ASoC: atmel-classd: remove codec component

The CPU and the codec both are represented now as components, so for
CLASS-D we are registering two componenets with the same name. Since
there is no actual codec, we will merge the codec component into the
CPU one and use a dummy codec instead, for the DAI link.
As a bonus, debugfs will no longer report an error when will try to
create entries for both componenets with the same name.
Signed-off-by: default avatarCodrin Ciubotariu <codrin.ciubotariu@microchip.com>
Link: https://lore.kernel.org/r/20200708101249.2626560-1-codrin.ciubotariu@microchip.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 6940701c
...@@ -120,39 +120,21 @@ static int atmel_classd_cpu_dai_startup(struct snd_pcm_substream *substream, ...@@ -120,39 +120,21 @@ static int atmel_classd_cpu_dai_startup(struct snd_pcm_substream *substream,
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card);
int err;
regmap_write(dd->regmap, CLASSD_THR, 0x0); regmap_write(dd->regmap, CLASSD_THR, 0x0);
return clk_prepare_enable(dd->pclk); err = clk_prepare_enable(dd->pclk);
} if (err)
return err;
static void atmel_classd_cpu_dai_shutdown(struct snd_pcm_substream *substream, err = clk_prepare_enable(dd->gclk);
struct snd_soc_dai *cpu_dai) if (err) {
{ clk_disable_unprepare(dd->pclk);
struct snd_soc_pcm_runtime *rtd = substream->private_data; return err;
struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); }
return 0;
clk_disable_unprepare(dd->pclk);
} }
static const struct snd_soc_dai_ops atmel_classd_cpu_dai_ops = {
.startup = atmel_classd_cpu_dai_startup,
.shutdown = atmel_classd_cpu_dai_shutdown,
};
static struct snd_soc_dai_driver atmel_classd_cpu_dai = {
.playback = {
.channels_min = 1,
.channels_max = 2,
.rates = ATMEL_CLASSD_RATES,
.formats = SNDRV_PCM_FMTBIT_S16_LE,},
.ops = &atmel_classd_cpu_dai_ops,
};
static const struct snd_soc_component_driver atmel_classd_cpu_dai_component = {
.name = "atmel-classd",
};
/* platform */ /* platform */
static int static int
atmel_classd_platform_configure_dma(struct snd_pcm_substream *substream, atmel_classd_platform_configure_dma(struct snd_pcm_substream *substream,
...@@ -306,31 +288,10 @@ static int atmel_classd_component_resume(struct snd_soc_component *component) ...@@ -306,31 +288,10 @@ static int atmel_classd_component_resume(struct snd_soc_component *component)
return regcache_sync(dd->regmap); return regcache_sync(dd->regmap);
} }
static struct snd_soc_component_driver soc_component_dev_classd = { static int atmel_classd_cpu_dai_digital_mute(struct snd_soc_dai *cpu_dai,
.probe = atmel_classd_component_probe, int mute)
.resume = atmel_classd_component_resume,
.controls = atmel_classd_snd_controls,
.num_controls = ARRAY_SIZE(atmel_classd_snd_controls),
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
};
/* codec dai component */
static int atmel_classd_codec_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card);
return clk_prepare_enable(dd->gclk);
}
static int atmel_classd_codec_dai_digital_mute(struct snd_soc_dai *codec_dai,
int mute)
{ {
struct snd_soc_component *component = codec_dai->component; struct snd_soc_component *component = cpu_dai->component;
u32 mask, val; u32 mask, val;
mask = CLASSD_MR_LMUTE_MASK | CLASSD_MR_RMUTE_MASK; mask = CLASSD_MR_LMUTE_MASK | CLASSD_MR_RMUTE_MASK;
...@@ -373,13 +334,13 @@ static struct { ...@@ -373,13 +334,13 @@ static struct {
}; };
static int static int
atmel_classd_codec_dai_hw_params(struct snd_pcm_substream *substream, atmel_classd_cpu_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *codec_dai) struct snd_soc_dai *cpu_dai)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_component *component = codec_dai->component; struct snd_soc_component *component = cpu_dai->component;
int fs; int fs;
int i, best, best_val, cur_val, ret; int i, best, best_val, cur_val, ret;
u32 mask, val; u32 mask, val;
...@@ -417,8 +378,8 @@ atmel_classd_codec_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -417,8 +378,8 @@ atmel_classd_codec_dai_hw_params(struct snd_pcm_substream *substream,
} }
static void static void
atmel_classd_codec_dai_shutdown(struct snd_pcm_substream *substream, atmel_classd_cpu_dai_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai) struct snd_soc_dai *cpu_dai)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card);
...@@ -426,10 +387,10 @@ atmel_classd_codec_dai_shutdown(struct snd_pcm_substream *substream, ...@@ -426,10 +387,10 @@ atmel_classd_codec_dai_shutdown(struct snd_pcm_substream *substream,
clk_disable_unprepare(dd->gclk); clk_disable_unprepare(dd->gclk);
} }
static int atmel_classd_codec_dai_prepare(struct snd_pcm_substream *substream, static int atmel_classd_cpu_dai_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai) struct snd_soc_dai *cpu_dai)
{ {
struct snd_soc_component *component = codec_dai->component; struct snd_soc_component *component = cpu_dai->component;
snd_soc_component_update_bits(component, CLASSD_MR, snd_soc_component_update_bits(component, CLASSD_MR,
CLASSD_MR_LEN_MASK | CLASSD_MR_REN_MASK, CLASSD_MR_LEN_MASK | CLASSD_MR_REN_MASK,
...@@ -439,10 +400,10 @@ static int atmel_classd_codec_dai_prepare(struct snd_pcm_substream *substream, ...@@ -439,10 +400,10 @@ static int atmel_classd_codec_dai_prepare(struct snd_pcm_substream *substream,
return 0; return 0;
} }
static int atmel_classd_codec_dai_trigger(struct snd_pcm_substream *substream, static int atmel_classd_cpu_dai_trigger(struct snd_pcm_substream *substream,
int cmd, struct snd_soc_dai *codec_dai) int cmd, struct snd_soc_dai *cpu_dai)
{ {
struct snd_soc_component *component = codec_dai->component; struct snd_soc_component *component = cpu_dai->component;
u32 mask, val; u32 mask, val;
mask = CLASSD_MR_LEN_MASK | CLASSD_MR_REN_MASK; mask = CLASSD_MR_LEN_MASK | CLASSD_MR_REN_MASK;
...@@ -468,19 +429,16 @@ static int atmel_classd_codec_dai_trigger(struct snd_pcm_substream *substream, ...@@ -468,19 +429,16 @@ static int atmel_classd_codec_dai_trigger(struct snd_pcm_substream *substream,
return 0; return 0;
} }
static const struct snd_soc_dai_ops atmel_classd_codec_dai_ops = { static const struct snd_soc_dai_ops atmel_classd_cpu_dai_ops = {
.digital_mute = atmel_classd_codec_dai_digital_mute, .startup = atmel_classd_cpu_dai_startup,
.startup = atmel_classd_codec_dai_startup, .shutdown = atmel_classd_cpu_dai_shutdown,
.shutdown = atmel_classd_codec_dai_shutdown, .digital_mute = atmel_classd_cpu_dai_digital_mute,
.hw_params = atmel_classd_codec_dai_hw_params, .hw_params = atmel_classd_cpu_dai_hw_params,
.prepare = atmel_classd_codec_dai_prepare, .prepare = atmel_classd_cpu_dai_prepare,
.trigger = atmel_classd_codec_dai_trigger, .trigger = atmel_classd_cpu_dai_trigger,
}; };
#define ATMEL_CLASSD_CODEC_DAI_NAME "atmel-classd-hifi" static struct snd_soc_dai_driver atmel_classd_cpu_dai = {
static struct snd_soc_dai_driver atmel_classd_codec_dai = {
.name = ATMEL_CLASSD_CODEC_DAI_NAME,
.playback = { .playback = {
.stream_name = "Playback", .stream_name = "Playback",
.channels_min = 1, .channels_min = 1,
...@@ -488,7 +446,18 @@ static struct snd_soc_dai_driver atmel_classd_codec_dai = { ...@@ -488,7 +446,18 @@ static struct snd_soc_dai_driver atmel_classd_codec_dai = {
.rates = ATMEL_CLASSD_RATES, .rates = ATMEL_CLASSD_RATES,
.formats = SNDRV_PCM_FMTBIT_S16_LE, .formats = SNDRV_PCM_FMTBIT_S16_LE,
}, },
.ops = &atmel_classd_codec_dai_ops, .ops = &atmel_classd_cpu_dai_ops,
};
static const struct snd_soc_component_driver atmel_classd_cpu_dai_component = {
.name = "atmel-classd",
.probe = atmel_classd_component_probe,
.resume = atmel_classd_component_resume,
.controls = atmel_classd_snd_controls,
.num_controls = ARRAY_SIZE(atmel_classd_snd_controls),
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
}; };
/* ASoC sound card */ /* ASoC sound card */
...@@ -517,9 +486,9 @@ static int atmel_classd_asoc_card_init(struct device *dev, ...@@ -517,9 +486,9 @@ static int atmel_classd_asoc_card_init(struct device *dev,
dai_link->name = "CLASSD"; dai_link->name = "CLASSD";
dai_link->stream_name = "CLASSD PCM"; dai_link->stream_name = "CLASSD PCM";
dai_link->codecs->dai_name = ATMEL_CLASSD_CODEC_DAI_NAME; dai_link->codecs->dai_name = "snd-soc-dummy-dai";
dai_link->cpus->dai_name = dev_name(dev); dai_link->cpus->dai_name = dev_name(dev);
dai_link->codecs->name = dev_name(dev); dai_link->codecs->name = "snd-soc-dummy";
dai_link->platforms->name = dev_name(dev); dai_link->platforms->name = dev_name(dev);
card->dai_link = dai_link; card->dai_link = dai_link;
...@@ -620,13 +589,6 @@ static int atmel_classd_probe(struct platform_device *pdev) ...@@ -620,13 +589,6 @@ static int atmel_classd_probe(struct platform_device *pdev)
return ret; return ret;
} }
ret = devm_snd_soc_register_component(dev, &soc_component_dev_classd,
&atmel_classd_codec_dai, 1);
if (ret) {
dev_err(dev, "could not register component: %d\n", ret);
return ret;
}
/* register sound card */ /* register sound card */
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
if (!card) { if (!card) {
......
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