seq_oss_device.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. /* max. applications */
  32. #define SNDRV_SEQ_OSS_MAX_CLIENTS 16
  33. #define SNDRV_SEQ_OSS_MAX_SYNTH_DEVS 16
  34. #define SNDRV_SEQ_OSS_MAX_MIDI_DEVS 32
  35. /* version */
  36. #define SNDRV_SEQ_OSS_MAJOR_VERSION 0
  37. #define SNDRV_SEQ_OSS_MINOR_VERSION 1
  38. #define SNDRV_SEQ_OSS_TINY_VERSION 8
  39. #define SNDRV_SEQ_OSS_VERSION_STR "0.1.8"
  40. /* device and proc interface name */
  41. #define SNDRV_SEQ_OSS_PROCNAME "oss"
  42. /*
  43. * type definitions
  44. */
  45. typedef unsigned int reltime_t;
  46. typedef unsigned int abstime_t;
  47. /*
  48. * synthesizer channel information
  49. */
  50. struct seq_oss_chinfo {
  51. int note, vel;
  52. };
  53. /*
  54. * synthesizer information
  55. */
  56. struct seq_oss_synthinfo {
  57. struct snd_seq_oss_arg arg;
  58. struct seq_oss_chinfo *ch;
  59. struct seq_oss_synth_sysex *sysex;
  60. int nr_voices;
  61. int opened;
  62. int is_midi;
  63. int midi_mapped;
  64. };
  65. /*
  66. * sequencer client information
  67. */
  68. struct seq_oss_devinfo {
  69. int index; /* application index */
  70. int cseq; /* sequencer client number */
  71. int port; /* sequencer port number */
  72. int queue; /* sequencer queue number */
  73. struct snd_seq_addr addr; /* address of this device */
  74. int seq_mode; /* sequencer mode */
  75. int file_mode; /* file access */
  76. /* midi device table */
  77. int max_mididev;
  78. /* synth device table */
  79. int max_synthdev;
  80. struct seq_oss_synthinfo synths[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS];
  81. int synth_opened;
  82. /* output queue */
  83. struct seq_oss_writeq *writeq;
  84. /* midi input queue */
  85. struct seq_oss_readq *readq;
  86. /* timer */
  87. struct seq_oss_timer *timer;
  88. };
  89. /*
  90. * function prototypes
  91. */
  92. /* create/delete OSS sequencer client */
  93. int snd_seq_oss_create_client(void);
  94. int snd_seq_oss_delete_client(void);
  95. /* device file interface */
  96. int snd_seq_oss_open(struct file *file, int level);
  97. void snd_seq_oss_release(struct seq_oss_devinfo *dp);
  98. int snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long arg);
  99. int snd_seq_oss_read(struct seq_oss_devinfo *dev, char __user *buf, int count);
  100. int snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, struct file *opt);
  101. unsigned int snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait);
  102. void snd_seq_oss_reset(struct seq_oss_devinfo *dp);
  103. /* */
  104. void snd_seq_oss_process_queue(struct seq_oss_devinfo *dp, abstime_t time);
  105. /* proc interface */
  106. void snd_seq_oss_system_info_read(struct snd_info_buffer *buf);
  107. void snd_seq_oss_midi_info_read(struct snd_info_buffer *buf);
  108. void snd_seq_oss_synth_info_read(struct snd_info_buffer *buf);
  109. void snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf);
  110. /* file mode macros */
  111. #define is_read_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_READ)
  112. #define is_write_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_WRITE)
  113. #define is_nonblock_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_NONBLOCK)
  114. /* dispatch event */
  115. static inline int
  116. snd_seq_oss_dispatch(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int atomic, int hop)
  117. {
  118. return snd_seq_kernel_client_dispatch(dp->cseq, ev, atomic, hop);
  119. }
  120. /* ioctl */
  121. static inline int
  122. snd_seq_oss_control(struct seq_oss_devinfo *dp, unsigned int type, void *arg)
  123. {
  124. return snd_seq_kernel_client_ctl(dp->cseq, type, arg);
  125. }
  126. /* fill the addresses in header */
  127. static inline void
  128. snd_seq_oss_fill_addr(struct seq_oss_devinfo *dp, struct snd_seq_event *ev,
  129. int dest_client, int dest_port)
  130. {
  131. ev->queue = dp->queue;
  132. ev->source = dp->addr;
  133. ev->dest.client = dest_client;
  134. ev->dest.port = dest_port;
  135. }
  136. /* misc. functions for proc interface */
  137. char *enabled_str(int bool);
  138. #endif /* __SEQ_OSS_DEVICE_H */