• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/sound/core/seq/

Lines Matching defs:tmr

36 static void snd_seq_timer_set_tick_resolution(struct snd_seq_timer *tmr)
38 if (tmr->tempo < 1000000)
39 tmr->tick.resolution = (tmr->tempo * 1000) / tmr->ppq;
43 s = tmr->tempo % tmr->ppq;
44 s = (s * 1000) / tmr->ppq;
45 tmr->tick.resolution = (tmr->tempo / tmr->ppq) * 1000;
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);
56 struct snd_seq_timer *tmr;
58 tmr = kzalloc(sizeof(*tmr), GFP_KERNEL);
59 if (tmr == NULL) {
63 spin_lock_init(&tmr->lock);
66 snd_seq_timer_defaults(tmr);
69 snd_seq_timer_reset(tmr);
71 return tmr;
75 void snd_seq_timer_delete(struct snd_seq_timer **tmr)
77 struct snd_seq_timer *t = *tmr;
78 *tmr = NULL;
93 void snd_seq_timer_defaults(struct snd_seq_timer * tmr)
96 tmr->ppq = 96; /* 96 PPQ */
97 tmr->tempo = 500000; /* 120 BPM */
98 snd_seq_timer_set_tick_resolution(tmr);
99 tmr->running = 0;
101 tmr->type = SNDRV_SEQ_TIMER_ALSA;
102 tmr->alsa_id.dev_class = seq_default_timer_class;
103 tmr->alsa_id.dev_sclass = seq_default_timer_sclass;
104 tmr->alsa_id.card = seq_default_timer_card;
105 tmr->alsa_id.device = seq_default_timer_device;
106 tmr->alsa_id.subdevice = seq_default_timer_subdevice;
107 tmr->preferred_resolution = seq_default_timer_resolution;
109 tmr->skew = tmr->skew_base = SKEW_BASE;
112 void snd_seq_timer_reset(struct snd_seq_timer * tmr)
116 spin_lock_irqsave(&tmr->lock, flags);
119 tmr->cur_time.tv_sec = 0;
120 tmr->cur_time.tv_nsec = 0;
122 tmr->tick.cur_tick = 0;
123 tmr->tick.fraction = 0;
125 spin_unlock_irqrestore(&tmr->lock, flags);
136 struct snd_seq_timer *tmr;
140 tmr = q->timer;
141 if (tmr == NULL)
143 if (!tmr->running)
147 if (tmr->skew != tmr->skew_base) {
148 resolution = (resolution >> 16) * tmr->skew +
149 (((resolution & 0xffff) * tmr->skew) >> 16);
152 spin_lock_irqsave(&tmr->lock, flags);
155 snd_seq_inc_time_nsec(&tmr->cur_time, resolution);
158 snd_seq_timer_update_tick(&tmr->tick, resolution);
161 do_gettimeofday(&tmr->last_update);
163 spin_unlock_irqrestore(&tmr->lock, flags);
170 int snd_seq_timer_set_tempo(struct snd_seq_timer * tmr, int tempo)
174 if (snd_BUG_ON(!tmr))
178 spin_lock_irqsave(&tmr->lock, flags);
179 if ((unsigned int)tempo != tmr->tempo) {
180 tmr->tempo = tempo;
181 snd_seq_timer_set_tick_resolution(tmr);
183 spin_unlock_irqrestore(&tmr->lock, flags);
188 int snd_seq_timer_set_ppq(struct snd_seq_timer * tmr, int ppq)
192 if (snd_BUG_ON(!tmr))
196 spin_lock_irqsave(&tmr->lock, flags);
197 if (tmr->running && (ppq != tmr->ppq)) {
200 spin_unlock_irqrestore(&tmr->lock, flags);
205 tmr->ppq = ppq;
206 snd_seq_timer_set_tick_resolution(tmr);
207 spin_unlock_irqrestore(&tmr->lock, flags);
212 int snd_seq_timer_set_position_tick(struct snd_seq_timer *tmr,
217 if (snd_BUG_ON(!tmr))
220 spin_lock_irqsave(&tmr->lock, flags);
221 tmr->tick.cur_tick = position;
222 tmr->tick.fraction = 0;
223 spin_unlock_irqrestore(&tmr->lock, flags);
228 int snd_seq_timer_set_position_time(struct snd_seq_timer *tmr,
233 if (snd_BUG_ON(!tmr))
237 spin_lock_irqsave(&tmr->lock, flags);
238 tmr->cur_time = position;
239 spin_unlock_irqrestore(&tmr->lock, flags);
244 int snd_seq_timer_set_skew(struct snd_seq_timer *tmr, unsigned int skew,
249 if (snd_BUG_ON(!tmr))
256 spin_lock_irqsave(&tmr->lock, flags);
257 tmr->skew = skew;
258 spin_unlock_irqrestore(&tmr->lock, flags);
265 struct snd_seq_timer *tmr;
269 tmr = q->timer;
270 if (snd_BUG_ON(!tmr))
272 if (tmr->timeri)
275 if (tmr->type != SNDRV_SEQ_TIMER_ALSA) /* standard ALSA timer */
277 if (tmr->alsa_id.dev_class != SNDRV_TIMER_CLASS_SLAVE)
278 tmr->alsa_id.dev_sclass = SNDRV_TIMER_SCLASS_SEQUENCER;
279 err = snd_timer_open(&t, str, &tmr->alsa_id, q->queue);
280 if (err < 0 && tmr->alsa_id.dev_class != SNDRV_TIMER_CLASS_SLAVE) {
281 if (tmr->alsa_id.dev_class != SNDRV_TIMER_CLASS_GLOBAL ||
282 tmr->alsa_id.device != SNDRV_TIMER_GLOBAL_SYSTEM) {
299 tmr->timeri = t;
305 struct snd_seq_timer *tmr;
307 tmr = q->timer;
308 if (snd_BUG_ON(!tmr))
310 if (tmr->timeri) {
311 snd_timer_stop(tmr->timeri);
312 snd_timer_close(tmr->timeri);
313 tmr->timeri = NULL;
318 int snd_seq_timer_stop(struct snd_seq_timer * tmr)
320 if (! tmr->timeri)
322 if (!tmr->running)
324 tmr->running = 0;
325 snd_timer_pause(tmr->timeri);
329 static int initialize_timer(struct snd_seq_timer *tmr)
334 t = tmr->timeri->timer;
338 freq = tmr->preferred_resolution;
346 tmr->ticks = 1;
352 tmr->ticks = (unsigned int)(1000000000uL / (r * freq));
353 if (! tmr->ticks)
354 tmr->ticks = 1;
357 tmr->initialized = 1;
361 int snd_seq_timer_start(struct snd_seq_timer * tmr)
363 if (! tmr->timeri)
365 if (tmr->running)
366 snd_seq_timer_stop(tmr);
367 snd_seq_timer_reset(tmr);
368 if (initialize_timer(tmr) < 0)
370 snd_timer_start(tmr->timeri, tmr->ticks);
371 tmr->running = 1;
372 do_gettimeofday(&tmr->last_update);
376 int snd_seq_timer_continue(struct snd_seq_timer * tmr)
378 if (! tmr->timeri)
380 if (tmr->running)
382 if (! tmr->initialized) {
383 snd_seq_timer_reset(tmr);
384 if (initialize_timer(tmr) < 0)
387 snd_timer_start(tmr->timeri, tmr->ticks);
388 tmr->running = 1;
389 do_gettimeofday(&tmr->last_update);
394 snd_seq_real_time_t snd_seq_timer_get_cur_time(struct snd_seq_timer *tmr)
398 cur_time = tmr->cur_time;
399 if (tmr->running) {
403 usec = (int)(tm.tv_usec - tmr->last_update.tv_usec);
406 cur_time.tv_sec += tm.tv_sec - tmr->last_update.tv_sec - 1;
409 cur_time.tv_sec += tm.tv_sec - tmr->last_update.tv_sec;
419 snd_seq_tick_time_t snd_seq_timer_get_cur_tick(struct snd_seq_timer *tmr)
421 return tmr->tick.cur_tick;
432 struct snd_seq_timer *tmr;
440 if ((tmr = q->timer) == NULL ||
441 (ti = tmr->timeri) == NULL) {
446 resolution = snd_timer_resolution(ti) * tmr->ticks;
448 snd_iprintf(buffer, " Skew : %u / %u\n", tmr->skew, tmr->skew_base);