Skip to contentSkip to conversation

patches for rme9652

PATCH Paul Davis 2 participants 3 messages May 9, 2002

lore
Share & tools
lore

Paul Davis

author
#0 lore raw

this patch fixes a bug in the hammerfall driver, and improves the code logic in a couple of places. the bug was that when we trigger the capture substream and there is no playback substream, we failed to silence the playback buffer. this leads to some potentially horrible noises during capture-only software execution (such as arecord). the code is also slightly rearranged to check h/w versions before doing resource allocation.

there is still a hard-to-solve bug in the driver: if you try to change between a "single-speed" sample rate and a "double-speed" sample rate by using the params API, it will fail because there is a substream already open. this was 100% by design - the speed change alters the number of channels and their memory locations. but its a silly restriction that needs to be fixed at some point.

please let me know when this is applied to CVS.

thanks
--p

Index: rme9652.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/rme9652/rme9652.c,v retrieving revision 1.15

rme9652.c +39 -11
diff -u -u -r1.15 rme9652.c
@@ -24,7 +24,6 @@
 #include <asm/io.h>
 #include <linux/delay.h>
 #include <linux/init.h>
-#include <linux/pci.h>
 #include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/control.h>
@@ -480,6 +479,10 @@
 	int reject_if_open = 0;
 	int xrate;
 
+	if (!snd_rme9652_use_is_exclusive (rme9652)) {
+		return -EBUSY;
+	}
+
 	/* Changing from a "single speed" to a "double speed" rate is
 	   not allowed if any substreams are open. This is because
 	   such a change causes a shift in the location of 
@@ -523,8 +526,7 @@
 		return -EINVAL;
 	}
 
-	if (reject_if_open &&
-	    (rme9652->capture_pid >= 0 || rme9652->playback_pid >= 0)) {
+	if (reject_if_open && (rme9652->capture_pid >= 0 || rme9652->playback_pid >= 0))
 		spin_unlock_irq(&rme9652->lock);
 		return -EBUSY;
 	}
@@ -2231,6 +2233,9 @@
 			    substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
 				rme9652_silence_playback(rme9652);
 		}
+	} else {
+		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) 
+			rme9652_silence_playback(rme9652);
 	}
  _ok:
 	snd_pcm_trigger_done(substream, substream);
@@ -2543,6 +2548,20 @@
 	rme9652->irq = -1;
 	rme9652->card = card;
 
+	pci_read_config_word(rme9652->pci, PCI_CLASS_REVISION, &rev);
+
+	switch (rev & 0xff) {
+	case 3:
+	case 4:
+	case 8:
+	case 9:
+		break;
+
+	default:
+		/* who knows? */
+		return -ENODEV;
+	}
+
 	if ((err = pci_enable_device(pci)) < 0)
 		return err;
 
@@ -2554,18 +2573,28 @@
 		return -EBUSY;
 	}
 
-	if (request_irq(pci->irq, snd_rme9652_interrupt, SA_INTERRUPT|SA_SHIRQ, "rme9652", (void *)rme9652)) {
-		snd_printk("unable to grab IRQ %d\n", pci->irq);
+	rme9652->iobase = (unsigned long) ioremap_nocache(rme9652->port, RME9652_IO_EXTENT);
+	if (rme9652->iobase == 0) {
+		snd_printk("unable to remap region 0x%lx-0x%lx\n", rme9652->port, rme9652->port + RME9652_IO_EXTENT - 1);
 		return -EBUSY;
 	}
-	rme9652->irq = pci->irq;
-
+	
 	rme9652->iobase = (unsigned long) ioremap_nocache(rme9652->port, RME9652_IO_EXTENT);
 	if (rme9652->iobase == 0) {
 		snd_printk("unable to remap region 0x%lx-0x%lx\n", rme9652->port, rme9652->port + RME9652_IO_EXTENT - 1);
 		return -EBUSY;
 	}
 	
+
+
+
+
+	if (request_irq(pci->irq, snd_rme9652_interrupt, SA_INTERRUPT|SA_SHIRQ, "rme9652", (void *)rme9652)) {
+		snd_printk("unable to grab IRQ %d\n", pci->irq);
+		return -EBUSY;
+	}
+	rme9652->irq = pci->irq;
+
 	rme9652->precise_ptr = precise_ptr;
 
 	/* Determine the h/w rev level of the card. This seems like
@@ -2587,9 +2616,7 @@
 	   relevant.  
 	*/
 
-	pci_read_config_word(rme9652->pci, PCI_CLASS_REVISION, &rev);
-	strcpy(card->driver, "RME9652");
-	switch (rev & 0xff) {
+	switch (rev) {
 	case 8: /* original eprom */
 		strcpy(card->driver, "RME9636");
 		if (rme9652->hw_rev == 15) {
@@ -2605,11 +2632,12 @@
 		rme9652->ss_channels = RME9636_NCHANNELS;
 		break;
 	case 4: /* W52_G EPROM */
+		strcpy(card->driver, "RME9652");
 		rme9652->card_name = "RME Digi9652 (Rev G)";
 		rme9652->ss_channels = RME9652_NCHANNELS;
 		break;
-	default:
 	case 3: /* original eprom */
+		strcpy(card->driver, "RME9652");
 		if (rme9652->hw_rev == 15) {
 			rme9652->card_name = "RME Digi9652 (Rev 1.5)";
 		} else {

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [email protected]

#1 lore raw
Quoted 8 lines · Paul Davis

this patch fixes a bug in the hammerfall driver, and improves the code logic in a couple of places. the bug was that when we trigger the capture substream and there is no playback substream, we failed to silence the playback buffer. this leads to some potentially horrible noises during capture-only software execution (such as arecord). the code is also slightly rearranged to check h/w versions before doing resource allocation.

Quoted 6 lines

there is still a hard-to-solve bug in the driver: if you try to change between a "single-speed" sample rate and a "double-speed" sample rate by using the params API, it will fail because there is a substream already open. this was 100% by design - the speed change alters the number of channels and their memory locations. but its a silly restriction that needs to be fixed at some point.

Note: We have hw_free callback for PCM resources which should clear all used resources. After this point, driver should allow to change ANY parameters.

Quoted 1 line

please let me know when this is applied to CVS.

Applied (the later one).

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project http://www.alsa-project.org
SuSE Linux http://www.suse.com

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [email protected]

author
#2 lore raw

[ changing between single and double speed modes on a hammerfall ]

Quoted 3 lines

Note: We have hw_free callback for PCM resources which should clear all used resources. After this point, driver should allow to change ANY parameters.

that doesn't solve the problem - there aren't any resources allocated that are channel count/location dependent. the reason for the restriction was that user space may have cached channel counts and worse still channel addresses. it may attempt to use these again after changing the rate to a value that invalidates these cached values.

however, after some reflection it seems to me that user space probably can't do any damage by using these cached values. they don't actually give user space access to any invalid memory or data structures, its just that the data they access may not refer to what the application thinks is actually there.

i think that its ok to simply remove this restriction, after another careful reading of the code. at the same time, we need to somehow document that changing the rate in this way has serious implications for the application.

takashi: when do you think we might see progress on a card info database?

Quoted 3 lines
Quoted 1 line

please let me know when this is applied to CVS.

Applied (the later one).

thanks.

--p

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [email protected]