patch-2.2.18 linux/drivers/sound/emu10k1/audio.c

Next file: linux/drivers/sound/emu10k1/cardmi.c
Previous file: linux/drivers/sound/emu10k1/Makefile
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/drivers/sound/emu10k1/audio.c linux/drivers/sound/emu10k1/audio.c
@@ -34,7 +34,13 @@
 #include <linux/module.h>
 #include <linux/poll.h>
 #include <linux/malloc.h>
+#include <linux/version.h>
+#include <linux/bitops.h>
 #include <asm/io.h>
+#include <linux/sched.h>
+#include <linux/smp_lock.h>
+#include <linux/wrapper.h>
+
 
 #include "hwaccess.h"
 #include "cardwo.h"
@@ -47,7 +53,7 @@
 static void calculate_ifrag(struct wiinst *);
 
 /* Audio file operations */
-static loff_t emu10k1_audio_llseek(struct file *file, loff_t offset, int nOrigin)
+static loff_t emu10k1_audio_llseek(struct file *file, loff_t offset, int origin)
 {
 	return -ESPIPE;
 }
@@ -61,7 +67,7 @@
 
 	GET_INODE_STRUCT();
 
-	DPD(4, "emu10k1_audio_read(), buffer=%p, count=%d\n", buffer, (u32) count);
+	DPD(3, "emu10k1_audio_read(), buffer=%p, count=%d\n", buffer, (u32) count);
 
 	if (ppos != &file->f_pos)
 		return -ESPIPE;
@@ -112,7 +118,7 @@
 
 		spin_unlock_irqrestore(&wiinst->lock, flags);
 
-		DPD(4, "bytestocopy --> %d\n", bytestocopy);
+		DPD(3, "bytestocopy --> %d\n", bytestocopy);
 
 		if ((bytestocopy >= wiinst->buffer.fragment_size)
 		    || (bytestocopy >= count)) {
@@ -140,7 +146,7 @@
 		}
 	}
 
-	DPD(4, "bytes copied -> %d\n", (u32) ret);
+	DPD(3, "bytes copied -> %d\n", (u32) ret);
 
 	return ret;
 }
@@ -154,7 +160,7 @@
 
 	GET_INODE_STRUCT();
 
-	DPD(4, "emu10k1_audio_write(), buffer=%p, count=%d\n", buffer, (u32) count);
+	DPD(3, "emu10k1_audio_write(), buffer=%p, count=%d\n", buffer, (u32) count);
 
 	if (ppos != &file->f_pos)
 		return -ESPIPE;
@@ -200,7 +206,7 @@
 		emu10k1_waveout_getxfersize(woinst, &bytestocopy);
 		spin_unlock_irqrestore(&woinst->lock, flags);
 
-		DPD(4, "bytestocopy --> %d\n", bytestocopy);
+		DPD(3, "bytestocopy --> %d\n", bytestocopy);
 
 		if ((bytestocopy >= woinst->buffer.fragment_size)
 		    || (bytestocopy >= count)) {
@@ -238,7 +244,7 @@
 		}
 	}
 
-	DPD(4, "bytes copied -> %d\n", (u32) ret);
+	DPD(3, "bytes copied -> %d\n", (u32) ret);
 
 	return ret;
 }
@@ -278,7 +284,7 @@
 
 					/* Undo marking the pages as reserved */
 					for (i = 0; i < woinst->buffer.pages; i++)
-						set_bit(PG_reserved, &mem_map[MAP_NR(woinst->buffer.addr[i])].flags);
+						mem_map_reserve(MAP_NR(woinst->buffer.addr[i]));
 				}
 
 				emu10k1_waveout_close(wave_dev);
@@ -328,7 +334,7 @@
 
 					/* Undo marking the pages as reserved */
 					for (i = 0; i < woinst->buffer.pages; i++)
-						set_bit(PG_reserved, &mem_map[MAP_NR(woinst->buffer.addr[i])].flags);
+						mem_map_reserve(MAP_NR(woinst->buffer.addr[i]));
 				}
 
 				emu10k1_waveout_close(wave_dev);
@@ -367,7 +373,9 @@
 	case SNDCTL_DSP_SPEED:
 		DPF(2, "SNDCTL_DSP_SPEED:\n");
 
