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