soundcard.h revision 108533
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. 2950734Speter * 3050734Speter * $FreeBSD: head/sys/sys/soundcard.h 108533 2003-01-01 18:49:04Z schweikh $ 31652Sjkh */ 32652Sjkh 3350906Sdfr#ifndef _SYS_SOUNDCARD_H_ 3450906Sdfr#define _SYS_SOUNDCARD_H_ 3565335Scg /* 36652Sjkh * If you make modifications to this file, please contact me before 3765335Scg * distributing the modified version. There is already enough 3813765Smpp * diversity in the world. 39652Sjkh * 40652Sjkh * Regards, 41652Sjkh * Hannu Savolainen 423256Sswallace * hannu@voxware.pp.fi 4330866Smarkm * 4430866Smarkm ********************************************************************** 4565335Scg * PS. The Hacker's Guide to VoxWare available from 4682033Sgreid * nic.funet.fi:pub/Linux/ALPHA/sound. The file is 4730866Smarkm * snd-sdk-doc-0.1.ps.gz (gzipped postscript). It contains 4830866Smarkm * some useful information about programming with VoxWare. 4982033Sgreid * (NOTE! The pub/Linux/ALPHA/ directories are hidden. You have 5030866Smarkm * to cd inside them before the files are accessible.) 5130866Smarkm ********************************************************************** 52652Sjkh */ 53652Sjkh 5433530Sscrappy/* 5533530Sscrappy * SOUND_VERSION is only used by the voxware driver. Hopefully apps 5633530Sscrappy * should not depend on it, but rather look at the capabilities 5733530Sscrappy * of the driver in the kernel! 5833530Sscrappy */ 5933530Sscrappy#define SOUND_VERSION 301 6033530Sscrappy#define VOXWARE /* does this have any use ? */ 6133530Sscrappy 6233530Sscrappy/* 6333530Sscrappy * Supported card ID numbers (Should be somewhere else? We keep 6433530Sscrappy * them here just for compativility with the old driver, but these 6533530Sscrappy * constants are of little or no use). 6633530Sscrappy */ 6733530Sscrappy 6833530Sscrappy#define SNDCARD_ADLIB 1 6933530Sscrappy#define SNDCARD_SB 2 7033530Sscrappy#define SNDCARD_PAS 3 7133530Sscrappy#define SNDCARD_GUS 4 7233530Sscrappy#define SNDCARD_MPU401 5 7333530Sscrappy#define SNDCARD_SB16 6 7433530Sscrappy#define SNDCARD_SB16MIDI 7 7533530Sscrappy#define SNDCARD_UART6850 8 7633530Sscrappy#define SNDCARD_GUS16 9 7733530Sscrappy#define SNDCARD_MSS 10 7833530Sscrappy#define SNDCARD_PSS 11 7933530Sscrappy#define SNDCARD_SSCAPE 12 8033530Sscrappy#define SNDCARD_PSS_MPU 13 8133530Sscrappy#define SNDCARD_PSS_MSS 14 8233530Sscrappy#define SNDCARD_SSCAPE_MSS 15 8333530Sscrappy#define SNDCARD_TRXPRO 16 8433530Sscrappy#define SNDCARD_TRXPRO_SB 17 8533530Sscrappy#define SNDCARD_TRXPRO_MPU 18 8633530Sscrappy#define SNDCARD_MAD16 19 8733530Sscrappy#define SNDCARD_MAD16_MPU 20 8833530Sscrappy#define SNDCARD_CS4232 21 8933530Sscrappy#define SNDCARD_CS4232_MPU 22 9033530Sscrappy#define SNDCARD_MAUI 23 9133530Sscrappy#define SNDCARD_PSEUDO_MSS 24 9282033Sgreid#define SNDCARD_AWE32 25 9345240Skato#define SNDCARD_NSS 26 9462947Stanimura#define SNDCARD_UART16550 27 9562947Stanimura#define SNDCARD_OPL 28 9633530Sscrappy 9733473Sscrappy#include <sys/types.h> 9833473Sscrappy#ifndef _IOWR 9933473Sscrappy#include <sys/ioccom.h> 10033473Sscrappy#endif /* !_IOWR */ 101652Sjkh 102652Sjkh/* 10333473Sscrappy * The first part of this file contains the new FreeBSD sound ioctl 10433473Sscrappy * interface. Tries to minimize the number of different ioctls, and 10533473Sscrappy * to be reasonably general. 10633473Sscrappy * 10733473Sscrappy * 970821: some of the new calls have not been implemented yet. 108652Sjkh */ 109652Sjkh 11033473Sscrappy/* 11133473Sscrappy * the following three calls extend the generic file descriptor 11233473Sscrappy * interface. AIONWRITE is the dual of FIONREAD, i.e. returns the max 11333473Sscrappy * number of bytes for a write operation to be non-blocking. 11433473Sscrappy * 11533473Sscrappy * AIOGSIZE/AIOSSIZE are used to change the behaviour of the device, 11633473Sscrappy * from a character device (default) to a block device. In block mode, 11733473Sscrappy * (not to be confused with blocking mode) the main difference for the 11833473Sscrappy * application is that select() will return only when a complete 11933473Sscrappy * block can be read/written to the device, whereas in character mode 12033473Sscrappy * select will return true when one byte can be exchanged. For audio 12133473Sscrappy * devices, character mode makes select almost useless since one byte 12233473Sscrappy * will always be ready by the next sample time (which is often only a 12365335Scg * handful of microseconds away). 12433473Sscrappy * Use a size of 0 or 1 to return to character mode. 12533473Sscrappy */ 12633473Sscrappy#define AIONWRITE _IOR('A', 10, int) /* get # bytes to write */ 12733473Sscrappystruct snd_size { 12833473Sscrappy int play_size; 12933473Sscrappy int rec_size; 13033473Sscrappy}; 13133473Sscrappy#define AIOGSIZE _IOR('A', 11, struct snd_size)/* read current blocksize */ 13233473Sscrappy#define AIOSSIZE _IOWR('A', 11, struct snd_size) /* sets blocksize */ 133652Sjkh 13430866Smarkm/* 13533473Sscrappy * The following constants define supported audio formats. The 13633473Sscrappy * encoding follows voxware conventions, i.e. 1 bit for each supported 13733473Sscrappy * format. We extend it by using bit 31 (RO) to indicate full-duplex 13833473Sscrappy * capability, and bit 29 (RO) to indicate that the card supports/ 13933473Sscrappy * needs different formats on capture & playback channels. 14033473Sscrappy * Bit 29 (RW) is used to indicate/ask stereo. 14181891Ssobomax * 14281891Ssobomax * The number of bits required to store the sample is: 14381891Ssobomax * o 4 bits for the IDA ADPCM format, 14481891Ssobomax * o 8 bits for 8-bit formats, mu-law and A-law, 14581891Ssobomax * o 16 bits for the 16-bit formats, and 14681891Ssobomax * o 32 bits for the 24/32-bit formats. 14781891Ssobomax * o undefined for the MPEG audio format. 14833473Sscrappy */ 14933473Sscrappy 15081891Ssobomax#define AFMT_QUERY 0x00000000 /* Return current format */ 15181891Ssobomax#define AFMT_MU_LAW 0x00000001 /* Logarithmic mu-law */ 15281891Ssobomax#define AFMT_A_LAW 0x00000002 /* Logarithmic A-law */ 15381891Ssobomax#define AFMT_IMA_ADPCM 0x00000004 /* A 4:1 compressed format where 16-bit 15481891Ssobomax * squence represented using the 15581891Ssobomax * the average 4 bits per sample */ 15681891Ssobomax#define AFMT_U8 0x00000008 /* Unsigned 8-bit */ 15781891Ssobomax#define AFMT_S16_LE 0x00000010 /* Little endian signed 16-bit */ 15881891Ssobomax#define AFMT_S16_BE 0x00000020 /* Big endian signed 16-bit */ 15981891Ssobomax#define AFMT_S8 0x00000040 /* Signed 8-bit */ 16081891Ssobomax#define AFMT_U16_LE 0x00000080 /* Little endian unsigned 16-bit */ 16181891Ssobomax#define AFMT_U16_BE 0x00000100 /* Big endian unsigned 16-bit */ 16281891Ssobomax#define AFMT_MPEG 0x00000200 /* MPEG MP2/MP3 audio */ 16381891Ssobomax#define AFMT_AC3 0x00000400 /* Dolby Digital AC3 */ 16465335Scg/* 16581891Ssobomax * 32-bit formats below used for 24-bit audio data where the data is stored 16681891Ssobomax * in the 24 most significant bits and the least significant bits are not used 16781891Ssobomax * (should be set to 0). 16865335Scg */ 16981891Ssobomax#define AFMT_S32_LE 0x00001000 /* Little endian signed 32-bit */ 17081891Ssobomax#define AFMT_S32_BE 0x00002000 /* Big endian signed 32-bit */ 17181891Ssobomax#define AFMT_U32_LE 0x00004000 /* Little endian unsigned 32-bit */ 17281891Ssobomax#define AFMT_U32_BE 0x00008000 /* Big endian unsigned 32-bit */ 17333473Sscrappy 17481891Ssobomax#define AFMT_STEREO 0x10000000 /* can do/want stereo */ 17533473Sscrappy 17633473Sscrappy/* 17733473Sscrappy * the following are really capabilities 17833473Sscrappy */ 17981891Ssobomax#define AFMT_WEIRD 0x20000000 /* weird hardware... */ 18033473Sscrappy /* 18133473Sscrappy * AFMT_WEIRD reports that the hardware might need to operate 18233473Sscrappy * with different formats in the playback and capture 18333473Sscrappy * channels when operating in full duplex. 18433473Sscrappy * As an example, SoundBlaster16 cards only support U8 in one 18533473Sscrappy * direction and S16 in the other one, and applications should 18633473Sscrappy * be aware of this limitation. 18733473Sscrappy */ 18881891Ssobomax#define AFMT_FULLDUPLEX 0x80000000 /* can do full duplex */ 18933473Sscrappy 19033473Sscrappy/* 19133473Sscrappy * The following structure is used to get/set format and sampling rate. 19233473Sscrappy * While it would be better to have things such as stereo, bits per 19333473Sscrappy * sample, endiannes, etc split in different variables, it turns out 19433473Sscrappy * that formats are not that many, and not all combinations are possible. 19533473Sscrappy * So we followed the Voxware approach of associating one bit to each 19633473Sscrappy * format. 19733473Sscrappy */ 19833473Sscrappy 19933473Sscrappytypedef struct _snd_chan_param { 20033473Sscrappy u_long play_rate; /* sampling rate */ 20133473Sscrappy u_long rec_rate; /* sampling rate */ 20233473Sscrappy u_long play_format; /* everything describing the format */ 20333473Sscrappy u_long rec_format; /* everything describing the format */ 20433473Sscrappy} snd_chan_param; 20533473Sscrappy#define AIOGFMT _IOR('f', 12, snd_chan_param) /* get format */ 20633473Sscrappy#define AIOSFMT _IOWR('f', 12, snd_chan_param) /* sets format */ 20733473Sscrappy 20833473Sscrappy/* 20933473Sscrappy * The following structure is used to get/set the mixer setting. 21033473Sscrappy * Up to 32 mixers are supported, each one with up to 32 channels. 21133473Sscrappy */ 21233473Sscrappytypedef struct _snd_mix_param { 21333473Sscrappy u_char subdev; /* which output */ 21433473Sscrappy u_char line; /* which input */ 21533473Sscrappy u_char left,right; /* volumes, 0..255, 0 = mute */ 21633473Sscrappy} snd_mix_param ; 21733473Sscrappy 21833473Sscrappy/* XXX AIOGMIX, AIOSMIX not implemented yet */ 21933473Sscrappy#define AIOGMIX _IOWR('A', 13, snd_mix_param) /* return mixer status */ 22033473Sscrappy#define AIOSMIX _IOWR('A', 14, snd_mix_param) /* sets mixer status */ 22133473Sscrappy 22233473Sscrappy/* 22333473Sscrappy * channel specifiers used in AIOSTOP and AIOSYNC 22433473Sscrappy */ 22533473Sscrappy#define AIOSYNC_PLAY 0x1 /* play chan */ 22633473Sscrappy#define AIOSYNC_CAPTURE 0x2 /* capture chan */ 22733473Sscrappy/* AIOSTOP stop & flush a channel, returns the residual count */ 22833473Sscrappy#define AIOSTOP _IOWR ('A', 15, int) 22933473Sscrappy 23033473Sscrappy/* alternate method used to notify the sync condition */ 23133473Sscrappy#define AIOSYNC_SIGNAL 0x100 23233473Sscrappy#define AIOSYNC_SELECT 0x200 23333473Sscrappy 23433473Sscrappy/* what the 'pos' field refers to */ 23533473Sscrappy#define AIOSYNC_READY 0x400 23633473Sscrappy#define AIOSYNC_FREE 0x800 23733473Sscrappy 23833473Sscrappytypedef struct _snd_sync_parm { 23933473Sscrappy long chan ; /* play or capture channel, plus modifier */ 24033473Sscrappy long pos; 24133473Sscrappy} snd_sync_parm; 24233473Sscrappy#define AIOSYNC _IOWR ('A', 15, snd_sync_parm) /* misc. synchronization */ 24333473Sscrappy 24433473Sscrappy/* 24533473Sscrappy * The following is used to return device capabilities. If the structure 24633473Sscrappy * passed to the ioctl is zeroed, default values are returned for rate 24733473Sscrappy * and formats, a bitmap of available mixers is returned, and values 24833473Sscrappy * (inputs, different levels) for the first one are returned. 24933473Sscrappy * 25033473Sscrappy * If formats, mixers, inputs are instantiated, then detailed info 25133473Sscrappy * are returned depending on the call. 25233473Sscrappy */ 25333473Sscrappytypedef struct _snd_capabilities { 25433473Sscrappy u_long rate_min, rate_max; /* min-max sampling rate */ 25533473Sscrappy u_long formats; 25633473Sscrappy u_long bufsize; /* DMA buffer size */ 25733473Sscrappy u_long mixers; /* bitmap of available mixers */ 25833473Sscrappy u_long inputs; /* bitmap of available inputs (per mixer) */ 25933473Sscrappy u_short left, right; /* how many levels are supported */ 26033473Sscrappy} snd_capabilities; 26133473Sscrappy#define AIOGCAP _IOWR('A', 15, snd_capabilities) /* get capabilities */ 26233473Sscrappy 26333473Sscrappy/* 26433473Sscrappy * here is the old (Voxware) ioctl interface 26533473Sscrappy */ 26633473Sscrappy 26733473Sscrappy/* 268652Sjkh * IOCTL Commands for /dev/sequencer 269652Sjkh */ 270652Sjkh 27133473Sscrappy#define SNDCTL_SEQ_RESET _IO ('Q', 0) 27233473Sscrappy#define SNDCTL_SEQ_SYNC _IO ('Q', 1) 27333473Sscrappy#define SNDCTL_SYNTH_INFO _IOWR('Q', 2, struct synth_info) 27433473Sscrappy#define SNDCTL_SEQ_CTRLRATE _IOWR('Q', 3, int) /* Set/get timer res.(hz) */ 27533473Sscrappy#define SNDCTL_SEQ_GETOUTCOUNT _IOR ('Q', 4, int) 27633473Sscrappy#define SNDCTL_SEQ_GETINCOUNT _IOR ('Q', 5, int) 27733473Sscrappy#define SNDCTL_SEQ_PERCMODE _IOW ('Q', 6, int) 27833473Sscrappy#define SNDCTL_FM_LOAD_INSTR _IOW ('Q', 7, struct sbi_instrument) /* Valid for FM only */ 27933473Sscrappy#define SNDCTL_SEQ_TESTMIDI _IOW ('Q', 8, int) 28033473Sscrappy#define SNDCTL_SEQ_RESETSAMPLES _IOW ('Q', 9, int) 28133473Sscrappy#define SNDCTL_SEQ_NRSYNTHS _IOR ('Q',10, int) 28233473Sscrappy#define SNDCTL_SEQ_NRMIDIS _IOR ('Q',11, int) 28333473Sscrappy#define SNDCTL_MIDI_INFO _IOWR('Q',12, struct midi_info) 28433473Sscrappy#define SNDCTL_SEQ_THRESHOLD _IOW ('Q',13, int) 28533473Sscrappy#define SNDCTL_SEQ_TRESHOLD SNDCTL_SEQ_THRESHOLD /* there was once a typo */ 28633473Sscrappy#define SNDCTL_SYNTH_MEMAVL _IOWR('Q',14, int) /* in=dev#, out=memsize */ 28733473Sscrappy#define SNDCTL_FM_4OP_ENABLE _IOW ('Q',15, int) /* in=dev# */ 28833473Sscrappy#define SNDCTL_PMGR_ACCESS _IOWR('Q',16, struct patmgr_info) 28933473Sscrappy#define SNDCTL_SEQ_PANIC _IO ('Q',17) 29033473Sscrappy#define SNDCTL_SEQ_OUTOFBAND _IOW ('Q',18, struct seq_event_rec) 2919750Sjkh 29230866Smarkmstruct seq_event_rec { 29330866Smarkm u_char arr[8]; 29430866Smarkm}; 2959750Sjkh 29633473Sscrappy#define SNDCTL_TMR_TIMEBASE _IOWR('T', 1, int) 29733473Sscrappy#define SNDCTL_TMR_START _IO ('T', 2) 29833473Sscrappy#define SNDCTL_TMR_STOP _IO ('T', 3) 29933473Sscrappy#define SNDCTL_TMR_CONTINUE _IO ('T', 4) 30033473Sscrappy#define SNDCTL_TMR_TEMPO _IOWR('T', 5, int) 30133473Sscrappy#define SNDCTL_TMR_SOURCE _IOWR('T', 6, int) 30233473Sscrappy# define TMR_INTERNAL 0x00000001 30333473Sscrappy# define TMR_EXTERNAL 0x00000002 30433473Sscrappy# define TMR_MODE_MIDI 0x00000010 30533473Sscrappy# define TMR_MODE_FSK 0x00000020 30633473Sscrappy# define TMR_MODE_CLS 0x00000040 30733473Sscrappy# define TMR_MODE_SMPTE 0x00000080 30833473Sscrappy#define SNDCTL_TMR_METRONOME _IOW ('T', 7, int) 30933473Sscrappy#define SNDCTL_TMR_SELECT _IOW ('T', 8, int) 3103256Sswallace 311652Sjkh/* 31230866Smarkm * Endian aware patch key generation algorithm. 31330866Smarkm */ 31430866Smarkm 31530866Smarkm#if defined(_AIX) || defined(AIX) 31630866Smarkm# define _PATCHKEY(id) (0xfd00|id) 31730866Smarkm#else 31830866Smarkm# define _PATCHKEY(id) ((id<<8)|0xfd) 31930866Smarkm#endif 32030866Smarkm 32130866Smarkm/* 322652Sjkh * Sample loading mechanism for internal synthesizers (/dev/sequencer) 323652Sjkh * The following patch_info structure has been designed to support 324652Sjkh * Gravis UltraSound. It tries to be universal format for uploading 32533473Sscrappy * sample based patches but is probably too limited. 326652Sjkh */ 327652Sjkh 328652Sjkhstruct patch_info { 32930866Smarkm/* u_short key; Use GUS_PATCH here */ 33030866Smarkm short key; /* Use GUS_PATCH here */ 33130866Smarkm#define GUS_PATCH _PATCHKEY(0x04) 33230866Smarkm#define OBSOLETE_GUS_PATCH _PATCHKEY(0x02) 333652Sjkh 33430866Smarkm short device_no; /* Synthesizer number */ 33530866Smarkm short instr_no; /* Midi pgm# */ 33630866Smarkm 33730866Smarkm u_long mode; 338652Sjkh/* 339652Sjkh * The least significant byte has the same format than the GUS .PAT 340652Sjkh * files 341652Sjkh */ 342652Sjkh#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ 343652Sjkh#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ 344652Sjkh#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ 345652Sjkh#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ 346652Sjkh#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ 347652Sjkh#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ 348652Sjkh#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ 349652Sjkh /* (use the env_rate/env_offs fields). */ 350652Sjkh/* Linux specific bits */ 351652Sjkh#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ 352652Sjkh#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ 353652Sjkh#define WAVE_SCALE 0x00040000 /* The scaling info is valid */ 354652Sjkh/* Other bits must be zeroed */ 355652Sjkh 35630866Smarkm long len; /* Size of the wave data in bytes */ 35730866Smarkm long loop_start, loop_end; /* Byte offsets from the beginning */ 358652Sjkh 35965335Scg/* 360652Sjkh * The base_freq and base_note fields are used when computing the 361652Sjkh * playback speed for a note. The base_note defines the tone frequency 362652Sjkh * which is heard if the sample is played using the base_freq as the 363652Sjkh * playback speed. 364652Sjkh * 365652Sjkh * The low_note and high_note fields define the minimum and maximum note 366652Sjkh * frequencies for which this sample is valid. It is possible to define 367108533Sschweikh * more than one samples for an instrument number at the same time. The 368652Sjkh * low_note and high_note fields are used to select the most suitable one. 369652Sjkh * 370652Sjkh * The fields base_note, high_note and low_note should contain 371652Sjkh * the note frequency multiplied by 1000. For example value for the 372652Sjkh * middle A is 440*1000. 373652Sjkh */ 374652Sjkh 37530866Smarkm u_int base_freq; 37630866Smarkm u_long base_note; 37730866Smarkm u_long high_note; 37830866Smarkm u_long low_note; 37930866Smarkm int panning; /* -128=left, 127=right */ 38030866Smarkm int detuning; 381652Sjkh 382652Sjkh/* New fields introduced in version 1.99.5 */ 383652Sjkh 384652Sjkh /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ 38530866Smarkm u_char env_rate[ 6 ]; /* GUS HW ramping rate */ 38630866Smarkm u_char env_offset[ 6 ]; /* 255 == 100% */ 387652Sjkh 38865335Scg /* 389652Sjkh * The tremolo, vibrato and scale info are not supported yet. 390652Sjkh * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or 391652Sjkh * WAVE_SCALE 392652Sjkh */ 393652Sjkh 39430866Smarkm u_char tremolo_sweep; 39530866Smarkm u_char tremolo_rate; 39630866Smarkm u_char tremolo_depth; 397652Sjkh 39830866Smarkm u_char vibrato_sweep; 39930866Smarkm u_char vibrato_rate; 40030866Smarkm u_char vibrato_depth; 40130866Smarkm 40230866Smarkm int scale_frequency; 40330866Smarkm u_int scale_factor; /* from 0 to 2048 or 0 to 2 */ 40465335Scg 40530866Smarkm int volume; 40630866Smarkm int spare[4]; 40730866Smarkm char data[1]; /* The waveform data starts here */ 40830866Smarkm}; 409652Sjkh 4103256Sswallacestruct sysex_info { 41130866Smarkm short key; /* Use GUS_PATCH here */ 41230866Smarkm#define SYSEX_PATCH _PATCHKEY(0x05) 41330866Smarkm#define MAUI_PATCH _PATCHKEY(0x06) 41430866Smarkm short device_no; /* Synthesizer number */ 41530866Smarkm long len; /* Size of the sysex data in bytes */ 41630866Smarkm u_char data[1]; /* Sysex data starts here */ 41730866Smarkm}; 4183256Sswallace 419652Sjkh/* 420652Sjkh * Patch management interface (/dev/sequencer, /dev/patmgr#) 421652Sjkh * Don't use these calls if you want to maintain compatibility with 422652Sjkh * the future versions of the driver. 423652Sjkh */ 424652Sjkh 42533473Sscrappy#define PS_NO_PATCHES 0 /* No patch support on device */ 42633473Sscrappy#define PS_MGR_NOT_OK 1 /* Plain patch support (no mgr) */ 42733473Sscrappy#define PS_MGR_OK 2 /* Patch manager supported */ 42833473Sscrappy#define PS_MANAGED 3 /* Patch manager running */ 429652Sjkh 430652Sjkh#define SNDCTL_PMGR_IFACE _IOWR('P', 1, struct patmgr_info) 431652Sjkh 432652Sjkh/* 433652Sjkh * The patmgr_info is a fixed size structure which is used for two 434652Sjkh * different purposes. The intended use is for communication between 435652Sjkh * the application using /dev/sequencer and the patch manager daemon 436652Sjkh * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)). 437652Sjkh * 438652Sjkh * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows 439652Sjkh * a patch manager daemon to read and write device parameters. This 440652Sjkh * ioctl available through /dev/sequencer also. Avoid using it since it's 44165335Scg * extremely hardware dependent. In addition access trough /dev/sequencer 442652Sjkh * may confuse the patch manager daemon. 443652Sjkh */ 444652Sjkh 445652Sjkhstruct patmgr_info { /* Note! size must be < 4k since kmalloc() is used */ 44630866Smarkm u_long key; /* Don't worry. Reserved for communication 447652Sjkh between the patch manager and the driver. */ 448652Sjkh#define PM_K_EVENT 1 /* Event from the /dev/sequencer driver */ 449108533Sschweikh#define PM_K_COMMAND 2 /* Request from an application */ 450652Sjkh#define PM_K_RESPONSE 3 /* From patmgr to application */ 451652Sjkh#define PM_ERROR 4 /* Error returned by the patmgr */ 452652Sjkh int device; 453652Sjkh int command; 454652Sjkh 45565335Scg/* 45665335Scg * Commands 0x000 to 0xfff reserved for patch manager programs 457652Sjkh */ 458652Sjkh#define PM_GET_DEVTYPE 1 /* Returns type of the patch mgr interface of dev */ 459652Sjkh#define PMTYPE_FM2 1 /* 2 OP fm */ 460652Sjkh#define PMTYPE_FM4 2 /* Mixed 4 or 2 op FM (OPL-3) */ 461652Sjkh#define PMTYPE_WAVE 3 /* Wave table synthesizer (GUS) */ 462652Sjkh#define PM_GET_NRPGM 2 /* Returns max # of midi programs in parm1 */ 463652Sjkh#define PM_GET_PGMMAP 3 /* Returns map of loaded midi programs in data8 */ 464652Sjkh#define PM_GET_PGM_PATCHES 4 /* Return list of patches of a program (parm1) */ 465652Sjkh#define PM_GET_PATCH 5 /* Return patch header of patch parm1 */ 466652Sjkh#define PM_SET_PATCH 6 /* Set patch header of patch parm1 */ 467652Sjkh#define PM_READ_PATCH 7 /* Read patch (wave) data */ 468652Sjkh#define PM_WRITE_PATCH 8 /* Write patch (wave) data */ 469652Sjkh 470652Sjkh/* 471652Sjkh * Commands 0x1000 to 0xffff are for communication between the patch manager 472652Sjkh * and the client 473652Sjkh */ 474652Sjkh#define _PM_LOAD_PATCH 0x100 475652Sjkh 47665335Scg/* 477652Sjkh * Commands above 0xffff reserved for device specific use 478652Sjkh */ 479652Sjkh 48030866Smarkm long parm1; 48130866Smarkm long parm2; 48230866Smarkm long parm3; 483652Sjkh 48430866Smarkm union { 48530866Smarkm u_char data8[4000]; 48630866Smarkm u_short data16[2000]; 48730866Smarkm u_long data32[1000]; 488652Sjkh struct patch_info patch; 48930866Smarkm } data; 49030866Smarkm}; 491652Sjkh 492652Sjkh/* 493652Sjkh * When a patch manager daemon is present, it will be informed by the 494652Sjkh * driver when something important happens. For example when the 495652Sjkh * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is 496652Sjkh * returned. The command field contains the event type: 497652Sjkh */ 498652Sjkh#define PM_E_OPENED 1 /* /dev/sequencer opened */ 499652Sjkh#define PM_E_CLOSED 2 /* /dev/sequencer closed */ 500652Sjkh#define PM_E_PATCH_RESET 3 /* SNDCTL_RESETSAMPLES called */ 501652Sjkh#define PM_E_PATCH_LOADED 4 /* A patch has been loaded by appl */ 502652Sjkh 503652Sjkh/* 504652Sjkh * /dev/sequencer input events. 505652Sjkh * 506652Sjkh * The data written to the /dev/sequencer is a stream of events. Events 50765335Scg * are records of 4 or 8 bytes. The first byte defines the size. 508652Sjkh * Any number of events can be written with a write call. There 509652Sjkh * is a set of macros for sending these events. Use these macros if you 510652Sjkh * want to maximize portability of your program. 511652Sjkh * 512652Sjkh * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. 513652Sjkh * (All input events are currently 4 bytes long. Be prepared to support 5143256Sswallace * 8 byte events also. If you receive any event having first byte >= 128, 515652Sjkh * it's a 8 byte event. 516652Sjkh * 517652Sjkh * The events are documented at the end of this file. 518652Sjkh * 519652Sjkh * Normal events (4 bytes) 520652Sjkh * There is also a 8 byte version of most of the 4 byte events. The 521652Sjkh * 8 byte one is recommended. 522652Sjkh */ 523652Sjkh#define SEQ_NOTEOFF 0 524652Sjkh#define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ 525652Sjkh#define SEQ_NOTEON 1 526652Sjkh#define SEQ_FMNOTEON SEQ_NOTEON 5273256Sswallace#define SEQ_WAIT TMR_WAIT_ABS 528652Sjkh#define SEQ_PGMCHANGE 3 529652Sjkh#define SEQ_FMPGMCHANGE SEQ_PGMCHANGE 5303256Sswallace#define SEQ_SYNCTIMER TMR_START 531652Sjkh#define SEQ_MIDIPUTC 5 532652Sjkh#define SEQ_DRUMON 6 /*** OBSOLETE ***/ 533652Sjkh#define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ 5343256Sswallace#define SEQ_ECHO TMR_ECHO /* For synching programs with output */ 535652Sjkh#define SEQ_AFTERTOUCH 9 536652Sjkh#define SEQ_CONTROLLER 10 5373256Sswallace 53833473Sscrappy/* 5393256Sswallace * Midi controller numbers 54033473Sscrappy * 54133473Sscrappy * Controllers 0 to 31 (0x00 to 0x1f) and 32 to 63 (0x20 to 0x3f) 54233473Sscrappy * are continuous controllers. 54333473Sscrappy * In the MIDI 1.0 these controllers are sent using two messages. 54433473Sscrappy * Controller numbers 0 to 31 are used to send the MSB and the 54533473Sscrappy * controller numbers 32 to 63 are for the LSB. Note that just 7 bits 54633473Sscrappy * are used in MIDI bytes. 5473256Sswallace */ 5483256Sswallace 54933473Sscrappy#define CTL_BANK_SELECT 0x00 55033473Sscrappy#define CTL_MODWHEEL 0x01 55133473Sscrappy#define CTL_BREATH 0x02 55233473Sscrappy/* undefined 0x03 */ 55333473Sscrappy#define CTL_FOOT 0x04 55433473Sscrappy#define CTL_PORTAMENTO_TIME 0x05 55533473Sscrappy#define CTL_DATA_ENTRY 0x06 55633473Sscrappy#define CTL_MAIN_VOLUME 0x07 55733473Sscrappy#define CTL_BALANCE 0x08 55833473Sscrappy/* undefined 0x09 */ 55933473Sscrappy#define CTL_PAN 0x0a 56033473Sscrappy#define CTL_EXPRESSION 0x0b 56133473Sscrappy/* undefined 0x0c - 0x0f */ 56233473Sscrappy#define CTL_GENERAL_PURPOSE1 0x10 56333473Sscrappy#define CTL_GENERAL_PURPOSE2 0x11 56433473Sscrappy#define CTL_GENERAL_PURPOSE3 0x12 56533473Sscrappy#define CTL_GENERAL_PURPOSE4 0x13 56633473Sscrappy/* undefined 0x14 - 0x1f */ 5673256Sswallace 56833473Sscrappy/* undefined 0x20 */ 5693256Sswallace 57033473Sscrappy/* 57133473Sscrappy * The controller numbers 0x21 to 0x3f are reserved for the 57233473Sscrappy * least significant bytes of the controllers 0x00 to 0x1f. 57333473Sscrappy * These controllers are not recognised by the driver. 57433473Sscrappy * 57533473Sscrappy * Controllers 64 to 69 (0x40 to 0x45) are on/off switches. 57633473Sscrappy * 0=OFF and 127=ON (intermediate values are possible) 57733473Sscrappy */ 57833473Sscrappy#define CTL_DAMPER_PEDAL 0x40 57933473Sscrappy#define CTL_SUSTAIN CTL_DAMPER_PEDAL /* Alias */ 58033473Sscrappy#define CTL_HOLD CTL_DAMPER_PEDAL /* Alias */ 58133473Sscrappy#define CTL_PORTAMENTO 0x41 58233473Sscrappy#define CTL_SOSTENUTO 0x42 58333473Sscrappy#define CTL_SOFT_PEDAL 0x43 58433473Sscrappy/* undefined 0x44 */ 58533473Sscrappy#define CTL_HOLD2 0x45 58633473Sscrappy/* undefined 0x46 - 0x4f */ 5873256Sswallace 58833473Sscrappy#define CTL_GENERAL_PURPOSE5 0x50 58933473Sscrappy#define CTL_GENERAL_PURPOSE6 0x51 59033473Sscrappy#define CTL_GENERAL_PURPOSE7 0x52 59133473Sscrappy#define CTL_GENERAL_PURPOSE8 0x53 59233473Sscrappy/* undefined 0x54 - 0x5a */ 59333473Sscrappy#define CTL_EXT_EFF_DEPTH 0x5b 59433473Sscrappy#define CTL_TREMOLO_DEPTH 0x5c 59533473Sscrappy#define CTL_CHORUS_DEPTH 0x5d 59633473Sscrappy#define CTL_DETUNE_DEPTH 0x5e 59733473Sscrappy#define CTL_CELESTE_DEPTH CTL_DETUNE_DEPTH /* Alias for the above one */ 59833473Sscrappy#define CTL_PHASER_DEPTH 0x5f 59933473Sscrappy#define CTL_DATA_INCREMENT 0x60 60033473Sscrappy#define CTL_DATA_DECREMENT 0x61 60133473Sscrappy#define CTL_NONREG_PARM_NUM_LSB 0x62 60233473Sscrappy#define CTL_NONREG_PARM_NUM_MSB 0x63 60333473Sscrappy#define CTL_REGIST_PARM_NUM_LSB 0x64 60433473Sscrappy#define CTL_REGIST_PARM_NUM_MSB 0x65 60533473Sscrappy/* undefined 0x66 - 0x78 */ 60633473Sscrappy/* reserved 0x79 - 0x7f */ 6073256Sswallace 6083256Sswallace/* Pseudo controllers (not midi compatible) */ 60933473Sscrappy#define CTRL_PITCH_BENDER 255 61033473Sscrappy#define CTRL_PITCH_BENDER_RANGE 254 61133473Sscrappy#define CTRL_EXPRESSION 253 /* Obsolete */ 61233473Sscrappy#define CTRL_MAIN_VOLUME 252 /* Obsolete */ 61333473Sscrappy 614652Sjkh#define SEQ_BALANCE 11 6151402Sache#define SEQ_VOLMODE 12 616652Sjkh 617652Sjkh/* 6181402Sache * Volume mode decides how volumes are used 6191402Sache */ 6201402Sache 6211402Sache#define VOL_METHOD_ADAGIO 1 6221402Sache#define VOL_METHOD_LINEAR 2 6231402Sache 6241402Sache/* 625652Sjkh * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as 626652Sjkh * input events. 627652Sjkh */ 628652Sjkh 629652Sjkh/* 630652Sjkh * Event codes 0xf0 to 0xfc are reserved for future extensions. 631652Sjkh */ 632652Sjkh 633652Sjkh#define SEQ_FULLSIZE 0xfd /* Long events */ 634652Sjkh/* 63533473Sscrappy * SEQ_FULLSIZE events are used for loading patches/samples to the 63633473Sscrappy * synthesizer devices. These events are passed directly to the driver 63733473Sscrappy * of the associated synthesizer device. There is no limit to the size 63833473Sscrappy * of the extended events. These events are not queued but executed 63933473Sscrappy * immediately when the write() is called (execution can take several 64065335Scg * seconds of time). 641652Sjkh * 64233473Sscrappy * When a SEQ_FULLSIZE message is written to the device, it must 64333473Sscrappy * be written using exactly one write() call. Other events cannot 64433473Sscrappy * be mixed to the same write. 64565335Scg * 64633473Sscrappy * For FM synths (YM3812/OPL3) use struct sbi_instrument and write 64733473Sscrappy * it to the /dev/sequencer. Don't write other data together with 64833473Sscrappy * the instrument structure Set the key field of the structure to 64933473Sscrappy * FM_PATCH. The device field is used to route the patch to the 65033473Sscrappy * corresponding device. 651652Sjkh * 65233473Sscrappy * For Gravis UltraSound use struct patch_info. Initialize the key field 65333473Sscrappy * to GUS_PATCH. 654652Sjkh */ 65533473Sscrappy#define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ 65633473Sscrappy#define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */ 657652Sjkh 658652Sjkh/* 659652Sjkh * Record for FM patches 660652Sjkh */ 661652Sjkh 66230866Smarkmtypedef u_char sbi_instr_data[32]; 663652Sjkh 664652Sjkhstruct sbi_instrument { 66530866Smarkm u_short key; /* FM_PATCH or OPL3_PATCH */ 66630866Smarkm#define FM_PATCH _PATCHKEY(0x01) 66730866Smarkm#define OPL3_PATCH _PATCHKEY(0x03) 66830866Smarkm short device; /* Synth# (0-4) */ 66930866Smarkm int channel; /* Program# to be initialized */ 67030866Smarkm sbi_instr_data operators; /* Reg. settings for operator cells 67130866Smarkm * (.SBI format) */ 67230866Smarkm}; 673652Sjkh 674652Sjkhstruct synth_info { /* Read only */ 67545462Skato char name[30]; 67630866Smarkm int device; /* 0-N. INITIALIZE BEFORE CALLING */ 67730866Smarkm int synth_type; 678652Sjkh#define SYNTH_TYPE_FM 0 679652Sjkh#define SYNTH_TYPE_SAMPLE 1 6803256Sswallace#define SYNTH_TYPE_MIDI 2 /* Midi interface */ 681652Sjkh 68230866Smarkm int synth_subtype; 683652Sjkh#define FM_TYPE_ADLIB 0x00 684652Sjkh#define FM_TYPE_OPL3 0x01 685652Sjkh 68633473Sscrappy#define SAMPLE_TYPE_BASIC 0x10 68733473Sscrappy#define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC 68833530Sscrappy#define SAMPLE_TYPE_AWE32 0x20 689652Sjkh 69030866Smarkm int perc_mode; /* No longer supported */ 69130866Smarkm int nr_voices; 69230866Smarkm int nr_drums; /* Obsolete field */ 69330866Smarkm int instr_bank_size; 69465335Scg u_long capabilities; 69533473Sscrappy#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ 69633473Sscrappy#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ 69733473Sscrappy#define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */ 69830866Smarkm int dummies[19]; /* Reserve space */ 69930866Smarkm}; 700652Sjkh 7013256Sswallacestruct sound_timer_info { 70230866Smarkm char name[32]; 70330866Smarkm int caps; 70430866Smarkm}; 7053256Sswallace 7063256Sswallace#define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */ 7073256Sswallace 708652Sjkhstruct midi_info { 70930866Smarkm char name[30]; 71030866Smarkm int device; /* 0-N. INITIALIZE BEFORE CALLING */ 71130866Smarkm u_long capabilities; /* To be defined later */ 71230866Smarkm int dev_type; 71330866Smarkm int dummies[18]; /* Reserve space */ 71430866Smarkm}; 715652Sjkh 71633473Sscrappy/* 7173256Sswallace * ioctl commands for the /dev/midi## 7183256Sswallace */ 7193256Sswallacetypedef struct { 72030866Smarkm u_char cmd; 72130866Smarkm char nr_args, nr_returns; 72230866Smarkm u_char data[30]; 72330866Smarkm} mpu_command_rec; 7243256Sswallace 72533473Sscrappy#define SNDCTL_MIDI_PRETIME _IOWR('m', 0, int) 72633473Sscrappy#define SNDCTL_MIDI_MPUMODE _IOWR('m', 1, int) 72733473Sscrappy#define SNDCTL_MIDI_MPUCMD _IOWR('m', 2, mpu_command_rec) 72862947Stanimura#define MIOSPASSTHRU _IOWR('m', 3, int) 72962947Stanimura#define MIOGPASSTHRU _IOWR('m', 4, int) 7303256Sswallace 73133473Sscrappy/* 732652Sjkh * IOCTL commands for /dev/dsp and /dev/audio 733652Sjkh */ 734652Sjkh 73533473Sscrappy#define SNDCTL_DSP_RESET _IO ('P', 0) 73633473Sscrappy#define SNDCTL_DSP_SYNC _IO ('P', 1) 73733473Sscrappy#define SNDCTL_DSP_SPEED _IOWR('P', 2, int) 73833473Sscrappy#define SNDCTL_DSP_STEREO _IOWR('P', 3, int) 73933473Sscrappy#define SNDCTL_DSP_GETBLKSIZE _IOR('P', 4, int) 74033473Sscrappy#define SNDCTL_DSP_SETBLKSIZE _IOW('P', 4, int) 74133473Sscrappy#define SNDCTL_DSP_SETFMT _IOWR('P',5, int) /* Selects ONE fmt*/ 74233473Sscrappy 74333473Sscrappy/* 74433473Sscrappy * SOUND_PCM_WRITE_CHANNELS is not that different 74533473Sscrappy * from SNDCTL_DSP_STEREO 74633473Sscrappy */ 747652Sjkh#define SOUND_PCM_WRITE_CHANNELS _IOWR('P', 6, int) 74865335Scg#define SNDCTL_DSP_CHANNELS SOUND_PCM_WRITE_CHANNELS 74933473Sscrappy#define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int) 75033473Sscrappy#define SNDCTL_DSP_POST _IO ('P', 8) 751652Sjkh 75233473Sscrappy/* 75333473Sscrappy * SNDCTL_DSP_SETBLKSIZE and the following two calls mostly do 75433473Sscrappy * the same thing, i.e. set the block size used in DMA transfers. 75533473Sscrappy */ 75633473Sscrappy#define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int) 75733473Sscrappy#define SNDCTL_DSP_SETFRAGMENT _IOWR('P',10, int) 75830866Smarkm 7593256Sswallace 76033473Sscrappy#define SNDCTL_DSP_GETFMTS _IOR ('P',11, int) /* Returns a mask */ 7619750Sjkh/* 7629750Sjkh * Buffer status queries. 7639750Sjkh */ 7649750Sjkhtypedef struct audio_buf_info { 76533473Sscrappy int fragments; /* # of avail. frags (partly used ones not counted) */ 76633473Sscrappy int fragstotal; /* Total # of fragments allocated */ 76733473Sscrappy int fragsize; /* Size of a fragment in bytes */ 7689750Sjkh 76933473Sscrappy int bytes; /* Avail. space in bytes (includes partly used fragments) */ 77033473Sscrappy /* Note! 'bytes' could be more than fragments*fragsize */ 77130866Smarkm} audio_buf_info; 7729750Sjkh 77333473Sscrappy#define SNDCTL_DSP_GETOSPACE _IOR ('P',12, audio_buf_info) 77433473Sscrappy#define SNDCTL_DSP_GETISPACE _IOR ('P',13, audio_buf_info) 7759750Sjkh 77633473Sscrappy/* 77733473Sscrappy * SNDCTL_DSP_NONBLOCK is the same (but less powerful, since the 77833473Sscrappy * action cannot be undone) of FIONBIO. The same can be achieved 77933473Sscrappy * by opening the device with O_NDELAY 78033473Sscrappy */ 78133473Sscrappy#define SNDCTL_DSP_NONBLOCK _IO ('P',14) 78230866Smarkm 78333473Sscrappy#define SNDCTL_DSP_GETCAPS _IOR ('P',15, int) 78433473Sscrappy#define DSP_CAP_REVISION 0x000000ff /* revision level (0 to 255) */ 78533473Sscrappy#define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */ 78633473Sscrappy#define DSP_CAP_REALTIME 0x00000200 /* Real time capability */ 78733473Sscrappy#define DSP_CAP_BATCH 0x00000400 78833473Sscrappy /* 78933473Sscrappy * Device has some kind of internal buffers which may 79033473Sscrappy * cause some delays and decrease precision of timing 79133473Sscrappy */ 79233473Sscrappy#define DSP_CAP_COPROC 0x00000800 79333473Sscrappy /* Has a coprocessor, sometimes it's a DSP but usually not */ 79433473Sscrappy#define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */ 79533530Sscrappy#define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */ 79630866Smarkm 79733473Sscrappy/* 79833473Sscrappy * What do these function do ? 79933473Sscrappy */ 80033473Sscrappy#define SNDCTL_DSP_GETTRIGGER _IOR ('P',16, int) 80133473Sscrappy#define SNDCTL_DSP_SETTRIGGER _IOW ('P',16, int) 80233473Sscrappy#define PCM_ENABLE_INPUT 0x00000001 80330866Smarkm#define PCM_ENABLE_OUTPUT 0x00000002 80430866Smarkm 80530866Smarkmtypedef struct count_info { 80630866Smarkm int bytes; /* Total # of bytes processed */ 80730866Smarkm int blocks; /* # of fragment transitions since last time */ 80830866Smarkm int ptr; /* Current DMA pointer value */ 80930866Smarkm} count_info; 81030866Smarkm 81133473Sscrappy/* 81233473Sscrappy * GETIPTR and GETISPACE are not that different... same for out. 81333473Sscrappy */ 81433473Sscrappy#define SNDCTL_DSP_GETIPTR _IOR ('P',17, count_info) 81533473Sscrappy#define SNDCTL_DSP_GETOPTR _IOR ('P',18, count_info) 81630866Smarkm 81730866Smarkmtypedef struct buffmem_desc { 81830866Smarkm caddr_t buffer; 81930866Smarkm int size; 82030866Smarkm} buffmem_desc; 82130866Smarkm 82233473Sscrappy#define SNDCTL_DSP_MAPINBUF _IOR ('P', 19, buffmem_desc) 82333473Sscrappy#define SNDCTL_DSP_MAPOUTBUF _IOR ('P', 20, buffmem_desc) 82433473Sscrappy#define SNDCTL_DSP_SETSYNCRO _IO ('P', 21) 82565335Scg#define SNDCTL_DSP_SETDUPLEX _IO ('P', 22) 82653901Salfred#define SNDCTL_DSP_GETODELAY _IOR ('P', 23, int) 82730866Smarkm 82833473Sscrappy/* 82933473Sscrappy * I guess these are the readonly version of the same 83033473Sscrappy * functions that exist above as SNDCTL_DSP_... 83133473Sscrappy */ 83233473Sscrappy#define SOUND_PCM_READ_RATE _IOR ('P', 2, int) 83333473Sscrappy#define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int) 83433473Sscrappy#define SOUND_PCM_READ_BITS _IOR ('P', 5, int) 83533473Sscrappy#define SOUND_PCM_READ_FILTER _IOR ('P', 7, int) 836652Sjkh 8379750Sjkh/* 8389750Sjkh * ioctl calls to be used in communication with coprocessors and 8399750Sjkh * DSP chips. 8403256Sswallace */ 8413256Sswallace 8429750Sjkhtypedef struct copr_buffer { 84330866Smarkm int command; /* Set to 0 if not used */ 84430866Smarkm int flags; 8459750Sjkh#define CPF_NONE 0x0000 8469750Sjkh#define CPF_FIRST 0x0001 /* First block */ 8479750Sjkh#define CPF_LAST 0x0002 /* Last block */ 84830866Smarkm int len; 84930866Smarkm int offs; /* If required by the device (0 if not used) */ 8503256Sswallace 85130866Smarkm u_char data[4000]; /* NOTE! 4000 is not 4k */ 85230866Smarkm} copr_buffer; 8539750Sjkh 8549750Sjkhtypedef struct copr_debug_buf { 85530866Smarkm int command; /* Used internally. Set to 0 */ 85630866Smarkm int parm1; 85730866Smarkm int parm2; 85865335Scg int flags; 85930866Smarkm int len; /* Length of data in bytes */ 86030866Smarkm} copr_debug_buf; 8619750Sjkh 8629750Sjkhtypedef struct copr_msg { 86330866Smarkm int len; 86430866Smarkm u_char data[4000]; 86530866Smarkm} copr_msg; 8669750Sjkh 86733473Sscrappy#define SNDCTL_COPR_RESET _IO ('C', 0) 86833473Sscrappy#define SNDCTL_COPR_LOAD _IOWR('C', 1, copr_buffer) 86933473Sscrappy#define SNDCTL_COPR_RDATA _IOWR('C', 2, copr_debug_buf) 87033473Sscrappy#define SNDCTL_COPR_RCODE _IOWR('C', 3, copr_debug_buf) 87133473Sscrappy#define SNDCTL_COPR_WDATA _IOW ('C', 4, copr_debug_buf) 87233473Sscrappy#define SNDCTL_COPR_WCODE _IOW ('C', 5, copr_debug_buf) 87333473Sscrappy#define SNDCTL_COPR_RUN _IOWR('C', 6, copr_debug_buf) 87433473Sscrappy#define SNDCTL_COPR_HALT _IOWR('C', 7, copr_debug_buf) 87533473Sscrappy#define SNDCTL_COPR_SENDMSG _IOW ('C', 8, copr_msg) 87633473Sscrappy#define SNDCTL_COPR_RCVMSG _IOR ('C', 9, copr_msg) 8779750Sjkh 87833473Sscrappy/* 879652Sjkh * IOCTL commands for /dev/mixer 880652Sjkh */ 88165335Scg 88265335Scg/* 883652Sjkh * Mixer devices 884652Sjkh * 885652Sjkh * There can be up to 20 different analog mixer channels. The 88665335Scg * SOUND_MIXER_NRDEVICES gives the currently supported maximum. 887652Sjkh * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells 888652Sjkh * the devices supported by the particular mixer. 889652Sjkh */ 890652Sjkh 89133473Sscrappy#define SOUND_MIXER_NRDEVICES 25 89281891Ssobomax#define SOUND_MIXER_VOLUME 0 /* Master output level */ 89381891Ssobomax#define SOUND_MIXER_BASS 1 /* Treble level of all output channels */ 89481891Ssobomax#define SOUND_MIXER_TREBLE 2 /* Bass level of all output channels */ 89581891Ssobomax#define SOUND_MIXER_SYNTH 3 /* Volume of synthesier input */ 89681891Ssobomax#define SOUND_MIXER_PCM 4 /* Output level for the audio device */ 89781891Ssobomax#define SOUND_MIXER_SPEAKER 5 /* Output level for the PC speaker 89881891Ssobomax * signals */ 89981891Ssobomax#define SOUND_MIXER_LINE 6 /* Volume level for the line in jack */ 90081891Ssobomax#define SOUND_MIXER_MIC 7 /* Volume for the signal coming from 90181891Ssobomax * the microphone jack */ 90281891Ssobomax#define SOUND_MIXER_CD 8 /* Volume level for the input signal 90381891Ssobomax * connected to the CD audio input */ 90481891Ssobomax#define SOUND_MIXER_IMIX 9 /* Recording monitor. It controls the 90581891Ssobomax * output volume of the selected 90681891Ssobomax * recording sources while recording */ 90781891Ssobomax#define SOUND_MIXER_ALTPCM 10 /* Volume of the alternative codec 90881891Ssobomax * device */ 90981891Ssobomax#define SOUND_MIXER_RECLEV 11 /* Global recording level */ 9109750Sjkh#define SOUND_MIXER_IGAIN 12 /* Input gain */ 9119750Sjkh#define SOUND_MIXER_OGAIN 13 /* Output gain */ 91265335Scg/* 9139750Sjkh * The AD1848 codec and compatibles have three line level inputs 9149750Sjkh * (line, aux1 and aux2). Since each card manufacturer have assigned 91530866Smarkm * different meanings to these inputs, it's inpractical to assign 9169750Sjkh * specific meanings (line, cd, synth etc.) to them. 9179750Sjkh */ 9189750Sjkh#define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */ 9199750Sjkh#define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */ 9209750Sjkh#define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */ 92133473Sscrappy#define SOUND_MIXER_DIGITAL1 17 /* Digital (input) 1 */ 92233473Sscrappy#define SOUND_MIXER_DIGITAL2 18 /* Digital (input) 2 */ 92333473Sscrappy#define SOUND_MIXER_DIGITAL3 19 /* Digital (input) 3 */ 92433473Sscrappy#define SOUND_MIXER_PHONEIN 20 /* Phone input */ 92533473Sscrappy#define SOUND_MIXER_PHONEOUT 21 /* Phone output */ 92633473Sscrappy#define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */ 92733473Sscrappy#define SOUND_MIXER_RADIO 23 /* Radio in */ 92833473Sscrappy#define SOUND_MIXER_MONITOR 24 /* Monitor (usually mic) volume */ 929652Sjkh 93033473Sscrappy 93133473Sscrappy/* 93233473Sscrappy * Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) 93333473Sscrappy * Not counted to SOUND_MIXER_NRDEVICES, but use the same number space 93433473Sscrappy */ 935652Sjkh#define SOUND_ONOFF_MIN 28 936652Sjkh#define SOUND_ONOFF_MAX 30 937652Sjkh#define SOUND_MIXER_MUTE 28 /* 0 or 1 */ 938652Sjkh#define SOUND_MIXER_ENHANCE 29 /* Enhanced stereo (0, 40, 60 or 80) */ 939652Sjkh#define SOUND_MIXER_LOUD 30 /* 0 or 1 */ 940652Sjkh 941652Sjkh/* Note! Number 31 cannot be used since the sign bit is reserved */ 94233473Sscrappy#define SOUND_MIXER_NONE 31 943652Sjkh 94430866Smarkm#define SOUND_DEVICE_LABELS { \ 94530866Smarkm "Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ 94633473Sscrappy "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \ 94733473Sscrappy "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \ 94833473Sscrappy "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"} 949652Sjkh 95030866Smarkm#define SOUND_DEVICE_NAMES { \ 95130866Smarkm "vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ 95230866Smarkm "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \ 95333473Sscrappy "line1", "line2", "line3", "dig1", "dig2", "dig3", \ 95433473Sscrappy "phin", "phout", "video", "radio", "monitor"} 955652Sjkh 956652Sjkh/* Device bitmask identifiers */ 957652Sjkh 95830866Smarkm#define SOUND_MIXER_RECSRC 0xff /* 1 bit per recording source */ 95930866Smarkm#define SOUND_MIXER_DEVMASK 0xfe /* 1 bit per supported device */ 96030866Smarkm#define SOUND_MIXER_RECMASK 0xfd /* 1 bit per supp. recording source */ 961652Sjkh#define SOUND_MIXER_CAPS 0xfc 96230866Smarkm#define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only 1 rec. src at a time */ 963652Sjkh#define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ 964652Sjkh 965652Sjkh/* Device mask bits */ 966652Sjkh 967652Sjkh#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) 968652Sjkh#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) 969652Sjkh#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) 970652Sjkh#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) 971652Sjkh#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) 972652Sjkh#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) 973652Sjkh#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) 974652Sjkh#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) 975652Sjkh#define SOUND_MASK_CD (1 << SOUND_MIXER_CD) 976652Sjkh#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) 977652Sjkh#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) 978652Sjkh#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) 9799750Sjkh#define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN) 9809750Sjkh#define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN) 9819750Sjkh#define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1) 9829750Sjkh#define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2) 9839750Sjkh#define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3) 98433473Sscrappy#define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1) 98533473Sscrappy#define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2) 98633473Sscrappy#define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3) 98733473Sscrappy#define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN) 98833473Sscrappy#define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT) 98933473Sscrappy#define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO) 99033473Sscrappy#define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO) 99133473Sscrappy#define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR) 992652Sjkh 99333473Sscrappy/* Obsolete macros */ 994652Sjkh#define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) 995652Sjkh#define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) 996652Sjkh#define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) 997652Sjkh 998652Sjkh#define MIXER_READ(dev) _IOR('M', dev, int) 999652Sjkh#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) 1000652Sjkh#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) 1001652Sjkh#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) 1002652Sjkh#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) 1003652Sjkh#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) 1004652Sjkh#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) 1005652Sjkh#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) 1006652Sjkh#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) 1007652Sjkh#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) 1008652Sjkh#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) 1009652Sjkh#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) 1010652Sjkh#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) 10119750Sjkh#define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN) 10129750Sjkh#define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN) 10139750Sjkh#define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1) 10149750Sjkh#define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2) 10159750Sjkh#define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3) 101633473Sscrappy 101733473Sscrappy/* Obsolete macros */ 1018652Sjkh#define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) 1019652Sjkh#define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) 1020652Sjkh#define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) 1021652Sjkh 1022652Sjkh#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) 1023652Sjkh#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) 1024652Sjkh#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) 1025652Sjkh#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) 1026652Sjkh#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) 1027652Sjkh 1028652Sjkh#define MIXER_WRITE(dev) _IOWR('M', dev, int) 1029652Sjkh#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) 1030652Sjkh#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) 1031652Sjkh#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) 1032652Sjkh#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) 1033652Sjkh#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) 1034652Sjkh#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) 1035652Sjkh#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) 1036652Sjkh#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) 1037652Sjkh#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) 1038652Sjkh#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) 1039652Sjkh#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) 1040652Sjkh#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) 10419750Sjkh#define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN) 10429750Sjkh#define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN) 10439750Sjkh#define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1) 10449750Sjkh#define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2) 10459750Sjkh#define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3) 1046652Sjkh#define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) 1047652Sjkh#define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) 1048652Sjkh#define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) 1049652Sjkh 1050652Sjkh#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) 1051652Sjkh 105233473Sscrappy#define LEFT_CHN 0 105333473Sscrappy#define RIGHT_CHN 1 105433473Sscrappy 1055652Sjkh/* 10563256Sswallace * Level 2 event types for /dev/sequencer 10573256Sswallace */ 10583256Sswallace 10593256Sswallace/* 10603256Sswallace * The 4 most significant bits of byte 0 specify the class of 106165335Scg * the event: 1062652Sjkh * 10633256Sswallace * 0x8X = system level events, 10643256Sswallace * 0x9X = device/port specific events, event[1] = device/port, 10653256Sswallace * The last 4 bits give the subtype: 10663256Sswallace * 0x02 = Channel event (event[3] = chn). 10673256Sswallace * 0x01 = note event (event[4] = note). 10683256Sswallace * (0x01 is not used alone but always with bit 0x02). 10693256Sswallace * event[2] = MIDI message code (0x80=note off etc.) 10703256Sswallace * 1071652Sjkh */ 1072652Sjkh 10733256Sswallace#define EV_SEQ_LOCAL 0x80 10743256Sswallace#define EV_TIMING 0x81 10753256Sswallace#define EV_CHN_COMMON 0x92 10763256Sswallace#define EV_CHN_VOICE 0x93 107730866Smarkm#define EV_SYSEX 0x94 10783256Sswallace/* 10793256Sswallace * Event types 200 to 220 are reserved for application use. 10803256Sswallace * These numbers will not be used by the driver. 10813256Sswallace */ 1082652Sjkh 1083652Sjkh/* 10843256Sswallace * Events for event type EV_CHN_VOICE 1085652Sjkh */ 1086652Sjkh 10873256Sswallace#define MIDI_NOTEOFF 0x80 10883256Sswallace#define MIDI_NOTEON 0x90 10893256Sswallace#define MIDI_KEY_PRESSURE 0xA0 10903256Sswallace 1091652Sjkh/* 10923256Sswallace * Events for event type EV_CHN_COMMON 1093652Sjkh */ 1094652Sjkh 10953256Sswallace#define MIDI_CTL_CHANGE 0xB0 10963256Sswallace#define MIDI_PGM_CHANGE 0xC0 10973256Sswallace#define MIDI_CHN_PRESSURE 0xD0 10983256Sswallace#define MIDI_PITCH_BEND 0xE0 1099652Sjkh 11003256Sswallace#define MIDI_SYSTEM_PREFIX 0xF0 11013256Sswallace 1102652Sjkh/* 11033256Sswallace * Timer event types 11043256Sswallace */ 11053256Sswallace#define TMR_WAIT_REL 1 /* Time relative to the prev time */ 11063256Sswallace#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */ 11073256Sswallace#define TMR_STOP 3 11083256Sswallace#define TMR_START 4 11093256Sswallace#define TMR_CONTINUE 5 11103256Sswallace#define TMR_TEMPO 6 11113256Sswallace#define TMR_ECHO 8 11123256Sswallace#define TMR_CLOCK 9 /* MIDI clock */ 11133256Sswallace#define TMR_SPP 10 /* Song position pointer */ 11143256Sswallace#define TMR_TIMESIG 11 /* Time signature */ 11153256Sswallace 111630866Smarkm/* 111730866Smarkm * Local event types 111830866Smarkm */ 111930866Smarkm#define LOCL_STARTAUDIO 1 112030866Smarkm 112165335Scg#if (!defined(_KERNEL) && !defined(INKERNEL)) || defined(USE_SEQ_MACROS) 11223256Sswallace/* 1123652Sjkh * Some convenience macros to simplify programming of the 1124652Sjkh * /dev/sequencer interface 1125652Sjkh * 1126652Sjkh * These macros define the API which should be used when possible. 1127652Sjkh */ 1128652Sjkh 11293256Sswallace#ifndef USE_SIMPLE_MACROS 113092719Salfredvoid seqbuf_dump(void); /* This function must be provided by programs */ 1131652Sjkh 1132652Sjkh/* Sample seqbuf_dump() implementation: 1133652Sjkh * 1134652Sjkh * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes 1135652Sjkh * 1136652Sjkh * int seqfd; -- The file descriptor for /dev/sequencer. 1137652Sjkh * 1138652Sjkh * void 1139652Sjkh * seqbuf_dump () 1140652Sjkh * { 1141652Sjkh * if (_seqbufptr) 1142652Sjkh * if (write (seqfd, _seqbuf, _seqbufptr) == -1) 1143652Sjkh * { 1144652Sjkh * perror ("write /dev/sequencer"); 1145652Sjkh * exit (-1); 1146652Sjkh * } 1147652Sjkh * _seqbufptr = 0; 1148652Sjkh * } 1149652Sjkh */ 1150652Sjkh 115130866Smarkm#define SEQ_DEFINEBUF(len) \ 115230866Smarkm u_char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0 115330866Smarkm#define SEQ_USE_EXTBUF() \ 115430866Smarkm extern u_char _seqbuf[]; \ 115530866Smarkm extern int _seqbuflen;extern int _seqbufptr 11563256Sswallace#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF() 1157652Sjkh#define SEQ_PM_DEFINES struct patmgr_info _pm_info 115830866Smarkm#define _SEQ_NEEDBUF(len) \ 115930866Smarkm if ((_seqbufptr+(len)) > _seqbuflen) \ 116030866Smarkm seqbuf_dump() 1161652Sjkh#define _SEQ_ADVBUF(len) _seqbufptr += len 1162652Sjkh#define SEQ_DUMPBUF seqbuf_dump 11633256Sswallace#else 11643256Sswallace/* 11653256Sswallace * This variation of the sequencer macros is used just to format one event 11663256Sswallace * using fixed buffer. 116765335Scg * 11683256Sswallace * The program using the macro library must define the following macros before 11693256Sswallace * using this library. 11703256Sswallace * 117165335Scg * #define _seqbuf name of the buffer (u_char[]) 11723256Sswallace * #define _SEQ_ADVBUF(len) If the applic needs to know the exact 11733256Sswallace * size of the event, this macro can be used. 11743256Sswallace * Otherwise this must be defined as empty. 11753256Sswallace * #define _seqbufptr Define the name of index variable or 0 if 117665335Scg * not required. 11773256Sswallace */ 11783256Sswallace#define _SEQ_NEEDBUF(len) /* empty */ 11793256Sswallace#endif 11803256Sswallace 118130866Smarkm#define PM_LOAD_PATCH(dev, bank, pgm) \ 118230866Smarkm (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ 118330866Smarkm _pm_info.device=dev, _pm_info.data.data8[0]=pgm, \ 118430866Smarkm _pm_info.parm1 = bank, _pm_info.parm2 = 1, \ 118530866Smarkm ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) 118630866Smarkm#define PM_LOAD_PATCHES(dev, bank, pgm) \ 118730866Smarkm (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ 118830866Smarkm _pm_info.device=dev, bcopy( pgm, _pm_info.data.data8, 128), \ 118930866Smarkm _pm_info.parm1 = bank, _pm_info.parm2 = 128, \ 119030866Smarkm ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) 1191652Sjkh 119230866Smarkm#define SEQ_VOLUME_MODE(dev, mode) { \ 119330866Smarkm _SEQ_NEEDBUF(8);\ 119430866Smarkm _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 119530866Smarkm _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\ 119630866Smarkm _seqbuf[_seqbufptr+2] = (dev);\ 119730866Smarkm _seqbuf[_seqbufptr+3] = (mode);\ 119830866Smarkm _seqbuf[_seqbufptr+4] = 0;\ 119930866Smarkm _seqbuf[_seqbufptr+5] = 0;\ 120030866Smarkm _seqbuf[_seqbufptr+6] = 0;\ 120130866Smarkm _seqbuf[_seqbufptr+7] = 0;\ 120230866Smarkm _SEQ_ADVBUF(8);} 12031402Sache 12043256Sswallace/* 12053256Sswallace * Midi voice messages 12063256Sswallace */ 1207652Sjkh 120830866Smarkm#define _CHN_VOICE(dev, event, chn, note, parm) { \ 120930866Smarkm _SEQ_NEEDBUF(8);\ 121030866Smarkm _seqbuf[_seqbufptr] = EV_CHN_VOICE;\ 121130866Smarkm _seqbuf[_seqbufptr+1] = (dev);\ 121230866Smarkm _seqbuf[_seqbufptr+2] = (event);\ 121330866Smarkm _seqbuf[_seqbufptr+3] = (chn);\ 121430866Smarkm _seqbuf[_seqbufptr+4] = (note);\ 121530866Smarkm _seqbuf[_seqbufptr+5] = (parm);\ 121630866Smarkm _seqbuf[_seqbufptr+6] = (0);\ 121730866Smarkm _seqbuf[_seqbufptr+7] = 0;\ 121830866Smarkm _SEQ_ADVBUF(8);} 1219652Sjkh 12203256Sswallace#define SEQ_START_NOTE(dev, chn, note, vol) \ 12213256Sswallace _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol) 12223256Sswallace 12233256Sswallace#define SEQ_STOP_NOTE(dev, chn, note, vol) \ 12243256Sswallace _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol) 12253256Sswallace 12263256Sswallace#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \ 12273256Sswallace _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure) 12283256Sswallace 12293256Sswallace/* 12303256Sswallace * Midi channel messages 12313256Sswallace */ 12323256Sswallace 123330866Smarkm#define _CHN_COMMON(dev, event, chn, p1, p2, w14) { \ 123430866Smarkm _SEQ_NEEDBUF(8);\ 123530866Smarkm _seqbuf[_seqbufptr] = EV_CHN_COMMON;\ 123630866Smarkm _seqbuf[_seqbufptr+1] = (dev);\ 123730866Smarkm _seqbuf[_seqbufptr+2] = (event);\ 123830866Smarkm _seqbuf[_seqbufptr+3] = (chn);\ 123930866Smarkm _seqbuf[_seqbufptr+4] = (p1);\ 124030866Smarkm _seqbuf[_seqbufptr+5] = (p2);\ 124130866Smarkm *(short *)&_seqbuf[_seqbufptr+6] = (w14);\ 124230866Smarkm _SEQ_ADVBUF(8);} 124330866Smarkm/* 124430866Smarkm * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits 124530866Smarkm * sending any MIDI bytes but it's absolutely not possible. Trying to do 124630866Smarkm * so _will_ cause problems with MPU401 intelligent mode). 124730866Smarkm * 124865335Scg * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be 124930866Smarkm * sent by calling SEQ_SYSEX() several times (there must be no other events 125030866Smarkm * between them). First sysex fragment must have 0xf0 in the first byte 125130866Smarkm * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte 125230866Smarkm * between these sysex start and end markers cannot be larger than 0x7f. Also 125330866Smarkm * lengths of each fragments (except the last one) must be 6. 125430866Smarkm * 125530866Smarkm * Breaking the above rules may work with some MIDI ports but is likely to 125630866Smarkm * cause fatal problems with some other devices (such as MPU401). 125730866Smarkm */ 125830866Smarkm#define SEQ_SYSEX(dev, buf, len) { \ 125930866Smarkm int i, l=(len); if (l>6)l=6;\ 126030866Smarkm _SEQ_NEEDBUF(8);\ 126130866Smarkm _seqbuf[_seqbufptr] = EV_SYSEX;\ 126230866Smarkm for(i=0;i<l;i++)_seqbuf[_seqbufptr+i+1] = (buf)[i];\ 126330866Smarkm for(i=l;i<6;i++)_seqbuf[_seqbufptr+i+1] = 0xff;\ 126430866Smarkm _SEQ_ADVBUF(8);} 1265652Sjkh 12663256Sswallace#define SEQ_CHN_PRESSURE(dev, chn, pressure) \ 126730866Smarkm _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0) 12683256Sswallace 12693256Sswallace#define SEQ_SET_PATCH(dev, chn, patch) \ 127030866Smarkm _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0) 12713256Sswallace 12723256Sswallace#define SEQ_CONTROL(dev, chn, controller, value) \ 127330866Smarkm _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value) 12743256Sswallace 12753256Sswallace#define SEQ_BENDER(dev, chn, value) \ 127630866Smarkm _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value) 12773256Sswallace 12789750Sjkh 127930866Smarkm#define SEQ_V2_X_CONTROL(dev, voice, controller, value) { \ 128030866Smarkm _SEQ_NEEDBUF(8);\ 128130866Smarkm _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 128230866Smarkm _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\ 128330866Smarkm _seqbuf[_seqbufptr+2] = (dev);\ 128430866Smarkm _seqbuf[_seqbufptr+3] = (voice);\ 128530866Smarkm _seqbuf[_seqbufptr+4] = (controller);\ 128630866Smarkm *(short *)&_seqbuf[_seqbufptr+5] = (value);\ 128730866Smarkm _seqbuf[_seqbufptr+7] = 0;\ 128830866Smarkm _SEQ_ADVBUF(8);} 128930866Smarkm 12903256Sswallace/* 12913256Sswallace * The following 5 macros are incorrectly implemented and obsolete. 12923256Sswallace * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead. 12933256Sswallace */ 1294652Sjkh 129530866Smarkm#define SEQ_PITCHBEND(dev, voice, value) \ 129630866Smarkm SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value) 129730866Smarkm#define SEQ_BENDER_RANGE(dev, voice, value) \ 129830866Smarkm SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value) 129930866Smarkm#define SEQ_EXPRESSION(dev, voice, value) \ 130030866Smarkm SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128) 130130866Smarkm#define SEQ_MAIN_VOLUME(dev, voice, value) \ 130230866Smarkm SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100) 130330866Smarkm#define SEQ_PANNING(dev, voice, pos) \ 130430866Smarkm SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2) 130530866Smarkm 13063256Sswallace/* 130730866Smarkm * Timing and syncronization macros 13083256Sswallace */ 1309652Sjkh 131030866Smarkm#define _TIMER_EVENT(ev, parm) { \ 131130866Smarkm _SEQ_NEEDBUF(8);\ 131230866Smarkm _seqbuf[_seqbufptr+0] = EV_TIMING; \ 131330866Smarkm _seqbuf[_seqbufptr+1] = (ev); \ 131430866Smarkm _seqbuf[_seqbufptr+2] = 0;\ 131530866Smarkm _seqbuf[_seqbufptr+3] = 0;\ 131630866Smarkm *(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \ 131730866Smarkm _SEQ_ADVBUF(8); \ 131830866Smarkm } 1319652Sjkh 13203256Sswallace#define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0) 13213256Sswallace#define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0) 13223256Sswallace#define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0) 13233256Sswallace#define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks) 13243256Sswallace#define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks) 13253256Sswallace#define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key) 13263256Sswallace#define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value) 13273256Sswallace#define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos) 13283256Sswallace#define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig) 1329652Sjkh 13303256Sswallace/* 133130866Smarkm * Local control events 133230866Smarkm */ 133330866Smarkm 133430866Smarkm#define _LOCAL_EVENT(ev, parm) { \ 133530866Smarkm _SEQ_NEEDBUF(8);\ 133630866Smarkm _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \ 133730866Smarkm _seqbuf[_seqbufptr+1] = (ev); \ 133830866Smarkm _seqbuf[_seqbufptr+2] = 0;\ 133930866Smarkm _seqbuf[_seqbufptr+3] = 0;\ 134030866Smarkm *(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \ 134130866Smarkm _SEQ_ADVBUF(8); \ 134230866Smarkm } 134330866Smarkm 134430866Smarkm#define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask) 134530866Smarkm/* 13469750Sjkh * Events for the level 1 interface only 13473256Sswallace */ 1348652Sjkh 134930866Smarkm#define SEQ_MIDIOUT(device, byte) { \ 135030866Smarkm _SEQ_NEEDBUF(4);\ 135130866Smarkm _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\ 135230866Smarkm _seqbuf[_seqbufptr+1] = (byte);\ 135330866Smarkm _seqbuf[_seqbufptr+2] = (device);\ 135430866Smarkm _seqbuf[_seqbufptr+3] = 0;\ 135530866Smarkm _SEQ_ADVBUF(4);} 13563256Sswallace 13573256Sswallace/* 13583256Sswallace * Patch loading. 13593256Sswallace */ 136030866Smarkm#define SEQ_WRPATCH(patchx, len) { \ 136130866Smarkm if (_seqbufptr) seqbuf_dump(); \ 136230866Smarkm if (write(seqfd, (char*)(patchx), len)==-1) \ 136330866Smarkm perror("Write patch: /dev/sequencer"); \ 136430866Smarkm } 1365652Sjkh 136630866Smarkm#define SEQ_WRPATCH2(patchx, len) \ 136730866Smarkm ( seqbuf_dump(), write(seqfd, (char*)(patchx), len) ) 136818444Sbde 136930866Smarkm#endif 137033473Sscrappy 137133473Sscrappy/* 137233473Sscrappy * Here I have moved all the aliases for ioctl names. 137333473Sscrappy */ 137433473Sscrappy 137533473Sscrappy#define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT 137633473Sscrappy#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT 137733473Sscrappy#define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT 137833473Sscrappy 137933473Sscrappy#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED 138033473Sscrappy#define SOUND_PCM_POST SNDCTL_DSP_POST 138133473Sscrappy#define SOUND_PCM_RESET SNDCTL_DSP_RESET 138233473Sscrappy#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC 138333473Sscrappy#define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE 138433473Sscrappy#define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT 138533473Sscrappy#define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS 138633473Sscrappy#define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE 138733473Sscrappy#define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE 138833473Sscrappy#define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK 138933473Sscrappy#define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS 139033473Sscrappy#define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER 139133473Sscrappy#define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER 139233473Sscrappy#define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO 139333473Sscrappy#define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR 139433473Sscrappy#define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR 139533473Sscrappy#define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF 139633473Sscrappy#define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF 139733473Sscrappy 139850906Sdfr#endif /* !_SYS_SOUNDCARD_H_ */ 1399