soundcard.h 47 KB

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