1 #ifndef SOUNDCARD_H 2 #define SOUNDCARD_H 3 4 #ifndef lint 5 static char *_soundcard_h_ident_ = "@(#)soundcard.h 7.4 03/12/12"; 6 #endif 7 8 /* 9 * Copyright by Hannu Savolainen 1993-1997 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions are 13 * met: 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 2. 15 * Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY 20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32 33 /* 34 * OSS interface version. With versions earlier than 3.6 this value is 35 * an integer with value less than 361. In versions 3.6 and later 36 * it's a six digit hexadecimal value. For example value 37 * of 0x030600 represents OSS version 3.6.0. 38 * Use ioctl(fd, OSS_GETVERSION, &int) to get the version number of 39 * the currently active driver. 40 */ 41 #define SOUND_VERSION 0x030810 42 #define OPEN_SOUND_SYSTEM 43 44 #ifdef _LINUX 45 /* In Linux we need to be prepared for cross compiling */ 46 #include <linux/ioctl.h> 47 #else 48 # ifdef __FreeBSD__ 49 # include <sys/ioccom.h> 50 # else 51 # include <sys/ioctl.h> 52 # endif 53 #endif 54 55 /* 56 * Supported card ID numbers (Should be somewhere else?) 57 */ 58 59 #define SNDCARD_ADLIB 1 60 #define SNDCARD_SB 2 61 #define SNDCARD_PAS 3 62 #define SNDCARD_GUS 4 63 #define SNDCARD_MPU401 5 64 #define SNDCARD_SB16 6 65 #define SNDCARD_SB16MIDI 7 66 #define SNDCARD_UART6850 8 67 #define SNDCARD_GUS16 9 68 #define SNDCARD_MSS 10 69 #define SNDCARD_PSS 11 70 #define SNDCARD_SSCAPE 12 71 #define SNDCARD_PSS_MPU 13 72 #define SNDCARD_PSS_MSS 14 73 #define SNDCARD_SSCAPE_MSS 15 74 #define SNDCARD_TRXPRO 16 75 #define SNDCARD_TRXPRO_SB 17 76 #define SNDCARD_TRXPRO_MPU 18 77 #define SNDCARD_MAD16 19 78 #define SNDCARD_MAD16_MPU 20 79 #define SNDCARD_CS4232 21 80 #define SNDCARD_CS4232_MPU 22 81 #define SNDCARD_MAUI 23 82 #define SNDCARD_PSEUDO_MSS 24 83 #define SNDCARD_GUSPNP 25 84 #define SNDCARD_UART401 26 85 /* Soundcard numbers 27 to N are reserved. Don't add more numbers here */ 86 87 /*********************************** 88 * IOCTL Commands for /dev/sequencer 89 */ 90 91 #ifndef _SIOWR 92 #if defined(_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__INCioctlh) && !defined(__Lynx__))) 93 /* Use already defined ioctl defines if they exist (except with Sun) */ 94 #define SIOCPARM_MASK IOCPARM_MASK 95 #define SIOC_VOID IOC_VOID 96 #define SIOC_OUT IOC_OUT 97 #define SIOC_IN IOC_IN 98 #define SIOC_INOUT IOC_INOUT 99 #define _SIOC_SIZE _IOC_SIZE 100 #define _SIOC_DIR _IOC_DIR 101 #define _SIOC_NONE _IOC_NONE 102 #define _SIOC_READ _IOC_READ 103 #define _SIOC_WRITE _IOC_WRITE 104 #define _SIO _IO 105 #define _SIOR _IOR 106 #define _SIOW _IOW 107 #define _SIOWR _IOWR 108 #else 109 110 /* Ioctl's have the command encoded in the lower word, 111 * and the size of any in or out parameters in the upper 112 * word. The high 2 bits of the upper word are used 113 * to encode the in/out status of the parameter; for now 114 * we restrict parameters to at most 8191 bytes. 115 */ 116 /* #define SIOCTYPE (0xff<<8) */ 117 #define SIOCPARM_MASK 0x1fff /* parameters must be < 8192 bytes */ 118 #define SIOC_VOID 0x00000000 /* no parameters */ 119 #define SIOC_OUT 0x20000000 /* copy out parameters */ 120 #define SIOC_IN 0x40000000 /* copy in parameters */ 121 #define SIOC_INOUT (SIOC_IN|SIOC_OUT) 122 /* the 0x20000000 is so we can distinguish new ioctl's from old */ 123 #define _SIO(x,y) ((int)(SIOC_VOID|(x<<8)|y)) 124 #define _SIOR(x,y,t) ((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) 125 #define _SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) 126 /* this should be _SIORW, but stdio got there first */ 127 #define _SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) 128 #define _SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK) 129 #define _SIOC_DIR(x) (x & 0xf0000000) 130 #define _SIOC_NONE SIOC_VOID 131 #define _SIOC_READ SIOC_OUT 132 #define _SIOC_WRITE SIOC_IN 133 # endif /* _IOWR */ 134 #endif /* !_SIOWR */ 135 136 #define SNDCTL_SEQ_RESET _SIO ('Q', 0) 137 #define SNDCTL_SEQ_SYNC _SIO ('Q', 1) 138 #define SNDCTL_SYNTH_INFO _SIOWR('Q', 2, struct synth_info) 139 #define SNDCTL_SEQ_CTRLRATE _SIOWR('Q', 3, int) /* Set/get timer resolution (HZ) */ 140 #define SNDCTL_SEQ_GETOUTCOUNT _SIOR ('Q', 4, int) 141 #define SNDCTL_SEQ_GETINCOUNT _SIOR ('Q', 5, int) 142 #define SNDCTL_SEQ_PERCMODE _SIOW ('Q', 6, int) 143 #define SNDCTL_FM_LOAD_INSTR _SIOW ('Q', 7, struct sbi_instrument) /* Obsolete. Don't use!!!!!! */ 144 #define SNDCTL_SEQ_TESTMIDI _SIOW ('Q', 8, int) 145 #define SNDCTL_SEQ_RESETSAMPLES _SIOW ('Q', 9, int) 146 #define SNDCTL_SEQ_NRSYNTHS _SIOR ('Q',10, int) 147 #define SNDCTL_SEQ_NRMIDIS _SIOR ('Q',11, int) 148 #define SNDCTL_MIDI_INFO _SIOWR('Q',12, struct midi_info) 149 #define SNDCTL_SEQ_THRESHOLD _SIOW ('Q',13, int) 150 #define SNDCTL_SYNTH_MEMAVL _SIOWR('Q',14, int) /* in=dev#, out=memsize */ 151 #define SNDCTL_FM_4OP_ENABLE _SIOW ('Q',15, int) /* in=dev# */ 152 #define SNDCTL_SEQ_PANIC _SIO ('Q',17) 153 #define SNDCTL_SEQ_OUTOFBAND _SIOW ('Q',18, struct seq_event_rec) 154 #define SNDCTL_SEQ_GETTIME _SIOR ('Q',19, int) 155 #define SNDCTL_SYNTH_ID _SIOWR('Q',20, struct synth_info) 156 #define SNDCTL_SYNTH_CONTROL _SIOWR('Q',21, struct synth_control) 157 #define SNDCTL_SYNTH_REMOVESAMPLE _SIOWR('Q',22, struct remove_sample) 158 159 typedef struct synth_control 160 { 161 int devno; /* Synthesizer # */ 162 char data[4000]; /* Device spesific command/data record */ 163 }synth_control; 164 165 typedef struct remove_sample 166 { 167 int devno; /* Synthesizer # */ 168 int bankno; /* MIDI bank # (0=General MIDI) */ 169 int instrno; /* MIDI instrument number */ 170 } remove_sample; 171 172 typedef struct seq_event_rec { 173 unsigned char arr[8]; 174 } seq_event_rec; 175 176 #define SNDCTL_TMR_TIMEBASE _SIOWR('T', 1, int) 177 #define SNDCTL_TMR_START _SIO ('T', 2) 178 #define SNDCTL_TMR_STOP _SIO ('T', 3) 179 #define SNDCTL_TMR_CONTINUE _SIO ('T', 4) 180 #define SNDCTL_TMR_TEMPO _SIOWR('T', 5, int) 181 #define SNDCTL_TMR_SOURCE _SIOWR('T', 6, int) 182 # define TMR_INTERNAL 0x00000001 183 # define TMR_EXTERNAL 0x00000002 184 # define TMR_MODE_MIDI 0x00000010 185 # define TMR_MODE_FSK 0x00000020 186 # define TMR_MODE_CLS 0x00000040 187 # define TMR_MODE_SMPTE 0x00000080 188 #define SNDCTL_TMR_METRONOME _SIOW ('T', 7, int) 189 #define SNDCTL_TMR_SELECT _SIOW ('T', 8, int) 190 191 /* 192 * Some big endian/little endian handling macros 193 */ 194 195 #if defined(_AIX) || defined(AIX) || defined(sparc) || defined(HPPA) || defined(PPC) 196 /* Big endian machines */ 197 # define _PATCHKEY(id) (0xfd00|id) 198 # define AFMT_S16_NE AFMT_S16_BE 199 #else 200 # define _PATCHKEY(id) ((id<<8)|0xfd) 201 # define AFMT_S16_NE AFMT_S16_LE 202 #endif 203 204 /* 205 * Sample loading mechanism for internal synthesizers (/dev/sequencer) 206 * The following patch_info structure has been designed to support 207 * Gravis UltraSound. It tries to be universal format for uploading 208 * sample based patches but is probably too limited. 209 */ 210 211 struct patch_info { 212 unsigned short key; /* Use WAVE_PATCH here */ 213 #define WAVE_PATCH _PATCHKEY(0x04) 214 #define GUS_PATCH WAVE_PATCH 215 216 short device_no; /* Synthesizer number */ 217 short instr_no; /* Midi pgm# */ 218 219 unsigned int mode; 220 /* 221 * The least significant byte has the same format than the GUS .PAT 222 * files 223 */ 224 #define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ 225 #define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ 226 #define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ 227 #define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ 228 #define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ 229 #define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ 230 #define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ 231 #define WAVE_FAST_RELEASE 0x80 /* bit 7 = Shut off immediately after note off */ 232 /* (use the env_rate/env_offs fields). */ 233 /* Linux specific bits */ 234 #define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ 235 #define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ 236 #define WAVE_SCALE 0x00040000 /* The scaling info is valid */ 237 #define WAVE_FRACTIONS 0x00080000 /* Fraction information is valid */ 238 /* Reserved bits */ 239 #define WAVE_ROM 0x40000000 /* For future use */ 240 #define WAVE_MULAW 0x20000000 /* For future use */ 241 /* Other bits must be zeroed */ 242 243 int len; /* Size of the wave data in bytes */ 244 int loop_start, loop_end; /* Byte offsets from the beginning */ 245 246 /* 247 * The base_freq and base_note fields are used when computing the 248 * playback speed for a note. The base_note defines the tone frequency 249 * which is heard if the sample is played using the base_freq as the 250 * playback speed. 251 * 252 * The low_note and high_note fields define the minimum and maximum note 253 * frequencies for which this sample is valid. It is possible to define 254 * more than one samples for an instrument number at the same time. The 255 * low_note and high_note fields are used to select the most suitable one. 256 * 257 * The fields base_note, high_note and low_note should contain 258 * the note frequency multiplied by 1000. For example value for the 259 * middle A is 440*1000. 260 */ 261 262 unsigned int base_freq; 263 unsigned int base_note; 264 unsigned int high_note; 265 unsigned int low_note; 266 int panning; /* -128=left, 127=right */ 267 int detuning; 268 269 /* New fields introduced in version 1.99.5 */ 270 271 /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ 272 unsigned char env_rate[ 6 ]; /* GUS HW ramping rate */ 273 unsigned char env_offset[ 6 ]; /* 255 == 100% */ 274 275 /* 276 * The tremolo, vibrato and scale info are not supported yet. 277 * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or 278 * WAVE_SCALE 279 */ 280 281 unsigned char tremolo_sweep; 282 unsigned char tremolo_rate; 283 unsigned char tremolo_depth; 284 285 unsigned char vibrato_sweep; 286 unsigned char vibrato_rate; 287 unsigned char vibrato_depth; 288 289 int scale_frequency; 290 unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */ 291 292 int volume; 293 int fractions; 294 int reserved1; 295 int spare[2]; 296 char data[1]; /* The waveform data starts here */ 297 }; 298 299 struct sysex_info { 300 short key; /* Use SYSEX_PATCH or MAUI_PATCH here */ 301 #define SYSEX_PATCH _PATCHKEY(0x05) 302 #define MAUI_PATCH _PATCHKEY(0x06) 303 short device_no; /* Synthesizer number */ 304 int len; /* Size of the sysex data in bytes */ 305 unsigned char data[1]; /* Sysex data starts here */ 306 }; 307 308 /* 309 * /dev/sequencer input events. 310 * 311 * The data written to the /dev/sequencer is a stream of events. Events 312 * are records of 4 or 8 bytes. The first byte defines the size. 313 * Any number of events can be written with a write call. There 314 * is a set of macros for sending these events. Use these macros if you 315 * want to maximize portability of your program. 316 * 317 * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. 318 * (All input events are currently 4 bytes long. Be prepared to support 319 * 8 byte events also. If you receive any event having first byte >= 128, 320 * it's a 8 byte event. 321 * 322 * The events are documented at the end of this file. 323 * 324 * Normal events (4 bytes) 325 * There is also a 8 byte version of most of the 4 byte events. The 326 * 8 byte one is recommended. 327 */ 328 #define SEQ_NOTEOFF 0 329 #define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ 330 #define SEQ_NOTEON 1 331 #define SEQ_FMNOTEON SEQ_NOTEON 332 #define SEQ_WAIT TMR_WAIT_ABS 333 #define SEQ_PGMCHANGE 3 334 #define SEQ_FMPGMCHANGE SEQ_PGMCHANGE 335 #define SEQ_SYNCTIMER TMR_START 336 #define SEQ_MIDIPUTC 5 337 #define SEQ_DRUMON 6 /*** OBSOLETE ***/ 338 #define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ 339 #define SEQ_ECHO TMR_ECHO /* For synching programs with output */ 340 #define SEQ_AFTERTOUCH 9 341 #define SEQ_CONTROLLER 10 342 343 /******************************************* 344 * Midi controller numbers 345 ******************************************* 346 * Controllers 0 to 31 (0x00 to 0x1f) and 347 * 32 to 63 (0x20 to 0x3f) are continuous 348 * controllers. 349 * In the MIDI 1.0 these controllers are sent using 350 * two messages. Controller numbers 0 to 31 are used 351 * to send the MSB and the controller numbers 32 to 63 352 * are for the LSB. Note that just 7 bits are used in MIDI bytes. 353 */ 354 355 #define CTL_BANK_SELECT 0x00 356 #define CTL_MODWHEEL 0x01 357 #define CTL_BREATH 0x02 358 /* undefined 0x03 */ 359 #define CTL_FOOT 0x04 360 #define CTL_PORTAMENTO_TIME 0x05 361 #define CTL_DATA_ENTRY 0x06 362 #define CTL_MAIN_VOLUME 0x07 363 #define CTL_BALANCE 0x08 364 /* undefined 0x09 */ 365 #define CTL_PAN 0x0a 366 #define CTL_EXPRESSION 0x0b 367 /* undefined 0x0c */ 368 /* undefined 0x0d */ 369 /* undefined 0x0e */ 370 /* undefined 0x0f */ 371 #define CTL_GENERAL_PURPOSE1 0x10 372 #define CTL_GENERAL_PURPOSE2 0x11 373 #define CTL_GENERAL_PURPOSE3 0x12 374 #define CTL_GENERAL_PURPOSE4 0x13 375 /* undefined 0x14 - 0x1f */ 376 377 /* undefined 0x20 */ 378 /* The controller numbers 0x21 to 0x3f are reserved for the */ 379 /* least significant bytes of the controllers 0x00 to 0x1f. */ 380 /* These controllers are not recognised by the driver. */ 381 382 /* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. */ 383 /* 0=OFF and 127=ON (intermediate values are possible) */ 384 #define CTL_DAMPER_PEDAL 0x40 385 #define CTL_SUSTAIN 0x40 /* Alias */ 386 #define CTL_HOLD 0x40 /* Alias */ 387 #define CTL_PORTAMENTO 0x41 388 #define CTL_SOSTENUTO 0x42 389 #define CTL_SOFT_PEDAL 0x43 390 /* undefined 0x44 */ 391 #define CTL_HOLD2 0x45 392 /* undefined 0x46 - 0x4f */ 393 394 #define CTL_GENERAL_PURPOSE5 0x50 395 #define CTL_GENERAL_PURPOSE6 0x51 396 #define CTL_GENERAL_PURPOSE7 0x52 397 #define CTL_GENERAL_PURPOSE8 0x53 398 /* undefined 0x54 - 0x5a */ 399 #define CTL_EXT_EFF_DEPTH 0x5b 400 #define CTL_TREMOLO_DEPTH 0x5c 401 #define CTL_CHORUS_DEPTH 0x5d 402 #define CTL_DETUNE_DEPTH 0x5e 403 #define CTL_CELESTE_DEPTH 0x5e /* Alias for the above one */ 404 #define CTL_PHASER_DEPTH 0x5f 405 #define CTL_DATA_INCREMENT 0x60 406 #define CTL_DATA_DECREMENT 0x61 407 #define CTL_NONREG_PARM_NUM_LSB 0x62 408 #define CTL_NONREG_PARM_NUM_MSB 0x63 409 #define CTL_REGIST_PARM_NUM_LSB 0x64 410 #define CTL_REGIST_PARM_NUM_MSB 0x65 411 /* undefined 0x66 - 0x78 */ 412 /* reserved 0x79 - 0x7f */ 413 414 /* Pseudo controllers (not midi compatible) */ 415 #define CTRL_PITCH_BENDER 255 416 #define CTRL_PITCH_BENDER_RANGE 254 417 #define CTRL_EXPRESSION 253 /* Obsolete */ 418 #define CTRL_MAIN_VOLUME 252 /* Obsolete */ 419 #define SEQ_BALANCE 11 420 #define SEQ_VOLMODE 12 421 422 /* 423 * Volume mode decides how volumes are used 424 */ 425 426 #define VOL_METHOD_ADAGIO 1 427 #define VOL_METHOD_LINEAR 2 428 429 /* 430 * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as 431 * input events. 432 */ 433 434 /* 435 * Event codes 0xf0 to 0xfc are reserved for future extensions. 436 */ 437 438 #define SEQ_FULLSIZE 0xfd /* Long events */ 439 /* 440 * SEQ_FULLSIZE events are used for loading patches/samples to the 441 * synthesizer devices. These events are passed directly to the driver 442 * of the associated synthesizer device. There is no limit to the size 443 * of the extended events. These events are not queued but executed 444 * immediately when the write() is called (execution can take several 445 * seconds of time). 446 * 447 * When a SEQ_FULLSIZE message is written to the device, it must 448 * be written using exactly one write() call. Other events cannot 449 * be mixed to the same write. 450 * 451 * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the 452 * /dev/sequencer. Don't write other data together with the instrument structure 453 * Set the key field of the structure to FM_PATCH. The device field is used to 454 * route the patch to the corresponding device. 455 * 456 * For wave table use struct patch_info. Initialize the key field 457 * to WAVE_PATCH. 458 */ 459 #define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ 460 #define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */ 461 462 /* 463 * Record for FM patches 464 */ 465 466 typedef unsigned char sbi_instr_data[32]; 467 468 struct sbi_instrument { 469 unsigned short key; /* FM_PATCH or OPL3_PATCH */ 470 #define FM_PATCH _PATCHKEY(0x01) 471 #define OPL3_PATCH _PATCHKEY(0x03) 472 short device; /* Synth# (0-4) */ 473 int channel; /* Program# to be initialized */ 474 sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */ 475 }; 476 477 struct synth_info { /* Read only */ 478 char name[30]; 479 int device; /* 0-N. INITIALIZE BEFORE CALLING */ 480 int synth_type; 481 #define SYNTH_TYPE_FM 0 482 #define SYNTH_TYPE_SAMPLE 1 483 #define SYNTH_TYPE_MIDI 2 /* Midi interface */ 484 485 int synth_subtype; 486 #define FM_TYPE_ADLIB 0x00 487 #define FM_TYPE_OPL3 0x01 488 #define MIDI_TYPE_MPU401 0x401 489 490 #define SAMPLE_TYPE_BASIC 0x10 491 #define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC 492 493 int perc_mode; /* No longer supported */ 494 int nr_voices; 495 int nr_drums; /* Obsolete field */ 496 int instr_bank_size; 497 unsigned int capabilities; 498 #define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ 499 #define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ 500 #define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */ 501 int dummies[19]; /* Reserve space */ 502 }; 503 504 struct sound_timer_info { 505 char name[32]; 506 int caps; 507 }; 508 509 #define MIDI_CAP_MPU401 1 /* MPU-401 intelligent mode */ 510 511 struct midi_info { 512 char name[30]; 513 int device; /* 0-N. INITIALIZE BEFORE CALLING */ 514 unsigned int capabilities; /* To be defined later */ 515 int dev_type; 516 int dummies[18]; /* Reserve space */ 517 }; 518 519 /******************************************** 520 * ioctl commands for the /dev/midi## 521 */ 522 typedef struct { 523 unsigned char cmd; 524 char nr_args, nr_returns; 525 unsigned char data[30]; 526 } mpu_command_rec; 527 528 #define SNDCTL_MIDI_PRETIME _SIOWR('m', 0, int) 529 #define SNDCTL_MIDI_MPUMODE _SIOWR('m', 1, int) 530 #define SNDCTL_MIDI_MPUCMD _SIOWR('m', 2, mpu_command_rec) 531 532 /******************************************** 533 * IOCTL commands for /dev/dsp and /dev/audio 534 */ 535 536 #define SNDCTL_DSP_RESET _SIO ('P', 0) 537 #define SNDCTL_DSP_SYNC _SIO ('P', 1) 538 #define SNDCTL_DSP_SPEED _SIOWR('P', 2, int) 539 #define SNDCTL_DSP_STEREO _SIOWR('P', 3, int) 540 #define SNDCTL_DSP_GETBLKSIZE _SIOWR('P', 4, int) 541 #define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT 542 #define SNDCTL_DSP_CHANNELS _SIOWR('P', 6, int) 543 #define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS 544 #define SOUND_PCM_WRITE_FILTER _SIOWR('P', 7, int) 545 #define SNDCTL_DSP_POST _SIO ('P', 8) 546 #define SNDCTL_DSP_SUBDIVIDE _SIOWR('P', 9, int) 547 #define SNDCTL_DSP_SETFRAGMENT _SIOWR('P',10, int) 548 549 /* Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */ 550 #define SNDCTL_DSP_GETFMTS _SIOR ('P',11, int) /* Returns a mask */ 551 #define SNDCTL_DSP_SETFMT _SIOWR('P',5, int) /* Selects ONE fmt*/ 552 # define AFMT_QUERY 0x00000000 /* Return current fmt */ 553 # define AFMT_MU_LAW 0x00000001 554 # define AFMT_A_LAW 0x00000002 555 # define AFMT_IMA_ADPCM 0x00000004 556 # define AFMT_U8 0x00000008 557 # define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/ 558 # define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */ 559 # define AFMT_S8 0x00000040 560 # define AFMT_U16_LE 0x00000080 /* Little endian U16 */ 561 # define AFMT_U16_BE 0x00000100 /* Big endian U16 */ 562 # define AFMT_MPEG 0x00000200 /* MPEG (2) audio */ 563 564 /* 565 * Buffer status queries. 566 */ 567 typedef struct audio_buf_info { 568 int fragments; /* # of available fragments (partially usend ones not counted) */ 569 int fragstotal; /* Total # of fragments allocated */ 570 int fragsize; /* Size of a fragment in bytes */ 571 572 int bytes; /* Available space in bytes (includes partially used fragments) */ 573 /* Note! 'bytes' could be more than fragments*fragsize */ 574 } audio_buf_info; 575 576 #define SNDCTL_DSP_GETOSPACE _SIOR ('P',12, audio_buf_info) 577 #define SNDCTL_DSP_GETISPACE _SIOR ('P',13, audio_buf_info) 578 #define SNDCTL_DSP_NONBLOCK _SIO ('P',14) 579 #define SNDCTL_DSP_GETCAPS _SIOR ('P',15, int) 580 # define DSP_CAP_REVISION 0x000000ff /* Bits for revision level (0 to 255) */ 581 # define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */ 582 # define DSP_CAP_REALTIME 0x00000200 /* Real time capability */ 583 # define DSP_CAP_BATCH 0x00000400 /* Device has some kind of */ 584 /* internal buffers which may */ 585 /* cause some delays and */ 586 /* decrease precision of timing */ 587 # define DSP_CAP_COPROC 0x00000800 /* Has a coprocessor */ 588 /* Sometimes it's a DSP */ 589 /* but usually not */ 590 # define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */ 591 # define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */ 592 593 #define SNDCTL_DSP_GETTRIGGER _SIOR ('P',16, int) 594 #define SNDCTL_DSP_SETTRIGGER _SIOW ('P',16, int) 595 # define PCM_ENABLE_INPUT 0x00000001 596 # define PCM_ENABLE_OUTPUT 0x00000002 597 598 typedef struct count_info { 599 int bytes; /* Total # of bytes processed */ 600 int blocks; /* # of fragment transitions since last time */ 601 int ptr; /* Current DMA pointer value */ 602 } count_info; 603 604 #define SNDCTL_DSP_GETIPTR _SIOR ('P',17, count_info) 605 #define SNDCTL_DSP_GETOPTR _SIOR ('P',18, count_info) 606 607 typedef struct buffmem_desc { 608 unsigned *buffer; 609 int size; 610 } buffmem_desc; 611 #define SNDCTL_DSP_MAPINBUF _SIOR ('P', 19, buffmem_desc) 612 #define SNDCTL_DSP_MAPOUTBUF _SIOR ('P', 20, buffmem_desc) 613 #define SNDCTL_DSP_SETSYNCRO _SIO ('P', 21) 614 #define SNDCTL_DSP_SETDUPLEX _SIO ('P', 22) 615 #define SNDCTL_DSP_GETODELAY _SIOR ('P', 23, int) 616 617 /* 618 * Application's profile defines the way how playback underrun situations should be handled. 619 * 620 * APF_NORMAL (the default) and APF_NETWORK make the driver to cleanup the 621 * playback buffer whenever an underrun occurs. This consumes some time 622 * preven's looping the existing buffer. 623 * APF_CPUINTENS is intended to be set by CPU intensive applications which 624 * are likely to run out of time occasionally. In this mode the buffer cleanup is 625 * disabled which saves CPU time but also let's the previous buffer content to 626 * be played during the "pause" after the underrun. 627 */ 628 #define SNDCTL_DSP_PROFILE _SIOW ('P', 23, int) 629 #define APF_NORMAL 0 /* Normal applications */ 630 #define APF_NETWORK 1 /* Underruns probably caused by an "external" delay */ 631 #define APF_CPUINTENS 2 /* Underruns probably caused by "overheating" the CPU */ 632 633 #define SOUND_PCM_READ_RATE _SIOR ('P', 2, int) 634 #define SOUND_PCM_READ_CHANNELS _SIOR ('P', 6, int) 635 #define SOUND_PCM_READ_BITS _SIOR ('P', 5, int) 636 #define SOUND_PCM_READ_FILTER _SIOR ('P', 7, int) 637 638 /* Some alias names */ 639 #define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT 640 #define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED 641 #define SOUND_PCM_POST SNDCTL_DSP_POST 642 #define SOUND_PCM_RESET SNDCTL_DSP_RESET 643 #define SOUND_PCM_SYNC SNDCTL_DSP_SYNC 644 #define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE 645 #define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT 646 #define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS 647 #define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT 648 #define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE 649 #define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE 650 #define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK 651 #define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS 652 #define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER 653 #define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER 654 #define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO 655 #define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR 656 #define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR 657 #define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF 658 #define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF 659 660 /* 661 * ioctl calls to be used in communication with coprocessors and 662 * DSP chips. 663 */ 664 665 typedef struct copr_buffer { 666 int command; /* Set to 0 if not used */ 667 int flags; 668 #define CPF_NONE 0x0000 669 #define CPF_FIRST 0x0001 /* First block */ 670 #define CPF_LAST 0x0002 /* Last block */ 671 int len; 672 int offs; /* If required by the device (0 if not used) */ 673 674 unsigned char data[4000]; /* NOTE! 4000 is not 4k */ 675 } copr_buffer; 676 677 typedef struct copr_debug_buf { 678 int command; /* Used internally. Set to 0 */ 679 int parm1; 680 int parm2; 681 int flags; 682 int len; /* Length of data in bytes */ 683 } copr_debug_buf; 684 685 typedef struct copr_msg { 686 int len; 687 unsigned char data[4000]; 688 } copr_msg; 689 690 #define SNDCTL_COPR_RESET _SIO ('C', 0) 691 #define SNDCTL_COPR_LOAD _SIOWR('C', 1, copr_buffer) 692 #define SNDCTL_COPR_RDATA _SIOWR('C', 2, copr_debug_buf) 693 #define SNDCTL_COPR_RCODE _SIOWR('C', 3, copr_debug_buf) 694 #define SNDCTL_COPR_WDATA _SIOW ('C', 4, copr_debug_buf) 695 #define SNDCTL_COPR_WCODE _SIOW ('C', 5, copr_debug_buf) 696 #define SNDCTL_COPR_RUN _SIOWR('C', 6, copr_debug_buf) 697 #define SNDCTL_COPR_HALT _SIOWR('C', 7, copr_debug_buf) 698 #define SNDCTL_COPR_SENDMSG _SIOWR('C', 8, copr_msg) 699 #define SNDCTL_COPR_RCVMSG _SIOR ('C', 9, copr_msg) 700 701 /********************************************* 702 * IOCTL commands for /dev/mixer 703 */ 704 705 /* 706 * Mixer devices 707 * 708 * There can be up to 20 different analog mixer channels. The 709 * SOUND_MIXER_NRDEVICES gives the currently supported maximum. 710 * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells 711 * the devices supported by the particular mixer. 712 */ 713 714 #define SOUND_MIXER_NRDEVICES 25 715 #define SOUND_MIXER_VOLUME 0 716 #define SOUND_MIXER_BASS 1 717 #define SOUND_MIXER_TREBLE 2 718 #define SOUND_MIXER_SYNTH 3 719 #define SOUND_MIXER_PCM 4 720 #define SOUND_MIXER_SPEAKER 5 721 #define SOUND_MIXER_LINE 6 722 #define SOUND_MIXER_MIC 7 723 #define SOUND_MIXER_CD 8 724 #define SOUND_MIXER_IMIX 9 /* Recording monitor */ 725 #define SOUND_MIXER_ALTPCM 10 726 #define SOUND_MIXER_RECLEV 11 /* Recording level */ 727 #define SOUND_MIXER_IGAIN 12 /* Input gain */ 728 #define SOUND_MIXER_OGAIN 13 /* Output gain */ 729 /* 730 * The AD1848 codec and compatibles have three line level inputs 731 * (line, aux1 and aux2). Since each card manufacturer have assigned 732 * different meanings to these inputs, it's inpractical to assign 733 * specific meanings (line, cd, synth etc.) to them. 734 */ 735 #define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */ 736 #define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */ 737 #define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */ 738 #define SOUND_MIXER_DIGITAL1 17 /* Digital (input) 1 */ 739 #define SOUND_MIXER_DIGITAL2 18 /* Digital (input) 2 */ 740 #define SOUND_MIXER_DIGITAL3 19 /* Digital (input) 3 */ 741 #define SOUND_MIXER_PHONEIN 20 /* Phone input */ 742 #define SOUND_MIXER_PHONEOUT 21 /* Phone output */ 743 #define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */ 744 #define SOUND_MIXER_RADIO 23 /* Radio in */ 745 #define SOUND_MIXER_MONITOR 24 /* Monitor (usually mic) volume */ 746 747 /* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */ 748 /* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */ 749 #define SOUND_ONOFF_MIN 28 750 #define SOUND_ONOFF_MAX 30 751 752 /* Note! Number 31 cannot be used since the sign bit is reserved */ 753 #define SOUND_MIXER_NONE 31 754 755 /* 756 * The following unsupported macros are no longer functional. 757 * Use SOUND_MIXER_PRIVATE# macros in future. 758 */ 759 #define SOUND_MIXER_ENHANCE SOUND_MIXER_NONE 760 #define SOUND_MIXER_MUTE SOUND_MIXER_NONE 761 #define SOUND_MIXER_LOUD SOUND_MIXER_NONE 762 763 764 #define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ 765 "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \ 766 "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \ 767 "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"} 768 769 #define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ 770 "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \ 771 "line1", "line2", "line3", "dig1", "dig2", "dig3", \ 772 "phin", "phout", "video", "radio", "monitor"} 773 774 /* Device bitmask identifiers */ 775 776 #define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */ 777 #define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */ 778 #define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */ 779 #define SOUND_MIXER_CAPS 0xfc 780 # define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */ 781 #define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ 782 783 /* Device mask bits */ 784 785 #define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) 786 #define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) 787 #define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) 788 #define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) 789 #define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) 790 #define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) 791 #define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) 792 #define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) 793 #define SOUND_MASK_CD (1 << SOUND_MIXER_CD) 794 #define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) 795 #define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) 796 #define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) 797 #define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN) 798 #define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN) 799 #define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1) 800 #define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2) 801 #define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3) 802 #define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1) 803 #define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2) 804 #define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3) 805 #define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN) 806 #define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT) 807 #define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO) 808 #define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO) 809 #define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR) 810 811 /* Obsolete macros */ 812 #define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) 813 #define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) 814 #define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) 815 816 #define MIXER_READ(dev) _SIOR('M', dev, int) 817 #define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) 818 #define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) 819 #define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) 820 #define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) 821 #define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) 822 #define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) 823 #define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) 824 #define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) 825 #define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) 826 #define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) 827 #define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) 828 #define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) 829 #define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN) 830 #define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN) 831 #define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1) 832 #define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2) 833 #define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3) 834 835 /* Obsolete macros */ 836 #define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) 837 #define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) 838 #define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) 839 840 #define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) 841 #define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) 842 #define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) 843 #define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) 844 #define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) 845 846 #define MIXER_WRITE(dev) _SIOWR('M', dev, int) 847 #define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) 848 #define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) 849 #define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) 850 #define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) 851 #define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) 852 #define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) 853 #define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) 854 #define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) 855 #define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) 856 #define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) 857 #define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) 858 #define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) 859 #define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN) 860 #define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN) 861 #define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1) 862 #define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2) 863 #define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3) 864 865 /* Obsolete macros */ 866 #define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) 867 #define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) 868 #define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) 869 870 #define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) 871 872 typedef struct mixer_info 873 { 874 char id[16]; 875 char name[32]; 876 int modify_counter; 877 int fillers[10]; 878 } mixer_info; 879 880 typedef struct _old_mixer_info /* Obsolete */ 881 { 882 char id[16]; 883 char name[32]; 884 } _old_mixer_info; 885 886 #define SOUND_MIXER_INFO _SIOR ('M', 101, mixer_info) 887 #define SOUND_OLD_MIXER_INFO _SIOR ('M', 101, _old_mixer_info) 888 889 /* 890 * A mechanism for accessing "proprietary" mixer features. This method 891 * permits passing 128 bytes of arbitrary data between a mixer application 892 * and the mixer driver. Interpretation of the record is defined by 893 * the particular mixer driver. 894 */ 895 typedef unsigned char mixer_record[128]; 896 897 #define SOUND_MIXER_ACCESS _SIOWR('M', 102, mixer_record) 898 899 /* 900 * The SOUND_MIXER_PRIVATE# commands can be redefined by low level drivers. 901 * These features can be used when accessing device specific features. 902 */ 903 #define SOUND_MIXER_PRIVATE1 _SIOWR('M', 111, int) 904 #define SOUND_MIXER_PRIVATE2 _SIOWR('M', 112, int) 905 #define SOUND_MIXER_PRIVATE3 _SIOWR('M', 113, int) 906 #define SOUND_MIXER_PRIVATE4 _SIOWR('M', 114, int) 907 #define SOUND_MIXER_PRIVATE5 _SIOWR('M', 115, int) 908 909 /* 910 * SOUND_MIXER_GETLEVELS and SOUND_MIXER_SETLEVELS calls can be used 911 * for querying current mixer settings from the driver and for loading 912 * default volume settings _prior_ activating the mixer (loading 913 * doesn't affect current state of the mixer hardware). These calls 914 * are for internal use only. 915 */ 916 917 typedef struct mixer_vol_table { 918 int num; /* Index to volume table */ 919 char name[32]; 920 int levels[32]; 921 } mixer_vol_table; 922 923 #define SOUND_MIXER_GETLEVELS _SIOWR('M', 116, mixer_vol_table) 924 #define SOUND_MIXER_SETLEVELS _SIOWR('M', 117, mixer_vol_table) 925 926 /* 927 * An ioctl for identifying the driver version. It will return value 928 * of the SOUND_VERSION macro used when compiling the driver. 929 * This call was introduced in OSS version 3.6 and it will not work 930 * with earlier versions (returns EINVAL). 931 */ 932 #define OSS_GETVERSION _SIOR ('M', 118, int) 933 934 /* 935 * Level 2 event types for /dev/sequencer 936 */ 937 938 /* 939 * The 4 most significant bits of byte 0 specify the class of 940 * the event: 941 * 942 * 0x8X = system level events, 943 * 0x9X = device/port specific events, event[1] = device/port, 944 * The last 4 bits give the subtype: 945 * 0x02 = Channel event (event[3] = chn). 946 * 0x01 = note event (event[4] = note). 947 * (0x01 is not used alone but always with bit 0x02). 948 * event[2] = MIDI message code (0x80=note off etc.) 949 * 950 */ 951 952 #define EV_SEQ_LOCAL 0x80 953 #define EV_TIMING 0x81 954 #define EV_CHN_COMMON 0x92 955 #define EV_CHN_VOICE 0x93 956 #define EV_SYSEX 0x94 957 /* 958 * Event types 200 to 220 are reserved for application use. 959 * These numbers will not be used by the driver. 960 */ 961 962 /* 963 * Events for event type EV_CHN_VOICE 964 */ 965 966 #define MIDI_NOTEOFF 0x80 967 #define MIDI_NOTEON 0x90 968 #define MIDI_KEY_PRESSURE 0xA0 969 970 /* 971 * Events for event type EV_CHN_COMMON 972 */ 973 974 #define MIDI_CTL_CHANGE 0xB0 975 #define MIDI_PGM_CHANGE 0xC0 976 #define MIDI_CHN_PRESSURE 0xD0 977 #define MIDI_PITCH_BEND 0xE0 978 979 #define MIDI_SYSTEM_PREFIX 0xF0 980 981 /* 982 * Timer event types 983 */ 984 #define TMR_WAIT_REL 1 /* Time relative to the prev time */ 985 #define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */ 986 #define TMR_STOP 3 987 #define TMR_START 4 988 #define TMR_CONTINUE 5 989 #define TMR_TEMPO 6 990 #define TMR_ECHO 8 991 #define TMR_CLOCK 9 /* MIDI clock */ 992 #define TMR_SPP 10 /* Song position pointer */ 993 #define TMR_TIMESIG 11 /* Time signature */ 994 995 /* 996 * Local event types 997 */ 998 #define LOCL_STARTAUDIO 1 999 1000 #if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS) 1001 /* 1002 * Some convenience macros to simplify programming of the 1003 * /dev/sequencer interface 1004 * 1005 * These macros define the API which should be used when possible. 1006 */ 1007 #define SEQ_DECLAREBUF() SEQ_USE_EXTBUF() 1008 1009 void seqbuf_dump(void); /* This function must be provided by programs */ 1010 1011 extern int OSS_init(int seqfd, int buflen); 1012 extern void OSS_seqbuf_dump(int fd, unsigned char *buf, int buflen); 1013 extern void OSS_seq_advbuf(int len, int fd, unsigned char *buf, int buflen); 1014 extern void OSS_seq_needbuf(int len, int fd, unsigned char *buf, int buflen); 1015 extern void OSS_patch_caching(int dev, int chn, int patch, 1016 int fd, unsigned char *buf, int buflen); 1017 extern void OSS_drum_caching(int dev, int chn, int patch, 1018 int fd, unsigned char *buf, int buflen); 1019 extern void OSS_write_patch(int fd, unsigned char *buf, int len); 1020 extern int OSS_write_patch2(int fd, unsigned char *buf, int len); 1021 1022 #define SEQ_PM_DEFINES int __foo_bar___ 1023 #ifdef OSSLIB 1024 # define SEQ_USE_EXTBUF() \ 1025 extern unsigned char *_seqbuf; \ 1026 extern int _seqbuflen;extern int _seqbufptr 1027 # define SEQ_DEFINEBUF(len) SEQ_USE_EXTBUF();static int _requested_seqbuflen=len 1028 # define _SEQ_ADVBUF(len) OSS_seq_advbuf(len, seqfd, _seqbuf, _seqbuflen) 1029 # define _SEQ_NEEDBUF(len) OSS_seq_needbuf(len, seqfd, _seqbuf, _seqbuflen) 1030 # define SEQ_DUMPBUF() OSS_seqbuf_dump(seqfd, _seqbuf, _seqbuflen) 1031 1032 # define SEQ_LOAD_GMINSTR(dev, instr) \ 1033 OSS_patch_caching(dev, -1, instr, seqfd, _seqbuf, _seqbuflen) 1034 # define SEQ_LOAD_GMDRUM(dev, drum) \ 1035 OSS_drum_caching(dev, -1, drum, seqfd, _seqbuf, _seqbuflen) 1036 #else /* !OSSLIB */ 1037 1038 # define SEQ_LOAD_GMINSTR(dev, instr) 1039 # define SEQ_LOAD_GMDRUM(dev, drum) 1040 1041 # define SEQ_USE_EXTBUF() \ 1042 extern unsigned char _seqbuf[]; \ 1043 extern int _seqbuflen;extern int _seqbufptr 1044 1045 #ifndef USE_SIMPLE_MACROS 1046 /* Sample seqbuf_dump() implementation: 1047 * 1048 * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes 1049 * 1050 * int seqfd; -- The file descriptor for /dev/sequencer. 1051 * 1052 * void 1053 * seqbuf_dump () 1054 * { 1055 * if (_seqbufptr) 1056 * if (write (seqfd, _seqbuf, _seqbufptr) == -1) 1057 * { 1058 * perror ("write /dev/sequencer"); 1059 * exit (-1); 1060 * } 1061 * _seqbufptr = 0; 1062 * } 1063 */ 1064 1065 #define SEQ_DEFINEBUF(len) unsigned char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0 1066 #define _SEQ_NEEDBUF(len) if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump() 1067 #define _SEQ_ADVBUF(len) _seqbufptr += len 1068 #define SEQ_DUMPBUF seqbuf_dump 1069 #else 1070 /* 1071 * This variation of the sequencer macros is used just to format one event 1072 * using fixed buffer. 1073 * 1074 * The program using the macro library must define the following macros before 1075 * using this library. 1076 * 1077 * #define _seqbuf name of the buffer (unsigned char[]) 1078 * #define _SEQ_ADVBUF(len) If the applic needs to know the exact 1079 * size of the event, this macro can be used. 1080 * Otherwise this must be defined as empty. 1081 * #define _seqbufptr Define the name of index variable or 0 if 1082 * not required. 1083 */ 1084 #define _SEQ_NEEDBUF(len) /* empty */ 1085 #endif 1086 #endif /* !OSSLIB */ 1087 1088 #define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);\ 1089 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 1090 _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\ 1091 _seqbuf[_seqbufptr+2] = (dev);\ 1092 _seqbuf[_seqbufptr+3] = (mode);\ 1093 _seqbuf[_seqbufptr+4] = 0;\ 1094 _seqbuf[_seqbufptr+5] = 0;\ 1095 _seqbuf[_seqbufptr+6] = 0;\ 1096 _seqbuf[_seqbufptr+7] = 0;\ 1097 _SEQ_ADVBUF(8);} 1098 1099 /* 1100 * Midi voice messages 1101 */ 1102 1103 #define _CHN_VOICE(dev, event, chn, note, parm) \ 1104 {_SEQ_NEEDBUF(8);\ 1105 _seqbuf[_seqbufptr] = EV_CHN_VOICE;\ 1106 _seqbuf[_seqbufptr+1] = (dev);\ 1107 _seqbuf[_seqbufptr+2] = (event);\ 1108 _seqbuf[_seqbufptr+3] = (chn);\ 1109 _seqbuf[_seqbufptr+4] = (note);\ 1110 _seqbuf[_seqbufptr+5] = (parm);\ 1111 _seqbuf[_seqbufptr+6] = (0);\ 1112 _seqbuf[_seqbufptr+7] = 0;\ 1113 _SEQ_ADVBUF(8);} 1114 1115 #define SEQ_START_NOTE(dev, chn, note, vol) \ 1116 _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol) 1117 1118 #define SEQ_STOP_NOTE(dev, chn, note, vol) \ 1119 _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol) 1120 1121 #define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \ 1122 _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure) 1123 1124 /* 1125 * Midi channel messages 1126 */ 1127 1128 #define _CHN_COMMON(dev, event, chn, p1, p2, w14) \ 1129 {_SEQ_NEEDBUF(8);\ 1130 _seqbuf[_seqbufptr] = EV_CHN_COMMON;\ 1131 _seqbuf[_seqbufptr+1] = (dev);\ 1132 _seqbuf[_seqbufptr+2] = (event);\ 1133 _seqbuf[_seqbufptr+3] = (chn);\ 1134 _seqbuf[_seqbufptr+4] = (p1);\ 1135 _seqbuf[_seqbufptr+5] = (p2);\ 1136 *(short *)&_seqbuf[_seqbufptr+6] = (w14);\ 1137 _SEQ_ADVBUF(8);} 1138 /* 1139 * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits 1140 * sending any MIDI bytes but it's absolutely not possible. Trying to do 1141 * so _will_ cause problems with MPU401 intelligent mode). 1142 * 1143 * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be 1144 * sent by calling SEQ_SYSEX() several times (there must be no other events 1145 * between them). First sysex fragment must have 0xf0 in the first byte 1146 * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte 1147 * between these sysex start and end markers cannot be larger than 0x7f. Also 1148 * lengths of each fragments (except the last one) must be 6. 1149 * 1150 * Breaking the above rules may work with some MIDI ports but is likely to 1151 * cause fatal problems with some other devices (such as MPU401). 1152 */ 1153 #define SEQ_SYSEX(dev, buf, len) \ 1154 {int ii, ll=(len); \ 1155 unsigned char *bufp=buf;\ 1156 if (ll>6)ll=6;\ 1157 _SEQ_NEEDBUF(8);\ 1158 _seqbuf[_seqbufptr] = EV_SYSEX;\ 1159 _seqbuf[_seqbufptr+1] = (dev);\ 1160 for(ii=0;ii<ll;ii++)\ 1161 _seqbuf[_seqbufptr+ii+2] = bufp[ii];\ 1162 for(ii=ll;ii<6;ii++)\ 1163 _seqbuf[_seqbufptr+ii+2] = 0xff;\ 1164 _SEQ_ADVBUF(8);} 1165 1166 #define SEQ_CHN_PRESSURE(dev, chn, pressure) \ 1167 _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0) 1168 1169 #define SEQ_SET_PATCH SEQ_PGM_CHANGE 1170 #ifdef OSSLIB 1171 # define SEQ_PGM_CHANGE(dev, chn, patch) \ 1172 {OSS_patch_caching(dev, chn, patch, seqfd, _seqbuf, _seqbuflen); \ 1173 _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0);} 1174 #else 1175 # define SEQ_PGM_CHANGE(dev, chn, patch) \ 1176 _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0) 1177 #endif 1178 1179 #define SEQ_CONTROL(dev, chn, controller, value) \ 1180 _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value) 1181 1182 #define SEQ_BENDER(dev, chn, value) \ 1183 _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value) 1184 1185 1186 #define SEQ_V2_X_CONTROL(dev, voice, controller, value) {_SEQ_NEEDBUF(8);\ 1187 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 1188 _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\ 1189 _seqbuf[_seqbufptr+2] = (dev);\ 1190 _seqbuf[_seqbufptr+3] = (voice);\ 1191 _seqbuf[_seqbufptr+4] = (controller);\ 1192 _seqbuf[_seqbufptr+5] = ((value)&0xff);\ 1193 _seqbuf[_seqbufptr+6] = ((value>>8)&0xff);\ 1194 _seqbuf[_seqbufptr+7] = 0;\ 1195 _SEQ_ADVBUF(8);} 1196 /* 1197 * The following 5 macros are incorrectly implemented and obsolete. 1198 * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead. 1199 */ 1200 #define SEQ_PITCHBEND(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value) 1201 #define SEQ_BENDER_RANGE(dev, voice, value) SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value) 1202 #define SEQ_EXPRESSION(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128) 1203 #define SEQ_MAIN_VOLUME(dev, voice, value) SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100) 1204 #define SEQ_PANNING(dev, voice, pos) SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2) 1205 #if 0 1206 #define SEQ_PANNING(dev, voice, pos) {_SEQ_NEEDBUF(8);\ 1207 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 1208 _seqbuf[_seqbufptr+1] = SEQ_BALANCE;\ 1209 _seqbuf[_seqbufptr+2] = (dev);\ 1210 _seqbuf[_seqbufptr+3] = (voice);\ 1211 (char)_seqbuf[_seqbufptr+4] = (pos);\ 1212 _seqbuf[_seqbufptr+5] = 0;\ 1213 _seqbuf[_seqbufptr+6] = 0;\ 1214 _seqbuf[_seqbufptr+7] = 1;\ 1215 _SEQ_ADVBUF(8);} 1216 #endif 1217 1218 /* 1219 * Timing and syncronization macros 1220 */ 1221 1222 #define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\ 1223 _seqbuf[_seqbufptr+0] = EV_TIMING; \ 1224 _seqbuf[_seqbufptr+1] = (ev); \ 1225 _seqbuf[_seqbufptr+2] = 0;\ 1226 _seqbuf[_seqbufptr+3] = 0;\ 1227 *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \ 1228 _SEQ_ADVBUF(8);} 1229 1230 #define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0) 1231 #define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0) 1232 #define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0) 1233 #define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks) 1234 #define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks) 1235 #define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key) 1236 #define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value) 1237 #define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos) 1238 #define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig) 1239 1240 /* 1241 * Local control events 1242 */ 1243 1244 #define _LOCAL_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\ 1245 _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \ 1246 _seqbuf[_seqbufptr+1] = (ev); \ 1247 _seqbuf[_seqbufptr+2] = 0;\ 1248 _seqbuf[_seqbufptr+3] = 0;\ 1249 *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \ 1250 _SEQ_ADVBUF(8);} 1251 1252 #define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask) 1253 /* 1254 * Events for the level 1 interface only 1255 */ 1256 1257 #define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\ 1258 _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\ 1259 _seqbuf[_seqbufptr+1] = (byte);\ 1260 _seqbuf[_seqbufptr+2] = (device);\ 1261 _seqbuf[_seqbufptr+3] = 0;\ 1262 _SEQ_ADVBUF(4);} 1263 1264 /* 1265 * Patch loading. 1266 */ 1267 #ifdef OSSLIB 1268 # define SEQ_WRPATCH(patchx, len) \ 1269 OSS_write_patch(seqfd, (char*)(patchx), len) 1270 # define SEQ_WRPATCH2(patchx, len) \ 1271 OSS_write_patch2(seqfd, (char*)(patchx), len) 1272 #else 1273 # define SEQ_WRPATCH(patchx, len) \ 1274 {if (_seqbufptr) SEQ_DUMPBUF();\ 1275 if (write(seqfd, (char*)(patchx), len)==-1) \ 1276 perror("Write patch: /dev/sequencer");} 1277 # define SEQ_WRPATCH2(patchx, len) \ 1278 (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len)) 1279 #endif 1280 1281 #endif 1282 #endif 1283