Skip to content

Commit ab53dfd

Browse files
TE-N-ShengjiuWangbroonie
authored andcommitted
ASoC: fsl-asoc-card: Dynamically allocate memory for snd_soc_dai_link_components
The static snd_soc_dai_link_components cause conflict for multiple instances of this generic driver. For example, when there is wm8962 and SPDIF case enabled together, the contaminated snd_soc_dai_link_components will cause another device probe fail. Fixes: 6d174cc ("ASoC: fsl-asoc-card: merge spdif support from imx-spdif.c") Signed-off-by: Shengjiu Wang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 1d9ce44 commit ab53dfd

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

sound/soc/fsl/fsl-asoc-card.c

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -306,27 +306,12 @@ static int be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
306306
return 0;
307307
}
308308

309-
SND_SOC_DAILINK_DEFS(hifi,
310-
DAILINK_COMP_ARRAY(COMP_EMPTY()),
311-
DAILINK_COMP_ARRAY(COMP_EMPTY(), COMP_EMPTY()),
312-
DAILINK_COMP_ARRAY(COMP_EMPTY()));
313-
314-
SND_SOC_DAILINK_DEFS(hifi_fe,
315-
DAILINK_COMP_ARRAY(COMP_EMPTY()),
316-
DAILINK_COMP_ARRAY(COMP_DUMMY()),
317-
DAILINK_COMP_ARRAY(COMP_EMPTY()));
318-
319-
SND_SOC_DAILINK_DEFS(hifi_be,
320-
DAILINK_COMP_ARRAY(COMP_EMPTY()),
321-
DAILINK_COMP_ARRAY(COMP_EMPTY(), COMP_EMPTY()));
322-
323309
static const struct snd_soc_dai_link fsl_asoc_card_dai[] = {
324310
/* Default ASoC DAI Link*/
325311
{
326312
.name = "HiFi",
327313
.stream_name = "HiFi",
328314
.ops = &fsl_asoc_card_ops,
329-
SND_SOC_DAILINK_REG(hifi),
330315
},
331316
/* DPCM Link between Front-End and Back-End (Optional) */
332317
{
@@ -335,7 +320,6 @@ static const struct snd_soc_dai_link fsl_asoc_card_dai[] = {
335320
.dpcm_playback = 1,
336321
.dpcm_capture = 1,
337322
.dynamic = 1,
338-
SND_SOC_DAILINK_REG(hifi_fe),
339323
},
340324
{
341325
.name = "HiFi-ASRC-BE",
@@ -345,7 +329,6 @@ static const struct snd_soc_dai_link fsl_asoc_card_dai[] = {
345329
.dpcm_playback = 1,
346330
.dpcm_capture = 1,
347331
.no_pcm = 1,
348-
SND_SOC_DAILINK_REG(hifi_be),
349332
},
350333
};
351334

@@ -637,6 +620,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
637620
struct platform_device *cpu_pdev;
638621
struct fsl_asoc_card_priv *priv;
639622
struct device *codec_dev[2] = { NULL, NULL };
623+
struct snd_soc_dai_link_component *dlc;
640624
const char *codec_dai_name[2];
641625
const char *codec_dev_name[2];
642626
u32 asrc_fmt = 0;
@@ -717,7 +701,35 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
717701

718702
memcpy(priv->dai_link, fsl_asoc_card_dai,
719703
sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(priv->dai_link));
704+
/*
705+
* "Default ASoC DAI Link": 1 cpus, 2 codecs, 1 platforms
706+
* "DPCM Link Front-End": 1 cpus, 1 codecs (dummy), 1 platforms
707+
* "DPCM Link Back-End": 1 cpus, 2 codecs
708+
* totally 10 components
709+
*/
710+
dlc = devm_kcalloc(&pdev->dev, 10, sizeof(*dlc), GFP_KERNEL);
711+
if (!dlc) {
712+
ret = -ENOMEM;
713+
goto asrc_fail;
714+
}
715+
716+
priv->dai_link[0].cpus = &dlc[0];
717+
priv->dai_link[0].num_cpus = 1;
718+
priv->dai_link[0].codecs = &dlc[1];
720719
priv->dai_link[0].num_codecs = 1;
720+
priv->dai_link[0].platforms = &dlc[3];
721+
priv->dai_link[0].num_platforms = 1;
722+
723+
priv->dai_link[1].cpus = &dlc[4];
724+
priv->dai_link[1].num_cpus = 1;
725+
priv->dai_link[1].codecs = &dlc[5];
726+
priv->dai_link[1].num_codecs = 0; /* dummy */
727+
priv->dai_link[1].platforms = &dlc[6];
728+
priv->dai_link[1].num_platforms = 1;
729+
730+
priv->dai_link[2].cpus = &dlc[7];
731+
priv->dai_link[2].num_cpus = 1;
732+
priv->dai_link[2].codecs = &dlc[8];
721733
priv->dai_link[2].num_codecs = 1;
722734

723735
priv->card.dapm_routes = audio_map;

0 commit comments

Comments
 (0)