aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-10-19 08:38:30 -0400
committerJaroslav Kysela <perex@suse.cz>2005-11-04 07:19:07 -0500
commit87ef7779be825c187747b6b39a24d5326d610c53 (patch)
treefd1ca6f88f1cadc68a07054beef067f210010039
parent051b51653309db976c9665f8d4b1774fa1f8124a (diff)
[ALSA] seq-timer: restrict timer frequencies
Modules: ALSA sequencer When no default timer frequency has been set, initialize_timer() just uses the maximum frequency supported by the timer, which is ridiculously high on 96 kHz timers. This patch introduces a default frequency of 1000 Hz for this case, and makes sure that a frequency set by the user isn't too high. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
-rw-r--r--sound/core/seq/seq_timer.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c
index 9c87d9f8ba9f..65b64a7c456d 100644
--- a/sound/core/seq/seq_timer.c
+++ b/sound/core/seq/seq_timer.c
@@ -34,6 +34,11 @@ extern int seq_default_timer_device;
34extern int seq_default_timer_subdevice; 34extern int seq_default_timer_subdevice;
35extern int seq_default_timer_resolution; 35extern int seq_default_timer_resolution;
36 36
37/* allowed sequencer timer frequencies, in Hz */
38#define MIN_FREQUENCY 10
39#define MAX_FREQUENCY 6250
40#define DEFAULT_FREQUENCY 1000
41
37#define SKEW_BASE 0x10000 /* 16bit shift */ 42#define SKEW_BASE 0x10000 /* 16bit shift */
38 43
39static void snd_seq_timer_set_tick_resolution(seq_timer_tick_t *tick, 44static void snd_seq_timer_set_tick_resolution(seq_timer_tick_t *tick,
@@ -325,17 +330,26 @@ int snd_seq_timer_stop(seq_timer_t * tmr)
325static int initialize_timer(seq_timer_t *tmr) 330static int initialize_timer(seq_timer_t *tmr)
326{ 331{
327 snd_timer_t *t; 332 snd_timer_t *t;
333 unsigned long freq;
334
328 t = tmr->timeri->timer; 335 t = tmr->timeri->timer;
329 snd_assert(t, return -EINVAL); 336 snd_assert(t, return -EINVAL);
330 337
338 freq = tmr->preferred_resolution;
339 if (!freq)
340 freq = DEFAULT_FREQUENCY;
341 else if (freq < MIN_FREQUENCY)
342 freq = MIN_FREQUENCY;
343 else if (freq > MAX_FREQUENCY)
344 freq = MAX_FREQUENCY;
345
331 tmr->ticks = 1; 346 tmr->ticks = 1;
332 if (tmr->preferred_resolution && 347 if (!(t->hw.flags & SNDRV_TIMER_HW_SLAVE)) {
333 ! (t->hw.flags & SNDRV_TIMER_HW_SLAVE)) {
334 unsigned long r = t->hw.resolution; 348 unsigned long r = t->hw.resolution;
335 if (! r && t->hw.c_resolution) 349 if (! r && t->hw.c_resolution)
336 r = t->hw.c_resolution(t); 350 r = t->hw.c_resolution(t);
337 if (r) { 351 if (r) {
338 tmr->ticks = (unsigned int)(1000000000uL / (r * tmr->preferred_resolution)); 352 tmr->ticks = (unsigned int)(1000000000uL / (r * freq));
339 if (! tmr->ticks) 353 if (! tmr->ticks)
340 tmr->ticks = 1; 354 tmr->ticks = 1;
341 } 355 }