seq_fifo.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * ALSA sequencer FIFO
  4. * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
  5. */
  6. #ifndef __SND_SEQ_FIFO_H
  7. #define __SND_SEQ_FIFO_H
  8. #include "seq_memory.h"
  9. #include "seq_lock.h"
  10. /* === FIFO === */
  11. struct snd_seq_fifo {
  12. struct snd_seq_pool *pool; /* FIFO pool */
  13. struct snd_seq_event_cell *head; /* pointer to head of fifo */
  14. struct snd_seq_event_cell *tail; /* pointer to tail of fifo */
  15. int cells;
  16. spinlock_t lock;
  17. snd_use_lock_t use_lock;
  18. wait_queue_head_t input_sleep;
  19. atomic_t overflow;
  20. };
  21. /* create new fifo (constructor) */
  22. struct snd_seq_fifo *snd_seq_fifo_new(int poolsize);
  23. /* delete fifo (destructor) */
  24. void snd_seq_fifo_delete(struct snd_seq_fifo **f);
  25. /* enqueue event to fifo */
  26. int snd_seq_fifo_event_in(struct snd_seq_fifo *f, struct snd_seq_event *event);
  27. /* lock fifo from release */
  28. #define snd_seq_fifo_lock(fifo) snd_use_lock_use(&(fifo)->use_lock)
  29. #define snd_seq_fifo_unlock(fifo) snd_use_lock_free(&(fifo)->use_lock)
  30. DEFINE_GUARD(snd_seq_fifo, struct snd_seq_fifo *, snd_seq_fifo_lock(_T), snd_seq_fifo_unlock(_T))
  31. /* get a cell from fifo - fifo should be locked */
  32. int snd_seq_fifo_cell_out(struct snd_seq_fifo *f, struct snd_seq_event_cell **cellp, int nonblock);
  33. /* free dequeued cell - fifo should be locked */
  34. void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f, struct snd_seq_event_cell *cell);
  35. /* clean up queue */
  36. void snd_seq_fifo_clear(struct snd_seq_fifo *f);
  37. /* polling */
  38. int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file, poll_table *wait);
  39. /* resize pool in fifo */
  40. int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize);
  41. /* get the number of unused cells safely */
  42. int snd_seq_fifo_unused_cells(struct snd_seq_fifo *f);
  43. #endif