patch-2.1.63 linux/drivers/sound/audio.c

Next file: linux/drivers/sound/configure.c
Previous file: linux/drivers/sound/adlib_card.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.62/linux/drivers/sound/audio.c linux/drivers/sound/audio.c
@@ -30,7 +30,7 @@
 #define		AM_NONE		0
 #define		AM_WRITE	OPEN_WRITE
 #define 	AM_READ		OPEN_READ
-static int      dma_ioctl (int dev, unsigned int cmd, caddr_t arg);
+int      dma_ioctl (int dev, unsigned int cmd, caddr_t arg);
 
 
 static int      local_format[MAX_AUDIO_DEV], audio_format[MAX_AUDIO_DEV];
@@ -59,7 +59,7 @@
   else
     return local_format[dev];
 
-  return audio_format[dev];
+  return local_format[dev];
 }
 
 int
@@ -247,12 +247,16 @@
 	{
 	  if ((dma_buf + l) >
 	      (audio_devs[dev]->dmap_out->raw_buf + audio_devs[dev]->dmap_out->buffsize))
-	    printk ("audio: Buffer error 3 (%lx,%d), (%lx, %d)\n",
-		    (long) dma_buf, l,
-		    (long) audio_devs[dev]->dmap_out->raw_buf,
-		    (int) audio_devs[dev]->dmap_out->buffsize);
+	    {
+	      printk ("audio: Buffer error 3 (%lx,%d), (%lx, %d)\n", (long) dma_buf, l, (long) audio_devs[dev]->dmap_out->raw_buf, (int) audio_devs[dev]->dmap_out->buffsize);
+	      return -EDOM;
+	    }
+
 	  if (dma_buf < audio_devs[dev]->dmap_out->raw_buf)
-	    printk ("audio: Buffer error 13\n");
+	    {
+	      printk ("audio: Buffer error 13 (%lx<%lx)\n", (long) dma_buf, (long) audio_devs[dev]->dmap_out->raw_buf);
+	      return -EDOM;
+	    }
 	  copy_from_user (dma_buf, &(buf)[p], l);
 	}
       else
@@ -352,7 +356,7 @@
 {
   int             val;
 
-  /* printk("audio_ioctl(%x, %x)\n", (int)cmd, (int)arg); */
+  /* printk( "audio_ioctl(%x, %x)\n",  (int)cmd,  (int)arg); */
 
   dev = dev >> 4;
 
@@ -484,8 +488,7 @@
 	  n = *(int *) arg;
 	  if (n > 1)
 	    {
-	      printk ("sound: SNDCTL_DSP_STEREO called with invalid argument %d\n",
-		      n);
+	      printk ("sound: SNDCTL_DSP_STEREO called with invalid argument %d\n", n);
 	      return -EINVAL;
 	    }
 
@@ -550,13 +553,9 @@
   unsigned        i, n;
   unsigned        sr, nc, sz, bsz;
 
-  if (!dmap->needs_reorg)
-    return;
-
   sr = dsp_dev->d->set_speed (dev, 0);
   nc = dsp_dev->d->set_channels (dev, 0);
   sz = dsp_dev->d->set_bits (dev, 0);
-  dmap->needs_reorg = 0;
 
   if (sz == 8)
     dmap->neutral_byte = NEUTRAL8;
@@ -565,8 +564,7 @@
 
   if (sr < 1 || nc < 1 || sz < 1)
     {
-      printk ("Warning: Invalid PCM parameters[%d] sr=%d, nc=%d, sz=%d\n",
-	      dev, sr, nc, sz);
+      printk ("Warning: Invalid PCM parameters[%d] sr=%d, nc=%d, sz=%d\n", dev, sr, nc, sz);
       sr = DSP_DEFAULT_SPEED;
       nc = 1;
       sz = 8;
@@ -577,6 +575,10 @@
   sz /= 8;			/* #bits -> #bytes */
   dmap->data_rate = sz;
 
+  if (!dmap->needs_reorg)
+    return;
+  dmap->needs_reorg = 0;
+
   if (dmap->fragment_size == 0)
     {				/* Compute the fragment size using the default algorithm */
 
@@ -752,7 +754,7 @@
     return 0;
 }
 
-static int
+int
 dma_ioctl (int dev, unsigned int cmd, caddr_t arg)
 {
 
@@ -841,6 +843,11 @@
 
 	if (cmd == SNDCTL_DSP_GETISPACE && dmap->qlen)
 	  info->bytes -= dmap->counts[dmap->qhead];
+	else
+	  {
+	    info->fragments = info->bytes / dmap->fragment_size;
+	    info->bytes -= dmap->user_counter % dmap->fragment_size;
+	  }
       }
       return 0;
 

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