ASoC: soc-pcm cleanup step3
Subsystems (7)
v3 cover ASoC: soc-pcm cleanup step3
Hi Mark
These are v3 of soc-pcm cleanup step3. Main change from v2 is that last patch was splited into each files (= [10/18] to [18/18]). And all patches have Reviewed-by tag from Ranjani
Kuninori Morimoto (18):
1) ASoC: soc-pcm: move dai_get_widget()
2) ASoC: soc-pcm: use dai_get_widget() at dpcm_get_be()
3) ASoC: soc-pcm: use dai_get_widget() at dpcm_end_walk_at_be()
4) ASoC: soc-pcm: use dpcm_get_be() at dpcm_end_walk_at_be()
5) ASoC: soc-pcm: remove soc_dpcm_be_digital_mute()
6) ASoC: soc-pcm: remove snd_soc_dpcm_be_get/set_state()
7) ASoC: soc-pcm: add snd_soc_dpcm_can_be() and remove duplicate code
8) ASoC: soc-pcm: use goto and remove multi return
9) ASoC: soc-pcm: merge playback/cature_active into stream_active
10) ASoC: soc.h: add for_each_pcm_streams()
11) ASoC: soc-core: use for_each_pcm_streams() macro
12) ASoC: soc-pcm: use for_each_pcm_streams() macro
13) ASoC: soc-generic-dmaengine-pcm: use for_each_pcm_streams() macro
14) ASoC: dwc: dwc-i2s: use for_each_pcm_streams() macro
15) ASoC: fsl: fsl_asrc_dma: use for_each_pcm_streams() macro
16) ASoC: qcom: lpass-platform: use for_each_pcm_streams() macro
17) ASoC: sof: sof-audio: use for_each_pcm_streams() macro
18) ALSA: usx2y: use for_each_pcm_streams() macro
include/sound/pcm.h | 5 + include/sound/soc-dai.h | 3 +- include/sound/soc-dpcm.h | 9 - sound/soc/codecs/cs4271.c | 4 +- sound/soc/dwc/dwc-i2s.c | 8 +- sound/soc/fsl/fsl_asrc_dma.c | 4 +- sound/soc/qcom/lpass-platform.c | 2 +- sound/soc/soc-core.c | 48 ++-- sound/soc/soc-generic-dmaengine-pcm.c | 8 +- sound/soc/soc-pcm.c | 327 +++++++++----------------- sound/soc/sof/sof-audio.c | 19 +- sound/usb/usx2y/usbusx2yaudio.c | 9 +- 12 files changed, 162 insertions(+), 284 deletions(-)
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 1/18 ASoC: soc-pcm: move dai_get_widget()
From: Kuninori Morimoto <[email protected]>
This patch moves dai_get_widget() to top side.
This is prepare for cleanup soc-pcm.c
--- sound/soc/soc-pcm.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
sound/soc/soc-pcm.c +9 -9
@@ -82,6 +82,15 @@ static int soc_rtd_trigger(struct snd_soc_pcm_runtime *rtd,return 0 ; } +static inline +struct snd_soc_dapm_widget *dai_get_widget (struct snd_soc_dai *dai,int stream) +{ +if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) +return dai->playback_widget; +else +return dai->capture_widget; +} +static void snd_soc_runtime_action (struct snd_soc_pcm_runtime *rtd,int stream,int action) {
@@ -1287,15 +1296,6 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,return NULL ; } -static inline struct snd_soc_dapm_widget * -dai_get_widget (struct snd_soc_dai *dai,int stream) -{ -if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) -return dai->playback_widget; -else -return dai->capture_widget; -} -static int widget_in_list (struct snd_soc_dapm_widget_list *list,struct snd_soc_dapm_widget *widget) {
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 2/18 ASoC: soc-pcm: use dai_get_widget() at dpcm_get_be()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
dpcm_get_be() has very duplicate code.
dpcm_get_be() {
...
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
(1) /* code for Playback */
} else {
(2) /* code for Capture */
}
}The difference between Playback (1) and Capture (2) code is pointer only (= "playback_widget" or "caputre_widget").
OTOH, now we already has dai_get_widget() for it.
This means we can merge (1) and (2).
This patch do it and remove duplicated code.
--- sound/soc/soc-pcm.c | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-)
sound/soc/soc-pcm.c +12 -29
@@ -1246,47 +1246,30 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, struct snd_soc_dapm_widget *widget, int stream) {struct snd_soc_pcm_runtime *be; +struct snd_soc_dapm_widget *w;struct snd_soc_dai *dai;int i;dev_dbg (card->dev,"ASoC: find BE for widget %s\n" , widget->name); -if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { -for_each_card_rtds (card, be) { +for_each_card_rtds (card, be) { -if (!be->dai_link->no_pcm) -continue ; +if (!be->dai_link->no_pcm) +continue ; -dev_dbg (card->dev,"ASoC: try BE : %s\n" , - be->cpu_dai->playback_widget ? - be->cpu_dai->playback_widget->name :"(not set)" ); + w =dai_get_widget (be->cpu_dai, stream); -if (be->cpu_dai->playback_widget == widget) -return be; +dev_dbg (card->dev,"ASoC: try BE : %s\n" , + w ? w->name :"(not set)" ); -for_each_rtd_codec_dai (be, i, dai) { -if (dai->playback_widget == widget) -return be; - } - } - }else { - -for_each_card_rtds (card, be) { - -if (!be->dai_link->no_pcm) -continue ; +if (w == widget) +return be; -dev_dbg (card->dev,"ASoC: try BE %s\n" , - be->cpu_dai->capture_widget ? - be->cpu_dai->capture_widget->name :"(not set)" ); +for_each_rtd_codec_dai (be, i, dai) { + w =dai_get_widget (dai, stream); -if (be->cpu_dai->capture_widget == widget) +if (w == widget)return be; - -for_each_rtd_codec_dai (be, i, dai) { -if (dai->capture_widget == widget) -return be; - } } }
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 3/18 ASoC: soc-pcm: use dai_get_widget() at dpcm_end_walk_at_be()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
dpcm_end_walk_at_be() has very duplicate code.
dpcm_end_walk_at_be() {
...
if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
(1) /* code for Playback */
} else {
(2) /* code for Capture */
}
}The difference between Playback (1) and Capture (2) code is pointer only (= "playback_widget" or "caputre_widget").
OTOH, now we already has dai_get_widget() for it.
This means we can merge (1) and (2).
This patch do it and remove duplicated code.
--- sound/soc/soc-pcm.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
sound/soc/soc-pcm.c +16 -21
@@ -1297,34 +1297,29 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget, {struct snd_soc_card *card = widget->dapm->card;struct snd_soc_pcm_runtime *rtd; +struct snd_soc_dapm_widget *w;struct snd_soc_dai *dai; +int stream;int i; -if (dir ==SND_SOC_DAPM_DIR_OUT ) { -for_each_card_rtds (card, rtd) { -if (!rtd->dai_link->no_pcm) -continue ; +/* adjust dir to stream */ +if (dir ==SND_SOC_DAPM_DIR_OUT ) + stream =SNDRV_PCM_STREAM_PLAYBACK ; +else + stream =SNDRV_PCM_STREAM_CAPTURE ; -if (rtd->cpu_dai->playback_widget == widget) -return true; +for_each_card_rtds (card, rtd) { +if (!rtd->dai_link->no_pcm) +continue ; -for_each_rtd_codec_dai (rtd, i, dai) { -if (dai->playback_widget == widget) -return true; - } - } - }else {/* SND_SOC_DAPM_DIR_IN */ -for_each_card_rtds (card, rtd) { -if (!rtd->dai_link->no_pcm) -continue ; + w =dai_get_widget (rtd->cpu_dai, stream); +if (w == widget) +return true; -if (rtd->cpu_dai->capture_widget == widget) +for_each_rtd_codec_dai (rtd, i, dai) { + w =dai_get_widget (dai, stream); +if (w == widget)return true; - -for_each_rtd_codec_dai (rtd, i, dai) { -if (dai->capture_widget == widget) -return true; - } } }
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 4/18 ASoC: soc-pcm: use dpcm_get_be() at dpcm_end_walk_at_be()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
dpcm_end_walk_at_be() and dpcm_get_be() are almost same code. This patch uses dpcm_get_be() from dpcm_end_walk_at_be().
--- sound/soc/soc-pcm.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
sound/soc/soc-pcm.c +3 -17
@@ -1297,10 +1297,7 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget, {struct snd_soc_card *card = widget->dapm->card;struct snd_soc_pcm_runtime *rtd; -struct snd_soc_dapm_widget *w; -struct snd_soc_dai *dai;int stream; -int i;/* adjust dir to stream */ if (dir ==SND_SOC_DAPM_DIR_OUT )
@@ -1308,20 +1305,9 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget,else stream =SNDRV_PCM_STREAM_CAPTURE ; -for_each_card_rtds (card, rtd) { -if (!rtd->dai_link->no_pcm) -continue ; - - w =dai_get_widget (rtd->cpu_dai, stream); -if (w == widget) -return true; - -for_each_rtd_codec_dai (rtd, i, dai) { - w =dai_get_widget (dai, stream); -if (w == widget) -return true; - } - } + rtd =dpcm_get_be (card, widget, stream); +if (rtd) +return true;return false; }
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 5/18 ASoC: soc-pcm: remove soc_dpcm_be_digital_mute()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
No one is using soc_dpcm_be_digital_mute().
If it exists only by assumption that "it may be necessary someday", let's remove it now. Otherwise code maintenance will be difficult. We can revive it when we really needed it.
Let's remove it, so far.
--- include/sound/soc-dpcm.h | 1 - sound/soc/soc-pcm.c | 27 --------------------------- 2 files changed, 28 deletions(-)
include/sound/soc-dpcm.h +0 -1
@@ -141,7 +141,6 @@ void snd_soc_dpcm_be_set_state(struct snd_soc_pcm_runtime *be, int stream, enum snd_soc_dpcm_state state);/* internal use only */ -int soc_dpcm_be_digital_mute (struct snd_soc_pcm_runtime *fe,int mute);int soc_dpcm_runtime_update (struct snd_soc_card *);#ifdef CONFIG_DEBUG_FS
sound/soc/soc-pcm.c +0 -27
@@ -2719,33 +2719,6 @@ int soc_dpcm_runtime_update(struct snd_soc_card *card)mutex_unlock (&card->mutex);return ret; } -int soc_dpcm_be_digital_mute (struct snd_soc_pcm_runtime *fe,int mute) -{ -struct snd_soc_dpcm *dpcm; -struct snd_soc_dai *dai; - -for_each_dpcm_be (fe,SNDRV_PCM_STREAM_PLAYBACK , dpcm) { - -struct snd_soc_pcm_runtime *be = dpcm->be; -int i; - -if (be->dai_link->ignore_suspend) -continue ; - -for_each_rtd_codec_dai (be, i, dai) { -struct snd_soc_dai_driver *drv = dai->driver; - -dev_dbg (be->dev,"ASoC: BE digital mute %s\n" , - be->dai_link->name); - -if (drv->ops && drv->ops->digital_mute && - dai->playback_active) - drv->ops->digital_mute (dai, mute); - } - } - -return 0 ; -}static int dpcm_fe_dai_open (struct snd_pcm_substream *fe_substream) {
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 6/18 ASoC: soc-pcm: remove snd_soc_dpcm_be_get/set_state()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
No one is using snd_soc_dpcm_be_get/set_state().
If it exists only by assumption that "it may be necessary someday", let's remove it now. Otherwise code maintenance will be difficult. We can revive it when we really needed it.
Let's remove it, so far.
--- include/sound/soc-dpcm.h | 8 -------- sound/soc/soc-pcm.c | 16 ---------------- 2 files changed, 24 deletions(-)
include/sound/soc-dpcm.h +0 -8
@@ -132,14 +132,6 @@ int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe,struct snd_pcm_substream *snd_soc_dpcm_get_substream (struct snd_soc_pcm_runtime *be,int stream); -/* get the BE runtime state */ -enum snd_soc_dpcm_state -snd_soc_dpcm_be_get_state (struct snd_soc_pcm_runtime *be,int stream); - -/* set the BE runtime state */ -void snd_soc_dpcm_be_set_state (struct snd_soc_pcm_runtime *be,int stream, -enum snd_soc_dpcm_state state); -/* internal use only */ int soc_dpcm_runtime_update (struct snd_soc_card *);
sound/soc/soc-pcm.c +0 -16
@@ -2957,22 +2957,6 @@ struct snd_pcm_substream * }EXPORT_SYMBOL_GPL (snd_soc_dpcm_get_substream); -/* get the BE runtime state */ -enum snd_soc_dpcm_state -snd_soc_dpcm_be_get_state (struct snd_soc_pcm_runtime *be,int stream) -{ -return be->dpcm[stream].state; -} -EXPORT_SYMBOL_GPL (snd_soc_dpcm_be_get_state); - -/* set the BE runtime state */ -void snd_soc_dpcm_be_set_state (struct snd_soc_pcm_runtime *be, -int stream,enum snd_soc_dpcm_state state) -{ - be->dpcm[stream].state = state; -} -EXPORT_SYMBOL_GPL (snd_soc_dpcm_be_set_state); -/* * We can only hw_free, stop, pause or suspend a BE DAI if any of it's FE * are not running, paused or suspended for the specified stream direction.
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 7/18 ASoC: soc-pcm: add snd_soc_dpcm_can_be() and remove duplicate code
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Below functions are doing very similar things, the difference is used state only.
snd_soc_dpcm_can_be_free_stop() snd_soc_dpcm_can_be_params()
This patch adds common snd_soc_dpcm_check_state(), and use it from snd_soc_dpcm_can_be_free_stop() / snd_soc_dpcm_can_be_params(). It can reduce duplicate code.
--- sound/soc/soc-pcm.c | 70 ++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 35 deletions(-)
sound/soc/soc-pcm.c +35 -35
@@ -2957,17 +2957,17 @@ struct snd_pcm_substream * }EXPORT_SYMBOL_GPL (snd_soc_dpcm_get_substream); -/* -* We can only hw_free, stop, pause or suspend a BE DAI if any of it's FE -* are not running, paused or suspended for the specified stream direction. -*/ -int snd_soc_dpcm_can_be_free_stop (struct snd_soc_pcm_runtime *fe, -struct snd_soc_pcm_runtime *be,int stream) +static int snd_soc_dpcm_check_state (struct snd_soc_pcm_runtime *fe, +struct snd_soc_pcm_runtime *be, +int stream, +const enum snd_soc_dpcm_state *states, +int num_states) {struct snd_soc_dpcm *dpcm;int state;int ret =1 ;unsigned long flags; +int i;spin_lock_irqsave (&fe->card->dpcm_lock, flags);for_each_dpcm_fe (be, stream, dpcm) {
@@ -2976,18 +2976,34 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,continue ; state = dpcm->fe->dpcm[stream].state; -if (state ==SND_SOC_DPCM_STATE_START || - state ==SND_SOC_DPCM_STATE_PAUSED || - state ==SND_SOC_DPCM_STATE_SUSPEND ) { - ret =0 ; -break ; +for (i =0 ; i < num_states; i++) { +if (state == states[i]) { + ret =0 ; +break ; + } } }spin_unlock_irqrestore (&fe->card->dpcm_lock, flags); -/* it's safe to free/stop this BE DAI */ +/* it's safe to do this BE DAI */ return ret; } + +/* +* We can only hw_free, stop, pause or suspend a BE DAI if any of it's FE +* are not running, paused or suspended for the specified stream direction. +*/ +int snd_soc_dpcm_can_be_free_stop (struct snd_soc_pcm_runtime *fe, +struct snd_soc_pcm_runtime *be,int stream) +{ +const enum snd_soc_dpcm_state state[] = { +SND_SOC_DPCM_STATE_START , +SND_SOC_DPCM_STATE_PAUSED , +SND_SOC_DPCM_STATE_SUSPEND , + }; + +return snd_soc_dpcm_check_state (fe, be, stream, state,ARRAY_SIZE (state)); +}EXPORT_SYMBOL_GPL (snd_soc_dpcm_can_be_free_stop);/*
@@ -2997,30 +3013,14 @@ EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_free_stop);int snd_soc_dpcm_can_be_params (struct snd_soc_pcm_runtime *fe,struct snd_soc_pcm_runtime *be,int stream) { -struct snd_soc_dpcm *dpcm; -int state; -int ret =1 ; -unsigned long flags; - -spin_lock_irqsave (&fe->card->dpcm_lock, flags); -for_each_dpcm_fe (be, stream, dpcm) { - -if (dpcm->fe == fe) -continue ; +const enum snd_soc_dpcm_state state[] = { +SND_SOC_DPCM_STATE_START , +SND_SOC_DPCM_STATE_PAUSED , +SND_SOC_DPCM_STATE_SUSPEND , +SND_SOC_DPCM_STATE_PREPARE , + }; - state = dpcm->fe->dpcm[stream].state; -if (state ==SND_SOC_DPCM_STATE_START || - state ==SND_SOC_DPCM_STATE_PAUSED || - state ==SND_SOC_DPCM_STATE_SUSPEND || - state ==SND_SOC_DPCM_STATE_PREPARE ) { - ret =0 ; -break ; - } - } -spin_unlock_irqrestore (&fe->card->dpcm_lock, flags); - -/* it's safe to change hw_params */ -return ret; +return snd_soc_dpcm_check_state (fe, be, stream, state,ARRAY_SIZE (state)); }EXPORT_SYMBOL_GPL (snd_soc_dpcm_can_be_params);
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 8/18 ASoC: soc-pcm: use goto and remove multi return
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
When we use some kind of lock, we need to do unlock. In that time, multi unlock/return is not good implementation. This patch add label and use goto at dpcm_fe_dai_open() to reduce such code.
--- sound/soc/soc-pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/soc-pcm.c +2 -2
@@ -2733,8 +2733,7 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream) ret =dpcm_path_get (fe, stream, &list);if (ret <0 ) { -mutex_unlock (&fe->card->mutex); -return ret; + goto open_end; }else if (ret ==0 ) {dev_dbg (fe->dev,"ASoC: %s no valid %s route\n" , fe->dai_link->name, stream ?"capture" :"playback" );
@@ -2755,6 +2754,7 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)dpcm_clear_pending_state (fe, stream);dpcm_path_put (&list); +open_end:mutex_unlock (&fe->card->mutex);return ret; }
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 9/18 ASoC: soc-pcm: merge playback/cature_active into stream_active
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
DAI has playback_active and capture_active to care usage count. OTOH, we have SNDRV_PCM_STREAM_PLAYBACK/CAPTURE.
But because of this kind of implementation mismatch, ALSA SoC has many verbose code.
To solve this issue, this patch merge playback_active/capture_active into stream_active[2];
--- include/sound/soc-dai.h | 3 +-- sound/soc/codecs/cs4271.c | 4 ++-- sound/soc/dwc/dwc-i2s.c | 4 ++-- sound/soc/soc-core.c | 17 +++++++++-------- sound/soc/soc-pcm.c | 25 ++++++++++++------------- 5 files changed, 26 insertions(+), 27 deletions(-)
include/sound/soc-dai.h +1 -2
@@ -322,8 +322,7 @@ struct snd_soc_dai {struct snd_soc_dai_driver *driver;/* DAI runtime info */ -unsigned int capture_active;/* stream usage count */ -unsigned int playback_active;/* stream usage count */ +unsigned int stream_active[SNDRV_PCM_STREAM_LAST +1 ];/* usage count */ unsigned int active;
sound/soc/codecs/cs4271.c +2 -2
@@ -356,9 +356,9 @@ static int cs4271_hw_params(struct snd_pcm_substream *substream,*/ if ((substream->stream ==SNDRV_PCM_STREAM_PLAYBACK && - !dai->capture_active) || + !dai->stream_active[SNDRV_PCM_STREAM_CAPTURE ]) || (substream->stream ==SNDRV_PCM_STREAM_CAPTURE && - !dai->playback_active)) { + !dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK ])) { ret =regmap_update_bits (cs4271->regmap,CS4271_MODE2 ,CS4271_MODE2_PDN ,CS4271_MODE2_PDN );
sound/soc/dwc/dwc-i2s.c +2 -2
@@ -427,9 +427,9 @@ static int dw_i2s_resume(struct snd_soc_component *component)clk_enable (dev->clk);for_each_component_dais (component, dai) { -if (dai->playback_active) +if (dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK ])dw_i2s_config (dev,SNDRV_PCM_STREAM_PLAYBACK ); -if (dai->capture_active) +if (dai->stream_active[SNDRV_PCM_STREAM_CAPTURE ])dw_i2s_config (dev,SNDRV_PCM_STREAM_CAPTURE ); }
sound/soc/soc-core.c +9 -8
@@ -365,19 +365,20 @@ EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime);void snd_soc_close_delayed_work (struct snd_soc_pcm_runtime *rtd) {struct snd_soc_dai *codec_dai = rtd->codec_dai; +int playback =SNDRV_PCM_STREAM_PLAYBACK ;mutex_lock_nested (&rtd->card->pcm_mutex, rtd->card->pcm_subclass);dev_dbg (rtd->dev,"ASoC: pop wq checking: %s status: %s waiting: %s\n" , codec_dai->driver->playback.stream_name, - codec_dai->playback_active ?"active" :"inactive" , + codec_dai->stream_active[playback] ?"active" :"inactive" , rtd->pop_wait ?"yes" :"no" );/* are we waiting on this codec DAI stream */ if (rtd->pop_wait ==1 ) { rtd->pop_wait =0 ; -snd_soc_dapm_stream_event (rtd,SNDRV_PCM_STREAM_PLAYBACK , +snd_soc_dapm_stream_event (rtd, playback,SND_SOC_DAPM_STREAM_STOP ); }
@@ -514,6 +515,7 @@ int snd_soc_suspend(struct device *dev)struct snd_soc_card *card =dev_get_drvdata (dev);struct snd_soc_component *component;struct snd_soc_pcm_runtime *rtd; +int playback =SNDRV_PCM_STREAM_PLAYBACK ;int i;/* If the card is not initialized yet there is nothing to do */
@@ -537,9 +539,8 @@ int snd_soc_suspend(struct device *dev)continue ;for_each_rtd_codec_dai (rtd, i, dai) { -if (dai->playback_active) -snd_soc_dai_digital_mute (dai,1 , -SNDRV_PCM_STREAM_PLAYBACK ); +if (dai->stream_active[playback]) +snd_soc_dai_digital_mute (dai,1 , playback); } }
@@ -680,14 +681,14 @@ static void soc_resume_deferred(struct work_struct *work)/* unmute any active DACs */ for_each_card_rtds (card, rtd) {struct snd_soc_dai *dai; +int playback =SNDRV_PCM_STREAM_PLAYBACK ;if (rtd->dai_link->ignore_suspend)continue ;for_each_rtd_codec_dai (rtd, i, dai) { -if (dai->playback_active) -snd_soc_dai_digital_mute (dai,0 , -SNDRV_PCM_STREAM_PLAYBACK ); +if (dai->stream_active[playback]) +snd_soc_dai_digital_mute (dai,0 , playback); } }
sound/soc/soc-pcm.c +12 -13
@@ -100,15 +100,9 @@ static void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,lockdep_assert_held (&rtd->card->pcm_mutex); -if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { - cpu_dai->playback_active += action; -for_each_rtd_codec_dai (rtd, i, codec_dai) - codec_dai->playback_active += action; - }else { - cpu_dai->capture_active += action; -for_each_rtd_codec_dai (rtd, i, codec_dai) - codec_dai->capture_active += action; - } + cpu_dai->stream_active[stream] += action; +for_each_rtd_codec_dai (rtd, i, codec_dai) + codec_dai->stream_active[stream] += action; cpu_dai->active += action; cpu_dai->component->active += action;
@@ -967,8 +961,11 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)/* apply codec digital mute */ for_each_rtd_codec_dai (rtd, i, codec_dai) { -if ((playback && codec_dai->playback_active ==1 ) || - (!playback && codec_dai->capture_active ==1 )) +int playback_active = codec_dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK ]; +int capture_active = codec_dai->stream_active[SNDRV_PCM_STREAM_CAPTURE ]; + +if ((playback && playback_active ==1 ) || + (!playback && capture_active ==1 ))snd_soc_dai_digital_mute (codec_dai,1 , substream->stream); }
@@ -2634,7 +2631,8 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new) goto capture;/* skip if FE isn't currently playing */ -if (!fe->cpu_dai->playback_active || !fe->codec_dai->playback_active) +if (!fe->cpu_dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK ] || + !fe->codec_dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK ]) goto capture; paths =dpcm_path_get (fe,SNDRV_PCM_STREAM_PLAYBACK , &list);
@@ -2665,7 +2663,8 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)return 0 ;/* skip if FE isn't currently capturing */ -if (!fe->cpu_dai->capture_active || !fe->codec_dai->capture_active) +if (!fe->cpu_dai->stream_active[SNDRV_PCM_STREAM_CAPTURE ] || + !fe->codec_dai->stream_active[SNDRV_PCM_STREAM_CAPTURE ])return 0 ; paths =dpcm_path_get (fe,SNDRV_PCM_STREAM_CAPTURE , &list);
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 10/18 ASoC: soc.h: add for_each_pcm_streams()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
ALSA SoC has SNDRV_PCM_STREAM_PLAYBACK/CAPTURE everywhere. Having for_each_xxxx macro is useful.
This patch adds for_each_pcm_streams() for it.
--- include/sound/pcm.h | 5 +++++ 1 file changed, 5 insertions(+)
include/sound/pcm.h +5 -0
@@ -644,6 +644,11 @@ void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,#define snd_pcm_group_for_each_entry (s, substream) \ list_for_each_entry(s, &substream->group->substreams, link_list) +#define for_each_pcm_streams (stream) \ + for (stream = SNDRV_PCM_STREAM_PLAYBACK; \ + stream <= SNDRV_PCM_STREAM_LAST; \ + stream++) +/** * snd_pcm_running - Check whether the substream is in a running state * @substream: substream to check
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [alsa-devel] [PATCH v3 10/18] ASoC: soc.h: add for_each_pcm_streams()
Quoted 7 lines · Kuninori Morimoto
From: Kuninori Morimoto <[email protected]>
ALSA SoC has SNDRV_PCM_STREAM_PLAYBACK/CAPTURE everywhere. Having
for_each_xxxxmacro is useful.
This patch addsfor_each_pcm_streams()for it.
The subject prefix should be "ALSA" as it's ALSA-common code.
Other than that,
BTW, Mark, if you merge this series, please send the pull request earlier to me. I'm going to apply the similar cleanups in the whole rest ALSA code, and this change is needed at first.
thanks,
Takashi
Quoted 30 lines
Signed-off-by Kuninori Morimoto <[email protected]>Reviewed-by Ranjani Sridharan <[email protected]>--- include/sound/pcm.h | 5 +++++ 1 file changed, 5 insertions(+)include/sound/pcm.h +5
-0@@ -644,6 +644,11 @@ void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream,#define snd_pcm_group_for_each_entry (s, substream) \ list_for_each_entry(s, &substream->group->substreams, link_list) +#define for_each_pcm_streams (stream) \ + for (stream = SNDRV_PCM_STREAM_PLAYBACK; \ + stream <= SNDRV_PCM_STREAM_LAST; \ + stream++) +/** * snd_pcm_running - Check whether the substream is in a running state * @substream: substream to check Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [alsa-devel] [PATCH v3 10/18] ASoC: soc.h: add for_each_pcm_streams()
Hi Takashi-san
Thank you for your review.
Quoted 7 lines
Quoted 5 lines
From: Kuninori Morimoto <[email protected]>
ALSA SoC has SNDRV_PCM_STREAM_PLAYBACK/CAPTURE everywhere. Having
for_each_xxxxmacro is useful.
This patch addsfor_each_pcm_streams()for it.The subject prefix should be "ALSA" as it's ALSA-common code.
Oops. And it needs to fixup "soc.h" to "pcm.h" on Subject. Will post v4 patch set soon
Thank you for your help !!
Best regards
---
Kuninori Morimoto
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 11/18 ASoC: soc-core: use for_each_pcm_streams() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/soc-core.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-)
sound/soc/soc-core.c +13 -18
@@ -432,6 +432,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(struct snd_soc_component *component;struct device *dev;int ret; +int stream;/* * for rtd->dev
@@ -466,10 +467,10 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( rtd->dev = dev;INIT_LIST_HEAD (&rtd->list); -INIT_LIST_HEAD (&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK ].be_clients); -INIT_LIST_HEAD (&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE ].be_clients); -INIT_LIST_HEAD (&rtd->dpcm[SNDRV_PCM_STREAM_PLAYBACK ].fe_clients); -INIT_LIST_HEAD (&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE ].fe_clients); +for_each_pcm_streams (stream) { +INIT_LIST_HEAD (&rtd->dpcm[stream].be_clients); +INIT_LIST_HEAD (&rtd->dpcm[stream].fe_clients); + }dev_set_drvdata (dev, rtd);INIT_DELAYED_WORK (&rtd->delayed_work, close_delayed_work);
@@ -559,17 +560,14 @@ int snd_soc_suspend(struct device *dev)snd_soc_flush_all_delayed_work (card);for_each_card_rtds (card, rtd) { +int stream;if (rtd->dai_link->ignore_suspend)continue ; -snd_soc_dapm_stream_event (rtd, -SNDRV_PCM_STREAM_PLAYBACK , -SND_SOC_DAPM_STREAM_SUSPEND ); - -snd_soc_dapm_stream_event (rtd, -SNDRV_PCM_STREAM_CAPTURE , -SND_SOC_DAPM_STREAM_SUSPEND ); +for_each_pcm_streams (stream) +snd_soc_dapm_stream_event (rtd, stream, +SND_SOC_DAPM_STREAM_SUSPEND ); }/* Recheck all endpoints too, their state is affected by suspend */
@@ -665,17 +663,14 @@ static void soc_resume_deferred(struct work_struct *work) }for_each_card_rtds (card, rtd) { +int stream;if (rtd->dai_link->ignore_suspend)continue ; -snd_soc_dapm_stream_event (rtd, -SNDRV_PCM_STREAM_PLAYBACK , -SND_SOC_DAPM_STREAM_RESUME ); - -snd_soc_dapm_stream_event (rtd, -SNDRV_PCM_STREAM_CAPTURE , -SND_SOC_DAPM_STREAM_RESUME ); +for_each_pcm_streams (stream) +snd_soc_dapm_stream_event (rtd, stream, +SND_SOC_DAPM_STREAM_RESUME ); }/* unmute any active DACs */
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 12/18 ASoC: soc-pcm: use for_each_pcm_streams() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/soc-pcm.c | 97 ++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 62 deletions(-)
sound/soc/soc-pcm.c +35 -62
@@ -2612,6 +2612,7 @@ static int dpcm_run_old_update(struct snd_soc_pcm_runtime *fe, int stream)static int soc_dpcm_fe_runtime_update (struct snd_soc_pcm_runtime *fe,int new) {struct snd_soc_dapm_widget_list *list; +int stream;int count, paths;if (!fe->dai_link->dynamic)
@@ -2625,69 +2626,42 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)dev_dbg (fe->dev,"ASoC: DPCM %s runtime update for FE %s\n" , new ?"new" :"old" , fe->dai_link->name); -/* skip if FE doesn't have playback capability */ -if (!snd_soc_dai_stream_valid (fe->cpu_dai,SNDRV_PCM_STREAM_PLAYBACK ) || - !snd_soc_dai_stream_valid (fe->codec_dai,SNDRV_PCM_STREAM_PLAYBACK )) - goto capture; - -/* skip if FE isn't currently playing */ -if (!fe->cpu_dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK ] || - !fe->codec_dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK ]) - goto capture; - - paths =dpcm_path_get (fe,SNDRV_PCM_STREAM_PLAYBACK , &list); -if (paths <0 ) { -dev_warn (fe->dev,"ASoC: %s no valid %s path\n" , - fe->dai_link->name,"playback" ); -return paths; - } - -/* update any playback paths */ - count =dpcm_process_paths (fe,SNDRV_PCM_STREAM_PLAYBACK , &list, new); -if (count) { -if (new) -dpcm_run_new_update (fe,SNDRV_PCM_STREAM_PLAYBACK ); -else -dpcm_run_old_update (fe,SNDRV_PCM_STREAM_PLAYBACK ); +for_each_pcm_streams (stream) { -dpcm_clear_pending_state (fe,SNDRV_PCM_STREAM_PLAYBACK ); -dpcm_be_disconnect (fe,SNDRV_PCM_STREAM_PLAYBACK ); - } - -dpcm_path_put (&list); +/* skip if FE doesn't have playback/capture capability */ +if (!snd_soc_dai_stream_valid (fe->cpu_dai, stream) || + !snd_soc_dai_stream_valid (fe->codec_dai, stream)) +continue ; -capture: -/* skip if FE doesn't have capture capability */ -if (!snd_soc_dai_stream_valid (fe->cpu_dai,SNDRV_PCM_STREAM_CAPTURE ) || - !snd_soc_dai_stream_valid (fe->codec_dai,SNDRV_PCM_STREAM_CAPTURE )) -return 0 ; +/* skip if FE isn't currently playing/capturing */ +if (!fe->cpu_dai->stream_active[stream] || + !fe->codec_dai->stream_active[stream]) +continue ; -/* skip if FE isn't currently capturing */ -if (!fe->cpu_dai->stream_active[SNDRV_PCM_STREAM_CAPTURE ] || - !fe->codec_dai->stream_active[SNDRV_PCM_STREAM_CAPTURE ]) -return 0 ; + paths =dpcm_path_get (fe, stream, &list); +if (paths <0 ) { +dev_warn (fe->dev,"ASoC: %s no valid %s path\n" , + fe->dai_link->name, + stream ==SNDRV_PCM_STREAM_PLAYBACK ? +"playback" :"capture" ); +return paths; + } - paths =dpcm_path_get (fe,SNDRV_PCM_STREAM_CAPTURE , &list); -if (paths <0 ) { -dev_warn (fe->dev,"ASoC: %s no valid %s path\n" , - fe->dai_link->name,"capture" ); -return paths; - } +/* update any playback/capture paths */ + count =dpcm_process_paths (fe, stream, &list, new); +if (count) { +if (new) +dpcm_run_new_update (fe, stream); +else +dpcm_run_old_update (fe, stream); -/* update any old capture paths */ - count =dpcm_process_paths (fe,SNDRV_PCM_STREAM_CAPTURE , &list, new); -if (count) { -if (new) -dpcm_run_new_update (fe,SNDRV_PCM_STREAM_CAPTURE ); -else -dpcm_run_old_update (fe,SNDRV_PCM_STREAM_CAPTURE ); +dpcm_clear_pending_state (fe, stream); +dpcm_be_disconnect (fe, stream); + } -dpcm_clear_pending_state (fe,SNDRV_PCM_STREAM_CAPTURE ); -dpcm_be_disconnect (fe,SNDRV_PCM_STREAM_CAPTURE ); +dpcm_path_put (&list); } -dpcm_path_put (&list); -return 0 ; }
@@ -3117,19 +3091,18 @@ static ssize_t dpcm_state_read_file(struct file *file, char __user *user_buf, {struct snd_soc_pcm_runtime *fe = file->private_data;ssize_t out_count =PAGE_SIZE , offset =0 , ret =0 ; +int stream;char *buf; buf =kmalloc (out_count,GFP_KERNEL );if (!buf)return -ENOMEM ; -if (snd_soc_dai_stream_valid (fe->cpu_dai,SNDRV_PCM_STREAM_PLAYBACK )) - offset +=dpcm_show_state (fe,SNDRV_PCM_STREAM_PLAYBACK , - buf + offset, out_count - offset); - -if (snd_soc_dai_stream_valid (fe->cpu_dai,SNDRV_PCM_STREAM_CAPTURE )) - offset +=dpcm_show_state (fe,SNDRV_PCM_STREAM_CAPTURE , - buf + offset, out_count - offset); +for_each_pcm_streams (stream) +if (snd_soc_dai_stream_valid (fe->cpu_dai, stream)) + offset +=dpcm_show_state (fe, stream, + buf + offset, + out_count - offset); ret =simple_read_from_buffer (user_buf, count, ppos, buf, offset);
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 13/18 ASoC: soc-generic-dmaengine-pcm: use for_each_pcm_streams() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/soc-generic-dmaengine-pcm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
sound/soc/soc-generic-dmaengine-pcm.c +3 -5
@@ -237,7 +237,7 @@ static int dmaengine_pcm_new(struct snd_soc_component *component, max_buffer_size =SIZE_MAX ; } -for (i =SNDRV_PCM_STREAM_PLAYBACK ; i <=SNDRV_PCM_STREAM_CAPTURE ; i++) { +for_each_pcm_streams (i) { substream = rtd->pcm->streams[i].substream;if (!substream)continue ;
@@ -371,8 +371,7 @@ static int dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm, dev = config->dma_dev; } -for (i =SNDRV_PCM_STREAM_PLAYBACK ; i <=SNDRV_PCM_STREAM_CAPTURE ; - i++) { +for_each_pcm_streams (i) {if (pcm->flags &SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX ) name ="rx-tx" ;else
@@ -401,8 +400,7 @@ static void dmaengine_pcm_release_chan(struct dmaengine_pcm *pcm) {unsigned int i; -for (i =SNDRV_PCM_STREAM_PLAYBACK ; i <=SNDRV_PCM_STREAM_CAPTURE ; - i++) { +for_each_pcm_streams (i) {if (!pcm->chan[i])continue ;dma_release_channel (pcm->chan[i]);
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 14/18 ASoC: dwc: dwc-i2s: use for_each_pcm_streams() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/dwc/dwc-i2s.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/dwc/dwc-i2s.c +4 -4
@@ -422,15 +422,15 @@ static int dw_i2s_resume(struct snd_soc_component *component) {struct dw_i2s_dev *dev =snd_soc_component_get_drvdata (component);struct snd_soc_dai *dai; +int stream;if (dev->capability &DW_I2S_MASTER )clk_enable (dev->clk);for_each_component_dais (component, dai) { -if (dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK ]) -dw_i2s_config (dev,SNDRV_PCM_STREAM_PLAYBACK ); -if (dai->stream_active[SNDRV_PCM_STREAM_CAPTURE ]) -dw_i2s_config (dev,SNDRV_PCM_STREAM_CAPTURE ); +for_each_pcm_streams (stream) +if (dai->stream_active[stream]) +dw_i2s_config (dev, stream); }return 0 ;
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 15/18 ASoC: fsl: fsl_asrc_dma: use for_each_pcm_streams() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/fsl/fsl_asrc_dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/fsl/fsl_asrc_dma.c +2 -2
@@ -400,7 +400,7 @@ static int fsl_asrc_dma_pcm_new(struct snd_soc_component *component,return ret; } -for (i =SNDRV_PCM_STREAM_PLAYBACK ; i <=SNDRV_PCM_STREAM_LAST ; i++) { +for_each_pcm_streams (i) { substream = pcm->streams[i].substream;if (!substream)continue ;
@@ -428,7 +428,7 @@ static void fsl_asrc_dma_pcm_free(struct snd_soc_component *component,struct snd_pcm_substream *substream;int i; -for (i =SNDRV_PCM_STREAM_PLAYBACK ; i <=SNDRV_PCM_STREAM_LAST ; i++) { +for_each_pcm_streams (i) { substream = pcm->streams[i].substream;if (!substream)continue ;
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 16/18 ASoC: qcom: lpass-platform: use for_each_pcm_streams() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/qcom/lpass-platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/qcom/lpass-platform.c +1 -1
@@ -529,7 +529,7 @@ static void lpass_platform_pcm_free(struct snd_soc_component *component,struct snd_pcm_substream *substream;int i; -for (i =0 ; i <ARRAY_SIZE (pcm->streams); i++) { +for_each_pcm_streams (i) { substream = pcm->streams[i].substream;if (substream) {snd_dma_free_pages (&substream->dma_buffer);
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 17/18 ASoC: sof: sof-audio: use for_each_pcm_streams() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/sof/sof-audio.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
sound/soc/sof/sof-audio.c +7 -12
@@ -23,7 +23,7 @@ bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev)int dir;list_for_each_entry (spcm, &sdev->pcm_list, list) { -for (dir =0 ; dir <=SNDRV_PCM_STREAM_CAPTURE ; dir++) { +for_each_pcm_streams (dir) { substream = spcm->stream[dir].substream;if (!substream || !substream->runtime)continue ;
@@ -71,7 +71,7 @@ int sof_set_hw_params_upon_resume(struct device *dev)* have been suspended. */ list_for_each_entry (spcm, &sdev->pcm_list, list) { -for (dir =0 ; dir <=SNDRV_PCM_STREAM_CAPTURE ; dir++) { +for_each_pcm_streams (dir) {/* * do not reset hw_params upon resume for streams that * were kept running during suspend
@@ -319,16 +319,11 @@ struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp,int dir;list_for_each_entry (spcm, &sdev->pcm_list, list) { - dir =SNDRV_PCM_STREAM_PLAYBACK ; -if (spcm->stream[dir].comp_id == comp_id) { - *direction = dir; -return spcm; - } - - dir =SNDRV_PCM_STREAM_CAPTURE ; -if (spcm->stream[dir].comp_id == comp_id) { - *direction = dir; -return spcm; +for_each_pcm_streams (dir) { +if (spcm->stream[dir].comp_id == comp_id) { + *direction = dir; +return spcm; + } } }
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH v3 18/18 ALSA: usx2y: use for_each_pcm_streams() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/usb/usx2y/usbusx2yaudio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
sound/usb/usx2y/usbusx2yaudio.c +5 -4
@@ -906,11 +906,12 @@ static const struct snd_pcm_ops snd_usX2Y_pcm_ops =*/ static void usX2Y_audio_stream_free (struct snd_usX2Y_substream **usX2Y_substream) { -kfree (usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK ]); - usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK ] =NULL ; +int stream; -kfree (usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE ]); - usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE ] =NULL ; +for_each_pcm_streams (stream) { +kfree (usX2Y_substream[stream]); + usX2Y_substream[stream] =NULL ; + } }static void snd_usX2Y_pcm_private_free (struct snd_pcm *pcm)
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [alsa-devel] [PATCH v3 18/18] ALSA: usx2y: use for_each_pcm_streams() macro
Quoted 6 lines · Kuninori Morimoto
From: Kuninori Morimoto <[email protected]>
Signed-off-by Kuninori Morimoto <[email protected]>Reviewed-by Ranjani Sridharan <[email protected]>
thanks,
Takashi
Quoted 33 lines
--- sound/usb/usx2y/usbusx2yaudio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)sound/usb/usx2y/usbusx2yaudio.c +5
-4@@ -906,11 +906,12 @@ static const struct snd_pcm_ops snd_usX2Y_pcm_ops =*/ static void usX2Y_audio_stream_free (struct snd_usX2Y_substream **usX2Y_substream) { -kfree (usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK ]); - usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK ] =NULL ; +int stream; -kfree (usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE ]); - usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE ] =NULL ; +for_each_pcm_streams (stream) { +kfree (usX2Y_substream[stream]); + usX2Y_substream[stream] =NULL ; + } }static void snd_usX2Y_pcm_private_free (struct snd_pcm *pcm)Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel