Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: cleasnup rtd and its ID

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

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 (?)

+60 -58
+2 -3
include/sound/soc-dai.h
··· 216 216 struct snd_pcm_substream *substream, int rollback); 217 217 void snd_soc_dai_suspend(struct snd_soc_dai *dai); 218 218 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); 221 220 bool snd_soc_dai_stream_valid(const struct snd_soc_dai *dai, int stream); 222 221 void snd_soc_dai_action(struct snd_soc_dai *dai, 223 222 int stream, int action); ··· 274 275 int (*probe)(struct snd_soc_dai *dai); 275 276 int (*remove)(struct snd_soc_dai *dai); 276 277 /* compress dai */ 277 - int (*compress_new)(struct snd_soc_pcm_runtime *rtd, int num); 278 + int (*compress_new)(struct snd_soc_pcm_runtime *rtd); 278 279 /* Optional Callback used at pcm creation*/ 279 280 int (*pcm_new)(struct snd_soc_pcm_runtime *rtd, 280 281 struct snd_soc_dai *dai);
+4 -4
include/sound/soc.h
··· 486 486 struct snd_soc_component *snd_soc_lookup_component(struct device *dev, 487 487 const char *driver_name); 488 488 489 - int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num); 489 + int soc_new_pcm(struct snd_soc_pcm_runtime *rtd); 490 490 #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); 492 492 #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) 494 494 { 495 495 return 0; 496 496 } ··· 1195 1195 struct dentry *debugfs_dpcm_root; 1196 1196 #endif 1197 1197 1198 - unsigned int num; /* 0-based and monotonic increasing */ 1198 + unsigned int id; /* 0-based and monotonic increasing */ 1199 1199 struct list_head list; /* rtd list of the soc card */ 1200 1200 1201 1201 /* function mark */
+3 -3
sound/soc/fsl/imx-card.c
··· 275 275 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 276 276 struct imx_card_data *data = snd_soc_card_get_drvdata(rtd->card); 277 277 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]; 279 279 unsigned int width = slots * slot_width; 280 280 unsigned int rate = params_rate(params); 281 281 int i; ··· 313 313 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 314 314 struct snd_soc_card *card = rtd->card; 315 315 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]; 317 317 struct imx_card_plat_data *plat_data = data->plat_data; 318 318 struct device *dev = card->dev; 319 319 struct snd_soc_dai *codec_dai; ··· 435 435 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 436 436 struct snd_soc_card *card = rtd->card; 437 437 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]; 439 439 static struct snd_pcm_hw_constraint_list constraint_rates; 440 440 static struct snd_pcm_hw_constraint_list constraint_channels; 441 441 int ret = 0;
+5 -5
sound/soc/generic/simple-card-utils.c
··· 296 296 { 297 297 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 298 298 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); 300 300 struct simple_util_dai *dai; 301 301 unsigned int fixed_sysclk = 0; 302 302 int i1, i2, i; ··· 357 357 { 358 358 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 359 359 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); 361 361 struct simple_util_dai *dai; 362 362 int i; 363 363 ··· 448 448 struct simple_util_dai *pdai; 449 449 struct snd_soc_dai *sdai; 450 450 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); 452 452 unsigned int mclk, mclk_fs = 0; 453 453 int i, ret; 454 454 ··· 517 517 struct snd_pcm_hw_params *params) 518 518 { 519 519 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); 521 521 struct simple_util_data *data = &dai_props->adata; 522 522 struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 523 523 struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); ··· 628 628 int simple_util_dai_init(struct snd_soc_pcm_runtime *rtd) 629 629 { 630 630 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); 632 632 struct simple_util_dai *dai; 633 633 int i, ret; 634 634
+3 -3
sound/soc/meson/axg-card.c
··· 43 43 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 44 44 struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card); 45 45 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]; 47 47 48 48 return meson_card_i2s_set_sysclk(substream, params, be->mclk_fs); 49 49 } ··· 56 56 { 57 57 struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card); 58 58 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]; 60 60 struct snd_soc_dai *codec_dai; 61 61 int ret, i; 62 62 ··· 86 86 { 87 87 struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card); 88 88 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]; 90 90 int ret; 91 91 92 92 /* The loopback rx_mask is the pad tx_mask */
+1 -1
sound/soc/meson/gx-card.c
··· 32 32 struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 33 33 struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card); 34 34 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]; 36 36 37 37 return meson_card_i2s_set_sysclk(substream, params, be->mclk_fs); 38 38 }
+1 -1
sound/soc/renesas/rcar/core.c
··· 1843 1843 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1844 1844 .name = name, 1845 1845 .info = rsnd_kctrl_info, 1846 - .index = rtd->num, 1846 + .index = rtd->id, 1847 1847 .get = rsnd_kctrl_get, 1848 1848 .put = rsnd_kctrl_put, 1849 1849 };
+4 -5
sound/soc/soc-compress.c
··· 537 537 * snd_soc_new_compress - create a new compress. 538 538 * 539 539 * @rtd: The runtime for which we will create compress 540 - * @num: the device index number (zero based - shared with normal PCMs) 541 540 * 542 541 * Return: 0 for success, else error. 543 542 */ 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) 545 544 { 546 545 struct snd_soc_component *component; 547 546 struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); ··· 616 617 snprintf(new_name, sizeof(new_name), "(%s)", 617 618 rtd->dai_link->stream_name); 618 619 619 - ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, 620 + ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, rtd->id, 620 621 playback, capture, &be_pcm); 621 622 if (ret < 0) { 622 623 dev_err(rtd->card->dev, ··· 637 638 memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops)); 638 639 } else { 639 640 snprintf(new_name, sizeof(new_name), "%s %s-%d", 640 - rtd->dai_link->stream_name, codec_dai->name, num); 641 + rtd->dai_link->stream_name, codec_dai->name, rtd->id); 641 642 642 643 memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops)); 643 644 } ··· 651 652 break; 652 653 } 653 654 654 - ret = snd_compress_new(rtd->card->snd_card, num, direction, 655 + ret = snd_compress_new(rtd->card->snd_card, rtd->id, direction, 655 656 new_name, compr); 656 657 if (ret < 0) { 657 658 component = snd_soc_rtd_to_codec(rtd, 0)->component;
+27 -23
sound/soc/soc-core.c
··· 558 558 */ 559 559 rtd->card = card; 560 560 rtd->dai_link = dai_link; 561 - rtd->num = card->num_rtd++; 561 + rtd->id = card->num_rtd++; 562 562 rtd->pmdown_time = pmdown_time; /* default power off timeout */ 563 563 564 564 /* see for_each_card_rtds */ ··· 1166 1166 struct snd_soc_pcm_runtime *rtd; 1167 1167 struct snd_soc_dai_link_component *codec, *platform, *cpu; 1168 1168 struct snd_soc_component *component; 1169 - int i, ret; 1169 + int i, id, ret; 1170 1170 1171 1171 lockdep_assert_held(&client_mutex); 1172 1172 ··· 1224 1224 snd_soc_rtd_add_component(rtd, component); 1225 1225 } 1226 1226 } 1227 + 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; 1227 1249 1228 1250 return 0; 1229 1251 ··· 1479 1457 { 1480 1458 struct snd_soc_dai_link *dai_link = rtd->dai_link; 1481 1459 struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); 1482 - struct snd_soc_component *component; 1483 - int ret, num, i; 1460 + int ret; 1484 1461 1485 1462 /* do machine specific initialization */ 1486 1463 ret = snd_soc_link_init(rtd); ··· 1494 1473 /* add DPCM sysfs entries */ 1495 1474 soc_dpcm_debugfs_add(rtd); 1496 1475 1497 - num = rtd->num; 1498 - 1499 - /* 1500 - * most drivers will register their PCMs using DAI link ordering but 1501 - * topology based drivers can use the DAI link id field to set PCM 1502 - * device number and then use rtd + a base offset of the BEs. 1503 - */ 1504 - for_each_rtd_components(rtd, i, component) { 1505 - if (!component->driver->use_dai_pcm_id) 1506 - continue; 1507 - 1508 - if (rtd->dai_link->no_pcm) 1509 - num += component->driver->be_pcm_base; 1510 - else 1511 - num = rtd->dai_link->id; 1512 - } 1513 - 1514 1476 /* create compress_device if possible */ 1515 - ret = snd_soc_dai_compress_new(cpu_dai, rtd, num); 1477 + ret = snd_soc_dai_compress_new(cpu_dai, rtd); 1516 1478 if (ret != -ENOTSUPP) 1517 1479 goto err; 1518 1480 1519 1481 /* create the pcm */ 1520 - ret = soc_new_pcm(rtd, num); 1482 + ret = soc_new_pcm(rtd); 1521 1483 if (ret < 0) { 1522 1484 dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", 1523 1485 dai_link->stream_name, ret);
+2 -2
sound/soc/soc-dai.c
··· 457 457 } 458 458 459 459 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) 461 461 { 462 462 int ret = -ENOTSUPP; 463 463 if (dai->driver->ops && 464 464 dai->driver->ops->compress_new) 465 - ret = dai->driver->ops->compress_new(rtd, num); 465 + ret = dai->driver->ops->compress_new(rtd); 466 466 return soc_dai_ret(dai, ret); 467 467 } 468 468
+8 -8
sound/soc/soc-pcm.c
··· 2891 2891 2892 2892 static int soc_create_pcm(struct snd_pcm **pcm, 2893 2893 struct snd_soc_pcm_runtime *rtd, 2894 - int playback, int capture, int num) 2894 + int playback, int capture) 2895 2895 { 2896 2896 char new_name[64]; 2897 2897 int ret; ··· 2901 2901 snprintf(new_name, sizeof(new_name), "codec2codec(%s)", 2902 2902 rtd->dai_link->stream_name); 2903 2903 2904 - ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, 2904 + ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, rtd->id, 2905 2905 playback, capture, pcm); 2906 2906 } else if (rtd->dai_link->no_pcm) { 2907 2907 snprintf(new_name, sizeof(new_name), "(%s)", 2908 2908 rtd->dai_link->stream_name); 2909 2909 2910 - ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, 2910 + ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, rtd->id, 2911 2911 playback, capture, pcm); 2912 2912 } else { 2913 2913 if (rtd->dai_link->dynamic) ··· 2916 2916 else 2917 2917 snprintf(new_name, sizeof(new_name), "%s %s-%d", 2918 2918 rtd->dai_link->stream_name, 2919 - soc_codec_dai_name(rtd), num); 2919 + soc_codec_dai_name(rtd), rtd->id); 2920 2920 2921 - ret = snd_pcm_new(rtd->card->snd_card, new_name, num, playback, 2921 + ret = snd_pcm_new(rtd->card->snd_card, new_name, rtd->id, playback, 2922 2922 capture, pcm); 2923 2923 } 2924 2924 if (ret < 0) { ··· 2926 2926 new_name, rtd->dai_link->name, ret); 2927 2927 return ret; 2928 2928 } 2929 - dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n",num, new_name); 2929 + dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n", rtd->id, new_name); 2930 2930 2931 2931 return 0; 2932 2932 } 2933 2933 2934 2934 /* create a new pcm */ 2935 - int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) 2935 + int soc_new_pcm(struct snd_soc_pcm_runtime *rtd) 2936 2936 { 2937 2937 struct snd_soc_component *component; 2938 2938 struct snd_pcm *pcm; ··· 2943 2943 if (ret < 0) 2944 2944 return ret; 2945 2945 2946 - ret = soc_create_pcm(&pcm, rtd, playback, capture, num); 2946 + ret = soc_create_pcm(&pcm, rtd, playback, capture); 2947 2947 if (ret < 0) 2948 2948 return ret; 2949 2949