• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6.36/include/linux/
1#ifndef SOUNDCARD_H
2#define SOUNDCARD_H
3/*
4 * Copyright by Hannu Savolainen 1993-1997
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 2.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27
28/*
29 * OSS interface version. With versions earlier than 3.6 this value is
30 * an integer with value less than 361. In versions 3.6 and later
31 * it's a six digit hexadecimal value. For example value
32 * of 0x030600 represents OSS version 3.6.0.
33 * Use ioctl(fd, OSS_GETVERSION, &int) to get the version number of
34 * the currently active driver.
35 */
36#define SOUND_VERSION	0x030802
37#define OPEN_SOUND_SYSTEM
38
39/* In Linux we need to be prepared for cross compiling */
40#include <linux/ioctl.h>
41
42/* Endian macros. */
43#ifdef __KERNEL__
44#  include <asm/byteorder.h>
45#else
46#  include <endian.h>
47#endif
48
49/*
50 *	Supported card ID numbers (Should be somewhere else?)
51 */
52
53#define SNDCARD_ADLIB		1
54#define SNDCARD_SB		2
55#define SNDCARD_PAS		3
56#define SNDCARD_GUS		4
57#define SNDCARD_MPU401		5
58#define SNDCARD_SB16		6
59#define SNDCARD_SB16MIDI	7
60#define SNDCARD_UART6850	8
61#define SNDCARD_GUS16		9
62#define SNDCARD_MSS		10
63#define SNDCARD_PSS     	11
64#define SNDCARD_SSCAPE		12
65#define SNDCARD_PSS_MPU     	13
66#define SNDCARD_PSS_MSS     	14
67#define SNDCARD_SSCAPE_MSS	15
68#define SNDCARD_TRXPRO		16
69#define SNDCARD_TRXPRO_SB	17
70#define SNDCARD_TRXPRO_MPU	18
71#define SNDCARD_MAD16		19
72#define SNDCARD_MAD16_MPU	20
73#define SNDCARD_CS4232		21
74#define SNDCARD_CS4232_MPU	22
75#define SNDCARD_MAUI		23
76#define SNDCARD_PSEUDO_MSS	24
77#define SNDCARD_GUSPNP		25
78#define SNDCARD_UART401		26
79/* Sound card numbers 27 to N are reserved. Don't add more numbers here. */
80
81/***********************************
82 * IOCTL Commands for /dev/sequencer
83 */
84
85#ifndef _SIOWR
86#if defined(_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && \
87	!defined(__sparc__) && !defined(__INCioctlh) && !defined(__Lynx__)))
88/* Use already defined ioctl defines if they exist (except with Sun or Sparc) */
89#define	SIOCPARM_MASK	IOCPARM_MASK
90#define	SIOC_VOID	IOC_VOID
91#define	SIOC_OUT	IOC_OUT
92#define	SIOC_IN		IOC_IN
93#define	SIOC_INOUT	IOC_INOUT
94#define _SIOC_SIZE	_IOC_SIZE
95#define _SIOC_DIR	_IOC_DIR
96#define _SIOC_NONE	_IOC_NONE
97#define _SIOC_READ	_IOC_READ
98#define _SIOC_WRITE	_IOC_WRITE
99#define	_SIO		_IO
100#define	_SIOR		_IOR
101#define	_SIOW		_IOW
102#define	_SIOWR		_IOWR
103#else
104
105/* Ioctl's have the command encoded in the lower word,
106 * and the size of any in or out parameters in the upper
107 * word.  The high 2 bits of the upper word are used
108 * to encode the in/out status of the parameter; for now
109 * we restrict parameters to at most 8191 bytes.
110 */
111/* #define	SIOCTYPE		(0xff<<8) */
112#define	SIOCPARM_MASK	0x1fff		/* parameters must be < 8192 bytes */
113#define	SIOC_VOID	0x00000000	/* no parameters */
114#define	SIOC_OUT	0x20000000	/* copy out parameters */
115#define	SIOC_IN		0x40000000	/* copy in parameters */
116#define	SIOC_INOUT	(SIOC_IN|SIOC_OUT)
117/* the 0x20000000 is so we can distinguish new ioctl's from old */
118#define	_SIO(x,y)	((int)(SIOC_VOID|(x<<8)|y))
119#define	_SIOR(x,y,t)	((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
120#define	_SIOW(x,y,t)	((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
121/* this should be _SIORW, but stdio got there first */
122#define	_SIOWR(x,y,t)	((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
123#define _SIOC_SIZE(x)	((x>>16)&SIOCPARM_MASK)
124#define _SIOC_DIR(x)	(x & 0xf0000000)
125#define _SIOC_NONE	SIOC_VOID
126#define _SIOC_READ	SIOC_OUT
127#define _SIOC_WRITE	SIOC_IN
128#  endif /* _IOWR */
129#endif  /* !_SIOWR */
130
131#define SNDCTL_SEQ_RESET		_SIO  ('Q', 0)
132#define SNDCTL_SEQ_SYNC			_SIO  ('Q', 1)
133#define SNDCTL_SYNTH_INFO		_SIOWR('Q', 2, struct synth_info)
134#define SNDCTL_SEQ_CTRLRATE		_SIOWR('Q', 3, int)	/* Set/get timer resolution (HZ) */
135#define SNDCTL_SEQ_GETOUTCOUNT		_SIOR ('Q', 4, int)
136#define SNDCTL_SEQ_GETINCOUNT		_SIOR ('Q', 5, int)
137#define SNDCTL_SEQ_PERCMODE		_SIOW ('Q', 6, int)
138#define SNDCTL_FM_LOAD_INSTR		_SIOW ('Q', 7, struct sbi_instrument)	/* Obsolete. Don't use!!!!!! */
139#define SNDCTL_SEQ_TESTMIDI		_SIOW ('Q', 8, int)
140#define SNDCTL_SEQ_RESETSAMPLES		_SIOW ('Q', 9, int)
141#define SNDCTL_SEQ_NRSYNTHS		_SIOR ('Q',10, int)
142#define SNDCTL_SEQ_NRMIDIS		_SIOR ('Q',11, int)
143#define SNDCTL_MIDI_INFO		_SIOWR('Q',12, struct midi_info)
144#define SNDCTL_SEQ_THRESHOLD		_SIOW ('Q',13, int)
145#define SNDCTL_SYNTH_MEMAVL		_SIOWR('Q',14, int)	/* in=dev#, out=memsize */
146#define SNDCTL_FM_4OP_ENABLE		_SIOW ('Q',15, int)	/* in=dev# */
147#define SNDCTL_SEQ_PANIC		_SIO  ('Q',17)
148#define SNDCTL_SEQ_OUTOFBAND		_SIOW ('Q',18, struct seq_event_rec)
149#define SNDCTL_SEQ_GETTIME		_SIOR ('Q',19, int)
150#define SNDCTL_SYNTH_ID			_SIOWR('Q',20, struct synth_info)
151#define SNDCTL_SYNTH_CONTROL		_SIOWR('Q',21, struct synth_control)
152#define SNDCTL_SYNTH_REMOVESAMPLE	_SIOWR('Q',22, struct remove_sample)
153
154typedef struct synth_control
155{
156	int devno;	/* Synthesizer # */
157	char data[4000]; /* Device spesific command/data record */
158}synth_control;
159
160typedef struct remove_sample
161{
162	int devno;	/* Synthesizer # */
163	int bankno;	/* MIDI bank # (0=General MIDI) */
164	int instrno;	/* MIDI instrument number */
165} remove_sample;
166
167typedef struct seq_event_rec {
168		unsigned char arr[8];
169} seq_event_rec;
170
171#define SNDCTL_TMR_TIMEBASE		_SIOWR('T', 1, int)
172#define SNDCTL_TMR_START		_SIO  ('T', 2)
173#define SNDCTL_TMR_STOP			_SIO  ('T', 3)
174#define SNDCTL_TMR_CONTINUE		_SIO  ('T', 4)
175#define SNDCTL_TMR_TEMPO		_SIOWR('T', 5, int)
176#define SNDCTL_TMR_SOURCE		_SIOWR('T', 6, int)
177#	define TMR_INTERNAL		0x00000001
178#	define TMR_EXTERNAL		0x00000002
179#		define TMR_MODE_MIDI	0x00000010
180#		define TMR_MODE_FSK	0x00000020
181#		define TMR_MODE_CLS	0x00000040
182#		define TMR_MODE_SMPTE	0x00000080
183#define SNDCTL_TMR_METRONOME		_SIOW ('T', 7, int)
184#define SNDCTL_TMR_SELECT		_SIOW ('T', 8, int)
185
186/*
187 * Some big endian/little endian handling macros
188 */
189
190#define _LINUX_PATCHKEY_H_INDIRECT
191#include <linux/patchkey.h>
192#undef _LINUX_PATCHKEY_H_INDIRECT
193
194#if defined(__KERNEL__)
195#  if defined(__BIG_ENDIAN)
196#    define AFMT_S16_NE AFMT_S16_BE
197#  elif defined(__LITTLE_ENDIAN)
198#    define AFMT_S16_NE AFMT_S16_LE
199#  else
200#    error "could not determine byte order"
201#  endif
202#elif defined(__BYTE_ORDER)
203#  if __BYTE_ORDER == __BIG_ENDIAN
204#    define AFMT_S16_NE AFMT_S16_BE
205#  elif __BYTE_ORDER == __LITTLE_ENDIAN
206#    define AFMT_S16_NE AFMT_S16_LE
207#  else
208#    error "could not determine byte order"
209#  endif
210#endif
211
212/*
213 *	Sample loading mechanism for internal synthesizers (/dev/sequencer)
214 *	The following patch_info structure has been designed to support
215 *	Gravis UltraSound. It tries to be universal format for uploading
216 *	sample based patches but is probably too limited.
217 *
218 *      (PBD) As Hannu guessed, the GUS structure is too limited for
219 *      the WaveFront, but this is the right place for a constant definition.
220 */
221
222struct patch_info {
223		unsigned short key;		/* Use WAVE_PATCH here */
224#define WAVE_PATCH	   _PATCHKEY(0x04)
225#define GUS_PATCH	   WAVE_PATCH
226#define WAVEFRONT_PATCH    _PATCHKEY(0x06)
227
228		short device_no;	/* Synthesizer number */
229		short instr_no;		/* Midi pgm# */
230
231		unsigned int mode;
232/*
233 * The least significant byte has the same format than the GUS .PAT
234 * files
235 */
236#define WAVE_16_BITS	0x01	/* bit 0 = 8 or 16 bit wave data. */
237#define WAVE_UNSIGNED	0x02	/* bit 1 = Signed - Unsigned data. */
238#define WAVE_LOOPING	0x04	/* bit 2 = looping enabled-1. */
239#define WAVE_BIDIR_LOOP	0x08	/* bit 3 = Set is bidirectional looping. */
240#define WAVE_LOOP_BACK	0x10	/* bit 4 = Set is looping backward. */
241#define WAVE_SUSTAIN_ON	0x20	/* bit 5 = Turn sustaining on. (Env. pts. 3)*/
242#define WAVE_ENVELOPES	0x40	/* bit 6 = Enable envelopes - 1 */
243#define WAVE_FAST_RELEASE 0x80	/* bit 7 = Shut off immediately after note off */
244				/* 	(use the env_rate/env_offs fields). */
245/* Linux specific bits */
246#define WAVE_VIBRATO	0x00010000	/* The vibrato info is valid */
247#define WAVE_TREMOLO	0x00020000	/* The tremolo info is valid */
248#define WAVE_SCALE	0x00040000	/* The scaling info is valid */
249#define WAVE_FRACTIONS	0x00080000	/* Fraction information is valid */
250/* Reserved bits */
251#define WAVE_ROM	0x40000000	/* For future use */
252#define WAVE_MULAW	0x20000000	/* For future use */
253/* Other bits must be zeroed */
254
255		int len;	/* Size of the wave data in bytes */
256		int loop_start, loop_end; /* Byte offsets from the beginning */
257
258/*
259 * The base_freq and base_note fields are used when computing the
260 * playback speed for a note. The base_note defines the tone frequency
261 * which is heard if the sample is played using the base_freq as the
262 * playback speed.
263 *
264 * The low_note and high_note fields define the minimum and maximum note
265 * frequencies for which this sample is valid. It is possible to define
266 * more than one samples for an instrument number at the same time. The
267 * low_note and high_note fields are used to select the most suitable one.
268 *
269 * The fields base_note, high_note and low_note should contain
270 * the note frequency multiplied by 1000. For example value for the
271 * middle A is 440*1000.
272 */
273
274		unsigned int base_freq;
275		unsigned int base_note;
276		unsigned int high_note;
277		unsigned int low_note;
278		int panning;	/* -128=left, 127=right */
279		int detuning;
280
281/*	New fields introduced in version 1.99.5	*/
282
283       /* Envelope. Enabled by mode bit WAVE_ENVELOPES	*/
284		unsigned char	env_rate[ 6 ];	 /* GUS HW ramping rate */
285		unsigned char	env_offset[ 6 ]; /* 255 == 100% */
286
287	/*
288	 * The tremolo, vibrato and scale info are not supported yet.
289	 * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or
290	 * WAVE_SCALE
291	 */
292
293		unsigned char	tremolo_sweep;
294		unsigned char	tremolo_rate;
295		unsigned char	tremolo_depth;
296
297		unsigned char	vibrato_sweep;
298		unsigned char	vibrato_rate;
299		unsigned char	vibrato_depth;
300
301		int		scale_frequency;
302		unsigned int	scale_factor;		/* from 0 to 2048 or 0 to 2 */
303
304	        int		volume;
305		int		fractions;
306		int		reserved1;
307	        int		spare[2];
308		char data[1];	/* The waveform data starts here */
309	};
310
311struct sysex_info {
312		short key;		/* Use SYSEX_PATCH or MAUI_PATCH here */
313#define SYSEX_PATCH	_PATCHKEY(0x05)
314#define MAUI_PATCH	_PATCHKEY(0x06)
315		short device_no;	/* Synthesizer number */
316		int len;	/* Size of the sysex data in bytes */
317		unsigned char data[1];	/* Sysex data starts here */
318	};
319
320/*
321 * /dev/sequencer input events.
322 *
323 * The data written to the /dev/sequencer is a stream of events. Events
324 * are records of 4 or 8 bytes. The first byte defines the size.
325 * Any number of events can be written with a write call. There
326 * is a set of macros for sending these events. Use these macros if you
327 * want to maximize portability of your program.
328 *
329 * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events.
330 * (All input events are currently 4 bytes long. Be prepared to support
331 * 8 byte events also. If you receive any event having first byte >= 128,
332 * it's a 8 byte event.
333 *
334 * The events are documented at the end of this file.
335 *
336 * Normal events (4 bytes)
337 * There is also a 8 byte version of most of the 4 byte events. The
338 * 8 byte one is recommended.
339 */
340#define SEQ_NOTEOFF		0
341#define SEQ_FMNOTEOFF		SEQ_NOTEOFF	/* Just old name */
342#define SEQ_NOTEON		1
343#define	SEQ_FMNOTEON		SEQ_NOTEON
344#define SEQ_WAIT		TMR_WAIT_ABS
345#define SEQ_PGMCHANGE		3
346#define SEQ_FMPGMCHANGE		SEQ_PGMCHANGE
347#define SEQ_SYNCTIMER		TMR_START
348#define SEQ_MIDIPUTC		5
349#define SEQ_DRUMON		6	/*** OBSOLETE ***/
350#define SEQ_DRUMOFF		7	/*** OBSOLETE ***/
351#define SEQ_ECHO		TMR_ECHO	/* For synching programs with output */
352#define SEQ_AFTERTOUCH		9
353#define SEQ_CONTROLLER		10
354
355/*******************************************
356 *	Midi controller numbers
357 *******************************************
358 * Controllers 0 to 31 (0x00 to 0x1f) and
359 * 32 to 63 (0x20 to 0x3f) are continuous
360 * controllers.
361 * In the MIDI 1.0 these controllers are sent using
362 * two messages. Controller numbers 0 to 31 are used
363 * to send the MSB and the controller numbers 32 to 63
364 * are for the LSB. Note that just 7 bits are used in MIDI bytes.
365 */
366
367#define	   CTL_BANK_SELECT		0x00
368#define	   CTL_MODWHEEL			0x01
369#define    CTL_BREATH			0x02
370/*		undefined		0x03 */
371#define    CTL_FOOT			0x04
372#define    CTL_PORTAMENTO_TIME		0x05
373#define    CTL_DATA_ENTRY		0x06
374#define    CTL_MAIN_VOLUME		0x07
375#define    CTL_BALANCE			0x08
376/*		undefined		0x09 */
377#define    CTL_PAN			0x0a
378#define    CTL_EXPRESSION		0x0b
379/*		undefined		0x0c */
380/*		undefined		0x0d */
381/*		undefined		0x0e */
382/*		undefined		0x0f */
383#define    CTL_GENERAL_PURPOSE1	0x10
384#define    CTL_GENERAL_PURPOSE2	0x11
385#define    CTL_GENERAL_PURPOSE3	0x12
386#define    CTL_GENERAL_PURPOSE4	0x13
387/*		undefined		0x14 - 0x1f */
388
389/*		undefined		0x20 */
390/* The controller numbers 0x21 to 0x3f are reserved for the */
391/* least significant bytes of the controllers 0x00 to 0x1f. */
392/* These controllers are not recognised by the driver. */
393
394/* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. */
395/* 0=OFF and 127=ON (intermediate values are possible) */
396#define    CTL_DAMPER_PEDAL		0x40
397#define    CTL_SUSTAIN			0x40	/* Alias */
398#define    CTL_HOLD			0x40	/* Alias */
399#define    CTL_PORTAMENTO		0x41
400#define    CTL_SOSTENUTO		0x42
401#define    CTL_SOFT_PEDAL		0x43
402/*		undefined		0x44 */
403#define    CTL_HOLD2			0x45
404/*		undefined		0x46 - 0x4f */
405
406#define    CTL_GENERAL_PURPOSE5	0x50
407#define    CTL_GENERAL_PURPOSE6	0x51
408#define    CTL_GENERAL_PURPOSE7	0x52
409#define    CTL_GENERAL_PURPOSE8	0x53
410/*		undefined		0x54 - 0x5a */
411#define    CTL_EXT_EFF_DEPTH		0x5b
412#define    CTL_TREMOLO_DEPTH		0x5c
413#define    CTL_CHORUS_DEPTH		0x5d
414#define    CTL_DETUNE_DEPTH		0x5e
415#define    CTL_CELESTE_DEPTH		0x5e	/* Alias for the above one */
416#define    CTL_PHASER_DEPTH		0x5f
417#define    CTL_DATA_INCREMENT		0x60
418#define    CTL_DATA_DECREMENT		0x61
419#define    CTL_NONREG_PARM_NUM_LSB	0x62
420#define    CTL_NONREG_PARM_NUM_MSB	0x63
421#define    CTL_REGIST_PARM_NUM_LSB	0x64
422#define    CTL_REGIST_PARM_NUM_MSB	0x65
423/*		undefined		0x66 - 0x78 */
424/*		reserved		0x79 - 0x7f */
425
426/* Pseudo controllers (not midi compatible) */
427#define    CTRL_PITCH_BENDER		255
428#define    CTRL_PITCH_BENDER_RANGE	254
429#define    CTRL_EXPRESSION		253	/* Obsolete */
430#define    CTRL_MAIN_VOLUME		252	/* Obsolete */
431#define SEQ_BALANCE		11
432#define SEQ_VOLMODE             12
433
434/*
435 * Volume mode decides how volumes are used
436 */
437
438#define VOL_METHOD_ADAGIO	1
439#define VOL_METHOD_LINEAR	2
440
441/*
442 * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as
443 *	 input events.
444 */
445
446/*
447 * Event codes 0xf0 to 0xfc are reserved for future extensions.
448 */
449
450#define SEQ_FULLSIZE		0xfd	/* Long events */
451/*
452 *	SEQ_FULLSIZE events are used for loading patches/samples to the
453 *	synthesizer devices. These events are passed directly to the driver
454 *	of the associated synthesizer device. There is no limit to the size
455 *	of the extended events. These events are not queued but executed
456 *	immediately when the write() is called (execution can take several
457 *	seconds of time).
458 *
459 *	When a SEQ_FULLSIZE message is written to the device, it must
460 *	be written using exactly one write() call. Other events cannot
461 *	be mixed to the same write.
462 *
463 *	For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the
464 *	/dev/sequencer. Don't write other data together with the instrument structure
465 *	Set the key field of the structure to FM_PATCH. The device field is used to
466 *	route the patch to the corresponding device.
467 *
468 *	For wave table use struct patch_info. Initialize the key field
469 *      to WAVE_PATCH.
470 */
471#define SEQ_PRIVATE		0xfe	/* Low level HW dependent events (8 bytes) */
472#define SEQ_EXTENDED		0xff	/* Extended events (8 bytes) OBSOLETE */
473
474/*
475 * Record for FM patches
476 */
477
478typedef unsigned char sbi_instr_data[32];
479
480struct sbi_instrument {
481		unsigned short	key;	/* FM_PATCH or OPL3_PATCH */
482#define FM_PATCH	_PATCHKEY(0x01)
483#define OPL3_PATCH	_PATCHKEY(0x03)
484		short		device;		/*	Synth# (0-4)	*/
485		int 		channel;	/*	Program# to be initialized 	*/
486		sbi_instr_data	operators;	/*	Register settings for operator cells (.SBI format)	*/
487	};
488
489struct synth_info {	/* Read only */
490		char	name[30];
491		int	device;		/* 0-N. INITIALIZE BEFORE CALLING */
492		int	synth_type;
493#define SYNTH_TYPE_FM			0
494#define SYNTH_TYPE_SAMPLE		1
495#define SYNTH_TYPE_MIDI			2	/* Midi interface */
496
497		int	synth_subtype;
498#define FM_TYPE_ADLIB			0x00
499#define FM_TYPE_OPL3			0x01
500#define MIDI_TYPE_MPU401		0x401
501
502#define SAMPLE_TYPE_BASIC		0x10
503#define SAMPLE_TYPE_GUS			SAMPLE_TYPE_BASIC
504#define SAMPLE_TYPE_WAVEFRONT           0x11
505
506		int	perc_mode;	/* No longer supported */
507		int	nr_voices;
508		int	nr_drums;	/* Obsolete field */
509		int	instr_bank_size;
510		unsigned int	capabilities;
511#define SYNTH_CAP_PERCMODE		0x00000001 /* No longer used */
512#define SYNTH_CAP_OPL3			0x00000002 /* Set if OPL3 supported */
513#define SYNTH_CAP_INPUT			0x00000004 /* Input (MIDI) device */
514		int	dummies[19];	/* Reserve space */
515	};
516
517struct sound_timer_info {
518		char name[32];
519		int caps;
520	};
521
522#define MIDI_CAP_MPU401		1		/* MPU-401 intelligent mode */
523
524struct midi_info {
525		char		name[30];
526		int		device;		/* 0-N. INITIALIZE BEFORE CALLING */
527		unsigned int	capabilities;	/* To be defined later */
528		int		dev_type;
529		int		dummies[18];	/* Reserve space */
530	};
531
532/********************************************
533 * ioctl commands for the /dev/midi##
534 */
535typedef struct {
536		unsigned char cmd;
537		char nr_args, nr_returns;
538		unsigned char data[30];
539	} mpu_command_rec;
540
541#define SNDCTL_MIDI_PRETIME		_SIOWR('m', 0, int)
542#define SNDCTL_MIDI_MPUMODE		_SIOWR('m', 1, int)
543#define SNDCTL_MIDI_MPUCMD		_SIOWR('m', 2, mpu_command_rec)
544
545/********************************************
546 * IOCTL commands for /dev/dsp and /dev/audio
547 */
548
549#define SNDCTL_DSP_RESET		_SIO  ('P', 0)
550#define SNDCTL_DSP_SYNC			_SIO  ('P', 1)
551#define SNDCTL_DSP_SPEED		_SIOWR('P', 2, int)
552#define SNDCTL_DSP_STEREO		_SIOWR('P', 3, int)
553#define SNDCTL_DSP_GETBLKSIZE		_SIOWR('P', 4, int)
554#define SNDCTL_DSP_SAMPLESIZE		SNDCTL_DSP_SETFMT
555#define SNDCTL_DSP_CHANNELS		_SIOWR('P', 6, int)
556#define SOUND_PCM_WRITE_CHANNELS	SNDCTL_DSP_CHANNELS
557#define SOUND_PCM_WRITE_FILTER		_SIOWR('P', 7, int)
558#define SNDCTL_DSP_POST			_SIO  ('P', 8)
559#define SNDCTL_DSP_SUBDIVIDE		_SIOWR('P', 9, int)
560#define SNDCTL_DSP_SETFRAGMENT		_SIOWR('P',10, int)
561
562/*	Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */
563#define SNDCTL_DSP_GETFMTS		_SIOR ('P',11, int) /* Returns a mask */
564#define SNDCTL_DSP_SETFMT		_SIOWR('P',5, int) /* Selects ONE fmt*/
565#	define AFMT_QUERY		0x00000000	/* Return current fmt */
566#	define AFMT_MU_LAW		0x00000001
567#	define AFMT_A_LAW		0x00000002
568#	define AFMT_IMA_ADPCM		0x00000004
569#	define AFMT_U8			0x00000008
570#	define AFMT_S16_LE		0x00000010	/* Little endian signed 16*/
571#	define AFMT_S16_BE		0x00000020	/* Big endian signed 16 */
572#	define AFMT_S8			0x00000040
573#	define AFMT_U16_LE		0x00000080	/* Little endian U16 */
574#	define AFMT_U16_BE		0x00000100	/* Big endian U16 */
575#	define AFMT_MPEG		0x00000200	/* MPEG (2) audio */
576#	define AFMT_AC3		0x00000400	/* Dolby Digital AC3 */
577
578/*
579 * Buffer status queries.
580 */
581typedef struct audio_buf_info {
582			int fragments;	/* # of available fragments (partially usend ones not counted) */
583			int fragstotal;	/* Total # of fragments allocated */
584			int fragsize;	/* Size of a fragment in bytes */
585
586			int bytes;	/* Available space in bytes (includes partially used fragments) */
587			/* Note! 'bytes' could be more than fragments*fragsize */
588		} audio_buf_info;
589
590#define SNDCTL_DSP_GETOSPACE		_SIOR ('P',12, audio_buf_info)
591#define SNDCTL_DSP_GETISPACE		_SIOR ('P',13, audio_buf_info)
592#define SNDCTL_DSP_NONBLOCK		_SIO  ('P',14)
593#define SNDCTL_DSP_GETCAPS		_SIOR ('P',15, int)
594#	define DSP_CAP_REVISION		0x000000ff	/* Bits for revision level (0 to 255) */
595#	define DSP_CAP_DUPLEX		0x00000100	/* Full duplex record/playback */
596#	define DSP_CAP_REALTIME		0x00000200	/* Real time capability */
597#	define DSP_CAP_BATCH		0x00000400	/* Device has some kind of */
598							/* internal buffers which may */
599							/* cause some delays and */
600							/* decrease precision of timing */
601#	define DSP_CAP_COPROC		0x00000800	/* Has a coprocessor */
602							/* Sometimes it's a DSP */
603							/* but usually not */
604#	define DSP_CAP_TRIGGER		0x00001000	/* Supports SETTRIGGER */
605#	define DSP_CAP_MMAP		0x00002000	/* Supports mmap() */
606#	define DSP_CAP_MULTI		0x00004000	/* support multiple open */
607#	define DSP_CAP_BIND		0x00008000	/* channel binding to front/rear/cneter/lfe */
608
609
610#define SNDCTL_DSP_GETTRIGGER		_SIOR ('P',16, int)
611#define SNDCTL_DSP_SETTRIGGER		_SIOW ('P',16, int)
612#	define PCM_ENABLE_INPUT		0x00000001
613#	define PCM_ENABLE_OUTPUT		0x00000002
614
615typedef struct count_info {
616		int bytes;	/* Total # of bytes processed */
617		int blocks;	/* # of fragment transitions since last time */
618		int ptr;	/* Current DMA pointer value */
619	} count_info;
620
621#define SNDCTL_DSP_GETIPTR		_SIOR ('P',17, count_info)
622#define SNDCTL_DSP_GETOPTR		_SIOR ('P',18, count_info)
623
624typedef struct buffmem_desc {
625		unsigned *buffer;
626		int size;
627	} buffmem_desc;
628#define SNDCTL_DSP_MAPINBUF		_SIOR ('P', 19, buffmem_desc)
629#define SNDCTL_DSP_MAPOUTBUF		_SIOR ('P', 20, buffmem_desc)
630#define SNDCTL_DSP_SETSYNCRO		_SIO  ('P', 21)
631#define SNDCTL_DSP_SETDUPLEX		_SIO  ('P', 22)
632#define SNDCTL_DSP_GETODELAY		_SIOR ('P', 23, int)
633
634#define SNDCTL_DSP_GETCHANNELMASK		_SIOWR('P', 64, int)
635#define SNDCTL_DSP_BIND_CHANNEL		_SIOWR('P', 65, int)
636#	define DSP_BIND_QUERY		0x00000000
637#	define DSP_BIND_FRONT		0x00000001
638#	define DSP_BIND_SURR		0x00000002
639#	define DSP_BIND_CENTER_LFE	0x00000004
640#	define DSP_BIND_HANDSET		0x00000008
641#	define DSP_BIND_MIC		0x00000010
642#	define DSP_BIND_MODEM1		0x00000020
643#	define DSP_BIND_MODEM2		0x00000040
644#	define DSP_BIND_I2S		0x00000080
645#	define DSP_BIND_SPDIF		0x00000100
646
647#define SNDCTL_DSP_SETSPDIF		_SIOW ('P', 66, int)
648#define SNDCTL_DSP_GETSPDIF		_SIOR ('P', 67, int)
649#	define SPDIF_PRO	0x0001
650#	define SPDIF_N_AUD	0x0002
651#	define SPDIF_COPY	0x0004
652#	define SPDIF_PRE	0x0008
653#	define SPDIF_CC		0x07f0
654#	define SPDIF_L		0x0800
655#	define SPDIF_DRS	0x4000
656#	define SPDIF_V		0x8000
657
658/*
659 * Application's profile defines the way how playback underrun situations should be handled.
660 *
661 *	APF_NORMAL (the default) and APF_NETWORK make the driver to cleanup the
662 *	playback buffer whenever an underrun occurs. This consumes some time
663 *	prevents looping the existing buffer.
664 *	APF_CPUINTENS is intended to be set by CPU intensive applications which
665 *	are likely to run out of time occasionally. In this mode the buffer cleanup is
666 *	disabled which saves CPU time but also let's the previous buffer content to
667 *	be played during the "pause" after the underrun.
668 */
669#define SNDCTL_DSP_PROFILE		_SIOW ('P', 23, int)
670#define	  APF_NORMAL	0	/* Normal applications */
671#define	  APF_NETWORK	1	/* Underruns probably caused by an "external" delay */
672#define   APF_CPUINTENS 2	/* Underruns probably caused by "overheating" the CPU */
673
674#define SOUND_PCM_READ_RATE		_SIOR ('P', 2, int)
675#define SOUND_PCM_READ_CHANNELS		_SIOR ('P', 6, int)
676#define SOUND_PCM_READ_BITS		_SIOR ('P', 5, int)
677#define SOUND_PCM_READ_FILTER		_SIOR ('P', 7, int)
678
679/* Some alias names */
680#define SOUND_PCM_WRITE_BITS		SNDCTL_DSP_SETFMT
681#define SOUND_PCM_WRITE_RATE		SNDCTL_DSP_SPEED
682#define SOUND_PCM_POST			SNDCTL_DSP_POST
683#define SOUND_PCM_RESET			SNDCTL_DSP_RESET
684#define SOUND_PCM_SYNC			SNDCTL_DSP_SYNC
685#define SOUND_PCM_SUBDIVIDE		SNDCTL_DSP_SUBDIVIDE
686#define SOUND_PCM_SETFRAGMENT		SNDCTL_DSP_SETFRAGMENT
687#define SOUND_PCM_GETFMTS		SNDCTL_DSP_GETFMTS
688#define SOUND_PCM_SETFMT		SNDCTL_DSP_SETFMT
689#define SOUND_PCM_GETOSPACE		SNDCTL_DSP_GETOSPACE
690#define SOUND_PCM_GETISPACE		SNDCTL_DSP_GETISPACE
691#define SOUND_PCM_NONBLOCK		SNDCTL_DSP_NONBLOCK
692#define SOUND_PCM_GETCAPS		SNDCTL_DSP_GETCAPS
693#define SOUND_PCM_GETTRIGGER		SNDCTL_DSP_GETTRIGGER
694#define SOUND_PCM_SETTRIGGER		SNDCTL_DSP_SETTRIGGER
695#define SOUND_PCM_SETSYNCRO		SNDCTL_DSP_SETSYNCRO
696#define SOUND_PCM_GETIPTR		SNDCTL_DSP_GETIPTR
697#define SOUND_PCM_GETOPTR		SNDCTL_DSP_GETOPTR
698#define SOUND_PCM_MAPINBUF		SNDCTL_DSP_MAPINBUF
699#define SOUND_PCM_MAPOUTBUF		SNDCTL_DSP_MAPOUTBUF
700
701/*
702 * ioctl calls to be used in communication with coprocessors and
703 * DSP chips.
704 */
705
706typedef struct copr_buffer {
707		int command;	/* Set to 0 if not used */
708		int flags;
709#define CPF_NONE		0x0000
710#define CPF_FIRST		0x0001	/* First block */
711#define CPF_LAST		0x0002	/* Last block */
712		int len;
713		int offs;	/* If required by the device (0 if not used) */
714
715		unsigned char data[4000]; /* NOTE! 4000 is not 4k */
716	} copr_buffer;
717
718typedef struct copr_debug_buf {
719		int command;	/* Used internally. Set to 0 */
720		int parm1;
721		int parm2;
722		int flags;
723		int len;	/* Length of data in bytes */
724	} copr_debug_buf;
725
726typedef struct copr_msg {
727		int len;
728		unsigned char data[4000];
729	} copr_msg;
730
731#define SNDCTL_COPR_RESET             _SIO  ('C',  0)
732#define SNDCTL_COPR_LOAD	      _SIOWR('C',  1, copr_buffer)
733#define SNDCTL_COPR_RDATA	      _SIOWR('C',  2, copr_debug_buf)
734#define SNDCTL_COPR_RCODE	      _SIOWR('C',  3, copr_debug_buf)
735#define SNDCTL_COPR_WDATA	      _SIOW ('C',  4, copr_debug_buf)
736#define SNDCTL_COPR_WCODE	      _SIOW ('C',  5, copr_debug_buf)
737#define SNDCTL_COPR_RUN		      _SIOWR('C',  6, copr_debug_buf)
738#define SNDCTL_COPR_HALT	      _SIOWR('C',  7, copr_debug_buf)
739#define SNDCTL_COPR_SENDMSG	      _SIOWR('C',  8, copr_msg)
740#define SNDCTL_COPR_RCVMSG	      _SIOR ('C',  9, copr_msg)
741
742/*********************************************
743 * IOCTL commands for /dev/mixer
744 */
745
746/*
747 * Mixer devices
748 *
749 * There can be up to 20 different analog mixer channels. The
750 * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
751 * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
752 * the devices supported by the particular mixer.
753 */
754
755#define SOUND_MIXER_NRDEVICES	25
756#define SOUND_MIXER_VOLUME	0
757#define SOUND_MIXER_BASS	1
758#define SOUND_MIXER_TREBLE	2
759#define SOUND_MIXER_SYNTH	3
760#define SOUND_MIXER_PCM		4
761#define SOUND_MIXER_SPEAKER	5
762#define SOUND_MIXER_LINE	6
763#define SOUND_MIXER_MIC		7
764#define SOUND_MIXER_CD		8
765#define SOUND_MIXER_IMIX	9	/*  Recording monitor  */
766#define SOUND_MIXER_ALTPCM	10
767#define SOUND_MIXER_RECLEV	11	/* Recording level */
768#define SOUND_MIXER_IGAIN	12	/* Input gain */
769#define SOUND_MIXER_OGAIN	13	/* Output gain */
770/*
771 * The AD1848 codec and compatibles have three line level inputs
772 * (line, aux1 and aux2). Since each card manufacturer have assigned
773 * different meanings to these inputs, it's inpractical to assign
774 * specific meanings (line, cd, synth etc.) to them.
775 */
776#define SOUND_MIXER_LINE1	14	/* Input source 1  (aux1) */
777#define SOUND_MIXER_LINE2	15	/* Input source 2  (aux2) */
778#define SOUND_MIXER_LINE3	16	/* Input source 3  (line) */
779#define SOUND_MIXER_DIGITAL1	17	/* Digital (input) 1 */
780#define SOUND_MIXER_DIGITAL2	18	/* Digital (input) 2 */
781#define SOUND_MIXER_DIGITAL3	19	/* Digital (input) 3 */
782#define SOUND_MIXER_PHONEIN	20	/* Phone input */
783#define SOUND_MIXER_PHONEOUT	21	/* Phone output */
784#define SOUND_MIXER_VIDEO	22	/* Video/TV (audio) in */
785#define SOUND_MIXER_RADIO	23	/* Radio in */
786#define SOUND_MIXER_MONITOR	24	/* Monitor (usually mic) volume */
787
788/* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */
789/* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */
790#define SOUND_ONOFF_MIN		28
791#define SOUND_ONOFF_MAX		30
792
793/* Note!	Number 31 cannot be used since the sign bit is reserved */
794#define SOUND_MIXER_NONE	31
795
796/*
797 * The following unsupported macros are no longer functional.
798 * Use SOUND_MIXER_PRIVATE# macros in future.
799 */
800#define SOUND_MIXER_ENHANCE	SOUND_MIXER_NONE
801#define SOUND_MIXER_MUTE	SOUND_MIXER_NONE
802#define SOUND_MIXER_LOUD	SOUND_MIXER_NONE
803
804
805#define SOUND_DEVICE_LABELS	{"Vol  ", "Bass ", "Trebl", "Synth", "Pcm  ", "Spkr ", "Line ", \
806				 "Mic  ", "CD   ", "Mix  ", "Pcm2 ", "Rec  ", "IGain", "OGain", \
807				 "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
808				 "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
809
810#define SOUND_DEVICE_NAMES	{"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
811				 "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
812				 "line1", "line2", "line3", "dig1", "dig2", "dig3", \
813				 "phin", "phout", "video", "radio", "monitor"}
814
815/*	Device bitmask identifiers	*/
816
817#define SOUND_MIXER_RECSRC	0xff	/* Arg contains a bit for each recording source */
818#define SOUND_MIXER_DEVMASK	0xfe	/* Arg contains a bit for each supported device */
819#define SOUND_MIXER_RECMASK	0xfd	/* Arg contains a bit for each supported recording source */
820#define SOUND_MIXER_CAPS	0xfc
821#	define SOUND_CAP_EXCL_INPUT	0x00000001	/* Only one recording source at a time */
822#define SOUND_MIXER_STEREODEVS	0xfb	/* Mixer channels supporting stereo */
823#define SOUND_MIXER_OUTSRC	0xfa	/* Arg contains a bit for each input source to output */
824#define SOUND_MIXER_OUTMASK	0xf9	/* Arg contains a bit for each supported input source to output */
825
826/*	Device mask bits	*/
827
828#define SOUND_MASK_VOLUME	(1 << SOUND_MIXER_VOLUME)
829#define SOUND_MASK_BASS		(1 << SOUND_MIXER_BASS)
830#define SOUND_MASK_TREBLE	(1 << SOUND_MIXER_TREBLE)
831#define SOUND_MASK_SYNTH	(1 << SOUND_MIXER_SYNTH)
832#define SOUND_MASK_PCM		(1 << SOUND_MIXER_PCM)
833#define SOUND_MASK_SPEAKER	(1 << SOUND_MIXER_SPEAKER)
834#define SOUND_MASK_LINE		(1 << SOUND_MIXER_LINE)
835#define SOUND_MASK_MIC		(1 << SOUND_MIXER_MIC)
836#define SOUND_MASK_CD		(1 << SOUND_MIXER_CD)
837#define SOUND_MASK_IMIX		(1 << SOUND_MIXER_IMIX)
838#define SOUND_MASK_ALTPCM	(1 << SOUND_MIXER_ALTPCM)
839#define SOUND_MASK_RECLEV	(1 << SOUND_MIXER_RECLEV)
840#define SOUND_MASK_IGAIN	(1 << SOUND_MIXER_IGAIN)
841#define SOUND_MASK_OGAIN	(1 << SOUND_MIXER_OGAIN)
842#define SOUND_MASK_LINE1	(1 << SOUND_MIXER_LINE1)
843#define SOUND_MASK_LINE2	(1 << SOUND_MIXER_LINE2)
844#define SOUND_MASK_LINE3	(1 << SOUND_MIXER_LINE3)
845#define SOUND_MASK_DIGITAL1	(1 << SOUND_MIXER_DIGITAL1)
846#define SOUND_MASK_DIGITAL2	(1 << SOUND_MIXER_DIGITAL2)
847#define SOUND_MASK_DIGITAL3	(1 << SOUND_MIXER_DIGITAL3)
848#define SOUND_MASK_PHONEIN	(1 << SOUND_MIXER_PHONEIN)
849#define SOUND_MASK_PHONEOUT	(1 << SOUND_MIXER_PHONEOUT)
850#define SOUND_MASK_RADIO	(1 << SOUND_MIXER_RADIO)
851#define SOUND_MASK_VIDEO	(1 << SOUND_MIXER_VIDEO)
852#define SOUND_MASK_MONITOR	(1 << SOUND_MIXER_MONITOR)
853
854/* Obsolete macros */
855#define SOUND_MASK_MUTE		(1 << SOUND_MIXER_MUTE)
856#define SOUND_MASK_ENHANCE	(1 << SOUND_MIXER_ENHANCE)
857#define SOUND_MASK_LOUD		(1 << SOUND_MIXER_LOUD)
858
859#define MIXER_READ(dev)		_SIOR('M', dev, int)
860#define SOUND_MIXER_READ_VOLUME		MIXER_READ(SOUND_MIXER_VOLUME)
861#define SOUND_MIXER_READ_BASS		MIXER_READ(SOUND_MIXER_BASS)
862#define SOUND_MIXER_READ_TREBLE		MIXER_READ(SOUND_MIXER_TREBLE)
863#define SOUND_MIXER_READ_SYNTH		MIXER_READ(SOUND_MIXER_SYNTH)
864#define SOUND_MIXER_READ_PCM		MIXER_READ(SOUND_MIXER_PCM)
865#define SOUND_MIXER_READ_SPEAKER	MIXER_READ(SOUND_MIXER_SPEAKER)
866#define SOUND_MIXER_READ_LINE		MIXER_READ(SOUND_MIXER_LINE)
867#define SOUND_MIXER_READ_MIC		MIXER_READ(SOUND_MIXER_MIC)
868#define SOUND_MIXER_READ_CD		MIXER_READ(SOUND_MIXER_CD)
869#define SOUND_MIXER_READ_IMIX		MIXER_READ(SOUND_MIXER_IMIX)
870#define SOUND_MIXER_READ_ALTPCM		MIXER_READ(SOUND_MIXER_ALTPCM)
871#define SOUND_MIXER_READ_RECLEV		MIXER_READ(SOUND_MIXER_RECLEV)
872#define SOUND_MIXER_READ_IGAIN		MIXER_READ(SOUND_MIXER_IGAIN)
873#define SOUND_MIXER_READ_OGAIN		MIXER_READ(SOUND_MIXER_OGAIN)
874#define SOUND_MIXER_READ_LINE1		MIXER_READ(SOUND_MIXER_LINE1)
875#define SOUND_MIXER_READ_LINE2		MIXER_READ(SOUND_MIXER_LINE2)
876#define SOUND_MIXER_READ_LINE3		MIXER_READ(SOUND_MIXER_LINE3)
877
878/* Obsolete macros */
879#define SOUND_MIXER_READ_MUTE		MIXER_READ(SOUND_MIXER_MUTE)
880#define SOUND_MIXER_READ_ENHANCE	MIXER_READ(SOUND_MIXER_ENHANCE)
881#define SOUND_MIXER_READ_LOUD		MIXER_READ(SOUND_MIXER_LOUD)
882
883#define SOUND_MIXER_READ_RECSRC		MIXER_READ(SOUND_MIXER_RECSRC)
884#define SOUND_MIXER_READ_DEVMASK	MIXER_READ(SOUND_MIXER_DEVMASK)
885#define SOUND_MIXER_READ_RECMASK	MIXER_READ(SOUND_MIXER_RECMASK)
886#define SOUND_MIXER_READ_STEREODEVS	MIXER_READ(SOUND_MIXER_STEREODEVS)
887#define SOUND_MIXER_READ_CAPS		MIXER_READ(SOUND_MIXER_CAPS)
888
889#define MIXER_WRITE(dev)		_SIOWR('M', dev, int)
890#define SOUND_MIXER_WRITE_VOLUME	MIXER_WRITE(SOUND_MIXER_VOLUME)
891#define SOUND_MIXER_WRITE_BASS		MIXER_WRITE(SOUND_MIXER_BASS)
892#define SOUND_MIXER_WRITE_TREBLE	MIXER_WRITE(SOUND_MIXER_TREBLE)
893#define SOUND_MIXER_WRITE_SYNTH		MIXER_WRITE(SOUND_MIXER_SYNTH)
894#define SOUND_MIXER_WRITE_PCM		MIXER_WRITE(SOUND_MIXER_PCM)
895#define SOUND_MIXER_WRITE_SPEAKER	MIXER_WRITE(SOUND_MIXER_SPEAKER)
896#define SOUND_MIXER_WRITE_LINE		MIXER_WRITE(SOUND_MIXER_LINE)
897#define SOUND_MIXER_WRITE_MIC		MIXER_WRITE(SOUND_MIXER_MIC)
898#define SOUND_MIXER_WRITE_CD		MIXER_WRITE(SOUND_MIXER_CD)
899#define SOUND_MIXER_WRITE_IMIX		MIXER_WRITE(SOUND_MIXER_IMIX)
900#define SOUND_MIXER_WRITE_ALTPCM	MIXER_WRITE(SOUND_MIXER_ALTPCM)
901#define SOUND_MIXER_WRITE_RECLEV	MIXER_WRITE(SOUND_MIXER_RECLEV)
902#define SOUND_MIXER_WRITE_IGAIN		MIXER_WRITE(SOUND_MIXER_IGAIN)
903#define SOUND_MIXER_WRITE_OGAIN		MIXER_WRITE(SOUND_MIXER_OGAIN)
904#define SOUND_MIXER_WRITE_LINE1		MIXER_WRITE(SOUND_MIXER_LINE1)
905#define SOUND_MIXER_WRITE_LINE2		MIXER_WRITE(SOUND_MIXER_LINE2)
906#define SOUND_MIXER_WRITE_LINE3		MIXER_WRITE(SOUND_MIXER_LINE3)
907
908/* Obsolete macros */
909#define SOUND_MIXER_WRITE_MUTE		MIXER_WRITE(SOUND_MIXER_MUTE)
910#define SOUND_MIXER_WRITE_ENHANCE	MIXER_WRITE(SOUND_MIXER_ENHANCE)
911#define SOUND_MIXER_WRITE_LOUD		MIXER_WRITE(SOUND_MIXER_LOUD)
912
913#define SOUND_MIXER_WRITE_RECSRC	MIXER_WRITE(SOUND_MIXER_RECSRC)
914
915typedef struct mixer_info
916{
917  char id[16];
918  char name[32];
919  int  modify_counter;
920  int fillers[10];
921} mixer_info;
922
923typedef struct _old_mixer_info /* Obsolete */
924{
925  char id[16];
926  char name[32];
927} _old_mixer_info;
928
929#define SOUND_MIXER_INFO		_SIOR ('M', 101, mixer_info)
930#define SOUND_OLD_MIXER_INFO		_SIOR ('M', 101, _old_mixer_info)
931
932/*
933 * A mechanism for accessing "proprietary" mixer features. This method
934 * permits passing 128 bytes of arbitrary data between a mixer application
935 * and the mixer driver. Interpretation of the record is defined by
936 * the particular mixer driver.
937 */
938typedef unsigned char mixer_record[128];
939
940#define SOUND_MIXER_ACCESS		_SIOWR('M', 102, mixer_record)
941
942/*
943 * Two ioctls for special souncard function
944 */
945#define SOUND_MIXER_AGC  _SIOWR('M', 103, int)
946#define SOUND_MIXER_3DSE  _SIOWR('M', 104, int)
947
948/*
949 * The SOUND_MIXER_PRIVATE# commands can be redefined by low level drivers.
950 * These features can be used when accessing device specific features.
951 */
952#define SOUND_MIXER_PRIVATE1		_SIOWR('M', 111, int)
953#define SOUND_MIXER_PRIVATE2		_SIOWR('M', 112, int)
954#define SOUND_MIXER_PRIVATE3		_SIOWR('M', 113, int)
955#define SOUND_MIXER_PRIVATE4		_SIOWR('M', 114, int)
956#define SOUND_MIXER_PRIVATE5		_SIOWR('M', 115, int)
957
958/*
959 * SOUND_MIXER_GETLEVELS and SOUND_MIXER_SETLEVELS calls can be used
960 * for querying current mixer settings from the driver and for loading
961 * default volume settings _prior_ activating the mixer (loading
962 * doesn't affect current state of the mixer hardware). These calls
963 * are for internal use only.
964 */
965
966typedef struct mixer_vol_table {
967  int num;	/* Index to volume table */
968  char name[32];
969  int levels[32];
970} mixer_vol_table;
971
972#define SOUND_MIXER_GETLEVELS		_SIOWR('M', 116, mixer_vol_table)
973#define SOUND_MIXER_SETLEVELS		_SIOWR('M', 117, mixer_vol_table)
974
975/*
976 * An ioctl for identifying the driver version. It will return value
977 * of the SOUND_VERSION macro used when compiling the driver.
978 * This call was introduced in OSS version 3.6 and it will not work
979 * with earlier versions (returns EINVAL).
980 */
981#define OSS_GETVERSION			_SIOR ('M', 118, int)
982
983/*
984 * Level 2 event types for /dev/sequencer
985 */
986
987/*
988 * The 4 most significant bits of byte 0 specify the class of
989 * the event:
990 *
991 *	0x8X = system level events,
992 *	0x9X = device/port specific events, event[1] = device/port,
993 *		The last 4 bits give the subtype:
994 *			0x02	= Channel event (event[3] = chn).
995 *			0x01	= note event (event[4] = note).
996 *			(0x01 is not used alone but always with bit 0x02).
997 *	       event[2] = MIDI message code (0x80=note off etc.)
998 *
999 */
1000
1001#define EV_SEQ_LOCAL		0x80
1002#define EV_TIMING		0x81
1003#define EV_CHN_COMMON		0x92
1004#define EV_CHN_VOICE		0x93
1005#define EV_SYSEX		0x94
1006/*
1007 * Event types 200 to 220 are reserved for application use.
1008 * These numbers will not be used by the driver.
1009 */
1010
1011/*
1012 * Events for event type EV_CHN_VOICE
1013 */
1014
1015#define MIDI_NOTEOFF		0x80
1016#define MIDI_NOTEON		0x90
1017#define MIDI_KEY_PRESSURE	0xA0
1018
1019/*
1020 * Events for event type EV_CHN_COMMON
1021 */
1022
1023#define MIDI_CTL_CHANGE		0xB0
1024#define MIDI_PGM_CHANGE		0xC0
1025#define MIDI_CHN_PRESSURE	0xD0
1026#define MIDI_PITCH_BEND		0xE0
1027
1028#define MIDI_SYSTEM_PREFIX	0xF0
1029
1030/*
1031 * Timer event types
1032 */
1033#define TMR_WAIT_REL		1	/* Time relative to the prev time */
1034#define TMR_WAIT_ABS		2	/* Absolute time since TMR_START */
1035#define TMR_STOP		3
1036#define TMR_START		4
1037#define TMR_CONTINUE		5
1038#define TMR_TEMPO		6
1039#define TMR_ECHO		8
1040#define TMR_CLOCK		9	/* MIDI clock */
1041#define TMR_SPP			10	/* Song position pointer */
1042#define TMR_TIMESIG		11	/* Time signature */
1043
1044/*
1045 *	Local event types
1046 */
1047#define LOCL_STARTAUDIO		1
1048
1049#if !defined(__KERNEL__) || defined(USE_SEQ_MACROS)
1050/*
1051 *	Some convenience macros to simplify programming of the
1052 *	/dev/sequencer interface
1053 *
1054 *	This is a legacy interface for applications written against
1055 *	the OSSlib-3.8 style interface. It is no longer possible
1056 *	to actually link against OSSlib with this header, but we
1057 *	still provide these macros for programs using them.
1058 *
1059 *	If you want to use OSSlib, it is recommended that you get
1060 *	the GPL version of OSS-4.x and build against that version
1061 *	of the header.
1062 *
1063 *	We redefine the extern keyword so that make headers_check
1064 *	does not complain about SEQ_USE_EXTBUF.
1065 */
1066#define SEQ_DECLAREBUF()		SEQ_USE_EXTBUF()
1067
1068void seqbuf_dump(void);	/* This function must be provided by programs */
1069
1070#define SEQ_PM_DEFINES int __foo_bar___
1071
1072#define SEQ_LOAD_GMINSTR(dev, instr)
1073#define SEQ_LOAD_GMDRUM(dev, drum)
1074
1075#define _SEQ_EXTERN extern
1076#define SEQ_USE_EXTBUF() \
1077		_SEQ_EXTERN unsigned char _seqbuf[]; \
1078		_SEQ_EXTERN int _seqbuflen; _SEQ_EXTERN int _seqbufptr
1079
1080#ifndef USE_SIMPLE_MACROS
1081/* Sample seqbuf_dump() implementation:
1082 *
1083 *	SEQ_DEFINEBUF (2048);	-- Defines a buffer for 2048 bytes
1084 *
1085 *	int seqfd;		-- The file descriptor for /dev/sequencer.
1086 *
1087 *	void
1088 *	seqbuf_dump ()
1089 *	{
1090 *	  if (_seqbufptr)
1091 *	    if (write (seqfd, _seqbuf, _seqbufptr) == -1)
1092 *	      {
1093 *		perror ("write /dev/sequencer");
1094 *		exit (-1);
1095 *	      }
1096 *	  _seqbufptr = 0;
1097 *	}
1098 */
1099
1100#define SEQ_DEFINEBUF(len)		unsigned char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0
1101#define _SEQ_NEEDBUF(len)		if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump()
1102#define _SEQ_ADVBUF(len)		_seqbufptr += len
1103#define SEQ_DUMPBUF			seqbuf_dump
1104#else
1105/*
1106 * This variation of the sequencer macros is used just to format one event
1107 * using fixed buffer.
1108 *
1109 * The program using the macro library must define the following macros before
1110 * using this library.
1111 *
1112 * #define _seqbuf 		 name of the buffer (unsigned char[])
1113 * #define _SEQ_ADVBUF(len)	 If the applic needs to know the exact
1114 *				 size of the event, this macro can be used.
1115 *				 Otherwise this must be defined as empty.
1116 * #define _seqbufptr		 Define the name of index variable or 0 if
1117 *				 not required.
1118 */
1119#define _SEQ_NEEDBUF(len)	/* empty */
1120#endif
1121
1122#define SEQ_VOLUME_MODE(dev, mode)	{_SEQ_NEEDBUF(8);\
1123					_seqbuf[_seqbufptr] = SEQ_EXTENDED;\
1124					_seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\
1125					_seqbuf[_seqbufptr+2] = (dev);\
1126					_seqbuf[_seqbufptr+3] = (mode);\
1127					_seqbuf[_seqbufptr+4] = 0;\
1128					_seqbuf[_seqbufptr+5] = 0;\
1129					_seqbuf[_seqbufptr+6] = 0;\
1130					_seqbuf[_seqbufptr+7] = 0;\
1131					_SEQ_ADVBUF(8);}
1132
1133/*
1134 * Midi voice messages
1135 */
1136
1137#define _CHN_VOICE(dev, event, chn, note, parm) \
1138					{_SEQ_NEEDBUF(8);\
1139					_seqbuf[_seqbufptr] = EV_CHN_VOICE;\
1140					_seqbuf[_seqbufptr+1] = (dev);\
1141					_seqbuf[_seqbufptr+2] = (event);\
1142					_seqbuf[_seqbufptr+3] = (chn);\
1143					_seqbuf[_seqbufptr+4] = (note);\
1144					_seqbuf[_seqbufptr+5] = (parm);\
1145					_seqbuf[_seqbufptr+6] = (0);\
1146					_seqbuf[_seqbufptr+7] = 0;\
1147					_SEQ_ADVBUF(8);}
1148
1149#define SEQ_START_NOTE(dev, chn, note, vol) \
1150		_CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol)
1151
1152#define SEQ_STOP_NOTE(dev, chn, note, vol) \
1153		_CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol)
1154
1155#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \
1156		_CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure)
1157
1158/*
1159 * Midi channel messages
1160 */
1161
1162#define _CHN_COMMON(dev, event, chn, p1, p2, w14) \
1163					{_SEQ_NEEDBUF(8);\
1164					_seqbuf[_seqbufptr] = EV_CHN_COMMON;\
1165					_seqbuf[_seqbufptr+1] = (dev);\
1166					_seqbuf[_seqbufptr+2] = (event);\
1167					_seqbuf[_seqbufptr+3] = (chn);\
1168					_seqbuf[_seqbufptr+4] = (p1);\
1169					_seqbuf[_seqbufptr+5] = (p2);\
1170					*(short *)&_seqbuf[_seqbufptr+6] = (w14);\
1171					_SEQ_ADVBUF(8);}
1172/*
1173 * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits
1174 * sending any MIDI bytes but it's absolutely not possible. Trying to do
1175 * so _will_ cause problems with MPU401 intelligent mode).
1176 *
1177 * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
1178 * sent by calling SEQ_SYSEX() several times (there must be no other events
1179 * between them). First sysex fragment must have 0xf0 in the first byte
1180 * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte
1181 * between these sysex start and end markers cannot be larger than 0x7f. Also
1182 * lengths of each fragments (except the last one) must be 6.
1183 *
1184 * Breaking the above rules may work with some MIDI ports but is likely to
1185 * cause fatal problems with some other devices (such as MPU401).
1186 */
1187#define SEQ_SYSEX(dev, buf, len) \
1188					{int ii, ll=(len); \
1189					 unsigned char *bufp=buf;\
1190					 if (ll>6)ll=6;\
1191					_SEQ_NEEDBUF(8);\
1192					_seqbuf[_seqbufptr] = EV_SYSEX;\
1193					_seqbuf[_seqbufptr+1] = (dev);\
1194					for(ii=0;ii<ll;ii++)\
1195					   _seqbuf[_seqbufptr+ii+2] = bufp[ii];\
1196					for(ii=ll;ii<6;ii++)\
1197					   _seqbuf[_seqbufptr+ii+2] = 0xff;\
1198					_SEQ_ADVBUF(8);}
1199
1200#define SEQ_CHN_PRESSURE(dev, chn, pressure) \
1201		_CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0)
1202
1203#define SEQ_SET_PATCH SEQ_PGM_CHANGE
1204#define SEQ_PGM_CHANGE(dev, chn, patch) \
1205		_CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0)
1206
1207#define SEQ_CONTROL(dev, chn, controller, value) \
1208		_CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value)
1209
1210#define SEQ_BENDER(dev, chn, value) \
1211		_CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value)
1212
1213
1214#define SEQ_V2_X_CONTROL(dev, voice, controller, value)	{_SEQ_NEEDBUF(8);\
1215					_seqbuf[_seqbufptr] = SEQ_EXTENDED;\
1216					_seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\
1217					_seqbuf[_seqbufptr+2] = (dev);\
1218					_seqbuf[_seqbufptr+3] = (voice);\
1219					_seqbuf[_seqbufptr+4] = (controller);\
1220					_seqbuf[_seqbufptr+5] = ((value)&0xff);\
1221					_seqbuf[_seqbufptr+6] = ((value>>8)&0xff);\
1222					_seqbuf[_seqbufptr+7] = 0;\
1223					_SEQ_ADVBUF(8);}
1224/*
1225 * The following 5 macros are incorrectly implemented and obsolete.
1226 * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead.
1227 */
1228#define SEQ_PITCHBEND(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value)
1229#define SEQ_BENDER_RANGE(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value)
1230#define SEQ_EXPRESSION(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128)
1231#define SEQ_MAIN_VOLUME(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100)
1232#define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
1233
1234/*
1235 * Timing and syncronization macros
1236 */
1237
1238#define _TIMER_EVENT(ev, parm)		{_SEQ_NEEDBUF(8);\
1239				 	_seqbuf[_seqbufptr+0] = EV_TIMING; \
1240				 	_seqbuf[_seqbufptr+1] = (ev); \
1241					_seqbuf[_seqbufptr+2] = 0;\
1242					_seqbuf[_seqbufptr+3] = 0;\
1243				 	*(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
1244					_SEQ_ADVBUF(8);}
1245
1246#define SEQ_START_TIMER()		_TIMER_EVENT(TMR_START, 0)
1247#define SEQ_STOP_TIMER()		_TIMER_EVENT(TMR_STOP, 0)
1248#define SEQ_CONTINUE_TIMER()		_TIMER_EVENT(TMR_CONTINUE, 0)
1249#define SEQ_WAIT_TIME(ticks)		_TIMER_EVENT(TMR_WAIT_ABS, ticks)
1250#define SEQ_DELTA_TIME(ticks)		_TIMER_EVENT(TMR_WAIT_REL, ticks)
1251#define SEQ_ECHO_BACK(key)		_TIMER_EVENT(TMR_ECHO, key)
1252#define SEQ_SET_TEMPO(value)		_TIMER_EVENT(TMR_TEMPO, value)
1253#define SEQ_SONGPOS(pos)		_TIMER_EVENT(TMR_SPP, pos)
1254#define SEQ_TIME_SIGNATURE(sig)		_TIMER_EVENT(TMR_TIMESIG, sig)
1255
1256/*
1257 * Local control events
1258 */
1259
1260#define _LOCAL_EVENT(ev, parm)		{_SEQ_NEEDBUF(8);\
1261				 	_seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
1262				 	_seqbuf[_seqbufptr+1] = (ev); \
1263					_seqbuf[_seqbufptr+2] = 0;\
1264					_seqbuf[_seqbufptr+3] = 0;\
1265				 	*(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
1266					_SEQ_ADVBUF(8);}
1267
1268#define SEQ_PLAYAUDIO(devmask)		_LOCAL_EVENT(LOCL_STARTAUDIO, devmask)
1269/*
1270 * Events for the level 1 interface only
1271 */
1272
1273#define SEQ_MIDIOUT(device, byte)	{_SEQ_NEEDBUF(4);\
1274					_seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\
1275					_seqbuf[_seqbufptr+1] = (byte);\
1276					_seqbuf[_seqbufptr+2] = (device);\
1277					_seqbuf[_seqbufptr+3] = 0;\
1278					_SEQ_ADVBUF(4);}
1279
1280/*
1281 * Patch loading.
1282 */
1283#define SEQ_WRPATCH(patchx, len) \
1284		{if (_seqbufptr) SEQ_DUMPBUF();\
1285		 if (write(seqfd, (char*)(patchx), len)==-1) \
1286		    perror("Write patch: /dev/sequencer");}
1287#define SEQ_WRPATCH2(patchx, len) \
1288		(SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len))
1289
1290#endif
1291#endif
1292