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

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