Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dev_table.h
Go to the documentation of this file.
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 #include <linux/spinlock.h>
19 /*
20  * Sound card numbers 27 to 999. (1 to 26 are defined in soundcard.h)
21  * Numbers 1000 to N are reserved for driver's internal use.
22  */
23 
24 #define SNDCARD_DESKPROXL 27 /* Compaq Deskpro XL */
25 #define SNDCARD_VIDC 28 /* ARMs VIDC */
26 #define SNDCARD_SBPNP 29
27 #define SNDCARD_SOFTOSS 36
28 #define SNDCARD_VMIDI 37
29 #define SNDCARD_OPL3SA1 38 /* Note: clash in msnd.h */
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 /* Waveartist */
36 #define SNDCARD_OPL3SA2_MSS 45 /* Originally missed */
37 #define SNDCARD_AD1816 88
38 
39 /*
40  * NOTE! NOTE! NOTE! NOTE!
41  *
42  * If you modify this file, please check the dev_table.c also.
43  *
44  * NOTE! NOTE! NOTE! NOTE!
45  */
46 
47 struct driver_info
48 {
49  char *driver_id;
50  int card_subtype; /* Driver specific. Usually 0 */
51  int card_type; /* From soundcard.h */
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 
58 struct card_info
59 {
60  int card_type; /* Link (search key) to the driver list */
62  int enabled;
64 };
65 
66 
67 /*
68  * Device specific parameters (used only by dmabuf.c)
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 
77 {
78  int dma_mode; /* DMODE_INPUT, DMODE_OUTPUT or DMODE_NONE */
79  int closing;
80 
81  /*
82  * Pointers to raw buffers
83  */
84 
85  char *raw_buf;
86  unsigned long raw_buf_phys;
87  int buffsize;
88 
89  /*
90  * Device state tables
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 
107 
108  /*
109  * Queue parameters.
110  */
111  int qlen;
112  int qhead;
113  int qtail;
115 
116  int cfrag; /* Current incomplete fragment (write) */
117 
118  int nbufs;
121 
125 
127 
129  unsigned long byte_counter;
130  unsigned long user_counter;
131  unsigned long max_byte_counter;
132  int data_rate; /* Bytes/second */
133 
135 #define DMA_MAP_MAPPED 0x00000001
137  int dma; /* DMA channel */
138 
139  int applic_profile; /* Application profile (APF_*) */
140  /* Interrupt callback stuff */
141  void (*audio_callback) (int dev, int parm);
143 
145 #define BUFF_EOF 0x00000001 /* Increment eof count */
146 #define BUFF_DIRTY 0x00000002 /* Buffer written */
147 };
148 
149 /*
150  * Structure for use with various microcontrollers and DSP processors
151  * in the recent sound cards.
152  */
153 typedef 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; /* Driver specific info */
164 
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); /* Device spesific postprocessing for written data */
192  void (*preprocess_read)(int dev); /* Device spesific preprocessing for read data */
193  void (*mmap)(int dev);
194 };
195 
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; /* Bitmask for supported audio formats */
209  void *devc; /* Driver specific info */
210  struct audio_driver *d;
211  void *portc; /* Driver specific info */
217  int go;
218  int min_fragment; /* 0 == unlimited */
219  int max_fragment; /* 0 == unlimited */
220  int parent_dev; /* 0 -> no parent, 1 to n -> parent=parent_dev+1 */
221 
222  /* fields formerly in dmabuf.c */
226 
227  /* fields formerly in audio.c */
229 
230 #define AM_NONE 0
231 #define AM_WRITE OPEN_WRITE
232 #define AM_READ OPEN_READ
233 
237 #define CNV_MU_LAW 0x00000001
238 
239  /* large structures at the end to keep offsets small */
240  struct dma_buffparms dmaps[2];
241 };
242 
243 int *load_mixer_volumes(char *name, int *levels, int present);
244 
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;
254 };
255 
257 {
258  struct module *owner;
259  char *id; /* Unique identifier (ASCII) max 29 char */
260  struct synth_info *info;
261  int midi_dev;
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 
285  struct channel_info chn_info[16];
287 #define EMU_GM 1 /* General MIDI */
288 #define EMU_XG 2 /* Yamaha XG */
289 #define MAX_SYSEX_BUF 64
290  unsigned char sysex_buf[MAX_SYSEX_BUF];
292 };
293 
295 {
296  /* MIDI input scanner variables */
297 #define MI_MAX 10
298  volatile int m_busy;
299  unsigned char m_buf[MI_MAX];
300  unsigned char m_prev_status; /* For running 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 
310 {
311  struct module *owner;
312  struct midi_info 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);
327  int (*prefix_cmd) (int dev, unsigned char status);
329  void *devc;
330 };
331 
333 {
334  int dev;
335  int priority;
336  unsigned int (*tmr_start)(int dev, unsigned int usecs);
339 };
340 
342 {
343  struct module *owner;
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 
356 
358 extern int num_audiodevs;
360 extern int num_mixers;
362 extern int num_synths;
363 extern struct midi_operations *midi_devs[MAX_MIDI_DEV];
364 extern int num_midis;
366 extern int num_sound_timers;
367 
368 extern int sound_map_buffer (int dev, struct dma_buffparms *dmap, buffmem_desc *info);
369 void sound_timer_init (struct sound_lowlev_timer *t, char *name);
370 void sound_dma_intr (int dev, struct dma_buffparms *dmap, int chan);
371 
372 #define AUDIO_DRIVER_VERSION 2
373 #define MIXER_DRIVER_VERSION 2
374 int 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);
377 int sound_install_mixer(int vers, char *name, struct mixer_operations *driver,
378  int driver_size, void *devc);
379 
380 void sound_unload_audiodev(int dev);
381 void sound_unload_mixerdev(int dev);
382 void sound_unload_mididev(int dev);
383 void sound_unload_synthdev(int dev);
384 void sound_unload_timerdev(int dev);
385 int sound_alloc_mixerdev(void);
386 int sound_alloc_timerdev(void);
387 int sound_alloc_synthdev(void);
388 int sound_alloc_mididev(void);
389 #endif /* _DEV_TABLE_H_ */
390