soundcard.h revision 33530
1652Sjkh/* 233473Sscrappy * soundcard.h 333473Sscrappy * 4652Sjkh * Copyright by Hannu Savolainen 1993 533473Sscrappy * Modified for the new FreeBSD sound driver by Luigi Rizzo, 1997 6652Sjkh * 7652Sjkh * Redistribution and use in source and binary forms, with or without 8652Sjkh * modification, are permitted provided that the following conditions 9652Sjkh * are met: 10652Sjkh * 1. Redistributions of source code must retain the above copyright 11652Sjkh * notice, this list of conditions and the following disclaimer. 1233473Sscrappy * 2. Redistributions in binary form must reproduce the above 1333473Sscrappy * copyright notice, this list of conditions and the following 1433473Sscrappy * disclaimer in the documentation and/or other materials provided 1533473Sscrappy * with the distribution. 16652Sjkh * 1733473Sscrappy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' 1833473Sscrappy * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 1933473Sscrappy * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 2033473Sscrappy * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 2133473Sscrappy * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2233473Sscrappy * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2333473Sscrappy * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 2433473Sscrappy * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 2533473Sscrappy * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2633473Sscrappy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 2733473Sscrappy * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2833473Sscrappy * POSSIBILITY OF SUCH DAMAGE. 29652Sjkh */ 30652Sjkh 3133473Sscrappy#ifndef SOUNDCARD_H 3233473Sscrappy#define SOUNDCARD_H 339750Sjkh /* 34652Sjkh * If you make modifications to this file, please contact me before 359750Sjkh * distributing the modified version. There is already enough 3613765Smpp * diversity in the world. 37652Sjkh * 38652Sjkh * Regards, 39652Sjkh * Hannu Savolainen 403256Sswallace * hannu@voxware.pp.fi 4130866Smarkm * 4230866Smarkm ********************************************************************** 4330866Smarkm * PS. The Hacker's Guide to VoxWare available from 4430866Smarkm * nic.funet.fi:pub/OS/Linux/ALPHA/sound. The file is 4530866Smarkm * snd-sdk-doc-0.1.ps.gz (gzipped postscript). It contains 4630866Smarkm * some useful information about programming with VoxWare. 4730866Smarkm * (NOTE! The pub/OS/Linux/ALPHA/ directories are hidden. You have 4830866Smarkm * to cd inside them before the files are accessible.) 4930866Smarkm ********************************************************************** 50652Sjkh */ 51652Sjkh 5233530Sscrappy/* 5333530Sscrappy * SOUND_VERSION is only used by the voxware driver. Hopefully apps 5433530Sscrappy * should not depend on it, but rather look at the capabilities 5533530Sscrappy * of the driver in the kernel! 5633530Sscrappy */ 5733530Sscrappy#define SOUND_VERSION 301 5833530Sscrappy#define VOXWARE /* does this have any use ? */ 5933530Sscrappy 6033530Sscrappy/* 6133530Sscrappy * Supported card ID numbers (Should be somewhere else? We keep 6233530Sscrappy * them here just for compativility with the old driver, but these 6333530Sscrappy * constants are of little or no use). 6433530Sscrappy */ 6533530Sscrappy 6633530Sscrappy#define SNDCARD_ADLIB 1 6733530Sscrappy#define SNDCARD_SB 2 6833530Sscrappy#define SNDCARD_PAS 3 6933530Sscrappy#define SNDCARD_GUS 4 7033530Sscrappy#define SNDCARD_MPU401 5 7133530Sscrappy#define SNDCARD_SB16 6 7233530Sscrappy#define SNDCARD_SB16MIDI 7 7333530Sscrappy#define SNDCARD_UART6850 8 7433530Sscrappy#define SNDCARD_GUS16 9 7533530Sscrappy#define SNDCARD_MSS 10 7633530Sscrappy#define SNDCARD_PSS 11 7733530Sscrappy#define SNDCARD_SSCAPE 12 7833530Sscrappy#define SNDCARD_PSS_MPU 13 7933530Sscrappy#define SNDCARD_PSS_MSS 14 8033530Sscrappy#define SNDCARD_SSCAPE_MSS 15 8133530Sscrappy#define SNDCARD_TRXPRO 16 8233530Sscrappy#define SNDCARD_TRXPRO_SB 17 8333530Sscrappy#define SNDCARD_TRXPRO_MPU 18 8433530Sscrappy#define SNDCARD_MAD16 19 8533530Sscrappy#define SNDCARD_MAD16_MPU 20 8633530Sscrappy#define SNDCARD_CS4232 21 8733530Sscrappy#define SNDCARD_CS4232_MPU 22 8833530Sscrappy#define SNDCARD_MAUI 23 8933530Sscrappy#define SNDCARD_PSEUDO_MSS 24 9033530Sscrappy#define SNDCARD_AWE32 25 9133530Sscrappy 9233473Sscrappy#include <sys/types.h> 9333473Sscrappy#ifndef _IOWR 9433473Sscrappy#include <sys/ioccom.h> 9533473Sscrappy#endif /* !_IOWR */ 96652Sjkh 97652Sjkh/* 9833473Sscrappy * The first part of this file contains the new FreeBSD sound ioctl 9933473Sscrappy * interface. Tries to minimize the number of different ioctls, and 10033473Sscrappy * to be reasonably general. 10133473Sscrappy * 10233473Sscrappy * 970821: some of the new calls have not been implemented yet. 103652Sjkh */ 104652Sjkh 10533473Sscrappy/* 10633473Sscrappy * the following three calls extend the generic file descriptor 10733473Sscrappy * interface. AIONWRITE is the dual of FIONREAD, i.e. returns the max 10833473Sscrappy * number of bytes for a write operation to be non-blocking. 10933473Sscrappy * 11033473Sscrappy * AIOGSIZE/AIOSSIZE are used to change the behaviour of the device, 11133473Sscrappy * from a character device (default) to a block device. In block mode, 11233473Sscrappy * (not to be confused with blocking mode) the main difference for the 11333473Sscrappy * application is that select() will return only when a complete 11433473Sscrappy * block can be read/written to the device, whereas in character mode 11533473Sscrappy * select will return true when one byte can be exchanged. For audio 11633473Sscrappy * devices, character mode makes select almost useless since one byte 11733473Sscrappy * will always be ready by the next sample time (which is often only a 11833473Sscrappy * handful of microseconds away). 11933473Sscrappy * Use a size of 0 or 1 to return to character mode. 12033473Sscrappy */ 12133473Sscrappy#define AIONWRITE _IOR('A', 10, int) /* get # bytes to write */ 12233473Sscrappystruct snd_size { 12333473Sscrappy int play_size; 12433473Sscrappy int rec_size; 12533473Sscrappy}; 12633473Sscrappy#define AIOGSIZE _IOR('A', 11, struct snd_size)/* read current blocksize */ 12733473Sscrappy#define AIOSSIZE _IOWR('A', 11, struct snd_size) /* sets blocksize */ 128652Sjkh 12930866Smarkm/* 13033473Sscrappy * The following constants define supported audio formats. The 13133473Sscrappy * encoding follows voxware conventions, i.e. 1 bit for each supported 13233473Sscrappy * format. We extend it by using bit 31 (RO) to indicate full-duplex 13333473Sscrappy * capability, and bit 29 (RO) to indicate that the card supports/ 13433473Sscrappy * needs different formats on capture & playback channels. 13533473Sscrappy * Bit 29 (RW) is used to indicate/ask stereo. 13633473Sscrappy */ 13733473Sscrappy 13833473Sscrappy# define AFMT_QUERY 0x00000000 /* Return current fmt */ 13933473Sscrappy# define AFMT_MU_LAW 0x00000001 14033473Sscrappy# define AFMT_A_LAW 0x00000002 14133473Sscrappy# define AFMT_IMA_ADPCM 0x00000004 14233473Sscrappy# define AFMT_U8 0x00000008 14333473Sscrappy# define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/ 14433473Sscrappy# define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */ 14533473Sscrappy# define AFMT_S8 0x00000040 14633473Sscrappy# define AFMT_U16_LE 0x00000080 /* Little endian U16 */ 14733473Sscrappy# define AFMT_U16_BE 0x00000100 /* Big endian U16 */ 14833473Sscrappy# define AFMT_MPEG 0x00000200 /* MPEG (2) audio */ 14933473Sscrappy 15033473Sscrappy# define AFMT_STEREO 0x10000000 /* can do/want stereo */ 15133473Sscrappy 15233473Sscrappy/* 15333473Sscrappy * the following are really capabilities 15433473Sscrappy */ 15533473Sscrappy# define AFMT_WEIRD 0x20000000 /* weird hardware... */ 15633473Sscrappy /* 15733473Sscrappy * AFMT_WEIRD reports that the hardware might need to operate 15833473Sscrappy * with different formats in the playback and capture 15933473Sscrappy * channels when operating in full duplex. 16033473Sscrappy * As an example, SoundBlaster16 cards only support U8 in one 16133473Sscrappy * direction and S16 in the other one, and applications should 16233473Sscrappy * be aware of this limitation. 16333473Sscrappy */ 16433473Sscrappy# define AFMT_FULLDUPLEX 0x80000000 /* can do full duplex */ 16533473Sscrappy 16633473Sscrappy/* 16733473Sscrappy * The following structure is used to get/set format and sampling rate. 16833473Sscrappy * While it would be better to have things such as stereo, bits per 16933473Sscrappy * sample, endiannes, etc split in different variables, it turns out 17033473Sscrappy * that formats are not that many, and not all combinations are possible. 17133473Sscrappy * So we followed the Voxware approach of associating one bit to each 17233473Sscrappy * format. 17333473Sscrappy */ 17433473Sscrappy 17533473Sscrappytypedef struct _snd_chan_param { 17633473Sscrappy u_long play_rate; /* sampling rate */ 17733473Sscrappy u_long rec_rate; /* sampling rate */ 17833473Sscrappy u_long play_format; /* everything describing the format */ 17933473Sscrappy u_long rec_format; /* everything describing the format */ 18033473Sscrappy} snd_chan_param; 18133473Sscrappy#define AIOGFMT _IOR('f', 12, snd_chan_param) /* get format */ 18233473Sscrappy#define AIOSFMT _IOWR('f', 12, snd_chan_param) /* sets format */ 18333473Sscrappy 18433473Sscrappy/* 18533473Sscrappy * The following structure is used to get/set the mixer setting. 18633473Sscrappy * Up to 32 mixers are supported, each one with up to 32 channels. 18733473Sscrappy */ 18833473Sscrappytypedef struct _snd_mix_param { 18933473Sscrappy u_char subdev; /* which output */ 19033473Sscrappy u_char line; /* which input */ 19133473Sscrappy u_char left,right; /* volumes, 0..255, 0 = mute */ 19233473Sscrappy} snd_mix_param ; 19333473Sscrappy 19433473Sscrappy/* XXX AIOGMIX, AIOSMIX not implemented yet */ 19533473Sscrappy#define AIOGMIX _IOWR('A', 13, snd_mix_param) /* return mixer status */ 19633473Sscrappy#define AIOSMIX _IOWR('A', 14, snd_mix_param) /* sets mixer status */ 19733473Sscrappy 19833473Sscrappy/* 19933473Sscrappy * channel specifiers used in AIOSTOP and AIOSYNC 20033473Sscrappy */ 20133473Sscrappy#define AIOSYNC_PLAY 0x1 /* play chan */ 20233473Sscrappy#define AIOSYNC_CAPTURE 0x2 /* capture chan */ 20333473Sscrappy/* AIOSTOP stop & flush a channel, returns the residual count */ 20433473Sscrappy#define AIOSTOP _IOWR ('A', 15, int) 20533473Sscrappy 20633473Sscrappy/* alternate method used to notify the sync condition */ 20733473Sscrappy#define AIOSYNC_SIGNAL 0x100 20833473Sscrappy#define AIOSYNC_SELECT 0x200 20933473Sscrappy 21033473Sscrappy/* what the 'pos' field refers to */ 21133473Sscrappy#define AIOSYNC_READY 0x400 21233473Sscrappy#define AIOSYNC_FREE 0x800 21333473Sscrappy 21433473Sscrappytypedef struct _snd_sync_parm { 21533473Sscrappy long chan ; /* play or capture channel, plus modifier */ 21633473Sscrappy long pos; 21733473Sscrappy} snd_sync_parm; 21833473Sscrappy#define AIOSYNC _IOWR ('A', 15, snd_sync_parm) /* misc. synchronization */ 21933473Sscrappy 22033473Sscrappy/* 22133473Sscrappy * The following is used to return device capabilities. If the structure 22233473Sscrappy * passed to the ioctl is zeroed, default values are returned for rate 22333473Sscrappy * and formats, a bitmap of available mixers is returned, and values 22433473Sscrappy * (inputs, different levels) for the first one are returned. 22533473Sscrappy * 22633473Sscrappy * If formats, mixers, inputs are instantiated, then detailed info 22733473Sscrappy * are returned depending on the call. 22833473Sscrappy */ 22933473Sscrappytypedef struct _snd_capabilities { 23033473Sscrappy u_long rate_min, rate_max; /* min-max sampling rate */ 23133473Sscrappy u_long formats; 23233473Sscrappy u_long bufsize; /* DMA buffer size */ 23333473Sscrappy u_long mixers; /* bitmap of available mixers */ 23433473Sscrappy u_long inputs; /* bitmap of available inputs (per mixer) */ 23533473Sscrappy u_short left, right; /* how many levels are supported */ 23633473Sscrappy} snd_capabilities; 23733473Sscrappy#define AIOGCAP _IOWR('A', 15, snd_capabilities) /* get capabilities */ 23833473Sscrappy 23933473Sscrappy/* 24033473Sscrappy * here is the old (Voxware) ioctl interface 24133473Sscrappy */ 24233473Sscrappy 24333473Sscrappy/* 244652Sjkh * IOCTL Commands for /dev/sequencer 245652Sjkh */ 246652Sjkh 24733473Sscrappy#define SNDCTL_SEQ_RESET _IO ('Q', 0) 24833473Sscrappy#define SNDCTL_SEQ_SYNC _IO ('Q', 1) 24933473Sscrappy#define SNDCTL_SYNTH_INFO _IOWR('Q', 2, struct synth_info) 25033473Sscrappy#define SNDCTL_SEQ_CTRLRATE _IOWR('Q', 3, int) /* Set/get timer res.(hz) */ 25133473Sscrappy#define SNDCTL_SEQ_GETOUTCOUNT _IOR ('Q', 4, int) 25233473Sscrappy#define SNDCTL_SEQ_GETINCOUNT _IOR ('Q', 5, int) 25333473Sscrappy#define SNDCTL_SEQ_PERCMODE _IOW ('Q', 6, int) 25433473Sscrappy#define SNDCTL_FM_LOAD_INSTR _IOW ('Q', 7, struct sbi_instrument) /* Valid for FM only */ 25533473Sscrappy#define SNDCTL_SEQ_TESTMIDI _IOW ('Q', 8, int) 25633473Sscrappy#define SNDCTL_SEQ_RESETSAMPLES _IOW ('Q', 9, int) 25733473Sscrappy#define SNDCTL_SEQ_NRSYNTHS _IOR ('Q',10, int) 25833473Sscrappy#define SNDCTL_SEQ_NRMIDIS _IOR ('Q',11, int) 25933473Sscrappy#define SNDCTL_MIDI_INFO _IOWR('Q',12, struct midi_info) 26033473Sscrappy#define SNDCTL_SEQ_THRESHOLD _IOW ('Q',13, int) 26133473Sscrappy#define SNDCTL_SEQ_TRESHOLD SNDCTL_SEQ_THRESHOLD /* there was once a typo */ 26233473Sscrappy#define SNDCTL_SYNTH_MEMAVL _IOWR('Q',14, int) /* in=dev#, out=memsize */ 26333473Sscrappy#define SNDCTL_FM_4OP_ENABLE _IOW ('Q',15, int) /* in=dev# */ 26433473Sscrappy#define SNDCTL_PMGR_ACCESS _IOWR('Q',16, struct patmgr_info) 26533473Sscrappy#define SNDCTL_SEQ_PANIC _IO ('Q',17) 26633473Sscrappy#define SNDCTL_SEQ_OUTOFBAND _IOW ('Q',18, struct seq_event_rec) 2679750Sjkh 26830866Smarkmstruct seq_event_rec { 26930866Smarkm u_char arr[8]; 27030866Smarkm}; 2719750Sjkh 27233473Sscrappy#define SNDCTL_TMR_TIMEBASE _IOWR('T', 1, int) 27333473Sscrappy#define SNDCTL_TMR_START _IO ('T', 2) 27433473Sscrappy#define SNDCTL_TMR_STOP _IO ('T', 3) 27533473Sscrappy#define SNDCTL_TMR_CONTINUE _IO ('T', 4) 27633473Sscrappy#define SNDCTL_TMR_TEMPO _IOWR('T', 5, int) 27733473Sscrappy#define SNDCTL_TMR_SOURCE _IOWR('T', 6, int) 27833473Sscrappy# define TMR_INTERNAL 0x00000001 27933473Sscrappy# define TMR_EXTERNAL 0x00000002 28033473Sscrappy# define TMR_MODE_MIDI 0x00000010 28133473Sscrappy# define TMR_MODE_FSK 0x00000020 28233473Sscrappy# define TMR_MODE_CLS 0x00000040 28333473Sscrappy# define TMR_MODE_SMPTE 0x00000080 28433473Sscrappy#define SNDCTL_TMR_METRONOME _IOW ('T', 7, int) 28533473Sscrappy#define SNDCTL_TMR_SELECT _IOW ('T', 8, int) 2863256Sswallace 287652Sjkh/* 28830866Smarkm * Endian aware patch key generation algorithm. 28930866Smarkm */ 29030866Smarkm 29130866Smarkm#if defined(_AIX) || defined(AIX) 29230866Smarkm# define _PATCHKEY(id) (0xfd00|id) 29330866Smarkm#else 29430866Smarkm# define _PATCHKEY(id) ((id<<8)|0xfd) 29530866Smarkm#endif 29630866Smarkm 29730866Smarkm/* 298652Sjkh * Sample loading mechanism for internal synthesizers (/dev/sequencer) 299652Sjkh * The following patch_info structure has been designed to support 300652Sjkh * Gravis UltraSound. It tries to be universal format for uploading 30133473Sscrappy * sample based patches but is probably too limited. 302652Sjkh */ 303652Sjkh 304652Sjkhstruct patch_info { 30530866Smarkm/* u_short key; Use GUS_PATCH here */ 30630866Smarkm short key; /* Use GUS_PATCH here */ 30730866Smarkm#define GUS_PATCH _PATCHKEY(0x04) 30830866Smarkm#define OBSOLETE_GUS_PATCH _PATCHKEY(0x02) 309652Sjkh 31030866Smarkm short device_no; /* Synthesizer number */ 31130866Smarkm short instr_no; /* Midi pgm# */ 31230866Smarkm 31330866Smarkm u_long mode; 314652Sjkh/* 315652Sjkh * The least significant byte has the same format than the GUS .PAT 316652Sjkh * files 317652Sjkh */ 318652Sjkh#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ 319652Sjkh#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ 320652Sjkh#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ 321652Sjkh#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ 322652Sjkh#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ 323652Sjkh#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ 324652Sjkh#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ 325652Sjkh /* (use the env_rate/env_offs fields). */ 326652Sjkh/* Linux specific bits */ 327652Sjkh#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ 328652Sjkh#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ 329652Sjkh#define WAVE_SCALE 0x00040000 /* The scaling info is valid */ 330652Sjkh/* Other bits must be zeroed */ 331652Sjkh 33230866Smarkm long len; /* Size of the wave data in bytes */ 33330866Smarkm long loop_start, loop_end; /* Byte offsets from the beginning */ 334652Sjkh 3359750Sjkh/* 336652Sjkh * The base_freq and base_note fields are used when computing the 337652Sjkh * playback speed for a note. The base_note defines the tone frequency 338652Sjkh * which is heard if the sample is played using the base_freq as the 339652Sjkh * playback speed. 340652Sjkh * 341652Sjkh * The low_note and high_note fields define the minimum and maximum note 342652Sjkh * frequencies for which this sample is valid. It is possible to define 343652Sjkh * more than one samples for a instrument number at the same time. The 344652Sjkh * low_note and high_note fields are used to select the most suitable one. 345652Sjkh * 346652Sjkh * The fields base_note, high_note and low_note should contain 347652Sjkh * the note frequency multiplied by 1000. For example value for the 348652Sjkh * middle A is 440*1000. 349652Sjkh */ 350652Sjkh 35130866Smarkm u_int base_freq; 35230866Smarkm u_long base_note; 35330866Smarkm u_long high_note; 35430866Smarkm u_long low_note; 35530866Smarkm int panning; /* -128=left, 127=right */ 35630866Smarkm int detuning; 357652Sjkh 358652Sjkh/* New fields introduced in version 1.99.5 */ 359652Sjkh 360652Sjkh /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ 36130866Smarkm u_char env_rate[ 6 ]; /* GUS HW ramping rate */ 36230866Smarkm u_char env_offset[ 6 ]; /* 255 == 100% */ 363652Sjkh 3649750Sjkh /* 365652Sjkh * The tremolo, vibrato and scale info are not supported yet. 366652Sjkh * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or 367652Sjkh * WAVE_SCALE 368652Sjkh */ 369652Sjkh 37030866Smarkm u_char tremolo_sweep; 37130866Smarkm u_char tremolo_rate; 37230866Smarkm u_char tremolo_depth; 373652Sjkh 37430866Smarkm u_char vibrato_sweep; 37530866Smarkm u_char vibrato_rate; 37630866Smarkm u_char vibrato_depth; 37730866Smarkm 37830866Smarkm int scale_frequency; 37930866Smarkm u_int scale_factor; /* from 0 to 2048 or 0 to 2 */ 3809750Sjkh 38130866Smarkm int volume; 38230866Smarkm int spare[4]; 38330866Smarkm char data[1]; /* The waveform data starts here */ 38430866Smarkm}; 385652Sjkh 3863256Sswallacestruct sysex_info { 38730866Smarkm short key; /* Use GUS_PATCH here */ 38830866Smarkm#define SYSEX_PATCH _PATCHKEY(0x05) 38930866Smarkm#define MAUI_PATCH _PATCHKEY(0x06) 39030866Smarkm short device_no; /* Synthesizer number */ 39130866Smarkm long len; /* Size of the sysex data in bytes */ 39230866Smarkm u_char data[1]; /* Sysex data starts here */ 39330866Smarkm}; 3943256Sswallace 395652Sjkh/* 396652Sjkh * Patch management interface (/dev/sequencer, /dev/patmgr#) 397652Sjkh * Don't use these calls if you want to maintain compatibility with 398652Sjkh * the future versions of the driver. 399652Sjkh */ 400652Sjkh 40133473Sscrappy#define PS_NO_PATCHES 0 /* No patch support on device */ 40233473Sscrappy#define PS_MGR_NOT_OK 1 /* Plain patch support (no mgr) */ 40333473Sscrappy#define PS_MGR_OK 2 /* Patch manager supported */ 40433473Sscrappy#define PS_MANAGED 3 /* Patch manager running */ 405652Sjkh 406652Sjkh#define SNDCTL_PMGR_IFACE _IOWR('P', 1, struct patmgr_info) 407652Sjkh 408652Sjkh/* 409652Sjkh * The patmgr_info is a fixed size structure which is used for two 410652Sjkh * different purposes. The intended use is for communication between 411652Sjkh * the application using /dev/sequencer and the patch manager daemon 412652Sjkh * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)). 413652Sjkh * 414652Sjkh * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows 415652Sjkh * a patch manager daemon to read and write device parameters. This 416652Sjkh * ioctl available through /dev/sequencer also. Avoid using it since it's 4179750Sjkh * extremely hardware dependent. In addition access trough /dev/sequencer 418652Sjkh * may confuse the patch manager daemon. 419652Sjkh */ 420652Sjkh 421652Sjkhstruct patmgr_info { /* Note! size must be < 4k since kmalloc() is used */ 42230866Smarkm u_long key; /* Don't worry. Reserved for communication 423652Sjkh between the patch manager and the driver. */ 424652Sjkh#define PM_K_EVENT 1 /* Event from the /dev/sequencer driver */ 425652Sjkh#define PM_K_COMMAND 2 /* Request from a application */ 426652Sjkh#define PM_K_RESPONSE 3 /* From patmgr to application */ 427652Sjkh#define PM_ERROR 4 /* Error returned by the patmgr */ 428652Sjkh int device; 429652Sjkh int command; 430652Sjkh 4319750Sjkh/* 4329750Sjkh * Commands 0x000 to 0xfff reserved for patch manager programs 433652Sjkh */ 434652Sjkh#define PM_GET_DEVTYPE 1 /* Returns type of the patch mgr interface of dev */ 435652Sjkh#define PMTYPE_FM2 1 /* 2 OP fm */ 436652Sjkh#define PMTYPE_FM4 2 /* Mixed 4 or 2 op FM (OPL-3) */ 437652Sjkh#define PMTYPE_WAVE 3 /* Wave table synthesizer (GUS) */ 438652Sjkh#define PM_GET_NRPGM 2 /* Returns max # of midi programs in parm1 */ 439652Sjkh#define PM_GET_PGMMAP 3 /* Returns map of loaded midi programs in data8 */ 440652Sjkh#define PM_GET_PGM_PATCHES 4 /* Return list of patches of a program (parm1) */ 441652Sjkh#define PM_GET_PATCH 5 /* Return patch header of patch parm1 */ 442652Sjkh#define PM_SET_PATCH 6 /* Set patch header of patch parm1 */ 443652Sjkh#define PM_READ_PATCH 7 /* Read patch (wave) data */ 444652Sjkh#define PM_WRITE_PATCH 8 /* Write patch (wave) data */ 445652Sjkh 446652Sjkh/* 447652Sjkh * Commands 0x1000 to 0xffff are for communication between the patch manager 448652Sjkh * and the client 449652Sjkh */ 450652Sjkh#define _PM_LOAD_PATCH 0x100 451652Sjkh 4529750Sjkh/* 453652Sjkh * Commands above 0xffff reserved for device specific use 454652Sjkh */ 455652Sjkh 45630866Smarkm long parm1; 45730866Smarkm long parm2; 45830866Smarkm long parm3; 459652Sjkh 46030866Smarkm union { 46130866Smarkm u_char data8[4000]; 46230866Smarkm u_short data16[2000]; 46330866Smarkm u_long data32[1000]; 464652Sjkh struct patch_info patch; 46530866Smarkm } data; 46630866Smarkm}; 467652Sjkh 468652Sjkh/* 469652Sjkh * When a patch manager daemon is present, it will be informed by the 470652Sjkh * driver when something important happens. For example when the 471652Sjkh * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is 472652Sjkh * returned. The command field contains the event type: 473652Sjkh */ 474652Sjkh#define PM_E_OPENED 1 /* /dev/sequencer opened */ 475652Sjkh#define PM_E_CLOSED 2 /* /dev/sequencer closed */ 476652Sjkh#define PM_E_PATCH_RESET 3 /* SNDCTL_RESETSAMPLES called */ 477652Sjkh#define PM_E_PATCH_LOADED 4 /* A patch has been loaded by appl */ 478652Sjkh 479652Sjkh/* 480652Sjkh * /dev/sequencer input events. 481652Sjkh * 482652Sjkh * The data written to the /dev/sequencer is a stream of events. Events 4839750Sjkh * are records of 4 or 8 bytes. The first byte defines the size. 484652Sjkh * Any number of events can be written with a write call. There 485652Sjkh * is a set of macros for sending these events. Use these macros if you 486652Sjkh * want to maximize portability of your program. 487652Sjkh * 488652Sjkh * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. 489652Sjkh * (All input events are currently 4 bytes long. Be prepared to support 4903256Sswallace * 8 byte events also. If you receive any event having first byte >= 128, 491652Sjkh * it's a 8 byte event. 492652Sjkh * 493652Sjkh * The events are documented at the end of this file. 494652Sjkh * 495652Sjkh * Normal events (4 bytes) 496652Sjkh * There is also a 8 byte version of most of the 4 byte events. The 497652Sjkh * 8 byte one is recommended. 498652Sjkh */ 499652Sjkh#define SEQ_NOTEOFF 0 500652Sjkh#define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ 501652Sjkh#define SEQ_NOTEON 1 502652Sjkh#define SEQ_FMNOTEON SEQ_NOTEON 5033256Sswallace#define SEQ_WAIT TMR_WAIT_ABS 504652Sjkh#define SEQ_PGMCHANGE 3 505652Sjkh#define SEQ_FMPGMCHANGE SEQ_PGMCHANGE 5063256Sswallace#define SEQ_SYNCTIMER TMR_START 507652Sjkh#define SEQ_MIDIPUTC 5 508652Sjkh#define SEQ_DRUMON 6 /*** OBSOLETE ***/ 509652Sjkh#define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ 5103256Sswallace#define SEQ_ECHO TMR_ECHO /* For synching programs with output */ 511652Sjkh#define SEQ_AFTERTOUCH 9 512652Sjkh#define SEQ_CONTROLLER 10 5133256Sswallace 51433473Sscrappy/* 5153256Sswallace * Midi controller numbers 51633473Sscrappy * 51733473Sscrappy * Controllers 0 to 31 (0x00 to 0x1f) and 32 to 63 (0x20 to 0x3f) 51833473Sscrappy * are continuous controllers. 51933473Sscrappy * In the MIDI 1.0 these controllers are sent using two messages. 52033473Sscrappy * Controller numbers 0 to 31 are used to send the MSB and the 52133473Sscrappy * controller numbers 32 to 63 are for the LSB. Note that just 7 bits 52233473Sscrappy * are used in MIDI bytes. 5233256Sswallace */ 5243256Sswallace 52533473Sscrappy#define CTL_BANK_SELECT 0x00 52633473Sscrappy#define CTL_MODWHEEL 0x01 52733473Sscrappy#define CTL_BREATH 0x02 52833473Sscrappy/* undefined 0x03 */ 52933473Sscrappy#define CTL_FOOT 0x04 53033473Sscrappy#define CTL_PORTAMENTO_TIME 0x05 53133473Sscrappy#define CTL_DATA_ENTRY 0x06 53233473Sscrappy#define CTL_MAIN_VOLUME 0x07 53333473Sscrappy#define CTL_BALANCE 0x08 53433473Sscrappy/* undefined 0x09 */ 53533473Sscrappy#define CTL_PAN 0x0a 53633473Sscrappy#define CTL_EXPRESSION 0x0b 53733473Sscrappy/* undefined 0x0c - 0x0f */ 53833473Sscrappy#define CTL_GENERAL_PURPOSE1 0x10 53933473Sscrappy#define CTL_GENERAL_PURPOSE2 0x11 54033473Sscrappy#define CTL_GENERAL_PURPOSE3 0x12 54133473Sscrappy#define CTL_GENERAL_PURPOSE4 0x13 54233473Sscrappy/* undefined 0x14 - 0x1f */ 5433256Sswallace 54433473Sscrappy/* undefined 0x20 */ 5453256Sswallace 54633473Sscrappy/* 54733473Sscrappy * The controller numbers 0x21 to 0x3f are reserved for the 54833473Sscrappy * least significant bytes of the controllers 0x00 to 0x1f. 54933473Sscrappy * These controllers are not recognised by the driver. 55033473Sscrappy * 55133473Sscrappy * Controllers 64 to 69 (0x40 to 0x45) are on/off switches. 55233473Sscrappy * 0=OFF and 127=ON (intermediate values are possible) 55333473Sscrappy */ 55433473Sscrappy#define CTL_DAMPER_PEDAL 0x40 55533473Sscrappy#define CTL_SUSTAIN CTL_DAMPER_PEDAL /* Alias */ 55633473Sscrappy#define CTL_HOLD CTL_DAMPER_PEDAL /* Alias */ 55733473Sscrappy#define CTL_PORTAMENTO 0x41 55833473Sscrappy#define CTL_SOSTENUTO 0x42 55933473Sscrappy#define CTL_SOFT_PEDAL 0x43 56033473Sscrappy/* undefined 0x44 */ 56133473Sscrappy#define CTL_HOLD2 0x45 56233473Sscrappy/* undefined 0x46 - 0x4f */ 5633256Sswallace 56433473Sscrappy#define CTL_GENERAL_PURPOSE5 0x50 56533473Sscrappy#define CTL_GENERAL_PURPOSE6 0x51 56633473Sscrappy#define CTL_GENERAL_PURPOSE7 0x52 56733473Sscrappy#define CTL_GENERAL_PURPOSE8 0x53 56833473Sscrappy/* undefined 0x54 - 0x5a */ 56933473Sscrappy#define CTL_EXT_EFF_DEPTH 0x5b 57033473Sscrappy#define CTL_TREMOLO_DEPTH 0x5c 57133473Sscrappy#define CTL_CHORUS_DEPTH 0x5d 57233473Sscrappy#define CTL_DETUNE_DEPTH 0x5e 57333473Sscrappy#define CTL_CELESTE_DEPTH CTL_DETUNE_DEPTH /* Alias for the above one */ 57433473Sscrappy#define CTL_PHASER_DEPTH 0x5f 57533473Sscrappy#define CTL_DATA_INCREMENT 0x60 57633473Sscrappy#define CTL_DATA_DECREMENT 0x61 57733473Sscrappy#define CTL_NONREG_PARM_NUM_LSB 0x62 57833473Sscrappy#define CTL_NONREG_PARM_NUM_MSB 0x63 57933473Sscrappy#define CTL_REGIST_PARM_NUM_LSB 0x64 58033473Sscrappy#define CTL_REGIST_PARM_NUM_MSB 0x65 58133473Sscrappy/* undefined 0x66 - 0x78 */ 58233473Sscrappy/* reserved 0x79 - 0x7f */ 5833256Sswallace 5843256Sswallace/* Pseudo controllers (not midi compatible) */ 58533473Sscrappy#define CTRL_PITCH_BENDER 255 58633473Sscrappy#define CTRL_PITCH_BENDER_RANGE 254 58733473Sscrappy#define CTRL_EXPRESSION 253 /* Obsolete */ 58833473Sscrappy#define CTRL_MAIN_VOLUME 252 /* Obsolete */ 58933473Sscrappy 590652Sjkh#define SEQ_BALANCE 11 5911402Sache#define SEQ_VOLMODE 12 592652Sjkh 593652Sjkh/* 5941402Sache * Volume mode decides how volumes are used 5951402Sache */ 5961402Sache 5971402Sache#define VOL_METHOD_ADAGIO 1 5981402Sache#define VOL_METHOD_LINEAR 2 5991402Sache 6001402Sache/* 601652Sjkh * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as 602652Sjkh * input events. 603652Sjkh */ 604652Sjkh 605652Sjkh/* 606652Sjkh * Event codes 0xf0 to 0xfc are reserved for future extensions. 607652Sjkh */ 608652Sjkh 609652Sjkh#define SEQ_FULLSIZE 0xfd /* Long events */ 610652Sjkh/* 61133473Sscrappy * SEQ_FULLSIZE events are used for loading patches/samples to the 61233473Sscrappy * synthesizer devices. These events are passed directly to the driver 61333473Sscrappy * of the associated synthesizer device. There is no limit to the size 61433473Sscrappy * of the extended events. These events are not queued but executed 61533473Sscrappy * immediately when the write() is called (execution can take several 61633473Sscrappy * seconds of time). 617652Sjkh * 61833473Sscrappy * When a SEQ_FULLSIZE message is written to the device, it must 61933473Sscrappy * be written using exactly one write() call. Other events cannot 62033473Sscrappy * be mixed to the same write. 62133473Sscrappy * 62233473Sscrappy * For FM synths (YM3812/OPL3) use struct sbi_instrument and write 62333473Sscrappy * it to the /dev/sequencer. Don't write other data together with 62433473Sscrappy * the instrument structure Set the key field of the structure to 62533473Sscrappy * FM_PATCH. The device field is used to route the patch to the 62633473Sscrappy * corresponding device. 627652Sjkh * 62833473Sscrappy * For Gravis UltraSound use struct patch_info. Initialize the key field 62933473Sscrappy * to GUS_PATCH. 630652Sjkh */ 63133473Sscrappy#define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ 63233473Sscrappy#define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */ 633652Sjkh 634652Sjkh/* 635652Sjkh * Record for FM patches 636652Sjkh */ 637652Sjkh 63830866Smarkmtypedef u_char sbi_instr_data[32]; 639652Sjkh 640652Sjkhstruct sbi_instrument { 64130866Smarkm u_short key; /* FM_PATCH or OPL3_PATCH */ 64230866Smarkm#define FM_PATCH _PATCHKEY(0x01) 64330866Smarkm#define OPL3_PATCH _PATCHKEY(0x03) 64430866Smarkm short device; /* Synth# (0-4) */ 64530866Smarkm int channel; /* Program# to be initialized */ 64630866Smarkm sbi_instr_data operators; /* Reg. settings for operator cells 64730866Smarkm * (.SBI format) */ 64830866Smarkm}; 649652Sjkh 650652Sjkhstruct synth_info { /* Read only */ 65130866Smarkm char name[30]; 65230866Smarkm int device; /* 0-N. INITIALIZE BEFORE CALLING */ 65330866Smarkm int synth_type; 654652Sjkh#define SYNTH_TYPE_FM 0 655652Sjkh#define SYNTH_TYPE_SAMPLE 1 6563256Sswallace#define SYNTH_TYPE_MIDI 2 /* Midi interface */ 657652Sjkh 65830866Smarkm int synth_subtype; 659652Sjkh#define FM_TYPE_ADLIB 0x00 660652Sjkh#define FM_TYPE_OPL3 0x01 661652Sjkh 66233473Sscrappy#define SAMPLE_TYPE_BASIC 0x10 66333473Sscrappy#define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC 66433530Sscrappy#define SAMPLE_TYPE_AWE32 0x20 665652Sjkh 66630866Smarkm int perc_mode; /* No longer supported */ 66730866Smarkm int nr_voices; 66830866Smarkm int nr_drums; /* Obsolete field */ 66930866Smarkm int instr_bank_size; 67030866Smarkm u_long capabilities; 67133473Sscrappy#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ 67233473Sscrappy#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ 67333473Sscrappy#define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */ 67430866Smarkm int dummies[19]; /* Reserve space */ 67530866Smarkm}; 676652Sjkh 6773256Sswallacestruct sound_timer_info { 67830866Smarkm char name[32]; 67930866Smarkm int caps; 68030866Smarkm}; 6813256Sswallace 6823256Sswallace#define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */ 6833256Sswallace 684652Sjkhstruct midi_info { 68530866Smarkm char name[30]; 68630866Smarkm int device; /* 0-N. INITIALIZE BEFORE CALLING */ 68730866Smarkm u_long capabilities; /* To be defined later */ 68830866Smarkm int dev_type; 68930866Smarkm int dummies[18]; /* Reserve space */ 69030866Smarkm}; 691652Sjkh 69233473Sscrappy/* 6933256Sswallace * ioctl commands for the /dev/midi## 6943256Sswallace */ 6953256Sswallacetypedef struct { 69630866Smarkm u_char cmd; 69730866Smarkm char nr_args, nr_returns; 69830866Smarkm u_char data[30]; 69930866Smarkm} mpu_command_rec; 7003256Sswallace 70133473Sscrappy#define SNDCTL_MIDI_PRETIME _IOWR('m', 0, int) 70233473Sscrappy#define SNDCTL_MIDI_MPUMODE _IOWR('m', 1, int) 70333473Sscrappy#define SNDCTL_MIDI_MPUCMD _IOWR('m', 2, mpu_command_rec) 7043256Sswallace 70533473Sscrappy/* 706652Sjkh * IOCTL commands for /dev/dsp and /dev/audio 707652Sjkh */ 708652Sjkh 70933473Sscrappy#define SNDCTL_DSP_RESET _IO ('P', 0) 71033473Sscrappy#define SNDCTL_DSP_SYNC _IO ('P', 1) 71133473Sscrappy#define SNDCTL_DSP_SPEED _IOWR('P', 2, int) 71233473Sscrappy#define SNDCTL_DSP_STEREO _IOWR('P', 3, int) 71333473Sscrappy#define SNDCTL_DSP_GETBLKSIZE _IOR('P', 4, int) 71433473Sscrappy#define SNDCTL_DSP_SETBLKSIZE _IOW('P', 4, int) 71533473Sscrappy#define SNDCTL_DSP_SETFMT _IOWR('P',5, int) /* Selects ONE fmt*/ 71633473Sscrappy 71733473Sscrappy/* 71833473Sscrappy * SOUND_PCM_WRITE_CHANNELS is not that different 71933473Sscrappy * from SNDCTL_DSP_STEREO 72033473Sscrappy */ 721652Sjkh#define SOUND_PCM_WRITE_CHANNELS _IOWR('P', 6, int) 72233473Sscrappy#define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int) 72333473Sscrappy#define SNDCTL_DSP_POST _IO ('P', 8) 724652Sjkh 72533473Sscrappy/* 72633473Sscrappy * SNDCTL_DSP_SETBLKSIZE and the following two calls mostly do 72733473Sscrappy * the same thing, i.e. set the block size used in DMA transfers. 72833473Sscrappy */ 72933473Sscrappy#define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int) 73033473Sscrappy#define SNDCTL_DSP_SETFRAGMENT _IOWR('P',10, int) 73130866Smarkm 7323256Sswallace 73333473Sscrappy#define SNDCTL_DSP_GETFMTS _IOR ('P',11, int) /* Returns a mask */ 7349750Sjkh/* 7359750Sjkh * Buffer status queries. 7369750Sjkh */ 7379750Sjkhtypedef struct audio_buf_info { 73833473Sscrappy int fragments; /* # of avail. frags (partly used ones not counted) */ 73933473Sscrappy int fragstotal; /* Total # of fragments allocated */ 74033473Sscrappy int fragsize; /* Size of a fragment in bytes */ 7419750Sjkh 74233473Sscrappy int bytes; /* Avail. space in bytes (includes partly used fragments) */ 74333473Sscrappy /* Note! 'bytes' could be more than fragments*fragsize */ 74430866Smarkm} audio_buf_info; 7459750Sjkh 74633473Sscrappy#define SNDCTL_DSP_GETOSPACE _IOR ('P',12, audio_buf_info) 74733473Sscrappy#define SNDCTL_DSP_GETISPACE _IOR ('P',13, audio_buf_info) 7489750Sjkh 74933473Sscrappy/* 75033473Sscrappy * SNDCTL_DSP_NONBLOCK is the same (but less powerful, since the 75133473Sscrappy * action cannot be undone) of FIONBIO. The same can be achieved 75233473Sscrappy * by opening the device with O_NDELAY 75333473Sscrappy */ 75433473Sscrappy#define SNDCTL_DSP_NONBLOCK _IO ('P',14) 75530866Smarkm 75633473Sscrappy#define SNDCTL_DSP_GETCAPS _IOR ('P',15, int) 75733473Sscrappy#define DSP_CAP_REVISION 0x000000ff /* revision level (0 to 255) */ 75833473Sscrappy#define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */ 75933473Sscrappy#define DSP_CAP_REALTIME 0x00000200 /* Real time capability */ 76033473Sscrappy#define DSP_CAP_BATCH 0x00000400 76133473Sscrappy /* 76233473Sscrappy * Device has some kind of internal buffers which may 76333473Sscrappy * cause some delays and decrease precision of timing 76433473Sscrappy */ 76533473Sscrappy#define DSP_CAP_COPROC 0x00000800 76633473Sscrappy /* Has a coprocessor, sometimes it's a DSP but usually not */ 76733473Sscrappy#define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */ 76833530Sscrappy#define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */ 76930866Smarkm 77033473Sscrappy/* 77133473Sscrappy * What do these function do ? 77233473Sscrappy */ 77333473Sscrappy#define SNDCTL_DSP_GETTRIGGER _IOR ('P',16, int) 77433473Sscrappy#define SNDCTL_DSP_SETTRIGGER _IOW ('P',16, int) 77533473Sscrappy#define PCM_ENABLE_INPUT 0x00000001 77630866Smarkm#define PCM_ENABLE_OUTPUT 0x00000002 77730866Smarkm 77830866Smarkmtypedef struct count_info { 77930866Smarkm int bytes; /* Total # of bytes processed */ 78030866Smarkm int blocks; /* # of fragment transitions since last time */ 78130866Smarkm int ptr; /* Current DMA pointer value */ 78230866Smarkm} count_info; 78330866Smarkm 78433473Sscrappy/* 78533473Sscrappy * GETIPTR and GETISPACE are not that different... same for out. 78633473Sscrappy */ 78733473Sscrappy#define SNDCTL_DSP_GETIPTR _IOR ('P',17, count_info) 78833473Sscrappy#define SNDCTL_DSP_GETOPTR _IOR ('P',18, count_info) 78930866Smarkm 79030866Smarkmtypedef struct buffmem_desc { 79130866Smarkm caddr_t buffer; 79230866Smarkm int size; 79330866Smarkm} buffmem_desc; 79430866Smarkm 79533473Sscrappy#define SNDCTL_DSP_MAPINBUF _IOR ('P', 19, buffmem_desc) 79633473Sscrappy#define SNDCTL_DSP_MAPOUTBUF _IOR ('P', 20, buffmem_desc) 79733473Sscrappy#define SNDCTL_DSP_SETSYNCRO _IO ('P', 21) 79830866Smarkm 79933473Sscrappy/* 80033473Sscrappy * I guess these are the readonly version of the same 80133473Sscrappy * functions that exist above as SNDCTL_DSP_... 80233473Sscrappy */ 80333473Sscrappy#define SOUND_PCM_READ_RATE _IOR ('P', 2, int) 80433473Sscrappy#define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int) 80533473Sscrappy#define SOUND_PCM_READ_BITS _IOR ('P', 5, int) 80633473Sscrappy#define SOUND_PCM_READ_FILTER _IOR ('P', 7, int) 807652Sjkh 8089750Sjkh/* 8099750Sjkh * ioctl calls to be used in communication with coprocessors and 8109750Sjkh * DSP chips. 8113256Sswallace */ 8123256Sswallace 8139750Sjkhtypedef struct copr_buffer { 81430866Smarkm int command; /* Set to 0 if not used */ 81530866Smarkm int flags; 8169750Sjkh#define CPF_NONE 0x0000 8179750Sjkh#define CPF_FIRST 0x0001 /* First block */ 8189750Sjkh#define CPF_LAST 0x0002 /* Last block */ 81930866Smarkm int len; 82030866Smarkm int offs; /* If required by the device (0 if not used) */ 8213256Sswallace 82230866Smarkm u_char data[4000]; /* NOTE! 4000 is not 4k */ 82330866Smarkm} copr_buffer; 8249750Sjkh 8259750Sjkhtypedef struct copr_debug_buf { 82630866Smarkm int command; /* Used internally. Set to 0 */ 82730866Smarkm int parm1; 82830866Smarkm int parm2; 82930866Smarkm int flags; 83030866Smarkm int len; /* Length of data in bytes */ 83130866Smarkm} copr_debug_buf; 8329750Sjkh 8339750Sjkhtypedef struct copr_msg { 83430866Smarkm int len; 83530866Smarkm u_char data[4000]; 83630866Smarkm} copr_msg; 8379750Sjkh 83833473Sscrappy#define SNDCTL_COPR_RESET _IO ('C', 0) 83933473Sscrappy#define SNDCTL_COPR_LOAD _IOWR('C', 1, copr_buffer) 84033473Sscrappy#define SNDCTL_COPR_RDATA _IOWR('C', 2, copr_debug_buf) 84133473Sscrappy#define SNDCTL_COPR_RCODE _IOWR('C', 3, copr_debug_buf) 84233473Sscrappy#define SNDCTL_COPR_WDATA _IOW ('C', 4, copr_debug_buf) 84333473Sscrappy#define SNDCTL_COPR_WCODE _IOW ('C', 5, copr_debug_buf) 84433473Sscrappy#define SNDCTL_COPR_RUN _IOWR('C', 6, copr_debug_buf) 84533473Sscrappy#define SNDCTL_COPR_HALT _IOWR('C', 7, copr_debug_buf) 84633473Sscrappy#define SNDCTL_COPR_SENDMSG _IOW ('C', 8, copr_msg) 84733473Sscrappy#define SNDCTL_COPR_RCVMSG _IOR ('C', 9, copr_msg) 8489750Sjkh 84933473Sscrappy/* 850652Sjkh * IOCTL commands for /dev/mixer 851652Sjkh */ 8529750Sjkh 8539750Sjkh/* 854652Sjkh * Mixer devices 855652Sjkh * 856652Sjkh * There can be up to 20 different analog mixer channels. The 8579750Sjkh * SOUND_MIXER_NRDEVICES gives the currently supported maximum. 858652Sjkh * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells 859652Sjkh * the devices supported by the particular mixer. 860652Sjkh */ 861652Sjkh 86233473Sscrappy#define SOUND_MIXER_NRDEVICES 25 863652Sjkh#define SOUND_MIXER_VOLUME 0 864652Sjkh#define SOUND_MIXER_BASS 1 865652Sjkh#define SOUND_MIXER_TREBLE 2 866652Sjkh#define SOUND_MIXER_SYNTH 3 867652Sjkh#define SOUND_MIXER_PCM 4 868652Sjkh#define SOUND_MIXER_SPEAKER 5 869652Sjkh#define SOUND_MIXER_LINE 6 870652Sjkh#define SOUND_MIXER_MIC 7 871652Sjkh#define SOUND_MIXER_CD 8 872652Sjkh#define SOUND_MIXER_IMIX 9 /* Recording monitor */ 873652Sjkh#define SOUND_MIXER_ALTPCM 10 874652Sjkh#define SOUND_MIXER_RECLEV 11 /* Recording level */ 8759750Sjkh#define SOUND_MIXER_IGAIN 12 /* Input gain */ 8769750Sjkh#define SOUND_MIXER_OGAIN 13 /* Output gain */ 8779750Sjkh/* 8789750Sjkh * The AD1848 codec and compatibles have three line level inputs 8799750Sjkh * (line, aux1 and aux2). Since each card manufacturer have assigned 88030866Smarkm * different meanings to these inputs, it's inpractical to assign 8819750Sjkh * specific meanings (line, cd, synth etc.) to them. 8829750Sjkh */ 8839750Sjkh#define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */ 8849750Sjkh#define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */ 8859750Sjkh#define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */ 88633473Sscrappy#define SOUND_MIXER_DIGITAL1 17 /* Digital (input) 1 */ 88733473Sscrappy#define SOUND_MIXER_DIGITAL2 18 /* Digital (input) 2 */ 88833473Sscrappy#define SOUND_MIXER_DIGITAL3 19 /* Digital (input) 3 */ 88933473Sscrappy#define SOUND_MIXER_PHONEIN 20 /* Phone input */ 89033473Sscrappy#define SOUND_MIXER_PHONEOUT 21 /* Phone output */ 89133473Sscrappy#define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */ 89233473Sscrappy#define SOUND_MIXER_RADIO 23 /* Radio in */ 89333473Sscrappy#define SOUND_MIXER_MONITOR 24 /* Monitor (usually mic) volume */ 894652Sjkh 89533473Sscrappy 89633473Sscrappy/* 89733473Sscrappy * Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) 89833473Sscrappy * Not counted to SOUND_MIXER_NRDEVICES, but use the same number space 89933473Sscrappy */ 900652Sjkh#define SOUND_ONOFF_MIN 28 901652Sjkh#define SOUND_ONOFF_MAX 30 902652Sjkh#define SOUND_MIXER_MUTE 28 /* 0 or 1 */ 903652Sjkh#define SOUND_MIXER_ENHANCE 29 /* Enhanced stereo (0, 40, 60 or 80) */ 904652Sjkh#define SOUND_MIXER_LOUD 30 /* 0 or 1 */ 905652Sjkh 906652Sjkh/* Note! Number 31 cannot be used since the sign bit is reserved */ 90733473Sscrappy#define SOUND_MIXER_NONE 31 908652Sjkh 90930866Smarkm#define SOUND_DEVICE_LABELS { \ 91030866Smarkm "Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ 91133473Sscrappy "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \ 91233473Sscrappy "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \ 91333473Sscrappy "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"} 914652Sjkh 91530866Smarkm#define SOUND_DEVICE_NAMES { \ 91630866Smarkm "vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ 91730866Smarkm "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \ 91833473Sscrappy "line1", "line2", "line3", "dig1", "dig2", "dig3", \ 91933473Sscrappy "phin", "phout", "video", "radio", "monitor"} 920652Sjkh 921652Sjkh/* Device bitmask identifiers */ 922652Sjkh 92330866Smarkm#define SOUND_MIXER_RECSRC 0xff /* 1 bit per recording source */ 92430866Smarkm#define SOUND_MIXER_DEVMASK 0xfe /* 1 bit per supported device */ 92530866Smarkm#define SOUND_MIXER_RECMASK 0xfd /* 1 bit per supp. recording source */ 926652Sjkh#define SOUND_MIXER_CAPS 0xfc 92730866Smarkm#define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only 1 rec. src at a time */ 928652Sjkh#define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ 929652Sjkh 930652Sjkh/* Device mask bits */ 931652Sjkh 932652Sjkh#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) 933652Sjkh#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) 934652Sjkh#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) 935652Sjkh#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) 936652Sjkh#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) 937652Sjkh#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) 938652Sjkh#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) 939652Sjkh#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) 940652Sjkh#define SOUND_MASK_CD (1 << SOUND_MIXER_CD) 941652Sjkh#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) 942652Sjkh#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) 943652Sjkh#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) 9449750Sjkh#define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN) 9459750Sjkh#define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN) 9469750Sjkh#define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1) 9479750Sjkh#define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2) 9489750Sjkh#define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3) 94933473Sscrappy#define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1) 95033473Sscrappy#define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2) 95133473Sscrappy#define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3) 95233473Sscrappy#define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN) 95333473Sscrappy#define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT) 95433473Sscrappy#define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO) 95533473Sscrappy#define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO) 95633473Sscrappy#define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR) 957652Sjkh 95833473Sscrappy/* Obsolete macros */ 959652Sjkh#define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) 960652Sjkh#define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) 961652Sjkh#define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) 962652Sjkh 963652Sjkh#define MIXER_READ(dev) _IOR('M', dev, int) 964652Sjkh#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) 965652Sjkh#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) 966652Sjkh#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) 967652Sjkh#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) 968652Sjkh#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) 969652Sjkh#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) 970652Sjkh#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) 971652Sjkh#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) 972652Sjkh#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) 973652Sjkh#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) 974652Sjkh#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) 975652Sjkh#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) 9769750Sjkh#define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN) 9779750Sjkh#define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN) 9789750Sjkh#define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1) 9799750Sjkh#define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2) 9809750Sjkh#define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3) 98133473Sscrappy 98233473Sscrappy/* Obsolete macros */ 983652Sjkh#define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) 984652Sjkh#define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) 985652Sjkh#define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) 986652Sjkh 987652Sjkh#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) 988652Sjkh#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) 989652Sjkh#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) 990652Sjkh#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) 991652Sjkh#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) 992652Sjkh 993652Sjkh#define MIXER_WRITE(dev) _IOWR('M', dev, int) 994652Sjkh#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) 995652Sjkh#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) 996652Sjkh#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) 997652Sjkh#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) 998652Sjkh#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) 999652Sjkh#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) 1000652Sjkh#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) 1001652Sjkh#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) 1002652Sjkh#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) 1003652Sjkh#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) 1004652Sjkh#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) 1005652Sjkh#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) 10069750Sjkh#define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN) 10079750Sjkh#define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN) 10089750Sjkh#define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1) 10099750Sjkh#define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2) 10109750Sjkh#define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3) 1011652Sjkh#define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) 1012652Sjkh#define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) 1013652Sjkh#define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) 1014652Sjkh 1015652Sjkh#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) 1016652Sjkh 101733473Sscrappy#define LEFT_CHN 0 101833473Sscrappy#define RIGHT_CHN 1 101933473Sscrappy 1020652Sjkh/* 10213256Sswallace * Level 2 event types for /dev/sequencer 10223256Sswallace */ 10233256Sswallace 10243256Sswallace/* 10253256Sswallace * The 4 most significant bits of byte 0 specify the class of 10269750Sjkh * the event: 1027652Sjkh * 10283256Sswallace * 0x8X = system level events, 10293256Sswallace * 0x9X = device/port specific events, event[1] = device/port, 10303256Sswallace * The last 4 bits give the subtype: 10313256Sswallace * 0x02 = Channel event (event[3] = chn). 10323256Sswallace * 0x01 = note event (event[4] = note). 10333256Sswallace * (0x01 is not used alone but always with bit 0x02). 10343256Sswallace * event[2] = MIDI message code (0x80=note off etc.) 10353256Sswallace * 1036652Sjkh */ 1037652Sjkh 10383256Sswallace#define EV_SEQ_LOCAL 0x80 10393256Sswallace#define EV_TIMING 0x81 10403256Sswallace#define EV_CHN_COMMON 0x92 10413256Sswallace#define EV_CHN_VOICE 0x93 104230866Smarkm#define EV_SYSEX 0x94 10433256Sswallace/* 10443256Sswallace * Event types 200 to 220 are reserved for application use. 10453256Sswallace * These numbers will not be used by the driver. 10463256Sswallace */ 1047652Sjkh 1048652Sjkh/* 10493256Sswallace * Events for event type EV_CHN_VOICE 1050652Sjkh */ 1051652Sjkh 10523256Sswallace#define MIDI_NOTEOFF 0x80 10533256Sswallace#define MIDI_NOTEON 0x90 10543256Sswallace#define MIDI_KEY_PRESSURE 0xA0 10553256Sswallace 1056652Sjkh/* 10573256Sswallace * Events for event type EV_CHN_COMMON 1058652Sjkh */ 1059652Sjkh 10603256Sswallace#define MIDI_CTL_CHANGE 0xB0 10613256Sswallace#define MIDI_PGM_CHANGE 0xC0 10623256Sswallace#define MIDI_CHN_PRESSURE 0xD0 10633256Sswallace#define MIDI_PITCH_BEND 0xE0 1064652Sjkh 10653256Sswallace#define MIDI_SYSTEM_PREFIX 0xF0 10663256Sswallace 1067652Sjkh/* 10683256Sswallace * Timer event types 10693256Sswallace */ 10703256Sswallace#define TMR_WAIT_REL 1 /* Time relative to the prev time */ 10713256Sswallace#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */ 10723256Sswallace#define TMR_STOP 3 10733256Sswallace#define TMR_START 4 10743256Sswallace#define TMR_CONTINUE 5 10753256Sswallace#define TMR_TEMPO 6 10763256Sswallace#define TMR_ECHO 8 10773256Sswallace#define TMR_CLOCK 9 /* MIDI clock */ 10783256Sswallace#define TMR_SPP 10 /* Song position pointer */ 10793256Sswallace#define TMR_TIMESIG 11 /* Time signature */ 10803256Sswallace 108130866Smarkm/* 108230866Smarkm * Local event types 108330866Smarkm */ 108430866Smarkm#define LOCL_STARTAUDIO 1 108530866Smarkm 10869750Sjkh#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS) 10873256Sswallace/* 1088652Sjkh * Some convenience macros to simplify programming of the 1089652Sjkh * /dev/sequencer interface 1090652Sjkh * 1091652Sjkh * These macros define the API which should be used when possible. 1092652Sjkh */ 1093652Sjkh 10943256Sswallace#ifndef USE_SIMPLE_MACROS 109533473Sscrappyvoid seqbuf_dump(void); /* This function must be provided by programs */ 1096652Sjkh 1097652Sjkh/* Sample seqbuf_dump() implementation: 1098652Sjkh * 1099652Sjkh * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes 1100652Sjkh * 1101652Sjkh * int seqfd; -- The file descriptor for /dev/sequencer. 1102652Sjkh * 1103652Sjkh * void 1104652Sjkh * seqbuf_dump () 1105652Sjkh * { 1106652Sjkh * if (_seqbufptr) 1107652Sjkh * if (write (seqfd, _seqbuf, _seqbufptr) == -1) 1108652Sjkh * { 1109652Sjkh * perror ("write /dev/sequencer"); 1110652Sjkh * exit (-1); 1111652Sjkh * } 1112652Sjkh * _seqbufptr = 0; 1113652Sjkh * } 1114652Sjkh */ 1115652Sjkh 111630866Smarkm#define SEQ_DEFINEBUF(len) \ 111730866Smarkm u_char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0 111830866Smarkm#define SEQ_USE_EXTBUF() \ 111930866Smarkm extern u_char _seqbuf[]; \ 112030866Smarkm extern int _seqbuflen;extern int _seqbufptr 11213256Sswallace#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF() 1122652Sjkh#define SEQ_PM_DEFINES struct patmgr_info _pm_info 112330866Smarkm#define _SEQ_NEEDBUF(len) \ 112430866Smarkm if ((_seqbufptr+(len)) > _seqbuflen) \ 112530866Smarkm seqbuf_dump() 1126652Sjkh#define _SEQ_ADVBUF(len) _seqbufptr += len 1127652Sjkh#define SEQ_DUMPBUF seqbuf_dump 11283256Sswallace#else 11293256Sswallace/* 11303256Sswallace * This variation of the sequencer macros is used just to format one event 11313256Sswallace * using fixed buffer. 11329750Sjkh * 11333256Sswallace * The program using the macro library must define the following macros before 11343256Sswallace * using this library. 11353256Sswallace * 113630866Smarkm * #define _seqbuf name of the buffer (u_char[]) 11373256Sswallace * #define _SEQ_ADVBUF(len) If the applic needs to know the exact 11383256Sswallace * size of the event, this macro can be used. 11393256Sswallace * Otherwise this must be defined as empty. 11403256Sswallace * #define _seqbufptr Define the name of index variable or 0 if 11419750Sjkh * not required. 11423256Sswallace */ 11433256Sswallace#define _SEQ_NEEDBUF(len) /* empty */ 11443256Sswallace#endif 11453256Sswallace 114630866Smarkm#define PM_LOAD_PATCH(dev, bank, pgm) \ 114730866Smarkm (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ 114830866Smarkm _pm_info.device=dev, _pm_info.data.data8[0]=pgm, \ 114930866Smarkm _pm_info.parm1 = bank, _pm_info.parm2 = 1, \ 115030866Smarkm ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) 115130866Smarkm#define PM_LOAD_PATCHES(dev, bank, pgm) \ 115230866Smarkm (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ 115330866Smarkm _pm_info.device=dev, bcopy( pgm, _pm_info.data.data8, 128), \ 115430866Smarkm _pm_info.parm1 = bank, _pm_info.parm2 = 128, \ 115530866Smarkm ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) 1156652Sjkh 115730866Smarkm#define SEQ_VOLUME_MODE(dev, mode) { \ 115830866Smarkm _SEQ_NEEDBUF(8);\ 115930866Smarkm _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 116030866Smarkm _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\ 116130866Smarkm _seqbuf[_seqbufptr+2] = (dev);\ 116230866Smarkm _seqbuf[_seqbufptr+3] = (mode);\ 116330866Smarkm _seqbuf[_seqbufptr+4] = 0;\ 116430866Smarkm _seqbuf[_seqbufptr+5] = 0;\ 116530866Smarkm _seqbuf[_seqbufptr+6] = 0;\ 116630866Smarkm _seqbuf[_seqbufptr+7] = 0;\ 116730866Smarkm _SEQ_ADVBUF(8);} 11681402Sache 11693256Sswallace/* 11703256Sswallace * Midi voice messages 11713256Sswallace */ 1172652Sjkh 117330866Smarkm#define _CHN_VOICE(dev, event, chn, note, parm) { \ 117430866Smarkm _SEQ_NEEDBUF(8);\ 117530866Smarkm _seqbuf[_seqbufptr] = EV_CHN_VOICE;\ 117630866Smarkm _seqbuf[_seqbufptr+1] = (dev);\ 117730866Smarkm _seqbuf[_seqbufptr+2] = (event);\ 117830866Smarkm _seqbuf[_seqbufptr+3] = (chn);\ 117930866Smarkm _seqbuf[_seqbufptr+4] = (note);\ 118030866Smarkm _seqbuf[_seqbufptr+5] = (parm);\ 118130866Smarkm _seqbuf[_seqbufptr+6] = (0);\ 118230866Smarkm _seqbuf[_seqbufptr+7] = 0;\ 118330866Smarkm _SEQ_ADVBUF(8);} 1184652Sjkh 11853256Sswallace#define SEQ_START_NOTE(dev, chn, note, vol) \ 11863256Sswallace _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol) 11873256Sswallace 11883256Sswallace#define SEQ_STOP_NOTE(dev, chn, note, vol) \ 11893256Sswallace _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol) 11903256Sswallace 11913256Sswallace#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \ 11923256Sswallace _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure) 11933256Sswallace 11943256Sswallace/* 11953256Sswallace * Midi channel messages 11963256Sswallace */ 11973256Sswallace 119830866Smarkm#define _CHN_COMMON(dev, event, chn, p1, p2, w14) { \ 119930866Smarkm _SEQ_NEEDBUF(8);\ 120030866Smarkm _seqbuf[_seqbufptr] = EV_CHN_COMMON;\ 120130866Smarkm _seqbuf[_seqbufptr+1] = (dev);\ 120230866Smarkm _seqbuf[_seqbufptr+2] = (event);\ 120330866Smarkm _seqbuf[_seqbufptr+3] = (chn);\ 120430866Smarkm _seqbuf[_seqbufptr+4] = (p1);\ 120530866Smarkm _seqbuf[_seqbufptr+5] = (p2);\ 120630866Smarkm *(short *)&_seqbuf[_seqbufptr+6] = (w14);\ 120730866Smarkm _SEQ_ADVBUF(8);} 120830866Smarkm/* 120930866Smarkm * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits 121030866Smarkm * sending any MIDI bytes but it's absolutely not possible. Trying to do 121130866Smarkm * so _will_ cause problems with MPU401 intelligent mode). 121230866Smarkm * 121330866Smarkm * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be 121430866Smarkm * sent by calling SEQ_SYSEX() several times (there must be no other events 121530866Smarkm * between them). First sysex fragment must have 0xf0 in the first byte 121630866Smarkm * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte 121730866Smarkm * between these sysex start and end markers cannot be larger than 0x7f. Also 121830866Smarkm * lengths of each fragments (except the last one) must be 6. 121930866Smarkm * 122030866Smarkm * Breaking the above rules may work with some MIDI ports but is likely to 122130866Smarkm * cause fatal problems with some other devices (such as MPU401). 122230866Smarkm */ 122330866Smarkm#define SEQ_SYSEX(dev, buf, len) { \ 122430866Smarkm int i, l=(len); if (l>6)l=6;\ 122530866Smarkm _SEQ_NEEDBUF(8);\ 122630866Smarkm _seqbuf[_seqbufptr] = EV_SYSEX;\ 122730866Smarkm for(i=0;i<l;i++)_seqbuf[_seqbufptr+i+1] = (buf)[i];\ 122830866Smarkm for(i=l;i<6;i++)_seqbuf[_seqbufptr+i+1] = 0xff;\ 122930866Smarkm _SEQ_ADVBUF(8);} 1230652Sjkh 12313256Sswallace#define SEQ_CHN_PRESSURE(dev, chn, pressure) \ 123230866Smarkm _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0) 12333256Sswallace 12343256Sswallace#define SEQ_SET_PATCH(dev, chn, patch) \ 123530866Smarkm _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0) 12363256Sswallace 12373256Sswallace#define SEQ_CONTROL(dev, chn, controller, value) \ 123830866Smarkm _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value) 12393256Sswallace 12403256Sswallace#define SEQ_BENDER(dev, chn, value) \ 124130866Smarkm _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value) 12423256Sswallace 12439750Sjkh 124430866Smarkm#define SEQ_V2_X_CONTROL(dev, voice, controller, value) { \ 124530866Smarkm _SEQ_NEEDBUF(8);\ 124630866Smarkm _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 124730866Smarkm _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\ 124830866Smarkm _seqbuf[_seqbufptr+2] = (dev);\ 124930866Smarkm _seqbuf[_seqbufptr+3] = (voice);\ 125030866Smarkm _seqbuf[_seqbufptr+4] = (controller);\ 125130866Smarkm *(short *)&_seqbuf[_seqbufptr+5] = (value);\ 125230866Smarkm _seqbuf[_seqbufptr+7] = 0;\ 125330866Smarkm _SEQ_ADVBUF(8);} 125430866Smarkm 12553256Sswallace/* 12563256Sswallace * The following 5 macros are incorrectly implemented and obsolete. 12573256Sswallace * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead. 12583256Sswallace */ 1259652Sjkh 126030866Smarkm#define SEQ_PITCHBEND(dev, voice, value) \ 126130866Smarkm SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value) 126230866Smarkm#define SEQ_BENDER_RANGE(dev, voice, value) \ 126330866Smarkm SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value) 126430866Smarkm#define SEQ_EXPRESSION(dev, voice, value) \ 126530866Smarkm SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128) 126630866Smarkm#define SEQ_MAIN_VOLUME(dev, voice, value) \ 126730866Smarkm SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100) 126830866Smarkm#define SEQ_PANNING(dev, voice, pos) \ 126930866Smarkm SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2) 127030866Smarkm 12713256Sswallace/* 127230866Smarkm * Timing and syncronization macros 12733256Sswallace */ 1274652Sjkh 127530866Smarkm#define _TIMER_EVENT(ev, parm) { \ 127630866Smarkm _SEQ_NEEDBUF(8);\ 127730866Smarkm _seqbuf[_seqbufptr+0] = EV_TIMING; \ 127830866Smarkm _seqbuf[_seqbufptr+1] = (ev); \ 127930866Smarkm _seqbuf[_seqbufptr+2] = 0;\ 128030866Smarkm _seqbuf[_seqbufptr+3] = 0;\ 128130866Smarkm *(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \ 128230866Smarkm _SEQ_ADVBUF(8); \ 128330866Smarkm } 1284652Sjkh 12853256Sswallace#define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0) 12863256Sswallace#define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0) 12873256Sswallace#define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0) 12883256Sswallace#define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks) 12893256Sswallace#define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks) 12903256Sswallace#define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key) 12913256Sswallace#define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value) 12923256Sswallace#define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos) 12933256Sswallace#define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig) 1294652Sjkh 12953256Sswallace/* 129630866Smarkm * Local control events 129730866Smarkm */ 129830866Smarkm 129930866Smarkm#define _LOCAL_EVENT(ev, parm) { \ 130030866Smarkm _SEQ_NEEDBUF(8);\ 130130866Smarkm _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \ 130230866Smarkm _seqbuf[_seqbufptr+1] = (ev); \ 130330866Smarkm _seqbuf[_seqbufptr+2] = 0;\ 130430866Smarkm _seqbuf[_seqbufptr+3] = 0;\ 130530866Smarkm *(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \ 130630866Smarkm _SEQ_ADVBUF(8); \ 130730866Smarkm } 130830866Smarkm 130930866Smarkm#define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask) 131030866Smarkm/* 13119750Sjkh * Events for the level 1 interface only 13123256Sswallace */ 1313652Sjkh 131430866Smarkm#define SEQ_MIDIOUT(device, byte) { \ 131530866Smarkm _SEQ_NEEDBUF(4);\ 131630866Smarkm _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\ 131730866Smarkm _seqbuf[_seqbufptr+1] = (byte);\ 131830866Smarkm _seqbuf[_seqbufptr+2] = (device);\ 131930866Smarkm _seqbuf[_seqbufptr+3] = 0;\ 132030866Smarkm _SEQ_ADVBUF(4);} 13213256Sswallace 13223256Sswallace/* 13233256Sswallace * Patch loading. 13243256Sswallace */ 132530866Smarkm#define SEQ_WRPATCH(patchx, len) { \ 132630866Smarkm if (_seqbufptr) seqbuf_dump(); \ 132730866Smarkm if (write(seqfd, (char*)(patchx), len)==-1) \ 132830866Smarkm perror("Write patch: /dev/sequencer"); \ 132930866Smarkm } 1330652Sjkh 133130866Smarkm#define SEQ_WRPATCH2(patchx, len) \ 133230866Smarkm ( seqbuf_dump(), write(seqfd, (char*)(patchx), len) ) 133318444Sbde 133430866Smarkm#endif 133533473Sscrappy 133633473Sscrappy/* 133733473Sscrappy * Here I have moved all the aliases for ioctl names. 133833473Sscrappy */ 133933473Sscrappy 134033473Sscrappy#define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT 134133473Sscrappy#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT 134233473Sscrappy#define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT 134333473Sscrappy 134433473Sscrappy#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED 134533473Sscrappy#define SOUND_PCM_POST SNDCTL_DSP_POST 134633473Sscrappy#define SOUND_PCM_RESET SNDCTL_DSP_RESET 134733473Sscrappy#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC 134833473Sscrappy#define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE 134933473Sscrappy#define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT 135033473Sscrappy#define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS 135133473Sscrappy#define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE 135233473Sscrappy#define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE 135333473Sscrappy#define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK 135433473Sscrappy#define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS 135533473Sscrappy#define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER 135633473Sscrappy#define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER 135733473Sscrappy#define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO 135833473Sscrappy#define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR 135933473Sscrappy#define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR 136033473Sscrappy#define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF 136133473Sscrappy#define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF 136233473Sscrappy 136333473Sscrappy#endif /* SOUNDCARD_H */ 1364