Lines Matching refs:f

20 	struct snd_seq_fifo *f;  in snd_seq_fifo_new()  local
22 f = kzalloc(sizeof(*f), GFP_KERNEL); in snd_seq_fifo_new()
23 if (!f) in snd_seq_fifo_new()
26 f->pool = snd_seq_pool_new(poolsize); in snd_seq_fifo_new()
27 if (f->pool == NULL) { in snd_seq_fifo_new()
28 kfree(f); in snd_seq_fifo_new()
31 if (snd_seq_pool_init(f->pool) < 0) { in snd_seq_fifo_new()
32 snd_seq_pool_delete(&f->pool); in snd_seq_fifo_new()
33 kfree(f); in snd_seq_fifo_new()
37 spin_lock_init(&f->lock); in snd_seq_fifo_new()
38 snd_use_lock_init(&f->use_lock); in snd_seq_fifo_new()
39 init_waitqueue_head(&f->input_sleep); in snd_seq_fifo_new()
40 atomic_set(&f->overflow, 0); in snd_seq_fifo_new()
42 f->head = NULL; in snd_seq_fifo_new()
43 f->tail = NULL; in snd_seq_fifo_new()
44 f->cells = 0; in snd_seq_fifo_new()
46 return f; in snd_seq_fifo_new()
51 struct snd_seq_fifo *f; in snd_seq_fifo_delete() local
55 f = *fifo; in snd_seq_fifo_delete()
56 if (snd_BUG_ON(!f)) in snd_seq_fifo_delete()
60 if (f->pool) in snd_seq_fifo_delete()
61 snd_seq_pool_mark_closing(f->pool); in snd_seq_fifo_delete()
63 snd_seq_fifo_clear(f); in snd_seq_fifo_delete()
66 if (waitqueue_active(&f->input_sleep)) in snd_seq_fifo_delete()
67 wake_up(&f->input_sleep); in snd_seq_fifo_delete()
72 if (f->pool) { in snd_seq_fifo_delete()
73 snd_seq_pool_done(f->pool); in snd_seq_fifo_delete()
74 snd_seq_pool_delete(&f->pool); in snd_seq_fifo_delete()
77 kfree(f); in snd_seq_fifo_delete()
80 static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f);
83 void snd_seq_fifo_clear(struct snd_seq_fifo *f) in snd_seq_fifo_clear() argument
88 atomic_set(&f->overflow, 0); in snd_seq_fifo_clear()
90 snd_use_lock_sync(&f->use_lock); in snd_seq_fifo_clear()
91 spin_lock_irq(&f->lock); in snd_seq_fifo_clear()
93 while ((cell = fifo_cell_out(f)) != NULL) { in snd_seq_fifo_clear()
96 spin_unlock_irq(&f->lock); in snd_seq_fifo_clear()
101 int snd_seq_fifo_event_in(struct snd_seq_fifo *f, in snd_seq_fifo_event_in() argument
108 if (snd_BUG_ON(!f)) in snd_seq_fifo_event_in()
111 snd_use_lock_use(&f->use_lock); in snd_seq_fifo_event_in()
112 err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL, NULL); /* always non-blocking */ in snd_seq_fifo_event_in()
115 atomic_inc(&f->overflow); in snd_seq_fifo_event_in()
116 snd_use_lock_free(&f->use_lock); in snd_seq_fifo_event_in()
121 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_event_in()
122 if (f->tail != NULL) in snd_seq_fifo_event_in()
123 f->tail->next = cell; in snd_seq_fifo_event_in()
124 f->tail = cell; in snd_seq_fifo_event_in()
125 if (f->head == NULL) in snd_seq_fifo_event_in()
126 f->head = cell; in snd_seq_fifo_event_in()
128 f->cells++; in snd_seq_fifo_event_in()
129 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_event_in()
132 if (waitqueue_active(&f->input_sleep)) in snd_seq_fifo_event_in()
133 wake_up(&f->input_sleep); in snd_seq_fifo_event_in()
135 snd_use_lock_free(&f->use_lock); in snd_seq_fifo_event_in()
142 static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f) in fifo_cell_out() argument
146 cell = f->head; in fifo_cell_out()
148 f->head = cell->next; in fifo_cell_out()
151 if (f->tail == cell) in fifo_cell_out()
152 f->tail = NULL; in fifo_cell_out()
155 f->cells--; in fifo_cell_out()
162 int snd_seq_fifo_cell_out(struct snd_seq_fifo *f, in snd_seq_fifo_cell_out() argument
169 if (snd_BUG_ON(!f)) in snd_seq_fifo_cell_out()
174 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_cell_out()
175 while ((cell = fifo_cell_out(f)) == NULL) { in snd_seq_fifo_cell_out()
178 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_out()
182 add_wait_queue(&f->input_sleep, &wait); in snd_seq_fifo_cell_out()
183 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_out()
185 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_cell_out()
186 remove_wait_queue(&f->input_sleep, &wait); in snd_seq_fifo_cell_out()
188 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_out()
192 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_out()
199 void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f, in snd_seq_fifo_cell_putback() argument
205 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_cell_putback()
206 cell->next = f->head; in snd_seq_fifo_cell_putback()
207 f->head = cell; in snd_seq_fifo_cell_putback()
208 if (!f->tail) in snd_seq_fifo_cell_putback()
209 f->tail = cell; in snd_seq_fifo_cell_putback()
210 f->cells++; in snd_seq_fifo_cell_putback()
211 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_cell_putback()
217 int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file, in snd_seq_fifo_poll_wait() argument
220 poll_wait(file, &f->input_sleep, wait); in snd_seq_fifo_poll_wait()
221 return (f->cells > 0); in snd_seq_fifo_poll_wait()
225 int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize) in snd_seq_fifo_resize() argument
230 if (snd_BUG_ON(!f || !f->pool)) in snd_seq_fifo_resize()
242 spin_lock_irq(&f->lock); in snd_seq_fifo_resize()
244 oldpool = f->pool; in snd_seq_fifo_resize()
245 oldhead = f->head; in snd_seq_fifo_resize()
247 f->pool = newpool; in snd_seq_fifo_resize()
248 f->head = NULL; in snd_seq_fifo_resize()
249 f->tail = NULL; in snd_seq_fifo_resize()
250 f->cells = 0; in snd_seq_fifo_resize()
252 spin_unlock_irq(&f->lock); in snd_seq_fifo_resize()
256 snd_use_lock_sync(&f->use_lock); in snd_seq_fifo_resize()
269 int snd_seq_fifo_unused_cells(struct snd_seq_fifo *f) in snd_seq_fifo_unused_cells() argument
274 if (!f) in snd_seq_fifo_unused_cells()
277 snd_use_lock_use(&f->use_lock); in snd_seq_fifo_unused_cells()
278 spin_lock_irqsave(&f->lock, flags); in snd_seq_fifo_unused_cells()
279 cells = snd_seq_unused_cells(f->pool); in snd_seq_fifo_unused_cells()
280 spin_unlock_irqrestore(&f->lock, flags); in snd_seq_fifo_unused_cells()
281 snd_use_lock_free(&f->use_lock); in snd_seq_fifo_unused_cells()