aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/pcm_lib.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2011-09-16 17:03:02 -0400
committerTakashi Iwai <tiwai@suse.de>2011-09-20 02:56:45 -0400
commitd5b702a64b4c273c8eed7e4e721364493d01fdc9 (patch)
treea2bdccd13ad840c8f71f848e3f4d096839a322df /sound/core/pcm_lib.c
parent84f9df159df6311f33ab16637772788cf3729ede (diff)
ALSA: pcm: add snd_pcm_hw_rule_noresample()
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>
Diffstat (limited to 'sound/core/pcm_lib.c')
-rw-r--r--sound/core/pcm_lib.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 62e90b862a0..95d1e789715 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -1399,6 +1399,32 @@ int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime,
1399 1399
1400EXPORT_SYMBOL(snd_pcm_hw_constraint_pow2); 1400EXPORT_SYMBOL(snd_pcm_hw_constraint_pow2);
1401 1401
1402static int snd_pcm_hw_rule_noresample_func(struct snd_pcm_hw_params *params,
1403 struct snd_pcm_hw_rule *rule)
1404{
1405 unsigned int base_rate = (unsigned int)(uintptr_t)rule->private;
1406 struct snd_interval *rate;
1407
1408 rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
1409 return snd_interval_list(rate, 1, &base_rate, 0);
1410}
1411
1412/**
1413 * snd_pcm_hw_rule_noresample - add a rule to allow disabling hw resampling
1414 * @runtime: PCM runtime instance
1415 * @base_rate: the rate at which the hardware does not resample
1416 */
1417int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime,
1418 unsigned int base_rate)
1419{
1420 return snd_pcm_hw_rule_add(runtime, SNDRV_PCM_HW_PARAMS_NORESAMPLE,
1421 SNDRV_PCM_HW_PARAM_RATE,
1422 snd_pcm_hw_rule_noresample_func,
1423 (void *)(uintptr_t)base_rate,
1424 SNDRV_PCM_HW_PARAM_RATE, -1);
1425}
1426EXPORT_SYMBOL(snd_pcm_hw_rule_noresample);
1427
1402static void _snd_pcm_hw_param_any(struct snd_pcm_hw_params *params, 1428static void _snd_pcm_hw_param_any(struct snd_pcm_hw_params *params,
1403 snd_pcm_hw_param_t var) 1429 snd_pcm_hw_param_t var)
1404{ 1430{