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