• Home
  • Raw
  • Download

Lines Matching refs:tmr

36 static void snd_seq_timer_set_tick_resolution(struct snd_seq_timer *tmr)  in snd_seq_timer_set_tick_resolution()  argument
38 if (tmr->tempo < 1000000) in snd_seq_timer_set_tick_resolution()
39 tmr->tick.resolution = (tmr->tempo * 1000) / tmr->ppq; in snd_seq_timer_set_tick_resolution()
43 s = tmr->tempo % tmr->ppq; in snd_seq_timer_set_tick_resolution()
44 s = (s * 1000) / tmr->ppq; in snd_seq_timer_set_tick_resolution()
45 tmr->tick.resolution = (tmr->tempo / tmr->ppq) * 1000; in snd_seq_timer_set_tick_resolution()
46 tmr->tick.resolution += s; in snd_seq_timer_set_tick_resolution()
48 if (tmr->tick.resolution <= 0) in snd_seq_timer_set_tick_resolution()
49 tmr->tick.resolution = 1; in snd_seq_timer_set_tick_resolution()
50 snd_seq_timer_update_tick(&tmr->tick, 0); in snd_seq_timer_set_tick_resolution()
56 struct snd_seq_timer *tmr; in snd_seq_timer_new() local
58 tmr = kzalloc(sizeof(*tmr), GFP_KERNEL); in snd_seq_timer_new()
59 if (!tmr) in snd_seq_timer_new()
61 spin_lock_init(&tmr->lock); in snd_seq_timer_new()
64 snd_seq_timer_defaults(tmr); in snd_seq_timer_new()
67 snd_seq_timer_reset(tmr); in snd_seq_timer_new()
69 return tmr; in snd_seq_timer_new()
73 void snd_seq_timer_delete(struct snd_seq_timer **tmr) in snd_seq_timer_delete() argument
75 struct snd_seq_timer *t = *tmr; in snd_seq_timer_delete()
76 *tmr = NULL; in snd_seq_timer_delete()
91 void snd_seq_timer_defaults(struct snd_seq_timer * tmr) in snd_seq_timer_defaults() argument
95 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_defaults()
97 tmr->ppq = 96; /* 96 PPQ */ in snd_seq_timer_defaults()
98 tmr->tempo = 500000; /* 120 BPM */ in snd_seq_timer_defaults()
99 snd_seq_timer_set_tick_resolution(tmr); in snd_seq_timer_defaults()
100 tmr->running = 0; in snd_seq_timer_defaults()
102 tmr->type = SNDRV_SEQ_TIMER_ALSA; in snd_seq_timer_defaults()
103 tmr->alsa_id.dev_class = seq_default_timer_class; in snd_seq_timer_defaults()
104 tmr->alsa_id.dev_sclass = seq_default_timer_sclass; in snd_seq_timer_defaults()
105 tmr->alsa_id.card = seq_default_timer_card; in snd_seq_timer_defaults()
106 tmr->alsa_id.device = seq_default_timer_device; in snd_seq_timer_defaults()
107 tmr->alsa_id.subdevice = seq_default_timer_subdevice; in snd_seq_timer_defaults()
108 tmr->preferred_resolution = seq_default_timer_resolution; in snd_seq_timer_defaults()
110 tmr->skew = tmr->skew_base = SKEW_BASE; in snd_seq_timer_defaults()
111 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_defaults()
114 static void seq_timer_reset(struct snd_seq_timer *tmr) in seq_timer_reset() argument
117 tmr->cur_time.tv_sec = 0; in seq_timer_reset()
118 tmr->cur_time.tv_nsec = 0; in seq_timer_reset()
120 tmr->tick.cur_tick = 0; in seq_timer_reset()
121 tmr->tick.fraction = 0; in seq_timer_reset()
124 void snd_seq_timer_reset(struct snd_seq_timer *tmr) in snd_seq_timer_reset() argument
128 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_reset()
129 seq_timer_reset(tmr); in snd_seq_timer_reset()
130 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_reset()
141 struct snd_seq_timer *tmr; in snd_seq_timer_interrupt() local
145 tmr = q->timer; in snd_seq_timer_interrupt()
146 if (tmr == NULL) in snd_seq_timer_interrupt()
148 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_interrupt()
149 if (!tmr->running) { in snd_seq_timer_interrupt()
150 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_interrupt()
155 if (tmr->skew != tmr->skew_base) { in snd_seq_timer_interrupt()
157 resolution = (resolution >> 16) * tmr->skew + in snd_seq_timer_interrupt()
158 (((resolution & 0xffff) * tmr->skew) >> 16); in snd_seq_timer_interrupt()
162 snd_seq_inc_time_nsec(&tmr->cur_time, resolution); in snd_seq_timer_interrupt()
165 snd_seq_timer_update_tick(&tmr->tick, resolution); in snd_seq_timer_interrupt()
168 do_gettimeofday(&tmr->last_update); in snd_seq_timer_interrupt()
170 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_interrupt()
177 int snd_seq_timer_set_tempo(struct snd_seq_timer * tmr, int tempo) in snd_seq_timer_set_tempo() argument
181 if (snd_BUG_ON(!tmr)) in snd_seq_timer_set_tempo()
185 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_set_tempo()
186 if ((unsigned int)tempo != tmr->tempo) { in snd_seq_timer_set_tempo()
187 tmr->tempo = tempo; in snd_seq_timer_set_tempo()
188 snd_seq_timer_set_tick_resolution(tmr); in snd_seq_timer_set_tempo()
190 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_set_tempo()
195 int snd_seq_timer_set_ppq(struct snd_seq_timer * tmr, int ppq) in snd_seq_timer_set_ppq() argument
199 if (snd_BUG_ON(!tmr)) in snd_seq_timer_set_ppq()
203 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_set_ppq()
204 if (tmr->running && (ppq != tmr->ppq)) { in snd_seq_timer_set_ppq()
207 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_set_ppq()
212 tmr->ppq = ppq; in snd_seq_timer_set_ppq()
213 snd_seq_timer_set_tick_resolution(tmr); in snd_seq_timer_set_ppq()
214 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_set_ppq()
219 int snd_seq_timer_set_position_tick(struct snd_seq_timer *tmr, in snd_seq_timer_set_position_tick() argument
224 if (snd_BUG_ON(!tmr)) in snd_seq_timer_set_position_tick()
227 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_set_position_tick()
228 tmr->tick.cur_tick = position; in snd_seq_timer_set_position_tick()
229 tmr->tick.fraction = 0; in snd_seq_timer_set_position_tick()
230 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_set_position_tick()
235 int snd_seq_timer_set_position_time(struct snd_seq_timer *tmr, in snd_seq_timer_set_position_time() argument
240 if (snd_BUG_ON(!tmr)) in snd_seq_timer_set_position_time()
244 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_set_position_time()
245 tmr->cur_time = position; in snd_seq_timer_set_position_time()
246 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_set_position_time()
251 int snd_seq_timer_set_skew(struct snd_seq_timer *tmr, unsigned int skew, in snd_seq_timer_set_skew() argument
256 if (snd_BUG_ON(!tmr)) in snd_seq_timer_set_skew()
264 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_set_skew()
265 tmr->skew = skew; in snd_seq_timer_set_skew()
266 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_set_skew()
273 struct snd_seq_timer *tmr; in snd_seq_timer_open() local
277 tmr = q->timer; in snd_seq_timer_open()
278 if (snd_BUG_ON(!tmr)) in snd_seq_timer_open()
280 if (tmr->timeri) in snd_seq_timer_open()
283 if (tmr->type != SNDRV_SEQ_TIMER_ALSA) /* standard ALSA timer */ in snd_seq_timer_open()
285 if (tmr->alsa_id.dev_class != SNDRV_TIMER_CLASS_SLAVE) in snd_seq_timer_open()
286 tmr->alsa_id.dev_sclass = SNDRV_TIMER_SCLASS_SEQUENCER; in snd_seq_timer_open()
287 err = snd_timer_open(&t, str, &tmr->alsa_id, q->queue); in snd_seq_timer_open()
288 if (err < 0 && tmr->alsa_id.dev_class != SNDRV_TIMER_CLASS_SLAVE) { in snd_seq_timer_open()
289 if (tmr->alsa_id.dev_class != SNDRV_TIMER_CLASS_GLOBAL || in snd_seq_timer_open()
290 tmr->alsa_id.device != SNDRV_TIMER_GLOBAL_SYSTEM) { in snd_seq_timer_open()
307 spin_lock_irq(&tmr->lock); in snd_seq_timer_open()
308 tmr->timeri = t; in snd_seq_timer_open()
309 spin_unlock_irq(&tmr->lock); in snd_seq_timer_open()
315 struct snd_seq_timer *tmr; in snd_seq_timer_close() local
318 tmr = q->timer; in snd_seq_timer_close()
319 if (snd_BUG_ON(!tmr)) in snd_seq_timer_close()
321 spin_lock_irq(&tmr->lock); in snd_seq_timer_close()
322 t = tmr->timeri; in snd_seq_timer_close()
323 tmr->timeri = NULL; in snd_seq_timer_close()
324 spin_unlock_irq(&tmr->lock); in snd_seq_timer_close()
330 static int seq_timer_stop(struct snd_seq_timer *tmr) in seq_timer_stop() argument
332 if (! tmr->timeri) in seq_timer_stop()
334 if (!tmr->running) in seq_timer_stop()
336 tmr->running = 0; in seq_timer_stop()
337 snd_timer_pause(tmr->timeri); in seq_timer_stop()
341 int snd_seq_timer_stop(struct snd_seq_timer *tmr) in snd_seq_timer_stop() argument
346 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_stop()
347 err = seq_timer_stop(tmr); in snd_seq_timer_stop()
348 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_stop()
352 static int initialize_timer(struct snd_seq_timer *tmr) in initialize_timer() argument
357 t = tmr->timeri->timer; in initialize_timer()
361 freq = tmr->preferred_resolution; in initialize_timer()
369 tmr->ticks = 1; in initialize_timer()
375 tmr->ticks = (unsigned int)(1000000000uL / (r * freq)); in initialize_timer()
376 if (! tmr->ticks) in initialize_timer()
377 tmr->ticks = 1; in initialize_timer()
380 tmr->initialized = 1; in initialize_timer()
384 static int seq_timer_start(struct snd_seq_timer *tmr) in seq_timer_start() argument
386 if (! tmr->timeri) in seq_timer_start()
388 if (tmr->running) in seq_timer_start()
389 seq_timer_stop(tmr); in seq_timer_start()
390 seq_timer_reset(tmr); in seq_timer_start()
391 if (initialize_timer(tmr) < 0) in seq_timer_start()
393 snd_timer_start(tmr->timeri, tmr->ticks); in seq_timer_start()
394 tmr->running = 1; in seq_timer_start()
395 do_gettimeofday(&tmr->last_update); in seq_timer_start()
399 int snd_seq_timer_start(struct snd_seq_timer *tmr) in snd_seq_timer_start() argument
404 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_start()
405 err = seq_timer_start(tmr); in snd_seq_timer_start()
406 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_start()
410 static int seq_timer_continue(struct snd_seq_timer *tmr) in seq_timer_continue() argument
412 if (! tmr->timeri) in seq_timer_continue()
414 if (tmr->running) in seq_timer_continue()
416 if (! tmr->initialized) { in seq_timer_continue()
417 seq_timer_reset(tmr); in seq_timer_continue()
418 if (initialize_timer(tmr) < 0) in seq_timer_continue()
421 snd_timer_start(tmr->timeri, tmr->ticks); in seq_timer_continue()
422 tmr->running = 1; in seq_timer_continue()
423 do_gettimeofday(&tmr->last_update); in seq_timer_continue()
427 int snd_seq_timer_continue(struct snd_seq_timer *tmr) in snd_seq_timer_continue() argument
432 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_continue()
433 err = seq_timer_continue(tmr); in snd_seq_timer_continue()
434 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_continue()
439 snd_seq_real_time_t snd_seq_timer_get_cur_time(struct snd_seq_timer *tmr, in snd_seq_timer_get_cur_time() argument
445 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_get_cur_time()
446 cur_time = tmr->cur_time; in snd_seq_timer_get_cur_time()
447 if (adjust_ktime && tmr->running) { in snd_seq_timer_get_cur_time()
451 usec = (int)(tm.tv_usec - tmr->last_update.tv_usec); in snd_seq_timer_get_cur_time()
454 cur_time.tv_sec += tm.tv_sec - tmr->last_update.tv_sec - 1; in snd_seq_timer_get_cur_time()
457 cur_time.tv_sec += tm.tv_sec - tmr->last_update.tv_sec; in snd_seq_timer_get_cur_time()
461 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_get_cur_time()
467 snd_seq_tick_time_t snd_seq_timer_get_cur_tick(struct snd_seq_timer *tmr) in snd_seq_timer_get_cur_tick() argument
472 spin_lock_irqsave(&tmr->lock, flags); in snd_seq_timer_get_cur_tick()
473 cur_tick = tmr->tick.cur_tick; in snd_seq_timer_get_cur_tick()
474 spin_unlock_irqrestore(&tmr->lock, flags); in snd_seq_timer_get_cur_tick()
486 struct snd_seq_timer *tmr; in snd_seq_info_timer_read() local
495 tmr = q->timer; in snd_seq_info_timer_read()
496 if (!tmr) in snd_seq_info_timer_read()
498 ti = tmr->timeri; in snd_seq_info_timer_read()
502 resolution = snd_timer_resolution(ti) * tmr->ticks; in snd_seq_info_timer_read()
504 snd_iprintf(buffer, " Skew : %u / %u\n", tmr->skew, tmr->skew_base); in snd_seq_info_timer_read()