ASoC: soc-pcm cleanup step4
Subsystems (7)
cover ASoC: soc-pcm cleanup step4
Hi Mark
These are soc-pcm cleanup step4.
[01/13] - [06/13] are posted but not yet accepted patches. To avoid conflict, I merged these into step4.
These patches are already received Reviewed-by from Pierre-Louis.
Subject: [PATCH 0/6] ASoC: use for_each_rtd_codec_dai() macro Date: Thu, 13 Feb 2020 13:08:07 +0900
Kuninori Morimoto (13):
1) ASoC: soundwaire: qcom: use for_each_rtd_codec_dai() macro
2) ASoC: qcom: sdm845: use for_each_rtd_codec_dai() macro
3) ASoC: qcom: apq8016_sbc: use for_each_rtd_codec_dai() macro
4) ASoC: intel: cml_rt1011_rt5682: use for_each_rtd_codec_dai() macro
5) ASoC: intel: kbl_da7219_max98927: use for_each_rtd_codec_dai() macro
6) ASoC: mediatek: mt8183-da7219-max98357: use for_each_rtd_codec_dai() macro
7) ASoC: soc-pcm: add snd_soc_dai_get_pcm_stream()
8) ASoC: soc-pcm: cleanup soc_pcm_apply_msb()
9) ASoC: soc-pcm: add snd_soc_dai_get_widget()
10) ASoC: soc-pcm: merge dpcm_run_new/old_update() into dpcm_fe_runtime_update()
11) ASoC: soc-pcm: move dpcm_path_put() to soc-pcm.c
12) ASoC: soc-pcm: move CONFIG_DEBUG_FS functions to top side
13) ASoC: soc-pcm: add dpcm_create/remove_debugfs_state()
drivers/soundwire/qcom.c | 7 +- include/sound/soc-dai.h | 15 + include/sound/soc-dapm.h | 1 + include/sound/soc-dpcm.h | 7 +- sound/soc/intel/boards/cml_rt1011_rt5682.c | 3 +- sound/soc/intel/boards/kbl_da7219_max98927.c | 8 +- sound/soc/intel/skylake/skl-pcm.c | 10 +- .../mediatek/mt8183/mt8183-da7219-max98357.c | 8 +- sound/soc/qcom/apq8016_sbc.c | 7 +- sound/soc/qcom/sdm845.c | 20 +- sound/soc/soc-dai.c | 7 +- sound/soc/soc-dapm.c | 20 +- sound/soc/soc-pcm.c | 462 ++++++++---------- 13 files changed, 266 insertions(+), 309 deletions(-)
Signature · 10 lines
2.17.1 Thank you for your help !! Best regards --- Kuninori Morimoto
PATCH 1/13 ASoC: soundwaire: qcom: use for_each_rtd_codec_dai() macro
From: Kuninori Morimoto <[email protected]>
--- drivers/soundwire/qcom.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/soundwire/qcom.c +4 -3
@@ -594,6 +594,7 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream,struct qcom_swrm_ctrl *ctrl =dev_get_drvdata (dai->dev);struct snd_soc_pcm_runtime *rtd = substream->private_data;struct sdw_stream_runtime *sruntime; +struct snd_soc_dai *codec_dai;int ret, i; sruntime =sdw_alloc_stream (dai->name);
@@ -602,12 +603,12 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream, ctrl->sruntime[dai->id] = sruntime; -for (i =0 ; i < rtd->num_codecs; i++) { - ret =snd_soc_dai_set_sdw_stream (rtd->codec_dais[i], sruntime, +for_each_rtd_codec_dai (rtd, i, codec_dai) { + ret =snd_soc_dai_set_sdw_stream (codec_dai, sruntime, substream->stream);if (ret <0 && ret != -ENOTSUPP ) {dev_err (dai->dev,"Failed to set sdw stream on %s" , - rtd->codec_dais[i]->name); + codec_dai->name);sdw_release_stream (sruntime);return ret; }
Signature · 1 line
2.17.1
PATCH 2/13 ASoC: qcom: sdm845: use for_each_rtd_codec_dai() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/qcom/sdm845.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
sound/soc/qcom/sdm845.c +9 -11
@@ -43,14 +43,14 @@ static int sdm845_slim_snd_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) {struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct snd_soc_dai_link *dai_link = rtd->dai_link;struct snd_soc_dai *cpu_dai = rtd->cpu_dai; +struct snd_soc_dai *codec_dai;u32 rx_ch[SLIM_MAX_RX_PORTS ], tx_ch[SLIM_MAX_TX_PORTS ];u32 rx_ch_cnt =0 , tx_ch_cnt =0 ;int ret =0 , i; -for (i =0 ; i < dai_link->num_codecs; i++) { - ret =snd_soc_dai_get_channel_map (rtd->codec_dais[i], +for_each_rtd_codec_dai (rtd, i, codec_dai) { + ret =snd_soc_dai_get_channel_map (codec_dai, &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);if (ret !=0 && ret != -ENOTSUPP ) {
@@ -77,6 +77,7 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream, {struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *cpu_dai = rtd->cpu_dai; +struct snd_soc_dai *codec_dai;int ret =0 , j;int channels, slot_width;
@@ -125,8 +126,7 @@ static int sdm845_tdm_snd_hw_params(struct snd_pcm_substream *substream, } } -for (j =0 ; j < rtd->num_codecs; j++) { -struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; +for_each_rtd_codec_dai (rtd, j, codec_dai) {if (!strcmp (codec_dai->component->name_prefix,"Left" )) { ret = snd_soc_dai_set_tdm_slot(
@@ -214,7 +214,6 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd)struct snd_soc_dai *cpu_dai = rtd->cpu_dai;struct sdm845_snd_data *pdata =snd_soc_card_get_drvdata (card);struct snd_jack *jack; -struct snd_soc_dai_link *dai_link = rtd->dai_link;/* * Codec SLIMBUS configuration * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8, RX9, RX10, RX11, RX12, RX13
@@ -266,8 +265,8 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) }break ; case SLIMBUS_0_RX...SLIMBUS_6_TX: -for (i =0 ; i < dai_link->num_codecs; i++) { - rval = snd_soc_dai_set_channel_map(rtd->codec_dais[i], +for_each_rtd_codec_dai (rtd, i, codec_dai) { + rval = snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch), tx_ch, ARRAY_SIZE(rx_ch),
@@ -275,7 +274,7 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd)if (rval !=0 && rval != -ENOTSUPP )return rval; -snd_soc_dai_set_sysclk (rtd->codec_dais[i],0 , +snd_soc_dai_set_sysclk (codec_dai,0 ,WCD934X_DEFAULT_MCLK_RATE ,SNDRV_PCM_STREAM_PLAYBACK ); }
@@ -345,8 +344,7 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream) codec_dai_fmt |=SND_SOC_DAIFMT_IB_NF |SND_SOC_DAIFMT_DSP_B ; -for (j =0 ; j < rtd->num_codecs; j++) { - codec_dai = rtd->codec_dais[j]; +for_each_rtd_codec_dai (rtd, j, codec_dai) {if (!strcmp (codec_dai->component->name_prefix,"Left" )) {
Signature · 1 line
2.17.1
PATCH 3/13 ASoC: qcom: apq8016_sbc: use for_each_rtd_codec_dai() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/qcom/apq8016_sbc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
sound/soc/qcom/apq8016_sbc.c +3 -4
@@ -34,8 +34,8 @@ struct apq8016_sbc_data {static int apq8016_sbc_dai_init (struct snd_soc_pcm_runtime *rtd) {struct snd_soc_dai *cpu_dai = rtd->cpu_dai; +struct snd_soc_dai *codec_dai;struct snd_soc_component *component; -struct snd_soc_dai_link *dai_link = rtd->dai_link;struct snd_soc_card *card = rtd->card;struct apq8016_sbc_data *pdata =snd_soc_card_get_drvdata (card);int i, rval;
@@ -90,10 +90,9 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) pdata->jack_setup = true; } -for (i =0 ; i < dai_link->num_codecs; i++) { -struct snd_soc_dai *dai = rtd->codec_dais[i]; +for_each_rtd_codec_dai (rtd, i, codec_dai) { - component = dai->component; + component = codec_dai->component;/* Set default mclk for internal codec */ rval =snd_soc_component_set_sysclk (component,0 ,0 ,DEFAULT_MCLK_RATE ,SND_SOC_CLOCK_IN );
Signature · 1 line
2.17.1
PATCH 4/13 ASoC: intel: cml_rt1011_rt5682: use for_each_rtd_codec_dai() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/intel/boards/cml_rt1011_rt5682.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/intel/boards/cml_rt1011_rt5682.c +1 -2
@@ -164,8 +164,7 @@ static int cml_rt1011_hw_params(struct snd_pcm_substream *substream, srate =params_rate (params); -for (i =0 ; i < rtd->num_codecs; i++) { - codec_dai = rtd->codec_dais[i]; +for_each_rtd_codec_dai (rtd, i, codec_dai) {/* 100 Fs to drive 24 bit data */ ret = snd_soc_dai_set_pll(codec_dai, 0, RT1011_PLL1_S_BCLK,
Signature · 1 line
2.17.1
PATCH 5/13 ASoC: intel: kbl_da7219_max98927: use for_each_rtd_codec_dai() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/intel/boards/kbl_da7219_max98927.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/intel/boards/kbl_da7219_max98927.c +4 -4
@@ -176,10 +176,10 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) {struct snd_soc_pcm_runtime *runtime = substream->private_data; +struct snd_soc_dai *codec_dai;int ret, j; -for (j =0 ; j < runtime->num_codecs; j++) { -struct snd_soc_dai *codec_dai = runtime->codec_dais[j]; +for_each_rtd_codec_dai (runtime, j, codec_dai) {if (!strcmp (codec_dai->component->name,MAX98927_DEV0_NAME )) { ret =snd_soc_dai_set_tdm_slot (codec_dai,0x30 ,3 ,8 ,16 );
@@ -221,10 +221,10 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream,static int kabylake_ssp0_trigger (struct snd_pcm_substream *substream,int cmd) {struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai *codec_dai;int j, ret; -for (j =0 ; j < rtd->num_codecs; j++) { -struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; +for_each_rtd_codec_dai (rtd, j, codec_dai) {const char *name = codec_dai->component->name;struct snd_soc_component *component = codec_dai->component; struct snd_soc_dapm_context *dapm =
Signature · 1 line
2.17.1
PATCH 6/13 ASoC: mediatek: mt8183-da7219-max98357: use for_each_rtd_codec_dai() macro
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
--- sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +4 -4
@@ -53,6 +53,7 @@ static int mt8183_da7219_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) {struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai *codec_dai;unsigned int rate =params_rate (params);unsigned int mclk_fs_ratio =256 ;unsigned int mclk_fs = rate * mclk_fs_ratio;
@@ -64,8 +65,7 @@ static int mt8183_da7219_i2s_hw_params(struct snd_pcm_substream *substream,if (ret <0 )dev_err (rtd->dev,"failed to set cpu dai sysclk\n" ); -for (j =0 ; j < rtd->num_codecs; j++) { -struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; +for_each_rtd_codec_dai (rtd, j, codec_dai) {if (!strcmp (codec_dai->component->name,"da7219.5-001a" )) { ret = snd_soc_dai_set_sysclk(codec_dai,
@@ -95,10 +95,10 @@ static int mt8183_da7219_i2s_hw_params(struct snd_pcm_substream *substream,static int mt8183_da7219_hw_free (struct snd_pcm_substream *substream) {struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_dai *codec_dai;int ret =0 , j; -for (j =0 ; j < rtd->num_codecs; j++) { -struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; +for_each_rtd_codec_dai (rtd, j, codec_dai) {if (!strcmp (codec_dai->component->name,"da7219.5-001a" )) { ret = snd_soc_dai_set_pll(codec_dai,
Signature · 1 line
2.17.1
PATCH 7/13 ASoC: soc-pcm: add snd_soc_dai_get_pcm_stream()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
DAI driver has playback/capture stream.
OTOH, we have SNDRV_PCM_STREAM_PLAYBACK/CAPTURE.
Because of this kind of implementation,
ALSA SoC needs to have many verbose code.
To solve this issue, this patch adds snd_soc_dai_get_pcm_stream() macro to get playback/capture stream pointer from stream.
--- include/sound/soc-dai.h | 7 ++++++ sound/soc/soc-dai.c | 7 +----- sound/soc/soc-pcm.c | 49 ++++++++--------------------------------- 3 files changed, 17 insertions(+), 46 deletions(-)
include/sound/soc-dai.h +7 -0
@@ -352,6 +352,13 @@ struct snd_soc_dai { unsigned int started:1; }; +static inline struct snd_soc_pcm_stream * +snd_soc_dai_get_pcm_stream (const struct snd_soc_dai *dai,int stream) +{ +return (stream ==SNDRV_PCM_STREAM_PLAYBACK ) ? + &dai->driver->playback : &dai->driver->capture; +} +static inline void *snd_soc_dai_get_dma_data (const struct snd_soc_dai *dai,const struct snd_pcm_substream *ss) {
sound/soc/soc-dai.c +1 -6
@@ -390,12 +390,7 @@ int snd_soc_dai_compress_new(struct snd_soc_dai *dai,*/ bool snd_soc_dai_stream_valid (struct snd_soc_dai *dai,int dir) { -struct snd_soc_pcm_stream *stream; - -if (dir ==SNDRV_PCM_STREAM_PLAYBACK ) - stream = &dai->driver->playback; -else - stream = &dai->driver->capture; +struct snd_soc_pcm_stream *stream =snd_soc_dai_get_pcm_stream (dai, dir);/* If the codec specifies any channels at all, it supports the stream */ return stream->channels_min;
sound/soc/soc-pcm.c +9 -40
113 lines not on this page · raw message
Signature · 1 line
2.17.1
Mark Brown
maintainerApplied "ASoC: soc-pcm: add snd_soc_dai_get_pcm_stream()" to the asoc tree
The patch
ASoC: soc-pcm: add snd_soc_dai_get_pcm_stream()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
From acf253c11329caa6be6d2abc14dfc8c0ec83718a Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Wed, 19 Feb 2020 15:56:30 +0900
Subject: [PATCH] ASoC: soc-pcm: add snd_soc_dai_get_pcm_stream()
DAI driver has playback/capture stream.
OTOH, we have SNDRV_PCM_STREAM_PLAYBACK/CAPTURE.
Because of this kind of implementation,
ALSA SoC needs to have many verbose code.
To solve this issue, this patch adds snd_soc_dai_get_pcm_stream() macro to get playback/capture stream pointer from stream.
--- include/sound/soc-dai.h | 7 ++++++ sound/soc/soc-dai.c | 7 +----- sound/soc/soc-pcm.c | 49 ++++++++--------------------------------- 3 files changed, 17 insertions(+), 46 deletions(-)
include/sound/soc-dai.h +7 -0
@@ -352,6 +352,13 @@ struct snd_soc_dai { unsigned int started:1; }; +static inline struct snd_soc_pcm_stream * +snd_soc_dai_get_pcm_stream (const struct snd_soc_dai *dai,int stream) +{ +return (stream ==SNDRV_PCM_STREAM_PLAYBACK ) ? + &dai->driver->playback : &dai->driver->capture; +} +static inline void *snd_soc_dai_get_dma_data (const struct snd_soc_dai *dai,const struct snd_pcm_substream *ss) {
sound/soc/soc-dai.c +1 -6
@@ -390,12 +390,7 @@ int snd_soc_dai_compress_new(struct snd_soc_dai *dai,*/ bool snd_soc_dai_stream_valid (struct snd_soc_dai *dai,int dir) { -struct snd_soc_pcm_stream *stream; - -if (dir ==SNDRV_PCM_STREAM_PLAYBACK ) - stream = &dai->driver->playback; -else - stream = &dai->driver->capture; +struct snd_soc_pcm_stream *stream =snd_soc_dai_get_pcm_stream (dai, dir);/* If the codec specifies any channels at all, it supports the stream */ return stream->channels_min;
sound/soc/soc-pcm.c +9 -40
113 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 8/13 ASoC: soc-pcm: cleanup soc_pcm_apply_msb()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
soc_pcm_apply_msb() apply msb for CPU/Codec, but, it has duplicate code. The difference is only SNDRV_PCM_STREAM_PLAYBACK and SNDRV_PCM_STEAM_CAPTURE.
It is very verbose and duplicate code.
This patch simplify code by using snd_soc_dai_get_pcm_stream().
--- sound/soc/soc-pcm.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-)
sound/soc/soc-pcm.c +12 -17
@@ -363,29 +363,24 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream)struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *cpu_dai = rtd->cpu_dai;struct snd_soc_dai *codec_dai; +struct snd_soc_pcm_stream *pcm_codec, *pcm_cpu; +int stream = substream->stream;int i;unsigned int bits =0 , cpu_bits; -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { -for_each_rtd_codec_dai (rtd, i, codec_dai) { -if (codec_dai->driver->playback.sig_bits ==0 ) { - bits =0 ; -break ; - } - bits =max (codec_dai->driver->playback.sig_bits, bits); - } - cpu_bits = cpu_dai->driver->playback.sig_bits; - }else { -for_each_rtd_codec_dai (rtd, i, codec_dai) { -if (codec_dai->driver->capture.sig_bits ==0 ) { - bits =0 ; -break ; - } - bits =max (codec_dai->driver->capture.sig_bits, bits); +for_each_rtd_codec_dai (rtd, i, codec_dai) { + pcm_codec =snd_soc_dai_get_pcm_stream (codec_dai, stream); + +if (pcm_codec->sig_bits ==0 ) { + bits =0 ; +break ; } - cpu_bits = cpu_dai->driver->capture.sig_bits; + bits =max (pcm_codec->sig_bits, bits); } + pcm_cpu =snd_soc_dai_get_pcm_stream (cpu_dai, stream); + cpu_bits = pcm_cpu->sig_bits; +soc_pcm_set_msb (substream, bits);soc_pcm_set_msb (substream, cpu_bits); }
Signature · 1 line
2.17.1
Mark Brown
maintainerApplied "ASoC: soc-pcm: cleanup soc_pcm_apply_msb()" to the asoc tree
The patch
ASoC: soc-pcm: cleanup soc_pcm_apply_msb()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
From 57be92066f68e63bd4a72a65d45c3407c0cb552a Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Wed, 19 Feb 2020 15:56:36 +0900
Subject: [PATCH] ASoC: soc-pcm: cleanup soc_pcm_apply_msb()
soc_pcm_apply_msb() apply msb for CPU/Codec, but, it has duplicate code. The difference is only SNDRV_PCM_STREAM_PLAYBACK and SNDRV_PCM_STEAM_CAPTURE.
It is very verbose and duplicate code.
This patch simplify code by using snd_soc_dai_get_pcm_stream().
--- sound/soc/soc-pcm.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-)
sound/soc/soc-pcm.c +12 -17
@@ -363,29 +363,24 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream)struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_dai *cpu_dai = rtd->cpu_dai;struct snd_soc_dai *codec_dai; +struct snd_soc_pcm_stream *pcm_codec, *pcm_cpu; +int stream = substream->stream;int i;unsigned int bits =0 , cpu_bits; -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { -for_each_rtd_codec_dai (rtd, i, codec_dai) { -if (codec_dai->driver->playback.sig_bits ==0 ) { - bits =0 ; -break ; - } - bits =max (codec_dai->driver->playback.sig_bits, bits); - } - cpu_bits = cpu_dai->driver->playback.sig_bits; - }else { -for_each_rtd_codec_dai (rtd, i, codec_dai) { -if (codec_dai->driver->capture.sig_bits ==0 ) { - bits =0 ; -break ; - } - bits =max (codec_dai->driver->capture.sig_bits, bits); +for_each_rtd_codec_dai (rtd, i, codec_dai) { + pcm_codec =snd_soc_dai_get_pcm_stream (codec_dai, stream); + +if (pcm_codec->sig_bits ==0 ) { + bits =0 ; +break ; } - cpu_bits = cpu_dai->driver->capture.sig_bits; + bits =max (pcm_codec->sig_bits, bits); } + pcm_cpu =snd_soc_dai_get_pcm_stream (cpu_dai, stream); + cpu_bits = pcm_cpu->sig_bits; +soc_pcm_set_msb (substream, bits);soc_pcm_set_msb (substream, cpu_bits); }
Signature · 1 line
2.20.1
PATCH 9/13 ASoC: soc-pcm: add snd_soc_dai_get_widget()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
soc-pcm.c has dai_get_widget(), but it can be more generic. This patch renames it to snd_soc_dai_get_widget(), and use it.
--- include/sound/soc-dai.h | 8 ++++++++ sound/soc/intel/skylake/skl-pcm.c | 10 ++-------- sound/soc/soc-dapm.c | 10 ++-------- sound/soc/soc-pcm.c | 17 ++++------------- 4 files changed, 16 insertions(+), 29 deletions(-)
include/sound/soc-dai.h +8 -0
@@ -359,6 +359,14 @@ snd_soc_dai_get_pcm_stream(const struct snd_soc_dai *dai, int stream) &dai->driver->playback : &dai->driver->capture; } +static inline +struct snd_soc_dapm_widget *snd_soc_dai_get_widget ( +struct snd_soc_dai *dai,int stream) +{ +return (stream ==SNDRV_PCM_STREAM_PLAYBACK ) ? + dai->playback_widget : dai->capture_widget; +} +static inline void *snd_soc_dai_get_dma_data (const struct snd_soc_dai *dai,const struct snd_pcm_substream *ss) {
sound/soc/intel/skylake/skl-pcm.c +2 -8
@@ -112,10 +112,7 @@ static void skl_set_suspend_active(struct snd_pcm_substream *substream,struct snd_soc_dapm_widget *w;struct skl_dev *skl =bus_to_skl (bus); -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - w = dai->playback_widget; -else - w = dai->capture_widget; + w =snd_soc_dai_get_widget (dai, substream->stream);if (w->ignore_suspend && enable) skl->supend_active++;
@@ -475,10 +472,7 @@ static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,if (!mconfig)return -EIO ; -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - w = dai->playback_widget; -else - w = dai->capture_widget; + w =snd_soc_dai_get_widget (dai, substream->stream);switch (cmd) {case SNDRV_PCM_TRIGGER_RESUME :
sound/soc/soc-dapm.c +2 -8
@@ -2620,10 +2620,7 @@ static int dapm_update_dai_unlocked(struct snd_pcm_substream *substream,struct snd_soc_dapm_widget *w;int ret; -if (dir ==SNDRV_PCM_STREAM_PLAYBACK ) - w = dai->playback_widget; -else - w = dai->capture_widget; + w =snd_soc_dai_get_widget (dai, dir);if (!w)return 0 ;
@@ -4386,10 +4383,7 @@ static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream,struct snd_soc_dapm_widget *w;unsigned int ep; -if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) - w = dai->playback_widget; -else - w = dai->capture_widget; + w =snd_soc_dai_get_widget (dai, stream);if (w) {dapm_mark_dirty (w,"stream event" );
sound/soc/soc-pcm.c +4 -13
@@ -82,15 +82,6 @@ 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) {
@@ -1242,7 +1233,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,if (!be->dai_link->no_pcm)continue ; - w =dai_get_widget (be->cpu_dai, stream); + w =snd_soc_dai_get_widget (be->cpu_dai, stream);dev_dbg (card->dev,"ASoC: try BE : %s\n" , w ? w->name :"(not set)" );
@@ -1251,7 +1242,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,return be;for_each_rtd_codec_dai (be, i, dai) { - w =dai_get_widget (dai, stream); + w =snd_soc_dai_get_widget (dai, stream);if (w == widget)return be;
@@ -1328,7 +1319,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,unsigned int i;/* is there a valid CPU DAI widget for this BE */ - widget =dai_get_widget (dpcm->be->cpu_dai, stream); + widget =snd_soc_dai_get_widget (dpcm->be->cpu_dai, stream);/* prune the BE if it's no longer in our active list */ if (widget &&widget_in_list (list, widget))
@@ -1337,7 +1328,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,/* is there a valid CODEC DAI widget for this BE */ do_prune =1 ;for_each_rtd_codec_dai (dpcm->be, i, dai) { - widget =dai_get_widget (dai, stream); + widget =snd_soc_dai_get_widget (dai, stream);/* prune the BE if it's no longer in our active list */ if (widget &&widget_in_list (list, widget))
Signature · 1 line
2.17.1
Mark Brown
maintainerApplied "ASoC: soc-pcm: add snd_soc_dai_get_widget()" to the asoc tree
The patch
ASoC: soc-pcm: add snd_soc_dai_get_widget()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
From 0c01f6ca8e4cc1e5505bf4657cf77fbfaa7b0bc2 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Wed, 19 Feb 2020 15:56:41 +0900
Subject: [PATCH] ASoC: soc-pcm: add snd_soc_dai_get_widget()
soc-pcm.c has dai_get_widget(), but it can be more generic. This patch renames it to snd_soc_dai_get_widget(), and use it.
--- include/sound/soc-dai.h | 8 ++++++++ sound/soc/intel/skylake/skl-pcm.c | 10 ++-------- sound/soc/soc-dapm.c | 10 ++-------- sound/soc/soc-pcm.c | 17 ++++------------- 4 files changed, 16 insertions(+), 29 deletions(-)
include/sound/soc-dai.h +8 -0
@@ -359,6 +359,14 @@ snd_soc_dai_get_pcm_stream(const struct snd_soc_dai *dai, int stream) &dai->driver->playback : &dai->driver->capture; } +static inline +struct snd_soc_dapm_widget *snd_soc_dai_get_widget ( +struct snd_soc_dai *dai,int stream) +{ +return (stream ==SNDRV_PCM_STREAM_PLAYBACK ) ? + dai->playback_widget : dai->capture_widget; +} +static inline void *snd_soc_dai_get_dma_data (const struct snd_soc_dai *dai,const struct snd_pcm_substream *ss) {
sound/soc/intel/skylake/skl-pcm.c +2 -8
@@ -112,10 +112,7 @@ static void skl_set_suspend_active(struct snd_pcm_substream *substream,struct snd_soc_dapm_widget *w;struct skl_dev *skl =bus_to_skl (bus); -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - w = dai->playback_widget; -else - w = dai->capture_widget; + w =snd_soc_dai_get_widget (dai, substream->stream);if (w->ignore_suspend && enable) skl->supend_active++;
@@ -475,10 +472,7 @@ static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,if (!mconfig)return -EIO ; -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - w = dai->playback_widget; -else - w = dai->capture_widget; + w =snd_soc_dai_get_widget (dai, substream->stream);switch (cmd) {case SNDRV_PCM_TRIGGER_RESUME :
sound/soc/soc-dapm.c +2 -8
@@ -2620,10 +2620,7 @@ static int dapm_update_dai_unlocked(struct snd_pcm_substream *substream,struct snd_soc_dapm_widget *w;int ret; -if (dir ==SNDRV_PCM_STREAM_PLAYBACK ) - w = dai->playback_widget; -else - w = dai->capture_widget; + w =snd_soc_dai_get_widget (dai, dir);if (!w)return 0 ;
@@ -4389,10 +4386,7 @@ static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream,struct snd_soc_dapm_widget *w;unsigned int ep; -if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) - w = dai->playback_widget; -else - w = dai->capture_widget; + w =snd_soc_dai_get_widget (dai, stream);if (w) {dapm_mark_dirty (w,"stream event" );
sound/soc/soc-pcm.c +4 -13
@@ -82,15 +82,6 @@ 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) {
@@ -1242,7 +1233,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,if (!be->dai_link->no_pcm)continue ; - w =dai_get_widget (be->cpu_dai, stream); + w =snd_soc_dai_get_widget (be->cpu_dai, stream);dev_dbg (card->dev,"ASoC: try BE : %s\n" , w ? w->name :"(not set)" );
@@ -1251,7 +1242,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,return be;for_each_rtd_codec_dai (be, i, dai) { - w =dai_get_widget (dai, stream); + w =snd_soc_dai_get_widget (dai, stream);if (w == widget)return be;
@@ -1326,7 +1317,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,unsigned int i;/* is there a valid CPU DAI widget for this BE */ - widget =dai_get_widget (dpcm->be->cpu_dai, stream); + widget =snd_soc_dai_get_widget (dpcm->be->cpu_dai, stream);/* prune the BE if it's no longer in our active list */ if (widget &&widget_in_list (list, widget))
@@ -1335,7 +1326,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,/* is there a valid CODEC DAI widget for this BE */ do_prune =1 ;for_each_rtd_codec_dai (dpcm->be, i, dai) { - widget =dai_get_widget (dai, stream); + widget =snd_soc_dai_get_widget (dai, stream);/* prune the BE if it's no longer in our active list */ if (widget &&widget_in_list (list, widget))
Signature · 1 line
2.20.1
PATCH 10/13 ASoC: soc-pcm: merge dpcm_run_new/old_update() into dpcm_fe_runtime_update()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
soc-pcm has dpcm_run_new/old_update(), but these are used from dpcm_fe_runtime_update() only, and are very verbose functions. This patch disassembles these.
--- sound/soc/soc-pcm.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-)
sound/soc/soc-pcm.c +7 -28
@@ -2538,37 +2538,12 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)return ret; } -static int dpcm_run_new_update (struct snd_soc_pcm_runtime *fe,int stream) -{ -int ret; - -dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_BE ); - ret =dpcm_run_update_startup (fe, stream); -if (ret <0 ) -dev_err (fe->dev,"ASoC: failed to startup some BEs\n" ); -dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_NO ); - -return ret; -} - -static int dpcm_run_old_update (struct snd_soc_pcm_runtime *fe,int stream) -{ -int ret; - -dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_BE ); - ret =dpcm_run_update_shutdown (fe, stream); -if (ret <0 ) -dev_err (fe->dev,"ASoC: failed to shutdown some BEs\n" ); -dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_NO ); - -return ret; -} -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; +int ret;if (!fe->dai_link->dynamic)return 0 ;
@@ -2605,10 +2580,14 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)/* update any playback/capture paths */ count =dpcm_process_paths (fe, stream, &list, new);if (count) { +dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_BE );if (new) -dpcm_run_new_update (fe, stream); + ret =dpcm_run_update_startup (fe, stream);else -dpcm_run_old_update (fe, stream); + ret =dpcm_run_update_shutdown (fe, stream); +if (ret <0 ) +dev_err (fe->dev,"ASoC: failed to shutdown some BEs\n" ); +dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_NO );dpcm_clear_pending_state (fe, stream);dpcm_be_disconnect (fe, stream);
Signature · 1 line
2.17.1
Mark Brown
maintainerApplied "ASoC: soc-pcm: merge dpcm_run_new/old_update() into dpcm_fe_runtime_update()" to the asoc tree
The patch
ASoC: soc-pcm: merge dpcm_run_new/old_update() into dpcm_fe_runtime_update()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
From 580dff3636d08ed12cb5d5db2fd895cbeffd0fd5 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Wed, 19 Feb 2020 15:56:46 +0900
Subject: [PATCH] ASoC: soc-pcm: merge dpcm_run_new/old_update() into
dpcm_fe_runtime_update()
soc-pcm has dpcm_run_new/old_update(), but these are used from dpcm_fe_runtime_update() only, and are very verbose functions. This patch disassembles these.
--- sound/soc/soc-pcm.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-)
sound/soc/soc-pcm.c +7 -28
@@ -2536,37 +2536,12 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)return ret; } -static int dpcm_run_new_update (struct snd_soc_pcm_runtime *fe,int stream) -{ -int ret; - -dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_BE ); - ret =dpcm_run_update_startup (fe, stream); -if (ret <0 ) -dev_err (fe->dev,"ASoC: failed to startup some BEs\n" ); -dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_NO ); - -return ret; -} - -static int dpcm_run_old_update (struct snd_soc_pcm_runtime *fe,int stream) -{ -int ret; - -dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_BE ); - ret =dpcm_run_update_shutdown (fe, stream); -if (ret <0 ) -dev_err (fe->dev,"ASoC: failed to shutdown some BEs\n" ); -dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_NO ); - -return ret; -} -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; +int ret;if (!fe->dai_link->dynamic)return 0 ;
@@ -2603,10 +2578,14 @@ static int soc_dpcm_fe_runtime_update(struct snd_soc_pcm_runtime *fe, int new)/* update any playback/capture paths */ count =dpcm_process_paths (fe, stream, &list, new);if (count) { +dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_BE );if (new) -dpcm_run_new_update (fe, stream); + ret =dpcm_run_update_startup (fe, stream);else -dpcm_run_old_update (fe, stream); + ret =dpcm_run_update_shutdown (fe, stream); +if (ret <0 ) +dev_err (fe->dev,"ASoC: failed to shutdown some BEs\n" ); +dpcm_set_fe_update_state (fe, stream,SND_SOC_DPCM_UPDATE_NO );dpcm_clear_pending_state (fe, stream);dpcm_be_disconnect (fe, stream);
Signature · 1 line
2.20.1
PATCH 11/13 ASoC: soc-pcm: move dpcm_path_put() to soc-pcm.c
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
dpcm_path_put() (A) is calling kfree(*list).
The freed list is created by dapm_widget_list_create() (B) which is called from snd_soc_dapm_dai_get_connected_widgets() (C) which is called from dpcm_path_get() (D).
(B) dapm_widget_list_create(**list, ...)
{
...
=> *list = kzalloc();
...
}(C) snd_soc_dapm_dai_get_connected_widgets(..., **list, ...)
{
...
dapm_widget_list_create(list, ...);
...
}(D) dpcm_path_get(..., **list)
{
...
snd_soc_dapm_dai_get_connected_widgets(..., list, ...);
...
}(A) dpcm_path_put(**list)
{
=> kfree(*list);
}This kind of unbalance code is very difficult to read/understand.
To avoid this issue, this patch adds each missing paired functiondapm_widget_list_free() for dapm_widget_list_create() (B), andsnd_soc_dapm_dai_free_widgets() for snd_soc_dapm_dai_get_connected_widgets() (C).
This patch uses these, and moves dpcm_path_put() next to dpcm_path_get().
--- include/sound/soc-dapm.h | 1 + include/sound/soc-dpcm.h | 7 +------ sound/soc/soc-dapm.c | 10 ++++++++++ sound/soc/soc-pcm.c | 5 +++++ 4 files changed, 17 insertions(+), 6 deletions(-)
include/sound/soc-dapm.h +1 -0
@@ -484,6 +484,7 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream,struct snd_soc_dapm_widget_list **list, bool (*custom_stop_condition)(struct snd_soc_dapm_widget *, enum snd_soc_dapm_direction)); +void snd_soc_dapm_dai_free_widgets (struct snd_soc_dapm_widget_list **list);struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm (struct snd_kcontrol *kcontrol);
include/sound/soc-dpcm.h +1 -6
@@ -145,6 +145,7 @@ static inline void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd)int dpcm_path_get (struct snd_soc_pcm_runtime *fe,int stream,struct snd_soc_dapm_widget_list **list_); +void dpcm_path_put (struct snd_soc_dapm_widget_list **list);int dpcm_process_paths (struct snd_soc_pcm_runtime *fe,int stream,struct snd_soc_dapm_widget_list **list,int new);int dpcm_be_dai_startup (struct snd_soc_pcm_runtime *fe,int stream);
@@ -158,10 +159,4 @@ int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream);int dpcm_dapm_stream_event (struct snd_soc_pcm_runtime *fe,int dir,int event); -static inline void dpcm_path_put (struct snd_soc_dapm_widget_list **list) -{ -kfree (*list); -} - -#endif
sound/soc/soc-dapm.c +10 -0
@@ -1105,6 +1105,11 @@ static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget) } } +static void dapm_widget_list_free (struct snd_soc_dapm_widget_list **list) +{ +kfree (*list); +} +static int dapm_widget_list_create (struct snd_soc_dapm_widget_list **list,struct list_head *widgets) {
@@ -1310,6 +1315,11 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream,return paths; } +void snd_soc_dapm_dai_free_widgets (struct snd_soc_dapm_widget_list **list) +{ +dapm_widget_list_free (list); +} +/* * Handler for regulator supply widget. */
sound/soc/soc-pcm.c +5 -0
@@ -1304,6 +1304,11 @@ int dpcm_path_get(struct snd_soc_pcm_runtime *fe,return paths; } +void dpcm_path_put (struct snd_soc_dapm_widget_list **list) +{ +snd_soc_dapm_dai_free_widgets (list); +} +static int dpcm_prune_paths (struct snd_soc_pcm_runtime *fe,int stream,struct snd_soc_dapm_widget_list **list_) {
Signature · 1 line
2.17.1
Mark Brown
maintainerApplied "ASoC: soc-pcm: move dpcm_path_put() to soc-pcm.c" to the asoc tree
The patch
ASoC: soc-pcm: move dpcm_path_put() to soc-pcm.c
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
From 52645e332d227a3d3cd345e97a10d99b7e80fae4 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Wed, 19 Feb 2020 15:56:52 +0900
Subject: [PATCH] ASoC: soc-pcm: move dpcm_path_put() to soc-pcm.c
dpcm_path_put() (A) is calling kfree(*list).
The freed list is created by dapm_widget_list_create() (B) which is called from snd_soc_dapm_dai_get_connected_widgets() (C) which is called from dpcm_path_get() (D).
(B) dapm_widget_list_create(**list, ...)
{
...
=> *list = kzalloc();
...
}(C) snd_soc_dapm_dai_get_connected_widgets(..., **list, ...)
{
...
dapm_widget_list_create(list, ...);
...
}(D) dpcm_path_get(..., **list)
{
...
snd_soc_dapm_dai_get_connected_widgets(..., list, ...);
...
}(A) dpcm_path_put(**list)
{
=> kfree(*list);
}This kind of unbalance code is very difficult to read/understand.
To avoid this issue, this patch adds each missing paired functiondapm_widget_list_free() for dapm_widget_list_create() (B), andsnd_soc_dapm_dai_free_widgets() for snd_soc_dapm_dai_get_connected_widgets() (C).
This patch uses these, and moves dpcm_path_put() next to dpcm_path_get().
--- include/sound/soc-dapm.h | 1 + include/sound/soc-dpcm.h | 7 +------ sound/soc/soc-dapm.c | 10 ++++++++++ sound/soc/soc-pcm.c | 5 +++++ 4 files changed, 17 insertions(+), 6 deletions(-)
include/sound/soc-dapm.h +1 -0
@@ -484,6 +484,7 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream,struct snd_soc_dapm_widget_list **list, bool (*custom_stop_condition)(struct snd_soc_dapm_widget *, enum snd_soc_dapm_direction)); +void snd_soc_dapm_dai_free_widgets (struct snd_soc_dapm_widget_list **list);struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm (struct snd_kcontrol *kcontrol);
include/sound/soc-dpcm.h +1 -6
@@ -145,6 +145,7 @@ static inline void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd)int dpcm_path_get (struct snd_soc_pcm_runtime *fe,int stream,struct snd_soc_dapm_widget_list **list_); +void dpcm_path_put (struct snd_soc_dapm_widget_list **list);int dpcm_process_paths (struct snd_soc_pcm_runtime *fe,int stream,struct snd_soc_dapm_widget_list **list,int new);int dpcm_be_dai_startup (struct snd_soc_pcm_runtime *fe,int stream);
@@ -158,10 +159,4 @@ int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream);int dpcm_dapm_stream_event (struct snd_soc_pcm_runtime *fe,int dir,int event); -static inline void dpcm_path_put (struct snd_soc_dapm_widget_list **list) -{ -kfree (*list); -} - -#endif
sound/soc/soc-dapm.c +10 -0
@@ -1105,6 +1105,11 @@ static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget) } } +static void dapm_widget_list_free (struct snd_soc_dapm_widget_list **list) +{ +kfree (*list); +} +static int dapm_widget_list_create (struct snd_soc_dapm_widget_list **list,struct list_head *widgets) {
@@ -1310,6 +1315,11 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream,return paths; } +void snd_soc_dapm_dai_free_widgets (struct snd_soc_dapm_widget_list **list) +{ +dapm_widget_list_free (list); +} +/* * Handler for regulator supply widget. */
sound/soc/soc-pcm.c +5 -0
@@ -1302,6 +1302,11 @@ int dpcm_path_get(struct snd_soc_pcm_runtime *fe,return paths; } +void dpcm_path_put (struct snd_soc_dapm_widget_list **list) +{ +snd_soc_dapm_dai_free_widgets (list); +} +static int dpcm_prune_paths (struct snd_soc_pcm_runtime *fe,int stream,struct snd_soc_dapm_widget_list **list_) {
Signature · 1 line
2.20.1
PATCH 12/13 ASoC: soc-pcm: move CONFIG_DEBUG_FS functions to top side
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
This is prepare for CONFIG_DEBUG_FS cleanup
--- sound/soc/soc-pcm.c | 276 ++++++++++++++++++++++---------------------- 1 file changed, 138 insertions(+), 138 deletions(-)
sound/soc/soc-pcm.c +138 -138
@@ -28,6 +28,144 @@#define DPCM_MAX_BE_USERS 8 +#ifdef CONFIG_DEBUG_FS +static const char *dpcm_state_string (enum snd_soc_dpcm_state state) +{ +switch (state) { +case SND_SOC_DPCM_STATE_NEW : +return "new" ; +case SND_SOC_DPCM_STATE_OPEN : +return "open" ; +case SND_SOC_DPCM_STATE_HW_PARAMS : +return "hw_params" ; +case SND_SOC_DPCM_STATE_PREPARE : +return "prepare" ; +case SND_SOC_DPCM_STATE_START : +return "start" ; +case SND_SOC_DPCM_STATE_STOP : +return "stop" ; +case SND_SOC_DPCM_STATE_SUSPEND : +return "suspend" ; +case SND_SOC_DPCM_STATE_PAUSED : +return "paused" ; +case SND_SOC_DPCM_STATE_HW_FREE : +return "hw_free" ; +case SND_SOC_DPCM_STATE_CLOSE : +return "close" ; + } + +return "unknown" ; +} + +static ssize_t dpcm_show_state (struct snd_soc_pcm_runtime *fe, +int stream,char *buf,size_t size) +{ +struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; +struct snd_soc_dpcm *dpcm; +ssize_t offset =0 ; +unsigned long flags; + +/* FE state */ + offset +=snprintf (buf + offset, size - offset, +"[%s - %s]\n" , fe->dai_link->name, + stream ?"Capture" :"Playback" ); + + offset +=snprintf (buf + offset, size - offset,"State: %s\n" , +dpcm_state_string (fe->dpcm[stream].state)); + +if ((fe->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && + (fe->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) + offset +=snprintf (buf + offset, size - offset, +"Hardware Params: " +"Format = %s, Channels = %d, Rate = %d\n" , +snd_pcm_format_name (params_format (params)), +params_channels (params), +params_rate (params)); + +/* BEs state */ + offset +=snprintf (buf + offset, size - offset,"Backends:\n" ); + +if (list_empty (&fe->dpcm[stream].be_clients)) { + offset +=snprintf (buf + offset, size - offset, +" No active DSP links\n" ); + goto out; + } + +spin_lock_irqsave (&fe->card->dpcm_lock, flags); +for_each_dpcm_be (fe, stream, dpcm) { +struct snd_soc_pcm_runtime *be = dpcm->be; + params = &dpcm->hw_params; + + offset +=snprintf (buf + offset, size - offset, +"- %s\n" , be->dai_link->name); + + offset +=snprintf (buf + offset, size - offset, +" State: %s\n" , +dpcm_state_string (be->dpcm[stream].state)); + +if ((be->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && + (be->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) + offset +=snprintf (buf + offset, size - offset, +" Hardware Params: " +"Format = %s, Channels = %d, Rate = %d\n" , +snd_pcm_format_name (params_format (params)), +params_channels (params), +params_rate (params)); + } +spin_unlock_irqrestore (&fe->card->dpcm_lock, flags); +out: +return offset; +} + +static ssize_t dpcm_state_read_file (struct file *file,char __user *user_buf, +size_t count,loff_t *ppos) +{ +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 ; + +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); + +kfree (buf); +return ret; +} + +static const struct file_operations dpcm_state_fops = { + .open = simple_open, + .read = dpcm_state_read_file, + .llseek = default_llseek, +}; + +void soc_dpcm_debugfs_add (struct snd_soc_pcm_runtime *rtd) +{ +if (!rtd->dai_link) +return ; + +if (!rtd->dai_link->dynamic) +return ; + +if (!rtd->card->debugfs_card_root) +return ; + + rtd->debugfs_dpcm_root =debugfs_create_dir (rtd->dai_link->name, + rtd->card->debugfs_card_root); + +debugfs_create_file ("state" ,0444 , rtd->debugfs_dpcm_root, + rtd, &dpcm_state_fops); +} +#endif +static int soc_rtd_startup (struct snd_soc_pcm_runtime *rtd,struct snd_pcm_substream *substream) {
@@ -2932,141 +3070,3 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,return snd_soc_dpcm_check_state (fe, be, stream, state,ARRAY_SIZE (state)); }EXPORT_SYMBOL_GPL (snd_soc_dpcm_can_be_params); - -#ifdef CONFIG_DEBUG_FS -static const char *dpcm_state_string (enum snd_soc_dpcm_state state) -{ -switch (state) { -case SND_SOC_DPCM_STATE_NEW : -return "new" ; -case SND_SOC_DPCM_STATE_OPEN : -return "open" ; -case SND_SOC_DPCM_STATE_HW_PARAMS : -return "hw_params" ; -case SND_SOC_DPCM_STATE_PREPARE : -return "prepare" ; -case SND_SOC_DPCM_STATE_START : -return "start" ; -case SND_SOC_DPCM_STATE_STOP : -return "stop" ; -case SND_SOC_DPCM_STATE_SUSPEND : -return "suspend" ; -case SND_SOC_DPCM_STATE_PAUSED : -return "paused" ; -case SND_SOC_DPCM_STATE_HW_FREE : -return "hw_free" ; -case SND_SOC_DPCM_STATE_CLOSE : -return "close" ; - } - -return "unknown" ; -} - -static ssize_t dpcm_show_state (struct snd_soc_pcm_runtime *fe, -int stream,char *buf,size_t size) -{ -struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; -struct snd_soc_dpcm *dpcm; -ssize_t offset =0 ; -unsigned long flags; - -/* FE state */ - offset +=snprintf (buf + offset, size - offset, -"[%s - %s]\n" , fe->dai_link->name, - stream ?"Capture" :"Playback" ); - - offset +=snprintf (buf + offset, size - offset,"State: %s\n" , -dpcm_state_string (fe->dpcm[stream].state)); - -if ((fe->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && - (fe->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) - offset +=snprintf (buf + offset, size - offset, -"Hardware Params: " -"Format = %s, Channels = %d, Rate = %d\n" , -snd_pcm_format_name (params_format (params)), -params_channels (params), -params_rate (params)); - -/* BEs state */ - offset +=snprintf (buf + offset, size - offset,"Backends:\n" ); - -if (list_empty (&fe->dpcm[stream].be_clients)) { - offset +=snprintf (buf + offset, size - offset, -" No active DSP links\n" ); - goto out; - } - -spin_lock_irqsave (&fe->card->dpcm_lock, flags); -for_each_dpcm_be (fe, stream, dpcm) { -struct snd_soc_pcm_runtime *be = dpcm->be; - params = &dpcm->hw_params; - - offset +=snprintf (buf + offset, size - offset, -"- %s\n" , be->dai_link->name); - - offset +=snprintf (buf + offset, size - offset, -" State: %s\n" , -dpcm_state_string (be->dpcm[stream].state)); - -if ((be->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && - (be->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) - offset +=snprintf (buf + offset, size - offset, -" Hardware Params: " -"Format = %s, Channels = %d, Rate = %d\n" , -snd_pcm_format_name (params_format (params)), -params_channels (params), -params_rate (params)); - } -spin_unlock_irqrestore (&fe->card->dpcm_lock, flags); -out: -return offset; -} - -static ssize_t dpcm_state_read_file (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) -{ -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 ; - -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); - -kfree (buf); -return ret; -} - -static const struct file_operations dpcm_state_fops = { - .open = simple_open, - .read = dpcm_state_read_file, - .llseek = default_llseek, -}; - -void soc_dpcm_debugfs_add (struct snd_soc_pcm_runtime *rtd) -{ -if (!rtd->dai_link) -return ; - -if (!rtd->dai_link->dynamic) -return ; - -if (!rtd->card->debugfs_card_root) -return ; - - rtd->debugfs_dpcm_root =debugfs_create_dir (rtd->dai_link->name, - rtd->card->debugfs_card_root); - -debugfs_create_file ("state" ,0444 , rtd->debugfs_dpcm_root, - rtd, &dpcm_state_fops); -} -#endif
Signature · 1 line
2.17.1
Mark Brown
maintainerApplied "ASoC: soc-pcm: move CONFIG_DEBUG_FS functions to top side" to the asoc tree
The patch
ASoC: soc-pcm: move CONFIG_DEBUG_FS functions to top side
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
From c3212829f812a4ac0c6078978c109c6f1ff882c2 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Wed, 19 Feb 2020 15:56:57 +0900
Subject: [PATCH] ASoC: soc-pcm: move CONFIG_DEBUG_FS functions to top side
This is prepare for CONFIG_DEBUG_FS cleanup
--- sound/soc/soc-pcm.c | 276 ++++++++++++++++++++++---------------------- 1 file changed, 138 insertions(+), 138 deletions(-)
sound/soc/soc-pcm.c +138 -138
@@ -28,6 +28,144 @@#define DPCM_MAX_BE_USERS 8 +#ifdef CONFIG_DEBUG_FS +static const char *dpcm_state_string (enum snd_soc_dpcm_state state) +{ +switch (state) { +case SND_SOC_DPCM_STATE_NEW : +return "new" ; +case SND_SOC_DPCM_STATE_OPEN : +return "open" ; +case SND_SOC_DPCM_STATE_HW_PARAMS : +return "hw_params" ; +case SND_SOC_DPCM_STATE_PREPARE : +return "prepare" ; +case SND_SOC_DPCM_STATE_START : +return "start" ; +case SND_SOC_DPCM_STATE_STOP : +return "stop" ; +case SND_SOC_DPCM_STATE_SUSPEND : +return "suspend" ; +case SND_SOC_DPCM_STATE_PAUSED : +return "paused" ; +case SND_SOC_DPCM_STATE_HW_FREE : +return "hw_free" ; +case SND_SOC_DPCM_STATE_CLOSE : +return "close" ; + } + +return "unknown" ; +} + +static ssize_t dpcm_show_state (struct snd_soc_pcm_runtime *fe, +int stream,char *buf,size_t size) +{ +struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; +struct snd_soc_dpcm *dpcm; +ssize_t offset =0 ; +unsigned long flags; + +/* FE state */ + offset +=snprintf (buf + offset, size - offset, +"[%s - %s]\n" , fe->dai_link->name, + stream ?"Capture" :"Playback" ); + + offset +=snprintf (buf + offset, size - offset,"State: %s\n" , +dpcm_state_string (fe->dpcm[stream].state)); + +if ((fe->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && + (fe->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) + offset +=snprintf (buf + offset, size - offset, +"Hardware Params: " +"Format = %s, Channels = %d, Rate = %d\n" , +snd_pcm_format_name (params_format (params)), +params_channels (params), +params_rate (params)); + +/* BEs state */ + offset +=snprintf (buf + offset, size - offset,"Backends:\n" ); + +if (list_empty (&fe->dpcm[stream].be_clients)) { + offset +=snprintf (buf + offset, size - offset, +" No active DSP links\n" ); + goto out; + } + +spin_lock_irqsave (&fe->card->dpcm_lock, flags); +for_each_dpcm_be (fe, stream, dpcm) { +struct snd_soc_pcm_runtime *be = dpcm->be; + params = &dpcm->hw_params; + + offset +=snprintf (buf + offset, size - offset, +"- %s\n" , be->dai_link->name); + + offset +=snprintf (buf + offset, size - offset, +" State: %s\n" , +dpcm_state_string (be->dpcm[stream].state)); + +if ((be->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && + (be->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) + offset +=snprintf (buf + offset, size - offset, +" Hardware Params: " +"Format = %s, Channels = %d, Rate = %d\n" , +snd_pcm_format_name (params_format (params)), +params_channels (params), +params_rate (params)); + } +spin_unlock_irqrestore (&fe->card->dpcm_lock, flags); +out: +return offset; +} + +static ssize_t dpcm_state_read_file (struct file *file,char __user *user_buf, +size_t count,loff_t *ppos) +{ +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 ; + +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); + +kfree (buf); +return ret; +} + +static const struct file_operations dpcm_state_fops = { + .open = simple_open, + .read = dpcm_state_read_file, + .llseek = default_llseek, +}; + +void soc_dpcm_debugfs_add (struct snd_soc_pcm_runtime *rtd) +{ +if (!rtd->dai_link) +return ; + +if (!rtd->dai_link->dynamic) +return ; + +if (!rtd->card->debugfs_card_root) +return ; + + rtd->debugfs_dpcm_root =debugfs_create_dir (rtd->dai_link->name, + rtd->card->debugfs_card_root); + +debugfs_create_file ("state" ,0444 , rtd->debugfs_dpcm_root, + rtd, &dpcm_state_fops); +} +#endif +static int soc_rtd_startup (struct snd_soc_pcm_runtime *rtd,struct snd_pcm_substream *substream) {
@@ -2930,141 +3068,3 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,return snd_soc_dpcm_check_state (fe, be, stream, state,ARRAY_SIZE (state)); }EXPORT_SYMBOL_GPL (snd_soc_dpcm_can_be_params); - -#ifdef CONFIG_DEBUG_FS -static const char *dpcm_state_string (enum snd_soc_dpcm_state state) -{ -switch (state) { -case SND_SOC_DPCM_STATE_NEW : -return "new" ; -case SND_SOC_DPCM_STATE_OPEN : -return "open" ; -case SND_SOC_DPCM_STATE_HW_PARAMS : -return "hw_params" ; -case SND_SOC_DPCM_STATE_PREPARE : -return "prepare" ; -case SND_SOC_DPCM_STATE_START : -return "start" ; -case SND_SOC_DPCM_STATE_STOP : -return "stop" ; -case SND_SOC_DPCM_STATE_SUSPEND : -return "suspend" ; -case SND_SOC_DPCM_STATE_PAUSED : -return "paused" ; -case SND_SOC_DPCM_STATE_HW_FREE : -return "hw_free" ; -case SND_SOC_DPCM_STATE_CLOSE : -return "close" ; - } - -return "unknown" ; -} - -static ssize_t dpcm_show_state (struct snd_soc_pcm_runtime *fe, -int stream,char *buf,size_t size) -{ -struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; -struct snd_soc_dpcm *dpcm; -ssize_t offset =0 ; -unsigned long flags; - -/* FE state */ - offset +=snprintf (buf + offset, size - offset, -"[%s - %s]\n" , fe->dai_link->name, - stream ?"Capture" :"Playback" ); - - offset +=snprintf (buf + offset, size - offset,"State: %s\n" , -dpcm_state_string (fe->dpcm[stream].state)); - -if ((fe->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && - (fe->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) - offset +=snprintf (buf + offset, size - offset, -"Hardware Params: " -"Format = %s, Channels = %d, Rate = %d\n" , -snd_pcm_format_name (params_format (params)), -params_channels (params), -params_rate (params)); - -/* BEs state */ - offset +=snprintf (buf + offset, size - offset,"Backends:\n" ); - -if (list_empty (&fe->dpcm[stream].be_clients)) { - offset +=snprintf (buf + offset, size - offset, -" No active DSP links\n" ); - goto out; - } - -spin_lock_irqsave (&fe->card->dpcm_lock, flags); -for_each_dpcm_be (fe, stream, dpcm) { -struct snd_soc_pcm_runtime *be = dpcm->be; - params = &dpcm->hw_params; - - offset +=snprintf (buf + offset, size - offset, -"- %s\n" , be->dai_link->name); - - offset +=snprintf (buf + offset, size - offset, -" State: %s\n" , -dpcm_state_string (be->dpcm[stream].state)); - -if ((be->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && - (be->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) - offset +=snprintf (buf + offset, size - offset, -" Hardware Params: " -"Format = %s, Channels = %d, Rate = %d\n" , -snd_pcm_format_name (params_format (params)), -params_channels (params), -params_rate (params)); - } -spin_unlock_irqrestore (&fe->card->dpcm_lock, flags); -out: -return offset; -} - -static ssize_t dpcm_state_read_file (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) -{ -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 ; - -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); - -kfree (buf); -return ret; -} - -static const struct file_operations dpcm_state_fops = { - .open = simple_open, - .read = dpcm_state_read_file, - .llseek = default_llseek, -}; - -void soc_dpcm_debugfs_add (struct snd_soc_pcm_runtime *rtd) -{ -if (!rtd->dai_link) -return ; - -if (!rtd->dai_link->dynamic) -return ; - -if (!rtd->card->debugfs_card_root) -return ; - - rtd->debugfs_dpcm_root =debugfs_create_dir (rtd->dai_link->name, - rtd->card->debugfs_card_root); - -debugfs_create_file ("state" ,0444 , rtd->debugfs_dpcm_root, - rtd, &dpcm_state_fops); -} -#endif
Signature · 1 line
2.20.1
PATCH 13/13 ASoC: soc-pcm: add dpcm_create/remove_debugfs_state()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
soc-pcm.c has implementation which depends on CONFIG_DEBUG_FS. But, we don't want to have random #ifdef.
This patch adds dpcm_create/remove_debugfs_state() and care it.
--- sound/soc/soc-pcm.c | 51 ++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 17 deletions(-)
sound/soc/soc-pcm.c +34 -17
@@ -164,6 +164,36 @@ void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd)debugfs_create_file ("state" ,0444 , rtd->debugfs_dpcm_root, rtd, &dpcm_state_fops); } + +static void dpcm_create_debugfs_state (struct snd_soc_dpcm *dpcm,int stream) +{ +char *name; + + name =kasprintf (GFP_KERNEL ,"%s:%s" , dpcm->be->dai_link->name, + stream ?"capture" :"playback" ); +if (name) { + dpcm->debugfs_state =debugfs_create_dir ( + name, dpcm->fe->debugfs_dpcm_root); +debugfs_create_u32 ("state" ,0644 , dpcm->debugfs_state, + &dpcm->state); +kfree (name); + } +} + +static void dpcm_remove_debugfs_state (struct snd_soc_dpcm *dpcm) +{ +debugfs_remove_recursive (dpcm->debugfs_state); +} + +#else +static inline void dpcm_create_debugfs_state (struct snd_soc_dpcm *dpcm, +int stream) +{ +} + +static inline void dpcm_remove_debugfs_state (struct snd_soc_dpcm *dpcm) +{ +}#endif static int soc_rtd_startup(struct snd_soc_pcm_runtime *rtd,
@@ -1254,9 +1284,6 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, {struct snd_soc_dpcm *dpcm;unsigned long flags; -#ifdef CONFIG_DEBUG_FS -char *name; -#endif /* only add new dpcms */ for_each_dpcm_be (fe, stream, dpcm) {
@@ -1281,17 +1308,8 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, stream ?"capture" :"playback" , fe->dai_link->name, stream ? "<-" : "->", be->dai_link->name); -#ifdef CONFIG_DEBUG_FS - name =kasprintf (GFP_KERNEL ,"%s:%s" , be->dai_link->name, - stream ?"capture" :"playback" ); -if (name) { - dpcm->debugfs_state =debugfs_create_dir (name, - fe->debugfs_dpcm_root); -debugfs_create_u32 ("state" ,0644 , dpcm->debugfs_state, - &dpcm->state); -kfree (name); - } -#endif +dpcm_create_debugfs_state (dpcm, stream); +return 1 ; }
@@ -1344,9 +1362,8 @@ void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)/* BEs still alive need new FE */ dpcm_be_reparent (fe, dpcm->be, stream); -#ifdef CONFIG_DEBUG_FS -debugfs_remove_recursive (dpcm->debugfs_state); -#endif +dpcm_remove_debugfs_state (dpcm); +spin_lock_irqsave (&fe->card->dpcm_lock, flags);list_del (&dpcm->list_be);list_del (&dpcm->list_fe);
Signature · 1 line
2.17.1
Mark Brown
maintainerApplied "ASoC: soc-pcm: add dpcm_create/remove_debugfs_state()" to the asoc tree
The patch
ASoC: soc-pcm: add dpcm_create/remove_debugfs_state()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
From 154dae87e73faa6d56265f22cae16dcdcea3dbb0 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Wed, 19 Feb 2020 15:57:06 +0900
Subject: [PATCH] ASoC: soc-pcm: add dpcm_create/remove_debugfs_state()
soc-pcm.c has implementation which depends on CONFIG_DEBUG_FS. But, we don't want to have random #ifdef.
This patch adds dpcm_create/remove_debugfs_state() and care it.
--- sound/soc/soc-pcm.c | 51 ++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 17 deletions(-)
sound/soc/soc-pcm.c +34 -17
@@ -164,6 +164,36 @@ void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd)debugfs_create_file ("state" ,0444 , rtd->debugfs_dpcm_root, rtd, &dpcm_state_fops); } + +static void dpcm_create_debugfs_state (struct snd_soc_dpcm *dpcm,int stream) +{ +char *name; + + name =kasprintf (GFP_KERNEL ,"%s:%s" , dpcm->be->dai_link->name, + stream ?"capture" :"playback" ); +if (name) { + dpcm->debugfs_state =debugfs_create_dir ( + name, dpcm->fe->debugfs_dpcm_root); +debugfs_create_u32 ("state" ,0644 , dpcm->debugfs_state, + &dpcm->state); +kfree (name); + } +} + +static void dpcm_remove_debugfs_state (struct snd_soc_dpcm *dpcm) +{ +debugfs_remove_recursive (dpcm->debugfs_state); +} + +#else +static inline void dpcm_create_debugfs_state (struct snd_soc_dpcm *dpcm, +int stream) +{ +} + +static inline void dpcm_remove_debugfs_state (struct snd_soc_dpcm *dpcm) +{ +}#endif static int soc_rtd_startup(struct snd_soc_pcm_runtime *rtd,
@@ -1254,9 +1284,6 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, {struct snd_soc_dpcm *dpcm;unsigned long flags; -#ifdef CONFIG_DEBUG_FS -char *name; -#endif /* only add new dpcms */ for_each_dpcm_be (fe, stream, dpcm) {
@@ -1281,17 +1308,8 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, stream ?"capture" :"playback" , fe->dai_link->name, stream ? "<-" : "->", be->dai_link->name); -#ifdef CONFIG_DEBUG_FS - name =kasprintf (GFP_KERNEL ,"%s:%s" , be->dai_link->name, - stream ?"capture" :"playback" ); -if (name) { - dpcm->debugfs_state =debugfs_create_dir (name, - fe->debugfs_dpcm_root); -debugfs_create_u32 ("state" ,0644 , dpcm->debugfs_state, - &dpcm->state); -kfree (name); - } -#endif +dpcm_create_debugfs_state (dpcm, stream); +return 1 ; }
@@ -1344,9 +1362,8 @@ void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)/* BEs still alive need new FE */ dpcm_be_reparent (fe, dpcm->be, stream); -#ifdef CONFIG_DEBUG_FS -debugfs_remove_recursive (dpcm->debugfs_state); -#endif +dpcm_remove_debugfs_state (dpcm); +spin_lock_irqsave (&fe->card->dpcm_lock, flags);list_del (&dpcm->list_be);list_del (&dpcm->list_fe);
Signature · 1 line
2.20.1