1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #define ALLOW_SELECT
30
31 #ifdef MODULE
32 #include <linux/config.h>
33 #include <linux/module.h>
34 #include <linux/version.h>
35 #endif
36
37 #include <linux/param.h>
38 #include <linux/types.h>
39 #include <linux/errno.h>
40 #include <linux/signal.h>
41 #include <linux/fcntl.h>
42 #include <linux/sched.h>
43 #include <linux/timer.h>
44 #include <linux/tty.h>
45 #include <linux/ctype.h>
46 #include <asm/io.h>
47 #include <asm/segment.h>
48 #include <asm/system.h>
49 #include <asm/dma.h>
50 #include <sys/kd.h>
51 #include <linux/wait.h>
52 #include <linux/malloc.h>
53 #include <linux/string.h>
54
55 #include "linux/soundcard.h"
56
57 typedef char snd_rw_buf;
58
59 #define FALSE 0
60 #define TRUE 1
61
62 #define COPY_FROM_USER(d, s, o, c) memcpy_fromfs((d), &((s)[o]), (c))
63 #define COPY_TO_USER(d, o, s, c) memcpy_tofs(&((d)[o]), (s), (c))
64 #define IOCTL_FROM_USER(d, s, o, c) memcpy_fromfs((d), &((s)[o]), (c))
65 #define IOCTL_TO_USER(d, o, s, c) memcpy_tofs(&((d)[o]), (s), (c))
66
67 #define GET_BYTE_FROM_USER(target, addr, offs) target = get_fs_byte(&((addr)[offs]))
68 #define GET_SHORT_FROM_USER(target, addr, offs) target = get_fs_word(&((addr)[offs]))
69 #define GET_WORD_FROM_USER(target, addr, offs) target = get_fs_long((long*)&((addr)[offs]))
70 #define PUT_WORD_TO_USER(addr, offs, data) put_fs_long(data, (long*)&((addr)[offs]))
71 #define IOCTL_IN(arg) get_fs_long((long *)(arg))
72 #define IOCTL_OUT(arg, ret) snd_ioctl_return((int *)arg, ret)
73
74 struct snd_wait {
75 int mode; int aborting;
76 };
77
78 #define DEFINE_WAIT_QUEUE(name, flag) static struct wait_queue *name = NULL; \
79 static volatile struct snd_wait flag = {0}
80 #define DEFINE_WAIT_QUEUES(name, flag) static struct wait_queue *name = {NULL}; \
81 static volatile struct snd_wait flag = {{0}}
82 #define RESET_WAIT_QUEUE(q, f) {f.aborting = 0;f.mode = WK_NONE;}
83 #define PROCESS_ABORTING(q, f) ((current->signal & ~current->blocked))
84 #define SET_ABORT_FLAG(q, f) f.aborting = 1
85 #define TIMED_OUT(q, f) (f.mode & WK_TIMEOUT)
86 #define DO_SLEEP(q, f, time_limit) \
87 { unsigned long tl;\
88 if (time_limit) tl = current->timeout = jiffies + (time_limit); \
89 else tl = 0xffffffff; \
90 f.mode = WK_SLEEP;interruptible_sleep_on(&q); \
91 if (!(f.mode & WK_WAKEUP)) \
92 { \
93 if (current->signal & ~current->blocked) \
94 f.aborting = 1; \
95 else \
96 if (jiffies >= tl) f.mode |= WK_TIMEOUT; \
97 } \
98 f.mode &= ~WK_SLEEP; \
99 }
100 #define SOMEONE_WAITING(q, f) (f.mode & WK_SLEEP)
101 #define WAKE_UP(q, f) {f.mode = WK_WAKEUP;wake_up(&q);}
102
103 #define ALLOC_DMA_CHN(chn,deviceID) request_dma(chn, deviceID)
104 #define RELEASE_DMA_CHN(chn) free_dma(chn)
105
106 #define GET_TIME() jiffies
107 #define RELEASE_IRQ free_irq
108 #define RET_ERROR(err) -err
109
110
111
112
113
114
115 #define DISABLE_INTR(flags) __asm__ __volatile__("pushfl ; popl %0 ; cli":"=r" (flags));
116 #define RESTORE_INTR(flags) __asm__ __volatile__("pushl %0 ; popfl": \
117 :"r" (flags));
118
119
120
121
122
123
124
125
126
127 #define KERNEL_MALLOC(nbytes) kmalloc(nbytes, GFP_KERNEL)
128 #define KERNEL_FREE(addr) kfree(addr)
129
130
131
132
133
134
135
136
137
138
139 #define PERMANENT_MALLOC(typecast, mem_ptr, size, linux_ptr) \
140 {mem_ptr = (typecast)linux_ptr; \
141 linux_ptr += (size);}
142
143
144
145
146
147
148
149 #define DEFINE_TIMER(name, proc) \
150 static struct timer_list name = \
151 {NULL, NULL, 0, 0, proc}
152
153
154
155
156
157 #define ACTIVATE_TIMER(name, proc, time) \
158 {name.expires = time; \
159 add_timer (&name);}
160
161 #define INB inb
162 #define INW inw
163 #define OUTB outb
164 #define OUTW outw
165
166
167
168
169
170 #define SND_SA_INTERRUPT
171
172
173
174
175
176
177
178
179
180
181 #define DECLARE_FILE() struct file *filp
182 #define ISSET_FILE_FLAG(fileinfo, flag) (fileinfo->filp->f_flags & (flag) ? \
183 1 : 0)
184 #define INT_HANDLER_PROTO() void(*hndlr)(int, struct pt_regs *)
185 #define INT_HANDLER_PARMS(irq, parms) int irq, struct pt_regs *parms
186 #define INT_HANDLER_CALL(irq) irq, NULL