X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fcore%2Fseq%2Fseq_queue.c;h=9b87bb0c7f33a3f4dcf266b8d5d1236004a62c92;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=c9ac37e8de23075623f813c110dbe96fc6c7489d;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c index c9ac37e8d..9b87bb0c7 100644 --- a/sound/core/seq/seq_queue.c +++ b/sound/core/seq/seq_queue.c @@ -29,7 +29,7 @@ * Aug. 30, 2000 Takashi Iwai * - Queues are managed in static array again, but with better way. * The API itself is identical. - * - The queue is locked when queue_t pinter is returned via + * - The queue is locked when struct snd_seq_queue pointer is returned via * queueptr(). This pointer *MUST* be released afterward by * queuefree(ptr). * - Addition of experimental sync support. @@ -48,8 +48,8 @@ #include "seq_info.h" /* list of allocated queues */ -static queue_t *queue_list[SNDRV_SEQ_MAX_QUEUES]; -static spinlock_t queue_list_lock = SPIN_LOCK_UNLOCKED; +static struct snd_seq_queue *queue_list[SNDRV_SEQ_MAX_QUEUES]; +static DEFINE_SPINLOCK(queue_list_lock); /* number of queues allocated */ static int num_queues; @@ -61,7 +61,7 @@ int snd_seq_queue_get_cur_queues(void) /*----------------------------------------------------------------*/ /* assign queue id and insert to list */ -static int queue_list_add(queue_t *q) +static int queue_list_add(struct snd_seq_queue *q) { int i; unsigned long flags; @@ -80,9 +80,9 @@ static int queue_list_add(queue_t *q) return -1; } -static queue_t *queue_list_remove(int id, int client) +static struct snd_seq_queue *queue_list_remove(int id, int client) { - queue_t *q; + struct snd_seq_queue *q; unsigned long flags; spin_lock_irqsave(&queue_list_lock, flags); @@ -107,11 +107,11 @@ static queue_t *queue_list_remove(int id, int client) /*----------------------------------------------------------------*/ /* create new queue (constructor) */ -static queue_t *queue_new(int owner, int locked) +static struct snd_seq_queue *queue_new(int owner, int locked) { - queue_t *q; + struct snd_seq_queue *q; - q = snd_kcalloc(sizeof(queue_t), GFP_KERNEL); + q = kzalloc(sizeof(*q), GFP_KERNEL); if (q == NULL) { snd_printd("malloc failed for snd_seq_queue_new()\n"); return NULL; @@ -119,7 +119,7 @@ static queue_t *queue_new(int owner, int locked) spin_lock_init(&q->owner_lock); spin_lock_init(&q->check_lock); - init_MUTEX(&q->timer_mutex); + mutex_init(&q->timer_mutex); snd_use_lock_init(&q->use_lock); q->queue = -1; @@ -142,7 +142,7 @@ static queue_t *queue_new(int owner, int locked) } /* delete queue (destructor) */ -static void queue_delete(queue_t *q) +static void queue_delete(struct snd_seq_queue *q) { /* stop and release the timer */ snd_seq_timer_stop(q->timer); @@ -187,7 +187,7 @@ void __exit snd_seq_queues_delete(void) */ int snd_seq_queue_alloc(int client, int locked, unsigned int info_flags) { - queue_t *q; + struct snd_seq_queue *q; q = queue_new(client, locked); if (q == NULL) @@ -204,7 +204,7 @@ int snd_seq_queue_alloc(int client, int locked, unsigned int info_flags) /* delete a queue - queue must be owned by the client */ int snd_seq_queue_delete(int client, int queueid) { - queue_t *q; + struct snd_seq_queue *q; if (queueid < 0 || queueid >= SNDRV_SEQ_MAX_QUEUES) return -EINVAL; @@ -218,9 +218,9 @@ int snd_seq_queue_delete(int client, int queueid) /* return pointer to queue structure for specified id */ -queue_t *queueptr(int queueid) +struct snd_seq_queue *queueptr(int queueid) { - queue_t *q; + struct snd_seq_queue *q; unsigned long flags; if (queueid < 0 || queueid >= SNDRV_SEQ_MAX_QUEUES) @@ -234,10 +234,10 @@ queue_t *queueptr(int queueid) } /* return the (first) queue matching with the specified name */ -queue_t *snd_seq_queue_find_name(char *name) +struct snd_seq_queue *snd_seq_queue_find_name(char *name) { int i; - queue_t *q; + struct snd_seq_queue *q; for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { if ((q = queueptr(i)) != NULL) { @@ -252,10 +252,10 @@ queue_t *snd_seq_queue_find_name(char *name) /* -------------------------------------------------------- */ -void snd_seq_check_queue(queue_t *q, int atomic, int hop) +void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop) { unsigned long flags; - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; if (q == NULL) return; @@ -273,7 +273,8 @@ void snd_seq_check_queue(queue_t *q, int atomic, int hop) __again: /* Process tick queue... */ while ((cell = snd_seq_prioq_cell_peek(q->tickq)) != NULL) { - if (snd_seq_compare_tick_time(&q->timer->tick.cur_tick, &cell->event.time.tick)) { + if (snd_seq_compare_tick_time(&q->timer->tick.cur_tick, + &cell->event.time.tick)) { cell = snd_seq_prioq_cell_out(q->tickq); if (cell) snd_seq_dispatch_event(cell, atomic, hop); @@ -286,7 +287,8 @@ void snd_seq_check_queue(queue_t *q, int atomic, int hop) /* Process time queue... */ while ((cell = snd_seq_prioq_cell_peek(q->timeq)) != NULL) { - if (snd_seq_compare_real_time(&q->timer->cur_time, &cell->event.time.time)) { + if (snd_seq_compare_real_time(&q->timer->cur_time, + &cell->event.time.time)) { cell = snd_seq_prioq_cell_out(q->timeq); if (cell) snd_seq_dispatch_event(cell, atomic, hop); @@ -309,10 +311,10 @@ void snd_seq_check_queue(queue_t *q, int atomic, int hop) /* enqueue a event to singe queue */ -int snd_seq_enqueue_event(snd_seq_event_cell_t *cell, int atomic, int hop) +int snd_seq_enqueue_event(struct snd_seq_event_cell *cell, int atomic, int hop) { int dest, err; - queue_t *q; + struct snd_seq_queue *q; snd_assert(cell != NULL, return -EINVAL); dest = cell->event.queue; /* destination queue */ @@ -327,7 +329,8 @@ int snd_seq_enqueue_event(snd_seq_event_cell_t *cell, int atomic, int hop) break; case SNDRV_SEQ_TIME_STAMP_REAL: - snd_seq_inc_real_time(&cell->event.time.time, &q->timer->cur_time); + snd_seq_inc_real_time(&cell->event.time.time, + &q->timer->cur_time); break; } cell->event.flags &= ~SNDRV_SEQ_TIME_MODE_MASK; @@ -361,7 +364,7 @@ int snd_seq_enqueue_event(snd_seq_event_cell_t *cell, int atomic, int hop) /*----------------------------------------------------------------*/ -static inline int check_access(queue_t *q, int client) +static inline int check_access(struct snd_seq_queue *q, int client) { return (q->owner == client) || (!q->locked && !q->klocked); } @@ -369,7 +372,7 @@ static inline int check_access(queue_t *q, int client) /* check if the client has permission to modify queue parameters. * if it does, lock the queue */ -static int queue_access_lock(queue_t *q, int client) +static int queue_access_lock(struct snd_seq_queue *q, int client) { unsigned long flags; int access_ok; @@ -383,7 +386,7 @@ static int queue_access_lock(queue_t *q, int client) } /* unlock the queue */ -static inline void queue_access_unlock(queue_t *q) +static inline void queue_access_unlock(struct snd_seq_queue *q) { unsigned long flags; @@ -395,7 +398,7 @@ static inline void queue_access_unlock(queue_t *q) /* exported - only checking permission */ int snd_seq_queue_check_access(int queueid, int client) { - queue_t *q = queueptr(queueid); + struct snd_seq_queue *q = queueptr(queueid); int access_ok; unsigned long flags; @@ -415,7 +418,7 @@ int snd_seq_queue_check_access(int queueid, int client) */ int snd_seq_queue_set_owner(int queueid, int client, int locked) { - queue_t *q = queueptr(queueid); + struct snd_seq_queue *q = queueptr(queueid); if (q == NULL) return -EINVAL; @@ -443,8 +446,8 @@ int snd_seq_queue_set_owner(int queueid, int client, int locked) int snd_seq_queue_timer_open(int queueid) { int result = 0; - queue_t *queue; - seq_timer_t *tmr; + struct snd_seq_queue *queue; + struct snd_seq_timer *tmr; queue = queueptr(queueid); if (queue == NULL) @@ -463,8 +466,8 @@ int snd_seq_queue_timer_open(int queueid) */ int snd_seq_queue_timer_close(int queueid) { - queue_t *queue; - seq_timer_t *tmr; + struct snd_seq_queue *queue; + struct snd_seq_timer *tmr; int result = 0; queue = queueptr(queueid); @@ -477,9 +480,10 @@ int snd_seq_queue_timer_close(int queueid) } /* change queue tempo and ppq */ -int snd_seq_queue_timer_set_tempo(int queueid, int client, snd_seq_queue_tempo_t *info) +int snd_seq_queue_timer_set_tempo(int queueid, int client, + struct snd_seq_queue_tempo *info) { - queue_t *q = queueptr(queueid); + struct snd_seq_queue *q = queueptr(queueid); int result; if (q == NULL) @@ -493,7 +497,8 @@ int snd_seq_queue_timer_set_tempo(int queueid, int client, snd_seq_queue_tempo_t if (result >= 0) result = snd_seq_timer_set_ppq(q->timer, info->ppq); if (result >= 0 && info->skew_base > 0) - result = snd_seq_timer_set_skew(q->timer, info->skew_value, info->skew_base); + result = snd_seq_timer_set_skew(q->timer, info->skew_value, + info->skew_base); queue_access_unlock(q); queuefree(q); return result; @@ -506,12 +511,12 @@ int snd_seq_queue_timer_set_tempo(int queueid, int client, snd_seq_queue_tempo_t */ int snd_seq_queue_use(int queueid, int client, int use) { - queue_t *queue; + struct snd_seq_queue *queue; queue = queueptr(queueid); if (queue == NULL) return -EINVAL; - down(&queue->timer_mutex); + mutex_lock(&queue->timer_mutex); if (use) { if (!test_and_set_bit(client, queue->clients_bitmap)) queue->clients++; @@ -526,7 +531,7 @@ int snd_seq_queue_use(int queueid, int client, int use) } else { snd_seq_timer_close(queue); } - up(&queue->timer_mutex); + mutex_unlock(&queue->timer_mutex); queuefree(queue); return 0; } @@ -538,7 +543,7 @@ int snd_seq_queue_use(int queueid, int client, int use) */ int snd_seq_queue_is_used(int queueid, int client) { - queue_t *q; + struct snd_seq_queue *q; int result; q = queueptr(queueid); @@ -559,7 +564,7 @@ void snd_seq_queue_client_termination(int client) { unsigned long flags; int i; - queue_t *q; + struct snd_seq_queue *q; for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { if ((q = queueptr(i)) == NULL) @@ -584,7 +589,7 @@ void snd_seq_queue_client_termination(int client) void snd_seq_queue_client_leave(int client) { int i; - queue_t *q; + struct snd_seq_queue *q; /* delete own queues from queue list */ for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { @@ -615,7 +620,7 @@ void snd_seq_queue_client_leave(int client) void snd_seq_queue_client_leave_cells(int client) { int i; - queue_t *q; + struct snd_seq_queue *q; for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { if ((q = queueptr(i)) == NULL) @@ -627,10 +632,10 @@ void snd_seq_queue_client_leave_cells(int client) } /* remove cells based on flush criteria */ -void snd_seq_queue_remove_cells(int client, snd_seq_remove_events_t *info) +void snd_seq_queue_remove_cells(int client, struct snd_seq_remove_events *info) { int i; - queue_t *q; + struct snd_seq_queue *q; for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { if ((q = queueptr(i)) == NULL) @@ -650,9 +655,10 @@ void snd_seq_queue_remove_cells(int client, snd_seq_remove_events_t *info) /* * send events to all subscribed ports */ -static void queue_broadcast_event(queue_t *q, snd_seq_event_t *ev, int from_timer_port, int atomic, int hop) +static void queue_broadcast_event(struct snd_seq_queue *q, struct snd_seq_event *ev, + int atomic, int hop) { - snd_seq_event_t sev; + struct snd_seq_event sev; sev = *ev; @@ -661,60 +667,60 @@ static void queue_broadcast_event(queue_t *q, snd_seq_event_t *ev, int from_time sev.queue = q->queue; sev.data.queue.queue = q->queue; - if (from_timer_port) { - /* broadcast events from Timer port */ - sev.source.client = SNDRV_SEQ_CLIENT_SYSTEM; - sev.source.port = SNDRV_SEQ_PORT_SYSTEM_TIMER; - sev.dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS; - snd_seq_kernel_client_dispatch(SNDRV_SEQ_CLIENT_SYSTEM, &sev, atomic, hop); - } + /* broadcast events from Timer port */ + sev.source.client = SNDRV_SEQ_CLIENT_SYSTEM; + sev.source.port = SNDRV_SEQ_PORT_SYSTEM_TIMER; + sev.dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS; + snd_seq_kernel_client_dispatch(SNDRV_SEQ_CLIENT_SYSTEM, &sev, atomic, hop); } /* * process a received queue-control event. * this function is exported for seq_sync.c. */ -void snd_seq_queue_process_event(queue_t *q, snd_seq_event_t *ev, int from_timer_port, int atomic, int hop) +static void snd_seq_queue_process_event(struct snd_seq_queue *q, + struct snd_seq_event *ev, + int atomic, int hop) { switch (ev->type) { case SNDRV_SEQ_EVENT_START: snd_seq_prioq_leave(q->tickq, ev->source.client, 1); snd_seq_prioq_leave(q->timeq, ev->source.client, 1); if (! snd_seq_timer_start(q->timer)) - queue_broadcast_event(q, ev, from_timer_port, atomic, hop); + queue_broadcast_event(q, ev, atomic, hop); break; case SNDRV_SEQ_EVENT_CONTINUE: if (! snd_seq_timer_continue(q->timer)) - queue_broadcast_event(q, ev, from_timer_port, atomic, hop); + queue_broadcast_event(q, ev, atomic, hop); break; case SNDRV_SEQ_EVENT_STOP: snd_seq_timer_stop(q->timer); - queue_broadcast_event(q, ev, from_timer_port, atomic, hop); + queue_broadcast_event(q, ev, atomic, hop); break; case SNDRV_SEQ_EVENT_TEMPO: snd_seq_timer_set_tempo(q->timer, ev->data.queue.param.value); - queue_broadcast_event(q, ev, from_timer_port, atomic, hop); + queue_broadcast_event(q, ev, atomic, hop); break; case SNDRV_SEQ_EVENT_SETPOS_TICK: if (snd_seq_timer_set_position_tick(q->timer, ev->data.queue.param.time.tick) == 0) { - queue_broadcast_event(q, ev, from_timer_port, atomic, hop); + queue_broadcast_event(q, ev, atomic, hop); } break; case SNDRV_SEQ_EVENT_SETPOS_TIME: if (snd_seq_timer_set_position_time(q->timer, ev->data.queue.param.time.time) == 0) { - queue_broadcast_event(q, ev, from_timer_port, atomic, hop); + queue_broadcast_event(q, ev, atomic, hop); } break; case SNDRV_SEQ_EVENT_QUEUE_SKEW: if (snd_seq_timer_set_skew(q->timer, ev->data.queue.param.skew.value, ev->data.queue.param.skew.base) == 0) { - queue_broadcast_event(q, ev, from_timer_port, atomic, hop); + queue_broadcast_event(q, ev, atomic, hop); } break; } @@ -725,9 +731,9 @@ void snd_seq_queue_process_event(queue_t *q, snd_seq_event_t *ev, int from_timer * Queue control via timer control port: * this function is exported as a callback of timer port. */ -int snd_seq_control_queue(snd_seq_event_t *ev, int atomic, int hop) +int snd_seq_control_queue(struct snd_seq_event *ev, int atomic, int hop) { - queue_t *q; + struct snd_seq_queue *q; snd_assert(ev != NULL, return -EINVAL); q = queueptr(ev->data.queue.queue); @@ -740,7 +746,7 @@ int snd_seq_control_queue(snd_seq_event_t *ev, int atomic, int hop) return -EPERM; } - snd_seq_queue_process_event(q, ev, 1, atomic, hop); + snd_seq_queue_process_event(q, ev, atomic, hop); queue_access_unlock(q); queuefree(q); @@ -750,13 +756,14 @@ int snd_seq_control_queue(snd_seq_event_t *ev, int atomic, int hop) /*----------------------------------------------------------------*/ +#ifdef CONFIG_PROC_FS /* exported to seq_info.c */ -void snd_seq_info_queues_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +void snd_seq_info_queues_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { int i, bpm; - queue_t *q; - seq_timer_t *tmr; + struct snd_seq_queue *q; + struct snd_seq_timer *tmr; for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { if ((q = queueptr(i)) == NULL) @@ -783,3 +790,5 @@ void snd_seq_info_queues_read(snd_info_entry_t *entry, queuefree(q); } } +#endif /* CONFIG_PROC_FS */ +