ASoC: cleasnup rtd and its ID
Subsystems (9)
Kuninori Morimoto
maintainercover ASoC: cleasnup rtd and its ID
Hi Mark
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 (?)
Kuninori Morimoto (8):
ASoC: rename rtd->num to rtd->id
ASoC: fsl: switch to use rtd->id from rtd->num
ASoC: meson: switch to use rtd->id from rtd->num
ASoC: sh: switch to use rtd->id from rtd->num
ASoC: generic: switch to use rtd->id from rtd->num
ASoC: remove rtd->num
ASoC: soc-core: do rtd->id trick at snd_soc_add_pcm_runtime()
ASoC: cleanup function parameter for rtd and its id
include/sound/soc-dai.h | 5 ++- include/sound/soc.h | 8 ++--- sound/soc/fsl/imx-card.c | 6 ++-- sound/soc/generic/simple-card-utils.c | 10 +++--- sound/soc/meson/axg-card.c | 6 ++-- sound/soc/meson/gx-card.c | 2 +- sound/soc/sh/rcar/core.c | 2 +- sound/soc/soc-compress.c | 9 +++-- sound/soc/soc-core.c | 50 +++++++++++++++------------ sound/soc/soc-dai.c | 4 +-- sound/soc/soc-pcm.c | 16 ++++----- 11 files changed, 60 insertions(+), 58 deletions(-)
Signature · 1 line
2.43.0
Kuninori Morimoto
maintainerPATCH 1/8 ASoC: rename rtd->num to rtd->id
Current rtd has "num". It sounds/looks like size of rtd or something, but it will be mainly used at snd_pcm_new() as "device index". This naming is confusable. Let's rename it to "id"
Some drivers are using rtd->num, so let's keep it so far, and remove it if all user was switched.
--- include/sound/soc-dai.h | 4 ++-- include/sound/soc.h | 9 +++++---- sound/soc/soc-compress.c | 10 +++++----- sound/soc/soc-core.c | 15 ++++++++------- sound/soc/soc-dai.c | 4 ++-- sound/soc/soc-pcm.c | 16 ++++++++-------- 6 files changed, 30 insertions(+), 28 deletions(-)
include/sound/soc-dai.h +2 -2
@@ -217,7 +217,7 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai,void snd_soc_dai_suspend (struct snd_soc_dai *dai);void snd_soc_dai_resume (struct snd_soc_dai *dai);int snd_soc_dai_compress_new (struct snd_soc_dai *dai, -struct snd_soc_pcm_runtime *rtd,int num); +struct snd_soc_pcm_runtime *rtd,int id);bool snd_soc_dai_stream_valid (const struct snd_soc_dai *dai,int stream);void snd_soc_dai_action (struct snd_soc_dai *dai,int stream,int action);
@@ -275,7 +275,7 @@ struct snd_soc_dai_ops {int (*probe)(struct snd_soc_dai *dai);int (*remove)(struct snd_soc_dai *dai);/* compress dai */ -int (*compress_new)(struct snd_soc_pcm_runtime *rtd,int num); +int (*compress_new)(struct snd_soc_pcm_runtime *rtd,int id);/* Optional Callback used at pcm creation*/ int (*pcm_new)(struct snd_soc_pcm_runtime *rtd,struct snd_soc_dai *dai);
include/sound/soc.h +5 -4
@@ -486,11 +486,11 @@ struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,struct snd_soc_component *snd_soc_lookup_component (struct device *dev,const char *driver_name); -int soc_new_pcm (struct snd_soc_pcm_runtime *rtd,int num); +int soc_new_pcm (struct snd_soc_pcm_runtime *rtd,int id);#ifdef CONFIG_SND_SOC_COMPRESS -int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd,int num); +int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd,int id);#else -static inline int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd,int num) +static inline int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd,int id) {return 0 ; }
@@ -1195,7 +1195,8 @@ struct snd_soc_pcm_runtime {struct dentry *debugfs_dpcm_root;#endif -unsigned int num;/* 0-based and monotonic increasing */ +unsigned int num;/* REMOVE ME */ +unsigned int id;/* 0-based and monotonic increasing */ struct list_head list;/* rtd list of the soc card */ /* function mark */
sound/soc/soc-compress.c +5 -5
@@ -537,11 +537,11 @@ static struct snd_compr_ops soc_compr_dyn_ops = {* snd_soc_new_compress - create a new compress. * * @rtd: The runtime for which we will create compress -* @num: the device index number (zero based - shared with normal PCMs) +* @id: the device index number (zero based - shared with normal PCMs) * * Return: 0 for success, else error. */ -int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd,int num) +int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd,int id) {struct snd_soc_component *component;struct snd_soc_dai *codec_dai =snd_soc_rtd_to_codec (rtd,0 );
@@ -617,7 +617,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)snprintf (new_name,sizeof (new_name),"(%s)" , rtd->dai_link->stream_name); - ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, num, + ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, id, playback, capture, &be_pcm);if (ret <0 ) { dev_err(rtd->card->dev,
@@ -638,7 +638,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)memcpy (compr->ops, &soc_compr_dyn_ops,sizeof (soc_compr_dyn_ops)); }else {snprintf (new_name,sizeof (new_name),"%s %s-%d" , - rtd->dai_link->stream_name, codec_dai->name, num); + rtd->dai_link->stream_name, codec_dai->name, id);memcpy (compr->ops, &soc_compr_ops,sizeof (soc_compr_ops)); }
@@ -652,7 +652,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)break ; } - ret =snd_compress_new (rtd->card->snd_card, num, direction, + ret =snd_compress_new (rtd->card->snd_card, id, direction, new_name, compr);if (ret <0 ) { component =snd_soc_rtd_to_codec (rtd,0 )->component;
sound/soc/soc-core.c +8 -7
@@ -558,7 +558,8 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(*/ rtd->card = card; rtd->dai_link = dai_link; - rtd->num = card->num_rtd++; + rtd->id = card->num_rtd++; + rtd->num = rtd->id;/* REMOVE ME */ rtd->pmdown_time = pmdown_time;/* default power off timeout */ /* see for_each_card_rtds */
@@ -1458,7 +1459,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,struct snd_soc_dai_link *dai_link = rtd->dai_link;struct snd_soc_dai *cpu_dai =snd_soc_rtd_to_cpu (rtd,0 );struct snd_soc_component *component; -int ret, num, i; +int ret, id, i;/* do machine specific initialization */ ret =snd_soc_link_init (rtd);
@@ -1473,7 +1474,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,/* add DPCM sysfs entries */ soc_dpcm_debugfs_add (rtd); - num = rtd->num; + id = rtd->id;/* * most drivers will register their PCMs using DAI link ordering but
@@ -1485,18 +1486,18 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,continue ;if (rtd->dai_link->no_pcm) - num += component->driver->be_pcm_base; + id += component->driver->be_pcm_base;else - num = rtd->dai_link->id; + id = rtd->dai_link->id; }/* create compress_device if possible */ - ret =snd_soc_dai_compress_new (cpu_dai, rtd, num); + ret =snd_soc_dai_compress_new (cpu_dai, rtd, id);if (ret != -ENOTSUPP ) goto err;/* create the pcm */ - ret =soc_new_pcm (rtd, num); + ret =soc_new_pcm (rtd, id);if (ret <0 ) {dev_err (card->dev,"ASoC: can't create pcm %s :%d\n" , dai_link->stream_name, ret);
sound/soc/soc-dai.c +2 -2
@@ -457,12 +457,12 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai, }int snd_soc_dai_compress_new (struct snd_soc_dai *dai, -struct snd_soc_pcm_runtime *rtd,int num) +struct snd_soc_pcm_runtime *rtd,int id) {int ret = -ENOTSUPP ;if (dai->driver->ops && dai->driver->ops->compress_new) - ret = dai->driver->ops->compress_new (rtd, num); + ret = dai->driver->ops->compress_new (rtd, id);return soc_dai_ret (dai, ret); }
sound/soc/soc-pcm.c +8 -8
@@ -2891,7 +2891,7 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,static int soc_create_pcm (struct snd_pcm **pcm,struct snd_soc_pcm_runtime *rtd, -int playback,int capture,int num) +int playback,int capture,int id) {char new_name[64 ];int ret;
@@ -2901,13 +2901,13 @@ static int soc_create_pcm(struct snd_pcm **pcm,snprintf (new_name,sizeof (new_name),"codec2codec(%s)" , rtd->dai_link->stream_name); - ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, num, + ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, id, playback, capture, pcm); }else if (rtd->dai_link->no_pcm) {snprintf (new_name,sizeof (new_name),"(%s)" , rtd->dai_link->stream_name); - ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, num, + ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, id, playback, capture, pcm); }else {if (rtd->dai_link->dynamic)
@@ -2916,9 +2916,9 @@ static int soc_create_pcm(struct snd_pcm **pcm,else snprintf (new_name,sizeof (new_name),"%s %s-%d" , rtd->dai_link->stream_name, -soc_codec_dai_name (rtd), num); +soc_codec_dai_name (rtd), id); - ret =snd_pcm_new (rtd->card->snd_card, new_name, num, playback, + ret =snd_pcm_new (rtd->card->snd_card, new_name, id, playback, capture, pcm); }if (ret <0 ) {
@@ -2926,13 +2926,13 @@ static int soc_create_pcm(struct snd_pcm **pcm, new_name, rtd->dai_link->name, ret);return ret; } -dev_dbg (rtd->card->dev,"ASoC: registered pcm #%d %s\n" ,num, new_name); +dev_dbg (rtd->card->dev,"ASoC: registered pcm #%d %s\n" , id, new_name);return 0 ; }/* create a new pcm */ -int soc_new_pcm (struct snd_soc_pcm_runtime *rtd,int num) +int soc_new_pcm (struct snd_soc_pcm_runtime *rtd,int id) {struct snd_soc_component *component;struct snd_pcm *pcm;
@@ -2943,7 +2943,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)if (ret <0 )return ret; - ret =soc_create_pcm (&pcm, rtd, playback, capture, num); + ret =soc_create_pcm (&pcm, rtd, playback, capture, id);if (ret <0 )return ret;
Signature · 1 line
2.43.0
Kuninori Morimoto
maintainerPATCH 2/8 ASoC: fsl: switch to use rtd->id from rtd->num
In reply to Kuninori MorimotoNow rtd->num is renamed to rtd->id. Let's switch.
--- sound/soc/fsl/imx-card.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/fsl/imx-card.c +3 -3
@@ -275,7 +275,7 @@ static unsigned long akcodec_get_mclk_rate(struct snd_pcm_substream *substream,struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);struct imx_card_data *data =snd_soc_card_get_drvdata (rtd->card);const struct imx_card_plat_data *plat_data = data->plat_data; -struct dai_link_data *link_data = &data->link_data[rtd->num]; +struct dai_link_data *link_data = &data->link_data[rtd->id];unsigned int width = slots * slot_width;unsigned int rate =params_rate (params);int i;
@@ -313,7 +313,7 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream,struct snd_soc_dai *cpu_dai =snd_soc_rtd_to_cpu (rtd,0 );struct snd_soc_card *card = rtd->card;struct imx_card_data *data =snd_soc_card_get_drvdata (card); -struct dai_link_data *link_data = &data->link_data[rtd->num]; +struct dai_link_data *link_data = &data->link_data[rtd->id];struct imx_card_plat_data *plat_data = data->plat_data;struct device *dev = card->dev;struct snd_soc_dai *codec_dai;
@@ -435,7 +435,7 @@ static int imx_aif_startup(struct snd_pcm_substream *substream)struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);struct snd_soc_card *card = rtd->card;struct imx_card_data *data =snd_soc_card_get_drvdata (card); -struct dai_link_data *link_data = &data->link_data[rtd->num]; +struct dai_link_data *link_data = &data->link_data[rtd->id];static struct snd_pcm_hw_constraint_list constraint_rates;static struct snd_pcm_hw_constraint_list constraint_channels;int ret =0 ;
Signature · 1 line
2.43.0
Kuninori Morimoto
maintainerPATCH 3/8 ASoC: meson: switch to use rtd->id from rtd->num
In reply to Kuninori MorimotoNow rtd->num is renamed to rtd->id. Let's switch.
--- sound/soc/meson/axg-card.c | 6 +++--- sound/soc/meson/gx-card.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/meson/axg-card.c +3 -3
@@ -43,7 +43,7 @@ static int axg_card_tdm_be_hw_params(struct snd_pcm_substream *substream,struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);struct meson_card *priv =snd_soc_card_get_drvdata (rtd->card);struct axg_dai_link_tdm_data *be = - (struct axg_dai_link_tdm_data *)priv->link_data[rtd->num]; + (struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];return meson_card_i2s_set_sysclk (substream, params, be->mclk_fs); }
@@ -56,7 +56,7 @@ static int axg_card_tdm_dai_init(struct snd_soc_pcm_runtime *rtd) {struct meson_card *priv =snd_soc_card_get_drvdata (rtd->card);struct axg_dai_link_tdm_data *be = - (struct axg_dai_link_tdm_data *)priv->link_data[rtd->num]; + (struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];struct snd_soc_dai *codec_dai;int ret, i;
@@ -86,7 +86,7 @@ static int axg_card_tdm_dai_lb_init(struct snd_soc_pcm_runtime *rtd) {struct meson_card *priv =snd_soc_card_get_drvdata (rtd->card);struct axg_dai_link_tdm_data *be = - (struct axg_dai_link_tdm_data *)priv->link_data[rtd->num]; + (struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];int ret;/* The loopback rx_mask is the pad tx_mask */
sound/soc/meson/gx-card.c +1 -1
@@ -32,7 +32,7 @@ static int gx_card_i2s_be_hw_params(struct snd_pcm_substream *substream,struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);struct meson_card *priv =snd_soc_card_get_drvdata (rtd->card);struct gx_dai_link_i2s_data *be = - (struct gx_dai_link_i2s_data *)priv->link_data[rtd->num]; + (struct gx_dai_link_i2s_data *)priv->link_data[rtd->id];return meson_card_i2s_set_sysclk (substream, params, be->mclk_fs); }
Signature · 1 line
2.43.0
Re: [PATCH 3/8] ASoC: meson: switch to use rtd->id from rtd->num
Quoted 3 lines · Kuninori Morimoto
Now
rtd->numis renamed tortd->id. Let's switch.Signed-off-by Kuninori Morimoto <[email protected]>
Just one comment: I understand why you have split this into multiple patches, I suppose it will help with the review but I wonder if it wouldn't be better to squash it all into a single change before applying ? To avoid exposing the intermediate state. It might be confusing too. The change would not be that big actually.
Just a suggestion ;)
Quoted 49 lines
--- sound/soc/meson/axg-card.c | 6 +++--- sound/soc/meson/gx-card.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)sound/soc/meson/axg-card.c +3
-3@@ -43,7 +43,7 @@ static int axg_card_tdm_be_hw_params(struct snd_pcm_substream *substream,struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);struct meson_card *priv =snd_soc_card_get_drvdata (rtd->card);struct axg_dai_link_tdm_data *be = - (struct axg_dai_link_tdm_data *)priv->link_data[rtd->num]; + (struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];return meson_card_i2s_set_sysclk (substream, params, be->mclk_fs); }@@ -56,7 +56,7 @@ static int axg_card_tdm_dai_init(struct snd_soc_pcm_runtime *rtd) {struct meson_card *priv =snd_soc_card_get_drvdata (rtd->card);struct axg_dai_link_tdm_data *be = - (struct axg_dai_link_tdm_data *)priv->link_data[rtd->num]; + (struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];struct snd_soc_dai *codec_dai;int ret, i;@@ -86,7 +86,7 @@ static int axg_card_tdm_dai_lb_init(struct snd_soc_pcm_runtime *rtd) {struct meson_card *priv =snd_soc_card_get_drvdata (rtd->card);struct axg_dai_link_tdm_data *be = - (struct axg_dai_link_tdm_data *)priv->link_data[rtd->num]; + (struct axg_dai_link_tdm_data *)priv->link_data[rtd->id];int ret;/* The loopback rx_mask is the pad tx_mask */ sound/soc/meson/gx-card.c +1
-1@@ -32,7 +32,7 @@ static int gx_card_i2s_be_hw_params(struct snd_pcm_substream *substream,struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);struct meson_card *priv =snd_soc_card_get_drvdata (rtd->card);struct gx_dai_link_i2s_data *be = - (struct gx_dai_link_i2s_data *)priv->link_data[rtd->num]; + (struct gx_dai_link_i2s_data *)priv->link_data[rtd->id];return meson_card_i2s_set_sysclk (substream, params, be->mclk_fs); }
Signature · 1 line
Jerome
Kuninori Morimoto
maintainerRe: [PATCH 3/8] ASoC: meson: switch to use rtd->id from rtd->num
Hi Jerome
Sorry for my late responce
Quoted 5 lines
Just one comment: I understand why you have split this into multiple patches, I suppose it will help with the review but I wonder if it wouldn't be better to squash it all into a single change before applying ? To avoid exposing the intermediate state. It might be confusing too. The change would not be that big actually.
Thank you for suggesting, but I don't want to squash them, because it makes backport difficult for LTS and/or BSP people. I'm always trying to create patch as much as small piece which can easy to backport.
Thank you for your help !!
Best regards
---
Kuninori Morimoto
Kuninori Morimoto
maintainerPATCH 4/8 ASoC: sh: switch to use rtd->id from rtd->num
In reply to Kuninori MorimotoNow rtd->num is renamed to rtd->id. Let's switch.
--- sound/soc/sh/rcar/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sh/rcar/core.c +1 -1
@@ -1843,7 +1843,7 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = name, .info = rsnd_kctrl_info, - .index = rtd->num, + .index = rtd->id, .get = rsnd_kctrl_get, .put = rsnd_kctrl_put, };
Signature · 1 line
2.43.0
Kuninori Morimoto
maintainerPATCH 5/8 ASoC: generic: switch to use rtd->id from rtd->num
In reply to Kuninori MorimotoNow rtd->num is renamed to rtd->id. Let's switch.
--- sound/soc/generic/simple-card-utils.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
sound/soc/generic/simple-card-utils.c +5 -5
@@ -296,7 +296,7 @@ int simple_util_startup(struct snd_pcm_substream *substream) {struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);struct simple_util_priv *priv =snd_soc_card_get_drvdata (rtd->card); -struct simple_dai_props *props =simple_priv_to_props (priv, rtd->num); +struct simple_dai_props *props =simple_priv_to_props (priv, rtd->id);struct simple_util_dai *dai;unsigned int fixed_sysclk =0 ;int i1, i2, i;
@@ -357,7 +357,7 @@ void simple_util_shutdown(struct snd_pcm_substream *substream) {struct snd_soc_pcm_runtime *rtd =snd_soc_substream_to_rtd (substream);struct simple_util_priv *priv =snd_soc_card_get_drvdata (rtd->card); -struct simple_dai_props *props =simple_priv_to_props (priv, rtd->num); +struct simple_dai_props *props =simple_priv_to_props (priv, rtd->id);struct simple_util_dai *dai;int i;
@@ -448,7 +448,7 @@ int simple_util_hw_params(struct snd_pcm_substream *substream,struct simple_util_dai *pdai;struct snd_soc_dai *sdai;struct simple_util_priv *priv =snd_soc_card_get_drvdata (rtd->card); -struct simple_dai_props *props =simple_priv_to_props (priv, rtd->num); +struct simple_dai_props *props =simple_priv_to_props (priv, rtd->id);unsigned int mclk, mclk_fs =0 ;int i, ret;
@@ -517,7 +517,7 @@ int simple_util_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) {struct simple_util_priv *priv =snd_soc_card_get_drvdata (rtd->card); -struct simple_dai_props *dai_props =simple_priv_to_props (priv, rtd->num); +struct simple_dai_props *dai_props =simple_priv_to_props (priv, rtd->id);struct simple_util_data *data = &dai_props->adata;struct snd_interval *rate =hw_param_interval (params,SNDRV_PCM_HW_PARAM_RATE );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,int simple_util_dai_init (struct snd_soc_pcm_runtime *rtd) {struct simple_util_priv *priv =snd_soc_card_get_drvdata (rtd->card); -struct simple_dai_props *props =simple_priv_to_props (priv, rtd->num); +struct simple_dai_props *props =simple_priv_to_props (priv, rtd->id);struct simple_util_dai *dai;int i, ret;
Signature · 1 line
2.43.0
Kuninori Morimoto
maintainerPATCH 6/8 ASoC: remove rtd->num
In reply to Kuninori MorimotoNo one is using rtd->num. Let's remove it.
--- include/sound/soc.h | 1 - sound/soc/soc-core.c | 1 - 2 files changed, 2 deletions(-)
include/sound/soc.h +0 -1
@@ -1195,7 +1195,6 @@ struct snd_soc_pcm_runtime {struct dentry *debugfs_dpcm_root;#endif -unsigned int num;/* REMOVE ME */ unsigned int id;/* 0-based and monotonic increasing */ struct list_head list;/* rtd list of the soc card */
sound/soc/soc-core.c +0 -1
@@ -559,7 +559,6 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( rtd->card = card; rtd->dai_link = dai_link; rtd->id = card->num_rtd++; - rtd->num = rtd->id;/* REMOVE ME */ rtd->pmdown_time = pmdown_time;/* default power off timeout */ /* see for_each_card_rtds */
Signature · 1 line
2.43.0
Kuninori Morimoto
maintainerPATCH 7/8 ASoC: soc-core: do rtd->id trick at snd_soc_add_pcm_runtime()
In reply to Kuninori Morimotoqcom/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.
--- sound/soc/soc-core.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-)
sound/soc/soc-core.c +24 -18
@@ -1166,7 +1166,7 @@ static int snd_soc_add_pcm_runtime(struct snd_soc_card *card,struct snd_soc_pcm_runtime *rtd;struct snd_soc_dai_link_component *codec, *platform, *cpu;struct snd_soc_component *component; -int i, ret; +int i, id, ret;lockdep_assert_held (&client_mutex);
@@ -1225,6 +1225,28 @@ static int snd_soc_add_pcm_runtime(struct snd_soc_card *card, } } +/* +* Most drivers will register their PCMs using DAI link ordering but +* topology based drivers can use the DAI link id field to set PCM +* device number and then use rtd + a base offset of the BEs. +* +* FIXME +* +* This should be implemented by using "dai_link" feature instead of +* "component" feature. +*/ + id = rtd->id; +for_each_rtd_components (rtd, i, component) { +if (!component->driver->use_dai_pcm_id) +continue ; + +if (rtd->dai_link->no_pcm) + id += component->driver->be_pcm_base; +else + id = rtd->dai_link->id; + } + rtd->id = id; +return 0 ; _err_defer:
@@ -1457,8 +1479,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card, {struct snd_soc_dai_link *dai_link = rtd->dai_link;struct snd_soc_dai *cpu_dai =snd_soc_rtd_to_cpu (rtd,0 ); -struct snd_soc_component *component; -int ret, id, i; +int ret, id;/* do machine specific initialization */ ret =snd_soc_link_init (rtd);
@@ -1475,21 +1496,6 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card, id = rtd->id; -/* -* most drivers will register their PCMs using DAI link ordering but -* topology based drivers can use the DAI link id field to set PCM -* device number and then use rtd + a base offset of the BEs. -*/ -for_each_rtd_components (rtd, i, component) { -if (!component->driver->use_dai_pcm_id) -continue ; - -if (rtd->dai_link->no_pcm) - id += component->driver->be_pcm_base; -else - id = rtd->dai_link->id; - } -/* create compress_device if possible */ ret =snd_soc_dai_compress_new (cpu_dai, rtd, id);if (ret != -ENOTSUPP )
Signature · 1 line
2.43.0
Kuninori Morimoto
maintainerPATCH 8/8 ASoC: cleanup function parameter for rtd and its id
In reply to Kuninori Morimotosome functions had parameter like below
xxx(..., rtd, ..., id);
This "id" is rtd->id. We don't need to have "id" on each functions because we can get it from "rtd". Let's cleanup it.
--- include/sound/soc-dai.h | 5 ++--- include/sound/soc.h | 6 +++--- sound/soc/soc-compress.c | 9 ++++----- sound/soc/soc-core.c | 8 +++----- sound/soc/soc-dai.c | 4 ++-- sound/soc/soc-pcm.c | 16 ++++++++-------- 6 files changed, 22 insertions(+), 26 deletions(-)
include/sound/soc-dai.h +2 -3
@@ -216,8 +216,7 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai, struct snd_pcm_substream *substream, int rollback);void snd_soc_dai_suspend (struct snd_soc_dai *dai);void snd_soc_dai_resume (struct snd_soc_dai *dai); -int snd_soc_dai_compress_new (struct snd_soc_dai *dai, -struct snd_soc_pcm_runtime *rtd,int id); +int snd_soc_dai_compress_new (struct snd_soc_dai *dai,struct snd_soc_pcm_runtime *rtd);bool snd_soc_dai_stream_valid (const struct snd_soc_dai *dai,int stream);void snd_soc_dai_action (struct snd_soc_dai *dai,int stream,int action);
@@ -275,7 +274,7 @@ struct snd_soc_dai_ops {int (*probe)(struct snd_soc_dai *dai);int (*remove)(struct snd_soc_dai *dai);/* compress dai */ -int (*compress_new)(struct snd_soc_pcm_runtime *rtd,int id); +int (*compress_new)(struct snd_soc_pcm_runtime *rtd);/* Optional Callback used at pcm creation*/ int (*pcm_new)(struct snd_soc_pcm_runtime *rtd,struct snd_soc_dai *dai);
include/sound/soc.h +3 -3
@@ -486,11 +486,11 @@ struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,struct snd_soc_component *snd_soc_lookup_component (struct device *dev,const char *driver_name); -int soc_new_pcm (struct snd_soc_pcm_runtime *rtd,int id); +int soc_new_pcm (struct snd_soc_pcm_runtime *rtd);#ifdef CONFIG_SND_SOC_COMPRESS -int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd,int id); +int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd);#else -static inline int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd,int id) +static inline int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd) {return 0 ; }
sound/soc/soc-compress.c +4 -5
@@ -537,11 +537,10 @@ static struct snd_compr_ops soc_compr_dyn_ops = {* snd_soc_new_compress - create a new compress. * * @rtd: The runtime for which we will create compress -* @id: the device index number (zero based - shared with normal PCMs) * * Return: 0 for success, else error. */ -int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd,int id) +int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd) {struct snd_soc_component *component;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 id)snprintf (new_name,sizeof (new_name),"(%s)" , rtd->dai_link->stream_name); - ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, id, + ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, rtd->id, playback, capture, &be_pcm);if (ret <0 ) { dev_err(rtd->card->dev,
@@ -638,7 +637,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int id)memcpy (compr->ops, &soc_compr_dyn_ops,sizeof (soc_compr_dyn_ops)); }else {snprintf (new_name,sizeof (new_name),"%s %s-%d" , - rtd->dai_link->stream_name, codec_dai->name, id); + rtd->dai_link->stream_name, codec_dai->name, rtd->id);memcpy (compr->ops, &soc_compr_ops,sizeof (soc_compr_ops)); }
@@ -652,7 +651,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int id)break ; } - ret =snd_compress_new (rtd->card->snd_card, id, direction, + ret =snd_compress_new (rtd->card->snd_card, rtd->id, direction, new_name, compr);if (ret <0 ) { component =snd_soc_rtd_to_codec (rtd,0 )->component;
sound/soc/soc-core.c +3 -5
@@ -1479,7 +1479,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card, {struct snd_soc_dai_link *dai_link = rtd->dai_link;struct snd_soc_dai *cpu_dai =snd_soc_rtd_to_cpu (rtd,0 ); -int ret, id; +int ret;/* do machine specific initialization */ ret =snd_soc_link_init (rtd);
@@ -1494,15 +1494,13 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,/* add DPCM sysfs entries */ soc_dpcm_debugfs_add (rtd); - id = rtd->id; -/* create compress_device if possible */ - ret =snd_soc_dai_compress_new (cpu_dai, rtd, id); + ret =snd_soc_dai_compress_new (cpu_dai, rtd);if (ret != -ENOTSUPP ) goto err;/* create the pcm */ - ret =soc_new_pcm (rtd, id); + ret =soc_new_pcm (rtd);if (ret <0 ) {dev_err (card->dev,"ASoC: can't create pcm %s :%d\n" , dai_link->stream_name, ret);
sound/soc/soc-dai.c +2 -2
@@ -457,12 +457,12 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai, }int snd_soc_dai_compress_new (struct snd_soc_dai *dai, -struct snd_soc_pcm_runtime *rtd,int id) +struct snd_soc_pcm_runtime *rtd) {int ret = -ENOTSUPP ;if (dai->driver->ops && dai->driver->ops->compress_new) - ret = dai->driver->ops->compress_new (rtd, id); + ret = dai->driver->ops->compress_new (rtd);return soc_dai_ret (dai, ret); }
sound/soc/soc-pcm.c +8 -8
@@ -2891,7 +2891,7 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd,static int soc_create_pcm (struct snd_pcm **pcm,struct snd_soc_pcm_runtime *rtd, -int playback,int capture,int id) +int playback,int capture) {char new_name[64 ];int ret;
@@ -2901,13 +2901,13 @@ static int soc_create_pcm(struct snd_pcm **pcm,snprintf (new_name,sizeof (new_name),"codec2codec(%s)" , rtd->dai_link->stream_name); - ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, id, + ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, rtd->id, playback, capture, pcm); }else if (rtd->dai_link->no_pcm) {snprintf (new_name,sizeof (new_name),"(%s)" , rtd->dai_link->stream_name); - ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, id, + ret =snd_pcm_new_internal (rtd->card->snd_card, new_name, rtd->id, playback, capture, pcm); }else {if (rtd->dai_link->dynamic)
@@ -2916,9 +2916,9 @@ static int soc_create_pcm(struct snd_pcm **pcm,else snprintf (new_name,sizeof (new_name),"%s %s-%d" , rtd->dai_link->stream_name, -soc_codec_dai_name (rtd), id); +soc_codec_dai_name (rtd), rtd->id); - ret =snd_pcm_new (rtd->card->snd_card, new_name, id, playback, + ret =snd_pcm_new (rtd->card->snd_card, new_name, rtd->id, playback, capture, pcm); }if (ret <0 ) {
@@ -2926,13 +2926,13 @@ static int soc_create_pcm(struct snd_pcm **pcm, new_name, rtd->dai_link->name, ret);return ret; } -dev_dbg (rtd->card->dev,"ASoC: registered pcm #%d %s\n" , id, new_name); +dev_dbg (rtd->card->dev,"ASoC: registered pcm #%d %s\n" , rtd->id, new_name);return 0 ; }/* create a new pcm */ -int soc_new_pcm (struct snd_soc_pcm_runtime *rtd,int id) +int soc_new_pcm (struct snd_soc_pcm_runtime *rtd) {struct snd_soc_component *component;struct snd_pcm *pcm;
@@ -2943,7 +2943,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int id)if (ret <0 )return ret; - ret =soc_create_pcm (&pcm, rtd, playback, capture, id); + ret =soc_create_pcm (&pcm, rtd, playback, capture);if (ret <0 )return ret;
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 11 lines · Kuninori Morimoto
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 hasrtd->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 (?)[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/8] ASoC: rename rtd->num to rtd->id
commit: 40e47e2db6864aa053a62477bd71a16be9dd4066
[2/8] ASoC: fsl: switch to use rtd->id from rtd->num
commit: eae33f737c7a929d92b559fe1a1002d597b7b903
[3/8] ASoC: meson: switch to use rtd->id from rtd->num
commit: b19f75df8fa9f8d4aa8b5886dca0f2d832a76baa
[4/8] ASoC: sh: switch to use rtd->id from rtd->num
commit: 970a874b76d09d6a5880e8832e572850cfcb4008
[5/8] ASoC: generic: switch to use rtd->id from rtd->num
commit: 742e622db67efc32affb5893fdcc0149f374533e
[6/8] ASoC: remove rtd->num
commit: c59db5ed233a19f6aadd086fb89149ec5f6fa855
[7/8] ASoC: soc-core: do rtd->id trick at snd_soc_add_pcm_runtime()
commit: cb18cd26039f5cdecb0ac53fb447b6f0859f3d1c
[8/8] ASoC: cleanup function parameter for rtd and its id
commit: 8b12da9a18f4dd53e4b3a7393829a555e84f073cAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark