Skip to content

Commit ff96429

Browse files
committed
ASoC: cleasnup rtd and its ID
Merge series from Kuninori Morimoto <[email protected]>: rtd has own ID, but it is naming "num" for it. The naming is confusable. This patch rename it to "id". And many functions request both "rtd" and its "id" as function parameter, but rtd itself has rtd->id. This patch cleanup it. And, Qcom driver want to use irregular rtd ID because of its topology, and thus, soc-core need irregular calculation. I'm not sure why only Qcom needs such calculation, but this patch also cleanup it. But I guess we want to cleanup is not soc-core but Qcom side (?)
2 parents 9934878 + 8b12da9 commit ff96429

File tree

11 files changed

+60
-58
lines changed

11 files changed

+60
-58
lines changed

include/sound/soc-dai.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
216216
struct snd_pcm_substream *substream, int rollback);
217217
void snd_soc_dai_suspend(struct snd_soc_dai *dai);
218218
void snd_soc_dai_resume(struct snd_soc_dai *dai);
219-
int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
220-
struct snd_soc_pcm_runtime *rtd, int num);
219+
int snd_soc_dai_compress_new(struct snd_soc_dai *dai, struct snd_soc_pcm_runtime *rtd);
221220
bool snd_soc_dai_stream_valid(const struct snd_soc_dai *dai, int stream);
222221
void snd_soc_dai_action(struct snd_soc_dai *dai,
223222
int stream, int action);
@@ -275,7 +274,7 @@ struct snd_soc_dai_ops {
275274
int (*probe)(struct snd_soc_dai *dai);
276275
int (*remove)(struct snd_soc_dai *dai);
277276
/* compress dai */
278-
int (*compress_new)(struct snd_soc_pcm_runtime *rtd, int num);
277+
int (*compress_new)(struct snd_soc_pcm_runtime *rtd);
279278
/* Optional Callback used at pcm creation*/
280279
int (*pcm_new)(struct snd_soc_pcm_runtime *rtd,
281280
struct snd_soc_dai *dai);

include/sound/soc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,11 @@ struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
486486
struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
487487
const char *driver_name);
488488

