soundcard.h revision 33473
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 5233473Sscrappy#include <sys/types.h> 5333473Sscrappy#ifndef _IOWR 5433473Sscrappy#include <sys/ioccom.h> 5533473Sscrappy#endif /* !_IOWR */ 56652Sjkh 57652Sjkh/* 5833473Sscrappy * The first part of this file contains the new FreeBSD sound ioctl 5933473Sscrappy * interface. Tries to minimize the number of different ioctls, and 6033473Sscrappy * to be reasonably general. 6133473Sscrappy * 6233473Sscrappy * 970821: some of the new calls have not been implemented yet. 63652Sjkh */ 64652Sjkh 6533473Sscrappy/* 6633473Sscrappy * the following three calls extend the generic file descriptor 6733473Sscrappy * interface. AIONWRITE is the dual of FIONREAD, i.e. returns the max 6833473Sscrappy * number of bytes for a write operation to be non-blocking. 6933473Sscrappy * 7033473Sscrappy * AIOGSIZE/AIOSSIZE are used to change the behaviour of the device, 7133473Sscrappy * from a character device (default) to a block device. In block mode, 7233473Sscrappy * (not to be confused with blocking mode) the main difference for the 7333473Sscrappy * application is that select() will return only when a complete 7433473Sscrappy * block can be read/written to the device, whereas in character mode 7533473Sscrappy * select will return true when one byte can be exchanged. For audio 7633473Sscrappy * devices, character mode makes select almost useless since one byte 7733473Sscrappy * will always be ready by the next sample time (which is often only a 7833473Sscrappy * handful of microseconds away). 7933473Sscrappy * Use a size of 0 or 1 to return to character mode. 8033473Sscrappy */ 8133473Sscrappy#define AIONWRITE _IOR('A', 10, int) /* get # bytes to write */ 8233473Sscrappystruct snd_size { 8333473Sscrappy int play_size; 8433473Sscrappy int rec_size; 8533473Sscrappy}; 8633473Sscrappy#define AIOGSIZE _IOR('A', 11, struct snd_size)/* read current blocksize */ 8733473Sscrappy#define AIOSSIZE _IOWR('A', 11, struct snd_size) /* sets blocksize */ 88652Sjkh 8930866Smarkm/* 9033473Sscrappy * The following constants define supported audio formats. The 9133473Sscrappy * encoding follows voxware conventions, i.e. 1 bit for each supported 9233473Sscrappy * format. We extend it by using bit 31 (RO) to indicate full-duplex 9333473Sscrappy * capability, and bit 29 (RO) to indicate that the card supports/ 9433473Sscrappy * needs different formats on capture & playback channels. 9533473Sscrappy * Bit 29 (RW) is used to indicate/ask stereo. 9633473Sscrappy */ 9733473Sscrappy 9833473Sscrappy# define AFMT_QUERY 0x00000000 /* Return current fmt */ 9933473Sscrappy# define AFMT_MU_LAW 0x00000001 10033473Sscrappy# define AFMT_A_LAW 0x00000002 10133473Sscrappy# define AFMT_IMA_ADPCM 0x00000004 10233473Sscrappy# define AFMT_U8 0x00000008 10333473Sscrappy# define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/ 10433473Sscrappy# define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */ 10533473Sscrappy# define AFMT_S8 0x00000040 10633473Sscrappy# define AFMT_U16_LE 0x00000080 /* Little endian U16 */ 10733473Sscrappy# define AFMT_U16_BE 0x00000100 /* Big endian U16 */ 10833473Sscrappy# define AFMT_MPEG 0x00000200 /* MPEG (2) audio */ 10933473Sscrappy 11033473Sscrappy# define AFMT_STEREO 0x10000000 /* can do/want stereo */ 11133473Sscrappy 11233473Sscrappy/* 11333473Sscrappy * the following are really capabilities 11433473Sscrappy */ 11533473Sscrappy# define AFMT_WEIRD 0x20000000 /* weird hardware... */ 11633473Sscrappy /* 11733473Sscrappy * AFMT_WEIRD reports that the hardware might need to operate 11833473Sscrappy * with different formats in the playback and capture 11933473Sscrappy * channels when operating in full duplex. 12033473Sscrappy * As an example, SoundBlaster16 cards only support U8 in one 12133473Sscrappy * direction and S16 in the other one, and applications should 12233473Sscrappy * be aware of this limitation. 12333473Sscrappy */ 12433473Sscrappy# define AFMT_FULLDUPLEX 0x80000000 /* can do full duplex */ 12533473Sscrappy 12633473Sscrappy/* 12733473Sscrappy * The following structure is used to get/set format and sampling rate. 12833473Sscrappy * While it would be better to have things such as stereo, bits per 12933473Sscrappy * sample, endiannes, etc split in different variables, it turns out 13033473Sscrappy * that formats are not that many, and not all combinations are possible. 13133473Sscrappy * So we followed the Voxware approach of associating one bit to each 13233473Sscrappy * format. 13333473Sscrappy */ 13433473Sscrappy 13533473Sscrappytypedef struct _snd_chan_param { 13633473Sscrappy u_long play_rate; /* sampling rate */ 13733473Sscrappy u_long rec_rate; /* sampling rate */ 13833473Sscrappy u_long play_format; /* everything describing the format */ 13933473Sscrappy u_long rec_format; /* everything describing the format */ 14033473Sscrappy} snd_chan_param; 14133473Sscrappy#define AIOGFMT _IOR('f', 12, snd_chan_param) /* get format */ 14233473Sscrappy#define AIOSFMT _IOWR('f', 12, snd_chan_param) /* sets format */ 14333473Sscrappy 14433473Sscrappy/* 14533473Sscrappy * The following structure is used to get/set the mixer setting. 14633473Sscrappy * Up to 32 mixers are supported, each one with up to 32 channels. 14733473Sscrappy */ 14833473Sscrappytypedef struct _snd_mix_param { 14933473Sscrappy u_char subdev; /* which output */ 15033473Sscrappy u_char line; /* which input */ 15133473Sscrappy u_char left,right; /* volumes, 0..255, 0 = mute */ 15233473Sscrappy} snd_mix_param ; 15333473Sscrappy 15433473Sscrappy/* XXX AIOGMIX, AIOSMIX not implemented yet */ 15533473Sscrappy#define AIOGMIX _IOWR('A', 13, snd_mix_param) /* return mixer status */ 15633473Sscrappy#define AIOSMIX _IOWR('A', 14, snd_mix_param) /* sets mixer status */ 15733473Sscrappy 15833473Sscrappy/* 15933473Sscrappy * channel specifiers used in AIOSTOP and AIOSYNC 16033473Sscrappy */ 16133473Sscrappy#define AIOSYNC_PLAY 0x1 /* play chan */ 16233473Sscrappy#define AIOSYNC_CAPTURE 0x2 /* capture chan */ 16333473Sscrappy/* AIOSTOP stop & flush a channel, returns the residual count */ 16433473Sscrappy#define AIOSTOP _IOWR ('A', 15, int) 16533473Sscrappy 16633473Sscrappy/* alternate method used to notify the sync condition */ 16733473Sscrappy#define AIOSYNC_SIGNAL 0x100 16833473Sscrappy#define AIOSYNC_SELECT 0x200 16933473Sscrappy 17033473Sscrappy/* what the 'pos' field refers to */ 17133473Sscrappy#define AIOSYNC_READY 0x400 17233473Sscrappy#define AIOSYNC_FREE 0x800 17333473Sscrappy 17433473Sscrappytypedef struct _snd_sync_parm { 17533473Sscrappy long chan ; /* play or capture channel, plus modifier */ 17633473Sscrappy long pos; 17733473Sscrappy} snd_sync_parm; 17833473Sscrappy#define AIOSYNC _IOWR ('A', 15, snd_sync_parm) /* misc. synchronization */ 17933473Sscrappy 18033473Sscrappy/* 18133473Sscrappy * The following is used to return device capabilities. If the structure 18233473Sscrappy * passed to the ioctl is zeroed, default values are returned for rate 18333473Sscrappy * and formats, a bitmap of available mixers is returned, and values 18433473Sscrappy * (inputs, different levels) for the first one are returned. 18533473Sscrappy * 18633473Sscrappy * If formats, mixers, inputs are instantiated, then detailed info 18733473Sscrappy * are returned depending on the call. 18833473Sscrappy */ 18933473Sscrappytypedef struct _snd_capabilities { 19033473Sscrappy u_long rate_min, rate_max; /* min-max sampling rate */ 19133473Sscrappy u_long formats; 19233473Sscrappy u_long bufsize; /* DMA buffer size */ 19333473Sscrappy u_long mixers; /* bitmap of available mixers */ 19433473Sscrappy u_long inputs; /* bitmap of available inputs (per mixer) */ 19533473Sscrappy u_short left, right; /* how many levels are supported */ 19633473Sscrappy} snd_capabilities; 19733473Sscrappy#define AIOGCAP _IOWR('A', 15, snd_capabilities) /* get capabilities */ 19833473Sscrappy 19933473Sscrappy/* 20033473Sscrappy * here is the old (Voxware) ioctl interface 20133473Sscrappy */ 20233473Sscrappy 20333473Sscrappy/* 204652Sjkh * IOCTL Commands for /dev/sequencer 205652Sjkh */ 206652Sjkh 20733473Sscrappy#define SNDCTL_SEQ_RESET _IO ('Q', 0) 20833473Sscrappy#define SNDCTL_SEQ_SYNC _IO ('Q', 1) 20933473Sscrappy#define SNDCTL_SYNTH_INFO _IOWR('Q', 2, struct synth_info) 21033473Sscrappy#define SNDCTL_SEQ_CTRLRATE _IOWR('Q', 3, int) /* Set/get timer res.(hz) */ 21133473Sscrappy#define SNDCTL_SEQ_GETOUTCOUNT _IOR ('Q', 4, int) 21233473Sscrappy#define SNDCTL_SEQ_GETINCOUNT _IOR ('Q', 5, int) 21333473Sscrappy#define SNDCTL_SEQ_PERCMODE _IOW ('Q', 6, int) 21433473Sscrappy#define SNDCTL_FM_LOAD_INSTR _IOW ('Q', 7, struct sbi_instrument) /* Valid for FM only */ 21533473Sscrappy#define SNDCTL_SEQ_TESTMIDI _IOW ('Q', 8, int) 21633473Sscrappy#define SNDCTL_SEQ_RESETSAMPLES _IOW ('Q', 9, int) 21733473Sscrappy#define SNDCTL_SEQ_NRSYNTHS _IOR ('Q',10, int) 21833473Sscrappy#define SNDCTL_SEQ_NRMIDIS _IOR ('Q',11, int) 21933473Sscrappy#define SNDCTL_MIDI_INFO _IOWR('Q',12, struct midi_info) 22033473Sscrappy#define SNDCTL_SEQ_THRESHOLD _IOW ('Q',13, int) 22133473Sscrappy#define SNDCTL_SEQ_TRESHOLD SNDCTL_SEQ_THRESHOLD /* there was once a typo */ 22233473Sscrappy#define SNDCTL_SYNTH_MEMAVL _IOWR('Q',14, int) /* in=dev#, out=memsize */ 22333473Sscrappy#define SNDCTL_FM_4OP_ENABLE _IOW ('Q',15, int) /* in=dev# */ 22433473Sscrappy#define SNDCTL_PMGR_ACCESS _IOWR('Q',16, struct patmgr_info) 22533473Sscrappy#define SNDCTL_SEQ_PANIC _IO ('Q',17) 22633473Sscrappy#define SNDCTL_SEQ_OUTOFBAND _IOW ('Q',18, struct seq_event_rec) 2279750Sjkh 22830866Smarkmstruct seq_event_rec { 22930866Smarkm u_char arr[8]; 23030866Smarkm}; 2319750Sjkh 23233473Sscrappy#define SNDCTL_TMR_TIMEBASE _IOWR('T', 1, int) 23333473Sscrappy#define SNDCTL_TMR_START _IO ('T', 2) 23433473Sscrappy#define SNDCTL_TMR_STOP _IO ('T', 3) 23533473Sscrappy#define SNDCTL_TMR_CONTINUE _IO ('T', 4) 23633473Sscrappy#define SNDCTL_TMR_TEMPO _IOWR('T', 5, int) 23733473Sscrappy#define SNDCTL_TMR_SOURCE _IOWR('T', 6, int) 23833473Sscrappy# define TMR_INTERNAL 0x00000001 23933473Sscrappy# define TMR_EXTERNAL 0x00000002 24033473Sscrappy# define TMR_MODE_MIDI 0x00000010 24133473Sscrappy# define TMR_MODE_FSK 0x00000020 24233473Sscrappy# define TMR_MODE_CLS 0x00000040 24333473Sscrappy# define TMR_MODE_SMPTE 0x00000080 24433473Sscrappy#define SNDCTL_TMR_METRONOME _IOW ('T', 7, int) 24533473Sscrappy#define SNDCTL_TMR_SELECT _IOW ('T', 8, int) 2463256Sswallace 247652Sjkh/* 24830866Smarkm * Endian aware patch key generation algorithm. 24930866Smarkm */ 25030866Smarkm 25130866Smarkm#if defined(_AIX) || defined(AIX) 25230866Smarkm# define _PATCHKEY(id) (0xfd00|id) 25330866Smarkm#else 25430866Smarkm# define _PATCHKEY(id) ((id<<8)|0xfd) 25530866Smarkm#endif 25630866Smarkm 25730866Smarkm/* 258652Sjkh * Sample loading mechanism for internal synthesizers (/dev/sequencer) 259652Sjkh * The following patch_info structure has been designed to support 260652Sjkh * Gravis UltraSound. It tries to be universal format for uploading 26133473Sscrappy * sample based patches but is probably too limited. 262652Sjkh */ 263652Sjkh 264652Sjkhstruct patch_info { 26530866Smarkm/* u_short key; Use GUS_PATCH here */ 26630866Smarkm short key; /* Use GUS_PATCH here */ 26730866Smarkm#define GUS_PATCH _PATCHKEY(0x04) 26830866Smarkm#define OBSOLETE_GUS_PATCH _PATCHKEY(0x02) 269652Sjkh 27030866Smarkm short device_no; /* Synthesizer number */ 27130866Smarkm short instr_no; /* Midi pgm# */ 27230866Smarkm 27330866Smarkm u_long mode; 274652Sjkh/* 275652Sjkh * The least significant byte has the same format than the GUS .PAT 276652Sjkh * files 277652Sjkh */ 278652Sjkh#define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ 279652Sjkh#define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ 280652Sjkh#define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ 281652Sjkh#define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ 282652Sjkh#define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ 283652Sjkh#define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ 284652Sjkh#define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ 285652Sjkh /* (use the env_rate/env_offs fields). */ 286652Sjkh/* Linux specific bits */ 287652Sjkh#define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ 288652Sjkh#define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ 289652Sjkh#define WAVE_SCALE 0x00040000 /* The scaling info is valid */ 290652Sjkh/* Other bits must be zeroed */ 291652Sjkh 29230866Smarkm long len; /* Size of the wave data in bytes */ 29330866Smarkm long loop_start, loop_end; /* Byte offsets from the beginning */ 294652Sjkh 2959750Sjkh/* 296652Sjkh * The base_freq and base_note fields are used when computing the 297652Sjkh * playback speed for a note. The base_note defines the tone frequency 298652Sjkh * which is heard if the sample is played using the base_freq as the 299652Sjkh * playback speed. 300652Sjkh * 301652Sjkh * The low_note and high_note fields define the minimum and maximum note 302652Sjkh * frequencies for which this sample is valid. It is possible to define 303652Sjkh * more than one samples for a instrument number at the same time. The 304652Sjkh * low_note and high_note fields are used to select the most suitable one. 305652Sjkh * 306652Sjkh * The fields base_note, high_note and low_note should contain 307652Sjkh * the note frequency multiplied by 1000. For example value for the 308652Sjkh * middle A is 440*1000. 309652Sjkh */ 310652Sjkh 31130866Smarkm u_int base_freq; 31230866Smarkm u_long base_note; 31330866Smarkm u_long high_note; 31430866Smarkm u_long low_note; 31530866Smarkm int panning; /* -128=left, 127=right */ 31630866Smarkm int detuning; 317652Sjkh 318652Sjkh/* New fields introduced in version 1.99.5 */ 319652Sjkh 320652Sjkh /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ 32130866Smarkm u_char env_rate[ 6 ]; /* GUS HW ramping rate */ 32230866Smarkm u_char env_offset[ 6 ]; /* 255 == 100% */ 323652Sjkh 3249750Sjkh /* 325652Sjkh * The tremolo, vibrato and scale info are not supported yet. 326652Sjkh * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or 327652Sjkh * WAVE_SCALE 328652Sjkh */ 329652Sjkh 33030866Smarkm u_char tremolo_sweep; 33130866Smarkm u_char tremolo_rate; 33230866Smarkm u_char tremolo_depth; 333652Sjkh 33430866Smarkm u_char vibrato_sweep; 33530866Smarkm u_char vibrato_rate; 33630866Smarkm u_char vibrato_depth; 33730866Smarkm 33830866Smarkm int scale_frequency; 33930866Smarkm u_int scale_factor; /* from 0 to 2048 or 0 to 2 */ 3409750Sjkh 34130866Smarkm int volume; 34230866Smarkm int spare[4]; 34330866Smarkm char data[1]; /* The waveform data starts here */ 34430866Smarkm}; 345652Sjkh 3463256Sswallacestruct sysex_info { 34730866Smarkm short key; /* Use GUS_PATCH here */ 34830866Smarkm#define SYSEX_PATCH _PATCHKEY(0x05) 34930866Smarkm#define MAUI_PATCH _PATCHKEY(0x06) 35030866Smarkm short device_no; /* Synthesizer number */ 35130866Smarkm long len; /* Size of the sysex data in bytes */ 35230866Smarkm u_char data[1]; /* Sysex data starts here */ 35330866Smarkm}; 3543256Sswallace 355652Sjkh/* 356652Sjkh * Patch management interface (/dev/sequencer, /dev/patmgr#) 357652Sjkh * Don't use these calls if you want to maintain compatibility with 358652Sjkh * the future versions of the driver. 359652Sjkh */ 360652Sjkh 36133473Sscrappy#define PS_NO_PATCHES 0 /* No patch support on device */ 36233473Sscrappy#define PS_MGR_NOT_OK 1 /* Plain patch support (no mgr) */ 36333473Sscrappy#define PS_MGR_OK 2 /* Patch manager supported */ 36433473Sscrappy#define PS_MANAGED 3 /* Patch manager running */ 365652Sjkh 366652Sjkh#define SNDCTL_PMGR_IFACE _IOWR('P', 1, struct patmgr_info) 367652Sjkh 368652Sjkh/* 369652Sjkh * The patmgr_info is a fixed size structure which is used for two 370652Sjkh * different purposes. The intended use is for communication between 371652Sjkh * the application using /dev/sequencer and the patch manager daemon 372652Sjkh * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)). 373652Sjkh * 374652Sjkh * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows 375652Sjkh * a patch manager daemon to read and write device parameters. This 376652Sjkh * ioctl available through /dev/sequencer also. Avoid using it since it's 3779750Sjkh * extremely hardware dependent. In addition access trough /dev/sequencer 378652Sjkh * may confuse the patch manager daemon. 379652Sjkh */ 380652Sjkh 381652Sjkhstruct patmgr_info { /* Note! size must be < 4k since kmalloc() is used */ 38230866Smarkm u_long key; /* Don't worry. Reserved for communication 383652Sjkh between the patch manager and the driver. */ 384652Sjkh#define PM_K_EVENT 1 /* Event from the /dev/sequencer driver */ 385652Sjkh#define PM_K_COMMAND 2 /* Request from a application */ 386652Sjkh#define PM_K_RESPONSE 3 /* From patmgr to application */ 387652Sjkh#define PM_ERROR 4 /* Error returned by the patmgr */ 388652Sjkh int device; 389652Sjkh int command; 390652Sjkh 3919750Sjkh/* 3929750Sjkh * Commands 0x000 to 0xfff reserved for patch manager programs 393652Sjkh */ 394652Sjkh#define PM_GET_DEVTYPE 1 /* Returns type of the patch mgr interface of dev */ 395652Sjkh#define PMTYPE_FM2 1 /* 2 OP fm */ 396652Sjkh#define PMTYPE_FM4 2 /* Mixed 4 or 2 op FM (OPL-3) */ 397652Sjkh#define PMTYPE_WAVE 3 /* Wave table synthesizer (GUS) */ 398652Sjkh#define PM_GET_NRPGM 2 /* Returns max # of midi programs in parm1 */ 399652Sjkh#define PM_GET_PGMMAP 3 /* Returns map of loaded midi programs in data8 */ 400652Sjkh#define PM_GET_PGM_PATCHES 4 /* Return list of patches of a program (parm1) */ 401652Sjkh#define PM_GET_PATCH 5 /* Return patch header of patch parm1 */ 402652Sjkh#define PM_SET_PATCH 6 /* Set patch header of patch parm1 */ 403652Sjkh#define PM_READ_PATCH 7 /* Read patch (wave) data */ 404652Sjkh#define PM_WRITE_PATCH 8 /* Write patch (wave) data */ 405652Sjkh 406652Sjkh/* 407652Sjkh * Commands 0x1000 to 0xffff are for communication between the patch manager 408652Sjkh * and the client 409652Sjkh */ 410652Sjkh#define _PM_LOAD_PATCH 0x100 411652Sjkh 4129750Sjkh/* 413652Sjkh * Commands above 0xffff reserved for device specific use 414652Sjkh */ 415652Sjkh 41630866Smarkm long parm1; 41730866Smarkm long parm2; 41830866Smarkm long parm3; 419652Sjkh 42030866Smarkm union { 42130866Smarkm u_char data8[4000]; 42230866Smarkm u_short data16[2000]; 42330866Smarkm u_long data32[1000]; 424652Sjkh struct patch_info patch; 42530866Smarkm } data; 42630866Smarkm}; 427652Sjkh 428652Sjkh/* 429652Sjkh * When a patch manager daemon is present, it will be informed by the 430652Sjkh * driver when something important happens. For example when the 431652Sjkh * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is 432652Sjkh * returned. The command field contains the event type: 433652Sjkh */ 434652Sjkh#define PM_E_OPENED 1 /* /dev/sequencer opened */ 435652Sjkh#define PM_E_CLOSED 2 /* /dev/sequencer closed */ 436652Sjkh#define PM_E_PATCH_RESET 3 /* SNDCTL_RESETSAMPLES called */ 437652Sjkh#define PM_E_PATCH_LOADED 4 /* A patch has been loaded by appl */ 438652Sjkh 439652Sjkh/* 440652Sjkh * /dev/sequencer input events. 441652Sjkh * 442652Sjkh * The data written to the /dev/sequencer is a stream of events. Events 4439750Sjkh * are records of 4 or 8 bytes. The first byte defines the size. 444652Sjkh * Any number of events can be written with a write call. There 445652Sjkh * is a set of macros for sending these events. Use these macros if you 446652Sjkh * want to maximize portability of your program. 447652Sjkh * 448652Sjkh * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. 449652Sjkh * (All input events are currently 4 bytes long. Be prepared to support 4503256Sswallace * 8 byte events also. If you receive any event having first byte >= 128, 451652Sjkh * it's a 8 byte event. 452652Sjkh * 453652Sjkh * The events are documented at the end of this file. 454652Sjkh * 455652Sjkh * Normal events (4 bytes) 456652Sjkh * There is also a 8 byte version of most of the 4 byte events. The 457652Sjkh * 8 byte one is recommended. 458652Sjkh */ 459652Sjkh#define SEQ_NOTEOFF 0 460652Sjkh#define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ 461652Sjkh#define SEQ_NOTEON 1 462652Sjkh#define SEQ_FMNOTEON SEQ_NOTEON 4633256Sswallace#define SEQ_WAIT TMR_WAIT_ABS 464652Sjkh#define SEQ_PGMCHANGE 3 465652Sjkh#define SEQ_FMPGMCHANGE SEQ_PGMCHANGE 4663256Sswallace#define SEQ_SYNCTIMER TMR_START 467652Sjkh#define SEQ_MIDIPUTC 5 468652Sjkh#define SEQ_DRUMON 6 /*** OBSOLETE ***/ 469652Sjkh#define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ 4703256Sswallace#define SEQ_ECHO TMR_ECHO /* For synching programs with output */ 471652Sjkh#define SEQ_AFTERTOUCH 9 472652Sjkh#define SEQ_CONTROLLER 10 4733256Sswallace 47433473Sscrappy/* 4753256Sswallace * Midi controller numbers 47633473Sscrappy * 47733473Sscrappy * Controllers 0 to 31 (0x00 to 0x1f) and 32 to 63 (0x20 to 0x3f) 47833473Sscrappy * are continuous controllers. 47933473Sscrappy * In the MIDI 1.0 these controllers are sent using two messages. 48033473Sscrappy * Controller numbers 0 to 31 are used to send the MSB and the 48133473Sscrappy * controller numbers 32 to 63 are for the LSB. Note that just 7 bits 48233473Sscrappy * are used in MIDI bytes. 4833256Sswallace */ 4843256Sswallace 48533473Sscrappy#define CTL_BANK_SELECT 0x00 48633473Sscrappy#define CTL_MODWHEEL 0x01 48733473Sscrappy#define CTL_BREATH 0x02 48833473Sscrappy/* undefined 0x03 */ 48933473Sscrappy#define CTL_FOOT 0x04 49033473Sscrappy#define CTL_PORTAMENTO_TIME 0x05 49133473Sscrappy#define CTL_DATA_ENTRY 0x06 49233473Sscrappy#define CTL_MAIN_VOLUME 0x07 49333473Sscrappy#define CTL_BALANCE 0x08 49433473Sscrappy/* undefined 0x09 */ 49533473Sscrappy#define CTL_PAN 0x0a 49633473Sscrappy#define CTL_EXPRESSION 0x0b 49733473Sscrappy/* undefined 0x0c - 0x0f */ 49833473Sscrappy#define CTL_GENERAL_PURPOSE1 0x10 49933473Sscrappy#define CTL_GENERAL_PURPOSE2 0x11 50033473Sscrappy#define CTL_GENERAL_PURPOSE3 0x12 50133473Sscrappy#define CTL_GENERAL_PURPOSE4 0x13 50233473Sscrappy/* undefined 0x14 - 0x1f */ 5033256Sswallace 50433473Sscrappy/* undefined 0x20 */ 5053256Sswallace 50633473Sscrappy/* 50733473Sscrappy * The controller numbers 0x21 to 0x3f are reserved for the 50833473Sscrappy * least significant bytes of the controllers 0x00 to 0x1f. 50933473Sscrappy * These controllers are not recognised by the driver. 51033473Sscrappy * 51133473Sscrappy * Controllers 64 to 69 (0x40 to 0x45) are on/off switches. 51233473Sscrappy * 0=OFF and 127=ON (intermediate values are possible) 51333473Sscrappy */ 51433473Sscrappy#define CTL_DAMPER_PEDAL 0x40 51533473Sscrappy#define CTL_SUSTAIN CTL_DAMPER_PEDAL /* Alias */ 51633473Sscrappy#define CTL_HOLD CTL_DAMPER_PEDAL /* Alias */ 51733473Sscrappy#define CTL_PORTAMENTO 0x41 51833473Sscrappy#define CTL_SOSTENUTO 0x42 51933473Sscrappy#define CTL_SOFT_PEDAL 0x43 52033473Sscrappy/* undefined 0x44 */ 52133473Sscrappy#define CTL_HOLD2 0x45 52233473Sscrappy/* undefined 0x46 - 0x4f */ 5233256Sswallace 52433473Sscrappy#define CTL_GENERAL_PURPOSE5 0x50 52533473Sscrappy#define CTL_GENERAL_PURPOSE6 0x51 52633473Sscrappy#define CTL_GENERAL_PURPOSE7 0x52 52733473Sscrappy#define CTL_GENERAL_PURPOSE8 0x53 52833473Sscrappy/* undefined 0x54 - 0x5a */ 52933473Sscrappy#define CTL_EXT_EFF_DEPTH 0x5b 53033473Sscrappy#define CTL_TREMOLO_DEPTH 0x5c 53133473Sscrappy#define CTL_CHORUS_DEPTH 0x5d 53233473Sscrappy#define CTL_DETUNE_DEPTH 0x5e 53333473Sscrappy#define CTL_CELESTE_DEPTH CTL_DETUNE_DEPTH /* Alias for the above one */ 53433473Sscrappy#define CTL_PHASER_DEPTH 0x5f 53533473Sscrappy#define CTL_DATA_INCREMENT 0x60 53633473Sscrappy#define CTL_DATA_DECREMENT 0x61 53733473Sscrappy#define CTL_NONREG_PARM_NUM_LSB 0x62 53833473Sscrappy#define CTL_NONREG_PARM_NUM_MSB 0x63 53933473Sscrappy#define CTL_REGIST_PARM_NUM_LSB 0x64 54033473Sscrappy#define CTL_REGIST_PARM_NUM_MSB 0x65 54133473Sscrappy/* undefined 0x66 - 0x78 */ 54233473Sscrappy/* reserved 0x79 - 0x7f */ 5433256Sswallace 5443256Sswallace/* Pseudo controllers (not midi compatible) */ 54533473Sscrappy#define CTRL_PITCH_BENDER 255 54633473Sscrappy#define CTRL_PITCH_BENDER_RANGE 254 54733473Sscrappy#define CTRL_EXPRESSION 253 /* Obsolete */ 54833473Sscrappy#define CTRL_MAIN_VOLUME 252 /* Obsolete */ 54933473Sscrappy 550652Sjkh#define SEQ_BALANCE 11 5511402Sache#define SEQ_VOLMODE 12 552652Sjkh 553652Sjkh/* 5541402Sache * Volume mode decides how volumes are used 5551402Sache */ 5561402Sache 5571402Sache#define VOL_METHOD_ADAGIO 1 5581402Sache#define VOL_METHOD_LINEAR 2 5591402Sache 5601402Sache/* 561652Sjkh * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as 562652Sjkh * input events. 563652Sjkh */ 564652Sjkh 565652Sjkh/* 566652Sjkh * Event codes 0xf0 to 0xfc are reserved for future extensions. 567652Sjkh */ 568652Sjkh 569652Sjkh#define SEQ_FULLSIZE 0xfd /* Long events */ 570652Sjkh/* 57133473Sscrappy * SEQ_FULLSIZE events are used for loading patches/samples to the 57233473Sscrappy * synthesizer devices. These events are passed directly to the driver 57333473Sscrappy * of the associated synthesizer device. There is no limit to the size 57433473Sscrappy * of the extended events. These events are not queued but executed 57533473Sscrappy * immediately when the write() is called (execution can take several 57633473Sscrappy * seconds of time). 577652Sjkh * 57833473Sscrappy * When a SEQ_FULLSIZE message is written to the device, it must 57933473Sscrappy * be written using exactly one write() call. Other events cannot 58033473Sscrappy * be mixed to the same write. 58133473Sscrappy * 58233473Sscrappy * For FM synths (YM3812/OPL3) use struct sbi_instrument and write 58333473Sscrappy * it to the /dev/sequencer. Don't write other data together with 58433473Sscrappy * the instrument structure Set the key field of the structure to 58533473Sscrappy * FM_PATCH. The device field is used to route the patch to the 58633473Sscrappy * corresponding device. 587652Sjkh * 58833473Sscrappy * For Gravis UltraSound use struct patch_info. Initialize the key field 58933473Sscrappy * to GUS_PATCH. 590652Sjkh */ 59133473Sscrappy#define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ 59233473Sscrappy#define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */ 593652Sjkh 594652Sjkh/* 595652Sjkh * Record for FM patches 596652Sjkh */ 597652Sjkh 59830866Smarkmtypedef u_char sbi_instr_data[32]; 599652Sjkh 600652Sjkhstruct sbi_instrument { 60130866Smarkm u_short key; /* FM_PATCH or OPL3_PATCH */ 60230866Smarkm#define FM_PATCH _PATCHKEY(0x01) 60330866Smarkm#define OPL3_PATCH _PATCHKEY(0x03) 60430866Smarkm short device; /* Synth# (0-4) */ 60530866Smarkm int channel; /* Program# to be initialized */ 60630866Smarkm sbi_instr_data operators; /* Reg. settings for operator cells 60730866Smarkm * (.SBI format) */ 60830866Smarkm}; 609652Sjkh 610652Sjkhstruct synth_info { /* Read only */ 61130866Smarkm char name[30]; 61230866Smarkm int device; /* 0-N. INITIALIZE BEFORE CALLING */ 61330866Smarkm int synth_type; 614652Sjkh#define SYNTH_TYPE_FM 0 615652Sjkh#define SYNTH_TYPE_SAMPLE 1 6163256Sswallace#define SYNTH_TYPE_MIDI 2 /* Midi interface */ 617652Sjkh 61830866Smarkm int synth_subtype; 619652Sjkh#define FM_TYPE_ADLIB 0x00 620652Sjkh#define FM_TYPE_OPL3 0x01 621652Sjkh 62233473Sscrappy#define SAMPLE_TYPE_BASIC 0x10 62333473Sscrappy#define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC 624652Sjkh 62530866Smarkm int perc_mode; /* No longer supported */ 62630866Smarkm int nr_voices; 62730866Smarkm int nr_drums; /* Obsolete field */ 62830866Smarkm int instr_bank_size; 62930866Smarkm u_long capabilities; 63033473Sscrappy#define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ 63133473Sscrappy#define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ 63233473Sscrappy#define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */ 63330866Smarkm int dummies[19]; /* Reserve space */ 63430866Smarkm}; 635652Sjkh 6363256Sswallacestruct sound_timer_info { 63730866Smarkm char name[32]; 63830866Smarkm int caps; 63930866Smarkm}; 6403256Sswallace 6413256Sswallace#define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */ 6423256Sswallace 643652Sjkhstruct midi_info { 64430866Smarkm char name[30]; 64530866Smarkm int device; /* 0-N. INITIALIZE BEFORE CALLING */ 64630866Smarkm u_long capabilities; /* To be defined later */ 64730866Smarkm int dev_type; 64830866Smarkm int dummies[18]; /* Reserve space */ 64930866Smarkm}; 650652Sjkh 65133473Sscrappy/* 6523256Sswallace * ioctl commands for the /dev/midi## 6533256Sswallace */ 6543256Sswallacetypedef struct { 65530866Smarkm u_char cmd; 65630866Smarkm char nr_args, nr_returns; 65730866Smarkm u_char data[30]; 65830866Smarkm} mpu_command_rec; 6593256Sswallace 66033473Sscrappy#define SNDCTL_MIDI_PRETIME _IOWR('m', 0, int) 66133473Sscrappy#define SNDCTL_MIDI_MPUMODE _IOWR('m', 1, int) 66233473Sscrappy#define SNDCTL_MIDI_MPUCMD _IOWR('m', 2, mpu_command_rec) 6633256Sswallace 66433473Sscrappy/* 665652Sjkh * IOCTL commands for /dev/dsp and /dev/audio 666652Sjkh */ 667652Sjkh 66833473Sscrappy#define SNDCTL_DSP_RESET _IO ('P', 0) 66933473Sscrappy#define SNDCTL_DSP_SYNC _IO ('P', 1) 67033473Sscrappy#define SNDCTL_DSP_SPEED _IOWR('P', 2, int) 67133473Sscrappy#define SNDCTL_DSP_STEREO _IOWR('P', 3, int) 67233473Sscrappy#define SNDCTL_DSP_GETBLKSIZE _IOR('P', 4, int) 67333473Sscrappy#define SNDCTL_DSP_SETBLKSIZE _IOW('P', 4, int) 67433473Sscrappy#define SNDCTL_DSP_SETFMT _IOWR('P',5, int) /* Selects ONE fmt*/ 67533473Sscrappy 67633473Sscrappy/* 67733473Sscrappy * SOUND_PCM_WRITE_CHANNELS is not that different 67833473Sscrappy * from SNDCTL_DSP_STEREO 67933473Sscrappy */ 680652Sjkh#define SOUND_PCM_WRITE_CHANNELS _IOWR('P', 6, int) 68133473Sscrappy#define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int) 68233473Sscrappy#define SNDCTL_DSP_POST _IO ('P', 8) 683652Sjkh 68433473Sscrappy/* 68533473Sscrappy * SNDCTL_DSP_SETBLKSIZE and the following two calls mostly do 68633473Sscrappy * the same thing, i.e. set the block size used in DMA transfers. 68733473Sscrappy */ 68833473Sscrappy#define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int) 68933473Sscrappy#define SNDCTL_DSP_SETFRAGMENT _IOWR('P',10, int) 69030866Smarkm 6913256Sswallace 69233473Sscrappy#define SNDCTL_DSP_GETFMTS _IOR ('P',11, int) /* Returns a mask */ 6939750Sjkh/* 6949750Sjkh * Buffer status queries. 6959750Sjkh */ 6969750Sjkhtypedef struct audio_buf_info { 69733473Sscrappy int fragments; /* # of avail. frags (partly used ones not counted) */ 69833473Sscrappy int fragstotal; /* Total # of fragments allocated */ 69933473Sscrappy int fragsize; /* Size of a fragment in bytes */ 7009750Sjkh 70133473Sscrappy int bytes; /* Avail. space in bytes (includes partly used fragments) */ 70233473Sscrappy /* Note! 'bytes' could be more than fragments*fragsize */ 70330866Smarkm} audio_buf_info; 7049750Sjkh 70533473Sscrappy#define SNDCTL_DSP_GETOSPACE _IOR ('P',12, audio_buf_info) 70633473Sscrappy#define SNDCTL_DSP_GETISPACE _IOR ('P',13, audio_buf_info) 7079750Sjkh 70833473Sscrappy/* 70933473Sscrappy * SNDCTL_DSP_NONBLOCK is the same (but less powerful, since the 71033473Sscrappy * action cannot be undone) of FIONBIO. The same can be achieved 71133473Sscrappy * by opening the device with O_NDELAY 71233473Sscrappy */ 71333473Sscrappy#define SNDCTL_DSP_NONBLOCK _IO ('P',14) 71430866Smarkm 71533473Sscrappy#define SNDCTL_DSP_GETCAPS _IOR ('P',15, int) 71633473Sscrappy#define DSP_CAP_REVISION 0x000000ff /* revision level (0 to 255) */ 71733473Sscrappy#define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */ 71833473Sscrappy#define DSP_CAP_REALTIME 0x00000200 /* Real time capability */ 71933473Sscrappy#define DSP_CAP_BATCH 0x00000400 72033473Sscrappy /* 72133473Sscrappy * Device has some kind of internal buffers which may 72233473Sscrappy * cause some delays and decrease precision of timing 72333473Sscrappy */ 72433473Sscrappy#define DSP_CAP_COPROC 0x00000800 72533473Sscrappy /* Has a coprocessor, sometimes it's a DSP but usually not */ 72633473Sscrappy#define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */ 72730866Smarkm 72833473Sscrappy/* 72933473Sscrappy * What do these function do ? 73033473Sscrappy */ 73133473Sscrappy#define SNDCTL_DSP_GETTRIGGER _IOR ('P',16, int) 73233473Sscrappy#define SNDCTL_DSP_SETTRIGGER _IOW ('P',16, int) 73333473Sscrappy#define PCM_ENABLE_INPUT 0x00000001 73430866Smarkm#define PCM_ENABLE_OUTPUT 0x00000002 73530866Smarkm 73630866Smarkmtypedef struct count_info { 73730866Smarkm int bytes; /* Total # of bytes processed */ 73830866Smarkm int blocks; /* # of fragment transitions since last time */ 73930866Smarkm int ptr; /* Current DMA pointer value */ 74030866Smarkm} count_info; 74130866Smarkm 74233473Sscrappy/* 74333473Sscrappy * GETIPTR and GETISPACE are not that different... same for out. 74433473Sscrappy */ 74533473Sscrappy#define SNDCTL_DSP_GETIPTR _IOR ('P',17, count_info) 74633473Sscrappy#define SNDCTL_DSP_GETOPTR _IOR ('P',18, count_info) 74730866Smarkm 74830866Smarkmtypedef struct buffmem_desc { 74930866Smarkm caddr_t buffer; 75030866Smarkm int size; 75130866Smarkm} buffmem_desc; 75230866Smarkm 75333473Sscrappy#define SNDCTL_DSP_MAPINBUF _IOR ('P', 19, buffmem_desc) 75433473Sscrappy#define SNDCTL_DSP_MAPOUTBUF _IOR ('P', 20, buffmem_desc) 75533473Sscrappy#define SNDCTL_DSP_SETSYNCRO _IO ('P', 21) 75630866Smarkm 75733473Sscrappy/* 75833473Sscrappy * I guess these are the readonly version of the same 75933473Sscrappy * functions that exist above as SNDCTL_DSP_... 76033473Sscrappy */ 76133473Sscrappy#define SOUND_PCM_READ_RATE _IOR ('P', 2, int) 76233473Sscrappy#define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int) 76333473Sscrappy#define SOUND_PCM_READ_BITS _IOR ('P', 5, int) 76433473Sscrappy#define SOUND_PCM_READ_FILTER _IOR ('P', 7, int) 765652Sjkh 7669750Sjkh/* 7679750Sjkh * ioctl calls to be used in communication with coprocessors and 7689750Sjkh * DSP chips. 7693256Sswallace */ 7703256Sswallace 7719750Sjkhtypedef struct copr_buffer { 77230866Smarkm int command; /* Set to 0 if not used */ 77330866Smarkm int flags; 7749750Sjkh#define CPF_NONE 0x0000 7759750Sjkh#define CPF_FIRST 0x0001 /* First block */ 7769750Sjkh#define CPF_LAST 0x0002 /* Last block */ 77730866Smarkm int len; 77830866Smarkm int offs; /* If required by the device (0 if not used) */ 7793256Sswallace 78030866Smarkm u_char data[4000]; /* NOTE! 4000 is not 4k */ 78130866Smarkm} copr_buffer; 7829750Sjkh 7839750Sjkhtypedef struct copr_debug_buf { 78430866Smarkm int command; /* Used internally. Set to 0 */ 78530866Smarkm int parm1; 78630866Smarkm int parm2; 78730866Smarkm int flags; 78830866Smarkm int len; /* Length of data in bytes */ 78930866Smarkm} copr_debug_buf; 7909750Sjkh 7919750Sjkhtypedef struct copr_msg { 79230866Smarkm int len; 79330866Smarkm u_char data[4000]; 79430866Smarkm} copr_msg; 7959750Sjkh 79633473Sscrappy#define SNDCTL_COPR_RESET _IO ('C', 0) 79733473Sscrappy#define SNDCTL_COPR_LOAD _IOWR('C', 1, copr_buffer) 79833473Sscrappy#define SNDCTL_COPR_RDATA _IOWR('C', 2, copr_debug_buf) 79933473Sscrappy#define SNDCTL_COPR_RCODE _IOWR('C', 3, copr_debug_buf) 80033473Sscrappy#define SNDCTL_COPR_WDATA _IOW ('C', 4, copr_debug_buf) 80133473Sscrappy#define SNDCTL_COPR_WCODE _IOW ('C', 5, copr_debug_buf) 80233473Sscrappy#define SNDCTL_COPR_RUN _IOWR('C', 6, copr_debug_buf) 80333473Sscrappy#define SNDCTL_COPR_HALT _IOWR('C', 7, copr_debug_buf) 80433473Sscrappy#define SNDCTL_COPR_SENDMSG _IOW ('C', 8, copr_msg) 80533473Sscrappy#define SNDCTL_COPR_RCVMSG _IOR ('C', 9, copr_msg) 8069750Sjkh 80733473Sscrappy/* 808652Sjkh * IOCTL commands for /dev/mixer 809652Sjkh */ 8109750Sjkh 8119750Sjkh/* 812652Sjkh * Mixer devices 813652Sjkh * 814652Sjkh * There can be up to 20 different analog mixer channels. The 8159750Sjkh * SOUND_MIXER_NRDEVICES gives the currently supported maximum. 816652Sjkh * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells 817652Sjkh * the devices supported by the particular mixer. 818652Sjkh */ 819652Sjkh 82033473Sscrappy#define SOUND_MIXER_NRDEVICES 25 821652Sjkh#define SOUND_MIXER_VOLUME 0 822652Sjkh#define SOUND_MIXER_BASS 1 823652Sjkh#define SOUND_MIXER_TREBLE 2 824652Sjkh#define SOUND_MIXER_SYNTH 3 825652Sjkh#define SOUND_MIXER_PCM 4 826652Sjkh#define SOUND_MIXER_SPEAKER 5 827652Sjkh#define SOUND_MIXER_LINE 6 828652Sjkh#define SOUND_MIXER_MIC 7 829652Sjkh#define SOUND_MIXER_CD 8 830652Sjkh#define SOUND_MIXER_IMIX 9 /* Recording monitor */ 831652Sjkh#define SOUND_MIXER_ALTPCM 10 832652Sjkh#define SOUND_MIXER_RECLEV 11 /* Recording level */ 8339750Sjkh#define SOUND_MIXER_IGAIN 12 /* Input gain */ 8349750Sjkh#define SOUND_MIXER_OGAIN 13 /* Output gain */ 8359750Sjkh/* 8369750Sjkh * The AD1848 codec and compatibles have three line level inputs 8379750Sjkh * (line, aux1 and aux2). Since each card manufacturer have assigned 83830866Smarkm * different meanings to these inputs, it's inpractical to assign 8399750Sjkh * specific meanings (line, cd, synth etc.) to them. 8409750Sjkh */ 8419750Sjkh#define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */ 8429750Sjkh#define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */ 8439750Sjkh#define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */ 84433473Sscrappy#define SOUND_MIXER_DIGITAL1 17 /* Digital (input) 1 */ 84533473Sscrappy#define SOUND_MIXER_DIGITAL2 18 /* Digital (input) 2 */ 84633473Sscrappy#define SOUND_MIXER_DIGITAL3 19 /* Digital (input) 3 */ 84733473Sscrappy#define SOUND_MIXER_PHONEIN 20 /* Phone input */ 84833473Sscrappy#define SOUND_MIXER_PHONEOUT 21 /* Phone output */ 84933473Sscrappy#define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */ 85033473Sscrappy#define SOUND_MIXER_RADIO 23 /* Radio in */ 85133473Sscrappy#define SOUND_MIXER_MONITOR 24 /* Monitor (usually mic) volume */ 852652Sjkh 85333473Sscrappy 85433473Sscrappy/* 85533473Sscrappy * Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) 85633473Sscrappy * Not counted to SOUND_MIXER_NRDEVICES, but use the same number space 85733473Sscrappy */ 858652Sjkh#define SOUND_ONOFF_MIN 28 859652Sjkh#define SOUND_ONOFF_MAX 30 860652Sjkh#define SOUND_MIXER_MUTE 28 /* 0 or 1 */ 861652Sjkh#define SOUND_MIXER_ENHANCE 29 /* Enhanced stereo (0, 40, 60 or 80) */ 862652Sjkh#define SOUND_MIXER_LOUD 30 /* 0 or 1 */ 863652Sjkh 864652Sjkh/* Note! Number 31 cannot be used since the sign bit is reserved */ 86533473Sscrappy#define SOUND_MIXER_NONE 31 866652Sjkh 86730866Smarkm#define SOUND_DEVICE_LABELS { \ 86830866Smarkm "Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ 86933473Sscrappy "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \ 87033473Sscrappy "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \ 87133473Sscrappy "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"} 872652Sjkh 87330866Smarkm#define SOUND_DEVICE_NAMES { \ 87430866Smarkm "vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ 87530866Smarkm "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \ 87633473Sscrappy "line1", "line2", "line3", "dig1", "dig2", "dig3", \ 87733473Sscrappy "phin", "phout", "video", "radio", "monitor"} 878652Sjkh 879652Sjkh/* Device bitmask identifiers */ 880652Sjkh 88130866Smarkm#define SOUND_MIXER_RECSRC 0xff /* 1 bit per recording source */ 88230866Smarkm#define SOUND_MIXER_DEVMASK 0xfe /* 1 bit per supported device */ 88330866Smarkm#define SOUND_MIXER_RECMASK 0xfd /* 1 bit per supp. recording source */ 884652Sjkh#define SOUND_MIXER_CAPS 0xfc 88530866Smarkm#define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only 1 rec. src at a time */ 886652Sjkh#define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ 887652Sjkh 888652Sjkh/* Device mask bits */ 889652Sjkh 890652Sjkh#define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) 891652Sjkh#define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) 892652Sjkh#define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) 893652Sjkh#define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) 894652Sjkh#define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) 895652Sjkh#define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) 896652Sjkh#define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) 897652Sjkh#define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) 898652Sjkh#define SOUND_MASK_CD (1 << SOUND_MIXER_CD) 899652Sjkh#define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) 900652Sjkh#define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) 901652Sjkh#define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) 9029750Sjkh#define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN) 9039750Sjkh#define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN) 9049750Sjkh#define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1) 9059750Sjkh#define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2) 9069750Sjkh#define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3) 90733473Sscrappy#define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1) 90833473Sscrappy#define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2) 90933473Sscrappy#define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3) 91033473Sscrappy#define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN) 91133473Sscrappy#define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT) 91233473Sscrappy#define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO) 91333473Sscrappy#define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO) 91433473Sscrappy#define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR) 915652Sjkh 91633473Sscrappy/* Obsolete macros */ 917652Sjkh#define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) 918652Sjkh#define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) 919652Sjkh#define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) 920652Sjkh 921652Sjkh#define MIXER_READ(dev) _IOR('M', dev, int) 922652Sjkh#define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) 923652Sjkh#define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) 924652Sjkh#define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) 925652Sjkh#define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) 926652Sjkh#define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) 927652Sjkh#define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) 928652Sjkh#define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) 929652Sjkh#define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) 930652Sjkh#define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) 931652Sjkh#define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) 932652Sjkh#define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) 933652Sjkh#define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) 9349750Sjkh#define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN) 9359750Sjkh#define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN) 9369750Sjkh#define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1) 9379750Sjkh#define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2) 9389750Sjkh#define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3) 93933473Sscrappy 94033473Sscrappy/* Obsolete macros */ 941652Sjkh#define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) 942652Sjkh#define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) 943652Sjkh#define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) 944652Sjkh 945652Sjkh#define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) 946652Sjkh#define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) 947652Sjkh#define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) 948652Sjkh#define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) 949652Sjkh#define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) 950652Sjkh 951652Sjkh#define MIXER_WRITE(dev) _IOWR('M', dev, int) 952652Sjkh#define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) 953652Sjkh#define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) 954652Sjkh#define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) 955652Sjkh#define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) 956652Sjkh#define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) 957652Sjkh#define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) 958652Sjkh#define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) 959652Sjkh#define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) 960652Sjkh#define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) 961652Sjkh#define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) 962652Sjkh#define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) 963652Sjkh#define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) 9649750Sjkh#define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN) 9659750Sjkh#define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN) 9669750Sjkh#define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1) 9679750Sjkh#define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2) 9689750Sjkh#define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3) 969652Sjkh#define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) 970652Sjkh#define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) 971652Sjkh#define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) 972652Sjkh 973652Sjkh#define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) 974652Sjkh 97533473Sscrappy#define LEFT_CHN 0 97633473Sscrappy#define RIGHT_CHN 1 97733473Sscrappy 978652Sjkh/* 9793256Sswallace * Level 2 event types for /dev/sequencer 9803256Sswallace */ 9813256Sswallace 9823256Sswallace/* 9833256Sswallace * The 4 most significant bits of byte 0 specify the class of 9849750Sjkh * the event: 985652Sjkh * 9863256Sswallace * 0x8X = system level events, 9873256Sswallace * 0x9X = device/port specific events, event[1] = device/port, 9883256Sswallace * The last 4 bits give the subtype: 9893256Sswallace * 0x02 = Channel event (event[3] = chn). 9903256Sswallace * 0x01 = note event (event[4] = note). 9913256Sswallace * (0x01 is not used alone but always with bit 0x02). 9923256Sswallace * event[2] = MIDI message code (0x80=note off etc.) 9933256Sswallace * 994652Sjkh */ 995652Sjkh 9963256Sswallace#define EV_SEQ_LOCAL 0x80 9973256Sswallace#define EV_TIMING 0x81 9983256Sswallace#define EV_CHN_COMMON 0x92 9993256Sswallace#define EV_CHN_VOICE 0x93 100030866Smarkm#define EV_SYSEX 0x94 10013256Sswallace/* 10023256Sswallace * Event types 200 to 220 are reserved for application use. 10033256Sswallace * These numbers will not be used by the driver. 10043256Sswallace */ 1005652Sjkh 1006652Sjkh/* 10073256Sswallace * Events for event type EV_CHN_VOICE 1008652Sjkh */ 1009652Sjkh 10103256Sswallace#define MIDI_NOTEOFF 0x80 10113256Sswallace#define MIDI_NOTEON 0x90 10123256Sswallace#define MIDI_KEY_PRESSURE 0xA0 10133256Sswallace 1014652Sjkh/* 10153256Sswallace * Events for event type EV_CHN_COMMON 1016652Sjkh */ 1017652Sjkh 10183256Sswallace#define MIDI_CTL_CHANGE 0xB0 10193256Sswallace#define MIDI_PGM_CHANGE 0xC0 10203256Sswallace#define MIDI_CHN_PRESSURE 0xD0 10213256Sswallace#define MIDI_PITCH_BEND 0xE0 1022652Sjkh 10233256Sswallace#define MIDI_SYSTEM_PREFIX 0xF0 10243256Sswallace 1025652Sjkh/* 10263256Sswallace * Timer event types 10273256Sswallace */ 10283256Sswallace#define TMR_WAIT_REL 1 /* Time relative to the prev time */ 10293256Sswallace#define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */ 10303256Sswallace#define TMR_STOP 3 10313256Sswallace#define TMR_START 4 10323256Sswallace#define TMR_CONTINUE 5 10333256Sswallace#define TMR_TEMPO 6 10343256Sswallace#define TMR_ECHO 8 10353256Sswallace#define TMR_CLOCK 9 /* MIDI clock */ 10363256Sswallace#define TMR_SPP 10 /* Song position pointer */ 10373256Sswallace#define TMR_TIMESIG 11 /* Time signature */ 10383256Sswallace 103930866Smarkm/* 104030866Smarkm * Local event types 104130866Smarkm */ 104230866Smarkm#define LOCL_STARTAUDIO 1 104330866Smarkm 10449750Sjkh#if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS) 10453256Sswallace/* 1046652Sjkh * Some convenience macros to simplify programming of the 1047652Sjkh * /dev/sequencer interface 1048652Sjkh * 1049652Sjkh * These macros define the API which should be used when possible. 1050652Sjkh */ 1051652Sjkh 10523256Sswallace#ifndef USE_SIMPLE_MACROS 105333473Sscrappyvoid seqbuf_dump(void); /* This function must be provided by programs */ 1054652Sjkh 1055652Sjkh/* Sample seqbuf_dump() implementation: 1056652Sjkh * 1057652Sjkh * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes 1058652Sjkh * 1059652Sjkh * int seqfd; -- The file descriptor for /dev/sequencer. 1060652Sjkh * 1061652Sjkh * void 1062652Sjkh * seqbuf_dump () 1063652Sjkh * { 1064652Sjkh * if (_seqbufptr) 1065652Sjkh * if (write (seqfd, _seqbuf, _seqbufptr) == -1) 1066652Sjkh * { 1067652Sjkh * perror ("write /dev/sequencer"); 1068652Sjkh * exit (-1); 1069652Sjkh * } 1070652Sjkh * _seqbufptr = 0; 1071652Sjkh * } 1072652Sjkh */ 1073652Sjkh 107430866Smarkm#define SEQ_DEFINEBUF(len) \ 107530866Smarkm u_char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0 107630866Smarkm#define SEQ_USE_EXTBUF() \ 107730866Smarkm extern u_char _seqbuf[]; \ 107830866Smarkm extern int _seqbuflen;extern int _seqbufptr 10793256Sswallace#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF() 1080652Sjkh#define SEQ_PM_DEFINES struct patmgr_info _pm_info 108130866Smarkm#define _SEQ_NEEDBUF(len) \ 108230866Smarkm if ((_seqbufptr+(len)) > _seqbuflen) \ 108330866Smarkm seqbuf_dump() 1084652Sjkh#define _SEQ_ADVBUF(len) _seqbufptr += len 1085652Sjkh#define SEQ_DUMPBUF seqbuf_dump 10863256Sswallace#else 10873256Sswallace/* 10883256Sswallace * This variation of the sequencer macros is used just to format one event 10893256Sswallace * using fixed buffer. 10909750Sjkh * 10913256Sswallace * The program using the macro library must define the following macros before 10923256Sswallace * using this library. 10933256Sswallace * 109430866Smarkm * #define _seqbuf name of the buffer (u_char[]) 10953256Sswallace * #define _SEQ_ADVBUF(len) If the applic needs to know the exact 10963256Sswallace * size of the event, this macro can be used. 10973256Sswallace * Otherwise this must be defined as empty. 10983256Sswallace * #define _seqbufptr Define the name of index variable or 0 if 10999750Sjkh * not required. 11003256Sswallace */ 11013256Sswallace#define _SEQ_NEEDBUF(len) /* empty */ 11023256Sswallace#endif 11033256Sswallace 110430866Smarkm#define PM_LOAD_PATCH(dev, bank, pgm) \ 110530866Smarkm (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ 110630866Smarkm _pm_info.device=dev, _pm_info.data.data8[0]=pgm, \ 110730866Smarkm _pm_info.parm1 = bank, _pm_info.parm2 = 1, \ 110830866Smarkm ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) 110930866Smarkm#define PM_LOAD_PATCHES(dev, bank, pgm) \ 111030866Smarkm (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ 111130866Smarkm _pm_info.device=dev, bcopy( pgm, _pm_info.data.data8, 128), \ 111230866Smarkm _pm_info.parm1 = bank, _pm_info.parm2 = 128, \ 111330866Smarkm ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) 1114652Sjkh 111530866Smarkm#define SEQ_VOLUME_MODE(dev, mode) { \ 111630866Smarkm _SEQ_NEEDBUF(8);\ 111730866Smarkm _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 111830866Smarkm _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\ 111930866Smarkm _seqbuf[_seqbufptr+2] = (dev);\ 112030866Smarkm _seqbuf[_seqbufptr+3] = (mode);\ 112130866Smarkm _seqbuf[_seqbufptr+4] = 0;\ 112230866Smarkm _seqbuf[_seqbufptr+5] = 0;\ 112330866Smarkm _seqbuf[_seqbufptr+6] = 0;\ 112430866Smarkm _seqbuf[_seqbufptr+7] = 0;\ 112530866Smarkm _SEQ_ADVBUF(8);} 11261402Sache 11273256Sswallace/* 11283256Sswallace * Midi voice messages 11293256Sswallace */ 1130652Sjkh 113130866Smarkm#define _CHN_VOICE(dev, event, chn, note, parm) { \ 113230866Smarkm _SEQ_NEEDBUF(8);\ 113330866Smarkm _seqbuf[_seqbufptr] = EV_CHN_VOICE;\ 113430866Smarkm _seqbuf[_seqbufptr+1] = (dev);\ 113530866Smarkm _seqbuf[_seqbufptr+2] = (event);\ 113630866Smarkm _seqbuf[_seqbufptr+3] = (chn);\ 113730866Smarkm _seqbuf[_seqbufptr+4] = (note);\ 113830866Smarkm _seqbuf[_seqbufptr+5] = (parm);\ 113930866Smarkm _seqbuf[_seqbufptr+6] = (0);\ 114030866Smarkm _seqbuf[_seqbufptr+7] = 0;\ 114130866Smarkm _SEQ_ADVBUF(8);} 1142652Sjkh 11433256Sswallace#define SEQ_START_NOTE(dev, chn, note, vol) \ 11443256Sswallace _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol) 11453256Sswallace 11463256Sswallace#define SEQ_STOP_NOTE(dev, chn, note, vol) \ 11473256Sswallace _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol) 11483256Sswallace 11493256Sswallace#define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \ 11503256Sswallace _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure) 11513256Sswallace 11523256Sswallace/* 11533256Sswallace * Midi channel messages 11543256Sswallace */ 11553256Sswallace 115630866Smarkm#define _CHN_COMMON(dev, event, chn, p1, p2, w14) { \ 115730866Smarkm _SEQ_NEEDBUF(8);\ 115830866Smarkm _seqbuf[_seqbufptr] = EV_CHN_COMMON;\ 115930866Smarkm _seqbuf[_seqbufptr+1] = (dev);\ 116030866Smarkm _seqbuf[_seqbufptr+2] = (event);\ 116130866Smarkm _seqbuf[_seqbufptr+3] = (chn);\ 116230866Smarkm _seqbuf[_seqbufptr+4] = (p1);\ 116330866Smarkm _seqbuf[_seqbufptr+5] = (p2);\ 116430866Smarkm *(short *)&_seqbuf[_seqbufptr+6] = (w14);\ 116530866Smarkm _SEQ_ADVBUF(8);} 116630866Smarkm/* 116730866Smarkm * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits 116830866Smarkm * sending any MIDI bytes but it's absolutely not possible. Trying to do 116930866Smarkm * so _will_ cause problems with MPU401 intelligent mode). 117030866Smarkm * 117130866Smarkm * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be 117230866Smarkm * sent by calling SEQ_SYSEX() several times (there must be no other events 117330866Smarkm * between them). First sysex fragment must have 0xf0 in the first byte 117430866Smarkm * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte 117530866Smarkm * between these sysex start and end markers cannot be larger than 0x7f. Also 117630866Smarkm * lengths of each fragments (except the last one) must be 6. 117730866Smarkm * 117830866Smarkm * Breaking the above rules may work with some MIDI ports but is likely to 117930866Smarkm * cause fatal problems with some other devices (such as MPU401). 118030866Smarkm */ 118130866Smarkm#define SEQ_SYSEX(dev, buf, len) { \ 118230866Smarkm int i, l=(len); if (l>6)l=6;\ 118330866Smarkm _SEQ_NEEDBUF(8);\ 118430866Smarkm _seqbuf[_seqbufptr] = EV_SYSEX;\ 118530866Smarkm for(i=0;i<l;i++)_seqbuf[_seqbufptr+i+1] = (buf)[i];\ 118630866Smarkm for(i=l;i<6;i++)_seqbuf[_seqbufptr+i+1] = 0xff;\ 118730866Smarkm _SEQ_ADVBUF(8);} 1188652Sjkh 11893256Sswallace#define SEQ_CHN_PRESSURE(dev, chn, pressure) \ 119030866Smarkm _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0) 11913256Sswallace 11923256Sswallace#define SEQ_SET_PATCH(dev, chn, patch) \ 119330866Smarkm _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0) 11943256Sswallace 11953256Sswallace#define SEQ_CONTROL(dev, chn, controller, value) \ 119630866Smarkm _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value) 11973256Sswallace 11983256Sswallace#define SEQ_BENDER(dev, chn, value) \ 119930866Smarkm _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value) 12003256Sswallace 12019750Sjkh 120230866Smarkm#define SEQ_V2_X_CONTROL(dev, voice, controller, value) { \ 120330866Smarkm _SEQ_NEEDBUF(8);\ 120430866Smarkm _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 120530866Smarkm _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\ 120630866Smarkm _seqbuf[_seqbufptr+2] = (dev);\ 120730866Smarkm _seqbuf[_seqbufptr+3] = (voice);\ 120830866Smarkm _seqbuf[_seqbufptr+4] = (controller);\ 120930866Smarkm *(short *)&_seqbuf[_seqbufptr+5] = (value);\ 121030866Smarkm _seqbuf[_seqbufptr+7] = 0;\ 121130866Smarkm _SEQ_ADVBUF(8);} 121230866Smarkm 12133256Sswallace/* 12143256Sswallace * The following 5 macros are incorrectly implemented and obsolete. 12153256Sswallace * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead. 12163256Sswallace */ 1217652Sjkh 121830866Smarkm#define SEQ_PITCHBEND(dev, voice, value) \ 121930866Smarkm SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value) 122030866Smarkm#define SEQ_BENDER_RANGE(dev, voice, value) \ 122130866Smarkm SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value) 122230866Smarkm#define SEQ_EXPRESSION(dev, voice, value) \ 122330866Smarkm SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128) 122430866Smarkm#define SEQ_MAIN_VOLUME(dev, voice, value) \ 122530866Smarkm SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100) 122630866Smarkm#define SEQ_PANNING(dev, voice, pos) \ 122730866Smarkm SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2) 122830866Smarkm 12293256Sswallace/* 123030866Smarkm * Timing and syncronization macros 12313256Sswallace */ 1232652Sjkh 123330866Smarkm#define _TIMER_EVENT(ev, parm) { \ 123430866Smarkm _SEQ_NEEDBUF(8);\ 123530866Smarkm _seqbuf[_seqbufptr+0] = EV_TIMING; \ 123630866Smarkm _seqbuf[_seqbufptr+1] = (ev); \ 123730866Smarkm _seqbuf[_seqbufptr+2] = 0;\ 123830866Smarkm _seqbuf[_seqbufptr+3] = 0;\ 123930866Smarkm *(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \ 124030866Smarkm _SEQ_ADVBUF(8); \ 124130866Smarkm } 1242652Sjkh 12433256Sswallace#define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0) 12443256Sswallace#define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0) 12453256Sswallace#define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0) 12463256Sswallace#define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks) 12473256Sswallace#define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks) 12483256Sswallace#define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key) 12493256Sswallace#define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value) 12503256Sswallace#define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos) 12513256Sswallace#define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig) 1252652Sjkh 12533256Sswallace/* 125430866Smarkm * Local control events 125530866Smarkm */ 125630866Smarkm 125730866Smarkm#define _LOCAL_EVENT(ev, parm) { \ 125830866Smarkm _SEQ_NEEDBUF(8);\ 125930866Smarkm _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \ 126030866Smarkm _seqbuf[_seqbufptr+1] = (ev); \ 126130866Smarkm _seqbuf[_seqbufptr+2] = 0;\ 126230866Smarkm _seqbuf[_seqbufptr+3] = 0;\ 126330866Smarkm *(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \ 126430866Smarkm _SEQ_ADVBUF(8); \ 126530866Smarkm } 126630866Smarkm 126730866Smarkm#define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask) 126830866Smarkm/* 12699750Sjkh * Events for the level 1 interface only 12703256Sswallace */ 1271652Sjkh 127230866Smarkm#define SEQ_MIDIOUT(device, byte) { \ 127330866Smarkm _SEQ_NEEDBUF(4);\ 127430866Smarkm _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\ 127530866Smarkm _seqbuf[_seqbufptr+1] = (byte);\ 127630866Smarkm _seqbuf[_seqbufptr+2] = (device);\ 127730866Smarkm _seqbuf[_seqbufptr+3] = 0;\ 127830866Smarkm _SEQ_ADVBUF(4);} 12793256Sswallace 12803256Sswallace/* 12813256Sswallace * Patch loading. 12823256Sswallace */ 128330866Smarkm#define SEQ_WRPATCH(patchx, len) { \ 128430866Smarkm if (_seqbufptr) seqbuf_dump(); \ 128530866Smarkm if (write(seqfd, (char*)(patchx), len)==-1) \ 128630866Smarkm perror("Write patch: /dev/sequencer"); \ 128730866Smarkm } 1288652Sjkh 128930866Smarkm#define SEQ_WRPATCH2(patchx, len) \ 129030866Smarkm ( seqbuf_dump(), write(seqfd, (char*)(patchx), len) ) 129118444Sbde 129230866Smarkm#endif 129333473Sscrappy 129433473Sscrappy/* 129533473Sscrappy * Here I have moved all the aliases for ioctl names. 129633473Sscrappy */ 129733473Sscrappy 129833473Sscrappy#define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT 129933473Sscrappy#define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT 130033473Sscrappy#define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT 130133473Sscrappy 130233473Sscrappy#define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED 130333473Sscrappy#define SOUND_PCM_POST SNDCTL_DSP_POST 130433473Sscrappy#define SOUND_PCM_RESET SNDCTL_DSP_RESET 130533473Sscrappy#define SOUND_PCM_SYNC SNDCTL_DSP_SYNC 130633473Sscrappy#define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE 130733473Sscrappy#define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT 130833473Sscrappy#define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS 130933473Sscrappy#define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE 131033473Sscrappy#define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE 131133473Sscrappy#define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK 131233473Sscrappy#define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS 131333473Sscrappy#define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER 131433473Sscrappy#define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER 131533473Sscrappy#define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO 131633473Sscrappy#define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR 131733473Sscrappy#define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR 131833473Sscrappy#define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF 131933473Sscrappy#define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF 132033473Sscrappy 132133473Sscrappy#endif /* SOUNDCARD_H */ 1322