Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

soundcard.h 65KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878
  1. /*
  2. * soundcard.h
  3. */
  4. /*-
  5. * Copyright by Hannu Savolainen 1993 / 4Front Technologies 1993-2006
  6. * Modified for the new FreeBSD sound driver by Luigi Rizzo, 1997
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above
  14. * copyright notice, this list of conditions and the following
  15. * disclaimer in the documentation and/or other materials provided
  16. * with the distribution.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
  19. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  20. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  21. * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
  22. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  25. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  26. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  28. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29. * POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. * $FreeBSD: src/sys/sys/soundcard.h,v 1.48 2006/11/26 11:55:48 netchild Exp $
  32. */
  33. /*
  34. * Unless coordinating changes with 4Front Technologies, do NOT make any
  35. * modifications to ioctl commands, types, etc. that would break
  36. * compatibility with the OSS API.
  37. */
  38. #ifndef _SYS_SOUNDCARD_H_
  39. #define _SYS_SOUNDCARD_H_
  40. /*
  41. * If you make modifications to this file, please contact me before
  42. * distributing the modified version. There is already enough
  43. * diversity in the world.
  44. *
  45. * Regards,
  46. * Hannu Savolainen
  47. * hannu@voxware.pp.fi
  48. *
  49. **********************************************************************
  50. * PS. The Hacker's Guide to VoxWare available from
  51. * nic.funet.fi:pub/Linux/ALPHA/sound. The file is
  52. * snd-sdk-doc-0.1.ps.gz (gzipped postscript). It contains
  53. * some useful information about programming with VoxWare.
  54. * (NOTE! The pub/Linux/ALPHA/ directories are hidden. You have
  55. * to cd inside them before the files are accessible.)
  56. **********************************************************************
  57. */
  58. /*
  59. * SOUND_VERSION is only used by the voxware driver. Hopefully apps
  60. * should not depend on it, but rather look at the capabilities
  61. * of the driver in the kernel!
  62. */
  63. #define SOUND_VERSION 301
  64. #define VOXWARE /* does this have any use ? */
  65. /*
  66. * Supported card ID numbers (Should be somewhere else? We keep
  67. * them here just for compativility with the old driver, but these
  68. * constants are of little or no use).
  69. */
  70. #define SNDCARD_ADLIB 1
  71. #define SNDCARD_SB 2
  72. #define SNDCARD_PAS 3
  73. #define SNDCARD_GUS 4
  74. #define SNDCARD_MPU401 5
  75. #define SNDCARD_SB16 6
  76. #define SNDCARD_SB16MIDI 7
  77. #define SNDCARD_UART6850 8
  78. #define SNDCARD_GUS16 9
  79. #define SNDCARD_MSS 10
  80. #define SNDCARD_PSS 11
  81. #define SNDCARD_SSCAPE 12
  82. #define SNDCARD_PSS_MPU 13
  83. #define SNDCARD_PSS_MSS 14
  84. #define SNDCARD_SSCAPE_MSS 15
  85. #define SNDCARD_TRXPRO 16
  86. #define SNDCARD_TRXPRO_SB 17
  87. #define SNDCARD_TRXPRO_MPU 18
  88. #define SNDCARD_MAD16 19
  89. #define SNDCARD_MAD16_MPU 20
  90. #define SNDCARD_CS4232 21
  91. #define SNDCARD_CS4232_MPU 22
  92. #define SNDCARD_MAUI 23
  93. #define SNDCARD_PSEUDO_MSS 24
  94. #define SNDCARD_AWE32 25
  95. #define SNDCARD_NSS 26
  96. #define SNDCARD_UART16550 27
  97. #define SNDCARD_OPL 28
  98. #include <sys/types.h>
  99. #include <machine/endian.h>
  100. #ifndef _IOWR
  101. #include <sys/ioccom.h>
  102. #endif /* !_IOWR */
  103. /*
  104. * The first part of this file contains the new FreeBSD sound ioctl
  105. * interface. Tries to minimize the number of different ioctls, and
  106. * to be reasonably general.
  107. *
  108. * 970821: some of the new calls have not been implemented yet.
  109. */
  110. /*
  111. * the following three calls extend the generic file descriptor
  112. * interface. AIONWRITE is the dual of FIONREAD, i.e. returns the max
  113. * number of bytes for a write operation to be non-blocking.
  114. *
  115. * AIOGSIZE/AIOSSIZE are used to change the behaviour of the device,
  116. * from a character device (default) to a block device. In block mode,
  117. * (not to be confused with blocking mode) the main difference for the
  118. * application is that select() will return only when a complete
  119. * block can be read/written to the device, whereas in character mode
  120. * select will return true when one byte can be exchanged. For audio
  121. * devices, character mode makes select almost useless since one byte
  122. * will always be ready by the next sample time (which is often only a
  123. * handful of microseconds away).
  124. * Use a size of 0 or 1 to return to character mode.
  125. */
  126. #define AIONWRITE _IOR('A', 10, int) /* get # bytes to write */
  127. struct snd_size {
  128. int play_size;
  129. int rec_size;
  130. };
  131. #define AIOGSIZE _IOR('A', 11, struct snd_size)/* read current blocksize */
  132. #define AIOSSIZE _IOWR('A', 11, struct snd_size) /* sets blocksize */
  133. /*
  134. * The following constants define supported audio formats. The
  135. * encoding follows voxware conventions, i.e. 1 bit for each supported
  136. * format. We extend it by using bit 31 (RO) to indicate full-duplex
  137. * capability, and bit 29 (RO) to indicate that the card supports/
  138. * needs different formats on capture & playback channels.
  139. * Bit 29 (RW) is used to indicate/ask stereo.
  140. *
  141. * The number of bits required to store the sample is:
  142. * o 4 bits for the IDA ADPCM format,
  143. * o 8 bits for 8-bit formats, mu-law and A-law,
  144. * o 16 bits for the 16-bit formats, and
  145. * o 32 bits for the 24/32-bit formats.
  146. * o undefined for the MPEG audio format.
  147. */
  148. #define AFMT_QUERY 0x00000000 /* Return current format */
  149. #define AFMT_MU_LAW 0x00000001 /* Logarithmic mu-law */
  150. #define AFMT_A_LAW 0x00000002 /* Logarithmic A-law */
  151. #define AFMT_IMA_ADPCM 0x00000004 /* A 4:1 compressed format where 16-bit
  152. * squence represented using the
  153. * the average 4 bits per sample */
  154. #define AFMT_U8 0x00000008 /* Unsigned 8-bit */
  155. #define AFMT_S16_LE 0x00000010 /* Little endian signed 16-bit */
  156. #define AFMT_S16_BE 0x00000020 /* Big endian signed 16-bit */
  157. #define AFMT_S8 0x00000040 /* Signed 8-bit */
  158. #define AFMT_U16_LE 0x00000080 /* Little endian unsigned 16-bit */
  159. #define AFMT_U16_BE 0x00000100 /* Big endian unsigned 16-bit */
  160. #define AFMT_MPEG 0x00000200 /* MPEG MP2/MP3 audio */
  161. #define AFMT_AC3 0x00000400 /* Dolby Digital AC3 */
  162. #if _BYTE_ORDER == _LITTLE_ENDIAN
  163. #define AFMT_S16_NE AFMT_S16_LE /* native endian signed 16 */
  164. #else
  165. #define AFMT_S16_NE AFMT_S16_BE
  166. #endif
  167. /*
  168. * 32-bit formats below used for 24-bit audio data where the data is stored
  169. * in the 24 most significant bits and the least significant bits are not used
  170. * (should be set to 0).
  171. */
  172. #define AFMT_S32_LE 0x00001000 /* Little endian signed 32-bit */
  173. #define AFMT_S32_BE 0x00002000 /* Big endian signed 32-bit */
  174. #define AFMT_U32_LE 0x00004000 /* Little endian unsigned 32-bit */
  175. #define AFMT_U32_BE 0x00008000 /* Big endian unsigned 32-bit */
  176. #define AFMT_S24_LE 0x00010000 /* Little endian signed 24-bit */
  177. #define AFMT_S24_BE 0x00020000 /* Big endian signed 24-bit */
  178. #define AFMT_U24_LE 0x00040000 /* Little endian unsigned 24-bit */
  179. #define AFMT_U24_BE 0x00080000 /* Big endian unsigned 24-bit */
  180. #define AFMT_STEREO 0x10000000 /* can do/want stereo */
  181. /*
  182. * the following are really capabilities
  183. */
  184. #define AFMT_WEIRD 0x20000000 /* weird hardware... */
  185. /*
  186. * AFMT_WEIRD reports that the hardware might need to operate
  187. * with different formats in the playback and capture
  188. * channels when operating in full duplex.
  189. * As an example, SoundBlaster16 cards only support U8 in one
  190. * direction and S16 in the other one, and applications should
  191. * be aware of this limitation.
  192. */
  193. #define AFMT_FULLDUPLEX 0x80000000 /* can do full duplex */
  194. /*
  195. * The following structure is used to get/set format and sampling rate.
  196. * While it would be better to have things such as stereo, bits per
  197. * sample, endiannes, etc split in different variables, it turns out
  198. * that formats are not that many, and not all combinations are possible.
  199. * So we followed the Voxware approach of associating one bit to each
  200. * format.
  201. */
  202. typedef struct _snd_chan_param {
  203. u_long play_rate; /* sampling rate */
  204. u_long rec_rate; /* sampling rate */
  205. u_long play_format; /* everything describing the format */
  206. u_long rec_format; /* everything describing the format */
  207. } snd_chan_param;
  208. #define AIOGFMT _IOR('f', 12, snd_chan_param) /* get format */
  209. #define AIOSFMT _IOWR('f', 12, snd_chan_param) /* sets format */
  210. /*
  211. * The following structure is used to get/set the mixer setting.
  212. * Up to 32 mixers are supported, each one with up to 32 channels.
  213. */
  214. typedef struct _snd_mix_param {
  215. u_char subdev; /* which output */
  216. u_char line; /* which input */
  217. u_char left,right; /* volumes, 0..255, 0 = mute */
  218. } snd_mix_param ;
  219. /* XXX AIOGMIX, AIOSMIX not implemented yet */
  220. #define AIOGMIX _IOWR('A', 13, snd_mix_param) /* return mixer status */
  221. #define AIOSMIX _IOWR('A', 14, snd_mix_param) /* sets mixer status */
  222. /*
  223. * channel specifiers used in AIOSTOP and AIOSYNC
  224. */
  225. #define AIOSYNC_PLAY 0x1 /* play chan */
  226. #define AIOSYNC_CAPTURE 0x2 /* capture chan */
  227. /* AIOSTOP stop & flush a channel, returns the residual count */
  228. #define AIOSTOP _IOWR ('A', 15, int)
  229. /* alternate method used to notify the sync condition */
  230. #define AIOSYNC_SIGNAL 0x100
  231. #define AIOSYNC_SELECT 0x200
  232. /* what the 'pos' field refers to */
  233. #define AIOSYNC_READY 0x400
  234. #define AIOSYNC_FREE 0x800
  235. typedef struct _snd_sync_parm {
  236. long chan ; /* play or capture channel, plus modifier */
  237. long pos;
  238. } snd_sync_parm;
  239. #define AIOSYNC _IOWR ('A', 15, snd_sync_parm) /* misc. synchronization */
  240. /*
  241. * The following is used to return device capabilities. If the structure
  242. * passed to the ioctl is zeroed, default values are returned for rate
  243. * and formats, a bitmap of available mixers is returned, and values
  244. * (inputs, different levels) for the first one are returned.
  245. *
  246. * If formats, mixers, inputs are instantiated, then detailed info
  247. * are returned depending on the call.
  248. */
  249. typedef struct _snd_capabilities {
  250. u_long rate_min, rate_max; /* min-max sampling rate */
  251. u_long formats;
  252. u_long bufsize; /* DMA buffer size */
  253. u_long mixers; /* bitmap of available mixers */
  254. u_long inputs; /* bitmap of available inputs (per mixer) */
  255. u_short left, right; /* how many levels are supported */
  256. } snd_capabilities;
  257. #define AIOGCAP _IOWR('A', 15, snd_capabilities) /* get capabilities */
  258. /*
  259. * here is the old (Voxware) ioctl interface
  260. */
  261. /*
  262. * IOCTL Commands for /dev/sequencer
  263. */
  264. #define SNDCTL_SEQ_RESET _IO ('Q', 0)
  265. #define SNDCTL_SEQ_SYNC _IO ('Q', 1)
  266. #define SNDCTL_SYNTH_INFO _IOWR('Q', 2, struct synth_info)
  267. #define SNDCTL_SEQ_CTRLRATE _IOWR('Q', 3, int) /* Set/get timer res.(hz) */
  268. #define SNDCTL_SEQ_GETOUTCOUNT _IOR ('Q', 4, int)
  269. #define SNDCTL_SEQ_GETINCOUNT _IOR ('Q', 5, int)
  270. #define SNDCTL_SEQ_PERCMODE _IOW ('Q', 6, int)
  271. #define SNDCTL_FM_LOAD_INSTR _IOW ('Q', 7, struct sbi_instrument) /* Valid for FM only */
  272. #define SNDCTL_SEQ_TESTMIDI _IOW ('Q', 8, int)
  273. #define SNDCTL_SEQ_RESETSAMPLES _IOW ('Q', 9, int)
  274. #define SNDCTL_SEQ_NRSYNTHS _IOR ('Q',10, int)
  275. #define SNDCTL_SEQ_NRMIDIS _IOR ('Q',11, int)
  276. #define SNDCTL_MIDI_INFO _IOWR('Q',12, struct midi_info)
  277. #define SNDCTL_SEQ_THRESHOLD _IOW ('Q',13, int)
  278. #define SNDCTL_SEQ_TRESHOLD SNDCTL_SEQ_THRESHOLD /* there was once a typo */
  279. #define SNDCTL_SYNTH_MEMAVL _IOWR('Q',14, int) /* in=dev#, out=memsize */
  280. #define SNDCTL_FM_4OP_ENABLE _IOW ('Q',15, int) /* in=dev# */
  281. #define SNDCTL_PMGR_ACCESS _IOWR('Q',16, struct patmgr_info)
  282. #define SNDCTL_SEQ_PANIC _IO ('Q',17)
  283. #define SNDCTL_SEQ_OUTOFBAND _IOW ('Q',18, struct seq_event_rec)
  284. #define SNDCTL_SEQ_GETTIME _IOR ('Q',19, int)
  285. struct seq_event_rec {
  286. u_char arr[8];
  287. };
  288. #define SNDCTL_TMR_TIMEBASE _IOWR('T', 1, int)
  289. #define SNDCTL_TMR_START _IO ('T', 2)
  290. #define SNDCTL_TMR_STOP _IO ('T', 3)
  291. #define SNDCTL_TMR_CONTINUE _IO ('T', 4)
  292. #define SNDCTL_TMR_TEMPO _IOWR('T', 5, int)
  293. #define SNDCTL_TMR_SOURCE _IOWR('T', 6, int)
  294. # define TMR_INTERNAL 0x00000001
  295. # define TMR_EXTERNAL 0x00000002
  296. # define TMR_MODE_MIDI 0x00000010
  297. # define TMR_MODE_FSK 0x00000020
  298. # define TMR_MODE_CLS 0x00000040
  299. # define TMR_MODE_SMPTE 0x00000080
  300. #define SNDCTL_TMR_METRONOME _IOW ('T', 7, int)
  301. #define SNDCTL_TMR_SELECT _IOW ('T', 8, int)
  302. /*
  303. * Endian aware patch key generation algorithm.
  304. */
  305. #if defined(_AIX) || defined(AIX)
  306. # define _PATCHKEY(id) (0xfd00|id)
  307. #else
  308. # define _PATCHKEY(id) ((id<<8)|0xfd)
  309. #endif
  310. /*
  311. * Sample loading mechanism for internal synthesizers (/dev/sequencer)
  312. * The following patch_info structure has been designed to support
  313. * Gravis UltraSound. It tries to be universal format for uploading
  314. * sample based patches but is probably too limited.
  315. */
  316. struct patch_info {
  317. /* u_short key; Use GUS_PATCH here */
  318. short key; /* Use GUS_PATCH here */
  319. #define GUS_PATCH _PATCHKEY(0x04)
  320. #define OBSOLETE_GUS_PATCH _PATCHKEY(0x02)
  321. short device_no; /* Synthesizer number */
  322. short instr_no; /* Midi pgm# */
  323. u_long mode;
  324. /*
  325. * The least significant byte has the same format than the GUS .PAT
  326. * files
  327. */
  328. #define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */
  329. #define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */
  330. #define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */
  331. #define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */
  332. #define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */
  333. #define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3)*/
  334. #define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */
  335. /* (use the env_rate/env_offs fields). */
  336. /* Linux specific bits */
  337. #define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */
  338. #define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */
  339. #define WAVE_SCALE 0x00040000 /* The scaling info is valid */
  340. /* Other bits must be zeroed */
  341. long len; /* Size of the wave data in bytes */
  342. long loop_start, loop_end; /* Byte offsets from the beginning */
  343. /*
  344. * The base_freq and base_note fields are used when computing the
  345. * playback speed for a note. The base_note defines the tone frequency
  346. * which is heard if the sample is played using the base_freq as the
  347. * playback speed.
  348. *
  349. * The low_note and high_note fields define the minimum and maximum note
  350. * frequencies for which this sample is valid. It is possible to define
  351. * more than one samples for an instrument number at the same time. The
  352. * low_note and high_note fields are used to select the most suitable one.
  353. *
  354. * The fields base_note, high_note and low_note should contain
  355. * the note frequency multiplied by 1000. For example value for the
  356. * middle A is 440*1000.
  357. */
  358. u_int base_freq;
  359. u_long base_note;
  360. u_long high_note;
  361. u_long low_note;
  362. int panning; /* -128=left, 127=right */
  363. int detuning;
  364. /* New fields introduced in version 1.99.5 */
  365. /* Envelope. Enabled by mode bit WAVE_ENVELOPES */
  366. u_char env_rate[ 6 ]; /* GUS HW ramping rate */
  367. u_char env_offset[ 6 ]; /* 255 == 100% */
  368. /*
  369. * The tremolo, vibrato and scale info are not supported yet.
  370. * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or
  371. * WAVE_SCALE
  372. */
  373. u_char tremolo_sweep;
  374. u_char tremolo_rate;
  375. u_char tremolo_depth;
  376. u_char vibrato_sweep;
  377. u_char vibrato_rate;
  378. u_char vibrato_depth;
  379. int scale_frequency;
  380. u_int scale_factor; /* from 0 to 2048 or 0 to 2 */
  381. int volume;
  382. int spare[4];
  383. char data[1]; /* The waveform data starts here */
  384. };
  385. struct sysex_info {
  386. short key; /* Use GUS_PATCH here */
  387. #define SYSEX_PATCH _PATCHKEY(0x05)
  388. #define MAUI_PATCH _PATCHKEY(0x06)
  389. short device_no; /* Synthesizer number */
  390. long len; /* Size of the sysex data in bytes */
  391. u_char data[1]; /* Sysex data starts here */
  392. };
  393. /*
  394. * Patch management interface (/dev/sequencer, /dev/patmgr#)
  395. * Don't use these calls if you want to maintain compatibility with
  396. * the future versions of the driver.
  397. */
  398. #define PS_NO_PATCHES 0 /* No patch support on device */
  399. #define PS_MGR_NOT_OK 1 /* Plain patch support (no mgr) */
  400. #define PS_MGR_OK 2 /* Patch manager supported */
  401. #define PS_MANAGED 3 /* Patch manager running */
  402. #define SNDCTL_PMGR_IFACE _IOWR('P', 1, struct patmgr_info)
  403. /*
  404. * The patmgr_info is a fixed size structure which is used for two
  405. * different purposes. The intended use is for communication between
  406. * the application using /dev/sequencer and the patch manager daemon
  407. * associated with a synthesizer device (ioctl(SNDCTL_PMGR_ACCESS)).
  408. *
  409. * This structure is also used with ioctl(SNDCTL_PGMR_IFACE) which allows
  410. * a patch manager daemon to read and write device parameters. This
  411. * ioctl available through /dev/sequencer also. Avoid using it since it's
  412. * extremely hardware dependent. In addition access trough /dev/sequencer
  413. * may confuse the patch manager daemon.
  414. */
  415. struct patmgr_info { /* Note! size must be < 4k since kmalloc() is used */
  416. u_long key; /* Don't worry. Reserved for communication
  417. between the patch manager and the driver. */
  418. #define PM_K_EVENT 1 /* Event from the /dev/sequencer driver */
  419. #define PM_K_COMMAND 2 /* Request from an application */
  420. #define PM_K_RESPONSE 3 /* From patmgr to application */
  421. #define PM_ERROR 4 /* Error returned by the patmgr */
  422. int device;
  423. int command;
  424. /*
  425. * Commands 0x000 to 0xfff reserved for patch manager programs
  426. */
  427. #define PM_GET_DEVTYPE 1 /* Returns type of the patch mgr interface of dev */
  428. #define PMTYPE_FM2 1 /* 2 OP fm */
  429. #define PMTYPE_FM4 2 /* Mixed 4 or 2 op FM (OPL-3) */
  430. #define PMTYPE_WAVE 3 /* Wave table synthesizer (GUS) */
  431. #define PM_GET_NRPGM 2 /* Returns max # of midi programs in parm1 */
  432. #define PM_GET_PGMMAP 3 /* Returns map of loaded midi programs in data8 */
  433. #define PM_GET_PGM_PATCHES 4 /* Return list of patches of a program (parm1) */
  434. #define PM_GET_PATCH 5 /* Return patch header of patch parm1 */
  435. #define PM_SET_PATCH 6 /* Set patch header of patch parm1 */
  436. #define PM_READ_PATCH 7 /* Read patch (wave) data */
  437. #define PM_WRITE_PATCH 8 /* Write patch (wave) data */
  438. /*
  439. * Commands 0x1000 to 0xffff are for communication between the patch manager
  440. * and the client
  441. */
  442. #define _PM_LOAD_PATCH 0x100
  443. /*
  444. * Commands above 0xffff reserved for device specific use
  445. */
  446. long parm1;
  447. long parm2;
  448. long parm3;
  449. union {
  450. u_char data8[4000];
  451. u_short data16[2000];
  452. u_long data32[1000];
  453. struct patch_info patch;
  454. } data;
  455. };
  456. /*
  457. * When a patch manager daemon is present, it will be informed by the
  458. * driver when something important happens. For example when the
  459. * /dev/sequencer is opened or closed. A record with key == PM_K_EVENT is
  460. * returned. The command field contains the event type:
  461. */
  462. #define PM_E_OPENED 1 /* /dev/sequencer opened */
  463. #define PM_E_CLOSED 2 /* /dev/sequencer closed */
  464. #define PM_E_PATCH_RESET 3 /* SNDCTL_RESETSAMPLES called */
  465. #define PM_E_PATCH_LOADED 4 /* A patch has been loaded by appl */
  466. /*
  467. * /dev/sequencer input events.
  468. *
  469. * The data written to the /dev/sequencer is a stream of events. Events
  470. * are records of 4 or 8 bytes. The first byte defines the size.
  471. * Any number of events can be written with a write call. There
  472. * is a set of macros for sending these events. Use these macros if you
  473. * want to maximize portability of your program.
  474. *
  475. * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events.
  476. * (All input events are currently 4 bytes long. Be prepared to support
  477. * 8 byte events also. If you receive any event having first byte >= 128,
  478. * it's a 8 byte event.
  479. *
  480. * The events are documented at the end of this file.
  481. *
  482. * Normal events (4 bytes)
  483. * There is also a 8 byte version of most of the 4 byte events. The
  484. * 8 byte one is recommended.
  485. */
  486. #define SEQ_NOTEOFF 0
  487. #define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */
  488. #define SEQ_NOTEON 1
  489. #define SEQ_FMNOTEON SEQ_NOTEON
  490. #define SEQ_WAIT TMR_WAIT_ABS
  491. #define SEQ_PGMCHANGE 3
  492. #define SEQ_FMPGMCHANGE SEQ_PGMCHANGE
  493. #define SEQ_SYNCTIMER TMR_START
  494. #define SEQ_MIDIPUTC 5
  495. #define SEQ_DRUMON 6 /*** OBSOLETE ***/
  496. #define SEQ_DRUMOFF 7 /*** OBSOLETE ***/
  497. #define SEQ_ECHO TMR_ECHO /* For synching programs with output */
  498. #define SEQ_AFTERTOUCH 9
  499. #define SEQ_CONTROLLER 10
  500. /*
  501. * Midi controller numbers
  502. *
  503. * Controllers 0 to 31 (0x00 to 0x1f) and 32 to 63 (0x20 to 0x3f)
  504. * are continuous controllers.
  505. * In the MIDI 1.0 these controllers are sent using two messages.
  506. * Controller numbers 0 to 31 are used to send the MSB and the
  507. * controller numbers 32 to 63 are for the LSB. Note that just 7 bits
  508. * are used in MIDI bytes.
  509. */
  510. #define CTL_BANK_SELECT 0x00
  511. #define CTL_MODWHEEL 0x01
  512. #define CTL_BREATH 0x02
  513. /* undefined 0x03 */
  514. #define CTL_FOOT 0x04
  515. #define CTL_PORTAMENTO_TIME 0x05
  516. #define CTL_DATA_ENTRY 0x06
  517. #define CTL_MAIN_VOLUME 0x07
  518. #define CTL_BALANCE 0x08
  519. /* undefined 0x09 */
  520. #define CTL_PAN 0x0a
  521. #define CTL_EXPRESSION 0x0b
  522. /* undefined 0x0c - 0x0f */
  523. #define CTL_GENERAL_PURPOSE1 0x10
  524. #define CTL_GENERAL_PURPOSE2 0x11
  525. #define CTL_GENERAL_PURPOSE3 0x12
  526. #define CTL_GENERAL_PURPOSE4 0x13
  527. /* undefined 0x14 - 0x1f */
  528. /* undefined 0x20 */
  529. /*
  530. * The controller numbers 0x21 to 0x3f are reserved for the
  531. * least significant bytes of the controllers 0x00 to 0x1f.
  532. * These controllers are not recognised by the driver.
  533. *
  534. * Controllers 64 to 69 (0x40 to 0x45) are on/off switches.
  535. * 0=OFF and 127=ON (intermediate values are possible)
  536. */
  537. #define CTL_DAMPER_PEDAL 0x40
  538. #define CTL_SUSTAIN CTL_DAMPER_PEDAL /* Alias */
  539. #define CTL_HOLD CTL_DAMPER_PEDAL /* Alias */
  540. #define CTL_PORTAMENTO 0x41
  541. #define CTL_SOSTENUTO 0x42
  542. #define CTL_SOFT_PEDAL 0x43
  543. /* undefined 0x44 */
  544. #define CTL_HOLD2 0x45
  545. /* undefined 0x46 - 0x4f */
  546. #define CTL_GENERAL_PURPOSE5 0x50
  547. #define CTL_GENERAL_PURPOSE6 0x51
  548. #define CTL_GENERAL_PURPOSE7 0x52
  549. #define CTL_GENERAL_PURPOSE8 0x53
  550. /* undefined 0x54 - 0x5a */
  551. #define CTL_EXT_EFF_DEPTH 0x5b
  552. #define CTL_TREMOLO_DEPTH 0x5c
  553. #define CTL_CHORUS_DEPTH 0x5d
  554. #define CTL_DETUNE_DEPTH 0x5e
  555. #define CTL_CELESTE_DEPTH CTL_DETUNE_DEPTH /* Alias for the above one */
  556. #define CTL_PHASER_DEPTH 0x5f
  557. #define CTL_DATA_INCREMENT 0x60
  558. #define CTL_DATA_DECREMENT 0x61
  559. #define CTL_NONREG_PARM_NUM_LSB 0x62
  560. #define CTL_NONREG_PARM_NUM_MSB 0x63
  561. #define CTL_REGIST_PARM_NUM_LSB 0x64
  562. #define CTL_REGIST_PARM_NUM_MSB 0x65
  563. /* undefined 0x66 - 0x78 */
  564. /* reserved 0x79 - 0x7f */
  565. /* Pseudo controllers (not midi compatible) */
  566. #define CTRL_PITCH_BENDER 255
  567. #define CTRL_PITCH_BENDER_RANGE 254
  568. #define CTRL_EXPRESSION 253 /* Obsolete */
  569. #define CTRL_MAIN_VOLUME 252 /* Obsolete */
  570. #define SEQ_BALANCE 11
  571. #define SEQ_VOLMODE 12
  572. /*
  573. * Volume mode decides how volumes are used
  574. */
  575. #define VOL_METHOD_ADAGIO 1
  576. #define VOL_METHOD_LINEAR 2
  577. /*
  578. * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as
  579. * input events.
  580. */
  581. /*
  582. * Event codes 0xf0 to 0xfc are reserved for future extensions.
  583. */
  584. #define SEQ_FULLSIZE 0xfd /* Long events */
  585. /*
  586. * SEQ_FULLSIZE events are used for loading patches/samples to the
  587. * synthesizer devices. These events are passed directly to the driver
  588. * of the associated synthesizer device. There is no limit to the size
  589. * of the extended events. These events are not queued but executed
  590. * immediately when the write() is called (execution can take several
  591. * seconds of time).
  592. *
  593. * When a SEQ_FULLSIZE message is written to the device, it must
  594. * be written using exactly one write() call. Other events cannot
  595. * be mixed to the same write.
  596. *
  597. * For FM synths (YM3812/OPL3) use struct sbi_instrument and write
  598. * it to the /dev/sequencer. Don't write other data together with
  599. * the instrument structure Set the key field of the structure to
  600. * FM_PATCH. The device field is used to route the patch to the
  601. * corresponding device.
  602. *
  603. * For Gravis UltraSound use struct patch_info. Initialize the key field
  604. * to GUS_PATCH.
  605. */
  606. #define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */
  607. #define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */
  608. /*
  609. * Record for FM patches
  610. */
  611. typedef u_char sbi_instr_data[32];
  612. struct sbi_instrument {
  613. u_short key; /* FM_PATCH or OPL3_PATCH */
  614. #define FM_PATCH _PATCHKEY(0x01)
  615. #define OPL3_PATCH _PATCHKEY(0x03)
  616. short device; /* Synth# (0-4) */
  617. int channel; /* Program# to be initialized */
  618. sbi_instr_data operators; /* Reg. settings for operator cells
  619. * (.SBI format) */
  620. };
  621. struct synth_info { /* Read only */
  622. char name[30];
  623. int device; /* 0-N. INITIALIZE BEFORE CALLING */
  624. int synth_type;
  625. #define SYNTH_TYPE_FM 0
  626. #define SYNTH_TYPE_SAMPLE 1
  627. #define SYNTH_TYPE_MIDI 2 /* Midi interface */
  628. int synth_subtype;
  629. #define FM_TYPE_ADLIB 0x00
  630. #define FM_TYPE_OPL3 0x01
  631. #define MIDI_TYPE_MPU401 0x401
  632. #define SAMPLE_TYPE_BASIC 0x10
  633. #define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC
  634. #define SAMPLE_TYPE_AWE32 0x20
  635. int perc_mode; /* No longer supported */
  636. int nr_voices;
  637. int nr_drums; /* Obsolete field */
  638. int instr_bank_size;
  639. u_long capabilities;
  640. #define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */
  641. #define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */
  642. #define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */
  643. int dummies[19]; /* Reserve space */
  644. };
  645. struct sound_timer_info {
  646. char name[32];
  647. int caps;
  648. };
  649. struct midi_info {
  650. char name[30];
  651. int device; /* 0-N. INITIALIZE BEFORE CALLING */
  652. u_long capabilities; /* To be defined later */
  653. int dev_type;
  654. int dummies[18]; /* Reserve space */
  655. };
  656. /*
  657. * ioctl commands for the /dev/midi##
  658. */
  659. typedef struct {
  660. u_char cmd;
  661. char nr_args, nr_returns;
  662. u_char data[30];
  663. } mpu_command_rec;
  664. #define SNDCTL_MIDI_PRETIME _IOWR('m', 0, int)
  665. #define SNDCTL_MIDI_MPUMODE _IOWR('m', 1, int)
  666. #define SNDCTL_MIDI_MPUCMD _IOWR('m', 2, mpu_command_rec)
  667. #define MIOSPASSTHRU _IOWR('m', 3, int)
  668. #define MIOGPASSTHRU _IOWR('m', 4, int)
  669. /*
  670. * IOCTL commands for /dev/dsp and /dev/audio
  671. */
  672. #define SNDCTL_DSP_RESET _IO ('P', 0)
  673. #define SNDCTL_DSP_SYNC _IO ('P', 1)
  674. #define SNDCTL_DSP_SPEED _IOWR('P', 2, int)
  675. #define SNDCTL_DSP_STEREO _IOWR('P', 3, int)
  676. #define SNDCTL_DSP_GETBLKSIZE _IOR('P', 4, int)
  677. #define SNDCTL_DSP_SETBLKSIZE _IOW('P', 4, int)
  678. #define SNDCTL_DSP_SETFMT _IOWR('P',5, int) /* Selects ONE fmt*/
  679. /*
  680. * SOUND_PCM_WRITE_CHANNELS is not that different
  681. * from SNDCTL_DSP_STEREO
  682. */
  683. #define SOUND_PCM_WRITE_CHANNELS _IOWR('P', 6, int)
  684. #define SNDCTL_DSP_CHANNELS SOUND_PCM_WRITE_CHANNELS
  685. #define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int)
  686. #define SNDCTL_DSP_POST _IO ('P', 8)
  687. /*
  688. * SNDCTL_DSP_SETBLKSIZE and the following two calls mostly do
  689. * the same thing, i.e. set the block size used in DMA transfers.
  690. */
  691. #define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int)
  692. #define SNDCTL_DSP_SETFRAGMENT _IOWR('P',10, int)
  693. #define SNDCTL_DSP_GETFMTS _IOR ('P',11, int) /* Returns a mask */
  694. /*
  695. * Buffer status queries.
  696. */
  697. typedef struct audio_buf_info {
  698. int fragments; /* # of avail. frags (partly used ones not counted) */
  699. int fragstotal; /* Total # of fragments allocated */
  700. int fragsize; /* Size of a fragment in bytes */
  701. int bytes; /* Avail. space in bytes (includes partly used fragments) */
  702. /* Note! 'bytes' could be more than fragments*fragsize */
  703. } audio_buf_info;
  704. #define SNDCTL_DSP_GETOSPACE _IOR ('P',12, audio_buf_info)
  705. #define SNDCTL_DSP_GETISPACE _IOR ('P',13, audio_buf_info)
  706. /*
  707. * SNDCTL_DSP_NONBLOCK is the same (but less powerful, since the
  708. * action cannot be undone) of FIONBIO. The same can be achieved
  709. * by opening the device with O_NDELAY
  710. */
  711. #define SNDCTL_DSP_NONBLOCK _IO ('P',14)
  712. #define SNDCTL_DSP_GETCAPS _IOR ('P',15, int)
  713. #define DSP_CAP_REVISION 0x000000ff /* revision level (0 to 255) */
  714. #define DSP_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */
  715. #define DSP_CAP_REALTIME 0x00000200 /* Real time capability */
  716. #define DSP_CAP_BATCH 0x00000400
  717. /*
  718. * Device has some kind of internal buffers which may
  719. * cause some delays and decrease precision of timing
  720. */
  721. #define DSP_CAP_COPROC 0x00000800
  722. /* Has a coprocessor, sometimes it's a DSP but usually not */
  723. #define DSP_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */
  724. #define DSP_CAP_MMAP 0x00002000 /* Supports mmap() */
  725. /*
  726. * What do these function do ?
  727. */
  728. #define SNDCTL_DSP_GETTRIGGER _IOR ('P',16, int)
  729. #define SNDCTL_DSP_SETTRIGGER _IOW ('P',16, int)
  730. #define PCM_ENABLE_INPUT 0x00000001
  731. #define PCM_ENABLE_OUTPUT 0x00000002
  732. typedef struct count_info {
  733. int bytes; /* Total # of bytes processed */
  734. int blocks; /* # of fragment transitions since last time */
  735. int ptr; /* Current DMA pointer value */
  736. } count_info;
  737. /*
  738. * GETIPTR and GETISPACE are not that different... same for out.
  739. */
  740. #define SNDCTL_DSP_GETIPTR _IOR ('P',17, count_info)
  741. #define SNDCTL_DSP_GETOPTR _IOR ('P',18, count_info)
  742. typedef struct buffmem_desc {
  743. caddr_t buffer;
  744. int size;
  745. } buffmem_desc;
  746. #define SNDCTL_DSP_MAPINBUF _IOR ('P', 19, buffmem_desc)
  747. #define SNDCTL_DSP_MAPOUTBUF _IOR ('P', 20, buffmem_desc)
  748. #define SNDCTL_DSP_SETSYNCRO _IO ('P', 21)
  749. #define SNDCTL_DSP_SETDUPLEX _IO ('P', 22)
  750. #define SNDCTL_DSP_GETODELAY _IOR ('P', 23, int)
  751. /*
  752. * I guess these are the readonly version of the same
  753. * functions that exist above as SNDCTL_DSP_...
  754. */
  755. #define SOUND_PCM_READ_RATE _IOR ('P', 2, int)
  756. #define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int)
  757. #define SOUND_PCM_READ_BITS _IOR ('P', 5, int)
  758. #define SOUND_PCM_READ_FILTER _IOR ('P', 7, int)
  759. /*
  760. * ioctl calls to be used in communication with coprocessors and
  761. * DSP chips.
  762. */
  763. typedef struct copr_buffer {
  764. int command; /* Set to 0 if not used */
  765. int flags;
  766. #define CPF_NONE 0x0000
  767. #define CPF_FIRST 0x0001 /* First block */
  768. #define CPF_LAST 0x0002 /* Last block */
  769. int len;
  770. int offs; /* If required by the device (0 if not used) */
  771. u_char data[4000]; /* NOTE! 4000 is not 4k */
  772. } copr_buffer;
  773. typedef struct copr_debug_buf {
  774. int command; /* Used internally. Set to 0 */
  775. int parm1;
  776. int parm2;
  777. int flags;
  778. int len; /* Length of data in bytes */
  779. } copr_debug_buf;
  780. typedef struct copr_msg {
  781. int len;
  782. u_char data[4000];
  783. } copr_msg;
  784. #define SNDCTL_COPR_RESET _IO ('C', 0)
  785. #define SNDCTL_COPR_LOAD _IOWR('C', 1, copr_buffer)
  786. #define SNDCTL_COPR_RDATA _IOWR('C', 2, copr_debug_buf)
  787. #define SNDCTL_COPR_RCODE _IOWR('C', 3, copr_debug_buf)
  788. #define SNDCTL_COPR_WDATA _IOW ('C', 4, copr_debug_buf)
  789. #define SNDCTL_COPR_WCODE _IOW ('C', 5, copr_debug_buf)
  790. #define SNDCTL_COPR_RUN _IOWR('C', 6, copr_debug_buf)
  791. #define SNDCTL_COPR_HALT _IOWR('C', 7, copr_debug_buf)
  792. #define SNDCTL_COPR_SENDMSG _IOW ('C', 8, copr_msg)
  793. #define SNDCTL_COPR_RCVMSG _IOR ('C', 9, copr_msg)
  794. /*
  795. * IOCTL commands for /dev/mixer
  796. */
  797. /*
  798. * Mixer devices
  799. *
  800. * There can be up to 20 different analog mixer channels. The
  801. * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
  802. * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
  803. * the devices supported by the particular mixer.
  804. */
  805. #define SOUND_MIXER_NRDEVICES 25
  806. #define SOUND_MIXER_VOLUME 0 /* Master output level */
  807. #define SOUND_MIXER_BASS 1 /* Treble level of all output channels */
  808. #define SOUND_MIXER_TREBLE 2 /* Bass level of all output channels */
  809. #define SOUND_MIXER_SYNTH 3 /* Volume of synthesier input */
  810. #define SOUND_MIXER_PCM 4 /* Output level for the audio device */
  811. #define SOUND_MIXER_SPEAKER 5 /* Output level for the PC speaker
  812. * signals */
  813. #define SOUND_MIXER_LINE 6 /* Volume level for the line in jack */
  814. #define SOUND_MIXER_MIC 7 /* Volume for the signal coming from
  815. * the microphone jack */
  816. #define SOUND_MIXER_CD 8 /* Volume level for the input signal
  817. * connected to the CD audio input */
  818. #define SOUND_MIXER_IMIX 9 /* Recording monitor. It controls the
  819. * output volume of the selected
  820. * recording sources while recording */
  821. #define SOUND_MIXER_ALTPCM 10 /* Volume of the alternative codec
  822. * device */
  823. #define SOUND_MIXER_RECLEV 11 /* Global recording level */
  824. #define SOUND_MIXER_IGAIN 12 /* Input gain */
  825. #define SOUND_MIXER_OGAIN 13 /* Output gain */
  826. /*
  827. * The AD1848 codec and compatibles have three line level inputs
  828. * (line, aux1 and aux2). Since each card manufacturer have assigned
  829. * different meanings to these inputs, it's inpractical to assign
  830. * specific meanings (line, cd, synth etc.) to them.
  831. */
  832. #define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */
  833. #define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */
  834. #define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */
  835. #define SOUND_MIXER_DIGITAL1 17 /* Digital (input) 1 */
  836. #define SOUND_MIXER_DIGITAL2 18 /* Digital (input) 2 */
  837. #define SOUND_MIXER_DIGITAL3 19 /* Digital (input) 3 */
  838. #define SOUND_MIXER_PHONEIN 20 /* Phone input */
  839. #define SOUND_MIXER_PHONEOUT 21 /* Phone output */
  840. #define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */
  841. #define SOUND_MIXER_RADIO 23 /* Radio in */
  842. #define SOUND_MIXER_MONITOR 24 /* Monitor (usually mic) volume */
  843. /*
  844. * Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX)
  845. * Not counted to SOUND_MIXER_NRDEVICES, but use the same number space
  846. */
  847. #define SOUND_ONOFF_MIN 28
  848. #define SOUND_ONOFF_MAX 30
  849. #define SOUND_MIXER_MUTE 28 /* 0 or 1 */
  850. #define SOUND_MIXER_ENHANCE 29 /* Enhanced stereo (0, 40, 60 or 80) */
  851. #define SOUND_MIXER_LOUD 30 /* 0 or 1 */
  852. /* Note! Number 31 cannot be used since the sign bit is reserved */
  853. #define SOUND_MIXER_NONE 31
  854. #define SOUND_DEVICE_LABELS { \
  855. "Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \
  856. "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \
  857. "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
  858. "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
  859. #define SOUND_DEVICE_NAMES { \
  860. "vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
  861. "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
  862. "line1", "line2", "line3", "dig1", "dig2", "dig3", \
  863. "phin", "phout", "video", "radio", "monitor"}
  864. /* Device bitmask identifiers */
  865. #define SOUND_MIXER_RECSRC 0xff /* 1 bit per recording source */
  866. #define SOUND_MIXER_DEVMASK 0xfe /* 1 bit per supported device */
  867. #define SOUND_MIXER_RECMASK 0xfd /* 1 bit per supp. recording source */
  868. #define SOUND_MIXER_CAPS 0xfc
  869. #define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only 1 rec. src at a time */
  870. #define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */
  871. /* Device mask bits */
  872. #define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME)
  873. #define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS)
  874. #define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE)
  875. #define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH)
  876. #define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM)
  877. #define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER)
  878. #define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE)
  879. #define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC)
  880. #define SOUND_MASK_CD (1 << SOUND_MIXER_CD)
  881. #define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX)
  882. #define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM)
  883. #define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV)
  884. #define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN)
  885. #define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN)
  886. #define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1)
  887. #define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2)
  888. #define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3)
  889. #define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1)
  890. #define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2)
  891. #define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3)
  892. #define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN)
  893. #define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT)
  894. #define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO)
  895. #define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO)
  896. #define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR)
  897. /* Obsolete macros */
  898. #define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE)
  899. #define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE)
  900. #define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD)
  901. #define MIXER_READ(dev) _IOR('M', dev, int)
  902. #define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME)
  903. #define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS)
  904. #define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE)
  905. #define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH)
  906. #define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM)
  907. #define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER)
  908. #define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE)
  909. #define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC)
  910. #define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD)
  911. #define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX)
  912. #define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM)
  913. #define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV)
  914. #define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN)
  915. #define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN)
  916. #define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1)
  917. #define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2)
  918. #define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3)
  919. #define SOUND_MIXER_READ_DIGITAL1 MIXER_READ(SOUND_MIXER_DIGITAL1)
  920. #define SOUND_MIXER_READ_DIGITAL2 MIXER_READ(SOUND_MIXER_DIGITAL2)
  921. #define SOUND_MIXER_READ_DIGITAL3 MIXER_READ(SOUND_MIXER_DIGITAL3)
  922. #define SOUND_MIXER_READ_PHONEIN MIXER_READ(SOUND_MIXER_PHONEIN)
  923. #define SOUND_MIXER_READ_PHONEOUT MIXER_READ(SOUND_MIXER_PHONEOUT)
  924. #define SOUND_MIXER_READ_RADIO MIXER_READ(SOUND_MIXER_RADIO)
  925. #define SOUND_MIXER_READ_VIDEO MIXER_READ(SOUND_MIXER_VIDEO)
  926. #define SOUND_MIXER_READ_MONITOR MIXER_READ(SOUND_MIXER_MONITOR)
  927. /* Obsolete macros */
  928. #define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE)
  929. #define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE)
  930. #define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD)
  931. #define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC)
  932. #define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK)
  933. #define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK)
  934. #define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS)
  935. #define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS)
  936. #define MIXER_WRITE(dev) _IOWR('M', dev, int)
  937. #define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME)
  938. #define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS)
  939. #define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE)
  940. #define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH)
  941. #define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM)
  942. #define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER)
  943. #define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE)
  944. #define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC)
  945. #define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD)
  946. #define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX)
  947. #define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM)
  948. #define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV)
  949. #define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN)
  950. #define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN)
  951. #define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1)
  952. #define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2)
  953. #define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3)
  954. #define SOUND_MIXER_WRITE_DIGITAL1 MIXER_WRITE(SOUND_MIXER_DIGITAL1)
  955. #define SOUND_MIXER_WRITE_DIGITAL2 MIXER_WRITE(SOUND_MIXER_DIGITAL2)
  956. #define SOUND_MIXER_WRITE_DIGITAL3 MIXER_WRITE(SOUND_MIXER_DIGITAL3)
  957. #define SOUND_MIXER_WRITE_PHONEIN MIXER_WRITE(SOUND_MIXER_PHONEIN)
  958. #define SOUND_MIXER_WRITE_PHONEOUT MIXER_WRITE(SOUND_MIXER_PHONEOUT)
  959. #define SOUND_MIXER_WRITE_RADIO MIXER_WRITE(SOUND_MIXER_RADIO)
  960. #define SOUND_MIXER_WRITE_VIDEO MIXER_WRITE(SOUND_MIXER_VIDEO)
  961. #define SOUND_MIXER_WRITE_MONITOR MIXER_WRITE(SOUND_MIXER_MONITOR)
  962. #define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE)
  963. #define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE)
  964. #define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD)
  965. #define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC)
  966. typedef struct mixer_info {
  967. char id[16];
  968. char name[32];
  969. int modify_counter;
  970. int fillers[10];
  971. } mixer_info;
  972. #define SOUND_MIXER_INFO _IOR('M', 101, mixer_info)
  973. #define LEFT_CHN 0
  974. #define RIGHT_CHN 1
  975. /*
  976. * Level 2 event types for /dev/sequencer
  977. */
  978. /*
  979. * The 4 most significant bits of byte 0 specify the class of
  980. * the event:
  981. *
  982. * 0x8X = system level events,
  983. * 0x9X = device/port specific events, event[1] = device/port,
  984. * The last 4 bits give the subtype:
  985. * 0x02 = Channel event (event[3] = chn).
  986. * 0x01 = note event (event[4] = note).
  987. * (0x01 is not used alone but always with bit 0x02).
  988. * event[2] = MIDI message code (0x80=note off etc.)
  989. *
  990. */
  991. #define EV_SEQ_LOCAL 0x80
  992. #define EV_TIMING 0x81
  993. #define EV_CHN_COMMON 0x92
  994. #define EV_CHN_VOICE 0x93
  995. #define EV_SYSEX 0x94
  996. /*
  997. * Event types 200 to 220 are reserved for application use.
  998. * These numbers will not be used by the driver.
  999. */
  1000. /*
  1001. * Events for event type EV_CHN_VOICE
  1002. */
  1003. #define MIDI_NOTEOFF 0x80
  1004. #define MIDI_NOTEON 0x90
  1005. #define MIDI_KEY_PRESSURE 0xA0
  1006. /*
  1007. * Events for event type EV_CHN_COMMON
  1008. */
  1009. #define MIDI_CTL_CHANGE 0xB0
  1010. #define MIDI_PGM_CHANGE 0xC0
  1011. #define MIDI_CHN_PRESSURE 0xD0
  1012. #define MIDI_PITCH_BEND 0xE0
  1013. #define MIDI_SYSTEM_PREFIX 0xF0
  1014. /*
  1015. * Timer event types
  1016. */
  1017. #define TMR_WAIT_REL 1 /* Time relative to the prev time */
  1018. #define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */
  1019. #define TMR_STOP 3
  1020. #define TMR_START 4
  1021. #define TMR_CONTINUE 5
  1022. #define TMR_TEMPO 6
  1023. #define TMR_ECHO 8
  1024. #define TMR_CLOCK 9 /* MIDI clock */
  1025. #define TMR_SPP 10 /* Song position pointer */
  1026. #define TMR_TIMESIG 11 /* Time signature */
  1027. /*
  1028. * Local event types
  1029. */
  1030. #define LOCL_STARTAUDIO 1
  1031. #if (!defined(_KERNEL) && !defined(INKERNEL)) || defined(USE_SEQ_MACROS)
  1032. /*
  1033. * Some convenience macros to simplify programming of the
  1034. * /dev/sequencer interface
  1035. *
  1036. * These macros define the API which should be used when possible.
  1037. */
  1038. #ifndef USE_SIMPLE_MACROS
  1039. void seqbuf_dump(void); /* This function must be provided by programs */
  1040. /* Sample seqbuf_dump() implementation:
  1041. *
  1042. * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes
  1043. *
  1044. * int seqfd; -- The file descriptor for /dev/sequencer.
  1045. *
  1046. * void
  1047. * seqbuf_dump ()
  1048. * {
  1049. * if (_seqbufptr)
  1050. * if (write (seqfd, _seqbuf, _seqbufptr) == -1)
  1051. * {
  1052. * perror ("write /dev/sequencer");
  1053. * exit (-1);
  1054. * }
  1055. * _seqbufptr = 0;
  1056. * }
  1057. */
  1058. #define SEQ_DEFINEBUF(len) \
  1059. u_char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0
  1060. #define SEQ_USE_EXTBUF() \
  1061. extern u_char _seqbuf[]; \
  1062. extern int _seqbuflen;extern int _seqbufptr
  1063. #define SEQ_DECLAREBUF() SEQ_USE_EXTBUF()
  1064. #define SEQ_PM_DEFINES struct patmgr_info _pm_info
  1065. #define _SEQ_NEEDBUF(len) \
  1066. if ((_seqbufptr+(len)) > _seqbuflen) \
  1067. seqbuf_dump()
  1068. #define _SEQ_ADVBUF(len) _seqbufptr += len
  1069. #define SEQ_DUMPBUF seqbuf_dump
  1070. #else
  1071. /*
  1072. * This variation of the sequencer macros is used just to format one event
  1073. * using fixed buffer.
  1074. *
  1075. * The program using the macro library must define the following macros before
  1076. * using this library.
  1077. *
  1078. * #define _seqbuf name of the buffer (u_char[])
  1079. * #define _SEQ_ADVBUF(len) If the applic needs to know the exact
  1080. * size of the event, this macro can be used.
  1081. * Otherwise this must be defined as empty.
  1082. * #define _seqbufptr Define the name of index variable or 0 if
  1083. * not required.
  1084. */
  1085. #define _SEQ_NEEDBUF(len) /* empty */
  1086. #endif
  1087. #define PM_LOAD_PATCH(dev, bank, pgm) \
  1088. (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \
  1089. _pm_info.device=dev, _pm_info.data.data8[0]=pgm, \
  1090. _pm_info.parm1 = bank, _pm_info.parm2 = 1, \
  1091. ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info))
  1092. #define PM_LOAD_PATCHES(dev, bank, pgm) \
  1093. (SEQ_DUMPBUF(), _pm_info.command = _PM_LOAD_PATCH, \
  1094. _pm_info.device=dev, bcopy( pgm, _pm_info.data.data8, 128), \
  1095. _pm_info.parm1 = bank, _pm_info.parm2 = 128, \
  1096. ioctl(seqfd, SNDCTL_PMGR_ACCESS, &_pm_info))
  1097. #define SEQ_VOLUME_MODE(dev, mode) { \
  1098. _SEQ_NEEDBUF(8);\
  1099. _seqbuf[_seqbufptr] = SEQ_EXTENDED;\
  1100. _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\
  1101. _seqbuf[_seqbufptr+2] = (dev);\
  1102. _seqbuf[_seqbufptr+3] = (mode);\
  1103. _seqbuf[_seqbufptr+4] = 0;\
  1104. _seqbuf[_seqbufptr+5] = 0;\
  1105. _seqbuf[_seqbufptr+6] = 0;\
  1106. _seqbuf[_seqbufptr+7] = 0;\
  1107. _SEQ_ADVBUF(8);}
  1108. /*
  1109. * Midi voice messages
  1110. */
  1111. #define _CHN_VOICE(dev, event, chn, note, parm) { \
  1112. _SEQ_NEEDBUF(8);\
  1113. _seqbuf[_seqbufptr] = EV_CHN_VOICE;\
  1114. _seqbuf[_seqbufptr+1] = (dev);\
  1115. _seqbuf[_seqbufptr+2] = (event);\
  1116. _seqbuf[_seqbufptr+3] = (chn);\
  1117. _seqbuf[_seqbufptr+4] = (note);\
  1118. _seqbuf[_seqbufptr+5] = (parm);\
  1119. _seqbuf[_seqbufptr+6] = (0);\
  1120. _seqbuf[_seqbufptr+7] = 0;\
  1121. _SEQ_ADVBUF(8);}
  1122. #define SEQ_START_NOTE(dev, chn, note, vol) \
  1123. _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol)
  1124. #define SEQ_STOP_NOTE(dev, chn, note, vol) \
  1125. _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol)
  1126. #define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \
  1127. _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure)
  1128. /*
  1129. * Midi channel messages
  1130. */
  1131. #define _CHN_COMMON(dev, event, chn, p1, p2, w14) { \
  1132. _SEQ_NEEDBUF(8);\
  1133. _seqbuf[_seqbufptr] = EV_CHN_COMMON;\
  1134. _seqbuf[_seqbufptr+1] = (dev);\
  1135. _seqbuf[_seqbufptr+2] = (event);\
  1136. _seqbuf[_seqbufptr+3] = (chn);\
  1137. _seqbuf[_seqbufptr+4] = (p1);\
  1138. _seqbuf[_seqbufptr+5] = (p2);\
  1139. *(short *)&_seqbuf[_seqbufptr+6] = (w14);\
  1140. _SEQ_ADVBUF(8);}
  1141. /*
  1142. * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits
  1143. * sending any MIDI bytes but it's absolutely not possible. Trying to do
  1144. * so _will_ cause problems with MPU401 intelligent mode).
  1145. *
  1146. * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
  1147. * sent by calling SEQ_SYSEX() several times (there must be no other events
  1148. * between them). First sysex fragment must have 0xf0 in the first byte
  1149. * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte
  1150. * between these sysex start and end markers cannot be larger than 0x7f. Also
  1151. * lengths of each fragments (except the last one) must be 6.
  1152. *
  1153. * Breaking the above rules may work with some MIDI ports but is likely to
  1154. * cause fatal problems with some other devices (such as MPU401).
  1155. */
  1156. #define SEQ_SYSEX(dev, buf, len) { \
  1157. int i, l=(len); if (l>6)l=6;\
  1158. _SEQ_NEEDBUF(8);\
  1159. _seqbuf[_seqbufptr] = EV_SYSEX;\
  1160. for(i=0;i<l;i++)_seqbuf[_seqbufptr+i+1] = (buf)[i];\
  1161. for(i=l;i<6;i++)_seqbuf[_seqbufptr+i+1] = 0xff;\
  1162. _SEQ_ADVBUF(8);}
  1163. #define SEQ_CHN_PRESSURE(dev, chn, pressure) \
  1164. _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0)
  1165. #define SEQ_SET_PATCH(dev, chn, patch) \
  1166. _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0)
  1167. #define SEQ_CONTROL(dev, chn, controller, value) \
  1168. _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value)
  1169. #define SEQ_BENDER(dev, chn, value) \
  1170. _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value)
  1171. #define SEQ_V2_X_CONTROL(dev, voice, controller, value) { \
  1172. _SEQ_NEEDBUF(8);\
  1173. _seqbuf[_seqbufptr] = SEQ_EXTENDED;\
  1174. _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\
  1175. _seqbuf[_seqbufptr+2] = (dev);\
  1176. _seqbuf[_seqbufptr+3] = (voice);\
  1177. _seqbuf[_seqbufptr+4] = (controller);\
  1178. *(short *)&_seqbuf[_seqbufptr+5] = (value);\
  1179. _seqbuf[_seqbufptr+7] = 0;\
  1180. _SEQ_ADVBUF(8);}
  1181. /*
  1182. * The following 5 macros are incorrectly implemented and obsolete.
  1183. * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead.
  1184. */
  1185. #define SEQ_PITCHBEND(dev, voice, value) \
  1186. SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value)
  1187. #define SEQ_BENDER_RANGE(dev, voice, value) \
  1188. SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value)
  1189. #define SEQ_EXPRESSION(dev, voice, value) \
  1190. SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128)
  1191. #define SEQ_MAIN_VOLUME(dev, voice, value) \
  1192. SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100)
  1193. #define SEQ_PANNING(dev, voice, pos) \
  1194. SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
  1195. /*
  1196. * Timing and syncronization macros
  1197. */
  1198. #define _TIMER_EVENT(ev, parm) { \
  1199. _SEQ_NEEDBUF(8);\
  1200. _seqbuf[_seqbufptr+0] = EV_TIMING; \
  1201. _seqbuf[_seqbufptr+1] = (ev); \
  1202. _seqbuf[_seqbufptr+2] = 0;\
  1203. _seqbuf[_seqbufptr+3] = 0;\
  1204. *(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \
  1205. _SEQ_ADVBUF(8); \
  1206. }
  1207. #define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0)
  1208. #define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0)
  1209. #define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0)
  1210. #define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks)
  1211. #define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks)
  1212. #define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key)
  1213. #define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value)
  1214. #define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos)
  1215. #define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig)
  1216. /*
  1217. * Local control events
  1218. */
  1219. #define _LOCAL_EVENT(ev, parm) { \
  1220. _SEQ_NEEDBUF(8);\
  1221. _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
  1222. _seqbuf[_seqbufptr+1] = (ev); \
  1223. _seqbuf[_seqbufptr+2] = 0;\
  1224. _seqbuf[_seqbufptr+3] = 0;\
  1225. *(u_int *)&_seqbuf[_seqbufptr+4] = (parm); \
  1226. _SEQ_ADVBUF(8); \
  1227. }
  1228. #define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask)
  1229. /*
  1230. * Events for the level 1 interface only
  1231. */
  1232. #define SEQ_MIDIOUT(device, byte) { \
  1233. _SEQ_NEEDBUF(4);\
  1234. _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\
  1235. _seqbuf[_seqbufptr+1] = (byte);\
  1236. _seqbuf[_seqbufptr+2] = (device);\
  1237. _seqbuf[_seqbufptr+3] = 0;\
  1238. _SEQ_ADVBUF(4);}
  1239. /*
  1240. * Patch loading.
  1241. */
  1242. #define SEQ_WRPATCH(patchx, len) { \
  1243. if (_seqbufptr) seqbuf_dump(); \
  1244. if (write(seqfd, (char*)(patchx), len)==-1) \
  1245. perror("Write patch: /dev/sequencer"); \
  1246. }
  1247. #define SEQ_WRPATCH2(patchx, len) \
  1248. ( seqbuf_dump(), write(seqfd, (char*)(patchx), len) )
  1249. #endif
  1250. /*
  1251. * Here I have moved all the aliases for ioctl names.
  1252. */
  1253. #define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT
  1254. #define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT
  1255. #define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT
  1256. #define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED
  1257. #define SOUND_PCM_POST SNDCTL_DSP_POST
  1258. #define SOUND_PCM_RESET SNDCTL_DSP_RESET
  1259. #define SOUND_PCM_SYNC SNDCTL_DSP_SYNC
  1260. #define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE
  1261. #define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT
  1262. #define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS
  1263. #define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE
  1264. #define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE
  1265. #define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK
  1266. #define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS
  1267. #define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER
  1268. #define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER
  1269. #define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO
  1270. #define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR
  1271. #define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR
  1272. #define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF
  1273. #define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF
  1274. /***********************************************************************/
  1275. /**
  1276. * XXX OSSv4 defines -- some bits taken straight out of the new
  1277. * sys/soundcard.h bundled with recent OSS releases.
  1278. *
  1279. * NB: These macros and structures will be reorganized and inserted
  1280. * in appropriate places throughout this file once the code begins
  1281. * to take shape.
  1282. *
  1283. * @todo reorganize layout more like the 4Front version
  1284. * @todo ask about maintaining __SIOWR vs. _IOWR ioctl cmd defines
  1285. */
  1286. /**
  1287. * @note The @c OSSV4_EXPERIMENT macro is meant to wrap new development code
  1288. * in the sound system relevant to adopting 4Front's OSSv4 specification.
  1289. * Users should not enable this! Really!
  1290. */
  1291. #if 0
  1292. # define OSSV4_EXPERIMENT 1
  1293. #else
  1294. # undef OSSV4_EXPERIMENT
  1295. #endif
  1296. #ifdef SOUND_VERSION
  1297. # undef SOUND_VERSION
  1298. # define SOUND_VERSION 0x040000
  1299. #endif /* !SOUND_VERSION */
  1300. #define OSS_LONGNAME_SIZE 64
  1301. #define OSS_LABEL_SIZE 16
  1302. #define OSS_DEVNODE_SIZE 32
  1303. typedef char oss_longname_t[OSS_LONGNAME_SIZE];
  1304. typedef char oss_label_t[OSS_LABEL_SIZE];
  1305. typedef char oss_devnode_t[OSS_DEVNODE_SIZE];
  1306. typedef struct audio_errinfo
  1307. {
  1308. int play_underruns;
  1309. int rec_overruns;
  1310. unsigned int play_ptradjust;
  1311. unsigned int rec_ptradjust;
  1312. int play_errorcount;
  1313. int rec_errorcount;
  1314. int play_lasterror;
  1315. int rec_lasterror;
  1316. long play_errorparm;
  1317. long rec_errorparm;
  1318. int filler[16];
  1319. } audio_errinfo;
  1320. #define SNDCTL_DSP_GETPLAYVOL _IOR ('P', 24, int)
  1321. #define SNDCTL_DSP_SETPLAYVOL _IOWR('P', 24, int)
  1322. #define SNDCTL_DSP_GETERROR _IOR ('P', 25, audio_errinfo)
  1323. /*
  1324. ****************************************************************************
  1325. * Sync groups for audio devices
  1326. */
  1327. typedef struct oss_syncgroup
  1328. {
  1329. int id;
  1330. int mode;
  1331. int filler[16];
  1332. } oss_syncgroup;
  1333. #define SNDCTL_DSP_SYNCGROUP _IOWR('P', 28, oss_syncgroup)
  1334. #define SNDCTL_DSP_SYNCSTART _IOW ('P', 29, int)
  1335. /*
  1336. **************************************************************************
  1337. * "cooked" mode enables software based conversions for sample rate, sample
  1338. * format (bits) and number of channels (mono/stereo). These conversions are
  1339. * required with some devices that support only one sample rate or just stereo
  1340. * to let the applications to use other formats. The cooked mode is enabled by
  1341. * default. However it's necessary to disable this mode when mmap() is used or
  1342. * when very deterministic timing is required. SNDCTL_DSP_COOKEDMODE is an
  1343. * optional call introduced in OSS 3.9.6f. It's _error return must be ignored_
  1344. * since normally this call will return erno=EINVAL.
  1345. *
  1346. * SNDCTL_DSP_COOKEDMODE must be called immediately after open before doing
  1347. * anything else. Otherwise the call will not have any effect.
  1348. */
  1349. #define SNDCTL_DSP_COOKEDMODE _IOW ('P', 30, int)
  1350. /*
  1351. **************************************************************************
  1352. * SNDCTL_DSP_SILENCE and SNDCTL_DSP_SKIP are new calls in OSS 3.99.0
  1353. * that can be used to implement pause/continue during playback (no effect
  1354. * on recording).
  1355. */
  1356. #define SNDCTL_DSP_SILENCE _IO ('P', 31)
  1357. #define SNDCTL_DSP_SKIP _IO ('P', 32)
  1358. /*
  1359. ****************************************************************************
  1360. * Abort transfer (reset) functions for input and output
  1361. */
  1362. #define SNDCTL_DSP_HALT_INPUT _IO ('P', 33)
  1363. #define SNDCTL_DSP_RESET_INPUT SNDCTL_DSP_HALT_INPUT /* Old name */
  1364. #define SNDCTL_DSP_HALT_OUTPUT _IO ('P', 34)
  1365. #define SNDCTL_DSP_RESET_OUTPUT SNDCTL_DSP_HALT_OUTPUT /* Old name */
  1366. /*
  1367. ****************************************************************************
  1368. * Low water level control
  1369. */
  1370. #define SNDCTL_DSP_LOW_WATER _IOW ('P', 34, int)
  1371. /** @todo Get rid of OSS_NO_LONG_LONG references? */
  1372. /*
  1373. ****************************************************************************
  1374. * 64 bit pointer support. Only available in environments that support
  1375. * the 64 bit (long long) integer type.
  1376. */
  1377. #ifndef OSS_NO_LONG_LONG
  1378. typedef struct
  1379. {
  1380. long long samples;
  1381. int fifo_samples;
  1382. int filler[32]; /* For future use */
  1383. } oss_count_t;
  1384. #define SNDCTL_DSP_CURRENT_IPTR _IOR ('P', 35, oss_count_t)
  1385. #define SNDCTL_DSP_CURRENT_OPTR _IOR ('P', 36, oss_count_t)
  1386. #endif
  1387. /*
  1388. ****************************************************************************
  1389. * Interface for selecting recording sources and playback output routings.
  1390. */
  1391. #define SNDCTL_DSP_GET_RECSRC_NAMES _IOR ('P', 37, oss_mixer_enuminfo)
  1392. #define SNDCTL_DSP_GET_RECSRC _IOR ('P', 38, int)
  1393. #define SNDCTL_DSP_SET_RECSRC _IOWR('P', 38, int)
  1394. #define SNDCTL_DSP_GET_PLAYTGT_NAMES _IOR ('P', 39, oss_mixer_enuminfo)
  1395. #define SNDCTL_DSP_GET_PLAYTGT _IOR ('P', 40, int)
  1396. #define SNDCTL_DSP_SET_PLAYTGT _IOWR('P', 40, int)
  1397. #define SNDCTL_DSP_GETRECVOL _IOR ('P', 41, int)
  1398. #define SNDCTL_DSP_SETRECVOL _IOWR('P', 41, int)
  1399. /*
  1400. ***************************************************************************
  1401. * Some calls for setting the channel assignment with multi channel devices
  1402. * (see the manual for details). */
  1403. #define SNDCTL_DSP_GET_CHNORDER _IOR ('P', 42, unsigned long long)
  1404. #define SNDCTL_DSP_SET_CHNORDER _IOWR('P', 42, unsigned long long)
  1405. # define CHID_UNDEF 0
  1406. # define CHID_L 1 # define CHID_R 2
  1407. # define CHID_C 3
  1408. # define CHID_LFE 4
  1409. # define CHID_LS 5
  1410. # define CHID_RS 6
  1411. # define CHID_LR 7
  1412. # define CHID_RR 8
  1413. #define CHNORDER_UNDEF 0x0000000000000000ULL
  1414. #define CHNORDER_NORMAL 0x0000000087654321ULL
  1415. #define MAX_PEAK_CHANNELS 128
  1416. typedef unsigned short oss_peaks_t[MAX_PEAK_CHANNELS];
  1417. #define SNDCTL_DSP_GETIPEAKS _IOR('P', 43, oss_peaks_t)
  1418. #define SNDCTL_DSP_GETOPEAKS _IOR('P', 44, oss_peaks_t)
  1419. #define SNDCTL_DSP_POLICY _IOW('P', 45, int) /* See the manual */
  1420. /*
  1421. * OSS_SYSIFO is obsolete. Use SNDCTL_SYSINFO insteads.
  1422. */
  1423. #define OSS_GETVERSION _IOR ('M', 118, int)
  1424. /**
  1425. * @brief Argument for SNDCTL_SYSINFO ioctl.
  1426. *
  1427. * For use w/ the SNDCTL_SYSINFO ioctl available on audio (/dev/dsp*),
  1428. * mixer, and MIDI devices.
  1429. */
  1430. typedef struct oss_sysinfo
  1431. {
  1432. char product[32]; /* For example OSS/Free, OSS/Linux or
  1433. OSS/Solaris */
  1434. char version[32]; /* For example 4.0a */
  1435. int versionnum; /* See OSS_GETVERSION */
  1436. char options[128]; /* Reserved */
  1437. int numaudios; /* # of audio/dsp devices */
  1438. int openedaudio[8]; /* Bit mask telling which audio devices
  1439. are busy */
  1440. int numsynths; /* # of availavle synth devices */
  1441. int nummidis; /* # of available MIDI ports */
  1442. int numtimers; /* # of available timer devices */
  1443. int nummixers; /* # of mixer devices */
  1444. int openedmidi[8]; /* Bit mask telling which midi devices
  1445. are busy */
  1446. int numcards; /* Number of sound cards in the system */
  1447. int filler[241]; /* For future expansion (set to -1) */
  1448. } oss_sysinfo;
  1449. typedef struct oss_mixext
  1450. {
  1451. int dev; /* Mixer device number */
  1452. int ctrl; /* Controller number */
  1453. int type; /* Entry type */
  1454. # define MIXT_DEVROOT 0 /* Device root entry */
  1455. # define MIXT_GROUP 1 /* Controller group */
  1456. # define MIXT_ONOFF 2 /* OFF (0) or ON (1) */
  1457. # define MIXT_ENUM 3 /* Enumerated (0 to maxvalue) */
  1458. # define MIXT_MONOSLIDER 4 /* Mono slider (0 to 100) */
  1459. # define MIXT_STEREOSLIDER 5 /* Stereo slider (dual 0 to 100) */
  1460. # define MIXT_MESSAGE 6 /* (Readable) textual message */
  1461. # define MIXT_MONOVU 7 /* VU meter value (mono) */
  1462. # define MIXT_STEREOVU 8 /* VU meter value (stereo) */
  1463. # define MIXT_MONOPEAK 9 /* VU meter peak value (mono) */
  1464. # define MIXT_STEREOPEAK 10 /* VU meter peak value (stereo) */
  1465. # define MIXT_RADIOGROUP 11 /* Radio button group */
  1466. # define MIXT_MARKER 12 /* Separator between normal and extension entries */
  1467. # define MIXT_VALUE 13 /* Decimal value entry */
  1468. # define MIXT_HEXVALUE 14 /* Hexadecimal value entry */
  1469. # define MIXT_MONODB 15 /* Mono atten. slider (0 to -144) */
  1470. # define MIXT_STEREODB 16 /* Stereo atten. slider (dual 0 to -144) */
  1471. # define MIXT_SLIDER 17 /* Slider (mono) with full integer range */
  1472. # define MIXT_3D 18
  1473. /* Possible value range (minvalue to maxvalue) */
  1474. /* Note that maxvalue may also be smaller than minvalue */
  1475. int maxvalue;
  1476. int minvalue;
  1477. int flags;
  1478. # define MIXF_READABLE 0x00000001 /* Has readable value */
  1479. # define MIXF_WRITEABLE 0x00000002 /* Has writeable value */
  1480. # define MIXF_POLL 0x00000004 /* May change itself */
  1481. # define MIXF_HZ 0x00000008 /* Herz scale */
  1482. # define MIXF_STRING 0x00000010 /* Use dynamic extensions for value */
  1483. # define MIXF_DYNAMIC 0x00000010 /* Supports dynamic extensions */
  1484. # define MIXF_OKFAIL 0x00000020 /* Interpret value as 1=OK, 0=FAIL */
  1485. # define MIXF_FLAT 0x00000040 /* Flat vertical space requirements */
  1486. # define MIXF_LEGACY 0x00000080 /* Legacy mixer control group */
  1487. char id[16]; /* Mnemonic ID (mainly for internal use) */
  1488. int parent; /* Entry# of parent (group) node (-1 if root) */
  1489. int dummy; /* Internal use */
  1490. int timestamp;
  1491. char data[64]; /* Misc data (entry type dependent) */
  1492. unsigned char enum_present[32]; /* Mask of allowed enum values */
  1493. int control_no; /* SOUND_MIXER_VOLUME..SOUND_MIXER_MIDI */
  1494. /* (-1 means not indicated) */
  1495. /*
  1496. * The desc field is reserved for internal purposes of OSS. It should not be
  1497. * used by applications.
  1498. */
  1499. unsigned int desc;
  1500. #define MIXEXT_SCOPE_MASK 0x0000003f
  1501. #define MIXEXT_SCOPE_OTHER 0x00000000
  1502. #define MIXEXT_SCOPE_INPUT 0x00000001
  1503. #define MIXEXT_SCOPE_OUTPUT 0x00000002
  1504. #define MIXEXT_SCOPE_MONITOR 0x00000003
  1505. #define MIXEXT_SCOPE_RECSWITCH 0x00000004
  1506. char extname[32];
  1507. int update_counter;
  1508. int filler[7];
  1509. } oss_mixext;
  1510. typedef struct oss_mixext_root
  1511. {
  1512. char id[16];
  1513. char name[48];
  1514. } oss_mixext_root;
  1515. typedef struct oss_mixer_value
  1516. {
  1517. int dev;
  1518. int ctrl;
  1519. int value;
  1520. int flags; /* Reserved for future use. Initialize to 0 */
  1521. int timestamp; /* Must be set to oss_mixext.timestamp */
  1522. int filler[8]; /* Reserved for future use. Initialize to 0 */
  1523. } oss_mixer_value;
  1524. #define OSS_ENUM_MAXVALUE 255
  1525. typedef struct oss_mixer_enuminfo
  1526. {
  1527. int dev;
  1528. int ctrl;
  1529. int nvalues;
  1530. int version; /* Read the manual */
  1531. short strindex[OSS_ENUM_MAXVALUE];
  1532. char strings[3000];
  1533. } oss_mixer_enuminfo;
  1534. #define OPEN_READ PCM_ENABLE_INPUT
  1535. #define OPEN_WRITE PCM_ENABLE_OUTPUT
  1536. #define OPEN_READWRITE (OPEN_READ|OPEN_WRITE)
  1537. /**
  1538. * @brief Argument for SNDCTL_AUDIOINFO ioctl.
  1539. *
  1540. * For use w/ the SNDCTL_AUDIOINFO ioctl available on audio (/dev/dsp*)
  1541. * devices.
  1542. */
  1543. typedef struct oss_audioinfo
  1544. {
  1545. int dev; /* Audio device number */
  1546. char name[64];
  1547. int busy; /* 0, OPEN_READ, OPEN_WRITE or OPEN_READWRITE */
  1548. int pid;
  1549. int caps; /* DSP_CAP_INPUT, DSP_CAP_OUTPUT */
  1550. int iformats;
  1551. int oformats;
  1552. int magic; /* Reserved for internal use */
  1553. char cmd[64]; /* Command using the device (if known) */
  1554. int card_number;
  1555. int port_number;
  1556. int mixer_dev;
  1557. int real_device; /* Obsolete field. Replaced by devnode */
  1558. int enabled; /* 1=enabled, 0=device not ready at this
  1559. moment */
  1560. int flags; /* For internal use only - no practical
  1561. meaning */
  1562. int min_rate; /* Sample rate limits */
  1563. int max_rate;
  1564. int min_channels; /* Number of channels supported */
  1565. int max_channels;
  1566. int binding; /* DSP_BIND_FRONT, etc. 0 means undefined */
  1567. int rate_source;
  1568. char handle[32];
  1569. #define OSS_MAX_SAMPLE_RATES 20 /* Cannot be changed */
  1570. unsigned int nrates;
  1571. unsigned int rates[OSS_MAX_SAMPLE_RATES]; /* Please read the manual before using these */
  1572. oss_longname_t song_name; /* Song name (if given) */
  1573. oss_label_t label; /* Device label (if given) */
  1574. int latency; /* In usecs, -1=unknown */
  1575. oss_devnode_t devnode; /* Device special file name (inside
  1576. /dev) */
  1577. int filler[186];
  1578. } oss_audioinfo;
  1579. typedef struct oss_mixerinfo
  1580. {
  1581. int dev;
  1582. char id[16];
  1583. char name[32];
  1584. int modify_counter;
  1585. int card_number;
  1586. int port_number;
  1587. char handle[32];
  1588. int magic; /* Reserved */
  1589. int enabled; /* Reserved */
  1590. int caps;
  1591. #define MIXER_CAP_VIRTUAL 0x00000001
  1592. int flags; /* Reserved */
  1593. int nrext;
  1594. /*
  1595. * The priority field can be used to select the default (motherboard)
  1596. * mixer device. The mixer with the highest priority is the
  1597. * most preferred one. -2 or less means that this device cannot be used
  1598. * as the default mixer.
  1599. */
  1600. int priority;
  1601. int filler[254]; /* Reserved */
  1602. } oss_mixerinfo;
  1603. typedef struct oss_midi_info
  1604. {
  1605. int dev; /* Midi device number */
  1606. char name[64];
  1607. int busy; /* 0, OPEN_READ, OPEN_WRITE or OPEN_READWRITE */
  1608. int pid;
  1609. char cmd[64]; /* Command using the device (if known) */
  1610. int caps;
  1611. #define MIDI_CAP_MPU401 0x00000001 /**** OBSOLETE ****/
  1612. #define MIDI_CAP_INPUT 0x00000002
  1613. #define MIDI_CAP_OUTPUT 0x00000004
  1614. #define MIDI_CAP_INOUT (MIDI_CAP_INPUT|MIDI_CAP_OUTPUT)
  1615. #define MIDI_CAP_VIRTUAL 0x00000008 /* Pseudo device */
  1616. #define MIDI_CAP_MTCINPUT 0x00000010 /* Supports SNDCTL_MIDI_MTCINPUT */
  1617. #define MIDI_CAP_CLIENT 0x00000020 /* Virtual client side device */
  1618. #define MIDI_CAP_SERVER 0x00000040 /* Virtual server side device */
  1619. #define MIDI_CAP_INTERNAL 0x00000080 /* Internal (synth) device */
  1620. #define MIDI_CAP_EXTERNAL 0x00000100 /* external (MIDI port) device */
  1621. #define MIDI_CAP_PTOP 0x00000200 /* Point to point link to one device */
  1622. #define MIDI_CAP_MTC 0x00000400 /* MTC/SMPTE (control) device */
  1623. int magic; /* Reserved for internal use */
  1624. int card_number;
  1625. int port_number;
  1626. int enabled; /* 1=enabled, 0=device not ready at this moment */
  1627. int flags; /* For internal use only - no practical meaning */
  1628. char handle[32];
  1629. oss_longname_t song_name; /* Song name (if known) */
  1630. oss_label_t label; /* Device label (if given) */
  1631. int latency; /* In usecs, -1=unknown */
  1632. int filler[244];
  1633. } oss_midi_info;
  1634. typedef struct oss_card_info
  1635. {
  1636. int card;
  1637. char shortname[16];
  1638. char longname[128];
  1639. int flags;
  1640. int filler[256];
  1641. } oss_card_info;
  1642. #define SNDCTL_SYSINFO _IOR ('X', 1, oss_sysinfo)
  1643. #define OSS_SYSINFO SNDCTL_SYSINFO /* Old name */
  1644. #define SNDCTL_MIX_NRMIX _IOR ('X', 2, int)
  1645. #define SNDCTL_MIX_NREXT _IOWR('X', 3, int)
  1646. #define SNDCTL_MIX_EXTINFO _IOWR('X', 4, oss_mixext)
  1647. #define SNDCTL_MIX_READ _IOWR('X', 5, oss_mixer_value)
  1648. #define SNDCTL_MIX_WRITE _IOWR('X', 6, oss_mixer_value)
  1649. #define SNDCTL_AUDIOINFO _IOWR('X', 7, oss_audioinfo)
  1650. #define SNDCTL_MIX_ENUMINFO _IOWR('X', 8, oss_mixer_enuminfo)
  1651. #define SNDCTL_MIDIINFO _IOWR('X', 9, oss_midi_info)
  1652. #define SNDCTL_MIXERINFO _IOWR('X',10, oss_mixerinfo)
  1653. #define SNDCTL_CARDINFO _IOWR('X',11, oss_card_info)
  1654. /*
  1655. * Few more "globally" available ioctl calls.
  1656. */
  1657. #define SNDCTL_SETSONG _IOW ('Y', 2, oss_longname_t)
  1658. #define SNDCTL_GETSONG _IOR ('Y', 2, oss_longname_t)
  1659. #define SNDCTL_SETNAME _IOW ('Y', 3, oss_longname_t)
  1660. #define SNDCTL_SETLABEL _IOW ('Y', 4, oss_label_t)
  1661. #define SNDCTL_GETLABEL _IOR ('Y', 4, oss_label_t)
  1662. #endif /* !_SYS_SOUNDCARD_H_ */