xref: /freebsd/sys/sys/soundcard.h (revision d056fa046c6a91b90cd98165face0e42a33a5173)
1 /*
2  * soundcard.h
3  */
4 
5 /*-
6  * Copyright by Hannu Savolainen 1993
7  * Modified for the new FreeBSD sound driver by Luigi Rizzo, 1997
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above
15  *    copyright notice, this list of conditions and the following
16  *    disclaimer in the documentation and/or other materials provided
17  *    with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR
23  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  * $FreeBSD$
33  */
34 
35 #ifndef _SYS_SOUNDCARD_H_
36 #define _SYS_SOUNDCARD_H_
37  /*
38   * If you make modifications to this file, please contact me before
39   * distributing the modified version. There is already enough
40   * diversity in the world.
41   *
42   * Regards,
43   * Hannu Savolainen
44   * hannu@voxware.pp.fi
45   *
46   **********************************************************************
47   * PS.	The Hacker's Guide to VoxWare available from
48   *     nic.funet.fi:pub/Linux/ALPHA/sound. The file is
49   *	snd-sdk-doc-0.1.ps.gz (gzipped postscript). It contains
50   *	some useful information about programming with VoxWare.
51   *	(NOTE! The pub/Linux/ALPHA/ directories are hidden. You have
52   *	to cd inside them before the files are accessible.)
53   **********************************************************************
54   */
55 
56 /*
57  * SOUND_VERSION is only used by the voxware driver. Hopefully apps
58  * should not depend on it, but rather look at the capabilities
59  * of the driver in the kernel!
60  */
61 #define SOUND_VERSION  301
62 #define VOXWARE		/* does this have any use ? */
63 
64 /*
65  * Supported card ID numbers (Should be somewhere else? We keep
66  * them here just for compativility with the old driver, but these
67  * constants are of little or no use).
68  */
69 
70 #define SNDCARD_ADLIB          1
71 #define SNDCARD_SB             2
72 #define SNDCARD_PAS            3
73 #define SNDCARD_GUS            4
74 #define SNDCARD_MPU401         5
75 #define SNDCARD_SB16           6
76 #define SNDCARD_SB16MIDI       7
77 #define SNDCARD_UART6850       8
78 #define SNDCARD_GUS16          9
79 #define SNDCARD_MSS            10
80 #define SNDCARD_PSS            11
81 #define SNDCARD_SSCAPE         12
82 #define SNDCARD_PSS_MPU        13
83 #define SNDCARD_PSS_MSS        14
84 #define SNDCARD_SSCAPE_MSS     15
85 #define SNDCARD_TRXPRO         16
86 #define SNDCARD_TRXPRO_SB      17
87 #define SNDCARD_TRXPRO_MPU     18
88 #define SNDCARD_MAD16          19
89 #define SNDCARD_MAD16_MPU      20
90 #define SNDCARD_CS4232         21
91 #define SNDCARD_CS4232_MPU     22
92 #define SNDCARD_MAUI           23
93 #define SNDCARD_PSEUDO_MSS     24
94 #define SNDCARD_AWE32          25
95 #define SNDCARD_NSS            26
96 #define SNDCARD_UART16550      27
97 #define SNDCARD_OPL            28
98 
99 #include <sys/types.h>
100 #include <machine/endian.h>
101 #ifndef _IOWR
102 #include <sys/ioccom.h>
103 #endif  /* !_IOWR */
104 
105 /*
106  * The first part of this file contains the new FreeBSD sound ioctl
107  * interface. Tries to minimize the number of different ioctls, and
108  * to be reasonably general.
109  *
110  * 970821: some of the new calls have not been implemented yet.
111  */
112 
113 /*
114  * the following three calls extend the generic file descriptor
115  * interface. AIONWRITE is the dual of FIONREAD, i.e. returns the max
116  * number of bytes for a write operation to be non-blocking.
117  *
118  * AIOGSIZE/AIOSSIZE are used to change the behaviour of the device,
119  * from a character device (default) to a block device. In block mode,
120  * (not to be confused with blocking mode) the main difference for the
121  * application is that select() will return only when a complete
122  * block can be read/written to the device, whereas in character mode
123  * select will return true when one byte can be exchanged. For audio
124  * devices, character mode makes select almost useless since one byte
125  * will always be ready by the next sample time (which is often only a
126  * handful of microseconds away).
127  * Use a size of 0 or 1 to return to character mode.
128  */
129 #define	AIONWRITE   _IOR('A', 10, int)   /* get # bytes to write */
130 struct snd_size {
131     int play_size;
132     int rec_size;
133 };
134 #define	AIOGSIZE    _IOR('A', 11, struct snd_size)/* read current blocksize */
135 #define	AIOSSIZE    _IOWR('A', 11, struct snd_size)  /* sets blocksize */
136 
137 /*
138  * The following constants define supported audio formats. The
139  * encoding follows voxware conventions, i.e. 1 bit for each supported
140  * format. We extend it by using bit 31 (RO) to indicate full-duplex
141  * capability, and bit 29 (RO) to indicate that the card supports/
142  * needs different formats on capture & playback channels.
143  * Bit 29 (RW) is used to indicate/ask stereo.
144  *
145  * The number of bits required to store the sample is:
146  *  o  4 bits for the IDA ADPCM format,
147  *  o  8 bits for 8-bit formats, mu-law and A-law,
148  *  o  16 bits for the 16-bit formats, and
149  *  o  32 bits for the 24/32-bit formats.
150  *  o  undefined for the MPEG audio format.
151  */
152 
153 #define AFMT_QUERY	0x00000000	/* Return current format */
154 #define AFMT_MU_LAW	0x00000001	/* Logarithmic mu-law */
155 #define AFMT_A_LAW	0x00000002	/* Logarithmic A-law */
156 #define AFMT_IMA_ADPCM	0x00000004	/* A 4:1 compressed format where 16-bit
157 					 * squence represented using the
158 					 * the average 4 bits per sample */
159 #define AFMT_U8		0x00000008	/* Unsigned 8-bit */
160 #define AFMT_S16_LE	0x00000010	/* Little endian signed 16-bit */
161 #define AFMT_S16_BE	0x00000020	/* Big endian signed 16-bit */
162 #define AFMT_S8		0x00000040	/* Signed 8-bit */
163 #define AFMT_U16_LE	0x00000080	/* Little endian unsigned 16-bit */
164 #define AFMT_U16_BE	0x00000100	/* Big endian unsigned 16-bit */
165 #define AFMT_MPEG	0x00000200	/* MPEG MP2/MP3 audio */
166 #define AFMT_AC3	0x00000400	/* Dolby Digital AC3 */
167 
168 #if _BYTE_ORDER == _LITTLE_ENDIAN
169 #define AFMT_S16_NE	AFMT_S16_LE	/* native endian signed 16 */
170 #else
171 #define AFMT_S16_NE	AFMT_S16_BE
172 #endif
173 
174 /*
175  * 32-bit formats below used for 24-bit audio data where the data is stored
176  * in the 24 most significant bits and the least significant bits are not used
177  * (should be set to 0).
178  */
179 #define AFMT_S32_LE	0x00001000	/* Little endian signed 32-bit */
180 #define AFMT_S32_BE	0x00002000	/* Big endian signed 32-bit */
181 #define AFMT_U32_LE	0x00004000	/* Little endian unsigned 32-bit */
182 #define AFMT_U32_BE	0x00008000	/* Big endian unsigned 32-bit */
183 #define AFMT_S24_LE	0x00010000	/* Little endian signed 24-bit */
184 #define AFMT_S24_BE	0x00020000	/* Big endian signed 24-bit */
185 #define AFMT_U24_LE	0x00040000	/* Little endian unsigned 24-bit */
186 #define AFMT_U24_BE	0x00080000	/* Big endian unsigned 24-bit */
187 
188 #define AFMT_STEREO	0x10000000	/* can do/want stereo	*/
189 
190 /*
191  * the following are really capabilities
192  */
193 #define AFMT_WEIRD	0x20000000	/* weird hardware...	*/
194     /*
195      * AFMT_WEIRD reports that the hardware might need to operate
196      * with different formats in the playback and capture
197      * channels when operating in full duplex.
198      * As an example, SoundBlaster16 cards only support U8 in one
199      * direction and S16 in the other one, and applications should
200      * be aware of this limitation.
201      */
202 #define AFMT_FULLDUPLEX	0x80000000	/* can do full duplex	*/
203 
204 /*
205  * The following structure is used to get/set format and sampling rate.
206  * While it would be better to have things such as stereo, bits per
207  * sample, endiannes, etc split in different variables, it turns out
208  * that formats are not that many, and not all combinations are possible.
209  * So we followed the Voxware approach of associating one bit to each
210  * format.
211  */
212 
213 typedef struct _snd_chan_param {
214     u_long	play_rate;	/* sampling rate			*/
215     u_long	rec_rate;	/* sampling rate			*/
216     u_long	play_format;	/* everything describing the format	*/
217     u_long	rec_format;	/* everything describing the format	*/
218 } snd_chan_param;
219 #define	AIOGFMT    _IOR('f', 12, snd_chan_param)   /* get format */
220 #define	AIOSFMT    _IOWR('f', 12, snd_chan_param)  /* sets format */
221 
222 /*
223  * The following structure is used to get/set the mixer setting.
224  * Up to 32 mixers are supported, each one with up to 32 channels.
225  */
226 typedef struct _snd_mix_param {
227     u_char	subdev;	/* which output				*/
228     u_char	line;	/* which input				*/
229     u_char	left,right; /* volumes, 0..255, 0 = mute	*/
230 } snd_mix_param ;
231 
232 /* XXX AIOGMIX, AIOSMIX not implemented yet */
233 #define AIOGMIX	_IOWR('A', 13, snd_mix_param)	/* return mixer status */
234 #define AIOSMIX	_IOWR('A', 14, snd_mix_param)	/* sets mixer status   */
235 
236 /*
237  * channel specifiers used in AIOSTOP and AIOSYNC
238  */
239 #define	AIOSYNC_PLAY	0x1	/* play chan */
240 #define	AIOSYNC_CAPTURE	0x2	/* capture chan */
241 /* AIOSTOP stop & flush a channel, returns the residual count */
242 #define	AIOSTOP	_IOWR ('A', 15, int)
243 
244 /* alternate method used to notify the sync condition */
245 #define	AIOSYNC_SIGNAL	0x100
246 #define	AIOSYNC_SELECT	0x200
247 
248 /* what the 'pos' field refers to */
249 #define AIOSYNC_READY	0x400
250 #define AIOSYNC_FREE	0x800
251 
252 typedef struct _snd_sync_parm {
253     long chan ; /* play or capture channel, plus modifier */
254     long pos;
255 } snd_sync_parm;
256 #define	AIOSYNC	_IOWR ('A', 15, snd_sync_parm)	/* misc. synchronization */
257 
258 /*
259  * The following is used to return device capabilities. If the structure
260  * passed to the ioctl is zeroed, default values are returned for rate
261  * and formats, a bitmap of available mixers is returned, and values
262  * (inputs, different levels) for the first one are returned.
263  *
264  * If  formats, mixers, inputs are instantiated, then detailed info
265  * are returned depending on the call.
266  */
267 typedef struct _snd_capabilities {
268     u_long	rate_min, rate_max;	/* min-max sampling rate */
269     u_long	formats;
270     u_long	bufsize; /* DMA buffer size */
271     u_long	mixers; /* bitmap of available mixers */
272     u_long	inputs; /* bitmap of available inputs (per mixer) */
273     u_short	left, right;	/* how many levels are supported */
274 } snd_capabilities;
275 #define AIOGCAP	_IOWR('A', 15, snd_capabilities)	/* get capabilities */
276 
277 /*
278  * here is the old (Voxware) ioctl interface
279  */
280 
281 /*
282  * IOCTL Commands for /dev/sequencer
283  */
284 
285 #define SNDCTL_SEQ_RESET	_IO  ('Q', 0)
286 #define SNDCTL_SEQ_SYNC		_IO  ('Q', 1)
287 #define SNDCTL_SYNTH_INFO	_IOWR('Q', 2, struct synth_info)
288 #define SNDCTL_SEQ_CTRLRATE	_IOWR('Q', 3, int) /* Set/get timer res.(hz) */
289 #define SNDCTL_SEQ_GETOUTCOUNT	_IOR ('Q', 4, int)
290 #define SNDCTL_SEQ_GETINCOUNT	_IOR ('Q', 5, int)
291 #define SNDCTL_SEQ_PERCMODE	_IOW ('Q', 6, int)
292 #define SNDCTL_FM_LOAD_INSTR	_IOW ('Q', 7, struct sbi_instrument)	/* Valid for FM only */
293 #define SNDCTL_SEQ_TESTMIDI	_IOW ('Q', 8, int)
294 #define SNDCTL_SEQ_RESETSAMPLES	_IOW ('Q', 9, int)
295 #define SNDCTL_SEQ_NRSYNTHS	_IOR ('Q',10, int)
296 #define SNDCTL_SEQ_NRMIDIS	_IOR ('Q',11, int)
297 #define SNDCTL_MIDI_INFO	_IOWR('Q',12, struct midi_info)
298 #define SNDCTL_SEQ_THRESHOLD	_IOW ('Q',13, int)
299 #define SNDCTL_SEQ_TRESHOLD	SNDCTL_SEQ_THRESHOLD	/* there was once a typo */
300 #define SNDCTL_SYNTH_MEMAVL	_IOWR('Q',14, int) /* in=dev#, out=memsize */
301 #define SNDCTL_FM_4OP_ENABLE	_IOW ('Q',15, int) /* in=dev# */
302 #define SNDCTL_PMGR_ACCESS	_IOWR('Q',16, struct patmgr_info)
303 #define SNDCTL_SEQ_PANIC	_IO  ('Q',17)
304 #define SNDCTL_SEQ_OUTOFBAND	_IOW ('Q',18, struct seq_event_rec)
305 #define SNDCTL_SEQ_GETTIME	_IOR ('Q',19, int)
306 
307 struct seq_event_rec {
308 	u_char arr[8];
309 };
310 
311 #define SNDCTL_TMR_TIMEBASE	_IOWR('T', 1, int)
312 #define SNDCTL_TMR_START	_IO  ('T', 2)
313 #define SNDCTL_TMR_STOP		_IO  ('T', 3)
314 #define SNDCTL_TMR_CONTINUE	_IO  ('T', 4)
315 #define SNDCTL_TMR_TEMPO	_IOWR('T', 5, int)
316 #define SNDCTL_TMR_SOURCE	_IOWR('T', 6, int)
317 #   define TMR_INTERNAL		0x00000001
318 #   define TMR_EXTERNAL		0x00000002
319 #	define TMR_MODE_MIDI	0x00000010
320 #	define TMR_MODE_FSK	0x00000020
321 #	define TMR_MODE_CLS	0x00000040
322 #	define TMR_MODE_SMPTE	0x00000080
323 #define SNDCTL_TMR_METRONOME	_IOW ('T', 7, int)
324 #define SNDCTL_TMR_SELECT	_IOW ('T', 8, int)
325 
326 /*
327  *	Endian aware patch key generation algorithm.
328  */
329 
330 #if defined(_AIX) || defined(AIX)
331 #  define _PATCHKEY(id) (0xfd00|id)
332 #else
333 #  define _PATCHKEY(id) ((id<<8)|0xfd)
334 #endif
335 
336 /*
337  *	Sample loading mechanism for internal synthesizers (/dev/sequencer)
338  *	The following patch_info structure has been designed to support
339  *	Gravis UltraSound. It tries to be universal format for uploading
340  *	sample based patches but is probably too limited.
341  */
342 
343 struct patch_info {
344 /*		u_short key;		 Use GUS_PATCH here */
345 	short key;		 /* Use GUS_PATCH here */
346 #define GUS_PATCH	_PATCHKEY(0x04)
347 #define OBSOLETE_GUS_PATCH	_PATCHKEY(0x02)
348 
349 	short device_no;	/* Synthesizer number */
350 	short instr_no;		/* Midi pgm# */
351 
352 	u_long mode;
353 /*
354  * The least significant byte has the same format than the GUS .PAT
355  * files
356  */
357 #define WAVE_16_BITS	0x01	/* bit 0 = 8 or 16 bit wave data. */
358 #define WAVE_UNSIGNED	0x02	/* bit 1 = Signed - Unsigned data. */
359 #define WAVE_LOOPING	0x04	/* bit 2 = looping enabled-1. */
360 #define WAVE_BIDIR_LOOP	0x08	/* bit 3 = Set is bidirectional looping. */
361 #define WAVE_LOOP_BACK	0x10	/* bit 4 = Set is looping backward. */
362 #define WAVE_SUSTAIN_ON	0x20	/* bit 5 = Turn sustaining on. (Env. pts. 3)*/
363 #define WAVE_ENVELOPES	0x40	/* bit 6 = Enable envelopes - 1 */
364 				/* 	(use the env_rate/env_offs fields). */
365 /* Linux specific bits */
366 #define WAVE_VIBRATO	0x00010000	/* The vibrato info is valid */
367 #define WAVE_TREMOLO	0x00020000	/* The tremolo info is valid */
368 #define WAVE_SCALE	0x00040000	/* The scaling info is valid */
369 /* Other bits must be zeroed */
370 
371 	long len;	/* Size of the wave data in bytes */
372 	long loop_start, loop_end; /* Byte offsets from the beginning */
373 
374 /*
375  * The base_freq and base_note fields are used when computing the
376  * playback speed for a note. The base_note defines the tone frequency
377  * which is heard if the sample is played using the base_freq as the
378  * playback speed.
379  *
380  * The low_note and high_note fields define the minimum and maximum note
381  * frequencies for which this sample is valid. It is possible to define
382  * more than one samples for an instrument number at the same time. The
383  * low_note and high_note fields are used to select the most suitable one.
384  *
385  * The fields base_note, high_note and low_note should contain
386  * the note frequency multiplied by 1000. For example value for the
387  * middle A is 440*1000.
388  */
389 
390 	u_int base_freq;
391 	u_long base_note;
392 	u_long high_note;
393 	u_long low_note;
394 	int panning;	/* -128=left, 127=right */
395 	int detuning;
396 
397 /*	New fields introduced in version 1.99.5	*/
398 
399        /* Envelope. Enabled by mode bit WAVE_ENVELOPES	*/
400 	u_char	env_rate[ 6 ];	 /* GUS HW ramping rate */
401 	u_char	env_offset[ 6 ]; /* 255 == 100% */
402 
403 	/*
404 	 * The tremolo, vibrato and scale info are not supported yet.
405 	 * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or
406 	 * WAVE_SCALE
407 	 */
408 
409 	u_char	tremolo_sweep;
410 	u_char	tremolo_rate;
411 	u_char	tremolo_depth;
412 
413 	u_char	vibrato_sweep;
414 	u_char	vibrato_rate;
415 	u_char	vibrato_depth;
416 
417 	int		scale_frequency;
418 	u_int	scale_factor;		/* from 0 to 2048 or 0 to 2 */
419 
420 	int		volume;
421 	int		spare[4];
422 	char data[1];	/* The waveform data starts here */
423 };
424 
425 struct sysex_info {
426 	short key;		/* Use GUS_PATCH here */
427 #define SYSEX_PATCH	_PATCHKEY(0x05)
428 #define MAUI_PATCH	_PATCHKEY(0x06)
429 	short device_no;	/* Synthesizer number */
430 	long len;	/* Size of the sysex data in bytes */
431 	u_char data[1];	/* Sysex data starts here */
432 };
433 
434 /*
435  * Patch management interface (/dev/sequencer, /dev/patmgr#)
436  * Don't use these calls if you want to maintain compatibility with
437  * the future versions of the driver.
438  */
439 
440 #define PS_NO_PATCHES		0	/* No patch support on device */
441 #define	PS_MGR_NOT_OK		1	/* Plain patch support (no mgr) */
442 #define	PS_MGR_OK		2	/* Patch manager supported */
443 #define	PS_MANAGED		3	/* Patch manager running */
444 
445 #define SNDCTL_PMGR_IFACE		_IOWR('P', 1, struct patmgr_info)
446 
447 /*
448  * The patmgr_info is a fixed size structure which is used for two
449  * different purposes. The intended use is for communication between
450  * the application using /dev/sequencer and the patch manager daemon
451  * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)).
452  *
453  * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows
454  * a patch manager daemon to read and write device parameters. This
455  * ioctl available through /dev/sequencer also. Avoid using it since it's
456  * extremely hardware dependent. In addition access trough /dev/sequencer
457  * may confuse the patch manager daemon.
458  */
459 
460 struct patmgr_info {	/* Note! size must be < 4k since kmalloc() is used */
461 	  u_long key;	/* Don't worry. Reserved for communication
462 	  			   between the patch manager and the driver. */
463 #define PM_K_EVENT		1 /* Event from the /dev/sequencer driver */
464 #define PM_K_COMMAND		2 /* Request from an application */
465 #define PM_K_RESPONSE		3 /* From patmgr to application */
466 #define PM_ERROR		4 /* Error returned by the patmgr */
467 	  int device;
468 	  int command;
469 
470 /*
471  * Commands 0x000 to 0xfff reserved for patch manager programs
472  */
473 #define PM_GET_DEVTYPE	1	/* Returns type of the patch mgr interface of dev */
474 #define		PMTYPE_FM2	1	/* 2 OP fm */
475 #define		PMTYPE_FM4	2	/* Mixed 4 or 2 op FM (OPL-3) */
476 #define		PMTYPE_WAVE	3	/* Wave table synthesizer (GUS) */
477 #define PM_GET_NRPGM	2	/* Returns max # of midi programs in parm1 */
478 #define PM_GET_PGMMAP	3	/* Returns map of loaded midi programs in data8 */
479 #define PM_GET_PGM_PATCHES 4	/* Return list of patches of a program (parm1) */
480 #define PM_GET_PATCH	5	/* Return patch header of patch parm1 */
481 #define PM_SET_PATCH	6	/* Set patch header of patch parm1 */
482 #define PM_READ_PATCH	7	/* Read patch (wave) data */
483 #define PM_WRITE_PATCH	8	/* Write patch (wave) data */
484 
485 /*
486  * Commands 0x1000 to 0xffff are for communication between the patch manager
487  * and the client
488  */
489 #define _PM_LOAD_PATCH	0x100
490 
491 /*
492  * Commands above 0xffff reserved for device specific use
493  */
494 
495 	long parm1;
496 	long parm2;
497 	long parm3;
498 
499 	union {
500 		u_char data8[4000];
501 		u_short data16[2000];
502 		u_long data32[1000];
503 		struct patch_info patch;
504 	} data;
505 };
506 
507 /*
508  * When a patch manager daemon is present, it will be informed by the
509  * driver when something important happens. For example when the
510  * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is
511  * returned. The command field contains the event type:
512  */
513 #define PM_E_OPENED		1	/* /dev/sequencer opened */
514 #define PM_E_CLOSED		2	/* /dev/sequencer closed */
515 #define PM_E_PATCH_RESET	3	/* SNDCTL_RESETSAMPLES called */
516 #define PM_E_PATCH_LOADED	4	/* A patch has been loaded by appl */
517 
518 /*
519  * /dev/sequencer input events.
520  *
521  * The data written to the /dev/sequencer is a stream of events. Events
522  * are records of 4 or 8 bytes. The first byte defines the size.
523  * Any number of events can be written with a write call. There
524  * is a set of macros for sending these events. Use these macros if you
525  * want to maximize portability of your program.
526  *
527  * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events.
528  * (All input events are currently 4 bytes long. Be prepared to support
529  * 8 byte events also. If you receive any event having first byte >= 128,
530  * it's a 8 byte event.
531  *
532  * The events are documented at the end of this file.
533  *
534  * Normal events (4 bytes)
535  * There is also a 8 byte version of most of the 4 byte events. The
536  * 8 byte one is recommended.
537  */
538 #define SEQ_NOTEOFF		0
539 #define SEQ_FMNOTEOFF		SEQ_NOTEOFF	/* Just old name */
540 #define SEQ_NOTEON		1
541 #define	SEQ_FMNOTEON		SEQ_NOTEON
542 #define SEQ_WAIT		TMR_WAIT_ABS
543 #define SEQ_PGMCHANGE		3
544 #define SEQ_FMPGMCHANGE		SEQ_PGMCHANGE
545 #define SEQ_SYNCTIMER		TMR_START
546 #define SEQ_MIDIPUTC		5
547 #define SEQ_DRUMON		6	/*** OBSOLETE ***/
548 #define SEQ_DRUMOFF		7	/*** OBSOLETE ***/
549 #define SEQ_ECHO		TMR_ECHO	/* For synching programs with output */
550 #define SEQ_AFTERTOUCH		9
551 #define SEQ_CONTROLLER		10
552 
553 /*
554  *	Midi controller numbers
555  *
556  * Controllers 0 to 31 (0x00 to 0x1f) and 32 to 63 (0x20 to 0x3f)
557  * are continuous controllers.
558  * In the MIDI 1.0 these controllers are sent using two messages.
559  * Controller numbers 0 to 31 are used to send the MSB and the
560  * controller numbers 32 to 63 are for the LSB. Note that just 7 bits
561  * are used in MIDI bytes.
562  */
563 
564 #define	CTL_BANK_SELECT		0x00
565 #define	CTL_MODWHEEL		0x01
566 #define CTL_BREATH		0x02
567 /*	undefined		0x03 */
568 #define CTL_FOOT		0x04
569 #define CTL_PORTAMENTO_TIME	0x05
570 #define CTL_DATA_ENTRY		0x06
571 #define CTL_MAIN_VOLUME		0x07
572 #define CTL_BALANCE		0x08
573 /*	undefined		0x09 */
574 #define CTL_PAN			0x0a
575 #define CTL_EXPRESSION		0x0b
576 /*	undefined		0x0c - 0x0f */
577 #define CTL_GENERAL_PURPOSE1	0x10
578 #define CTL_GENERAL_PURPOSE2	0x11
579 #define CTL_GENERAL_PURPOSE3	0x12
580 #define CTL_GENERAL_PURPOSE4	0x13
581 /*	undefined		0x14 - 0x1f */
582 
583 /*	undefined		0x20 */
584 
585 /*
586  * The controller numbers 0x21 to 0x3f are reserved for the
587  * least significant bytes of the controllers 0x00 to 0x1f.
588  * These controllers are not recognised by the driver.
589  *
590  * Controllers 64 to 69 (0x40 to 0x45) are on/off switches.
591  * 0=OFF and 127=ON (intermediate values are possible)
592  */
593 #define CTL_DAMPER_PEDAL	0x40
594 #define CTL_SUSTAIN		CTL_DAMPER_PEDAL	/* Alias */
595 #define CTL_HOLD		CTL_DAMPER_PEDAL	/* Alias */
596 #define CTL_PORTAMENTO		0x41
597 #define CTL_SOSTENUTO		0x42
598 #define CTL_SOFT_PEDAL		0x43
599 /*	undefined		0x44 */
600 #define CTL_HOLD2		0x45
601 /*	undefined		0x46 - 0x4f */
602 
603 #define CTL_GENERAL_PURPOSE5	0x50
604 #define CTL_GENERAL_PURPOSE6	0x51
605 #define CTL_GENERAL_PURPOSE7	0x52
606 #define CTL_GENERAL_PURPOSE8	0x53
607 /*	undefined		0x54 - 0x5a */
608 #define CTL_EXT_EFF_DEPTH	0x5b
609 #define CTL_TREMOLO_DEPTH	0x5c
610 #define CTL_CHORUS_DEPTH	0x5d
611 #define CTL_DETUNE_DEPTH	0x5e
612 #define CTL_CELESTE_DEPTH	CTL_DETUNE_DEPTH /* Alias for the above one */
613 #define CTL_PHASER_DEPTH	0x5f
614 #define CTL_DATA_INCREMENT	0x60
615 #define CTL_DATA_DECREMENT	0x61
616 #define CTL_NONREG_PARM_NUM_LSB	0x62
617 #define CTL_NONREG_PARM_NUM_MSB	0x63
618 #define CTL_REGIST_PARM_NUM_LSB	0x64
619 #define CTL_REGIST_PARM_NUM_MSB	0x65
620 /*	undefined		0x66 - 0x78 */
621 /*	reserved		0x79 - 0x7f */
622 
623 /* Pseudo controllers (not midi compatible) */
624 #define CTRL_PITCH_BENDER	255
625 #define CTRL_PITCH_BENDER_RANGE	254
626 #define CTRL_EXPRESSION		253	/* Obsolete */
627 #define CTRL_MAIN_VOLUME	252	/* Obsolete */
628 
629 #define SEQ_BALANCE		11
630 #define SEQ_VOLMODE             12
631 
632 /*
633  * Volume mode decides how volumes are used
634  */
635 
636 #define VOL_METHOD_ADAGIO	1
637 #define VOL_METHOD_LINEAR	2
638 
639 /*
640  * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as
641  *	 input events.
642  */
643 
644 /*
645  * Event codes 0xf0 to 0xfc are reserved for future extensions.
646  */
647 
648 #define SEQ_FULLSIZE		0xfd	/* Long events */
649 /*
650  * SEQ_FULLSIZE events are used for loading patches/samples to the
651  * synthesizer devices. These events are passed directly to the driver
652  * of the associated synthesizer device. There is no limit to the size
653  * of the extended events. These events are not queued but executed
654  * immediately when the write() is called (execution can take several
655  * seconds of time).
656  *
657  * When a SEQ_FULLSIZE message is written to the device, it must
658  * be written using exactly one write() call. Other events cannot
659  * be mixed to the same write.
660  *
661  * For FM synths (YM3812/OPL3) use struct sbi_instrument and write
662  * it to the /dev/sequencer. Don't write other data together with
663  * the instrument structure Set the key field of the structure to
664  * FM_PATCH. The device field is used to route the patch to the
665  * corresponding device.
666  *
667  * For Gravis UltraSound use struct patch_info. Initialize the key field
668  * to GUS_PATCH.
669  */
670 #define SEQ_PRIVATE	0xfe	/* Low level HW dependent events (8 bytes) */
671 #define SEQ_EXTENDED	0xff	/* Extended events (8 bytes) OBSOLETE */
672 
673 /*
674  * Record for FM patches
675  */
676 
677 typedef u_char sbi_instr_data[32];
678 
679 struct sbi_instrument {
680 	u_short	key;	/* FM_PATCH or OPL3_PATCH */
681 #define FM_PATCH	_PATCHKEY(0x01)
682 #define OPL3_PATCH	_PATCHKEY(0x03)
683 	short		device;		/* Synth# (0-4)	*/
684 	int 		channel;	/* Program# to be initialized  */
685 	sbi_instr_data	operators;	/* Reg. settings for operator cells
686 					 * (.SBI format)	*/
687 };
688 
689 struct synth_info {	/* Read only */
690 	char	name[30];
691 	int	device;		/* 0-N. INITIALIZE BEFORE CALLING */
692 	int	synth_type;
693 #define SYNTH_TYPE_FM			0
694 #define SYNTH_TYPE_SAMPLE		1
695 #define SYNTH_TYPE_MIDI			2	/* Midi interface */
696 
697 	int	synth_subtype;
698 #define FM_TYPE_ADLIB			0x00
699 #define FM_TYPE_OPL3			0x01
700 #define MIDI_TYPE_MPU401		0x401
701 
702 #define SAMPLE_TYPE_BASIC		0x10
703 #define SAMPLE_TYPE_GUS			SAMPLE_TYPE_BASIC
704 #define SAMPLE_TYPE_AWE32		0x20
705 
706 	int	perc_mode;	/* No longer supported */
707 	int	nr_voices;
708 	int	nr_drums;	/* Obsolete field */
709 	int	instr_bank_size;
710 	u_long	capabilities;
711 #define SYNTH_CAP_PERCMODE	0x00000001 /* No longer used */
712 #define SYNTH_CAP_OPL3		0x00000002 /* Set if OPL3 supported */
713 #define SYNTH_CAP_INPUT		0x00000004 /* Input (MIDI) device */
714 	int	dummies[19];	/* Reserve space */
715 };
716 
717 struct sound_timer_info {
718 	char name[32];
719 	int caps;
720 };
721 
722 #define MIDI_CAP_MPU401		1		/* MPU-401 intelligent mode */
723 
724 struct midi_info {
725 	char		name[30];
726 	int		device;		/* 0-N. INITIALIZE BEFORE CALLING */
727 	u_long	capabilities;	/* To be defined later */
728 	int		dev_type;
729 	int		dummies[18];	/* Reserve space */
730 };
731 
732 /*
733  * ioctl commands for the /dev/midi##
734  */
735 typedef struct {
736 	u_char cmd;
737 	char nr_args, nr_returns;
738 	u_char data[30];
739 } mpu_command_rec;
740 
741 #define SNDCTL_MIDI_PRETIME	_IOWR('m', 0, int)
742 #define SNDCTL_MIDI_MPUMODE	_IOWR('m', 1, int)
743 #define SNDCTL_MIDI_MPUCMD	_IOWR('m', 2, mpu_command_rec)
744 #define MIOSPASSTHRU		_IOWR('m', 3, int)
745 #define MIOGPASSTHRU		_IOWR('m', 4, int)
746 
747 /*
748  * IOCTL commands for /dev/dsp and /dev/audio
749  */
750 
751 #define SNDCTL_DSP_RESET	_IO  ('P', 0)
752 #define SNDCTL_DSP_SYNC		_IO  ('P', 1)
753 #define SNDCTL_DSP_SPEED	_IOWR('P', 2, int)
754 #define SNDCTL_DSP_STEREO	_IOWR('P', 3, int)
755 #define SNDCTL_DSP_GETBLKSIZE	_IOR('P', 4, int)
756 #define SNDCTL_DSP_SETBLKSIZE   _IOW('P', 4, int)
757 #define SNDCTL_DSP_SETFMT	_IOWR('P',5, int) /* Selects ONE fmt*/
758 
759 /*
760  * SOUND_PCM_WRITE_CHANNELS is not that different
761  * from SNDCTL_DSP_STEREO
762  */
763 #define SOUND_PCM_WRITE_CHANNELS	_IOWR('P', 6, int)
764 #define SNDCTL_DSP_CHANNELS	SOUND_PCM_WRITE_CHANNELS
765 #define SOUND_PCM_WRITE_FILTER	_IOWR('P', 7, int)
766 #define SNDCTL_DSP_POST		_IO  ('P', 8)
767 
768 /*
769  * SNDCTL_DSP_SETBLKSIZE and the following two calls mostly do
770  * the same thing, i.e. set the block size used in DMA transfers.
771  */
772 #define SNDCTL_DSP_SUBDIVIDE	_IOWR('P', 9, int)
773 #define SNDCTL_DSP_SETFRAGMENT	_IOWR('P',10, int)
774 
775 
776 #define SNDCTL_DSP_GETFMTS	_IOR ('P',11, int) /* Returns a mask */
777 /*
778  * Buffer status queries.
779  */
780 typedef struct audio_buf_info {
781     int fragments;	/* # of avail. frags (partly used ones not counted) */
782     int fragstotal;	/* Total # of fragments allocated */
783     int fragsize;	/* Size of a fragment in bytes */
784 
785     int bytes;	/* Avail. space in bytes (includes partly used fragments) */
786 		/* Note! 'bytes' could be more than fragments*fragsize */
787 } audio_buf_info;
788 
789 #define SNDCTL_DSP_GETOSPACE	_IOR ('P',12, audio_buf_info)
790 #define SNDCTL_DSP_GETISPACE	_IOR ('P',13, audio_buf_info)
791 
792 /*
793  * SNDCTL_DSP_NONBLOCK is the same (but less powerful, since the
794  * action cannot be undone) of FIONBIO. The same can be achieved
795  * by opening the device with O_NDELAY
796  */
797 #define SNDCTL_DSP_NONBLOCK	_IO  ('P',14)
798 
799 #define SNDCTL_DSP_GETCAPS	_IOR ('P',15, int)
800 #define DSP_CAP_REVISION	0x000000ff /* revision level (0 to 255) */
801 #define DSP_CAP_DUPLEX		0x00000100 /* Full duplex record/playback */
802 #define DSP_CAP_REALTIME	0x00000200 /* Real time capability */
803 #define DSP_CAP_BATCH		0x00000400
804     /*
805      * Device has some kind of internal buffers which may
806      * cause some delays and decrease precision of timing
807      */
808 #define DSP_CAP_COPROC		0x00000800
809     /* Has a coprocessor, sometimes it's a DSP but usually not */
810 #define DSP_CAP_TRIGGER		0x00001000 /* Supports SETTRIGGER */
811 #define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */
812 
813 /*
814  * What do these function do ?
815  */
816 #define SNDCTL_DSP_GETTRIGGER	_IOR ('P',16, int)
817 #define SNDCTL_DSP_SETTRIGGER	_IOW ('P',16, int)
818 #define PCM_ENABLE_INPUT	0x00000001
819 #define PCM_ENABLE_OUTPUT	0x00000002
820 
821 typedef struct count_info {
822 	int bytes;	/* Total # of bytes processed */
823 	int blocks;	/* # of fragment transitions since last time */
824 	int ptr;	/* Current DMA pointer value */
825 } count_info;
826 
827 /*
828  * GETIPTR and GETISPACE are not that different... same for out.
829  */
830 #define SNDCTL_DSP_GETIPTR	_IOR ('P',17, count_info)
831 #define SNDCTL_DSP_GETOPTR	_IOR ('P',18, count_info)
832 
833 typedef struct buffmem_desc {
834 	caddr_t buffer;
835 	int size;
836 } buffmem_desc;
837 
838 #define SNDCTL_DSP_MAPINBUF	_IOR ('P', 19, buffmem_desc)
839 #define SNDCTL_DSP_MAPOUTBUF	_IOR ('P', 20, buffmem_desc)
840 #define SNDCTL_DSP_SETSYNCRO	_IO  ('P', 21)
841 #define SNDCTL_DSP_SETDUPLEX	_IO  ('P', 22)
842 #define SNDCTL_DSP_GETODELAY	_IOR ('P', 23, int)
843 
844 /*
845  * I guess these are the readonly version of the same
846  * functions that exist above as SNDCTL_DSP_...
847  */
848 #define SOUND_PCM_READ_RATE	_IOR ('P', 2, int)
849 #define SOUND_PCM_READ_CHANNELS	_IOR ('P', 6, int)
850 #define SOUND_PCM_READ_BITS	_IOR ('P', 5, int)
851 #define SOUND_PCM_READ_FILTER	_IOR ('P', 7, int)
852 
853 /*
854  * ioctl calls to be used in communication with coprocessors and
855  * DSP chips.
856  */
857 
858 typedef struct copr_buffer {
859 	int command;	/* Set to 0 if not used */
860 	int flags;
861 #define CPF_NONE		0x0000
862 #define CPF_FIRST		0x0001	/* First block */
863 #define CPF_LAST		0x0002	/* Last block */
864 	int len;
865 	int offs;	/* If required by the device (0 if not used) */
866 
867 	u_char data[4000]; /* NOTE! 4000 is not 4k */
868 } copr_buffer;
869 
870 typedef struct copr_debug_buf {
871 	int command;	/* Used internally. Set to 0 */
872 	int parm1;
873 	int parm2;
874 	int flags;
875 	int len;	/* Length of data in bytes */
876 } copr_debug_buf;
877 
878 typedef struct copr_msg {
879 	int len;
880 	u_char data[4000];
881 } copr_msg;
882 
883 #define SNDCTL_COPR_RESET       _IO  ('C',  0)
884 #define SNDCTL_COPR_LOAD	_IOWR('C',  1, copr_buffer)
885 #define SNDCTL_COPR_RDATA	_IOWR('C',  2, copr_debug_buf)
886 #define SNDCTL_COPR_RCODE	_IOWR('C',  3, copr_debug_buf)
887 #define SNDCTL_COPR_WDATA	_IOW ('C',  4, copr_debug_buf)
888 #define SNDCTL_COPR_WCODE	_IOW ('C',  5, copr_debug_buf)
889 #define SNDCTL_COPR_RUN		_IOWR('C',  6, copr_debug_buf)
890 #define SNDCTL_COPR_HALT	_IOWR('C',  7, copr_debug_buf)
891 #define SNDCTL_COPR_SENDMSG	_IOW ('C',  8, copr_msg)
892 #define SNDCTL_COPR_RCVMSG	_IOR ('C',  9, copr_msg)
893 
894 /*
895  * IOCTL commands for /dev/mixer
896  */
897 
898 /*
899  * Mixer devices
900  *
901  * There can be up to 20 different analog mixer channels. The
902  * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
903  * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
904  * the devices supported by the particular mixer.
905  */
906 
907 #define SOUND_MIXER_NRDEVICES	25
908 #define SOUND_MIXER_VOLUME	0	/* Master output level */
909 #define SOUND_MIXER_BASS	1	/* Treble level of all output channels */
910 #define SOUND_MIXER_TREBLE	2	/* Bass level of all output channels */
911 #define SOUND_MIXER_SYNTH	3	/* Volume of synthesier input */
912 #define SOUND_MIXER_PCM		4	/* Output level for the audio device */
913 #define SOUND_MIXER_SPEAKER	5	/* Output level for the PC speaker
914 					 * signals */
915 #define SOUND_MIXER_LINE	6	/* Volume level for the line in jack */
916 #define SOUND_MIXER_MIC		7	/* Volume for the signal coming from
917 					 * the microphone jack */
918 #define SOUND_MIXER_CD		8	/* Volume level for the input signal
919 					 * connected to the CD audio input */
920 #define SOUND_MIXER_IMIX	9	/* Recording monitor. It controls the
921 					 * output volume of the selected
922 					 * recording sources while recording */
923 #define SOUND_MIXER_ALTPCM	10	/* Volume of the alternative codec
924 					 * device */
925 #define SOUND_MIXER_RECLEV	11	/* Global recording level */
926 #define SOUND_MIXER_IGAIN	12	/* Input gain */
927 #define SOUND_MIXER_OGAIN	13	/* Output gain */
928 /*
929  * The AD1848 codec and compatibles have three line level inputs
930  * (line, aux1 and aux2). Since each card manufacturer have assigned
931  * different meanings to these inputs, it's inpractical to assign
932  * specific meanings (line, cd, synth etc.) to them.
933  */
934 #define SOUND_MIXER_LINE1	14	/* Input source 1  (aux1) */
935 #define SOUND_MIXER_LINE2	15	/* Input source 2  (aux2) */
936 #define SOUND_MIXER_LINE3	16	/* Input source 3  (line) */
937 #define SOUND_MIXER_DIGITAL1    17      /* Digital (input) 1 */
938 #define SOUND_MIXER_DIGITAL2    18      /* Digital (input) 2 */
939 #define SOUND_MIXER_DIGITAL3    19      /* Digital (input) 3 */
940 #define SOUND_MIXER_PHONEIN     20      /* Phone input */
941 #define SOUND_MIXER_PHONEOUT    21      /* Phone output */
942 #define SOUND_MIXER_VIDEO       22      /* Video/TV (audio) in */
943 #define SOUND_MIXER_RADIO       23      /* Radio in */
944 #define SOUND_MIXER_MONITOR     24      /* Monitor (usually mic) volume */
945 
946 
947 /*
948  * Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX)
949  * Not counted to SOUND_MIXER_NRDEVICES, but use the same number space
950  */
951 #define SOUND_ONOFF_MIN		28
952 #define SOUND_ONOFF_MAX		30
953 #define SOUND_MIXER_MUTE	28	/* 0 or 1 */
954 #define SOUND_MIXER_ENHANCE	29	/* Enhanced stereo (0, 40, 60 or 80) */
955 #define SOUND_MIXER_LOUD	30	/* 0 or 1 */
956 
957 /* Note!	Number 31 cannot be used since the sign bit is reserved */
958 #define SOUND_MIXER_NONE        31
959 
960 #define SOUND_DEVICE_LABELS	{ \
961 	"Vol  ", "Bass ", "Trebl", "Synth", "Pcm  ", "Spkr ", "Line ", \
962 	"Mic  ", "CD   ", "Mix  ", "Pcm2 ", "Rec  ", "IGain", "OGain", \
963 	"Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
964 	"PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
965 
966 #define SOUND_DEVICE_NAMES	{ \
967 	"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
968 	"mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
969 	"line1", "line2", "line3", "dig1", "dig2", "dig3", \
970 	"phin", "phout", "video", "radio", "monitor"}
971 
972 /*	Device bitmask identifiers	*/
973 
974 #define SOUND_MIXER_RECSRC	0xff	/* 1 bit per recording source */
975 #define SOUND_MIXER_DEVMASK	0xfe	/* 1 bit per supported device */
976 #define SOUND_MIXER_RECMASK	0xfd	/* 1 bit per supp. recording source */
977 #define SOUND_MIXER_CAPS	0xfc
978 #define SOUND_CAP_EXCL_INPUT	0x00000001	/* Only 1 rec. src at a time */
979 #define SOUND_MIXER_STEREODEVS	0xfb	/* Mixer channels supporting stereo */
980 
981 /*	Device mask bits	*/
982 
983 #define SOUND_MASK_VOLUME	(1 << SOUND_MIXER_VOLUME)
984 #define SOUND_MASK_BASS		(1 << SOUND_MIXER_BASS)
985 #define SOUND_MASK_TREBLE	(1 << SOUND_MIXER_TREBLE)
986 #define SOUND_MASK_SYNTH	(1 << SOUND_MIXER_SYNTH)
987 #define SOUND_MASK_PCM		(1 << SOUND_MIXER_PCM)
988 #define SOUND_MASK_SPEAKER	(1 << SOUND_MIXER_SPEAKER)
989 #define SOUND_MASK_LINE		(1 << SOUND_MIXER_LINE)
990 #define SOUND_MASK_MIC		(1 << SOUND_MIXER_MIC)
991 #define SOUND_MASK_CD		(1 << SOUND_MIXER_CD)
992 #define SOUND_MASK_IMIX		(1 << SOUND_MIXER_IMIX)
993 #define SOUND_MASK_ALTPCM	(1 << SOUND_MIXER_ALTPCM)
994 #define SOUND_MASK_RECLEV	(1 << SOUND_MIXER_RECLEV)
995 #define SOUND_MASK_IGAIN	(1 << SOUND_MIXER_IGAIN)
996 #define SOUND_MASK_OGAIN	(1 << SOUND_MIXER_OGAIN)
997 #define SOUND_MASK_LINE1	(1 << SOUND_MIXER_LINE1)
998 #define SOUND_MASK_LINE2	(1 << SOUND_MIXER_LINE2)
999 #define SOUND_MASK_LINE3	(1 << SOUND_MIXER_LINE3)
1000 #define SOUND_MASK_DIGITAL1     (1 << SOUND_MIXER_DIGITAL1)
1001 #define SOUND_MASK_DIGITAL2     (1 << SOUND_MIXER_DIGITAL2)
1002 #define SOUND_MASK_DIGITAL3     (1 << SOUND_MIXER_DIGITAL3)
1003 #define SOUND_MASK_PHONEIN      (1 << SOUND_MIXER_PHONEIN)
1004 #define SOUND_MASK_PHONEOUT     (1 << SOUND_MIXER_PHONEOUT)
1005 #define SOUND_MASK_RADIO        (1 << SOUND_MIXER_RADIO)
1006 #define SOUND_MASK_VIDEO        (1 << SOUND_MIXER_VIDEO)
1007 #define SOUND_MASK_MONITOR      (1 << SOUND_MIXER_MONITOR)
1008 
1009 /* Obsolete macros */
1010 #define SOUND_MASK_MUTE		(1 << SOUND_MIXER_MUTE)
1011 #define SOUND_MASK_ENHANCE	(1 << SOUND_MIXER_ENHANCE)
1012 #define SOUND_MASK_LOUD		(1 << SOUND_MIXER_LOUD)
1013 
1014 #define MIXER_READ(dev)		_IOR('M', dev, int)
1015 #define SOUND_MIXER_READ_VOLUME		MIXER_READ(SOUND_MIXER_VOLUME)
1016 #define SOUND_MIXER_READ_BASS		MIXER_READ(SOUND_MIXER_BASS)
1017 #define SOUND_MIXER_READ_TREBLE		MIXER_READ(SOUND_MIXER_TREBLE)
1018 #define SOUND_MIXER_READ_SYNTH		MIXER_READ(SOUND_MIXER_SYNTH)
1019 #define SOUND_MIXER_READ_PCM		MIXER_READ(SOUND_MIXER_PCM)
1020 #define SOUND_MIXER_READ_SPEAKER	MIXER_READ(SOUND_MIXER_SPEAKER)
1021 #define SOUND_MIXER_READ_LINE		MIXER_READ(SOUND_MIXER_LINE)
1022 #define SOUND_MIXER_READ_MIC		MIXER_READ(SOUND_MIXER_MIC)
1023 #define SOUND_MIXER_READ_CD		MIXER_READ(SOUND_MIXER_CD)
1024 #define SOUND_MIXER_READ_IMIX		MIXER_READ(SOUND_MIXER_IMIX)
1025 #define SOUND_MIXER_READ_ALTPCM		MIXER_READ(SOUND_MIXER_ALTPCM)
1026 #define SOUND_MIXER_READ_RECLEV		MIXER_READ(SOUND_MIXER_RECLEV)
1027 #define SOUND_MIXER_READ_IGAIN		MIXER_READ(SOUND_MIXER_IGAIN)
1028 #define SOUND_MIXER_READ_OGAIN		MIXER_READ(SOUND_MIXER_OGAIN)
1029 #define SOUND_MIXER_READ_LINE1		MIXER_READ(SOUND_MIXER_LINE1)
1030 #define SOUND_MIXER_READ_LINE2		MIXER_READ(SOUND_MIXER_LINE2)
1031 #define SOUND_MIXER_READ_LINE3		MIXER_READ(SOUND_MIXER_LINE3)
1032 #define SOUND_MIXER_READ_DIGITAL1	MIXER_READ(SOUND_MIXER_DIGITAL1)
1033 #define SOUND_MIXER_READ_DIGITAL2	MIXER_READ(SOUND_MIXER_DIGITAL2)
1034 #define SOUND_MIXER_READ_DIGITAL3	MIXER_READ(SOUND_MIXER_DIGITAL3)
1035 #define SOUND_MIXER_READ_PHONEIN      	MIXER_READ(SOUND_MIXER_PHONEIN)
1036 #define SOUND_MIXER_READ_PHONEOUT	MIXER_READ(SOUND_MIXER_PHONEOUT)
1037 #define SOUND_MIXER_READ_RADIO		MIXER_READ(SOUND_MIXER_RADIO)
1038 #define SOUND_MIXER_READ_VIDEO		MIXER_READ(SOUND_MIXER_VIDEO)
1039 #define SOUND_MIXER_READ_MONITOR	MIXER_READ(SOUND_MIXER_MONITOR)
1040 
1041 /* Obsolete macros */
1042 #define SOUND_MIXER_READ_MUTE		MIXER_READ(SOUND_MIXER_MUTE)
1043 #define SOUND_MIXER_READ_ENHANCE	MIXER_READ(SOUND_MIXER_ENHANCE)
1044 #define SOUND_MIXER_READ_LOUD		MIXER_READ(SOUND_MIXER_LOUD)
1045 
1046 #define SOUND_MIXER_READ_RECSRC		MIXER_READ(SOUND_MIXER_RECSRC)
1047 #define SOUND_MIXER_READ_DEVMASK	MIXER_READ(SOUND_MIXER_DEVMASK)
1048 #define SOUND_MIXER_READ_RECMASK	MIXER_READ(SOUND_MIXER_RECMASK)
1049 #define SOUND_MIXER_READ_STEREODEVS	MIXER_READ(SOUND_MIXER_STEREODEVS)
1050 #define SOUND_MIXER_READ_CAPS		MIXER_READ(SOUND_MIXER_CAPS)
1051 
1052 #define MIXER_WRITE(dev)		_IOWR('M', dev, int)
1053 #define SOUND_MIXER_WRITE_VOLUME	MIXER_WRITE(SOUND_MIXER_VOLUME)
1054 #define SOUND_MIXER_WRITE_BASS		MIXER_WRITE(SOUND_MIXER_BASS)
1055 #define SOUND_MIXER_WRITE_TREBLE	MIXER_WRITE(SOUND_MIXER_TREBLE)
1056 #define SOUND_MIXER_WRITE_SYNTH		MIXER_WRITE(SOUND_MIXER_SYNTH)
1057 #define SOUND_MIXER_WRITE_PCM		MIXER_WRITE(SOUND_MIXER_PCM)
1058 #define SOUND_MIXER_WRITE_SPEAKER	MIXER_WRITE(SOUND_MIXER_SPEAKER)
1059 #define SOUND_MIXER_WRITE_LINE		MIXER_WRITE(SOUND_MIXER_LINE)
1060 #define SOUND_MIXER_WRITE_MIC		MIXER_WRITE(SOUND_MIXER_MIC)
1061 #define SOUND_MIXER_WRITE_CD		MIXER_WRITE(SOUND_MIXER_CD)
1062 #define SOUND_MIXER_WRITE_IMIX		MIXER_WRITE(SOUND_MIXER_IMIX)
1063 #define SOUND_MIXER_WRITE_ALTPCM	MIXER_WRITE(SOUND_MIXER_ALTPCM)
1064 #define SOUND_MIXER_WRITE_RECLEV	MIXER_WRITE(SOUND_MIXER_RECLEV)
1065 #define SOUND_MIXER_WRITE_IGAIN		MIXER_WRITE(SOUND_MIXER_IGAIN)
1066 #define SOUND_MIXER_WRITE_OGAIN		MIXER_WRITE(SOUND_MIXER_OGAIN)
1067 #define SOUND_MIXER_WRITE_LINE1		MIXER_WRITE(SOUND_MIXER_LINE1)
1068 #define SOUND_MIXER_WRITE_LINE2		MIXER_WRITE(SOUND_MIXER_LINE2)
1069 #define SOUND_MIXER_WRITE_LINE3		MIXER_WRITE(SOUND_MIXER_LINE3)
1070 #define SOUND_MIXER_WRITE_DIGITAL1	MIXER_WRITE(SOUND_MIXER_DIGITAL1)
1071 #define SOUND_MIXER_WRITE_DIGITAL2	MIXER_WRITE(SOUND_MIXER_DIGITAL2)
1072 #define SOUND_MIXER_WRITE_DIGITAL3	MIXER_WRITE(SOUND_MIXER_DIGITAL3)
1073 #define SOUND_MIXER_WRITE_PHONEIN      	MIXER_WRITE(SOUND_MIXER_PHONEIN)
1074 #define SOUND_MIXER_WRITE_PHONEOUT	MIXER_WRITE(SOUND_MIXER_PHONEOUT)
1075 #define SOUND_MIXER_WRITE_RADIO		MIXER_WRITE(SOUND_MIXER_RADIO)
1076 #define SOUND_MIXER_WRITE_VIDEO		MIXER_WRITE(SOUND_MIXER_VIDEO)
1077 #define SOUND_MIXER_WRITE_MONITOR	MIXER_WRITE(SOUND_MIXER_MONITOR)
1078 
1079 #define SOUND_MIXER_WRITE_MUTE		MIXER_WRITE(SOUND_MIXER_MUTE)
1080 #define SOUND_MIXER_WRITE_ENHANCE	MIXER_WRITE(SOUND_MIXER_ENHANCE)
1081 #define SOUND_MIXER_WRITE_LOUD		MIXER_WRITE(SOUND_MIXER_LOUD)
1082 
1083 #define SOUND_MIXER_WRITE_RECSRC	MIXER_WRITE(SOUND_MIXER_RECSRC)
1084 
1085 typedef struct mixer_info {
1086   char id[16];
1087   char name[32];
1088   int  modify_counter;
1089   int fillers[10];
1090 } mixer_info;
1091 
1092 #define SOUND_MIXER_INFO		_IOR('M', 101, mixer_info)
1093 
1094 #define LEFT_CHN	0
1095 #define RIGHT_CHN	1
1096 
1097 /*
1098  * Level 2 event types for /dev/sequencer
1099  */
1100 
1101 /*
1102  * The 4 most significant bits of byte 0 specify the class of
1103  * the event:
1104  *
1105  *	0x8X = system level events,
1106  *	0x9X = device/port specific events, event[1] = device/port,
1107  *		The last 4 bits give the subtype:
1108  *			0x02	= Channel event (event[3] = chn).
1109  *			0x01	= note event (event[4] = note).
1110  *			(0x01 is not used alone but always with bit 0x02).
1111  *	       event[2] = MIDI message code (0x80=note off etc.)
1112  *
1113  */
1114 
1115 #define EV_SEQ_LOCAL		0x80
1116 #define EV_TIMING		0x81
1117 #define EV_CHN_COMMON		0x92
1118 #define EV_CHN_VOICE		0x93
1119 #define EV_SYSEX		0x94
1120 /*
1121  * Event types 200 to 220 are reserved for application use.
1122  * These numbers will not be used by the driver.
1123  */
1124 
1125 /*
1126  * Events for event type EV_CHN_VOICE
1127  */
1128 
1129 #define MIDI_NOTEOFF		0x80
1130 #define MIDI_NOTEON		0x90
1131 #define MIDI_KEY_PRESSURE	0xA0
1132 
1133 /*
1134  * Events for event type EV_CHN_COMMON
1135  */
1136 
1137 #define MIDI_CTL_CHANGE		0xB0
1138 #define MIDI_PGM_CHANGE		0xC0
1139 #define MIDI_CHN_PRESSURE	0xD0
1140 #define MIDI_PITCH_BEND		0xE0
1141 
1142 #define MIDI_SYSTEM_PREFIX	0xF0
1143 
1144 /*
1145  * Timer event types
1146  */
1147 #define TMR_WAIT_REL		1	/* Time relative to the prev time */
1148 #define TMR_WAIT_ABS		2	/* Absolute time since TMR_START */
1149 #define TMR_STOP		3
1150 #define TMR_START		4
1151 #define TMR_CONTINUE		5
1152 #define TMR_TEMPO		6
1153 #define TMR_ECHO		8
1154 #define TMR_CLOCK		9	/* MIDI clock */
1155 #define TMR_SPP			10	/* Song position pointer */
1156 #define TMR_TIMESIG		11	/* Time signature */
1157 
1158 /*
1159  *	Local event types
1160  */
1161 #define LOCL_STARTAUDIO		1
1162 
1163 #if (!defined(_KERNEL) && !defined(INKERNEL)) || defined(USE_SEQ_MACROS)
1164 /*
1165  *	Some convenience macros to simplify programming of the
1166  *	/dev/sequencer interface
1167  *
1168  *	These macros define the API which should be used when possible.
1169  */
1170 
1171 #ifndef USE_SIMPLE_MACROS
1172 void seqbuf_dump(void);	/* This function must be provided by programs */
1173 
1174 /* Sample seqbuf_dump() implementation:
1175  *
1176  *	SEQ_DEFINEBUF (2048);	-- Defines a buffer for 2048 bytes
1177  *
1178  *	int seqfd;		-- The file descriptor for /dev/sequencer.
1179  *
1180  *	void
1181  *	seqbuf_dump ()
1182  *	{
1183  *	  if (_seqbufptr)
1184  *	    if (write (seqfd, _seqbuf, _seqbufptr) == -1)
1185  *	      {
1186  *		perror ("write /dev/sequencer");
1187  *		exit (-1);
1188  *	      }
1189  *	  _seqbufptr = 0;
1190  *	}
1191  */
1192 
1193 #define SEQ_DEFINEBUF(len)		\
1194 	u_char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0
1195 #define SEQ_USE_EXTBUF()		\
1196 	extern u_char _seqbuf[]; \
1197 	extern int _seqbuflen;extern int _seqbufptr
1198 #define SEQ_DECLAREBUF()		SEQ_USE_EXTBUF()
1199 #define SEQ_PM_DEFINES			struct patmgr_info _pm_info
1200 #define _SEQ_NEEDBUF(len)		\
1201 	if ((_seqbufptr+(len)) > _seqbuflen) \
1202 		seqbuf_dump()
1203 #define _SEQ_ADVBUF(len)		_seqbufptr += len
1204 #define SEQ_DUMPBUF			seqbuf_dump
1205 #else
1206 /*
1207  * This variation of the sequencer macros is used just to format one event
1208  * using fixed buffer.
1209  *
1210  * The program using the macro library must define the following macros before
1211  * using this library.
1212  *
1213  * #define _seqbuf 		 name of the buffer (u_char[])
1214  * #define _SEQ_ADVBUF(len)	 If the applic needs to know the exact
1215  *				 size of the event, this macro can be used.
1216  *				 Otherwise this must be defined as empty.
1217  * #define _seqbufptr		 Define the name of index variable or 0 if
1218  *				 not required.
1219  */
1220 #define _SEQ_NEEDBUF(len)	/* empty */
1221 #endif
1222 
1223 #define PM_LOAD_PATCH(dev, bank, pgm)	\
1224 	(SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \
1225 	_pm_info.device=dev, _pm_info.data.data8[0]=pgm, \
1226 	_pm_info.parm1 = bank, _pm_info.parm2 = 1, \
1227 	ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info))
1228 #define PM_LOAD_PATCHES(dev, bank, pgm) \
1229 	(SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \
1230 	_pm_info.device=dev, bcopy( pgm, _pm_info.data.data8,  128), \
1231 	_pm_info.parm1 = bank, _pm_info.parm2 = 128, \
1232 	ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info))
1233 
1234 #define SEQ_VOLUME_MODE(dev, mode)	{ \
1235 	_SEQ_NEEDBUF(8);\
1236 	_seqbuf[_seqbufptr] = SEQ_EXTENDED;\
1237 	_seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\
1238 	_seqbuf[_seqbufptr+2] = (dev);\
1239 	_seqbuf[_seqbufptr+3] = (mode);\
1240 	_seqbuf[_seqbufptr+4] = 0;\
1241 	_seqbuf[_seqbufptr+5] = 0;\
1242 	_seqbuf[_seqbufptr+6] = 0;\
1243 	_seqbuf[_seqbufptr+7] = 0;\
1244 	_SEQ_ADVBUF(8);}
1245 
1246 /*
1247  * Midi voice messages
1248  */
1249 
1250 #define _CHN_VOICE(dev, event, chn, note, parm)  { \
1251 	_SEQ_NEEDBUF(8);\
1252 	_seqbuf[_seqbufptr] = EV_CHN_VOICE;\
1253 	_seqbuf[_seqbufptr+1] = (dev);\
1254 	_seqbuf[_seqbufptr+2] = (event);\
1255 	_seqbuf[_seqbufptr+3] = (chn);\
1256 	_seqbuf[_seqbufptr+4] = (note);\
1257 	_seqbuf[_seqbufptr+5] = (parm);\
1258 	_seqbuf[_seqbufptr+6] = (0);\
1259 	_seqbuf[_seqbufptr+7] = 0;\
1260 	_SEQ_ADVBUF(8);}
1261 
1262 #define SEQ_START_NOTE(dev, chn, note, vol) \
1263 		_CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol)
1264 
1265 #define SEQ_STOP_NOTE(dev, chn, note, vol) \
1266 		_CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol)
1267 
1268 #define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \
1269 		_CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure)
1270 
1271 /*
1272  * Midi channel messages
1273  */
1274 
1275 #define _CHN_COMMON(dev, event, chn, p1, p2, w14) { \
1276 	_SEQ_NEEDBUF(8);\
1277 	_seqbuf[_seqbufptr] = EV_CHN_COMMON;\
1278 	_seqbuf[_seqbufptr+1] = (dev);\
1279 	_seqbuf[_seqbufptr+2] = (event);\
1280 	_seqbuf[_seqbufptr+3] = (chn);\
1281 	_seqbuf[_seqbufptr+4] = (p1);\
1282 	_seqbuf[_seqbufptr+5] = (p2);\
1283 	*(short *)&_seqbuf[_seqbufptr+6] = (w14);\
1284 	_SEQ_ADVBUF(8);}
1285 /*
1286  * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits
1287  * sending any MIDI bytes but it's absolutely not possible. Trying to do
1288  * so _will_ cause problems with MPU401 intelligent mode).
1289  *
1290  * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
1291  * sent by calling SEQ_SYSEX() several times (there must be no other events
1292  * between them). First sysex fragment must have 0xf0 in the first byte
1293  * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte
1294  * between these sysex start and end markers cannot be larger than 0x7f. Also
1295  * lengths of each fragments (except the last one) must be 6.
1296  *
1297  * Breaking the above rules may work with some MIDI ports but is likely to
1298  * cause fatal problems with some other devices (such as MPU401).
1299  */
1300 #define SEQ_SYSEX(dev, buf, len) { \
1301 	int i, l=(len); if (l>6)l=6;\
1302 	_SEQ_NEEDBUF(8);\
1303 	_seqbuf[_seqbufptr] = EV_SYSEX;\
1304 	for(i=0;i<l;i++)_seqbuf[_seqbufptr+i+1] = (buf)[i];\
1305 	for(i=l;i<6;i++)_seqbuf[_seqbufptr+i+1] = 0xff;\
1306 	_SEQ_ADVBUF(8);}
1307 
1308 #define SEQ_CHN_PRESSURE(dev, chn, pressure) \
1309 	_CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0)
1310 
1311 #define SEQ_SET_PATCH(dev, chn, patch) \
1312 	_CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0)
1313 
1314 #define SEQ_CONTROL(dev, chn, controller, value) \
1315 	_CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value)
1316 
1317 #define SEQ_BENDER(dev, chn, value) \
1318 	_CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value)
1319 
1320 
1321 #define SEQ_V2_X_CONTROL(dev, voice, controller, value)	{ \
1322 	_SEQ_NEEDBUF(8);\
1323 	_seqbuf[_seqbufptr] = SEQ_EXTENDED;\
1324 	_seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\
1325 	_seqbuf[_seqbufptr+2] = (dev);\
1326 	_seqbuf[_seqbufptr+3] = (voice);\
1327 	_seqbuf[_seqbufptr+4] = (controller);\
1328 	*(short *)&_seqbuf[_seqbufptr+5] = (value);\
1329 	_seqbuf[_seqbufptr+7] = 0;\
1330 	_SEQ_ADVBUF(8);}
1331 
1332 /*
1333  * The following 5 macros are incorrectly implemented and obsolete.
1334  * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead.
1335  */
1336 
1337 #define SEQ_PITCHBEND(dev, voice, value) \
1338 	SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value)
1339 #define SEQ_BENDER_RANGE(dev, voice, value) \
1340 	SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value)
1341 #define SEQ_EXPRESSION(dev, voice, value) \
1342 	SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128)
1343 #define SEQ_MAIN_VOLUME(dev, voice, value) \
1344 	SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100)
1345 #define SEQ_PANNING(dev, voice, pos) \
1346 	SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
1347 
1348 /*
1349  * Timing and syncronization macros
1350  */
1351 
1352 #define _TIMER_EVENT(ev, parm)		{ \
1353 	_SEQ_NEEDBUF(8);\
1354 	_seqbuf[_seqbufptr+0] = EV_TIMING; \
1355 	_seqbuf[_seqbufptr+1] = (ev); \
1356 	_seqbuf[_seqbufptr+2] = 0;\
1357 	_seqbuf[_seqbufptr+3] = 0;\
1358 	*(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \
1359 	_SEQ_ADVBUF(8); \
1360 	}
1361 
1362 #define SEQ_START_TIMER()		_TIMER_EVENT(TMR_START, 0)
1363 #define SEQ_STOP_TIMER()		_TIMER_EVENT(TMR_STOP, 0)
1364 #define SEQ_CONTINUE_TIMER()		_TIMER_EVENT(TMR_CONTINUE, 0)
1365 #define SEQ_WAIT_TIME(ticks)		_TIMER_EVENT(TMR_WAIT_ABS, ticks)
1366 #define SEQ_DELTA_TIME(ticks)		_TIMER_EVENT(TMR_WAIT_REL, ticks)
1367 #define SEQ_ECHO_BACK(key)		_TIMER_EVENT(TMR_ECHO, key)
1368 #define SEQ_SET_TEMPO(value)		_TIMER_EVENT(TMR_TEMPO, value)
1369 #define SEQ_SONGPOS(pos)		_TIMER_EVENT(TMR_SPP, pos)
1370 #define SEQ_TIME_SIGNATURE(sig)		_TIMER_EVENT(TMR_TIMESIG, sig)
1371 
1372 /*
1373  * Local control events
1374  */
1375 
1376 #define _LOCAL_EVENT(ev, parm)		{ \
1377 	_SEQ_NEEDBUF(8);\
1378 	_seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
1379 	_seqbuf[_seqbufptr+1] = (ev); \
1380 	_seqbuf[_seqbufptr+2] = 0;\
1381 	_seqbuf[_seqbufptr+3] = 0;\
1382 	*(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \
1383 	_SEQ_ADVBUF(8); \
1384 	}
1385 
1386 #define SEQ_PLAYAUDIO(devmask)		_LOCAL_EVENT(LOCL_STARTAUDIO, devmask)
1387 /*
1388  * Events for the level 1 interface only
1389  */
1390 
1391 #define SEQ_MIDIOUT(device, byte)	{ \
1392 	_SEQ_NEEDBUF(4);\
1393 	_seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\
1394 	_seqbuf[_seqbufptr+1] = (byte);\
1395 	_seqbuf[_seqbufptr+2] = (device);\
1396 	_seqbuf[_seqbufptr+3] = 0;\
1397 	_SEQ_ADVBUF(4);}
1398 
1399 /*
1400  * Patch loading.
1401  */
1402 #define SEQ_WRPATCH(patchx, len)	{ \
1403 	if (_seqbufptr) seqbuf_dump(); \
1404 	if (write(seqfd, (char*)(patchx), len)==-1) \
1405 	   perror("Write patch: /dev/sequencer"); \
1406 	}
1407 
1408 #define SEQ_WRPATCH2(patchx, len)	\
1409 	( seqbuf_dump(), write(seqfd, (char*)(patchx), len) )
1410 
1411 #endif
1412 
1413 /*
1414  * Here I have moved all the aliases for ioctl names.
1415  */
1416 
1417 #define SNDCTL_DSP_SAMPLESIZE	SNDCTL_DSP_SETFMT
1418 #define SOUND_PCM_WRITE_BITS	SNDCTL_DSP_SETFMT
1419 #define SOUND_PCM_SETFMT	SNDCTL_DSP_SETFMT
1420 
1421 #define SOUND_PCM_WRITE_RATE	SNDCTL_DSP_SPEED
1422 #define SOUND_PCM_POST		SNDCTL_DSP_POST
1423 #define SOUND_PCM_RESET		SNDCTL_DSP_RESET
1424 #define SOUND_PCM_SYNC		SNDCTL_DSP_SYNC
1425 #define SOUND_PCM_SUBDIVIDE	SNDCTL_DSP_SUBDIVIDE
1426 #define SOUND_PCM_SETFRAGMENT	SNDCTL_DSP_SETFRAGMENT
1427 #define SOUND_PCM_GETFMTS	SNDCTL_DSP_GETFMTS
1428 #define SOUND_PCM_GETOSPACE	SNDCTL_DSP_GETOSPACE
1429 #define SOUND_PCM_GETISPACE	SNDCTL_DSP_GETISPACE
1430 #define SOUND_PCM_NONBLOCK	SNDCTL_DSP_NONBLOCK
1431 #define SOUND_PCM_GETCAPS	SNDCTL_DSP_GETCAPS
1432 #define SOUND_PCM_GETTRIGGER	SNDCTL_DSP_GETTRIGGER
1433 #define SOUND_PCM_SETTRIGGER	SNDCTL_DSP_SETTRIGGER
1434 #define SOUND_PCM_SETSYNCRO	SNDCTL_DSP_SETSYNCRO
1435 #define SOUND_PCM_GETIPTR	SNDCTL_DSP_GETIPTR
1436 #define SOUND_PCM_GETOPTR	SNDCTL_DSP_GETOPTR
1437 #define SOUND_PCM_MAPINBUF	SNDCTL_DSP_MAPINBUF
1438 #define SOUND_PCM_MAPOUTBUF	SNDCTL_DSP_MAPOUTBUF
1439 
1440 #endif	/* !_SYS_SOUNDCARD_H_ */
1441