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