patch-2.1.28 linux/drivers/sound/lowlevel/aci.c

Next file: linux/drivers/sound/lowlevel/aedsp16.c
Previous file: linux/drivers/sound/lowlevel/README.awe
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.27/linux/drivers/sound/lowlevel/aci.c linux/drivers/sound/lowlevel/aci.c
@@ -22,9 +22,9 @@
  *        First version written.
  *   1995-12-31  Markus Kuhn
  *        Second revision, general code cleanup.
- *   1996-05-16	 Hannu Savolainen
+ *   1997-05-16	 Hannu Savolainen
  *	  Integrated with other parts of the driver.
- *   1996-05-28  Markus Kuhn
+ *   1997-05-28  Markus Kuhn
  *        Initialize CS4231A mixer, make ACI first mixer,
  *        use new private mixer API for solo mode.
  */
@@ -73,6 +73,13 @@
 
 static int aci_present = 0;
 
+#ifdef MODULE                  /* Whether the aci mixer is to be reset.    */
+int aci_reset = 0;             /* Default: don't reset if the driver is a  */
+#else                          /* module; use "insmod sound.o aci_reset=1" */
+int aci_reset = 1;             /* to override.                             */
+#endif
+
+
 #define COMMAND_REGISTER    (aci_port)
 #define STATUS_REGISTER     (aci_port + 1)
 #define BUSY_REGISTER       (aci_port + 2)
@@ -282,7 +289,7 @@
   if (indexed_cmd(0xf0, right_index, &buf)) return -EIO;
   vol |= SCALE(0x20, 100, buf < 0x20 ? 0x20-buf : 0) << 8;
 
-  return snd_ioctl_return((int *) arg, vol);
+  return (*(int *) arg = vol);
 }
 
 
@@ -290,23 +297,21 @@
 		     unsigned char left_index, unsigned char right_index)
 {
   int vol, ret;
-  unsigned param;
 
-  param = get_user((int *) arg);
   /* left channel */
-  vol = param & 0xff;
+  vol = *(int *)arg & 0xff;
   if (vol > 100) vol = 100;
   vol = SCALE(100, 0x20, vol);
   if (write_cmd(left_index, 0x20 - vol)) return -EIO;
   ret = SCALE(0x20, 100, vol);
   /* right channel */
-  vol = (param >> 8) & 0xff;
+  vol = (*(int *)arg >> 8) & 0xff;
   if (vol > 100) vol = 100;
   vol = SCALE(100, 0x20, vol);
   if (write_cmd(right_index, 0x20 - vol)) return -EIO;
   ret |= SCALE(0x20, 100, vol) << 8;
  
-  return snd_ioctl_return((int *) arg, ret);
+  return (*(int *) arg = ret);
 }
 
 
