seq_clientmgr.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * ALSA sequencer Client Manager
  4. * Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
  5. */
  6. #ifndef __SND_SEQ_CLIENTMGR_H
  7. #define __SND_SEQ_CLIENTMGR_H
  8. #include <sound/seq_kernel.h>
  9. #include <linux/bitops.h>
  10. #include "seq_fifo.h"
  11. #include "seq_ports.h"
  12. #include "seq_lock.h"
  13. /* client manager */
  14. struct snd_seq_user_client {
  15. struct file *file; /* file struct of client */
  16. /* ... */
  17. struct pid *owner;
  18. /* fifo */
  19. struct snd_seq_fifo *fifo; /* queue for incoming events */
  20. int fifo_pool_size;
  21. };
  22. struct snd_seq_kernel_client {
  23. /* ... */
  24. struct snd_card *card;
  25. };
  26. struct snd_seq_client {
  27. snd_seq_client_type_t type;
  28. unsigned int accept_input: 1,
  29. accept_output: 1;
  30. unsigned int midi_version;
  31. unsigned int user_pversion;
  32. char name[64]; /* client name */
  33. int number; /* client number */
  34. unsigned int filter; /* filter flags */
  35. DECLARE_BITMAP(event_filter, 256);
  36. unsigned short group_filter;
  37. snd_use_lock_t use_lock;
  38. int event_lost;
  39. /* ports */
  40. int num_ports; /* number of ports */
  41. struct list_head ports_list_head;
  42. rwlock_t ports_lock;
  43. struct mutex ports_mutex;
  44. struct mutex ioctl_mutex;
  45. int convert32; /* convert 32->64bit */
  46. int ump_endpoint_port;
  47. /* output pool */
  48. struct snd_seq_pool *pool; /* memory pool for this client */
  49. union {
  50. struct snd_seq_user_client user;
  51. struct snd_seq_kernel_client kernel;
  52. } data;
  53. /* for UMP */
  54. void **ump_info;
  55. };
  56. /* usage statistics */
  57. struct snd_seq_usage {
  58. int cur;
  59. int peak;
  60. };
  61. int client_init_data(void);
  62. int snd_sequencer_device_init(void);
  63. void snd_sequencer_device_done(void);
  64. /* get locked pointer to client */
  65. struct snd_seq_client *snd_seq_client_use_ptr(int clientid);
  66. static inline struct snd_seq_client *
  67. snd_seq_client_ref(struct snd_seq_client *client)
  68. {
  69. snd_use_lock_use(&client->use_lock);
  70. return client;
  71. }
  72. /* unlock pointer to client */
  73. static inline void snd_seq_client_unref(struct snd_seq_client *client)
  74. {
  75. snd_use_lock_free(&client->use_lock);
  76. }
  77. DEFINE_FREE(snd_seq_client, struct snd_seq_client *, if (!IS_ERR_OR_NULL(_T)) snd_seq_client_unref(_T))
  78. /* dispatch event to client(s) */
  79. int snd_seq_dispatch_event(struct snd_seq_event_cell *cell, int atomic, int hop);
  80. int snd_seq_kernel_client_write_poll(int clientid, struct file *file, poll_table *wait);
  81. int snd_seq_client_notify_subscription(int client, int port,
  82. struct snd_seq_port_subscribe *info, int evtype);
  83. int __snd_seq_deliver_single_event(struct snd_seq_client *dest,
  84. struct snd_seq_client_port *dest_port,
  85. struct snd_seq_event *event,
  86. int atomic, int hop);
  87. /* only for OSS sequencer */
  88. int snd_seq_kernel_client_ioctl(int clientid, unsigned int cmd, void *arg);
  89. extern int seq_client_load[15];
  90. /* for internal use between kernel sequencer clients */
  91. struct snd_seq_client *snd_seq_kernel_client_get(int client);
  92. void snd_seq_kernel_client_put(struct snd_seq_client *cptr);
  93. static inline bool snd_seq_client_is_ump(struct snd_seq_client *c)
  94. {
  95. return c->midi_version != SNDRV_SEQ_CLIENT_LEGACY_MIDI;
  96. }
  97. static inline bool snd_seq_client_is_midi2(struct snd_seq_client *c)
  98. {
  99. return c->midi_version == SNDRV_SEQ_CLIENT_UMP_MIDI_2_0;
  100. }
  101. #endif