soundcard.h revision 193640
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 193640 2009-06-07 19:12:08Z 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
174114642Smbr#if _BYTE_ORDER == _LITTLE_ENDIAN
175114181Smbr#define AFMT_S16_NE	AFMT_S16_LE	/* native endian signed 16 */
176114181Smbr#else
177114181Smbr#define AFMT_S16_NE	AFMT_S16_BE
178114181Smbr#endif
179114181Smbr
18065335Scg/*
18181891Ssobomax * 32-bit formats below used for 24-bit audio data where the data is stored
18281891Ssobomax * in the 24 most significant bits and the least significant bits are not used
18381891Ssobomax * (should be set to 0).
18465335Scg */
18581891Ssobomax#define AFMT_S32_LE	0x00001000	/* Little endian signed 32-bit */
18681891Ssobomax#define AFMT_S32_BE	0x00002000	/* Big endian signed 32-bit */
18781891Ssobomax#define AFMT_U32_LE	0x00004000	/* Little endian unsigned 32-bit */
18881891Ssobomax#define AFMT_U32_BE	0x00008000	/* Big endian unsigned 32-bit */
189148605Snetchild#define AFMT_S24_LE	0x00010000	/* Little endian signed 24-bit */
190148605Snetchild#define AFMT_S24_BE	0x00020000	/* Big endian signed 24-bit */
191148605Snetchild#define AFMT_U24_LE	0x00040000	/* Little endian unsigned 24-bit */
192148605Snetchild#define AFMT_U24_BE	0x00080000	/* Big endian unsigned 24-bit */
19333473Sscrappy
19481891Ssobomax#define AFMT_STEREO	0x10000000	/* can do/want stereo	*/
19533473Sscrappy
19633473Sscrappy/*
19733473Sscrappy * the following are really capabilities
19833473Sscrappy */
19981891Ssobomax#define AFMT_WEIRD	0x20000000	/* weird hardware...	*/
20033473Sscrappy    /*
20133473Sscrappy     * AFMT_WEIRD reports that the hardware might need to operate
20233473Sscrappy     * with different formats in the playback and capture
20333473Sscrappy     * channels when operating in full duplex.
20433473Sscrappy     * As an example, SoundBlaster16 cards only support U8 in one
20533473Sscrappy     * direction and S16 in the other one, and applications should
20633473Sscrappy     * be aware of this limitation.
20733473Sscrappy     */
20881891Ssobomax#define AFMT_FULLDUPLEX	0x80000000	/* can do full duplex	*/
20933473Sscrappy
21033473Sscrappy/*
21133473Sscrappy * The following structure is used to get/set format and sampling rate.
21233473Sscrappy * While it would be better to have things such as stereo, bits per
21333473Sscrappy * sample, endiannes, etc split in different variables, it turns out
21433473Sscrappy * that formats are not that many, and not all combinations are possible.
21533473Sscrappy * So we followed the Voxware approach of associating one bit to each
21633473Sscrappy * format.
21733473Sscrappy */
21833473Sscrappy
21933473Sscrappytypedef struct _snd_chan_param {
22033473Sscrappy    u_long	play_rate;	/* sampling rate			*/
22133473Sscrappy    u_long	rec_rate;	/* sampling rate			*/
22233473Sscrappy    u_long	play_format;	/* everything describing the format	*/
22333473Sscrappy    u_long	rec_format;	/* everything describing the format	*/
22433473Sscrappy} snd_chan_param;
22533473Sscrappy#define	AIOGFMT    _IOR('f', 12, snd_chan_param)   /* get format */
22633473Sscrappy#define	AIOSFMT    _IOWR('f', 12, snd_chan_param)  /* sets format */
22733473Sscrappy
22833473Sscrappy/*
22933473Sscrappy * The following structure is used to get/set the mixer setting.
23033473Sscrappy * Up to 32 mixers are supported, each one with up to 32 channels.
23133473Sscrappy */
23233473Sscrappytypedef struct _snd_mix_param {
23333473Sscrappy    u_char	subdev;	/* which output				*/
23433473Sscrappy    u_char	line;	/* which input				*/
23533473Sscrappy    u_char	left,right; /* volumes, 0..255, 0 = mute	*/
23633473Sscrappy} snd_mix_param ;
23733473Sscrappy
23833473Sscrappy/* XXX AIOGMIX, AIOSMIX not implemented yet */
23933473Sscrappy#define AIOGMIX	_IOWR('A', 13, snd_mix_param)	/* return mixer status */
24033473Sscrappy#define AIOSMIX	_IOWR('A', 14, snd_mix_param)	/* sets mixer status   */
24133473Sscrappy
24233473Sscrappy/*
24333473Sscrappy * channel specifiers used in AIOSTOP and AIOSYNC
24433473Sscrappy */
24533473Sscrappy#define	AIOSYNC_PLAY	0x1	/* play chan */
24633473Sscrappy#define	AIOSYNC_CAPTURE	0x2	/* capture chan */
24733473Sscrappy/* AIOSTOP stop & flush a channel, returns the residual count */
24833473Sscrappy#define	AIOSTOP	_IOWR ('A', 15, int)
24933473Sscrappy
25033473Sscrappy/* alternate method used to notify the sync condition */
25133473Sscrappy#define	AIOSYNC_SIGNAL	0x100
25233473Sscrappy#define	AIOSYNC_SELECT	0x200
25333473Sscrappy
25433473Sscrappy/* what the 'pos' field refers to */
25533473Sscrappy#define AIOSYNC_READY	0x400
25633473Sscrappy#define AIOSYNC_FREE	0x800
25733473Sscrappy
25833473Sscrappytypedef struct _snd_sync_parm {
25933473Sscrappy    long chan ; /* play or capture channel, plus modifier */
26033473Sscrappy    long pos;
26133473Sscrappy} snd_sync_parm;
26233473Sscrappy#define	AIOSYNC	_IOWR ('A', 15, snd_sync_parm)	/* misc. synchronization */
26333473Sscrappy
26433473Sscrappy/*
26533473Sscrappy * The following is used to return device capabilities. If the structure
26633473Sscrappy * passed to the ioctl is zeroed, default values are returned for rate
26733473Sscrappy * and formats, a bitmap of available mixers is returned, and values
26833473Sscrappy * (inputs, different levels) for the first one are returned.
26933473Sscrappy *
27033473Sscrappy * If  formats, mixers, inputs are instantiated, then detailed info
27133473Sscrappy * are returned depending on the call.
27233473Sscrappy */
27333473Sscrappytypedef struct _snd_capabilities {
27433473Sscrappy    u_long	rate_min, rate_max;	/* min-max sampling rate */
27533473Sscrappy    u_long	formats;
27633473Sscrappy    u_long	bufsize; /* DMA buffer size */
27733473Sscrappy    u_long	mixers; /* bitmap of available mixers */
27833473Sscrappy    u_long	inputs; /* bitmap of available inputs (per mixer) */
27933473Sscrappy    u_short	left, right;	/* how many levels are supported */
28033473Sscrappy} snd_capabilities;
28133473Sscrappy#define AIOGCAP	_IOWR('A', 15, snd_capabilities)	/* get capabilities */
28233473Sscrappy
28333473Sscrappy/*
28433473Sscrappy * here is the old (Voxware) ioctl interface
28533473Sscrappy */
28633473Sscrappy
28733473Sscrappy/*
288652Sjkh * IOCTL Commands for /dev/sequencer
289652Sjkh */
290652Sjkh
29133473Sscrappy#define SNDCTL_SEQ_RESET	_IO  ('Q', 0)
29233473Sscrappy#define SNDCTL_SEQ_SYNC		_IO  ('Q', 1)
29333473Sscrappy#define SNDCTL_SYNTH_INFO	_IOWR('Q', 2, struct synth_info)
29433473Sscrappy#define SNDCTL_SEQ_CTRLRATE	_IOWR('Q', 3, int) /* Set/get timer res.(hz) */
29533473Sscrappy#define SNDCTL_SEQ_GETOUTCOUNT	_IOR ('Q', 4, int)
29633473Sscrappy#define SNDCTL_SEQ_GETINCOUNT	_IOR ('Q', 5, int)
29733473Sscrappy#define SNDCTL_SEQ_PERCMODE	_IOW ('Q', 6, int)
29833473Sscrappy#define SNDCTL_FM_LOAD_INSTR	_IOW ('Q', 7, struct sbi_instrument)	/* Valid for FM only */
29933473Sscrappy#define SNDCTL_SEQ_TESTMIDI	_IOW ('Q', 8, int)
30033473Sscrappy#define SNDCTL_SEQ_RESETSAMPLES	_IOW ('Q', 9, int)
30133473Sscrappy#define SNDCTL_SEQ_NRSYNTHS	_IOR ('Q',10, int)
30233473Sscrappy#define SNDCTL_SEQ_NRMIDIS	_IOR ('Q',11, int)
30333473Sscrappy#define SNDCTL_MIDI_INFO	_IOWR('Q',12, struct midi_info)
30433473Sscrappy#define SNDCTL_SEQ_THRESHOLD	_IOW ('Q',13, int)
30533473Sscrappy#define SNDCTL_SEQ_TRESHOLD	SNDCTL_SEQ_THRESHOLD	/* there was once a typo */
30633473Sscrappy#define SNDCTL_SYNTH_MEMAVL	_IOWR('Q',14, int) /* in=dev#, out=memsize */
30733473Sscrappy#define SNDCTL_FM_4OP_ENABLE	_IOW ('Q',15, int) /* in=dev# */
30833473Sscrappy#define SNDCTL_PMGR_ACCESS	_IOWR('Q',16, struct patmgr_info)
30933473Sscrappy#define SNDCTL_SEQ_PANIC	_IO  ('Q',17)
31033473Sscrappy#define SNDCTL_SEQ_OUTOFBAND	_IOW ('Q',18, struct seq_event_rec)
311122954Smatk#define SNDCTL_SEQ_GETTIME	_IOR ('Q',19, int)
3129750Sjkh
31330866Smarkmstruct seq_event_rec {
31430866Smarkm	u_char arr[8];
31530866Smarkm};
3169750Sjkh
31733473Sscrappy#define SNDCTL_TMR_TIMEBASE	_IOWR('T', 1, int)
31833473Sscrappy#define SNDCTL_TMR_START	_IO  ('T', 2)
31933473Sscrappy#define SNDCTL_TMR_STOP		_IO  ('T', 3)
32033473Sscrappy#define SNDCTL_TMR_CONTINUE	_IO  ('T', 4)
32133473Sscrappy#define SNDCTL_TMR_TEMPO	_IOWR('T', 5, int)
32233473Sscrappy#define SNDCTL_TMR_SOURCE	_IOWR('T', 6, int)
32333473Sscrappy#   define TMR_INTERNAL		0x00000001
32433473Sscrappy#   define TMR_EXTERNAL		0x00000002
32533473Sscrappy#	define TMR_MODE_MIDI	0x00000010
32633473Sscrappy#	define TMR_MODE_FSK	0x00000020
32733473Sscrappy#	define TMR_MODE_CLS	0x00000040
32833473Sscrappy#	define TMR_MODE_SMPTE	0x00000080
32933473Sscrappy#define SNDCTL_TMR_METRONOME	_IOW ('T', 7, int)
33033473Sscrappy#define SNDCTL_TMR_SELECT	_IOW ('T', 8, int)
3313256Sswallace
332652Sjkh/*
33330866Smarkm *	Endian aware patch key generation algorithm.
33430866Smarkm */
33530866Smarkm
33630866Smarkm#if defined(_AIX) || defined(AIX)
33730866Smarkm#  define _PATCHKEY(id) (0xfd00|id)
33830866Smarkm#else
33930866Smarkm#  define _PATCHKEY(id) ((id<<8)|0xfd)
34030866Smarkm#endif
34130866Smarkm
34230866Smarkm/*
343652Sjkh *	Sample loading mechanism for internal synthesizers (/dev/sequencer)
344652Sjkh *	The following patch_info structure has been designed to support
345652Sjkh *	Gravis UltraSound. It tries to be universal format for uploading
34633473Sscrappy *	sample based patches but is probably too limited.
347652Sjkh */
348652Sjkh
349652Sjkhstruct patch_info {
35030866Smarkm/*		u_short key;		 Use GUS_PATCH here */
35130866Smarkm	short key;		 /* Use GUS_PATCH here */
35230866Smarkm#define GUS_PATCH	_PATCHKEY(0x04)
35330866Smarkm#define OBSOLETE_GUS_PATCH	_PATCHKEY(0x02)
354652Sjkh
35530866Smarkm	short device_no;	/* Synthesizer number */
35630866Smarkm	short instr_no;		/* Midi pgm# */
35730866Smarkm
35830866Smarkm	u_long mode;
359652Sjkh/*
360652Sjkh * The least significant byte has the same format than the GUS .PAT
361652Sjkh * files
362652Sjkh */
363652Sjkh#define WAVE_16_BITS	0x01	/* bit 0 = 8 or 16 bit wave data. */
364652Sjkh#define WAVE_UNSIGNED	0x02	/* bit 1 = Signed - Unsigned data. */
365652Sjkh#define WAVE_LOOPING	0x04	/* bit 2 = looping enabled-1. */
366652Sjkh#define WAVE_BIDIR_LOOP	0x08	/* bit 3 = Set is bidirectional looping. */
367652Sjkh#define WAVE_LOOP_BACK	0x10	/* bit 4 = Set is looping backward. */
368652Sjkh#define WAVE_SUSTAIN_ON	0x20	/* bit 5 = Turn sustaining on. (Env. pts. 3)*/
369652Sjkh#define WAVE_ENVELOPES	0x40	/* bit 6 = Enable envelopes - 1 */
370652Sjkh				/* 	(use the env_rate/env_offs fields). */
371652Sjkh/* Linux specific bits */
372652Sjkh#define WAVE_VIBRATO	0x00010000	/* The vibrato info is valid */
373652Sjkh#define WAVE_TREMOLO	0x00020000	/* The tremolo info is valid */
374652Sjkh#define WAVE_SCALE	0x00040000	/* The scaling info is valid */
375652Sjkh/* Other bits must be zeroed */
376652Sjkh
37730866Smarkm	long len;	/* Size of the wave data in bytes */
37830866Smarkm	long loop_start, loop_end; /* Byte offsets from the beginning */
379652Sjkh
38065335Scg/*
381652Sjkh * The base_freq and base_note fields are used when computing the
382652Sjkh * playback speed for a note. The base_note defines the tone frequency
383652Sjkh * which is heard if the sample is played using the base_freq as the
384652Sjkh * playback speed.
385652Sjkh *
386652Sjkh * The low_note and high_note fields define the minimum and maximum note
387652Sjkh * frequencies for which this sample is valid. It is possible to define
388108533Sschweikh * more than one samples for an instrument number at the same time. The
389652Sjkh * low_note and high_note fields are used to select the most suitable one.
390652Sjkh *
391652Sjkh * The fields base_note, high_note and low_note should contain
392652Sjkh * the note frequency multiplied by 1000. For example value for the
393652Sjkh * middle A is 440*1000.
394652Sjkh */
395652Sjkh
39630866Smarkm	u_int base_freq;
39730866Smarkm	u_long base_note;
39830866Smarkm	u_long high_note;
39930866Smarkm	u_long low_note;
40030866Smarkm	int panning;	/* -128=left, 127=right */
40130866Smarkm	int detuning;
402652Sjkh
403652Sjkh/*	New fields introduced in version 1.99.5	*/
404652Sjkh
405652Sjkh       /* Envelope. Enabled by mode bit WAVE_ENVELOPES	*/
40630866Smarkm	u_char	env_rate[ 6 ];	 /* GUS HW ramping rate */
40730866Smarkm	u_char	env_offset[ 6 ]; /* 255 == 100% */
408652Sjkh
40965335Scg	/*
410652Sjkh	 * The tremolo, vibrato and scale info are not supported yet.
411652Sjkh	 * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or
412652Sjkh	 * WAVE_SCALE
413652Sjkh	 */
414652Sjkh
41530866Smarkm	u_char	tremolo_sweep;
41630866Smarkm	u_char	tremolo_rate;
41730866Smarkm	u_char	tremolo_depth;
418652Sjkh
41930866Smarkm	u_char	vibrato_sweep;
42030866Smarkm	u_char	vibrato_rate;
42130866Smarkm	u_char	vibrato_depth;
42230866Smarkm
42330866Smarkm	int		scale_frequency;
42430866Smarkm	u_int	scale_factor;		/* from 0 to 2048 or 0 to 2 */
42565335Scg
42630866Smarkm	int		volume;
42730866Smarkm	int		spare[4];
42830866Smarkm	char data[1];	/* The waveform data starts here */
42930866Smarkm};
430652Sjkh
4313256Sswallacestruct sysex_info {
43230866Smarkm	short key;		/* Use GUS_PATCH here */
43330866Smarkm#define SYSEX_PATCH	_PATCHKEY(0x05)
43430866Smarkm#define MAUI_PATCH	_PATCHKEY(0x06)
43530866Smarkm	short device_no;	/* Synthesizer number */
43630866Smarkm	long len;	/* Size of the sysex data in bytes */
43730866Smarkm	u_char data[1];	/* Sysex data starts here */
43830866Smarkm};
4393256Sswallace
440652Sjkh/*
441652Sjkh * Patch management interface (/dev/sequencer, /dev/patmgr#)
442652Sjkh * Don't use these calls if you want to maintain compatibility with
443652Sjkh * the future versions of the driver.
444652Sjkh */
445652Sjkh
44633473Sscrappy#define PS_NO_PATCHES		0	/* No patch support on device */
44733473Sscrappy#define	PS_MGR_NOT_OK		1	/* Plain patch support (no mgr) */
44833473Sscrappy#define	PS_MGR_OK		2	/* Patch manager supported */
44933473Sscrappy#define	PS_MANAGED		3	/* Patch manager running */
450652Sjkh
451652Sjkh#define SNDCTL_PMGR_IFACE		_IOWR('P', 1, struct patmgr_info)
452652Sjkh
453652Sjkh/*
454652Sjkh * The patmgr_info is a fixed size structure which is used for two
455652Sjkh * different purposes. The intended use is for communication between
456652Sjkh * the application using /dev/sequencer and the patch manager daemon
457652Sjkh * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)).
458652Sjkh *
459652Sjkh * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows
460652Sjkh * a patch manager daemon to read and write device parameters. This
461652Sjkh * ioctl available through /dev/sequencer also. Avoid using it since it's
46265335Scg * extremely hardware dependent. In addition access trough /dev/sequencer
463652Sjkh * may confuse the patch manager daemon.
464652Sjkh */
465652Sjkh
466652Sjkhstruct patmgr_info {	/* Note! size must be < 4k since kmalloc() is used */
46730866Smarkm	  u_long key;	/* Don't worry. Reserved for communication
468652Sjkh	  			   between the patch manager and the driver. */
469652Sjkh#define PM_K_EVENT		1 /* Event from the /dev/sequencer driver */
470108533Sschweikh#define PM_K_COMMAND		2 /* Request from an application */
471652Sjkh#define PM_K_RESPONSE		3 /* From patmgr to application */
472652Sjkh#define PM_ERROR		4 /* Error returned by the patmgr */
473652Sjkh	  int device;
474652Sjkh	  int command;
475652Sjkh
47665335Scg/*
47765335Scg * Commands 0x000 to 0xfff reserved for patch manager programs
478652Sjkh */
479652Sjkh#define PM_GET_DEVTYPE	1	/* Returns type of the patch mgr interface of dev */
480652Sjkh#define		PMTYPE_FM2	1	/* 2 OP fm */
481652Sjkh#define		PMTYPE_FM4	2	/* Mixed 4 or 2 op FM (OPL-3) */
482652Sjkh#define		PMTYPE_WAVE	3	/* Wave table synthesizer (GUS) */
483652Sjkh#define PM_GET_NRPGM	2	/* Returns max # of midi programs in parm1 */
484652Sjkh#define PM_GET_PGMMAP	3	/* Returns map of loaded midi programs in data8 */
485652Sjkh#define PM_GET_PGM_PATCHES 4	/* Return list of patches of a program (parm1) */
486652Sjkh#define PM_GET_PATCH	5	/* Return patch header of patch parm1 */
487652Sjkh#define PM_SET_PATCH	6	/* Set patch header of patch parm1 */
488652Sjkh#define PM_READ_PATCH	7	/* Read patch (wave) data */
489652Sjkh#define PM_WRITE_PATCH	8	/* Write patch (wave) data */
490652Sjkh
491652Sjkh/*
492652Sjkh * Commands 0x1000 to 0xffff are for communication between the patch manager
493652Sjkh * and the client
494652Sjkh */
495652Sjkh#define _PM_LOAD_PATCH	0x100
496652Sjkh
49765335Scg/*
498652Sjkh * Commands above 0xffff reserved for device specific use
499652Sjkh */
500652Sjkh
50130866Smarkm	long parm1;
50230866Smarkm	long parm2;
50330866Smarkm	long parm3;
504652Sjkh
50530866Smarkm	union {
50630866Smarkm		u_char data8[4000];
50730866Smarkm		u_short data16[2000];
50830866Smarkm		u_long data32[1000];
509652Sjkh		struct patch_info patch;
51030866Smarkm	} data;
51130866Smarkm};
512652Sjkh
513652Sjkh/*
514652Sjkh * When a patch manager daemon is present, it will be informed by the
515652Sjkh * driver when something important happens. For example when the
516652Sjkh * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is
517652Sjkh * returned. The command field contains the event type:
518652Sjkh */
519652Sjkh#define PM_E_OPENED		1	/* /dev/sequencer opened */
520652Sjkh#define PM_E_CLOSED		2	/* /dev/sequencer closed */
521652Sjkh#define PM_E_PATCH_RESET	3	/* SNDCTL_RESETSAMPLES called */
522652Sjkh#define PM_E_PATCH_LOADED	4	/* A patch has been loaded by appl */
523652Sjkh
524652Sjkh/*
525652Sjkh * /dev/sequencer input events.
526652Sjkh *
527652Sjkh * The data written to the /dev/sequencer is a stream of events. Events
52865335Scg * are records of 4 or 8 bytes. The first byte defines the size.
529652Sjkh * Any number of events can be written with a write call. There
530652Sjkh * is a set of macros for sending these events. Use these macros if you
531652Sjkh * want to maximize portability of your program.
532652Sjkh *
533652Sjkh * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events.
534652Sjkh * (All input events are currently 4 bytes long. Be prepared to support
5353256Sswallace * 8 byte events also. If you receive any event having first byte >= 128,
536652Sjkh * it's a 8 byte event.
537652Sjkh *
538652Sjkh * The events are documented at the end of this file.
539652Sjkh *
540652Sjkh * Normal events (4 bytes)
541652Sjkh * There is also a 8 byte version of most of the 4 byte events. The
542652Sjkh * 8 byte one is recommended.
543652Sjkh */
544652Sjkh#define SEQ_NOTEOFF		0
545652Sjkh#define SEQ_FMNOTEOFF		SEQ_NOTEOFF	/* Just old name */
546652Sjkh#define SEQ_NOTEON		1
547652Sjkh#define	SEQ_FMNOTEON		SEQ_NOTEON
5483256Sswallace#define SEQ_WAIT		TMR_WAIT_ABS
549652Sjkh#define SEQ_PGMCHANGE		3
550652Sjkh#define SEQ_FMPGMCHANGE		SEQ_PGMCHANGE
5513256Sswallace#define SEQ_SYNCTIMER		TMR_START
552652Sjkh#define SEQ_MIDIPUTC		5
553652Sjkh#define SEQ_DRUMON		6	/*** OBSOLETE ***/
554652Sjkh#define SEQ_DRUMOFF		7	/*** OBSOLETE ***/
5553256Sswallace#define SEQ_ECHO		TMR_ECHO	/* For synching programs with output */
556652Sjkh#define SEQ_AFTERTOUCH		9
557652Sjkh#define SEQ_CONTROLLER		10
5583256Sswallace
55933473Sscrappy/*
5603256Sswallace *	Midi controller numbers
56133473Sscrappy *
56233473Sscrappy * Controllers 0 to 31 (0x00 to 0x1f) and 32 to 63 (0x20 to 0x3f)
56333473Sscrappy * are continuous controllers.
56433473Sscrappy * In the MIDI 1.0 these controllers are sent using two messages.
56533473Sscrappy * Controller numbers 0 to 31 are used to send the MSB and the
56633473Sscrappy * controller numbers 32 to 63 are for the LSB. Note that just 7 bits
56733473Sscrappy * are used in MIDI bytes.
5683256Sswallace */
5693256Sswallace
57033473Sscrappy#define	CTL_BANK_SELECT		0x00
57133473Sscrappy#define	CTL_MODWHEEL		0x01
57233473Sscrappy#define CTL_BREATH		0x02
57333473Sscrappy/*	undefined		0x03 */
57433473Sscrappy#define CTL_FOOT		0x04
57533473Sscrappy#define CTL_PORTAMENTO_TIME	0x05
57633473Sscrappy#define CTL_DATA_ENTRY		0x06
57733473Sscrappy#define CTL_MAIN_VOLUME		0x07
57833473Sscrappy#define CTL_BALANCE		0x08
57933473Sscrappy/*	undefined		0x09 */
58033473Sscrappy#define CTL_PAN			0x0a
58133473Sscrappy#define CTL_EXPRESSION		0x0b
58233473Sscrappy/*	undefined		0x0c - 0x0f */
58333473Sscrappy#define CTL_GENERAL_PURPOSE1	0x10
58433473Sscrappy#define CTL_GENERAL_PURPOSE2	0x11
58533473Sscrappy#define CTL_GENERAL_PURPOSE3	0x12
58633473Sscrappy#define CTL_GENERAL_PURPOSE4	0x13
58733473Sscrappy/*	undefined		0x14 - 0x1f */
5883256Sswallace
58933473Sscrappy/*	undefined		0x20 */
5903256Sswallace
59133473Sscrappy/*
59233473Sscrappy * The controller numbers 0x21 to 0x3f are reserved for the
59333473Sscrappy * least significant bytes of the controllers 0x00 to 0x1f.
59433473Sscrappy * These controllers are not recognised by the driver.
59533473Sscrappy *
59633473Sscrappy * Controllers 64 to 69 (0x40 to 0x45) are on/off switches.
59733473Sscrappy * 0=OFF and 127=ON (intermediate values are possible)
59833473Sscrappy */
59933473Sscrappy#define CTL_DAMPER_PEDAL	0x40
60033473Sscrappy#define CTL_SUSTAIN		CTL_DAMPER_PEDAL	/* Alias */
60133473Sscrappy#define CTL_HOLD		CTL_DAMPER_PEDAL	/* Alias */
60233473Sscrappy#define CTL_PORTAMENTO		0x41
60333473Sscrappy#define CTL_SOSTENUTO		0x42
60433473Sscrappy#define CTL_SOFT_PEDAL		0x43
60533473Sscrappy/*	undefined		0x44 */
60633473Sscrappy#define CTL_HOLD2		0x45
60733473Sscrappy/*	undefined		0x46 - 0x4f */
6083256Sswallace
60933473Sscrappy#define CTL_GENERAL_PURPOSE5	0x50
61033473Sscrappy#define CTL_GENERAL_PURPOSE6	0x51
61133473Sscrappy#define CTL_GENERAL_PURPOSE7	0x52
61233473Sscrappy#define CTL_GENERAL_PURPOSE8	0x53
61333473Sscrappy/*	undefined		0x54 - 0x5a */
61433473Sscrappy#define CTL_EXT_EFF_DEPTH	0x5b
61533473Sscrappy#define CTL_TREMOLO_DEPTH	0x5c
61633473Sscrappy#define CTL_CHORUS_DEPTH	0x5d
61733473Sscrappy#define CTL_DETUNE_DEPTH	0x5e
61833473Sscrappy#define CTL_CELESTE_DEPTH	CTL_DETUNE_DEPTH /* Alias for the above one */
61933473Sscrappy#define CTL_PHASER_DEPTH	0x5f
62033473Sscrappy#define CTL_DATA_INCREMENT	0x60
62133473Sscrappy#define CTL_DATA_DECREMENT	0x61
62233473Sscrappy#define CTL_NONREG_PARM_NUM_LSB	0x62
62333473Sscrappy#define CTL_NONREG_PARM_NUM_MSB	0x63
62433473Sscrappy#define CTL_REGIST_PARM_NUM_LSB	0x64
62533473Sscrappy#define CTL_REGIST_PARM_NUM_MSB	0x65
62633473Sscrappy/*	undefined		0x66 - 0x78 */
62733473Sscrappy/*	reserved		0x79 - 0x7f */
6283256Sswallace
6293256Sswallace/* Pseudo controllers (not midi compatible) */
63033473Sscrappy#define CTRL_PITCH_BENDER	255
63133473Sscrappy#define CTRL_PITCH_BENDER_RANGE	254
63233473Sscrappy#define CTRL_EXPRESSION		253	/* Obsolete */
63333473Sscrappy#define CTRL_MAIN_VOLUME	252	/* Obsolete */
63433473Sscrappy
635652Sjkh#define SEQ_BALANCE		11
6361402Sache#define SEQ_VOLMODE             12
637652Sjkh
638652Sjkh/*
6391402Sache * Volume mode decides how volumes are used
6401402Sache */
6411402Sache
6421402Sache#define VOL_METHOD_ADAGIO	1
6431402Sache#define VOL_METHOD_LINEAR	2
6441402Sache
6451402Sache/*
646652Sjkh * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as
647652Sjkh *	 input events.
648652Sjkh */
649652Sjkh
650652Sjkh/*
651652Sjkh * Event codes 0xf0 to 0xfc are reserved for future extensions.
652652Sjkh */
653652Sjkh
654652Sjkh#define SEQ_FULLSIZE		0xfd	/* Long events */
655652Sjkh/*
65633473Sscrappy * SEQ_FULLSIZE events are used for loading patches/samples to the
65733473Sscrappy * synthesizer devices. These events are passed directly to the driver
65833473Sscrappy * of the associated synthesizer device. There is no limit to the size
65933473Sscrappy * of the extended events. These events are not queued but executed
66033473Sscrappy * immediately when the write() is called (execution can take several
66165335Scg * seconds of time).
662652Sjkh *
66333473Sscrappy * When a SEQ_FULLSIZE message is written to the device, it must
66433473Sscrappy * be written using exactly one write() call. Other events cannot
66533473Sscrappy * be mixed to the same write.
66665335Scg *
66733473Sscrappy * For FM synths (YM3812/OPL3) use struct sbi_instrument and write
66833473Sscrappy * it to the /dev/sequencer. Don't write other data together with
66933473Sscrappy * the instrument structure Set the key field of the structure to
67033473Sscrappy * FM_PATCH. The device field is used to route the patch to the
67133473Sscrappy * corresponding device.
672652Sjkh *
67333473Sscrappy * For Gravis UltraSound use struct patch_info. Initialize the key field
67433473Sscrappy * to GUS_PATCH.
675652Sjkh */
67633473Sscrappy#define SEQ_PRIVATE	0xfe	/* Low level HW dependent events (8 bytes) */
67733473Sscrappy#define SEQ_EXTENDED	0xff	/* Extended events (8 bytes) OBSOLETE */
678652Sjkh
679652Sjkh/*
680652Sjkh * Record for FM patches
681652Sjkh */
682652Sjkh
68330866Smarkmtypedef u_char sbi_instr_data[32];
684652Sjkh
685652Sjkhstruct sbi_instrument {
68630866Smarkm	u_short	key;	/* FM_PATCH or OPL3_PATCH */
68730866Smarkm#define FM_PATCH	_PATCHKEY(0x01)
68830866Smarkm#define OPL3_PATCH	_PATCHKEY(0x03)
68930866Smarkm	short		device;		/* Synth# (0-4)	*/
69030866Smarkm	int 		channel;	/* Program# to be initialized  */
69130866Smarkm	sbi_instr_data	operators;	/* Reg. settings for operator cells
69230866Smarkm					 * (.SBI format)	*/
69330866Smarkm};
694652Sjkh
695652Sjkhstruct synth_info {	/* Read only */
69645462Skato	char	name[30];
69730866Smarkm	int	device;		/* 0-N. INITIALIZE BEFORE CALLING */
69830866Smarkm	int	synth_type;
699652Sjkh#define SYNTH_TYPE_FM			0
700652Sjkh#define SYNTH_TYPE_SAMPLE		1
7013256Sswallace#define SYNTH_TYPE_MIDI			2	/* Midi interface */
702652Sjkh
70330866Smarkm	int	synth_subtype;
704652Sjkh#define FM_TYPE_ADLIB			0x00
705652Sjkh#define FM_TYPE_OPL3			0x01
706122954Smatk#define MIDI_TYPE_MPU401		0x401
707652Sjkh
70833473Sscrappy#define SAMPLE_TYPE_BASIC		0x10
70933473Sscrappy#define SAMPLE_TYPE_GUS			SAMPLE_TYPE_BASIC
71033530Sscrappy#define SAMPLE_TYPE_AWE32		0x20
711652Sjkh
71230866Smarkm	int	perc_mode;	/* No longer supported */
71330866Smarkm	int	nr_voices;
71430866Smarkm	int	nr_drums;	/* Obsolete field */
71530866Smarkm	int	instr_bank_size;
71665335Scg	u_long	capabilities;
71733473Sscrappy#define SYNTH_CAP_PERCMODE	0x00000001 /* No longer used */
71833473Sscrappy#define SYNTH_CAP_OPL3		0x00000002 /* Set if OPL3 supported */
71933473Sscrappy#define SYNTH_CAP_INPUT		0x00000004 /* Input (MIDI) device */
72030866Smarkm	int	dummies[19];	/* Reserve space */
72130866Smarkm};
722652Sjkh
7233256Sswallacestruct sound_timer_info {
72430866Smarkm	char name[32];
72530866Smarkm	int caps;
72630866Smarkm};
7273256Sswallace
728652Sjkhstruct midi_info {
72930866Smarkm	char		name[30];
73030866Smarkm	int		device;		/* 0-N. INITIALIZE BEFORE CALLING */
73130866Smarkm	u_long	capabilities;	/* To be defined later */
73230866Smarkm	int		dev_type;
73330866Smarkm	int		dummies[18];	/* Reserve space */
73430866Smarkm};
735652Sjkh
73633473Sscrappy/*
7373256Sswallace * ioctl commands for the /dev/midi##
7383256Sswallace */
7393256Sswallacetypedef struct {
74030866Smarkm	u_char cmd;
74130866Smarkm	char nr_args, nr_returns;
74230866Smarkm	u_char data[30];
74330866Smarkm} mpu_command_rec;
7443256Sswallace
74533473Sscrappy#define SNDCTL_MIDI_PRETIME	_IOWR('m', 0, int)
74633473Sscrappy#define SNDCTL_MIDI_MPUMODE	_IOWR('m', 1, int)
74733473Sscrappy#define SNDCTL_MIDI_MPUCMD	_IOWR('m', 2, mpu_command_rec)
74862947Stanimura#define MIOSPASSTHRU		_IOWR('m', 3, int)
74962947Stanimura#define MIOGPASSTHRU		_IOWR('m', 4, int)
7503256Sswallace
75133473Sscrappy/*
752652Sjkh * IOCTL commands for /dev/dsp and /dev/audio
753652Sjkh */
754652Sjkh
75533473Sscrappy#define SNDCTL_DSP_RESET	_IO  ('P', 0)
75633473Sscrappy#define SNDCTL_DSP_SYNC		_IO  ('P', 1)
75733473Sscrappy#define SNDCTL_DSP_SPEED	_IOWR('P', 2, int)
75833473Sscrappy#define SNDCTL_DSP_STEREO	_IOWR('P', 3, int)
75933473Sscrappy#define SNDCTL_DSP_GETBLKSIZE	_IOR('P', 4, int)
76033473Sscrappy#define SNDCTL_DSP_SETBLKSIZE   _IOW('P', 4, int)
76133473Sscrappy#define SNDCTL_DSP_SETFMT	_IOWR('P',5, int) /* Selects ONE fmt*/
76233473Sscrappy
76333473Sscrappy/*
76433473Sscrappy * SOUND_PCM_WRITE_CHANNELS is not that different
76533473Sscrappy * from SNDCTL_DSP_STEREO
76633473Sscrappy */
767652Sjkh#define SOUND_PCM_WRITE_CHANNELS	_IOWR('P', 6, int)
76865335Scg#define SNDCTL_DSP_CHANNELS	SOUND_PCM_WRITE_CHANNELS
76933473Sscrappy#define SOUND_PCM_WRITE_FILTER	_IOWR('P', 7, int)
77033473Sscrappy#define SNDCTL_DSP_POST		_IO  ('P', 8)
771652Sjkh
77233473Sscrappy/*
77333473Sscrappy * SNDCTL_DSP_SETBLKSIZE and the following two calls mostly do
77433473Sscrappy * the same thing, i.e. set the block size used in DMA transfers.
77533473Sscrappy */
77633473Sscrappy#define SNDCTL_DSP_SUBDIVIDE	_IOWR('P', 9, int)
77733473Sscrappy#define SNDCTL_DSP_SETFRAGMENT	_IOWR('P',10, int)
77830866Smarkm
7793256Sswallace
78033473Sscrappy#define SNDCTL_DSP_GETFMTS	_IOR ('P',11, int) /* Returns a mask */
7819750Sjkh/*
7829750Sjkh * Buffer status queries.
7839750Sjkh */
7849750Sjkhtypedef struct audio_buf_info {
78533473Sscrappy    int fragments;	/* # of avail. frags (partly used ones not counted) */
78633473Sscrappy    int fragstotal;	/* Total # of fragments allocated */
78733473Sscrappy    int fragsize;	/* Size of a fragment in bytes */
7889750Sjkh
78933473Sscrappy    int bytes;	/* Avail. space in bytes (includes partly used fragments) */
79033473Sscrappy		/* Note! 'bytes' could be more than fragments*fragsize */
79130866Smarkm} audio_buf_info;
7929750Sjkh
79333473Sscrappy#define SNDCTL_DSP_GETOSPACE	_IOR ('P',12, audio_buf_info)
79433473Sscrappy#define SNDCTL_DSP_GETISPACE	_IOR ('P',13, audio_buf_info)
7959750Sjkh
79633473Sscrappy/*
79733473Sscrappy * SNDCTL_DSP_NONBLOCK is the same (but less powerful, since the
79833473Sscrappy * action cannot be undone) of FIONBIO. The same can be achieved
79933473Sscrappy * by opening the device with O_NDELAY
80033473Sscrappy */
80133473Sscrappy#define SNDCTL_DSP_NONBLOCK	_IO  ('P',14)
80230866Smarkm
80333473Sscrappy#define SNDCTL_DSP_GETCAPS	_IOR ('P',15, int)
804187030Smav#	define PCM_CAP_REVISION		0x000000ff	/* Bits for revision level (0 to 255) */
805187030Smav#	define PCM_CAP_DUPLEX		0x00000100	/* Full duplex record/playback */
806187030Smav#	define PCM_CAP_REALTIME		0x00000200	/* Not in use */
807187030Smav#	define PCM_CAP_BATCH		0x00000400	/* Device has some kind of */
808187030Smav							/* internal buffers which may */
809187030Smav							/* cause some delays and */
810187030Smav							/* decrease precision of timing */
811187030Smav#	define PCM_CAP_COPROC		0x00000800	/* Has a coprocessor */
812187030Smav							/* Sometimes it's a DSP */
813187030Smav							/* but usually not */
814187030Smav#	define PCM_CAP_TRIGGER		0x00001000	/* Supports SETTRIGGER */
815187030Smav#	define PCM_CAP_MMAP		0x00002000	/* Supports mmap() */
816187030Smav#	define PCM_CAP_MULTI		0x00004000	/* Supports multiple open */
817187030Smav#	define PCM_CAP_BIND		0x00008000	/* Supports binding to front/rear/center/lfe */
818187030Smav#   	define PCM_CAP_INPUT		0x00010000	/* Supports recording */
819187030Smav#   	define PCM_CAP_OUTPUT		0x00020000	/* Supports playback */
820187030Smav#	define PCM_CAP_VIRTUAL		0x00040000	/* Virtual device */
821187030Smav/* 0x00040000 and 0x00080000 reserved for future use */
82230866Smarkm
823187030Smav/* Analog/digital control capabilities */
824187030Smav#	define PCM_CAP_ANALOGOUT	0x00100000
825187030Smav#	define PCM_CAP_ANALOGIN		0x00200000
826187030Smav#	define PCM_CAP_DIGITALOUT	0x00400000
827187030Smav#	define PCM_CAP_DIGITALIN	0x00800000
828187030Smav#	define PCM_CAP_ADMASK		0x00f00000
82933473Sscrappy/*
830187030Smav * NOTE! (capabilities & PCM_CAP_ADMASK)==0 means just that the
831187030Smav * digital/analog interface control features are not supported by the
832187030Smav * device/driver. However the device still supports analog, digital or
833187030Smav * both inputs/outputs (depending on the device). See the OSS Programmer's
834187030Smav * Guide for full details.
835187030Smav */
836187030Smav#	define PCM_CAP_SPECIAL		0x01000000	/* Not for ordinary "multimedia" use */
837187030Smav#	define PCM_CAP_SHADOW		0x00000000	/* OBSOLETE */
838187030Smav
839187030Smav/*
840187030Smav * Preferred channel usage. These bits can be used to
841187030Smav * give recommendations to the application. Used by few drivers.
842187030Smav * For example if ((caps & DSP_CH_MASK) == DSP_CH_MONO) means that
843187030Smav * the device works best in mono mode. However it doesn't necessarily mean
844187030Smav * that the device cannot be used in stereo. These bits should only be used
845187030Smav * by special applications such as multi track hard disk recorders to find
846187030Smav * out the initial setup. However the user should be able to override this
847187030Smav * selection.
848187030Smav *
849187030Smav * To find out which modes are actually supported the application should
850187030Smav * try to select them using SNDCTL_DSP_CHANNELS.
851187030Smav */
852187030Smav#	define DSP_CH_MASK		0x06000000	/* Mask */
853187030Smav#	define DSP_CH_ANY		0x00000000	/* No preferred mode */
854187030Smav#	define DSP_CH_MONO		0x02000000
855187030Smav#	define DSP_CH_STEREO		0x04000000
856187030Smav#	define DSP_CH_MULTI		0x06000000	/* More than two channels */
857187030Smav
858187030Smav#	define PCM_CAP_HIDDEN		0x08000000	/* Hidden device */
859187030Smav#	define PCM_CAP_FREERATE		0x10000000
860187030Smav#	define PCM_CAP_MODEM		0x20000000	/* Modem device */
861187030Smav#	define PCM_CAP_DEFAULT		0x40000000	/* "Default" device */
862187030Smav
863187030Smav/*
864187030Smav * The PCM_CAP_* capability names were known as DSP_CAP_* prior OSS 4.0
865187030Smav * so it's necessary to define the older names too.
866187030Smav */
867187030Smav#define DSP_CAP_ADMASK		PCM_CAP_ADMASK
868187030Smav#define DSP_CAP_ANALOGIN	PCM_CAP_ANALOGIN
869187030Smav#define DSP_CAP_ANALOGOUT	PCM_CAP_ANALOGOUT
870187030Smav#define DSP_CAP_BATCH		PCM_CAP_BATCH
871187030Smav#define DSP_CAP_BIND		PCM_CAP_BIND
872187030Smav#define DSP_CAP_COPROC		PCM_CAP_COPROC
873187030Smav#define DSP_CAP_DEFAULT		PCM_CAP_DEFAULT
874187030Smav#define DSP_CAP_DIGITALIN	PCM_CAP_DIGITALIN
875187030Smav#define DSP_CAP_DIGITALOUT	PCM_CAP_DIGITALOUT
876187030Smav#define DSP_CAP_DUPLEX		PCM_CAP_DUPLEX
877187030Smav#define DSP_CAP_FREERATE	PCM_CAP_FREERATE
878187030Smav#define DSP_CAP_HIDDEN		PCM_CAP_HIDDEN
879187030Smav#define DSP_CAP_INPUT		PCM_CAP_INPUT
880187030Smav#define DSP_CAP_MMAP		PCM_CAP_MMAP
881187030Smav#define DSP_CAP_MODEM		PCM_CAP_MODEM
882187030Smav#define DSP_CAP_MULTI		PCM_CAP_MULTI
883187030Smav#define DSP_CAP_OUTPUT		PCM_CAP_OUTPUT
884187030Smav#define DSP_CAP_REALTIME	PCM_CAP_REALTIME
885187030Smav#define DSP_CAP_REVISION	PCM_CAP_REVISION
886187030Smav#define DSP_CAP_SHADOW		PCM_CAP_SHADOW
887187030Smav#define DSP_CAP_TRIGGER		PCM_CAP_TRIGGER
888187030Smav#define DSP_CAP_VIRTUAL		PCM_CAP_VIRTUAL
889187030Smav
890187030Smav/*
89133473Sscrappy * What do these function do ?
89233473Sscrappy */
89333473Sscrappy#define SNDCTL_DSP_GETTRIGGER	_IOR ('P',16, int)
89433473Sscrappy#define SNDCTL_DSP_SETTRIGGER	_IOW ('P',16, int)
89533473Sscrappy#define PCM_ENABLE_INPUT	0x00000001
89630866Smarkm#define PCM_ENABLE_OUTPUT	0x00000002
89730866Smarkm
89830866Smarkmtypedef struct count_info {
89930866Smarkm	int bytes;	/* Total # of bytes processed */
90030866Smarkm	int blocks;	/* # of fragment transitions since last time */
90130866Smarkm	int ptr;	/* Current DMA pointer value */
90230866Smarkm} count_info;
90330866Smarkm
90433473Sscrappy/*
90533473Sscrappy * GETIPTR and GETISPACE are not that different... same for out.
90633473Sscrappy */
90733473Sscrappy#define SNDCTL_DSP_GETIPTR	_IOR ('P',17, count_info)
90833473Sscrappy#define SNDCTL_DSP_GETOPTR	_IOR ('P',18, count_info)
90930866Smarkm
91030866Smarkmtypedef struct buffmem_desc {
91130866Smarkm	caddr_t buffer;
91230866Smarkm	int size;
91330866Smarkm} buffmem_desc;
91430866Smarkm
91533473Sscrappy#define SNDCTL_DSP_MAPINBUF	_IOR ('P', 19, buffmem_desc)
91633473Sscrappy#define SNDCTL_DSP_MAPOUTBUF	_IOR ('P', 20, buffmem_desc)
91733473Sscrappy#define SNDCTL_DSP_SETSYNCRO	_IO  ('P', 21)
91865335Scg#define SNDCTL_DSP_SETDUPLEX	_IO  ('P', 22)
91953901Salfred#define SNDCTL_DSP_GETODELAY	_IOR ('P', 23, int)
92030866Smarkm
92133473Sscrappy/*
92233473Sscrappy * I guess these are the readonly version of the same
92333473Sscrappy * functions that exist above as SNDCTL_DSP_...
92433473Sscrappy */
92533473Sscrappy#define SOUND_PCM_READ_RATE	_IOR ('P', 2, int)
92633473Sscrappy#define SOUND_PCM_READ_CHANNELS	_IOR ('P', 6, int)
92733473Sscrappy#define SOUND_PCM_READ_BITS	_IOR ('P', 5, int)
92833473Sscrappy#define SOUND_PCM_READ_FILTER	_IOR ('P', 7, int)
929652Sjkh
9309750Sjkh/*
9319750Sjkh * ioctl calls to be used in communication with coprocessors and
9329750Sjkh * DSP chips.
9333256Sswallace */
9343256Sswallace
9359750Sjkhtypedef struct copr_buffer {
93630866Smarkm	int command;	/* Set to 0 if not used */
93730866Smarkm	int flags;
9389750Sjkh#define CPF_NONE		0x0000
9399750Sjkh#define CPF_FIRST		0x0001	/* First block */
9409750Sjkh#define CPF_LAST		0x0002	/* Last block */
94130866Smarkm	int len;
94230866Smarkm	int offs;	/* If required by the device (0 if not used) */
9433256Sswallace
94430866Smarkm	u_char data[4000]; /* NOTE! 4000 is not 4k */
94530866Smarkm} copr_buffer;
9469750Sjkh
9479750Sjkhtypedef struct copr_debug_buf {
94830866Smarkm	int command;	/* Used internally. Set to 0 */
94930866Smarkm	int parm1;
95030866Smarkm	int parm2;
95165335Scg	int flags;
95230866Smarkm	int len;	/* Length of data in bytes */
95330866Smarkm} copr_debug_buf;
9549750Sjkh
9559750Sjkhtypedef struct copr_msg {
95630866Smarkm	int len;
95730866Smarkm	u_char data[4000];
95830866Smarkm} copr_msg;
9599750Sjkh
96033473Sscrappy#define SNDCTL_COPR_RESET       _IO  ('C',  0)
96133473Sscrappy#define SNDCTL_COPR_LOAD	_IOWR('C',  1, copr_buffer)
96233473Sscrappy#define SNDCTL_COPR_RDATA	_IOWR('C',  2, copr_debug_buf)
96333473Sscrappy#define SNDCTL_COPR_RCODE	_IOWR('C',  3, copr_debug_buf)
96433473Sscrappy#define SNDCTL_COPR_WDATA	_IOW ('C',  4, copr_debug_buf)
96533473Sscrappy#define SNDCTL_COPR_WCODE	_IOW ('C',  5, copr_debug_buf)
96633473Sscrappy#define SNDCTL_COPR_RUN		_IOWR('C',  6, copr_debug_buf)
96733473Sscrappy#define SNDCTL_COPR_HALT	_IOWR('C',  7, copr_debug_buf)
96833473Sscrappy#define SNDCTL_COPR_SENDMSG	_IOW ('C',  8, copr_msg)
96933473Sscrappy#define SNDCTL_COPR_RCVMSG	_IOR ('C',  9, copr_msg)
9709750Sjkh
97133473Sscrappy/*
972652Sjkh * IOCTL commands for /dev/mixer
973652Sjkh */
97465335Scg
97565335Scg/*
976652Sjkh * Mixer devices
977652Sjkh *
978652Sjkh * There can be up to 20 different analog mixer channels. The
97965335Scg * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
980652Sjkh * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
981652Sjkh * the devices supported by the particular mixer.
982652Sjkh */
983652Sjkh
98433473Sscrappy#define SOUND_MIXER_NRDEVICES	25
98581891Ssobomax#define SOUND_MIXER_VOLUME	0	/* Master output level */
98681891Ssobomax#define SOUND_MIXER_BASS	1	/* Treble level of all output channels */
98781891Ssobomax#define SOUND_MIXER_TREBLE	2	/* Bass level of all output channels */
98881891Ssobomax#define SOUND_MIXER_SYNTH	3	/* Volume of synthesier input */
98981891Ssobomax#define SOUND_MIXER_PCM		4	/* Output level for the audio device */
99081891Ssobomax#define SOUND_MIXER_SPEAKER	5	/* Output level for the PC speaker
99181891Ssobomax					 * signals */
99281891Ssobomax#define SOUND_MIXER_LINE	6	/* Volume level for the line in jack */
99381891Ssobomax#define SOUND_MIXER_MIC		7	/* Volume for the signal coming from
99481891Ssobomax					 * the microphone jack */
99581891Ssobomax#define SOUND_MIXER_CD		8	/* Volume level for the input signal
99681891Ssobomax					 * connected to the CD audio input */
99781891Ssobomax#define SOUND_MIXER_IMIX	9	/* Recording monitor. It controls the
99881891Ssobomax					 * output volume of the selected
99981891Ssobomax					 * recording sources while recording */
100081891Ssobomax#define SOUND_MIXER_ALTPCM	10	/* Volume of the alternative codec
100181891Ssobomax					 * device */
100281891Ssobomax#define SOUND_MIXER_RECLEV	11	/* Global recording level */
10039750Sjkh#define SOUND_MIXER_IGAIN	12	/* Input gain */
10049750Sjkh#define SOUND_MIXER_OGAIN	13	/* Output gain */
100565335Scg/*
10069750Sjkh * The AD1848 codec and compatibles have three line level inputs
10079750Sjkh * (line, aux1 and aux2). Since each card manufacturer have assigned
100830866Smarkm * different meanings to these inputs, it's inpractical to assign
10099750Sjkh * specific meanings (line, cd, synth etc.) to them.
10109750Sjkh */
10119750Sjkh#define SOUND_MIXER_LINE1	14	/* Input source 1  (aux1) */
10129750Sjkh#define SOUND_MIXER_LINE2	15	/* Input source 2  (aux2) */
10139750Sjkh#define SOUND_MIXER_LINE3	16	/* Input source 3  (line) */
101433473Sscrappy#define SOUND_MIXER_DIGITAL1    17      /* Digital (input) 1 */
101533473Sscrappy#define SOUND_MIXER_DIGITAL2    18      /* Digital (input) 2 */
101633473Sscrappy#define SOUND_MIXER_DIGITAL3    19      /* Digital (input) 3 */
101733473Sscrappy#define SOUND_MIXER_PHONEIN     20      /* Phone input */
101833473Sscrappy#define SOUND_MIXER_PHONEOUT    21      /* Phone output */
101933473Sscrappy#define SOUND_MIXER_VIDEO       22      /* Video/TV (audio) in */
102033473Sscrappy#define SOUND_MIXER_RADIO       23      /* Radio in */
102133473Sscrappy#define SOUND_MIXER_MONITOR     24      /* Monitor (usually mic) volume */
1022652Sjkh
102333473Sscrappy
102433473Sscrappy/*
102533473Sscrappy * Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX)
102633473Sscrappy * Not counted to SOUND_MIXER_NRDEVICES, but use the same number space
102733473Sscrappy */
1028652Sjkh#define SOUND_ONOFF_MIN		28
1029652Sjkh#define SOUND_ONOFF_MAX		30
1030652Sjkh#define SOUND_MIXER_MUTE	28	/* 0 or 1 */
1031652Sjkh#define SOUND_MIXER_ENHANCE	29	/* Enhanced stereo (0, 40, 60 or 80) */
1032652Sjkh#define SOUND_MIXER_LOUD	30	/* 0 or 1 */
1033652Sjkh
1034652Sjkh/* Note!	Number 31 cannot be used since the sign bit is reserved */
103533473Sscrappy#define SOUND_MIXER_NONE        31
1036652Sjkh
103730866Smarkm#define SOUND_DEVICE_LABELS	{ \
103830866Smarkm	"Vol  ", "Bass ", "Trebl", "Synth", "Pcm  ", "Spkr ", "Line ", \
103933473Sscrappy	"Mic  ", "CD   ", "Mix  ", "Pcm2 ", "Rec  ", "IGain", "OGain", \
104033473Sscrappy	"Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
104133473Sscrappy	"PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
1042652Sjkh
104330866Smarkm#define SOUND_DEVICE_NAMES	{ \
104430866Smarkm	"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
104530866Smarkm	"mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
104633473Sscrappy	"line1", "line2", "line3", "dig1", "dig2", "dig3", \
104733473Sscrappy	"phin", "phout", "video", "radio", "monitor"}
1048652Sjkh
1049652Sjkh/*	Device bitmask identifiers	*/
1050652Sjkh
105130866Smarkm#define SOUND_MIXER_RECSRC	0xff	/* 1 bit per recording source */
105230866Smarkm#define SOUND_MIXER_DEVMASK	0xfe	/* 1 bit per supported device */
105330866Smarkm#define SOUND_MIXER_RECMASK	0xfd	/* 1 bit per supp. recording source */
1054652Sjkh#define SOUND_MIXER_CAPS	0xfc
105530866Smarkm#define SOUND_CAP_EXCL_INPUT	0x00000001	/* Only 1 rec. src at a time */
1056652Sjkh#define SOUND_MIXER_STEREODEVS	0xfb	/* Mixer channels supporting stereo */
1057652Sjkh
1058652Sjkh/*	Device mask bits	*/
1059652Sjkh
1060652Sjkh#define SOUND_MASK_VOLUME	(1 << SOUND_MIXER_VOLUME)
1061652Sjkh#define SOUND_MASK_BASS		(1 << SOUND_MIXER_BASS)
1062652Sjkh#define SOUND_MASK_TREBLE	(1 << SOUND_MIXER_TREBLE)
1063652Sjkh#define SOUND_MASK_SYNTH	(1 << SOUND_MIXER_SYNTH)
1064652Sjkh#define SOUND_MASK_PCM		(1 << SOUND_MIXER_PCM)
1065652Sjkh#define SOUND_MASK_SPEAKER	(1 << SOUND_MIXER_SPEAKER)
1066652Sjkh#define SOUND_MASK_LINE		(1 << SOUND_MIXER_LINE)
1067652Sjkh#define SOUND_MASK_MIC		(1 << SOUND_MIXER_MIC)
1068652Sjkh#define SOUND_MASK_CD		(1 << SOUND_MIXER_CD)
1069652Sjkh#define SOUND_MASK_IMIX		(1 << SOUND_MIXER_IMIX)
1070652Sjkh#define SOUND_MASK_ALTPCM	(1 << SOUND_MIXER_ALTPCM)
1071652Sjkh#define SOUND_MASK_RECLEV	(1 << SOUND_MIXER_RECLEV)
10729750Sjkh#define SOUND_MASK_IGAIN	(1 << SOUND_MIXER_IGAIN)
10739750Sjkh#define SOUND_MASK_OGAIN	(1 << SOUND_MIXER_OGAIN)
10749750Sjkh#define SOUND_MASK_LINE1	(1 << SOUND_MIXER_LINE1)
10759750Sjkh#define SOUND_MASK_LINE2	(1 << SOUND_MIXER_LINE2)
10769750Sjkh#define SOUND_MASK_LINE3	(1 << SOUND_MIXER_LINE3)
107733473Sscrappy#define SOUND_MASK_DIGITAL1     (1 << SOUND_MIXER_DIGITAL1)
107833473Sscrappy#define SOUND_MASK_DIGITAL2     (1 << SOUND_MIXER_DIGITAL2)
107933473Sscrappy#define SOUND_MASK_DIGITAL3     (1 << SOUND_MIXER_DIGITAL3)
108033473Sscrappy#define SOUND_MASK_PHONEIN      (1 << SOUND_MIXER_PHONEIN)
108133473Sscrappy#define SOUND_MASK_PHONEOUT     (1 << SOUND_MIXER_PHONEOUT)
108233473Sscrappy#define SOUND_MASK_RADIO        (1 << SOUND_MIXER_RADIO)
108333473Sscrappy#define SOUND_MASK_VIDEO        (1 << SOUND_MIXER_VIDEO)
108433473Sscrappy#define SOUND_MASK_MONITOR      (1 << SOUND_MIXER_MONITOR)
1085652Sjkh
108633473Sscrappy/* Obsolete macros */
1087652Sjkh#define SOUND_MASK_MUTE		(1 << SOUND_MIXER_MUTE)
1088652Sjkh#define SOUND_MASK_ENHANCE	(1 << SOUND_MIXER_ENHANCE)
1089652Sjkh#define SOUND_MASK_LOUD		(1 << SOUND_MIXER_LOUD)
1090652Sjkh
1091652Sjkh#define MIXER_READ(dev)		_IOR('M', dev, int)
1092652Sjkh#define SOUND_MIXER_READ_VOLUME		MIXER_READ(SOUND_MIXER_VOLUME)
1093652Sjkh#define SOUND_MIXER_READ_BASS		MIXER_READ(SOUND_MIXER_BASS)
1094652Sjkh#define SOUND_MIXER_READ_TREBLE		MIXER_READ(SOUND_MIXER_TREBLE)
1095652Sjkh#define SOUND_MIXER_READ_SYNTH		MIXER_READ(SOUND_MIXER_SYNTH)
1096652Sjkh#define SOUND_MIXER_READ_PCM		MIXER_READ(SOUND_MIXER_PCM)
1097652Sjkh#define SOUND_MIXER_READ_SPEAKER	MIXER_READ(SOUND_MIXER_SPEAKER)
1098652Sjkh#define SOUND_MIXER_READ_LINE		MIXER_READ(SOUND_MIXER_LINE)
1099652Sjkh#define SOUND_MIXER_READ_MIC		MIXER_READ(SOUND_MIXER_MIC)
1100652Sjkh#define SOUND_MIXER_READ_CD		MIXER_READ(SOUND_MIXER_CD)
1101652Sjkh#define SOUND_MIXER_READ_IMIX		MIXER_READ(SOUND_MIXER_IMIX)
1102652Sjkh#define SOUND_MIXER_READ_ALTPCM		MIXER_READ(SOUND_MIXER_ALTPCM)
1103652Sjkh#define SOUND_MIXER_READ_RECLEV		MIXER_READ(SOUND_MIXER_RECLEV)
11049750Sjkh#define SOUND_MIXER_READ_IGAIN		MIXER_READ(SOUND_MIXER_IGAIN)
11059750Sjkh#define SOUND_MIXER_READ_OGAIN		MIXER_READ(SOUND_MIXER_OGAIN)
11069750Sjkh#define SOUND_MIXER_READ_LINE1		MIXER_READ(SOUND_MIXER_LINE1)
11079750Sjkh#define SOUND_MIXER_READ_LINE2		MIXER_READ(SOUND_MIXER_LINE2)
11089750Sjkh#define SOUND_MIXER_READ_LINE3		MIXER_READ(SOUND_MIXER_LINE3)
1109118923Scg#define SOUND_MIXER_READ_DIGITAL1	MIXER_READ(SOUND_MIXER_DIGITAL1)
1110118923Scg#define SOUND_MIXER_READ_DIGITAL2	MIXER_READ(SOUND_MIXER_DIGITAL2)
1111118923Scg#define SOUND_MIXER_READ_DIGITAL3	MIXER_READ(SOUND_MIXER_DIGITAL3)
1112118923Scg#define SOUND_MIXER_READ_PHONEIN      	MIXER_READ(SOUND_MIXER_PHONEIN)
1113118923Scg#define SOUND_MIXER_READ_PHONEOUT	MIXER_READ(SOUND_MIXER_PHONEOUT)
1114118923Scg#define SOUND_MIXER_READ_RADIO		MIXER_READ(SOUND_MIXER_RADIO)
1115118923Scg#define SOUND_MIXER_READ_VIDEO		MIXER_READ(SOUND_MIXER_VIDEO)
1116118923Scg#define SOUND_MIXER_READ_MONITOR	MIXER_READ(SOUND_MIXER_MONITOR)
111733473Sscrappy
111833473Sscrappy/* Obsolete macros */
1119652Sjkh#define SOUND_MIXER_READ_MUTE		MIXER_READ(SOUND_MIXER_MUTE)
1120652Sjkh#define SOUND_MIXER_READ_ENHANCE	MIXER_READ(SOUND_MIXER_ENHANCE)
1121652Sjkh#define SOUND_MIXER_READ_LOUD		MIXER_READ(SOUND_MIXER_LOUD)
1122652Sjkh
1123652Sjkh#define SOUND_MIXER_READ_RECSRC		MIXER_READ(SOUND_MIXER_RECSRC)
1124652Sjkh#define SOUND_MIXER_READ_DEVMASK	MIXER_READ(SOUND_MIXER_DEVMASK)
1125652Sjkh#define SOUND_MIXER_READ_RECMASK	MIXER_READ(SOUND_MIXER_RECMASK)
1126652Sjkh#define SOUND_MIXER_READ_STEREODEVS	MIXER_READ(SOUND_MIXER_STEREODEVS)
1127652Sjkh#define SOUND_MIXER_READ_CAPS		MIXER_READ(SOUND_MIXER_CAPS)
1128652Sjkh
1129652Sjkh#define MIXER_WRITE(dev)		_IOWR('M', dev, int)
1130652Sjkh#define SOUND_MIXER_WRITE_VOLUME	MIXER_WRITE(SOUND_MIXER_VOLUME)
1131652Sjkh#define SOUND_MIXER_WRITE_BASS		MIXER_WRITE(SOUND_MIXER_BASS)
1132652Sjkh#define SOUND_MIXER_WRITE_TREBLE	MIXER_WRITE(SOUND_MIXER_TREBLE)
1133652Sjkh#define SOUND_MIXER_WRITE_SYNTH		MIXER_WRITE(SOUND_MIXER_SYNTH)
1134652Sjkh#define SOUND_MIXER_WRITE_PCM		MIXER_WRITE(SOUND_MIXER_PCM)
1135652Sjkh#define SOUND_MIXER_WRITE_SPEAKER	MIXER_WRITE(SOUND_MIXER_SPEAKER)
1136652Sjkh#define SOUND_MIXER_WRITE_LINE		MIXER_WRITE(SOUND_MIXER_LINE)
1137652Sjkh#define SOUND_MIXER_WRITE_MIC		MIXER_WRITE(SOUND_MIXER_MIC)
1138652Sjkh#define SOUND_MIXER_WRITE_CD		MIXER_WRITE(SOUND_MIXER_CD)
1139652Sjkh#define SOUND_MIXER_WRITE_IMIX		MIXER_WRITE(SOUND_MIXER_IMIX)
1140652Sjkh#define SOUND_MIXER_WRITE_ALTPCM	MIXER_WRITE(SOUND_MIXER_ALTPCM)
1141652Sjkh#define SOUND_MIXER_WRITE_RECLEV	MIXER_WRITE(SOUND_MIXER_RECLEV)
11429750Sjkh#define SOUND_MIXER_WRITE_IGAIN		MIXER_WRITE(SOUND_MIXER_IGAIN)
11439750Sjkh#define SOUND_MIXER_WRITE_OGAIN		MIXER_WRITE(SOUND_MIXER_OGAIN)
11449750Sjkh#define SOUND_MIXER_WRITE_LINE1		MIXER_WRITE(SOUND_MIXER_LINE1)
11459750Sjkh#define SOUND_MIXER_WRITE_LINE2		MIXER_WRITE(SOUND_MIXER_LINE2)
11469750Sjkh#define SOUND_MIXER_WRITE_LINE3		MIXER_WRITE(SOUND_MIXER_LINE3)
1147118923Scg#define SOUND_MIXER_WRITE_DIGITAL1	MIXER_WRITE(SOUND_MIXER_DIGITAL1)
1148118923Scg#define SOUND_MIXER_WRITE_DIGITAL2	MIXER_WRITE(SOUND_MIXER_DIGITAL2)
1149118923Scg#define SOUND_MIXER_WRITE_DIGITAL3	MIXER_WRITE(SOUND_MIXER_DIGITAL3)
1150118923Scg#define SOUND_MIXER_WRITE_PHONEIN      	MIXER_WRITE(SOUND_MIXER_PHONEIN)
1151118923Scg#define SOUND_MIXER_WRITE_PHONEOUT	MIXER_WRITE(SOUND_MIXER_PHONEOUT)
1152118923Scg#define SOUND_MIXER_WRITE_RADIO		MIXER_WRITE(SOUND_MIXER_RADIO)
1153118923Scg#define SOUND_MIXER_WRITE_VIDEO		MIXER_WRITE(SOUND_MIXER_VIDEO)
1154118923Scg#define SOUND_MIXER_WRITE_MONITOR	MIXER_WRITE(SOUND_MIXER_MONITOR)
1155118923Scg
1156652Sjkh#define SOUND_MIXER_WRITE_MUTE		MIXER_WRITE(SOUND_MIXER_MUTE)
1157652Sjkh#define SOUND_MIXER_WRITE_ENHANCE	MIXER_WRITE(SOUND_MIXER_ENHANCE)
1158652Sjkh#define SOUND_MIXER_WRITE_LOUD		MIXER_WRITE(SOUND_MIXER_LOUD)
1159652Sjkh
1160652Sjkh#define SOUND_MIXER_WRITE_RECSRC	MIXER_WRITE(SOUND_MIXER_RECSRC)
1161652Sjkh
1162118923Scgtypedef struct mixer_info {
1163118923Scg  char id[16];
1164118923Scg  char name[32];
1165118923Scg  int  modify_counter;
1166118923Scg  int fillers[10];
1167118923Scg} mixer_info;
1168118923Scg
1169118923Scg#define SOUND_MIXER_INFO		_IOR('M', 101, mixer_info)
1170118923Scg
117133473Sscrappy#define LEFT_CHN	0
117233473Sscrappy#define RIGHT_CHN	1
117333473Sscrappy
1174652Sjkh/*
11753256Sswallace * Level 2 event types for /dev/sequencer
11763256Sswallace */
11773256Sswallace
11783256Sswallace/*
11793256Sswallace * The 4 most significant bits of byte 0 specify the class of
118065335Scg * the event:
1181652Sjkh *
11823256Sswallace *	0x8X = system level events,
11833256Sswallace *	0x9X = device/port specific events, event[1] = device/port,
11843256Sswallace *		The last 4 bits give the subtype:
11853256Sswallace *			0x02	= Channel event (event[3] = chn).
11863256Sswallace *			0x01	= note event (event[4] = note).
11873256Sswallace *			(0x01 is not used alone but always with bit 0x02).
11883256Sswallace *	       event[2] = MIDI message code (0x80=note off etc.)
11893256Sswallace *
1190652Sjkh */
1191652Sjkh
11923256Sswallace#define EV_SEQ_LOCAL		0x80
11933256Sswallace#define EV_TIMING		0x81
11943256Sswallace#define EV_CHN_COMMON		0x92
11953256Sswallace#define EV_CHN_VOICE		0x93
119630866Smarkm#define EV_SYSEX		0x94
11973256Sswallace/*
11983256Sswallace * Event types 200 to 220 are reserved for application use.
11993256Sswallace * These numbers will not be used by the driver.
12003256Sswallace */
1201652Sjkh
1202652Sjkh/*
12033256Sswallace * Events for event type EV_CHN_VOICE
1204652Sjkh */
1205652Sjkh
12063256Sswallace#define MIDI_NOTEOFF		0x80
12073256Sswallace#define MIDI_NOTEON		0x90
12083256Sswallace#define MIDI_KEY_PRESSURE	0xA0
12093256Sswallace
1210652Sjkh/*
12113256Sswallace * Events for event type EV_CHN_COMMON
1212652Sjkh */
1213652Sjkh
12143256Sswallace#define MIDI_CTL_CHANGE		0xB0
12153256Sswallace#define MIDI_PGM_CHANGE		0xC0
12163256Sswallace#define MIDI_CHN_PRESSURE	0xD0
12173256Sswallace#define MIDI_PITCH_BEND		0xE0
1218652Sjkh
12193256Sswallace#define MIDI_SYSTEM_PREFIX	0xF0
12203256Sswallace
1221652Sjkh/*
12223256Sswallace * Timer event types
12233256Sswallace */
12243256Sswallace#define TMR_WAIT_REL		1	/* Time relative to the prev time */
12253256Sswallace#define TMR_WAIT_ABS		2	/* Absolute time since TMR_START */
12263256Sswallace#define TMR_STOP		3
12273256Sswallace#define TMR_START		4
12283256Sswallace#define TMR_CONTINUE		5
12293256Sswallace#define TMR_TEMPO		6
12303256Sswallace#define TMR_ECHO		8
12313256Sswallace#define TMR_CLOCK		9	/* MIDI clock */
12323256Sswallace#define TMR_SPP			10	/* Song position pointer */
12333256Sswallace#define TMR_TIMESIG		11	/* Time signature */
12343256Sswallace
123530866Smarkm/*
123630866Smarkm *	Local event types
123730866Smarkm */
123830866Smarkm#define LOCL_STARTAUDIO		1
123930866Smarkm
124065335Scg#if (!defined(_KERNEL) && !defined(INKERNEL)) || defined(USE_SEQ_MACROS)
12413256Sswallace/*
1242652Sjkh *	Some convenience macros to simplify programming of the
1243652Sjkh *	/dev/sequencer interface
1244652Sjkh *
1245652Sjkh *	These macros define the API which should be used when possible.
1246652Sjkh */
1247652Sjkh
12483256Sswallace#ifndef USE_SIMPLE_MACROS
124992719Salfredvoid seqbuf_dump(void);	/* This function must be provided by programs */
1250652Sjkh
1251652Sjkh/* Sample seqbuf_dump() implementation:
1252652Sjkh *
1253652Sjkh *	SEQ_DEFINEBUF (2048);	-- Defines a buffer for 2048 bytes
1254652Sjkh *
1255652Sjkh *	int seqfd;		-- The file descriptor for /dev/sequencer.
1256652Sjkh *
1257652Sjkh *	void
1258652Sjkh *	seqbuf_dump ()
1259652Sjkh *	{
1260652Sjkh *	  if (_seqbufptr)
1261652Sjkh *	    if (write (seqfd, _seqbuf, _seqbufptr) == -1)
1262652Sjkh *	      {
1263652Sjkh *		perror ("write /dev/sequencer");
1264652Sjkh *		exit (-1);
1265652Sjkh *	      }
1266652Sjkh *	  _seqbufptr = 0;
1267652Sjkh *	}
1268652Sjkh */
1269652Sjkh
127030866Smarkm#define SEQ_DEFINEBUF(len)		\
127130866Smarkm	u_char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0
127230866Smarkm#define SEQ_USE_EXTBUF()		\
127330866Smarkm	extern u_char _seqbuf[]; \
127430866Smarkm	extern int _seqbuflen;extern int _seqbufptr
12753256Sswallace#define SEQ_DECLAREBUF()		SEQ_USE_EXTBUF()
1276652Sjkh#define SEQ_PM_DEFINES			struct patmgr_info _pm_info
127730866Smarkm#define _SEQ_NEEDBUF(len)		\
127830866Smarkm	if ((_seqbufptr+(len)) > _seqbuflen) \
127930866Smarkm		seqbuf_dump()
1280652Sjkh#define _SEQ_ADVBUF(len)		_seqbufptr += len
1281652Sjkh#define SEQ_DUMPBUF			seqbuf_dump
12823256Sswallace#else
12833256Sswallace/*
12843256Sswallace * This variation of the sequencer macros is used just to format one event
12853256Sswallace * using fixed buffer.
128665335Scg *
12873256Sswallace * The program using the macro library must define the following macros before
12883256Sswallace * using this library.
12893256Sswallace *
129065335Scg * #define _seqbuf 		 name of the buffer (u_char[])
12913256Sswallace * #define _SEQ_ADVBUF(len)	 If the applic needs to know the exact
12923256Sswallace *				 size of the event, this macro can be used.
12933256Sswallace *				 Otherwise this must be defined as empty.
12943256Sswallace * #define _seqbufptr		 Define the name of index variable or 0 if
129565335Scg *				 not required.
12963256Sswallace */
12973256Sswallace#define _SEQ_NEEDBUF(len)	/* empty */
12983256Sswallace#endif
12993256Sswallace
130030866Smarkm#define PM_LOAD_PATCH(dev, bank, pgm)	\
130130866Smarkm	(SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \
130230866Smarkm	_pm_info.device=dev, _pm_info.data.data8[0]=pgm, \
130330866Smarkm	_pm_info.parm1 = bank, _pm_info.parm2 = 1, \
130430866Smarkm	ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info))
130530866Smarkm#define PM_LOAD_PATCHES(dev, bank, pgm) \
130630866Smarkm	(SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \
130730866Smarkm	_pm_info.device=dev, bcopy( pgm, _pm_info.data.data8,  128), \
130830866Smarkm	_pm_info.parm1 = bank, _pm_info.parm2 = 128, \
130930866Smarkm	ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info))
1310652Sjkh
131130866Smarkm#define SEQ_VOLUME_MODE(dev, mode)	{ \
131230866Smarkm	_SEQ_NEEDBUF(8);\
131330866Smarkm	_seqbuf[_seqbufptr] = SEQ_EXTENDED;\
131430866Smarkm	_seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\
131530866Smarkm	_seqbuf[_seqbufptr+2] = (dev);\
131630866Smarkm	_seqbuf[_seqbufptr+3] = (mode);\
131730866Smarkm	_seqbuf[_seqbufptr+4] = 0;\
131830866Smarkm	_seqbuf[_seqbufptr+5] = 0;\
131930866Smarkm	_seqbuf[_seqbufptr+6] = 0;\
132030866Smarkm	_seqbuf[_seqbufptr+7] = 0;\
132130866Smarkm	_SEQ_ADVBUF(8);}
13221402Sache
13233256Sswallace/*
13243256Sswallace * Midi voice messages
13253256Sswallace */
1326652Sjkh
132730866Smarkm#define _CHN_VOICE(dev, event, chn, note, parm)  { \
132830866Smarkm	_SEQ_NEEDBUF(8);\
132930866Smarkm	_seqbuf[_seqbufptr] = EV_CHN_VOICE;\
133030866Smarkm	_seqbuf[_seqbufptr+1] = (dev);\
133130866Smarkm	_seqbuf[_seqbufptr+2] = (event);\
133230866Smarkm	_seqbuf[_seqbufptr+3] = (chn);\
133330866Smarkm	_seqbuf[_seqbufptr+4] = (note);\
133430866Smarkm	_seqbuf[_seqbufptr+5] = (parm);\
133530866Smarkm	_seqbuf[_seqbufptr+6] = (0);\
133630866Smarkm	_seqbuf[_seqbufptr+7] = 0;\
133730866Smarkm	_SEQ_ADVBUF(8);}
1338652Sjkh
13393256Sswallace#define SEQ_START_NOTE(dev, chn, note, vol) \
13403256Sswallace		_CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol)
13413256Sswallace
13423256Sswallace#define SEQ_STOP_NOTE(dev, chn, note, vol) \
13433256Sswallace		_CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol)
13443256Sswallace
13453256Sswallace#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \
13463256Sswallace		_CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure)
13473256Sswallace
13483256Sswallace/*
13493256Sswallace * Midi channel messages
13503256Sswallace */
13513256Sswallace
135230866Smarkm#define _CHN_COMMON(dev, event, chn, p1, p2, w14) { \
135330866Smarkm	_SEQ_NEEDBUF(8);\
135430866Smarkm	_seqbuf[_seqbufptr] = EV_CHN_COMMON;\
135530866Smarkm	_seqbuf[_seqbufptr+1] = (dev);\
135630866Smarkm	_seqbuf[_seqbufptr+2] = (event);\
135730866Smarkm	_seqbuf[_seqbufptr+3] = (chn);\
135830866Smarkm	_seqbuf[_seqbufptr+4] = (p1);\
135930866Smarkm	_seqbuf[_seqbufptr+5] = (p2);\
136030866Smarkm	*(short *)&_seqbuf[_seqbufptr+6] = (w14);\
136130866Smarkm	_SEQ_ADVBUF(8);}
136230866Smarkm/*
136330866Smarkm * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits
136430866Smarkm * sending any MIDI bytes but it's absolutely not possible. Trying to do
136530866Smarkm * so _will_ cause problems with MPU401 intelligent mode).
136630866Smarkm *
136765335Scg * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
136830866Smarkm * sent by calling SEQ_SYSEX() several times (there must be no other events
136930866Smarkm * between them). First sysex fragment must have 0xf0 in the first byte
137030866Smarkm * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte
137130866Smarkm * between these sysex start and end markers cannot be larger than 0x7f. Also
137230866Smarkm * lengths of each fragments (except the last one) must be 6.
137330866Smarkm *
137430866Smarkm * Breaking the above rules may work with some MIDI ports but is likely to
137530866Smarkm * cause fatal problems with some other devices (such as MPU401).
137630866Smarkm */
137730866Smarkm#define SEQ_SYSEX(dev, buf, len) { \
137830866Smarkm	int i, l=(len); if (l>6)l=6;\
137930866Smarkm	_SEQ_NEEDBUF(8);\
138030866Smarkm	_seqbuf[_seqbufptr] = EV_SYSEX;\
138130866Smarkm	for(i=0;i<l;i++)_seqbuf[_seqbufptr+i+1] = (buf)[i];\
138230866Smarkm	for(i=l;i<6;i++)_seqbuf[_seqbufptr+i+1] = 0xff;\
138330866Smarkm	_SEQ_ADVBUF(8);}
1384652Sjkh
13853256Sswallace#define SEQ_CHN_PRESSURE(dev, chn, pressure) \
138630866Smarkm	_CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0)
13873256Sswallace
13883256Sswallace#define SEQ_SET_PATCH(dev, chn, patch) \
138930866Smarkm	_CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0)
13903256Sswallace
13913256Sswallace#define SEQ_CONTROL(dev, chn, controller, value) \
139230866Smarkm	_CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value)
13933256Sswallace
13943256Sswallace#define SEQ_BENDER(dev, chn, value) \
139530866Smarkm	_CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value)
13963256Sswallace
13979750Sjkh
139830866Smarkm#define SEQ_V2_X_CONTROL(dev, voice, controller, value)	{ \
139930866Smarkm	_SEQ_NEEDBUF(8);\
140030866Smarkm	_seqbuf[_seqbufptr] = SEQ_EXTENDED;\
140130866Smarkm	_seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\
140230866Smarkm	_seqbuf[_seqbufptr+2] = (dev);\
140330866Smarkm	_seqbuf[_seqbufptr+3] = (voice);\
140430866Smarkm	_seqbuf[_seqbufptr+4] = (controller);\
140530866Smarkm	*(short *)&_seqbuf[_seqbufptr+5] = (value);\
140630866Smarkm	_seqbuf[_seqbufptr+7] = 0;\
140730866Smarkm	_SEQ_ADVBUF(8);}
140830866Smarkm
14093256Sswallace/*
14103256Sswallace * The following 5 macros are incorrectly implemented and obsolete.
14113256Sswallace * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead.
14123256Sswallace */
1413652Sjkh
141430866Smarkm#define SEQ_PITCHBEND(dev, voice, value) \
141530866Smarkm	SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value)
141630866Smarkm#define SEQ_BENDER_RANGE(dev, voice, value) \
141730866Smarkm	SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value)
141830866Smarkm#define SEQ_EXPRESSION(dev, voice, value) \
141930866Smarkm	SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128)
142030866Smarkm#define SEQ_MAIN_VOLUME(dev, voice, value) \
142130866Smarkm	SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100)
142230866Smarkm#define SEQ_PANNING(dev, voice, pos) \
142330866Smarkm	SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
142430866Smarkm
14253256Sswallace/*
142630866Smarkm * Timing and syncronization macros
14273256Sswallace */
1428652Sjkh
142930866Smarkm#define _TIMER_EVENT(ev, parm)		{ \
143030866Smarkm	_SEQ_NEEDBUF(8);\
143130866Smarkm	_seqbuf[_seqbufptr+0] = EV_TIMING; \
143230866Smarkm	_seqbuf[_seqbufptr+1] = (ev); \
143330866Smarkm	_seqbuf[_seqbufptr+2] = 0;\
143430866Smarkm	_seqbuf[_seqbufptr+3] = 0;\
143530866Smarkm	*(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \
143630866Smarkm	_SEQ_ADVBUF(8); \
143730866Smarkm	}
1438652Sjkh
14393256Sswallace#define SEQ_START_TIMER()		_TIMER_EVENT(TMR_START, 0)
14403256Sswallace#define SEQ_STOP_TIMER()		_TIMER_EVENT(TMR_STOP, 0)
14413256Sswallace#define SEQ_CONTINUE_TIMER()		_TIMER_EVENT(TMR_CONTINUE, 0)
14423256Sswallace#define SEQ_WAIT_TIME(ticks)		_TIMER_EVENT(TMR_WAIT_ABS, ticks)
14433256Sswallace#define SEQ_DELTA_TIME(ticks)		_TIMER_EVENT(TMR_WAIT_REL, ticks)
14443256Sswallace#define SEQ_ECHO_BACK(key)		_TIMER_EVENT(TMR_ECHO, key)
14453256Sswallace#define SEQ_SET_TEMPO(value)		_TIMER_EVENT(TMR_TEMPO, value)
14463256Sswallace#define SEQ_SONGPOS(pos)		_TIMER_EVENT(TMR_SPP, pos)
14473256Sswallace#define SEQ_TIME_SIGNATURE(sig)		_TIMER_EVENT(TMR_TIMESIG, sig)
1448652Sjkh
14493256Sswallace/*
145030866Smarkm * Local control events
145130866Smarkm */
145230866Smarkm
145330866Smarkm#define _LOCAL_EVENT(ev, parm)		{ \
145430866Smarkm	_SEQ_NEEDBUF(8);\
145530866Smarkm	_seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
145630866Smarkm	_seqbuf[_seqbufptr+1] = (ev); \
145730866Smarkm	_seqbuf[_seqbufptr+2] = 0;\
145830866Smarkm	_seqbuf[_seqbufptr+3] = 0;\
145930866Smarkm	*(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \
146030866Smarkm	_SEQ_ADVBUF(8); \
146130866Smarkm	}
146230866Smarkm
146330866Smarkm#define SEQ_PLAYAUDIO(devmask)		_LOCAL_EVENT(LOCL_STARTAUDIO, devmask)
146430866Smarkm/*
1465118923Scg * Events for the level 1 interface only
14663256Sswallace */
1467652Sjkh
146830866Smarkm#define SEQ_MIDIOUT(device, byte)	{ \
146930866Smarkm	_SEQ_NEEDBUF(4);\
147030866Smarkm	_seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\
147130866Smarkm	_seqbuf[_seqbufptr+1] = (byte);\
147230866Smarkm	_seqbuf[_seqbufptr+2] = (device);\
147330866Smarkm	_seqbuf[_seqbufptr+3] = 0;\
147430866Smarkm	_SEQ_ADVBUF(4);}
14753256Sswallace
14763256Sswallace/*
14773256Sswallace * Patch loading.
14783256Sswallace */
147930866Smarkm#define SEQ_WRPATCH(patchx, len)	{ \
148030866Smarkm	if (_seqbufptr) seqbuf_dump(); \
148130866Smarkm	if (write(seqfd, (char*)(patchx), len)==-1) \
148230866Smarkm	   perror("Write patch: /dev/sequencer"); \
148330866Smarkm	}
1484652Sjkh
148530866Smarkm#define SEQ_WRPATCH2(patchx, len)	\
148630866Smarkm	( seqbuf_dump(), write(seqfd, (char*)(patchx), len) )
148718444Sbde
148830866Smarkm#endif
148933473Sscrappy
149033473Sscrappy/*
149133473Sscrappy * Here I have moved all the aliases for ioctl names.
149233473Sscrappy */
149333473Sscrappy
149433473Sscrappy#define SNDCTL_DSP_SAMPLESIZE	SNDCTL_DSP_SETFMT
149533473Sscrappy#define SOUND_PCM_WRITE_BITS	SNDCTL_DSP_SETFMT
149633473Sscrappy#define SOUND_PCM_SETFMT	SNDCTL_DSP_SETFMT
149733473Sscrappy
149833473Sscrappy#define SOUND_PCM_WRITE_RATE	SNDCTL_DSP_SPEED
149933473Sscrappy#define SOUND_PCM_POST		SNDCTL_DSP_POST
150033473Sscrappy#define SOUND_PCM_RESET		SNDCTL_DSP_RESET
150133473Sscrappy#define SOUND_PCM_SYNC		SNDCTL_DSP_SYNC
150233473Sscrappy#define SOUND_PCM_SUBDIVIDE	SNDCTL_DSP_SUBDIVIDE
150333473Sscrappy#define SOUND_PCM_SETFRAGMENT	SNDCTL_DSP_SETFRAGMENT
150433473Sscrappy#define SOUND_PCM_GETFMTS	SNDCTL_DSP_GETFMTS
150533473Sscrappy#define SOUND_PCM_GETOSPACE	SNDCTL_DSP_GETOSPACE
150633473Sscrappy#define SOUND_PCM_GETISPACE	SNDCTL_DSP_GETISPACE
150733473Sscrappy#define SOUND_PCM_NONBLOCK	SNDCTL_DSP_NONBLOCK
150833473Sscrappy#define SOUND_PCM_GETCAPS	SNDCTL_DSP_GETCAPS
150933473Sscrappy#define SOUND_PCM_GETTRIGGER	SNDCTL_DSP_GETTRIGGER
151033473Sscrappy#define SOUND_PCM_SETTRIGGER	SNDCTL_DSP_SETTRIGGER
151133473Sscrappy#define SOUND_PCM_SETSYNCRO	SNDCTL_DSP_SETSYNCRO
151233473Sscrappy#define SOUND_PCM_GETIPTR	SNDCTL_DSP_GETIPTR
151333473Sscrappy#define SOUND_PCM_GETOPTR	SNDCTL_DSP_GETOPTR
151433473Sscrappy#define SOUND_PCM_MAPINBUF	SNDCTL_DSP_MAPINBUF
151533473Sscrappy#define SOUND_PCM_MAPOUTBUF	SNDCTL_DSP_MAPOUTBUF
151633473Sscrappy
1517162588Snetchild/***********************************************************************/
1518162588Snetchild
1519162588Snetchild/**
1520162588Snetchild * XXX OSSv4 defines -- some bits taken straight out of the new
1521162588Snetchild * sys/soundcard.h bundled with recent OSS releases.
1522162588Snetchild *
1523162588Snetchild * NB:  These macros and structures will be reorganized and inserted
1524162588Snetchild * 	in appropriate places throughout this file once the code begins
1525162588Snetchild * 	to take shape.
1526162588Snetchild *
1527162588Snetchild * @todo reorganize layout more like the 4Front version
1528162588Snetchild * @todo ask about maintaining __SIOWR vs. _IOWR ioctl cmd defines
1529162588Snetchild */
1530162588Snetchild
1531162588Snetchild/**
1532162588Snetchild * @note The @c OSSV4_EXPERIMENT macro is meant to wrap new development code
1533162588Snetchild * in the sound system relevant to adopting 4Front's OSSv4 specification.
1534162588Snetchild * Users should not enable this!  Really!
1535162588Snetchild */
1536162588Snetchild#if 0
1537162588Snetchild# define OSSV4_EXPERIMENT 1
1538162588Snetchild#else
1539162588Snetchild# undef OSSV4_EXPERIMENT
1540162588Snetchild#endif
1541162588Snetchild
1542162588Snetchild#ifdef SOUND_VERSION
1543162588Snetchild# undef SOUND_VERSION
1544162588Snetchild# define SOUND_VERSION	0x040000
1545162588Snetchild#endif	/* !SOUND_VERSION */
1546162588Snetchild
1547162588Snetchild#define OSS_LONGNAME_SIZE	64
1548162588Snetchild#define OSS_LABEL_SIZE		16
1549162588Snetchild#define OSS_DEVNODE_SIZE        32
1550162588Snetchildtypedef char oss_longname_t[OSS_LONGNAME_SIZE];
1551162588Snetchildtypedef char oss_label_t[OSS_LABEL_SIZE];
1552162588Snetchildtypedef char oss_devnode_t[OSS_DEVNODE_SIZE];
1553162588Snetchild
1554162588Snetchildtypedef struct audio_errinfo
1555162588Snetchild{
1556162588Snetchild	int		play_underruns;
1557162588Snetchild	int		rec_overruns;
1558162588Snetchild	unsigned int	play_ptradjust;
1559162588Snetchild	unsigned int	rec_ptradjust;
1560162588Snetchild	int		play_errorcount;
1561162588Snetchild	int		rec_errorcount;
1562162588Snetchild	int		play_lasterror;
1563162588Snetchild	int		rec_lasterror;
1564162588Snetchild	long		play_errorparm;
1565162588Snetchild	long		rec_errorparm;
1566162588Snetchild	int		filler[16];
1567162588Snetchild} audio_errinfo;
1568162588Snetchild
1569162588Snetchild#define SNDCTL_DSP_GETPLAYVOL           _IOR ('P', 24, int)
1570162588Snetchild#define SNDCTL_DSP_SETPLAYVOL           _IOWR('P', 24, int)
1571162588Snetchild#define SNDCTL_DSP_GETERROR             _IOR ('P', 25, audio_errinfo)
1572162588Snetchild
1573162588Snetchild
1574162588Snetchild/*
1575162588Snetchild ****************************************************************************
1576162588Snetchild * Sync groups for audio devices
1577162588Snetchild */
1578162588Snetchildtypedef struct oss_syncgroup
1579162588Snetchild{
1580162588Snetchild  int id;
1581162588Snetchild  int mode;
1582162588Snetchild  int filler[16];
1583162588Snetchild} oss_syncgroup;
1584162588Snetchild
1585162588Snetchild#define SNDCTL_DSP_SYNCGROUP            _IOWR('P', 28, oss_syncgroup)
1586162588Snetchild#define SNDCTL_DSP_SYNCSTART            _IOW ('P', 29, int)
1587162588Snetchild
1588162588Snetchild/*
1589162588Snetchild **************************************************************************
1590162588Snetchild * "cooked" mode enables software based conversions for sample rate, sample
1591162588Snetchild * format (bits) and number of channels (mono/stereo). These conversions are
1592162588Snetchild * required with some devices that support only one sample rate or just stereo
1593162588Snetchild * to let the applications to use other formats. The cooked mode is enabled by
1594162588Snetchild * default. However it's necessary to disable this mode when mmap() is used or
1595162588Snetchild * when very deterministic timing is required. SNDCTL_DSP_COOKEDMODE is an
1596162588Snetchild * optional call introduced in OSS 3.9.6f. It's _error return must be ignored_
1597162588Snetchild * since normally this call will return erno=EINVAL.
1598162588Snetchild *
1599162588Snetchild * SNDCTL_DSP_COOKEDMODE must be called immediately after open before doing
1600162588Snetchild * anything else. Otherwise the call will not have any effect.
1601162588Snetchild */
1602162588Snetchild#define SNDCTL_DSP_COOKEDMODE           _IOW ('P', 30, int)
1603162588Snetchild
1604162588Snetchild/*
1605162588Snetchild **************************************************************************
1606162588Snetchild * SNDCTL_DSP_SILENCE and SNDCTL_DSP_SKIP are new calls in OSS 3.99.0
1607162588Snetchild * that can be used to implement pause/continue during playback (no effect
1608162588Snetchild * on recording).
1609162588Snetchild */
1610162588Snetchild#define SNDCTL_DSP_SILENCE              _IO  ('P', 31)
1611162588Snetchild#define SNDCTL_DSP_SKIP                 _IO  ('P', 32)
1612162588Snetchild
1613162588Snetchild/*
1614162588Snetchild ****************************************************************************
1615162588Snetchild * Abort transfer (reset) functions for input and output
1616162588Snetchild */
1617162588Snetchild#define SNDCTL_DSP_HALT_INPUT		_IO  ('P', 33)
1618162588Snetchild#define SNDCTL_DSP_RESET_INPUT	SNDCTL_DSP_HALT_INPUT	/* Old name */
1619162588Snetchild#define SNDCTL_DSP_HALT_OUTPUT		_IO  ('P', 34)
1620162588Snetchild#define SNDCTL_DSP_RESET_OUTPUT	SNDCTL_DSP_HALT_OUTPUT	/* Old name */
1621162588Snetchild
1622162588Snetchild/*
1623162588Snetchild ****************************************************************************
1624162588Snetchild * Low water level control
1625162588Snetchild */
1626162588Snetchild#define SNDCTL_DSP_LOW_WATER		_IOW ('P', 34, int)
1627162588Snetchild
1628162588Snetchild/** @todo Get rid of OSS_NO_LONG_LONG references? */
1629162588Snetchild
1630162588Snetchild/*
1631162588Snetchild ****************************************************************************
1632162588Snetchild * 64 bit pointer support. Only available in environments that support
1633162588Snetchild * the 64 bit (long long) integer type.
1634162588Snetchild */
1635162588Snetchild#ifndef OSS_NO_LONG_LONG
1636162588Snetchildtypedef struct
1637162588Snetchild{
1638162588Snetchild  long long samples;
1639162588Snetchild  int fifo_samples;
1640162588Snetchild  int filler[32];		/* For future use */
1641162588Snetchild} oss_count_t;
1642162588Snetchild
1643162588Snetchild#define SNDCTL_DSP_CURRENT_IPTR		_IOR ('P', 35, oss_count_t)
1644162588Snetchild#define SNDCTL_DSP_CURRENT_OPTR		_IOR ('P', 36, oss_count_t)
1645162588Snetchild#endif
1646162588Snetchild
1647162588Snetchild/*
1648162588Snetchild ****************************************************************************
1649162588Snetchild * Interface for selecting recording sources and playback output routings.
1650162588Snetchild */
1651162588Snetchild#define SNDCTL_DSP_GET_RECSRC_NAMES     _IOR ('P', 37, oss_mixer_enuminfo)
1652162588Snetchild#define SNDCTL_DSP_GET_RECSRC           _IOR ('P', 38, int)
1653162588Snetchild#define SNDCTL_DSP_SET_RECSRC           _IOWR('P', 38, int)
1654162588Snetchild
1655162588Snetchild#define SNDCTL_DSP_GET_PLAYTGT_NAMES    _IOR ('P', 39, oss_mixer_enuminfo)
1656162588Snetchild#define SNDCTL_DSP_GET_PLAYTGT          _IOR ('P', 40, int)
1657162588Snetchild#define SNDCTL_DSP_SET_PLAYTGT          _IOWR('P', 40, int)
1658162588Snetchild#define SNDCTL_DSP_GETRECVOL            _IOR ('P', 41, int)
1659162588Snetchild#define SNDCTL_DSP_SETRECVOL            _IOWR('P', 41, int)
1660162588Snetchild
1661162588Snetchild/*
1662162588Snetchild ***************************************************************************
1663162588Snetchild * Some calls for setting the channel assignment with multi channel devices
1664162588Snetchild * (see the manual for details).                                                 */
1665162588Snetchild#define SNDCTL_DSP_GET_CHNORDER         _IOR ('P', 42, unsigned long long)
1666162588Snetchild#define SNDCTL_DSP_SET_CHNORDER         _IOWR('P', 42, unsigned long long)
1667162588Snetchild#       define CHID_UNDEF       0
1668193640Sariff#       define CHID_L           1
1669193640Sariff#       define CHID_R           2
1670162588Snetchild#       define CHID_C           3
1671162588Snetchild#       define CHID_LFE         4
1672162588Snetchild#       define CHID_LS          5
1673162588Snetchild#       define CHID_RS          6
1674162588Snetchild#       define CHID_LR          7
1675162588Snetchild#       define CHID_RR          8
1676162588Snetchild#define CHNORDER_UNDEF          0x0000000000000000ULL
1677162588Snetchild#define CHNORDER_NORMAL         0x0000000087654321ULL
1678162588Snetchild
1679162588Snetchild#define MAX_PEAK_CHANNELS	128
1680162588Snetchildtypedef unsigned short oss_peaks_t[MAX_PEAK_CHANNELS];
1681162588Snetchild#define SNDCTL_DSP_GETIPEAKS		_IOR('P', 43, oss_peaks_t)
1682162588Snetchild#define SNDCTL_DSP_GETOPEAKS		_IOR('P', 44, oss_peaks_t)
1683162588Snetchild#define SNDCTL_DSP_POLICY               _IOW('P', 45, int)    /* See the manual */
1684162588Snetchild
1685164613Snetchild/*
1686193640Sariff ****************************************************************************
1687193640Sariff * Few ioctl calls that are not official parts of OSS. They have been used
1688193640Sariff * by few freeware implementations of OSS.
1689193640Sariff */
1690193640Sariff#define SNDCTL_DSP_GETCHANNELMASK	_IOWR('P', 64, int)
1691193640Sariff#define SNDCTL_DSP_BIND_CHANNEL		_IOWR('P', 65, int)
1692193640Sariff#define DSP_BIND_QUERY			0x00000000
1693193640Sariff#define DSP_BIND_FRONT			0x00000001
1694193640Sariff#define DSP_BIND_SURR			0x00000002
1695193640Sariff#define DSP_BIND_CENTER_LFE		0x00000004
1696193640Sariff#define DSP_BIND_HANDSET		0x00000008
1697193640Sariff#define DSP_BIND_MIC			0x00000010
1698193640Sariff#define DSP_BIND_MODEM1			0x00000020
1699193640Sariff#define DSP_BIND_MODEM2			0x00000040
1700193640Sariff#define DSP_BIND_I2S			0x00000080
1701193640Sariff#define DSP_BIND_SPDIF			0x00000100
1702193640Sariff#define DSP_BIND_REAR			0x00000200
1703193640Sariff
1704193640Sariff/*
1705164613Snetchild * OSS_SYSIFO is obsolete. Use SNDCTL_SYSINFO insteads.
1706164613Snetchild */
1707164613Snetchild#define OSS_GETVERSION                  _IOR ('M', 118, int)
1708164613Snetchild
1709162588Snetchild/**
1710162588Snetchild * @brief	Argument for SNDCTL_SYSINFO ioctl.
1711162588Snetchild *
1712162588Snetchild * For use w/ the SNDCTL_SYSINFO ioctl available on audio (/dev/dsp*),
1713162588Snetchild * mixer, and MIDI devices.
1714162588Snetchild */
1715162588Snetchildtypedef struct oss_sysinfo
1716162588Snetchild{
1717162588Snetchild	char	product[32];	/* For example OSS/Free, OSS/Linux or
1718162588Snetchild				   OSS/Solaris */
1719162588Snetchild	char	version[32];	/* For example 4.0a */
1720162588Snetchild	int	versionnum;	/* See OSS_GETVERSION */
1721162588Snetchild	char	options[128];	/* Reserved */
1722162588Snetchild
1723162588Snetchild	int	numaudios;	/* # of audio/dsp devices */
1724162588Snetchild	int	openedaudio[8];	/* Bit mask telling which audio devices
1725162588Snetchild				   are busy */
1726162588Snetchild
1727162588Snetchild	int	numsynths;	/* # of availavle synth devices */
1728162588Snetchild	int	nummidis;	/* # of available MIDI ports */
1729162588Snetchild	int	numtimers;	/* # of available timer devices */
1730162588Snetchild	int	nummixers;	/* # of mixer devices */
1731162588Snetchild
1732162588Snetchild	int	openedmidi[8];	/* Bit mask telling which midi devices
1733162588Snetchild				   are busy */
1734162588Snetchild	int	numcards;	/* Number of sound cards in the system */
1735186875Smav	int	numaudioengines;	/* Number of audio engines in the system */
1736186875Smav	char	license[16];	/* For example "GPL" or "CDDL" */
1737186875Smav	char	revision_info[256];	/* For internal use */
1738186875Smav	int	filler[172];	/* For future expansion (set to -1) */
1739162588Snetchild} oss_sysinfo;
1740162588Snetchild
1741162588Snetchildtypedef struct oss_mixext
1742162588Snetchild{
1743162588Snetchild  int dev;			/* Mixer device number */
1744162588Snetchild  int ctrl;			/* Controller number */
1745162588Snetchild  int type;			/* Entry type */
1746162588Snetchild#	define MIXT_DEVROOT	 0	/* Device root entry */
1747162588Snetchild#	define MIXT_GROUP	 1	/* Controller group */
1748162588Snetchild#	define MIXT_ONOFF	 2	/* OFF (0) or ON (1) */
1749162588Snetchild#	define MIXT_ENUM	 3	/* Enumerated (0 to maxvalue) */
1750162588Snetchild#	define MIXT_MONOSLIDER	 4	/* Mono slider (0 to 100) */
1751162588Snetchild#	define MIXT_STEREOSLIDER 5	/* Stereo slider (dual 0 to 100) */
1752162588Snetchild#	define MIXT_MESSAGE	 6	/* (Readable) textual message */
1753162588Snetchild#	define MIXT_MONOVU	 7	/* VU meter value (mono) */
1754162588Snetchild#	define MIXT_STEREOVU	 8	/* VU meter value (stereo) */
1755162588Snetchild#	define MIXT_MONOPEAK	 9	/* VU meter peak value (mono) */
1756162588Snetchild#	define MIXT_STEREOPEAK	10	/* VU meter peak value (stereo) */
1757162588Snetchild#	define MIXT_RADIOGROUP	11	/* Radio button group */
1758162588Snetchild#	define MIXT_MARKER	12	/* Separator between normal and extension entries */
1759162588Snetchild#	define MIXT_VALUE	13	/* Decimal value entry */
1760162588Snetchild#	define MIXT_HEXVALUE	14	/* Hexadecimal value entry */
1761162588Snetchild#	define MIXT_MONODB	15	/* Mono atten. slider (0 to -144) */
1762162588Snetchild#	define MIXT_STEREODB	16	/* Stereo atten. slider (dual 0 to -144) */
1763162588Snetchild#	define MIXT_SLIDER	17	/* Slider (mono) with full integer range */
1764162588Snetchild#	define MIXT_3D		18
1765162588Snetchild
1766162588Snetchild  /* Possible value range (minvalue to maxvalue) */
1767162588Snetchild  /* Note that maxvalue may also be smaller than minvalue */
1768162588Snetchild  int maxvalue;
1769162588Snetchild  int minvalue;
1770162588Snetchild
1771162588Snetchild  int flags;
1772162588Snetchild#	define MIXF_READABLE	0x00000001	/* Has readable value */
1773162588Snetchild#	define MIXF_WRITEABLE	0x00000002	/* Has writeable value */
1774162588Snetchild#	define MIXF_POLL	0x00000004	/* May change itself */
1775162588Snetchild#	define MIXF_HZ		0x00000008	/* Herz scale */
1776162588Snetchild#	define MIXF_STRING	0x00000010	/* Use dynamic extensions for value */
1777162588Snetchild#	define MIXF_DYNAMIC	0x00000010	/* Supports dynamic extensions */
1778162588Snetchild#	define MIXF_OKFAIL	0x00000020	/* Interpret value as 1=OK, 0=FAIL */
1779162588Snetchild#	define MIXF_FLAT	0x00000040	/* Flat vertical space requirements */
1780162588Snetchild#	define MIXF_LEGACY	0x00000080	/* Legacy mixer control group */
1781162588Snetchild  char id[16];			/* Mnemonic ID (mainly for internal use) */
1782162588Snetchild  int parent;			/* Entry# of parent (group) node (-1 if root) */
1783162588Snetchild
1784162588Snetchild  int dummy;			/* Internal use */
1785162588Snetchild
1786162588Snetchild  int timestamp;
1787162588Snetchild
1788162588Snetchild  char data[64];		/* Misc data (entry type dependent) */
1789162588Snetchild  unsigned char enum_present[32];	/* Mask of allowed enum values */
1790162588Snetchild  int control_no;		/* SOUND_MIXER_VOLUME..SOUND_MIXER_MIDI */
1791162588Snetchild  /* (-1 means not indicated) */
1792162588Snetchild
1793162588Snetchild/*
1794162588Snetchild * The desc field is reserved for internal purposes of OSS. It should not be
1795162588Snetchild * used by applications.
1796162588Snetchild */
1797162588Snetchild  unsigned int desc;
1798162588Snetchild#define MIXEXT_SCOPE_MASK			0x0000003f
1799162588Snetchild#define MIXEXT_SCOPE_OTHER			0x00000000
1800162588Snetchild#define MIXEXT_SCOPE_INPUT			0x00000001
1801162588Snetchild#define MIXEXT_SCOPE_OUTPUT			0x00000002
1802162588Snetchild#define MIXEXT_SCOPE_MONITOR			0x00000003
1803162588Snetchild#define MIXEXT_SCOPE_RECSWITCH			0x00000004
1804162588Snetchild
1805162588Snetchild  char extname[32];
1806162588Snetchild  int update_counter;
1807162588Snetchild  int filler[7];
1808162588Snetchild} oss_mixext;
1809162588Snetchild
1810162588Snetchildtypedef struct oss_mixext_root
1811162588Snetchild{
1812162588Snetchild  char id[16];
1813162588Snetchild  char name[48];
1814162588Snetchild} oss_mixext_root;
1815162588Snetchild
1816162588Snetchildtypedef struct oss_mixer_value
1817162588Snetchild{
1818162588Snetchild  int dev;
1819162588Snetchild  int ctrl;
1820162588Snetchild  int value;
1821162588Snetchild  int flags;			/* Reserved for future use. Initialize to 0 */
1822162588Snetchild  int timestamp;		/* Must be set to oss_mixext.timestamp */
1823162588Snetchild  int filler[8];		/* Reserved for future use. Initialize to 0 */
1824162588Snetchild} oss_mixer_value;
1825162588Snetchild
1826162588Snetchild#define OSS_ENUM_MAXVALUE       255
1827162588Snetchildtypedef struct oss_mixer_enuminfo
1828162588Snetchild{
1829162588Snetchild	int	dev;
1830162588Snetchild	int	ctrl;
1831162588Snetchild	int	nvalues;
1832162588Snetchild	int	version;                  /* Read the manual */
1833162588Snetchild	short	strindex[OSS_ENUM_MAXVALUE];
1834162588Snetchild	char	strings[3000];
1835162588Snetchild} oss_mixer_enuminfo;
1836162588Snetchild
1837162588Snetchild#define OPEN_READ       PCM_ENABLE_INPUT
1838162588Snetchild#define OPEN_WRITE      PCM_ENABLE_OUTPUT
1839162588Snetchild#define OPEN_READWRITE  (OPEN_READ|OPEN_WRITE)
1840162588Snetchild
1841162588Snetchild/**
1842162588Snetchild * @brief	Argument for SNDCTL_AUDIOINFO ioctl.
1843162588Snetchild *
1844162588Snetchild * For use w/ the SNDCTL_AUDIOINFO ioctl available on audio (/dev/dsp*)
1845162588Snetchild * devices.
1846162588Snetchild */
1847162588Snetchildtypedef struct oss_audioinfo
1848162588Snetchild{
1849162588Snetchild	int	dev;		/* Audio device number */
1850162588Snetchild	char	name[64];
1851162588Snetchild	int	busy;		/* 0, OPEN_READ, OPEN_WRITE or OPEN_READWRITE */
1852162588Snetchild	int	pid;
1853162588Snetchild	int	caps;		/* DSP_CAP_INPUT, DSP_CAP_OUTPUT */
1854162588Snetchild	int	iformats;
1855162588Snetchild	int	oformats;
1856162588Snetchild	int	magic;		/* Reserved for internal use */
1857162588Snetchild	char 	cmd[64];	/* Command using the device (if known) */
1858162588Snetchild	int	card_number;
1859162588Snetchild	int	port_number;
1860162588Snetchild	int	mixer_dev;
1861162588Snetchild	int	real_device;	/* Obsolete field. Replaced by devnode */
1862162588Snetchild	int	enabled;	/* 1=enabled, 0=device not ready at this
1863162588Snetchild				   moment */
1864162588Snetchild	int	flags;		/* For internal use only - no practical
1865162588Snetchild				   meaning */
1866162588Snetchild	int	min_rate;	/* Sample rate limits */
1867162588Snetchild	int	max_rate;
1868162588Snetchild	int	min_channels;	/* Number of channels supported */
1869162588Snetchild	int	max_channels;
1870162588Snetchild	int	binding;	/* DSP_BIND_FRONT, etc. 0 means undefined */
1871162588Snetchild	int	rate_source;
1872162588Snetchild	char	handle[32];
1873163731Snetchild	#define OSS_MAX_SAMPLE_RATES	20	/* Cannot be changed  */
1874162588Snetchild	unsigned int nrates;
1875163731Snetchild	unsigned int rates[OSS_MAX_SAMPLE_RATES]; /* Please read the manual before using these */
1876162588Snetchild	oss_longname_t	song_name;	/* Song name (if given) */
1877162588Snetchild	oss_label_t	label;		/* Device label (if given) */
1878162588Snetchild	int		latency;	/* In usecs, -1=unknown */
1879162588Snetchild	oss_devnode_t	devnode;	/* Device special file name (inside
1880162588Snetchild					   /dev) */
1881187030Smav	int next_play_engine;
1882187030Smav	int next_rec_engine;
1883187030Smav	int filler[184];
1884162588Snetchild} oss_audioinfo;
1885162588Snetchild
1886162588Snetchildtypedef struct oss_mixerinfo
1887162588Snetchild{
1888162588Snetchild  int dev;
1889162588Snetchild  char id[16];
1890162588Snetchild  char name[32];
1891162588Snetchild  int modify_counter;
1892162588Snetchild  int card_number;
1893162588Snetchild  int port_number;
1894162588Snetchild  char handle[32];
1895162588Snetchild  int magic;			/* Reserved */
1896162588Snetchild  int enabled;			/* Reserved */
1897162588Snetchild  int caps;
1898162588Snetchild#define MIXER_CAP_VIRTUAL				0x00000001
1899162588Snetchild  int flags;			/* Reserved */
1900162588Snetchild  int nrext;
1901162588Snetchild  /*
1902162588Snetchild   * The priority field can be used to select the default (motherboard)
1903162588Snetchild   * mixer device. The mixer with the highest priority is the
1904162588Snetchild   * most preferred one. -2 or less means that this device cannot be used
1905162588Snetchild   * as the default mixer.
1906162588Snetchild   */
1907162588Snetchild  int priority;
1908162588Snetchild  int filler[254];		/* Reserved */
1909162588Snetchild} oss_mixerinfo;
1910162588Snetchild
1911162588Snetchildtypedef struct oss_midi_info
1912162588Snetchild{
1913162588Snetchild  int dev;			/* Midi device number */
1914162588Snetchild  char name[64];
1915162588Snetchild  int busy;			/* 0, OPEN_READ, OPEN_WRITE or OPEN_READWRITE */
1916162588Snetchild  int pid;
1917162588Snetchild  char cmd[64];			/* Command using the device (if known) */
1918162588Snetchild  int caps;
1919162588Snetchild#define MIDI_CAP_MPU401		0x00000001	/**** OBSOLETE ****/
1920162588Snetchild#define MIDI_CAP_INPUT		0x00000002
1921162588Snetchild#define MIDI_CAP_OUTPUT		0x00000004
1922162588Snetchild#define MIDI_CAP_INOUT		(MIDI_CAP_INPUT|MIDI_CAP_OUTPUT)
1923162588Snetchild#define MIDI_CAP_VIRTUAL	0x00000008	/* Pseudo device */
1924162588Snetchild#define MIDI_CAP_MTCINPUT	0x00000010	/* Supports SNDCTL_MIDI_MTCINPUT */
1925162588Snetchild#define MIDI_CAP_CLIENT		0x00000020	/* Virtual client side device */
1926162588Snetchild#define MIDI_CAP_SERVER		0x00000040	/* Virtual server side device */
1927162588Snetchild#define MIDI_CAP_INTERNAL	0x00000080	/* Internal (synth) device */
1928162588Snetchild#define MIDI_CAP_EXTERNAL	0x00000100	/* external (MIDI port) device */
1929162588Snetchild#define MIDI_CAP_PTOP		0x00000200	/* Point to point link to one device */
1930162588Snetchild#define MIDI_CAP_MTC		0x00000400	/* MTC/SMPTE (control) device */
1931162588Snetchild  int magic;			/* Reserved for internal use */
1932162588Snetchild  int card_number;
1933162588Snetchild  int port_number;
1934162588Snetchild  int enabled;			/* 1=enabled, 0=device not ready at this moment */
1935162588Snetchild  int flags;			/* For internal use only - no practical meaning */
1936162588Snetchild  char handle[32];
1937162588Snetchild  oss_longname_t song_name;	/* Song name (if known) */
1938162588Snetchild  oss_label_t label;		/* Device label (if given) */
1939162588Snetchild  int latency;			/* In usecs, -1=unknown */
1940162588Snetchild  int filler[244];
1941162588Snetchild} oss_midi_info;
1942162588Snetchild
1943162588Snetchildtypedef struct oss_card_info
1944162588Snetchild{
1945162588Snetchild  int card;
1946162588Snetchild  char shortname[16];
1947162588Snetchild  char longname[128];
1948162588Snetchild  int flags;
1949187030Smav  char hw_info[400];
1950187030Smav  int intr_count, ack_count;
1951187030Smav  int filler[154];
1952162588Snetchild} oss_card_info;
1953162588Snetchild
1954162588Snetchild#define SNDCTL_SYSINFO          _IOR ('X', 1, oss_sysinfo)
1955162588Snetchild#define OSS_SYSINFO             SNDCTL_SYSINFO /* Old name */
1956162588Snetchild
1957162588Snetchild#define SNDCTL_MIX_NRMIX	_IOR ('X', 2, int)
1958162588Snetchild#define SNDCTL_MIX_NREXT	_IOWR('X', 3, int)
1959162588Snetchild#define SNDCTL_MIX_EXTINFO	_IOWR('X', 4, oss_mixext)
1960162588Snetchild#define SNDCTL_MIX_READ		_IOWR('X', 5, oss_mixer_value)
1961162588Snetchild#define SNDCTL_MIX_WRITE	_IOWR('X', 6, oss_mixer_value)
1962162588Snetchild
1963162588Snetchild#define SNDCTL_AUDIOINFO	_IOWR('X', 7, oss_audioinfo)
1964162588Snetchild#define SNDCTL_MIX_ENUMINFO	_IOWR('X', 8, oss_mixer_enuminfo)
1965162588Snetchild#define SNDCTL_MIDIINFO		_IOWR('X', 9, oss_midi_info)
1966162588Snetchild#define SNDCTL_MIXERINFO	_IOWR('X',10, oss_mixerinfo)
1967162588Snetchild#define SNDCTL_CARDINFO		_IOWR('X',11, oss_card_info)
1968187030Smav#define SNDCTL_ENGINEINFO	_IOWR('X',12, oss_audioinfo)
1969187030Smav#define SNDCTL_AUDIOINFO_EX	_IOWR('X',13, oss_audioinfo)
1970162588Snetchild
1971162588Snetchild/*
1972162588Snetchild * Few more "globally" available ioctl calls.
1973162588Snetchild */
1974162588Snetchild#define SNDCTL_SETSONG          _IOW ('Y', 2, oss_longname_t)
1975162588Snetchild#define SNDCTL_GETSONG          _IOR ('Y', 2, oss_longname_t)
1976162588Snetchild#define SNDCTL_SETNAME          _IOW ('Y', 3, oss_longname_t)
1977162588Snetchild#define SNDCTL_SETLABEL         _IOW ('Y', 4, oss_label_t)
1978162588Snetchild#define SNDCTL_GETLABEL         _IOR ('Y', 4, oss_label_t)
1979162588Snetchild
198050906Sdfr#endif	/* !_SYS_SOUNDCARD_H_ */
1981