sound/core/seq/seq_queue.c
Source file repositories/reference/linux-study-clean/sound/core/seq/seq_queue.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/seq/seq_queue.c- Extension
.c- Size
- 17874 bytes
- Lines
- 711
- Domain
- Driver Families
- Bucket
- sound/core
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/slab.hsound/core.hseq_memory.hseq_queue.hseq_clientmgr.hseq_fifo.hseq_timer.hseq_info.h
Detected Declarations
function snd_seq_queue_get_cur_queuesfunction queue_list_addfunction queue_deletefunction snd_seq_queues_deletefunction ERR_PTRfunction snd_seq_queue_deletefunction snd_seq_check_queuefunction snd_seq_enqueue_eventfunction check_accessfunction queue_access_lockfunction queue_access_unlockfunction snd_seq_queue_check_accessfunction snd_seq_queue_set_ownerfunction scoped_guardfunction snd_seq_queue_usefunction snd_seq_queue_timer_closefunction snd_seq_queue_timer_set_tempofunction queue_usefunction snd_seq_queue_usefunction snd_seq_queue_is_usedfunction clientfunction snd_seq_queue_remove_cellsfunction queue_broadcast_eventfunction snd_seq_queue_process_eventfunction snd_seq_control_queuefunction snd_seq_info_queues_readfunction scoped_guard
Annotated Snippet
if (! queue_list[i]) {
queue_list[i] = q;
q->queue = i;
num_queues++;
return i;
}
}
return -1;
}
static struct snd_seq_queue *queue_list_remove(int id, int client)
{
struct snd_seq_queue *q;
guard(spinlock_irqsave)(&queue_list_lock);
q = queue_list[id];
if (q) {
guard(spinlock)(&q->owner_lock);
if (q->owner == client) {
/* found */
q->klocked = 1;
queue_list[id] = NULL;
num_queues--;
return q;
}
}
return NULL;
}
/*----------------------------------------------------------------*/
/* create new queue (constructor) */
static struct snd_seq_queue *queue_new(int owner, int locked)
{
struct snd_seq_queue *q;
q = kzalloc_obj(*q);
if (!q)
return NULL;
spin_lock_init(&q->owner_lock);
spin_lock_init(&q->check_lock);
mutex_init(&q->timer_mutex);
snd_use_lock_init(&q->use_lock);
q->queue = -1;
q->tickq = snd_seq_prioq_new();
q->timeq = snd_seq_prioq_new();
q->timer = snd_seq_timer_new();
if (q->tickq == NULL || q->timeq == NULL || q->timer == NULL) {
snd_seq_prioq_delete(&q->tickq);
snd_seq_prioq_delete(&q->timeq);
snd_seq_timer_delete(&q->timer);
kfree(q);
return NULL;
}
q->owner = owner;
q->locked = locked;
q->klocked = 0;
return q;
}
/* delete queue (destructor) */
static void queue_delete(struct snd_seq_queue *q)
{
/* stop and release the timer */
mutex_lock(&q->timer_mutex);
snd_seq_timer_stop(q->timer);
snd_seq_timer_close(q);
mutex_unlock(&q->timer_mutex);
/* wait until access free */
snd_use_lock_sync(&q->use_lock);
/* release resources... */
snd_seq_prioq_delete(&q->tickq);
snd_seq_prioq_delete(&q->timeq);
snd_seq_timer_delete(&q->timer);
kfree(q);
}
/*----------------------------------------------------------------*/
/* delete all existing queues */
void snd_seq_queues_delete(void)
{
int i;
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `sound/core.h`, `seq_memory.h`, `seq_queue.h`, `seq_clientmgr.h`, `seq_fifo.h`, `seq_timer.h`.
- Detected declarations: `function snd_seq_queue_get_cur_queues`, `function queue_list_add`, `function queue_delete`, `function snd_seq_queues_delete`, `function ERR_PTR`, `function snd_seq_queue_delete`, `function snd_seq_check_queue`, `function snd_seq_enqueue_event`, `function check_access`, `function queue_access_lock`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.