• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/src/linux/linux-2.6/sound/core/seq/

Lines Matching defs:tmr

65 	struct snd_seq_timer *tmr;
67 tmr = kzalloc(sizeof(*tmr), GFP_KERNEL);
68 if (tmr == NULL) {
72 spin_lock_init(&tmr->lock);
75 snd_seq_timer_defaults(tmr);
78 snd_seq_timer_reset(tmr);
80 return tmr;
84 void snd_seq_timer_delete(struct snd_seq_timer **tmr)
86 struct snd_seq_timer *t = *tmr;
87 *tmr = NULL;
102 void snd_seq_timer_defaults(struct snd_seq_timer * tmr)
105 tmr->ppq = 96; /* 96 PPQ */
106 tmr->tempo = 500000; /* 120 BPM */
107 snd_seq_timer_set_tick_resolution(&tmr->tick, tmr->tempo, tmr->ppq);
108 tmr->running = 0;
110 tmr->type = SNDRV_SEQ_TIMER_ALSA;
111 tmr->alsa_id.dev_class = seq_default_timer_class;
112 tmr->alsa_id.dev_sclass = seq_default_timer_sclass;
113 tmr->alsa_id.card = seq_default_timer_card;
114 tmr->alsa_id.device = seq_default_timer_device;
115 tmr->alsa_id.subdevice = seq_default_timer_subdevice;
116 tmr->preferred_resolution = seq_default_timer_resolution;
118 tmr->skew = tmr->skew_base = SKEW_BASE;
121 void snd_seq_timer_reset(struct snd_seq_timer * tmr)
125 spin_lock_irqsave(&tmr->lock, flags);
128 tmr->cur_time.tv_sec = 0;
129 tmr->cur_time.tv_nsec = 0;
131 tmr->tick.cur_tick = 0;
132 tmr->tick.fraction = 0;
134 spin_unlock_irqrestore(&tmr->lock, flags);
145 struct snd_seq_timer *tmr;
149 tmr = q->timer;
150 if (tmr == NULL)
152 if (!tmr->running)
156 if (tmr->skew != tmr->skew_base) {
157 resolution = (resolution >> 16) * tmr->skew +
158 (((resolution & 0xffff) * tmr->skew) >> 16);
161 spin_lock_irqsave(&tmr->lock, flags);
164 snd_seq_inc_time_nsec(&tmr->cur_time, resolution);
167 snd_seq_timer_update_tick(&tmr->tick, resolution);
170 do_gettimeofday(&tmr->last_update);
172 spin_unlock_irqrestore(&tmr->lock, flags);
179 int snd_seq_timer_set_tempo(struct snd_seq_timer * tmr, int tempo)
183 snd_assert(tmr, return -EINVAL);
186 spin_lock_irqsave(&tmr->lock, flags);
187 if ((unsigned int)tempo != tmr->tempo) {
188 tmr->tempo = tempo;
189 snd_seq_timer_set_tick_resolution(&tmr->tick, tmr->tempo, tmr->ppq);
191 spin_unlock_irqrestore(&tmr->lock, flags);
196 int snd_seq_timer_set_ppq(struct snd_seq_timer * tmr, int ppq)
200 snd_assert(tmr, return -EINVAL);
203 spin_lock_irqsave(&tmr->lock, flags);
204 if (tmr->running && (ppq != tmr->ppq)) {
207 spin_unlock_irqrestore(&tmr->lock, flags);
212 tmr->ppq = ppq;
213 snd_seq_timer_set_tick_resolution(&tmr->tick, tmr->tempo, tmr->ppq);
214 spin_unlock_irqrestore(&tmr->lock, flags);
219 int snd_seq_timer_set_position_tick(struct snd_seq_timer *tmr,
224 snd_assert(tmr, return -EINVAL);
226 spin_lock_irqsave(&tmr->lock, flags);
227 tmr->tick.cur_tick = position;
228 tmr->tick.fraction = 0;
229 spin_unlock_irqrestore(&tmr->lock, flags);
234 int snd_seq_timer_set_position_time(struct snd_seq_timer *tmr,
239 snd_assert(tmr, return -EINVAL);
242 spin_lock_irqsave(&tmr->lock, flags);
243 tmr->cur_time = position;
244 spin_unlock_irqrestore(&tmr->lock, flags);
249 int snd_seq_timer_set_skew(struct snd_seq_timer *tmr, unsigned int skew,
254 snd_assert(tmr, return -EINVAL);
260 spin_lock_irqsave(&tmr->lock, flags);
261 tmr->skew = skew;
262 spin_unlock_irqrestore(&tmr->lock, flags);
269 struct snd_seq_timer *tmr;
273 tmr = q->timer;
274 snd_assert(tmr != NULL, return -EINVAL);
275 if (tmr->timeri)
278 if (tmr->type != SNDRV_SEQ_TIMER_ALSA) /* standard ALSA timer */
280 if (tmr->alsa_id.dev_class != SNDRV_TIMER_CLASS_SLAVE)
281 tmr->alsa_id.dev_sclass = SNDRV_TIMER_SCLASS_SEQUENCER;
282 err = snd_timer_open(&t, str, &tmr->alsa_id, q->queue);
283 if (err < 0 && tmr->alsa_id.dev_class != SNDRV_TIMER_CLASS_SLAVE) {
284 if (tmr->alsa_id.dev_class != SNDRV_TIMER_CLASS_GLOBAL ||
285 tmr->alsa_id.device != SNDRV_TIMER_GLOBAL_SYSTEM) {
302 tmr->timeri = t;
308 struct snd_seq_timer *tmr;
310 tmr = q->timer;
311 snd_assert(tmr != NULL, return -EINVAL);
312 if (tmr->timeri) {
313 snd_timer_stop(tmr->timeri);
314 snd_timer_close(tmr->timeri);
315 tmr->timeri = NULL;
320 int snd_seq_timer_stop(struct snd_seq_timer * tmr)
322 if (! tmr->timeri)
324 if (!tmr->running)
326 tmr->running = 0;
327 snd_timer_pause(tmr->timeri);
331 static int initialize_timer(struct snd_seq_timer *tmr)
336 t = tmr->timeri->timer;
339 freq = tmr->preferred_resolution;
347 tmr->ticks = 1;
353 tmr->ticks = (unsigned int)(1000000000uL / (r * freq));
354 if (! tmr->ticks)
355 tmr->ticks = 1;
358 tmr->initialized = 1;
362 int snd_seq_timer_start(struct snd_seq_timer * tmr)
364 if (! tmr->timeri)
366 if (tmr->running)
367 snd_seq_timer_stop(tmr);
368 snd_seq_timer_reset(tmr);
369 if (initialize_timer(tmr) < 0)
371 snd_timer_start(tmr->timeri, tmr->ticks);
372 tmr->running = 1;
373 do_gettimeofday(&tmr->last_update);
377 int snd_seq_timer_continue(struct snd_seq_timer * tmr)
379 if (! tmr->timeri)
381 if (tmr->running)
383 if (! tmr->initialized) {
384 snd_seq_timer_reset(tmr);
385 if (initialize_timer(tmr) < 0)
388 snd_timer_start(tmr->timeri, tmr->ticks);
389 tmr->running = 1;
390 do_gettimeofday(&tmr->last_update);
395 snd_seq_real_time_t snd_seq_timer_get_cur_time(struct snd_seq_timer *tmr)
399 cur_time = tmr->cur_time;
400 if (tmr->running) {
404 usec = (int)(tm.tv_usec - tmr->last_update.tv_usec);
407 cur_time.tv_sec += tm.tv_sec - tmr->last_update.tv_sec - 1;
410 cur_time.tv_sec += tm.tv_sec - tmr->last_update.tv_sec;
420 snd_seq_tick_time_t snd_seq_timer_get_cur_tick(struct snd_seq_timer *tmr)
422 return tmr->tick.cur_tick;
433 struct snd_seq_timer *tmr;
441 if ((tmr = q->timer) == NULL ||
442 (ti = tmr->timeri) == NULL) {
447 resolution = snd_timer_resolution(ti) * tmr->ticks;
449 snd_iprintf(buffer, " Skew : %u / %u\n", tmr->skew, tmr->skew_base);