From: Lars-Peter Clausen <lars@metafoo.de>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>
Subject: Re: [PATCH 4/5] ALSA: Add helper function for intersecting two rate masks
Date: Fri, 10 Jan 2014 16:49:22 +0100 [thread overview]
Message-ID: <52D01682.3000408@metafoo.de> (raw)
In-Reply-To: <s5hwqi7x3w2.wl%tiwai@suse.de>
On 01/10/2014 04:17 PM, Takashi Iwai wrote:
> At Fri, 10 Jan 2014 16:06:35 +0100,
> Lars-Peter Clausen wrote:
>>
>> A bit of special care is necessary when creating the intersection of two rate
>> masks. This comes from the special meaning of the SNDRV_PCM_RATE_CONTINUOUS and
>> SNDRV_PCM_RATE_KNOT bits, which needs special handling when intersecting two
>> rate masks. SNDRV_PCM_RATE_CONTINUOUS means the hardware supports all rates in a
>> specific interval. SNDRV_PCM_RATE_KNOT means the hardware supports a set of
>> discrete rates specified by a list constraint. For all other cases the supported
>> rates are specified directly in the rate mask.
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>> ---
>> include/sound/pcm.h | 2 ++
>> sound/core/pcm_misc.c | 39 +++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 41 insertions(+)
>>
>> diff --git a/include/sound/pcm.h b/include/sound/pcm.h
>> index 84b10f9..d017091 100644
>> --- a/include/sound/pcm.h
>> +++ b/include/sound/pcm.h
>> @@ -901,6 +901,8 @@ extern const struct snd_pcm_hw_constraint_list snd_pcm_known_rates;
>> int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime);
>> unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate);
>> unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit);
>> +unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
>> + unsigned int rates_b);
>>
>> static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream,
>> struct snd_dma_buffer *bufp)
>> diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
>> index 43f24cc..1552537 100644
>> --- a/sound/core/pcm_misc.c
>> +++ b/sound/core/pcm_misc.c
>> @@ -514,3 +514,42 @@ unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit)
>> return 0;
>> }
>> EXPORT_SYMBOL(snd_pcm_rate_bit_to_rate);
>> +
>> +static unsigned int snd_pcm_rate_mask_sanitize(unsigned int rates)
>> +{
>> + if (rates & SNDRV_PCM_RATE_CONTINUOUS)
>> + return SNDRV_PCM_RATE_CONTINUOUS;
>> + else if (rates & SNDRV_PCM_RATE_KNOT)
>> + return SNDRV_PCM_RATE_KNOT;
>> + return rates;
>> +}
>> +
>> +/**
>> + * snd_pcm_rate_mask_intersect - computes the intersection between two rate masks
>> + * @rates_a: The first rate mask
>> + * @rates_b: The second rate mask
>> + *
>> + * This function computes the rates that are supported by both rate masks passed
>> + * to the function. It will take care of the special handling of
>> + * SNDRV_PCM_RATE_CONTINUOUS and SNDRV_PCM_RATE_KNOT.
>> + *
>> + * Return: A rate mask containing the rates that are supported by both rates_a
>> + * and rates_b.
>> + */
>> +unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
>> + unsigned int rates_b)
>> +{
>> + rates_a = snd_pcm_rate_mask_sanitize(rates_a);
>> + rates_b = snd_pcm_rate_mask_sanitize(rates_b);
>> +
>> + if (rates_a & SNDRV_PCM_RATE_CONTINUOUS)
>> + return rates_b;
>> + else if (rates_b & SNDRV_PCM_RATE_CONTINUOUS)
>> + return rates_a;
>> + else if (rates_a & SNDRV_PCM_RATE_KNOT)
>> + return rates_b;
>> + else if (rates_b & SNDRV_PCM_RATE_KNOT)
>> + return rates_a;
>> + return rates_a & rates_b;
>> +}
>> +EXPORT_SYMBOL(snd_pcm_rate_mask_intersect);
>
> We can use EXPORT_SYMBOL_GPL() for new functions safely.
Ok, I'll change that.
>
> I suppose this patchset will go through ASoC tree? Then take my ack:
>
> Reviewed-by: Takashi Iwai <tiwai@suse.de>
Thanks.
next prev parent reply other threads:[~2014-01-10 15:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-10 15:06 [PATCH 1/5] ASoC: pcm: Properly initialize hw->rate_max Lars-Peter Clausen
2014-01-10 15:06 ` [PATCH 2/5] ASoC: fsl: Don't mix SNDRV_PCM_RATE_CONTINUOUS with specific rates Lars-Peter Clausen
2014-01-10 15:06 ` [PATCH 3/5] ASoC: s6000: " Lars-Peter Clausen
2014-01-10 15:06 ` [PATCH 4/5] ALSA: Add helper function for intersecting two rate masks Lars-Peter Clausen
2014-01-10 15:17 ` Takashi Iwai
2014-01-10 15:49 ` Lars-Peter Clausen [this message]
2014-01-10 15:06 ` [PATCH 5/5] ASoC: pcm: Use snd_pcm_rate_mask_intersect() helper Lars-Peter Clausen
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=52D01682.3000408@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--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