-		get_user_ret(val, (int *) arg, -EFAULT);
+		if (get_user(val, (int *) arg))
+			return -EFAULT;
+
 		DPD(2, "val is %d\n", val);
 
 		if (val > 0) {
@@ -421,7 +429,9 @@
 	case SNDCTL_DSP_STEREO:
 		DPF(2, "SNDCTL_DSP_STEREO:\n");
 
-		get_user_ret(val, (int *) arg, -EFAULT);
+		if (get_user(val, (int *) arg))
+			return -EFAULT;
+
 		DPD(2, " val is %d\n", val);
 
 		if (file->f_mode & FMODE_READ) {
@@ -466,7 +476,9 @@
 	case SNDCTL_DSP_CHANNELS:
 		DPF(2, "SNDCTL_DSP_CHANNELS:\n");
 
-		get_user_ret(val, (int *) arg, -EFAULT);
+		if (get_user(val, (int *) arg))
+			return -EFAULT;
+
 		DPD(2, " val is %d\n", val);
 
 		if (val > 0) {
@@ -528,7 +540,9 @@
 	case SNDCTL_DSP_SETFMT:	/* Same as SNDCTL_DSP_SAMPLESIZE */
 		DPF(2, "SNDCTL_DSP_SETFMT:\n");
 
-		get_user_ret(val, (int *) arg, -EFAULT);
+		if (get_user(val, (int *) arg))
+			return -EFAULT;
+
 		DPD(2, " val is %d\n", val);
 
 		if (val != AFMT_QUERY) {
@@ -630,7 +644,8 @@
 	case SNDCTL_DSP_SETTRIGGER:
 		DPF(2, "SNDCTL_DSP_SETTRIGGER:\n");
 
-		get_user_ret(val, (int *) arg, -EFAULT);
+		if (get_user(val, (int *) arg))
+			return -EFAULT;
 
 		if (file->f_mode & FMODE_WRITE) {
 			spin_lock_irqsave(&woinst->lock, flags);
@@ -856,7 +871,8 @@
 	case SNDCTL_DSP_SETFRAGMENT:
 		DPF(2, "SNDCTL_DSP_SETFRAGMENT:\n");
 
-		get_user_ret(val, (int *) arg, -EFAULT);
+		if (get_user(val, (int *) arg))
+			return -EFAULT;
 
 		DPD(2, "val is 0x%x\n", val);
 
@@ -947,7 +963,7 @@
 
 			/* Now mark the pages as reserved, otherwise remap_page_range doesn't do what we want */
 			for (i = 0; i < woinst->buffer.pages; i++)
-				set_bit(PG_reserved, &mem_map[MAP_NR(woinst->buffer.addr[i])].flags);
+				mem_map_reserve(MAP_NR(woinst->buffer.addr[i]));
 		}
 
 		size = vma->vm_end - vma->vm_start;
@@ -995,7 +1011,7 @@
 	list_for_each(entry, &emu10k1_devs) {
 		card = list_entry(entry, struct emu10k1_card, list);
 
-		if (!((card->audio1_num ^ minor) & ~0xf) || !((card->audio2_num ^ minor) & ~0xf))
+		if (!((card->audio_num ^ minor) & ~0xf) || !((card->audio1_num ^ minor) & ~0xf))
 			break;
 	}
 
@@ -1026,7 +1042,10 @@
 			return -ENODEV;
 		}
 
-		switch (card->wavein->recsrc) {
+		wiinst->recsrc = card->wavein.recsrc;
+                wiinst->fxwc = card->wavein.fxwc;
+
+		switch (wiinst->recsrc) {
 		case WAVERECORD_AC97:
 			wiinst->format.samplingrate = 8000;
 			wiinst->format.bitsperchannel = 16;
@@ -1040,7 +1059,7 @@
 		case WAVERECORD_FX:
 			wiinst->format.samplingrate = 48000;
 			wiinst->format.bitsperchannel = 16;
-			wiinst->format.channels = 2;
+			wiinst->format.channels = hweight32(wiinst->fxwc);
 			break;
 		default:
 			BUG();
@@ -1049,7 +1068,6 @@
 
 		wiinst->state = WAVE_STATE_CLOSED;
 
-		wiinst->recsrc = card->wavein->recsrc;
 		wiinst->buffer.ossfragshift = 0;
 		wiinst->buffer.fragment_size = 0;
 		wiinst->buffer.numfrags = 0;
@@ -1087,7 +1105,7 @@
 		woinst->buffer.fragment_size = 0;
 		woinst->buffer.ossfragshift = 0;
 		woinst->buffer.numfrags = 0;
-		woinst->device = (card->audio2_num == minor);
+		woinst->device = (card->audio1_num == minor);
 
 		init_waitqueue_head(&woinst->wait_queue);
 
@@ -1149,9 +1167,11 @@
 static int emu10k1_audio_release(struct inode *inode, struct file *file)
 {
 	struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) file->private_data;
-	struct emu10k1_card *card = wave_dev->card;
+	struct emu10k1_card *card;
 	unsigned long flags;
 
+	card = wave_dev->card;
+
 	DPF(2, "emu10k1_audio_release()\n");
 
 	if (file->f_mode & FMODE_WRITE) {
@@ -1177,7 +1197,7 @@
 
 				/* Undo marking the pages as reserved */
 				for (i = 0; i < woinst->buffer.pages; i++)
-					set_bit(PG_reserved, &mem_map[MAP_NR(woinst->buffer.addr[i])].flags);
+					mem_map_reserve(MAP_NR(woinst->buffer.addr[i]));
 			}
 
 			emu10k1_waveout_close(wave_dev);
@@ -1451,7 +1471,7 @@
 	if (bytestocopy >= wiinst->buffer.fragment_size)
 		wake_up_interruptible(&wiinst->wait_queue);
 	else
-		DPD(4, "Not enough transfer size, %d\n", bytestocopy);
+		DPD(3, "Not enough transfer size, %d\n", bytestocopy);
 
 	return;
 }
@@ -1482,18 +1502,18 @@
 	if (bytestocopy >= woinst->buffer.fragment_size)
 		wake_up_interruptible(&woinst->wait_queue);
 	else
-		DPD(4, "Not enough transfer size -> %d\n", bytestocopy);
+		DPD(3, "Not enough transfer size -> %d\n", bytestocopy);
 
 	return;
 }
 
 struct file_operations emu10k1_audio_fops = {
-	llseek:emu10k1_audio_llseek,
-	read:emu10k1_audio_read,
-	write:emu10k1_audio_write,
-	poll:emu10k1_audio_poll,
-	ioctl:emu10k1_audio_ioctl,
-	mmap:emu10k1_audio_mmap,
-	open:emu10k1_audio_open,
-	release:emu10k1_audio_release,
+	llseek:		emu10k1_audio_llseek,
+	read:		emu10k1_audio_read,
+	write:		emu10k1_audio_write,
+	poll:		emu10k1_audio_poll,
+	ioctl:		emu10k1_audio_ioctl,
+	mmap:		emu10k1_audio_mmap,
+	open:		emu10k1_audio_open,
+	release:	emu10k1_audio_release,
 };

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)