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.

2062 lines
74KB

  1. #ifndef SOUNDCARD_H
  2. #define SOUNDCARD_H
  3. /*
  4. ****************************************************************************
  5. * Copyright by 4Front Technologies 1993-2006
  6. *
  7. ******************************************************************************
  8. * Modifications to this file are NOT allowed. This header file controls the
  9. * OSS API. For compatibility reasons only 4Front Technologies can make changes
  10. * to the definitions. If you have any questions, please contact
  11. * hannu@opensound.com.
  12. ******************************************************************************
  13. *
  14. * Redistribution and use in source and binary forms, without
  15. * modification, are permitted provided that the following conditions are
  16. * met: 1. Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer. 2.
  18. * Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
  23. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
  26. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. ****************************************************************************
  34. */
  35. /*
  36. * Purpose: The C/C++ header file that defines the OSS API.
  37. * Description:
  38. * This header file contains all the declarations required to compile OSS
  39. * programs. The latest version is always installed together with OSS
  40. * use of the latest version is strongly recommended.
  41. *
  42. * {!notice This header file contains many obsolete definitions
  43. * (for compatibility with older applications that still ned them).
  44. * Do not use this file as a reference manual of OSS.
  45. * Please check the OSS Programmer's guide for descriptions
  46. * of the supported API details (http://www.opensound.com/pguide).}
  47. */
  48. #if defined(__cplusplus)
  49. #define EXTERNC extern "C"
  50. #else
  51. #define EXTERNC extern
  52. #endif /* EXTERN_C_WRAPPERS */
  53. #define OSS_VERSION 0x040002
  54. #define SOUND_VERSION OSS_VERSION
  55. #define OPEN_SOUND_SYSTEM
  56. #if defined(__hpux) && !defined(_HPUX_SOURCE)
  57. # error "-D_HPUX_SOURCE must be used when compiling OSS applications"
  58. #endif
  59. #ifdef __hpux
  60. #include <sys/ioctl.h>
  61. #endif
  62. #ifdef linux
  63. /* In Linux we need to be prepared for cross compiling */
  64. #include <linux/ioctl.h>
  65. #else
  66. # ifdef __FreeBSD__
  67. # include <sys/ioccom.h>
  68. # else
  69. # include <sys/ioctl.h>
  70. # endif
  71. #endif
  72. #ifndef __SIOWR
  73. #if defined(__hpux) || (defined(_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__INCioctlh) && !defined(__Lynx__))))
  74. /*
  75. * Make sure the ioctl macros are compatible with the ones already used
  76. * by this operating system.
  77. */
  78. #define SIOCPARM_MASK IOCPARM_MASK
  79. #define SIOC_VOID IOC_VOID
  80. #define SIOC_OUT IOC_OUT
  81. #define SIOC_IN IOC_IN
  82. #define SIOC_INOUT IOC_INOUT
  83. #define __SIOC_SIZE _IOC_SIZE
  84. #define __SIOC_DIR _IOC_DIR
  85. #define __SIOC_NONE _IOC_NONE
  86. #define __SIOC_READ _IOC_READ
  87. #define __SIOC_WRITE _IOC_WRITE
  88. #define __SIO _IO
  89. #define __SIOR _IOR
  90. #define __SIOW _IOW
  91. #define __SIOWR _IOWR
  92. #else
  93. /* #define SIOCTYPE (0xff<<8) */
  94. #define SIOCPARM_MASK 0x1fff /* parameters must be < 8192 bytes */
  95. #define SIOC_VOID 0x00000000 /* no parameters */
  96. #define SIOC_OUT 0x20000000 /* copy out parameters */
  97. #define SIOC_IN 0x40000000 /* copy in parameters */
  98. #define SIOC_INOUT (SIOC_IN|SIOC_OUT)
  99. #define __SIO(x,y) ((int)(SIOC_VOID|(x<<8)|y))
  100. #define __SIOR(x,y,t) ((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
  101. #define __SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
  102. #define __SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
  103. #define __SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK)
  104. #define __SIOC_DIR(x) (x & 0xf0000000)
  105. #define __SIOC_NONE SIOC_VOID
  106. #define __SIOC_READ SIOC_OUT
  107. #define __SIOC_WRITE SIOC_IN
  108. # endif /* _IOWR */
  109. #endif /* !__SIOWR */
  110. #define OSS_LONGNAME_SIZE 64
  111. #define OSS_LABEL_SIZE 16
  112. #define OSS_DEVNODE_SIZE 32
  113. typedef char oss_longname_t[OSS_LONGNAME_SIZE];
  114. typedef char oss_label_t[OSS_LABEL_SIZE];
  115. typedef char oss_devnode_t[OSS_DEVNODE_SIZE];
  116. #ifndef DISABLE_SEQUENCER
  117. /*
  118. ****************************************************************************
  119. * IOCTL Commands for /dev/sequencer and /dev/music (AKA /dev/sequencer2)
  120. *
  121. * Note that this interface is obsolete and no longer developed. New
  122. * applications should use /dev/midi instead.
  123. ****************************************************************************/
  124. #define SNDCTL_SEQ_RESET __SIO ('Q', 0)
  125. #define SNDCTL_SEQ_SYNC __SIO ('Q', 1)
  126. #define SNDCTL_SYNTH_INFO __SIOWR('Q', 2, struct synth_info)
  127. #define SNDCTL_SEQ_CTRLRATE __SIOWR('Q', 3, int) /* Set/get timer resolution (HZ) */
  128. #define SNDCTL_SEQ_GETOUTCOUNT __SIOR ('Q', 4, int)
  129. #define SNDCTL_SEQ_GETINCOUNT __SIOR ('Q', 5, int)
  130. #define SNDCTL_SEQ_PERCMODE __SIOW ('Q', 6, int)
  131. #define SNDCTL_FM_LOAD_INSTR __SIOW ('Q', 7, struct sbi_instrument) /* Obsolete. Don't use!!!!!! */
  132. #define SNDCTL_SEQ_TESTMIDI __SIOW ('Q', 8, int)
  133. #define SNDCTL_SEQ_RESETSAMPLES __SIOW ('Q', 9, int)
  134. #define SNDCTL_SEQ_NRSYNTHS __SIOR ('Q',10, int)
  135. #define SNDCTL_SEQ_NRMIDIS __SIOR ('Q',11, int)
  136. #define SNDCTL_MIDI_INFO __SIOWR('Q',12, struct midi_info) /* OBSOLETE - use SNDCTL_MIDIINFO instead */
  137. #define SNDCTL_SEQ_THRESHOLD __SIOW ('Q',13, int)
  138. #define SNDCTL_SYNTH_MEMAVL __SIOWR('Q',14, int) /* in=dev#, out=memsize */
  139. #define SNDCTL_FM_4OP_ENABLE __SIOW ('Q',15, int) /* in=dev# */
  140. #define SNDCTL_SEQ_PANIC __SIO ('Q',17)
  141. #define SNDCTL_SEQ_OUTOFBAND __SIOW ('Q',18, struct seq_event_rec)
  142. #define SNDCTL_SEQ_GETTIME __SIOR ('Q',19, int)
  143. #define SNDCTL_SYNTH_ID __SIOWR('Q',20, struct synth_info)
  144. #define SNDCTL_SYNTH_CONTROL __SIOWR('Q',21, struct synth_control)
  145. #define SNDCTL_SYNTH_REMOVESAMPLE __SIOWR('Q',22, struct remove_sample) /* Reserved for future use */
  146. #define SNDCTL_SEQ_TIMING_ENABLE __SIO ('Q', 23) /* Enable incoming MIDI timing messages */
  147. #define SNDCTL_SEQ_ACTSENSE_ENABLE __SIO ('Q', 24) /* Enable incoming active sensing messages */
  148. #define SNDCTL_SEQ_RT_ENABLE __SIO ('Q', 25) /* Enable other incoming realtime messages */
  149. typedef struct synth_control
  150. {
  151. int devno; /* Synthesizer # */
  152. char data[4000]; /* Device spesific command/data record */
  153. } synth_control;
  154. typedef struct remove_sample
  155. {
  156. int devno; /* Synthesizer # */
  157. int bankno; /* MIDI bank # (0=General MIDI) */
  158. int instrno; /* MIDI instrument number */
  159. } remove_sample;
  160. typedef struct seq_event_rec
  161. {
  162. unsigned char arr[8];
  163. } seq_event_rec;
  164. #define SNDCTL_TMR_TIMEBASE __SIOWR('T', 1, int)
  165. #define SNDCTL_TMR_START __SIO ('T', 2)
  166. #define SNDCTL_TMR_STOP __SIO ('T', 3)
  167. #define SNDCTL_TMR_CONTINUE __SIO ('T', 4)
  168. #define SNDCTL_TMR_TEMPO __SIOWR('T', 5, int)
  169. #define SNDCTL_TMR_SOURCE __SIOWR('T', 6, int)
  170. # define TMR_INTERNAL 0x00000001
  171. # define TMR_EXTERNAL 0x00000002
  172. # define TMR_MODE_MIDI 0x00000010
  173. # define TMR_MODE_FSK 0x00000020
  174. # define TMR_MODE_CLS 0x00000040
  175. # define TMR_MODE_SMPTE 0x00000080
  176. #define SNDCTL_TMR_METRONOME __SIOW ('T', 7, int)
  177. #define SNDCTL_TMR_SELECT __SIOW ('T', 8, int)
  178. /*
  179. * Sample loading mechanism for internal synthesizers (/dev/sequencer)
  180. * (for the .PAT format).
  181. */
  182. struct patch_info
  183. {
  184. unsigned short key; /* Use WAVE_PATCH here */
  185. #define WAVE_PATCH _PATCHKEY(0x04)
  186. #define GUS_PATCH WAVE_PATCH
  187. #define WAVEFRONT_PATCH _PATCHKEY(0x06)
  188. short device_no; /* Synthesizer number */
  189. short instr_no; /* Midi pgm# */
  190. unsigned int mode;
  191. /*
  192. * The least significant byte has the same format than the GUS .PAT
  193. * files
  194. */
  195. #define WAVE_16_BITS 0x01 /* bit 0 = 8 or 16 bit wave data. */
  196. #define WAVE_UNSIGNED 0x02 /* bit 1 = Signed - Unsigned data. */
  197. #define WAVE_LOOPING 0x04 /* bit 2 = looping enabled-1. */
  198. #define WAVE_BIDIR_LOOP 0x08 /* bit 3 = Set is bidirectional looping. */
  199. #define WAVE_LOOP_BACK 0x10 /* bit 4 = Set is looping backward. */
  200. #define WAVE_SUSTAIN_ON 0x20 /* bit 5 = Turn sustaining on. (Env. pts. 3) */
  201. #define WAVE_ENVELOPES 0x40 /* bit 6 = Enable envelopes - 1 */
  202. #define WAVE_FAST_RELEASE 0x80 /* bit 7 = Shut off immediately after note off */
  203. /* (use the env_rate/env_offs fields). */
  204. /* Linux specific bits */
  205. #define WAVE_VIBRATO 0x00010000 /* The vibrato info is valid */
  206. #define WAVE_TREMOLO 0x00020000 /* The tremolo info is valid */
  207. #define WAVE_SCALE 0x00040000 /* The scaling info is valid */
  208. #define WAVE_FRACTIONS 0x00080000 /* Fraction information is valid */
  209. /* Reserved bits */
  210. #define WAVE_ROM 0x40000000 /* For future use */
  211. #define WAVE_MULAW 0x20000000 /* For future use */
  212. /* Other bits must be zeroed */
  213. int len; /* Size of the wave data in bytes */
  214. int loop_start, loop_end; /* Byte offsets from the beginning */
  215. /*
  216. * The base_freq and base_note fields are used when computing the
  217. * playback speed for a note. The base_note defines the tone frequency
  218. * which is heard if the sample is played using the base_freq as the
  219. * playback speed.
  220. *
  221. * The low_note and high_note fields define the minimum and maximum note
  222. * frequencies for which this sample is valid. It is possible to define
  223. * more than one samples for an instrument number at the same time. The
  224. * low_note and high_note fields are used to select the most suitable one.
  225. *
  226. * The fields base_note, high_note and low_note should contain
  227. * the note frequency multiplied by 1000. For example value for the
  228. * middle A is 440*1000.
  229. */
  230. unsigned int base_freq;
  231. unsigned int base_note;
  232. unsigned int high_note;
  233. unsigned int low_note;
  234. int panning; /* -128=left, 127=right */
  235. int detuning;
  236. /* Envelope. Enabled by mode bit WAVE_ENVELOPES */
  237. unsigned char env_rate[6]; /* GUS HW ramping rate */
  238. unsigned char env_offset[6]; /* 255 == 100% */
  239. /*
  240. * The tremolo, vibrato and scale info are not supported yet.
  241. * Enable by setting the mode bits WAVE_TREMOLO, WAVE_VIBRATO or
  242. * WAVE_SCALE
  243. */
  244. unsigned char tremolo_sweep;
  245. unsigned char tremolo_rate;
  246. unsigned char tremolo_depth;
  247. unsigned char vibrato_sweep;
  248. unsigned char vibrato_rate;
  249. unsigned char vibrato_depth;
  250. int scale_frequency;
  251. unsigned int scale_factor; /* from 0 to 2048 or 0 to 2 */
  252. int volume;
  253. int fractions;
  254. int reserved1;
  255. int spare[2];
  256. char data[1]; /* The waveform data starts here */
  257. };
  258. struct sysex_info
  259. {
  260. short key; /* Use SYSEX_PATCH or MAUI_PATCH here */
  261. #define SYSEX_PATCH _PATCHKEY(0x05)
  262. #define MAUI_PATCH _PATCHKEY(0x06)
  263. short device_no; /* Synthesizer number */
  264. int len; /* Size of the sysex data in bytes */
  265. unsigned char data[1]; /* Sysex data starts here */
  266. };
  267. /*
  268. * /dev/sequencer input events.
  269. *
  270. * The data written to the /dev/sequencer is a stream of events. Events
  271. * are records of 4 or 8 bytes. The first byte defines the size.
  272. * Any number of events can be written with a write call. There
  273. * is a set of macros for sending these events. Use these macros if you
  274. * want to maximize portability of your program.
  275. *
  276. * Events SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO. Are also input events.
  277. * (All input events are currently 4 bytes long. Be prepared to support
  278. * 8 byte events also. If you receive any event having first byte >= 128,
  279. * it's a 8 byte event.
  280. *
  281. * The events are documented at the end of this file.
  282. *
  283. * Normal events (4 bytes)
  284. * There is also a 8 byte version of most of the 4 byte events. The
  285. * 8 byte one is recommended.
  286. *
  287. * NOTE! All 4 byte events are now obsolete. Applications should not write
  288. * them. However 4 byte events are still used as inputs from
  289. * /dev/sequencer (/dev/music uses only 8 byte ones).
  290. */
  291. #define SEQ_NOTEOFF 0
  292. #define SEQ_FMNOTEOFF SEQ_NOTEOFF /* Just old name */
  293. #define SEQ_NOTEON 1
  294. #define SEQ_FMNOTEON SEQ_NOTEON
  295. #define SEQ_WAIT TMR_WAIT_ABS
  296. #define SEQ_PGMCHANGE 3
  297. #define SEQ_FMPGMCHANGE SEQ_PGMCHANGE
  298. #define SEQ_SYNCTIMER TMR_START
  299. #define SEQ_MIDIPUTC 5
  300. #define SEQ_DRUMON 6 /*** OBSOLETE ***/
  301. #define SEQ_DRUMOFF 7 /*** OBSOLETE ***/
  302. #define SEQ_ECHO TMR_ECHO /* For synching programs with output */
  303. #define SEQ_AFTERTOUCH 9
  304. #define SEQ_CONTROLLER 10
  305. #define SEQ_BALANCE 11
  306. #define SEQ_VOLMODE 12
  307. /************************************
  308. * Midi controller numbers *
  309. ************************************/
  310. /*
  311. * Controllers 0 to 31 (0x00 to 0x1f) and
  312. * 32 to 63 (0x20 to 0x3f) are continuous
  313. * controllers.
  314. * In the MIDI 1.0 these controllers are sent using
  315. * two messages. Controller numbers 0 to 31 are used
  316. * to send the MSB and the controller numbers 32 to 63
  317. * are for the LSB. Note that just 7 bits are used in MIDI bytes.
  318. */
  319. #define CTL_BANK_SELECT 0x00
  320. #define CTL_MODWHEEL 0x01
  321. #define CTL_BREATH 0x02
  322. /* undefined 0x03 */
  323. #define CTL_FOOT 0x04
  324. #define CTL_PORTAMENTO_TIME 0x05
  325. #define CTL_DATA_ENTRY 0x06
  326. #define CTL_MAIN_VOLUME 0x07
  327. #define CTL_BALANCE 0x08
  328. /* undefined 0x09 */
  329. #define CTL_PAN 0x0a
  330. #define CTL_EXPRESSION 0x0b
  331. /* undefined 0x0c */
  332. /* undefined 0x0d */
  333. /* undefined 0x0e */
  334. /* undefined 0x0f */
  335. #define CTL_GENERAL_PURPOSE1 0x10
  336. #define CTL_GENERAL_PURPOSE2 0x11
  337. #define CTL_GENERAL_PURPOSE3 0x12
  338. #define CTL_GENERAL_PURPOSE4 0x13
  339. /* undefined 0x14 - 0x1f */
  340. /* undefined 0x20 */
  341. /* The controller numbers 0x21 to 0x3f are reserved for the */
  342. /* least significant bytes of the controllers 0x00 to 0x1f. */
  343. /* These controllers are not recognised by the driver. */
  344. /* Controllers 64 to 69 (0x40 to 0x45) are on/off switches. */
  345. /* 0=OFF and 127=ON (intermediate values are possible) */
  346. #define CTL_DAMPER_PEDAL 0x40
  347. #define CTL_SUSTAIN 0x40 /* Alias */
  348. #define CTL_HOLD 0x40 /* Alias */
  349. #define CTL_PORTAMENTO 0x41
  350. #define CTL_SOSTENUTO 0x42
  351. #define CTL_SOFT_PEDAL 0x43
  352. /* undefined 0x44 */
  353. #define CTL_HOLD2 0x45
  354. /* undefined 0x46 - 0x4f */
  355. #define CTL_GENERAL_PURPOSE5 0x50
  356. #define CTL_GENERAL_PURPOSE6 0x51
  357. #define CTL_GENERAL_PURPOSE7 0x52
  358. #define CTL_GENERAL_PURPOSE8 0x53
  359. /* undefined 0x54 - 0x5a */
  360. #define CTL_EXT_EFF_DEPTH 0x5b
  361. #define CTL_TREMOLO_DEPTH 0x5c
  362. #define CTL_CHORUS_DEPTH 0x5d
  363. #define CTL_DETUNE_DEPTH 0x5e
  364. #define CTL_CELESTE_DEPTH 0x5e /* Alias for the above one */
  365. #define CTL_PHASER_DEPTH 0x5f
  366. #define CTL_DATA_INCREMENT 0x60
  367. #define CTL_DATA_DECREMENT 0x61
  368. #define CTL_NONREG_PARM_NUM_LSB 0x62
  369. #define CTL_NONREG_PARM_NUM_MSB 0x63
  370. #define CTL_REGIST_PARM_NUM_LSB 0x64
  371. #define CTL_REGIST_PARM_NUM_MSB 0x65
  372. /* undefined 0x66 - 0x78 */
  373. /* reserved 0x79 - 0x7f */
  374. /* Pseudo controllers (not midi compatible) */
  375. #define CTRL_PITCH_BENDER 255
  376. #define CTRL_PITCH_BENDER_RANGE 254
  377. #define CTRL_EXPRESSION 253 /* Obsolete */
  378. #define CTRL_MAIN_VOLUME 252 /* Obsolete */
  379. /*
  380. * Volume mode defines how volumes are used
  381. */
  382. #define VOL_METHOD_ADAGIO 1
  383. #define VOL_METHOD_LINEAR 2
  384. /*
  385. * Note! SEQ_WAIT, SEQ_MIDIPUTC and SEQ_ECHO are used also as
  386. * input events.
  387. */
  388. /*
  389. * Event codes 0xf0 to 0xfc are reserved for future extensions.
  390. */
  391. #define SEQ_FULLSIZE 0xfd /* Long events */
  392. /*
  393. * SEQ_FULLSIZE events are used for loading patches/samples to the
  394. * synthesizer devices. These events are passed directly to the driver
  395. * of the associated synthesizer device. There is no limit to the size
  396. * of the extended events. These events are not queued but executed
  397. * immediately when the write() is called (execution can take several
  398. * seconds of time).
  399. *
  400. * When a SEQ_FULLSIZE message is written to the device, it must
  401. * be written using exactly one write() call. Other events cannot
  402. * be mixed to the same write.
  403. *
  404. * For FM synths (YM3812/OPL3) use struct sbi_instrument and write it to the
  405. * /dev/sequencer. Don't write other data together with the instrument structure
  406. * Set the key field of the structure to FM_PATCH. The device field is used to
  407. * route the patch to the corresponding device.
  408. *
  409. * For wave table use struct patch_info. Initialize the key field
  410. * to WAVE_PATCH.
  411. */
  412. #define SEQ_PRIVATE 0xfe /* Low level HW dependent events (8 bytes) */
  413. #define SEQ_EXTENDED 0xff /* Extended events (8 bytes) OBSOLETE */
  414. /*
  415. * Record for FM patches
  416. */
  417. typedef unsigned char sbi_instr_data[32];
  418. struct sbi_instrument
  419. {
  420. unsigned short key; /* FM_PATCH or OPL3_PATCH */
  421. #define FM_PATCH _PATCHKEY(0x01)
  422. #define OPL3_PATCH _PATCHKEY(0x03)
  423. short device; /* Synth# (0-4) */
  424. int channel; /* Program# to be initialized */
  425. sbi_instr_data operators; /* Register settings for operator cells (.SBI format) */
  426. };
  427. struct synth_info
  428. { /* Read only */
  429. char name[30];
  430. int device; /* 0-N. INITIALIZE BEFORE CALLING */
  431. int synth_type;
  432. #define SYNTH_TYPE_FM 0
  433. #define SYNTH_TYPE_SAMPLE 1
  434. #define SYNTH_TYPE_MIDI 2 /* Midi interface */
  435. int synth_subtype;
  436. #define FM_TYPE_ADLIB 0x00
  437. #define FM_TYPE_OPL3 0x01
  438. #define MIDI_TYPE_MPU401 0x401
  439. #define SAMPLE_TYPE_BASIC 0x10
  440. #define SAMPLE_TYPE_GUS SAMPLE_TYPE_BASIC
  441. #define SAMPLE_TYPE_WAVEFRONT 0x11
  442. int perc_mode; /* No longer supported */
  443. int nr_voices;
  444. int nr_drums; /* Obsolete field */
  445. int instr_bank_size;
  446. unsigned int capabilities;
  447. #define SYNTH_CAP_PERCMODE 0x00000001 /* No longer used */
  448. #define SYNTH_CAP_OPL3 0x00000002 /* Set if OPL3 supported */
  449. #define SYNTH_CAP_INPUT 0x00000004 /* Input (MIDI) device */
  450. int dummies[19]; /* Reserve space */
  451. };
  452. struct sound_timer_info
  453. {
  454. char name[32];
  455. int caps;
  456. };
  457. struct midi_info /* OBSOLETE */
  458. {
  459. char name[30];
  460. int device; /* 0-N. INITIALIZE BEFORE CALLING */
  461. unsigned int capabilities; /* To be defined later */
  462. int dev_type;
  463. int dummies[18]; /* Reserve space */
  464. };
  465. /*
  466. * Level 2 event types for /dev/sequencer
  467. */
  468. /*
  469. * The 4 most significant bits of byte 0 specify the class of
  470. * the event:
  471. *
  472. * 0x8X = system level events,
  473. * 0x9X = device/port specific events, event[1] = device/port,
  474. * The last 4 bits give the subtype:
  475. * 0x02 = Channel event (event[3] = chn).
  476. * 0x01 = note event (event[4] = note).
  477. * (0x01 is not used alone but always with bit 0x02).
  478. * event[2] = MIDI message code (0x80=note off etc.)
  479. *
  480. */
  481. #define EV_SEQ_LOCAL 0x80
  482. #define EV_TIMING 0x81
  483. #define EV_CHN_COMMON 0x92
  484. #define EV_CHN_VOICE 0x93
  485. #define EV_SYSEX 0x94
  486. #define EV_SYSTEM 0x95 /* MIDI system and real time messages (input only) */
  487. /*
  488. * Event types 200 to 220 are reserved for application use.
  489. * These numbers will not be used by the driver.
  490. */
  491. /*
  492. * Events for event type EV_CHN_VOICE
  493. */
  494. #define MIDI_NOTEOFF 0x80
  495. #define MIDI_NOTEON 0x90
  496. #define MIDI_KEY_PRESSURE 0xA0
  497. /*
  498. * Events for event type EV_CHN_COMMON
  499. */
  500. #define MIDI_CTL_CHANGE 0xB0
  501. #define MIDI_PGM_CHANGE 0xC0
  502. #define MIDI_CHN_PRESSURE 0xD0
  503. #define MIDI_PITCH_BEND 0xE0
  504. #define MIDI_SYSTEM_PREFIX 0xF0
  505. /*
  506. * Timer event types
  507. */
  508. #define TMR_WAIT_REL 1 /* Time relative to the prev time */
  509. #define TMR_WAIT_ABS 2 /* Absolute time since TMR_START */
  510. #define TMR_STOP 3
  511. #define TMR_START 4
  512. #define TMR_CONTINUE 5
  513. #define TMR_TEMPO 6
  514. #define TMR_ECHO 8
  515. #define TMR_CLOCK 9 /* MIDI clock */
  516. #define TMR_SPP 10 /* Song position pointer */
  517. #define TMR_TIMESIG 11 /* Time signature */
  518. /*
  519. * Local event types
  520. */
  521. #define LOCL_STARTAUDIO 1
  522. #define LOCL_STARTAUDIO2 2
  523. #define LOCL_STARTAUDIO3 3
  524. #define LOCL_STARTAUDIO4 4
  525. #if (!defined(__KERNEL__) && !defined(KERNEL) && !defined(INKERNEL) && !defined(_KERNEL)) || defined(USE_SEQ_MACROS)
  526. /*
  527. * Some convenience macros to simplify programming of the
  528. * /dev/sequencer interface
  529. *
  530. * These macros define the API which should be used when possible.
  531. */
  532. #define SEQ_DECLAREBUF() SEQ_USE_EXTBUF()
  533. void seqbuf_dump (void); /* This function must be provided by programs */
  534. EXTERNC int OSS_init (int seqfd, int buflen);
  535. EXTERNC void OSS_seqbuf_dump (int fd, unsigned char *buf, int buflen);
  536. EXTERNC void OSS_seq_advbuf (int len, int fd, unsigned char *buf, int buflen);
  537. EXTERNC void OSS_seq_needbuf (int len, int fd, unsigned char *buf,
  538. int buflen);
  539. EXTERNC void OSS_patch_caching (int dev, int chn, int patch, int fd,
  540. unsigned char *buf, int buflen);
  541. EXTERNC void OSS_drum_caching (int dev, int chn, int patch, int fd,
  542. unsigned char *buf, int buflen);
  543. EXTERNC void OSS_write_patch (int fd, unsigned char *buf, int len);
  544. EXTERNC int OSS_write_patch2 (int fd, unsigned char *buf, int len);
  545. #define SEQ_PM_DEFINES int __foo_bar___
  546. #ifdef OSSLIB
  547. # define SEQ_USE_EXTBUF() \
  548. EXTERNC unsigned char *_seqbuf; \
  549. EXTERNC int _seqbuflen;EXTERNC int _seqbufptr
  550. # define SEQ_DEFINEBUF(len) SEQ_USE_EXTBUF();static int _requested_seqbuflen=len
  551. # define _SEQ_ADVBUF(len) OSS_seq_advbuf(len, seqfd, _seqbuf, _seqbuflen)
  552. # define _SEQ_NEEDBUF(len) OSS_seq_needbuf(len, seqfd, _seqbuf, _seqbuflen)
  553. # define SEQ_DUMPBUF() OSS_seqbuf_dump(seqfd, _seqbuf, _seqbuflen)
  554. # define SEQ_LOAD_GMINSTR(dev, instr) \
  555. OSS_patch_caching(dev, -1, instr, seqfd, _seqbuf, _seqbuflen)
  556. # define SEQ_LOAD_GMDRUM(dev, drum) \
  557. OSS_drum_caching(dev, -1, drum, seqfd, _seqbuf, _seqbuflen)
  558. #else /* !OSSLIB */
  559. # define SEQ_LOAD_GMINSTR(dev, instr)
  560. # define SEQ_LOAD_GMDRUM(dev, drum)
  561. # define SEQ_USE_EXTBUF() \
  562. EXTERNC unsigned char _seqbuf[]; \
  563. EXTERNC int _seqbuflen;EXTERNC int _seqbufptr
  564. #ifndef USE_SIMPLE_MACROS
  565. /* Sample seqbuf_dump() implementation:
  566. *
  567. * SEQ_DEFINEBUF (2048); -- Defines a buffer for 2048 bytes
  568. *
  569. * int seqfd; -- The file descriptor for /dev/sequencer.
  570. *
  571. * void
  572. * seqbuf_dump ()
  573. * {
  574. * if (_seqbufptr)
  575. * if (write (seqfd, _seqbuf, _seqbufptr) == -1)
  576. * {
  577. * perror ("write /dev/sequencer");
  578. * exit (-1);
  579. * }
  580. * _seqbufptr = 0;
  581. * }
  582. */
  583. #define SEQ_DEFINEBUF(len) \
  584. unsigned char _seqbuf[len]; int _seqbuflen = len;int _seqbufptr = 0
  585. #define _SEQ_NEEDBUF(len) \
  586. if ((_seqbufptr+(len)) > _seqbuflen) seqbuf_dump()
  587. #define _SEQ_ADVBUF(len) _seqbufptr += len
  588. #define SEQ_DUMPBUF seqbuf_dump
  589. #else
  590. /*
  591. * This variation of the sequencer macros is used just to format one event
  592. * using fixed buffer.
  593. *
  594. * The program using the macro library must define the following macros before
  595. * using this library.
  596. *
  597. * #define _seqbuf name of the buffer (unsigned char[])
  598. * #define _SEQ_ADVBUF(len) If the applic needs to know the exact
  599. * size of the event, this macro can be used.
  600. * Otherwise this must be defined as empty.
  601. * #define _seqbufptr Define the name of index variable or 0 if
  602. * not required.
  603. */
  604. #define _SEQ_NEEDBUF(len) /* empty */
  605. #endif
  606. #endif /* !OSSLIB */
  607. #define SEQ_VOLUME_MODE(dev, mode) \
  608. {_SEQ_NEEDBUF(8);\
  609. _seqbuf[_seqbufptr] = SEQ_EXTENDED;\
  610. _seqbuf[_seqbufptr+1] = SEQ_VOLMODE;\
  611. _seqbuf[_seqbufptr+2] = (dev);\
  612. _seqbuf[_seqbufptr+3] = (mode);\
  613. _seqbuf[_seqbufptr+4] = 0;\
  614. _seqbuf[_seqbufptr+5] = 0;\
  615. _seqbuf[_seqbufptr+6] = 0;\
  616. _seqbuf[_seqbufptr+7] = 0;\
  617. _SEQ_ADVBUF(8);}
  618. /*
  619. * Midi voice messages
  620. */
  621. #define _CHN_VOICE(dev, event, chn, note, parm) \
  622. {_SEQ_NEEDBUF(8);\
  623. _seqbuf[_seqbufptr] = EV_CHN_VOICE;\
  624. _seqbuf[_seqbufptr+1] = (dev);\
  625. _seqbuf[_seqbufptr+2] = (event);\
  626. _seqbuf[_seqbufptr+3] = (chn);\
  627. _seqbuf[_seqbufptr+4] = (note);\
  628. _seqbuf[_seqbufptr+5] = (parm);\
  629. _seqbuf[_seqbufptr+6] = (0);\
  630. _seqbuf[_seqbufptr+7] = 0;\
  631. _SEQ_ADVBUF(8);}
  632. #define SEQ_START_NOTE(dev, chn, note, vol) \
  633. _CHN_VOICE(dev, MIDI_NOTEON, chn, note, vol)
  634. #define SEQ_STOP_NOTE(dev, chn, note, vol) \
  635. _CHN_VOICE(dev, MIDI_NOTEOFF, chn, note, vol)
  636. #define SEQ_KEY_PRESSURE(dev, chn, note, pressure) \
  637. _CHN_VOICE(dev, MIDI_KEY_PRESSURE, chn, note, pressure)
  638. /*
  639. * Midi channel messages
  640. */
  641. #define _CHN_COMMON(dev, event, chn, p1, p2, w14) \
  642. {_SEQ_NEEDBUF(8);\
  643. _seqbuf[_seqbufptr] = EV_CHN_COMMON;\
  644. _seqbuf[_seqbufptr+1] = (dev);\
  645. _seqbuf[_seqbufptr+2] = (event);\
  646. _seqbuf[_seqbufptr+3] = (chn);\
  647. _seqbuf[_seqbufptr+4] = (p1);\
  648. _seqbuf[_seqbufptr+5] = (p2);\
  649. *(short *)&_seqbuf[_seqbufptr+6] = (w14);\
  650. _SEQ_ADVBUF(8);}
  651. /*
  652. * SEQ_SYSEX permits sending of sysex messages. (It may look that it permits
  653. * sending any MIDI bytes but it's absolutely not possible. Trying to do
  654. * so _will_ cause problems with MPU401 intelligent mode).
  655. *
  656. * Sysex messages are sent in blocks of 1 to 6 bytes. Longer messages must be
  657. * sent by calling SEQ_SYSEX() several times (there must be no other events
  658. * between them). First sysex fragment must have 0xf0 in the first byte
  659. * and the last byte (buf[len-1] of the last fragment must be 0xf7. No byte
  660. * between these sysex start and end markers cannot be larger than 0x7f. Also
  661. * lengths of each fragments (except the last one) must be 6.
  662. *
  663. * Breaking the above rules may work with some MIDI ports but is likely to
  664. * cause fatal problems with some other devices (such as MPU401).
  665. */
  666. #define SEQ_SYSEX(dev, buf, len) \
  667. {int ii, ll=(len); \
  668. unsigned char *bufp=buf;\
  669. if (ll>6)ll=6;\
  670. _SEQ_NEEDBUF(8);\
  671. _seqbuf[_seqbufptr] = EV_SYSEX;\
  672. _seqbuf[_seqbufptr+1] = (dev);\
  673. for(ii=0;ii<ll;ii++)\
  674. _seqbuf[_seqbufptr+ii+2] = bufp[ii];\
  675. for(ii=ll;ii<6;ii++)\
  676. _seqbuf[_seqbufptr+ii+2] = 0xff;\
  677. _SEQ_ADVBUF(8);}
  678. #define SEQ_CHN_PRESSURE(dev, chn, pressure) \
  679. _CHN_COMMON(dev, MIDI_CHN_PRESSURE, chn, pressure, 0, 0)
  680. #define SEQ_SET_PATCH SEQ_PGM_CHANGE
  681. #ifdef OSSLIB
  682. # define SEQ_PGM_CHANGE(dev, chn, patch) \
  683. {OSS_patch_caching(dev, chn, patch, seqfd, _seqbuf, _seqbuflen); \
  684. _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0);}
  685. #else
  686. # define SEQ_PGM_CHANGE(dev, chn, patch) \
  687. _CHN_COMMON(dev, MIDI_PGM_CHANGE, chn, patch, 0, 0)
  688. #endif
  689. #define SEQ_CONTROL(dev, chn, controller, value) \
  690. _CHN_COMMON(dev, MIDI_CTL_CHANGE, chn, controller, 0, value)
  691. #define SEQ_BENDER(dev, chn, value) \
  692. _CHN_COMMON(dev, MIDI_PITCH_BEND, chn, 0, 0, value)
  693. #define SEQ_V2_X_CONTROL(dev, voice, controller, value) \
  694. {_SEQ_NEEDBUF(8);\
  695. _seqbuf[_seqbufptr] = SEQ_EXTENDED;\
  696. _seqbuf[_seqbufptr+1] = SEQ_CONTROLLER;\
  697. _seqbuf[_seqbufptr+2] = (dev);\
  698. _seqbuf[_seqbufptr+3] = (voice);\
  699. _seqbuf[_seqbufptr+4] = (controller);\
  700. _seqbuf[_seqbufptr+5] = ((value)&0xff);\
  701. _seqbuf[_seqbufptr+6] = ((value>>8)&0xff);\
  702. _seqbuf[_seqbufptr+7] = 0;\
  703. _SEQ_ADVBUF(8);}
  704. /*
  705. * The following 5 macros are incorrectly implemented and obsolete.
  706. * Use SEQ_BENDER and SEQ_CONTROL (with proper controller) instead.
  707. */
  708. #define SEQ_PITCHBEND(dev, voice, value) \
  709. SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER, value)
  710. #define SEQ_BENDER_RANGE(dev, voice, value) \
  711. SEQ_V2_X_CONTROL(dev, voice, CTRL_PITCH_BENDER_RANGE, value)
  712. #define SEQ_EXPRESSION(dev, voice, value) \
  713. SEQ_CONTROL(dev, voice, CTL_EXPRESSION, value*128)
  714. #define SEQ_MAIN_VOLUME(dev, voice, value) \
  715. SEQ_CONTROL(dev, voice, CTL_MAIN_VOLUME, (value*16383)/100)
  716. #define SEQ_PANNING(dev, voice, pos) \
  717. SEQ_CONTROL(dev, voice, CTL_PAN, (pos+128) / 2)
  718. /*
  719. * Timing and syncronization macros
  720. */
  721. #define _TIMER_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
  722. _seqbuf[_seqbufptr+0] = EV_TIMING; \
  723. _seqbuf[_seqbufptr+1] = (ev); \
  724. _seqbuf[_seqbufptr+2] = 0;\
  725. _seqbuf[_seqbufptr+3] = 0;\
  726. *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
  727. _SEQ_ADVBUF(8);}
  728. #define SEQ_START_TIMER() _TIMER_EVENT(TMR_START, 0)
  729. #define SEQ_STOP_TIMER() _TIMER_EVENT(TMR_STOP, 0)
  730. #define SEQ_CONTINUE_TIMER() _TIMER_EVENT(TMR_CONTINUE, 0)
  731. #define SEQ_WAIT_TIME(ticks) _TIMER_EVENT(TMR_WAIT_ABS, ticks)
  732. #define SEQ_DELTA_TIME(ticks) _TIMER_EVENT(TMR_WAIT_REL, ticks)
  733. #define SEQ_ECHO_BACK(key) _TIMER_EVENT(TMR_ECHO, key)
  734. #define SEQ_SET_TEMPO(value) _TIMER_EVENT(TMR_TEMPO, value)
  735. #define SEQ_SONGPOS(pos) _TIMER_EVENT(TMR_SPP, pos)
  736. #define SEQ_TIME_SIGNATURE(sig) _TIMER_EVENT(TMR_TIMESIG, sig)
  737. /*
  738. * Local control events
  739. */
  740. #define _LOCAL_EVENT(ev, parm) {_SEQ_NEEDBUF(8);\
  741. _seqbuf[_seqbufptr+0] = EV_SEQ_LOCAL; \
  742. _seqbuf[_seqbufptr+1] = (ev); \
  743. _seqbuf[_seqbufptr+2] = 0;\
  744. _seqbuf[_seqbufptr+3] = 0;\
  745. *(unsigned int *)&_seqbuf[_seqbufptr+4] = (parm); \
  746. _SEQ_ADVBUF(8);}
  747. #define SEQ_PLAYAUDIO(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO, devmask)
  748. #define SEQ_PLAYAUDIO2(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO2, devmask)
  749. #define SEQ_PLAYAUDIO3(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO3, devmask)
  750. #define SEQ_PLAYAUDIO4(devmask) _LOCAL_EVENT(LOCL_STARTAUDIO4, devmask)
  751. /*
  752. * Events for the level 1 interface only
  753. */
  754. #define SEQ_MIDIOUT(device, byte) {_SEQ_NEEDBUF(4);\
  755. _seqbuf[_seqbufptr] = SEQ_MIDIPUTC;\
  756. _seqbuf[_seqbufptr+1] = (byte);\
  757. _seqbuf[_seqbufptr+2] = (device);\
  758. _seqbuf[_seqbufptr+3] = 0;\
  759. _SEQ_ADVBUF(4);}
  760. /*
  761. * Patch loading.
  762. */
  763. #ifdef OSSLIB
  764. # define SEQ_WRPATCH(patchx, len) \
  765. OSS_write_patch(seqfd, (char*)(patchx), len)
  766. # define SEQ_WRPATCH2(patchx, len) \
  767. OSS_write_patch2(seqfd, (char*)(patchx), len)
  768. #else
  769. # define SEQ_WRPATCH(patchx, len) \
  770. {if (_seqbufptr) SEQ_DUMPBUF();\
  771. if (write(seqfd, (char*)(patchx), len)==-1) \
  772. perror("Write patch: /dev/sequencer");}
  773. # define SEQ_WRPATCH2(patchx, len) \
  774. (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len))
  775. #endif
  776. #endif
  777. #endif /* ifndef DISABLE_SEQUENCER */
  778. /*
  779. ****************************************************************************
  780. * ioctl commands for the /dev/midi##
  781. ****************************************************************************/
  782. #define SNDCTL_MIDI_PRETIME __SIOWR('m', 0, int)
  783. #if 0
  784. /*
  785. * The SNDCTL_MIDI_MPUMODE and SNDCTL_MIDI_MPUCMD calls
  786. * are completely obsolete. The hardware device (MPU-401 "intelligent mode"
  787. * and compatibles) has disappeared from the market 10 years ago so there
  788. * is no need for this stuff. The MPU-401 "UART" mode devices don't support
  789. * this stuff.
  790. */
  791. typedef struct
  792. {
  793. unsigned char cmd;
  794. char nr_args, nr_returns;
  795. unsigned char data[30];
  796. } mpu_command_rec;
  797. #define SNDCTL_MIDI_MPUMODE __SIOWR('m', 1, int)
  798. #define SNDCTL_MIDI_MPUCMD __SIOWR('m', 2, mpu_command_rec)
  799. #endif
  800. /*
  801. * SNDCTL_MIDI_MTCINPUT turns on a mode where OSS automatically inserts
  802. * MTC quarter frame messages (F1 xx) to the input.
  803. * The argument is the MTC mode:
  804. *
  805. * -1 = Turn MTC messages OFF (default)
  806. * 24 = 24 FPS
  807. * 25 = 25 FPS
  808. * 29 = 30 FPS drop frame
  809. * 30 = 30 FPS
  810. *
  811. * Note that 25 FPS mode is probably the only mode that is supported. Other
  812. * modes may be supported in the future versions of OSS, 25 FPS is handy
  813. * because it generates 25*4=100 quarter frame messages per second which
  814. * matches the usual 100 HZ system timer rate).
  815. *
  816. * The quarter frame timer will be reset to 0:00:00:00.0 at the moment this
  817. * ioctl is made.
  818. */
  819. #define SNDCTL_MIDI_MTCINPUT __SIOWR('m', 3, int)
  820. /*
  821. * MTC/SMPTE time code record (for future use)
  822. */
  823. typedef struct
  824. {
  825. unsigned char hours, minutes, seconds, frames, qframes;
  826. char direction;
  827. #define MTC_DIR_STOPPED 0
  828. #define MTC_DIR_FORWARD 1
  829. #define MTC_DIR_BACKWARD -1
  830. unsigned char time_code_type;
  831. unsigned int flags;
  832. } oss_mtc_data_t;
  833. #define SNDCTL_MIDI_SETMODE __SIOWR('m', 6, int)
  834. # define MIDI_MODE_TRADITIONAL 0
  835. # define MIDI_MODE_TIMED 1 /* Input times are in MIDI ticks */
  836. # define MIDI_MODE_TIMED_ABS 2 /* Input times are absolute (usecs) */
  837. /*
  838. * Packet header for MIDI_MODE_TIMED and MIDI_MODE_TIMED_ABS
  839. */
  840. typedef unsigned long long oss_midi_time_t; /* Variable type for MIDI time (clock ticks) */
  841. typedef struct
  842. {
  843. int magic; /* Initialize to MIDI_HDR_MAGIC */
  844. #define MIDI_HDR_MAGIC -1
  845. unsigned short event_type;
  846. #define MIDI_EV_WRITE 0 /* Write or read (with payload) */
  847. #define MIDI_EV_TEMPO 1
  848. #define MIDI_EV_ECHO 2
  849. #define MIDI_EV_START 3
  850. #define MIDI_EV_STOP 4
  851. #define MIDI_EV_CONTINUE 5
  852. #define MIDI_EV_XPRESSWRITE 6
  853. #define MIDI_EV_TIMEBASE 7
  854. #define MIDI_EV_DEVCTL 8 /* Device control read/write */
  855. unsigned short options;
  856. #define MIDI_OPT_NONE 0x0000
  857. #define MIDI_OPT_TIMED 0x0001
  858. #define MIDI_OPT_CONTINUATION 0x0002
  859. #define MIDI_OPT_USECTIME 0x0004 /* Time is absolute (in usecs) */
  860. #define MIDI_OPT_BUSY 0x0008 /* Reserved for internal use */
  861. oss_midi_time_t time;
  862. int parm;
  863. int filler[3]; /* Fur future expansion - init to zeros */
  864. } midi_packet_header_t;
  865. /*
  866. * MIDI_PAYLOAD_SIZE is the maximum size of one MIDI input chunk. It must be
  867. * less (or equal) than 1024 which is the read size recommended in the
  868. * documentation. TODO: Explain this better.
  869. */
  870. #define MIDI_PAYLOAD_SIZE 1000
  871. typedef struct
  872. {
  873. midi_packet_header_t hdr;
  874. unsigned char payload[MIDI_PAYLOAD_SIZE];
  875. } midi_packet_t;
  876. #define SNDCTL_MIDI_TIMEBASE __SIOWR('m', 7, int)
  877. #define SNDCTL_MIDI_TEMPO __SIOWR('m', 8, int)
  878. /*
  879. * User land MIDI servers (synths) can use SNDCTL_MIDI_SET_LATENCY
  880. * to request MIDI events to be sent to them in advance. The parameter
  881. * (in microseconds) tells how much before the events are submitted.
  882. *
  883. * This feature is only valid for loopback devices and possibly some other
  884. * types of virtual devices.
  885. */
  886. #define SNDCTL_MIDI_SET_LATENCY __SIOW ('m', 9, int)
  887. /*
  888. ****************************************************************************
  889. * IOCTL commands for /dev/dsp
  890. ****************************************************************************/
  891. #define SNDCTL_DSP_HALT __SIO ('P', 0)
  892. #define SNDCTL_DSP_RESET SNDCTL_DSP_HALT /* Old name */
  893. #define SNDCTL_DSP_SYNC __SIO ('P', 1)
  894. #define SNDCTL_DSP_SPEED __SIOWR('P', 2, int)
  895. /* SNDCTL_DSP_STEREO is obsolete - use SNDCTL_DSP_CHANNELS instead */
  896. #define SNDCTL_DSP_STEREO __SIOWR('P', 3, int)
  897. /* SNDCTL_DSP_STEREO is obsolete - use SNDCTL_DSP_CHANNELS instead */
  898. #define SNDCTL_DSP_GETBLKSIZE __SIOWR('P', 4, int)
  899. #define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT
  900. #define SNDCTL_DSP_CHANNELS __SIOWR('P', 6, int)
  901. #define SNDCTL_DSP_POST __SIO ('P', 8)
  902. #define SNDCTL_DSP_SUBDIVIDE __SIOWR('P', 9, int)
  903. #define SNDCTL_DSP_SETFRAGMENT __SIOWR('P',10, int)
  904. /* Audio data formats (Note! U8=8 and S16_LE=16 for compatibility) */
  905. #define SNDCTL_DSP_GETFMTS __SIOR ('P',11, int) /* Returns a mask */
  906. #define SNDCTL_DSP_SETFMT __SIOWR('P',5, int) /* Selects ONE fmt */
  907. # define AFMT_QUERY 0x00000000 /* Return current fmt */
  908. # define AFMT_MU_LAW 0x00000001
  909. # define AFMT_A_LAW 0x00000002
  910. # define AFMT_IMA_ADPCM 0x00000004
  911. # define AFMT_U8 0x00000008
  912. # define AFMT_S16_LE 0x00000010 /* Little endian signed 16 */
  913. # define AFMT_S16_BE 0x00000020 /* Big endian signed 16 */
  914. # define AFMT_S8 0x00000040
  915. # define AFMT_U16_LE 0x00000080 /* Little endian U16 */
  916. # define AFMT_U16_BE 0x00000100 /* Big endian U16 */
  917. # define AFMT_MPEG 0x00000200 /* MPEG (2) audio */
  918. /* AC3 _compressed_ bitstreams (See Programmer's Guide for details). */
  919. # define AFMT_AC3 0x00000400
  920. /* Ogg Vorbis _compressed_ bit streams */
  921. # define AFMT_VORBIS 0x00000800
  922. /* 32 bit formats (MSB aligned) formats */
  923. # define AFMT_S32_LE 0x00001000
  924. # define AFMT_S32_BE 0x00002000
  925. /* Reserved for _native_ endian double precision IEEE floating point */
  926. # define AFMT_FLOAT 0x00004000
  927. /* 24 bit formats (LSB aligned in 32 bit word) formats */
  928. # define AFMT_S24_LE 0x00008000
  929. # define AFMT_S24_BE 0x00010000
  930. /*
  931. * S/PDIF raw format. In this format the S/PDIF frames (including all
  932. * control and user bits) are included in the data stream. Each sample
  933. * is stored in a 32 bit frame (see IEC-958 for more info). This format
  934. * is supported by very few devices and it's only usable for purposes
  935. * where full access to the control/user bits is required (real time control).
  936. */
  937. # define AFMT_SPDIF_RAW 0x00020000
  938. /* 24 bit packed (3 byte) little endian format (USB compatibility) */
  939. # define AFMT_S24_PACKED 0x00040000
  940. /*
  941. * Some big endian/little endian handling macros (native endian and opposite
  942. * endian formats). The usage of these macros is described in the OSS
  943. * Programmer's Manual.
  944. */
  945. #if defined(_AIX) || defined(AIX) || defined(sparc) || defined(__hppa) || defined(PPC) || defined(__powerpc__) && !defined(i386) && !defined(__i386) && !defined(__i386__)
  946. /* Big endian machines */
  947. # define _PATCHKEY(id) (0xfd00|id)
  948. # define AFMT_S16_NE AFMT_S16_BE
  949. # define AFMT_U16_NE AFMT_U16_BE
  950. # define AFMT_S32_NE AFMT_S32_BE
  951. # define AFMT_S24_NE AFMT_S24_BE
  952. # define AFMT_S16_OE AFMT_S16_LE
  953. # define AFMT_S32_OE AFMT_S32_LE
  954. # define AFMT_S24_OE AFMT_S24_LE
  955. #else
  956. # define _PATCHKEY(id) ((id<<8)|0xfd)
  957. # define AFMT_S16_NE AFMT_S16_LE
  958. # define AFMT_U16_NE AFMT_U16_LE
  959. # define AFMT_S32_NE AFMT_S32_LE
  960. # define AFMT_S24_NE AFMT_S24_LE
  961. # define AFMT_S16_OE AFMT_S16_BE
  962. # define AFMT_S32_OE AFMT_S32_BE
  963. # define AFMT_S24_OE AFMT_S24_BE
  964. #endif
  965. /*
  966. * Buffer status queries.
  967. */
  968. typedef struct audio_buf_info
  969. {
  970. int fragments; /* # of available fragments (partially usend ones not counted) */
  971. int fragstotal; /* Total # of fragments allocated */
  972. int fragsize; /* Size of a fragment in bytes */
  973. int bytes; /* Available space in bytes (includes partially used fragments) */
  974. /* Note! 'bytes' could be more than fragments*fragsize */
  975. } audio_buf_info;
  976. #define SNDCTL_DSP_GETOSPACE __SIOR ('P',12, audio_buf_info)
  977. #define SNDCTL_DSP_GETISPACE __SIOR ('P',13, audio_buf_info)
  978. #define SNDCTL_DSP_GETCAPS __SIOR ('P',15, int)
  979. # define PCM_CAP_REVISION 0x000000ff /* Bits for revision level (0 to 255) */
  980. # define PCM_CAP_DUPLEX 0x00000100 /* Full duplex record/playback */
  981. # define PCM_CAP_REALTIME 0x00000200 /* Not in use */
  982. # define PCM_CAP_BATCH 0x00000400 /* Device has some kind of */
  983. /* internal buffers which may */
  984. /* cause some delays and */
  985. /* decrease precision of timing */
  986. # define PCM_CAP_COPROC 0x00000800 /* Has a coprocessor */
  987. /* Sometimes it's a DSP */
  988. /* but usually not */
  989. # define PCM_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */
  990. # define PCM_CAP_MMAP 0x00002000 /* Supports mmap() */
  991. # define PCM_CAP_MULTI 0x00004000 /* Supports multiple open */
  992. # define PCM_CAP_BIND 0x00008000 /* Supports binding to front/rear/center/lfe */
  993. # define PCM_CAP_INPUT 0x00010000 /* Supports recording */
  994. # define PCM_CAP_OUTPUT 0x00020000 /* Supports playback */
  995. # define PCM_CAP_VIRTUAL 0x00040000 /* Virtuial device */
  996. /* 0x00040000 and 0x00080000 reserved for future use */
  997. /* Analog/digital control capabilities */
  998. # define PCM_CAP_ANALOGOUT 0x00100000
  999. # define PCM_CAP_ANALOGIN 0x00200000
  1000. # define PCM_CAP_DIGITALOUT 0x00400000
  1001. # define PCM_CAP_DIGITALIN 0x00800000
  1002. # define PCM_CAP_ADMASK 0x00f00000
  1003. /*
  1004. * NOTE! (capabilities & PCM_CAP_ADMASK)==0 means just that the
  1005. * digital/analog interface control features are not supported by the
  1006. * device/driver. However the device still supports analog, digital or
  1007. * both inputs/outputs (depending on the device). See the OSS Programmer's
  1008. * Guide for full details.
  1009. */
  1010. # define PCM_CAP_SHADOW 0x01000000 /* "Shadow" device */
  1011. /*
  1012. * Preferred channel usage. These bits can be used to
  1013. * give recommendations to the application. Used by few drivers.
  1014. * For example if ((caps & DSP_CH_MASK) == DSP_CH_MONO) means that
  1015. * the device works best in mono mode. However it doesn't necessarily mean
  1016. * that the device cannot be used in stereo. These bits should only be used
  1017. * special applications such as multi track hard disk recorders to find out
  1018. * the initial setup. However the user should be able to override this
  1019. * selection.
  1020. *
  1021. * To find out which modes are actually supported the application should
  1022. * try to select them using SNDCTL_DSP_CHANNELS.
  1023. */
  1024. # define DSP_CH_MASK 0x06000000 /* Mask */
  1025. # define DSP_CH_ANY 0x00000000 /* No preferred mode */
  1026. # define DSP_CH_MONO 0x02000000
  1027. # define DSP_CH_STEREO 0x04000000
  1028. # define DSP_CH_MULTI 0x06000000 /* More than two channels */
  1029. # define PCM_CAP_HIDDEN 0x08000000 /* Hidden device */
  1030. # define PCM_CAP_FREERATE 0x10000000
  1031. # define PCM_CAP_MODEM 0x20000000 /* Modem device */
  1032. # define PCM_CAP_DEFAULT 0x40000000 /* "Default" device */
  1033. /*
  1034. * The PCM_CAP_* capability names were known as DSP_CAP_* prior OSS 4.0
  1035. * so it's necessary to define the older names too.
  1036. */
  1037. #define DSP_CAP_ADMASK PCM_CAP_ADMASK
  1038. #define DSP_CAP_ANALOGIN PCM_CAP_ANALOGIN
  1039. #define DSP_CAP_ANALOGOUT PCM_CAP_ANALOGOUT
  1040. #define DSP_CAP_BATCH PCM_CAP_BATCH
  1041. #define DSP_CAP_BIND PCM_CAP_BIND
  1042. #define DSP_CAP_COPROC PCM_CAP_COPROC
  1043. #define DSP_CAP_DEFAULT PCM_CAP_DEFAULT
  1044. #define DSP_CAP_DIGITALIN PCM_CAP_DIGITALIN
  1045. #define DSP_CAP_DIGITALOUT PCM_CAP_DIGITALOUT
  1046. #define DSP_CAP_DUPLEX PCM_CAP_DUPLEX
  1047. #define DSP_CAP_FREERATE PCM_CAP_FREERATE
  1048. #define DSP_CAP_HIDDEN PCM_CAP_HIDDEN
  1049. #define DSP_CAP_INPUT PCM_CAP_INPUT
  1050. #define DSP_CAP_MMAP PCM_CAP_MMAP
  1051. #define DSP_CAP_MODEM PCM_CAP_MODEM
  1052. #define DSP_CAP_MULTI PCM_CAP_MULTI
  1053. #define DSP_CAP_OUTPUT PCM_CAP_OUTPUT
  1054. #define DSP_CAP_REALTIME PCM_CAP_REALTIME
  1055. #define DSP_CAP_REVISION PCM_CAP_REVISION
  1056. #define DSP_CAP_SHADOW PCM_CAP_SHADOW
  1057. #define DSP_CAP_TRIGGER PCM_CAP_TRIGGER
  1058. #define DSP_CAP_VIRTUAL PCM_CAP_VIRTUAL
  1059. #define SNDCTL_DSP_GETTRIGGER __SIOR ('P',16, int)
  1060. #define SNDCTL_DSP_SETTRIGGER __SIOW ('P',16, int)
  1061. # define PCM_ENABLE_INPUT 0x00000001
  1062. # define PCM_ENABLE_OUTPUT 0x00000002
  1063. typedef struct count_info
  1064. {
  1065. unsigned int bytes; /* Total # of bytes processed */
  1066. int blocks; /* # of fragment transitions since last time */
  1067. int ptr; /* Current DMA pointer value */
  1068. } count_info;
  1069. #define SNDCTL_DSP_GETIPTR __SIOR ('P',17, count_info)
  1070. #define SNDCTL_DSP_GETOPTR __SIOR ('P',18, count_info)
  1071. typedef struct buffmem_desc
  1072. {
  1073. unsigned *buffer;
  1074. int size;
  1075. } buffmem_desc;
  1076. #define SNDCTL_DSP_SETSYNCRO __SIO ('P', 21)
  1077. #define SNDCTL_DSP_SETDUPLEX __SIO ('P', 22)
  1078. #define SNDCTL_DSP_PROFILE __SIOW ('P', 23, int) /* OBSOLETE */
  1079. #define APF_NORMAL 0 /* Normal applications */
  1080. #define APF_NETWORK 1 /* Underruns probably caused by an "external" delay */
  1081. #define APF_CPUINTENS 2 /* Underruns probably caused by "overheating" the CPU */
  1082. #define SNDCTL_DSP_GETODELAY __SIOR ('P', 23, int)
  1083. typedef struct audio_errinfo
  1084. {
  1085. int play_underruns;
  1086. int rec_overruns;
  1087. unsigned int play_ptradjust;
  1088. unsigned int rec_ptradjust;
  1089. int play_errorcount;
  1090. int rec_errorcount;
  1091. int play_lasterror;
  1092. int rec_lasterror;
  1093. int play_errorparm;
  1094. int rec_errorparm;
  1095. int filler[16];
  1096. } audio_errinfo;
  1097. #define SNDCTL_DSP_GETPLAYVOL __SIOR ('P', 24, int)
  1098. #define SNDCTL_DSP_SETPLAYVOL __SIOWR('P', 24, int)
  1099. #define SNDCTL_DSP_GETERROR __SIOR ('P', 25, audio_errinfo)
  1100. /*
  1101. ****************************************************************************
  1102. * Digital interface (S/PDIF) control interface
  1103. */
  1104. typedef struct oss_digital_control
  1105. {
  1106. unsigned int caps;
  1107. #define DIG_CBITIN_NONE 0x00000000
  1108. #define DIG_CBITIN_LIMITED 0x00000001
  1109. #define DIG_CBITIN_DATA 0x00000002
  1110. #define DIG_CBITIN_BYTE0 0x00000004
  1111. #define DIG_CBITIN_FULL 0x00000008
  1112. #define DIG_CBITIN_MASK 0x0000000f
  1113. #define DIG_CBITOUT_NONE 0x00000000
  1114. #define DIG_CBITOUT_LIMITED 0x00000010
  1115. #define DIG_CBITOUT_BYTE0 0x00000020
  1116. #define DIG_CBITOUT_FULL 0x00000040
  1117. #define DIG_CBITOUT_DATA 0x00000080
  1118. #define DIG_CBITOUT_MASK 0x000000f0
  1119. #define DIG_UBITIN 0x00000100
  1120. #define DIG_UBITOUT 0x00000200
  1121. #define DIG_VBITOUT 0x00000400
  1122. #define DIG_OUTRATE 0x00000800
  1123. #define DIG_INRATE 0x00001000
  1124. #define DIG_INBITS 0x00002000
  1125. #define DIG_OUTBITS 0x00004000
  1126. #define DIG_EXACT 0x00010000
  1127. #define DIG_PRO 0x00020000
  1128. #define DIG_CONSUMER 0x00040000
  1129. #define DIG_PASSTHROUGH 0x00080000
  1130. #define DIG_OUTSEL 0x00100000
  1131. unsigned int valid;
  1132. #define VAL_CBITIN 0x00000001
  1133. #define VAL_UBITIN 0x00000002
  1134. #define VAL_CBITOUT 0x00000004
  1135. #define VAL_UBITOUT 0x00000008
  1136. #define VAL_ISTATUS 0x00000010
  1137. #define VAL_IRATE 0x00000020
  1138. #define VAL_ORATE 0x00000040
  1139. #define VAL_INBITS 0x00000080
  1140. #define VAL_OUTBITS 0x00000100
  1141. #define VAL_REQUEST 0x00000200
  1142. #define VAL_OUTSEL 0x00000400
  1143. #define VAL_OUTMASK (VAL_CBITOUT|VAL_UBITOUT|VAL_ORATE|VAL_OUTBITS|VAL_OUTSEL)
  1144. unsigned int request, param;
  1145. #define SPD_RQ_PASSTHROUGH 1
  1146. unsigned char cbitin[24];
  1147. unsigned char ubitin[24];
  1148. unsigned char cbitout[24];
  1149. unsigned char ubitout[24];
  1150. unsigned int outsel;
  1151. #define OUTSEL_DIGITAL 1
  1152. #define OUTSEL_ANALOG 2
  1153. #define OUTSEL_BOTH (OUTSEL_DIGITAL|OUTSEL_ANALOG)
  1154. int in_data; /* Audio/data if autodetectable by the receiver */
  1155. #define IND_UNKNOWN 0
  1156. #define IND_AUDIO 1
  1157. #define IND_DATA 2
  1158. int in_locked; /* Receiver locked */
  1159. #define LOCK_NOT_INDICATED 0
  1160. #define LOCK_UNLOCKED 1
  1161. #define LOCK_LOCKED 2
  1162. int in_quality; /* Input signal quality */
  1163. #define IN_QUAL_NOT_INDICATED 0
  1164. #define IN_QUAL_POOR 1
  1165. #define IN_QUAL_GOOD 2
  1166. int in_vbit, out_vbit; /* V bits */
  1167. #define VBIT_NOT_INDICATED 0
  1168. #define VBIT_OFF 1
  1169. #define VBIT_ON 2
  1170. unsigned int in_errors; /* Various input errro conditions */
  1171. #define INERR_CRC 0x0001
  1172. #define INERR_QCODE_CRC 0x0002
  1173. #define INERR_PARITY 0x0004
  1174. #define INERR_BIPHASE 0x0008
  1175. int srate_in, srate_out;
  1176. int bits_in, bits_out;
  1177. int filler[32];
  1178. } oss_digital_control;
  1179. #define SNDCTL_DSP_READCTL __SIOWR('P', 26, oss_digital_control)
  1180. #define SNDCTL_DSP_WRITECTL __SIOWR('P', 27, oss_digital_control)
  1181. /*
  1182. ****************************************************************************
  1183. * Sync groups for audio devices
  1184. */
  1185. typedef struct oss_syncgroup
  1186. {
  1187. int id;
  1188. int mode;
  1189. int filler[16];
  1190. } oss_syncgroup;
  1191. #define SNDCTL_DSP_SYNCGROUP __SIOWR('P', 28, oss_syncgroup)
  1192. #define SNDCTL_DSP_SYNCSTART __SIOW ('P', 29, int)
  1193. /*
  1194. **************************************************************************
  1195. * "cooked" mode enables software based conversions for sample rate, sample
  1196. * format (bits) and number of channels (mono/stereo). These conversions are
  1197. * required with some devices that support only one sample rate or just stereo
  1198. * to let the applications to use other formats. The cooked mode is enabled by
  1199. * default. However it's necessary to disable this mode when mmap() is used or
  1200. * when very deterministic timing is required. SNDCTL_DSP_COOKEDMODE is an
  1201. * optional call introduced in OSS 3.9.6f. It's _error return must be ignored_
  1202. * since normally this call will return erno=EINVAL.
  1203. *
  1204. * SNDCTL_DSP_COOKEDMODE must be called immediately after open before doing
  1205. * anything else. Otherwise the call will not have any effect.
  1206. */
  1207. #define SNDCTL_DSP_COOKEDMODE __SIOW ('P', 30, int)
  1208. /*
  1209. **************************************************************************
  1210. * SNDCTL_DSP_SILENCE and SNDCTL_DSP_SKIP are new calls in OSS 3.99.0
  1211. * that can be used to implement pause/continue during playback (no effect
  1212. * on recording).
  1213. */
  1214. #define SNDCTL_DSP_SILENCE __SIO ('P', 31)
  1215. #define SNDCTL_DSP_SKIP __SIO ('P', 32)
  1216. /*
  1217. ****************************************************************************
  1218. * Abort transfer (reset) functions for input and output
  1219. */
  1220. #define SNDCTL_DSP_HALT_INPUT __SIO ('P', 33)
  1221. #define SNDCTL_DSP_RESET_INPUT SNDCTL_DSP_HALT_INPUT /* Old name */
  1222. #define SNDCTL_DSP_HALT_OUTPUT __SIO ('P', 34)
  1223. #define SNDCTL_DSP_RESET_OUTPUT SNDCTL_DSP_HALT_OUTPUT /* Old name */
  1224. /*
  1225. ****************************************************************************
  1226. * Low water level control
  1227. */
  1228. #define SNDCTL_DSP_LOW_WATER __SIOW ('P', 34, int)
  1229. /*
  1230. ****************************************************************************
  1231. * 64 bit pointer support. Only available in environments that support
  1232. * the 64 bit (long long) integer type.
  1233. */
  1234. #ifndef OSS_NO_LONG_LONG
  1235. typedef struct
  1236. {
  1237. long long samples;
  1238. int fifo_samples;
  1239. int filler[32]; /* For future use */
  1240. } oss_count_t;
  1241. #define SNDCTL_DSP_CURRENT_IPTR __SIOR ('P', 35, oss_count_t)
  1242. #define SNDCTL_DSP_CURRENT_OPTR __SIOR ('P', 36, oss_count_t)
  1243. #endif
  1244. /*
  1245. ****************************************************************************
  1246. * Interface for selecting recording sources and playback output routings.
  1247. */
  1248. #define SNDCTL_DSP_GET_RECSRC_NAMES __SIOR ('P', 37, oss_mixer_enuminfo)
  1249. #define SNDCTL_DSP_GET_RECSRC __SIOR ('P', 38, int)
  1250. #define SNDCTL_DSP_SET_RECSRC __SIOWR('P', 38, int)
  1251. #define SNDCTL_DSP_GET_PLAYTGT_NAMES __SIOR ('P', 39, oss_mixer_enuminfo)
  1252. #define SNDCTL_DSP_GET_PLAYTGT __SIOR ('P', 40, int)
  1253. #define SNDCTL_DSP_SET_PLAYTGT __SIOWR('P', 40, int)
  1254. #define SNDCTL_DSP_GETRECVOL __SIOR ('P', 41, int)
  1255. #define SNDCTL_DSP_SETRECVOL __SIOWR('P', 41, int)
  1256. /*
  1257. ***************************************************************************
  1258. * Some calls for setting the channel assignment with multi channel devices
  1259. * (see the manual for details).
  1260. */
  1261. #ifndef OSS_NO_LONG_LONG
  1262. #define SNDCTL_DSP_GET_CHNORDER __SIOR ('P', 42, unsigned long long)
  1263. #define SNDCTL_DSP_SET_CHNORDER __SIOWR('P', 42, unsigned long long)
  1264. # define CHID_UNDEF 0
  1265. # define CHID_L 1
  1266. # define CHID_R 2
  1267. # define CHID_C 3
  1268. # define CHID_LFE 4
  1269. # define CHID_LS 5
  1270. # define CHID_RS 6
  1271. # define CHID_LR 7
  1272. # define CHID_RR 8
  1273. #define CHNORDER_UNDEF 0x0000000000000000ULL
  1274. #define CHNORDER_NORMAL 0x0000000087654321ULL
  1275. #endif
  1276. #define MAX_PEAK_CHANNELS 128
  1277. typedef unsigned short oss_peaks_t[MAX_PEAK_CHANNELS];
  1278. #define SNDCTL_DSP_GETIPEAKS __SIOR('P', 43, oss_peaks_t)
  1279. #define SNDCTL_DSP_GETOPEAKS __SIOR('P', 44, oss_peaks_t)
  1280. #define SNDCTL_DSP_POLICY __SIOW('P', 45, int) /* See the manual */
  1281. /*
  1282. ****************************************************************************
  1283. * Few ioctl calls that are not official parts of OSS. They have been used
  1284. * by few freeware implementations of OSS.
  1285. */
  1286. #define SNDCTL_DSP_GETCHANNELMASK __SIOWR('P', 64, int)
  1287. #define SNDCTL_DSP_BIND_CHANNEL __SIOWR('P', 65, int)
  1288. # define DSP_BIND_QUERY 0x00000000
  1289. # define DSP_BIND_FRONT 0x00000001
  1290. # define DSP_BIND_SURR 0x00000002
  1291. # define DSP_BIND_CENTER_LFE 0x00000004
  1292. # define DSP_BIND_HANDSET 0x00000008
  1293. # define DSP_BIND_MIC 0x00000010
  1294. # define DSP_BIND_MODEM1 0x00000020
  1295. # define DSP_BIND_MODEM2 0x00000040
  1296. # define DSP_BIND_I2S 0x00000080
  1297. # define DSP_BIND_SPDIF 0x00000100
  1298. # define DSP_BIND_REAR 0x00000200
  1299. #ifndef NO_LEGACY_MIXER
  1300. /*
  1301. ****************************************************************************
  1302. * IOCTL commands for the "legacy " /dev/mixer API (obsolete)
  1303. *
  1304. * Mixer controls
  1305. *
  1306. * There can be up to 20 different analog mixer channels. The
  1307. * SOUND_MIXER_NRDEVICES gives the currently supported maximum.
  1308. * The SOUND_MIXER_READ_DEVMASK returns a bitmask which tells
  1309. * the devices supported by the particular mixer.
  1310. *
  1311. * {!notice This "legacy" mixer API is obsolete. It has been superceded
  1312. * by a new one (see below).
  1313. */
  1314. #define SOUND_MIXER_NRDEVICES 28
  1315. #define SOUND_MIXER_VOLUME 0
  1316. #define SOUND_MIXER_BASS 1
  1317. #define SOUND_MIXER_TREBLE 2
  1318. #define SOUND_MIXER_SYNTH 3
  1319. #define SOUND_MIXER_PCM 4
  1320. #define SOUND_MIXER_SPEAKER 5
  1321. #define SOUND_MIXER_LINE 6
  1322. #define SOUND_MIXER_MIC 7
  1323. #define SOUND_MIXER_CD 8
  1324. #define SOUND_MIXER_IMIX 9 /* Recording monitor */
  1325. #define SOUND_MIXER_ALTPCM 10
  1326. #define SOUND_MIXER_RECLEV 11 /* Recording level */
  1327. #define SOUND_MIXER_IGAIN 12 /* Input gain */
  1328. #define SOUND_MIXER_OGAIN 13 /* Output gain */
  1329. /*
  1330. * Some soundcards have three line level inputs (line, aux1 and aux2).
  1331. * Since each card manufacturer has assigned different meanings to
  1332. * these inputs, it's impractical to assign specific meanings
  1333. * (eg line, cd, synth etc.) to them.
  1334. */
  1335. #define SOUND_MIXER_LINE1 14 /* Input source 1 (aux1) */
  1336. #define SOUND_MIXER_LINE2 15 /* Input source 2 (aux2) */
  1337. #define SOUND_MIXER_LINE3 16 /* Input source 3 (line) */
  1338. #define SOUND_MIXER_DIGITAL1 17 /* Digital I/O 1 */
  1339. #define SOUND_MIXER_DIGITAL2 18 /* Digital I/O 2 */
  1340. #define SOUND_MIXER_DIGITAL3 19 /* Digital I/O 3 */
  1341. #define SOUND_MIXER_PHONE 20 /* Phone */
  1342. #define SOUND_MIXER_MONO 21 /* Mono Output */
  1343. #define SOUND_MIXER_VIDEO 22 /* Video/TV (audio) in */
  1344. #define SOUND_MIXER_RADIO 23 /* Radio in */
  1345. #define SOUND_MIXER_DEPTH 24 /* Surround depth */
  1346. #define SOUND_MIXER_REARVOL 25 /* Rear/Surround speaker vol */
  1347. #define SOUND_MIXER_CENTERVOL 26 /* Center/LFE speaker vol */
  1348. #define SOUND_MIXER_SIDEVOL 27 /* Side-Surround (8speaker) vol */
  1349. /*
  1350. * Warning: SOUND_MIXER_SURRVOL is an old name of SOUND_MIXER_SIDEVOL.
  1351. * They are both assigned to the same mixer control. Don't
  1352. * use both control names in the same program/driver.
  1353. */
  1354. #define SOUND_MIXER_SURRVOL SOUND_MIXER_SIDEVOL
  1355. /* Some on/off settings (SOUND_SPECIAL_MIN - SOUND_SPECIAL_MAX) */
  1356. /* Not counted to SOUND_MIXER_NRDEVICES, but use the same number space */
  1357. #define SOUND_ONOFF_MIN 28
  1358. #define SOUND_ONOFF_MAX 30
  1359. /* Note! Number 31 cannot be used since the sign bit is reserved */
  1360. #define SOUND_MIXER_NONE 31
  1361. /*
  1362. * The following unsupported macros are no longer functional.
  1363. * Use SOUND_MIXER_PRIVATE# macros in future.
  1364. */
  1365. #define SOUND_MIXER_ENHANCE SOUND_MIXER_NONE
  1366. #define SOUND_MIXER_MUTE SOUND_MIXER_NONE
  1367. #define SOUND_MIXER_LOUD SOUND_MIXER_NONE
  1368. #define SOUND_DEVICE_LABELS \
  1369. {"Vol ", "Bass ", "Treble", "Synth", "Pcm ", "Speaker ", "Line ", \
  1370. "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \
  1371. "Aux1", "Aux2", "Aux3", "Digital1", "Digital2", "Digital3", \
  1372. "Phone", "Mono", "Video", "Radio", "Depth", \
  1373. "Rear", "Center", "Side"}
  1374. #define SOUND_DEVICE_NAMES \
  1375. {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
  1376. "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
  1377. "aux1", "aux2", "aux3", "dig1", "dig2", "dig3", \
  1378. "phone", "mono", "video", "radio", "depth", \
  1379. "rear", "center", "side"}
  1380. /* Device bitmask identifiers */
  1381. #define SOUND_MIXER_RECSRC 0xff /* Arg contains a bit for each recording source */
  1382. #define SOUND_MIXER_DEVMASK 0xfe /* Arg contains a bit for each supported device */
  1383. #define SOUND_MIXER_RECMASK 0xfd /* Arg contains a bit for each supported recording source */
  1384. #define SOUND_MIXER_CAPS 0xfc
  1385. # define SOUND_CAP_EXCL_INPUT 0x00000001 /* Only one recording source at a time */
  1386. # define SOUND_CAP_NOLEGACY 0x00000004 /* For internal use only */
  1387. # define SOUND_CAP_NORECSRC 0x00000008
  1388. #define SOUND_MIXER_STEREODEVS 0xfb /* Mixer channels supporting stereo */
  1389. /* OSS/Free ONLY */
  1390. #define SOUND_MIXER_OUTSRC 0xfa /* Arg contains a bit for each input source to output */
  1391. #define SOUND_MIXER_OUTMASK 0xf9 /* Arg contains a bit for each supported input source to output */
  1392. /* OSS/Free ONLY */
  1393. /* Device mask bits */
  1394. #define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME)
  1395. #define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS)
  1396. #define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE)
  1397. #define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH)
  1398. #define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM)
  1399. #define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER)
  1400. #define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE)
  1401. #define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC)
  1402. #define SOUND_MASK_CD (1 << SOUND_MIXER_CD)
  1403. #define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX)
  1404. #define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM)
  1405. #define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV)
  1406. #define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN)
  1407. #define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN)
  1408. #define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1)
  1409. #define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2)
  1410. #define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3)
  1411. #define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1)
  1412. #define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2)
  1413. #define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3)
  1414. #define SOUND_MASK_MONO (1 << SOUND_MIXER_MONO)
  1415. #define SOUND_MASK_PHONE (1 << SOUND_MIXER_PHONE)
  1416. #define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO)
  1417. #define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO)
  1418. #define SOUND_MASK_DEPTH (1 << SOUND_MIXER_DEPTH)
  1419. #define SOUND_MASK_REARVOL (1 << SOUND_MIXER_REARVOL)
  1420. #define SOUND_MASK_CENTERVOL (1 << SOUND_MIXER_CENTERVOL)
  1421. #define SOUND_MASK_SIDEVOL (1 << SOUND_MIXER_SIDEVOL)
  1422. /* Note! SOUND_MASK_SURRVOL is alias of SOUND_MASK_SIDEVOL */
  1423. #define SOUND_MASK_SURRVOL (1 << SOUND_MIXER_SIDEVOL)
  1424. /* Obsolete macros */
  1425. #define SOUND_MASK_MUTE (1 << SOUND_MIXER_MUTE)
  1426. #define SOUND_MASK_ENHANCE (1 << SOUND_MIXER_ENHANCE)
  1427. #define SOUND_MASK_LOUD (1 << SOUND_MIXER_LOUD)
  1428. #define MIXER_READ(dev) __SIOR('M', dev, int)
  1429. #define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME)
  1430. #define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS)
  1431. #define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE)
  1432. #define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH)
  1433. #define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM)
  1434. #define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER)
  1435. #define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE)
  1436. #define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC)
  1437. #define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD)
  1438. #define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX)
  1439. #define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM)
  1440. #define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV)
  1441. #define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN)
  1442. #define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN)
  1443. #define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1)
  1444. #define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2)
  1445. #define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3)
  1446. /* Obsolete macros */
  1447. #define SOUND_MIXER_READ_MUTE MIXER_READ(SOUND_MIXER_MUTE)
  1448. #define SOUND_MIXER_READ_ENHANCE MIXER_READ(SOUND_MIXER_ENHANCE)
  1449. #define SOUND_MIXER_READ_LOUD MIXER_READ(SOUND_MIXER_LOUD)
  1450. #define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC)
  1451. #define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK)
  1452. #define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK)
  1453. #define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS)
  1454. #define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS)
  1455. #define MIXER_WRITE(dev) __SIOWR('M', dev, int)
  1456. #define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME)
  1457. #define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS)
  1458. #define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE)
  1459. #define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH)
  1460. #define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM)
  1461. #define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER)
  1462. #define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE)
  1463. #define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC)
  1464. #define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD)
  1465. #define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX)
  1466. #define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM)
  1467. #define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV)
  1468. #define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN)
  1469. #define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN)
  1470. #define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1)
  1471. #define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2)
  1472. #define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3)
  1473. /* Obsolete macros */
  1474. #define SOUND_MIXER_WRITE_MUTE MIXER_WRITE(SOUND_MIXER_MUTE)
  1475. #define SOUND_MIXER_WRITE_ENHANCE MIXER_WRITE(SOUND_MIXER_ENHANCE)
  1476. #define SOUND_MIXER_WRITE_LOUD MIXER_WRITE(SOUND_MIXER_LOUD)
  1477. #define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC)
  1478. typedef struct mixer_info /* OBSOLETE */
  1479. {
  1480. char id[16];
  1481. char name[32];
  1482. int modify_counter;
  1483. int card_number;
  1484. int port_number;
  1485. char handle[32];
  1486. } mixer_info;
  1487. /* SOUND_MIXER_INFO is obsolete - use SNDCTL_MIXERINFO instead */
  1488. #define SOUND_MIXER_INFO __SIOR ('M', 101, mixer_info)
  1489. /*
  1490. * Two ioctls for special souncard function (OSS/Free only)
  1491. */
  1492. #define SOUND_MIXER_AGC _SIOWR('M', 103, int)
  1493. #define SOUND_MIXER_3DSE _SIOWR('M', 104, int)
  1494. /*
  1495. * The SOUND_MIXER_PRIVATE# commands can be redefined by low level drivers.
  1496. * These features can be used when accessing device specific features.
  1497. */
  1498. #define SOUND_MIXER_PRIVATE1 __SIOWR('M', 111, int)
  1499. #define SOUND_MIXER_PRIVATE2 __SIOWR('M', 112, int)
  1500. #define SOUND_MIXER_PRIVATE3 __SIOWR('M', 113, int)
  1501. #define SOUND_MIXER_PRIVATE4 __SIOWR('M', 114, int)
  1502. #define SOUND_MIXER_PRIVATE5 __SIOWR('M', 115, int)
  1503. /* The following two controls were never implemented and they should not be used. */
  1504. #define SOUND_MIXER_READ_MAINVOL __SIOR ('M', 116, int)
  1505. #define SOUND_MIXER_WRITE_MAINVOL __SIOWR('M', 116, int)
  1506. /*
  1507. * SOUND_MIXER_GETLEVELS and SOUND_MIXER_SETLEVELS calls can be used
  1508. * for querying current mixer settings from the driver and for loading
  1509. * default volume settings _prior_ activating the mixer (loading
  1510. * doesn't affect current state of the mixer hardware). These calls
  1511. * are for internal use by the driver software only.
  1512. */
  1513. typedef struct mixer_vol_table
  1514. {
  1515. int num; /* Index to volume table */
  1516. char name[32];
  1517. int levels[32];
  1518. } mixer_vol_table;
  1519. #define SOUND_MIXER_GETLEVELS __SIOWR('M', 116, mixer_vol_table)
  1520. #define SOUND_MIXER_SETLEVELS __SIOWR('M', 117, mixer_vol_table)
  1521. #define OSS_GETVERSION __SIOR ('M', 118, int)
  1522. /*
  1523. * Calls to set/get the recording gain for the currently active
  1524. * recording source. These calls automatically map to the right control.
  1525. * Note that these calls are not supported by all drivers. In this case
  1526. * the call will return -1 with errno set to EINVAL
  1527. *
  1528. * The _MONGAIN work in similar way but set/get the monitoring gain for
  1529. * the currently selected recording source.
  1530. */
  1531. #define SOUND_MIXER_READ_RECGAIN __SIOR ('M', 119, int)
  1532. #define SOUND_MIXER_WRITE_RECGAIN __SIOWR('M', 119, int)
  1533. #define SOUND_MIXER_READ_MONGAIN __SIOR ('M', 120, int)
  1534. #define SOUND_MIXER_WRITE_MONGAIN __SIOWR('M', 120, int)
  1535. /* The following call is for driver development time purposes. It's not
  1536. * present in any released drivers.
  1537. */
  1538. typedef unsigned char oss_reserved_t[512];
  1539. #define SOUND_MIXER_RESERVED __SIOWR('M', 121, oss_reserved_t)
  1540. #endif /* ifndef NO_LEGACY_MIXER */
  1541. /*
  1542. *************************************************************************
  1543. * The "new" mixer API of OSS 4.0 and later.
  1544. *
  1545. * This improved mixer API makes it possible to access every possible feature
  1546. * of every possible device. However you should read the mixer programming
  1547. * section of the OSS API Developer's Manual. There is no chance that you
  1548. * could use this interface correctly just by examining this header.
  1549. */
  1550. typedef struct oss_sysinfo
  1551. {
  1552. char product[32]; /* For example OSS/Free, OSS/Linux or OSS/Solaris */
  1553. char version[32]; /* For example 4.0a */
  1554. int versionnum; /* See OSS_GETVERSION */
  1555. char options[128]; /* Reserved */
  1556. int numaudios; /* # of audio/dsp devices */
  1557. int openedaudio[8]; /* Bit mask telling which audio devices are busy */
  1558. int numsynths; /* # of availavle synth devices */
  1559. int nummidis; /* # of available MIDI ports */
  1560. int numtimers; /* # of available timer devices */
  1561. int nummixers; /* # of mixer devices */
  1562. int openedmidi[8]; /* Bit mask telling which midi devices are busy */
  1563. int numcards; /* Number of sound cards in the system */
  1564. int numaudioengines; /* Number of audio engines in the system */
  1565. int filler[240]; /* For future expansion (set to -1) */
  1566. } oss_sysinfo;
  1567. typedef struct oss_mixext
  1568. {
  1569. int dev; /* Mixer device number */
  1570. int ctrl; /* Controller number */
  1571. int type; /* Entry type */
  1572. # define MIXT_DEVROOT 0 /* Device root entry */
  1573. # define MIXT_GROUP 1 /* Controller group */
  1574. # define MIXT_ONOFF 2 /* OFF (0) or ON (1) */
  1575. # define MIXT_ENUM 3 /* Enumerated (0 to maxvalue) */
  1576. # define MIXT_MONOSLIDER 4 /* Mono slider (0 to 255) */
  1577. # define MIXT_STEREOSLIDER 5 /* Stereo slider (dual 0 to 255) */
  1578. # define MIXT_MESSAGE 6 /* (Readable) textual message */
  1579. # define MIXT_MONOVU 7 /* VU meter value (mono) */
  1580. # define MIXT_STEREOVU 8 /* VU meter value (stereo) */
  1581. # define MIXT_MONOPEAK 9 /* VU meter peak value (mono) */
  1582. # define MIXT_STEREOPEAK 10 /* VU meter peak value (stereo) */
  1583. # define MIXT_RADIOGROUP 11 /* Radio button group */
  1584. # define MIXT_MARKER 12 /* Separator between normal and extension entries */
  1585. # define MIXT_VALUE 13 /* Decimal value entry */
  1586. # define MIXT_HEXVALUE 14 /* Hexadecimal value entry */
  1587. # define MIXT_MONODB 15 /* OBSOLETE */
  1588. # define MIXT_STEREODB 16 /* OBSOLETE */
  1589. # define MIXT_SLIDER 17 /* Slider (mono) with full (31 bit) postitive integer range */
  1590. # define MIXT_3D 18
  1591. /*
  1592. * Sliders with range expanded to 15 bits per channel (0-32767)
  1593. */
  1594. # define MIXT_MONOSLIDER16 19
  1595. # define MIXT_STEREOSLIDER16 20
  1596. /* Possible value range (minvalue to maxvalue) */
  1597. /* Note that maxvalue may also be smaller than minvalue */
  1598. int maxvalue;
  1599. int minvalue;
  1600. int flags;
  1601. # define MIXF_READABLE 0x00000001 /* Has readable value */
  1602. # define MIXF_WRITEABLE 0x00000002 /* Has writeable value */
  1603. # define MIXF_POLL 0x00000004 /* May change itself */
  1604. # define MIXF_HZ 0x00000008 /* Herz scale */
  1605. # define MIXF_STRING 0x00000010 /* Use dynamic extensions for value */
  1606. # define MIXF_DYNAMIC 0x00000010 /* Supports dynamic extensions */
  1607. # define MIXF_OKFAIL 0x00000020 /* Interpret value as 1=OK, 0=FAIL */
  1608. # define MIXF_FLAT 0x00000040 /* Flat vertical space requirements */
  1609. # define MIXF_LEGACY 0x00000080 /* Legacy mixer control group */
  1610. # define MIXF_CENTIBEL 0x00000100 /* Centibel (0.1 dB) step size */
  1611. # define MIXF_DECIBEL 0x00000200 /* Step size of 1 dB */
  1612. # define MIXF_MAINVOL 0x00000400 /* Main volume control */
  1613. # define MIXF_PCMVOL 0x00000800 /* PCM output volume control */
  1614. # define MIXF_RECVOL 0x00001000 /* PCM recording volume control */
  1615. char id[16]; /* Mnemonic ID (mainly for internal use) */
  1616. int parent; /* Entry# of parent (group) node (-1 if root) */
  1617. int dummy; /* Internal use */
  1618. int timestamp;
  1619. char data[64]; /* Misc data (entry type dependent) */
  1620. unsigned char enum_present[32]; /* Mask of allowed enum values */
  1621. int control_no; /* SOUND_MIXER_VOLUME..SOUND_MIXER_MIDI */
  1622. /* (-1 means not indicated) */
  1623. /*
  1624. * The desc field is reserved for internal purposes of OSS. It should not be
  1625. * used by applications.
  1626. */
  1627. unsigned int desc;
  1628. #define MIXEXT_SCOPE_MASK 0x0000003f
  1629. #define MIXEXT_SCOPE_OTHER 0x00000000
  1630. #define MIXEXT_SCOPE_INPUT 0x00000001
  1631. #define MIXEXT_SCOPE_OUTPUT 0x00000002
  1632. #define MIXEXT_SCOPE_MONITOR 0x00000003
  1633. #define MIXEXT_SCOPE_RECSWITCH 0x00000004
  1634. char extname[32];
  1635. int update_counter;
  1636. int filler[7];
  1637. } oss_mixext;
  1638. typedef struct oss_mixext_root
  1639. {
  1640. char id[16];
  1641. char name[48];
  1642. } oss_mixext_root;
  1643. typedef struct oss_mixer_value
  1644. {
  1645. int dev;
  1646. int ctrl;
  1647. int value;
  1648. int flags; /* Reserved for future use. Initialize to 0 */
  1649. int timestamp; /* Must be set to oss_mixext.timestamp */
  1650. int filler[8]; /* Reserved for future use. Initialize to 0 */
  1651. } oss_mixer_value;
  1652. #define OSS_ENUM_MAXVALUE 255
  1653. typedef struct oss_mixer_enuminfo
  1654. {
  1655. int dev;
  1656. int ctrl;
  1657. int nvalues;
  1658. int version; /* Read the manual */
  1659. short strindex[OSS_ENUM_MAXVALUE];
  1660. char strings[3000];
  1661. } oss_mixer_enuminfo;
  1662. #define OPEN_READ PCM_ENABLE_INPUT
  1663. #define OPEN_WRITE PCM_ENABLE_OUTPUT
  1664. #define OPEN_READWRITE (OPEN_READ|OPEN_WRITE)
  1665. typedef struct oss_audioinfo
  1666. {
  1667. int dev; /* Audio device number */
  1668. char name[64];
  1669. int busy; /* 0, OPEN_READ, OPEN_WRITE or OPEN_READWRITE */
  1670. int pid;
  1671. int caps; /* PCM_CAP_INPUT, PCM_CAP_OUTPUT */
  1672. int iformats, oformats;
  1673. int magic; /* Reserved for internal use */
  1674. char cmd[64]; /* Command using the device (if known) */
  1675. int card_number;
  1676. int port_number;
  1677. int mixer_dev;
  1678. int legacy_device; /* Obsolete field. Replaced by devnode */
  1679. int enabled; /* 1=enabled, 0=device not ready at this moment */
  1680. int flags; /* For internal use only - no practical meaning */
  1681. int min_rate, max_rate; /* Sample rate limits */
  1682. int min_channels, max_channels; /* Number of channels supported */
  1683. int binding; /* DSP_BIND_FRONT, etc. 0 means undefined */
  1684. int rate_source;
  1685. char handle[32];
  1686. #define OSS_MAX_SAMPLE_RATES 20 /* Cannot be changed */
  1687. unsigned int nrates, rates[OSS_MAX_SAMPLE_RATES]; /* Please read the manual before using these */
  1688. oss_longname_t song_name; /* Song name (if given) */
  1689. oss_label_t label; /* Device label (if given) */
  1690. int latency; /* In usecs, -1=unknown */
  1691. oss_devnode_t devnode; /* Device special file name (absolute path) */
  1692. int next_play_engine; /* Read the documentation for more info */
  1693. int next_rec_engine; /* Read the documentation for more info */
  1694. int filler[184];
  1695. } oss_audioinfo;
  1696. typedef struct oss_mixerinfo
  1697. {
  1698. int dev;
  1699. char id[16];
  1700. char name[32];
  1701. int modify_counter;
  1702. int card_number;
  1703. int port_number;
  1704. char handle[32];
  1705. int magic; /* Reserved */
  1706. int enabled; /* Reserved */
  1707. int caps;
  1708. #define MIXER_CAP_VIRTUAL 0x00000001
  1709. #define MIXER_CAP_LAYOUT_B 0x00000002 /* For internal use only */
  1710. #define MIXER_CAP_NARROW 0x00000004 /* Conserve horiz space */
  1711. int flags; /* Reserved */
  1712. int nrext;
  1713. /*
  1714. * The priority field can be used to select the default (motherboard)
  1715. * mixer device. The mixer with the highest priority is the
  1716. * most preferred one. -2 or less means that this device cannot be used
  1717. * as the default mixer.
  1718. */
  1719. int priority;
  1720. oss_devnode_t devnode; /* Device special file name (absolute path) */
  1721. int legacy_device;
  1722. int filler[245]; /* Reserved */
  1723. } oss_mixerinfo;
  1724. typedef struct oss_midi_info
  1725. {
  1726. int dev; /* Midi device number */
  1727. char name[64];
  1728. int busy; /* 0, OPEN_READ, OPEN_WRITE or OPEN_READWRITE */
  1729. int pid;
  1730. char cmd[64]; /* Command using the device (if known) */
  1731. int caps;
  1732. #define MIDI_CAP_MPU401 0x00000001 /**** OBSOLETE ****/
  1733. #define MIDI_CAP_INPUT 0x00000002
  1734. #define MIDI_CAP_OUTPUT 0x00000004
  1735. #define MIDI_CAP_INOUT (MIDI_CAP_INPUT|MIDI_CAP_OUTPUT)
  1736. #define MIDI_CAP_VIRTUAL 0x00000008 /* Pseudo device */
  1737. #define MIDI_CAP_MTCINPUT 0x00000010 /* Supports SNDCTL_MIDI_MTCINPUT */
  1738. #define MIDI_CAP_CLIENT 0x00000020 /* Virtual client side device */
  1739. #define MIDI_CAP_SERVER 0x00000040 /* Virtual server side device */
  1740. #define MIDI_CAP_INTERNAL 0x00000080 /* Internal (synth) device */
  1741. #define MIDI_CAP_EXTERNAL 0x00000100 /* external (MIDI port) device */
  1742. #define MIDI_CAP_PTOP 0x00000200 /* Point to point link to one device */
  1743. #define MIDI_CAP_MTC 0x00000400 /* MTC/SMPTE (control) device */
  1744. int magic; /* Reserved for internal use */
  1745. int card_number;
  1746. int port_number;
  1747. int enabled; /* 1=enabled, 0=device not ready at this moment */
  1748. int flags; /* For internal use only - no practical meaning */
  1749. char handle[32];
  1750. oss_longname_t song_name; /* Song name (if known) */
  1751. oss_label_t label; /* Device label (if given) */
  1752. int latency; /* In usecs, -1=unknown */
  1753. oss_devnode_t devnode; /* Device special file name (absolute path) */
  1754. int legacy_device; /* Legacy device mapping */
  1755. int filler[235];
  1756. } oss_midi_info;
  1757. typedef struct oss_card_info
  1758. {
  1759. int card;
  1760. char shortname[16];
  1761. char longname[128];
  1762. int flags;
  1763. int filler[256];
  1764. } oss_card_info;
  1765. #define SNDCTL_SYSINFO __SIOR ('X', 1, oss_sysinfo)
  1766. #define OSS_SYSINFO SNDCTL_SYSINFO /* Old name */
  1767. #define SNDCTL_MIX_NRMIX __SIOR ('X', 2, int)
  1768. #define SNDCTL_MIX_NREXT __SIOWR('X', 3, int)
  1769. #define SNDCTL_MIX_EXTINFO __SIOWR('X', 4, oss_mixext)
  1770. #define SNDCTL_MIX_READ __SIOWR('X', 5, oss_mixer_value)
  1771. #define SNDCTL_MIX_WRITE __SIOWR('X', 6, oss_mixer_value)
  1772. #define SNDCTL_AUDIOINFO __SIOWR('X', 7, oss_audioinfo)
  1773. #define SNDCTL_MIX_ENUMINFO __SIOWR('X', 8, oss_mixer_enuminfo)
  1774. #define SNDCTL_MIDIINFO __SIOWR('X', 9, oss_midi_info)
  1775. #define SNDCTL_MIXERINFO __SIOWR('X',10, oss_mixerinfo)
  1776. #define SNDCTL_CARDINFO __SIOWR('X',11, oss_card_info)
  1777. #define SNDCTL_ENGINEINFO __SIOWR('X',12, oss_audioinfo)
  1778. #define SNDCTL_AUDIOINFO_EX __SIOWR('X',13, oss_audioinfo)
  1779. /* ioctl codes 'X', 200-255 are reserved for internal use */
  1780. /*
  1781. * Few more "globally" available ioctl calls.
  1782. */
  1783. #define SNDCTL_SETSONG __SIOW ('Y', 2, oss_longname_t)
  1784. #define SNDCTL_GETSONG __SIOR ('Y', 2, oss_longname_t)
  1785. #define SNDCTL_SETNAME __SIOW ('Y', 3, oss_longname_t)
  1786. #define SNDCTL_SETLABEL __SIOW ('Y', 4, oss_label_t)
  1787. #define SNDCTL_GETLABEL __SIOR ('Y', 4, oss_label_t)
  1788. /*
  1789. * The "new" mixer API definitions end here.
  1790. ***************************************
  1791. */
  1792. /*
  1793. *********************************************************
  1794. * Few routines that are included in -lOSSlib
  1795. *
  1796. * At this moment this interface is not used. OSSlib contains just
  1797. * stubs that call the related system calls directly.
  1798. */
  1799. #ifdef OSSLIB
  1800. extern int osslib_open (const char *path, int flags, int dummy);
  1801. extern void osslib_close (int fd);
  1802. extern int osslib_write (int fd, const void *buf, int count);
  1803. extern int osslib_read (int fd, void *buf, int count);
  1804. extern int osslib_ioctl (int fd, unsigned int request, void *arg);
  1805. #else
  1806. # define osslib_open open
  1807. # define osslib_close close
  1808. # define osslib_write write
  1809. # define osslib_read read
  1810. # define osslib_ioctl ioctl
  1811. #endif
  1812. #if 1
  1813. #define SNDCTL_DSP_NONBLOCK __SIO ('P',14) /* Obsolete. Not supported any more */
  1814. #endif
  1815. #if 1
  1816. /*
  1817. * Some obsolete macros that are not part of Open Sound System API.
  1818. */
  1819. #define SOUND_PCM_READ_RATE SOUND_PCM_READ_RATE_is_obsolete
  1820. #define SOUND_PCM_READ_BITS SOUND_PCM_READ_BITS_is_obsolete
  1821. #define SOUND_PCM_READ_CHANNELS SOUND_PCM_READ_CHANNELS_is_obsolete
  1822. #define SOUND_PCM_WRITE_RATE SOUND_PCM_WRITE_RATE_is_obsolet_use_SNDCTL_DSP_SPEED_instead
  1823. #define SOUND_PCM_WRITE_CHANNELS SOUND_PCM_WRITE_CHANNELS_is_obsolete_use_SNDCTL_DSP_CHANNELS_instead
  1824. #define SOUND_PCM_WRITE_BITS SOUND_PCM_WRITE_BITS_is_obsolete_use_SNDCTL_DSP_SETFMT_instead
  1825. #define SOUND_PCM_POST SOUND_PCM_POST_is_obsolete_use_SNDCTL_DSP_POST_instead
  1826. #define SOUND_PCM_RESET SOUND_PCM_RESET_is_obsolete_use_SNDCTL_DSP_HALT_instead
  1827. #define SOUND_PCM_SYNC SOUND_PCM_SYNC_is_obsolete_use_SNDCTL_DSP_SYNC_instead
  1828. #define SOUND_PCM_SUBDIVIDE SOUND_PCM_SUBDIVIDE_is_obsolete_use_SNDCTL_DSP_SUBDIVIDE_instead
  1829. #define SOUND_PCM_SETFRAGMENT SOUND_PCM_SETFRAGMENT_is_obsolete_use_SNDCTL_DSP_SETFRAGMENT_instead
  1830. #define SOUND_PCM_GETFMTS SOUND_PCM_GETFMTS_is_obsolete_use_SNDCTL_DSP_GETFMTS_instead
  1831. #define SOUND_PCM_SETFMT SOUND_PCM_SETFMT_is_obsolete_use_SNDCTL_DSP_SETFMT_instead
  1832. #define SOUND_PCM_GETOSPACE SOUND_PCM_GETOSPACE_is_obsolete_use_SNDCTL_DSP_GETOSPACE_instead
  1833. #define SOUND_PCM_GETISPACE SOUND_PCM_GETISPACE_is_obsolete_use_SNDCTL_DSP_GETISPACE_instead
  1834. #define SOUND_PCM_NONBLOCK SOUND_PCM_NONBLOCK_is_obsolete_use_SNDCTL_DSP_NONBLOCK_instead
  1835. #define SOUND_PCM_GETCAPS SOUND_PCM_GETCAPS_is_obsolete_use_SNDCTL_DSP_GETCAPS_instead
  1836. #define SOUND_PCM_GETTRIGGER SOUND_PCM_GETTRIGGER_is_obsolete_use_SNDCTL_DSP_GETTRIGGER_instead
  1837. #define SOUND_PCM_SETTRIGGER SOUND_PCM_SETTRIGGER_is_obsolete_use_SNDCTL_DSP_SETTRIGGER_instead
  1838. #define SOUND_PCM_SETSYNCRO SOUND_PCM_SETSYNCRO_is_obsolete_use_SNDCTL_DSP_SETSYNCRO_instead
  1839. #define SOUND_PCM_GETIPTR SOUND_PCM_GETIPTR_is_obsolete_use_SNDCTL_DSP_GETIPTR_instead
  1840. #define SOUND_PCM_GETOPTR SOUND_PCM_GETOPTR_is_obsolete_use_SNDCTL_DSP_GETOPTR_instead
  1841. #define SOUND_PCM_MAPINBUF SOUND_PCM_MAPINBUF_is_obsolete_use_SNDCTL_DSP_MAPINBUF_instead
  1842. #define SOUND_PCM_MAPOUTBUF SOUND_PCM_MAPOUTBUF_is_obsolete_use_SNDCTL_DSP_MAPOUTBUF_instead
  1843. #endif
  1844. #endif