patch-2.1.128 linux/drivers/sound/dmabuf.c

Next file: linux/drivers/sound/dmasound.c
Previous file: linux/drivers/sound/dev_table.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.127/linux/drivers/sound/dmabuf.c linux/drivers/sound/dmabuf.c
@@ -18,7 +18,10 @@
  *                   determine if it was woken up by the expiring timeout or by
  *                   an explicit wake_up. The return value from schedule_timeout
  *		     can be used instead; if 0, the wakeup was due to the timeout.
+ *
+ * Rob Riggs		Added persistent DMA buffers (1998/10/17)
  */
+ 
 #include <linux/config.h>
 
 #define BE_CONSERVATIVE
@@ -28,6 +31,9 @@
 
 #if defined(CONFIG_AUDIO) || defined(CONFIG_GUS)
 
+#define DMAP_FREE_ON_CLOSE      0
+#define DMAP_KEEP_ON_CLOSE      1
+extern int sound_dmap_flag;
 
 static void dma_reset_output(int dev);
 static void dma_reset_input(int dev);
@@ -212,7 +218,8 @@
 	disable_dma(dmap->dma);
 	release_dma_lock(flags);
 	
-	sound_free_dmap(dmap);
+	if (sound_dmap_flag == DMAP_FREE_ON_CLOSE)
+		sound_free_dmap(dmap);
 }
 
 
@@ -732,7 +739,7 @@
 	 * Wait for free space
 	 */
 	if (signal_pending(current))
-		return -EIO;
+		return -EINTR;
 	timeout = (adev->go && !(dmap->flags & DMA_NOTIMEOUT));
 	if (timeout) 
 		timeout_value = dmabuf_timeout(dmap);
@@ -1009,8 +1016,8 @@
 		unsigned long f;
 		
 		f=claim_dma_lock();
-		clear_dma_ff(chan);
 		disable_dma(dmap->dma);
+		clear_dma_ff(chan);
 		pos = dmap->bytes_in_use - get_dma_residue(chan);
 		enable_dma(dmap->dma);
 		release_dma_lock(f);
@@ -1104,8 +1111,8 @@
 		unsigned long f;
 		
 		f=claim_dma_lock();
-		clear_dma_ff(chan);
 		disable_dma(dmap->dma);
+		clear_dma_ff(chan);
 		pos = dmap->bytes_in_use - get_dma_residue(chan);
 		enable_dma(dmap->dma);
 		release_dma_lock(f);
@@ -1181,6 +1188,13 @@
 				adev->dmap_in->dma = dma2;
 			}
 		}
+		/* Persistent DMA buffers allocated here */
+		if (sound_dmap_flag == DMAP_KEEP_ON_CLOSE) {
+			if (adev->dmap_in->raw_buf == NULL)
+				sound_alloc_dmap(adev->dmap_in);
+			if (adev->dmap_out->raw_buf == NULL)
+				sound_alloc_dmap(adev->dmap_out);
+		}
 	}
 }
 
@@ -1251,12 +1265,13 @@
 	/* This routine is called when driver is being unloaded */
 	if (!adev)
 		return;
-#ifdef RUNTIME_DMA_ALLOC
-	sound_free_dmap(adev->dmap_out);
 
-	if (adev->flags & DMA_DUPLEX)
-		sound_free_dmap(adev->dmap_in);
-#endif
+	/* Persistent DMA buffers deallocated here */
+	if (sound_dmap_flag == DMAP_KEEP_ON_CLOSE) {
+		sound_free_dmap(adev->dmap_out);
+		if (adev->flags & DMA_DUPLEX)
+			sound_free_dmap(adev->dmap_in);
+	}
 }
 
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov