soundcard.h revision 193886
1652Sjkh/*
233473Sscrappy * soundcard.h
3139825Simp */
4139825Simp
5139825Simp/*-
6162588Snetchild * Copyright by Hannu Savolainen 1993 / 4Front Technologies 1993-2006
733473Sscrappy * Modified for the new FreeBSD sound driver by Luigi Rizzo, 1997
8652Sjkh *
9652Sjkh * Redistribution and use in source and binary forms, with or without
10652Sjkh * modification, are permitted provided that the following conditions
11652Sjkh * are met:
12652Sjkh * 1. Redistributions of source code must retain the above copyright
13652Sjkh *    notice, this list of conditions and the following disclaimer.
1433473Sscrappy * 2. Redistributions in binary form must reproduce the above
1533473Sscrappy *    copyright notice, this list of conditions and the following
1633473Sscrappy *    disclaimer in the documentation and/or other materials provided
1733473Sscrappy *    with the distribution.
18652Sjkh *
1933473Sscrappy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
2033473Sscrappy * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2133473Sscrappy * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
2233473Sscrappy * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR
2333473Sscrappy * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2433473Sscrappy * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2533473Sscrappy * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
2633473Sscrappy * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2733473Sscrappy * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2833473Sscrappy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
2933473Sscrappy * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3033473Sscrappy * POSSIBILITY OF SUCH DAMAGE.
3150734Speter *
3250734Speter * $FreeBSD: head/sys/sys/soundcard.h 193886 2009-06-10 03:56:24Z ariff $
33652Sjkh */
34652Sjkh
35162588Snetchild/*
36162588Snetchild * Unless coordinating changes with 4Front Technologies, do NOT make any
37162588Snetchild * modifications to ioctl commands, types, etc. that would break
38162588Snetchild * compatibility with the OSS API.
39162588Snetchild */
40162588Snetchild
4150906Sdfr#ifndef _SYS_SOUNDCARD_H_
4250906Sdfr#define _SYS_SOUNDCARD_H_
4365335Scg /*
44652Sjkh  * If you make modifications to this file, please contact me before
4565335Scg  * distributing the modified version. There is already enough
4613765Smpp  * diversity in the world.
47652Sjkh  *
48652Sjkh  * Regards,
49652Sjkh  * Hannu Savolainen
503256Sswallace  * hannu@voxware.pp.fi
5130866Smarkm  *
5230866Smarkm  **********************************************************************
5365335Scg  * PS.	The Hacker's Guide to VoxWare available from
5482033Sgreid  *     nic.funet.fi:pub/Linux/ALPHA/sound. The file is
5530866Smarkm  *	snd-sdk-doc-0.1.ps.gz (gzipped postscript). It contains
5630866Smarkm  *	some useful information about programming with VoxWare.
5782033Sgreid  *	(NOTE! The pub/Linux/ALPHA/ directories are hidden. You have
5830866Smarkm  *	to cd inside them before the files are accessible.)
5930866Smarkm  **********************************************************************
60652Sjkh  */
61652Sjkh
6233530Sscrappy/*
6333530Sscrappy * SOUND_VERSION is only used by the voxware driver. Hopefully apps
6433530Sscrappy * should not depend on it, but rather look at the capabilities
6533530Sscrappy * of the driver in the kernel!
6633530Sscrappy */
6733530Sscrappy#define SOUND_VERSION  301
6833530Sscrappy#define VOXWARE		/* does this have any use ? */
6933530Sscrappy
7033530Sscrappy/*
7133530Sscrappy * Supported card ID numbers (Should be somewhere else? We keep
7233530Sscrappy * them here just for compativility with the old driver, but these
7333530Sscrappy * constants are of little or no use).
7433530Sscrappy */
7533530Sscrappy
7633530Sscrappy#define SNDCARD_ADLIB          1
7733530Sscrappy#define SNDCARD_SB             2
7833530Sscrappy#define SNDCARD_PAS            3
7933530Sscrappy#define SNDCARD_GUS            4
8033530Sscrappy#define SNDCARD_MPU401         5
8133530Sscrappy#define SNDCARD_SB16           6
8233530Sscrappy#define SNDCARD_SB16MIDI       7
8333530Sscrappy#define SNDCARD_UART6850       8
8433530Sscrappy#define SNDCARD_GUS16          9
8533530Sscrappy#define SNDCARD_MSS            10
8633530Sscrappy#define SNDCARD_PSS            11
8733530Sscrappy#define SNDCARD_SSCAPE         12
8833530Sscrappy#define SNDCARD_PSS_MPU        13
8933530Sscrappy#define SNDCARD_PSS_MSS        14
9033530Sscrappy#define SNDCARD_SSCAPE_MSS     15
9133530Sscrappy#define SNDCARD_TRXPRO         16
9233530Sscrappy#define SNDCARD_TRXPRO_SB      17
9333530Sscrappy#define SNDCARD_TRXPRO_MPU     18
9433530Sscrappy#define SNDCARD_MAD16          19
9533530Sscrappy#define SNDCARD_MAD16_MPU      20
9633530Sscrappy#define SNDCARD_CS4232         21
9733530Sscrappy#define SNDCARD_CS4232_MPU     22
9833530Sscrappy#define SNDCARD_MAUI           23
9933530Sscrappy#define SNDCARD_PSEUDO_MSS     24
10082033Sgreid#define SNDCARD_AWE32          25
10145240Skato#define SNDCARD_NSS            26
10262947Stanimura#define SNDCARD_UART16550      27
10362947Stanimura#define SNDCARD_OPL            28
10433530Sscrappy
10533473Sscrappy#include <sys/types.h>
106114181Smbr#include <machine/endian.h>
10733473Sscrappy#ifndef _IOWR
10833473Sscrappy#include <sys/ioccom.h>
10933473Sscrappy#endif  /* !_IOWR */
110652Sjkh
111652Sjkh/*
11233473Sscrappy * The first part of this file contains the new FreeBSD sound ioctl
11333473Sscrappy * interface. Tries to minimize the number of different ioctls, and
11433473Sscrappy * to be reasonably general.
11533473Sscrappy *
11633473Sscrappy * 970821: some of the new calls have not been implemented yet.
117652Sjkh */
118652Sjkh
11933473Sscrappy/*
12033473Sscrappy * the following three calls extend the generic file descriptor
12133473Sscrappy * interface. AIONWRITE is the dual of FIONREAD, i.e. returns the max
12233473Sscrappy * number of bytes for a write operation to be non-blocking.
12333473Sscrappy *
12433473Sscrappy * AIOGSIZE/AIOSSIZE are used to change the behaviour of the device,
12533473Sscrappy * from a character device (default) to a block device. In block mode,
12633473Sscrappy * (not to be confused with blocking mode) the main difference for the
12733473Sscrappy * application is that select() will return only when a complete
12833473Sscrappy * block can be read/written to the device, whereas in character mode
12933473Sscrappy * select will return true when one byte can be exchanged. For audio
13033473Sscrappy * devices, character mode makes select almost useless since one byte
13133473Sscrappy * will always be ready by the next sample time (which is often only a
13265335Scg * handful of microseconds away).
13333473Sscrappy * Use a size of 0 or 1 to return to character mode.
13433473Sscrappy */
13533473Sscrappy#define	AIONWRITE   _IOR('A', 10, int)   /* get # bytes to write */
13633473Sscrappystruct snd_size {
13733473Sscrappy    int play_size;
13833473Sscrappy    int rec_size;
13933473Sscrappy};
14033473Sscrappy#define	AIOGSIZE    _IOR('A', 11, struct snd_size)/* read current blocksize */
14133473Sscrappy#define	AIOSSIZE    _IOWR('A', 11, struct snd_size)  /* sets blocksize */
142652Sjkh
14330866Smarkm/*
14433473Sscrappy * The following constants define supported audio formats. The
14533473Sscrappy * encoding follows voxware conventions, i.e. 1 bit for each supported
14633473Sscrappy * format. We extend it by using bit 31 (RO) to indicate full-duplex
14733473Sscrappy * capability, and bit 29 (RO) to indicate that the card supports/
14833473Sscrappy * needs different formats on capture & playback channels.
14933473Sscrappy * Bit 29 (RW) is used to indicate/ask stereo.
15081891Ssobomax *
15181891Ssobomax * The number of bits required to store the sample is:
15281891Ssobomax *  o  4 bits for the IDA ADPCM format,
15381891Ssobomax *  o  8 bits for 8-bit formats, mu-law and A-law,
15481891Ssobomax *  o  16 bits for the 16-bit formats, and
15581891Ssobomax *  o  32 bits for the 24/32-bit formats.
15681891Ssobomax *  o  undefined for the MPEG audio format.
15733473Sscrappy */
15833473Sscrappy
15981891Ssobomax#define AFMT_QUERY	0x00000000	/* Return current format */
16081891Ssobomax#define AFMT_MU_LAW	0x00000001	/* Logarithmic mu-law */
16181891Ssobomax#define AFMT_A_LAW	0x00000002	/* Logarithmic A-law */
16281891Ssobomax#define AFMT_IMA_ADPCM	0x00000004	/* A 4:1 compressed format where 16-bit
16381891Ssobomax					 * squence represented using the
16481891Ssobomax					 * the average 4 bits per sample */
16581891Ssobomax#define AFMT_U8		0x00000008	/* Unsigned 8-bit */
16681891Ssobomax#define AFMT_S16_LE	0x00000010	/* Little endian signed 16-bit */
16781891Ssobomax#define AFMT_S16_BE	0x00000020	/* Big endian signed 16-bit */
16881891Ssobomax#define AFMT_S8		0x00000040	/* Signed 8-bit */
16981891Ssobomax#define AFMT_U16_LE	0x00000080	/* Little endian unsigned 16-bit */
17081891Ssobomax#define AFMT_U16_BE	0x00000100	/* Big endian unsigned 16-bit */
17181891Ssobomax#define AFMT_MPEG	0x00000200	/* MPEG MP2/MP3 audio */
17281891Ssobomax#define AFMT_AC3	0x00000400	/* Dolby Digital AC3 */
173114181Smbr
17465335Scg/*
17581891Ssobomax * 32-bit formats below used for 24-bit audio data where the data is stored
17681891Ssobomax * in the 24 most significant bits and the least significant bits are not used
17781891Ssobomax * (should be set to 0).
17865335Scg */
17981891Ssobomax#define AFMT_S32_LE	0x00001000	/* Little endian signed 32-bit */
18081891Ssobomax#define AFMT_S32_BE	0x00002000	/* Big endian signed 32-bit */
18181891Ssobomax#define AFMT_U32_LE	0x00004000	/* Little endian unsigned 32-bit */
18281891Ssobomax#define AFMT_U32_BE	0x00008000	/* Big endian unsigned 32-bit */
183148605Snetchild#define AFMT_S24_LE	0x00010000	/* Little endian signed 24-bit */
184148605Snetchild#define AFMT_S24_BE	0x00020000	/* Big endian signed 24-bit */
185148605Snetchild#define AFMT_U24_LE	0x00040000	/* Little endian unsigned 24-bit */
186148605Snetchild#define AFMT_U24_BE	0x00080000	/* Big endian unsigned 24-bit */
18733473Sscrappy
188193886Sariff/* Machine dependant AFMT_* definitions. */
189193886Sariff#if BYTE_ORDER == LITTLE_ENDIAN
190193886Sariff#define AFMT_S16_NE	AFMT_S16_LE
191193886Sariff#define AFMT_S24_NE	AFMT_S24_LE
192193886Sariff#define AFMT_S32_NE	AFMT_S32_LE
193193886Sariff#define AFMT_U16_NE	AFMT_U16_LE
194193886Sariff#define AFMT_U24_NE	AFMT_U24_LE
195193886Sariff#define AFMT_U32_NE	AFMT_U32_LE
196193886Sariff#define AFMT_S16_OE	AFMT_S16_BE
197193886Sariff#define AFMT_S24_OE	AFMT_S24_BE
198193886Sariff#define AFMT_S32_OE	AFMT_S32_BE
199193886Sariff#define AFMT_U16_OE	AFMT_U16_BE
200193886Sariff#define AFMT_U24_OE	AFMT_U24_BE
201193886Sariff#define AFMT_U32_OE	AFMT_U32_BE
202193886Sariff#else
203193886Sariff#define AFMT_S16_OE	AFMT_S16_LE
204193886Sariff#define AFMT_S24_OE	AFMT_S24_LE
205193886Sariff#define AFMT_S32_OE	AFMT_S32_LE
206193886Sariff#define AFMT_U16_OE	AFMT_U16_LE
207193886Sariff#define AFMT_U24_OE	AFMT_U24_LE
208193886Sariff#define AFMT_U32_OE	AFMT_U32_LE
209193886Sariff#define AFMT_S16_NE	AFMT_S16_BE
210193886Sariff#define AFMT_S24_NE	AFMT_S24_BE
211193886Sariff#define AFMT_S32_NE	AFMT_S32_BE
212193886Sariff#define AFMT_U16_NE	AFMT_U16_BE
213193886Sariff#define AFMT_U24_NE	AFMT_U24_BE
214193886Sariff#define AFMT_U32_NE	AFMT_U32_BE
215193886Sariff#endif
216193886Sariff
21781891Ssobomax#define AFMT_STEREO	0x10000000	/* can do/want stereo	*/
21833473Sscrappy
21933473Sscrappy/*
22033473Sscrappy * the following are really capabilities
22133473Sscrappy */
22281891Ssobomax#define AFMT_WEIRD	0x20000000	/* weird hardware...	*/
22333473Sscrappy    /*
22433473Sscrappy     * AFMT_WEIRD reports that the hardware might need to operate
22533473Sscrappy     * with different formats in the playback and capture
22633473Sscrappy     * channels when operating in full duplex.
22733473Sscrappy     * As an example, SoundBlaster16 cards only support U8 in one
22833473Sscrappy     * direction and S16 in the other one, and applications should
22933473Sscrappy     * be aware of this limitation.
23033473Sscrappy     */
23181891Ssobomax#define AFMT_FULLDUPLEX	0x80000000	/* can do full duplex	*/
23233473Sscrappy
23333473Sscrappy/*
23433473Sscrappy * The following structure is used to get/set format and sampling rate.
23533473Sscrappy * While it would be better to have things such as stereo, bits per
23633473Sscrappy * sample, endiannes, etc split in different variables, it turns out
23733473Sscrappy * that formats are not that many, and not all combinations are possible.
23833473Sscrappy * So we followed the Voxware approach of associating one bit to each
23933473Sscrappy * format.
24033473Sscrappy */
24133473Sscrappy
24233473Sscrappytypedef struct _snd_chan_param {
24333473Sscrappy    u_long	play_rate;	/* sampling rate			*/
24433473Sscrappy    u_long	rec_rate;	/* sampling rate			*/
24533473Sscrappy    u_long	play_format;	/* everything describing the format	*/
24633473Sscrappy    u_long	rec_format;	/* everything describing the format	*/
24733473Sscrappy} snd_chan_param;
24833473Sscrappy#define	AIOGFMT    _IOR('f', 12, snd_chan_param)   /* get format */
24933473Sscrappy#define	AIOSFMT    _IOWR('f', 12, snd_chan_param)  /* sets format */
25033473Sscrappy
25133473Sscrappy/*
25233473Sscrappy * The following structure is used to get/set the mixer setting.
25333473Sscrappy * Up to 32 mixers are supported, each one with up to 32 channels.
25433473Sscrappy */
25533473Sscrappytypedef struct _snd_mix_param {
25633473Sscrappy    u_char	subdev;	/* which output				*/
25733473Sscrappy    u_char	line;	/* which input				*/
25833473Sscrappy    u_char	left,right; /* volumes, 0..255, 0 = mute	*/
25933473Sscrappy} snd_mix_param ;
26033473Sscrappy
26133473Sscrappy/* XXX AIOGMIX, AIOSMIX not implemented yet */
26233473Sscrappy#define AIOGMIX	_IOWR('A', 13, snd_mix_param)	/* return mixer status */
26333473Sscrappy#define AIOSMIX	_IOWR('A', 14, snd_mix_param)	/* sets mixer status   */
26433473Sscrappy
26533473Sscrappy/*
26633473Sscrappy * channel specifiers used in AIOSTOP and AIOSYNC
26733473Sscrappy */
26833473Sscrappy#define	AIOSYNC_PLAY	0x1	/* play chan */
26933473Sscrappy#define	AIOSYNC_CAPTURE	0x2	/* capture chan */
27033473Sscrappy/* AIOSTOP stop & flush a channel, returns the residual count */
27133473Sscrappy#define	AIOSTOP	_IOWR ('A', 15, int)
27233473Sscrappy
27333473Sscrappy/* alternate method used to notify the sync condition */
27433473Sscrappy#define	AIOSYNC_SIGNAL	0x100
27533473Sscrappy#define	AIOSYNC_SELECT	0x200
27633473Sscrappy
27733473Sscrappy/* what the 'pos' field refers to */
27833473Sscrappy#define AIOSYNC_READY	0x400
27933473Sscrappy#define AIOSYNC_FREE	0x800
28033473Sscrappy
28133473Sscrappytypedef struct _snd_sync_parm {
28233473Sscrappy    long chan ; /* play or capture channel, plus modifier */
28333473Sscrappy    long pos;
28433473Sscrappy} snd_sync_parm;
28533473Sscrappy#define	AIOSYNC	_IOWR ('A', 15, snd_sync_parm)	/* misc. synchronization */
28633473Sscrappy
28733473Sscrappy/*
28833473Sscrappy * The following is used to return device capabilities. If the structure
28933473Sscrappy * passed to the ioctl is zeroed, default values are returned for rate
29033473Sscrappy * and formats, a bitmap of available mixers is returned, and values
29133473Sscrappy * (inputs, different levels) for the first one are returned.
29233473Sscrappy *
29333473Sscrappy * If  formats, mixers, inputs are instantiated, then detailed info
29433473Sscrappy * are returned depending on the call.
29533473Sscrappy */
29633473Sscrappytypedef struct _snd_capabilities {
29733473Sscrappy    u_long	rate_min, rate_max;	/* min-max sampling rate */
29833473Sscrappy    u_long	formats;
29933473Sscrappy    u_long	bufsize; /* DMA buffer size */
30033473Sscrappy    u_long	mixers; /* bitmap of available mixers */
30133473Sscrappy    u_long	inputs; /* bitmap of available inputs (per mixer) */
30233473Sscrappy    u_short	left, right;	/* how many levels are supported */
30333473Sscrappy} snd_capabilities;
30433473Sscrappy#define AIOGCAP	_IOWR('A', 15, snd_capabilities)	/* get capabilities */
30533473Sscrappy
30633473Sscrappy/*
30733473Sscrappy * here is the old (Voxware) ioctl interface
30833473Sscrappy */
30933473Sscrappy
31033473Sscrappy/*
311652Sjkh * IOCTL Commands for /dev/sequencer
312652Sjkh */
313652Sjkh
31433473Sscrappy#define SNDCTL_SEQ_RESET	_IO  ('Q', 0)
31533473Sscrappy#define SNDCTL_SEQ_SYNC		_IO  ('Q', 1)
31633473Sscrappy#define SNDCTL_SYNTH_INFO	_IOWR('Q', 2, struct synth_info)
31733473Sscrappy#define SNDCTL_SEQ_CTRLRATE	_IOWR('Q', 3, int) /* Set/get timer res.(hz) */
31833473Sscrappy#define SNDCTL_SEQ_GETOUTCOUNT	_IOR ('Q', 4, int)
31933473Sscrappy#define SNDCTL_SEQ_GETINCOUNT	_IOR ('Q', 5, int)
32033473Sscrappy#define SNDCTL_SEQ_PERCMODE	_IOW ('Q', 6, int)
32133473Sscrappy#define SNDCTL_FM_LOAD_INSTR	_IOW ('Q', 7, struct sbi_instrument)	/* Valid for FM only */
32233473Sscrappy#define SNDCTL_SEQ_TESTMIDI	_IOW ('Q', 8, int)
32333473Sscrappy#define SNDCTL_SEQ_RESETSAMPLES	_IOW ('Q', 9, int)
32433473Sscrappy#define SNDCTL_SEQ_NRSYNTHS	_IOR ('Q',10, int)
32533473Sscrappy#define SNDCTL_SEQ_NRMIDIS	_IOR ('Q',11, int)
32633473Sscrappy#define SNDCTL_MIDI_INFO	_IOWR('Q',12, struct midi_info)
32733473Sscrappy#define SNDCTL_SEQ_THRESHOLD	_IOW ('Q',13, int)
32833473Sscrappy#define SNDCTL_SEQ_TRESHOLD	SNDCTL_SEQ_THRESHOLD	/* there was once a typo */
32933473Sscrappy#define SNDCTL_SYNTH_MEMAVL	_IOWR('Q',14, int) /* in=dev#, out=memsize */
33033473Sscrappy#define SNDCTL_FM_4OP_ENABLE	_IOW ('Q',15, int) /* in=dev# */
33133473Sscrappy#define SNDCTL_PMGR_ACCESS	_IOWR('Q',16, struct patmgr_info)
33233473Sscrappy#define SNDCTL_SEQ_PANIC	_IO  ('Q',17)
33333473Sscrappy#define SNDCTL_SEQ_OUTOFBAND	_IOW ('Q',18, struct seq_event_rec)
334122954Smatk#define SNDCTL_SEQ_GETTIME	_IOR ('Q',19, int)
3359750Sjkh
33630866Smarkmstruct seq_event_rec {
33730866Smarkm	u_char arr[8];
33830866Smarkm};
3399750Sjkh
34033473Sscrappy#define SNDCTL_TMR_TIMEBASE	_IOWR('T', 1, int)
34133473Sscrappy#define SNDCTL_TMR_START	_IO  ('T', 2)
34233473Sscrappy#define SNDCTL_TMR_STOP		_IO  ('T', 3)
34333473Sscrappy#define SNDCTL_TMR_CONTINUE	_IO  ('T', 4)
34433473Sscrappy#define SNDCTL_TMR_TEMPO	_IOWR('T', 5, int)
34533473Sscrappy#define SNDCTL_TMR_SOURCE	_IOWR('T', 6, int)
34633473Sscrappy#   define TMR_INTERNAL		0x00000001
34733473Sscrappy#   define TMR_EXTERNAL		0x00000002
34833473Sscrappy#	define TMR_MODE_MIDI	0x00000010
34933473Sscrappy#	define TMR_MODE_FSK	0x00000020
35033473Sscrappy#	define TMR_MODE_CLS	0x00000040
35133473Sscrappy#	define TMR_MODE_SMPTE	0x00000080
35233473Sscrappy#define SNDCTL_TMR_METRONOME	_IOW ('T', 7, int)
35333473Sscrappy#define SNDCTL_TMR_SELECT	_IOW ('T', 8, int)
3543256Sswallace
355652Sjkh/*
35630866Smarkm *	Endian aware patch key generation algorithm.
35730866Smarkm */
35830866Smarkm
35930866Smarkm#if defined(_AIX) || defined(AIX)
36030866Smarkm#  define _PATCHKEY(id) (0xfd00|id)
36130866Smarkm#else
36230866Smarkm#  define _PATCHKEY(id) ((id<<8)|0xfd)
36330866Smarkm#endif
36430866Smarkm
36530866Smarkm/*
366652Sjkh *	Sample loading mechanism for internal synthesizers (/dev/sequencer)
367652Sjkh *	The following patch_info structure has been designed to support
368652Sjkh *	Gravis UltraSound. It tries to be universal format for uploading
36933473Sscrappy *	sample based patches but is probably too limited.
370652Sjkh */
371652Sjkh
372652Sjkhstruct patch_info {
37330866Smarkm/*		u_short key;		 Use GUS_PATCH here */
37430866Smarkm	short key;		 /* Use GUS_PATCH here */
37530866Smarkm#define GUS_PATCH	_PATCHKEY(0x04)
37630866Smarkm#define OBSOLETE_GUS_PATCH	_PATCHKEY(0x02)
377652Sjkh
37830866Smarkm	short device_no;	/* Synthesizer number */
37930866Smarkm	short instr_no;		/* Midi pgm# */
38030866Smarkm
38130866Smarkm	u_long mode;
382652Sjkh/*
383652Sjkh * The least significant byte has the same format than the GUS .PAT
384652Sjkh * files
385652Sjkh */
386652Sjkh#define WAVE_16_BITS	0x01	/* bit 0 = 8 or 16 bit wave data. */
387652Sjkh#define WAVE_UNSIGNED	0x02	/* bit 1 = Signed - Unsigned data. */
388652Sjkh#define WAVE_LOOPING	0x04	/* bit 2 = looping enabled-1. */
389652Sjkh#define WAVE_BIDIR_LOOP	0x08	/* bit 3 = Set is bidirectional looping. */
390652Sjkh#define WAVE_LOOP_BACK	0x10	/* bit 4 = Set is looping backward. */
391652Sjkh#define WAVE_SUSTAIN_ON	0x20	/* bit 5 = Turn sustaining on. (Env. pts. 3)*/
392652Sjkh#define WAVE_ENVELOPES	0x40	/* bit 6 = Enable envelopes - 1 */
393652Sjkh				/* 	(use the env_rate/env_offs fields). */
394652Sjkh/* Linux specific bits */
395652Sjkh#define WAVE_VIBRATO	0x00010000	/* The vibrato info is valid */
396652Sjkh#define WAVE_TREMOLO	0x00020000	/* The tremolo info is valid */
397652Sjkh#define WAVE_SCALE	0x00040000	/* The scaling info is valid */
398652Sjkh/* Other bits must be zeroed */
399652Sjkh
40030866Smarkm	long len;	/* Size of the wave data in bytes */
40130866Smarkm	long loop_start, loop_end; /* Byte offsets from the beginning */
402652Sjkh
40365335Scg/*
404652Sjkh * The base_freq and base_note fields are used when computing the
405652Sjkh * playback speed for a note. The base_note defines the tone frequency
406652Sjkh * which is heard if the sample is played using the base_freq as the
407652Sjkh * playback speed.
408652Sjkh *
409652Sjkh * The low_note and high_note fields define the minimum and maximum note
410652Sjkh * frequencies for which this sample is valid. It is possible to define
411108533Sschweikh * more than one samples for an instrument number at the same time. The
412652Sjkh * low_note and high_note fields are used to select the most suitable one.
413652Sjkh *
414652Sjkh * The fields base_note, high_note and low_note should contain
415652Sjkh * the note frequency multiplied by 1000. For example value for the
416652Sjkh * middle A is 440*1000.
417652Sjkh */
418652Sjkh
41930866Smarkm	u_int base_freq;
42030866Smarkm	u_long base_note;
42130866Smarkm	u_long high_note;
42230866Smarkm	u_long low_note;
42330866Smarkm	int panning;	/* -128=left, 127=right */
42430866Smarkm	int detuning;
425652Sjkh
426652Sjkh/*	New fields introduced in version 1.99.5	*/
427652Sjkh
428652Sjkh       /* Envelope. Enabled by mode bit WAVE_ENVELOPES	*/
42930866Smarkm	u_char	env_rate[ 6 ];	 /* GUS HW ramping rate */
43030866Smarkm	u_char	env_offset[ 6 ]; /* 255 == 100% */
431652Sjkh
43265335Scg	/*
433652Sjkh	 * The tremolo, vibrato and scale info are not supported yet.
434652Sjkh	 * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or
435652Sjkh	 * WAVE_SCALE
436652Sjkh	 */
437652Sjkh
43830866Smarkm	u_char	tremolo_sweep;
43930866Smarkm	u_char	tremolo_rate;
44030866Smarkm	u_char	tremolo_depth;
441652Sjkh
44230866Smarkm	u_char	vibrato_sweep;
44330866Smarkm	u_char	vibrato_rate;
44430866Smarkm	u_char	vibrato_depth;
44530866Smarkm
44630866Smarkm	int		scale_frequency;
44730866Smarkm	u_int	scale_factor;		/* from 0 to 2048 or 0 to 2 */
44865335Scg
44930866Smarkm	int		volume;
45030866Smarkm	int		spare[4];
45130866Smarkm	char data[1];	/* The waveform data starts here */
45230866Smarkm};
453652Sjkh
4543256Sswallacestruct sysex_info {
45530866Smarkm	short key;		/* Use GUS_PATCH here */
45630866Smarkm#define SYSEX_PATCH	_PATCHKEY(0x05)
45730866Smarkm#define MAUI_PATCH	_PATCHKEY(0x06)
45830866Smarkm	short device_no;	/* Synthesizer number */
45930866Smarkm	long len;	/* Size of the sysex data in bytes */
46030866Smarkm	u_char data[1];	/* Sysex data starts here */
46130866Smarkm};
4623256Sswallace
463652Sjkh/*
464652Sjkh * Patch management interface (/dev/sequencer, /dev/patmgr#)
465652Sjkh * Don't use these calls if you want to maintain compatibility with
466652Sjkh * the future versions of the driver.
467652Sjkh */
468652Sjkh
46933473Sscrappy#define PS_NO_PATCHES		0	/* No patch support on device */
47033473Sscrappy#define	PS_MGR_NOT_OK		1	/* Plain patch support (no mgr) */
47133473Sscrappy#define	PS_MGR_OK		2	/* Patch manager supported */
47233473Sscrappy#define	PS_MANAGED		3	/* Patch manager running */
473652Sjkh
474652Sjkh#define SNDCTL_PMGR_IFACE		_IOWR('P', 1, struct patmgr_info)
475652Sjkh
476652Sjkh/*
477652Sjkh * The patmgr_info is a fixed size structure which is used for two
478652Sjkh * different purposes. The intended use is for communication between
479652Sjkh * the application using /dev/sequencer and the patch manager daemon
480652Sjkh * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)).
481652Sjkh *
482652Sjkh * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows
483652Sjkh * a patch manager daemon to read and write device parameters. This
484652Sjkh * ioctl available through /dev/sequencer also. Avoid using it since it's
48565335Scg * extremely hardware dependent. In addition access trough /dev/sequencer
486652Sjkh * may confuse the patch manager daemon.
487652Sjkh */
488652Sjkh
489652Sjkhstruct patmgr_info {	/* Note! size must be < 4k since kmalloc() is used */
49030866Smarkm	  u_long key;	/* Don't worry. Reserved for communication
491652Sjkh	  			   between the patch manager and the driver. */
492652Sjkh#define PM_K_EVENT		1 /* Event from the /dev/sequencer driver */
493108533Sschweikh#define PM_K_COMMAND		2 /* Request from an application */
494652Sjkh#define PM_K_RESPONSE		3 /* From patmgr to application */
495652Sjkh#define PM_ERROR		4 /* Error returned by the patmgr */
496652Sjkh	  int device;
497652Sjkh	  int command;
498652Sjkh
49965335Scg/*
50065335Scg * Commands 0x000 to 0xfff reserved for patch manager programs
501652Sjkh */
502652Sjkh#define PM_GET_DEVTYPE	1	/* Returns type of the patch mgr interface of dev */
503652Sjkh#define		PMTYPE_FM2	1	/* 2 OP fm */
504652Sjkh#define		PMTYPE_FM4	2	/* Mixed 4 or 2 op FM (OPL-3) */
505652Sjkh#define		PMTYPE_WAVE	3	/* Wave table synthesizer (GUS) */
506652Sjkh#define PM_GET_NRPGM	2	/* Returns max # of midi programs in parm1 */
507652Sjkh#define PM_GET_PGMMAP	3	/* Returns map of loaded midi programs in data8 */
508652Sjkh#define PM_GET_PGM_PATCHES 4	/* Return list of patches of a program (parm1) */
509652Sjkh#define PM_GET_PATCH	5	/* Return patch header of patch parm1 */
510652Sjkh#define PM_SET_PATCH	6	/* Set patch header of patch parm1 */
511652Sjkh#define PM_READ_PATCH	7	/* Read patch (wave) data */
512652Sjkh#define PM_WRITE_PATCH	8	/* Write patch (wave) data */
513652Sjkh
514652Sjkh/*
515652Sjkh * Commands 0x1000 to 0xffff are for communication between the patch manager
516652Sjkh * and the client
517652Sjkh */
518652Sjkh#define _PM_LOAD_PATCH	0x100
519652Sjkh
52065335Scg/*
521652Sjkh * Commands above 0xffff reserved for device specific use
522652Sjkh */
523652Sjkh
52430866Smarkm	long parm1;
52530866Smarkm	long parm2;
52630866Smarkm	long parm3;
527652Sjkh
52830866Smarkm	union {
52930866Smarkm		u_char data8[4000];
53030866Smarkm		u_short data16[2000];
53130866Smarkm		u_long data32[1000];
532652Sjkh		struct patch_info patch;
53330866Smarkm	} data;
53430866Smarkm};
535652Sjkh
536652Sjkh/*
537652Sjkh * When a patch manager daemon is present, it will be informed by the
538652Sjkh * driver when something important happens. For example when the
539652Sjkh * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is
540652Sjkh * returned. The command field contains the event type:
541652Sjkh */
542652Sjkh#define PM_E_OPENED		1	/* /dev/sequencer opened */
543652Sjkh#define PM_E_CLOSED		2	/* /dev/sequencer closed */
544652Sjkh#define PM_E_PATCH_RESET	3	/* SNDCTL_RESETSAMPLES called */
545652Sjkh#define PM_E_PATCH_LOADED	4	/* A patch has been loaded by appl */
546652Sjkh
547652Sjkh/*
548652Sjkh * /dev/sequencer input events.
549652Sjkh *
550652Sjkh * The data written to the /dev/sequencer is a stream of events. Events
55165335Scg * are records of 4 or 8 bytes. The first byte defines the size.
552652Sjkh * Any number of events can be written with a write call. There
553652Sjkh * is a set of macros for sending these events. Use these macros if you
554652Sjkh * want to maximize portability of your program.
555652Sjkh *
556652Sjkh * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events.
557652Sjkh * (All input events are currently 4 bytes long. Be prepared to support
5583256Sswallace * 8 byte events also. If you receive any event having first byte >= 128,
559652Sjkh * it's a 8 byte event.
560652Sjkh *
561652Sjkh * The events are documented at the end of this file.
562652Sjkh *
563652Sjkh * Normal events (4 bytes)
564652Sjkh * There is also a 8 byte version of most of the 4 byte events. The
565652Sjkh * 8 byte one is recommended.
566652Sjkh */
567652Sjkh#define SEQ_NOTEOFF		0
568652Sjkh#define SEQ_FMNOTEOFF		SEQ_NOTEOFF	/* Just old name */
569652Sjkh#define SEQ_NOTEON		1
570652Sjkh#define	SEQ_FMNOTEON		SEQ_NOTEON
5713256Sswallace#define SEQ_WAIT		TMR_WAIT_ABS
572652Sjkh#define SEQ_PGMCHANGE		3
573652Sjkh#define SEQ_FMPGMCHANGE		SEQ_PGMCHANGE
5743256Sswallace#define SEQ_SYNCTIMER		TMR_START
575652Sjkh#define SEQ_MIDIPUTC		5
576652Sjkh#define SEQ_DRUMON		6	/*** OBSOLETE ***/
577652Sjkh#define SEQ_DRUMOFF		7	/*** OBSOLETE ***/
5783256Sswallace#define SEQ_ECHO		TMR_ECHO	/* For synching programs with output */
579652Sjkh#define SEQ_AFTERTOUCH		9
580652Sjkh#define SEQ_CONTROLLER		10
5813256Sswallace
58233473Sscrappy/*
5833256Sswallace *	Midi controller numbers
58433473Sscrappy *
58533473Sscrappy * Controllers 0 to 31 (0x00 to 0x1f) and 32 to 63 (0x20 to 0x3f)
58633473Sscrappy * are continuous controllers.
58733473Sscrappy * In the MIDI 1.0 these controllers are sent using two messages.
58833473Sscrappy * Controller numbers 0 to 31 are used to send the MSB and the
58933473Sscrappy * controller numbers 32 to 63 are for the LSB. Note that just 7 bits
59033473Sscrappy * are used in MIDI bytes.
5913256Sswallace */
5923256Sswallace
59333473Sscrappy#define	CTL_BANK_SELECT		0x00
59433473Sscrappy#define	CTL_MODWHEEL		0x01
59533473Sscrappy#define CTL_BREATH		0x02
59633473Sscrappy/*	undefined		0x03 */
59733473Sscrappy#define CTL_FOOT		0x04
59833473Sscrappy#define CTL_PORTAMENTO_TIME	0x05
59933473Sscrappy#define CTL_DATA_ENTRY		0x06
60033473Sscrappy#define CTL_MAIN_VOLUME		0x07
60133473Sscrappy#define CTL_BALANCE		0x08
60233473Sscrappy/*	undefined		0x09 */
60333473Sscrappy#define CTL_PAN			0x0a
60433473Sscrappy#define CTL_EXPRESSION		0x0b
60533473Sscrappy/*	undefined		0x0c - 0x0f */
60633473Sscrappy#define CTL_GENERAL_PURPOSE1	0x10
60733473Sscrappy#define CTL_GENERAL_PURPOSE2	0x11
60833473Sscrappy#define CTL_GENERAL_PURPOSE3	0x12
60933473Sscrappy#define CTL_GENERAL_PURPOSE4	0x13
61033473Sscrappy/*	undefined		0x14 - 0x1f */
6113256Sswallace
61233473Sscrappy/*	undefined		0x20 */
6133256Sswallace
61433473Sscrappy/*
61533473Sscrappy * The controller numbers 0x21 to 0x3f are reserved for the
61633473Sscrappy * least significant bytes of the controllers 0x00 to 0x1f.
61733473Sscrappy * These controllers are not recognised by the driver.
61833473Sscrappy *
61933473Sscrappy * Controllers 64 to 69 (0x40 to 0x45) are on/off switches.
62033473Sscrappy * 0=OFF and 127=ON (intermediate values are possible)
62133473Sscrappy */
62233473Sscrappy#define CTL_DAMPER_PEDAL	0x40
62333473Sscrappy#define CTL_SUSTAIN		CTL_DAMPER_PEDAL	/* Alias */
62433473Sscrappy#define CTL_HOLD		CTL_DAMPER_PEDAL	/* Alias */
62533473Sscrappy#define CTL_PORTAMENTO		0x41
62633473Sscrappy#define CTL_SOSTENUTO		0x42
62733473Sscrappy#define CTL_SOFT_PEDAL		0x43
62833473Sscrappy/*	undefined		0x44 */
62933473Sscrappy#define CTL_HOLD2		0x45
63033473Sscrappy/*	undefined		0x46 - 0x4f */
6313256Sswallace
63233473Sscrappy#define CTL_GENERAL_PURPOSE5	0x50
63333473Sscrappy#define CTL_GENERAL_PURPOSE6	0x51
63433473Sscrappy#define CTL_GENERAL_PURPOSE7	0x52
63533473Sscrappy#define CTL_GENERAL_PURPOSE8	0x53
63633473Sscrappy/*	undefined		0x54 - 0x5a */
63733473Sscrappy#define CTL_EXT_EFF_DEPTH	0x5b
63833473Sscrappy#define CTL_TREMOLO_DEPTH	0x5c
63933473Sscrappy#define CTL_CHORUS_DEPTH	0x5d
64033473Sscrappy#define CTL_DETUNE_DEPTH	0x5e
64133473Sscrappy#define CTL_CELESTE_DEPTH	CTL_DETUNE_DEPTH /* Alias for the above one */
64233473Sscrappy#define CTL_PHASER_DEPTH	0x5f
64333473Sscrappy#define CTL_DATA_INCREMENT	0x60
64433473Sscrappy#define CTL_DATA_DECREMENT	0x61
64533473Sscrappy#define CTL_NONREG_PARM_NUM_LSB	0x62
64633473Sscrappy#define CTL_NONREG_PARM_NUM_MSB	0x63
64733473Sscrappy#define CTL_REGIST_PARM_NUM_LSB	0x64
64833473Sscrappy#define CTL_REGIST_PARM_NUM_MSB	0x65
64933473Sscrappy/*	undefined		0x66 - 0x78 */
65033473Sscrappy/*	reserved		0x79 - 0x7f */
6513256Sswallace
6523256Sswallace/* Pseudo controllers (not midi compatible) */
65333473Sscrappy#define CTRL_PITCH_BENDER	255
65433473Sscrappy#define CTRL_PITCH_BENDER_RANGE	254
65533473Sscrappy#define CTRL_EXPRESSION		253	/* Obsolete */
65633473Sscrappy#define CTRL_MAIN_VOLUME	252	/* Obsolete */
65733473Sscrappy
658652Sjkh#define SEQ_BALANCE		11
6591402Sache#define SEQ_VOLMODE             12
660652Sjkh
661652Sjkh/*
6621402Sache * Volume mode decides how volumes are used
6631402Sache */
6641402Sache
6651402Sache#define VOL_METHOD_ADAGIO	1
6661402Sache#define VOL_METHOD_LINEAR	2
6671402Sache
6681402Sache/*
669652Sjkh * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as
670652Sjkh *	 input events.
671652Sjkh */
672652Sjkh
673652Sjkh/*
674652Sjkh * Event codes 0xf0 to 0xfc are reserved for future extensions.
675652Sjkh */
676652Sjkh
677652Sjkh#define SEQ_FULLSIZE		0xfd	/* Long events */
678652Sjkh/*
67933473Sscrappy * SEQ_FULLSIZE events are used for loading patches/samples to the
68033473Sscrappy * synthesizer devices. These events are passed directly to the driver
68133473Sscrappy * of the associated synthesizer device. There is no limit to the size
68233473Sscrappy * of the extended events. These events are not queued but executed
68333473Sscrappy * immediately when the write() is called (execution can take several
68465335Scg * seconds of time).
685652Sjkh *
68633473Sscrappy * When a SEQ_FULLSIZE message is written to the device, it must
68733473Sscrappy * be written using exactly one write() call. Other events cannot
68833473Sscrappy * be mixed to the same write.
68965335Scg *
69033473Sscrappy * For FM synths (YM3812/OPL3) use struct sbi_instrument and write
69133473Sscrappy * it to the /dev/sequencer. Don't write other data together with
69233473Sscrappy * the instrument structure Set the key field of the structure to
69333473Sscrappy * FM_PATCH. The device field is used to route the patch to the
69433473Sscrappy * corresponding device.
695652Sjkh *
69633473Sscrappy * For Gravis UltraSound use struct patch_info. Initialize the key field
69733473Sscrappy * to GUS_PATCH.
698652Sjkh */
69933473Sscrappy#define SEQ_PRIVATE	0xfe	/* Low level HW dependent events (8 bytes) */
70033473Sscrappy#define SEQ_EXTENDED	0xff	/* Extended events (8 bytes) OBSOLETE */
701652Sjkh
702652Sjkh/*
703652Sjkh * Record for FM patches
704652Sjkh */
705652Sjkh
70630866Smarkmtypedef u_char sbi_instr_data[32];
707652Sjkh
708652Sjkhstruct sbi_instrument {
70930866Smarkm	u_short	key;	/* FM_PATCH or OPL3_PATCH */
71030866Smarkm#define FM_PATCH	_PATCHKEY(0x01)
71130866Smarkm#define OPL3_PATCH	_PATCHKEY(0x03)
71230866Smarkm	short		device;		/* Synth# (0-4)	*/
71330866Smarkm	int 		channel;	/* Program# to be initialized  */
71430866Smarkm	sbi_instr_data	operators;	/* Reg. settings for operator cells
71530866Smarkm					 * (.SBI format)	*/
71630866Smarkm};
717652Sjkh
718652Sjkhstruct synth_info {	/* Read only */
71945462Skato	char	name[30];
72030866Smarkm	int	device;		/* 0-N. INITIALIZE BEFORE CALLING */
72130866Smarkm	int	synth_type;
722652Sjkh#define SYNTH_TYPE_FM			0
723652Sjkh#define SYNTH_TYPE_SAMPLE		1
7243256Sswallace#define SYNTH_TYPE_MIDI			2	/* Midi interface */
725652Sjkh
72630866Smarkm	int	synth_subtype;
727652Sjkh#define FM_TYPE_ADLIB			0x00
728652Sjkh#define FM_TYPE_OPL3			0x01
729122954Smatk#define MIDI_TYPE_MPU401		0x401
730652Sjkh
73133473Sscrappy#define SAMPLE_TYPE_BASIC		0x10
73233473Sscrappy#define SAMPLE_TYPE_GUS			SAMPLE_TYPE_BASIC
73333530Sscrappy#define SAMPLE_TYPE_AWE32		0x20
734652Sjkh
73530866Smarkm	int	perc_mode;	/* No longer supported */
73630866Smarkm	int	nr_voices;
73730866Smarkm	int	nr_drums;	/* Obsolete field */
73830866Smarkm	int	instr_bank_size;
73965335Scg	u_long	capabilities;
74033473Sscrappy#define SYNTH_CAP_PERCMODE	0x00000001 /* No longer used */
74133473Sscrappy#define SYNTH_CAP_OPL3		0x00000002 /* Set if OPL3 supported */
74233473Sscrappy#define SYNTH_CAP_INPUT		0x00000004 /* Input (MIDI) device */
74330866Smarkm	int	dummies[19];	/* Reserve space */
74430866Smarkm};
745652Sjkh
7463256Sswallacestruct sound_timer_info {
74730866Smarkm	char name[32];
74830866Smarkm	int caps;
74930866Smarkm};
7503256Sswallace
751652Sjkhstruct midi_info {
75230866Smarkm	char		name[30];
75330866Smarkm	int		device;		/* 0-N. INITIALIZE BEFORE CALLING */
75430866Smarkm	u_long	capabilities;	/* To be defined later */
75530866Smarkm	int		dev_type;
75630866Smarkm	int		dummies[18];	/* Reserve space */
75730866Smarkm};
758652Sjkh
75933473Sscrappy/*
7603256Sswallace * ioctl commands for the /dev/midi##
7613256Sswallace */
7623256Sswallacetypedef struct {
76330866Smarkm	u_char cmd;
76430866Smarkm	char nr_args, nr_returns;
76530866Smarkm	u_char data[30];
76630866Smarkm} mpu_command_rec;
7673256Sswallace
76833473Sscrappy#define SNDCTL_MIDI_PRETIME	_IOWR('m', 0, int)
76933473Sscrappy#define SNDCTL_MIDI_MPUMODE	_IOWR('m', 1, int)
77033473Sscrappy#define SNDCTL_MIDI_MPUCMD	_IOWR('m', 2, mpu_command_rec)
77162947Stanimura#define MIOSPASSTHRU		_IOWR('m', 3, int)
77262947Stanimura#define MIOGPASSTHRU		_IOWR('m', 4, int)
7733256Sswallace
77433473Sscrappy/*
775652Sjkh * IOCTL commands for /dev/dsp and /dev/audio
776652Sjkh */
777652Sjkh
77833473Sscrappy#define SNDCTL_DSP_RESET	_IO  ('P', 0)
77933473Sscrappy#define SNDCTL_DSP_SYNC		_IO  ('P', 1)
78033473Sscrappy#define SNDCTL_DSP_SPEED	_IOWR('P', 2, int)
78133473Sscrappy#define SNDCTL_DSP_STEREO	_IOWR('P', 3, int)
78233473Sscrappy#define SNDCTL_DSP_GETBLKSIZE	_IOR('P', 4, int)
78333473Sscrappy#define SNDCTL_DSP_SETBLKSIZE   _IOW('P', 4, int)
78433473Sscrappy#define SNDCTL_DSP_SETFMT	_IOWR('P',5, int) /* Selects ONE fmt*/
78533473Sscrappy
78633473Sscrappy/*
78733473Sscrappy * SOUND_PCM_WRITE_CHANNELS is not that different
78833473Sscrappy * from SNDCTL_DSP_STEREO
78933473Sscrappy */
790652Sjkh#define SOUND_PCM_WRITE_CHANNELS	_IOWR('P', 6, int)
79165335Scg#define SNDCTL_DSP_CHANNELS	SOUND_PCM_WRITE_CHANNELS
79233473Sscrappy#define SOUND_PCM_WRITE_FILTER	_IOWR('P', 7, int)
79333473Sscrappy#define SNDCTL_DSP_POST		_IO  ('P', 8)
794652Sjkh
79533473Sscrappy/*
79633473Sscrappy * SNDCTL_DSP_SETBLKSIZE and the following two calls mostly do
79733473Sscrappy * the same thing, i.e. set the block size used in DMA transfers.
79833473Sscrappy */
79933473Sscrappy#define SNDCTL_DSP_SUBDIVIDE	_IOWR('P', 9, int)
80033473Sscrappy#define SNDCTL_DSP_SETFRAGMENT	_IOWR('P',10, int)
80130866Smarkm
8023256Sswallace
80333473Sscrappy#define SNDCTL_DSP_GETFMTS	_IOR ('P',11, int) /* Returns a mask */
8049750Sjkh/*
8059750Sjkh * Buffer status queries.
8069750Sjkh */
8079750Sjkhtypedef struct audio_buf_info {
80833473Sscrappy    int fragments;	/* # of avail. frags (partly used ones not counted) */
80933473Sscrappy    int fragstotal;	/* Total # of fragments allocated */
81033473Sscrappy    int fragsize;	/* Size of a fragment in bytes */
8119750Sjkh
81233473Sscrappy    int bytes;	/* Avail. space in bytes (includes partly used fragments) */
81333473Sscrappy		/* Note! 'bytes' could be more than fragments*fragsize */
81430866Smarkm} audio_buf_info;
8159750Sjkh
81633473Sscrappy#define SNDCTL_DSP_GETOSPACE	_IOR ('P',12, audio_buf_info)
81733473Sscrappy#define SNDCTL_DSP_GETISPACE	_IOR ('P',13, audio_buf_info)
8189750Sjkh
81933473Sscrappy/*
82033473Sscrappy * SNDCTL_DSP_NONBLOCK is the same (but less powerful, since the
82133473Sscrappy * action cannot be undone) of FIONBIO. The same can be achieved
82233473Sscrappy * by opening the device with O_NDELAY
82333473Sscrappy */
82433473Sscrappy#define SNDCTL_DSP_NONBLOCK	_IO  ('P',14)
82530866Smarkm
82633473Sscrappy#define SNDCTL_DSP_GETCAPS	_IOR ('P',15, int)
827187030Smav#	define PCM_CAP_REVISION		0x000000ff	/* Bits for revision level (0 to 255) */
828187030Smav#	define PCM_CAP_DUPLEX		0x00000100	/* Full duplex record/playback */
829187030Smav#	define PCM_CAP_REALTIME		0x00000200	/* Not in use */
830187030Smav#	define PCM_CAP_BATCH		0x00000400	/* Device has some kind of */
831187030Smav							/* internal buffers which may */
832187030Smav							/* cause some delays and */
833187030Smav							/* decrease precision of timing */
834187030Smav#	define PCM_CAP_COPROC		0x00000800	/* Has a coprocessor */
835187030Smav							/* Sometimes it's a DSP */
836187030Smav							/* but usually not */
837187030Smav#	define PCM_CAP_TRIGGER		0x00001000	/* Supports SETTRIGGER */
838187030Smav#	define PCM_CAP_MMAP		0x00002000	/* Supports mmap() */
839187030Smav#	define PCM_CAP_MULTI		0x00004000	/* Supports multiple open */
840187030Smav#	define PCM_CAP_BIND		0x00008000	/* Supports binding to front/rear/center/lfe */
841187030Smav#   	define PCM_CAP_INPUT		0x00010000	/* Supports recording */
842187030Smav#   	define PCM_CAP_OUTPUT		0x00020000	/* Supports playback */
843187030Smav#	define PCM_CAP_VIRTUAL		0x00040000	/* Virtual device */
844187030Smav/* 0x00040000 and 0x00080000 reserved for future use */
84530866Smarkm
846187030Smav/* Analog/digital control capabilities */
847187030Smav#	define PCM_CAP_ANALOGOUT	0x00100000
848187030Smav#	define PCM_CAP_ANALOGIN		0x00200000
849187030Smav#	define PCM_CAP_DIGITALOUT	0x00400000
850187030Smav#	define PCM_CAP_DIGITALIN	0x00800000
851187030Smav#	define PCM_CAP_ADMASK		0x00f00000
85233473Sscrappy/*
853187030Smav * NOTE! (capabilities & PCM_CAP_ADMASK)==0 means just that the
854187030Smav * digital/analog interface control features are not supported by the
855187030Smav * device/driver. However the device still supports analog, digital or
856187030Smav * both inputs/outputs (depending on the device). See the OSS Programmer's
857187030Smav * Guide for full details.
858187030Smav */
859187030Smav#	define PCM_CAP_SPECIAL		0x01000000	/* Not for ordinary "multimedia" use */
860187030Smav#	define PCM_CAP_SHADOW		0x00000000	/* OBSOLETE */
861187030Smav
862187030Smav/*
863187030Smav * Preferred channel usage. These bits can be used to
864187030Smav * give recommendations to the application. Used by few drivers.
865187030Smav * For example if ((caps & DSP_CH_MASK) == DSP_CH_MONO) means that
866187030Smav * the device works best in mono mode. However it doesn't necessarily mean
867187030Smav * that the device cannot be used in stereo. These bits should only be used
868187030Smav * by special applications such as multi track hard disk recorders to find
869187030Smav * out the initial setup. However the user should be able to override this
870187030Smav * selection.
871187030Smav *
872187030Smav * To find out which modes are actually supported the application should
873187030Smav * try to select them using SNDCTL_DSP_CHANNELS.
874187030Smav */
875187030Smav#	define DSP_CH_MASK		0x06000000	/* Mask */
876187030Smav#	define DSP_CH_ANY		0x00000000	/* No preferred mode */
877187030Smav#	define DSP_CH_MONO		0x02000000
878187030Smav#	define DSP_CH_STEREO		0x04000000
879187030Smav#	define DSP_CH_MULTI		0x06000000	/* More than two channels */
880187030Smav
881187030Smav#	define PCM_CAP_HIDDEN		0x08000000	/* Hidden device */
882187030Smav#	define PCM_CAP_FREERATE		0x10000000
883187030Smav#	define PCM_CAP_MODEM		0x20000000	/* Modem device */
884187030Smav#	define PCM_CAP_DEFAULT		0x40000000	/* "Default" device */
885187030Smav
886187030Smav/*
887187030Smav * The PCM_CAP_* capability names were known as DSP_CAP_* prior OSS 4.0
888187030Smav * so it's necessary to define the older names too.
889187030Smav */
890187030Smav#define DSP_CAP_ADMASK		PCM_CAP_ADMASK
891187030Smav#define DSP_CAP_ANALOGIN	PCM_CAP_ANALOGIN
892187030Smav#define DSP_CAP_ANALOGOUT	PCM_CAP_ANALOGOUT
893187030Smav#define DSP_CAP_BATCH		PCM_CAP_BATCH
894187030Smav#define DSP_CAP_BIND		PCM_CAP_BIND
895187030Smav#define DSP_CAP_COPROC		PCM_CAP_COPROC
896187030Smav#define DSP_CAP_DEFAULT		PCM_CAP_DEFAULT
897187030Smav#define DSP_CAP_DIGITALIN	PCM_CAP_DIGITALIN
898187030Smav#define DSP_CAP_DIGITALOUT	PCM_CAP_DIGITALOUT
899187030Smav#define DSP_CAP_DUPLEX		PCM_CAP_DUPLEX
900187030Smav#define DSP_CAP_FREERATE	PCM_CAP_FREERATE
901187030Smav#define DSP_CAP_HIDDEN		PCM_CAP_HIDDEN
902187030Smav#define DSP_CAP_INPUT		PCM_CAP_INPUT
903187030Smav#define DSP_CAP_MMAP		PCM_CAP_MMAP
904187030Smav#define DSP_CAP_MODEM		PCM_CAP_MODEM
905187030Smav#define DSP_CAP_MULTI		PCM_CAP_MULTI
906187030Smav#define DSP_CAP_OUTPUT		PCM_CAP_OUTPUT
907187030Smav#define DSP_CAP_REALTIME	PCM_CAP_REALTIME
908187030Smav#define DSP_CAP_REVISION	PCM_CAP_REVISION
909187030Smav#define DSP_CAP_SHADOW		PCM_CAP_SHADOW
910187030Smav#define DSP_CAP_TRIGGER		PCM_CAP_TRIGGER
911187030Smav#define DSP_CAP_VIRTUAL		PCM_CAP_VIRTUAL
912187030Smav
913187030Smav/*
91433473Sscrappy * What do these function do ?
91533473Sscrappy */
91633473Sscrappy#define SNDCTL_DSP_GETTRIGGER	_IOR ('P',16, int)
91733473Sscrappy#define SNDCTL_DSP_SETTRIGGER	_IOW ('P',16, int)
91833473Sscrappy#define PCM_ENABLE_INPUT	0x00000001
91930866Smarkm#define PCM_ENABLE_OUTPUT	0x00000002
92030866Smarkm
92130866Smarkmtypedef struct count_info {
92230866Smarkm	int bytes;	/* Total # of bytes processed */
92330866Smarkm	int blocks;	/* # of fragment transitions since last time */
92430866Smarkm	int ptr;	/* Current DMA pointer value */
92530866Smarkm} count_info;
92630866Smarkm
92733473Sscrappy/*
92833473Sscrappy * GETIPTR and GETISPACE are not that different... same for out.
92933473Sscrappy */
93033473Sscrappy#define SNDCTL_DSP_GETIPTR	_IOR ('P',17, count_info)
93133473Sscrappy#define SNDCTL_DSP_GETOPTR	_IOR ('P',18, count_info)
93230866Smarkm
93330866Smarkmtypedef struct buffmem_desc {
93430866Smarkm	caddr_t buffer;
93530866Smarkm	int size;
93630866Smarkm} buffmem_desc;
93730866Smarkm
93833473Sscrappy#define SNDCTL_DSP_MAPINBUF	_IOR ('P', 19, buffmem_desc)
93933473Sscrappy#define SNDCTL_DSP_MAPOUTBUF	_IOR ('P', 20, buffmem_desc)
94033473Sscrappy#define SNDCTL_DSP_SETSYNCRO	_IO  ('P', 21)
94165335Scg#define SNDCTL_DSP_SETDUPLEX	_IO  ('P', 22)
94253901Salfred#define SNDCTL_DSP_GETODELAY	_IOR ('P', 23, int)
94330866Smarkm
94433473Sscrappy/*
94533473Sscrappy * I guess these are the readonly version of the same
94633473Sscrappy * functions that exist above as SNDCTL_DSP_...
94733473Sscrappy */
94833473Sscrappy#define SOUND_PCM_READ_RATE	_IOR ('P', 2, int)
94933473Sscrappy#define SOUND_PCM_READ_CHANNELS	_IOR ('P', 6, int)
95033473Sscrappy#define SOUND_PCM_READ_BITS	_IOR ('P', 5, int)
95133473Sscrappy#define SOUND_PCM_READ_FILTER	_IOR ('P', 7, int)
952652Sjkh
9539750Sjkh/*
9549750Sjkh * ioctl calls to be used in communication with coprocessors and
9559750Sjkh * DSP chips.
9563256Sswallace */
9573256Sswallace
9589750Sjkhtypedef struct copr_buffer {
95930866Smarkm	int command;	/* Set to 0 if not used */
96030866Smarkm	int flags;
9619750Sjkh#define CPF_NONE		0x0000
9629750Sjkh#define CPF_FIRST		0x0001	/* First block */
9639750Sjkh#define CPF_LAST		0x0002	/* Last block */
96430866Smarkm	int len;
96530866Smarkm	int offs;	/* If required by the device (0 if not used) */
9663256Sswallace
96730866Smarkm	u_char data[4000]; /* NOTE! 4000 is not 4k */
96830866Smarkm} copr_buffer;
9699750Sjkh
9709750Sjkhtypedef struct copr_debug_buf {
97130866Smarkm	int command;	/* Used internally. Set to 0 */
97230866Smarkm	int parm1;
97330866Smarkm	int parm2;
97465335Scg	int flags;
97530866Smarkm	int len;	/* Length of data in bytes */
97630866Smarkm} copr_debug_buf;
9779750Sjkh
9789750Sjkhtypedef struct copr_msg {
97930866Smarkm	int len;
98030866Smarkm	u_char data[4000];
98130866Smarkm} copr_msg;
9829750Sjkh
98333473Sscrappy#define SNDCTL_COPR_RESET       _IO  ('C',  0)
98433473Sscrappy#define SNDCTL_COPR_LOAD	_IOWR('C',  1, copr_buffer)
98533473Sscrappy#define SNDCTL_COPR_RDATA	_IOWR('C',  2, copr_debug_buf)
98633473Sscrappy#define SNDCTL_COPR_RCODE	_IOWR('C',  3, copr_debug_buf)
98733473Sscrappy#define SNDCTL_COPR_WDATA	_IOW ('C',  4, copr_debug_buf)
98833473Sscrappy#define SNDCTL_COPR_WCODE	_IOW ('C',  5, copr_debug_buf)
98933473Sscrappy#define SNDCTL_COPR_RUN		_IOWR('C',  6, copr_debug_buf)
99033473Sscrappy#define SNDCTL_COPR_HALT	_IOWR('C',  7, copr_debug_buf)
99133473Sscrappy#define SNDCTL_COPR_SENDMSG	_IOW ('C',  8, copr_msg)
99233473Sscrappy#define SNDCTL_COPR_RCVMSG	_IOR ('C',  9, copr_msg)
9939750Sjkh
99433473Sscrappy/*
995652Sjkh * IOCTL commands for /dev/mixer
996652Sjkh */
99765335Scg
99865335Scg/*
999652Sjkh * Mixer devices
1000652Sjkh *
1001652Sjkh * There can be up to 20 different analog mixer channels. The
100265335Scg * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
1003652Sjkh * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
1004652Sjkh * the devices supported by the particular mixer.
1005652Sjkh */
1006652Sjkh
100733473Sscrappy#define SOUND_MIXER_NRDEVICES	25
100881891Ssobomax#define SOUND_MIXER_VOLUME	0	/* Master output level */
100981891Ssobomax#define SOUND_MIXER_BASS	1	/* Treble level of all output channels */
101081891Ssobomax#define SOUND_MIXER_TREBLE	2	/* Bass level of all output channels */
101181891Ssobomax#define SOUND_MIXER_SYNTH	3	/* Volume of synthesier input */
101281891Ssobomax#define SOUND_MIXER_PCM		4	/* Output level for the audio device */
101381891Ssobomax#define SOUND_MIXER_SPEAKER	5	/* Output level for the PC speaker
101481891Ssobomax					 * signals */
101581891Ssobomax#define SOUND_MIXER_LINE	6	/* Volume level for the line in jack */
101681891Ssobomax#define SOUND_MIXER_MIC		7	/* Volume for the signal coming from
101781891Ssobomax					 * the microphone jack */
101881891Ssobomax#define SOUND_MIXER_CD		8	/* Volume level for the input signal
101981891Ssobomax					 * connected to the CD audio input */
102081891Ssobomax#define SOUND_MIXER_IMIX	9	/* Recording monitor. It controls the
102181891Ssobomax					 * output volume of the selected
102281891Ssobomax					 * recording sources while recording */
102381891Ssobomax#define SOUND_MIXER_ALTPCM	10	/* Volume of the alternative codec
102481891Ssobomax					 * device */
102581891Ssobomax#define SOUND_MIXER_RECLEV	11	/* Global recording level */
10269750Sjkh#define SOUND_MIXER_IGAIN	12	/* Input gain */
10279750Sjkh#define SOUND_MIXER_OGAIN	13	/* Output gain */
102865335Scg/*
10299750Sjkh * The AD1848 codec and compatibles have three line level inputs
10309750Sjkh * (line, aux1 and aux2). Since each card manufacturer have assigned
103130866Smarkm * different meanings to these inputs, it's inpractical to assign
10329750Sjkh * specific meanings (line, cd, synth etc.) to them.
10339750Sjkh */
10349750Sjkh#define SOUND_MIXER_LINE1	14	/* Input source 1  (aux1) */
10359750Sjkh#define SOUND_MIXER_LINE2	15	/* Input source 2  (aux2) */
10369750Sjkh#define SOUND_MIXER_LINE3	16	/* Input source 3  (line) */
103733473Sscrappy#define SOUND_MIXER_DIGITAL1    17      /* Digital (input) 1 */
103833473Sscrappy#define SOUND_MIXER_DIGITAL2    18      /* Digital (input) 2 */
103933473Sscrappy#define SOUND_MIXER_DIGITAL3    19      /* Digital (input) 3 */
104033473Sscrappy#define SOUND_MIXER_PHONEIN     20      /* Phone input */
104133473Sscrappy#define SOUND_MIXER_PHONEOUT    21      /* Phone output */
104233473Sscrappy#define SOUND_MIXER_VIDEO       22      /* Video/TV (audio) in */
104333473Sscrappy#define SOUND_MIXER_RADIO       23      /* Radio in */
104433473Sscrappy#define SOUND_MIXER_MONITOR     24      /* Monitor (usually mic) volume */
1045652Sjkh
104633473Sscrappy
104733473Sscrappy/*
104833473Sscrappy * Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX)
104933473Sscrappy * Not counted to SOUND_MIXER_NRDEVICES, but use the same number space
105033473Sscrappy */
1051652Sjkh#define SOUND_ONOFF_MIN		28
1052652Sjkh#define SOUND_ONOFF_MAX		30
1053652Sjkh#define SOUND_MIXER_MUTE	28	/* 0 or 1 */
1054652Sjkh#define SOUND_MIXER_ENHANCE	29	/* Enhanced stereo (0, 40, 60 or 80) */
1055652Sjkh#define SOUND_MIXER_LOUD	30	/* 0 or 1 */
1056652Sjkh
1057652Sjkh/* Note!	Number 31 cannot be used since the sign bit is reserved */
105833473Sscrappy#define SOUND_MIXER_NONE        31
1059652Sjkh
106030866Smarkm#define SOUND_DEVICE_LABELS	{ \
106130866Smarkm	"Vol  ", "Bass ", "Trebl", "Synth", "Pcm  ", "Spkr ", "Line ", \
106233473Sscrappy	"Mic  ", "CD   ", "Mix  ", "Pcm2 ", "Rec  ", "IGain", "OGain", \
106333473Sscrappy	"Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
106433473Sscrappy	"PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
1065652Sjkh
106630866Smarkm#define SOUND_DEVICE_NAMES	{ \
106730866Smarkm	"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
106830866Smarkm	"mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
106933473Sscrappy	"line1", "line2", "line3", "dig1", "dig2", "dig3", \
107033473Sscrappy	"phin", "phout", "video", "radio", "monitor"}
1071652Sjkh
1072652Sjkh/*	Device bitmask identifiers	*/
1073652Sjkh
107430866Smarkm#define SOUND_MIXER_RECSRC	0xff	/* 1 bit per recording source */
107530866Smarkm#define SOUND_MIXER_DEVMASK	0xfe	/* 1 bit per supported device */
107630866Smarkm#define SOUND_MIXER_RECMASK	0xfd	/* 1 bit per supp. recording source */
1077652Sjkh#define SOUND_MIXER_CAPS	0xfc
107830866Smarkm#define SOUND_CAP_EXCL_INPUT	0x00000001	/* Only 1 rec. src at a time */
1079652Sjkh#define SOUND_MIXER_STEREODEVS	0xfb	/* Mixer channels supporting stereo */
1080652Sjkh
1081652Sjkh/*	Device mask bits	*/
1082652Sjkh
1083652Sjkh#define SOUND_MASK_VOLUME	(1 << SOUND_MIXER_VOLUME)
1084652Sjkh#define SOUND_MASK_BASS		(1 << SOUND_MIXER_BASS)
1085652Sjkh#define SOUND_MASK_TREBLE	(1 << SOUND_MIXER_TREBLE)
1086652Sjkh#define SOUND_MASK_SYNTH	(1 << SOUND_MIXER_SYNTH)
1087652Sjkh#define SOUND_MASK_PCM		(1 << SOUND_MIXER_PCM)
1088652Sjkh#define SOUND_MASK_SPEAKER	(1 << SOUND_MIXER_SPEAKER)
1089652Sjkh#define SOUND_MASK_LINE		(1 << SOUND_MIXER_LINE)
1090652Sjkh#define SOUND_MASK_MIC		(1 << SOUND_MIXER_MIC)
1091652Sjkh#define SOUND_MASK_CD		(1 << SOUND_MIXER_CD)
1092652Sjkh#define SOUND_MASK_IMIX		(1 << SOUND_MIXER_IMIX)
1093652Sjkh#define SOUND_MASK_ALTPCM	(1 << SOUND_MIXER_ALTPCM)
1094652Sjkh#define SOUND_MASK_RECLEV	(1 << SOUND_MIXER_RECLEV)
10959750Sjkh#define SOUND_MASK_IGAIN	(1 << SOUND_MIXER_IGAIN)
10969750Sjkh#define SOUND_MASK_OGAIN	(1 << SOUND_MIXER_OGAIN)
10979750Sjkh#define SOUND_MASK_LINE1	(1 << SOUND_MIXER_LINE1)
10989750Sjkh#define SOUND_MASK_LINE2	(1 << SOUND_MIXER_LINE2)
10999750Sjkh#define SOUND_MASK_LINE3	(1 << SOUND_MIXER_LINE3)
110033473Sscrappy#define SOUND_MASK_DIGITAL1     (1 << SOUND_MIXER_DIGITAL1)
110133473Sscrappy#define SOUND_MASK_DIGITAL2     (1 << SOUND_MIXER_DIGITAL2)
110233473Sscrappy#define SOUND_MASK_DIGITAL3     (1 << SOUND_MIXER_DIGITAL3)
110333473Sscrappy#define SOUND_MASK_PHONEIN      (1 << SOUND_MIXER_PHONEIN)
110433473Sscrappy#define SOUND_MASK_PHONEOUT     (1 << SOUND_MIXER_PHONEOUT)
110533473Sscrappy#define SOUND_MASK_RADIO        (1 << SOUND_MIXER_RADIO)
110633473Sscrappy#define SOUND_MASK_VIDEO        (1 << SOUND_MIXER_VIDEO)
110733473Sscrappy#define SOUND_MASK_MONITOR      (1 << SOUND_MIXER_MONITOR)
1108652Sjkh
110933473Sscrappy/* Obsolete macros */
1110652Sjkh#define SOUND_MASK_MUTE		(1 << SOUND_MIXER_MUTE)
1111652Sjkh#define SOUND_MASK_ENHANCE	(1 << SOUND_MIXER_ENHANCE)
1112652Sjkh#define SOUND_MASK_LOUD		(1 << SOUND_MIXER_LOUD)
1113652Sjkh
1114652Sjkh#define MIXER_READ(dev)		_IOR('M', dev, int)
1115652Sjkh#define SOUND_MIXER_READ_VOLUME		MIXER_READ(SOUND_MIXER_VOLUME)
1116652Sjkh#define SOUND_MIXER_READ_BASS		MIXER_READ(SOUND_MIXER_BASS)
1117652Sjkh#define SOUND_MIXER_READ_TREBLE		MIXER_READ(SOUND_MIXER_TREBLE)
1118652Sjkh#define SOUND_MIXER_READ_SYNTH		MIXER_READ(SOUND_MIXER_SYNTH)
1119652Sjkh#define SOUND_MIXER_READ_PCM		MIXER_READ(SOUND_MIXER_PCM)
1120652Sjkh#define SOUND_MIXER_READ_SPEAKER	MIXER_READ(SOUND_MIXER_SPEAKER)
1121652Sjkh#define SOUND_MIXER_READ_LINE		MIXER_READ(SOUND_MIXER_LINE)
1122652Sjkh#define SOUND_MIXER_READ_MIC		MIXER_READ(SOUND_MIXER_MIC)
1123652Sjkh#define SOUND_MIXER_READ_CD		MIXER_READ(SOUND_MIXER_CD)
1124652Sjkh#define SOUND_MIXER_READ_IMIX		MIXER_READ(SOUND_MIXER_IMIX)
1125652Sjkh#define SOUND_MIXER_READ_ALTPCM		MIXER_READ(SOUND_MIXER_ALTPCM)
1126652Sjkh#define SOUND_MIXER_READ_RECLEV		MIXER_READ(SOUND_MIXER_RECLEV)
11279750Sjkh#define SOUND_MIXER_READ_IGAIN		MIXER_READ(SOUND_MIXER_IGAIN)
11289750Sjkh#define SOUND_MIXER_READ_OGAIN		MIXER_READ(SOUND_MIXER_OGAIN)
11299750Sjkh#define SOUND_MIXER_READ_LINE1		MIXER_READ(SOUND_MIXER_LINE1)
11309750Sjkh#define SOUND_MIXER_READ_LINE2		MIXER_READ(SOUND_MIXER_LINE2)
11319750Sjkh#define SOUND_MIXER_READ_LINE3		MIXER_READ(SOUND_MIXER_LINE3)
1132118923Scg#define SOUND_MIXER_READ_DIGITAL1	MIXER_READ(SOUND_MIXER_DIGITAL1)
1133118923Scg#define SOUND_MIXER_READ_DIGITAL2	MIXER_READ(SOUND_MIXER_DIGITAL2)
1134118923Scg#define SOUND_MIXER_READ_DIGITAL3	MIXER_READ(SOUND_MIXER_DIGITAL3)
1135118923Scg#define SOUND_MIXER_READ_PHONEIN      	MIXER_READ(SOUND_MIXER_PHONEIN)
1136118923Scg#define SOUND_MIXER_READ_PHONEOUT	MIXER_READ(SOUND_MIXER_PHONEOUT)
1137118923Scg#define SOUND_MIXER_READ_RADIO		MIXER_READ(SOUND_MIXER_RADIO)
1138118923Scg#define SOUND_MIXER_READ_VIDEO		MIXER_READ(SOUND_MIXER_VIDEO)
1139118923Scg#define SOUND_MIXER_READ_MONITOR	MIXER_READ(SOUND_MIXER_MONITOR)
114033473Sscrappy
114133473Sscrappy/* Obsolete macros */
1142652Sjkh#define SOUND_MIXER_READ_MUTE		MIXER_READ(SOUND_MIXER_MUTE)
1143652Sjkh#define SOUND_MIXER_READ_ENHANCE	MIXER_READ(SOUND_MIXER_ENHANCE)
1144652Sjkh#define SOUND_MIXER_READ_LOUD		MIXER_READ(SOUND_MIXER_LOUD)
1145652Sjkh
1146652Sjkh#define SOUND_MIXER_READ_RECSRC		MIXER_READ(SOUND_MIXER_RECSRC)
1147652Sjkh#define SOUND_MIXER_READ_DEVMASK	MIXER_READ(SOUND_MIXER_DEVMASK)
1148652Sjkh#define SOUND_MIXER_READ_RECMASK	MIXER_READ(SOUND_MIXER_RECMASK)
1149652Sjkh#define SOUND_MIXER_READ_STEREODEVS	MIXER_READ(SOUND_MIXER_STEREODEVS)
1150652Sjkh#define SOUND_MIXER_READ_CAPS		MIXER_READ(SOUND_MIXER_CAPS)
1151652Sjkh
1152652Sjkh#define MIXER_WRITE(dev)		_IOWR('M', dev, int)
1153652Sjkh#define SOUND_MIXER_WRITE_VOLUME	MIXER_WRITE(SOUND_MIXER_VOLUME)
1154652Sjkh#define SOUND_MIXER_WRITE_BASS		MIXER_WRITE(SOUND_MIXER_BASS)
1155652Sjkh#define SOUND_MIXER_WRITE_TREBLE	MIXER_WRITE(SOUND_MIXER_TREBLE)
1156652Sjkh#define SOUND_MIXER_WRITE_SYNTH		MIXER_WRITE(SOUND_MIXER_SYNTH)
1157652Sjkh#define SOUND_MIXER_WRITE_PCM		MIXER_WRITE(SOUND_MIXER_PCM)
1158652Sjkh#define SOUND_MIXER_WRITE_SPEAKER	MIXER_WRITE(SOUND_MIXER_SPEAKER)
1159652Sjkh#define SOUND_MIXER_WRITE_LINE		MIXER_WRITE(SOUND_MIXER_LINE)
1160652Sjkh#define SOUND_MIXER_WRITE_MIC		MIXER_WRITE(SOUND_MIXER_MIC)
1161652Sjkh#define SOUND_MIXER_WRITE_CD		MIXER_WRITE(SOUND_MIXER_CD)
1162652Sjkh#define SOUND_MIXER_WRITE_IMIX		MIXER_WRITE(SOUND_MIXER_IMIX)
1163652Sjkh#define SOUND_MIXER_WRITE_ALTPCM	MIXER_WRITE(SOUND_MIXER_ALTPCM)
1164652Sjkh#define SOUND_MIXER_WRITE_RECLEV	MIXER_WRITE(SOUND_MIXER_RECLEV)
11659750Sjkh#define SOUND_MIXER_WRITE_IGAIN		MIXER_WRITE(SOUND_MIXER_IGAIN)
11669750Sjkh#define SOUND_MIXER_WRITE_OGAIN		MIXER_WRITE(SOUND_MIXER_OGAIN)
11679750Sjkh#define SOUND_MIXER_WRITE_LINE1		MIXER_WRITE(SOUND_MIXER_LINE1)
11689750Sjkh#define SOUND_MIXER_WRITE_LINE2		MIXER_WRITE(SOUND_MIXER_LINE2)
11699750Sjkh#define SOUND_MIXER_WRITE_LINE3		MIXER_WRITE(SOUND_MIXER_LINE3)
1170118923Scg#define SOUND_MIXER_WRITE_DIGITAL1	MIXER_WRITE(SOUND_MIXER_DIGITAL1)
1171118923Scg#define SOUND_MIXER_WRITE_DIGITAL2	MIXER_WRITE(SOUND_MIXER_DIGITAL2)
1172118923Scg#define SOUND_MIXER_WRITE_DIGITAL3	MIXER_WRITE(SOUND_MIXER_DIGITAL3)
1173118923Scg#define SOUND_MIXER_WRITE_PHONEIN      	MIXER_WRITE(SOUND_MIXER_PHONEIN)
1174118923Scg#define SOUND_MIXER_WRITE_PHONEOUT	MIXER_WRITE(SOUND_MIXER_PHONEOUT)
1175118923Scg#define SOUND_MIXER_WRITE_RADIO		MIXER_WRITE(SOUND_MIXER_RADIO)
1176118923Scg#define SOUND_MIXER_WRITE_VIDEO		MIXER_WRITE(SOUND_MIXER_VIDEO)
1177118923Scg#define SOUND_MIXER_WRITE_MONITOR	MIXER_WRITE(SOUND_MIXER_MONITOR)
1178118923Scg
1179652Sjkh#define SOUND_MIXER_WRITE_MUTE		MIXER_WRITE(SOUND_MIXER_MUTE)
1180652Sjkh#define SOUND_MIXER_WRITE_ENHANCE	MIXER_WRITE(SOUND_MIXER_ENHANCE)
1181652Sjkh#define SOUND_MIXER_WRITE_LOUD		MIXER_WRITE(SOUND_MIXER_LOUD)
1182652Sjkh
1183652Sjkh#define SOUND_MIXER_WRITE_RECSRC	MIXER_WRITE(SOUND_MIXER_RECSRC)
1184652Sjkh
1185118923Scgtypedef struct mixer_info {
1186118923Scg  char id[16];
1187118923Scg  char name[32];
1188118923Scg  int  modify_counter;
1189118923Scg  int fillers[10];
1190118923Scg} mixer_info;
1191118923Scg
1192118923Scg#define SOUND_MIXER_INFO		_IOR('M', 101, mixer_info)
1193118923Scg
119433473Sscrappy#define LEFT_CHN	0
119533473Sscrappy#define RIGHT_CHN	1
119633473Sscrappy
1197652Sjkh/*
11983256Sswallace * Level 2 event types for /dev/sequencer
11993256Sswallace */
12003256Sswallace
12013256Sswallace/*
12023256Sswallace * The 4 most significant bits of byte 0 specify the class of
120365335Scg * the event:
1204652Sjkh *
12053256Sswallace *	0x8X = system level events,
12063256Sswallace *	0x9X = device/port specific events, event[1] = device/port,
12073256Sswallace *		The last 4 bits give the subtype:
12083256Sswallace *			0x02	= Channel event (event[3] = chn).
12093256Sswallace *			0x01	= note event (event[4] = note).
12103256Sswallace *			(0x01 is not used alone but always with bit 0x02).
12113256Sswallace *	       event[2] = MIDI message code (0x80=note off etc.)
12123256Sswallace *
1213652Sjkh */
1214652Sjkh
12153256Sswallace#define EV_SEQ_LOCAL		0x80
12163256Sswallace#define EV_TIMING		0x81
12173256Sswallace#define EV_CHN_COMMON		0x92
12183256Sswallace#define EV_CHN_VOICE		0x93
121930866Smarkm#define EV_SYSEX		0x94
12203256Sswallace/*
12213256Sswallace * Event types 200 to 220 are reserved for application use.
12223256Sswallace * These numbers will not be used by the driver.
12233256Sswallace */
1224652Sjkh
1225652Sjkh/*
12263256Sswallace * Events for event type EV_CHN_VOICE
1227652Sjkh */
1228652Sjkh
12293256Sswallace#define MIDI_NOTEOFF		0x80
12303256Sswallace#define MIDI_NOTEON		0x90
12313256Sswallace#define MIDI_KEY_PRESSURE	0xA0
12323256Sswallace
1233652Sjkh/*
12343256Sswallace * Events for event type EV_CHN_COMMON
1235652Sjkh */
1236652Sjkh
12373256Sswallace#define MIDI_CTL_CHANGE		0xB0
12383256Sswallace#define MIDI_PGM_CHANGE		0xC0
12393256Sswallace#define MIDI_CHN_PRESSURE	0xD0
12403256Sswallace#define MIDI_PITCH_BEND		0xE0
1241652Sjkh
12423256Sswallace#define MIDI_SYSTEM_PREFIX	0xF0
12433256Sswallace
1244652Sjkh/*
12453256Sswallace * Timer event types
12463256Sswallace */
12473256Sswallace#define TMR_WAIT_REL		1	/* Time relative to the prev time */
12483256Sswallace#define TMR_WAIT_ABS		2	/* Absolute time since TMR_START */
12493256Sswallace#define TMR_STOP		3
12503256Sswallace#define TMR_START		4
12513256Sswallace#define TMR_CONTINUE		5
12523256Sswallace#define TMR_TEMPO		6
12533256Sswallace#define TMR_ECHO		8
12543256Sswallace#define TMR_CLOCK		9	/* MIDI clock */
12553256Sswallace#define TMR_SPP			10	/* Song position pointer */
12563256Sswallace#define TMR_TIMESIG		11	/* Time signature */
12573256Sswallace
125830866Smarkm/*
125930866Smarkm *	Local event types
126030866Smarkm */
126130866Smarkm#define LOCL_STARTAUDIO		1
126230866Smarkm
126365335Scg#if (!defined(_KERNEL) && !defined(INKERNEL)) || defined(USE_SEQ_MACROS)
12643256Sswallace/*
1265652Sjkh *	Some convenience macros to simplify programming of the
1266652Sjkh *	/dev/sequencer interface
1267652Sjkh *
1268652Sjkh *	These macros define the API which should be used when possible.
1269652Sjkh */
1270652Sjkh
12713256Sswallace#ifndef USE_SIMPLE_MACROS
127292719Salfredvoid seqbuf_dump(void);	/* This function must be provided by programs */
1273652Sjkh
1274652Sjkh/* Sample seqbuf_dump() implementation:
1275652Sjkh *
1276652Sjkh *	SEQ_DEFINEBUF (2048);	-- Defines a buffer for 2048 bytes
1277652Sjkh *
1278652Sjkh *	int seqfd;		-- The file descriptor for /dev/sequencer.
1279652Sjkh *
1280652Sjkh *	void
1281652Sjkh *	seqbuf_dump ()
1282652Sjkh *	{
1283652Sjkh *	  if (_seqbufptr)
1284652Sjkh *	    if (write (seqfd, _seqbuf, _seqbufptr) == -1)
1285652Sjkh *	      {
1286652Sjkh *		perror ("write /dev/sequencer");
1287652Sjkh *		exit (-1);
1288652Sjkh *	      }
1289652Sjkh *	  _seqbufptr = 0;
1290652Sjkh *	}
1291652Sjkh */
1292652Sjkh
129330866Smarkm#define SEQ_DEFINEBUF(len)		\
129430866Smarkm	u_char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0
129530866Smarkm#define SEQ_USE_EXTBUF()		\
129630866Smarkm	extern u_char _seqbuf[]; \
129730866Smarkm	extern int _seqbuflen;extern int _seqbufptr
12983256Sswallace#define SEQ_DECLAREBUF()		SEQ_USE_EXTBUF()
1299652Sjkh#define SEQ_PM_DEFINES			struct patmgr_info _pm_info
130030866Smarkm#define _SEQ_NEEDBUF(len)		\
130130866Smarkm	if ((_seqbufptr+(len)) > _seqbuflen) \
130230866Smarkm		seqbuf_dump()
1303652Sjkh#define _SEQ_ADVBUF(len)		_seqbufptr += len
1304652Sjkh#define SEQ_DUMPBUF			seqbuf_dump
13053256Sswallace#else
13063256Sswallace/*
13073256Sswallace * This variation of the sequencer macros is used just to format one event
13083256Sswallace * using fixed buffer.
130965335Scg *
13103256Sswallace * The program using the macro library must define the following macros before
13113256Sswallace * using this library.
13123256Sswallace *
131365335Scg * #define _seqbuf 		 name of the buffer (u_char[])
13143256Sswallace * #define _SEQ_ADVBUF(len)	 If the applic needs to know the exact
13153256Sswallace *				 size of the event, this macro can be used.
13163256Sswallace *				 Otherwise this must be defined as empty.
13173256Sswallace * #define _seqbufptr		 Define the name of index variable or 0 if
131865335Scg *				 not required.
13193256Sswallace */
13203256Sswallace#define _SEQ_NEEDBUF(len)	/* empty */
13213256Sswallace#endif
13223256Sswallace
132330866Smarkm#define PM_LOAD_PATCH(dev, bank, pgm)	\
132430866Smarkm	(SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \
132530866Smarkm	_pm_info.device=dev, _pm_info.data.data8[0]=pgm, \
132630866Smarkm	_pm_info.parm1 = bank, _pm_info.parm2 = 1, \
132730866Smarkm	ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info))
132830866Smarkm#define PM_LOAD_PATCHES(dev, bank, pgm) \
132930866Smarkm	(SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \
133030866Smarkm	_pm_info.device=dev, bcopy( pgm, _pm_info.data.data8,  128), \
133130866Smarkm	_pm_info.parm1 = bank, _pm_info.parm2 = 128, \
133230866Smarkm	ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info))
1333652Sjkh
133430866Smarkm#define SEQ_VOLUME_MODE(dev, mode)	{ \
133530866Smarkm	_SEQ_NEEDBUF(8);\
133630866Smarkm	_seqbuf[_seqbufptr] = SEQ_EXTENDED;\
133730866Smarkm	_seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\
133830866Smarkm	_seqbuf[_seqbufptr+2] = (dev);\
133930866Smarkm	_seqbuf[_seqbufptr+3] = (mode);\
134030866Smarkm	_seqbuf[_seqbufptr+4] = 0;\
134130866Smarkm	_seqbuf[_seqbufptr+5] = 0;\
134230866Smarkm	_seqbuf[_seqbufptr+6] = 0;\
134330866Smarkm	_seqbuf[_seqbufptr+7] = 0;\
134430866Smarkm	_SEQ_ADVBUF(8);}
13451402Sache
13463256Sswallace/*
13473256Sswallace * Midi voice messages
13483256Sswallace */
1349652Sjkh
135030866Smarkm#define _CHN_VOICE(dev, event, chn, note, parm)  { \
135130866Smarkm	_SEQ_NEEDBUF(8);\
135230866Smarkm	_seqbuf[_seqbufptr] = EV_CHN_VOICE;\
135330866Smarkm	_seqbuf[_seqbufptr+1] = (dev);\
135430866Smarkm	_seqbuf[_seqbufptr+2] = (event);\
135530866Smarkm	_seqbuf[_seqbufptr+3] = (chn);\
135630866Smarkm	_seqbuf[_seqbufptr+4] = (note);\
135730866Smarkm	_seqbuf[_seqbufptr+5] = (parm);\
135830866Smarkm	_seqbuf[_seqbufptr+6] = (0);\
135930866Smarkm	_seqbuf[_seqbufptr+7] = 0;\
136030866Smarkm	_SEQ_ADVBUF(8);}
1361652Sjkh
13623256Sswallace#define SEQ_START_NOTE(dev, chn, note, vol) \
13633256Sswallace		_CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol)
13643256Sswallace
13653256Sswallace#define SEQ_STOP_NOTE(dev, chn, note, vol) \
13663256Sswallace		_CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol)
13673256Sswallace
13683256Sswallace#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \
13693256Sswallace		_CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure)
13703256Sswallace
13713256Sswallace/*
13723256Sswallace * Midi channel messages
13733256Sswallace */
13743256Sswallace
137530866Smarkm#define _CHN_COMMON(dev, event, chn, p1, p2, w14) { \
137630866Smarkm	_SEQ_NEEDBUF(8);\
137730866Smarkm	_seqbuf[_seqbufptr] = EV_CHN_COMMON;\
137830866Smarkm	_seqbuf[_seqbufptr+1] = (dev);\
137930866Smarkm	_seqbuf[_seqbufptr+2] = (event);\
138030866Smarkm	_seqbuf[_seqbufptr+3] = (chn);\
138130866Smarkm	_seqbuf[_seqbufptr+4] = (p1);\
138230866Smarkm	_seqbuf[_seqbufptr+5] = (p2);\
138330866Smarkm	*(short *)&_seqbuf[_seqbufptr+6] = (w14);\
138430866Smarkm	_SEQ_ADVBUF(8);}
138530866Smarkm/*
138630866Smarkm * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits
138730866Smarkm * sending any MIDI bytes but it's absolutely not possible. Trying to do
138830866Smarkm * so _will_ cause problems with MPU401 intelligent mode).
138930866Smarkm *
139065335Scg * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
139130866Smarkm * sent by calling SEQ_SYSEX() several times (there must be no other events
139230866Smarkm * between them). First sysex fragment must have 0xf0 in the first byte
139330866Smarkm * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte
139430866Smarkm * between these sysex start and end markers cannot be larger than 0x7f. Also
139530866Smarkm * lengths of each fragments (except the last one) must be 6.
139630866Smarkm *
139730866Smarkm * Breaking the above rules may work with some MIDI ports but is likely to
139830866Smarkm * cause fatal problems with some other devices (such as MPU401).
139930866Smarkm */
140030866Smarkm#define SEQ_SYSEX(dev, buf, len) { \
140130866Smarkm	int i, l=(len); if (l>6)l=6;\
140230866Smarkm	_SEQ_NEEDBUF(8);\
140330866Smarkm	_seqbuf[_seqbufptr] = EV_SYSEX;\
140430866Smarkm	for(i=0;i<l;i++)_seqbuf[_seqbufptr+i+1] = (buf)[i];\
140530866Smarkm	for(i=l;i<6;i++)_seqbuf[_seqbufptr+i+1] = 0xff;\
140630866Smarkm	_SEQ_ADVBUF(8);}
1407652Sjkh
14083256Sswallace#define SEQ_CHN_PRESSURE(dev, chn, pressure) \
140930866Smarkm	_CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0)
14103256Sswallace
14113256Sswallace#define SEQ_SET_PATCH(dev, chn, patch) \
141230866Smarkm	_CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0)
14133256Sswallace
14143256Sswallace#define SEQ_CONTROL(dev, chn, controller, value) \
141530866Smarkm	_CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value)
14163256Sswallace
14173256Sswallace#define SEQ_BENDER(dev, chn, value) \
141830866Smarkm	_CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value)
14193256Sswallace
14209750Sjkh
142130866Smarkm#define SEQ_V2_X_CONTROL(dev, voice, controller, value)	{ \
142230866Smarkm	_SEQ_NEEDBUF(8);\
142330866Smarkm	_seqbuf[_seqbufptr] = SEQ_EXTENDED;\
142430866Smarkm	_seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\
142530866Smarkm	_seqbuf[_seqbufptr+2] = (dev);\
142630866Smarkm	_seqbuf[_seqbufptr+3] = (voice);\
142730866Smarkm	_seqbuf[_seqbufptr+4] = (controller);\
142830866Smarkm	*(short *)&_seqbuf[_seqbufptr+5] = (value);\
142930866Smarkm	_seqbuf[_seqbufptr+7] = 0;\
143030866Smarkm	_SEQ_ADVBUF(8);}
143130866Smarkm
14323256Sswallace/*
14333256Sswallace * The following 5 macros are incorrectly implemented and obsolete.
14343256Sswallace * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead.
14353256Sswallace */
1436652Sjkh
143730866Smarkm#define SEQ_PITCHBEND(dev, voice, value) \
143830866Smarkm	SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value)
143930866Smarkm#define SEQ_BENDER_RANGE(dev, voice, value) \
144030866Smarkm	SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value)
144130866Smarkm#define SEQ_EXPRESSION(dev, voice, value) \
144230866Smarkm	SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128)
144330866Smarkm#define SEQ_MAIN_VOLUME(dev, voice, value) \
144430866Smarkm	SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100)
144530866Smarkm#define SEQ_PANNING(dev, voice, pos) \
144630866Smarkm	SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
144730866Smarkm
14483256Sswallace/*
144930866Smarkm * Timing and syncronization macros
14503256Sswallace */
1451652Sjkh
145230866Smarkm#define _TIMER_EVENT(ev, parm)		{ \
145330866Smarkm	_SEQ_NEEDBUF(8);\
145430866Smarkm	_seqbuf[_seqbufptr+0] = EV_TIMING; \
145530866Smarkm	_seqbuf[_seqbufptr+1] = (ev); \
145630866Smarkm	_seqbuf[_seqbufptr+2] = 0;\
145730866Smarkm	_seqbuf[_seqbufptr+3] = 0;\
145830866Smarkm	*(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \
145930866Smarkm	_SEQ_ADVBUF(8); \
146030866Smarkm	}
1461652Sjkh
14623256Sswallace#define SEQ_START_TIMER()		_TIMER_EVENT(TMR_START, 0)
14633256Sswallace#define SEQ_STOP_TIMER()		_TIMER_EVENT(TMR_STOP, 0)
14643256Sswallace#define SEQ_CONTINUE_TIMER()		_TIMER_EVENT(TMR_CONTINUE, 0)
14653256Sswallace#define SEQ_WAIT_TIME(ticks)		_TIMER_EVENT(TMR_WAIT_ABS, ticks)
14663256Sswallace#define SEQ_DELTA_TIME(ticks)		_TIMER_EVENT(TMR_WAIT_REL, ticks)
14673256Sswallace#define SEQ_ECHO_BACK(key)		_TIMER_EVENT(TMR_ECHO, key)
14683256Sswallace#define SEQ_SET_TEMPO(value)		_TIMER_EVENT(TMR_TEMPO, value)
14693256Sswallace#define SEQ_SONGPOS(pos)		_TIMER_EVENT(TMR_SPP, pos)
14703256Sswallace#define SEQ_TIME_SIGNATURE(sig)		_TIMER_EVENT(TMR_TIMESIG, sig)
1471652Sjkh
14723256Sswallace/*
147330866Smarkm * Local control events
147430866Smarkm */
147530866Smarkm
147630866Smarkm#define _LOCAL_EVENT(ev, parm)		{ \
147730866Smarkm	_SEQ_NEEDBUF(8);\
147830866Smarkm	_seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
147930866Smarkm	_seqbuf[_seqbufptr+1] = (ev); \
148030866Smarkm	_seqbuf[_seqbufptr+2] = 0;\
148130866Smarkm	_seqbuf[_seqbufptr+3] = 0;\
148230866Smarkm	*(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \
148330866Smarkm	_SEQ_ADVBUF(8); \
148430866Smarkm	}
148530866Smarkm
148630866Smarkm#define SEQ_PLAYAUDIO(devmask)		_LOCAL_EVENT(LOCL_STARTAUDIO, devmask)
148730866Smarkm/*
1488118923Scg * Events for the level 1 interface only
14893256Sswallace */
1490652Sjkh
149130866Smarkm#define SEQ_MIDIOUT(device, byte)	{ \
149230866Smarkm	_SEQ_NEEDBUF(4);\
149330866Smarkm	_seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\
149430866Smarkm	_seqbuf[_seqbufptr+1] = (byte);\
149530866Smarkm	_seqbuf[_seqbufptr+2] = (device);\
149630866Smarkm	_seqbuf[_seqbufptr+3] = 0;\
149730866Smarkm	_SEQ_ADVBUF(4);}
14983256Sswallace
14993256Sswallace/*
15003256Sswallace * Patch loading.
15013256Sswallace */
150230866Smarkm#define SEQ_WRPATCH(patchx, len)	{ \
150330866Smarkm	if (_seqbufptr) seqbuf_dump(); \
150430866Smarkm	if (write(seqfd, (char*)(patchx), len)==-1) \
150530866Smarkm	   perror("Write patch: /dev/sequencer"); \
150630866Smarkm	}
1507652Sjkh
150830866Smarkm#define SEQ_WRPATCH2(patchx, len)	\
150930866Smarkm	( seqbuf_dump(), write(seqfd, (char*)(patchx), len) )
151018444Sbde
151130866Smarkm#endif
151233473Sscrappy
151333473Sscrappy/*
151433473Sscrappy * Here I have moved all the aliases for ioctl names.
151533473Sscrappy */
151633473Sscrappy
151733473Sscrappy#define SNDCTL_DSP_SAMPLESIZE	SNDCTL_DSP_SETFMT
151833473Sscrappy#define SOUND_PCM_WRITE_BITS	SNDCTL_DSP_SETFMT
151933473Sscrappy#define SOUND_PCM_SETFMT	SNDCTL_DSP_SETFMT
152033473Sscrappy
152133473Sscrappy#define SOUND_PCM_WRITE_RATE	SNDCTL_DSP_SPEED
152233473Sscrappy#define SOUND_PCM_POST		SNDCTL_DSP_POST
152333473Sscrappy#define SOUND_PCM_RESET		SNDCTL_DSP_RESET
152433473Sscrappy#define SOUND_PCM_SYNC		SNDCTL_DSP_SYNC
152533473Sscrappy#define SOUND_PCM_SUBDIVIDE	SNDCTL_DSP_SUBDIVIDE
152633473Sscrappy#define SOUND_PCM_SETFRAGMENT	SNDCTL_DSP_SETFRAGMENT
152733473Sscrappy#define SOUND_PCM_GETFMTS	SNDCTL_DSP_GETFMTS
152833473Sscrappy#define SOUND_PCM_GETOSPACE	SNDCTL_DSP_GETOSPACE
152933473Sscrappy#define SOUND_PCM_GETISPACE	SNDCTL_DSP_GETISPACE
153033473Sscrappy#define SOUND_PCM_NONBLOCK	SNDCTL_DSP_NONBLOCK
153133473Sscrappy#define SOUND_PCM_GETCAPS	SNDCTL_DSP_GETCAPS
153233473Sscrappy#define SOUND_PCM_GETTRIGGER	SNDCTL_DSP_GETTRIGGER
153333473Sscrappy#define SOUND_PCM_SETTRIGGER	SNDCTL_DSP_SETTRIGGER
153433473Sscrappy#define SOUND_PCM_SETSYNCRO	SNDCTL_DSP_SETSYNCRO
153533473Sscrappy#define SOUND_PCM_GETIPTR	SNDCTL_DSP_GETIPTR
153633473Sscrappy#define SOUND_PCM_GETOPTR	SNDCTL_DSP_GETOPTR
153733473Sscrappy#define SOUND_PCM_MAPINBUF	SNDCTL_DSP_MAPINBUF
153833473Sscrappy#define SOUND_PCM_MAPOUTBUF	SNDCTL_DSP_MAPOUTBUF
153933473Sscrappy
1540162588Snetchild/***********************************************************************/
1541162588Snetchild
1542162588Snetchild/**
1543162588Snetchild * XXX OSSv4 defines -- some bits taken straight out of the new
1544162588Snetchild * sys/soundcard.h bundled with recent OSS releases.
1545162588Snetchild *
1546162588Snetchild * NB:  These macros and structures will be reorganized and inserted
1547162588Snetchild * 	in appropriate places throughout this file once the code begins
1548162588Snetchild * 	to take shape.
1549162588Snetchild *
1550162588Snetchild * @todo reorganize layout more like the 4Front version
1551162588Snetchild * @todo ask about maintaining __SIOWR vs. _IOWR ioctl cmd defines
1552162588Snetchild */
1553162588Snetchild
1554162588Snetchild/**
1555162588Snetchild * @note The @c OSSV4_EXPERIMENT macro is meant to wrap new development code
1556162588Snetchild * in the sound system relevant to adopting 4Front's OSSv4 specification.
1557162588Snetchild * Users should not enable this!  Really!
1558162588Snetchild */
1559162588Snetchild#if 0
1560162588Snetchild# define OSSV4_EXPERIMENT 1
1561162588Snetchild#else
1562162588Snetchild# undef OSSV4_EXPERIMENT
1563162588Snetchild#endif
1564162588Snetchild
1565162588Snetchild#ifdef SOUND_VERSION
1566162588Snetchild# undef SOUND_VERSION
1567162588Snetchild# define SOUND_VERSION	0x040000
1568162588Snetchild#endif	/* !SOUND_VERSION */
1569162588Snetchild
1570162588Snetchild#define OSS_LONGNAME_SIZE	64
1571162588Snetchild#define OSS_LABEL_SIZE		16
1572162588Snetchild#define OSS_DEVNODE_SIZE        32
1573162588Snetchildtypedef char oss_longname_t[OSS_LONGNAME_SIZE];
1574162588Snetchildtypedef char oss_label_t[OSS_LABEL_SIZE];
1575162588Snetchildtypedef char oss_devnode_t[OSS_DEVNODE_SIZE];
1576162588Snetchild
1577162588Snetchildtypedef struct audio_errinfo
1578162588Snetchild{
1579162588Snetchild	int		play_underruns;
1580162588Snetchild	int		rec_overruns;
1581162588Snetchild	unsigned int	play_ptradjust;
1582162588Snetchild	unsigned int	rec_ptradjust;
1583162588Snetchild	int		play_errorcount;
1584162588Snetchild	int		rec_errorcount;
1585162588Snetchild	int		play_lasterror;
1586162588Snetchild	int		rec_lasterror;
1587162588Snetchild	long		play_errorparm;
1588162588Snetchild	long		rec_errorparm;
1589162588Snetchild	int		filler[16];
1590162588Snetchild} audio_errinfo;
1591162588Snetchild
1592162588Snetchild#define SNDCTL_DSP_GETPLAYVOL           _IOR ('P', 24, int)
1593162588Snetchild#define SNDCTL_DSP_SETPLAYVOL           _IOWR('P', 24, int)
1594162588Snetchild#define SNDCTL_DSP_GETERROR             _IOR ('P', 25, audio_errinfo)
1595162588Snetchild
1596162588Snetchild
1597162588Snetchild/*
1598162588Snetchild ****************************************************************************
1599162588Snetchild * Sync groups for audio devices
1600162588Snetchild */
1601162588Snetchildtypedef struct oss_syncgroup
1602162588Snetchild{
1603162588Snetchild  int id;
1604162588Snetchild  int mode;
1605162588Snetchild  int filler[16];
1606162588Snetchild} oss_syncgroup;
1607162588Snetchild
1608162588Snetchild#define SNDCTL_DSP_SYNCGROUP            _IOWR('P', 28, oss_syncgroup)
1609162588Snetchild#define SNDCTL_DSP_SYNCSTART            _IOW ('P', 29, int)
1610162588Snetchild
1611162588Snetchild/*
1612162588Snetchild **************************************************************************
1613162588Snetchild * "cooked" mode enables software based conversions for sample rate, sample
1614162588Snetchild * format (bits) and number of channels (mono/stereo). These conversions are
1615162588Snetchild * required with some devices that support only one sample rate or just stereo
1616162588Snetchild * to let the applications to use other formats. The cooked mode is enabled by
1617162588Snetchild * default. However it's necessary to disable this mode when mmap() is used or
1618162588Snetchild * when very deterministic timing is required. SNDCTL_DSP_COOKEDMODE is an
1619162588Snetchild * optional call introduced in OSS 3.9.6f. It's _error return must be ignored_
1620162588Snetchild * since normally this call will return erno=EINVAL.
1621162588Snetchild *
1622162588Snetchild * SNDCTL_DSP_COOKEDMODE must be called immediately after open before doing
1623162588Snetchild * anything else. Otherwise the call will not have any effect.
1624162588Snetchild */
1625162588Snetchild#define SNDCTL_DSP_COOKEDMODE           _IOW ('P', 30, int)
1626162588Snetchild
1627162588Snetchild/*
1628162588Snetchild **************************************************************************
1629162588Snetchild * SNDCTL_DSP_SILENCE and SNDCTL_DSP_SKIP are new calls in OSS 3.99.0
1630162588Snetchild * that can be used to implement pause/continue during playback (no effect
1631162588Snetchild * on recording).
1632162588Snetchild */
1633162588Snetchild#define SNDCTL_DSP_SILENCE              _IO  ('P', 31)
1634162588Snetchild#define SNDCTL_DSP_SKIP                 _IO  ('P', 32)
1635162588Snetchild
1636162588Snetchild/*
1637162588Snetchild ****************************************************************************
1638162588Snetchild * Abort transfer (reset) functions for input and output
1639162588Snetchild */
1640162588Snetchild#define SNDCTL_DSP_HALT_INPUT		_IO  ('P', 33)
1641162588Snetchild#define SNDCTL_DSP_RESET_INPUT	SNDCTL_DSP_HALT_INPUT	/* Old name */
1642162588Snetchild#define SNDCTL_DSP_HALT_OUTPUT		_IO  ('P', 34)
1643162588Snetchild#define SNDCTL_DSP_RESET_OUTPUT	SNDCTL_DSP_HALT_OUTPUT	/* Old name */
1644162588Snetchild
1645162588Snetchild/*
1646162588Snetchild ****************************************************************************
1647162588Snetchild * Low water level control
1648162588Snetchild */
1649162588Snetchild#define SNDCTL_DSP_LOW_WATER		_IOW ('P', 34, int)
1650162588Snetchild
1651162588Snetchild/** @todo Get rid of OSS_NO_LONG_LONG references? */
1652162588Snetchild
1653162588Snetchild/*
1654162588Snetchild ****************************************************************************
1655162588Snetchild * 64 bit pointer support. Only available in environments that support
1656162588Snetchild * the 64 bit (long long) integer type.
1657162588Snetchild */
1658162588Snetchild#ifndef OSS_NO_LONG_LONG
1659162588Snetchildtypedef struct
1660162588Snetchild{
1661162588Snetchild  long long samples;
1662162588Snetchild  int fifo_samples;
1663162588Snetchild  int filler[32];		/* For future use */
1664162588Snetchild} oss_count_t;
1665162588Snetchild
1666162588Snetchild#define SNDCTL_DSP_CURRENT_IPTR		_IOR ('P', 35, oss_count_t)
1667162588Snetchild#define SNDCTL_DSP_CURRENT_OPTR		_IOR ('P', 36, oss_count_t)
1668162588Snetchild#endif
1669162588Snetchild
1670162588Snetchild/*
1671162588Snetchild ****************************************************************************
1672162588Snetchild * Interface for selecting recording sources and playback output routings.
1673162588Snetchild */
1674162588Snetchild#define SNDCTL_DSP_GET_RECSRC_NAMES     _IOR ('P', 37, oss_mixer_enuminfo)
1675162588Snetchild#define SNDCTL_DSP_GET_RECSRC           _IOR ('P', 38, int)
1676162588Snetchild#define SNDCTL_DSP_SET_RECSRC           _IOWR('P', 38, int)
1677162588Snetchild
1678162588Snetchild#define SNDCTL_DSP_GET_PLAYTGT_NAMES    _IOR ('P', 39, oss_mixer_enuminfo)
1679162588Snetchild#define SNDCTL_DSP_GET_PLAYTGT          _IOR ('P', 40, int)
1680162588Snetchild#define SNDCTL_DSP_SET_PLAYTGT          _IOWR('P', 40, int)
1681162588Snetchild#define SNDCTL_DSP_GETRECVOL            _IOR ('P', 41, int)
1682162588Snetchild#define SNDCTL_DSP_SETRECVOL            _IOWR('P', 41, int)
1683162588Snetchild
1684162588Snetchild/*
1685162588Snetchild ***************************************************************************
1686162588Snetchild * Some calls for setting the channel assignment with multi channel devices
1687162588Snetchild * (see the manual for details).                                                 */
1688162588Snetchild#define SNDCTL_DSP_GET_CHNORDER         _IOR ('P', 42, unsigned long long)
1689162588Snetchild#define SNDCTL_DSP_SET_CHNORDER         _IOWR('P', 42, unsigned long long)
1690162588Snetchild#       define CHID_UNDEF       0
1691193640Sariff#       define CHID_L           1
1692193640Sariff#       define CHID_R           2
1693162588Snetchild#       define CHID_C           3
1694162588Snetchild#       define CHID_LFE         4
1695162588Snetchild#       define CHID_LS          5
1696162588Snetchild#       define CHID_RS          6
1697162588Snetchild#       define CHID_LR          7
1698162588Snetchild#       define CHID_RR          8
1699162588Snetchild#define CHNORDER_UNDEF          0x0000000000000000ULL
1700162588Snetchild#define CHNORDER_NORMAL         0x0000000087654321ULL
1701162588Snetchild
1702162588Snetchild#define MAX_PEAK_CHANNELS	128
1703162588Snetchildtypedef unsigned short oss_peaks_t[MAX_PEAK_CHANNELS];
1704162588Snetchild#define SNDCTL_DSP_GETIPEAKS		_IOR('P', 43, oss_peaks_t)
1705162588Snetchild#define SNDCTL_DSP_GETOPEAKS		_IOR('P', 44, oss_peaks_t)
1706162588Snetchild#define SNDCTL_DSP_POLICY               _IOW('P', 45, int)    /* See the manual */
1707162588Snetchild
1708164613Snetchild/*
1709193640Sariff ****************************************************************************
1710193640Sariff * Few ioctl calls that are not official parts of OSS. They have been used
1711193640Sariff * by few freeware implementations of OSS.
1712193640Sariff */
1713193640Sariff#define SNDCTL_DSP_GETCHANNELMASK	_IOWR('P', 64, int)
1714193640Sariff#define SNDCTL_DSP_BIND_CHANNEL		_IOWR('P', 65, int)
1715193640Sariff#define DSP_BIND_QUERY			0x00000000
1716193640Sariff#define DSP_BIND_FRONT			0x00000001
1717193640Sariff#define DSP_BIND_SURR			0x00000002
1718193640Sariff#define DSP_BIND_CENTER_LFE		0x00000004
1719193640Sariff#define DSP_BIND_HANDSET		0x00000008
1720193640Sariff#define DSP_BIND_MIC			0x00000010
1721193640Sariff#define DSP_BIND_MODEM1			0x00000020
1722193640Sariff#define DSP_BIND_MODEM2			0x00000040
1723193640Sariff#define DSP_BIND_I2S			0x00000080
1724193640Sariff#define DSP_BIND_SPDIF			0x00000100
1725193640Sariff#define DSP_BIND_REAR			0x00000200
1726193640Sariff
1727193640Sariff/*
1728164613Snetchild * OSS_SYSIFO is obsolete. Use SNDCTL_SYSINFO insteads.
1729164613Snetchild */
1730164613Snetchild#define OSS_GETVERSION                  _IOR ('M', 118, int)
1731164613Snetchild
1732162588Snetchild/**
1733162588Snetchild * @brief	Argument for SNDCTL_SYSINFO ioctl.
1734162588Snetchild *
1735162588Snetchild * For use w/ the SNDCTL_SYSINFO ioctl available on audio (/dev/dsp*),
1736162588Snetchild * mixer, and MIDI devices.
1737162588Snetchild */
1738162588Snetchildtypedef struct oss_sysinfo
1739162588Snetchild{
1740162588Snetchild	char	product[32];	/* For example OSS/Free, OSS/Linux or
1741162588Snetchild				   OSS/Solaris */
1742162588Snetchild	char	version[32];	/* For example 4.0a */
1743162588Snetchild	int	versionnum;	/* See OSS_GETVERSION */
1744162588Snetchild	char	options[128];	/* Reserved */
1745162588Snetchild
1746162588Snetchild	int	numaudios;	/* # of audio/dsp devices */
1747162588Snetchild	int	openedaudio[8];	/* Bit mask telling which audio devices
1748162588Snetchild				   are busy */
1749162588Snetchild
1750162588Snetchild	int	numsynths;	/* # of availavle synth devices */
1751162588Snetchild	int	nummidis;	/* # of available MIDI ports */
1752162588Snetchild	int	numtimers;	/* # of available timer devices */
1753162588Snetchild	int	nummixers;	/* # of mixer devices */
1754162588Snetchild
1755162588Snetchild	int	openedmidi[8];	/* Bit mask telling which midi devices
1756162588Snetchild				   are busy */
1757162588Snetchild	int	numcards;	/* Number of sound cards in the system */
1758186875Smav	int	numaudioengines;	/* Number of audio engines in the system */
1759186875Smav	char	license[16];	/* For example "GPL" or "CDDL" */
1760186875Smav	char	revision_info[256];	/* For internal use */
1761186875Smav	int	filler[172];	/* For future expansion (set to -1) */
1762162588Snetchild} oss_sysinfo;
1763162588Snetchild
1764162588Snetchildtypedef struct oss_mixext
1765162588Snetchild{
1766162588Snetchild  int dev;			/* Mixer device number */
1767162588Snetchild  int ctrl;			/* Controller number */
1768162588Snetchild  int type;			/* Entry type */
1769162588Snetchild#	define MIXT_DEVROOT	 0	/* Device root entry */
1770162588Snetchild#	define MIXT_GROUP	 1	/* Controller group */
1771162588Snetchild#	define MIXT_ONOFF	 2	/* OFF (0) or ON (1) */
1772162588Snetchild#	define MIXT_ENUM	 3	/* Enumerated (0 to maxvalue) */
1773162588Snetchild#	define MIXT_MONOSLIDER	 4	/* Mono slider (0 to 100) */
1774162588Snetchild#	define MIXT_STEREOSLIDER 5	/* Stereo slider (dual 0 to 100) */
1775162588Snetchild#	define MIXT_MESSAGE	 6	/* (Readable) textual message */
1776162588Snetchild#	define MIXT_MONOVU	 7	/* VU meter value (mono) */
1777162588Snetchild#	define MIXT_STEREOVU	 8	/* VU meter value (stereo) */
1778162588Snetchild#	define MIXT_MONOPEAK	 9	/* VU meter peak value (mono) */
1779162588Snetchild#	define MIXT_STEREOPEAK	10	/* VU meter peak value (stereo) */
1780162588Snetchild#	define MIXT_RADIOGROUP	11	/* Radio button group */
1781162588Snetchild#	define MIXT_MARKER	12	/* Separator between normal and extension entries */
1782162588Snetchild#	define MIXT_VALUE	13	/* Decimal value entry */
1783162588Snetchild#	define MIXT_HEXVALUE	14	/* Hexadecimal value entry */
1784162588Snetchild#	define MIXT_MONODB	15	/* Mono atten. slider (0 to -144) */
1785162588Snetchild#	define MIXT_STEREODB	16	/* Stereo atten. slider (dual 0 to -144) */
1786162588Snetchild#	define MIXT_SLIDER	17	/* Slider (mono) with full integer range */
1787162588Snetchild#	define MIXT_3D		18
1788162588Snetchild
1789162588Snetchild  /* Possible value range (minvalue to maxvalue) */
1790162588Snetchild  /* Note that maxvalue may also be smaller than minvalue */
1791162588Snetchild  int maxvalue;
1792162588Snetchild  int minvalue;
1793162588Snetchild
1794162588Snetchild  int flags;
1795162588Snetchild#	define MIXF_READABLE	0x00000001	/* Has readable value */
1796162588Snetchild#	define MIXF_WRITEABLE	0x00000002	/* Has writeable value */
1797162588Snetchild#	define MIXF_POLL	0x00000004	/* May change itself */
1798162588Snetchild#	define MIXF_HZ		0x00000008	/* Herz scale */
1799162588Snetchild#	define MIXF_STRING	0x00000010	/* Use dynamic extensions for value */
1800162588Snetchild#	define MIXF_DYNAMIC	0x00000010	/* Supports dynamic extensions */
1801162588Snetchild#	define MIXF_OKFAIL	0x00000020	/* Interpret value as 1=OK, 0=FAIL */
1802162588Snetchild#	define MIXF_FLAT	0x00000040	/* Flat vertical space requirements */
1803162588Snetchild#	define MIXF_LEGACY	0x00000080	/* Legacy mixer control group */
1804162588Snetchild  char id[16];			/* Mnemonic ID (mainly for internal use) */
1805162588Snetchild  int parent;			/* Entry# of parent (group) node (-1 if root) */
1806162588Snetchild
1807162588Snetchild  int dummy;			/* Internal use */
1808162588Snetchild
1809162588Snetchild  int timestamp;
1810162588Snetchild
1811162588Snetchild  char data[64];		/* Misc data (entry type dependent) */
1812162588Snetchild  unsigned char enum_present[32];	/* Mask of allowed enum values */
1813162588Snetchild  int control_no;		/* SOUND_MIXER_VOLUME..SOUND_MIXER_MIDI */
1814162588Snetchild  /* (-1 means not indicated) */
1815162588Snetchild
1816162588Snetchild/*
1817162588Snetchild * The desc field is reserved for internal purposes of OSS. It should not be
1818162588Snetchild * used by applications.
1819162588Snetchild */
1820162588Snetchild  unsigned int desc;
1821162588Snetchild#define MIXEXT_SCOPE_MASK			0x0000003f
1822162588Snetchild#define MIXEXT_SCOPE_OTHER			0x00000000
1823162588Snetchild#define MIXEXT_SCOPE_INPUT			0x00000001
1824162588Snetchild#define MIXEXT_SCOPE_OUTPUT			0x00000002
1825162588Snetchild#define MIXEXT_SCOPE_MONITOR			0x00000003
1826162588Snetchild#define MIXEXT_SCOPE_RECSWITCH			0x00000004
1827162588Snetchild
1828162588Snetchild  char extname[32];
1829162588Snetchild  int update_counter;
1830162588Snetchild  int filler[7];
1831162588Snetchild} oss_mixext;
1832162588Snetchild
1833162588Snetchildtypedef struct oss_mixext_root
1834162588Snetchild{
1835162588Snetchild  char id[16];
1836162588Snetchild  char name[48];
1837162588Snetchild} oss_mixext_root;
1838162588Snetchild
1839162588Snetchildtypedef struct oss_mixer_value
1840162588Snetchild{
1841162588Snetchild  int dev;
1842162588Snetchild  int ctrl;
1843162588Snetchild  int value;
1844162588Snetchild  int flags;			/* Reserved for future use. Initialize to 0 */
1845162588Snetchild  int timestamp;		/* Must be set to oss_mixext.timestamp */
1846162588Snetchild  int filler[8];		/* Reserved for future use. Initialize to 0 */
1847162588Snetchild} oss_mixer_value;
1848162588Snetchild
1849162588Snetchild#define OSS_ENUM_MAXVALUE       255
1850162588Snetchildtypedef struct oss_mixer_enuminfo
1851162588Snetchild{
1852162588Snetchild	int	dev;
1853162588Snetchild	int	ctrl;
1854162588Snetchild	int	nvalues;
1855162588Snetchild	int	version;                  /* Read the manual */
1856162588Snetchild	short	strindex[OSS_ENUM_MAXVALUE];
1857162588Snetchild	char	strings[3000];
1858162588Snetchild} oss_mixer_enuminfo;
1859162588Snetchild
1860162588Snetchild#define OPEN_READ       PCM_ENABLE_INPUT
1861162588Snetchild#define OPEN_WRITE      PCM_ENABLE_OUTPUT
1862162588Snetchild#define OPEN_READWRITE  (OPEN_READ|OPEN_WRITE)
1863162588Snetchild
1864162588Snetchild/**
1865162588Snetchild * @brief	Argument for SNDCTL_AUDIOINFO ioctl.
1866162588Snetchild *
1867162588Snetchild * For use w/ the SNDCTL_AUDIOINFO ioctl available on audio (/dev/dsp*)
1868162588Snetchild * devices.
1869162588Snetchild */
1870162588Snetchildtypedef struct oss_audioinfo
1871162588Snetchild{
1872162588Snetchild	int	dev;		/* Audio device number */
1873162588Snetchild	char	name[64];
1874162588Snetchild	int	busy;		/* 0, OPEN_READ, OPEN_WRITE or OPEN_READWRITE */
1875162588Snetchild	int	pid;
1876162588Snetchild	int	caps;		/* DSP_CAP_INPUT, DSP_CAP_OUTPUT */
1877162588Snetchild	int	iformats;
1878162588Snetchild	int	oformats;
1879162588Snetchild	int	magic;		/* Reserved for internal use */
1880162588Snetchild	char 	cmd[64];	/* Command using the device (if known) */
1881162588Snetchild	int	card_number;
1882162588Snetchild	int	port_number;
1883162588Snetchild	int	mixer_dev;
1884162588Snetchild	int	real_device;	/* Obsolete field. Replaced by devnode */
1885162588Snetchild	int	enabled;	/* 1=enabled, 0=device not ready at this
1886162588Snetchild				   moment */
1887162588Snetchild	int	flags;		/* For internal use only - no practical
1888162588Snetchild				   meaning */
1889162588Snetchild	int	min_rate;	/* Sample rate limits */
1890162588Snetchild	int	max_rate;
1891162588Snetchild	int	min_channels;	/* Number of channels supported */
1892162588Snetchild	int	max_channels;
1893162588Snetchild	int	binding;	/* DSP_BIND_FRONT, etc. 0 means undefined */
1894162588Snetchild	int	rate_source;
1895162588Snetchild	char	handle[32];
1896163731Snetchild	#define OSS_MAX_SAMPLE_RATES	20	/* Cannot be changed  */
1897162588Snetchild	unsigned int nrates;
1898163731Snetchild	unsigned int rates[OSS_MAX_SAMPLE_RATES]; /* Please read the manual before using these */
1899162588Snetchild	oss_longname_t	song_name;	/* Song name (if given) */
1900162588Snetchild	oss_label_t	label;		/* Device label (if given) */
1901162588Snetchild	int		latency;	/* In usecs, -1=unknown */
1902162588Snetchild	oss_devnode_t	devnode;	/* Device special file name (inside
1903162588Snetchild					   /dev) */
1904187030Smav	int next_play_engine;
1905187030Smav	int next_rec_engine;
1906187030Smav	int filler[184];
1907162588Snetchild} oss_audioinfo;
1908162588Snetchild
1909162588Snetchildtypedef struct oss_mixerinfo
1910162588Snetchild{
1911162588Snetchild  int dev;
1912162588Snetchild  char id[16];
1913162588Snetchild  char name[32];
1914162588Snetchild  int modify_counter;
1915162588Snetchild  int card_number;
1916162588Snetchild  int port_number;
1917162588Snetchild  char handle[32];
1918162588Snetchild  int magic;			/* Reserved */
1919162588Snetchild  int enabled;			/* Reserved */
1920162588Snetchild  int caps;
1921162588Snetchild#define MIXER_CAP_VIRTUAL				0x00000001
1922162588Snetchild  int flags;			/* Reserved */
1923162588Snetchild  int nrext;
1924162588Snetchild  /*
1925162588Snetchild   * The priority field can be used to select the default (motherboard)
1926162588Snetchild   * mixer device. The mixer with the highest priority is the
1927162588Snetchild   * most preferred one. -2 or less means that this device cannot be used
1928162588Snetchild   * as the default mixer.
1929162588Snetchild   */
1930162588Snetchild  int priority;
1931162588Snetchild  int filler[254];		/* Reserved */
1932162588Snetchild} oss_mixerinfo;
1933162588Snetchild
1934162588Snetchildtypedef struct oss_midi_info
1935162588Snetchild{
1936162588Snetchild  int dev;			/* Midi device number */
1937162588Snetchild  char name[64];
1938162588Snetchild  int busy;			/* 0, OPEN_READ, OPEN_WRITE or OPEN_READWRITE */
1939162588Snetchild  int pid;
1940162588Snetchild  char cmd[64];			/* Command using the device (if known) */
1941162588Snetchild  int caps;
1942162588Snetchild#define MIDI_CAP_MPU401		0x00000001	/**** OBSOLETE ****/
1943162588Snetchild#define MIDI_CAP_INPUT		0x00000002
1944162588Snetchild#define MIDI_CAP_OUTPUT		0x00000004
1945162588Snetchild#define MIDI_CAP_INOUT		(MIDI_CAP_INPUT|MIDI_CAP_OUTPUT)
1946162588Snetchild#define MIDI_CAP_VIRTUAL	0x00000008	/* Pseudo device */
1947162588Snetchild#define MIDI_CAP_MTCINPUT	0x00000010	/* Supports SNDCTL_MIDI_MTCINPUT */
1948162588Snetchild#define MIDI_CAP_CLIENT		0x00000020	/* Virtual client side device */
1949162588Snetchild#define MIDI_CAP_SERVER		0x00000040	/* Virtual server side device */
1950162588Snetchild#define MIDI_CAP_INTERNAL	0x00000080	/* Internal (synth) device */
1951162588Snetchild#define MIDI_CAP_EXTERNAL	0x00000100	/* external (MIDI port) device */
1952162588Snetchild#define MIDI_CAP_PTOP		0x00000200	/* Point to point link to one device */
1953162588Snetchild#define MIDI_CAP_MTC		0x00000400	/* MTC/SMPTE (control) device */
1954162588Snetchild  int magic;			/* Reserved for internal use */
1955162588Snetchild  int card_number;
1956162588Snetchild  int port_number;
1957162588Snetchild  int enabled;			/* 1=enabled, 0=device not ready at this moment */
1958162588Snetchild  int flags;			/* For internal use only - no practical meaning */
1959162588Snetchild  char handle[32];
1960162588Snetchild  oss_longname_t song_name;	/* Song name (if known) */
1961162588Snetchild  oss_label_t label;		/* Device label (if given) */
1962162588Snetchild  int latency;			/* In usecs, -1=unknown */
1963162588Snetchild  int filler[244];
1964162588Snetchild} oss_midi_info;
1965162588Snetchild
1966162588Snetchildtypedef struct oss_card_info
1967162588Snetchild{
1968162588Snetchild  int card;
1969162588Snetchild  char shortname[16];
1970162588Snetchild  char longname[128];
1971162588Snetchild  int flags;
1972187030Smav  char hw_info[400];
1973187030Smav  int intr_count, ack_count;
1974187030Smav  int filler[154];
1975162588Snetchild} oss_card_info;
1976162588Snetchild
1977162588Snetchild#define SNDCTL_SYSINFO          _IOR ('X', 1, oss_sysinfo)
1978162588Snetchild#define OSS_SYSINFO             SNDCTL_SYSINFO /* Old name */
1979162588Snetchild
1980162588Snetchild#define SNDCTL_MIX_NRMIX	_IOR ('X', 2, int)
1981162588Snetchild#define SNDCTL_MIX_NREXT	_IOWR('X', 3, int)
1982162588Snetchild#define SNDCTL_MIX_EXTINFO	_IOWR('X', 4, oss_mixext)
1983162588Snetchild#define SNDCTL_MIX_READ		_IOWR('X', 5, oss_mixer_value)
1984162588Snetchild#define SNDCTL_MIX_WRITE	_IOWR('X', 6, oss_mixer_value)
1985162588Snetchild
1986162588Snetchild#define SNDCTL_AUDIOINFO	_IOWR('X', 7, oss_audioinfo)
1987162588Snetchild#define SNDCTL_MIX_ENUMINFO	_IOWR('X', 8, oss_mixer_enuminfo)
1988162588Snetchild#define SNDCTL_MIDIINFO		_IOWR('X', 9, oss_midi_info)
1989162588Snetchild#define SNDCTL_MIXERINFO	_IOWR('X',10, oss_mixerinfo)
1990162588Snetchild#define SNDCTL_CARDINFO		_IOWR('X',11, oss_card_info)
1991187030Smav#define SNDCTL_ENGINEINFO	_IOWR('X',12, oss_audioinfo)
1992187030Smav#define SNDCTL_AUDIOINFO_EX	_IOWR('X',13, oss_audioinfo)
1993162588Snetchild
1994162588Snetchild/*
1995162588Snetchild * Few more "globally" available ioctl calls.
1996162588Snetchild */
1997162588Snetchild#define SNDCTL_SETSONG          _IOW ('Y', 2, oss_longname_t)
1998162588Snetchild#define SNDCTL_GETSONG          _IOR ('Y', 2, oss_longname_t)
1999162588Snetchild#define SNDCTL_SETNAME          _IOW ('Y', 3, oss_longname_t)
2000162588Snetchild#define SNDCTL_SETLABEL         _IOW ('Y', 4, oss_label_t)
2001162588Snetchild#define SNDCTL_GETLABEL         _IOR ('Y', 4, oss_label_t)
2002162588Snetchild
200350906Sdfr#endif	/* !_SYS_SOUNDCARD_H_ */
2004