* [PATCH] ALSA: Add snd_pcm_rate_bit_to_rate()
@ 2012-06-15 15:35 Dimitris Papastamos
2012-06-18 7:44 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Dimitris Papastamos @ 2012-06-15 15:35 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel, Mark Brown, patches
This is essentially the reverse of snd_pcm_rate_to_rate_bit().
This is generally useful as the Compress API uses the rate bit
directly and it helps to be able to map back to the actual sample
rate.
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
---
include/sound/pcm.h | 1 +
sound/core/pcm_misc.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 1d58d79..18ad1f1 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -892,6 +892,7 @@ 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);
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 9c9eff9..d4fc1bf 100644
--- a/sound/core/pcm_misc.c
+++ b/sound/core/pcm_misc.c
@@ -488,3 +488,21 @@ unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate)
return SNDRV_PCM_RATE_KNOT;
}
EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit);
+
+/**
+ * snd_pcm_rate_bit_to_rate - converts SNDRV_PCM_RATE_xxx bit to sample rate
+ * @rate_bit: the rate bit to convert
+ *
+ * Returns the sample rate that corresponds to the given SNDRV_PCM_RATE_xxx flag
+ * or 0 for an unknown rate bit
+ */
+unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit)
+{
+ unsigned int i;
+
+ for (i = 0; i < snd_pcm_known_rates.count; i++)
+ if ((1u << i) == rate_bit)
+ return snd_pcm_known_rates.list[i];
+ return 0;
+}
+EXPORT_SYMBOL(snd_pcm_rate_bit_to_rate);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ALSA: Add snd_pcm_rate_bit_to_rate()
2012-06-15 15:35 [PATCH] ALSA: Add snd_pcm_rate_bit_to_rate() Dimitris Papastamos
@ 2012-06-18 7:44 ` Takashi Iwai
2012-06-18 9:47 ` Dimitris Papastamos
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2012-06-18 7:44 UTC (permalink / raw)
To: Dimitris Papastamos; +Cc: alsa-devel, Mark Brown, patches
At Fri, 15 Jun 2012 16:35:28 +0100,
Dimitris Papastamos wrote:
>
> This is essentially the reverse of snd_pcm_rate_to_rate_bit().
>
> This is generally useful as the Compress API uses the rate bit
> directly and it helps to be able to map back to the actual sample
> rate.
>
> Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Applied to topic/misc branch of sound git tree.
If this change is necessary, simply pull that branch.
thanks,
Takashi
> ---
> include/sound/pcm.h | 1 +
> sound/core/pcm_misc.c | 18 ++++++++++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/include/sound/pcm.h b/include/sound/pcm.h
> index 1d58d79..18ad1f1 100644
> --- a/include/sound/pcm.h
> +++ b/include/sound/pcm.h
> @@ -892,6 +892,7 @@ 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);
>
> 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 9c9eff9..d4fc1bf 100644
> --- a/sound/core/pcm_misc.c
> +++ b/sound/core/pcm_misc.c
> @@ -488,3 +488,21 @@ unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate)
> return SNDRV_PCM_RATE_KNOT;
> }
> EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit);
> +
> +/**
> + * snd_pcm_rate_bit_to_rate - converts SNDRV_PCM_RATE_xxx bit to sample rate
> + * @rate_bit: the rate bit to convert
> + *
> + * Returns the sample rate that corresponds to the given SNDRV_PCM_RATE_xxx flag
> + * or 0 for an unknown rate bit
> + */
> +unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < snd_pcm_known_rates.count; i++)
> + if ((1u << i) == rate_bit)
> + return snd_pcm_known_rates.list[i];
> + return 0;
> +}
> +EXPORT_SYMBOL(snd_pcm_rate_bit_to_rate);
> --
> 1.7.10.4
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ALSA: Add snd_pcm_rate_bit_to_rate()
2012-06-18 7:44 ` Takashi Iwai
@ 2012-06-18 9:47 ` Dimitris Papastamos
0 siblings, 0 replies; 3+ messages in thread
From: Dimitris Papastamos @ 2012-06-18 9:47 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel, Mark Brown, patches
On Mon, Jun 18, 2012 at 09:44:19AM +0200, Takashi Iwai wrote:
> At Fri, 15 Jun 2012 16:35:28 +0100,
> Dimitris Papastamos wrote:
> >
> > This is essentially the reverse of snd_pcm_rate_to_rate_bit().
> >
> > This is generally useful as the Compress API uses the rate bit
> > directly and it helps to be able to map back to the actual sample
> > rate.
> >
> > Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
>
> Applied to topic/misc branch of sound git tree.
> If this change is necessary, simply pull that branch.
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-18 9:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-15 15:35 [PATCH] ALSA: Add snd_pcm_rate_bit_to_rate() Dimitris Papastamos
2012-06-18 7:44 ` Takashi Iwai
2012-06-18 9:47 ` Dimitris Papastamos
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.