1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef _DEV_TABLE_H_
16#define _DEV_TABLE_H_
17
18
19
20
21
22
23#define SNDCARD_DESKPROXL 27
24#define SNDCARD_VIDC 28
25#define SNDCARD_SBPNP 29
26#define SNDCARD_SOFTOSS 36
27#define SNDCARD_VMIDI 37
28#define SNDCARD_OPL3SA1 38
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
35#define SNDCARD_OPL3SA2_MSS 45
36#define SNDCARD_AD1816 88
37
38
39
40
41
42
43
44
45
46struct driver_info
47{
48 char *driver_id;
49 int card_subtype;
50 int card_type;
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
57struct card_info
58{
59 int card_type;
60 struct address_info config;
61 int enabled;
62 void *for_driver_use;
63};
64
65
66
67
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
75struct dma_buffparms
76{
77 int dma_mode;
78 int closing;
79
80
81
82
83
84 char *raw_buf;
85 unsigned long raw_buf_phys;
86 int buffsize;
87
88
89
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
109
110 int qlen;
111 int qhead;
112 int qtail;
113 int cfrag;
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;
130
131 int mapping_flags;
132#define DMA_MAP_MAPPED 0x00000001
133 char neutral_byte;
134 int dma;
135
136 int applic_profile;
137
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
143#define BUFF_DIRTY 0x00000002
144};
145
146
147
148
149
150typedef struct coproc_operations
151{
152 char name[64];
153 struct module *owner;
154 int (*open) (void *devc, int sub_device);
155 void (*close) (void *devc, int sub_device);
156 int (*ioctl) (void *devc, unsigned int cmd, caddr_t arg, int local);
157 void (*reset) (void *devc);
158
159 void *devc;
160} coproc_operations;
161
162struct audio_driver
163{
164 struct module *owner;
165 int (*open) (int dev, int mode);
166 void (*close) (int dev);
167 void (*output_block) (int dev, unsigned long buf,
168 int count, int intrflag);
169 void (*start_input) (int dev, unsigned long buf,
170 int count, int intrflag);
171 int (*ioctl) (int dev, unsigned int cmd, caddr_t arg);
172 int (*prepare_for_input) (int dev, int bufsize, int nbufs);
173 int (*prepare_for_output) (int dev, int bufsize, int nbufs);
174 void (*halt_io) (int dev);
175 int (*local_qlen)(int dev);
176 void (*copy_user) (int dev,
177 char *localbuf, int localoffs,
178 const char *userbuf, int useroffs,
179 int max_in, int max_out,
180 int *used, int *returned,
181 int len);
182 void (*halt_input) (int dev);
183 void (*halt_output) (int dev);
184 void (*trigger) (int dev, int bits);
185 int (*set_speed)(int dev, int speed);
186 unsigned int (*set_bits)(int dev, unsigned int bits);
187 short (*set_channels)(int dev, short channels);
188 void (*postprocess_write)(int dev);
189 void (*preprocess_read)(int dev);
190 void (*mmap)(int dev);
191};
192
193struct audio_operations
194{
195 char name[128];
196 int flags;
197#define NOTHING_SPECIAL 0x00
198#define NEEDS_RESTART 0x01
199#define DMA_AUTOMODE 0x02
200#define DMA_DUPLEX 0x04
201#define DMA_PSEUDO_AUTOMODE 0x08
202#define DMA_HARDSTOP 0x10
203#define DMA_EXACT 0x40
204#define DMA_NORESET 0x80
205 int format_mask;
206 void *devc;
207 struct audio_driver *d;
208 void *portc;
209 struct dma_buffparms *dmap_in, *dmap_out;
210 struct coproc_operations *coproc;
211 int mixer_dev;
212 int enable_bits;
213 int open_mode;
214 int go;
215 int min_fragment;
216 int max_fragment;
217 int parent_dev;
218
219
220 wait_queue_head_t in_sleeper;
221 wait_queue_head_t out_sleeper;
222 wait_queue_head_t poll_sleeper;
223
224
225 int audio_mode;
226
227#define AM_NONE 0
228#define AM_WRITE OPEN_WRITE
229#define AM_READ OPEN_READ
230
231 int local_format;
232 int audio_format;
233 int local_conversion;
234#define CNV_MU_LAW 0x00000001
235
236
237 struct dma_buffparms dmaps[2];
238};
239
240int *load_mixer_volumes(char *name, int *levels, int present);
241
242struct mixer_operations
243{
244 struct module *owner;
245 char id[16];
246 char name[64];
247 int (*ioctl) (int dev, unsigned int cmd, caddr_t arg);
248
249 void *devc;
250 int modify_counter;
251};
252
253struct synth_operations
254{
255 struct module *owner;
256 char *id;
257 struct synth_info *info;
258 int midi_dev;
259 int synth_type;
260 int synth_subtype;
261
262 int (*open) (int dev, int mode);
263 void (*close) (int dev);
264 int (*ioctl) (int dev, unsigned int cmd, caddr_t arg);
265 int (*kill_note) (int dev, int voice, int note, int velocity);
266 int (*start_note) (int dev, int voice, int note, int velocity);
267 int (*set_instr) (int dev, int voice, int instr);
268 void (*reset) (int dev);
269 void (*hw_control) (int dev, unsigned char *event);
270 int (*load_patch) (int dev, int format, const char *addr,
271 int offs, int count, int pmgr_flag);
272 void (*aftertouch) (int dev, int voice, int pressure);
273 void (*controller) (int dev, int voice, int ctrl_num, int value);
274 void (*panning) (int dev, int voice, int value);
275 void (*volume_method) (int dev, int mode);
276 void (*bender) (int dev, int chn, int value);
277 int (*alloc_voice) (int dev, int chn, int note, struct voice_alloc_info *alloc);
278 void (*setup_voice) (int dev, int voice, int chn);
279 int (*send_sysex)(int dev, unsigned char *bytes, int len);
280
281 struct voice_alloc_info alloc;
282 struct channel_info chn_info[16];
283 int emulation;
284#define EMU_GM 1
285#define EMU_XG 2
286#define MAX_SYSEX_BUF 64
287 unsigned char sysex_buf[MAX_SYSEX_BUF];
288 int sysex_ptr;
289};
290
291struct midi_input_info
292{
293
294#define MI_MAX 10
295 int m_busy;
296 unsigned char m_buf[MI_MAX];
297 unsigned char m_prev_status;
298 int m_ptr;
299#define MST_INIT 0
300#define MST_DATA 1
301#define MST_SYSEX 2
302 int m_state;
303 int m_left;
304};
305
306struct midi_operations
307{
308 struct module *owner;
309 struct midi_info info;
310 struct synth_operations *converter;
311 struct midi_input_info in_info;
312 int (*open) (int dev, int mode,
313 void (*inputintr)(int dev, unsigned char data),
314 void (*outputintr)(int dev)
315 );
316 void (*close) (int dev);
317 int (*ioctl) (int dev, unsigned int cmd, caddr_t arg);
318 int (*outputc) (int dev, unsigned char data);
319 int (*start_read) (int dev);
320 int (*end_read) (int dev);
321 void (*kick)(int dev);
322 int (*command) (int dev, unsigned char *data);
323 int (*buffer_status) (int dev);
324 int (*prefix_cmd) (int dev, unsigned char status);
325 struct coproc_operations *coproc;
326 void *devc;
327};
328
329struct sound_lowlev_timer
330{
331 int dev;
332 int priority;
333 unsigned int (*tmr_start)(int dev, unsigned int usecs);
334 void (*tmr_disable)(int dev);
335 void (*tmr_restart)(int dev);
336};
337
338struct sound_timer_operations
339{
340 struct module *owner;
341 struct sound_timer_info info;
342 int priority;
343 int devlink;
344 int (*open)(int dev, int mode);
345 void (*close)(int dev);
346 int (*event)(int dev, unsigned char *ev);
347 unsigned long (*get_time)(int dev);
348 int (*ioctl) (int dev, unsigned int cmd, caddr_t arg);
349 void (*arm_timer)(int dev, long time);
350};
351
352#ifdef _DEV_TABLE_C_
353struct audio_operations *audio_devs[MAX_AUDIO_DEV];
354int num_audiodevs;
355struct mixer_operations *mixer_devs[MAX_MIXER_DEV];
356int num_mixers;
357struct synth_operations *synth_devs[MAX_SYNTH_DEV+MAX_MIDI_DEV];
358int num_synths;
359struct midi_operations *midi_devs[MAX_MIDI_DEV];
360int num_midis;
361
362extern struct sound_timer_operations default_sound_timer;
363struct sound_timer_operations *sound_timer_devs[MAX_TIMER_DEV] = {
364 &default_sound_timer, NULL
365};
366int num_sound_timers = 1;
367#else
368extern struct audio_operations *audio_devs[MAX_AUDIO_DEV];
369extern int num_audiodevs;
370extern struct mixer_operations *mixer_devs[MAX_MIXER_DEV];
371extern int num_mixers;
372extern struct synth_operations *synth_devs[MAX_SYNTH_DEV+MAX_MIDI_DEV];
373extern int num_synths;
374extern struct midi_operations *midi_devs[MAX_MIDI_DEV];
375extern int num_midis;
376extern struct sound_timer_operations * sound_timer_devs[MAX_TIMER_DEV];
377extern int num_sound_timers;
378#endif
379
380extern int sound_map_buffer (int dev, struct dma_buffparms *dmap, buffmem_desc *info);
381void sound_timer_init (struct sound_lowlev_timer *t, char *name);
382void sound_dma_intr (int dev, struct dma_buffparms *dmap, int chan);
383
384#define AUDIO_DRIVER_VERSION 2
385#define MIXER_DRIVER_VERSION 2
386int sound_install_audiodrv(int vers, char *name, struct audio_driver *driver,
387 int driver_size, int flags, unsigned int format_mask,
388 void *devc, int dma1, int dma2);
389int sound_install_mixer(int vers, char *name, struct mixer_operations *driver,
390 int driver_size, void *devc);
391
392void sound_unload_audiodev(int dev);
393void sound_unload_mixerdev(int dev);
394void sound_unload_mididev(int dev);
395void sound_unload_synthdev(int dev);
396void sound_unload_timerdev(int dev);
397int sound_alloc_audiodev(void);
398int sound_alloc_mixerdev(void);
399int sound_alloc_timerdev(void);
400int sound_alloc_synthdev(void);
401int sound_alloc_mididev(void);
402#endif
403
404