source: sbliveos2/trunk/include/linux/soundcard.h@ 148

Last change on this file since 148 was 142, checked in by ktk, 25 years ago

Import

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