]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
ALSA: pcm: add snd_pcm_hw_rule_noresample()
authorClemens Ladisch <clemens@ladisch.de>
Fri, 16 Sep 2011 21:03:02 +0000 (23:03 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 20 Sep 2011 06:56:45 +0000 (08:56 +0200)
Add a helper function to allow drivers to disable hardware resampling
when the application has specified the SNDRV_PCM_HW_PARAMS_NORESAMPLE
flag.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/pcm.h
sound/core/pcm_lib.c

index 57e71fa33f7ce8eac899870d9e11937a2240a6dd..dc36f756fe8d55541b484b8c1e9a30ab06ffc25d 100644 (file)
@@ -825,6 +825,8 @@ int snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime,
 int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime,
                               unsigned int cond,
                               snd_pcm_hw_param_t var);
+int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime,
+                              unsigned int base_rate);
 int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime,
                        unsigned int cond,
                        int var,
index 62e90b862a0ddd2a1b7a0c49d34e76686a13b869..95d1e789715f13b0ae9185dc213da64728d43c76 100644 (file)
@@ -1399,6 +1399,32 @@ int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime,
 
 EXPORT_SYMBOL(snd_pcm_hw_constraint_pow2);
 
+static int snd_pcm_hw_rule_noresample_func(struct snd_pcm_hw_params *params,
+                                          struct snd_pcm_hw_rule *rule)
+{
+       unsigned int base_rate = (unsigned int)(uintptr_t)rule->private;
+       struct snd_interval *rate;
+
+       rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
+       return snd_interval_list(rate, 1, &base_rate, 0);
+}
+
+/**
+ * snd_pcm_hw_rule_noresample - add a rule to allow disabling hw resampling
+ * @runtime: PCM runtime instance
+ * @base_rate: the rate at which the hardware does not resample
+ */
+int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime,
+                              unsigned int base_rate)
+{
+       return snd_pcm_hw_rule_add(runtime, SNDRV_PCM_HW_PARAMS_NORESAMPLE,
+                                  SNDRV_PCM_HW_PARAM_RATE,
+                                  snd_pcm_hw_rule_noresample_func,
+                                  (void *)(uintptr_t)base_rate,
+                                  SNDRV_PCM_HW_PARAM_RATE, -1);
+}
+EXPORT_SYMBOL(snd_pcm_hw_rule_noresample);
+
 static void _snd_pcm_hw_param_any(struct snd_pcm_hw_params *params,
                                  snd_pcm_hw_param_t var)
 {