489-
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
489+
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd);
490490
#ifdef CONFIG_SND_SOC_COMPRESS
491-
int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
491+
int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd);
492492
#else
493-
static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
493+
static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd)
494494
{
495495
return 0;
496496
}
@@ -1195,7 +1195,7 @@ struct snd_soc_pcm_runtime {
11951195
struct dentry *debugfs_dpcm_root;
11961196
#endif
11971197

1198-
unsigned int num; /* 0-based and monotonic increasing */
1198+
unsigned int id; /* 0-based and monotonic increasing */
11991199
struct list_head list; /* rtd list of the soc card */
12001200

12011201
/* function mark */

sound/soc/fsl/imx-card.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static unsigned long akcodec_get_mclk_rate(struct snd_pcm_substream *substream,
275275
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
276276
struct imx_card_data *data = snd_soc_card_get_drvdata(rtd->card);
277277
const struct imx_card_plat_data *plat_data = data->plat_data;
278-
struct dai_link_data *link_data = &data->link_data[rtd->num];
278+
struct dai_link_data *link_data = &data->link_data[rtd->id];
279279
unsigned int width = slots * slot_width;
280280
unsigned int rate = params_rate(params);
281281
int i;
@@ -313,7 +313,7 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream,
313313
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
314314
struct snd_soc_card *card = rtd->card;
315315
struct imx_card_data *data = snd_soc_card_get_drvdata(card);
316-
struct dai_link_data *link_data = &data->link_data[rtd->num];
316+
struct dai_link_data *link_data = &data->link_data[rtd->id];
317317
struct imx_card_plat_data *plat_data = data->plat_data;
318318
struct device *dev = card->dev;
319319
struct snd_soc_dai *codec_dai;
@@ -435,7 +435,7 @@ static int imx_aif_startup(struct snd_pcm_substream *substream)
435435
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
436436
struct snd_soc_card *card = rtd->card;
437437
struct imx_card_data *data = snd_soc_card_get_drvdata(card);
438-
struct dai_link_data *link_data = &data->link_data[rtd->num];
438+
struct dai_link_data *link_data = &data->link_data[rtd->id];
439439
static struct snd_pcm_hw_constraint_list constraint_rates;
440440
static struct snd_pcm_hw_constraint_list constraint_channels;
441441
int ret = 0;

sound/soc/generic/simple-card-utils.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ int simple_util_startup(struct snd_pcm_substream *substream)
296296
{
297297
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
298298
struct simple_util_priv *priv = snd_soc_card_get_drvdata(rtd->card);
299-
struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num);
299+
struct simple_dai_props *props = simple_priv_to_props(priv, rtd->id);
300300
struct simple_util_dai *dai;
301301
unsigned int fixed_sysclk = 0;
302302
int i1, i2, i;
@@ -357,7 +357,7 @@ void simple_util_shutdown(struct snd_pcm_substream *substream)
357357
{
358358
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
359359
struct simple_util_priv *priv = snd_soc_card_get_drvdata(rtd->card);
360-
struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num);
360+
struct simple_dai_props *props = simple_priv_to_props(priv, rtd->id);
361361
struct simple_util_dai *dai;
362362
int i;
363363

@@ -448,7 +448,7 @@ int simple_util_hw_params(struct snd_pcm_substream *substream,
448448
struct simple_util_dai *pdai;
449449
struct snd_soc_dai *sdai;
450450
struct simple_util_priv *priv = snd_soc_card_get_drvdata(rtd->card);
451-
struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num);
451+
struct simple_dai_props *props = simple_priv_to_props(priv, rtd->id);
452452
unsigned int mclk, mclk_fs = 0;
453453
int i, ret;
454454

@@ -517,7 +517,7 @@ int simple_util_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
517517
struct snd_pcm_hw_params *params)
518518
{
519519
struct simple_util_priv *priv = snd_soc_card_get_drvdata(rtd->card);
520-
struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
520+
struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->id);
521521
struct simple_util_data *data = &dai_props->adata;
522522
struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
523523
struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
@@ -628,7 +628,7 @@ static int simple_init_for_codec2codec(struct snd_soc_pcm_runtime *rtd,
628628
int simple_util_dai_init(struct snd_soc_pcm_runtime *rtd)
629629
{
630630
struct simple_util_priv *priv = snd_soc_card_get_drvdata(rtd->card);
631-
struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num);
631+
struct simple_dai_props *props = simple_priv_to_props(priv, rtd->id);
632632
struct simple_util_dai *dai;
633633
int i, ret;
634634

sound/soc/meson/axg-card.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int axg_card_tdm_be_hw_params(struct snd_pcm_substream *substream,
4343
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
4444
struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card);
4545
struct axg_dai_link_tdm_data *be =
46-
(struct axg_dai_link_tdm_data *)priv->link_data[rtd->num];
46+
(struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];
4747

4848
return meson_card_i2s_set_sysclk(substream, params, be->mclk_fs);
4949
}
@@ -56,7 +56,7 @@ static int axg_card_tdm_dai_init(struct snd_soc_pcm_runtime *rtd)
5656
{
5757
struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card);
5858
struct axg_dai_link_tdm_data *be =
59-
(struct axg_dai_link_tdm_data *)priv->link_data[rtd->num];
59+
(struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];
6060
struct snd_soc_dai *codec_dai;
6161
int ret, i;
6262

@@ -86,7 +86,7 @@ static int axg_card_tdm_dai_lb_init(struct snd_soc_pcm_runtime *rtd)
8686
{
8787
struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card);
8888
struct axg_dai_link_tdm_data *be =
89-
(struct axg_dai_link_tdm_data *)priv->link_data[rtd->num];
89+
(struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];
9090
int ret;
9191

9292
/* The loopback rx_mask is the pad tx_mask */

sound/soc/meson/gx-card.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static int gx_card_i2s_be_hw_params(struct snd_pcm_substream *substream,
3232
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
3333
struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card);
3434
struct gx_dai_link_i2s_data *be =
35-
(struct gx_dai_link_i2s_data *)priv->link_data[rtd->num];
35+
(struct gx_dai_link_i2s_data *)priv->link_data[rtd->id];
3636

3737
return meson_card_i2s_set_sysclk(substream, params, be->mclk_fs);
3838
}

