1607ca46eSDavid Howells /* 2607ca46eSDavid Howells * Copyright by Hannu Savolainen 1993-1997 3607ca46eSDavid Howells * 4607ca46eSDavid Howells * Redistribution and use in source and binary forms, with or without 5607ca46eSDavid Howells * modification, are permitted provided that the following conditions are 6607ca46eSDavid Howells * met: 1. Redistributions of source code must retain the above copyright 7607ca46eSDavid Howells * notice, this list of conditions and the following disclaimer. 2. 8607ca46eSDavid Howells * Redistributions in binary form must reproduce the above copyright notice, 9607ca46eSDavid Howells * this list of conditions and the following disclaimer in the documentation 10607ca46eSDavid Howells * and/or other materials provided with the distribution. 11607ca46eSDavid Howells * 12607ca46eSDavid Howells * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY 13607ca46eSDavid Howells * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14607ca46eSDavid Howells * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15607ca46eSDavid Howells * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 16607ca46eSDavid Howells * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 17607ca46eSDavid Howells * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 18607ca46eSDavid Howells * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 19607ca46eSDavid Howells * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 20607ca46eSDavid Howells * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21607ca46eSDavid Howells * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 22607ca46eSDavid Howells * SUCH DAMAGE. 23607ca46eSDavid Howells */ 24607ca46eSDavid Howells #ifndef _UAPISOUNDCARD_H 25607ca46eSDavid Howells #define _UAPISOUNDCARD_H 26607ca46eSDavid Howells 27607ca46eSDavid Howells 28607ca46eSDavid Howells /* 29607ca46eSDavid Howells * OSS interface version. With versions earlier than 3.6 this value is 30607ca46eSDavid Howells * an integer with value less than 361. In versions 3.6 and later 31607ca46eSDavid Howells * it's a six digit hexadecimal value. For example value 32607ca46eSDavid Howells * of 0x030600 represents OSS version 3.6.0. 33607ca46eSDavid Howells * Use ioctl(fd, OSS_GETVERSION, &int) to get the version number of 34607ca46eSDavid Howells * the currently active driver. 35607ca46eSDavid Howells */ 36607ca46eSDavid Howells #define SOUND_VERSION 0x030802 37607ca46eSDavid Howells #define OPEN_SOUND_SYSTEM 38607ca46eSDavid Howells 39607ca46eSDavid Howells /* In Linux we need to be prepared for cross compiling */ 40607ca46eSDavid Howells #include <linux/ioctl.h> 41607ca46eSDavid Howells 42607ca46eSDavid Howells /* Endian macros. */ 43607ca46eSDavid Howells #ifndef __KERNEL__ 44607ca46eSDavid Howells # include <endian.h> 45607ca46eSDavid Howells #endif 46607ca46eSDavid Howells 47607ca46eSDavid Howells /* 48607ca46eSDavid Howells * Supported card ID numbers (Should be somewhere else?) 49607ca46eSDavid Howells */ 50607ca46eSDavid Howells 51607ca46eSDavid Howells #define SNDCARD_ADLIB 1 52607ca46eSDavid Howells #define SNDCARD_SB 2 53607ca46eSDavid Howells #define SNDCARD_PAS 3 54607ca46eSDavid Howells #define SNDCARD_GUS 4 55607ca46eSDavid Howells #define SNDCARD_MPU401 5 56607ca46eSDavid Howells #define SNDCARD_SB16 6 57607ca46eSDavid Howells #define SNDCARD_SB16MIDI 7 58607ca46eSDavid Howells #define SNDCARD_UART6850 8 59607ca46eSDavid Howells #define SNDCARD_GUS16 9 60607ca46eSDavid Howells #define SNDCARD_MSS 10 61607ca46eSDavid Howells #define SNDCARD_PSS 11 62607ca46eSDavid Howells #define SNDCARD_SSCAPE 12 63607ca46eSDavid Howells #define SNDCARD_PSS_MPU 13 64607ca46eSDavid Howells #define SNDCARD_PSS_MSS 14 65607ca46eSDavid Howells #define SNDCARD_SSCAPE_MSS 15 66607ca46eSDavid Howells #define SNDCARD_TRXPRO 16 67607ca46eSDavid Howells #define SNDCARD_TRXPRO_SB 17 68607ca46eSDavid Howells #define SNDCARD_TRXPRO_MPU 18 69607ca46eSDavid Howells #define SNDCARD_MAD16 19 70607ca46eSDavid Howells #define SNDCARD_MAD16_MPU 20 71607ca46eSDavid Howells #define SNDCARD_CS4232 21 72607ca46eSDavid Howells #define SNDCARD_CS4232_MPU 22 73607ca46eSDavid Howells #define SNDCARD_MAUI 23 74607ca46eSDavid Howells #define SNDCARD_PSEUDO_MSS 24 75607ca46eSDavid Howells #define SNDCARD_GUSPNP 25 76607ca46eSDavid Howells #define SNDCARD_UART401 26 77607ca46eSDavid Howells /* Sound card numbers 27 to N are reserved. Don't add more numbers here. */ 78607ca46eSDavid Howells 79607ca46eSDavid Howells /*********************************** 80607ca46eSDavid Howells * IOCTL Commands for /dev/sequencer 81607ca46eSDavid Howells */ 82607ca46eSDavid Howells 83607ca46eSDavid Howells #ifndef _SIOWR 84607ca46eSDavid Howells #if defined(_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__sparc__) && !defined(__INCioctlh) && !defined(__Lynx__))) 85607ca46eSDavid Howells /* Use already defined ioctl defines if they exist (except with Sun or Sparc) */ 86607ca46eSDavid Howells #define SIOCPARM_MASK IOCPARM_MASK 87607ca46eSDavid Howells #define SIOC_VOID IOC_VOID 88607ca46eSDavid Howells #define SIOC_OUT IOC_OUT 89607ca46eSDavid Howells #define SIOC_IN IOC_IN 90607ca46eSDavid Howells #define SIOC_INOUT IOC_INOUT 91607ca46eSDavid Howells #define _SIOC_SIZE _IOC_SIZE 92607ca46eSDavid Howells #define _SIOC_DIR _IOC_DIR 93607ca46eSDavid Howells #define _SIOC_NONE _IOC_NONE 94607ca46eSDavid Howells #define _SIOC_READ _IOC_READ 95607ca46eSDavid Howells #define _SIOC_WRITE _IOC_WRITE 96607ca46eSDavid Howells #define _SIO _IO 97607ca46eSDavid Howells #define _SIOR _IOR 98607ca46eSDavid Howells #define _SIOW _IOW 99607ca46eSDavid Howells #define _SIOWR _IOWR 100607ca46eSDavid Howells #else 101607ca46eSDavid Howells 102607ca46eSDavid Howells /* Ioctl's have the command encoded in the lower word, 103607ca46eSDavid Howells * and the size of any in or out parameters in the upper 104607ca46eSDavid Howells * word. The high 2 bits of the upper word are used 105607ca46eSDavid Howells * to encode the in/out status of the parameter; for now 106607ca46eSDavid Howells * we restrict parameters to at most 8191 bytes. 107607ca46eSDavid Howells */ 108607ca46eSDavid Howells /* #define SIOCTYPE (0xff<<8) */ 109607ca46eSDavid Howells #define SIOCPARM_MASK 0x1fff /* parameters must be < 8192 bytes */ 110607ca46eSDavid Howells #define SIOC_VOID 0x00000000 /* no parameters */ 111607ca46eSDavid Howells #define SIOC_OUT 0x20000000 /* copy out parameters */ 112607ca46eSDavid Howells #define SIOC_IN 0x40000000 /* copy in parameters */ 113607ca46eSDavid Howells #define SIOC_INOUT (SIOC_IN|SIOC_OUT) 114607ca46eSDavid Howells /* the 0x20000000 is so we can distinguish new ioctl's from old */ 115607ca46eSDavid Howells #define _SIO(x,y) ((int)(SIOC_VOID|(x<<8)|y)) 116607ca46eSDavid Howells #define _SIOR(x,y,t) ((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) 117607ca46eSDavid Howells #define _SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) 118607ca46eSDavid Howells /* this should be _SIORW, but stdio got there first */ 119607ca46eSDavid Howells #define _SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) 120607ca46eSDavid Howells #define _SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK) 121607ca46eSDavid Howells #define _SIOC_DIR(x) (x & 0xf0000000) 122607ca46eSDavid Howells #define _SIOC_NONE SIOC_VOID 123607ca46eSDavid Howells #define _SIOC_READ SIOC_OUT 124607ca46eSDavid Howells #define _SIOC_WRITE SIOC_IN 125607ca46eSDavid Howells # endif /* _IOWR */ 126607ca46eSDavid Howells #endif /* !_SIOWR */ 127607ca46eSDavid Howells 128607ca46eSDavid Howells #define SNDCTL_SEQ_RESET _SIO ('Q', 0) 129607ca46eSDavid Howells #define SNDCTL_SEQ_SYNC _SIO ('Q', 1) 130607ca46eSDavid Howells #define SNDCTL_SYNTH_INFO _SIOWR('Q', 2, struct synth_info) 131607ca46eSDavid Howells #define SNDCTL_SEQ_CTRLRATE _SIOWR('Q', 3, int) /* Set/get timer resolution (HZ) */ 132607ca46eSDavid Howells #define SNDCTL_SEQ_GETOUTCOUNT _SIOR ('Q', 4, int) 133607ca46eSDavid Howells #define SNDCTL_SEQ_GETINCOUNT _SIOR ('Q', 5, int) 134607ca46eSDavid Howells #define SNDCTL_SEQ_PERCMODE _SIOW ('Q', 6, int) 135607ca46eSDavid Howells #define SNDCTL_FM_LOAD_INSTR _SIOW ('Q', 7, struct sbi_instrument) /* Obsolete. Don't use!!!!!! */ 136607ca46eSDavid Howells #define SNDCTL_SEQ_TESTMIDI _SIOW ('Q', 8, int) 137607ca46eSDavid Howells #define SNDCTL_SEQ_RESETSAMPLES _SIOW ('Q', 9, int) 138607ca46eSDavid Howells #define SNDCTL_SEQ_NRSYNTHS _SIOR ('Q',10, int) 139607ca46eSDavid Howells #define SNDCTL_SEQ_NRMIDIS _SIOR ('Q',11, int) 140607ca46eSDavid Howells #define SNDCTL_MIDI_INFO _SIOWR('Q',12, struct midi_info) 141607ca46eSDavid Howells #define SNDCTL_SEQ_THRESHOLD _SIOW ('Q',13, int) 142607ca46eSDavid Howells #define SNDCTL_SYNTH_MEMAVL _SIOWR('Q',14, int) /* in=dev#, out=memsize */ 143607ca46eSDavid Howells #define SNDCTL_FM_4OP_ENABLE _SIOW ('Q',15, int) /* in=dev# */ 144607ca46eSDavid Howells #define SNDCTL_SEQ_PANIC _SIO ('Q',17) 145607ca46eSDavid Howells #define SNDCTL_SEQ_OUTOFBAND _SIOW ('Q',18, struct seq_event_rec) 146607ca46eSDavid Howells #define SNDCTL_SEQ_GETTIME _SIOR ('Q',19, int) 147607ca46eSDavid Howells #define SNDCTL_SYNTH_ID _SIOWR('Q',20, struct synth_info) 148607ca46eSDavid Howells #define SNDCTL_SYNTH_CONTROL _SIOWR('Q',21, struct synth_control) 149607ca46eSDavid Howells #define SNDCTL_SYNTH_REMOVESAMPLE _SIOWR('Q',22, struct remove_sample) 150607ca46eSDavid Howells 151607ca46eSDavid Howells typedef struct synth_control 152607ca46eSDavid Howells { 153607ca46eSDavid Howells int devno; /* Synthesizer # */ 154607ca46eSDavid Howells char data[4000]; /* Device spesific command/data record */ 155607ca46eSDavid Howells }synth_control; 156607ca46eSDavid Howells 157607ca46eSDavid Howells typedef struct remove_sample 158607ca46eSDavid Howells { 159607ca46eSDavid Howells int devno; /* Synthesizer # */ 160607ca46eSDavid Howells int bankno; /* MIDI bank # (0=General MIDI) */ 161607ca46eSDavid Howells int instrno; /* MIDI instrument number */ 162607ca46eSDavid Howells } remove_sample; 163607ca46eSDavid Howells 164607ca46eSDavid Howells typedef struct seq_event_rec { 165607ca46eSDavid Howells unsigned char arr[8]; 166607ca46eSDavid Howells } seq_event_rec; 167607ca46eSDavid Howells 168607ca46eSDavid Howells #define SNDCTL_TMR_TIMEBASE _SIOWR('T', 1, int) 169607ca46eSDavid Howells #define SNDCTL_TMR_START _SIO ('T', 2) 170607ca46eSDavid Howells #define SNDCTL_TMR_STOP _SIO ('T', 3) 171607ca46eSDavid Howells #define SNDCTL_TMR_CONTINUE _SIO ('T', 4) 172607ca46eSDavid Howells #define SNDCTL_TMR_TEMPO _SIOWR('T', 5, int) 173607ca46eSDavid Howells #define SNDCTL_TMR_SOURCE _SIOWR('T', 6, int) 174607ca46eSDavid Howells # define TMR_INTERNAL 0x00000001 175607ca46eSDavid Howells # define TMR_EXTERNAL 0x00000002 176607ca46eSDavid Howells # define TMR_MODE_MIDI 0x00000010 177607ca46eSDavid Howells # define TMR_MODE_FSK 0x00000020 178607ca46eSDavid Howells # define TMR_MODE_CLS 0x00000040 179607ca46eSDavid Howells # define TMR_MODE_SMPTE 0x00000080 180607ca46eSDavid Howells #define SNDCTL_TMR_METRONOME _SIOW ('T', 7, int) 181607ca46eSDavid Howells #define SNDCTL_TMR_SELECT _SIOW ('T', 8, int) 182607ca46eSDavid Howells 183607ca46eSDavid Howells /* 184607ca46eSDavid Howells * Some big endian/little endian handling macros 185607ca46eSDavid Howells */ 186607ca46eSDavid Howells 187607ca46eSDavid Howells #define _LINUX_PATCHKEY_H_INDIRECT 188607ca46eSDavid Howells #include <linux/patchkey.h> 189607ca46eSDavid Howells #undef _LINUX_PATCHKEY_H_INDIRECT 190607ca46eSDavid Howells 191607ca46eSDavid Howells #if !defined(__KERNEL__) 192607ca46eSDavid Howells # if defined(__BYTE_ORDER) 193607ca46eSDavid Howells # if __BYTE_ORDER == __BIG_ENDIAN 194607ca46eSDavid Howells # define AFMT_S16_NE AFMT_S16_BE 195607ca46eSDavid Howells # elif __BYTE_ORDER == __LITTLE_ENDIAN 196607ca46eSDavid Howells # define AFMT_S16_NE AFMT_S16_LE 197607ca46eSDavid Howells # else 198607ca46eSDavid Howells # error "could not determine byte order" 199607ca46eSDavid Howells # endif 200607ca46eSDavid Howells # endif 201607ca46eSDavid Howells #endif 202607ca46eSDavid Howells 203607ca46eSDavid Howells /* 204607ca46eSDavid Howells * Sample loading mechanism for internal synthesizers (/dev/sequencer) 205607ca46eSDavid Howells * The following patch_info structure has been designed to support 206607ca46eSDavid Howells * Gravis UltraSound. It tries to be universal format for uploading 207607ca46eSDavid Howells * sample based patches but is probably too limited. 208607ca46eSDavid Howells * 209607ca46eSDavid Howells * (PBD) As Hannu guessed, the GUS structure is too limited for 210607ca46eSDavid Howells * the WaveFront, but this is the right place for a constant definition. 211607ca46eSDavid Howells */ 212607ca46eSDavid Howells 213607ca46eSDavid Howells struct patch_info { 214607ca46eSDavid Howells unsigned short key; /* Use WAVE_PATCH here */ 215607ca46eSDavid Howells #define WAVE_PATCH _PATCHKEY(0x04) 216607ca46eSDavid Howells #define GUS_PATCH WAVE_PATCH 217607ca46eSDavid Howells #define WAVEFRONT_PATCH _PATCHKEY(0x06) 218607ca46eSDavid Howells 219607ca46eSDavid Howells short device_no; /* Synthesizer number */ 220607ca46eSDavid Howells short instr_no; /* Midi pgm# */ 221607ca46eSDavid Howells 222607ca46eSDavid Howells unsigned int mode; 223607ca46eSDavid Howells /* 224607ca46eSDavid Howells * The least significant byte has the same format than the GUS .PAT 225607ca46eSDavid Howells * files 226607ca46eSDavid Howells */ 227607ca46eSDavid Howells #define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ 228607ca46eSDavid Howells #define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ 229607ca46eSDavid Howells #define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ 230607ca46eSDavid Howells #define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ 231607ca46eSDavid Howells #define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ 232607ca46eSDavid Howells #define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ 233607ca46eSDavid Howells #define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ 234607ca46eSDavid Howells #define WAVE_FAST_RELEASE 0x80 /* bit 7 = Shut off immediately after note off */ 235607ca46eSDavid Howells /* (use the env_rate/env_offs fields). */ 236607ca46eSDavid Howells /* Linux specific bits */ 237607ca46eSDavid Howells #define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ 238607ca46eSDavid Howells #define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ 239607ca46eSDavid Howells #define WAVE_SCALE 0x00040000 /* The scaling info is valid */ 240607ca46eSDavid Howells #define WAVE_FRACTIONS 0x00080000 /* Fraction information is valid */ 241607ca46eSDavid Howells /* Reserved bits */ 242607ca46eSDavid Howells #define WAVE_ROM 0x40000000 /* For future use */ 243607ca46eSDavid Howells #define WAVE_MULAW 0x20000000 /* For future use */ 244607ca46eSDavid Howells /* Other bits must be zeroed */ 245607ca46eSDavid Howells 246607ca46eSDavid Howells int len; /* Size of the wave data in bytes */ 247607ca46eSDavid Howells int loop_start, loop_end; /* Byte offsets from the beginning */ 248607ca46eSDavid Howells 249607ca46eSDavid Howells /* 250607ca46eSDavid Howells * The base_freq and base_note fields are used when computing the 251607ca46eSDavid Howells * playback speed for a note. The base_note defines the tone frequency 252607ca46eSDavid Howells * which is heard if the sample is played using the base_freq as the 253607ca46eSDavid Howells * playback speed. 254607ca46eSDavid Howells * 255607ca46eSDavid Howells * The low_note and high_note fields define the minimum and maximum note 256607ca46eSDavid Howells * frequencies for which this sample is valid. It is possible to define 257607ca46eSDavid Howells * more than one samples for an instrument number at the same time. The 258607ca46eSDavid Howells * low_note and high_note fields are used to select the most suitable one. 259607ca46eSDavid Howells * 260607ca46eSDavid Howells * The fields base_note, high_note and low_note should contain 261607ca46eSDavid Howells * the note frequency multiplied by 1000. For example value for the 262607ca46eSDavid Howells * middle A is 440*1000. 263607ca46eSDavid Howells */ 264607ca46eSDavid Howells 265607ca46eSDavid Howells unsigned int base_freq; 266607ca46eSDavid Howells unsigned int base_note; 267607ca46eSDavid Howells unsigned int high_note; 268607ca46eSDavid Howells unsigned int low_note; 269607ca46eSDavid Howells int panning; /* -128=left, 127=right */ 270607ca46eSDavid Howells int detuning; 271607ca46eSDavid Howells 272607ca46eSDavid Howells /* New fields introduced in version 1.99.5 */ 273607ca46eSDavid Howells 274607ca46eSDavid Howells /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ 275607ca46eSDavid Howells unsigned char env_rate[ 6 ]; /* GUS HW ramping rate */ 276607ca46eSDavid Howells unsigned char env_offset[ 6 ]; /* 255 == 100% */ 277607ca46eSDavid Howells 278607ca46eSDavid Howells /* 279607ca46eSDavid Howells * The tremolo, vibrato and scale info are not supported yet. 280607ca46eSDavid Howells * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or 281607ca46eSDavid Howells * WAVE_SCALE 282607ca46eSDavid Howells */ 283607ca46eSDavid Howells 284607ca46eSDavid Howells unsigned char tremolo_sweep; 285607ca46eSDavid Howells unsigned char tremolo_rate; 286607ca46eSDavid Howells unsigned char tremolo_depth; 287607ca46eSDavid Howells 288607ca46eSDavid Howells unsigned char vibrato_sweep; 289607ca46eSDavid Howells unsigned char vibrato_rate; 290607ca46eSDavid Howells unsigned char vibrato_depth; 291607ca46eSDavid Howells 292607ca46eSDavid Howells int scale_frequency; 293607ca46eSDavid Howells unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */ 294607ca46eSDavid Howells 295607ca46eSDavid Howells int volume; 296607ca46eSDavid Howells int fractions; 297607ca46eSDavid Howells int reserved1; 298607ca46eSDavid Howells int spare[2]; 299607ca46eSDavid Howells char data[1]; /* The waveform data starts here */ 300607ca46eSDavid Howells }; 301607ca46eSDavid Howells 302607ca46eSDavid Howells struct sysex_info { 303607ca46eSDavid Howells short key; /* Use SYSEX_PATCH or MAUI_PATCH here */ 304607ca46eSDavid Howells #define SYSEX_PATCH _PATCHKEY(0x05) 305607ca46eSDavid Howells #define MAUI_PATCH _PATCHKEY(0x06) 306607ca46eSDavid Howells short device_no; /* Synthesizer number */ 307607ca46eSDavid Howells int len; /* Size of the sysex data in bytes */ 308607ca46eSDavid Howells unsigned char data[1]; /* Sysex data starts here */ 309607ca46eSDavid Howells }; 310607ca46eSDavid Howells 311607ca46eSDavid Howells /* 312607ca46eSDavid Howells * /dev/sequencer input events. 313607ca46eSDavid Howells * 314607ca46eSDavid Howells * The data written to the /dev/sequencer is a stream of events. Events 315607ca46eSDavid Howells * are records of 4 or 8 bytes. The first byte defines the size. 316607ca46eSDavid Howells * Any number of events can be written with a write call. There 317607ca46eSDavid Howells * is a set of macros for sending these events. Use these macros if you 318607ca46eSDavid Howells * want to maximize portability of your program. 319607ca46eSDavid Howells * 320607ca46eSDavid Howells * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. 321607ca46eSDavid Howells * (All input events are currently 4 bytes long. Be prepared to support 322607ca46eSDavid Howells * 8 byte events also. If you receive any event having first byte >= 128, 323607ca46eSDavid Howells * it's a 8 byte event. 324607ca46eSDavid Howells * 325607ca46eSDavid Howells * The events are documented at the end of this file. 326607ca46eSDavid Howells * 327607ca46eSDavid Howells * Normal events (4 bytes) 328607ca46eSDavid Howells * There is also a 8 byte version of most of the 4 byte events. The 329607ca46eSDavid Howells * 8 byte one is recommended. 330607ca46eSDavid Howells */ 331607ca46eSDavid Howells #define SEQ_NOTEOFF 0 332607ca46eSDavid Howells #define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ 333607ca46eSDavid Howells #define SEQ_NOTEON 1 334607ca46eSDavid Howells #define SEQ_FMNOTEON SEQ_NOTEON 335607ca46eSDavid Howells #define SEQ_WAIT TMR_WAIT_ABS 336607ca46eSDavid Howells #define SEQ_PGMCHANGE 3 337607ca46eSDavid Howells #define SEQ_FMPGMCHANGE SEQ_PGMCHANGE 338607ca46eSDavid Howells #define SEQ_SYNCTIMER TMR_START 339607ca46eSDavid Howells #define SEQ_MIDIPUTC 5 340607ca46eSDavid Howells #define SEQ_DRUMON 6 /*** OBSOLETE ***/ 341607ca46eSDavid Howells #define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ 342607ca46eSDavid Howells #define SEQ_ECHO TMR_ECHO /* For synching programs with output */ 343607ca46eSDavid Howells #define SEQ_AFTERTOUCH 9 344607ca46eSDavid Howells #define SEQ_CONTROLLER 10 345607ca46eSDavid Howells 346607ca46eSDavid Howells /******************************************* 347607ca46eSDavid Howells * Midi controller numbers 348607ca46eSDavid Howells ******************************************* 349607ca46eSDavid Howells * Controllers 0 to 31 (0x00 to 0x1f) and 350607ca46eSDavid Howells * 32 to 63 (0x20 to 0x3f) are continuous 351607ca46eSDavid Howells * controllers. 352607ca46eSDavid Howells * In the MIDI 1.0 these controllers are sent using 353607ca46eSDavid Howells * two messages. Controller numbers 0 to 31 are used 354607ca46eSDavid Howells * to send the MSB and the controller numbers 32 to 63 355607ca46eSDavid Howells * are for the LSB. Note that just 7 bits are used in MIDI bytes. 356607ca46eSDavid Howells */ 357607ca46eSDavid Howells 358607ca46eSDavid Howells #define CTL_BANK_SELECT 0x00 359607ca46eSDavid Howells #define CTL_MODWHEEL 0x01 360607ca46eSDavid Howells #define CTL_BREATH 0x02 361607ca46eSDavid Howells /* undefined 0x03 */ 362607ca46eSDavid Howells #define CTL_FOOT 0x04 363607ca46eSDavid Howells #define CTL_PORTAMENTO_TIME 0x05 364607ca46eSDavid Howells #define CTL_DATA_ENTRY 0x06 365607ca46eSDavid Howells #define CTL_MAIN_VOLUME 0x07 366607ca46eSDavid Howells #define CTL_BALANCE 0x08 367607ca46eSDavid Howells /* undefined 0x09 */ 368607ca46eSDavid Howells #define CTL_PAN 0x0a 369607ca46eSDavid Howells #define CTL_EXPRESSION 0x0b 370607ca46eSDavid Howells /* undefined 0x0c */ 371607ca46eSDavid Howells /* undefined 0x0d */ 372607ca46eSDavid Howells /* undefined 0x0e */ 373607ca46eSDavid Howells /* undefined 0x0f */ 374607ca46eSDavid Howells #define CTL_GENERAL_PURPOSE1 0x10 375607ca46eSDavid Howells #define CTL_GENERAL_PURPOSE2 0x11 376607ca46eSDavid Howells #define CTL_GENERAL_PURPOSE3 0x12 377607ca46eSDavid Howells #define CTL_GENERAL_PURPOSE4 0x13 378607ca46eSDavid Howells /* undefined 0x14 - 0x1f */ 379607ca46eSDavid Howells 380607ca46eSDavid Howells /* undefined 0x20 */ 381607ca46eSDavid Howells /* The controller numbers 0x21 to 0x3f are reserved for the */ 382607ca46eSDavid Howells /* least significant bytes of the controllers 0x00 to 0x1f. */ 383607ca46eSDavid Howells /* These controllers are not recognised by the driver. */ 384607ca46eSDavid Howells 385607ca46eSDavid Howells /* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. */ 386607ca46eSDavid Howells /* 0=OFF and 127=ON (intermediate values are possible) */ 387607ca46eSDavid Howells #define CTL_DAMPER_PEDAL 0x40 388607ca46eSDavid Howells #define CTL_SUSTAIN 0x40 /* Alias */ 389607ca46eSDavid Howells #define CTL_HOLD 0x40 /* Alias */ 390607ca46eSDavid Howells #define CTL_PORTAMENTO 0x41 391607ca46eSDavid Howells #define CTL_SOSTENUTO 0x42 392607ca46eSDavid Howells #define CTL_SOFT_PEDAL 0x43 393607ca46eSDavid Howells /* undefined 0x44 */ 394607ca46eSDavid Howells #define CTL_HOLD2 0x45 395607ca46eSDavid Howells /* undefined 0x46 - 0x4f */ 396607ca46eSDavid Howells 397607ca46eSDavid Howells #define CTL_GENERAL_PURPOSE5 0x50 398607ca46eSDavid Howells #define CTL_GENERAL_PURPOSE6 0x51 399607ca46eSDavid Howells #define CTL_GENERAL_PURPOSE7 0x52 400607ca46eSDavid Howells #define CTL_GENERAL_PURPOSE8 0x53 401607ca46eSDavid Howells /* undefined 0x54 - 0x5a */ 402607ca46eSDavid Howells #define CTL_EXT_EFF_DEPTH 0x5b 403607ca46eSDavid Howells #define CTL_TREMOLO_DEPTH 0x5c 404607ca46eSDavid Howells #define CTL_CHORUS_DEPTH 0x5d 405607ca46eSDavid Howells #define CTL_DETUNE_DEPTH 0x5e 406607ca46eSDavid Howells #define CTL_CELESTE_DEPTH 0x5e /* Alias for the above one */ 407607ca46eSDavid Howells #define CTL_PHASER_DEPTH 0x5f 408607ca46eSDavid Howells #define CTL_DATA_INCREMENT 0x60 409607ca46eSDavid Howells #define CTL_DATA_DECREMENT 0x61 410607ca46eSDavid Howells #define CTL_NONREG_PARM_NUM_LSB 0x62 411607ca46eSDavid Howells #define CTL_NONREG_PARM_NUM_MSB 0x63 412607ca46eSDavid Howells #define CTL_REGIST_PARM_NUM_LSB 0x64 413607ca46eSDavid Howells #define CTL_REGIST_PARM_NUM_MSB 0x65 414607ca46eSDavid Howells /* undefined 0x66 - 0x78 */ 415607ca46eSDavid Howells /* reserved 0x79 - 0x7f */ 416607ca46eSDavid Howells 417607ca46eSDavid Howells /* Pseudo controllers (not midi compatible) */ 418607ca46eSDavid Howells #define CTRL_PITCH_BENDER 255 419607ca46eSDavid Howells #define CTRL_PITCH_BENDER_RANGE 254 420607ca46eSDavid Howells #define CTRL_EXPRESSION 253 /* Obsolete */ 421607ca46eSDavid Howells #define CTRL_MAIN_VOLUME 252 /* Obsolete */ 422607ca46eSDavid Howells #define SEQ_BALANCE 11 423607ca46eSDavid Howells #define SEQ_VOLMODE 12 424607ca46eSDavid Howells 425607ca46eSDavid Howells /* 426607ca46eSDavid Howells * Volume mode decides how volumes are used 427607ca46eSDavid Howells */ 428607ca46eSDavid Howells 429607ca46eSDavid Howells #define VOL_METHOD_ADAGIO 1 430607ca46eSDavid Howells #define VOL_METHOD_LINEAR 2 431607ca46eSDavid Howells 432607ca46eSDavid Howells /* 433607ca46eSDavid Howells * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as 434607ca46eSDavid Howells * input events. 435607ca46eSDavid Howells */ 436607ca46eSDavid Howells 437607ca46eSDavid Howells /* 438607ca46eSDavid Howells * Event codes 0xf0 to 0xfc are reserved for future extensions. 439607ca46eSDavid Howells */ 440607ca46eSDavid Howells 441607ca46eSDavid Howells #define SEQ_FULLSIZE 0xfd /* Long events */ 442607ca46eSDavid Howells /* 443607ca46eSDavid Howells * SEQ_FULLSIZE events are used for loading patches/samples to the 444607ca46eSDavid Howells * synthesizer devices. These events are passed directly to the driver 445607ca46eSDavid Howells * of the associated synthesizer device. There is no limit to the size 446607ca46eSDavid Howells * of the extended events. These events are not queued but executed 447607ca46eSDavid Howells * immediately when the write() is called (execution can take several 448607ca46eSDavid Howells * seconds of time). 449607ca46eSDavid Howells * 450607ca46eSDavid Howells * When a SEQ_FULLSIZE message is written to the device, it must 451607ca46eSDavid Howells * be written using exactly one write() call. Other events cannot 452607ca46eSDavid Howells * be mixed to the same write. 453607ca46eSDavid Howells * 454607ca46eSDavid Howells * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the 455607ca46eSDavid Howells * /dev/sequencer. Don't write other data together with the instrument structure 456607ca46eSDavid Howells * Set the key field of the structure to FM_PATCH. The device field is used to 457607ca46eSDavid Howells * route the patch to the corresponding device. 458607ca46eSDavid Howells * 459607ca46eSDavid Howells * For wave table use struct patch_info. Initialize the key field 460607ca46eSDavid Howells * to WAVE_PATCH. 461607ca46eSDavid Howells */ 462607ca46eSDavid Howells #define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ 463607ca46eSDavid Howells #define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */ 464607ca46eSDavid Howells 465607ca46eSDavid Howells /* 466607ca46eSDavid Howells * Record for FM patches 467607ca46eSDavid Howells */ 468607ca46eSDavid Howells 469607ca46eSDavid Howells typedef unsigned char sbi_instr_data[32]; 470607ca46eSDavid Howells 471607ca46eSDavid Howells struct sbi_instrument { 472607ca46eSDavid Howells unsigned short key; /* FM_PATCH or OPL3_PATCH */ 473607ca46eSDavid Howells #define FM_PATCH _PATCHKEY(0x01) 474607ca46eSDavid Howells #define OPL3_PATCH _PATCHKEY(0x03) 475607ca46eSDavid Howells short device; /* Synth# (0-4) */ 476607ca46eSDavid Howells int channel; /* Program# to be initialized */ 477607ca46eSDavid Howells sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */ 478607ca46eSDavid Howells }; 479607ca46eSDavid Howells 480607ca46eSDavid Howells struct synth_info { /* Read only */ 481607ca46eSDavid Howells char name[30]; 482607ca46eSDavid Howells int device; /* 0-N. INITIALIZE BEFORE CALLING */ 483607ca46eSDavid Howells int synth_type; 484607ca46eSDavid Howells #define SYNTH_TYPE_FM 0 485607ca46eSDavid Howells #define SYNTH_TYPE_SAMPLE 1 486607ca46eSDavid Howells #define SYNTH_TYPE_MIDI 2 /* Midi interface */ 487607ca46eSDavid Howells 488607ca46eSDavid Howells int synth_subtype; 489607ca46eSDavid Howells #define FM_TYPE_ADLIB 0x00 490607ca46eSDavid Howells #define FM_TYPE_OPL3 0x01 491607ca46eSDavid Howells #define MIDI_TYPE_MPU401 0x401 492607ca46eSDavid Howells 493607ca46eSDavid Howells #define SAMPLE_TYPE_BASIC 0x10 494607ca46eSDavid Howells #define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC 495607ca46eSDavid Howells #define SAMPLE_TYPE_WAVEFRONT 0x11 496607ca46eSDavid Howells 497607ca46eSDavid Howells int perc_mode; /* No longer supported */ 498607ca46eSDavid Howells int nr_voices; 499607ca46eSDavid Howells int nr_drums; /* Obsolete field */ 500607ca46eSDavid Howells int instr_bank_size; 501607ca46eSDavid Howells unsigned int capabilities; 502607ca46eSDavid Howells #define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ 503607ca46eSDavid Howells #define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ 504607ca46eSDavid Howells #define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */ 505607ca46eSDavid Howells int dummies[19]; /* Reserve space */ 506607ca46eSDavid Howells }; 507607ca46eSDavid Howells 508607ca46eSDavid Howells struct sound_timer_info { 509607ca46eSDavid Howells char name[32]; 510607ca46eSDavid Howells int caps; 511607ca46eSDavid Howells }; 512607ca46eSDavid Howells 513607ca46eSDavid Howells #define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */ 514607ca46eSDavid Howells 515607ca46eSDavid Howells struct midi_info { 516607ca46eSDavid Howells char name[30]; 517607ca46eSDavid Howells int device; /* 0-N. INITIALIZE BEFORE CALLING */ 518607ca46eSDavid Howells unsigned int capabilities; /* To be defined later */ 519607ca46eSDavid Howells int dev_type; 520607ca46eSDavid Howells int dummies[18]; /* Reserve space */ 521607ca46eSDavid Howells }; 522607ca46eSDavid Howells 523607ca46eSDavid Howells /******************************************** 524607ca46eSDavid Howells * ioctl commands for the /dev/midi## 525607ca46eSDavid Howells */ 526607ca46eSDavid Howells typedef struct { 527607ca46eSDavid Howells unsigned char cmd; 528607ca46eSDavid Howells char nr_args, nr_returns; 529607ca46eSDavid Howells unsigned char data[30]; 530607ca46eSDavid Howells } mpu_command_rec; 531607ca46eSDavid Howells 532607ca46eSDavid Howells #define SNDCTL_MIDI_PRETIME _SIOWR('m', 0, int) 533607ca46eSDavid Howells #define SNDCTL_MIDI_MPUMODE _SIOWR('m', 1, int) 534607ca46eSDavid Howells #define SNDCTL_MIDI_MPUCMD _SIOWR('m', 2, mpu_command_rec) 535607ca46eSDavid Howells 536607ca46eSDavid Howells /******************************************** 537607ca46eSDavid Howells * IOCTL commands for /dev/dsp and /dev/audio 538607ca46eSDavid Howells */ 539607ca46eSDavid Howells 540607ca46eSDavid Howells #define SNDCTL_DSP_RESET _SIO ('P', 0) 541607ca46eSDavid Howells #define SNDCTL_DSP_SYNC _SIO ('P', 1) 542607ca46eSDavid Howells #define SNDCTL_DSP_SPEED _SIOWR('P', 2, int) 543607ca46eSDavid Howells #define SNDCTL_DSP_STEREO _SIOWR('P', 3, int) 544607ca46eSDavid Howells #define SNDCTL_DSP_GETBLKSIZE _SIOWR('P', 4, int) 545607ca46eSDavid Howells #define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT 546607ca46eSDavid Howells #define SNDCTL_DSP_CHANNELS _SIOWR('P', 6, int) 547607ca46eSDavid Howells #define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS 548607ca46eSDavid Howells #define SOUND_PCM_WRITE_FILTER _SIOWR('P', 7, int) 549607ca46eSDavid Howells #define SNDCTL_DSP_POST _SIO ('P', 8) 550607ca46eSDavid Howells #define SNDCTL_DSP_SUBDIVIDE _SIOWR('P', 9, int) 551607ca46eSDavid Howells #define SNDCTL_DSP_SETFRAGMENT _SIOWR('P',10, int) 552607ca46eSDavid Howells 553607ca46eSDavid Howells /* Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */ 554607ca46eSDavid Howells #define SNDCTL_DSP_GETFMTS _SIOR ('P',11, int) /* Returns a mask */ 555607ca46eSDavid Howells #define SNDCTL_DSP_SETFMT _SIOWR('P',5, int) /* Selects ONE fmt*/ 556607ca46eSDavid Howells # define AFMT_QUERY 0x00000000 /* Return current fmt */ 557607ca46eSDavid Howells # define AFMT_MU_LAW 0x00000001 558607ca46eSDavid Howells # define AFMT_A_LAW 0x00000002 559607ca46eSDavid Howells # define AFMT_IMA_ADPCM 0x00000004 560607ca46eSDavid Howells # define AFMT_U8 0x00000008 561607ca46eSDavid Howells # define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/ 562607ca46eSDavid Howells # define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */ 563607ca46eSDavid Howells # define AFMT_S8 0x00000040 564607ca46eSDavid Howells # define AFMT_U16_LE 0x00000080 /* Little endian U16 */ 565607ca46eSDavid Howells # define AFMT_U16_BE 0x00000100 /* Big endian U16 */ 566607ca46eSDavid Howells # define AFMT_MPEG 0x00000200 /* MPEG (2) audio */ 567607ca46eSDavid Howells # define AFMT_AC3 0x00000400 /* Dolby Digital AC3 */ 568607ca46eSDavid Howells 569607ca46eSDavid Howells /* 570607ca46eSDavid Howells * Buffer status queries. 571607ca46eSDavid Howells */ 572607ca46eSDavid Howells typedef struct audio_buf_info { 573607ca46eSDavid Howells int fragments; /* # of available fragments (partially usend ones not counted) */ 574607ca46eSDavid Howells int fragstotal; /* Total # of fragments allocated */ 575607ca46eSDavid Howells int fragsize; /* Size of a fragment in bytes */ 576607ca46eSDavid Howells 577607ca46eSDavid Howells int bytes; /* Available space in bytes (includes partially used fragments) */ 578607ca46eSDavid Howells /* Note! 'bytes' could be more than fragments*fragsize */ 579607ca46eSDavid Howells } audio_buf_info; 580607ca46eSDavid Howells 581607ca46eSDavid Howells #define SNDCTL_DSP_GETOSPACE _SIOR ('P',12, audio_buf_info) 582607ca46eSDavid Howells #define SNDCTL_DSP_GETISPACE _SIOR ('P',13, audio_buf_info) 583607ca46eSDavid Howells #define SNDCTL_DSP_NONBLOCK _SIO ('P',14) 584607ca46eSDavid Howells #define SNDCTL_DSP_GETCAPS _SIOR ('P',15, int) 585607ca46eSDavid Howells # define DSP_CAP_REVISION 0x000000ff /* Bits for revision level (0 to 255) */ 586607ca46eSDavid Howells # define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */ 587607ca46eSDavid Howells # define DSP_CAP_REALTIME 0x00000200 /* Real time capability */ 588607ca46eSDavid Howells # define DSP_CAP_BATCH 0x00000400 /* Device has some kind of */ 589607ca46eSDavid Howells /* internal buffers which may */ 590607ca46eSDavid Howells /* cause some delays and */ 591607ca46eSDavid Howells /* decrease precision of timing */ 592607ca46eSDavid Howells # define DSP_CAP_COPROC 0x00000800 /* Has a coprocessor */ 593607ca46eSDavid Howells /* Sometimes it's a DSP */ 594607ca46eSDavid Howells /* but usually not */ 595607ca46eSDavid Howells # define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */ 596607ca46eSDavid Howells # define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */ 597607ca46eSDavid Howells # define DSP_CAP_MULTI 0x00004000 /* support multiple open */ 598607ca46eSDavid Howells # define DSP_CAP_BIND 0x00008000 /* channel binding to front/rear/cneter/lfe */ 599607ca46eSDavid Howells 600607ca46eSDavid Howells 601607ca46eSDavid Howells #define SNDCTL_DSP_GETTRIGGER _SIOR ('P',16, int) 602607ca46eSDavid Howells #define SNDCTL_DSP_SETTRIGGER _SIOW ('P',16, int) 603607ca46eSDavid Howells # define PCM_ENABLE_INPUT 0x00000001 604607ca46eSDavid Howells # define PCM_ENABLE_OUTPUT 0x00000002 605607ca46eSDavid Howells 606607ca46eSDavid Howells typedef struct count_info { 607607ca46eSDavid Howells int bytes; /* Total # of bytes processed */ 608607ca46eSDavid Howells int blocks; /* # of fragment transitions since last time */ 609607ca46eSDavid Howells int ptr; /* Current DMA pointer value */ 610607ca46eSDavid Howells } count_info; 611607ca46eSDavid Howells 612607ca46eSDavid Howells #define SNDCTL_DSP_GETIPTR _SIOR ('P',17, count_info) 613607ca46eSDavid Howells #define SNDCTL_DSP_GETOPTR _SIOR ('P',18, count_info) 614607ca46eSDavid Howells 615607ca46eSDavid Howells typedef struct buffmem_desc { 616607ca46eSDavid Howells unsigned *buffer; 617607ca46eSDavid Howells int size; 618607ca46eSDavid Howells } buffmem_desc; 619607ca46eSDavid Howells #define SNDCTL_DSP_MAPINBUF _SIOR ('P', 19, buffmem_desc) 620607ca46eSDavid Howells #define SNDCTL_DSP_MAPOUTBUF _SIOR ('P', 20, buffmem_desc) 621607ca46eSDavid Howells #define SNDCTL_DSP_SETSYNCRO _SIO ('P', 21) 622607ca46eSDavid Howells #define SNDCTL_DSP_SETDUPLEX _SIO ('P', 22) 623607ca46eSDavid Howells #define SNDCTL_DSP_GETODELAY _SIOR ('P', 23, int) 624607ca46eSDavid Howells 625607ca46eSDavid Howells #define SNDCTL_DSP_GETCHANNELMASK _SIOWR('P', 64, int) 626607ca46eSDavid Howells #define SNDCTL_DSP_BIND_CHANNEL _SIOWR('P', 65, int) 627607ca46eSDavid Howells # define DSP_BIND_QUERY 0x00000000 628607ca46eSDavid Howells # define DSP_BIND_FRONT 0x00000001 629607ca46eSDavid Howells # define DSP_BIND_SURR 0x00000002 630607ca46eSDavid Howells # define DSP_BIND_CENTER_LFE 0x00000004 631607ca46eSDavid Howells # define DSP_BIND_HANDSET 0x00000008 632607ca46eSDavid Howells # define DSP_BIND_MIC 0x00000010 633607ca46eSDavid Howells # define DSP_BIND_MODEM1 0x00000020 634607ca46eSDavid Howells # define DSP_BIND_MODEM2 0x00000040 635607ca46eSDavid Howells # define DSP_BIND_I2S 0x00000080 636607ca46eSDavid Howells # define DSP_BIND_SPDIF 0x00000100 637607ca46eSDavid Howells 638607ca46eSDavid Howells #define SNDCTL_DSP_SETSPDIF _SIOW ('P', 66, int) 639607ca46eSDavid Howells #define SNDCTL_DSP_GETSPDIF _SIOR ('P', 67, int) 640607ca46eSDavid Howells # define SPDIF_PRO 0x0001 641607ca46eSDavid Howells # define SPDIF_N_AUD 0x0002 642607ca46eSDavid Howells # define SPDIF_COPY 0x0004 643607ca46eSDavid Howells # define SPDIF_PRE 0x0008 644607ca46eSDavid Howells # define SPDIF_CC 0x07f0 645607ca46eSDavid Howells # define SPDIF_L 0x0800 646607ca46eSDavid Howells # define SPDIF_DRS 0x4000 647607ca46eSDavid Howells # define SPDIF_V 0x8000 648607ca46eSDavid Howells 649607ca46eSDavid Howells /* 650607ca46eSDavid Howells * Application's profile defines the way how playback underrun situations should be handled. 651607ca46eSDavid Howells * 652607ca46eSDavid Howells * APF_NORMAL (the default) and APF_NETWORK make the driver to cleanup the 653607ca46eSDavid Howells * playback buffer whenever an underrun occurs. This consumes some time 654607ca46eSDavid Howells * prevents looping the existing buffer. 655607ca46eSDavid Howells * APF_CPUINTENS is intended to be set by CPU intensive applications which 656607ca46eSDavid Howells * are likely to run out of time occasionally. In this mode the buffer cleanup is 657607ca46eSDavid Howells * disabled which saves CPU time but also let's the previous buffer content to 658607ca46eSDavid Howells * be played during the "pause" after the underrun. 659607ca46eSDavid Howells */ 660607ca46eSDavid Howells #define SNDCTL_DSP_PROFILE _SIOW ('P', 23, int) 661607ca46eSDavid Howells #define APF_NORMAL 0 /* Normal applications */ 662607ca46eSDavid Howells #define APF_NETWORK 1 /* Underruns probably caused by an "external" delay */ 663607ca46eSDavid Howells #define APF_CPUINTENS 2 /* Underruns probably caused by "overheating" the CPU */ 664607ca46eSDavid Howells 665607ca46eSDavid Howells #define SOUND_PCM_READ_RATE _SIOR ('P', 2, int) 666607ca46eSDavid Howells #define SOUND_PCM_READ_CHANNELS _SIOR ('P', 6, int) 667607ca46eSDavid Howells #define SOUND_PCM_READ_BITS _SIOR ('P', 5, int) 668607ca46eSDavid Howells #define SOUND_PCM_READ_FILTER _SIOR ('P', 7, int) 669607ca46eSDavid Howells 670607ca46eSDavid Howells /* Some alias names */ 671607ca46eSDavid Howells #define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT 672607ca46eSDavid Howells #define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED 673607ca46eSDavid Howells #define SOUND_PCM_POST SNDCTL_DSP_POST 674607ca46eSDavid Howells #define SOUND_PCM_RESET SNDCTL_DSP_RESET 675607ca46eSDavid Howells #define SOUND_PCM_SYNC SNDCTL_DSP_SYNC 676607ca46eSDavid Howells #define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE 677607ca46eSDavid Howells #define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT 678607ca46eSDavid Howells #define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS 679607ca46eSDavid Howells #define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT 680607ca46eSDavid Howells #define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE 681607ca46eSDavid Howells #define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE 682607ca46eSDavid Howells #define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK 683607ca46eSDavid Howells #define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS 684607ca46eSDavid Howells #define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER 685607ca46eSDavid Howells #define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER 686607ca46eSDavid Howells #define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO 687607ca46eSDavid Howells #define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR 688607ca46eSDavid Howells #define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR 689607ca46eSDavid Howells #define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF 690607ca46eSDavid Howells #define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF 691607ca46eSDavid Howells 692607ca46eSDavid Howells /* 693607ca46eSDavid Howells * ioctl calls to be used in communication with coprocessors and 694607ca46eSDavid Howells * DSP chips. 695607ca46eSDavid Howells */ 696607ca46eSDavid Howells 697607ca46eSDavid Howells typedef struct copr_buffer { 698607ca46eSDavid Howells int command; /* Set to 0 if not used */ 699607ca46eSDavid Howells int flags; 700607ca46eSDavid Howells #define CPF_NONE 0x0000 701607ca46eSDavid Howells #define CPF_FIRST 0x0001 /* First block */ 702607ca46eSDavid Howells #define CPF_LAST 0x0002 /* Last block */ 703607ca46eSDavid Howells int len; 704607ca46eSDavid Howells int offs; /* If required by the device (0 if not used) */ 705607ca46eSDavid Howells 706607ca46eSDavid Howells unsigned char data[4000]; /* NOTE! 4000 is not 4k */ 707607ca46eSDavid Howells } copr_buffer; 708607ca46eSDavid Howells 709607ca46eSDavid Howells typedef struct copr_debug_buf { 710607ca46eSDavid Howells int command; /* Used internally. Set to 0 */ 711607ca46eSDavid Howells int parm1; 712607ca46eSDavid Howells int parm2; 713607ca46eSDavid Howells int flags; 714607ca46eSDavid Howells int len; /* Length of data in bytes */ 715607ca46eSDavid Howells } copr_debug_buf; 716607ca46eSDavid Howells 717607ca46eSDavid Howells typedef struct copr_msg { 718607ca46eSDavid Howells int len; 719607ca46eSDavid Howells unsigned char data[4000]; 720607ca46eSDavid Howells } copr_msg; 721607ca46eSDavid Howells 722607ca46eSDavid Howells #define SNDCTL_COPR_RESET _SIO ('C', 0) 723607ca46eSDavid Howells #define SNDCTL_COPR_LOAD _SIOWR('C', 1, copr_buffer) 724607ca46eSDavid Howells #define SNDCTL_COPR_RDATA _SIOWR('C', 2, copr_debug_buf) 725607ca46eSDavid Howells #define SNDCTL_COPR_RCODE _SIOWR('C', 3, copr_debug_buf) 726607ca46eSDavid Howells #define SNDCTL_COPR_WDATA _SIOW ('C', 4, copr_debug_buf) 727607ca46eSDavid Howells #define SNDCTL_COPR_WCODE _SIOW ('C', 5, copr_debug_buf) 728607ca46eSDavid Howells #define SNDCTL_COPR_RUN _SIOWR('C', 6, copr_debug_buf) 729607ca46eSDavid Howells #define SNDCTL_COPR_HALT _SIOWR('C', 7, copr_debug_buf) 730607ca46eSDavid Howells #define SNDCTL_COPR_SENDMSG _SIOWR('C', 8, copr_msg) 731607ca46eSDavid Howells #define SNDCTL_COPR_RCVMSG _SIOR ('C', 9, copr_msg) 732607ca46eSDavid Howells 733607ca46eSDavid Howells /********************************************* 734607ca46eSDavid Howells * IOCTL commands for /dev/mixer 735607ca46eSDavid Howells */ 736607ca46eSDavid Howells 737607ca46eSDavid Howells /* 738607ca46eSDavid Howells * Mixer devices 739607ca46eSDavid Howells * 740607ca46eSDavid Howells * There can be up to 20 different analog mixer channels. The 741607ca46eSDavid Howells * SOUND_MIXER_NRDEVICES gives the currently supported maximum. 742607ca46eSDavid Howells * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells 743607ca46eSDavid Howells * the devices supported by the particular mixer. 744607ca46eSDavid Howells */ 745607ca46eSDavid Howells 746607ca46eSDavid Howells #define SOUND_MIXER_NRDEVICES 25 747607ca46eSDavid Howells #define SOUND_MIXER_VOLUME 0 748607ca46eSDavid Howells #define SOUND_MIXER_BASS 1 749607ca46eSDavid Howells #define SOUND_MIXER_TREBLE 2 750607ca46eSDavid Howells #define SOUND_MIXER_SYNTH 3 751607ca46eSDavid Howells #define SOUND_MIXER_PCM 4 752607ca46eSDavid Howells #define SOUND_MIXER_SPEAKER 5 753607ca46eSDavid Howells #define SOUND_MIXER_LINE 6 754607ca46eSDavid Howells #define SOUND_MIXER_MIC 7 755607ca46eSDavid Howells #define SOUND_MIXER_CD 8 756607ca46eSDavid Howells #define SOUND_MIXER_IMIX 9 /* Recording monitor */ 757607ca46eSDavid Howells #define SOUND_MIXER_ALTPCM 10 758607ca46eSDavid Howells #define SOUND_MIXER_RECLEV 11 /* Recording level */ 759607ca46eSDavid Howells #define SOUND_MIXER_IGAIN 12 /* Input gain */ 760607ca46eSDavid Howells #define SOUND_MIXER_OGAIN 13 /* Output gain */ 761607ca46eSDavid Howells /* 762607ca46eSDavid Howells * The AD1848 codec and compatibles have three line level inputs 763607ca46eSDavid Howells * (line, aux1 and aux2). Since each card manufacturer have assigned 764607ca46eSDavid Howells * different meanings to these inputs, it's inpractical to assign 765607ca46eSDavid Howells * specific meanings (line, cd, synth etc.) to them. 766607ca46eSDavid Howells */ 767607ca46eSDavid Howells #define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */ 768607ca46eSDavid Howells #define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */ 769607ca46eSDavid Howells #define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */ 770607ca46eSDavid Howells #define SOUND_MIXER_DIGITAL1 17 /* Digital (input) 1 */ 771607ca46eSDavid Howells #define SOUND_MIXER_DIGITAL2 18 /* Digital (input) 2 */ 772607ca46eSDavid Howells #define SOUND_MIXER_DIGITAL3 19 /* Digital (input) 3 */ 773607ca46eSDavid Howells #define SOUND_MIXER_PHONEIN 20 /* Phone input */ 774607ca46eSDavid Howells #define SOUND_MIXER_PHONEOUT 21 /* Phone output */ 775607ca46eSDavid Howells #define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */ 776607ca46eSDavid Howells #define SOUND_MIXER_RADIO 23 /* Radio in */ 777607ca46eSDavid Howells #define SOUND_MIXER_MONITOR 24 /* Monitor (usually mic) volume */ 778607ca46eSDavid Howells 779607ca46eSDavid Howells /* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */ 780607ca46eSDavid Howells /* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */ 781607ca46eSDavid Howells #define SOUND_ONOFF_MIN 28 782607ca46eSDavid Howells #define SOUND_ONOFF_MAX 30 783607ca46eSDavid Howells 784607ca46eSDavid Howells /* Note! Number 31 cannot be used since the sign bit is reserved */ 785607ca46eSDavid Howells #define SOUND_MIXER_NONE 31 786607ca46eSDavid Howells 787607ca46eSDavid Howells /* 788607ca46eSDavid Howells * The following unsupported macros are no longer functional. 789607ca46eSDavid Howells * Use SOUND_MIXER_PRIVATE# macros in future. 790607ca46eSDavid Howells */ 791607ca46eSDavid Howells #define SOUND_MIXER_ENHANCE SOUND_MIXER_NONE 792607ca46eSDavid Howells #define SOUND_MIXER_MUTE SOUND_MIXER_NONE 793607ca46eSDavid Howells #define SOUND_MIXER_LOUD SOUND_MIXER_NONE 794607ca46eSDavid Howells 795607ca46eSDavid Howells 796607ca46eSDavid Howells #define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ 797607ca46eSDavid Howells "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \ 798607ca46eSDavid Howells "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \ 799607ca46eSDavid Howells "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"} 800607ca46eSDavid Howells 801607ca46eSDavid Howells #define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ 802607ca46eSDavid Howells "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \ 803607ca46eSDavid Howells "line1", "line2", "line3", "dig1", "dig2", "dig3", \ 804607ca46eSDavid Howells "phin", "phout", "video", "radio", "monitor"} 805607ca46eSDavid Howells 806607ca46eSDavid Howells /* Device bitmask identifiers */ 807607ca46eSDavid Howells 808607ca46eSDavid Howells #define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */ 809607ca46eSDavid Howells #define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */ 810607ca46eSDavid Howells #define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */ 811607ca46eSDavid Howells #define SOUND_MIXER_CAPS 0xfc 812607ca46eSDavid Howells # define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */ 813607ca46eSDavid Howells #define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ 814607ca46eSDavid Howells #define SOUND_MIXER_OUTSRC 0xfa /* Arg contains a bit for each input source to output */ 815607ca46eSDavid Howells #define SOUND_MIXER_OUTMASK 0xf9 /* Arg contains a bit for each supported input source to output */ 816607ca46eSDavid Howells 817607ca46eSDavid Howells /* Device mask bits */ 818607ca46eSDavid Howells 819607ca46eSDavid Howells #define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) 820607ca46eSDavid Howells #define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) 821607ca46eSDavid Howells #define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) 822607ca46eSDavid Howells #define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) 823607ca46eSDavid Howells #define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) 824607ca46eSDavid Howells #define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) 825607ca46eSDavid Howells #define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) 826607ca46eSDavid Howells #define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) 827607ca46eSDavid Howells #define SOUND_MASK_CD (1 << SOUND_MIXER_CD) 828607ca46eSDavid Howells #define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) 829607ca46eSDavid Howells #define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) 830607ca46eSDavid Howells #define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) 831607ca46eSDavid Howells #define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN) 832607ca46eSDavid Howells #define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN) 833607ca46eSDavid Howells #define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1) 834607ca46eSDavid Howells #define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2) 835607ca46eSDavid Howells #define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3) 836607ca46eSDavid Howells #define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1) 837607ca46eSDavid Howells #define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2) 838607ca46eSDavid Howells #define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3) 839607ca46eSDavid Howells #define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN) 840607ca46eSDavid Howells #define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT) 841607ca46eSDavid Howells #define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO) 842607ca46eSDavid Howells #define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO) 843607ca46eSDavid Howells #define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR) 844607ca46eSDavid Howells 845607ca46eSDavid Howells /* Obsolete macros */ 846607ca46eSDavid Howells #define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) 847607ca46eSDavid Howells #define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) 848607ca46eSDavid Howells #define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) 849607ca46eSDavid Howells 850607ca46eSDavid Howells #define MIXER_READ(dev) _SIOR('M', dev, int) 851607ca46eSDavid Howells #define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) 852607ca46eSDavid Howells #define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) 853607ca46eSDavid Howells #define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) 854607ca46eSDavid Howells #define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) 855607ca46eSDavid Howells #define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) 856607ca46eSDavid Howells #define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) 857607ca46eSDavid Howells #define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) 858607ca46eSDavid Howells #define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) 859607ca46eSDavid Howells #define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) 860607ca46eSDavid Howells #define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) 861607ca46eSDavid Howells #define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) 862607ca46eSDavid Howells #define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) 863607ca46eSDavid Howells #define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN) 864607ca46eSDavid Howells #define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN) 865607ca46eSDavid Howells #define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1) 866607ca46eSDavid Howells #define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2) 867607ca46eSDavid Howells #define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3) 868607ca46eSDavid Howells 869607ca46eSDavid Howells /* Obsolete macros */ 870607ca46eSDavid Howells #define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) 871607ca46eSDavid Howells #define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) 872607ca46eSDavid Howells #define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) 873607ca46eSDavid Howells 874607ca46eSDavid Howells #define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) 875607ca46eSDavid Howells #define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) 876607ca46eSDavid Howells #define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) 877607ca46eSDavid Howells #define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) 878607ca46eSDavid Howells #define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) 879607ca46eSDavid Howells 880607ca46eSDavid Howells #define MIXER_WRITE(dev) _SIOWR('M', dev, int) 881607ca46eSDavid Howells #define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) 882607ca46eSDavid Howells #define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) 883607ca46eSDavid Howells #define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) 884607ca46eSDavid Howells #define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) 885607ca46eSDavid Howells #define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) 886607ca46eSDavid Howells #define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) 887607ca46eSDavid Howells #define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) 888607ca46eSDavid Howells #define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) 889607ca46eSDavid Howells #define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) 890607ca46eSDavid Howells #define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) 891607ca46eSDavid Howells #define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) 892607ca46eSDavid Howells #define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) 893607ca46eSDavid Howells #define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN) 894607ca46eSDavid Howells #define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN) 895607ca46eSDavid Howells #define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1) 896607ca46eSDavid Howells #define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2) 897607ca46eSDavid Howells #define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3) 898607ca46eSDavid Howells 899607ca46eSDavid Howells /* Obsolete macros */ 900607ca46eSDavid Howells #define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) 901607ca46eSDavid Howells #define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) 902607ca46eSDavid Howells #define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) 903607ca46eSDavid Howells 904607ca46eSDavid Howells #define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) 905607ca46eSDavid Howells 906607ca46eSDavid Howells typedef struct mixer_info 907607ca46eSDavid Howells { 908607ca46eSDavid Howells char id[16]; 909607ca46eSDavid Howells char name[32]; 910607ca46eSDavid Howells int modify_counter; 911607ca46eSDavid Howells int fillers[10]; 912607ca46eSDavid Howells } mixer_info; 913607ca46eSDavid Howells 914607ca46eSDavid Howells typedef struct _old_mixer_info /* Obsolete */ 915607ca46eSDavid Howells { 916607ca46eSDavid Howells char id[16]; 917607ca46eSDavid Howells char name[32]; 918607ca46eSDavid Howells } _old_mixer_info; 919607ca46eSDavid Howells 920607ca46eSDavid Howells #define SOUND_MIXER_INFO _SIOR ('M', 101, mixer_info) 921607ca46eSDavid Howells #define SOUND_OLD_MIXER_INFO _SIOR ('M', 101, _old_mixer_info) 922607ca46eSDavid Howells 923607ca46eSDavid Howells /* 924607ca46eSDavid Howells * A mechanism for accessing "proprietary" mixer features. This method 925607ca46eSDavid Howells * permits passing 128 bytes of arbitrary data between a mixer application 926607ca46eSDavid Howells * and the mixer driver. Interpretation of the record is defined by 927607ca46eSDavid Howells * the particular mixer driver. 928607ca46eSDavid Howells */ 929607ca46eSDavid Howells typedef unsigned char mixer_record[128]; 930607ca46eSDavid Howells 931607ca46eSDavid Howells #define SOUND_MIXER_ACCESS _SIOWR('M', 102, mixer_record) 932607ca46eSDavid Howells 933607ca46eSDavid Howells /* 934607ca46eSDavid Howells * Two ioctls for special souncard function 935607ca46eSDavid Howells */ 936607ca46eSDavid Howells #define SOUND_MIXER_AGC _SIOWR('M', 103, int) 937607ca46eSDavid Howells #define SOUND_MIXER_3DSE _SIOWR('M', 104, int) 938607ca46eSDavid Howells 939607ca46eSDavid Howells /* 940607ca46eSDavid Howells * The SOUND_MIXER_PRIVATE# commands can be redefined by low level drivers. 941607ca46eSDavid Howells * These features can be used when accessing device specific features. 942607ca46eSDavid Howells */ 943607ca46eSDavid Howells #define SOUND_MIXER_PRIVATE1 _SIOWR('M', 111, int) 944607ca46eSDavid Howells #define SOUND_MIXER_PRIVATE2 _SIOWR('M', 112, int) 945607ca46eSDavid Howells #define SOUND_MIXER_PRIVATE3 _SIOWR('M', 113, int) 946607ca46eSDavid Howells #define SOUND_MIXER_PRIVATE4 _SIOWR('M', 114, int) 947607ca46eSDavid Howells #define SOUND_MIXER_PRIVATE5 _SIOWR('M', 115, int) 948607ca46eSDavid Howells 949607ca46eSDavid Howells /* 950607ca46eSDavid Howells * SOUND_MIXER_GETLEVELS and SOUND_MIXER_SETLEVELS calls can be used 951607ca46eSDavid Howells * for querying current mixer settings from the driver and for loading 952607ca46eSDavid Howells * default volume settings _prior_ activating the mixer (loading 953607ca46eSDavid Howells * doesn't affect current state of the mixer hardware). These calls 954607ca46eSDavid Howells * are for internal use only. 955607ca46eSDavid Howells */ 956607ca46eSDavid Howells 957607ca46eSDavid Howells typedef struct mixer_vol_table { 958607ca46eSDavid Howells int num; /* Index to volume table */ 959607ca46eSDavid Howells char name[32]; 960607ca46eSDavid Howells int levels[32]; 961607ca46eSDavid Howells } mixer_vol_table; 962607ca46eSDavid Howells 963607ca46eSDavid Howells #define SOUND_MIXER_GETLEVELS _SIOWR('M', 116, mixer_vol_table) 964607ca46eSDavid Howells #define SOUND_MIXER_SETLEVELS _SIOWR('M', 117, mixer_vol_table) 965607ca46eSDavid Howells 966607ca46eSDavid Howells /* 967607ca46eSDavid Howells * An ioctl for identifying the driver version. It will return value 968607ca46eSDavid Howells * of the SOUND_VERSION macro used when compiling the driver. 969607ca46eSDavid Howells * This call was introduced in OSS version 3.6 and it will not work 970607ca46eSDavid Howells * with earlier versions (returns EINVAL). 971607ca46eSDavid Howells */ 972607ca46eSDavid Howells #define OSS_GETVERSION _SIOR ('M', 118, int) 973607ca46eSDavid Howells 974607ca46eSDavid Howells /* 975607ca46eSDavid Howells * Level 2 event types for /dev/sequencer 976607ca46eSDavid Howells */ 977607ca46eSDavid Howells 978607ca46eSDavid Howells /* 979607ca46eSDavid Howells * The 4 most significant bits of byte 0 specify the class of 980607ca46eSDavid Howells * the event: 981607ca46eSDavid Howells * 982607ca46eSDavid Howells * 0x8X = system level events, 983607ca46eSDavid Howells * 0x9X = device/port specific events, event[1] = device/port, 984607ca46eSDavid Howells * The last 4 bits give the subtype: 985607ca46eSDavid Howells * 0x02 = Channel event (event[3] = chn). 986607ca46eSDavid Howells * 0x01 = note event (event[4] = note). 987607ca46eSDavid Howells * (0x01 is not used alone but always with bit 0x02). 988607ca46eSDavid Howells * event[2] = MIDI message code (0x80=note off etc.) 989607ca46eSDavid Howells * 990607ca46eSDavid Howells */ 991607ca46eSDavid Howells 992607ca46eSDavid Howells #define EV_SEQ_LOCAL 0x80 993607ca46eSDavid Howells #define EV_TIMING 0x81 994607ca46eSDavid Howells #define EV_CHN_COMMON 0x92 995607ca46eSDavid Howells #define EV_CHN_VOICE 0x93 996607ca46eSDavid Howells #define EV_SYSEX 0x94 997607ca46eSDavid Howells /* 998607ca46eSDavid Howells * Event types 200 to 220 are reserved for application use. 999607ca46eSDavid Howells * These numbers will not be used by the driver. 1000607ca46eSDavid Howells */ 1001607ca46eSDavid Howells 1002607ca46eSDavid Howells /* 1003607ca46eSDavid Howells * Events for event type EV_CHN_VOICE 1004607ca46eSDavid Howells */ 1005607ca46eSDavid Howells 1006607ca46eSDavid Howells #define MIDI_NOTEOFF 0x80 1007607ca46eSDavid Howells #define MIDI_NOTEON 0x90 1008607ca46eSDavid Howells #define MIDI_KEY_PRESSURE 0xA0 1009607ca46eSDavid Howells 1010607ca46eSDavid Howells /* 1011607ca46eSDavid Howells * Events for event type EV_CHN_COMMON 1012607ca46eSDavid Howells */ 1013607ca46eSDavid Howells 1014607ca46eSDavid Howells #define MIDI_CTL_CHANGE 0xB0 1015607ca46eSDavid Howells #define MIDI_PGM_CHANGE 0xC0 1016607ca46eSDavid Howells #define MIDI_CHN_PRESSURE 0xD0 1017607ca46eSDavid Howells #define MIDI_PITCH_BEND 0xE0 1018607ca46eSDavid Howells 1019607ca46eSDavid Howells #define MIDI_SYSTEM_PREFIX 0xF0 1020607ca46eSDavid Howells 1021607ca46eSDavid Howells /* 1022607ca46eSDavid Howells * Timer event types 1023607ca46eSDavid Howells */ 1024607ca46eSDavid Howells #define TMR_WAIT_REL 1 /* Time relative to the prev time */ 1025607ca46eSDavid Howells #define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */ 1026607ca46eSDavid Howells #define TMR_STOP 3 1027607ca46eSDavid Howells #define TMR_START 4 1028607ca46eSDavid Howells #define TMR_CONTINUE 5 1029607ca46eSDavid Howells #define TMR_TEMPO 6 1030607ca46eSDavid Howells #define TMR_ECHO 8 1031607ca46eSDavid Howells #define TMR_CLOCK 9 /* MIDI clock */ 1032607ca46eSDavid Howells #define TMR_SPP 10 /* Song position pointer */ 1033607ca46eSDavid Howells #define TMR_TIMESIG 11 /* Time signature */ 1034607ca46eSDavid Howells 1035607ca46eSDavid Howells /* 1036607ca46eSDavid Howells * Local event types 1037607ca46eSDavid Howells */ 1038607ca46eSDavid Howells #define LOCL_STARTAUDIO 1 1039607ca46eSDavid Howells 1040607ca46eSDavid Howells #if !defined(__KERNEL__) || defined(USE_SEQ_MACROS) 1041607ca46eSDavid Howells /* 1042607ca46eSDavid Howells * Some convenience macros to simplify programming of the 1043607ca46eSDavid Howells * /dev/sequencer interface 1044607ca46eSDavid Howells * 1045607ca46eSDavid Howells * This is a legacy interface for applications written against 1046607ca46eSDavid Howells * the OSSlib-3.8 style interface. It is no longer possible 1047607ca46eSDavid Howells * to actually link against OSSlib with this header, but we 1048607ca46eSDavid Howells * still provide these macros for programs using them. 1049607ca46eSDavid Howells * 1050607ca46eSDavid Howells * If you want to use OSSlib, it is recommended that you get 1051607ca46eSDavid Howells * the GPL version of OSS-4.x and build against that version 1052607ca46eSDavid Howells * of the header. 1053607ca46eSDavid Howells * 1054*50a48340SMasahiro Yamada * We redefine the extern keyword so that usr/include/headers_check.pl 1055607ca46eSDavid Howells * does not complain about SEQ_USE_EXTBUF. 1056607ca46eSDavid Howells */ 1057607ca46eSDavid Howells #define SEQ_DECLAREBUF() SEQ_USE_EXTBUF() 1058607ca46eSDavid Howells 1059607ca46eSDavid Howells void seqbuf_dump(void); /* This function must be provided by programs */ 1060607ca46eSDavid Howells 1061607ca46eSDavid Howells #define SEQ_PM_DEFINES int __foo_bar___ 1062607ca46eSDavid Howells 1063607ca46eSDavid Howells #define SEQ_LOAD_GMINSTR(dev, instr) 1064607ca46eSDavid Howells #define SEQ_LOAD_GMDRUM(dev, drum) 1065607ca46eSDavid Howells 1066607ca46eSDavid Howells #define _SEQ_EXTERN extern 1067607ca46eSDavid Howells #define SEQ_USE_EXTBUF() \ 1068607ca46eSDavid Howells _SEQ_EXTERN unsigned char _seqbuf[]; \ 1069607ca46eSDavid Howells _SEQ_EXTERN int _seqbuflen; _SEQ_EXTERN int _seqbufptr 1070607ca46eSDavid Howells 1071607ca46eSDavid Howells #ifndef USE_SIMPLE_MACROS 1072607ca46eSDavid Howells /* Sample seqbuf_dump() implementation: 1073607ca46eSDavid Howells * 1074607ca46eSDavid Howells * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes 1075607ca46eSDavid Howells * 1076607ca46eSDavid Howells * int seqfd; -- The file descriptor for /dev/sequencer. 1077607ca46eSDavid Howells * 1078607ca46eSDavid Howells * void 1079607ca46eSDavid Howells * seqbuf_dump () 1080607ca46eSDavid Howells * { 1081607ca46eSDavid Howells * if (_seqbufptr) 1082607ca46eSDavid Howells * if (write (seqfd, _seqbuf, _seqbufptr) == -1) 1083607ca46eSDavid Howells * { 1084607ca46eSDavid Howells * perror ("write /dev/sequencer"); 1085607ca46eSDavid Howells * exit (-1); 1086607ca46eSDavid Howells * } 1087607ca46eSDavid Howells * _seqbufptr = 0; 1088607ca46eSDavid Howells * } 1089607ca46eSDavid Howells */ 1090607ca46eSDavid Howells 1091607ca46eSDavid Howells #define SEQ_DEFINEBUF(len) unsigned char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0 1092607ca46eSDavid Howells #define _SEQ_NEEDBUF(len) if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump() 1093607ca46eSDavid Howells #define _SEQ_ADVBUF(len) _seqbufptr += len 1094607ca46eSDavid Howells #define SEQ_DUMPBUF seqbuf_dump 1095607ca46eSDavid Howells #else 1096607ca46eSDavid Howells /* 1097607ca46eSDavid Howells * This variation of the sequencer macros is used just to format one event 1098607ca46eSDavid Howells * using fixed buffer. 1099607ca46eSDavid Howells * 1100607ca46eSDavid Howells * The program using the macro library must define the following macros before 1101607ca46eSDavid Howells * using this library. 1102607ca46eSDavid Howells * 1103607ca46eSDavid Howells * #define _seqbuf name of the buffer (unsigned char[]) 1104607ca46eSDavid Howells * #define _SEQ_ADVBUF(len) If the applic needs to know the exact 1105607ca46eSDavid Howells * size of the event, this macro can be used. 1106607ca46eSDavid Howells * Otherwise this must be defined as empty. 1107607ca46eSDavid Howells * #define _seqbufptr Define the name of index variable or 0 if 1108607ca46eSDavid Howells * not required. 1109607ca46eSDavid Howells */ 1110607ca46eSDavid Howells #define _SEQ_NEEDBUF(len) /* empty */ 1111607ca46eSDavid Howells #endif 1112607ca46eSDavid Howells 1113607ca46eSDavid Howells #define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);\ 1114607ca46eSDavid Howells _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 1115607ca46eSDavid Howells _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\ 1116607ca46eSDavid Howells _seqbuf[_seqbufptr+2] = (dev);\ 1117607ca46eSDavid Howells _seqbuf[_seqbufptr+3] = (mode);\ 1118607ca46eSDavid Howells _seqbuf[_seqbufptr+4] = 0;\ 1119607ca46eSDavid Howells _seqbuf[_seqbufptr+5] = 0;\ 1120607ca46eSDavid Howells _seqbuf[_seqbufptr+6] = 0;\ 1121607ca46eSDavid Howells _seqbuf[_seqbufptr+7] = 0;\ 1122607ca46eSDavid Howells _SEQ_ADVBUF(8);} 1123607ca46eSDavid Howells 1124607ca46eSDavid Howells /* 1125607ca46eSDavid Howells * Midi voice messages 1126607ca46eSDavid Howells */ 1127607ca46eSDavid Howells 1128607ca46eSDavid Howells #define _CHN_VOICE(dev, event, chn, note, parm) \ 1129607ca46eSDavid Howells {_SEQ_NEEDBUF(8);\ 1130607ca46eSDavid Howells _seqbuf[_seqbufptr] = EV_CHN_VOICE;\ 1131607ca46eSDavid Howells _seqbuf[_seqbufptr+1] = (dev);\ 1132607ca46eSDavid Howells _seqbuf[_seqbufptr+2] = (event);\ 1133607ca46eSDavid Howells _seqbuf[_seqbufptr+3] = (chn);\ 1134607ca46eSDavid Howells _seqbuf[_seqbufptr+4] = (note);\ 1135607ca46eSDavid Howells _seqbuf[_seqbufptr+5] = (parm);\ 1136607ca46eSDavid Howells _seqbuf[_seqbufptr+6] = (0);\ 1137607ca46eSDavid Howells _seqbuf[_seqbufptr+7] = 0;\ 1138607ca46eSDavid Howells _SEQ_ADVBUF(8);} 1139607ca46eSDavid Howells 1140607ca46eSDavid Howells #define SEQ_START_NOTE(dev, chn, note, vol) \ 1141607ca46eSDavid Howells _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol) 1142607ca46eSDavid Howells 1143607ca46eSDavid Howells #define SEQ_STOP_NOTE(dev, chn, note, vol) \ 1144607ca46eSDavid Howells _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol) 1145607ca46eSDavid Howells 1146607ca46eSDavid Howells #define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \ 1147607ca46eSDavid Howells _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure) 1148607ca46eSDavid Howells 1149607ca46eSDavid Howells /* 1150607ca46eSDavid Howells * Midi channel messages 1151607ca46eSDavid Howells */ 1152607ca46eSDavid Howells 1153607ca46eSDavid Howells #define _CHN_COMMON(dev, event, chn, p1, p2, w14) \ 1154607ca46eSDavid Howells {_SEQ_NEEDBUF(8);\ 1155607ca46eSDavid Howells _seqbuf[_seqbufptr] = EV_CHN_COMMON;\ 1156607ca46eSDavid Howells _seqbuf[_seqbufptr+1] = (dev);\ 1157607ca46eSDavid Howells _seqbuf[_seqbufptr+2] = (event);\ 1158607ca46eSDavid Howells _seqbuf[_seqbufptr+3] = (chn);\ 1159607ca46eSDavid Howells _seqbuf[_seqbufptr+4] = (p1);\ 1160607ca46eSDavid Howells _seqbuf[_seqbufptr+5] = (p2);\ 1161607ca46eSDavid Howells *(short *)&_seqbuf[_seqbufptr+6] = (w14);\ 1162607ca46eSDavid Howells _SEQ_ADVBUF(8);} 1163607ca46eSDavid Howells /* 1164607ca46eSDavid Howells * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits 1165607ca46eSDavid Howells * sending any MIDI bytes but it's absolutely not possible. Trying to do 1166607ca46eSDavid Howells * so _will_ cause problems with MPU401 intelligent mode). 1167607ca46eSDavid Howells * 1168607ca46eSDavid Howells * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be 1169607ca46eSDavid Howells * sent by calling SEQ_SYSEX() several times (there must be no other events 1170607ca46eSDavid Howells * between them). First sysex fragment must have 0xf0 in the first byte 1171607ca46eSDavid Howells * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte 1172607ca46eSDavid Howells * between these sysex start and end markers cannot be larger than 0x7f. Also 1173607ca46eSDavid Howells * lengths of each fragments (except the last one) must be 6. 1174607ca46eSDavid Howells * 1175607ca46eSDavid Howells * Breaking the above rules may work with some MIDI ports but is likely to 1176607ca46eSDavid Howells * cause fatal problems with some other devices (such as MPU401). 1177607ca46eSDavid Howells */ 1178607ca46eSDavid Howells #define SEQ_SYSEX(dev, buf, len) \ 1179607ca46eSDavid Howells {int ii, ll=(len); \ 1180607ca46eSDavid Howells unsigned char *bufp=buf;\ 1181607ca46eSDavid Howells if (ll>6)ll=6;\ 1182607ca46eSDavid Howells _SEQ_NEEDBUF(8);\ 1183607ca46eSDavid Howells _seqbuf[_seqbufptr] = EV_SYSEX;\ 1184607ca46eSDavid Howells _seqbuf[_seqbufptr+1] = (dev);\ 1185607ca46eSDavid Howells for(ii=0;ii<ll;ii++)\ 1186607ca46eSDavid Howells _seqbuf[_seqbufptr+ii+2] = bufp[ii];\ 1187607ca46eSDavid Howells for(ii=ll;ii<6;ii++)\ 1188607ca46eSDavid Howells _seqbuf[_seqbufptr+ii+2] = 0xff;\ 1189607ca46eSDavid Howells _SEQ_ADVBUF(8);} 1190607ca46eSDavid Howells 1191607ca46eSDavid Howells #define SEQ_CHN_PRESSURE(dev, chn, pressure) \ 1192607ca46eSDavid Howells _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0) 1193607ca46eSDavid Howells 1194607ca46eSDavid Howells #define SEQ_SET_PATCH SEQ_PGM_CHANGE 1195607ca46eSDavid Howells #define SEQ_PGM_CHANGE(dev, chn, patch) \ 1196607ca46eSDavid Howells _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0) 1197607ca46eSDavid Howells 1198607ca46eSDavid Howells #define SEQ_CONTROL(dev, chn, controller, value) \ 1199607ca46eSDavid Howells _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value) 1200607ca46eSDavid Howells 1201607ca46eSDavid Howells #define SEQ_BENDER(dev, chn, value) \ 1202607ca46eSDavid Howells _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value) 1203607ca46eSDavid Howells 1204607ca46eSDavid Howells 1205607ca46eSDavid Howells #define SEQ_V2_X_CONTROL(dev, voice, controller, value) {_SEQ_NEEDBUF(8);\ 1206607ca46eSDavid Howells _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 1207607ca46eSDavid Howells _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\ 1208607ca46eSDavid Howells _seqbuf[_seqbufptr+2] = (dev);\ 1209607ca46eSDavid Howells _seqbuf[_seqbufptr+3] = (voice);\ 1210607ca46eSDavid Howells _seqbuf[_seqbufptr+4] = (controller);\ 1211607ca46eSDavid Howells _seqbuf[_seqbufptr+5] = ((value)&0xff);\ 1212607ca46eSDavid Howells _seqbuf[_seqbufptr+6] = ((value>>8)&0xff);\ 1213607ca46eSDavid Howells _seqbuf[_seqbufptr+7] = 0;\ 1214607ca46eSDavid Howells _SEQ_ADVBUF(8);} 1215607ca46eSDavid Howells /* 1216607ca46eSDavid Howells * The following 5 macros are incorrectly implemented and obsolete. 1217607ca46eSDavid Howells * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead. 1218607ca46eSDavid Howells */ 1219607ca46eSDavid Howells #define SEQ_PITCHBEND(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value) 1220607ca46eSDavid Howells #define SEQ_BENDER_RANGE(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value) 1221607ca46eSDavid Howells #define SEQ_EXPRESSION(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128) 1222607ca46eSDavid Howells #define SEQ_MAIN_VOLUME(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100) 1223607ca46eSDavid Howells #define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2) 1224607ca46eSDavid Howells 1225607ca46eSDavid Howells /* 1226607ca46eSDavid Howells * Timing and synchronization macros 1227607ca46eSDavid Howells */ 1228607ca46eSDavid Howells 1229607ca46eSDavid Howells #define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\ 1230607ca46eSDavid Howells _seqbuf[_seqbufptr+0] = EV_TIMING; \ 1231607ca46eSDavid Howells _seqbuf[_seqbufptr+1] = (ev); \ 1232607ca46eSDavid Howells _seqbuf[_seqbufptr+2] = 0;\ 1233607ca46eSDavid Howells _seqbuf[_seqbufptr+3] = 0;\ 1234607ca46eSDavid Howells *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \ 1235607ca46eSDavid Howells _SEQ_ADVBUF(8);} 1236607ca46eSDavid Howells 1237607ca46eSDavid Howells #define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0) 1238607ca46eSDavid Howells #define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0) 1239607ca46eSDavid Howells #define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0) 1240607ca46eSDavid Howells #define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks) 1241607ca46eSDavid Howells #define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks) 1242607ca46eSDavid Howells #define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key) 1243607ca46eSDavid Howells #define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value) 1244607ca46eSDavid Howells #define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos) 1245607ca46eSDavid Howells #define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig) 1246607ca46eSDavid Howells 1247607ca46eSDavid Howells /* 1248607ca46eSDavid Howells * Local control events 1249607ca46eSDavid Howells */ 1250607ca46eSDavid Howells 1251607ca46eSDavid Howells #define _LOCAL_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\ 1252607ca46eSDavid Howells _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \ 1253607ca46eSDavid Howells _seqbuf[_seqbufptr+1] = (ev); \ 1254607ca46eSDavid Howells _seqbuf[_seqbufptr+2] = 0;\ 1255607ca46eSDavid Howells _seqbuf[_seqbufptr+3] = 0;\ 1256607ca46eSDavid Howells *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \ 1257607ca46eSDavid Howells _SEQ_ADVBUF(8);} 1258607ca46eSDavid Howells 1259607ca46eSDavid Howells #define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask) 1260607ca46eSDavid Howells /* 1261607ca46eSDavid Howells * Events for the level 1 interface only 1262607ca46eSDavid Howells */ 1263607ca46eSDavid Howells 1264607ca46eSDavid Howells #define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\ 1265607ca46eSDavid Howells _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\ 1266607ca46eSDavid Howells _seqbuf[_seqbufptr+1] = (byte);\ 1267607ca46eSDavid Howells _seqbuf[_seqbufptr+2] = (device);\ 1268607ca46eSDavid Howells _seqbuf[_seqbufptr+3] = 0;\ 1269607ca46eSDavid Howells _SEQ_ADVBUF(4);} 1270607ca46eSDavid Howells 1271607ca46eSDavid Howells /* 1272607ca46eSDavid Howells * Patch loading. 1273607ca46eSDavid Howells */ 1274607ca46eSDavid Howells #define SEQ_WRPATCH(patchx, len) \ 1275607ca46eSDavid Howells {if (_seqbufptr) SEQ_DUMPBUF();\ 1276607ca46eSDavid Howells if (write(seqfd, (char*)(patchx), len)==-1) \ 1277607ca46eSDavid Howells perror("Write patch: /dev/sequencer");} 1278607ca46eSDavid Howells #define SEQ_WRPATCH2(patchx, len) \ 1279607ca46eSDavid Howells (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len)) 1280607ca46eSDavid Howells 1281607ca46eSDavid Howells #endif 1282607ca46eSDavid Howells #endif /* _UAPISOUNDCARD_H */ 1283