From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
To: lgirdwood@gmail.com, broonie@kernel.org
Cc: linux-sound@vger.kernel.org, kai.vehmanen@linux.intel.com,
ranjani.sridharan@linux.intel.com,
yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev,
shengjiu.wang@nxp.com
Subject: [PATCH] ASoC: soc-pcm: Preserve hw parameters from components in dpcm_runtime_setup_fe
Date: Thu, 23 Oct 2025 11:14:04 +0300 [thread overview]
Message-ID: <20251023081404.3740-1-peter.ujfalusi@linux.intel.com> (raw)
Component drivers can prepare snd_pcm_hardware struct based on the hardware
capabilities which information should not be discarded.
Only touch the rates, channels_max and formats if they were left to 0,
otherwise keep the provided configuration intact for the parameter cross
checking decision.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
Hi,
Changes since RFC [1]:
- move the hw parameter initialization/preserve code inline to
dpcm_runtime_setup_fe
this patch in essence extends the special casing of formats done by
083a25b18d6a ("ASoC: soc-pcm: fix hw->formats cleared by soc_pcm_hw_init() for dpcm")
Other parameters might have been set in the same way as the formats
and preserving these are equally important.
A case for this is SOF used with HDA codec (analog or more importantly, HDMI)
where the hw-> params are set based on the connected display/device and
should be preserved so we can report correct rate, format and channels
supported by the equipment.
If the hw-> parameters are left uninitialized then we still need to
set the UINT/ULLONG_MAX for the refining code to work.
This applies only for FE setup, in other cases we shall (as before) do
a full re-initialization.
I think this makes sense and I cannot think where this might flop, but
sent as RFC to see what people think.
Br,
Peter
[1] https://lore.kernel.org/linux-sound/20251020073750.27784-1-peter.ujfalusi@linux.intel.com/
sound/soc/soc-pcm.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 2c21fd528afd..0877daab7b38 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1738,13 +1738,21 @@ static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream)
struct snd_pcm_hardware *hw = &runtime->hw;
struct snd_soc_dai *dai;
int stream = substream->stream;
- u64 formats = hw->formats;
int i;
- soc_pcm_hw_init(hw);
-
- if (formats)
- hw->formats &= formats;
+ /*
+ * Initialize only pcm hardware patameters that has not been initialized
+ * and preserve the configuration which might have been provided by
+ * component drivers
+ */
+ if (!hw->rates)
+ hw->rates = UINT_MAX;
+ if (!hw->rate_max)
+ hw->rate_max = UINT_MAX;
+ if (!hw->channels_max)
+ hw->channels_max = UINT_MAX;
+ if (!hw->formats)
+ hw->formats = ULLONG_MAX;
for_each_rtd_cpu_dais(fe, i, dai) {
const struct snd_soc_pcm_stream *cpu_stream;
--
2.51.1.dirty
next reply other threads:[~2025-10-23 8:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 8:14 Peter Ujfalusi [this message]
2025-10-27 6:11 ` [PATCH] ASoC: soc-pcm: Preserve hw parameters from components in dpcm_runtime_setup_fe Kuninori Morimoto
2025-10-27 6:20 ` Péter Ujfalusi
2025-10-27 6:54 ` Kuninori Morimoto
2025-10-27 7:07 ` Péter Ujfalusi
2025-10-28 21:57 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251023081404.3740-1-peter.ujfalusi@linux.intel.com \
--to=peter.ujfalusi@linux.intel.com \
--cc=broonie@kernel.org \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-sound@vger.kernel.org \
--cc=pierre-louis.bossart@linux.dev \
--cc=ranjani.sridharan@linux.intel.com \
--cc=shengjiu.wang@nxp.com \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox