aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core')
-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 }