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