File: pcm_native.patch

package info (click to toggle)
alsa-driver 1.0.13-5etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 20,108 kB
  • ctags: 50,477
  • sloc: ansic: 319,881; sh: 32,930; makefile: 2,015; python: 1,527; perl: 1,316; xml: 896; awk: 66
file content (412 lines) | stat: -rw-r--r-- 11,432 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
--- ../alsa-kernel/core/pcm_native.c	2006-04-24 12:24:02.000000000 +0200
+++ pcm_native.c	2006-04-24 12:29:03.000000000 +0200
@@ -1,3 +1,4 @@
+#define __NO_VERSION__
 /*
  *  Digital Audio (PCM) abstract layer
  *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
@@ -347,7 +348,10 @@
 	return err;
 }
 
-static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
+#ifndef CONFIG_SND_BIT32_EMUL_MODULE
+static
+#endif
+int snd_pcm_hw_params(struct snd_pcm_substream *substream,
 			     struct snd_pcm_hw_params *params)
 {
 	struct snd_pcm_runtime *runtime;
@@ -2843,6 +2847,9 @@
 	struct snd_pcm_runtime *runtime;
 	snd_pcm_sframes_t result;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
+	up(&file->f_dentry->d_inode->i_sem);
+#endif
 	pcm_file = file->private_data;
 	substream = pcm_file->substream;
 	snd_assert(substream != NULL, result = -ENXIO; goto end);
@@ -2860,9 +2867,13 @@
 	if (result > 0)
 		result = frames_to_bytes(runtime, result);
  end:
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
+	down(&file->f_dentry->d_inode->i_sem);
+#endif
 	return result;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 44)
 static ssize_t snd_pcm_readv(struct file *file, const struct iovec *_vector,
 			     unsigned long count, loff_t * offset)
 
@@ -2909,6 +2920,9 @@
 	void __user **bufs;
 	snd_pcm_uframes_t frames;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
+	up(&file->f_dentry->d_inode->i_sem);
+#endif
 	pcm_file = file->private_data;
 	substream = pcm_file->substream;
 	snd_assert(substream != NULL, result = -ENXIO; goto end);
@@ -2933,8 +2947,12 @@
 		result = frames_to_bytes(runtime, result);
 	kfree(bufs);
  end:
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
+	down(&file->f_dentry->d_inode->i_sem);
+#endif
 	return result;
 }
+#endif
 
 static unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait)
 {
@@ -3020,6 +3038,17 @@
  * mmap support
  */
 
+#ifndef VM_RESERVED
+#ifndef LINUX_2_2
+static int snd_pcm_mmap_swapout(struct page * page, struct file * file)
+#else
+static int snd_pcm_mmap_swapout(struct vm_area_struct * area, struct page * page)
+#endif
+{
+	return 0;
+}
+#endif
+
 /*
  * Only on coherent architectures, we can mmap the status and the control records
  * for effcient data transfer.  On others, we have to use HWSYNC ioctl...
@@ -3028,10 +3057,18 @@
 /*
  * mmap status record
  */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
 static struct page * snd_pcm_mmap_status_nopage(struct vm_area_struct *area,
 						unsigned long address, int *type)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
+static struct page * snd_pcm_mmap_status_nopage(struct vm_area_struct *area,
+						unsigned long address, int no_share)
+#else
+static unsigned long snd_pcm_mmap_status_nopage(struct vm_area_struct *area,
+						unsigned long address, int no_share)
+#endif
 {
-	struct snd_pcm_substream *substream = area->vm_private_data;
+	struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data;
 	struct snd_pcm_runtime *runtime;
 	struct page * page;
 	
@@ -3039,10 +3076,19 @@
 		return NOPAGE_OOM;
 	runtime = substream->runtime;
 	page = virt_to_page(runtime->status);
+#ifndef CONFIG_SND_REMOVE_PAGE_RESERVE
+	if (!PageReserved(page))
+#endif
 	get_page(page);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
 	if (type)
 		*type = VM_FAULT_MINOR;
+#endif
+#ifndef LINUX_2_2
 	return page;
+#else
+	return page_address(page);
+#endif
 }
 
 static struct vm_operations_struct snd_pcm_vm_ops_status =
@@ -3063,18 +3109,32 @@
 	if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status)))
 		return -EINVAL;
 	area->vm_ops = &snd_pcm_vm_ops_status;
+#ifndef LINUX_2_2
 	area->vm_private_data = substream;
+#else
+	area->vm_private_data = (long)substream;
+#endif
+#ifdef VM_RESERVED
 	area->vm_flags |= VM_RESERVED;
+#endif
 	return 0;
 }
 
 /*
  * mmap control record
  */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
 static struct page * snd_pcm_mmap_control_nopage(struct vm_area_struct *area,
 						 unsigned long address, int *type)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
