Commit f3c66807 authored by Codrin Ciubotariu's avatar Codrin Ciubotariu Committed by Mark Brown

ASoC: atmel-pdmic: remove codec component

The CPU and the codec both are represented now as components, so for
PDMIC 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/20200708163359.2698696-1-codrin.ciubotariu@microchip.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1dfdbe73
...@@ -147,32 +147,26 @@ static int atmel_pdmic_cpu_dai_prepare(struct snd_pcm_substream *substream, ...@@ -147,32 +147,26 @@ static int atmel_pdmic_cpu_dai_prepare(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_pdmic *dd = snd_soc_card_get_drvdata(rtd->card); struct atmel_pdmic *dd = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_component *component = cpu_dai->component;
u32 val; u32 val;
int ret;
/* Clean the PDMIC Converted Data Register */ /* Clean the PDMIC Converted Data Register */
return regmap_read(dd->regmap, PDMIC_CDR, &val); ret = regmap_read(dd->regmap, PDMIC_CDR, &val);
} if (ret < 0)
return 0;
static const struct snd_soc_dai_ops atmel_pdmic_cpu_dai_ops = {
.startup = atmel_pdmic_cpu_dai_startup,
.shutdown = atmel_pdmic_cpu_dai_shutdown,
.prepare = atmel_pdmic_cpu_dai_prepare,
};
#define ATMEL_PDMIC_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE) ret = snd_soc_component_update_bits(component, PDMIC_CR,
PDMIC_CR_ENPDM_MASK,
PDMIC_CR_ENPDM_DIS <<
PDMIC_CR_ENPDM_SHIFT);
if (ret < 0)
return ret;
static struct snd_soc_dai_driver atmel_pdmic_cpu_dai = { return 0;
.capture = { }
.channels_min = 1,
.channels_max = 1,
.rates = SNDRV_PCM_RATE_KNOT,
.formats = ATMEL_PDMIC_FORMATS,},
.ops = &atmel_pdmic_cpu_dai_ops,
};
static const struct snd_soc_component_driver atmel_pdmic_cpu_dai_component = { #define ATMEL_PDMIC_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
.name = "atmel-pdmic",
};
/* platform */ /* platform */
#define ATMEL_PDMIC_MAX_BUF_SIZE (64 * 1024) #define ATMEL_PDMIC_MAX_BUF_SIZE (64 * 1024)
...@@ -355,27 +349,16 @@ static int atmel_pdmic_component_probe(struct snd_soc_component *component) ...@@ -355,27 +349,16 @@ static int atmel_pdmic_component_probe(struct snd_soc_component *component)
return 0; return 0;
} }
static struct snd_soc_component_driver soc_component_dev_pdmic = {
.probe = atmel_pdmic_component_probe,
.controls = atmel_pdmic_snd_controls,
.num_controls = ARRAY_SIZE(atmel_pdmic_snd_controls),
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
};
/* codec dai component */
#define PDMIC_MR_PRESCAL_MAX_VAL 127 #define PDMIC_MR_PRESCAL_MAX_VAL 127
static int static int
atmel_pdmic_codec_dai_hw_params(struct snd_pcm_substream *substream, atmel_pdmic_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_pdmic *dd = snd_soc_card_get_drvdata(rtd->card); struct atmel_pdmic *dd = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_component *component = codec_dai->component; struct snd_soc_component *component = cpu_dai->component;
unsigned int rate_min = substream->runtime->hw.rate_min; unsigned int rate_min = substream->runtime->hw.rate_min;
unsigned int rate_max = substream->runtime->hw.rate_max; unsigned int rate_max = substream->runtime->hw.rate_max;
int fs = params_rate(params); int fs = params_rate(params);
...@@ -445,21 +428,10 @@ atmel_pdmic_codec_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -445,21 +428,10 @@ atmel_pdmic_codec_dai_hw_params(struct snd_pcm_substream *substream,
return 0; return 0;
} }
static int atmel_pdmic_codec_dai_prepare(struct snd_pcm_substream *substream, static int atmel_pdmic_cpu_dai_trigger(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai) int cmd, struct snd_soc_dai *cpu_dai)
{
struct snd_soc_component *component = codec_dai->component;
snd_soc_component_update_bits(component, PDMIC_CR, PDMIC_CR_ENPDM_MASK,
PDMIC_CR_ENPDM_DIS << PDMIC_CR_ENPDM_SHIFT);
return 0;
}
static int atmel_pdmic_codec_dai_trigger(struct snd_pcm_substream *substream,
int cmd, struct snd_soc_dai *codec_dai)
{ {
struct snd_soc_component *component = codec_dai->component; struct snd_soc_component *component = cpu_dai->component;
u32 val; u32 val;
switch (cmd) { switch (cmd) {
...@@ -482,16 +454,16 @@ static int atmel_pdmic_codec_dai_trigger(struct snd_pcm_substream *substream, ...@@ -482,16 +454,16 @@ static int atmel_pdmic_codec_dai_trigger(struct snd_pcm_substream *substream,
return 0; return 0;
} }
static const struct snd_soc_dai_ops atmel_pdmic_codec_dai_ops = { static const struct snd_soc_dai_ops atmel_pdmic_cpu_dai_ops = {
.hw_params = atmel_pdmic_codec_dai_hw_params, .startup = atmel_pdmic_cpu_dai_startup,
.prepare = atmel_pdmic_codec_dai_prepare, .shutdown = atmel_pdmic_cpu_dai_shutdown,
.trigger = atmel_pdmic_codec_dai_trigger, .prepare = atmel_pdmic_cpu_dai_prepare,
.hw_params = atmel_pdmic_cpu_dai_hw_params,
.trigger = atmel_pdmic_cpu_dai_trigger,
}; };
#define ATMEL_PDMIC_CODEC_DAI_NAME "atmel-pdmic-hifi"
static struct snd_soc_dai_driver atmel_pdmic_codec_dai = { static struct snd_soc_dai_driver atmel_pdmic_cpu_dai = {
.name = ATMEL_PDMIC_CODEC_DAI_NAME,
.capture = { .capture = {
.stream_name = "Capture", .stream_name = "Capture",
.channels_min = 1, .channels_min = 1,
...@@ -499,7 +471,17 @@ static struct snd_soc_dai_driver atmel_pdmic_codec_dai = { ...@@ -499,7 +471,17 @@ static struct snd_soc_dai_driver atmel_pdmic_codec_dai = {
.rates = SNDRV_PCM_RATE_KNOT, .rates = SNDRV_PCM_RATE_KNOT,
.formats = ATMEL_PDMIC_FORMATS, .formats = ATMEL_PDMIC_FORMATS,
}, },
.ops = &atmel_pdmic_codec_dai_ops, .ops = &atmel_pdmic_cpu_dai_ops,
};
static const struct snd_soc_component_driver atmel_pdmic_cpu_dai_component = {
.name = "atmel-pdmic",
.probe = atmel_pdmic_component_probe,
.controls = atmel_pdmic_snd_controls,
.num_controls = ARRAY_SIZE(atmel_pdmic_snd_controls),
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
}; };
/* ASoC sound card */ /* ASoC sound card */
...@@ -528,9 +510,9 @@ static int atmel_pdmic_asoc_card_init(struct device *dev, ...@@ -528,9 +510,9 @@ static int atmel_pdmic_asoc_card_init(struct device *dev,
dai_link->name = "PDMIC"; dai_link->name = "PDMIC";
dai_link->stream_name = "PDMIC PCM"; dai_link->stream_name = "PDMIC PCM";
dai_link->codecs->dai_name = ATMEL_PDMIC_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;
...@@ -684,16 +666,6 @@ static int atmel_pdmic_probe(struct platform_device *pdev) ...@@ -684,16 +666,6 @@ static int atmel_pdmic_probe(struct platform_device *pdev)
return ret; return ret;
} }
/* register codec and codec dai */
atmel_pdmic_codec_dai.capture.rate_min = rate_min;
atmel_pdmic_codec_dai.capture.rate_max = rate_max;
ret = devm_snd_soc_register_component(dev, &soc_component_dev_pdmic,
&atmel_pdmic_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