seq_oss_device.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * OSS compatible sequencer driver
  3. *
  4. * Copyright (C) 1998,99 Takashi Iwai <tiwai@suse.de>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #ifndef __SEQ_OSS_DEVICE_H
  21. #define __SEQ_OSS_DEVICE_H
  22. #include <linux/time.h>
  23. #include <linux/wait.h>
  24. #include <linux/slab.h>
  25. #include <linux/sched.h>
  26. #include <sound/core.h>
  27. #include <sound/seq_oss.h>
  28. #include <sound/rawmidi.h>
  29. #include <sound/seq_kernel.h>
  30. #include <sound/info.h>
  31. /* enable debug print */
  32. #define SNDRV_SEQ_OSS_DEBUG
  33. /* max. applications */
  34. #define SNDRV_SEQ_OSS_MAX_CLIENTS 16
  35. #define SNDRV_SEQ_OSS_MAX_SYNTH_DEVS 16
  36. #define SNDRV_SEQ_OSS_MAX_MIDI_DEVS 32
  37. /* version */
  38. #define SNDRV_SEQ_OSS_MAJOR_VERSION 0
  39. #define SNDRV_SEQ_OSS_MINOR_VERSION 1
  40. #define SNDRV_SEQ_OSS_TINY_VERSION 8
  41. #define SNDRV_SEQ_OSS_VERSION_STR "0.1.8"
  42. /* device and proc interface name */
  43. #define SNDRV_SEQ_OSS_DEVNAME "seq_oss"
  44. #define SNDRV_SEQ_OSS_PROCNAME "oss"
  45. /*
  46. * type definitions
  47. */
  48. typedef unsigned int reltime_t;
  49. typedef unsigned int abstime_t;
  50. /*
  51. * synthesizer channel information
  52. */
  53. struct seq_oss_chinfo {
  54. int note, vel;
  55. };
  56. /*
  57. * synthesizer information
  58. */
  59. struct seq_oss_synthinfo {
  60. struct snd_seq_oss_arg arg;
  61. struct seq_oss_chinfo *ch;
  62. struct seq_oss_synth_sysex *sysex;
  63. int nr_voices;
  64. int opened;
  65. int is_midi;
  66. int midi_mapped;
  67. };
  68. /*
  69. * sequencer client information
  70. */
  71. struct seq_oss_devinfo {
  72. int index; /* application index */
  73. int cseq; /* sequencer client number */
  74. int port; /* sequencer port number */
  75. int queue; /* sequencer queue number */
  76. struct snd_seq_addr addr; /* address of this device */
  77. int seq_mode; /* sequencer mode */
  78. int file_mode; /* file access */
  79. /* midi device table */
  80. int max_mididev;
  81. /* synth device table */
  82. int max_synthdev;
  83. struct seq_oss_synthinfo synths[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS];
  84. int synth_opened;
  85. /* output queue */
  86. struct seq_oss_writeq *writeq;
  87. /* midi input queue */
  88. struct seq_oss_readq *readq;
  89. /* timer */
  90. struct seq_oss_timer *timer;
  91. };
  92. /*
  93. * function prototypes
  94. */
  95. /* create/delete OSS sequencer client */
  96. int snd_seq_oss_create_client(void);
  97. int snd_seq_oss_delete_client(void);
  98. /* device file interface */
  99. int snd_seq_oss_open(struct file *file, int level);
  100. void snd_seq_oss_release(struct seq_oss_devinfo *dp);
  101. int snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long arg);
  102. int snd_seq_oss_read(struct seq_oss_devinfo *dev, char __user *buf, int count);
  103. int snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, struct file *opt);
  104. unsigned int snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait);
  105. void snd_seq_oss_reset(struct seq_oss_devinfo *dp);
  106. void snd_seq_oss_drain_write(struct seq_oss_devinfo *dp);
  107. /* */
  108. void snd_seq_oss_process_queue(struct seq_oss_devinfo *dp, abstime_t time);
  109. /* proc interface */
  110. void snd_seq_oss_system_info_read(struct snd_info_buffer *buf);
  111. void snd_seq_oss_midi_info_read(struct snd_info_buffer *buf);
  112. void snd_seq_oss_synth_info_read(struct snd_info_buffer *buf);
  113. void snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf);
  114. /* file mode macros */
  115. #define is_read_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_READ)
  116. #define is_write_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_WRITE)
  117. #define is_nonblock_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_NONBLOCK)
  118. /* dispatch event */
  119. static inline int
  120. snd_seq_oss_dispatch(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int atomic, int hop)
  121. {
  122. return snd_seq_kernel_client_dispatch(dp->cseq, ev, atomic, hop);
  123. }
  124. /* ioctl */
  125. static inline int
  126. snd_seq_oss_control(struct seq_oss_devinfo *dp, unsigned int type, void *arg)
  127. {
  128. return snd_seq_kernel_client_ctl(dp->cseq, type, arg);
  129. }
  130. /* fill the addresses in header */
  131. static inline void
  132. snd_seq_oss_fill_addr(struct seq_oss_devinfo *dp, struct snd_seq_event *ev,
  133. int dest_client, int dest_port)
  134. {
  135. ev->queue = dp->queue;
  136. ev->source = dp->addr;
  137. ev->dest.client = dest_client;
  138. ev->dest.port = dest_port;
  139. }
  140. /* misc. functions for proc interface */
  141. char *enabled_str(int bool);
  142. /* for debug */
  143. #ifdef SNDRV_SEQ_OSS_DEBUG
  144. extern int seq_oss_debug;
  145. #define debug_printk(x) do { if (seq_oss_debug > 0) snd_printd x; } while (0)
  146. #else
  147. #define debug_printk(x) /**/
  148. #endif
  149. #endif /* __SEQ_OSS_DEVICE_H */