Skip to content

Commit cb18cd2

Browse files
morimotobroonie
authored andcommitted
ASoC: soc-core: do rtd->id trick at snd_soc_add_pcm_runtime()
qcom/qdsp6 want to use irregular rtd->id because of its topology. Current code is calculating it at soc_init_pcm_runtime() which calls soc_new_pcm(), and it doesn't save it to rtd->id. Let's calculate and save it to rtd at snd_soc_add_pcm_runtime() which create rtd and connect related components. But, this feature should be implemented by using "dai_link" instead of "component". Add FIXME as comment. Signed-off-by: Kuninori Morimoto <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c59db5e commit cb18cd2

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

sound/soc/soc-core.c

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ static int snd_soc_add_pcm_runtime(struct snd_soc_card *card,
11661166
struct snd_soc_pcm_runtime *rtd;
11671167
struct snd_soc_dai_link_component *codec, *platform, *cpu;
11681168
struct snd_soc_component *component;
1169-
int i, ret;
1169+
int i, id, ret;
11701170

11711171
lockdep_assert_held(&client_mutex);
11721172

@@ -1225,6 +1225,28 @@ static int snd_soc_add_pcm_runtime(struct snd_soc_card *card,
12251225
}
12261226
}
12271227

1228+
/*
1229+
* Most drivers will register their PCMs using DAI link ordering but
1230+
* topology based drivers can use the DAI link id field to set PCM
1231+
* device number and then use rtd + a base offset of the BEs.
1232+
*
1233+
* FIXME
1234+
*
1235+
* This should be implemented by using "dai_link" feature instead of
1236+
* "component" feature.
1237+
*/
1238+
id = rtd->id;
1239+
for_each_rtd_components(rtd, i, component) {
1240+
if (!component->driver->use_dai_pcm_id)
1241+
continue;
1242+
1243+
if (rtd->dai_link->no_pcm)
1244+
id += component->driver->be_pcm_base;
1245+
else
1246+
id = rtd->dai_link->id;
1247+
}
1248+
rtd->id = id;
1249+
12281250
return 0;
12291251

12301252
_err_defer:
@@ -1457,8 +1479,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
14571479
{
14581480
struct snd_soc_dai_link *dai_link = rtd->dai_link;
14591481
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
1460-
struct snd_soc_component *component;
1461-
int ret, id, i;
1482+
int ret, id;
14621483

14631484
/* do machine specific initialization */
14641485
ret = snd_soc_link_init(rtd);
@@ -1475,21 +1496,6 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
14751496

14761497
id = rtd->id;
14771498

1478-
/*
1479-
* most drivers will register their PCMs using DAI link ordering but
1480-
* topology based drivers can use the DAI link id field to set PCM
1481-
* device number and then use rtd + a base offset of the BEs.
1482-
*/
1483-
for_each_rtd_components(rtd, i, component) {
1484-
if (!component->driver->use_dai_pcm_id)
1485-
continue;
1486-
1487-
if (rtd->dai_link->no_pcm)
1488-
id += component->driver->be_pcm_base;
1489-
else
1490-
id = rtd->dai_link->id;
1491-
}
1492-
14931499
/* create compress_device if possible */
14941500
ret = snd_soc_dai_compress_new(cpu_dai, rtd, id);
14951501
if (ret != -ENOTSUPP)

0 commit comments

Comments
 (0)