From: Lars-Peter Clausen <lars@metafoo.de>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>
Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 2/3] ALSA: Add support for wildcard msbits constraints
Date: Mon, 29 Dec 2014 18:43:37 +0100 [thread overview]
Message-ID: <1419875018-30812-2-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1419875018-30812-1-git-send-email-lars@metafoo.de>
Currently the msbits constraints requires to specify a specific sample
format width for which the constraint should be applied. But often the
number of most significant bits is not sample format specific, but rather a
absolute limit. E.g. the PCM interface might accept 32-bit and 24-bit
samples, but the DAC has a 16-bit resolution and throws away the LSBs. In
this case for both 32-bit and 24-bit format msbits should be set to 16. This
patch extends snd_pcm_hw_constraint_msbits() so that a wildcard constraint
can be setup that is applied for all formats with a sample width larger than
the specified msbits. Choosing the wildcard constraint is done by setting
the sample width parameter of the function to 0.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
sound/core/pcm_lib.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index b0c1535..db05e04 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -1299,8 +1299,14 @@ static int snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params,
int width = l & 0xffff;
unsigned int msbits = l >> 16;
struct snd_interval *i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS);
- if (snd_interval_single(i) && snd_interval_value(i) == width)
+
+ if (!snd_interval_single(i))
+ return 0;
+
+ if ((snd_interval_value(i) == width) ||
+ (width == 0 && snd_interval_value(i) > msbits))
params->msbits = min_not_zero(params->msbits, msbits);
+
return 0;
}
@@ -1311,6 +1317,11 @@ static int snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params,
* @width: sample bits width
* @msbits: msbits width
*
+ * This constraint will set the number of most significant bits (msbits) if a
+ * sample format with the specified width has been select. If width is set to 0
+ * the msbits will be set for any sample format with a width larger than the
+ * specified msbits.
+ *
* Return: Zero if successful, or a negative error code on failure.
*/
int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime,
--
1.8.0
next prev parent reply other threads:[~2014-12-29 17:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-29 17:43 [PATCH 1/3] ALSA: Fix handling of multiple msbits constraints on the same runtime Lars-Peter Clausen
2014-12-29 17:43 ` Lars-Peter Clausen [this message]
2014-12-29 17:43 ` [PATCH 3/3] ASoC: pcm: Use wildcard msbits constraints Lars-Peter Clausen
2014-12-29 18:25 ` Mark Brown
2014-12-31 16:16 ` Takashi Iwai
2014-12-31 16:24 ` Lars-Peter Clausen
2014-12-30 15:48 ` [PATCH 1/3] ALSA: Fix handling of multiple msbits constraints on the same runtime Takashi Iwai
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=1419875018-30812-2-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
/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