soundcard.h 46 KB

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