soundcard.h revision 300060
1139823Simp/*
263670Snsayer * soundcard.h
363670Snsayer */
463670Snsayer
563670Snsayer/*-
663670Snsayer * Copyright by Hannu Savolainen 1993 / 4Front Technologies 1993-2006
763670Snsayer * Modified for the new FreeBSD sound driver by Luigi Rizzo, 1997
863670Snsayer *
963670Snsayer * Redistribution and use in source and binary forms, with or without
1063670Snsayer * modification, are permitted provided that the following conditions
1163670Snsayer * are met:
1263670Snsayer * 1. Redistributions of source code must retain the above copyright
1363670Snsayer *    notice, this list of conditions and the following disclaimer.
1463670Snsayer * 2. Redistributions in binary form must reproduce the above
1563670Snsayer *    copyright notice, this list of conditions and the following
1663670Snsayer *    disclaimer in the documentation and/or other materials provided
1763670Snsayer *    with the distribution.
1863670Snsayer *
1963670Snsayer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
2063670Snsayer * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2163670Snsayer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
2263670Snsayer * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR
2363670Snsayer * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2463670Snsayer * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2563670Snsayer * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
2663670Snsayer * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2763670Snsayer * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2863670Snsayer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
2963670Snsayer * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3063670Snsayer * POSSIBILITY OF SUCH DAMAGE.
3163670Snsayer *
3263670Snsayer * $FreeBSD: stable/10/sys/sys/soundcard.h 300060 2016-05-17 15:18:01Z pfg $
3363670Snsayer */
3463670Snsayer
3563803Snsayer/*
3663670Snsayer * Unless coordinating changes with 4Front Technologies, do NOT make any
3763670Snsayer * modifications to ioctl commands, types, etc. that would break
3863670Snsayer * compatibility with the OSS API.
3963670Snsayer */
4063670Snsayer
4163670Snsayer#ifndef _SYS_SOUNDCARD_H_
42139207Sphk#define _SYS_SOUNDCARD_H_
4363670Snsayer /*
4463670Snsayer  * If you make modifications to this file, please contact me before
4563670Snsayer  * distributing the modified version. There is already enough
4663670Snsayer  * diversity in the world.
47129880Sphk  *
4863670Snsayer  * Regards,
4963670Snsayer  * Hannu Savolainen
50139207Sphk  * hannu@voxware.pp.fi
5163670Snsayer  *
5263670Snsayer  **********************************************************************
5363670Snsayer  * PS.	The Hacker's Guide to VoxWare available from
5463670Snsayer  *     nic.funet.fi:pub/Linux/ALPHA/sound. The file is
5563670Snsayer  *	snd-sdk-doc-0.1.ps.gz (gzipped postscript). It contains
5663670Snsayer  *	some useful information about programming with VoxWare.
5763670Snsayer  *	(NOTE! The pub/Linux/ALPHA/ directories are hidden. You have
5883043Sbrooks  *	to cd inside them before the files are accessible.)
5963670Snsayer  **********************************************************************
6063670Snsayer  */
6163670Snsayer
6263670Snsayer/*
6363670Snsayer * SOUND_VERSION is only used by the voxware driver. Hopefully apps
6463670Snsayer * should not depend on it, but rather look at the capabilities
6563670Snsayer * of the driver in the kernel!
6663670Snsayer */
6763670Snsayer#define SOUND_VERSION  301
6863670Snsayer#define VOXWARE		/* does this have any use ? */
6963670Snsayer
7063670Snsayer/*
7163670Snsayer * Supported card ID numbers (Should be somewhere else? We keep
7263670Snsayer * them here just for compativility with the old driver, but these
7363670Snsayer * constants are of little or no use).
7463670Snsayer */
7563670Snsayer
7663670Snsayer#define SNDCARD_ADLIB          1
7783043Sbrooks#define SNDCARD_SB             2
78126077Sphk#define SNDCARD_PAS            3
7963670Snsayer#define SNDCARD_GUS            4
8063670Snsayer#define SNDCARD_MPU401         5
81111742Sdes#define SNDCARD_SB16           6
8263670Snsayer#define SNDCARD_SB16MIDI       7
8363670Snsayer#define SNDCARD_UART6850       8
84130585Sphk#define SNDCARD_GUS16          9
85130585Sphk#define SNDCARD_MSS            10
8663670Snsayer#define SNDCARD_PSS            11
8763670Snsayer#define SNDCARD_SSCAPE         12
8893084Sbde#define SNDCARD_PSS_MPU        13
8993084Sbde#define SNDCARD_PSS_MSS        14
9093084Sbde#define SNDCARD_SSCAPE_MSS     15
9163670Snsayer#define SNDCARD_TRXPRO         16
9263670Snsayer#define SNDCARD_TRXPRO_SB      17
9363670Snsayer#define SNDCARD_TRXPRO_MPU     18
9463670Snsayer#define SNDCARD_MAD16          19
9563670Snsayer#define SNDCARD_MAD16_MPU      20
9663670Snsayer#define SNDCARD_CS4232         21
9763670Snsayer#define SNDCARD_CS4232_MPU     22
9863670Snsayer#define SNDCARD_MAUI           23
9963670Snsayer#define SNDCARD_PSEUDO_MSS     24
10063670Snsayer#define SNDCARD_AWE32          25
101126080Sphk#define SNDCARD_NSS            26
102126188Sbde#define SNDCARD_UART16550      27
103111815Sphk#define SNDCARD_OPL            28
104111815Sphk
105111815Sphk#include <sys/types.h>
106111815Sphk#include <machine/endian.h>
107111815Sphk#ifndef _IOWR
108111815Sphk#include <sys/ioccom.h>
109111815Sphk#endif  /* !_IOWR */
11063670Snsayer
11163670Snsayer/*
112127003Srwatson * The first part of this file contains the new FreeBSD sound ioctl
113127003Srwatson * interface. Tries to minimize the number of different ioctls, and
114127003Srwatson * to be reasonably general.
115127003Srwatson *
116127003Srwatson * 970821: some of the new calls have not been implemented yet.
117127003Srwatson */
11883043Sbrooks
119144979Smdodd/*
12083043Sbrooks * the following three calls extend the generic file descriptor
121126077Sphk * interface. AIONWRITE is the dual of FIONREAD, i.e. returns the max
12263670Snsayer * number of bytes for a write operation to be non-blocking.
12363670Snsayer *
12463670Snsayer * AIOGSIZE/AIOSSIZE are used to change the behaviour of the device,
12563670Snsayer * from a character device (default) to a block device. In block mode,
126144979Smdodd * (not to be confused with blocking mode) the main difference for the
127144979Smdodd * application is that select() will return only when a complete
128144979Smdodd * block can be read/written to the device, whereas in character mode
129144979Smdodd * select will return true when one byte can be exchanged. For audio
130144979Smdodd * devices, character mode makes select almost useless since one byte
131144979Smdodd * will always be ready by the next sample time (which is often only a
132144979Smdodd * handful of microseconds away).
133144979Smdodd * Use a size of 0 or 1 to return to character mode.
13463670Snsayer */
13563670Snsayer#define	AIONWRITE   _IOR('A', 10, int)   /* get # bytes to write */
13663670Snsayerstruct snd_size {
13763670Snsayer    int play_size;
13863670Snsayer    int rec_size;
13963670Snsayer};
14063670Snsayer#define	AIOGSIZE    _IOR('A', 11, struct snd_size)/* read current blocksize */
14163670Snsayer#define	AIOSSIZE    _IOWR('A', 11, struct snd_size)  /* sets blocksize */
14263670Snsayer
14363670Snsayer/*
14463670Snsayer * The following constants define supported audio formats. The
14563670Snsayer * encoding follows voxware conventions, i.e. 1 bit for each supported
14663670Snsayer * format. We extend it by using bit 31 (RO) to indicate full-duplex
14783043Sbrooks * capability, and bit 29 (RO) to indicate that the card supports/
14883043Sbrooks * needs different formats on capture & playback channels.
14983043Sbrooks * Bit 29 (RW) is used to indicate/ask stereo.
150126077Sphk *
15163670Snsayer * The number of bits required to store the sample is:
15263670Snsayer *  o  4 bits for the IDA ADPCM format,
15363670Snsayer *  o  8 bits for 8-bit formats, mu-law and A-law,
15463670Snsayer *  o  16 bits for the 16-bit formats, and
15583043Sbrooks *  o  32 bits for the 24/32-bit formats.
15683043Sbrooks *  o  undefined for the MPEG audio format.
157127003Srwatson */
15883043Sbrooks
15983043Sbrooks#define AFMT_QUERY	0x00000000	/* Return current format */
160126845Sphk#define AFMT_MU_LAW	0x00000001	/* Logarithmic mu-law */
16171602Sphk#define AFMT_A_LAW	0x00000002	/* Logarithmic A-law */
162127003Srwatson#define AFMT_IMA_ADPCM	0x00000004	/* A 4:1 compressed format where 16-bit
163127170Srwatson					 * squence represented using the
164127003Srwatson					 * the average 4 bits per sample */
165126077Sphk#define AFMT_U8		0x00000008	/* Unsigned 8-bit */
166127003Srwatson#define AFMT_S16_LE	0x00000010	/* Little endian signed 16-bit */
16783043Sbrooks#define AFMT_S16_BE	0x00000020	/* Big endian signed 16-bit */
16863670Snsayer#define AFMT_S8		0x00000040	/* Signed 8-bit */
16983043Sbrooks#define AFMT_U16_LE	0x00000080	/* Little endian unsigned 16-bit */
170127003Srwatson#define AFMT_U16_BE	0x00000100	/* Big endian unsigned 16-bit */
171127003Srwatson#define AFMT_MPEG	0x00000200	/* MPEG MP2/MP3 audio */
172127003Srwatson#define AFMT_AC3	0x00000400	/* Dolby Digital AC3 */
173127003Srwatson
174127003Srwatson/*
175127003Srwatson * 32-bit formats below used for 24-bit audio data where the data is stored
176127003Srwatson * in the 24 most significant bits and the least significant bits are not used
177127098Srwatson * (should be set to 0).
178127003Srwatson */
179127098Srwatson#define AFMT_S32_LE	0x00001000	/* Little endian signed 32-bit */
180127003Srwatson#define AFMT_S32_BE	0x00002000	/* Big endian signed 32-bit */
18183043Sbrooks#define AFMT_U32_LE	0x00004000	/* Little endian unsigned 32-bit */
182127003Srwatson#define AFMT_U32_BE	0x00008000	/* Big endian unsigned 32-bit */
183127098Srwatson#define AFMT_S24_LE	0x00010000	/* Little endian signed 24-bit */
184127003Srwatson#define AFMT_S24_BE	0x00020000	/* Big endian signed 24-bit */
185127003Srwatson#define AFMT_U24_LE	0x00040000	/* Little endian unsigned 24-bit */
18683043Sbrooks#define AFMT_U24_BE	0x00080000	/* Big endian unsigned 24-bit */
18771602Sphk
18863670Snsayer/* Machine dependent AFMT_* definitions. */
189127003Srwatson#if BYTE_ORDER == LITTLE_ENDIAN
19083043Sbrooks#define AFMT_S16_NE	AFMT_S16_LE
19183043Sbrooks#define AFMT_S24_NE	AFMT_S24_LE
192127003Srwatson#define AFMT_S32_NE	AFMT_S32_LE
19383043Sbrooks#define AFMT_U16_NE	AFMT_U16_LE
19483043Sbrooks#define AFMT_U24_NE	AFMT_U24_LE
19583043Sbrooks#define AFMT_U32_NE	AFMT_U32_LE
196121816Sbrooks#define AFMT_S16_OE	AFMT_S16_BE
19783043Sbrooks#define AFMT_S24_OE	AFMT_S24_BE
198127098Srwatson#define AFMT_S32_OE	AFMT_S32_BE
199121816Sbrooks#define AFMT_U16_OE	AFMT_U16_BE
200121816Sbrooks#define AFMT_U24_OE	AFMT_U24_BE
20183043Sbrooks#define AFMT_U32_OE	AFMT_U32_BE
202126077Sphk#else
20363670Snsayer#define AFMT_S16_OE	AFMT_S16_LE
204106939Ssam#define AFMT_S24_OE	AFMT_S24_LE
20563670Snsayer#define AFMT_S32_OE	AFMT_S32_LE
20663670Snsayer#define AFMT_U16_OE	AFMT_U16_LE
207127098Srwatson#define AFMT_U24_OE	AFMT_U24_LE
20893752Sluigi#define AFMT_U32_OE	AFMT_U32_LE
209127003Srwatson#define AFMT_S16_NE	AFMT_S16_BE
21083043Sbrooks#define AFMT_S24_NE	AFMT_S24_BE
211127003Srwatson#define AFMT_S32_NE	AFMT_S32_BE
212126077Sphk#define AFMT_U16_NE	AFMT_U16_BE
21363670Snsayer#define AFMT_U24_NE	AFMT_U24_BE
214135354Srwatson#define AFMT_U32_NE	AFMT_U32_BE
215135354Srwatson#endif
21683043Sbrooks
21763670Snsayer#define AFMT_STEREO	0x10000000	/* can do/want stereo	*/
21863670Snsayer
21963670Snsayer/*
22063670Snsayer * the following are really capabilities
22163670Snsayer */
22263670Snsayer#define AFMT_WEIRD	0x20000000	/* weird hardware...	*/
22363670Snsayer    /*
22463670Snsayer     * AFMT_WEIRD reports that the hardware might need to operate
22563670Snsayer     * with different formats in the playback and capture
22663670Snsayer     * channels when operating in full duplex.
22771602Sphk     * As an example, SoundBlaster16 cards only support U8 in one
22871602Sphk     * direction and S16 in the other one, and applications should
22971602Sphk     * be aware of this limitation.
23071602Sphk     */
23171602Sphk#define AFMT_FULLDUPLEX	0x80000000	/* can do full duplex	*/
23271602Sphk
23371602Sphk/*
23471602Sphk * The following structure is used to get/set format and sampling rate.
23571602Sphk * While it would be better to have things such as stereo, bits per
236130585Sphk * sample, endiannes, etc split in different variables, it turns out
23771602Sphk * that formats are not that many, and not all combinations are possible.
238126077Sphk * So we followed the Voxware approach of associating one bit to each
239126077Sphk * format.
24083043Sbrooks */
24171602Sphk
242130640Sphktypedef struct _snd_chan_param {
24371602Sphk    u_long	play_rate;	/* sampling rate			*/
24471602Sphk    u_long	rec_rate;	/* sampling rate			*/
245126077Sphk    u_long	play_format;	/* everything describing the format	*/
246126077Sphk    u_long	rec_format;	/* everything describing the format	*/
247126077Sphk} snd_chan_param;
248126077Sphk#define	AIOGFMT    _IOR('f', 12, snd_chan_param)   /* get format */
249126077Sphk#define	AIOSFMT    _IOWR('f', 12, snd_chan_param)  /* sets format */
250126077Sphk
251126077Sphk/*
252126077Sphk * The following structure is used to get/set the mixer setting.
253126077Sphk * Up to 32 mixers are supported, each one with up to 32 channels.
254126077Sphk */
255126077Sphktypedef struct _snd_mix_param {
256126077Sphk    u_char	subdev;	/* which output				*/
257126077Sphk    u_char	line;	/* which input				*/
25883043Sbrooks    u_char	left,right; /* volumes, 0..255, 0 = mute	*/
25971602Sphk} snd_mix_param ;
260126077Sphk
261126077Sphk/* XXX AIOGMIX, AIOSMIX not implemented yet */
262126077Sphk#define AIOGMIX	_IOWR('A', 13, snd_mix_param)	/* return mixer status */
263126796Sphk#define AIOSMIX	_IOWR('A', 14, snd_mix_param)	/* sets mixer status   */
264126077Sphk
265144389Sphk/*
266144389Sphk * channel specifiers used in AIOSTOP and AIOSYNC
267126077Sphk */
268144389Sphk#define	AIOSYNC_PLAY	0x1	/* play chan */
26971602Sphk#define	AIOSYNC_CAPTURE	0x2	/* capture chan */
27071602Sphk/* AIOSTOP stop & flush a channel, returns the residual count */
27171602Sphk#define	AIOSTOP	_IOWR ('A', 15, int)
27271602Sphk
27371602Sphk/* alternate method used to notify the sync condition */
27463670Snsayer#define	AIOSYNC_SIGNAL	0x100
27563670Snsayer#define	AIOSYNC_SELECT	0x200
27663670Snsayer
27763670Snsayer/* what the 'pos' field refers to */
27863670Snsayer#define AIOSYNC_READY	0x400
27963670Snsayer#define AIOSYNC_FREE	0x800
280130585Sphk
28163670Snsayertypedef struct _snd_sync_parm {
28263670Snsayer    long chan ; /* play or capture channel, plus modifier */
28363670Snsayer    long pos;
28463670Snsayer} snd_sync_parm;
28563803Snsayer#define	AIOSYNC	_IOWR ('A', 15, snd_sync_parm)	/* misc. synchronization */
28663670Snsayer
28763670Snsayer/*
288126077Sphk * The following is used to return device capabilities. If the structure
289126077Sphk * passed to the ioctl is zeroed, default values are returned for rate
29063670Snsayer * and formats, a bitmap of available mixers is returned, and values
291111119Simp * (inputs, different levels) for the first one are returned.
292127098Srwatson *
293127003Srwatson * If  formats, mixers, inputs are instantiated, then detailed info
29483043Sbrooks * are returned depending on the call.
295127003Srwatson */
29663670Snsayertypedef struct _snd_capabilities {
297126796Sphk    u_long	rate_min, rate_max;	/* min-max sampling rate */
29883043Sbrooks    u_long	formats;
29963670Snsayer    u_long	bufsize; /* DMA buffer size */
300126796Sphk    u_long	mixers; /* bitmap of available mixers */
30163670Snsayer    u_long	inputs; /* bitmap of available inputs (per mixer) */
30263803Snsayer    u_short	left, right;	/* how many levels are supported */
30383043Sbrooks} snd_capabilities;
30463670Snsayer#define AIOGCAP	_IOWR('A', 15, snd_capabilities)	/* get capabilities */
30563670Snsayer
306126796Sphk/*
307126796Sphk * here is the old (Voxware) ioctl interface
30883043Sbrooks */
30983043Sbrooks
31063670Snsayer/*
31163670Snsayer * IOCTL Commands for /dev/sequencer
31263670Snsayer */
31363670Snsayer
31463670Snsayer#define SNDCTL_SEQ_RESET	_IO  ('Q', 0)
31563670Snsayer#define SNDCTL_SEQ_SYNC		_IO  ('Q', 1)
316111742Sdes#define SNDCTL_SYNTH_INFO	_IOWR('Q', 2, struct synth_info)
31763670Snsayer#define SNDCTL_SEQ_CTRLRATE	_IOWR('Q', 3, int) /* Set/get timer res.(hz) */
31863670Snsayer#define SNDCTL_SEQ_GETOUTCOUNT	_IOR ('Q', 4, int)
319121816Sbrooks#define SNDCTL_SEQ_GETINCOUNT	_IOR ('Q', 5, int)
32063670Snsayer#define SNDCTL_SEQ_PERCMODE	_IOW ('Q', 6, int)
32163670Snsayer#define SNDCTL_FM_LOAD_INSTR	_IOW ('Q', 7, struct sbi_instrument)	/* Valid for FM only */
32263670Snsayer#define SNDCTL_SEQ_TESTMIDI	_IOW ('Q', 8, int)
32363670Snsayer#define SNDCTL_SEQ_RESETSAMPLES	_IOW ('Q', 9, int)
32463670Snsayer#define SNDCTL_SEQ_NRSYNTHS	_IOR ('Q',10, int)
32563670Snsayer#define SNDCTL_SEQ_NRMIDIS	_IOR ('Q',11, int)
32663670Snsayer#define SNDCTL_MIDI_INFO	_IOWR('Q',12, struct midi_info)
32783043Sbrooks#define SNDCTL_SEQ_THRESHOLD	_IOW ('Q',13, int)
328126077Sphk#define SNDCTL_SEQ_TRESHOLD	SNDCTL_SEQ_THRESHOLD	/* there was once a typo */
32983043Sbrooks#define SNDCTL_SYNTH_MEMAVL	_IOWR('Q',14, int) /* in=dev#, out=memsize */
33063803Snsayer#define SNDCTL_FM_4OP_ENABLE	_IOW ('Q',15, int) /* in=dev# */
331106939Ssam#define SNDCTL_PMGR_ACCESS	_IOWR('Q',16, struct patmgr_info)
33263803Snsayer#define SNDCTL_SEQ_PANIC	_IO  ('Q',17)
33363670Snsayer#define SNDCTL_SEQ_OUTOFBAND	_IOW ('Q',18, struct seq_event_rec)
334127098Srwatson#define SNDCTL_SEQ_GETTIME	_IOR ('Q',19, int)
33563803Snsayer
336127098Srwatsonstruct seq_event_rec {
33763803Snsayer	u_char arr[8];
338121816Sbrooks};
339121816Sbrooks
34063670Snsayer#define SNDCTL_TMR_TIMEBASE	_IOWR('T', 1, int)
34163670Snsayer#define SNDCTL_TMR_START	_IO  ('T', 2)
34263670Snsayer#define SNDCTL_TMR_STOP		_IO  ('T', 3)
34363670Snsayer#define SNDCTL_TMR_CONTINUE	_IO  ('T', 4)
344111742Sdes#define SNDCTL_TMR_TEMPO	_IOWR('T', 5, int)
34563670Snsayer#define SNDCTL_TMR_SOURCE	_IOWR('T', 6, int)
34663670Snsayer#   define TMR_INTERNAL		0x00000001
34763670Snsayer#   define TMR_EXTERNAL		0x00000002
34863670Snsayer#	define TMR_MODE_MIDI	0x00000010
34983366Sjulian#	define TMR_MODE_FSK	0x00000020
350130585Sphk#	define TMR_MODE_CLS	0x00000040
35163670Snsayer#	define TMR_MODE_SMPTE	0x00000080
35263670Snsayer#define SNDCTL_TMR_METRONOME	_IOW ('T', 7, int)
35383366Sjulian#define SNDCTL_TMR_SELECT	_IOW ('T', 8, int)
35463670Snsayer
35563670Snsayer/*
356133460Semax *	Endian aware patch key generation algorithm.
357144979Smdodd */
35863670Snsayer
359144979Smdodd#if defined(_AIX) || defined(AIX)
360144979Smdodd#  define _PATCHKEY(id) (0xfd00|id)
36163670Snsayer#else
362126796Sphk#  define _PATCHKEY(id) ((id<<8)|0xfd)
363126796Sphk#endif
36483043Sbrooks
365127165Srwatson/*
366127165Srwatson *	Sample loading mechanism for internal synthesizers (/dev/sequencer)
367127165Srwatson *	The following patch_info structure has been designed to support
368127165Srwatson *	Gravis UltraSound. It tries to be universal format for uploading
369127165Srwatson *	sample based patches but is probably too limited.
37063670Snsayer */
37163670Snsayer
37263670Snsayerstruct patch_info {
37363670Snsayer/*		u_short key;		 Use GUS_PATCH here */
37463670Snsayer	short key;		 /* Use GUS_PATCH here */
37563670Snsayer#define GUS_PATCH	_PATCHKEY(0x04)
376127165Srwatson#define OBSOLETE_GUS_PATCH	_PATCHKEY(0x02)
377127165Srwatson
378127165Srwatson	short device_no;	/* Synthesizer number */
379127165Srwatson	short instr_no;		/* Midi pgm# */
380127165Srwatson
38163670Snsayer	u_long mode;
38263861Snsayer/*
38383366Sjulian * The least significant byte has the same format than the GUS .PAT
38463670Snsayer * files
385133460Semax */
386127098Srwatson#define WAVE_16_BITS	0x01	/* bit 0 = 8 or 16 bit wave data. */
38763670Snsayer#define WAVE_UNSIGNED	0x02	/* bit 1 = Signed - Unsigned data. */
388133460Semax#define WAVE_LOOPING	0x04	/* bit 2 = looping enabled-1. */
389133460Semax#define WAVE_BIDIR_LOOP	0x08	/* bit 3 = Set is bidirectional looping. */
390133460Semax#define WAVE_LOOP_BACK	0x10	/* bit 4 = Set is looping backward. */
391133460Semax#define WAVE_SUSTAIN_ON	0x20	/* bit 5 = Turn sustaining on. (Env. pts. 3)*/
39263670Snsayer#define WAVE_ENVELOPES	0x40	/* bit 6 = Enable envelopes - 1 */
393133460Semax				/* 	(use the env_rate/env_offs fields). */
394133460Semax/* Linux specific bits */
39563670Snsayer#define WAVE_VIBRATO	0x00010000	/* The vibrato info is valid */
39663670Snsayer#define WAVE_TREMOLO	0x00020000	/* The tremolo info is valid */
39763670Snsayer#define WAVE_SCALE	0x00040000	/* The scaling info is valid */
39863670Snsayer/* Other bits must be zeroed */
39963670Snsayer
40063670Snsayer	long len;	/* Size of the wave data in bytes */
40163670Snsayer	long loop_start, loop_end; /* Byte offsets from the beginning */
40263670Snsayer
40363670Snsayer/*
40463670Snsayer * The base_freq and base_note fields are used when computing the
40583366Sjulian * playback speed for a note. The base_note defines the tone frequency
406130585Sphk * which is heard if the sample is played using the base_freq as the
40763670Snsayer * playback speed.
40863670Snsayer *
40983366Sjulian * The low_note and high_note fields define the minimum and maximum note
41063670Snsayer * frequencies for which this sample is valid. It is possible to define
41163670Snsayer * more than one samples for an instrument number at the same time. The
41263670Snsayer * low_note and high_note fields are used to select the most suitable one.
413126077Sphk *
41463670Snsayer * The fields base_note, high_note and low_note should contain
41563670Snsayer * the note frequency multiplied by 1000. For example value for the
41683043Sbrooks * middle A is 440*1000.
41763670Snsayer */
41863803Snsayer
41963803Snsayer	u_int base_freq;
42063803Snsayer	u_long base_note;
42163803Snsayer	u_long high_note;
42263803Snsayer	u_long low_note;
423127098Srwatson	int panning;	/* -128=left, 127=right */
42463803Snsayer	int detuning;
425127098Srwatson
42663670Snsayer/*	New fields introduced in version 1.99.5	*/
42763670Snsayer
42863670Snsayer       /* Envelope. Enabled by mode bit WAVE_ENVELOPES	*/
42963670Snsayer	u_char	env_rate[ 6 ];	 /* GUS HW ramping rate */
43063670Snsayer	u_char	env_offset[ 6 ]; /* 255 == 100% */
43163670Snsayer
432127098Srwatson	/*
43363803Snsayer	 * The tremolo, vibrato and scale info are not supported yet.
43463670Snsayer	 * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or
43563670Snsayer	 * WAVE_SCALE
43663670Snsayer	 */
43763670Snsayer
438111742Sdes	u_char	tremolo_sweep;
43963670Snsayer	u_char	tremolo_rate;
440111742Sdes	u_char	tremolo_depth;
44163670Snsayer
442111742Sdes	u_char	vibrato_sweep;
44363670Snsayer	u_char	vibrato_rate;
44463670Snsayer	u_char	vibrato_depth;
44563670Snsayer
44663670Snsayer	int		scale_frequency;
44763670Snsayer	u_int	scale_factor;		/* from 0 to 2048 or 0 to 2 */
44863670Snsayer
44963670Snsayer	int		volume;
450127098Srwatson	int		spare[4];
451127098Srwatson	char data[1];	/* The waveform data starts here */
45263670Snsayer};
45396122Salfred
454122352Stanimurastruct sysex_info {
45563670Snsayer	short key;		/* Use GUS_PATCH here */
456127098Srwatson#define SYSEX_PATCH	_PATCHKEY(0x05)
45763670Snsayer#define MAUI_PATCH	_PATCHKEY(0x06)
45863670Snsayer	short device_no;	/* Synthesizer number */
459127098Srwatson	long len;	/* Size of the sysex data in bytes */
46063670Snsayer	u_char data[1];	/* Sysex data starts here */
461121816Sbrooks};
462121816Sbrooks
46363670Snsayer/*
46463670Snsayer * Patch management interface (/dev/sequencer, /dev/patmgr#)
46563670Snsayer * Don't use these calls if you want to maintain compatibility with
46663670Snsayer * the future versions of the driver.
46763670Snsayer */
46863670Snsayer
46963670Snsayer#define PS_NO_PATCHES		0	/* No patch support on device */
47063670Snsayer#define	PS_MGR_NOT_OK		1	/* Plain patch support (no mgr) */
47163670Snsayer#define	PS_MGR_OK		2	/* Patch manager supported */
47263670Snsayer#define	PS_MANAGED		3	/* Patch manager running */
47363670Snsayer
47463670Snsayer#define SNDCTL_PMGR_IFACE		_IOWR('P', 1, struct patmgr_info)
47563670Snsayer
47663670Snsayer/*
47763670Snsayer * The patmgr_info is a fixed size structure which is used for two
47863670Snsayer * different purposes. The intended use is for communication between
47963670Snsayer * the application using /dev/sequencer and the patch manager daemon
480121816Sbrooks * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)).
48163670Snsayer *
48263670Snsayer * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows
48363670Snsayer * a patch manager daemon to read and write device parameters. This
48463670Snsayer * ioctl available through /dev/sequencer also. Avoid using it since it's
48563670Snsayer * extremely hardware dependent. In addition access trough /dev/sequencer
48663670Snsayer * may confuse the patch manager daemon.
48763670Snsayer */
48863670Snsayer
48963670Snsayerstruct patmgr_info {	/* Note! size must be < 4k since kmalloc() is used */
49063670Snsayer	  u_long key;	/* Don't worry. Reserved for communication
49163670Snsayer	  			   between the patch manager and the driver. */
49263670Snsayer#define PM_K_EVENT		1 /* Event from the /dev/sequencer driver */
49363670Snsayer#define PM_K_COMMAND		2 /* Request from an application */
49463670Snsayer#define PM_K_RESPONSE		3 /* From patmgr to application */
495105228Sphk#define PM_ERROR		4 /* Error returned by the patmgr */
49663670Snsayer	  int device;
49763670Snsayer	  int command;
49863670Snsayer
49963670Snsayer/*
50063670Snsayer * Commands 0x000 to 0xfff reserved for patch manager programs
501111742Sdes */
50263670Snsayer#define PM_GET_DEVTYPE	1	/* Returns type of the patch mgr interface of dev */
50363670Snsayer#define		PMTYPE_FM2	1	/* 2 OP fm */
50463670Snsayer#define		PMTYPE_FM4	2	/* Mixed 4 or 2 op FM (OPL-3) */
50563670Snsayer#define		PMTYPE_WAVE	3	/* Wave table synthesizer (GUS) */
50663670Snsayer#define PM_GET_NRPGM	2	/* Returns max # of midi programs in parm1 */
50763670Snsayer#define PM_GET_PGMMAP	3	/* Returns map of loaded midi programs in data8 */
50863670Snsayer#define PM_GET_PGM_PATCHES 4	/* Return list of patches of a program (parm1) */
50983043Sbrooks#define PM_GET_PATCH	5	/* Return patch header of patch parm1 */
51063670Snsayer#define PM_SET_PATCH	6	/* Set patch header of patch parm1 */
51163670Snsayer#define PM_READ_PATCH	7	/* Read patch (wave) data */
51263670Snsayer#define PM_WRITE_PATCH	8	/* Write patch (wave) data */
51363670Snsayer
51463670Snsayer/*
515127098Srwatson * Commands 0x1000 to 0xffff are for communication between the patch manager
51663670Snsayer * and the client
51763670Snsayer */
51863670Snsayer#define _PM_LOAD_PATCH	0x100
51963670Snsayer
520127098Srwatson/*
52163670Snsayer * Commands above 0xffff reserved for device specific use
52283043Sbrooks */
52363670Snsayer
52463670Snsayer	long parm1;
525106939Ssam	long parm2;
526106939Ssam	long parm3;
527106939Ssam
528106939Ssam	union {
52963670Snsayer		u_char data8[4000];
53063670Snsayer		u_short data16[2000];
53163670Snsayer		u_long data32[1000];
53263670Snsayer		struct patch_info patch;
53363670Snsayer	} data;
53463670Snsayer};
53563670Snsayer
536111742Sdes/*
537111742Sdes * When a patch manager daemon is present, it will be informed by the
53863670Snsayer * driver when something important happens. For example when the
53963670Snsayer * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is
54063670Snsayer * returned. The command field contains the event type:
54163670Snsayer */
54263670Snsayer#define PM_E_OPENED		1	/* /dev/sequencer opened */
54363670Snsayer#define PM_E_CLOSED		2	/* /dev/sequencer closed */
54463670Snsayer#define PM_E_PATCH_RESET	3	/* SNDCTL_RESETSAMPLES called */
54563670Snsayer#define PM_E_PATCH_LOADED	4	/* A patch has been loaded by appl */
54663670Snsayer
547121816Sbrooks/*
54863670Snsayer * /dev/sequencer input events.
54963803Snsayer *
55063803Snsayer * The data written to the /dev/sequencer is a stream of events. Events
55163803Snsayer * are records of 4 or 8 bytes. The first byte defines the size.
55263803Snsayer * Any number of events can be written with a write call. There
55363803Snsayer * is a set of macros for sending these events. Use these macros if you
554127098Srwatson * want to maximize portability of your program.
555111742Sdes *
55663803Snsayer * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events.
55763670Snsayer * (All input events are currently 4 bytes long. Be prepared to support
55863670Snsayer * 8 byte events also. If you receive any event having first byte >= 128,
559127098Srwatson * it's a 8 byte event.
560127098Srwatson *
561127098Srwatson * The events are documented at the end of this file.
562121816Sbrooks *
563121816Sbrooks * Normal events (4 bytes)
56463670Snsayer * There is also a 8 byte version of most of the 4 byte events. The
56563670Snsayer * 8 byte one is recommended.
56663670Snsayer */
56763670Snsayer#define SEQ_NOTEOFF		0
56863670Snsayer#define SEQ_FMNOTEOFF		SEQ_NOTEOFF	/* Just old name */
56963670Snsayer#define SEQ_NOTEON		1
57063670Snsayer#define	SEQ_FMNOTEON		SEQ_NOTEON
57163670Snsayer#define SEQ_WAIT		TMR_WAIT_ABS
57263670Snsayer#define SEQ_PGMCHANGE		3
57363670Snsayer#define SEQ_FMPGMCHANGE		SEQ_PGMCHANGE
57463670Snsayer#define SEQ_SYNCTIMER		TMR_START
57563670Snsayer#define SEQ_MIDIPUTC		5
576127098Srwatson#define SEQ_DRUMON		6	/*** OBSOLETE ***/
57763670Snsayer#define SEQ_DRUMOFF		7	/*** OBSOLETE ***/
57863670Snsayer#define SEQ_ECHO		TMR_ECHO	/* For synching programs with output */
57963670Snsayer#define SEQ_AFTERTOUCH		9
58063670Snsayer#define SEQ_CONTROLLER		10
58163670Snsayer
582127098Srwatson/*
58363670Snsayer *	Midi controller numbers
58463670Snsayer *
585111748Sdes * Controllers 0 to 31 (0x00 to 0x1f) and 32 to 63 (0x20 to 0x3f)
58663670Snsayer * are continuous controllers.
58763670Snsayer * In the MIDI 1.0 these controllers are sent using two messages.
588127098Srwatson * Controller numbers 0 to 31 are used to send the MSB and the
589127098Srwatson * controller numbers 32 to 63 are for the LSB. Note that just 7 bits
59095883Salfred * are used in MIDI bytes.
591127098Srwatson */
592127098Srwatson
59363670Snsayer#define	CTL_BANK_SELECT		0x00
594122352Stanimura#define	CTL_MODWHEEL		0x01
59563670Snsayer#define CTL_BREATH		0x02
59663670Snsayer/*	undefined		0x03 */
59763670Snsayer#define CTL_FOOT		0x04
59863670Snsayer#define CTL_PORTAMENTO_TIME	0x05
59963670Snsayer#define CTL_DATA_ENTRY		0x06
60063670Snsayer#define CTL_MAIN_VOLUME		0x07
60163670Snsayer#define CTL_BALANCE		0x08
60263670Snsayer/*	undefined		0x09 */
60363670Snsayer#define CTL_PAN			0x0a
60463670Snsayer#define CTL_EXPRESSION		0x0b
60563670Snsayer/*	undefined		0x0c - 0x0f */
60663670Snsayer#define CTL_GENERAL_PURPOSE1	0x10
60763670Snsayer#define CTL_GENERAL_PURPOSE2	0x11
60863670Snsayer#define CTL_GENERAL_PURPOSE3	0x12
60983366Sjulian#define CTL_GENERAL_PURPOSE4	0x13
610130585Sphk/*	undefined		0x14 - 0x1f */
61163670Snsayer
61263670Snsayer/*	undefined		0x20 */
61363670Snsayer
61483366Sjulian/*
61563670Snsayer * The controller numbers 0x21 to 0x3f are reserved for the
61663670Snsayer * least significant bytes of the controllers 0x00 to 0x1f.
61763670Snsayer * These controllers are not recognised by the driver.
618111742Sdes *
61963670Snsayer * Controllers 64 to 69 (0x40 to 0x45) are on/off switches.
620102052Ssobomax * 0=OFF and 127=ON (intermediate values are possible)
62163670Snsayer */
62263670Snsayer#define CTL_DAMPER_PEDAL	0x40
623111742Sdes#define CTL_SUSTAIN		CTL_DAMPER_PEDAL	/* Alias */
62463670Snsayer#define CTL_HOLD		CTL_DAMPER_PEDAL	/* Alias */
625111742Sdes#define CTL_PORTAMENTO		0x41
626111742Sdes#define CTL_SOSTENUTO		0x42
627111742Sdes#define CTL_SOFT_PEDAL		0x43
628111742Sdes/*	undefined		0x44 */
62963670Snsayer#define CTL_HOLD2		0x45
630111742Sdes/*	undefined		0x46 - 0x4f */
63163670Snsayer
632111742Sdes#define CTL_GENERAL_PURPOSE5	0x50
633111742Sdes#define CTL_GENERAL_PURPOSE6	0x51
634111742Sdes#define CTL_GENERAL_PURPOSE7	0x52
635111742Sdes#define CTL_GENERAL_PURPOSE8	0x53
636111742Sdes/*	undefined		0x54 - 0x5a */
637111742Sdes#define CTL_EXT_EFF_DEPTH	0x5b
63863670Snsayer#define CTL_TREMOLO_DEPTH	0x5c
63963670Snsayer#define CTL_CHORUS_DEPTH	0x5d
64063670Snsayer#define CTL_DETUNE_DEPTH	0x5e
64183043Sbrooks#define CTL_CELESTE_DEPTH	CTL_DETUNE_DEPTH /* Alias for the above one */
64263670Snsayer#define CTL_PHASER_DEPTH	0x5f
64363670Snsayer#define CTL_DATA_INCREMENT	0x60
64463670Snsayer#define CTL_DATA_DECREMENT	0x61
64583043Sbrooks#define CTL_NONREG_PARM_NUM_LSB	0x62
64663670Snsayer#define CTL_NONREG_PARM_NUM_MSB	0x63
64763670Snsayer#define CTL_REGIST_PARM_NUM_LSB	0x64
64883043Sbrooks#define CTL_REGIST_PARM_NUM_MSB	0x65
64963670Snsayer/*	undefined		0x66 - 0x78 */
65063670Snsayer/*	reserved		0x79 - 0x7f */
65163803Snsayer
652127098Srwatson/* Pseudo controllers (not midi compatible) */
65363670Snsayer#define CTRL_PITCH_BENDER	255
65463670Snsayer#define CTRL_PITCH_BENDER_RANGE	254
65563670Snsayer#define CTRL_EXPRESSION		253	/* Obsolete */
65663670Snsayer#define CTRL_MAIN_VOLUME	252	/* Obsolete */
657127098Srwatson
65863803Snsayer#define SEQ_BALANCE		11
65983043Sbrooks#define SEQ_VOLMODE             12
66063670Snsayer
66163670Snsayer/*
66263670Snsayer * Volume mode decides how volumes are used
66363670Snsayer */
66463670Snsayer
66563670Snsayer#define VOL_METHOD_ADAGIO	1
66663803Snsayer#define VOL_METHOD_LINEAR	2
66763670Snsayer
66883043Sbrooks/*
66963670Snsayer * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as
67063670Snsayer *	 input events.
67183043Sbrooks */
67263670Snsayer
67363670Snsayer/*
67463670Snsayer * Event codes 0xf0 to 0xfc are reserved for future extensions.
67563670Snsayer */
67663670Snsayer
677104393Struckman#define SEQ_FULLSIZE		0xfd	/* Long events */
67863670Snsayer/*
67963670Snsayer * SEQ_FULLSIZE events are used for loading patches/samples to the
68063670Snsayer * synthesizer devices. These events are passed directly to the driver
68163670Snsayer * of the associated synthesizer device. There is no limit to the size
68263670Snsayer * of the extended events. These events are not queued but executed
68363670Snsayer * immediately when the write() is called (execution can take several
68463670Snsayer * seconds of time).
68563670Snsayer *
686104393Struckman * When a SEQ_FULLSIZE message is written to the device, it must
68763670Snsayer * be written using exactly one write() call. Other events cannot
68863670Snsayer * be mixed to the same write.
68963670Snsayer *
69063670Snsayer * For FM synths (YM3812/OPL3) use struct sbi_instrument and write
69163670Snsayer * it to the /dev/sequencer. Don't write other data together with
69263670Snsayer * the instrument structure Set the key field of the structure to
69383043Sbrooks * FM_PATCH. The device field is used to route the patch to the
69463670Snsayer * corresponding device.
69583043Sbrooks *
696102052Ssobomax * For Gravis UltraSound use struct patch_info. Initialize the key field
69763670Snsayer * to GUS_PATCH.
69863670Snsayer */
69963670Snsayer#define SEQ_PRIVATE	0xfe	/* Low level HW dependent events (8 bytes) */
70063670Snsayer#define SEQ_EXTENDED	0xff	/* Extended events (8 bytes) OBSOLETE */
70163670Snsayer
70263670Snsayer/*
70363670Snsayer * Record for FM patches
70483043Sbrooks */
70563670Snsayer
70663861Snsayertypedef u_char sbi_instr_data[32];
70763670Snsayer
708127165Srwatsonstruct sbi_instrument {
70963861Snsayer	u_short	key;	/* FM_PATCH or OPL3_PATCH */
710127165Srwatson#define FM_PATCH	_PATCHKEY(0x01)
71183043Sbrooks#define OPL3_PATCH	_PATCHKEY(0x03)
71263670Snsayer	short		device;		/* Synth# (0-4)	*/
71363861Snsayer	int 		channel;	/* Program# to be initialized  */
714127165Srwatson	sbi_instr_data	operators;	/* Reg. settings for operator cells
71563861Snsayer					 * (.SBI format)	*/
716127165Srwatson};
71783043Sbrooks
71863670Snsayerstruct synth_info {	/* Read only */
71963670Snsayer	char	name[30];
72063670Snsayer	int	device;		/* 0-N. INITIALIZE BEFORE CALLING */
72163670Snsayer	int	synth_type;
72263670Snsayer#define SYNTH_TYPE_FM			0
72363670Snsayer#define SYNTH_TYPE_SAMPLE		1
72463670Snsayer#define SYNTH_TYPE_MIDI			2	/* Midi interface */
72563670Snsayer
72663670Snsayer	int	synth_subtype;
72763670Snsayer#define FM_TYPE_ADLIB			0x00
72863670Snsayer#define FM_TYPE_OPL3			0x01
72963670Snsayer#define MIDI_TYPE_MPU401		0x401
73063670Snsayer
73163670Snsayer#define SAMPLE_TYPE_BASIC		0x10
73263670Snsayer#define SAMPLE_TYPE_GUS			SAMPLE_TYPE_BASIC
73363670Snsayer#define SAMPLE_TYPE_AWE32		0x20
734130585Sphk
73563670Snsayer	int	perc_mode;	/* No longer supported */
73663670Snsayer	int	nr_voices;
73763670Snsayer	int	nr_drums;	/* Obsolete field */
73863670Snsayer	int	instr_bank_size;
73963670Snsayer	u_long	capabilities;
74090227Sdillon#define SYNTH_CAP_PERCMODE	0x00000001 /* No longer used */
74163670Snsayer#define SYNTH_CAP_OPL3		0x00000002 /* Set if OPL3 supported */
74263670Snsayer#define SYNTH_CAP_INPUT		0x00000004 /* Input (MIDI) device */
743121816Sbrooks	int	dummies[19];	/* Reserve space */
74463670Snsayer};
745127098Srwatson
74663670Snsayerstruct sound_timer_info {
747127098Srwatson	char name[32];
748127098Srwatson	int caps;
749127098Srwatson};
750121816Sbrooks
751121816Sbrooksstruct midi_info {
75263803Snsayer	char		name[30];
75363670Snsayer	int		device;		/* 0-N. INITIALIZE BEFORE CALLING */
75463670Snsayer	u_long	capabilities;	/* To be defined later */
75563670Snsayer	int		dev_type;
75663670Snsayer	int		dummies[18];	/* Reserve space */
757127098Srwatson};
75863670Snsayer
75963670Snsayer/*
76063670Snsayer * ioctl commands for the /dev/midi##
76163670Snsayer */
76290227Sdillontypedef struct {
76363670Snsayer	u_char cmd;
76463670Snsayer	char nr_args, nr_returns;
76590227Sdillon	u_char data[30];
766139207Sphk} mpu_command_rec;
76763670Snsayer
768111742Sdes#define SNDCTL_MIDI_PRETIME	_IOWR('m', 0, int)
769127098Srwatson#define SNDCTL_MIDI_MPUMODE	_IOWR('m', 1, int)
77063670Snsayer#define SNDCTL_MIDI_MPUCMD	_IOWR('m', 2, mpu_command_rec)
771127098Srwatson#define MIOSPASSTHRU		_IOWR('m', 3, int)
772111748Sdes#define MIOGPASSTHRU		_IOWR('m', 4, int)
77363670Snsayer
77463670Snsayer/*
77563670Snsayer * IOCTL commands for /dev/dsp and /dev/audio
77690227Sdillon */
77763670Snsayer
77863670Snsayer#define SNDCTL_DSP_HALT		_IO  ('P', 0)
779106939Ssam#define SNDCTL_DSP_RESET	SNDCTL_DSP_HALT
78063670Snsayer#define SNDCTL_DSP_SYNC		_IO  ('P', 1)
78163670Snsayer#define SNDCTL_DSP_SPEED	_IOWR('P', 2, int)
78290227Sdillon#define SNDCTL_DSP_STEREO	_IOWR('P', 3, int)
78390227Sdillon#define SNDCTL_DSP_GETBLKSIZE	_IOR('P', 4, int)
78463670Snsayer#define SNDCTL_DSP_SETBLKSIZE   _IOW('P', 4, int)
78563670Snsayer#define SNDCTL_DSP_SETFMT	_IOWR('P',5, int) /* Selects ONE fmt*/
78663670Snsayer
787111741Sdes/*
78890227Sdillon * SOUND_PCM_WRITE_CHANNELS is not that different
78963670Snsayer * from SNDCTL_DSP_STEREO
79063670Snsayer */
79190227Sdillon#define SOUND_PCM_WRITE_CHANNELS	_IOWR('P', 6, int)
792121816Sbrooks#define SNDCTL_DSP_CHANNELS	SOUND_PCM_WRITE_CHANNELS
793121816Sbrooks#define SOUND_PCM_WRITE_FILTER	_IOWR('P', 7, int)
79490227Sdillon#define SNDCTL_DSP_POST		_IO  ('P', 8)
79563670Snsayer
79663670Snsayer/*
79763670Snsayer * SNDCTL_DSP_SETBLKSIZE and the following two calls mostly do
79863670Snsayer * the same thing, i.e. set the block size used in DMA transfers.
79963670Snsayer */
80063670Snsayer#define SNDCTL_DSP_SUBDIVIDE	_IOWR('P', 9, int)
80163670Snsayer#define SNDCTL_DSP_SETFRAGMENT	_IOWR('P',10, int)
80263670Snsayer
80363670Snsayer
80463670Snsayer#define SNDCTL_DSP_GETFMTS	_IOR ('P',11, int) /* Returns a mask */
80563670Snsayer/*
80663670Snsayer * Buffer status queries.
80763670Snsayer */
808130585Sphktypedef struct audio_buf_info {
80963670Snsayer    int fragments;	/* # of avail. frags (partly used ones not counted) */
81063670Snsayer    int fragstotal;	/* Total # of fragments allocated */
81163670Snsayer    int fragsize;	/* Size of a fragment in bytes */
81263670Snsayer
81363670Snsayer    int bytes;	/* Avail. space in bytes (includes partly used fragments) */
814137101Sglebius		/* Note! 'bytes' could be more than fragments*fragsize */
815137101Sglebius} audio_buf_info;
81663670Snsayer
817121816Sbrooks#define SNDCTL_DSP_GETOSPACE	_IOR ('P',12, audio_buf_info)
818121816Sbrooks#define SNDCTL_DSP_GETISPACE	_IOR ('P',13, audio_buf_info)
81963670Snsayer
82063670Snsayer/*
82163670Snsayer * SNDCTL_DSP_NONBLOCK is the same (but less powerful, since the
82263670Snsayer * action cannot be undone) of FIONBIO. The same can be achieved
82363670Snsayer * by opening the device with O_NDELAY
824121816Sbrooks */
825121816Sbrooks#define SNDCTL_DSP_NONBLOCK	_IO  ('P',14)
82663803Snsayer
82763670Snsayer#define SNDCTL_DSP_GETCAPS	_IOR ('P',15, int)
82863670Snsayer#	define PCM_CAP_REVISION		0x000000ff	/* Bits for revision level (0 to 255) */
82963670Snsayer#	define PCM_CAP_DUPLEX		0x00000100	/* Full duplex record/playback */
830137101Sglebius#	define PCM_CAP_REALTIME		0x00000200	/* Not in use */
83163670Snsayer#	define PCM_CAP_BATCH		0x00000400	/* Device has some kind of */
83263670Snsayer							/* internal buffers which may */
83363670Snsayer							/* cause some delays and */
83463670Snsayer							/* decrease precision of timing */
835137101Sglebius#	define PCM_CAP_COPROC		0x00000800	/* Has a coprocessor */
836111742Sdes							/* Sometimes it's a DSP */
837106939Ssam							/* but usually not */
838137101Sglebius#	define PCM_CAP_TRIGGER		0x00001000	/* Supports SETTRIGGER */
839106939Ssam#	define PCM_CAP_MMAP		0x00002000	/* Supports mmap() */
84063670Snsayer#	define PCM_CAP_MULTI		0x00004000	/* Supports multiple open */
84163670Snsayer#	define PCM_CAP_BIND		0x00008000	/* Supports binding to front/rear/center/lfe */
84263670Snsayer#   	define PCM_CAP_INPUT		0x00010000	/* Supports recording */
84363670Snsayer#   	define PCM_CAP_OUTPUT		0x00020000	/* Supports playback */
84463670Snsayer#	define PCM_CAP_VIRTUAL		0x00040000	/* Virtual device */
84563670Snsayer/* 0x00040000 and 0x00080000 reserved for future use */
84663670Snsayer
84763670Snsayer/* Analog/digital control capabilities */
84863670Snsayer#	define PCM_CAP_ANALOGOUT	0x00100000
84963670Snsayer#	define PCM_CAP_ANALOGIN		0x00200000
85063670Snsayer#	define PCM_CAP_DIGITALOUT	0x00400000
85163670Snsayer#	define PCM_CAP_DIGITALIN	0x00800000
85263670Snsayer#	define PCM_CAP_ADMASK		0x00f00000
85383366Sjulian/*
854130585Sphk * NOTE! (capabilities & PCM_CAP_ADMASK)==0 means just that the
85563670Snsayer * digital/analog interface control features are not supported by the
85683366Sjulian * device/driver. However the device still supports analog, digital or
85763670Snsayer * both inputs/outputs (depending on the device). See the OSS Programmer's
85863670Snsayer * Guide for full details.
85963670Snsayer */
860111742Sdes#	define PCM_CAP_SPECIAL		0x01000000	/* Not for ordinary "multimedia" use */
86163670Snsayer#	define PCM_CAP_SHADOW		0x00000000	/* OBSOLETE */
862121816Sbrooks
863121816Sbrooks/*
86463670Snsayer * Preferred channel usage. These bits can be used to
86563670Snsayer * give recommendations to the application. Used by few drivers.
86663670Snsayer * For example if ((caps & DSP_CH_MASK) == DSP_CH_MONO) means that
86763670Snsayer * the device works best in mono mode. However it doesn't necessarily mean
868121816Sbrooks * that the device cannot be used in stereo. These bits should only be used
869121816Sbrooks * by special applications such as multi track hard disk recorders to find
87083043Sbrooks * out the initial setup. However the user should be able to override this
87163803Snsayer * selection.
87263670Snsayer *
87383043Sbrooks * To find out which modes are actually supported the application should
874121816Sbrooks * try to select them using SNDCTL_DSP_CHANNELS.
875121816Sbrooks */
87663803Snsayer#	define DSP_CH_MASK		0x06000000	/* Mask */
87783805Sjhb#	define DSP_CH_ANY		0x00000000	/* No preferred mode */
87863670Snsayer#	define DSP_CH_MONO		0x02000000
87963670Snsayer#	define DSP_CH_STEREO		0x04000000
88063670Snsayer#	define DSP_CH_MULTI		0x06000000	/* More than two channels */
88163670Snsayer
88263670Snsayer#	define PCM_CAP_HIDDEN		0x08000000	/* Hidden device */
88363670Snsayer#	define PCM_CAP_FREERATE		0x10000000
88463670Snsayer#	define PCM_CAP_MODEM		0x20000000	/* Modem device */
88563670Snsayer#	define PCM_CAP_DEFAULT		0x40000000	/* "Default" device */
88663670Snsayer
887/*
888 * The PCM_CAP_* capability names were known as DSP_CAP_* prior OSS 4.0
889 * so it's necessary to define the older names too.
890 */
891#define DSP_CAP_ADMASK		PCM_CAP_ADMASK
892#define DSP_CAP_ANALOGIN	PCM_CAP_ANALOGIN
893#define DSP_CAP_ANALOGOUT	PCM_CAP_ANALOGOUT
894#define DSP_CAP_BATCH		PCM_CAP_BATCH
895#define DSP_CAP_BIND		PCM_CAP_BIND
896#define DSP_CAP_COPROC		PCM_CAP_COPROC
897#define DSP_CAP_DEFAULT		PCM_CAP_DEFAULT
898#define DSP_CAP_DIGITALIN	PCM_CAP_DIGITALIN
899#define DSP_CAP_DIGITALOUT	PCM_CAP_DIGITALOUT
900#define DSP_CAP_DUPLEX		PCM_CAP_DUPLEX
901#define DSP_CAP_FREERATE	PCM_CAP_FREERATE
902#define DSP_CAP_HIDDEN		PCM_CAP_HIDDEN
903#define DSP_CAP_INPUT		PCM_CAP_INPUT
904#define DSP_CAP_MMAP		PCM_CAP_MMAP
905#define DSP_CAP_MODEM		PCM_CAP_MODEM
906#define DSP_CAP_MULTI		PCM_CAP_MULTI
907#define DSP_CAP_OUTPUT		PCM_CAP_OUTPUT
908#define DSP_CAP_REALTIME	PCM_CAP_REALTIME
909#define DSP_CAP_REVISION	PCM_CAP_REVISION
910#define DSP_CAP_SHADOW		PCM_CAP_SHADOW
911#define DSP_CAP_TRIGGER		PCM_CAP_TRIGGER
912#define DSP_CAP_VIRTUAL		PCM_CAP_VIRTUAL
913
914/*
915 * What do these function do ?
916 */
917#define SNDCTL_DSP_GETTRIGGER	_IOR ('P',16, int)
918#define SNDCTL_DSP_SETTRIGGER	_IOW ('P',16, int)
919#define PCM_ENABLE_INPUT	0x00000001
920#define PCM_ENABLE_OUTPUT	0x00000002
921
922typedef struct count_info {
923	int bytes;	/* Total # of bytes processed */
924	int blocks;	/* # of fragment transitions since last time */
925	int ptr;	/* Current DMA pointer value */
926} count_info;
927
928/*
929 * GETIPTR and GETISPACE are not that different... same for out.
930 */
931#define SNDCTL_DSP_GETIPTR	_IOR ('P',17, count_info)
932#define SNDCTL_DSP_GETOPTR	_IOR ('P',18, count_info)
933
934typedef struct buffmem_desc {
935	caddr_t buffer;
936	int size;
937} buffmem_desc;
938
939#define SNDCTL_DSP_MAPINBUF	_IOR ('P', 19, buffmem_desc)
940#define SNDCTL_DSP_MAPOUTBUF	_IOR ('P', 20, buffmem_desc)
941#define SNDCTL_DSP_SETSYNCRO	_IO  ('P', 21)
942#define SNDCTL_DSP_SETDUPLEX	_IO  ('P', 22)
943#define SNDCTL_DSP_GETODELAY	_IOR ('P', 23, int)
944
945/*
946 * I guess these are the readonly version of the same
947 * functions that exist above as SNDCTL_DSP_...
948 */
949#define SOUND_PCM_READ_RATE	_IOR ('P', 2, int)
950#define SOUND_PCM_READ_CHANNELS	_IOR ('P', 6, int)
951#define SOUND_PCM_READ_BITS	_IOR ('P', 5, int)
952#define SOUND_PCM_READ_FILTER	_IOR ('P', 7, int)
953
954/*
955 * ioctl calls to be used in communication with coprocessors and
956 * DSP chips.
957 */
958
959typedef struct copr_buffer {
960	int command;	/* Set to 0 if not used */
961	int flags;
962#define CPF_NONE		0x0000
963#define CPF_FIRST		0x0001	/* First block */
964#define CPF_LAST		0x0002	/* Last block */
965	int len;
966	int offs;	/* If required by the device (0 if not used) */
967
968	u_char data[4000]; /* NOTE! 4000 is not 4k */
969} copr_buffer;
970
971typedef struct copr_debug_buf {
972	int command;	/* Used internally. Set to 0 */
973	int parm1;
974	int parm2;
975	int flags;
976	int len;	/* Length of data in bytes */
977} copr_debug_buf;
978
979typedef struct copr_msg {
980	int len;
981	u_char data[4000];
982} copr_msg;
983
984#define SNDCTL_COPR_RESET       _IO  ('C',  0)
985#define SNDCTL_COPR_LOAD	_IOWR('C',  1, copr_buffer)
986#define SNDCTL_COPR_RDATA	_IOWR('C',  2, copr_debug_buf)
987#define SNDCTL_COPR_RCODE	_IOWR('C',  3, copr_debug_buf)
988#define SNDCTL_COPR_WDATA	_IOW ('C',  4, copr_debug_buf)
989#define SNDCTL_COPR_WCODE	_IOW ('C',  5, copr_debug_buf)
990#define SNDCTL_COPR_RUN		_IOWR('C',  6, copr_debug_buf)
991#define SNDCTL_COPR_HALT	_IOWR('C',  7, copr_debug_buf)
992#define SNDCTL_COPR_SENDMSG	_IOW ('C',  8, copr_msg)
993#define SNDCTL_COPR_RCVMSG	_IOR ('C',  9, copr_msg)
994
995/*
996 * IOCTL commands for /dev/mixer
997 */
998
999/*
1000 * Mixer devices
1001 *
1002 * There can be up to 20 different analog mixer channels. The
1003 * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
1004 * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
1005 * the devices supported by the particular mixer.
1006 */
1007
1008#define SOUND_MIXER_NRDEVICES	25
1009#define SOUND_MIXER_VOLUME	0	/* Master output level */
1010#define SOUND_MIXER_BASS	1	/* Treble level of all output channels */
1011#define SOUND_MIXER_TREBLE	2	/* Bass level of all output channels */
1012#define SOUND_MIXER_SYNTH	3	/* Volume of synthesier input */
1013#define SOUND_MIXER_PCM		4	/* Output level for the audio device */
1014#define SOUND_MIXER_SPEAKER	5	/* Output level for the PC speaker
1015					 * signals */
1016#define SOUND_MIXER_LINE	6	/* Volume level for the line in jack */
1017#define SOUND_MIXER_MIC		7	/* Volume for the signal coming from
1018					 * the microphone jack */
1019#define SOUND_MIXER_CD		8	/* Volume level for the input signal
1020					 * connected to the CD audio input */
1021#define SOUND_MIXER_IMIX	9	/* Recording monitor. It controls the
1022					 * output volume of the selected
1023					 * recording sources while recording */
1024#define SOUND_MIXER_ALTPCM	10	/* Volume of the alternative codec
1025					 * device */
1026#define SOUND_MIXER_RECLEV	11	/* Global recording level */
1027#define SOUND_MIXER_IGAIN	12	/* Input gain */
1028#define SOUND_MIXER_OGAIN	13	/* Output gain */
1029/*
1030 * The AD1848 codec and compatibles have three line level inputs
1031 * (line, aux1 and aux2). Since each card manufacturer have assigned
1032 * different meanings to these inputs, it's inpractical to assign
1033 * specific meanings (line, cd, synth etc.) to them.
1034 */
1035#define SOUND_MIXER_LINE1	14	/* Input source 1  (aux1) */
1036#define SOUND_MIXER_LINE2	15	/* Input source 2  (aux2) */
1037#define SOUND_MIXER_LINE3	16	/* Input source 3  (line) */
1038#define SOUND_MIXER_DIGITAL1    17      /* Digital (input) 1 */
1039#define SOUND_MIXER_DIGITAL2    18      /* Digital (input) 2 */
1040#define SOUND_MIXER_DIGITAL3    19      /* Digital (input) 3 */
1041#define SOUND_MIXER_PHONEIN     20      /* Phone input */
1042#define SOUND_MIXER_PHONEOUT    21      /* Phone output */
1043#define SOUND_MIXER_VIDEO       22      /* Video/TV (audio) in */
1044#define SOUND_MIXER_RADIO       23      /* Radio in */
1045#define SOUND_MIXER_MONITOR     24      /* Monitor (usually mic) volume */
1046
1047
1048/*
1049 * Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX)
1050 * Not counted to SOUND_MIXER_NRDEVICES, but use the same number space
1051 */
1052#define SOUND_ONOFF_MIN		28
1053#define SOUND_ONOFF_MAX		30
1054#define SOUND_MIXER_MUTE	28	/* 0 or 1 */
1055#define SOUND_MIXER_ENHANCE	29	/* Enhanced stereo (0, 40, 60 or 80) */
1056#define SOUND_MIXER_LOUD	30	/* 0 or 1 */
1057
1058/* Note!	Number 31 cannot be used since the sign bit is reserved */
1059#define SOUND_MIXER_NONE        31
1060
1061#define SOUND_DEVICE_LABELS	{ \
1062	"Vol  ", "Bass ", "Trebl", "Synth", "Pcm  ", "Spkr ", "Line ", \
1063	"Mic  ", "CD   ", "Mix  ", "Pcm2 ", "Rec  ", "IGain", "OGain", \
1064	"Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
1065	"PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
1066
1067#define SOUND_DEVICE_NAMES	{ \
1068	"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
1069	"mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
1070	"line1", "line2", "line3", "dig1", "dig2", "dig3", \
1071	"phin", "phout", "video", "radio", "monitor"}
1072
1073/*	Device bitmask identifiers	*/
1074
1075#define SOUND_MIXER_RECSRC	0xff	/* 1 bit per recording source */
1076#define SOUND_MIXER_DEVMASK	0xfe	/* 1 bit per supported device */
1077#define SOUND_MIXER_RECMASK	0xfd	/* 1 bit per supp. recording source */
1078#define SOUND_MIXER_CAPS	0xfc
1079#define SOUND_CAP_EXCL_INPUT	0x00000001	/* Only 1 rec. src at a time */
1080#define SOUND_MIXER_STEREODEVS	0xfb	/* Mixer channels supporting stereo */
1081
1082/*	Device mask bits	*/
1083
1084#define SOUND_MASK_VOLUME	(1 << SOUND_MIXER_VOLUME)
1085#define SOUND_MASK_BASS		(1 << SOUND_MIXER_BASS)
1086#define SOUND_MASK_TREBLE	(1 << SOUND_MIXER_TREBLE)
1087#define SOUND_MASK_SYNTH	(1 << SOUND_MIXER_SYNTH)
1088#define SOUND_MASK_PCM		(1 << SOUND_MIXER_PCM)
1089#define SOUND_MASK_SPEAKER	(1 << SOUND_MIXER_SPEAKER)
1090#define SOUND_MASK_LINE		(1 << SOUND_MIXER_LINE)
1091#define SOUND_MASK_MIC		(1 << SOUND_MIXER_MIC)
1092#define SOUND_MASK_CD		(1 << SOUND_MIXER_CD)
1093#define SOUND_MASK_IMIX		(1 << SOUND_MIXER_IMIX)
1094#define SOUND_MASK_ALTPCM	(1 << SOUND_MIXER_ALTPCM)
1095#define SOUND_MASK_RECLEV	(1 << SOUND_MIXER_RECLEV)
1096#define SOUND_MASK_IGAIN	(1 << SOUND_MIXER_IGAIN)
1097#define SOUND_MASK_OGAIN	(1 << SOUND_MIXER_OGAIN)
1098#define SOUND_MASK_LINE1	(1 << SOUND_MIXER_LINE1)
1099#define SOUND_MASK_LINE2	(1 << SOUND_MIXER_LINE2)
1100#define SOUND_MASK_LINE3	(1 << SOUND_MIXER_LINE3)
1101#define SOUND_MASK_DIGITAL1     (1 << SOUND_MIXER_DIGITAL1)
1102#define SOUND_MASK_DIGITAL2     (1 << SOUND_MIXER_DIGITAL2)
1103#define SOUND_MASK_DIGITAL3     (1 << SOUND_MIXER_DIGITAL3)
1104#define SOUND_MASK_PHONEIN      (1 << SOUND_MIXER_PHONEIN)
1105#define SOUND_MASK_PHONEOUT     (1 << SOUND_MIXER_PHONEOUT)
1106#define SOUND_MASK_RADIO        (1 << SOUND_MIXER_RADIO)
1107#define SOUND_MASK_VIDEO        (1 << SOUND_MIXER_VIDEO)
1108#define SOUND_MASK_MONITOR      (1 << SOUND_MIXER_MONITOR)
1109
1110/* Obsolete macros */
1111#define SOUND_MASK_MUTE		(1 << SOUND_MIXER_MUTE)
1112#define SOUND_MASK_ENHANCE	(1 << SOUND_MIXER_ENHANCE)
1113#define SOUND_MASK_LOUD		(1 << SOUND_MIXER_LOUD)
1114
1115#define MIXER_READ(dev)		_IOR('M', dev, int)
1116#define SOUND_MIXER_READ_VOLUME		MIXER_READ(SOUND_MIXER_VOLUME)
1117#define SOUND_MIXER_READ_BASS		MIXER_READ(SOUND_MIXER_BASS)
1118#define SOUND_MIXER_READ_TREBLE		MIXER_READ(SOUND_MIXER_TREBLE)
1119#define SOUND_MIXER_READ_SYNTH		MIXER_READ(SOUND_MIXER_SYNTH)
1120#define SOUND_MIXER_READ_PCM		MIXER_READ(SOUND_MIXER_PCM)
1121#define SOUND_MIXER_READ_SPEAKER	MIXER_READ(SOUND_MIXER_SPEAKER)
1122#define SOUND_MIXER_READ_LINE		MIXER_READ(SOUND_MIXER_LINE)
1123#define SOUND_MIXER_READ_MIC		MIXER_READ(SOUND_MIXER_MIC)
1124#define SOUND_MIXER_READ_CD		MIXER_READ(SOUND_MIXER_CD)
1125#define SOUND_MIXER_READ_IMIX		MIXER_READ(SOUND_MIXER_IMIX)
1126#define SOUND_MIXER_READ_ALTPCM		MIXER_READ(SOUND_MIXER_ALTPCM)
1127#define SOUND_MIXER_READ_RECLEV		MIXER_READ(SOUND_MIXER_RECLEV)
1128#define SOUND_MIXER_READ_IGAIN		MIXER_READ(SOUND_MIXER_IGAIN)
1129#define SOUND_MIXER_READ_OGAIN		MIXER_READ(SOUND_MIXER_OGAIN)
1130#define SOUND_MIXER_READ_LINE1		MIXER_READ(SOUND_MIXER_LINE1)
1131#define SOUND_MIXER_READ_LINE2		MIXER_READ(SOUND_MIXER_LINE2)
1132#define SOUND_MIXER_READ_LINE3		MIXER_READ(SOUND_MIXER_LINE3)
1133#define SOUND_MIXER_READ_DIGITAL1	MIXER_READ(SOUND_MIXER_DIGITAL1)
1134#define SOUND_MIXER_READ_DIGITAL2	MIXER_READ(SOUND_MIXER_DIGITAL2)
1135#define SOUND_MIXER_READ_DIGITAL3	MIXER_READ(SOUND_MIXER_DIGITAL3)
1136#define SOUND_MIXER_READ_PHONEIN      	MIXER_READ(SOUND_MIXER_PHONEIN)
1137#define SOUND_MIXER_READ_PHONEOUT	MIXER_READ(SOUND_MIXER_PHONEOUT)
1138#define SOUND_MIXER_READ_RADIO		MIXER_READ(SOUND_MIXER_RADIO)
1139#define SOUND_MIXER_READ_VIDEO		MIXER_READ(SOUND_MIXER_VIDEO)
1140#define SOUND_MIXER_READ_MONITOR	MIXER_READ(SOUND_MIXER_MONITOR)
1141
1142/* Obsolete macros */
1143#define SOUND_MIXER_READ_MUTE		MIXER_READ(SOUND_MIXER_MUTE)
1144#define SOUND_MIXER_READ_ENHANCE	MIXER_READ(SOUND_MIXER_ENHANCE)
1145#define SOUND_MIXER_READ_LOUD		MIXER_READ(SOUND_MIXER_LOUD)
1146
1147#define SOUND_MIXER_READ_RECSRC		MIXER_READ(SOUND_MIXER_RECSRC)
1148#define SOUND_MIXER_READ_DEVMASK	MIXER_READ(SOUND_MIXER_DEVMASK)
1149#define SOUND_MIXER_READ_RECMASK	MIXER_READ(SOUND_MIXER_RECMASK)
1150#define SOUND_MIXER_READ_STEREODEVS	MIXER_READ(SOUND_MIXER_STEREODEVS)
1151#define SOUND_MIXER_READ_CAPS		MIXER_READ(SOUND_MIXER_CAPS)
1152
1153#define MIXER_WRITE(dev)		_IOWR('M', dev, int)
1154#define SOUND_MIXER_WRITE_VOLUME	MIXER_WRITE(SOUND_MIXER_VOLUME)
1155#define SOUND_MIXER_WRITE_BASS		MIXER_WRITE(SOUND_MIXER_BASS)
1156#define SOUND_MIXER_WRITE_TREBLE	MIXER_WRITE(SOUND_MIXER_TREBLE)
1157#define SOUND_MIXER_WRITE_SYNTH		MIXER_WRITE(SOUND_MIXER_SYNTH)
1158#define SOUND_MIXER_WRITE_PCM		MIXER_WRITE(SOUND_MIXER_PCM)
1159#define SOUND_MIXER_WRITE_SPEAKER	MIXER_WRITE(SOUND_MIXER_SPEAKER)
1160#define SOUND_MIXER_WRITE_LINE		MIXER_WRITE(SOUND_MIXER_LINE)
1161#define SOUND_MIXER_WRITE_MIC		MIXER_WRITE(SOUND_MIXER_MIC)
1162#define SOUND_MIXER_WRITE_CD		MIXER_WRITE(SOUND_MIXER_CD)
1163#define SOUND_MIXER_WRITE_IMIX		MIXER_WRITE(SOUND_MIXER_IMIX)
1164#define SOUND_MIXER_WRITE_ALTPCM	MIXER_WRITE(SOUND_MIXER_ALTPCM)
1165#define SOUND_MIXER_WRITE_RECLEV	MIXER_WRITE(SOUND_MIXER_RECLEV)
1166#define SOUND_MIXER_WRITE_IGAIN		MIXER_WRITE(SOUND_MIXER_IGAIN)
1167#define SOUND_MIXER_WRITE_OGAIN		MIXER_WRITE(SOUND_MIXER_OGAIN)
1168#define SOUND_MIXER_WRITE_LINE1		MIXER_WRITE(SOUND_MIXER_LINE1)
1169#define SOUND_MIXER_WRITE_LINE2		MIXER_WRITE(SOUND_MIXER_LINE2)
1170#define SOUND_MIXER_WRITE_LINE3		MIXER_WRITE(SOUND_MIXER_LINE3)
1171#define SOUND_MIXER_WRITE_DIGITAL1	MIXER_WRITE(SOUND_MIXER_DIGITAL1)
1172#define SOUND_MIXER_WRITE_DIGITAL2	MIXER_WRITE(SOUND_MIXER_DIGITAL2)
1173#define SOUND_MIXER_WRITE_DIGITAL3	MIXER_WRITE(SOUND_MIXER_DIGITAL3)
1174#define SOUND_MIXER_WRITE_PHONEIN      	MIXER_WRITE(SOUND_MIXER_PHONEIN)
1175#define SOUND_MIXER_WRITE_PHONEOUT	MIXER_WRITE(SOUND_MIXER_PHONEOUT)
1176#define SOUND_MIXER_WRITE_RADIO		MIXER_WRITE(SOUND_MIXER_RADIO)
1177#define SOUND_MIXER_WRITE_VIDEO		MIXER_WRITE(SOUND_MIXER_VIDEO)
1178#define SOUND_MIXER_WRITE_MONITOR	MIXER_WRITE(SOUND_MIXER_MONITOR)
1179
1180#define SOUND_MIXER_WRITE_MUTE		MIXER_WRITE(SOUND_MIXER_MUTE)
1181#define SOUND_MIXER_WRITE_ENHANCE	MIXER_WRITE(SOUND_MIXER_ENHANCE)
1182#define SOUND_MIXER_WRITE_LOUD		MIXER_WRITE(SOUND_MIXER_LOUD)
1183
1184#define SOUND_MIXER_WRITE_RECSRC	MIXER_WRITE(SOUND_MIXER_RECSRC)
1185
1186typedef struct mixer_info {
1187  char id[16];
1188  char name[32];
1189  int  modify_counter;
1190  int fillers[10];
1191} mixer_info;
1192
1193#define SOUND_MIXER_INFO		_IOR('M', 101, mixer_info)
1194
1195#define LEFT_CHN	0
1196#define RIGHT_CHN	1
1197
1198/*
1199 * Level 2 event types for /dev/sequencer
1200 */
1201
1202/*
1203 * The 4 most significant bits of byte 0 specify the class of
1204 * the event:
1205 *
1206 *	0x8X = system level events,
1207 *	0x9X = device/port specific events, event[1] = device/port,
1208 *		The last 4 bits give the subtype:
1209 *			0x02	= Channel event (event[3] = chn).
1210 *			0x01	= note event (event[4] = note).
1211 *			(0x01 is not used alone but always with bit 0x02).
1212 *	       event[2] = MIDI message code (0x80=note off etc.)
1213 *
1214 */
1215
1216#define EV_SEQ_LOCAL		0x80
1217#define EV_TIMING		0x81
1218#define EV_CHN_COMMON		0x92
1219#define EV_CHN_VOICE		0x93
1220#define EV_SYSEX		0x94
1221/*
1222 * Event types 200 to 220 are reserved for application use.
1223 * These numbers will not be used by the driver.
1224 */
1225
1226/*
1227 * Events for event type EV_CHN_VOICE
1228 */
1229
1230#define MIDI_NOTEOFF		0x80
1231#define MIDI_NOTEON		0x90
1232#define MIDI_KEY_PRESSURE	0xA0
1233
1234/*
1235 * Events for event type EV_CHN_COMMON
1236 */
1237
1238#define MIDI_CTL_CHANGE		0xB0
1239#define MIDI_PGM_CHANGE		0xC0
1240#define MIDI_CHN_PRESSURE	0xD0
1241#define MIDI_PITCH_BEND		0xE0
1242
1243#define MIDI_SYSTEM_PREFIX	0xF0
1244
1245/*
1246 * Timer event types
1247 */
1248#define TMR_WAIT_REL		1	/* Time relative to the prev time */
1249#define TMR_WAIT_ABS		2	/* Absolute time since TMR_START */
1250#define TMR_STOP		3
1251#define TMR_START		4
1252#define TMR_CONTINUE		5
1253#define TMR_TEMPO		6
1254#define TMR_ECHO		8
1255#define TMR_CLOCK		9	/* MIDI clock */
1256#define TMR_SPP			10	/* Song position pointer */
1257#define TMR_TIMESIG		11	/* Time signature */
1258
1259/*
1260 *	Local event types
1261 */
1262#define LOCL_STARTAUDIO		1
1263
1264#if (!defined(_KERNEL) && !defined(INKERNEL)) || defined(USE_SEQ_MACROS)
1265/*
1266 *	Some convenience macros to simplify programming of the
1267 *	/dev/sequencer interface
1268 *
1269 *	These macros define the API which should be used when possible.
1270 */
1271
1272#ifndef USE_SIMPLE_MACROS
1273void seqbuf_dump(void);	/* This function must be provided by programs */
1274
1275/* Sample seqbuf_dump() implementation:
1276 *
1277 *	SEQ_DEFINEBUF (2048);	-- Defines a buffer for 2048 bytes
1278 *
1279 *	int seqfd;		-- The file descriptor for /dev/sequencer.
1280 *
1281 *	void
1282 *	seqbuf_dump ()
1283 *	{
1284 *	  if (_seqbufptr)
1285 *	    if (write (seqfd, _seqbuf, _seqbufptr) == -1)
1286 *	      {
1287 *		perror ("write /dev/sequencer");
1288 *		exit (-1);
1289 *	      }
1290 *	  _seqbufptr = 0;
1291 *	}
1292 */
1293
1294#define SEQ_DEFINEBUF(len)		\
1295	u_char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0
1296#define SEQ_USE_EXTBUF()		\
1297	extern u_char _seqbuf[]; \
1298	extern int _seqbuflen;extern int _seqbufptr
1299#define SEQ_DECLAREBUF()		SEQ_USE_EXTBUF()
1300#define SEQ_PM_DEFINES			struct patmgr_info _pm_info
1301#define _SEQ_NEEDBUF(len)		\
1302	if ((_seqbufptr+(len)) > _seqbuflen) \
1303		seqbuf_dump()
1304#define _SEQ_ADVBUF(len)		_seqbufptr += len
1305#define SEQ_DUMPBUF			seqbuf_dump
1306#else
1307/*
1308 * This variation of the sequencer macros is used just to format one event
1309 * using fixed buffer.
1310 *
1311 * The program using the macro library must define the following macros before
1312 * using this library.
1313 *
1314 * #define _seqbuf 		 name of the buffer (u_char[])
1315 * #define _SEQ_ADVBUF(len)	 If the applic needs to know the exact
1316 *				 size of the event, this macro can be used.
1317 *				 Otherwise this must be defined as empty.
1318 * #define _seqbufptr		 Define the name of index variable or 0 if
1319 *				 not required.
1320 */
1321#define _SEQ_NEEDBUF(len)	/* empty */
1322#endif
1323
1324#define PM_LOAD_PATCH(dev, bank, pgm)	\
1325	(SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \
1326	_pm_info.device=dev, _pm_info.data.data8[0]=pgm, \
1327	_pm_info.parm1 = bank, _pm_info.parm2 = 1, \
1328	ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info))
1329#define PM_LOAD_PATCHES(dev, bank, pgm) \
1330	(SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \
1331	_pm_info.device=dev, bcopy( pgm, _pm_info.data.data8,  128), \
1332	_pm_info.parm1 = bank, _pm_info.parm2 = 128, \
1333	ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info))
1334
1335#define SEQ_VOLUME_MODE(dev, mode)	{ \
1336	_SEQ_NEEDBUF(8);\
1337	_seqbuf[_seqbufptr] = SEQ_EXTENDED;\
1338	_seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\
1339	_seqbuf[_seqbufptr+2] = (dev);\
1340	_seqbuf[_seqbufptr+3] = (mode);\
1341	_seqbuf[_seqbufptr+4] = 0;\
1342	_seqbuf[_seqbufptr+5] = 0;\
1343	_seqbuf[_seqbufptr+6] = 0;\
1344	_seqbuf[_seqbufptr+7] = 0;\
1345	_SEQ_ADVBUF(8);}
1346
1347/*
1348 * Midi voice messages
1349 */
1350
1351#define _CHN_VOICE(dev, event, chn, note, parm)  { \
1352	_SEQ_NEEDBUF(8);\
1353	_seqbuf[_seqbufptr] = EV_CHN_VOICE;\
1354	_seqbuf[_seqbufptr+1] = (dev);\
1355	_seqbuf[_seqbufptr+2] = (event);\
1356	_seqbuf[_seqbufptr+3] = (chn);\
1357	_seqbuf[_seqbufptr+4] = (note);\
1358	_seqbuf[_seqbufptr+5] = (parm);\
1359	_seqbuf[_seqbufptr+6] = (0);\
1360	_seqbuf[_seqbufptr+7] = 0;\
1361	_SEQ_ADVBUF(8);}
1362
1363#define SEQ_START_NOTE(dev, chn, note, vol) \
1364		_CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol)
1365
1366#define SEQ_STOP_NOTE(dev, chn, note, vol) \
1367		_CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol)
1368
1369#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \
1370		_CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure)
1371
1372/*
1373 * Midi channel messages
1374 */
1375
1376#define _CHN_COMMON(dev, event, chn, p1, p2, w14) { \
1377	_SEQ_NEEDBUF(8);\
1378	_seqbuf[_seqbufptr] = EV_CHN_COMMON;\
1379	_seqbuf[_seqbufptr+1] = (dev);\
1380	_seqbuf[_seqbufptr+2] = (event);\
1381	_seqbuf[_seqbufptr+3] = (chn);\
1382	_seqbuf[_seqbufptr+4] = (p1);\
1383	_seqbuf[_seqbufptr+5] = (p2);\
1384	*(short *)&_seqbuf[_seqbufptr+6] = (w14);\
1385	_SEQ_ADVBUF(8);}
1386/*
1387 * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits
1388 * sending any MIDI bytes but it's absolutely not possible. Trying to do
1389 * so _will_ cause problems with MPU401 intelligent mode).
1390 *
1391 * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
1392 * sent by calling SEQ_SYSEX() several times (there must be no other events
1393 * between them). First sysex fragment must have 0xf0 in the first byte
1394 * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte
1395 * between these sysex start and end markers cannot be larger than 0x7f. Also
1396 * lengths of each fragments (except the last one) must be 6.
1397 *
1398 * Breaking the above rules may work with some MIDI ports but is likely to
1399 * cause fatal problems with some other devices (such as MPU401).
1400 */
1401#define SEQ_SYSEX(dev, buf, len) { \
1402	int i, l=(len); if (l>6)l=6;\
1403	_SEQ_NEEDBUF(8);\
1404	_seqbuf[_seqbufptr] = EV_SYSEX;\
1405	for(i=0;i<l;i++)_seqbuf[_seqbufptr+i+1] = (buf)[i];\
1406	for(i=l;i<6;i++)_seqbuf[_seqbufptr+i+1] = 0xff;\
1407	_SEQ_ADVBUF(8);}
1408
1409#define SEQ_CHN_PRESSURE(dev, chn, pressure) \
1410	_CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0)
1411
1412#define SEQ_SET_PATCH(dev, chn, patch) \
1413	_CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0)
1414
1415#define SEQ_CONTROL(dev, chn, controller, value) \
1416	_CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value)
1417
1418#define SEQ_BENDER(dev, chn, value) \
1419	_CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value)
1420
1421
1422#define SEQ_V2_X_CONTROL(dev, voice, controller, value)	{ \
1423	_SEQ_NEEDBUF(8);\
1424	_seqbuf[_seqbufptr] = SEQ_EXTENDED;\
1425	_seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\
1426	_seqbuf[_seqbufptr+2] = (dev);\
1427	_seqbuf[_seqbufptr+3] = (voice);\
1428	_seqbuf[_seqbufptr+4] = (controller);\
1429	*(short *)&_seqbuf[_seqbufptr+5] = (value);\
1430	_seqbuf[_seqbufptr+7] = 0;\
1431	_SEQ_ADVBUF(8);}
1432
1433/*
1434 * The following 5 macros are incorrectly implemented and obsolete.
1435 * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead.
1436 */
1437
1438#define SEQ_PITCHBEND(dev, voice, value) \
1439	SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value)
1440#define SEQ_BENDER_RANGE(dev, voice, value) \
1441	SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value)
1442#define SEQ_EXPRESSION(dev, voice, value) \
1443	SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128)
1444#define SEQ_MAIN_VOLUME(dev, voice, value) \
1445	SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100)
1446#define SEQ_PANNING(dev, voice, pos) \
1447	SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
1448
1449/*
1450 * Timing and synchronization macros
1451 */
1452
1453#define _TIMER_EVENT(ev, parm)		{ \
1454	_SEQ_NEEDBUF(8);\
1455	_seqbuf[_seqbufptr+0] = EV_TIMING; \
1456	_seqbuf[_seqbufptr+1] = (ev); \
1457	_seqbuf[_seqbufptr+2] = 0;\
1458	_seqbuf[_seqbufptr+3] = 0;\
1459	*(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \
1460	_SEQ_ADVBUF(8); \
1461	}
1462
1463#define SEQ_START_TIMER()		_TIMER_EVENT(TMR_START, 0)
1464#define SEQ_STOP_TIMER()		_TIMER_EVENT(TMR_STOP, 0)
1465#define SEQ_CONTINUE_TIMER()		_TIMER_EVENT(TMR_CONTINUE, 0)
1466#define SEQ_WAIT_TIME(ticks)		_TIMER_EVENT(TMR_WAIT_ABS, ticks)
1467#define SEQ_DELTA_TIME(ticks)		_TIMER_EVENT(TMR_WAIT_REL, ticks)
1468#define SEQ_ECHO_BACK(key)		_TIMER_EVENT(TMR_ECHO, key)
1469#define SEQ_SET_TEMPO(value)		_TIMER_EVENT(TMR_TEMPO, value)
1470#define SEQ_SONGPOS(pos)		_TIMER_EVENT(TMR_SPP, pos)
1471#define SEQ_TIME_SIGNATURE(sig)		_TIMER_EVENT(TMR_TIMESIG, sig)
1472
1473/*
1474 * Local control events
1475 */
1476
1477#define _LOCAL_EVENT(ev, parm)		{ \
1478	_SEQ_NEEDBUF(8);\
1479	_seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
1480	_seqbuf[_seqbufptr+1] = (ev); \
1481	_seqbuf[_seqbufptr+2] = 0;\
1482	_seqbuf[_seqbufptr+3] = 0;\
1483	*(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \
1484	_SEQ_ADVBUF(8); \
1485	}
1486
1487#define SEQ_PLAYAUDIO(devmask)		_LOCAL_EVENT(LOCL_STARTAUDIO, devmask)
1488/*
1489 * Events for the level 1 interface only
1490 */
1491
1492#define SEQ_MIDIOUT(device, byte)	{ \
1493	_SEQ_NEEDBUF(4);\
1494	_seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\
1495	_seqbuf[_seqbufptr+1] = (byte);\
1496	_seqbuf[_seqbufptr+2] = (device);\
1497	_seqbuf[_seqbufptr+3] = 0;\
1498	_SEQ_ADVBUF(4);}
1499
1500/*
1501 * Patch loading.
1502 */
1503#define SEQ_WRPATCH(patchx, len)	{ \
1504	if (_seqbufptr) seqbuf_dump(); \
1505	if (write(seqfd, (char*)(patchx), len)==-1) \
1506	   perror("Write patch: /dev/sequencer"); \
1507	}
1508
1509#define SEQ_WRPATCH2(patchx, len)	\
1510	( seqbuf_dump(), write(seqfd, (char*)(patchx), len) )
1511
1512#endif
1513
1514/*
1515 * Here I have moved all the aliases for ioctl names.
1516 */
1517
1518#define SNDCTL_DSP_SAMPLESIZE	SNDCTL_DSP_SETFMT
1519#define SOUND_PCM_WRITE_BITS	SNDCTL_DSP_SETFMT
1520#define SOUND_PCM_SETFMT	SNDCTL_DSP_SETFMT
1521
1522#define SOUND_PCM_WRITE_RATE	SNDCTL_DSP_SPEED
1523#define SOUND_PCM_POST		SNDCTL_DSP_POST
1524#define SOUND_PCM_RESET		SNDCTL_DSP_RESET
1525#define SOUND_PCM_SYNC		SNDCTL_DSP_SYNC
1526#define SOUND_PCM_SUBDIVIDE	SNDCTL_DSP_SUBDIVIDE
1527#define SOUND_PCM_SETFRAGMENT	SNDCTL_DSP_SETFRAGMENT
1528#define SOUND_PCM_GETFMTS	SNDCTL_DSP_GETFMTS
1529#define SOUND_PCM_GETOSPACE	SNDCTL_DSP_GETOSPACE
1530#define SOUND_PCM_GETISPACE	SNDCTL_DSP_GETISPACE
1531#define SOUND_PCM_NONBLOCK	SNDCTL_DSP_NONBLOCK
1532#define SOUND_PCM_GETCAPS	SNDCTL_DSP_GETCAPS
1533#define SOUND_PCM_GETTRIGGER	SNDCTL_DSP_GETTRIGGER
1534#define SOUND_PCM_SETTRIGGER	SNDCTL_DSP_SETTRIGGER
1535#define SOUND_PCM_SETSYNCRO	SNDCTL_DSP_SETSYNCRO
1536#define SOUND_PCM_GETIPTR	SNDCTL_DSP_GETIPTR
1537#define SOUND_PCM_GETOPTR	SNDCTL_DSP_GETOPTR
1538#define SOUND_PCM_MAPINBUF	SNDCTL_DSP_MAPINBUF
1539#define SOUND_PCM_MAPOUTBUF	SNDCTL_DSP_MAPOUTBUF
1540
1541/***********************************************************************/
1542
1543/**
1544 * XXX OSSv4 defines -- some bits taken straight out of the new
1545 * sys/soundcard.h bundled with recent OSS releases.
1546 *
1547 * NB:  These macros and structures will be reorganized and inserted
1548 * 	in appropriate places throughout this file once the code begins
1549 * 	to take shape.
1550 *
1551 * @todo reorganize layout more like the 4Front version
1552 * @todo ask about maintaining __SIOWR vs. _IOWR ioctl cmd defines
1553 */
1554
1555/**
1556 * @note The @c OSSV4_EXPERIMENT macro is meant to wrap new development code
1557 * in the sound system relevant to adopting 4Front's OSSv4 specification.
1558 * Users should not enable this!  Really!
1559 */
1560#if 0
1561# define OSSV4_EXPERIMENT 1
1562#else
1563# undef OSSV4_EXPERIMENT
1564#endif
1565
1566#ifdef SOUND_VERSION
1567# undef SOUND_VERSION
1568# define SOUND_VERSION	0x040000
1569#endif	/* !SOUND_VERSION */
1570
1571#define OSS_LONGNAME_SIZE	64
1572#define OSS_LABEL_SIZE		16
1573#define OSS_DEVNODE_SIZE        32
1574typedef char oss_longname_t[OSS_LONGNAME_SIZE];
1575typedef char oss_label_t[OSS_LABEL_SIZE];
1576typedef char oss_devnode_t[OSS_DEVNODE_SIZE];
1577
1578typedef struct audio_errinfo
1579{
1580	int		play_underruns;
1581	int		rec_overruns;
1582	unsigned int	play_ptradjust;
1583	unsigned int	rec_ptradjust;
1584	int		play_errorcount;
1585	int		rec_errorcount;
1586	int		play_lasterror;
1587	int		rec_lasterror;
1588	long		play_errorparm;
1589	long		rec_errorparm;
1590	int		filler[16];
1591} audio_errinfo;
1592
1593#define SNDCTL_DSP_GETPLAYVOL           _IOR ('P', 24, int)
1594#define SNDCTL_DSP_SETPLAYVOL           _IOWR('P', 24, int)
1595#define SNDCTL_DSP_GETERROR             _IOR ('P', 25, audio_errinfo)
1596
1597
1598/*
1599 ****************************************************************************
1600 * Sync groups for audio devices
1601 */
1602typedef struct oss_syncgroup
1603{
1604  int id;
1605  int mode;
1606  int filler[16];
1607} oss_syncgroup;
1608
1609#define SNDCTL_DSP_SYNCGROUP            _IOWR('P', 28, oss_syncgroup)
1610#define SNDCTL_DSP_SYNCSTART            _IOW ('P', 29, int)
1611
1612/*
1613 **************************************************************************
1614 * "cooked" mode enables software based conversions for sample rate, sample
1615 * format (bits) and number of channels (mono/stereo). These conversions are
1616 * required with some devices that support only one sample rate or just stereo
1617 * to let the applications to use other formats. The cooked mode is enabled by
1618 * default. However it's necessary to disable this mode when mmap() is used or
1619 * when very deterministic timing is required. SNDCTL_DSP_COOKEDMODE is an
1620 * optional call introduced in OSS 3.9.6f. It's _error return must be ignored_
1621 * since normally this call will return erno=EINVAL.
1622 *
1623 * SNDCTL_DSP_COOKEDMODE must be called immediately after open before doing
1624 * anything else. Otherwise the call will not have any effect.
1625 */
1626#define SNDCTL_DSP_COOKEDMODE           _IOW ('P', 30, int)
1627
1628/*
1629 **************************************************************************
1630 * SNDCTL_DSP_SILENCE and SNDCTL_DSP_SKIP are new calls in OSS 3.99.0
1631 * that can be used to implement pause/continue during playback (no effect
1632 * on recording).
1633 */
1634#define SNDCTL_DSP_SILENCE              _IO  ('P', 31)
1635#define SNDCTL_DSP_SKIP                 _IO  ('P', 32)
1636
1637/*
1638 ****************************************************************************
1639 * Abort transfer (reset) functions for input and output
1640 */
1641#define SNDCTL_DSP_HALT_INPUT		_IO  ('P', 33)
1642#define SNDCTL_DSP_RESET_INPUT	SNDCTL_DSP_HALT_INPUT	/* Old name */
1643#define SNDCTL_DSP_HALT_OUTPUT		_IO  ('P', 34)
1644#define SNDCTL_DSP_RESET_OUTPUT	SNDCTL_DSP_HALT_OUTPUT	/* Old name */
1645
1646/*
1647 ****************************************************************************
1648 * Low water level control
1649 */
1650#define SNDCTL_DSP_LOW_WATER		_IOW ('P', 34, int)
1651
1652/** @todo Get rid of OSS_NO_LONG_LONG references? */
1653
1654/*
1655 ****************************************************************************
1656 * 64 bit pointer support. Only available in environments that support
1657 * the 64 bit (long long) integer type.
1658 */
1659#ifndef OSS_NO_LONG_LONG
1660typedef struct
1661{
1662  long long samples;
1663  int fifo_samples;
1664  int filler[32];		/* For future use */
1665} oss_count_t;
1666
1667#define SNDCTL_DSP_CURRENT_IPTR		_IOR ('P', 35, oss_count_t)
1668#define SNDCTL_DSP_CURRENT_OPTR		_IOR ('P', 36, oss_count_t)
1669#endif
1670
1671/*
1672 ****************************************************************************
1673 * Interface for selecting recording sources and playback output routings.
1674 */
1675#define SNDCTL_DSP_GET_RECSRC_NAMES     _IOR ('P', 37, oss_mixer_enuminfo)
1676#define SNDCTL_DSP_GET_RECSRC           _IOR ('P', 38, int)
1677#define SNDCTL_DSP_SET_RECSRC           _IOWR('P', 38, int)
1678
1679#define SNDCTL_DSP_GET_PLAYTGT_NAMES    _IOR ('P', 39, oss_mixer_enuminfo)
1680#define SNDCTL_DSP_GET_PLAYTGT          _IOR ('P', 40, int)
1681#define SNDCTL_DSP_SET_PLAYTGT          _IOWR('P', 40, int)
1682#define SNDCTL_DSP_GETRECVOL            _IOR ('P', 41, int)
1683#define SNDCTL_DSP_SETRECVOL            _IOWR('P', 41, int)
1684
1685/*
1686 ***************************************************************************
1687 * Some calls for setting the channel assignment with multi channel devices
1688 * (see the manual for details).                                                 */
1689#define SNDCTL_DSP_GET_CHNORDER         _IOR ('P', 42, unsigned long long)
1690#define SNDCTL_DSP_SET_CHNORDER         _IOWR('P', 42, unsigned long long)
1691#       define CHID_UNDEF       0
1692#       define CHID_L           1
1693#       define CHID_R           2
1694#       define CHID_C           3
1695#       define CHID_LFE         4
1696#       define CHID_LS          5
1697#       define CHID_RS          6
1698#       define CHID_LR          7
1699#       define CHID_RR          8
1700#define CHNORDER_UNDEF          0x0000000000000000ULL
1701#define CHNORDER_NORMAL         0x0000000087654321ULL
1702
1703#define MAX_PEAK_CHANNELS	128
1704typedef unsigned short oss_peaks_t[MAX_PEAK_CHANNELS];
1705#define SNDCTL_DSP_GETIPEAKS		_IOR('P', 43, oss_peaks_t)
1706#define SNDCTL_DSP_GETOPEAKS		_IOR('P', 44, oss_peaks_t)
1707#define SNDCTL_DSP_POLICY               _IOW('P', 45, int)    /* See the manual */
1708
1709/*
1710 ****************************************************************************
1711 * Few ioctl calls that are not official parts of OSS. They have been used
1712 * by few freeware implementations of OSS.
1713 */
1714#define SNDCTL_DSP_GETCHANNELMASK	_IOWR('P', 64, int)
1715#define SNDCTL_DSP_BIND_CHANNEL		_IOWR('P', 65, int)
1716#define DSP_BIND_QUERY			0x00000000
1717#define DSP_BIND_FRONT			0x00000001
1718#define DSP_BIND_SURR			0x00000002
1719#define DSP_BIND_CENTER_LFE		0x00000004
1720#define DSP_BIND_HANDSET		0x00000008
1721#define DSP_BIND_MIC			0x00000010
1722#define DSP_BIND_MODEM1			0x00000020
1723#define DSP_BIND_MODEM2			0x00000040
1724#define DSP_BIND_I2S			0x00000080
1725#define DSP_BIND_SPDIF			0x00000100
1726#define DSP_BIND_REAR			0x00000200
1727
1728/*
1729 * OSS_SYSIFO is obsolete. Use SNDCTL_SYSINFO insteads.
1730 */
1731#define OSS_GETVERSION                  _IOR ('M', 118, int)
1732
1733/**
1734 * @brief	Argument for SNDCTL_SYSINFO ioctl.
1735 *
1736 * For use w/ the SNDCTL_SYSINFO ioctl available on audio (/dev/dsp*),
1737 * mixer, and MIDI devices.
1738 */
1739typedef struct oss_sysinfo
1740{
1741	char	product[32];	/* For example OSS/Free, OSS/Linux or
1742				   OSS/Solaris */
1743	char	version[32];	/* For example 4.0a */
1744	int	versionnum;	/* See OSS_GETVERSION */
1745	char	options[128];	/* Reserved */
1746
1747	int	numaudios;	/* # of audio/dsp devices */
1748	int	openedaudio[8];	/* Bit mask telling which audio devices
1749				   are busy */
1750
1751	int	numsynths;	/* # of availavle synth devices */
1752	int	nummidis;	/* # of available MIDI ports */
1753	int	numtimers;	/* # of available timer devices */
1754	int	nummixers;	/* # of mixer devices */
1755
1756	int	openedmidi[8];	/* Bit mask telling which midi devices
1757				   are busy */
1758	int	numcards;	/* Number of sound cards in the system */
1759	int	numaudioengines;	/* Number of audio engines in the system */
1760	char	license[16];	/* For example "GPL" or "CDDL" */
1761	char	revision_info[256];	/* For internal use */
1762	int	filler[172];	/* For future expansion (set to -1) */
1763} oss_sysinfo;
1764
1765typedef struct oss_mixext
1766{
1767  int dev;			/* Mixer device number */
1768  int ctrl;			/* Controller number */
1769  int type;			/* Entry type */
1770#	define MIXT_DEVROOT	 0	/* Device root entry */
1771#	define MIXT_GROUP	 1	/* Controller group */
1772#	define MIXT_ONOFF	 2	/* OFF (0) or ON (1) */
1773#	define MIXT_ENUM	 3	/* Enumerated (0 to maxvalue) */
1774#	define MIXT_MONOSLIDER	 4	/* Mono slider (0 to 100) */
1775#	define MIXT_STEREOSLIDER 5	/* Stereo slider (dual 0 to 100) */
1776#	define MIXT_MESSAGE	 6	/* (Readable) textual message */
1777#	define MIXT_MONOVU	 7	/* VU meter value (mono) */
1778#	define MIXT_STEREOVU	 8	/* VU meter value (stereo) */
1779#	define MIXT_MONOPEAK	 9	/* VU meter peak value (mono) */
1780#	define MIXT_STEREOPEAK	10	/* VU meter peak value (stereo) */
1781#	define MIXT_RADIOGROUP	11	/* Radio button group */
1782#	define MIXT_MARKER	12	/* Separator between normal and extension entries */
1783#	define MIXT_VALUE	13	/* Decimal value entry */
1784#	define MIXT_HEXVALUE	14	/* Hexadecimal value entry */
1785#	define MIXT_MONODB	15	/* Mono atten. slider (0 to -144) */
1786#	define MIXT_STEREODB	16	/* Stereo atten. slider (dual 0 to -144) */
1787#	define MIXT_SLIDER	17	/* Slider (mono) with full integer range */
1788#	define MIXT_3D		18
1789
1790  /* Possible value range (minvalue to maxvalue) */
1791  /* Note that maxvalue may also be smaller than minvalue */
1792  int maxvalue;
1793  int minvalue;
1794
1795  int flags;
1796#	define MIXF_READABLE	0x00000001	/* Has readable value */
1797#	define MIXF_WRITEABLE	0x00000002	/* Has writeable value */
1798#	define MIXF_POLL	0x00000004	/* May change itself */
1799#	define MIXF_HZ		0x00000008	/* Herz scale */
1800#	define MIXF_STRING	0x00000010	/* Use dynamic extensions for value */
1801#	define MIXF_DYNAMIC	0x00000010	/* Supports dynamic extensions */
1802#	define MIXF_OKFAIL	0x00000020	/* Interpret value as 1=OK, 0=FAIL */
1803#	define MIXF_FLAT	0x00000040	/* Flat vertical space requirements */
1804#	define MIXF_LEGACY	0x00000080	/* Legacy mixer control group */
1805  char id[16];			/* Mnemonic ID (mainly for internal use) */
1806  int parent;			/* Entry# of parent (group) node (-1 if root) */
1807
1808  int dummy;			/* Internal use */
1809
1810  int timestamp;
1811
1812  char data[64];		/* Misc data (entry type dependent) */
1813  unsigned char enum_present[32];	/* Mask of allowed enum values */
1814  int control_no;		/* SOUND_MIXER_VOLUME..SOUND_MIXER_MIDI */
1815  /* (-1 means not indicated) */
1816
1817/*
1818 * The desc field is reserved for internal purposes of OSS. It should not be
1819 * used by applications.
1820 */
1821  unsigned int desc;
1822#define MIXEXT_SCOPE_MASK			0x0000003f
1823#define MIXEXT_SCOPE_OTHER			0x00000000
1824#define MIXEXT_SCOPE_INPUT			0x00000001
1825#define MIXEXT_SCOPE_OUTPUT			0x00000002
1826#define MIXEXT_SCOPE_MONITOR			0x00000003
1827#define MIXEXT_SCOPE_RECSWITCH			0x00000004
1828
1829  char extname[32];
1830  int update_counter;
1831  int filler[7];
1832} oss_mixext;
1833
1834typedef struct oss_mixext_root
1835{
1836  char id[16];
1837  char name[48];
1838} oss_mixext_root;
1839
1840typedef struct oss_mixer_value
1841{
1842  int dev;
1843  int ctrl;
1844  int value;
1845  int flags;			/* Reserved for future use. Initialize to 0 */
1846  int timestamp;		/* Must be set to oss_mixext.timestamp */
1847  int filler[8];		/* Reserved for future use. Initialize to 0 */
1848} oss_mixer_value;
1849
1850#define OSS_ENUM_MAXVALUE       255
1851typedef struct oss_mixer_enuminfo
1852{
1853	int	dev;
1854	int	ctrl;
1855	int	nvalues;
1856	int	version;                  /* Read the manual */
1857	short	strindex[OSS_ENUM_MAXVALUE];
1858	char	strings[3000];
1859} oss_mixer_enuminfo;
1860
1861#define OPEN_READ       PCM_ENABLE_INPUT
1862#define OPEN_WRITE      PCM_ENABLE_OUTPUT
1863#define OPEN_READWRITE  (OPEN_READ|OPEN_WRITE)
1864
1865/**
1866 * @brief	Argument for SNDCTL_AUDIOINFO ioctl.
1867 *
1868 * For use w/ the SNDCTL_AUDIOINFO ioctl available on audio (/dev/dsp*)
1869 * devices.
1870 */
1871typedef struct oss_audioinfo
1872{
1873	int	dev;		/* Audio device number */
1874	char	name[64];
1875	int	busy;		/* 0, OPEN_READ, OPEN_WRITE or OPEN_READWRITE */
1876	int	pid;
1877	int	caps;		/* DSP_CAP_INPUT, DSP_CAP_OUTPUT */
1878	int	iformats;
1879	int	oformats;
1880	int	magic;		/* Reserved for internal use */
1881	char 	cmd[64];	/* Command using the device (if known) */
1882	int	card_number;
1883	int	port_number;
1884	int	mixer_dev;
1885	int	real_device;	/* Obsolete field. Replaced by devnode */
1886	int	enabled;	/* 1=enabled, 0=device not ready at this
1887				   moment */
1888	int	flags;		/* For internal use only - no practical
1889				   meaning */
1890	int	min_rate;	/* Sample rate limits */
1891	int	max_rate;
1892	int	min_channels;	/* Number of channels supported */
1893	int	max_channels;
1894	int	binding;	/* DSP_BIND_FRONT, etc. 0 means undefined */
1895	int	rate_source;
1896	char	handle[32];
1897	#define OSS_MAX_SAMPLE_RATES	20	/* Cannot be changed  */
1898	unsigned int nrates;
1899	unsigned int rates[OSS_MAX_SAMPLE_RATES]; /* Please read the manual before using these */
1900	oss_longname_t	song_name;	/* Song name (if given) */
1901	oss_label_t	label;		/* Device label (if given) */
1902	int		latency;	/* In usecs, -1=unknown */
1903	oss_devnode_t	devnode;	/* Device special file name (inside
1904					   /dev) */
1905	int next_play_engine;
1906	int next_rec_engine;
1907	int filler[184];
1908} oss_audioinfo;
1909
1910typedef struct oss_mixerinfo
1911{
1912  int dev;
1913  char id[16];
1914  char name[32];
1915  int modify_counter;
1916  int card_number;
1917  int port_number;
1918  char handle[32];
1919  int magic;			/* Reserved */
1920  int enabled;			/* Reserved */
1921  int caps;
1922#define MIXER_CAP_VIRTUAL				0x00000001
1923  int flags;			/* Reserved */
1924  int nrext;
1925  /*
1926   * The priority field can be used to select the default (motherboard)
1927   * mixer device. The mixer with the highest priority is the
1928   * most preferred one. -2 or less means that this device cannot be used
1929   * as the default mixer.
1930   */
1931  int priority;
1932  int filler[254];		/* Reserved */
1933} oss_mixerinfo;
1934
1935typedef struct oss_midi_info
1936{
1937  int dev;			/* Midi device number */
1938  char name[64];
1939  int busy;			/* 0, OPEN_READ, OPEN_WRITE or OPEN_READWRITE */
1940  int pid;
1941  char cmd[64];			/* Command using the device (if known) */
1942  int caps;
1943#define MIDI_CAP_MPU401		0x00000001	/**** OBSOLETE ****/
1944#define MIDI_CAP_INPUT		0x00000002
1945#define MIDI_CAP_OUTPUT		0x00000004
1946#define MIDI_CAP_INOUT		(MIDI_CAP_INPUT|MIDI_CAP_OUTPUT)
1947#define MIDI_CAP_VIRTUAL	0x00000008	/* Pseudo device */
1948#define MIDI_CAP_MTCINPUT	0x00000010	/* Supports SNDCTL_MIDI_MTCINPUT */
1949#define MIDI_CAP_CLIENT		0x00000020	/* Virtual client side device */
1950#define MIDI_CAP_SERVER		0x00000040	/* Virtual server side device */
1951#define MIDI_CAP_INTERNAL	0x00000080	/* Internal (synth) device */
1952#define MIDI_CAP_EXTERNAL	0x00000100	/* external (MIDI port) device */
1953#define MIDI_CAP_PTOP		0x00000200	/* Point to point link to one device */
1954#define MIDI_CAP_MTC		0x00000400	/* MTC/SMPTE (control) device */
1955  int magic;			/* Reserved for internal use */
1956  int card_number;
1957  int port_number;
1958  int enabled;			/* 1=enabled, 0=device not ready at this moment */
1959  int flags;			/* For internal use only - no practical meaning */
1960  char handle[32];
1961  oss_longname_t song_name;	/* Song name (if known) */
1962  oss_label_t label;		/* Device label (if given) */
1963  int latency;			/* In usecs, -1=unknown */
1964  int filler[244];
1965} oss_midi_info;
1966
1967typedef struct oss_card_info
1968{
1969  int card;
1970  char shortname[16];
1971  char longname[128];
1972  int flags;
1973  char hw_info[400];
1974  int intr_count, ack_count;
1975  int filler[154];
1976} oss_card_info;
1977
1978#define SNDCTL_SYSINFO          _IOR ('X', 1, oss_sysinfo)
1979#define OSS_SYSINFO             SNDCTL_SYSINFO /* Old name */
1980
1981#define SNDCTL_MIX_NRMIX	_IOR ('X', 2, int)
1982#define SNDCTL_MIX_NREXT	_IOWR('X', 3, int)
1983#define SNDCTL_MIX_EXTINFO	_IOWR('X', 4, oss_mixext)
1984#define SNDCTL_MIX_READ		_IOWR('X', 5, oss_mixer_value)
1985#define SNDCTL_MIX_WRITE	_IOWR('X', 6, oss_mixer_value)
1986
1987#define SNDCTL_AUDIOINFO	_IOWR('X', 7, oss_audioinfo)
1988#define SNDCTL_MIX_ENUMINFO	_IOWR('X', 8, oss_mixer_enuminfo)
1989#define SNDCTL_MIDIINFO		_IOWR('X', 9, oss_midi_info)
1990#define SNDCTL_MIXERINFO	_IOWR('X',10, oss_mixerinfo)
1991#define SNDCTL_CARDINFO		_IOWR('X',11, oss_card_info)
1992#define SNDCTL_ENGINEINFO	_IOWR('X',12, oss_audioinfo)
1993#define SNDCTL_AUDIOINFO_EX	_IOWR('X',13, oss_audioinfo)
1994
1995/*
1996 * Few more "globally" available ioctl calls.
1997 */
1998#define SNDCTL_SETSONG          _IOW ('Y', 2, oss_longname_t)
1999#define SNDCTL_GETSONG          _IOR ('Y', 2, oss_longname_t)
2000#define SNDCTL_SETNAME          _IOW ('Y', 3, oss_longname_t)
2001#define SNDCTL_SETLABEL         _IOW ('Y', 4, oss_label_t)
2002#define SNDCTL_GETLABEL         _IOR ('Y', 4, oss_label_t)
2003
2004#endif	/* !_SYS_SOUNDCARD_H_ */
2005