Linux Sound subsystem development
 help / color / mirror / Atom feed
From: "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: lgirdwood@gmail.com, broonie@kernel.org,
	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: Re: [PATCH] ASoC: soc-pcm: Preserve hw parameters from components in dpcm_runtime_setup_fe
Date: Mon, 27 Oct 2025 08:20:26 +0200	[thread overview]
Message-ID: <25cbc999-bb13-453f-8210-c0fd38866d2d@linux.intel.com> (raw)
In-Reply-To: <87pla8oowa.wl-kuninori.morimoto.gx@renesas.com>

Hi Morimoto-san,

On 27/10/2025 08:11, Kuninori Morimoto wrote:
> 
> Hi Peter
> 
> Thank you for the patch
> 
>> 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>
>> ---
> (snip)
>> -	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;
> 
> soc_pcm_hw_init() is used from only 2 functions
> 
> 	(a) snd_soc_runtime_calc_hw()
> 	(b) dpcm_runtime_setup_fe()
> 
> And this patch fixed not to use it in (b).
> Setting same variable in multiple method is not good idea, IMO.
> 
> How about like this ?

This is how the RFC was done, but decided to not modify
soc_pcm_hw_init() with an added bool.
Other option would be to add a new function which would do only
conditional initialization.

https://lore.kernel.org/linux-sound/20251020073750.27784-1-peter.ujfalusi@linux.intel.com/

> 
> 	static void soc_pcm_hw_init(struct snd_pcm_hardware *hw, boot force)
> 	{
> 		if (force || !hw->rates)
> 			hw->rates		= UINT_MAX;
> 		if (force || !hw->rate_max)
> 			hw->rate_max		= UINT_MAX;
> 		if (force || !hw->channels_max)
> 			hw->channels_max	= UINT_MAX;
> 		if (force || !hw->formats)
> 			hw->formats		= ULLONG_MAX;
> 
> 		hw->rate_min		= 0;
> 		hw->channels_min	= 0;

This way we would loose the rate_min, channel_min from components, see
my RFC which covers this, but it is using reverse condition (preserve vs
force).
The force boolean might be better than the preserve_config as parameter
if the preference is to modify the soc_pcm_hw_init()

> 	}
> 
> 	int snd_soc_runtime_calc_hw(...)
> 	{
> 		...
> 		soc_pcm_hw_init(hw, true);
> 		...
> 	}
> 
> 	int dpcm_runtime_setup_fe(...)
> 	{
> 		...
> 		soc_pcm_hw_init(hw, false);
> 		...
> 	}
> 
> 
> Thank you for your help !!
> 
> Best regards
> ---
> Kuninori Morimoto

-- 
Péter


  reply	other threads:[~2025-10-27  6:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23  8:14 [PATCH] ASoC: soc-pcm: Preserve hw parameters from components in dpcm_runtime_setup_fe Peter Ujfalusi
2025-10-27  6:11 ` Kuninori Morimoto
2025-10-27  6:20   ` Péter Ujfalusi [this message]
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=25cbc999-bb13-453f-8210-c0fd38866d2d@linux.intel.com \
    --to=peter.ujfalusi@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=kuninori.morimoto.gx@renesas.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