aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/pcm.h2
-rw-r--r--sound/core/pcm_misc.c13
-rw-r--r--sound/core/pcm_native.c8
3 files changed, 13 insertions, 10 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 73334e0f823f..2d5dee2fcb64 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -922,6 +922,8 @@ snd_pcm_sframes_t snd_pcm_lib_writev(struct snd_pcm_substream *substream,
922snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream, 922snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream,
923 void __user **bufs, snd_pcm_uframes_t frames); 923 void __user **bufs, snd_pcm_uframes_t frames);
924 924
925extern const struct snd_pcm_hw_constraint_list snd_pcm_known_rates;
926
925int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime); 927int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime);
926 928
927static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream, 929static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream,
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
index 9142fce4dda2..afd1e4929755 100644
--- a/sound/core/pcm_misc.c
+++ b/sound/core/pcm_misc.c
@@ -433,21 +433,16 @@ EXPORT_SYMBOL(snd_pcm_format_set_silence);
433 */ 433 */
434int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime) 434int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime)
435{ 435{
436 static unsigned rates[] = {
437 /* ATTENTION: these values depend on the definition in pcm.h! */
438 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000,
439 64000, 88200, 96000, 176400, 192000
440 };
441 int i; 436 int i;
442 for (i = 0; i < (int)ARRAY_SIZE(rates); i++) { 437 for (i = 0; i < (int)snd_pcm_known_rates.count; i++) {
443 if (runtime->hw.rates & (1 << i)) { 438 if (runtime->hw.rates & (1 << i)) {
444 runtime->hw.rate_min = rates[i]; 439 runtime->hw.rate_min = snd_pcm_known_rates.list[i];
445 break; 440 break;
446 } 441 }
447 } 442 }
448 for (i = (int)ARRAY_SIZE(rates) - 1; i >= 0; i--) { 443 for (i = (int)snd_pcm_known_rates.count - 1; i >= 0; i--) {
449 if (runtime->hw.rates & (1 << i)) { 444 if (runtime->hw.rates & (1 << i)) {
450 runtime->hw.rate_max = rates[i]; 445 runtime->hw.rate_max = snd_pcm_known_rates.list[i];
451 break; 446 break;
452 } 447 }
453 } 448 }
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 59b29cd482ae..b78a411fb550 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1787,12 +1787,18 @@ static int snd_pcm_hw_rule_sample_bits(struct snd_pcm_hw_params *params,
1787static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, 1787static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100,
1788 48000, 64000, 88200, 96000, 176400, 192000 }; 1788 48000, 64000, 88200, 96000, 176400, 192000 };
1789 1789
1790const struct snd_pcm_hw_constraint_list snd_pcm_known_rates = {
1791 .count = ARRAY_SIZE(rates),
1792 .list = rates,
1793};
1794
1790static int snd_pcm_hw_rule_rate(struct snd_pcm_hw_params *params, 1795static int snd_pcm_hw_rule_rate(struct snd_pcm_hw_params *params,
1791 struct snd_pcm_hw_rule *rule) 1796 struct snd_pcm_hw_rule *rule)
1792{ 1797{
1793 struct snd_pcm_hardware *hw = rule->private; 1798 struct snd_pcm_hardware *hw = rule->private;
1794 return snd_interval_list(hw_param_interval(params, rule->var), 1799 return snd_interval_list(hw_param_interval(params, rule->var),
1795 ARRAY_SIZE(rates), rates, hw->rates); 1800 snd_pcm_known_rates.count,
1801 snd_pcm_known_rates.list, hw->rates);
1796} 1802}
1797 1803
1798static int snd_pcm_hw_rule_buffer_bytes_max(struct snd_pcm_hw_params *params, 1804static int snd_pcm_hw_rule_buffer_bytes_max(struct snd_pcm_hw_params *params,