seq_queue.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * ALSA sequencer Queue handling
  4. * Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
  5. */
  6. #ifndef __SND_SEQ_QUEUE_H
  7. #define __SND_SEQ_QUEUE_H
  8. #include "seq_memory.h"
  9. #include "seq_prioq.h"
  10. #include "seq_timer.h"
  11. #include "seq_lock.h"
  12. #include <linux/interrupt.h>
  13. #include <linux/list.h>
  14. #include <linux/bitops.h>
  15. #define SEQ_QUEUE_NO_OWNER (-1)
  16. struct snd_seq_queue {
  17. int queue; /* queue number */
  18. char name[64]; /* name of this queue */
  19. struct snd_seq_prioq *tickq; /* midi tick event queue */
  20. struct snd_seq_prioq *timeq; /* real-time event queue */
  21. struct snd_seq_timer *timer; /* time keeper for this queue */
  22. int owner; /* client that 'owns' the timer */
  23. bool locked; /* timer is only accesibble by owner if set */
  24. bool klocked; /* kernel lock (after START) */
  25. bool check_again; /* concurrent access happened during check */
  26. bool check_blocked; /* queue being checked */
  27. unsigned int flags; /* status flags */
  28. unsigned int info_flags; /* info for sync */
  29. spinlock_t owner_lock;
  30. spinlock_t check_lock;
  31. /* clients which uses this queue (bitmap) */
  32. DECLARE_BITMAP(clients_bitmap, SNDRV_SEQ_MAX_CLIENTS);
  33. unsigned int clients; /* users of this queue */
  34. struct mutex timer_mutex;
  35. snd_use_lock_t use_lock;
  36. };
  37. /* get the number of current queues */
  38. int snd_seq_queue_get_cur_queues(void);
  39. /* delete queues */
  40. void snd_seq_queues_delete(void);
  41. /* create new queue (constructor) */
  42. struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int flags);
  43. /* delete queue (destructor) */
  44. int snd_seq_queue_delete(int client, int queueid);
  45. /* final stage */
  46. void snd_seq_queue_client_leave(int client);
  47. /* enqueue a event received from one the clients */
  48. int snd_seq_enqueue_event(struct snd_seq_event_cell *cell, int atomic, int hop);
  49. /* Remove events */
  50. void snd_seq_queue_remove_cells(int client, struct snd_seq_remove_events *info);
  51. /* return pointer to queue structure for specified id */
  52. struct snd_seq_queue *queueptr(int queueid);
  53. /* unlock */
  54. #define queuefree(q) snd_use_lock_free(&(q)->use_lock)
  55. DEFINE_FREE(snd_seq_queue, struct snd_seq_queue *, if (!IS_ERR_OR_NULL(_T)) queuefree(_T))
  56. /* return the (first) queue matching with the specified name */
  57. struct snd_seq_queue *snd_seq_queue_find_name(char *name);
  58. /* check single queue and dispatch events */
  59. void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop);
  60. /* access to queue's parameters */
  61. int snd_seq_queue_check_access(int queueid, int client);
  62. int snd_seq_queue_timer_set_tempo(int queueid, int client, struct snd_seq_queue_tempo *info);
  63. int snd_seq_queue_set_owner(int queueid, int client, int locked);
  64. int snd_seq_queue_timer_open(int queueid);
  65. int snd_seq_queue_timer_close(int queueid);
  66. int snd_seq_queue_use(int queueid, int client, int use);
  67. int snd_seq_queue_is_used(int queueid, int client);
  68. int snd_seq_control_queue(struct snd_seq_event *ev, int atomic, int hop);
  69. #endif