soundcard.h 45 KB

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