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

Lines Matching refs:timer

31 #include <sound/timer.h>
48 MODULE_DESCRIPTION("ALSA timer interface");
84 static int snd_timer_free(struct snd_timer *timer);
89 static void snd_timer_reschedule(struct snd_timer * timer, unsigned long ticks_left);
92 * create a timer instance with the given owner string.
93 * when timer is not NULL, increments the module counter
96 struct snd_timer *timer)
113 timeri->timer = timer;
114 if (timer && !try_module_get(timer->module)) {
124 * find a timer instance from the given timer id
128 struct snd_timer *timer = NULL;
130 list_for_each_entry(timer, &snd_timer_list, device_list) {
131 if (timer->tmr_class != tid->dev_class)
133 if ((timer->tmr_class == SNDRV_TIMER_CLASS_CARD ||
134 timer->tmr_class == SNDRV_TIMER_CLASS_PCM) &&
135 (timer->card == NULL ||
136 timer->card->number != tid->card))
138 if (timer->tmr_device != tid->device)
140 if (timer->tmr_subdevice != tid->subdevice)
142 return timer;
156 request_module("snd-timer-%i", tid->device);
178 struct snd_timer *timer;
181 list_for_each_entry(timer, &snd_timer_list, device_list) {
182 list_for_each_entry(master, &timer->open_list_head, open_list) {
190 slave->timer = master->timer;
215 slave->timer = master->timer;
225 * open a timer instance
232 struct snd_timer *timer;
260 timer = snd_timer_find(tid);
262 if (timer == NULL) {
266 timer = snd_timer_find(tid);
269 if (!timer) {
273 if (!list_empty(&timer->open_list_head)) {
274 timeri = list_entry(timer->open_list_head.next,
281 timeri = snd_timer_instance_new(owner, timer);
288 if (list_empty(&timer->open_list_head) && timer->hw.open)
289 timer->hw.open(timer);
290 list_add_tail(&timeri->open_list, &timer->open_list_head);
301 * close a timer instance
305 struct snd_timer *timer = NULL;
310 /* force to stop the timer */
326 timer = timeri->timer;
328 spin_lock_irq(&timer->lock);
330 spin_unlock_irq(&timer->lock);
332 spin_lock_irq(&timer->lock);
334 spin_unlock_irq(&timer->lock);
337 if (timer && list_empty(&timer->open_list_head) &&
338 timer->hw.close)
339 timer->hw.close(timer);
347 slave->timer = NULL;
356 if (timer)
357 module_put(timer->module);
363 struct snd_timer * timer;
367 if ((timer = timeri->timer) != NULL) {
368 if (timer->hw.c_resolution)
369 return timer->hw.c_resolution(timer);
370 return timer->hw.resolution;
377 struct snd_timer *timer;
393 timer = ti->timer;
394 if (timer == NULL)
396 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
398 spin_lock_irqsave(&timer->lock, flags);
402 spin_unlock_irqrestore(&timer->lock, flags);
405 static int snd_timer_start1(struct snd_timer *timer, struct snd_timer_instance *timeri,
409 list_add_tail(&timeri->active_list, &timer->active_list_head);
410 if (timer->running) {
411 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
413 timer->flags |= SNDRV_TIMER_FLG_RESCHED;
417 timer->sticks = sticks;
418 timer->hw.start(timer);
420 timer->running++;
440 * start the timer instance
444 struct snd_timer *timer;
455 timer = timeri->timer;
456 if (timer == NULL)
458 spin_lock_irqsave(&timer->lock, flags);
461 result = snd_timer_start1(timer, timeri, ticks);
462 spin_unlock_irqrestore(&timer->lock, flags);
470 struct snd_timer *timer;
483 timer = timeri->timer;
484 if (!timer)
486 spin_lock_irqsave(&timer->lock, flags);
490 !(--timer->running)) {
491 timer->hw.stop(timer);
492 if (timer->flags & SNDRV_TIMER_FLG_RESCHED) {
493 timer->flags &= ~SNDRV_TIMER_FLG_RESCHED;
494 snd_timer_reschedule(timer, 0);
495 if (timer->flags & SNDRV_TIMER_FLG_CHANGE) {
496 timer->flags &= ~SNDRV_TIMER_FLG_CHANGE;
497 timer->hw.start(timer);
504 spin_unlock_irqrestore(&timer->lock, flags);
512 * stop the timer instance.
514 * do not call this from the timer callback!
518 struct snd_timer *timer;
525 timer = timeri->timer;
526 spin_lock_irqsave(&timer->lock, flags);
529 spin_unlock_irqrestore(&timer->lock, flags);
538 struct snd_timer *timer;
546 timer = timeri->timer;
547 if (! timer)
549 spin_lock_irqsave(&timer->lock, flags);
553 result = snd_timer_start1(timer, timeri, timer->sticks);
554 spin_unlock_irqrestore(&timer->lock, flags);
568 * reschedule the timer
571 * when the scheduling ticks is changed set CHANGE flag to reprogram the timer.
573 static void snd_timer_reschedule(struct snd_timer * timer, unsigned long ticks_left)
578 list_for_each_entry(ti, &timer->active_list_head, active_list) {
582 timer->running++;
590 timer->flags &= ~SNDRV_TIMER_FLG_RESCHED;
593 if (ticks > timer->hw.ticks)
594 ticks = timer->hw.ticks;
596 timer->flags |= SNDRV_TIMER_FLG_CHANGE;
597 timer->sticks = ticks;
601 * timer tasklet
606 struct snd_timer *timer = (struct snd_timer *) arg;
612 spin_lock_irqsave(&timer->lock, flags);
614 while (!list_empty(&timer->sack_list_head)) {
615 p = timer->sack_list_head.next; /* get first item */
626 spin_unlock(&timer->lock);
629 spin_lock(&timer->lock);
632 spin_unlock_irqrestore(&timer->lock, flags);
636 * timer interrupt
638 * ticks_left is usually equal to timer->sticks.
641 void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
649 if (timer == NULL)
652 spin_lock_irqsave(&timer->lock, flags);
655 if (timer->hw.c_resolution)
656 resolution = timer->hw.c_resolution(timer);
658 resolution = timer->hw.resolution;
665 list_for_each_entry_safe(ti, tmp, &timer->active_list_head,
681 if (--timer->running)
684 if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) ||
686 ack_list_head = &timer->ack_list_head;
688 ack_list_head = &timer->sack_list_head;
698 if (timer->flags & SNDRV_TIMER_FLG_RESCHED)
699 snd_timer_reschedule(timer, timer->sticks);
700 if (timer->running) {
701 if (timer->hw.flags & SNDRV_TIMER_HW_STOP) {
702 timer->hw.stop(timer);
703 timer->flags |= SNDRV_TIMER_FLG_CHANGE;
705 if (!(timer->hw.flags & SNDRV_TIMER_HW_AUTO) ||
706 (timer->flags & SNDRV_TIMER_FLG_CHANGE)) {
707 /* restart timer */
708 timer->flags &= ~SNDRV_TIMER_FLG_CHANGE;
709 timer->hw.start(timer);
712 timer->hw.stop(timer);
716 while (!list_empty(&timer->ack_list_head)) {
717 p = timer->ack_list_head.next; /* get first item */
727 spin_unlock(&timer->lock);
730 spin_lock(&timer->lock);
735 use_tasklet = !list_empty(&timer->sack_list_head);
736 spin_unlock_irqrestore(&timer->lock, flags);
739 tasklet_hi_schedule(&timer->task_queue);
749 struct snd_timer *timer;
760 timer = kzalloc(sizeof(*timer), GFP_KERNEL);
761 if (timer == NULL) {
762 snd_printk(KERN_ERR "timer: cannot allocate\n");
765 timer->tmr_class = tid->dev_class;
766 timer->card = card;
767 timer->tmr_device = tid->device;
768 timer->tmr_subdevice = tid->subdevice;
770 strlcpy(timer->id, id, sizeof(timer->id));
771 INIT_LIST_HEAD(&timer->device_list);
772 INIT_LIST_HEAD(&timer->open_list_head);
773 INIT_LIST_HEAD(&timer->active_list_head);
774 INIT_LIST_HEAD(&timer->ack_list_head);
775 INIT_LIST_HEAD(&timer->sack_list_head);
776 spin_lock_init(&timer->lock);
777 tasklet_init(&timer->task_queue, snd_timer_tasklet,
778 (unsigned long)timer);
780 timer->module = card->module;
781 err = snd_device_new(card, SNDRV_DEV_TIMER, timer, &ops);
783 snd_timer_free(timer);
787 *rtimer = timer;
791 static int snd_timer_free(struct snd_timer *timer)
793 snd_assert(timer != NULL, return -ENXIO);
796 if (! list_empty(&timer->open_list_head)) {
799 snd_printk(KERN_WARNING "timer %p is busy?\n", timer);
800 list_for_each_safe(p, n, &timer->open_list_head) {
803 ti->timer = NULL;
806 list_del(&timer->device_list);
809 if (timer->private_free)
810 timer->private_free(timer);
811 kfree(timer);
817 struct snd_timer *timer = device->device_data;
818 return snd_timer_free(timer);
823 struct snd_timer *timer = dev->device_data;
826 snd_assert(timer != NULL && timer->hw.start != NULL &&
827 timer->hw.stop != NULL, return -ENXIO);
828 if (!(timer->hw.flags & SNDRV_TIMER_HW_SLAVE) &&
829 !timer->hw.resolution && timer->hw.c_resolution == NULL)
834 if (timer1->tmr_class > timer->tmr_class)
836 if (timer1->tmr_class < timer->tmr_class)
838 if (timer1->card && timer->card) {
839 if (timer1->card->number > timer->card->number)
841 if (timer1->card->number < timer->card->number)
844 if (timer1->tmr_device > timer->tmr_device)
846 if (timer1->tmr_device < timer->tmr_device)
848 if (timer1->tmr_subdevice > timer->tmr_subdevice)
850 if (timer1->tmr_subdevice < timer->tmr_subdevice)
856 list_add_tail(&timer->device_list, &timer1->device_list);
863 struct snd_timer *timer = device->device_data;
865 list_del_init(&timer->device_list);
870 void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp)
876 if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE))
880 spin_lock_irqsave(&timer->lock, flags);
884 if (timer->hw.c_resolution)
885 resolution = timer->hw.c_resolution(timer);
887 resolution = timer->hw.resolution;
889 list_for_each_entry(ti, &timer->active_list_head, active_list) {
896 spin_unlock_irqrestore(&timer->lock, flags);
914 int snd_timer_global_free(struct snd_timer *timer)
916 return snd_timer_free(timer);
919 int snd_timer_global_register(struct snd_timer *timer)
924 dev.device_data = timer;
929 * System timer
941 struct snd_timer *timer = (struct snd_timer *)data;
942 struct snd_timer_system_private *priv = timer->private_data;
946 snd_timer_interrupt(timer, (long)jiff - (long)priv->last_jiffies);
949 static int snd_timer_s_start(struct snd_timer * timer)
954 priv = (struct snd_timer_system_private *) timer->private_data;
956 if (priv->correction > timer->sticks - 1) {
957 priv->correction -= timer->sticks - 1;
960 njiff += timer->sticks - priv->correction;
968 static int snd_timer_s_stop(struct snd_timer * timer)
973 priv = (struct snd_timer_system_private *) timer->private_data;
977 timer->sticks = priv->last_expires - jiff;
979 timer->sticks = 1;
993 static void snd_timer_free_system(struct snd_timer *timer)
995 kfree(timer->private_data);
1000 struct snd_timer *timer;
1004 err = snd_timer_global_new("system", SNDRV_TIMER_GLOBAL_SYSTEM, &timer);
1007 strcpy(timer->name, "system timer");
1008 timer->hw = snd_timer_system;
1011 snd_timer_free(timer);
1016 priv->tlist.data = (unsigned long) timer;
1017 timer->private_data = priv;
1018 timer->private_free = snd_timer_free_system;
1019 return snd_timer_global_register(timer);
1030 struct snd_timer *timer;
1034 list_for_each_entry(timer, &snd_timer_list, device_list) {
1035 switch (timer->tmr_class) {
1037 snd_iprintf(buffer, "G%i: ", timer->tmr_device);
1041 timer->card->number, timer->tmr_device);
1044 snd_iprintf(buffer, "P%i-%i-%i: ", timer->card->number,
1045 timer->tmr_device, timer->tmr_subdevice);
1048 snd_iprintf(buffer, "?%i-%i-%i-%i: ", timer->tmr_class,
1049 timer->card ? timer->card->number : -1,
1050 timer->tmr_device, timer->tmr_subdevice);
1052 snd_iprintf(buffer, "%s :", timer->name);
1053 if (timer->hw.resolution)
1055 timer->hw.resolution / 1000,
1056 timer->hw.resolution % 1000,
1057 timer->hw.ticks);
1058 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
1061 list_for_each_entry(ti, &timer->open_list_head, open_list)
1270 static void snd_timer_user_copy_id(struct snd_timer_id *id, struct snd_timer *timer)
1272 id->dev_class = timer->tmr_class;
1274 id->card = timer->card ? timer->card->number : -1;
1275 id->device = timer->tmr_device;
1276 id->subdevice = timer->tmr_subdevice;
1282 struct snd_timer *timer;
1292 timer = list_entry(snd_timer_list.next,
1294 snd_timer_user_copy_id(&id, timer);
1301 timer = list_entry(p, struct snd_timer, device_list);
1302 if (timer->tmr_class > SNDRV_TIMER_CLASS_GLOBAL) {
1303 snd_timer_user_copy_id(&id, timer);
1306 if (timer->tmr_device >= id.device) {
1307 snd_timer_user_copy_id(&id, timer);
1334 timer = list_entry(p, struct snd_timer, device_list);
1335 if (timer->tmr_class > id.dev_class) {
1336 snd_timer_user_copy_id(&id, timer);
1339 if (timer->tmr_class < id.dev_class)
1341 if (timer->card->number > id.card) {
1342 snd_timer_user_copy_id(&id, timer);
1345 if (timer->card->number < id.card)
1347 if (timer->tmr_device > id.device) {
1348 snd_timer_user_copy_id(&id, timer);
1351 if (timer->tmr_device < id.device)
1353 if (timer->tmr_subdevice > id.subdevice) {
1354 snd_timer_user_copy_id(&id, timer);
1357 if (timer->tmr_subdevice < id.subdevice)
1359 snd_timer_user_copy_id(&id, timer);
1552 t = tu->timeri->timer;
1582 t = tu->timeri->timer;
1924 "system timer");
1928 snd_printk(KERN_ERR "unable to register system timer (%i)\n",
1931 &snd_timer_f_ops, NULL, "timer")) < 0)
1932 snd_printk(KERN_ERR "unable to register timer device (%i)\n",
1943 /* unregister the system timer */
1945 struct snd_timer *timer = list_entry(p, struct snd_timer, device_list);
1946 snd_timer_free(timer);