From a99b86e4eb3e67f9e2987f00fa31732ca8e435de Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 16 Sep 2011 23:03:02 +0200 Subject: [PATCH] --- yaml --- r: 270429 b: refs/heads/master c: d5b702a64b4c273c8eed7e4e721364493d01fdc9 h: refs/heads/master i: 270427: dfc0e7e7a08a73d425d1381f2bdc5494ecfd52be v: v3 --- [refs] | 2 +- trunk/include/sound/pcm.h | 2 ++ trunk/sound/core/pcm_lib.c | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 3c10c21eec67..10483bddcc9d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 84f9df159df6311f33ab16637772788cf3729ede +refs/heads/master: d5b702a64b4c273c8eed7e4e721364493d01fdc9 diff --git a/trunk/include/sound/pcm.h b/trunk/include/sound/pcm.h index 57e71fa33f7c..dc36f756fe8d 100644 --- a/trunk/include/sound/pcm.h +++ b/trunk/include/sound/pcm.h @@ -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, diff --git a/trunk/sound/core/pcm_lib.c b/trunk/sound/core/pcm_lib.c index 62e90b862a0d..95d1e789715f 100644 --- a/trunk/sound/core/pcm_lib.c +++ b/trunk/sound/core/pcm_lib.c @@ -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) {