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