1 /* 2 * Copyright by Hannu Savolainen 1993 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 * 25 * 26 * $Id: soundcard.h,v 1.6 1994/08/02 07:39:03 davidg Exp $ 27 */ 28 29 #ifndef _I386_MACHINE_SOUNDCARD_H_ 30 #define _I386_MACHINE_SOUNDCARD_H_ 31 32 /* 33 * If you make modifications to this file, please contact me before 34 * distributing the modified version. There is already enough 35 * divercity in the world. 36 * 37 * Regards, 38 * Hannu Savolainen 39 * hannu@voxware.pp.fi, Hannu.Savolainen@helsinki.fi 40 */ 41 42 #define SOUND_VERSION 205 43 #define VOXWARE 44 45 #include <sys/ioctl.h> 46 47 /* 48 * Supported card ID numbers (Should be somewhere else?) 49 */ 50 51 #define SNDCARD_ADLIB 1 52 #define SNDCARD_SB 2 53 #define SNDCARD_PAS 3 54 #define SNDCARD_GUS 4 55 #define SNDCARD_MPU401 5 56 #define SNDCARD_SB16 6 57 #define SNDCARD_SB16MIDI 7 58 59 /*********************************** 60 * IOCTL Commands for /dev/sequencer 61 */ 62 63 #ifndef _IOWR 64 /* @(#)ioctlp.h */ 65 66 /* Ioctl's have the command encoded in the lower word, 67 * and the size of any in or out parameters in the upper 68 * word. The high 2 bits of the upper word are used 69 * to encode the in/out status of the parameter; for now 70 * we restrict parameters to at most 128 bytes. 71 */ 72 /* #define IOCTYPE (0xff<<8) */ 73 #define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ 74 #define IOC_VOID 0x00000000 /* no parameters */ 75 #define IOC_OUT 0x20000000 /* copy out parameters */ 76 #define IOC_IN 0x40000000 /* copy in parameters */ 77 #define IOC_INOUT (IOC_IN|IOC_OUT) 78 /* the 0x20000000 is so we can distinguish new ioctl's from old */ 79 #define _IO(x,y) ((int)(IOC_VOID|(x<<8)|y)) 80 #define _IOR(x,y,t) ((int)(IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) 81 #define _IOW(x,y,t) ((int)(IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) 82 /* this should be _IORW, but stdio got there first */ 83 #define _IOWR(x,y,t) ((int)(IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)) 84 #endif /* !_IOWR */ 85 86 #define SNDCTL_SEQ_RESET _IO ('Q', 0) 87 #define SNDCTL_SEQ_SYNC _IO ('Q', 1) 88 #define SNDCTL_SYNTH_INFO _IOWR('Q', 2, struct synth_info) 89 #define SNDCTL_SEQ_CTRLRATE _IOWR('Q', 3, int) /* Set/get timer resolution (HZ) */ 90 #define SNDCTL_SEQ_GETOUTCOUNT _IOR ('Q', 4, int) 91 #define SNDCTL_SEQ_GETINCOUNT _IOR ('Q', 5, int) 92 #define SNDCTL_SEQ_PERCMODE _IOW ('Q', 6, int) 93 #define SNDCTL_FM_LOAD_INSTR _IOW ('Q', 7, struct sbi_instrument) /* Valid for FM only */ 94 #define SNDCTL_SEQ_TESTMIDI _IOW ('Q', 8, int) 95 #define SNDCTL_SEQ_RESETSAMPLES _IOW ('Q', 9, int) 96 #define SNDCTL_SEQ_NRSYNTHS _IOR ('Q',10, int) 97 #define SNDCTL_SEQ_NRMIDIS _IOR ('Q',11, int) 98 #define SNDCTL_MIDI_INFO _IOWR('Q',12, struct midi_info) 99 #define SNDCTL_SEQ_TRESHOLD _IOW ('Q',13, int) 100 #define SNDCTL_SYNTH_MEMAVL _IOWR('Q',14, int) /* in=dev#, out=memsize */ 101 #define SNDCTL_FM_4OP_ENABLE _IOW ('Q',15, int) /* in=dev# */ 102 #define SNDCTL_PMGR_ACCESS _IOWR('Q',16, struct patmgr_info) 103 104 /* 105 * Sample loading mechanism for internal synthesizers (/dev/sequencer) 106 * The following patch_info structure has been designed to support 107 * Gravis UltraSound. It tries to be universal format for uploading 108 * sample based patches but is propably too limited. 109 */ 110 111 struct patch_info { 112 short key; /* Use GUS_PATCH here */ 113 #define GUS_PATCH 0x04fd 114 #define OBSOLETE_GUS_PATCH 0x02fd 115 short device_no; /* Synthesizer number */ 116 short instr_no; /* Midi pgm# */ 117 118 unsigned long mode; 119 /* 120 * The least significant byte has the same format than the GUS .PAT 121 * files 122 */ 123 #define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */ 124 #define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */ 125 #define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */ 126 #define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */ 127 #define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */ 128 #define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/ 129 #define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */ 130 /* (use the env_rate/env_offs fields). */ 131 /* Linux specific bits */ 132 #define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */ 133 #define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */ 134 #define WAVE_SCALE 0x00040000 /* The scaling info is valid */ 135 /* Other bits must be zeroed */ 136 137 long len; /* Size of the wave data in bytes */ 138 long loop_start, loop_end; /* Byte offsets from the beginning */ 139 140 /* 141 * The base_freq and base_note fields are used when computing the 142 * playback speed for a note. The base_note defines the tone frequency 143 * which is heard if the sample is played using the base_freq as the 144 * playback speed. 145 * 146 * The low_note and high_note fields define the minimum and maximum note 147 * frequencies for which this sample is valid. It is possible to define 148 * more than one samples for a instrument number at the same time. The 149 * low_note and high_note fields are used to select the most suitable one. 150 * 151 * The fields base_note, high_note and low_note should contain 152 * the note frequency multiplied by 1000. For example value for the 153 * middle A is 440*1000. 154 */ 155 156 unsigned int base_freq; 157 unsigned long base_note; 158 unsigned long high_note; 159 unsigned long low_note; 160 int panning; /* -128=left, 127=right */ 161 int detuning; 162 163 /* New fields introduced in version 1.99.5 */ 164 165 /* Envelope. Enabled by mode bit WAVE_ENVELOPES */ 166 unsigned char env_rate[ 6 ]; /* GUS HW ramping rate */ 167 unsigned char env_offset[ 6 ]; /* 255 == 100% */ 168 169 /* 170 * The tremolo, vibrato and scale info are not supported yet. 171 * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or 172 * WAVE_SCALE 173 */ 174 175 unsigned char tremolo_sweep; 176 unsigned char tremolo_rate; 177 unsigned char tremolo_depth; 178 179 unsigned char vibrato_sweep; 180 unsigned char vibrato_rate; 181 unsigned char vibrato_depth; 182 183 int scale_frequency; 184 unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */ 185 186 int volume; 187 int spare[4]; 188 char data[1]; /* The waveform data starts here */ 189 }; 190 191 192 /* 193 * Patch management interface (/dev/sequencer, /dev/patmgr#) 194 * Don't use these calls if you want to maintain compatibility with 195 * the future versions of the driver. 196 */ 197 198 #define PS_NO_PATCHES 0 /* No patch support on device */ 199 #define PS_MGR_NOT_OK 1 /* Plain patch support (no mgr) */ 200 #define PS_MGR_OK 2 /* Patch manager supported */ 201 #define PS_MANAGED 3 /* Patch manager running */ 202 203 #define SNDCTL_PMGR_IFACE _IOWR('P', 1, struct patmgr_info) 204 205 /* 206 * The patmgr_info is a fixed size structure which is used for two 207 * different purposes. The intended use is for communication between 208 * the application using /dev/sequencer and the patch manager daemon 209 * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)). 210 * 211 * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows 212 * a patch manager daemon to read and write device parameters. This 213 * ioctl available through /dev/sequencer also. Avoid using it since it's 214 * extremely hardware dependent. In addition access trough /dev/sequencer 215 * may confuse the patch manager daemon. 216 */ 217 218 struct patmgr_info { /* Note! size must be < 4k since kmalloc() is used */ 219 unsigned long key; /* Don't worry. Reserved for communication 220 between the patch manager and the driver. */ 221 #define PM_K_EVENT 1 /* Event from the /dev/sequencer driver */ 222 #define PM_K_COMMAND 2 /* Request from a application */ 223 #define PM_K_RESPONSE 3 /* From patmgr to application */ 224 #define PM_ERROR 4 /* Error returned by the patmgr */ 225 int device; 226 int command; 227 228 /* 229 * Commands 0x000 to 0xfff reserved for patch manager programs 230 */ 231 #define PM_GET_DEVTYPE 1 /* Returns type of the patch mgr interface of dev */ 232 #define PMTYPE_FM2 1 /* 2 OP fm */ 233 #define PMTYPE_FM4 2 /* Mixed 4 or 2 op FM (OPL-3) */ 234 #define PMTYPE_WAVE 3 /* Wave table synthesizer (GUS) */ 235 #define PM_GET_NRPGM 2 /* Returns max # of midi programs in parm1 */ 236 #define PM_GET_PGMMAP 3 /* Returns map of loaded midi programs in data8 */ 237 #define PM_GET_PGM_PATCHES 4 /* Return list of patches of a program (parm1) */ 238 #define PM_GET_PATCH 5 /* Return patch header of patch parm1 */ 239 #define PM_SET_PATCH 6 /* Set patch header of patch parm1 */ 240 #define PM_READ_PATCH 7 /* Read patch (wave) data */ 241 #define PM_WRITE_PATCH 8 /* Write patch (wave) data */ 242 243 /* 244 * Commands 0x1000 to 0xffff are for communication between the patch manager 245 * and the client 246 */ 247 #define _PM_LOAD_PATCH 0x100 248 249 /* 250 * Commands above 0xffff reserved for device specific use 251 */ 252 253 long parm1; 254 long parm2; 255 long parm3; 256 257 union { 258 unsigned char data8[4000]; 259 unsigned short data16[2000]; 260 unsigned long data32[1000]; 261 struct patch_info patch; 262 } data; 263 }; 264 265 /* 266 * When a patch manager daemon is present, it will be informed by the 267 * driver when something important happens. For example when the 268 * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is 269 * returned. The command field contains the event type: 270 */ 271 #define PM_E_OPENED 1 /* /dev/sequencer opened */ 272 #define PM_E_CLOSED 2 /* /dev/sequencer closed */ 273 #define PM_E_PATCH_RESET 3 /* SNDCTL_RESETSAMPLES called */ 274 #define PM_E_PATCH_LOADED 4 /* A patch has been loaded by appl */ 275 276 /* 277 * /dev/sequencer input events. 278 * 279 * The data written to the /dev/sequencer is a stream of events. Events 280 * are records of 4 or 8 bytes. The first byte defines the size. 281 * Any number of events can be written with a write call. There 282 * is a set of macros for sending these events. Use these macros if you 283 * want to maximize portability of your program. 284 * 285 * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events. 286 * (All input events are currently 4 bytes long. Be prepared to support 287 * 8 byte events also. If you receive any event having first byte >= 0xf0, 288 * it's a 8 byte event. 289 * 290 * The events are documented at the end of this file. 291 * 292 * Normal events (4 bytes) 293 * There is also a 8 byte version of most of the 4 byte events. The 294 * 8 byte one is recommended. 295 */ 296 #define SEQ_NOTEOFF 0 297 #define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */ 298 #define SEQ_NOTEON 1 299 #define SEQ_FMNOTEON SEQ_NOTEON 300 #define SEQ_WAIT 2 301 #define SEQ_PGMCHANGE 3 302 #define SEQ_FMPGMCHANGE SEQ_PGMCHANGE 303 #define SEQ_SYNCTIMER 4 304 #define SEQ_MIDIPUTC 5 305 #define SEQ_DRUMON 6 /*** OBSOLETE ***/ 306 #define SEQ_DRUMOFF 7 /*** OBSOLETE ***/ 307 #define SEQ_ECHO 8 /* For synching programs with output */ 308 #define SEQ_AFTERTOUCH 9 309 #define SEQ_CONTROLLER 10 310 #define CTRL_PITCH_BENDER 255 311 #define CTRL_PITCH_BENDER_RANGE 254 312 #define CTRL_EXPRESSION 253 313 #define CTRL_MAIN_VOLUME 252 314 #define SEQ_BALANCE 11 315 #define SEQ_VOLMODE 12 316 317 /* 318 * Volume mode decides how volumes are used 319 */ 320 321 #define VOL_METHOD_ADAGIO 1 322 #define VOL_METHOD_LINEAR 2 323 324 /* 325 * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as 326 * input events. 327 */ 328 329 /* 330 * Event codes 0xf0 to 0xfc are reserved for future extensions. 331 */ 332 333 #define SEQ_FULLSIZE 0xfd /* Long events */ 334 /* 335 * SEQ_FULLSIZE events are used for loading patches/samples to the 336 * synthesizer devices. These events are passed directly to the driver 337 * of the associated synthesizer device. There is no limit to the size 338 * of the extended events. These events are not queued but executed 339 * immediately when the write() is called (execution can take several 340 * seconds of time). 341 * 342 * When a SEQ_FULLSIZE message is written to the device, it must 343 * be written using exactly one write() call. Other events cannot 344 * be mixed to the same write. 345 * 346 * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the 347 * /dev/sequencer. Don't write other data together with the instrument structure 348 * Set the key field of the structure to FM_PATCH. The device field is used to 349 * route the patch to the corresponding device. 350 * 351 * For Gravis UltraSound use struct patch_info. Initialize the key field 352 * to GUS_PATCH. 353 */ 354 #define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */ 355 #define SEQ_EXTENDED 0xff /* Extended events (8 bytes) */ 356 357 /* 358 * Extended events for synthesizers (8 bytes) 359 * 360 * Format: 361 * 362 * b0 = SEQ_EXTENDED 363 * b1 = command 364 * b2 = device 365 * b3-b7 = parameters 366 * 367 * Command b3 b4 b5 b6 b7 368 * ---------------------------------------------------------------------------- 369 * SEQ_NOTEON voice note volume 0 0 370 * SEQ_NOTEOFF voice note volume 0 0 371 * SEQ_PGMCHANGE voice pgm 0 0 0 372 * SEQ_DRUMON (voice) drum# volume 0 0 373 * SEQ_DRUMOFF (voice) drum# volume 0 0 374 */ 375 376 /* 377 * Record for FM patches 378 */ 379 380 typedef unsigned char sbi_instr_data[32]; 381 382 struct sbi_instrument { 383 unsigned short key; /* Initialize to FM_PATCH or OPL3_PATCH */ 384 #define FM_PATCH 0x01fd 385 #define OPL3_PATCH 0x03fd 386 short device; /* Synth# (0-4) */ 387 int channel; /* Program# to be initialized */ 388 sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */ 389 }; 390 391 struct synth_info { /* Read only */ 392 char name[30]; 393 int device; /* 0-N. INITIALIZE BEFORE CALLING */ 394 int synth_type; 395 #define SYNTH_TYPE_FM 0 396 #define SYNTH_TYPE_SAMPLE 1 397 398 int synth_subtype; 399 #define FM_TYPE_ADLIB 0x00 400 #define FM_TYPE_OPL3 0x01 401 402 #define SAMPLE_TYPE_GUS 0x10 403 404 int perc_mode; /* No longer supported */ 405 int nr_voices; 406 int nr_drums; /* Obsolete field */ 407 int instr_bank_size; 408 unsigned long capabilities; 409 #define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */ 410 #define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */ 411 int dummies[19]; /* Reserve space */ 412 }; 413 414 struct midi_info { 415 char name[30]; 416 int device; /* 0-N. INITIALIZE BEFORE CALLING */ 417 unsigned long capabilities; /* To be defined later */ 418 int dev_type; 419 int dummies[18]; /* Reserve space */ 420 }; 421 422 /******************************************** 423 * IOCTL commands for /dev/dsp and /dev/audio 424 */ 425 426 #define SNDCTL_DSP_RESET _IO ('P', 0) 427 #define SNDCTL_DSP_SYNC _IO ('P', 1) 428 #define SNDCTL_DSP_SPEED _IOWR('P', 2, int) 429 #define SNDCTL_DSP_STEREO _IOWR('P', 3, int) 430 #define SNDCTL_DSP_GETBLKSIZE _IOWR('P', 4, int) 431 #define SNDCTL_DSP_SAMPLESIZE _IOWR('P', 5, int) /* 8, 12 or 16 */ 432 #define SOUND_PCM_WRITE_CHANNELS _IOWR('P', 6, int) 433 #define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int) 434 #define SNDCTL_DSP_POST _IO ('P', 8) 435 #define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int) 436 437 #define SOUND_PCM_READ_RATE _IOR ('P', 2, int) 438 #define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int) 439 #define SOUND_PCM_READ_BITS _IOR ('P', 5, int) 440 #define SOUND_PCM_READ_FILTER _IOR ('P', 7, int) 441 442 /* Some alias names */ 443 #define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SAMPLESIZE 444 #define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED 445 #define SOUND_PCM_POST SNDCTL_DSP_POST 446 #define SOUND_PCM_RESET SNDCTL_DSP_RESET 447 #define SOUND_PCM_SYNC SNDCTL_DSP_SYNC 448 #define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE 449 450 /********************************************* 451 * IOCTL commands for /dev/mixer 452 */ 453 454 /* 455 * Mixer devices 456 * 457 * There can be up to 20 different analog mixer channels. The 458 * SOUND_MIXER_NRDEVICES gives the currently supported maximum. 459 * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells 460 * the devices supported by the particular mixer. 461 */ 462 463 #define SOUND_MIXER_NRDEVICES 12 464 #define SOUND_MIXER_VOLUME 0 465 #define SOUND_MIXER_BASS 1 466 #define SOUND_MIXER_TREBLE 2 467 #define SOUND_MIXER_SYNTH 3 468 #define SOUND_MIXER_PCM 4 469 #define SOUND_MIXER_SPEAKER 5 470 #define SOUND_MIXER_LINE 6 471 #define SOUND_MIXER_MIC 7 472 #define SOUND_MIXER_CD 8 473 #define SOUND_MIXER_IMIX 9 /* Recording monitor */ 474 #define SOUND_MIXER_ALTPCM 10 475 #define SOUND_MIXER_RECLEV 11 /* Recording level */ 476 477 /* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */ 478 /* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */ 479 #define SOUND_ONOFF_MIN 28 480 #define SOUND_ONOFF_MAX 30 481 #define SOUND_MIXER_MUTE 28 /* 0 or 1 */ 482 #define SOUND_MIXER_ENHANCE 29 /* Enhanced stereo (0, 40, 60 or 80) */ 483 #define SOUND_MIXER_LOUD 30 /* 0 or 1 */ 484 485 /* Note! Number 31 cannot be used since the sign bit is reserved */ 486 487 #define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \ 488 "Mic ", "CD ", "Mix ", "Pcm2 ", "rec"} 489 490 #define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \ 491 "mic", "cd", "mix", "pcm2", "rec"} 492 493 /* Device bitmask identifiers */ 494 495 #define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */ 496 #define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */ 497 #define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */ 498 #define SOUND_MIXER_CAPS 0xfc 499 #define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */ 500 #define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */ 501 502 /* Device mask bits */ 503 504 #define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME) 505 #define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS) 506 #define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE) 507 #define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH) 508 #define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM) 509 #define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER) 510 #define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE) 511 #define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC) 512 #define SOUND_MASK_CD (1 << SOUND_MIXER_CD) 513 #define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX) 514 #define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM) 515 #define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV) 516 517 #define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE) 518 #define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE) 519 #define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD) 520 521 #define MIXER_READ(dev) _IOR('M', dev, int) 522 #define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME) 523 #define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS) 524 #define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE) 525 #define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH) 526 #define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM) 527 #define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER) 528 #define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE) 529 #define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC) 530 #define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD) 531 #define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX) 532 #define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM) 533 #define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV) 534 #define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE) 535 #define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE) 536 #define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD) 537 538 #define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC) 539 #define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK) 540 #define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK) 541 #define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS) 542 #define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS) 543 544 #define MIXER_WRITE(dev) _IOWR('M', dev, int) 545 #define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME) 546 #define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS) 547 #define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE) 548 #define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH) 549 #define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM) 550 #define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER) 551 #define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE) 552 #define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC) 553 #define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD) 554 #define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX) 555 #define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM) 556 #define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV) 557 #define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE) 558 #define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE) 559 #define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD) 560 561 #define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC) 562 563 /* 564 * The following mixer ioctl calls are compatible with the BSD driver by 565 * Steve Haehnichen <shaehnic@ucsd.edu> 566 * 567 * Since this interface is entirely SB specific, it will be dropped in the 568 * near future. 569 */ 570 571 typedef unsigned char S_BYTE; 572 typedef unsigned char S_FLAG; 573 struct stereo_vol 574 { 575 S_BYTE l; /* Left volume */ 576 S_BYTE r; /* Right volume */ 577 }; 578 579 #define MIXER_IOCTL_SET_LEVELS _IOW ('s', 20, struct sb_mixer_levels) 580 #define MIXER_IOCTL_SET_PARAMS _IOW ('s', 21, struct sb_mixer_params) 581 #define MIXER_IOCTL_READ_LEVELS _IOR ('s', 22, struct sb_mixer_levels) 582 #define MIXER_IOCTL_READ_PARAMS _IOR ('s', 23, struct sb_mixer_params) 583 #define MIXER_IOCTL_RESET _IO ('s', 24) 584 585 /* 586 * Mixer volume levels for MIXER_IOCTL_SET_VOL & MIXER_IOCTL_READ_VOL 587 */ 588 struct sb_mixer_levels 589 { 590 struct stereo_vol master; /* Master volume */ 591 struct stereo_vol voc; /* DSP Voice volume */ 592 struct stereo_vol fm; /* FM volume */ 593 struct stereo_vol line; /* Line-in volume */ 594 struct stereo_vol cd; /* CD audio */ 595 S_BYTE mic; /* Microphone level */ 596 }; 597 598 /* 599 * Mixer parameters for MIXER_IOCTL_SET_PARAMS & MIXER_IOCTL_READ_PARAMS 600 */ 601 struct sb_mixer_params 602 { 603 S_BYTE record_source; /* Recording source (See SRC_xxx below) */ 604 S_FLAG hifreq_filter; /* Filter frequency (hi/low) */ 605 S_FLAG filter_input; /* ANFI input filter */ 606 S_FLAG filter_output; /* DNFI output filter */ 607 S_FLAG dsp_stereo; /* 1 if DSP is in Stereo mode */ 608 }; 609 610 #define SRC_MIC 1 /* Select Microphone recording source */ 611 #define SRC_CD 3 /* Select CD recording source */ 612 #define SRC_LINE 7 /* Use Line-in for recording source */ 613 614 #if !defined(KERNEL) && !defined(INKERNEL) 615 /* 616 * Some convenience macros to simplify programming of the 617 * /dev/sequencer interface 618 * 619 * These macros define the API which should be used when possible. 620 */ 621 622 void seqbuf_dump(void); /* This function must be provided by programs */ 623 624 /* Sample seqbuf_dump() implementation: 625 * 626 * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes 627 * 628 * int seqfd; -- The file descriptor for /dev/sequencer. 629 * 630 * void 631 * seqbuf_dump () 632 * { 633 * if (_seqbufptr) 634 * if (write (seqfd, _seqbuf, _seqbufptr) == -1) 635 * { 636 * perror ("write /dev/sequencer"); 637 * exit (-1); 638 * } 639 * _seqbufptr = 0; 640 * } 641 */ 642 643 #define SEQ_DEFINEBUF(len) unsigned char _seqbuf[len]; int _seqbuflen = len; int _seqbufptr = 0 644 #define SEQ_DECLAREBUF() extern unsigned char _seqbuf[]; extern int _seqbuflen;extern int _seqbufptr 645 #define SEQ_PM_DEFINES struct patmgr_info _pm_info 646 #define _SEQ_NEEDBUF(len) if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump() 647 #define _SEQ_ADVBUF(len) _seqbufptr += len 648 #define SEQ_DUMPBUF seqbuf_dump 649 #define PM_LOAD_PATCH(dev, bank, pgm) (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ 650 _pm_info.device=dev, _pm_info.data.data8[0]=pgm, \ 651 _pm_info.parm1 = bank, _pm_info.parm2 = 1, \ 652 ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) 653 #define PM_LOAD_PATCHES(dev, bank, pgm) (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \ 654 _pm_info.device=dev, memcpy(_pm_info.data.data8, pgm, 128), \ 655 _pm_info.parm1 = bank, _pm_info.parm2 = 128, \ 656 ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info)) 657 658 #define SEQ_VOLUME_MODE(dev, mode) {_SEQ_NEEDBUF(8);\ 659 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 660 _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\ 661 _seqbuf[_seqbufptr+2] = (dev);\ 662 _seqbuf[_seqbufptr+3] = (mode);\ 663 _seqbuf[_seqbufptr+4] = 0;\ 664 _seqbuf[_seqbufptr+5] = 0;\ 665 _seqbuf[_seqbufptr+6] = 0;\ 666 _seqbuf[_seqbufptr+7] = 0;\ 667 _SEQ_ADVBUF(8);} 668 669 #define SEQ_START_NOTE(dev, voice, note, vol) {_SEQ_NEEDBUF(8);\ 670 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 671 _seqbuf[_seqbufptr+1] = SEQ_NOTEON;\ 672 _seqbuf[_seqbufptr+2] = (dev);\ 673 _seqbuf[_seqbufptr+3] = (voice);\ 674 _seqbuf[_seqbufptr+4] = (note);\ 675 _seqbuf[_seqbufptr+5] = (vol);\ 676 _seqbuf[_seqbufptr+6] = 0;\ 677 _seqbuf[_seqbufptr+7] = 0;\ 678 _SEQ_ADVBUF(8);} 679 680 #define SEQ_STOP_NOTE(dev, voice, note, vol) {_SEQ_NEEDBUF(8);\ 681 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 682 _seqbuf[_seqbufptr+1] = SEQ_NOTEOFF;\ 683 _seqbuf[_seqbufptr+2] = (dev);\ 684 _seqbuf[_seqbufptr+3] = (voice);\ 685 _seqbuf[_seqbufptr+4] = (note);\ 686 _seqbuf[_seqbufptr+5] = (vol);\ 687 _seqbuf[_seqbufptr+6] = 0;\ 688 _seqbuf[_seqbufptr+7] = 0;\ 689 _SEQ_ADVBUF(8);} 690 691 #define SEQ_CHN_PRESSURE(dev, voice, pressure) {_SEQ_NEEDBUF(8);\ 692 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 693 _seqbuf[_seqbufptr+1] = SEQ_AFTERTOUCH;\ 694 _seqbuf[_seqbufptr+2] = (dev);\ 695 _seqbuf[_seqbufptr+3] = (voice);\ 696 _seqbuf[_seqbufptr+4] = (pressure);\ 697 _seqbuf[_seqbufptr+5] = 0;\ 698 _seqbuf[_seqbufptr+6] = 0;\ 699 _seqbuf[_seqbufptr+7] = 0;\ 700 _SEQ_ADVBUF(8);} 701 702 #define SEQ_PANNING(dev, voice, pos) {_SEQ_NEEDBUF(8);\ 703 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 704 _seqbuf[_seqbufptr+1] = SEQ_BALANCE;\ 705 _seqbuf[_seqbufptr+2] = (dev);\ 706 _seqbuf[_seqbufptr+3] = (voice);\ 707 (char)_seqbuf[_seqbufptr+4] = (pos);\ 708 _seqbuf[_seqbufptr+5] = 0;\ 709 _seqbuf[_seqbufptr+6] = 0;\ 710 _seqbuf[_seqbufptr+7] = 0;\ 711 _SEQ_ADVBUF(8);} 712 713 #define SEQ_CONTROL(dev, voice, controller, value) {_SEQ_NEEDBUF(8);\ 714 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 715 _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\ 716 _seqbuf[_seqbufptr+2] = (dev);\ 717 _seqbuf[_seqbufptr+3] = (voice);\ 718 _seqbuf[_seqbufptr+4] = (controller);\ 719 *(short *)&_seqbuf[_seqbufptr+5] = (value);\ 720 _seqbuf[_seqbufptr+7] = 0;\ 721 _SEQ_ADVBUF(8);} 722 723 #define SEQ_PITCHBEND(dev, voice, value) SEQ_CONTROL(dev, voice, CTRL_PITCH_BENDER, value) 724 #define SEQ_BENDER_RANGE(dev, voice, value) SEQ_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value) 725 #define SEQ_EXPRESSION(dev, voice, value) SEQ_CONTROL(dev, voice, CTRL_EXPRESSION, value) 726 #define SEQ_MAIN_VOLUME(dev, voice, value) SEQ_CONTROL(dev, voice, CTRL_MAIN_VOLUME, value) 727 728 #define SEQ_START_TIMER() {_SEQ_NEEDBUF(4);\ 729 _seqbuf[_seqbufptr] = SEQ_SYNCTIMER;\ 730 _seqbuf[_seqbufptr+1] = 0;\ 731 _seqbuf[_seqbufptr+2] = 0;\ 732 _seqbuf[_seqbufptr+3] = 0;\ 733 _SEQ_ADVBUF(4);} 734 #define SEQ_SET_PATCH(dev, voice, patch) {_SEQ_NEEDBUF(8);\ 735 _seqbuf[_seqbufptr] = SEQ_EXTENDED;\ 736 _seqbuf[_seqbufptr+1] = SEQ_PGMCHANGE;\ 737 _seqbuf[_seqbufptr+2] = (dev);\ 738 _seqbuf[_seqbufptr+3] = (voice);\ 739 _seqbuf[_seqbufptr+4] = (patch);\ 740 _seqbuf[_seqbufptr+5] = 0;\ 741 _seqbuf[_seqbufptr+6] = 0;\ 742 _seqbuf[_seqbufptr+7] = 0;\ 743 _SEQ_ADVBUF(8);} 744 745 #define SEQ_WAIT_TIME(ticks) {_SEQ_NEEDBUF(4);\ 746 *(unsigned long *)&_seqbuf[_seqbufptr] = SEQ_WAIT | ((ticks) << 8);\ 747 _SEQ_ADVBUF(4);} 748 749 #define SEQ_ECHO_BACK(key) {_SEQ_NEEDBUF(4);\ 750 *(unsigned long *)&_seqbuf[_seqbufptr] = SEQ_ECHO | ((key) << 8);\ 751 _SEQ_ADVBUF(4);} 752 753 #define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\ 754 _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\ 755 _seqbuf[_seqbufptr+1] = (byte);\ 756 _seqbuf[_seqbufptr+2] = (device);\ 757 _seqbuf[_seqbufptr+3] = 0;\ 758 _SEQ_ADVBUF(4);} 759 #define SEQ_WRPATCH(patchx, len) {if (_seqbufptr) seqbuf_dump();\ 760 if (write(seqfd, (char*)(patchx), len)==-1) \ 761 perror("Write patch: /dev/sequencer");} 762 763 #endif 764 long soundcard_init(long mem_start); 765 #endif 766