patch-2.1.6 linux/drivers/sound/sb_audio.c

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

diff -u --recursive --new-file v2.1.5/linux/drivers/sound/sb_audio.c linux/drivers/sound/sb_audio.c
@@ -6,7 +6,7 @@
 /*
  * Copyright (C) by Hannu Savolainen 1993-1996
  *
- * USS/Lite for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
+ * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
  * Version 2 (June 1991). See the "COPYING" file distributed with this software
  * for more info.
  */
@@ -29,13 +29,13 @@
   if (devc == NULL)
     {
       printk ("SB: Incomplete initialization\n");
-      return -(ENXIO);
+      return -ENXIO;
     }
 
   if (devc->caps & SB_NO_RECORDING && mode & OPEN_READ)
     {
       printk ("SB: Recording is not possible with this device\n");
-      return -(EPERM);
+      return -EPERM;
     }
 
   save_flags (flags);
@@ -43,14 +43,14 @@
   if (devc->opened)
     {
       restore_flags (flags);
-      return -(EBUSY);
+      return -EBUSY;
     }
 
   if (devc->dma16 != -1 && devc->dma16 != devc->dma8)
     {
       if (sound_open_dma (devc->dma16, "Sound Blaster 16 bit"))
 	{
-	  return -(EBUSY);
+	  return -EBUSY;
 	}
     }
   devc->opened = mode;
@@ -541,7 +541,8 @@
     if (channels != devc->channels)
       {
 	devc->channels = channels;
-	sbpro_audio_set_speed (dev, devc->speed);
+	if (devc->model == MDL_SBPRO)
+	  sbpro_audio_set_speed (dev, devc->speed);
       }
   return devc->channels;
 }
@@ -578,6 +579,37 @@
  * ESS specific routines
  */
 
+static int
+ess_audio_set_speed (int dev, int speed)
+{
+  sb_devc        *devc = audio_devs[dev]->devc;
+  int             divider;
+
+  if (speed > 0)
+    {
+      if (speed < 5000)
+	speed = 4000;
+
+      if (speed > 48000)
+	speed = 48000;
+
+      if (speed > 22000)
+	{
+	  divider = (795500 + speed / 2) / speed;
+	  speed = (795500 + divider / 2) / divider;
+	}
+      else
+	{
+	  divider = (397700 + speed / 2) / speed;
+	  speed = (397700 + divider / 2) / divider;
+	}
+
+      devc->speed = speed;
+    }
+
+  return devc->speed;
+}
+
 static void
 ess_speed (sb_devc * devc)
 {
@@ -965,7 +997,7 @@
 static int
 sb_audio_ioctl (int dev, unsigned int cmd, caddr_t arg, int local)
 {
-  return -(EINVAL);
+  return -EINVAL;
 }
 
 static void
@@ -1122,7 +1154,7 @@
   NULL,
   NULL,
   ess_audio_trigger,
-  sb16_audio_set_speed,
+  ess_audio_set_speed,
   sb16_audio_set_bits,
   sbpro_audio_set_channels
 };

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