soundcard.h 45 KB

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