[PATCH] ALSA: hda: Refactor calculating SDnFMT according to specification

Kai Vehmanen kai.vehmanen at linux.intel.com
Mon Aug 24 14:16:26 CEST 2020


Hey,

On Mon, 24 Aug 2020, Pawel Harlozinski wrote:

> Set SDnFMT depending on which format was given, as maxbps only describes container size.

hmm, I'm not entirely sure that is correct. Usage may be a bit varied, but 
most places in existing code, "maxbps" is treated as number of significant 
bits, not the container size. E.g. in hdac_hda.c:

»       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
»       »       maxbps = dai->driver->playback.sig_bits;
»       else
»       »       maxbps = dai->driver->capture.sig_bits;

It would seem "maxbps" is a bit superfluous given the same information can 
be relayed in "format" as well. But currently it's still used. E.g. if you 
look at snd_hdac_query_supported_pcm(), if codec reports 24bit support, 
format is always set to SNDRV_PCM_FMTBIT_S32_LE, even if only 24bit are 
valid. So snd_pcm_format_width() will not return the expected significant 
bits info, but you have to use "maxbps". So original code seems correct 
(or at least you'd need to update both places).

Br, Kai


More information about the Alsa-devel mailing list