sound/soc/renesas/rcar/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,7 @@ int rsnd_kctrl_new(struct rsnd_mod *mod,
18431843
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
18441844
.name = name,
18451845
.info = rsnd_kctrl_info,
1846-
.index = rtd->num,
1846+
.index = rtd->id,
18471847
.get = rsnd_kctrl_get,
18481848
.put = rsnd_kctrl_put,
18491849
};

sound/soc/soc-compress.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,11 +537,10 @@ static struct snd_compr_ops soc_compr_dyn_ops = {
537537
* snd_soc_new_compress - create a new compress.
538538
*
539539
* @rtd: The runtime for which we will create compress
540-
* @num: the device index number (zero based - shared with normal PCMs)
541540
*
542541
* Return: 0 for success, else error.
543542
*/
544-
int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
543+
int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd)
545544
{
546545
struct snd_soc_component *component;
547546
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
@@ -617,7 +616,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
617616
snprintf(new_name, sizeof(new_name), "(%s)",
618617
rtd->dai_link->stream_name);
619618

620-
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
619+
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, rtd->id,
621620
playback, capture, &be_pcm);
622621
if (ret < 0) {
623622
dev_err(rtd->card->dev,
@@ -638,7 +637,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
638637
memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops));
639638
} else {
640639
snprintf(new_name, sizeof(new_name), "%s %s-%d",
641-
rtd->dai_link->stream_name, codec_dai->name, num);
640+
rtd->dai_link->stream_name, codec_dai->name, rtd->id);
642641

643642
memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
644643
}
@@ -652,7 +651,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
652651
break;
653652
}
654653

655-
ret = snd_compress_new(rtd->card->snd_card, num, direction,
654+
ret = snd_compress_new(rtd->card->snd_card, rtd->id, direction,
656655
new_name, compr);
657656
if (ret < 0) {
658657
component = snd_soc_rtd_to_codec(rtd, 0)->component;

sound/soc/soc-core.c

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
558558
*/
559559
rtd->card = card;
560560
rtd->dai_link = dai_link;
561-
rtd->num = card->num_rtd++;
561+
rtd->id = card->num_rtd++;
562562
rtd->pmdown_time = pmdown_time; /* default power off timeout */
563563

564564
/* see for_each_card_rtds */
@@ -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, num, i;
1482+
int ret;
14621483

14631484
/* do machine specific initialization */
14641485
ret = snd_soc_link_init(rtd);
@@ -1473,30 +1494,13 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
14731494
/* add DPCM sysfs entries */
14741495
soc_dpcm_debugfs_add(rtd);
14751496

1476-
num = rtd->num;
1477-
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-
num += component->driver->be_pcm_base;
1489-
else
1490-
num = rtd->dai_link->id;
1491-
}
1492-
14931497
/* create compress_device if possible */
1494-
ret = snd_soc_dai_compress_new(cpu_dai, rtd, num);
1498+
ret = snd_soc_dai_compress_new(cpu_dai, rtd);
14951499
if (ret != -ENOTSUPP)
14961500
goto err;
14971501

14981502
/* create the pcm */
1499-
ret = soc_new_pcm(rtd, num);
1503+
ret = soc_new_pcm(rtd);
15001504
if (ret < 0) {
15011505
dev_err(card->dev, "ASoC: can't create pcm %s :%d\n",
15021506
dai_link->stream_name, ret);

sound/soc/soc-dai.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,12 +457,12 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
457457
}
458458

459459
int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
460-
struct snd_soc_pcm_runtime *rtd, int num)
460+
struct snd_soc_pcm_runtime *rtd)
461461
{
462462
int ret = -ENOTSUPP;
463463
if (dai->driver->ops &&
464464
dai->driver->ops->compress_new)
465-
ret = dai->driver->ops->compress_new(rtd, num);
465+
ret = dai->driver->ops->compress_new(rtd);
466466
return soc_dai_ret(dai, ret);
467467
}
468468

0 commit comments

Comments
 (0)