+static struct page * snd_pcm_mmap_control_nopage(struct vm_area_struct *area,
+						 unsigned long address, int no_share)
+#else
+static unsigned long snd_pcm_mmap_control_nopage(struct vm_area_struct *area,
+						 unsigned long address, int no_share)
+#endif
 {
-	struct snd_pcm_substream *substream = area->vm_private_data;
+	struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data;
 	struct snd_pcm_runtime *runtime;
 	struct page * page;
 	
@@ -3082,10 +3142,19 @@
 		return NOPAGE_OOM;
 	runtime = substream->runtime;
 	page = virt_to_page(runtime->control);
+#ifndef CONFIG_SND_REMOVE_PAGE_RESERVE
+	if (!PageReserved(page))
+#endif
 	get_page(page);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
 	if (type)
 		*type = VM_FAULT_MINOR;
+#endif
+#ifndef LINUX_2_2
 	return page;
+#else
+	return page_address(page);
+#endif
 }
 
 static struct vm_operations_struct snd_pcm_vm_ops_control =
@@ -3106,8 +3175,14 @@
 	if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control)))
 		return -EINVAL;
 	area->vm_ops = &snd_pcm_vm_ops_control;
+#ifndef LINUX_2_2
 	area->vm_private_data = substream;
+#else
+	area->vm_private_data = (long)substream;
+#endif
+#ifdef VM_RESERVED
 	area->vm_flags |= VM_RESERVED;
+#endif
 	return 0;
 }
 #else /* ! coherent mmap */
@@ -3129,10 +3204,18 @@
 /*
  * nopage callback for mmapping a RAM page
  */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
 static struct page *snd_pcm_mmap_data_nopage(struct vm_area_struct *area,
 					     unsigned long address, int *type)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
+static struct page * snd_pcm_mmap_data_nopage(struct vm_area_struct *area,
+					      unsigned long address, int no_share)
+#else
+static unsigned long snd_pcm_mmap_data_nopage(struct vm_area_struct *area,
+					      unsigned long address, int no_share)
+#endif
 {
-	struct snd_pcm_substream *substream = area->vm_private_data;
+	struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data;
 	struct snd_pcm_runtime *runtime;
 	unsigned long offset;
 	struct page * page;
@@ -3142,7 +3225,11 @@
 	if (substream == NULL)
 		return NOPAGE_OOM;
 	runtime = substream->runtime;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 25)
 	offset = area->vm_pgoff << PAGE_SHIFT;
+#else
+	offset = area->vm_offset;
+#endif
 	offset += address - area->vm_start;
 	snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM);
 	dma_bytes = PAGE_ALIGN(runtime->dma_bytes);
@@ -3156,10 +3243,19 @@
 		vaddr = runtime->dma_area + offset;
 		page = virt_to_page(vaddr);
 	}
+#ifndef CONFIG_SND_REMOVE_PAGE_RESERVE
+	if (!PageReserved(page))
+#endif
 	get_page(page);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
 	if (type)
 		*type = VM_FAULT_MINOR;
+#endif
+#ifndef LINUX_2_2
 	return page;
+#else
+	return page_address(page);
+#endif
 }
 
 static struct vm_operations_struct snd_pcm_vm_ops_data =
@@ -3167,6 +3263,9 @@
 	.open =		snd_pcm_mmap_data_open,
 	.close =	snd_pcm_mmap_data_close,
 	.nopage =	snd_pcm_mmap_data_nopage,
