24 #include <linux/slab.h>
30 #define MIN_FREQUENCY 10
31 #define MAX_FREQUENCY 6250
32 #define DEFAULT_FREQUENCY 1000
34 #define SKEW_BASE 0x10000
38 if (tmr->
tempo < 1000000)
44 s = (
s * 1000) / tmr->
ppq;
46 tmr->
tick.resolution +=
s;
48 if (
tmr->tick.resolution <= 0)
49 tmr->tick.resolution = 1;
50 snd_seq_timer_update_tick(&
tmr->tick, 0);
60 snd_printd(
"malloc failed for snd_seq_timer_new() \n");
81 snd_printd(
"oops: snd_seq_timer_delete() called with NULL timer\n");
98 snd_seq_timer_set_tick_resolution(tmr);
122 tmr->
tick.cur_tick = 0;
123 tmr->
tick.fraction = 0;
125 spin_unlock_irqrestore(&tmr->
lock, flags);
131 unsigned long resolution,
149 resolution = (resolution >> 16) * tmr->
skew +
150 (((resolution & 0xffff) * tmr->
skew) >> 16);
156 snd_seq_inc_time_nsec(&tmr->
cur_time, resolution);
159 snd_seq_timer_update_tick(&tmr->
tick, resolution);
164 spin_unlock_irqrestore(&tmr->
lock, flags);
180 if ((
unsigned int)tempo != tmr->
tempo) {
182 snd_seq_timer_set_tick_resolution(tmr);
184 spin_unlock_irqrestore(&tmr->
lock, flags);
201 spin_unlock_irqrestore(&tmr->
lock, flags);
202 snd_printd(
"seq: cannot change ppq of a running timer\n");
207 snd_seq_timer_set_tick_resolution(tmr);
208 spin_unlock_irqrestore(&tmr->
lock, flags);
222 tmr->
tick.cur_tick = position;
223 tmr->
tick.fraction = 0;
224 spin_unlock_irqrestore(&tmr->
lock, flags);
237 snd_seq_sanity_real_time(&position);
240 spin_unlock_irqrestore(&tmr->
lock, flags);
260 spin_unlock_irqrestore(&tmr->
lock, flags);
286 memset(&tid, 0,
sizeof(tid));
298 t->
callback = snd_seq_timer_interrupt;
350 unsigned long r = t->
hw.resolution;
351 if (! r && t->
hw.c_resolution)
352 r = t->
hw.c_resolution(t);
354 tmr->
ticks = (
unsigned int)(1000000000uL / (r * freq));
370 if (initialize_timer(tmr) < 0)
386 if (initialize_timer(tmr) < 0)
407 cur_time.
tv_nsec += (1000000 + usec) * 1000;
410 cur_time.
tv_nsec += usec * 1000;
413 snd_seq_sanity_real_time(&cur_time);
423 return tmr->
tick.cur_tick;
427 #ifdef CONFIG_PROC_FS
447 snd_iprintf(buffer,
"Timer for queue %i : %s\n", q->
queue, ti->
timer->name);
449 snd_iprintf(buffer,
" Period time : %lu.%09lu\n", resolution / 1000000000, resolution % 1000000000);
450 snd_iprintf(buffer,
" Skew : %u / %u\n", tmr->
skew, tmr->
skew_base);