root/include/linux/soundcard.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


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

/* [previous][next][first][last][top][bottom][index][help] */