Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Cc: cezary.rojewski@intel.com, patch@alsa-project.org,
	lgirdwood@gmail.com, alsa-devel@alsa-project.org,
	pierre-louis.bossart@linux.intel.com, broonie@kernel.org,
	amadeuszx.slawinski@linux.intel.com,
	Pawel Harlozinski <pawel.harlozinski@linux.intel.com>
Subject: Re: [PATCH] ALSA: hda: Refactor calculating SDnFMT according to specification
Date: Tue, 25 Aug 2020 10:25:56 +0200	[thread overview]
Message-ID: <s5h5z976siz.wl-tiwai@suse.de> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2008241434310.3186@eliteleevi.tm.intel.com>

On Mon, 24 Aug 2020 14:16:26 +0200,
Kai Vehmanen wrote:
> 
> 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).

Hm, we need to check the call pattern, then.  The maxbps passed to
this function was supposed to be the value obtained from
snd_hdac_query_supported_pcm(), i.e. the codec capability.

But, basically this patch wouldn't change any practical behavior.  In
the current code, snd_pcm_format_width() can be never 20 or 24,
because the 24 and 24bit supports are also with SNDRV_PCM_FMT_S32_LE.
That is, the cases 20 and 24 there are superfluous from the
beginning (although the checks of maxbps are still needed).

Instead, what we could improve is:
- Set up the proper msbits hw_constraint to reflect the maxbps value
- Choose the right AC_FMT_BITS_* depending on the hw_params msbits

We may change the query function not to return a single maxbps value
but rather storing the raw PCM parameter value (AC_SUPPCM_*), and pass
it at re-encoding the format value, too, if we want to make things
perfect.


thanks,

Takashi

  reply	other threads:[~2020-08-25  8:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-24 10:00 [PATCH] ALSA: hda: Refactor calculating SDnFMT according to specification Pawel Harlozinski
2020-08-24 12:16 ` Kai Vehmanen
2020-08-25  8:25   ` Takashi Iwai [this message]
2020-09-02 13:13     ` Harlozinski, Pawel
2020-09-02 13:29       ` Harlozinski, Pawel

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=s5h5z976siz.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=patch@alsa-project.org \
    --cc=pawel.harlozinski@linux.intel.com \
    --cc=pierre-louis.bossart@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