dev_table.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. /*
  2. * dev_table.h
  3. *
  4. * Global definitions for device call tables
  5. *
  6. *
  7. * Copyright (C) by Hannu Savolainen 1993-1997
  8. *
  9. * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
  10. * Version 2 (June 1991). See the "COPYING" file distributed with this software
  11. * for more info.
  12. */
  13. #ifndef _DEV_TABLE_H_
  14. #define _DEV_TABLE_H_
  15. #include <linux/spinlock.h>
  16. /*
  17. * Sound card numbers 27 to 999. (1 to 26 are defined in soundcard.h)
  18. * Numbers 1000 to N are reserved for driver's internal use.
  19. */
  20. #define SNDCARD_DESKPROXL 27 /* Compaq Deskpro XL */
  21. #define SNDCARD_VIDC 28 /* ARMs VIDC */
  22. #define SNDCARD_SBPNP 29
  23. #define SNDCARD_SOFTOSS 36
  24. #define SNDCARD_VMIDI 37
  25. #define SNDCARD_OPL3SA1 38 /* Note: clash in msnd.h */
  26. #define SNDCARD_OPL3SA1_SB 39
  27. #define SNDCARD_OPL3SA1_MPU 40
  28. #define SNDCARD_WAVEFRONT 41
  29. #define SNDCARD_OPL3SA2 42
  30. #define SNDCARD_OPL3SA2_MPU 43
  31. #define SNDCARD_WAVEARTIST 44 /* Waveartist */
  32. #define SNDCARD_OPL3SA2_MSS 45 /* Originally missed */
  33. #define SNDCARD_AD1816 88
  34. /*
  35. * NOTE! NOTE! NOTE! NOTE!
  36. *
  37. * If you modify this file, please check the dev_table.c also.
  38. *
  39. * NOTE! NOTE! NOTE! NOTE!
  40. */
  41. struct driver_info
  42. {
  43. char *driver_id;
  44. int card_subtype; /* Driver specific. Usually 0 */
  45. int card_type; /* From soundcard.h */
  46. char *name;
  47. void (*attach) (struct address_info *hw_config);
  48. int (*probe) (struct address_info *hw_config);
  49. void (*unload) (struct address_info *hw_config);
  50. };
  51. struct card_info
  52. {
  53. int card_type; /* Link (search key) to the driver list */
  54. struct address_info config;
  55. int enabled;
  56. void *for_driver_use;
  57. };
  58. /*
  59. * Device specific parameters (used only by dmabuf.c)
  60. */
  61. #define MAX_SUB_BUFFERS (32*MAX_REALTIME_FACTOR)
  62. #define DMODE_NONE 0
  63. #define DMODE_OUTPUT PCM_ENABLE_OUTPUT
  64. #define DMODE_INPUT PCM_ENABLE_INPUT
  65. struct dma_buffparms
  66. {
  67. int dma_mode; /* DMODE_INPUT, DMODE_OUTPUT or DMODE_NONE */
  68. int closing;
  69. /*
  70. * Pointers to raw buffers
  71. */
  72. char *raw_buf;
  73. unsigned long raw_buf_phys;
  74. int buffsize;
  75. /*
  76. * Device state tables
  77. */
  78. unsigned long flags;
  79. #define DMA_BUSY 0x00000001
  80. #define DMA_RESTART 0x00000002
  81. #define DMA_ACTIVE 0x00000004
  82. #define DMA_STARTED 0x00000008
  83. #define DMA_EMPTY 0x00000010
  84. #define DMA_ALLOC_DONE 0x00000020
  85. #define DMA_SYNCING 0x00000040
  86. #define DMA_DIRTY 0x00000080
  87. #define DMA_POST 0x00000100
  88. #define DMA_NODMA 0x00000200
  89. #define DMA_NOTIMEOUT 0x00000400
  90. int open_mode;
  91. /*
  92. * Queue parameters.
  93. */
  94. int qlen;
  95. int qhead;
  96. int qtail;
  97. spinlock_t lock;
  98. int cfrag; /* Current incomplete fragment (write) */
  99. int nbufs;
  100. int counts[MAX_SUB_BUFFERS];
  101. int subdivision;
  102. int fragment_size;
  103. int needs_reorg;
  104. int max_fragments;
  105. int bytes_in_use;
  106. int underrun_count;
  107. unsigned long byte_counter;
  108. unsigned long user_counter;
  109. unsigned long max_byte_counter;
  110. int data_rate; /* Bytes/second */
  111. int mapping_flags;
  112. #define DMA_MAP_MAPPED 0x00000001
  113. char neutral_byte;
  114. int dma; /* DMA channel */
  115. int applic_profile; /* Application profile (APF_*) */
  116. /* Interrupt callback stuff */
  117. void (*audio_callback) (int dev, int parm);
  118. int callback_parm;
  119. int buf_flags[MAX_SUB_BUFFERS];
  120. #define BUFF_EOF 0x00000001 /* Increment eof count */
  121. #define BUFF_DIRTY 0x00000002 /* Buffer written */
  122. };
  123. /*
  124. * Structure for use with various microcontrollers and DSP processors
  125. * in the recent sound cards.
  126. */
  127. typedef struct coproc_operations
  128. {
  129. char name[64];
  130. struct module *owner;
  131. int (*open) (void *devc, int sub_device);
  132. void (*close) (void *devc, int sub_device);
  133. int (*ioctl) (void *devc, unsigned int cmd, void __user * arg, int local);
  134. void (*reset) (void *devc);
  135. void *devc; /* Driver specific info */
  136. } coproc_operations;
  137. struct audio_driver
  138. {
  139. struct module *owner;
  140. int (*open) (int dev, int mode);
  141. void (*close) (int dev);
  142. void (*output_block) (int dev, unsigned long buf,
  143. int count, int intrflag);
  144. void (*start_input) (int dev, unsigned long buf,
  145. int count, int intrflag);
  146. int (*ioctl) (int dev, unsigned int cmd, void __user * arg);
  147. int (*prepare_for_input) (int dev, int bufsize, int nbufs);
  148. int (*prepare_for_output) (int dev, int bufsize, int nbufs);
  149. void (*halt_io) (int dev);
  150. int (*local_qlen)(int dev);
  151. void (*copy_user) (int dev,
  152. char *localbuf, int localoffs,
  153. const char __user *userbuf, int useroffs,
  154. int max_in, int max_out,
  155. int *used, int *returned,
  156. int len);
  157. void (*halt_input) (int dev);
  158. void (*halt_output) (int dev);
  159. void (*trigger) (int dev, int bits);
  160. int (*set_speed)(int dev, int speed);
  161. unsigned int (*set_bits)(int dev, unsigned int bits);
  162. short (*set_channels)(int dev, short channels);
  163. void (*postprocess_write)(int dev); /* Device spesific postprocessing for written data */
  164. void (*preprocess_read)(int dev); /* Device spesific preprocessing for read data */
  165. void (*mmap)(int dev);
  166. };
  167. struct audio_operations
  168. {
  169. char name[128];
  170. int flags;
  171. #define NOTHING_SPECIAL 0x00
  172. #define NEEDS_RESTART 0x01
  173. #define DMA_AUTOMODE 0x02
  174. #define DMA_DUPLEX 0x04
  175. #define DMA_PSEUDO_AUTOMODE 0x08
  176. #define DMA_HARDSTOP 0x10
  177. #define DMA_EXACT 0x40
  178. #define DMA_NORESET 0x80
  179. int format_mask; /* Bitmask for supported audio formats */
  180. void *devc; /* Driver specific info */
  181. struct audio_driver *d;
  182. void *portc; /* Driver specific info */
  183. struct dma_buffparms *dmap_in, *dmap_out;
  184. struct coproc_operations *coproc;
  185. int mixer_dev;
  186. int enable_bits;
  187. int open_mode;
  188. int go;
  189. int min_fragment; /* 0 == unlimited */
  190. int max_fragment; /* 0 == unlimited */
  191. int parent_dev; /* 0 -> no parent, 1 to n -> parent=parent_dev+1 */
  192. /* fields formerly in dmabuf.c */
  193. wait_queue_head_t in_sleeper;
  194. wait_queue_head_t out_sleeper;
  195. wait_queue_head_t poll_sleeper;
  196. /* fields formerly in audio.c */
  197. int audio_mode;
  198. #define AM_NONE 0
  199. #define AM_WRITE OPEN_WRITE
  200. #define AM_READ OPEN_READ
  201. int local_format;
  202. int audio_format;
  203. int local_conversion;
  204. #define CNV_MU_LAW 0x00000001
  205. /* large structures at the end to keep offsets small */
  206. struct dma_buffparms dmaps[2];
  207. };
  208. int *load_mixer_volumes(char *name, int *levels, int present);
  209. struct mixer_operations
  210. {
  211. struct module *owner;
  212. char id[16];
  213. char name[64];
  214. int (*ioctl) (int dev, unsigned int cmd, void __user * arg);
  215. void *devc;
  216. int modify_counter;
  217. };
  218. struct synth_operations
  219. {
  220. struct module *owner;
  221. char *id; /* Unique identifier (ASCII) max 29 char */
  222. struct synth_info *info;
  223. int midi_dev;
  224. int synth_type;
  225. int synth_subtype;
  226. int (*open) (int dev, int mode);
  227. void (*close) (int dev);
  228. int (*ioctl) (int dev, unsigned int cmd, void __user * arg);
  229. int (*kill_note) (int dev, int voice, int note, int velocity);
  230. int (*start_note) (int dev, int voice, int note, int velocity);
  231. int (*set_instr) (int dev, int voice, int instr);
  232. void (*reset) (int dev);
  233. void (*hw_control) (int dev, unsigned char *event);
  234. int (*load_patch) (int dev, int format, const char __user *addr,
  235. int count, int pmgr_flag);
  236. void (*aftertouch) (int dev, int voice, int pressure);
  237. void (*controller) (int dev, int voice, int ctrl_num, int value);
  238. void (*panning) (int dev, int voice, int value);
  239. void (*volume_method) (int dev, int mode);
  240. void (*bender) (int dev, int chn, int value);
  241. int (*alloc_voice) (int dev, int chn, int note, struct voice_alloc_info *alloc);
  242. void (*setup_voice) (int dev, int voice, int chn);
  243. int (*send_sysex)(int dev, unsigned char *bytes, int len);
  244. struct voice_alloc_info alloc;
  245. struct channel_info chn_info[16];
  246. int emulation;
  247. #define EMU_GM 1 /* General MIDI */
  248. #define EMU_XG 2 /* Yamaha XG */
  249. #define MAX_SYSEX_BUF 64
  250. unsigned char sysex_buf[MAX_SYSEX_BUF];
  251. int sysex_ptr;
  252. };
  253. struct midi_input_info
  254. {
  255. /* MIDI input scanner variables */
  256. #define MI_MAX 10
  257. volatile int m_busy;
  258. unsigned char m_buf[MI_MAX];
  259. unsigned char m_prev_status; /* For running status */
  260. int m_ptr;
  261. #define MST_INIT 0
  262. #define MST_DATA 1
  263. #define MST_SYSEX 2
  264. int m_state;
  265. int m_left;
  266. };
  267. struct midi_operations
  268. {
  269. struct module *owner;
  270. struct midi_info info;
  271. struct synth_operations *converter;
  272. struct midi_input_info in_info;
  273. int (*open) (int dev, int mode,
  274. void (*inputintr)(int dev, unsigned char data),
  275. void (*outputintr)(int dev)
  276. );
  277. void (*close) (int dev);
  278. int (*ioctl) (int dev, unsigned int cmd, void __user * arg);
  279. int (*outputc) (int dev, unsigned char data);
  280. int (*start_read) (int dev);
  281. int (*end_read) (int dev);
  282. void (*kick)(int dev);
  283. int (*command) (int dev, unsigned char *data);
  284. int (*buffer_status) (int dev);
  285. int (*prefix_cmd) (int dev, unsigned char status);
  286. struct coproc_operations *coproc;
  287. void *devc;
  288. };
  289. struct sound_lowlev_timer
  290. {
  291. int dev;
  292. int priority;
  293. unsigned int (*tmr_start)(int dev, unsigned int usecs);
  294. void (*tmr_disable)(int dev);
  295. void (*tmr_restart)(int dev);
  296. };
  297. struct sound_timer_operations
  298. {
  299. struct module *owner;
  300. struct sound_timer_info info;
  301. int priority;
  302. int devlink;
  303. int (*open)(int dev, int mode);
  304. void (*close)(int dev);
  305. int (*event)(int dev, unsigned char *ev);
  306. unsigned long (*get_time)(int dev);
  307. int (*ioctl) (int dev, unsigned int cmd, void __user * arg);
  308. void (*arm_timer)(int dev, long time);
  309. };
  310. extern struct sound_timer_operations default_sound_timer;
  311. extern struct audio_operations *audio_devs[MAX_AUDIO_DEV];
  312. extern int num_audiodevs;
  313. extern struct mixer_operations *mixer_devs[MAX_MIXER_DEV];
  314. extern int num_mixers;
  315. extern struct synth_operations *synth_devs[MAX_SYNTH_DEV+MAX_MIDI_DEV];
  316. extern int num_synths;
  317. extern struct midi_operations *midi_devs[MAX_MIDI_DEV];
  318. extern int num_midis;
  319. extern struct sound_timer_operations * sound_timer_devs[MAX_TIMER_DEV];
  320. extern int num_sound_timers;
  321. extern int sound_map_buffer (int dev, struct dma_buffparms *dmap, buffmem_desc *info);
  322. void sound_timer_init (struct sound_lowlev_timer *t, char *name);
  323. void sound_dma_intr (int dev, struct dma_buffparms *dmap, int chan);
  324. #define AUDIO_DRIVER_VERSION 2
  325. #define MIXER_DRIVER_VERSION 2
  326. int sound_install_audiodrv(int vers, char *name, struct audio_driver *driver,
  327. int driver_size, int flags, unsigned int format_mask,
  328. void *devc, int dma1, int dma2);
  329. int sound_install_mixer(int vers, char *name, struct mixer_operations *driver,
  330. int driver_size, void *devc);
  331. void sound_unload_audiodev(int dev);
  332. void sound_unload_mixerdev(int dev);
  333. void sound_unload_mididev(int dev);
  334. void sound_unload_synthdev(int dev);
  335. void sound_unload_timerdev(int dev);
  336. int sound_alloc_mixerdev(void);
  337. int sound_alloc_timerdev(void);
  338. int sound_alloc_synthdev(void);
  339. int sound_alloc_mididev(void);
  340. #endif /* _DEV_TABLE_H_ */