@@ -318,14 +323,14 @@
 
   /* handle solo mode control */
   if (cmd == SOUND_MIXER_PRIVATE1) {
-    if (get_user((int *) arg) >= 0) {
-      aci_solo = !!get_user((int *) arg);
+    if (*(int *) arg >= 0) {
+      aci_solo = !!*(int *) arg;
       if (write_cmd(0xd2, aci_solo)) return -EIO;
     } else if (aci_version >= 0xb0) {
       if ((status = read_general_status()) < 0) return -EIO;
-      return snd_ioctl_return ((int *) arg, (status & 0x20) == 0);
+      return (*(int *) arg = (status & 0x20) == 0);
     }
-    return snd_ioctl_return((int *) arg, aci_solo);
+    return (*(int *) arg = aci_solo);
   }
 
   if (((cmd >> 8) & 0xff) == 'M') {
@@ -349,14 +354,14 @@
       case SOUND_MIXER_LINE2:  /* AUX2 */
 	return setvolume(arg, 0x3e, 0x36);
       case SOUND_MIXER_IGAIN:  /* MIC pre-amp */
-	vol = get_user((int *) arg) & 0xff;
+	vol = *(int *) arg & 0xff;
 	if (vol > 100) vol = 100;
 	vol = SCALE(100, 3, vol);
 	if (write_cmd(0x03, vol)) return -EIO;
 	vol = SCALE(3, 100, vol);
-	return snd_ioctl_return((int *) arg, vol | (vol << 8));
+	return (*(int *) arg = vol | (vol << 8));
       case SOUND_MIXER_RECSRC:
-	return snd_ioctl_return ((int *) arg, 0);
+	return (*(int *) arg = 0);
 	break;
       default:
 	return -EINVAL;
@@ -365,7 +370,7 @@
       /* only read */
       switch (cmd & 0xff) {
       case SOUND_MIXER_DEVMASK:
-	return snd_ioctl_return ((int *) arg,
+	return (*(int *) arg =
 				 SOUND_MASK_VOLUME | SOUND_MASK_CD    |
 				 SOUND_MASK_MIC    | SOUND_MASK_LINE  |
 				 SOUND_MASK_SYNTH  | SOUND_MASK_PCM   |
@@ -375,20 +380,20 @@
 				 SOUND_MASK_LINE1  | SOUND_MASK_LINE2);
 	break;
       case SOUND_MIXER_STEREODEVS:
-	return snd_ioctl_return ((int *) arg,
+	return (*(int *) arg =
 				 SOUND_MASK_VOLUME | SOUND_MASK_CD   |
 				 SOUND_MASK_MIC    | SOUND_MASK_LINE |
 				 SOUND_MASK_SYNTH  | SOUND_MASK_PCM  |
 				 SOUND_MASK_LINE1  | SOUND_MASK_LINE2);
 	break;
       case SOUND_MIXER_RECMASK:
-	return snd_ioctl_return ((int *) arg, 0);
+	return (*(int *) arg = 0);
 	break;
       case SOUND_MIXER_RECSRC:
-	return snd_ioctl_return ((int *) arg, 0);
+	return (*(int *) arg = 0);
 	break;
       case SOUND_MIXER_CAPS:
-	return snd_ioctl_return ((int *) arg, 0);
+	return (*(int *) arg = 0);
 	break;
       case SOUND_MIXER_VOLUME:
 	return getvolume(arg, 0x04, 0x03);
@@ -410,7 +415,7 @@
 	if (indexed_cmd(0xf0, 0x21, &buf)) return -EIO;
 	vol = SCALE(3, 100, buf <= 3 ? buf : 3);
 	vol |= vol << 8;
-	return snd_ioctl_return((int *) arg, vol);
+	return (*(int *) arg = vol);
       default:
 	return -EINVAL;
       }
@@ -507,15 +512,17 @@
   printk("<ACI %02x, id %02x %02x (%s)> at 0x%03x\n",
 	 aci_version, aci_idcode[0], aci_idcode[1], boardname, aci_port);
 
-  /* initialize ACI mixer */
-  implied_cmd(0xff);
-  aci_solo = 0;
+  if (aci_reset) {
+    /* initialize ACI mixer */
+    implied_cmd(0xff);
+    aci_solo = 0;
+  }
 
   /* attach the mixer */
   request_region(aci_port, 3, "sound mixer (ACI)");
   if (num_mixers < MAX_MIXER_DEV) {
     if (num_mixers > 0 &&
-        !strcmp("MAD16 WSS (CS4231A)", mixer_devs[num_mixers-1]->name)) {
+        !strncmp("MAD16 WSS", mixer_devs[num_mixers-1]->name, 9)) {
       /*
        * The previously registered mixer device is the CS4231A which
        * has no function on an ACI card. Make the ACI mixer the first
@@ -560,23 +567,30 @@
       mixer_devs[num_mixers++] = &aci_mixer_operations;
   }
 
-  /* Initialize ACI mixer with reasonable power-up values */
-  volume = 0x3232;
-  aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_VOLUME, (caddr_t) &volume);
-  volume = 0x3232;
-  aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_SYNTH,  (caddr_t) &volume);
-  volume = 0x3232;
-  aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_PCM,    (caddr_t) &volume);
-  volume = 0x3232;
-  aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_LINE,   (caddr_t) &volume);
-  volume = 0x3232;
-  aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_MIC,    (caddr_t) &volume);
-  volume = 0x3232;
-  aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_CD,     (caddr_t) &volume);
-  volume = 0x3232;
-  aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_LINE1,  (caddr_t) &volume);
-  volume = 0x3232;
-  aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_LINE2,  (caddr_t) &volume);
+  /* Just do something; otherwise the first write command fails, at
+   * least with my PCM20.
+   */
+  aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_READ_VOLUME, (caddr_t) &volume);
+
+  if (aci_reset) {
+    /* Initialize ACI mixer with reasonable power-up values */
+    volume = 0x3232;
+    aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_VOLUME, (caddr_t) &volume);
+    volume = 0x3232;
+    aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_SYNTH,  (caddr_t) &volume);
+    volume = 0x3232;
+    aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_PCM,    (caddr_t) &volume);
+    volume = 0x3232;
+    aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_LINE,   (caddr_t) &volume);
+    volume = 0x3232;
+    aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_MIC,    (caddr_t) &volume);
+    volume = 0x3232;
+    aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_CD,     (caddr_t) &volume);
+    volume = 0x3232;
+    aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_LINE1,  (caddr_t) &volume);
+    volume = 0x3232;
+    aci_mixer_ioctl(num_mixers-1, SOUND_MIXER_WRITE_LINE2,  (caddr_t) &volume);
+  }
   
   aci_present = 1;
 

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