1 | #ifndef __DRIVER_H
|
---|
2 | #define __DRIVER_H
|
---|
3 |
|
---|
4 | /*
|
---|
5 | * Main header file for the ALSA driver
|
---|
6 | * Copyright (c) 1994-2000 by Jaroslav Kysela <perex@suse.cz>
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * This program is free software; you can redistribute it and/or modify
|
---|
10 | * it under the terms of the GNU General Public License as published by
|
---|
11 | * the Free Software Foundation; either version 2 of the License, or
|
---|
12 | * (at your option) any later version.
|
---|
13 | *
|
---|
14 | * This program is distributed in the hope that it will be useful,
|
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | * GNU General Public License for more details.
|
---|
18 | *
|
---|
19 | * You should have received a copy of the GNU General Public License
|
---|
20 | * along with this program; if not, write to the Free Software
|
---|
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
|
---|
26 | #define NEW_MACRO_VARARGS
|
---|
27 | #endif
|
---|
28 |
|
---|
29 | #ifdef ALSA_BUILD
|
---|
30 | #include "config.h"
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #define SNDRV_CARDS 8 /* number of supported soundcards - don't change - minor numbers */
|
---|
34 |
|
---|
35 | #ifndef CONFIG_SND_MAJOR /* standard configuration */
|
---|
36 | #define CONFIG_SND_MAJOR 116
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | #ifndef CONFIG_SND_DEBUG
|
---|
40 | #undef CONFIG_SND_DEBUG_MEMORY
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #ifndef __iomem
|
---|
44 | #define __iomem
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | #ifndef cond_resched
|
---|
48 | #define cond_resched() \
|
---|
49 | do { \
|
---|
50 | if (1) { \
|
---|
51 | set_current_state(TASK_RUNNING); \
|
---|
52 | schedule(); \
|
---|
53 | } \
|
---|
54 | } while (0)
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * ==========================================================================
|
---|
59 | */
|
---|
60 |
|
---|
61 | #ifdef ALSA_BUILD
|
---|
62 | #undef MODULE
|
---|
63 | #define MODULE
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | #include <linux/config.h>
|
---|
67 | #include <linux/version.h>
|
---|
68 |
|
---|
69 | #define IRQ_NONE /*void*/
|
---|
70 | #define IRQ_HANDLED /*void*/
|
---|
71 | #define IRQ_RETVAL(x) /*void*/
|
---|
72 | typedef void irqreturn_t;
|
---|
73 |
|
---|
74 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 3)
|
---|
75 | #error "This driver requires Linux 2.2.3 and higher."
|
---|
76 | #endif
|
---|
77 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 2, 0)
|
---|
78 | #define LINUX_2_2
|
---|
79 | #endif
|
---|
80 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 1)
|
---|
81 | #define LINUX_2_3
|
---|
82 | #endif
|
---|
83 | #if defined(LINUX_2_3) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
|
---|
84 | #error "This code requires Linux 2.4.0-test1 and higher."
|
---|
85 | #endif
|
---|
86 |
|
---|
87 | #ifdef ALSA_BUILD
|
---|
88 | #if defined(CONFIG_MODVERSIONS) && !defined(__GENKSYMS__) && !defined(__DEPEND__)
|
---|
89 | #define MODVERSIONS
|
---|
90 | #include <linux/modversions.h>
|
---|
91 | #include "sndversions.h"
|
---|
92 | #endif
|
---|
93 | #ifdef SNDRV_NO_MODVERS
|
---|
94 | #undef MODVERSIONS
|
---|
95 | #undef _set_ver
|
---|
96 | #endif
|
---|
97 | #endif /* ALSA_BUILD */
|
---|
98 |
|
---|
99 | #ifndef SNDRV_MAIN_OBJECT_FILE
|
---|
100 | #define __NO_VERSION__
|
---|
101 | #endif
|
---|
102 | #include <linux/module.h>
|
---|
103 |
|
---|
104 | #include <linux/utsname.h>
|
---|
105 | #include <linux/errno.h>
|
---|
106 | #include <linux/kernel.h>
|
---|
107 | #include <linux/sched.h>
|
---|
108 | #include <linux/malloc.h>
|
---|
109 | #include <linux/delay.h>
|
---|
110 |
|
---|
111 | #include <linux/ioport.h>
|
---|
112 |
|
---|
113 | #include <asm/io.h>
|
---|
114 | #include <asm/irq.h>
|
---|
115 | #include <asm/dma.h>
|
---|
116 | #include <asm/segment.h>
|
---|
117 | #include <asm/uaccess.h>
|
---|
118 | #include <asm/system.h>
|
---|
119 | #include <asm/string.h>
|
---|
120 |
|
---|
121 | #ifdef CONFIG_PCI
|
---|
122 | #include <linux/pci.h>
|
---|
123 | #endif
|
---|
124 | #include <linux/interrupt.h>
|
---|
125 | #include <linux/pagemap.h>
|
---|
126 | #include <linux/fs.h>
|
---|
127 | #include <linux/fcntl.h>
|
---|
128 | #include <linux/vmalloc.h>
|
---|
129 | #include <linux/proc_fs.h>
|
---|
130 | #include <linux/poll.h>
|
---|
131 | #include <linux/reboot.h>
|
---|
132 |
|
---|
133 | #ifdef LINUX_2_2
|
---|
134 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 2, 18)
|
---|
135 | #include <linux/init.h>
|
---|
136 | #endif
|
---|
137 | #include "compat_22.h"
|
---|
138 | #endif
|
---|
139 | #ifdef LINUX_2_3
|
---|
140 | #include <linux/init.h>
|
---|
141 | #include <linux/pm.h>
|
---|
142 | #define PCI_GET_DRIVER_DATA(pci) pci->driver_data
|
---|
143 | #define PCI_SET_DRIVER_DATA(pci, data) pci->driver_data = data
|
---|
144 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 3)
|
---|
145 | #define pci_set_dma_mask(pci, mask) pci->dma_mask = mask
|
---|
146 | #endif
|
---|
147 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 7)
|
---|
148 | #define PCI_NEW_SUSPEND
|
---|
149 | #endif
|
---|
150 | #ifndef virt_to_page
|
---|
151 | #define virt_to_page(x) (&mem_map[MAP_NR(x)])
|
---|
152 | #endif
|
---|
153 | #define snd_request_region request_region
|
---|
154 | #ifndef rwlock_init
|
---|
155 | #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
|
---|
156 | #endif
|
---|
157 | #define snd_kill_fasync(fp, sig, band) kill_fasync(fp, sig, band)
|
---|
158 | #if defined(__i386__) || defined(__ppc__)
|
---|
159 | /*
|
---|
160 | * Here a dirty hack for 2.4 kernels.. See kernel/memory.c.
|
---|
161 | */
|
---|
162 | #define HACK_PCI_ALLOC_CONSISTENT
|
---|
163 | void *snd_pci_hack_alloc_consistent(struct pci_dev *hwdev, size_t size,
|
---|
164 | dma_addr_t *dma_handle);
|
---|
165 | #undef pci_alloc_consistent
|
---|
166 | #define pci_alloc_consistent snd_pci_hack_alloc_consistent
|
---|
167 | #endif /* i386 or ppc */
|
---|
168 | #endif
|
---|
169 |
|
---|
170 | #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))
|
---|
171 | #if (defined(CONFIG_ISAPNP_KERNEL) && defined(ALSA_BUILD)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 30) && !defined(ALSA_BUILD))
|
---|
172 | #include <linux/isapnp.h>
|
---|
173 | #define isapnp_dev pci_dev
|
---|
174 | #define isapnp_card pci_bus
|
---|
175 | #else
|
---|
176 | #include "isapnp.h"
|
---|
177 | #endif
|
---|
178 | #undef __ISAPNP__
|
---|
179 | #define __ISAPNP__
|
---|
180 | #endif
|
---|
181 |
|
---|
182 | #ifndef PCI_D0
|
---|
183 | #define PCI_D0 0
|
---|
184 | #define PCI_D1 1
|
---|
185 | #define PCI_D2 2
|
---|
186 | #define PCI_D3hot 3
|
---|
187 | #define PCI_D3cold 4
|
---|
188 | #endif
|
---|
189 |
|
---|
190 |
|
---|
191 | #include <sound/asound.h>
|
---|
192 | #include <sound/asoundef.h>
|
---|
193 |
|
---|
194 | struct work_struct {
|
---|
195 | unsigned long pending;
|
---|
196 | struct list_head entry;
|
---|
197 | void (*func)(void *);
|
---|
198 | void *data;
|
---|
199 | void *wq_data;
|
---|
200 | struct timer_list timer;
|
---|
201 | };
|
---|
202 |
|
---|
203 | #define INIT_WORK(_work, _func, _data) \
|
---|
204 | do { \
|
---|
205 | (_work)->func = _func; \
|
---|
206 | (_work)->data = _data; \
|
---|
207 | init_timer(&(_work)->timer); \
|
---|
208 | } while (0)
|
---|
209 | #define __WORK_INITIALIZER(n, f, d) { \
|
---|
210 | .func = (f), \
|
---|
211 | .data = (d), \
|
---|
212 | }
|
---|
213 | #define DECLARE_WORK(n, f, d) \
|
---|
214 | struct work_struct n = __WORK_INITIALIZER(n, f, d)
|
---|
215 | int snd_compat_schedule_work(struct work_struct *work);
|
---|
216 | #define schedule_work(w) snd_compat_schedule_work(w)
|
---|
217 |
|
---|
218 | /* Name change */
|
---|
219 | typedef struct timeval snd_timestamp_t;
|
---|
220 | typedef struct sndrv_interval snd_interval_t;
|
---|
221 | #ifndef TARGET_OS2
|
---|
222 | typedef enum sndrv_card_type snd_card_type;
|
---|
223 | #endif
|
---|
224 | typedef struct sndrv_aes_iec958 snd_aes_iec958_t;
|
---|
225 | //typedef enum sndrv_hwdep_iface snd_hwdep_iface_t;
|
---|
226 | typedef struct sndrv_hwdep_info snd_hwdep_info_t;
|
---|
227 | //typedef enum sndrv_pcm_class snd_pcm_class_t;
|
---|
228 | //typedef enum sndrv_pcm_subclass snd_pcm_subclass_t;
|
---|
229 | //typedef enum sndrv_pcm_stream snd_pcm_stream_t;
|
---|
230 | //typedef enum sndrv_pcm_access snd_pcm_access_t;
|
---|
231 | //typedef enum sndrv_pcm_format snd_pcm_format_t;
|
---|
232 | //typedef enum sndrv_pcm_subformat snd_pcm_subformat_t;
|
---|
233 | //typedef enum sndrv_pcm_state snd_pcm_state_t;
|
---|
234 | typedef union sndrv_pcm_sync_id snd_pcm_sync_id_t;
|
---|
235 | typedef struct sndrv_pcm_info snd_pcm_info_t;
|
---|
236 | //typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t;
|
---|
237 | typedef struct sndrv_pcm_hw_params snd_pcm_hw_params_t;
|
---|
238 | #ifndef TARGET_OS2
|
---|
239 | typedef enum sndrv_pcm_start snd_pcm_start_t;
|
---|
240 | typedef enum sndrv_pcm_xrun snd_pcm_xrun_t;
|
---|
241 | #endif
|
---|
242 | //typedef enum sndrv_pcm_tstamp snd_pcm_tstamp_t;
|
---|
243 | typedef struct sndrv_pcm_sw_params snd_pcm_sw_params_t;
|
---|
244 | typedef struct sndrv_pcm_channel_info snd_pcm_channel_info_t;
|
---|
245 | typedef struct sndrv_pcm_status snd_pcm_status_t;
|
---|
246 | typedef struct sndrv_pcm_mmap_status snd_pcm_mmap_status_t;
|
---|
247 | typedef struct sndrv_pcm_mmap_control snd_pcm_mmap_control_t;
|
---|
248 | typedef struct sndrv_xferi snd_xferi_t;
|
---|
249 | typedef struct sndrv_xfern snd_xfern_t;
|
---|
250 | //typedef enum sndrv_rawmidi_stream snd_rawmidi_stream_t;
|
---|
251 | typedef struct sndrv_rawmidi_info snd_rawmidi_info_t;
|
---|
252 | typedef struct sndrv_rawmidi_params snd_rawmidi_params_t;
|
---|
253 | typedef struct sndrv_rawmidi_status snd_rawmidi_status_t;
|
---|
254 | //typedef enum sndrv_timer_class snd_timer_class_t;
|
---|
255 | //typedef enum sndrv_timer_slave_class snd_timer_slave_class_t;
|
---|
256 | #ifdef TARGET_OS2
|
---|
257 | typedef struct snd_pcm_volume snd_pcm_volume_t;
|
---|
258 | #else
|
---|
259 | typedef enum sndrv_timer_global snd_timer_global_t;
|
---|
260 | #endif
|
---|
261 | typedef struct sndrv_timer_id snd_timer_id_t;
|
---|
262 | typedef struct sndrv_timer_select snd_timer_select_t;
|
---|
263 | typedef struct sndrv_timer_info snd_timer_info_t;
|
---|
264 | typedef struct sndrv_timer_params snd_timer_params_t;
|
---|
265 | typedef struct sndrv_timer_status snd_timer_status_t;
|
---|
266 | typedef struct sndrv_timer_read snd_timer_read_t;
|
---|
267 | typedef struct sndrv_timer_tread snd_timer_tread_t;
|
---|
268 | typedef struct sndrv_timer_ginfo snd_timer_ginfo_t;
|
---|
269 | typedef struct sndrv_timer_gparams snd_timer_gparams_t;
|
---|
270 | typedef struct sndrv_timer_gstatus snd_timer_gstatus_t;
|
---|
271 | typedef struct sndrv_xferv snd_xferv_t;
|
---|
272 |
|
---|
273 | #ifdef CONFIG_SND_DEBUG_MEMORY
|
---|
274 | void *snd_wrapper_kmalloc(size_t, int);
|
---|
275 | #undef kmalloc
|
---|
276 | void snd_wrapper_kfree(const void *);
|
---|
277 | #undef kfree
|
---|
278 | void *snd_wrapper_vmalloc(size_t);
|
---|
279 | #undef vmalloc
|
---|
280 | void snd_wrapper_vfree(void *);
|
---|
281 | #undef vfree
|
---|
282 | #endif
|
---|
283 |
|
---|
284 | #ifdef TARGET_OS2
|
---|
285 | #define snd_enter_user() 0
|
---|
286 | #define snd_leave_user(a)
|
---|
287 | #define dec_mod_count(a) (*(unsigned long *)a)--
|
---|
288 |
|
---|
289 | #else
|
---|
290 | static inline mm_segment_t snd_enter_user(void)
|
---|
291 | {
|
---|
292 | mm_segment_t fs = get_fs();
|
---|
293 | set_fs(get_ds());
|
---|
294 | return fs;
|
---|
295 | }
|
---|
296 | static inline void snd_leave_user(mm_segment_t fs)
|
---|
297 | {
|
---|
298 | set_fs(fs);
|
---|
299 | }
|
---|
300 | static inline void dec_mod_count(struct module *module)
|
---|
301 | {
|
---|
302 | if (module)
|
---|
303 | __MOD_DEC_USE_COUNT(module);
|
---|
304 | }
|
---|
305 | #endif
|
---|
306 |
|
---|
307 | #if defined(__alpha__) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 14)
|
---|
308 | #undef writeb
|
---|
309 | #define writeb(v, a) do { __writeb((v),(a)); mb(); } while(0)
|
---|
310 | #undef writew
|
---|
311 | #define writew(v, a) do {__writew((v),(a)); mb(); } while(0)
|
---|
312 | #undef writel
|
---|
313 | #define writel(v, a) do {__writel((v),(a)); mb(); } while(0)
|
---|
314 | #undef writeq
|
---|
315 | #define writeq(v, a) do {__writeq((v),(a)); mb(); } while(0)
|
---|
316 | #endif
|
---|
317 |
|
---|
318 | /* do we have virt_to_bus? */
|
---|
319 | #if defined(CONFIG_SPARC64)
|
---|
320 | #undef HAVE_VIRT_TO_BUS
|
---|
321 | #else
|
---|
322 | #define HAVE_VIRT_TO_BUS 1
|
---|
323 | #endif
|
---|
324 |
|
---|
325 | /*
|
---|
326 | * ==========================================================================
|
---|
327 | */
|
---|
328 |
|
---|
329 | /* device allocation stuff */
|
---|
330 |
|
---|
331 | #define SNDRV_DEV_TYPE_RANGE_SIZE 0x1000
|
---|
332 |
|
---|
333 | typedef enum {
|
---|
334 | SNDRV_DEV_TOPLEVEL = (0*SNDRV_DEV_TYPE_RANGE_SIZE),
|
---|
335 | SNDRV_DEV_CONTROL,
|
---|
336 | SNDRV_DEV_LOWLEVEL_PRE,
|
---|
337 | SNDRV_DEV_LOWLEVEL_NORMAL = (1*SNDRV_DEV_TYPE_RANGE_SIZE),
|
---|
338 | SNDRV_DEV_PCM,
|
---|
339 | SNDRV_DEV_RAWMIDI,
|
---|
340 | SNDRV_DEV_TIMER,
|
---|
341 | SNDRV_DEV_SEQUENCER,
|
---|
342 | SNDRV_DEV_HWDEP,
|
---|
343 | SNDRV_DEV_INFO,
|
---|
344 | SNDRV_DEV_BUS,
|
---|
345 | SNDRV_DEV_CODEC,
|
---|
346 | SNDRV_DEV_LOWLEVEL = (2*SNDRV_DEV_TYPE_RANGE_SIZE)
|
---|
347 | } snd_device_type_t;
|
---|
348 |
|
---|
349 | typedef enum {
|
---|
350 | SNDRV_DEV_BUILD,
|
---|
351 | SNDRV_DEV_REGISTERED,
|
---|
352 | SNDRV_DEV_DISCONNECTED
|
---|
353 | } snd_device_state_t;
|
---|
354 |
|
---|
355 | typedef enum {
|
---|
356 | SNDRV_DEV_CMD_PRE = 0,
|
---|
357 | SNDRV_DEV_CMD_NORMAL = 1,
|
---|
358 | SNDRV_DEV_CMD_POST = 2
|
---|
359 | } snd_device_cmd_t;
|
---|
360 |
|
---|
361 |
|
---|
362 | struct snd_device;
|
---|
363 |
|
---|
364 | struct snd_device_ops {
|
---|
365 | int (*dev_free)(struct snd_device *dev);
|
---|
366 | int (*dev_register)(struct snd_device *dev);
|
---|
367 | int (*dev_disconnect)(struct snd_device *dev);
|
---|
368 | int (*dev_unregister)(struct snd_device *dev);
|
---|
369 | };
|
---|
370 |
|
---|
371 | struct snd_device {
|
---|
372 | struct list_head list; /* list of registered devices */
|
---|
373 | struct snd_card *card; /* card which holds this device */
|
---|
374 | snd_device_state_t state; /* state of the device */
|
---|
375 | snd_device_type_t type; /* device type */
|
---|
376 | void *device_data; /* device structure */
|
---|
377 | struct snd_device_ops *ops; /* operations */
|
---|
378 | };
|
---|
379 |
|
---|
380 | #define snd_device(n) list_entry(n, snd_device_t, list)
|
---|
381 |
|
---|
382 | /* various typedefs */
|
---|
383 |
|
---|
384 | typedef struct snd_info_entry snd_info_entry_t;
|
---|
385 | typedef struct _snd_pcm snd_pcm_t;
|
---|
386 | typedef struct _snd_pcm_str snd_pcm_str_t;
|
---|
387 | typedef struct _snd_pcm_substream snd_pcm_substream_t;
|
---|
388 | typedef struct _snd_mixer snd_kmixer_t;
|
---|
389 | typedef struct _snd_rawmidi snd_rawmidi_t;
|
---|
390 | typedef struct _snd_ctl_file snd_ctl_file_t;
|
---|
391 | typedef struct _snd_kcontrol snd_kcontrol_t;
|
---|
392 | typedef struct _snd_timer snd_timer_t;
|
---|
393 | typedef struct _snd_timer_instance snd_timer_instance_t;
|
---|
394 | typedef struct _snd_hwdep snd_hwdep_t;
|
---|
395 | #ifdef CONFIG_SND_OSSEMUL
|
---|
396 | typedef struct _snd_oss_mixer snd_mixer_oss_t;
|
---|
397 | #endif
|
---|
398 |
|
---|
399 | /* main structure for soundcard */
|
---|
400 |
|
---|
401 | /* monitor files for graceful shutdown (hotplug) */
|
---|
402 |
|
---|
403 | struct snd_monitor_file {
|
---|
404 | struct file *file;
|
---|
405 | struct snd_monitor_file *next;
|
---|
406 | };
|
---|
407 |
|
---|
408 | struct snd_card {
|
---|
409 | int number; /* number of soundcard (index to snd_cards) */
|
---|
410 |
|
---|
411 | char id[16]; /* id string of this card */
|
---|
412 | char driver[16]; /* driver name */
|
---|
413 | char shortname[32]; /* short name of this soundcard */
|
---|
414 | char longname[80]; /* name of this soundcard */
|
---|
415 | char mixername[80]; /* mixer name */
|
---|
416 | char components[80]; /* card components delimited with space */
|
---|
417 |
|
---|
418 | struct module *module; /* top-level module */
|
---|
419 |
|
---|
420 | void *private_data; /* private data for soundcard */
|
---|
421 | void (*private_free) (struct snd_card *card); /* callback for freeing of private data */
|
---|
422 |
|
---|
423 | struct list_head devices; /* devices */
|
---|
424 |
|
---|
425 | unsigned int last_numid; /* last used numeric ID */
|
---|
426 | struct rw_semaphore controls_rwsem; /* controls list lock */ rwlock_t control_rwlock; /* control list lock */
|
---|
427 | rwlock_t ctl_files_rwlock; /* ctl_files list lock */
|
---|
428 | int controls_count; /* count of all controls */
|
---|
429 | int user_ctl_count; /* count of all user controls */
|
---|
430 | struct list_head controls; /* all controls for this card */
|
---|
431 | struct list_head ctl_files; /* active control files */
|
---|
432 |
|
---|
433 | snd_info_entry_t *proc_root; /* root for soundcard specific files */
|
---|
434 | snd_info_entry_t *proc_id; /* the card id */
|
---|
435 | struct proc_dir_entry *proc_root_link; /* number link to real id */
|
---|
436 |
|
---|
437 | struct snd_monitor_file *files; /* all files associated to this card */
|
---|
438 | struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown state */
|
---|
439 | spinlock_t files_lock; /* lock the files for this card */
|
---|
440 | int shutdown; /* this card is going down */
|
---|
441 | wait_queue_head_t shutdown_sleep;
|
---|
442 | struct work_struct free_workq; /* for free in workqueue */
|
---|
443 | struct device *dev;
|
---|
444 | #ifdef CONFIG_PM
|
---|
445 | int (*pm_suspend)(struct snd_card *card, unsigned int state);
|
---|
446 | int (*pm_resume)(struct snd_card *card, unsigned int state);
|
---|
447 | struct pm_dev *pm_dev; /* for ISA */
|
---|
448 | void *pm_private_data;
|
---|
449 | unsigned int power_state; /* power state */
|
---|
450 | struct semaphore power_lock; /* power lock */
|
---|
451 | wait_queue_head_t power_sleep;
|
---|
452 | #endif
|
---|
453 |
|
---|
454 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
|
---|
455 | snd_mixer_oss_t *mixer_oss;
|
---|
456 | int mixer_oss_change_count;
|
---|
457 | #endif
|
---|
458 | };
|
---|
459 |
|
---|
460 | #ifdef CONFIG_PM
|
---|
461 | static inline void snd_power_lock(struct snd_card *card)
|
---|
462 | {
|
---|
463 | down(&card->power_lock);
|
---|
464 | }
|
---|
465 |
|
---|
466 | static inline void snd_power_unlock(struct snd_card *card)
|
---|
467 | {
|
---|
468 | up(&card->power_lock);
|
---|
469 | }
|
---|
470 |
|
---|
471 | int snd_power_wait(struct snd_card *card, unsigned int power_state, struct file *file);
|
---|
472 |
|
---|
473 | static inline unsigned int snd_power_get_state(struct snd_card *card)
|
---|
474 | {
|
---|
475 | return card->power_state;
|
---|
476 | }
|
---|
477 |
|
---|
478 | static inline void snd_power_change_state(struct snd_card *card, unsigned int state)
|
---|
479 | {
|
---|
480 | card->power_state = state;
|
---|
481 | wake_up(&card->power_sleep);
|
---|
482 | }
|
---|
483 | int snd_card_set_pm_callback(struct snd_card *card,
|
---|
484 | int (*suspend)(struct snd_card *, unsigned int),
|
---|
485 | int (*resume)(struct snd_card *, unsigned int),
|
---|
486 | void *private_data);
|
---|
487 | int snd_card_set_isa_pm_callback(struct snd_card *card,
|
---|
488 | int (*suspend)(struct snd_card *, unsigned int),
|
---|
489 | int (*resume)(struct snd_card *, unsigned int),
|
---|
490 | void *private_data);
|
---|
491 | #ifndef SND_PCI_PM_CALLBACKS
|
---|
492 | int snd_card_pci_suspend(struct pci_dev *dev, u32 state);
|
---|
493 | int snd_card_pci_resume(struct pci_dev *dev);
|
---|
494 | #define SND_PCI_PM_CALLBACKS \
|
---|
495 | snd_card_pci_suspend, \
|
---|
496 | snd_card_pci_resume
|
---|
497 | #endif
|
---|
498 | #else
|
---|
499 | #define snd_power_lock(card) do { ; } while (0)
|
---|
500 | #define snd_power_unlock(card) do { ; } while (0)
|
---|
501 | #define snd_power_wait(card) do { ; } while (0)
|
---|
502 | #define snd_power_get_state(card) SNDRV_CTL_POWER_D0
|
---|
503 | #define snd_power_change_state(card, state) do { ; } while (0)
|
---|
504 | #define snd_card_set_pm_callback(card,suspend,resume,data) -EINVAL
|
---|
505 | #define snd_card_set_isa_pm_callback(card,suspend,resume,data) -EINVAL
|
---|
506 | #define SND_PCI_PM_CALLBACKS
|
---|
507 | #endif
|
---|
508 |
|
---|
509 | /* device.c */
|
---|
510 |
|
---|
511 | struct _snd_minor {
|
---|
512 | struct list_head list; /* list of all minors per card */
|
---|
513 | int number; /* minor number */
|
---|
514 | int device; /* device number */
|
---|
515 | const char *comment; /* for /proc/asound/devices */
|
---|
516 | snd_info_entry_t *dev; /* for /proc/asound/dev */
|
---|
517 | struct file_operations *f_ops; /* file operations */
|
---|
518 | char name[1];
|
---|
519 | };
|
---|
520 |
|
---|
521 | typedef struct _snd_minor snd_minor_t;
|
---|
522 |
|
---|
523 | /* sound.c */
|
---|
524 |
|
---|
525 | extern int snd_ecards_limit;
|
---|
526 | extern int snd_device_mode;
|
---|
527 | extern int snd_device_gid;
|
---|
528 | extern int snd_device_uid;
|
---|
529 |
|
---|
530 | void snd_request_card(int card);
|
---|
531 |
|
---|
532 | int snd_register_device(int type, struct snd_card *card, int dev, snd_minor_t *reg, const char *name);
|
---|
533 | int snd_unregister_device(int type, struct snd_card *card, int dev);
|
---|
534 |
|
---|
535 | #ifdef CONFIG_SND_OSSEMUL
|
---|
536 | int snd_register_oss_device(int type, struct snd_card *card, int dev, snd_minor_t *reg, const char *name);
|
---|
537 | int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
|
---|
538 | #endif
|
---|
539 |
|
---|
540 | int snd_minor_info_init(void);
|
---|
541 | int snd_minor_info_done(void);
|
---|
542 |
|
---|
543 | /* sound_oss.c */
|
---|
544 |
|
---|
545 | #ifdef CONFIG_SND_OSSEMUL
|
---|
546 |
|
---|
547 | int snd_minor_info_oss_init(void);
|
---|
548 | int snd_minor_info_oss_done(void);
|
---|
549 |
|
---|
550 | int snd_oss_init_module(void);
|
---|
551 | void snd_oss_cleanup_module(void);
|
---|
552 |
|
---|
553 | #endif
|
---|
554 |
|
---|
555 | /* memory.c */
|
---|
556 |
|
---|
557 | #ifdef CONFIG_SND_DEBUG_MEMORY
|
---|
558 | void snd_memory_init(void);
|
---|
559 | void snd_memory_done(void);
|
---|
560 | int snd_memory_info_init(void);
|
---|
561 | int snd_memory_info_done(void);
|
---|
562 | void *snd_hidden_kmalloc(size_t size, int flags);
|
---|
563 | void *snd_hidden_kcalloc(size_t n, size_t size, int flags);
|
---|
564 | void snd_hidden_kfree(const void *obj);
|
---|
565 | void *snd_hidden_vmalloc(unsigned long size);
|
---|
566 | void snd_hidden_vfree(void *obj);
|
---|
567 | char *snd_hidden_kstrdup(const char *s, int flags);
|
---|
568 | #define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
|
---|
569 | #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
|
---|
570 | #define kfree(obj) snd_hidden_kfree(obj)
|
---|
571 | #define vmalloc(size) snd_hidden_vmalloc(size)
|
---|
572 | #define vfree(obj) snd_hidden_vfree(obj)
|
---|
573 | #define kstrdup(s, flags) snd_hidden_kstrdup(s, flags)
|
---|
574 | #endif
|
---|
575 | char *snd_kmalloc_strdup(const char *string, int flags);
|
---|
576 | int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
|
---|
577 | int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
|
---|
578 |
|
---|
579 | /* init.c */
|
---|
580 |
|
---|
581 | extern int snd_cards_count;
|
---|
582 | extern struct snd_card *snd_cards[SNDRV_CARDS];
|
---|
583 | extern rwlock_t snd_card_rwlock;
|
---|
584 | #ifdef CONFIG_SND_OSSEMUL
|
---|
585 | extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
|
---|
586 | #endif
|
---|
587 |
|
---|
588 | struct snd_card *snd_card_new(int idx, const char *id,
|
---|
589 | struct module *module, int extra_size);
|
---|
590 | int snd_card_free(struct snd_card *card);
|
---|
591 | int snd_card_register(struct snd_card *card);
|
---|
592 | int snd_card_info_init(void);
|
---|
593 | int snd_card_info_done(void);
|
---|
594 | int snd_component_add(struct snd_card *card, const char *component);
|
---|
595 | int snd_card_file_add(struct snd_card *card, struct file *file);
|
---|
596 | int snd_card_file_remove(struct snd_card *card, struct file *file);
|
---|
597 |
|
---|
598 | /* device.c */
|
---|
599 |
|
---|
600 | int snd_device_new(struct snd_card *card, snd_device_type_t type,
|
---|
601 | void *device_data, struct snd_device_ops *ops);
|
---|
602 | int snd_device_register(struct snd_card *card, void *device_data);
|
---|
603 | int snd_device_register_all(struct snd_card *card);
|
---|
604 | int snd_device_free(struct snd_card *card, void *device_data);
|
---|
605 | int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd);
|
---|
606 |
|
---|
607 | /* isadma.c */
|
---|
608 |
|
---|
609 | #define DMA_MODE_NO_ENABLE 0x0100
|
---|
610 |
|
---|
611 | void snd_dma_program(unsigned long dma, const void *buf, unsigned int size, unsigned short mode);
|
---|
612 | void snd_dma_disable(unsigned long dma);
|
---|
613 | unsigned int snd_dma_residue(unsigned long dma);
|
---|
614 |
|
---|
615 | /* misc.c */
|
---|
616 |
|
---|
617 | int snd_task_name(struct task_struct *task, char *name, size_t size);
|
---|
618 |
|
---|
619 | /* --- */
|
---|
620 |
|
---|
621 | #ifdef NEW_MACRO_VARARGS
|
---|
622 |
|
---|
623 | /*
|
---|
624 | * VARARGS section
|
---|
625 | */
|
---|
626 |
|
---|
627 | #define snd_printk(...) do {\
|
---|
628 | printk("ALSA %s:%d: ", __FILE__, __LINE__); \
|
---|
629 | printk(__VA_ARGS__); \
|
---|
630 | } while (0)
|
---|
631 |
|
---|
632 | #ifdef CONFIG_SND_DEBUG
|
---|
633 |
|
---|
634 | #define snd_printd(...) snd_printk(__VA_ARGS__)
|
---|
635 | #define snd_assert(expr, ...) do {\
|
---|
636 | if (!(expr)) {\
|
---|
637 | snd_printk("BUG? (%s) (called from %p)\n", __STRING(expr), __builtin_return_address(0));\
|
---|
638 | __VA_ARGS__;\
|
---|
639 | }\
|
---|
640 | } while (0)
|
---|
641 | #define snd_runtime_check(expr, ...) do {\
|
---|
642 | if (!(expr)) {\
|
---|
643 | snd_printk("ERROR (%s) (called from %p)\n", __STRING(expr), __builtin_return_address(0));\
|
---|
644 | __VA_ARGS__;\
|
---|
645 | }\
|
---|
646 | } while (0)
|
---|
647 |
|
---|
648 | #else /* !CONFIG_SND_DEBUG */
|
---|
649 |
|
---|
650 | #define snd_printd(...) /* nothing */
|
---|
651 | #define snd_assert(expr, ...) /* nothing */
|
---|
652 | #define snd_runtime_check(expr, ...) do { if (!(expr)) {__VA_ARGS__;} } while (0)
|
---|
653 |
|
---|
654 | #endif /* CONFIG_SND_DEBUG */
|
---|
655 |
|
---|
656 | #ifdef CONFIG_SND_DEBUG_DETECT
|
---|
657 | #define snd_printdd(...) snd_printk(__VA_ARGS__)
|
---|
658 | #else
|
---|
659 | #define snd_printdd(...) /* nothing */
|
---|
660 | #endif
|
---|
661 |
|
---|
662 | #else /* !NEW_MACRO_VARARGS */
|
---|
663 |
|
---|
664 | /*
|
---|
665 | * Old args section...
|
---|
666 | */
|
---|
667 |
|
---|
668 | #ifdef TARGET_OS2
|
---|
669 |
|
---|
670 | #define snd_printk printk
|
---|
671 |
|
---|
672 | #ifdef CONFIG_SND_DEBUG
|
---|
673 |
|
---|
674 | #define snd_printd snd_printk
|
---|
675 | #define snd_assert(expr, retval) \
|
---|
676 | if (!(expr)) {\
|
---|
677 | snd_printk("BUG? (%s)\n", __STRING(expr));\
|
---|
678 | ##retval;\
|
---|
679 | }
|
---|
680 |
|
---|
681 | #define snd_runtime_check snd_assert
|
---|
682 | #define snd_runtime_check_continue snd_assert_continue
|
---|
683 |
|
---|
684 |
|
---|
685 | #else /* !CONFIG_SND_DEBUG */
|
---|
686 |
|
---|
687 | #define snd_printd 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
|
---|
688 | #define snd_assert(expr, retval) \
|
---|
689 | if (!(expr)) {\
|
---|
690 | ##retval;\
|
---|
691 | }
|
---|
692 |
|
---|
693 | #define snd_runtime_check snd_assert
|
---|
694 |
|
---|
695 | #endif /* CONFIG_SND_DEBUG */
|
---|
696 |
|
---|
697 | #ifdef CONFIG_SND_DEBUG_DETECT
|
---|
698 | #define snd_printdd snd_printk
|
---|
699 | #else
|
---|
700 | #define snd_printdd 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
|
---|
701 | #endif
|
---|
702 |
|
---|
703 | #else
|
---|
704 | #define snd_printk(args...) do {\
|
---|
705 | printk("ALSA %s:%d: ", __FILE__, __LINE__); \
|
---|
706 | printk(##args); \
|
---|
707 | } while (0)
|
---|
708 |
|
---|
709 | #ifdef CONFIG_SND_DEBUG
|
---|
710 |
|
---|
711 | #define snd_printd(args...) snd_printk(##args)
|
---|
712 | #define snd_assert(expr, args...) do {\
|
---|
713 | if (!(expr)) {\
|
---|
714 | snd_printk("BUG? (%s)\n", __STRING(expr));\
|
---|
715 | ##args;\
|
---|
716 | }\
|
---|
717 | } while (0)
|
---|
718 | #define snd_runtime_check(expr, args...) do {\
|
---|
719 | if (!(expr)) {\
|
---|
720 | snd_printk("ERROR (%s)\n", __STRING(expr));\
|
---|
721 | ##args;\
|
---|
722 | }\
|
---|
723 | } while (0)
|
---|
724 |
|
---|
725 | #else /* !CONFIG_SND_DEBUG */
|
---|
726 |
|
---|
727 | #define snd_printd(args...) /* nothing */
|
---|
728 | #define snd_assert(expr, args...) /* nothing */
|
---|
729 | #define snd_runtime_check(expr, args...) do { if (!(expr)) {##args;} } while (0)
|
---|
730 |
|
---|
731 | #endif /* CONFIG_SND_DEBUG */
|
---|
732 |
|
---|
733 | #ifdef CONFIG_SND_DEBUG_DETECT
|
---|
734 | #define snd_printdd(args...) snd_printk(##args)
|
---|
735 | #else
|
---|
736 | #define snd_printdd(args...) /* nothing */
|
---|
737 | #endif
|
---|
738 | #endif
|
---|
739 |
|
---|
740 | #endif /* NEW_MACRO_VARARGS */
|
---|
741 |
|
---|
742 | #ifdef DEBUG
|
---|
743 | #define snd_BUG() _asm int 3;
|
---|
744 | #else
|
---|
745 | #define snd_BUG()
|
---|
746 | #endif
|
---|
747 |
|
---|
748 | static inline void snd_timestamp_now(struct timespec *tstamp, int timespec)
|
---|
749 | {
|
---|
750 | struct timeval val;
|
---|
751 | /* FIXME: use a linear time source */
|
---|
752 | do_gettimeofday(&val);
|
---|
753 | tstamp->tv_sec = val.tv_sec;
|
---|
754 | tstamp->tv_nsec = val.tv_usec;
|
---|
755 | if (timespec)
|
---|
756 | tstamp->tv_nsec *= 1000L;
|
---|
757 | }
|
---|
758 |
|
---|
759 | #define snd_timestamp_zero(tstamp) do { (tstamp)->tv_sec = 0; (tstamp)->tv_usec = 0; } while (0)
|
---|
760 | #define snd_timestamp_null(tstamp) ((tstamp)->tv_sec == 0 && (tstamp)->tv_usec ==0)
|
---|
761 |
|
---|
762 | #define SNDRV_OSS_VERSION ((3<<16)|(8<<8)|(1<<4)|(0)) /* 3.8.1a */
|
---|
763 |
|
---|
764 | /* kcalloc */
|
---|
765 | #ifndef CONFIG_HAVE_KCALLOC
|
---|
766 | #ifndef CONFIG_SND_DEBUG_MEMORY
|
---|
767 | void *snd_compat_kcalloc(size_t n, size_t size, int gfp_flags);
|
---|
768 | #define kcalloc(n,s,f) snd_compat_kcalloc(n,s,f)
|
---|
769 | #endif
|
---|
770 | #endif
|
---|
771 |
|
---|
772 | #define __builtin_expect(x, expected_value) (x)
|
---|
773 | #define likely(x) __builtin_expect((x),1)
|
---|
774 | #define unlikely(x) __builtin_expect((x),0)
|
---|
775 |
|
---|
776 | typedef u32 /*__bitwise*/ pm_message_t;
|
---|
777 |
|
---|
778 | #endif /* __DRIVER_H */
|
---|