From: Cezary Rojewski <cezary.rojewski@intel.com>
To: Jaroslav Kysela <perex@perex.cz>, <broonie@kernel.org>, <tiwai@suse.com>
Cc: <alsa-devel@alsa-project.org>,
<amadeuszx.slawinski@linux.intel.com>,
<pierre-louis.bossart@linux.intel.com>, <hdegoede@redhat.com>,
<linux-sound@vger.kernel.org>
Subject: Re: [PATCH v2 01/17] ALSA: pcm: Introduce MSBITS subformat interface
Date: Tue, 14 Nov 2023 21:09:28 +0100 [thread overview]
Message-ID: <cd4dd449-1fc5-8b2c-e453-1e137f370a53@intel.com> (raw)
In-Reply-To: <be2ec481-fb35-52be-0847-199d446b6431@perex.cz>
On 2023-09-21 8:25 AM, Jaroslav Kysela wrote:
> On 18. 09. 23 15:39, Cezary Rojewski wrote:
>> Improve granularity of format selection for S32/U32 formats by adding
>> constants representing 20, 24 and MAX most significant bits.
>>
>> To make it easy for drivers to utilize those constants, introduce
>> snd_pcm_subformat_width() and snd_pcm_hw_params_bps(). While the former
>> is self-explanatory, the latter returns the bit-per-sample value based
>> on format and subformat characteristics of the provided hw_params.
>> snd_pcm_hw_copy() helps with copying a hardware parameters space as with
>> introduction of subformats the operations becomes non-trivial.
>>
>> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
>
> ...
>
>> struct snd_pcm_hardware {
>> unsigned int info; /* SNDRV_PCM_INFO_* */
>> u64 formats; /* SNDRV_PCM_FMTBIT_* */
>> + struct snd_pcm_subformat *subformats;
>
> I don't think that it's required to add subformats to the hardware
> template. The new constraint can handle subformat refining without the
> template modifications (pointer to map table is stored privately to this
> constraint).
After iterating over the feedback, modified the field to u32 and all the
handlers to acknowledge that it is S32_LE-specific. I agree with
statement that we can expand on the API in the future if there's demand
for it.
> Also, I miss the constraint handling here. Without the constraint, the
> new API is not functional and it does not make sense to split the
> constraint code to other patch.
Ack, merging the two.
>> +int snd_pcm_hw_params_bps(const struct snd_pcm_hw_params *p);
>
> This may be probably inline function. See bellow.
>
>> + kfree(runtime->hw.subformats);
>
> Do we really need to do an assumption about allocations for this field?
> The driver may use a static structure. No problem, when this is not
> added to runtime->hw.
This code is gone in v3 since there is no need to kfree() a u32.
>> +int snd_pcm_hw_params_bps(const struct snd_pcm_hw_params *p)
>> +{
>> + snd_pcm_subformat_t subformat = params_subformat(p);
>> + snd_pcm_format_t format = params_format(p);
>> + int width;
>> +
>> + switch (format) {
>> + case SNDRV_PCM_FORMAT_S32_LE:
>> + case SNDRV_PCM_FORMAT_U32_LE:
>> + case SNDRV_PCM_FORMAT_S32_BE:
>> + case SNDRV_PCM_FORMAT_U32_BE:
>> + width = snd_pcm_subformat_width(subformat);
>
> This is not a correct implementation. The width should be returned for
> MAX subformat (== snd_pcm_format_width value). See bellow.
snd_pcm_subformat_width() returns 0 if subformat==MAX and fallthrough
ensures snd_pcm_format_width() is returned in such case.
>> +int snd_pcm_subformat_width(snd_pcm_subformat_t subformat)
>
> This function should probably have two arguments - format + subformat to
> return the correct information. The MAX subformat should return
> snd_pcm_format_width value.
My intention is to have two granular functions. One for obtaining
subformat-width explicitly and the other for calculating bits-per-sample.
>> +int snd_pcm_hw_copy(struct snd_pcm_hardware *hw, const struct
>> snd_pcm_hardware *from)
>
> This function is not required, if only the constraint function handles
> the subformat refining.
Ack, removing in v3.
next prev parent reply other threads:[~2023-11-14 20:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 13:39 [PATCH v2 00/17] ALSA/ASoC: hda: Address format selection limitations and ambiguity Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 01/17] ALSA: pcm: Introduce MSBITS subformat interface Cezary Rojewski
2023-09-21 6:25 ` Jaroslav Kysela
2023-11-14 20:09 ` Cezary Rojewski [this message]
2023-09-18 13:39 ` [PATCH v2 02/17] ALSA: pcm: Honor subformat when configuring substream Cezary Rojewski
2023-09-21 6:41 ` Jaroslav Kysela
2023-09-21 8:59 ` Cezary Rojewski
2023-09-23 10:55 ` kernel test robot
2023-09-18 13:39 ` [PATCH v2 03/17] ALSA: hda: Honor subformat when querying PCMs Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 04/17] ASoC: pcm: Honor subformat when configuring runtime Cezary Rojewski
2023-09-19 12:50 ` Mark Brown
2023-09-21 6:57 ` Jaroslav Kysela
2023-09-18 13:39 ` [PATCH v2 05/17] ALSA: hda: Upgrade stream-format infrastructure Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 06/17] ALSA: hda: Switch to new stream-format interface Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 07/17] ALSA: hda/hdmi: " Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 08/17] ALSA: hda/ca0132: " Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 09/17] ASoC: codecs: hda: " Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 10/17] ASoC: codecs: hdac_hda: " Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 11/17] ASoC: codecs: hdac_hdmi: " Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 12/17] ASoC: Intel Skylake: " Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 13/17] ASoC: SOF: Intel: " Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 14/17] ASoC: Intel: avs: " Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 15/17] ALSA: hda: Drop snd_hdac_calc_stream_format() Cezary Rojewski
2023-09-18 15:11 ` kernel test robot
2023-09-18 13:39 ` [PATCH v2 16/17] ASoC: Intel: avs: Kill S24_LE in HDAudio streaming Cezary Rojewski
2023-09-18 13:39 ` [PATCH v2 17/17] ASoC: Intel: avs: Unhardcode HDAudio BE DAI drivers description Cezary Rojewski
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=cd4dd449-1fc5-8b2c-e453-1e137f370a53@intel.com \
--to=cezary.rojewski@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=amadeuszx.slawinski@linux.intel.com \
--cc=broonie@kernel.org \
--cc=hdegoede@redhat.com \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=tiwai@suse.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;
as well as URLs for NNTP newsgroup(s).