doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
soundcard.h
Go to the documentation of this file.
1 #ifndef SOUNDCARD_H
2 #define SOUNDCARD_H
3 /*
4  * Copyright by Hannu Savolainen 1993-2004
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met: 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer. 2.
10  * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26 
27 /*
28  * IMPORTANT NOTICE!
29  *
30  * This header file contains many obsolete definitions (for compatibility
31  * purposes). Please check the OSS Programmer's guide for descriptions
32  * of the supported API details (http://www.opensound.com/pguide).
33  */
34 
35 #if defined(__cplusplus)
36 #define EXTERNC extern "C"
37 #else
38 #define EXTERNC extern
39 #endif /* EXTERN_C_WRAPPERS */
40 
41 /*
42  * OSS interface version. With versions earlier than 3.6 this value is
43  * an integer with value less than 361. In versions 3.6 and later
44  * it's a six digit hexadecimal value. For example value
45  * of 0x030600 represents OSS version 3.6.0.
46  * Use ioctl(fd, OSS_GETVERSION, &int) to get the version number of
47  * the currently active driver.
48  */
49 #define SOUND_VERSION 0x039999
50 #define OPEN_SOUND_SYSTEM
51 
52 #if defined(__hpux) && !defined(_HPUX_SOURCE)
53 # error "-D_HPUX_SOURCE must be used when compiling OSS applications"
54 #endif
55 
56 #ifdef __hpux
57 #include <sys/ioctl.h>
58 #endif
59 
60 #ifdef linux
61 /* In Linux we need to be prepared for cross compiling */
62 #include <linux/ioctl.h>
63 #else
64 # ifdef __FreeBSD__
65 # include <sys/ioccom.h>
66 # else
67 # include <sys/ioctl.h>
68 # endif
69 #endif
70 
71 /*
72  * Supported card ID numbers (OBSOLETE. NOT USED ANY MORE)
73  */
74 
75 #define SNDCARD_ADLIB 1
76 #define SNDCARD_SB 2
77 #define SNDCARD_PAS 3
78 #define SNDCARD_GUS 4
79 #define SNDCARD_MPU401 5
80 #define SNDCARD_SB16 6
81 #define SNDCARD_SB16MIDI 7
82 #define SNDCARD_UART6850 8
83 #define SNDCARD_GUS16 9
84 #define SNDCARD_MSS 10
85 #define SNDCARD_PSS 11
86 #define SNDCARD_SSCAPE 12
87 #define SNDCARD_PSS_MPU 13
88 #define SNDCARD_PSS_MSS 14
89 #define SNDCARD_SSCAPE_MSS 15
90 #define SNDCARD_TRXPRO 16
91 #define SNDCARD_TRXPRO_SB 17
92 #define SNDCARD_TRXPRO_MPU 18
93 #define SNDCARD_MAD16 19
94 #define SNDCARD_MAD16_MPU 20
95 #define SNDCARD_CS4232 21
96 #define SNDCARD_CS4232_MPU 22
97 #define SNDCARD_MAUI 23
98 #define SNDCARD_PSEUDO_MSS 24
99 #define SNDCARD_GUSPNP 25
100 #define SNDCARD_UART401 26
101 /* Sound card numbers 27 to N are reserved. Don't add more numbers here */
102 
103 /***********************************
104  * IOCTL Commands for /dev/sequencer
105  */
106 
107 #ifndef __SIOWR
108 #if defined(__hpux) || (defined(_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__INCioctlh) && !defined(__Lynx__))))
109 
110 /*
111  * Use already defined ioctl defines if they exist (except with Sun and some
112  * others)
113  */
114 #define SIOCPARM_MASK IOCPARM_MASK
115 #define SIOC_VOID IOC_VOID
116 #define SIOC_OUT IOC_OUT
117 #define SIOC_IN IOC_IN
118 #define SIOC_INOUT IOC_INOUT
119 #define __SIOC_SIZE _IOC_SIZE
120 #define __SIOC_DIR _IOC_DIR
121 #define __SIOC_NONE _IOC_NONE
122 #define __SIOC_READ _IOC_READ
123 #define __SIOC_WRITE _IOC_WRITE
124 #define __SIO _IO
125 #define __SIOR _IOR
126 #define __SIOW _IOW
127 #define __SIOWR _IOWR
128 #else
129 
130 /* Ioctl's have the command encoded in the lower word,
131  * and the size of any in or out parameters in the upper
132  * word. The high 2 bits of the upper word are used
133  * to encode the in/out status of the parameter; for now
134  * we restrict parameters to at most 8191 bytes.
135  */
136 /* #define SIOCTYPE (0xff<<8) */
137 #define SIOCPARM_MASK 0x1fff /* parameters must be < 8192 bytes */
138 #define SIOC_VOID 0x00000000 /* no parameters */
139 #define SIOC_OUT 0x20000000 /* copy out parameters */
140 #define SIOC_IN 0x40000000 /* copy in parameters */
141 #define SIOC_INOUT (SIOC_IN|SIOC_OUT)
142 
143 /* the 0x20000000 is so we can distinguish new ioctl's from old */
144 #define __SIO(x,y) ((int)(SIOC_VOID|(x<<8)|y))
145 #define __SIOR(x,y,t) ((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
146 #define __SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
147 #define __SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
148 #define __SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK)
149 #define __SIOC_DIR(x) (x & 0xf0000000)
150 #define __SIOC_NONE SIOC_VOID
151 #define __SIOC_READ SIOC_OUT
152 #define __SIOC_WRITE SIOC_IN
153 # endif /* _IOWR */
154 #endif /* !__SIOWR */
155 
156 #define SNDCTL_SEQ_RESET __SIO ('Q', 0)
157 #define SNDCTL_SEQ_SYNC __SIO ('Q', 1)
158 #define SNDCTL_SYNTH_INFO __SIOWR('Q', 2, struct synth_info)
159 #define SNDCTL_SEQ_CTRLRATE __SIOWR('Q', 3, int) /* Set/get timer resolution (HZ) */
160 #define SNDCTL_SEQ_GETOUTCOUNT __SIOR ('Q', 4, int)
161 #define SNDCTL_SEQ_GETINCOUNT __SIOR ('Q', 5, int)
162 #define SNDCTL_SEQ_PERCMODE __SIOW ('Q', 6, int)
163 #define SNDCTL_FM_LOAD_INSTR __SIOW ('Q', 7, struct sbi_instrument) /* Obsolete. Don't use!!!!!! */
164 #define SNDCTL_SEQ_TESTMIDI __SIOW ('Q', 8, int)
165 #define SNDCTL_SEQ_RESETSAMPLES __SIOW ('Q', 9, int)
166 #define SNDCTL_SEQ_NRSYNTHS __SIOR ('Q',10, int)
167 #define SNDCTL_SEQ_NRMIDIS __SIOR ('Q',11, int)
168 #define SNDCTL_MIDI_INFO __SIOWR('Q',12, struct midi_info)
169 #define SNDCTL_SEQ_THRESHOLD __SIOW ('Q',13, int)
170 #define SNDCTL_SYNTH_MEMAVL __SIOWR('Q',14, int) /* in=dev#, out=memsize */
171 #define SNDCTL_FM_4OP_ENABLE __SIOW ('Q',15, int) /* in=dev# */
172 #define SNDCTL_SEQ_PANIC __SIO ('Q',17)
173 #define SNDCTL_SEQ_OUTOFBAND __SIOW ('Q',18, struct seq_event_rec)
174 #define SNDCTL_SEQ_GETTIME __SIOR ('Q',19, int)
175 #define SNDCTL_SYNTH_ID __SIOWR('Q',20, struct synth_info)
176 #define SNDCTL_SYNTH_CONTROL __SIOWR('Q',21, struct synth_control)
177 #define SNDCTL_SYNTH_REMOVESAMPLE __SIOWR('Q',22, struct remove_sample) /* Reserved for future use */
178 #define SNDCTL_SEQ_TIMING_ENABLE __SIO ('Q', 23) /* Enable incoming MIDI timing messages */
179 #define SNDCTL_SEQ_ACTSENSE_ENABLE __SIO ('Q', 24) /* Enable incoming active sensing messages */
180 #define SNDCTL_SEQ_RT_ENABLE __SIO ('Q', 25) /* Enable other incoming realtime messages */
181 
182 typedef struct synth_control
183 {
184  int devno; /* Synthesizer # */
185  char data[4000]; /* Device spesific command/data record */
186 } synth_control;
187 
188 typedef struct remove_sample
189 {
190  int devno; /* Synthesizer # */
191  int bankno; /* MIDI bank # (0=General MIDI) */
192  int instrno; /* MIDI instrument number */
193 } remove_sample;
194 
195 typedef struct seq_event_rec
196 {
197  unsigned char arr[8];
198 } seq_event_rec;
199 
200 #define SNDCTL_TMR_TIMEBASE __SIOWR('T', 1, int)
201 #define SNDCTL_TMR_START __SIO ('T', 2)
202 #define SNDCTL_TMR_STOP __SIO ('T', 3)
203 #define SNDCTL_TMR_CONTINUE __SIO ('T', 4)
204 #define SNDCTL_TMR_TEMPO __SIOWR('T', 5, int)
205 #define SNDCTL_TMR_SOURCE __SIOWR('T', 6, int)
206 # define TMR_INTERNAL 0x00000001
207 # define TMR_EXTERNAL 0x00000002
208 # define TMR_MODE_MIDI 0x00000010
209 # define TMR_MODE_FSK 0x00000020
210 # define TMR_MODE_CLS 0x00000040
211 # define TMR_MODE_SMPTE 0x00000080
212 #define SNDCTL_TMR_METRONOME __SIOW ('T', 7, int)
213 #define SNDCTL_TMR_SELECT __SIOW ('T', 8, int)
214 
215 /*
216  * Some big endian/little endian handling macros (native endian and opposite
217  * endian formats)
218  */
219 
220 #if defined(_AIX) || defined(AIX) || defined(sparc) || defined(__hppa) || defined(PPC) || defined(__powerpc__) && !defined(i386) && !defined(__i386) && !defined(__i386__)
221 
222 /* Big endian machines */
223 # define _PATCHKEY(id) (0xfd00|id)
224 # define AFMT_S16_NE AFMT_S16_BE
225 # define AFMT_U16_NE AFMT_U16_BE
226 # define AFMT_S32_NE AFMT_S32_BE
227 # define AFMT_S24_NE AFMT_S24_BE
228 # define AFMT_S16_OE AFMT_S16_LE
229 # define AFMT_S32_OE AFMT_S32_LE
230 # define AFMT_S24_OE AFMT_S24_LE
231 #else
232 # define _PATCHKEY(id) ((id<<8)|0xfd)
233 # define AFMT_S16_NE AFMT_S16_LE
234 # define AFMT_U16_NE AFMT_U16_LE
235 # define AFMT_S32_NE AFMT_S32_LE
236 # define AFMT_S24_NE AFMT_S24_LE
237 # define AFMT_S16_OE AFMT_S16_BE
238 # define AFMT_S32_OE AFMT_S32_BE
239 # define AFMT_S24_OE AFMT_S24_BE
240 #endif
241 
242 /*
243  * Sample loading mechanism for internal synthesizers (/dev/sequencer)
244  * The following patch_info structure has been designed to support
245  * Gravis UltraSound. It tries to be universal format for uploading
246  * sample based patches but is probably too limited.
247  */
248 
250 {
251  unsigned short key; /* Use WAVE_PATCH here */
252 #define WAVE_PATCH _PATCHKEY(0x04)
253 #define GUS_PATCH WAVE_PATCH
254 #define WAVEFRONT_PATCH _PATCHKEY(0x06)
255 
256  short device_no; /* Synthesizer number */
257  short instr_no; /* Midi pgm# */
258 
259  unsigned int mode;
260 /*
261  * The least significant byte has the same format than the GUS .PAT
262  * files
263  */
264 #define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */
265 #define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */
266 #define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */
267 #define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */
268 #define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */
269 #define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3) */
270 #define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */
271 #define WAVE_FAST_RELEASE 0x80 /* bit 7 = Shut off immediately after note off */
272  /* (use the env_rate/env_offs fields). */
273 /* Linux specific bits */
274 #define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */
275 #define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */
276 #define WAVE_SCALE 0x00040000 /* The scaling info is valid */
277 #define WAVE_FRACTIONS 0x00080000 /* Fraction information is valid */
278 /* Reserved bits */
279 #define WAVE_ROM 0x40000000 /* For future use */
280 #define WAVE_MULAW 0x20000000 /* For future use */
281 /* Other bits must be zeroed */
282 
283  int len; /* Size of the wave data in bytes */
284  int loop_start, loop_end; /* Byte offsets from the beginning */
285 
286 /*
287  * The base_freq and base_note fields are used when computing the
288  * playback speed for a note. The base_note defines the tone frequency
289  * which is heard if the sample is played using the base_freq as the
290  * playback speed.
291  *
292  * The low_note and high_note fields define the minimum and maximum note
293  * frequencies for which this sample is valid. It is possible to define
294  * more than one samples for an instrument number at the same time. The
295  * low_note and high_note fields are used to select the most suitable one.
296  *
297  * The fields base_note, high_note and low_note should contain
298  * the note frequency multiplied by 1000. For example value for the
299  * middle A is 440*1000.
300  */
301 
302  unsigned int base_freq;
303  unsigned int base_note;
304  unsigned int high_note;
305  unsigned int low_note;
306  int panning; /* -128=left, 127=right */
307  int detuning;
308 
309  /* New fields introduced in version 1.99.5 */
310 
311  /* Envelope. Enabled by mode bit WAVE_ENVELOPES */
312  unsigned char env_rate[6]; /* GUS HW ramping rate */
313  unsigned char env_offset[6]; /* 255 == 100% */
314 
315  /*
316  * The tremolo, vibrato and scale info are not supported yet.
317  * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or
318  * WAVE_SCALE
319  */
320 
321  unsigned char tremolo_sweep;
322  unsigned char tremolo_rate;
323  unsigned char tremolo_depth;
324 
325  unsigned char vibrato_sweep;
326  unsigned char vibrato_rate;
327  unsigned char vibrato_depth;
328 
330  unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */
331 
332  int volume;
335  int spare[2];
336  char data[1]; /* The waveform data starts here */
337 };
338 
340 {
341  short key; /* Use SYSEX_PATCH or MAUI_PATCH here */
342 #define SYSEX_PATCH _PATCHKEY(0x05)
343 #define MAUI_PATCH _PATCHKEY(0x06)
344  short device_no; /* Synthesizer number */
345  int len; /* Size of the sysex data in bytes */
346  unsigned char data[1]; /* Sysex data starts here */
347 };
348 
349 /*
350  * /dev/sequencer input events.
351  *
352  * The data written to the /dev/sequencer is a stream of events. Events
353  * are records of 4 or 8 bytes. The first byte defines the size.
354  * Any number of events can be written with a write call. There
355  * is a set of macros for sending these events. Use these macros if you
356  * want to maximize portability of your program.
357  *
358  * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events.
359  * (All input events are currently 4 bytes long. Be prepared to support
360  * 8 byte events also. If you receive any event having first byte >= 128,
361  * it's a 8 byte event.
362  *
363  * The events are documented at the end of this file.
364  *
365  * Normal events (4 bytes)
366  * There is also a 8 byte version of most of the 4 byte events. The
367  * 8 byte one is recommended.
368  *
369  * NOTE! All 4 byte events are now obsolete. Applications should not write
370  * them. However 4 byte events are still used as inputs from
371  * /dev/sequencer (/dev/music uses only 8 byte ones).
372  */
373 #define SEQ_NOTEOFF 0
374 #define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */
375 #define SEQ_NOTEON 1
376 #define SEQ_FMNOTEON SEQ_NOTEON
377 #define SEQ_WAIT TMR_WAIT_ABS
378 #define SEQ_PGMCHANGE 3
379 #define SEQ_FMPGMCHANGE SEQ_PGMCHANGE
380 #define SEQ_SYNCTIMER TMR_START
381 #define SEQ_MIDIPUTC 5
382 #define SEQ_DRUMON 6 /*** OBSOLETE ***/
383 #define SEQ_DRUMOFF 7 /*** OBSOLETE ***/
384 #define SEQ_ECHO TMR_ECHO /* For synching programs with output */
385 #define SEQ_AFTERTOUCH 9
386 #define SEQ_CONTROLLER 10
387 #define SEQ_BALANCE 11
388 #define SEQ_VOLMODE 12
389 
390 /************************************
391  * Midi controller numbers *
392  ************************************/
393 /*
394  * Controllers 0 to 31 (0x00 to 0x1f) and
395  * 32 to 63 (0x20 to 0x3f) are continuous
396  * controllers.
397  * In the MIDI 1.0 these controllers are sent using
398  * two messages. Controller numbers 0 to 31 are used
399  * to send the MSB and the controller numbers 32 to 63
400  * are for the LSB. Note that just 7 bits are used in MIDI bytes.
401  */
402 
403 #define CTL_BANK_SELECT 0x00
404 #define CTL_MODWHEEL 0x01
405 #define CTL_BREATH 0x02
406 /* undefined 0x03 */
407 #define CTL_FOOT 0x04
408 #define CTL_PORTAMENTO_TIME 0x05
409 #define CTL_DATA_ENTRY 0x06
410 #define CTL_MAIN_VOLUME 0x07
411 #define CTL_BALANCE 0x08
412 /* undefined 0x09 */
413 #define CTL_PAN 0x0a
414 #define CTL_EXPRESSION 0x0b
415 /* undefined 0x0c */
416 /* undefined 0x0d */
417 /* undefined 0x0e */
418 /* undefined 0x0f */
419 #define CTL_GENERAL_PURPOSE1 0x10
420 #define CTL_GENERAL_PURPOSE2 0x11
421 #define CTL_GENERAL_PURPOSE3 0x12
422 #define CTL_GENERAL_PURPOSE4 0x13
423 /* undefined 0x14 - 0x1f */
424 
425 /* undefined 0x20 */
426 /* The controller numbers 0x21 to 0x3f are reserved for the */
427 /* least significant bytes of the controllers 0x00 to 0x1f. */
428 /* These controllers are not recognised by the driver. */
429 
430 /* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. */
431 /* 0=OFF and 127=ON (intermediate values are possible) */
432 #define CTL_DAMPER_PEDAL 0x40
433 #define CTL_SUSTAIN 0x40 /* Alias */
434 #define CTL_HOLD 0x40 /* Alias */
435 #define CTL_PORTAMENTO 0x41
436 #define CTL_SOSTENUTO 0x42
437 #define CTL_SOFT_PEDAL 0x43
438 /* undefined 0x44 */
439 #define CTL_HOLD2 0x45
440 /* undefined 0x46 - 0x4f */
441 
442 #define CTL_GENERAL_PURPOSE5 0x50
443 #define CTL_GENERAL_PURPOSE6 0x51
444 #define CTL_GENERAL_PURPOSE7 0x52
445 #define CTL_GENERAL_PURPOSE8 0x53
446 /* undefined 0x54 - 0x5a */
447 #define CTL_EXT_EFF_DEPTH 0x5b
448 #define CTL_TREMOLO_DEPTH 0x5c
449 #define CTL_CHORUS_DEPTH 0x5d
450 #define CTL_DETUNE_DEPTH 0x5e
451 #define CTL_CELESTE_DEPTH 0x5e /* Alias for the above one */
452 #define CTL_PHASER_DEPTH 0x5f
453 #define CTL_DATA_INCREMENT 0x60
454 #define CTL_DATA_DECREMENT 0x61
455 #define CTL_NONREG_PARM_NUM_LSB 0x62
456 #define CTL_NONREG_PARM_NUM_MSB 0x63
457 #define CTL_REGIST_PARM_NUM_LSB 0x64
458 #define CTL_REGIST_PARM_NUM_MSB 0x65
459 /* undefined 0x66 - 0x78 */
460 /* reserved 0x79 - 0x7f */
461 
462 /* Pseudo controllers (not midi compatible) */
463 #define CTRL_PITCH_BENDER 255
464 #define CTRL_PITCH_BENDER_RANGE 254
465 #define CTRL_EXPRESSION 253 /* Obsolete */
466 #define CTRL_MAIN_VOLUME 252 /* Obsolete */
467 
468 /*
469  * Volume mode defines how volumes are used
470  */
471 
472 #define VOL_METHOD_ADAGIO 1
473 #define VOL_METHOD_LINEAR 2
474 
475 /*
476  * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as
477  * input events.
478  */
479 
480 /*
481  * Event codes 0xf0 to 0xfc are reserved for future extensions.
482  */
483 
484 #define SEQ_FULLSIZE 0xfd /* Long events */
485 /*
486  * SEQ_FULLSIZE events are used for loading patches/samples to the
487  * synthesizer devices. These events are passed directly to the driver
488  * of the associated synthesizer device. There is no limit to the size
489  * of the extended events. These events are not queued but executed
490  * immediately when the write() is called (execution can take several
491  * seconds of time).
492  *
493  * When a SEQ_FULLSIZE message is written to the device, it must
494  * be written using exactly one write() call. Other events cannot
495  * be mixed to the same write.
496  *
497  * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the
498  * /dev/sequencer. Don't write other data together with the instrument structure
499  * Set the key field of the structure to FM_PATCH. The device field is used to
500  * route the patch to the corresponding device.
501  *
502  * For wave table use struct patch_info. Initialize the key field
503  * to WAVE_PATCH.
504  */
505 #define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */
506 #define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */
507 
508 /*
509  * Record for FM patches
510  */
511 
512 typedef unsigned char sbi_instr_data[32];
513 
515 {
516  unsigned short key; /* FM_PATCH or OPL3_PATCH */
517 #define FM_PATCH _PATCHKEY(0x01)
518 #define OPL3_PATCH _PATCHKEY(0x03)
519  short device; /* Synth# (0-4) */
520  int channel; /* Program# to be initialized */
521  sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */
522 };
523 
525 { /* Read only */
526  char name[30];
527  int device; /* 0-N. INITIALIZE BEFORE CALLING */
529 #define SYNTH_TYPE_FM 0
530 #define SYNTH_TYPE_SAMPLE 1
531 #define SYNTH_TYPE_MIDI 2 /* Midi interface */
532 
534 #define FM_TYPE_ADLIB 0x00
535 #define FM_TYPE_OPL3 0x01
536 #define MIDI_TYPE_MPU401 0x401
537 
538 #define SAMPLE_TYPE_BASIC 0x10
539 #define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC
540 #define SAMPLE_TYPE_WAVEFRONT 0x11
541 
542  int perc_mode; /* No longer supported */
544  int nr_drums; /* Obsolete field */
546  unsigned int capabilities;
547 #define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */
548 #define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */
549 #define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */
550  int dummies[19]; /* Reserve space */
551 };
552 
554 {
555  char name[32];
556  int caps;
557 };
558 
559 #define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */
560 
561 struct midi_info
562 {
563  char name[30];
564  int device; /* 0-N. INITIALIZE BEFORE CALLING */
565  unsigned int capabilities; /* To be defined later */
566  int dev_type;
567  int dummies[18]; /* Reserve space */
568 };
569 
570 /***************************************
571  * ioctl commands for the /dev/midi## *
572  ***************************************/
573 typedef struct
574 {
575  unsigned char cmd;
576  char nr_args, nr_returns;
577  unsigned char data[30];
579 
580 #define SNDCTL_MIDI_PRETIME __SIOWR('m', 0, int)
581 #define SNDCTL_MIDI_MPUMODE __SIOWR('m', 1, int)
582 #define SNDCTL_MIDI_MPUCMD __SIOWR('m', 2, mpu_command_rec)
583 
584 /**********************************************
585  * IOCTL commands for /dev/dsp and /dev/audio *
586  **********************************************/
587 
588 #define SNDCTL_DSP_RESET __SIO ('P', 0)
589 #define SNDCTL_DSP_SYNC __SIO ('P', 1)
590 #define SNDCTL_DSP_SPEED __SIOWR('P', 2, int)
591 #define SNDCTL_DSP_STEREO __SIOWR('P', 3, int)
592 #define SNDCTL_DSP_GETBLKSIZE __SIOWR('P', 4, int)
593 #define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT
594 #define SNDCTL_DSP_CHANNELS __SIOWR('P', 6, int)
595 #define SNDCTL_DSP_POST __SIO ('P', 8)
596 #define SNDCTL_DSP_SUBDIVIDE __SIOWR('P', 9, int)
597 #define SNDCTL_DSP_SETFRAGMENT __SIOWR('P',10, int)
598 
599 /* Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */
600 #define SNDCTL_DSP_GETFMTS __SIOR ('P',11, int) /* Returns a mask */
601 #define SNDCTL_DSP_SETFMT __SIOWR('P',5, int) /* Selects ONE fmt */
602 # define AFMT_QUERY 0x00000000 /* Return current fmt */
603 # define AFMT_MU_LAW 0x00000001
604 # define AFMT_A_LAW 0x00000002
605 # define AFMT_IMA_ADPCM 0x00000004
606 # define AFMT_U8 0x00000008
607 # define AFMT_S16_LE 0x00000010 /* Little endian signed 16 */
608 # define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */
609 # define AFMT_S8 0x00000040
610 # define AFMT_U16_LE 0x00000080 /* Little endian U16 */
611 # define AFMT_U16_BE 0x00000100 /* Big endian U16 */
612 # define AFMT_MPEG 0x00000200 /* MPEG (2) audio */
613 
614 /* AC3 _compressed_ bitstreams (See Programmer's Guide for details). */
615 # define AFMT_AC3 0x00000400
616 /* Ogg Vorbis _compressed_ bit streams */
617 # define AFMT_VORBIS 0x00000800
618 
619 /* 32 bit formats (MSB aligned) formats */
620 # define AFMT_S32_LE 0x00001000
621 # define AFMT_S32_BE 0x00002000
622 
623 /* Reserved for _native_ endian double precision IEEE floating point */
624 # define AFMT_FLOAT 0x00004000
625 
626 /* 24 bit formats (LSB aligned in 32 bit word) formats */
627 # define AFMT_S24_LE 0x00008000
628 # define AFMT_S24_BE 0x00010000
629 
630 /*
631  * S/PDIF raw format. In this format the S/PDIF frames (including all
632  * control and user bits) are included in the data stream. Each sample
633  * is stored in a 32 bit frame (see IEC-958 for more info). This format
634  * is supported by very few devices and it's only usable for purposes
635  * where full access to the control/user bits is required (real time control).
636  */
637 # define AFMT_SPDIF_RAW 0x00020000
638 
639 /* 24 bit packed (3 byte) little endian format (USB compatibility) */
640 # define AFMT_S24_PACKED 0x00040000
641 
642 /*
643  * Buffer status queries.
644  */
645 typedef struct audio_buf_info
646 {
647  int fragments; /* # of available fragments (partially usend ones not counted) */
648  int fragstotal; /* Total # of fragments allocated */
649  int fragsize; /* Size of a fragment in bytes */
650  int bytes; /* Available space in bytes (includes partially used fragments) */
651  /* Note! 'bytes' could be more than fragments*fragsize */
653 
654 #define SNDCTL_DSP_GETOSPACE __SIOR ('P',12, audio_buf_info)
655 #define SNDCTL_DSP_GETISPACE __SIOR ('P',13, audio_buf_info)
656 #define SNDCTL_DSP_NONBLOCK __SIO ('P',14) /* Obsolete. Not supported */
657 #define SNDCTL_DSP_GETCAPS __SIOR ('P',15, int)
658 # define DSP_CAP_REVISION 0x000000ff /* Bits for revision level (0 to 255) */
659 # define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */
660 # define DSP_CAP_REALTIME 0x00000200 /* Not in use */
661 # define DSP_CAP_BATCH 0x00000400 /* Device has some kind of */
662  /* internal buffers which may */
663  /* cause some delays and */
664  /* decrease precision of timing */
665 # define DSP_CAP_COPROC 0x00000800 /* Has a coprocessor */
666  /* Sometimes it's a DSP */
667  /* but usually not */
668 # define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */
669 # define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */
670 # define DSP_CAP_MULTI 0x00004000 /* Supports multiple open */
671 # define DSP_CAP_BIND 0x00008000 /* Supports binding to front/rear/center/lfe */
672 # define DSP_CAP_INPUT 0x00010000 /* Supports recording */
673 # define DSP_CAP_OUTPUT 0x00020000 /* Supports playback */
674 # define DSP_CAP_VIRTUAL 0x00040000 /* Virtuial device */
675 /* 0x00040000 and 0x00080000 reserved for future use */
676 
677 /* Analog/digital control capabilities */
678 # define DSP_CAP_ANALOGOUT 0x00100000
679 # define DSP_CAP_ANALOGIN 0x00200000
680 # define DSP_CAP_DIGITALOUT 0x00400000
681 # define DSP_CAP_DIGITALIN 0x00800000
682 # define DSP_CAP_ADMASK 0x00f00000
683 /*
684  * NOTE! (capabilities & DSP_CAP_ADMASK)==0 means just that the
685  * digital/analog interface control features are not supported by the
686  * device/driver. However the device still supports analog, digital or
687  * both inputs/outputs (depending on the device). See the OSS Programmer's
688  * Guide for full details.
689  */
690 # define DSP_CAP_SHADOW 0x01000000 /* "Shadow" device */
691 
692 /*
693  * Preferred channel usage. These bits can be used to
694  * give recommendations to the application. Used by few drivers.
695  * For example if ((caps & DSP_CH_MASK) == DSP_CH_MONO) means that
696  * the device works best in mono mode. However it doesn't necessarily mean
697  * that the device cannot be used in stereo. These bits should only be used
698  * special applications such as multi track hard disk recorders to find out
699  * the initial setup. However the user should be able to override this
700  * selection.
701  *
702  * To find out which modes are actually supported the application should
703  * try to select them using SNDCTL_DSP_CHANNELS.
704  */
705 # define DSP_CH_MASK 0x06000000 /* Mask */
706 # define DSP_CH_ANY 0x00000000 /* No preferred mode */
707 # define DSP_CH_MONO 0x02000000
708 # define DSP_CH_STEREO 0x04000000
709 # define DSP_CH_MULTI 0x06000000 /* More than two channels */
710 
711 # define DSP_CAP_SLAVE 0x08000000 /* "Slave" device */
712 # define DSP_CAP_FREERATE 0x10000000
713 
714 #define SNDCTL_DSP_GETTRIGGER __SIOR ('P',16, int)
715 #define SNDCTL_DSP_SETTRIGGER __SIOW ('P',16, int)
716 # define PCM_ENABLE_INPUT 0x00000001
717 # define PCM_ENABLE_OUTPUT 0x00000002
718 
719 typedef struct count_info
720 {
721  unsigned int bytes; /* Total # of bytes processed */
722  int blocks; /* # of fragment transitions since last time */
723  int ptr; /* Current DMA pointer value */
724 } count_info;
725 
726 #define SNDCTL_DSP_GETIPTR __SIOR ('P',17, count_info)
727 #define SNDCTL_DSP_GETOPTR __SIOR ('P',18, count_info)
728 
729 typedef struct buffmem_desc
730 {
731  unsigned *buffer;
732  int size;
733 } buffmem_desc;
734 #define SNDCTL_DSP_MAPINBUF __SIOR ('P', 19, buffmem_desc)
735 #define SNDCTL_DSP_MAPOUTBUF __SIOR ('P', 20, buffmem_desc)
736 #define SNDCTL_DSP_SETSYNCRO __SIO ('P', 21)
737 #define SNDCTL_DSP_SETDUPLEX __SIO ('P', 22)
738 
739 /*
740  * Application's profile defines the way how playback underrun situations
741  * should be handled.
742  *
743  * APF_NORMAL (the default) and APF_NETWORK make the driver to cleanup the
744  * playback buffer whenever an underrun occurs. This consumes some time
745  * prevents looping the existing buffer.
746  * APF_CPUINTENS is intended to be set by CPU intensive applications which
747  * are likely to run out of time occasionally. In this mode the buffer cleanup
748  * is disabled which saves CPU time but also let's the previous buffer content
749  * to be played during the "pause" after the underrun.
750  */
751 #define SNDCTL_DSP_PROFILE __SIOW ('P', 23, int)
752 #define APF_NORMAL 0 /* Normal applications */
753 #define APF_NETWORK 1 /* Underruns probably caused by an "external" delay */
754 #define APF_CPUINTENS 2 /* Underruns probably caused by "overheating" the CPU */
755 
756 #define SNDCTL_DSP_GETODELAY __SIOR ('P', 23, int)
757 #define SNDCTL_DSP_GETOUTVOL __SIOR ('P', 24, int)
758 #define SNDCTL_DSP_SETOUTVOL __SIOWR('P', 24, int)
759 
760 typedef struct audio_errinfo
761 {
764  unsigned int play_ptradjust;
765  unsigned int rec_ptradjust;
772  int filler[16];
773 } audio_errinfo;
774 
775 #define SNDCTL_DSP_GETERROR __SIOR ('P', 25, audio_errinfo)
776 
777 typedef struct oss_digital_control
778 {
779  unsigned int caps;
780 #define DIG_CBITIN_NONE 0x00000000
781 #define DIG_CBITIN_LIMITED 0x00000001
782 #define DIG_CBITIN_DATA 0x00000002
783 #define DIG_CBITIN_BYTE0 0x00000004
784 #define DIG_CBITIN_FULL 0x00000008
785 #define DIG_CBITIN_MASK 0x0000000f
786 #define DIG_CBITOUT_NONE 0x00000000
787 #define DIG_CBITOUT_LIMITED 0x00000010
788 #define DIG_CBITOUT_BYTE0 0x00000020
789 #define DIG_CBITOUT_FULL 0x00000040
790 #define DIG_CBITOUT_DATA 0x00000080
791 #define DIG_CBITOUT_MASK 0x000000f0
792 #define DIG_UBITIN 0x00000100
793 #define DIG_UBITOUT 0x00000200
794 #define DIG_VBITOUT 0x00000400
795 #define DIG_OUTRATE 0x00000800
796 #define DIG_INRATE 0x00001000
797 #define DIG_INBITS 0x00002000
798 #define DIG_OUTBITS 0x00004000
799 #define DIG_EXACT 0x00010000
800 #define DIG_PRO 0x00020000
801 #define DIG_CONSUMER 0x00040000
802 #define DIG_PASSTHROUGH 0x00080000
803 #define DIG_OUTSEL 0x00100000
804 
805  unsigned int valid;
806 #define VAL_CBITIN 0x00000001
807 #define VAL_UBITIN 0x00000002
808 #define VAL_CBITOUT 0x00000004
809 #define VAL_UBITOUT 0x00000008
810 #define VAL_ISTATUS 0x00000010
811 #define VAL_IRATE 0x00000020
812 #define VAL_ORATE 0x00000040
813 #define VAL_INBITS 0x00000080
814 #define VAL_OUTBITS 0x00000100
815 #define VAL_REQUEST 0x00000200
816 #define VAL_OUTSEL 0x00000400
817 
818 #define VAL_OUTMASK (VAL_CBITOUT|VAL_UBITOUT|VAL_ORATE|VAL_OUTBITS|VAL_OUTSEL)
819 
820  unsigned int request, param;
821 #define SPD_RQ_PASSTHROUGH 1
822 
823  unsigned char cbitin[24];
824  unsigned char ubitin[24];
825  unsigned char cbitout[24];
826  unsigned char ubitout[24];
827 
828  unsigned int outsel;
829 #define OUTSEL_DIGITAL 1
830 #define OUTSEL_ANALOG 2
831 #define OUTSEL_BOTH (OUTSEL_DIGITAL|OUTSEL_ANALOG)
832 
833  int in_data; /* Audio/data if autodetectable by the receiver */
834 #define IND_UNKNOWN 0
835 #define IND_AUDIO 1
836 #define IND_DATA 2
837 
838  int in_locked; /* Receiver locked */
839 #define LOCK_NOT_INDICATED 0
840 #define LOCK_UNLOCKED 1
841 #define LOCK_LOCKED 2
842 
843  int in_quality; /* Input signal quality */
844 #define IN_QUAL_NOT_INDICATED 0
845 #define IN_QUAL_POOR 1
846 #define IN_QUAL_GOOD 2
847 
848  int in_vbit, out_vbit; /* V bits */
849 #define VBIT_NOT_INDICATED 0
850 #define VBIT_OFF 1
851 #define VBIT_ON 2
852 
853  unsigned int in_errors; /* Various input errro conditions */
854 #define INERR_CRC 0x0001
855 #define INERR_QCODE_CRC 0x0002
856 #define INERR_PARITY 0x0004
857 #define INERR_BIPHASE 0x0008
858 
861 
862  int filler[32];
864 
865 #define SNDCTL_DSP_READCTL __SIOWR('P', 26, oss_digital_control)
866 #define SNDCTL_DSP_WRITECTL __SIOWR('P', 27, oss_digital_control)
867 
868 typedef struct oss_syncgroup
869 {
870  int id;
871  int mode;
872  int filler[16];
873 } oss_syncgroup;
874 
875 #define SNDCTL_DSP_SYNCGROUP __SIOWR('P', 28, oss_syncgroup)
876 #define SNDCTL_DSP_SYNCSTART __SIOW ('P', 29, int)
877 
878 /*
879  * "cooked" mode enables software based conversions for sample rate, sample
880  * format (bits) and number of channels (mono/stereo). These conversions are
881  * required with some devices that support only one sample rate or just stereo
882  * to let the applications to use other formats. The cooked mode is enabled by
883  * default. However it's necessary to disable this mode when mmap() is used or
884  * when very deterministic timing is required. SNDCTL_DSP_COOKEDMODE is an
885  * optional call introduced in OSS 3.9.6f. It's _error return must be ignored_
886  * since normally this call will return erno=EINVAL.
887  *
888  * SNDCTL_DSP_COOKEDMODE must be called immediately after open before doing
889  * anything else. Otherwise the call will not have any effect.
890  */
891 #define SNDCTL_DSP_COOKEDMODE __SIOW ('P', 30, int)
892 
893 /*
894  * SNDCTL_DSP_SILENCE and SNDCTL_DSP_SKIP are new calls in OSS 3.99.0
895  * that can be used to implement pause/continue during playback (no effect
896  * on recording).
897  */
898 #define SNDCTL_DSP_SILENCE __SIO ('P', 31)
899 #define SNDCTL_DSP_SKIP __SIO ('P', 32)
900 #define SNDCTL_DSP_RESET_INPUT __SIO ('P', 33)
901 #define SNDCTL_DSP_RESET_OUTPUT __SIO ('P', 34)
902 #define SNDCTL_DSP_LOW_WATER __SIOW ('P', 34, int)
903 
904 #ifndef OSS_NO_LONG_LONG
905 typedef struct
906 {
907  long long samples;
909  int filler[32]; /* For future use */
910 } oss_count_t;
911 
912 #define SNDCTL_DSP_CURRENT_IPTR __SIOR ('P', 35, oss_count_t)
913 #define SNDCTL_DSP_CURRENT_OPTR __SIOR ('P', 36, oss_count_t)
914 #endif
915 
916 #define SNDCTL_DSP_GET_RECSRC_NAMES __SIOR ('P', 37, oss_mixer_enuminfo)
917 #define SNDCTL_DSP_GET_RECSRC __SIOR ('P', 38, int)
918 #define SNDCTL_DSP_SET_RECSRC __SIOWR('P', 38, int)
919 
920 #define SNDCTL_DSP_GET_PLAYTGT_NAMES __SIOR ('P', 39, oss_mixer_enuminfo)
921 #define SNDCTL_DSP_GET_PLAYTGT __SIOR ('P', 40, int)
922 #define SNDCTL_DSP_SET_PLAYTGT __SIOWR('P', 40, int)
923 
924 #define SNDCTL_DSP_GETCHANNELMASK __SIOWR('P', 64, int)
925 #define SNDCTL_DSP_BIND_CHANNEL __SIOWR('P', 65, int)
926 # define DSP_BIND_QUERY 0x00000000
927 # define DSP_BIND_FRONT 0x00000001
928 # define DSP_BIND_SURR 0x00000002
929 # define DSP_BIND_CENTER_LFE 0x00000004
930 # define DSP_BIND_HANDSET 0x00000008
931 # define DSP_BIND_MIC 0x00000010
932 # define DSP_BIND_MODEM1 0x00000020
933 # define DSP_BIND_MODEM2 0x00000040
934 # define DSP_BIND_I2S 0x00000080
935 # define DSP_BIND_SPDIF 0x00000100
936 # define DSP_BIND_REAR 0x00000200
937 
938 /**********************************
939  * IOCTL commands for /dev/mixer *
940  **********************************/
941 
942 /*
943  * Mixer devices
944  *
945  * There can be up to 20 different analog mixer channels. The
946  * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
947  * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
948  * the devices supported by the particular mixer.
949  */
950 
951 #define SOUND_MIXER_NRDEVICES 28
952 #define SOUND_MIXER_VOLUME 0
953 #define SOUND_MIXER_BASS 1
954 #define SOUND_MIXER_TREBLE 2
955 #define SOUND_MIXER_SYNTH 3
956 #define SOUND_MIXER_PCM 4
957 #define SOUND_MIXER_SPEAKER 5
958 #define SOUND_MIXER_LINE 6
959 #define SOUND_MIXER_MIC 7
960 #define SOUND_MIXER_CD 8
961 #define SOUND_MIXER_IMIX 9 /* Recording monitor */
962 #define SOUND_MIXER_ALTPCM 10
963 #define SOUND_MIXER_RECLEV 11 /* Recording level */
964 #define SOUND_MIXER_IGAIN 12 /* Input gain */
965 #define SOUND_MIXER_OGAIN 13 /* Output gain */
966 /*
967  * Some soundcards have three line level inputs (line, aux1 and aux2).
968  * Since each card manufacturer has assigned different meanings to
969  * these inputs, it's impractical to assign specific meanings
970  * (eg line, cd, synth etc.) to them.
971  */
972 #define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */
973 #define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */
974 #define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */
975 #define SOUND_MIXER_DIGITAL1 17 /* Digital I/O 1 */
976 #define SOUND_MIXER_DIGITAL2 18 /* Digital I/O 2 */
977 #define SOUND_MIXER_DIGITAL3 19 /* Digital I/O 3 */
978 #define SOUND_MIXER_PHONE 20 /* Phone */
979 #define SOUND_MIXER_MONO 21 /* Mono Output */
980 #define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */
981 #define SOUND_MIXER_RADIO 23 /* Radio in */
982 #define SOUND_MIXER_DEPTH 24 /* Surround depth */
983 #define SOUND_MIXER_REARVOL 25 /* Rear/Surround speaker vol */
984 #define SOUND_MIXER_CENTERVOL 26 /* Center/LFE speaker vol */
985 #define SOUND_MIXER_SURRVOL 27 /* Mid-Surround (8speaker) vol */
986 
987 /* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */
988 /* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */
989 #define SOUND_ONOFF_MIN 28
990 #define SOUND_ONOFF_MAX 30
991 
992 /* Note! Number 31 cannot be used since the sign bit is reserved */
993 #define SOUND_MIXER_NONE 31
994 
995 /*
996  * The following unsupported macros are no longer functional.
997  * Use SOUND_MIXER_PRIVATE# macros in future.
998  */
999 #define SOUND_MIXER_ENHANCE SOUND_MIXER_NONE
1000 #define SOUND_MIXER_MUTE SOUND_MIXER_NONE
1001 #define SOUND_MIXER_LOUD SOUND_MIXER_NONE
1002 
1003 #define SOUND_DEVICE_LABELS \
1004  {"Vol ", "Bass ", "Treble", "Synth", "Pcm ", "Speaker ", "Line ", \
1005  "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \
1006  "Aux1", "Aux2", "Aux3", "Digital1", "Digital2", "Digital3", \
1007  "Phone", "Mono", "Video", "Radio", "Depth", \
1008  "Rear", "Center", "Surround"}
1009 
1010 #define SOUND_DEVICE_NAMES \
1011  {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
1012  "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
1013  "aux1", "aux2", "aux3", "dig1", "dig2", "dig3", \
1014  "phone", "mono", "video", "radio", "depth", \
1015  "rear", "center", "surround"}
1016 
1017 /* Device bitmask identifiers */
1018 
1019 #define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */
1020 #define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */
1021 #define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */
1022 #define SOUND_MIXER_CAPS 0xfc
1023 # define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */
1024 # define SOUND_CAP_LAYOUT_B 0x00000002 /* For internal use only */
1025 # define SOUND_CAP_NOLEGACY 0x00000004 /* For internal use only */
1026 # define SOUND_CAP_NORECSRC 0x00000008
1027 #define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */
1028 
1029 /* OSS/Free ONLY */
1030 #define SOUND_MIXER_OUTSRC 0xfa /* Arg contains a bit for each input source to output */
1031 #define SOUND_MIXER_OUTMASK 0xf9 /* Arg contains a bit for each supported input source to output */
1032 /* OSS/Free ONLY */
1033 
1034 /* Device mask bits */
1035 
1036 #define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME)
1037 #define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS)
1038 #define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE)
1039 #define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH)
1040 #define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM)
1041 #define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER)
1042 #define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE)
1043 #define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC)
1044 #define SOUND_MASK_CD (1 << SOUND_MIXER_CD)
1045 #define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX)
1046 #define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM)
1047 #define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV)
1048 #define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN)
1049 #define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN)
1050 #define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1)
1051 #define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2)
1052 #define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3)
1053 #define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1)
1054 #define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2)
1055 #define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3)
1056 #define SOUND_MASK_MONO (1 << SOUND_MIXER_MONO)
1057 #define SOUND_MASK_PHONE (1 << SOUND_MIXER_PHONE)
1058 #define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO)
1059 #define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO)
1060 #define SOUND_MASK_DEPTH (1 << SOUND_MIXER_DEPTH)
1061 #define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR)
1062 #define SOUND_MASK_REARVOL (1 << SOUND_MIXER_REARVOL)
1063 #define SOUND_MASK_CENTERVOL (1 << SOUND_MIXER_CENTERVOL)
1064 #define SOUND_MASK_SURRVOL (1 << SOUND_MIXER_SURRVOL)
1065 
1066 /* Obsolete macros */
1067 #define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE)
1068 #define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE)
1069 #define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD)
1070 
1071 #define MIXER_READ(dev) __SIOR('M', dev, int)
1072 #define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME)
1073 #define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS)
1074 #define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE)
1075 #define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH)
1076 #define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM)
1077 #define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER)
1078 #define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE)
1079 #define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC)
1080 #define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD)
1081 #define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX)
1082 #define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM)
1083 #define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV)
1084 #define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN)
1085 #define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN)
1086 #define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1)
1087 #define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2)
1088 #define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3)
1089 
1090 /* Obsolete macros */
1091 #define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE)
1092 #define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE)
1093 #define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD)
1094 
1095 #define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC)
1096 #define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK)
1097 #define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK)
1098 #define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS)
1099 #define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS)
1100 
1101 #define MIXER_WRITE(dev) __SIOWR('M', dev, int)
1102 #define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME)
1103 #define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS)
1104 #define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE)
1105 #define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH)
1106 #define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM)
1107 #define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER)
1108 #define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE)
1109 #define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC)
1110 #define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD)
1111 #define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX)
1112 #define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM)
1113 #define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV)
1114 #define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN)
1115 #define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN)
1116 #define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1)
1117 #define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2)
1118 #define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3)
1119 
1120 /* Obsolete macros */
1121 #define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE)
1122 #define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE)
1123 #define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD)
1124 
1125 #define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC)
1126 
1127 typedef struct mixer_info
1128 {
1129  char id[16];
1130  char name[32];
1132  int fillers[10];
1133 } mixer_info;
1134 
1135 typedef struct _old_mixer_info
1136 { /* Obsolete */
1137  char id[16];
1138  char name[32];
1139 } _old_mixer_info;
1140 
1141 #define SOUND_MIXER_INFO __SIOR ('M', 101, mixer_info)
1142 #define SOUND_OLD_MIXER_INFO __SIOR ('M', 101, _old_mixer_info)
1143 
1144 /*
1145  * A mechanism for accessing "proprietary" mixer features. This method
1146  * permits passing 128 bytes of arbitrary data between a mixer application
1147  * and the mixer driver. Interpretation of the record is defined by
1148  * the particular mixer driver.
1149  */
1150 typedef unsigned char mixer_record[128];
1151 
1152 #define SOUND_MIXER_ACCESS __SIOWR('M', 102, mixer_record)
1153 
1154 /*
1155  * Two ioctls for special souncard function (OSS/Free only)
1156  */
1157 #define SOUND_MIXER_AGC _SIOWR('M', 103, int)
1158 #define SOUND_MIXER_3DSE _SIOWR('M', 104, int)
1159 /*
1160  * The SOUND_MIXER_PRIVATE# commands can be redefined by low level drivers.
1161  * These features can be used when accessing device specific features.
1162  */
1163 #define SOUND_MIXER_PRIVATE1 __SIOWR('M', 111, int)
1164 #define SOUND_MIXER_PRIVATE2 __SIOWR('M', 112, int)
1165 #define SOUND_MIXER_PRIVATE3 __SIOWR('M', 113, int)
1166 #define SOUND_MIXER_PRIVATE4 __SIOWR('M', 114, int)
1167 #define SOUND_MIXER_PRIVATE5 __SIOWR('M', 115, int)
1168 
1169 /*
1170  * SOUND_MIXER_GETLEVELS and SOUND_MIXER_SETLEVELS calls can be used
1171  * for querying current mixer settings from the driver and for loading
1172  * default volume settings _prior_ activating the mixer (loading
1173  * doesn't affect current state of the mixer hardware). These calls
1174  * are for internal use by the driver software only.
1175  */
1176 
1177 typedef struct mixer_vol_table
1178 {
1179  int num; /* Index to volume table */
1180  char name[32];
1181  int levels[32];
1182 } mixer_vol_table;
1183 
1184 #define SOUND_MIXER_GETLEVELS __SIOWR('M', 116, mixer_vol_table)
1185 #define SOUND_MIXER_SETLEVELS __SIOWR('M', 117, mixer_vol_table)
1186 
1187 /*
1188  * An ioctl for identifying the driver version. It will return value
1189  * of the SOUND_VERSION macro used when compiling the driver.
1190  * This call was introduced in OSS version 3.6 and it will not work
1191  * with earlier versions (returns EINVAL).
1192  */
1193 #define OSS_GETVERSION __SIOR ('M', 118, int)
1194 /*
1195  * Calls to set/get the recording gain for the currently active
1196  * recording source. These calls automatically map to the right control.
1197  * Note that these calls are not supported by all drivers. In this case
1198  * the call will return -1 with errno set to EINVAL
1199  *
1200  * The _MONGAIN work in similar way but set/get the monitoring gain for
1201  * the currently selected recording source.
1202  */
1203 #define SOUND_MIXER_READ_RECGAIN __SIOR ('M', 119, int)
1204 #define SOUND_MIXER_WRITE_RECGAIN __SIOWR('M', 119, int)
1205 #define SOUND_MIXER_READ_MONGAIN __SIOR ('M', 120, int)
1206 #define SOUND_MIXER_WRITE_MONGAIN __SIOWR('M', 120, int)
1207 
1208 /* The following call is for driver development time purposes. It's not
1209  * present in any released drivers.
1210  */
1211 typedef unsigned char oss_reserved_t[512];
1212 #define SOUND_MIXER_RESERVED __SIOWR('M', 121, oss_reserved_t)
1213 
1214 /****************************************************
1215  * Extended mixer interface (OSS 3.99.0 and later) *
1216  ****************************************************/
1217 #define SYSINFO_FILL_SIZE 256
1218 
1219 typedef struct oss_sysinfo
1220 {
1221  char product[32]; /* For example OSS/Free, OSS/Linux or OSS/Solaris */
1222  char version[32]; /* For example 4.0a */
1223  int versionnum; /* See OSS_GETVERSION */
1224  char options[128]; /* Reserved */
1225 
1226  int numaudios; /* # of audio/dsp devices */
1227  int openedaudio[8]; /* Bit mask telling which audio devices are busy */
1228 
1229  int numsynths; /* # of availavle synth devices */
1230  int nummidis; /* # of available MIDI ports */
1231  int numtimers; /* # of available timer devices */
1232  int nummixers; /* # of mixer devices */
1233 
1234  int filler[SYSINFO_FILL_SIZE]; /* For future expansion (set to -1) */
1235 } oss_sysinfo;
1236 
1237 typedef struct oss_mixext
1238 {
1239  int dev; /* Mixer device number */
1240  int ctrl; /* Controller number */
1241  int type; /* Entry type */
1242 # define MIXT_DEVROOT 0 /* Device root entry */
1243 # define MIXT_GROUP 1 /* Controller group */
1244 # define MIXT_ONOFF 2 /* OFF (0) or ON (1) */
1245 # define MIXT_ENUM 3 /* Enumerated (0 to maxvalue) */
1246 # define MIXT_MONOSLIDER 4 /* Mono slider (0 to 100) */
1247 # define MIXT_STEREOSLIDER 5 /* Stereo slider (dual 0 to 100) */
1248 # define MIXT_MESSAGE 6 /* (Readable) textual message */
1249 # define MIXT_MONOVU 7 /* VU meter value (mono) */
1250 # define MIXT_STEREOVU 8 /* VU meter value (stereo) */
1251 # define MIXT_MONOPEAK 9 /* VU meter peak value (mono) */
1252 # define MIXT_STEREOPEAK 10 /* VU meter peak value (stereo) */
1253 # define MIXT_RADIOGROUP 11 /* Radio button group */
1254 # define MIXT_MARKER 12 /* Separator between normal and extension entries */
1255 # define MIXT_VALUE 13 /* Decimal value entry */
1256 # define MIXT_HEXVALUE 14 /* Hexadecimal value entry */
1257 # define MIXT_MONODB 15 /* Mono atten. slider (0 to -144) */
1258 # define MIXT_STEREODB 16 /* Stereo atten. slider (dual 0 to -144) */
1259 # define MIXT_SLIDER 17 /* Slider (mono) with full integer range */
1260 # define MIXT_3D 18
1261 
1262  /* Possible value range (minvalue to maxvalue) */
1263  /* Note that maxvalue may also be smaller than minvalue */
1266 
1267  int flags;
1268 # define MIXF_READABLE 0x00000001 /* Has readable value */
1269 # define MIXF_WRITEABLE 0x00000002 /* Has writeable value */
1270 # define MIXF_POLL 0x00000004 /* May change itself */
1271 # define MIXF_HZ 0x00000008 /* Herz scale */
1272 # define MIXF_STRING 0x00000010 /* Use dynamic extensions for value */
1273 # define MIXF_DYNAMIC 0x00000010 /* Supports dynamic extensions */
1274  char id[16]; /* Mnemonic ID (mainly for internal use) */
1275  int parent; /* Entry# of parent (group) node (-1 if root) */
1276 
1277  int dummy; /* Internal use */
1278 
1280 
1281  char data[64]; /* Misc data (entry type dependent) */
1282  unsigned char enum_present[32]; /* Mask of allowed enum values */
1283  int control_no; /* SOUND_MIXER_VOLUME..SOUND_MIXER_MIDI */
1284  /* (-1 means not indicated) */
1285  int desc; /* Descriptive code. For future use. */
1286  char extname[32];
1287  int filler[8];
1288 } oss_mixext;
1289 
1290 typedef struct oss_mixext_root
1291 {
1292  char id[16];
1293  char name[48];
1294 } oss_mixext_root;
1295 
1296 typedef struct oss_mixer_value
1297 {
1298  int dev;
1299  int ctrl;
1300  int value;
1301  int flags; /* Reserved for future use. Initialize to 0 */
1302  int timestamp; /* Must be set to oss_mixext.timestamp */
1303  int filler[8]; /* Reserved for future use. Initialize to 0 */
1304 } oss_mixer_value;
1305 
1306 #define OSS_ENUM_MAXVALUE 255
1307 typedef struct oss_mixer_enuminfo
1308 {
1309  int dev;
1310  int ctrl;
1311  int nvalues;
1313  char strings[3000];
1315 
1316 #define OPEN_READ PCM_ENABLE_INPUT
1317 #define OPEN_WRITE PCM_ENABLE_OUTPUT
1318 #define OPEN_READWRITE (OPEN_READ|OPEN_WRITE)
1319 
1320 typedef struct oss_audioinfo
1321 {
1322  int dev; /* Audio device number */
1323  char name[64];
1324  int busy; /* 0, OPEN_READ, OPEN_WRITE or OPEN_READWRITE */
1325  int pid;
1326  int caps; /* DSP_CAP_INPUT, DSP_CAP_OUTPUT */
1328  int magic; /* Reserved for internal use */
1329  char cmd[64]; /* Command using the device */
1333  int real_device; /* This is the right /dev/dsp# device to open */
1334  int enabled; /* 1=enabled, 0=device not ready at this moment */
1335  int flags; /* For internal use only - no practical meaning */
1336  int min_rate, max_rate; /* Sample rate limits */
1337  int min_channels, max_channels; /* Number of channels supported */
1338  int binding; /* DSP_BIND_FRONT, etc. 0 means undefined */
1340  char handle[32];
1341  int nrates, rates[20]; /* Please read the manual before using these */
1342  int filler[215];
1343 } oss_audioinfo;
1344 
1345 #define OSS_SYSINFO __SIOR ('X', 1, oss_sysinfo)
1346 
1347 #define SNDCTL_MIX_NRMIX __SIOR ('X', 2, int)
1348 #define SNDCTL_MIX_NREXT __SIOWR('X', 3, int)
1349 #define SNDCTL_MIX_EXTINFO __SIOWR('X', 4, oss_mixext)
1350 #define SNDCTL_MIX_READ __SIOWR('X', 5, oss_mixer_value)
1351 #define SNDCTL_MIX_WRITE __SIOWR('X', 6, oss_mixer_value)
1352 
1353 #define SNDCTL_AUDIOINFO __SIOWR('X', 7, oss_audioinfo)
1354 #define SNDCTL_MIX_ENUMINFO __SIOWR('X', 8, oss_mixer_enuminfo)
1355 
1356 /* ioctl codes 'X', 200-255 are reserved for internal use */
1357 
1358 /*
1359  * Level 2 event types for /dev/sequencer
1360  */
1361 
1362 /*
1363  * The 4 most significant bits of byte 0 specify the class of
1364  * the event:
1365  *
1366  * 0x8X = system level events,
1367  * 0x9X = device/port specific events, event[1] = device/port,
1368  * The last 4 bits give the subtype:
1369  * 0x02 = Channel event (event[3] = chn).
1370  * 0x01 = note event (event[4] = note).
1371  * (0x01 is not used alone but always with bit 0x02).
1372  * event[2] = MIDI message code (0x80=note off etc.)
1373  *
1374  */
1375 
1376 #define EV_SEQ_LOCAL 0x80
1377 #define EV_TIMING 0x81
1378 #define EV_CHN_COMMON 0x92
1379 #define EV_CHN_VOICE 0x93
1380 #define EV_SYSEX 0x94
1381 #define EV_SYSTEM 0x95 /* MIDI system and real time messages (input only) */
1382 /*
1383  * Event types 200 to 220 are reserved for application use.
1384  * These numbers will not be used by the driver.
1385  */
1386 
1387 /*
1388  * Events for event type EV_CHN_VOICE
1389  */
1390 
1391 #define MIDI_NOTEOFF 0x80
1392 #define MIDI_NOTEON 0x90
1393 #define MIDI_KEY_PRESSURE 0xA0
1394 
1395 /*
1396  * Events for event type EV_CHN_COMMON
1397  */
1398 
1399 #define MIDI_CTL_CHANGE 0xB0
1400 #define MIDI_PGM_CHANGE 0xC0
1401 #define MIDI_CHN_PRESSURE 0xD0
1402 #define MIDI_PITCH_BEND 0xE0
1403 
1404 #define MIDI_SYSTEM_PREFIX 0xF0
1405 
1406 /*
1407  * Timer event types
1408  */
1409 #define TMR_WAIT_REL 1 /* Time relative to the prev time */
1410 #define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */
1411 #define TMR_STOP 3
1412 #define TMR_START 4
1413 #define TMR_CONTINUE 5
1414 #define TMR_TEMPO 6
1415 #define TMR_ECHO 8
1416 #define TMR_CLOCK 9 /* MIDI clock */
1417 #define TMR_SPP 10 /* Song position pointer */
1418 #define TMR_TIMESIG 11 /* Time signature */
1419 
1420 /*
1421  * Local event types
1422  */
1423 #define LOCL_STARTAUDIO 1
1424 #define LOCL_STARTAUDIO2 2
1425 #define LOCL_STARTAUDIO3 3
1426 #define LOCL_STARTAUDIO4 4
1427 
1428 #if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS)
1429 /*
1430  * Some convenience macros to simplify programming of the
1431  * /dev/sequencer interface
1432  *
1433  * These macros define the API which should be used when possible.
1434  */
1435 #define SEQ_DECLAREBUF() SEQ_USE_EXTBUF()
1436 
1437 void seqbuf_dump (void); /* This function must be provided by programs */
1438 
1439 EXTERNC int OSS_init (int seqfd, int buflen);
1440 EXTERNC void OSS_seqbuf_dump (int fd, unsigned char *buf, int buflen);
1441 EXTERNC void OSS_seq_advbuf (int len, int fd, unsigned char *buf, int buflen);
1442 EXTERNC void OSS_seq_needbuf (int len, int fd, unsigned char *buf,
1443  int buflen);
1444 EXTERNC void OSS_patch_caching (int dev, int chn, int patch, int fd,
1445  unsigned char *buf, int buflen);
1446 EXTERNC void OSS_drum_caching (int dev, int chn, int patch, int fd,
1447  unsigned char *buf, int buflen);
1448 EXTERNC void OSS_write_patch (int fd, unsigned char *buf, int len);
1449 EXTERNC int OSS_write_patch2 (int fd, unsigned char *buf, int len);
1450 
1451 #define SEQ_PM_DEFINES int __foo_bar___
1452 #ifdef OSSLIB
1453 # define SEQ_USE_EXTBUF() \
1454  EXTERNC unsigned char *_seqbuf; \
1455  EXTERNC int _seqbuflen;EXTERNC int _seqbufptr
1456 # define SEQ_DEFINEBUF(len) SEQ_USE_EXTBUF();static int _requested_seqbuflen=len
1457 # define _SEQ_ADVBUF(len) OSS_seq_advbuf(len, seqfd, _seqbuf, _seqbuflen)
1458 # define _SEQ_NEEDBUF(len) OSS_seq_needbuf(len, seqfd, _seqbuf, _seqbuflen)
1459 # define SEQ_DUMPBUF() OSS_seqbuf_dump(seqfd, _seqbuf, _seqbuflen)
1460 
1461 # define SEQ_LOAD_GMINSTR(dev, instr) \
1462  OSS_patch_caching(dev, -1, instr, seqfd, _seqbuf, _seqbuflen)
1463 # define SEQ_LOAD_GMDRUM(dev, drum) \
1464  OSS_drum_caching(dev, -1, drum, seqfd, _seqbuf, _seqbuflen)
1465 #else /* !OSSLIB */
1466 
1467 # define SEQ_LOAD_GMINSTR(dev, instr)
1468 # define SEQ_LOAD_GMDRUM(dev, drum)
1469 
1470 # define SEQ_USE_EXTBUF() \
1471  EXTERNC unsigned char _seqbuf[]; \
1472  EXTERNC int _seqbuflen;EXTERNC int _seqbufptr
1473 
1474 #ifndef USE_SIMPLE_MACROS
1475 /* Sample seqbuf_dump() implementation:
1476  *
1477  * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes
1478  *
1479  * int seqfd; -- The file descriptor for /dev/sequencer.
1480  *
1481  * void
1482  * seqbuf_dump ()
1483  * {
1484  * if (_seqbufptr)
1485  * if (write (seqfd, _seqbuf, _seqbufptr) == -1)
1486  * {
1487  * perror ("write /dev/sequencer");
1488  * exit (-1);
1489  * }
1490  * _seqbufptr = 0;
1491  * }
1492  */
1493 
1494 #define SEQ_DEFINEBUF(len) \
1495  unsigned char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0
1496 #define _SEQ_NEEDBUF(len) \
1497  if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump()
1498 #define _SEQ_ADVBUF(len) _seqbufptr += len
1499 #define SEQ_DUMPBUF seqbuf_dump
1500 #else
1501 /*
1502  * This variation of the sequencer macros is used just to format one event
1503  * using fixed buffer.
1504  *
1505  * The program using the macro library must define the following macros before
1506  * using this library.
1507  *
1508  * #define _seqbuf name of the buffer (unsigned char[])
1509  * #define _SEQ_ADVBUF(len) If the applic needs to know the exact
1510  * size of the event, this macro can be used.
1511  * Otherwise this must be defined as empty.
1512  * #define _seqbufptr Define the name of index variable or 0 if
1513  * not required.
1514  */
1515 #define _SEQ_NEEDBUF(len) /* empty */
1516 #endif
1517 #endif /* !OSSLIB */
1518 
1519 #define SEQ_VOLUME_MODE(dev, mode) \
1520  {_SEQ_NEEDBUF(8);\
1521  _seqbuf[_seqbufptr] = SEQ_EXTENDED;\
1522  _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\
1523  _seqbuf[_seqbufptr+2] = (dev);\
1524  _seqbuf[_seqbufptr+3] = (mode);\
1525  _seqbuf[_seqbufptr+4] = 0;\
1526  _seqbuf[_seqbufptr+5] = 0;\
1527  _seqbuf[_seqbufptr+6] = 0;\
1528  _seqbuf[_seqbufptr+7] = 0;\
1529  _SEQ_ADVBUF(8);}
1530 
1531 /*
1532  * Midi voice messages
1533  */
1534 
1535 #define _CHN_VOICE(dev, event, chn, note, parm) \
1536  {_SEQ_NEEDBUF(8);\
1537  _seqbuf[_seqbufptr] = EV_CHN_VOICE;\
1538  _seqbuf[_seqbufptr+1] = (dev);\
1539  _seqbuf[_seqbufptr+2] = (event);\
1540  _seqbuf[_seqbufptr+3] = (chn);\
1541  _seqbuf[_seqbufptr+4] = (note);\
1542  _seqbuf[_seqbufptr+5] = (parm);\
1543  _seqbuf[_seqbufptr+6] = (0);\
1544  _seqbuf[_seqbufptr+7] = 0;\
1545  _SEQ_ADVBUF(8);}
1546 
1547 #define SEQ_START_NOTE(dev, chn, note, vol) \
1548  _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol)
1549 
1550 #define SEQ_STOP_NOTE(dev, chn, note, vol) \
1551  _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol)
1552 
1553 #define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \
1554  _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure)
1555 
1556 /*
1557  * Midi channel messages
1558  */
1559 
1560 #define _CHN_COMMON(dev, event, chn, p1, p2, w14) \
1561  {_SEQ_NEEDBUF(8);\
1562  _seqbuf[_seqbufptr] = EV_CHN_COMMON;\
1563  _seqbuf[_seqbufptr+1] = (dev);\
1564  _seqbuf[_seqbufptr+2] = (event);\
1565  _seqbuf[_seqbufptr+3] = (chn);\
1566  _seqbuf[_seqbufptr+4] = (p1);\
1567  _seqbuf[_seqbufptr+5] = (p2);\
1568  *(short *)&_seqbuf[_seqbufptr+6] = (w14);\
1569  _SEQ_ADVBUF(8);}
1570 /*
1571  * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits
1572  * sending any MIDI bytes but it's absolutely not possible. Trying to do
1573  * so _will_ cause problems with MPU401 intelligent mode).
1574  *
1575  * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
1576  * sent by calling SEQ_SYSEX() several times (there must be no other events
1577  * between them). First sysex fragment must have 0xf0 in the first byte
1578  * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte
1579  * between these sysex start and end markers cannot be larger than 0x7f. Also
1580  * lengths of each fragments (except the last one) must be 6.
1581  *
1582  * Breaking the above rules may work with some MIDI ports but is likely to
1583  * cause fatal problems with some other devices (such as MPU401).
1584  */
1585 #define SEQ_SYSEX(dev, buf, len) \
1586  {int ii, ll=(len); \
1587  unsigned char *bufp=buf;\
1588  if (ll>6)ll=6;\
1589  _SEQ_NEEDBUF(8);\
1590  _seqbuf[_seqbufptr] = EV_SYSEX;\
1591  _seqbuf[_seqbufptr+1] = (dev);\
1592  for(ii=0;ii<ll;ii++)\
1593  _seqbuf[_seqbufptr+ii+2] = bufp[ii];\
1594  for(ii=ll;ii<6;ii++)\
1595  _seqbuf[_seqbufptr+ii+2] = 0xff;\
1596  _SEQ_ADVBUF(8);}
1597 
1598 #define SEQ_CHN_PRESSURE(dev, chn, pressure) \
1599  _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0)
1600 
1601 #define SEQ_SET_PATCH SEQ_PGM_CHANGE
1602 #ifdef OSSLIB
1603 # define SEQ_PGM_CHANGE(dev, chn, patch) \
1604  {OSS_patch_caching(dev, chn, patch, seqfd, _seqbuf, _seqbuflen); \
1605  _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0);}
1606 #else
1607 # define SEQ_PGM_CHANGE(dev, chn, patch) \
1608  _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0)
1609 #endif
1610 
1611 #define SEQ_CONTROL(dev, chn, controller, value) \
1612  _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value)
1613 
1614 #define SEQ_BENDER(dev, chn, value) \
1615  _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value)
1616 
1617 #define SEQ_V2_X_CONTROL(dev, voice, controller, value) \
1618  {_SEQ_NEEDBUF(8);\
1619  _seqbuf[_seqbufptr] = SEQ_EXTENDED;\
1620  _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\
1621  _seqbuf[_seqbufptr+2] = (dev);\
1622  _seqbuf[_seqbufptr+3] = (voice);\
1623  _seqbuf[_seqbufptr+4] = (controller);\
1624  _seqbuf[_seqbufptr+5] = ((value)&0xff);\
1625  _seqbuf[_seqbufptr+6] = ((value>>8)&0xff);\
1626  _seqbuf[_seqbufptr+7] = 0;\
1627  _SEQ_ADVBUF(8);}
1628 /*
1629  * The following 5 macros are incorrectly implemented and obsolete.
1630  * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead.
1631  */
1632 #define SEQ_PITCHBEND(dev, voice, value) \
1633  SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value)
1634 #define SEQ_BENDER_RANGE(dev, voice, value) \
1635  SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value)
1636 #define SEQ_EXPRESSION(dev, voice, value) \
1637  SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128)
1638 #define SEQ_MAIN_VOLUME(dev, voice, value) \
1639  SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100)
1640 #define SEQ_PANNING(dev, voice, pos) \
1641  SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
1642 
1643 /*
1644  * Timing and syncronization macros
1645  */
1646 
1647 #define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
1648  _seqbuf[_seqbufptr+0] = EV_TIMING; \
1649  _seqbuf[_seqbufptr+1] = (ev); \
1650  _seqbuf[_seqbufptr+2] = 0;\
1651  _seqbuf[_seqbufptr+3] = 0;\
1652  *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
1653  _SEQ_ADVBUF(8);}
1654 
1655 #define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0)
1656 #define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0)
1657 #define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0)
1658 #define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks)
1659 #define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks)
1660 #define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key)
1661 #define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value)
1662 #define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos)
1663 #define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig)
1664 
1665 /*
1666  * Local control events
1667  */
1668 
1669 #define _LOCAL_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
1670  _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
1671  _seqbuf[_seqbufptr+1] = (ev); \
1672  _seqbuf[_seqbufptr+2] = 0;\
1673  _seqbuf[_seqbufptr+3] = 0;\
1674  *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
1675  _SEQ_ADVBUF(8);}
1676 
1677 #define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask)
1678 #define SEQ_PLAYAUDIO2(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO2, devmask)
1679 #define SEQ_PLAYAUDIO3(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO3, devmask)
1680 #define SEQ_PLAYAUDIO4(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO4, devmask)
1681 /*
1682  * Events for the level 1 interface only
1683  */
1684 
1685 #define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\
1686  _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\
1687  _seqbuf[_seqbufptr+1] = (byte);\
1688  _seqbuf[_seqbufptr+2] = (device);\
1689  _seqbuf[_seqbufptr+3] = 0;\
1690  _SEQ_ADVBUF(4);}
1691 
1692 /*
1693  * Patch loading.
1694  */
1695 #ifdef OSSLIB
1696 # define SEQ_WRPATCH(patchx, len) \
1697  OSS_write_patch(seqfd, (char*)(patchx), len)
1698 # define SEQ_WRPATCH2(patchx, len) \
1699  OSS_write_patch2(seqfd, (char*)(patchx), len)
1700 #else
1701 # define SEQ_WRPATCH(patchx, len) \
1702  {if (_seqbufptr) SEQ_DUMPBUF();\
1703  if (write(seqfd, (char*)(patchx), len)==-1) \
1704  perror("Write patch: /dev/sequencer");}
1705 # define SEQ_WRPATCH2(patchx, len) \
1706  (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len))
1707 #endif
1708 
1709 #endif
1710 
1711 #ifdef OSSLIB
1712 extern int osslib_open (const char *path, int flags, int dummy);
1713 extern void ossclose (int fd);
1714 extern int osslib_write (int fd, const void *buf, int count);
1715 extern int osslib_read (int fd, void *buf, int count);
1716 extern int osslib_ioctl (int fd, unsigned int request, void *arg);
1717 #else
1718 # define osslib_open open
1719 # define osslib_close close
1720 # define osslib_write write
1721 # define osslib_read read
1722 # define osslib_ioctl ioctl
1723 #endif
1724 
1725 #endif
unsigned char env_offset[6]
Definition: soundcard.h:313
unsigned int play_ptradjust
Definition: soundcard.h:764
int rec_overruns
Definition: soundcard.h:763
char strings[3000]
Definition: soundcard.h:1313
int versionnum
Definition: soundcard.h:1223
struct oss_mixer_enuminfo oss_mixer_enuminfo
int filler[SYSINFO_FILL_SIZE]
Definition: soundcard.h:1234
unsigned char enum_present[32]
Definition: soundcard.h:1282
unsigned char ubitout[24]
Definition: soundcard.h:826
unsigned int high_note
Definition: soundcard.h:304
unsigned char vibrato_depth
Definition: soundcard.h:327
char extname[32]
Definition: soundcard.h:1286
unsigned char cbitout[24]
Definition: soundcard.h:825
EXTERNC void OSS_seqbuf_dump(int fd, unsigned char *buf, int buflen)
short instr_no
Definition: soundcard.h:257
int volume
Definition: soundcard.h:332
unsigned int request
Definition: soundcard.h:820
unsigned char cbitin[24]
Definition: soundcard.h:823
int nr_voices
Definition: soundcard.h:543
int device
Definition: soundcard.h:564
int filler[8]
Definition: soundcard.h:1287
int filler[16]
Definition: soundcard.h:872
unsigned int capabilities
Definition: soundcard.h:546
#define osslib_open
Definition: soundcard.h:1718
struct oss_mixext oss_mixext
#define SYSINFO_FILL_SIZE
Definition: soundcard.h:1217
unsigned int low_note
Definition: soundcard.h:305
int instr_bank_size
Definition: soundcard.h:545
int dev_type
Definition: soundcard.h:566
GLenum GLsizei len
Definition: glext.h:3472
sbi_instr_data operators
Definition: soundcard.h:521
struct synth_control synth_control
#define EXTERNC
Definition: soundcard.h:38
int perc_mode
Definition: soundcard.h:542
int synth_subtype
Definition: soundcard.h:533
int scale_frequency
Definition: soundcard.h:329
char options[128]
Definition: soundcard.h:1224
#define osslib_write
Definition: soundcard.h:1720
char handle[32]
Definition: soundcard.h:1340
int minvalue
Definition: soundcard.h:1265
unsigned int capabilities
Definition: soundcard.h:565
EXTERNC void OSS_seq_needbuf(int len, int fd, unsigned char *buf, int buflen)
struct remove_sample remove_sample
int dummies[18]
Definition: soundcard.h:567
int modify_counter
Definition: soundcard.h:1131
#define osslib_read
Definition: soundcard.h:1721
unsigned int outsel
Definition: soundcard.h:828
unsigned char ubitin[24]
Definition: soundcard.h:824
unsigned short key
Definition: soundcard.h:251
int rec_errorcount
Definition: soundcard.h:767
GLuint GLuint GLsizei count
Definition: glext.h:2845
int filler[215]
Definition: soundcard.h:1342
EXTERNC void OSS_drum_caching(int dev, int chn, int patch, int fd, unsigned char *buf, int buflen)
char cmd[64]
Definition: soundcard.h:1329
struct audio_errinfo audio_errinfo
EXTERNC int OSS_write_patch2(int fd, unsigned char *buf, int len)
unsigned char tremolo_rate
Definition: soundcard.h:322
int filler[16]
Definition: soundcard.h:772
void seqbuf_dump(void)
#define OSS_ENUM_MAXVALUE
Definition: soundcard.h:1306
int detuning
Definition: soundcard.h:307
struct audio_buf_info audio_buf_info
char product[32]
Definition: soundcard.h:1221
EXTERNC void OSS_seq_advbuf(int len, int fd, unsigned char *buf, int buflen)
int levels[32]
Definition: soundcard.h:1181
unsigned char cmd
Definition: soundcard.h:575
unsigned char vibrato_sweep
Definition: soundcard.h:325
unsigned char mixer_record[128]
Definition: soundcard.h:1150
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:2853
unsigned int bytes
Definition: soundcard.h:721
struct buffmem_desc buffmem_desc
int play_underruns
Definition: soundcard.h:762
short device_no
Definition: soundcard.h:344
unsigned int base_note
Definition: soundcard.h:303
#define osslib_ioctl
Definition: soundcard.h:1722
unsigned char arr[8]
Definition: soundcard.h:197
int dummies[19]
Definition: soundcard.h:550
struct oss_sysinfo oss_sysinfo
long rec_errorparm
Definition: soundcard.h:771
const char * path
Definition: sws.c:117
struct oss_audioinfo oss_audioinfo
unsigned char sbi_instr_data[32]
Definition: soundcard.h:512
unsigned short key
Definition: soundcard.h:516
unsigned int mode
Definition: soundcard.h:259
int synth_type
Definition: soundcard.h:528
int control_no
Definition: soundcard.h:1283
int fractions
Definition: soundcard.h:333
unsigned char oss_reserved_t[512]
Definition: soundcard.h:1211
EXTERNC void OSS_patch_caching(int dev, int chn, int patch, int fd, unsigned char *buf, int buflen)
char version[32]
Definition: soundcard.h:1222
struct mixer_vol_table mixer_vol_table
int fillers[10]
Definition: soundcard.h:1132
struct oss_digital_control oss_digital_control
unsigned char tremolo_depth
Definition: soundcard.h:323
int fifo_samples
Definition: soundcard.h:908
long long samples
Definition: soundcard.h:907
unsigned int caps
Definition: soundcard.h:779
struct seq_event_rec seq_event_rec
int spare[2]
Definition: soundcard.h:335
struct _old_mixer_info _old_mixer_info
short device_no
Definition: soundcard.h:256
int reserved1
Definition: soundcard.h:334
struct oss_mixext_root oss_mixext_root
EXTERNC int OSS_init(int seqfd, int buflen)
int loop_start
Definition: soundcard.h:284
int timestamp
Definition: soundcard.h:1279
int play_lasterror
Definition: soundcard.h:768
unsigned int rec_ptradjust
Definition: soundcard.h:765
const GLcharARB * name
Definition: glext.h:3629
int rates[20]
Definition: soundcard.h:1341
short strindex[OSS_ENUM_MAXVALUE]
Definition: soundcard.h:1312
int maxvalue
Definition: soundcard.h:1264
long play_errorparm
Definition: soundcard.h:770
int panning
Definition: soundcard.h:306
EXTERNC void OSS_write_patch(int fd, unsigned char *buf, int len)
struct oss_syncgroup oss_syncgroup
unsigned * buffer
Definition: soundcard.h:731
struct oss_mixer_value oss_mixer_value
int rec_lasterror
Definition: soundcard.h:769
int device
Definition: soundcard.h:527
unsigned int param
Definition: soundcard.h:820
int openedaudio[8]
Definition: soundcard.h:1227
int loop_end
Definition: soundcard.h:284
int nr_drums
Definition: soundcard.h:544
unsigned int scale_factor
Definition: soundcard.h:330
unsigned int valid
Definition: soundcard.h:805
struct count_info count_info
unsigned int in_errors
Definition: soundcard.h:853
struct mixer_info mixer_info
unsigned char env_rate[6]
Definition: soundcard.h:312
int blocks
Definition: soundcard.h:722
unsigned int base_freq
Definition: soundcard.h:302
short key
Definition: soundcard.h:341
unsigned char tremolo_sweep
Definition: soundcard.h:321
unsigned char vibrato_rate
Definition: soundcard.h:326
int play_errorcount
Definition: soundcard.h:766