+#ifndef VM_RESERVED
+	.swapout =	snd_pcm_mmap_swapout,
+#endif
 };
 
 /*
@@ -3176,8 +3275,14 @@
 				struct vm_area_struct *area)
 {
 	area->vm_ops = &snd_pcm_vm_ops_data;
+#ifndef LINUX_2_2
 	area->vm_private_data = substream;
+#else
+	area->vm_private_data = (long)substream;
+#endif
+#ifdef VM_RESERVED
 	area->vm_flags |= VM_RESERVED;
+#endif
 	atomic_inc(&substream->mmap_count);
 	return 0;
 }
@@ -3202,14 +3307,37 @@
 	area->vm_page_prot = pgprot_noncached(area->vm_page_prot);
 #endif
 	area->vm_ops = &snd_pcm_vm_ops_data_mmio;
+#ifndef LINUX_2_2
 	area->vm_private_data = substream;
+#else
+	area->vm_private_data = (long)substream;
+#endif
 	area->vm_flags |= VM_IO;
 	size = area->vm_end - area->vm_start;
-	offset = area->vm_pgoff << PAGE_SHIFT;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 25)
+  	offset = area->vm_pgoff << PAGE_SHIFT;
+#else
+	offset = area->vm_offset;
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
+#define io_remap_page_range remap_page_range
+#endif
+#ifdef CONFIG_HAVE_IO_REMAP_PFN_RANGE
 	if (io_remap_pfn_range(area, area->vm_start,
 				(substream->runtime->dma_addr + offset) >> PAGE_SHIFT,
 				size, area->vm_page_prot))
 		return -EAGAIN;
+#elif defined(CONFIG_OLD_IO_REMAP_PAGE_RANGE)
+	if (io_remap_page_range(area->vm_start,
+				substream->runtime->dma_addr + offset,
+				size, area->vm_page_prot))
+		return -EAGAIN;
+#else
+	if (io_remap_page_range(area, area->vm_start,
+				substream->runtime->dma_addr + offset,
+				size, area->vm_page_prot))
+		return -EAGAIN;
+#endif
 	atomic_inc(&substream->mmap_count);
 	return 0;
 }
@@ -3245,7 +3373,11 @@
 	    runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED)
 		return -EINVAL;
 	size = area->vm_end - area->vm_start;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 25)
 	offset = area->vm_pgoff << PAGE_SHIFT;
+#else
+	offset = area->vm_offset;
+#endif
 	dma_bytes = PAGE_ALIGN(runtime->dma_bytes);
 	if ((size_t)size > dma_bytes)
 		return -EINVAL;
@@ -3270,7 +3402,11 @@
 	substream = pcm_file->substream;
 	snd_assert(substream != NULL, return -ENXIO);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 25)
 	offset = area->vm_pgoff << PAGE_SHIFT;
+#else
+	offset = area->vm_offset;
+#endif
 	switch (offset) {
 	case SNDRV_PCM_MMAP_OFFSET_STATUS:
 		if (substream->no_mmap_ctrl)
@@ -3307,12 +3443,34 @@
 /*
  * ioctl32 compat
  */
-#ifdef CONFIG_COMPAT
+#if defined(CONFIG_COMPAT) && defined(CONFIG_SND_HAVE_NEW_IOCTL)
 #include "pcm_compat.c"
 #else
 #define snd_pcm_ioctl_compat	NULL
 #endif
 
+#ifndef CONFIG_SND_HAVE_NEW_IOCTL
+/* need to unlock BKL to allow preemption */
+static int snd_pcm_playback_ioctl_old(struct inode *inode, struct file * file,
+				      unsigned int cmd, unsigned long arg)
+{
+	int err;
+	unlock_kernel();
+	err = snd_pcm_playback_ioctl(file, cmd, arg);
+	lock_kernel();
+	return err;
+}
+static int snd_pcm_capture_ioctl_old(struct inode *inode, struct file * file,
+				      unsigned int cmd, unsigned long arg)
+{
+	int err;
+	unlock_kernel();
+	err = snd_pcm_capture_ioctl(file, cmd, arg);
+	lock_kernel();
+	return err;
+}
+#endif
+
 /*
  *  To be removed helpers to keep binary compatibility
  */
@@ -3435,26 +3593,42 @@
 
 struct file_operations snd_pcm_f_ops[2] = {
 	{
+#ifndef LINUX_2_2
 		.owner =		THIS_MODULE,
+#endif
 		.write =		snd_pcm_write,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 44)
 		.writev =		snd_pcm_writev,
+#endif
 		.open =			snd_pcm_playback_open,
 		.release =		snd_pcm_release,
 		.poll =			snd_pcm_playback_poll,
+#ifdef CONFIG_SND_HAVE_NEW_IOCTL
 		.unlocked_ioctl =	snd_pcm_playback_ioctl,
 		.compat_ioctl = 	snd_pcm_ioctl_compat,
+#else
+		.ioctl =		snd_pcm_playback_ioctl_old,
+#endif
 		.mmap =			snd_pcm_mmap,
 		.fasync =		snd_pcm_fasync,
 	},
 	{
+#ifndef LINUX_2_2
 		.owner =		THIS_MODULE,
+#endif
 		.read =			snd_pcm_read,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 44)
 		.readv =		snd_pcm_readv,
+#endif
 		.open =			snd_pcm_capture_open,
 		.release =		snd_pcm_release,
 		.poll =			snd_pcm_capture_poll,
+#ifdef CONFIG_SND_HAVE_NEW_IOCTL
 		.unlocked_ioctl =	snd_pcm_capture_ioctl,
 		.compat_ioctl = 	snd_pcm_ioctl_compat,
+#else
+		.ioctl =		snd_pcm_capture_ioctl_old,
+#endif
 		.mmap =			snd_pcm_mmap,
 		.fasync =		snd_pcm_fasync,
 	}