patch-2.4.6 linux/drivers/sbus/audio/audio.c

Next file: linux/drivers/sbus/audio/cs4231.c
Previous file: linux/drivers/sbus/audio/amd7930.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.5/linux/drivers/sbus/audio/audio.c linux/drivers/sbus/audio/audio.c
@@ -1,4 +1,4 @@
-/* $Id: audio.c,v 1.58 2001/02/13 01:16:59 davem Exp $
+/* $Id: audio.c,v 1.60 2001/05/21 09:05:05 davem Exp $
  * drivers/sbus/audio/audio.c
  *
  * Copyright 1996 Thomas K. Dyas (tdyas@noc.rutgers.edu)
@@ -32,10 +32,11 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/soundcard.h>
-#include <linux/version.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/delay.h>
+#include <linux/poll.h>
 #include <asm/pgtable.h>
+#include <asm/uaccess.h>
 
 #include <asm/audioio.h>
 
@@ -73,24 +74,6 @@
 static struct sparcaudio_driver *drivers[SPARCAUDIO_MAX_DEVICES];
 static devfs_handle_t devfs_handle;
  
-/* This crap to be pulled off into a local include file */
-#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE < 0x20100
-
-#define COPY_IN(arg, get) verify_area(VERIFY_READ, (void *)arg, sizeof(long)); memcpy_fromfs(&get, (long *)arg, sizeof(get));
-#define COPY_OUT(arg, ret) verify_area(VERIFY_WRITE, (void *)arg, sizeof(long)); memcpy_tofs((long *)arg, &ret, sizeof(ret));
-#define copy_to_user memcpy_tofs
-#define copy_from_user memcpy_fromfs
-#define signal_pending(x) (((x)->signal) & ~((x)->blocked))
-
-#else
-
-#include <asm/uaccess.h>
-#include <linux/poll.h>
-#define COPY_IN(arg, get) get_user(get, (int *)arg)
-#define COPY_OUT(arg, ret) put_user(ret, (int *)arg)
-#define sparcaudio_select sparcaudio_poll
-
-#endif
 
 void sparcaudio_output_done(struct sparcaudio_driver * drv, int status)
 {
@@ -215,37 +198,6 @@
  *	VFS layer interface
  */
 
-#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE < 0x20100
-static int sparcaudio_select(struct inode * inode, struct file * file,
-			    int sel_type, select_table * wait)
-{
-        struct sparcaudio_driver *drv = drivers[(MINOR(inode->i_rdev) >>
-                                                 SPARCAUDIO_DEVICE_SHIFT)];
-  
-        switch (sel_type) {
-        case SEL_IN:
-                if (((!file->f_flags & O_NONBLOCK) && drv->input_count) ||
-                    (drv->input_size > drv->buffer_size)) {
-                        dprintk(("read ready: c%d o%d\n",
-                                 drv->input_count, drv->input_offset));
-                        return 1;
-                }
-                select_wait(&drv->input_read_wait, wait);
-                break;
-        case SEL_OUT:
-                dprintk(("sel out: c%d o%d p%d\n",
-                         drv->output_count, drv->output_offset, drv->playing_count));
-                if ((drv->output_count + drv->playing_count) < (drv->num_output_buffers))
-                        return 1;
-                select_wait(&drv->output_write_wait, wait);
-                break;
-        case SEL_EX:
-                break;
-        };
-
-        return 0;
-}
-#else
 static unsigned int sparcaudio_poll(struct file *file, poll_table * wait)
 {
         unsigned int mask = 0;
@@ -264,29 +216,16 @@
         }
         return mask;
 }
-#endif
 
-#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE < 0x20100
-static int sparcaudio_lseek(struct inode * inode, struct file * file,
-			    off_t offset, int origin)
-#else
-static loff_t sparcaudio_lseek(struct file * file, loff_t offset, int origin)
-#endif
+static loff_t sparcaudio_llseek(struct file * file, loff_t offset, int origin)
 {
 	return -ESPIPE;
 }
 
-#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE < 0x20100
-static int sparcaudio_read(struct inode * inode, struct file * file,
-			   char *buf, int count)
-#else
 static ssize_t sparcaudio_read(struct file * file, char *buf, 
                                size_t count, loff_t *ppos)
-#endif
 {
-#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x200ff
         struct inode *inode = file->f_dentry->d_inode;
-#endif
         struct sparcaudio_driver *drv = drivers[(MINOR(inode->i_rdev) >>
                                                  SPARCAUDIO_DEVICE_SHIFT)];
         int bytes_to_copy, bytes_read = 0, err;
@@ -358,17 +297,10 @@
         restore_flags(flags);
 }
 
-#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE < 0x20100
-static int sparcaudio_write(struct inode * inode, struct file * file,
-			    const char *buf, int count)
-#else
 static ssize_t sparcaudio_write(struct file * file, const char *buf,
                                 size_t count, loff_t *ppos)
-#endif
 {
-#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x200ff
         struct inode *inode = file->f_dentry->d_inode;
-#endif
         struct sparcaudio_driver *drv = drivers[(MINOR(inode->i_rdev) >>
                                                  SPARCAUDIO_DEVICE_SHIFT)];
         int bytes_written = 0, bytes_to_copy, err;
@@ -499,7 +431,7 @@
 
         switch (cmd) {
         case SOUND_MIXER_WRITE_RECLEV:
-                if(COPY_IN(arg, k))
+                if (get_user(k, (int *)arg))
                         return -EFAULT;
         iretry:
                 oprintk(("setting input volume (0x%x)", k));
@@ -531,9 +463,9 @@
                         oprintk((" try 0x%x\n", k));
                         goto iretry;
                 }
-                return COPY_OUT(arg, i);
+                return put_user(i, (int *)arg);
         case SOUND_MIXER_WRITE_VOLUME:
-                if(COPY_IN(arg, k))
+                if (get_user(k, (int *)arg))
                         return -EFAULT;
                 if (drv->ops->get_output_muted && drv->ops->set_output_muted) {
                         i = drv->ops->get_output_muted(drv);
@@ -546,9 +478,9 @@
                 if (drv->ops->get_output_muted) 
                         i = drv->ops->get_output_muted(drv);
                 k = 0x6464 * (1 - i);
-                return COPY_OUT(arg, k);
+                return put_user(k, (int *)arg);
         case SOUND_MIXER_WRITE_PCM:
-                if(COPY_IN(arg, k))
+                if (get_user(k, (int *)arg))
                         return -EFAULT;
         oretry:
                 oprintk(("setting output volume (0x%x)\n", k));
@@ -582,25 +514,25 @@
                         oprintk((" try 0x%x\n", k));
                         goto oretry;
                 }
-                return COPY_OUT(arg, i);
+                return put_user(i, (int *)arg);
         case SOUND_MIXER_READ_SPEAKER:
                 k = OSS_PORT_AUDIO(drv, AUDIO_SPEAKER);
-                return COPY_OUT(arg, k);
+                return put_user(k, (int *)arg);
         case SOUND_MIXER_READ_MIC:
                 k = OSS_IPORT_AUDIO(drv, AUDIO_MICROPHONE);
-                return COPY_OUT(arg, k);
+                return put_user(k, (int *)arg);
         case SOUND_MIXER_READ_CD:
                 k = OSS_IPORT_AUDIO(drv, AUDIO_CD);
-                return COPY_OUT(arg, k);
+                return put_user(k, (int *)arg);
         case SOUND_MIXER_READ_LINE:
                 k = OSS_IPORT_AUDIO(drv, AUDIO_LINE_IN);
-                return COPY_OUT(arg, k);
+                return put_user(k, (int *)arg);
         case SOUND_MIXER_READ_LINE1:
                 k = OSS_PORT_AUDIO(drv, AUDIO_HEADPHONE);
-                return COPY_OUT(arg, k);
+                return put_user(k, (int *)arg);
         case SOUND_MIXER_READ_LINE2:
                 k = OSS_PORT_AUDIO(drv, AUDIO_LINE_OUT);
-                return COPY_OUT(arg, k);
+                return put_user(k, (int *)arg);
 
         case SOUND_MIXER_WRITE_MIC:
         case SOUND_MIXER_WRITE_CD:
@@ -608,7 +540,7 @@
         case SOUND_MIXER_WRITE_LINE1:
         case SOUND_MIXER_WRITE_LINE2:
         case SOUND_MIXER_WRITE_SPEAKER:
-                if(COPY_IN(arg, k))
+                if (get_user(k, (int *)arg))
                         return -EFAULT;
                 OSS_TWIDDLE_IPORT(drv, cmd, SOUND_MIXER_WRITE_LINE, AUDIO_LINE_IN, k);
                 OSS_TWIDDLE_IPORT(drv, cmd, SOUND_MIXER_WRITE_MIC, AUDIO_MICROPHONE, k);
@@ -617,7 +549,7 @@
                 OSS_TWIDDLE_PORT(drv, cmd, SOUND_MIXER_WRITE_SPEAKER, AUDIO_SPEAKER, k);
                 OSS_TWIDDLE_PORT(drv, cmd, SOUND_MIXER_WRITE_LINE1, AUDIO_HEADPHONE, k);
                 OSS_TWIDDLE_PORT(drv, cmd, SOUND_MIXER_WRITE_LINE2, AUDIO_LINE_OUT, k);
-                return COPY_OUT(arg, k);
+                return put_user(k, (int *)arg);
         case SOUND_MIXER_READ_RECSRC: 
                 if (drv->ops->get_input_port)
                         i = drv->ops->get_input_port(drv);
@@ -627,11 +559,11 @@
                 if (i & AUDIO_LINE_IN) j = SOUND_MASK_LINE;
                 if (i & AUDIO_MICROPHONE) j = SOUND_MASK_MIC;
     
-                return COPY_OUT(arg, j);
+                return put_user(j, (int *)arg);
   case SOUND_MIXER_WRITE_RECSRC: 
           if (!drv->ops->set_input_port)
                   return -EINVAL;
-          if(COPY_IN(arg, k))
+          if (get_user(k, (int *)arg))
                   return -EFAULT;
 
           /* only one should ever be selected */
@@ -641,7 +573,7 @@
           oprintk(("setting inport to %d\n", j));
           i = drv->ops->set_input_port(drv, j);
     
-          return COPY_OUT(arg, i);
+          return put_user(i, (int *)arg);
         case SOUND_MIXER_READ_RECMASK: 
                 if (drv->ops->get_input_ports)
                         i = drv->ops->get_input_ports(drv);
@@ -650,10 +582,10 @@
                 if (i & AUDIO_LINE_IN) j |= SOUND_MASK_LINE;
                 if (i & AUDIO_CD) j |= SOUND_MASK_CD;
     
-                return COPY_OUT(arg, j);
+                return put_user(j, (int *)arg);
         case SOUND_MIXER_READ_CAPS: /* mixer capabilities */
                 i = SOUND_CAP_EXCL_INPUT;
-                return COPY_OUT(arg, i);
+                return put_user(i, (int *)arg);
 
         case SOUND_MIXER_READ_DEVMASK: /* all supported devices */
                 if (drv->ops->get_input_ports)
@@ -676,7 +608,7 @@
 
                 if (cmd == SOUND_MIXER_READ_STEREODEVS)
                         j &= ~(MONO_DEVICES);
-                return COPY_OUT(arg, j);
+                return put_user(j, (int *)arg);
         default:
                 return -EINVAL;
         };
@@ -742,7 +674,7 @@
                 case I_GETSIG:
                 case I_GETSIG_SOLARIS:
                         j = (int) lis_get_elist_ent(drv->sd_siglist,current->pid);
-                        COPY_OUT(arg, j);
+                        put_user(j, (int *)arg);
                         retval = drv->input_count;
                         break;
 
@@ -773,7 +705,7 @@
                          * as its retval. (streamio(7I)) This should work.
                          */
                         j = (drv->input_count > 0) ? drv->input_buffer_size : 0;
-                        COPY_OUT(arg, j);
+                        put_user(j, (int *)arg);
                         retval = drv->input_count;
                         break;
 
@@ -859,11 +791,11 @@
                                 if (drv->ops->get_output_pause(drv))
                                         j |= PCM_ENABLE_OUTPUT;
                         }
-                        COPY_OUT(arg, j);
+                        put_user(j, (int *)arg);
                         break;
                 case SNDCTL_DSP_GETBLKSIZE:
                         j = drv->input_buffer_size;
-                        COPY_OUT(arg, j);
+                        put_user(j, (int *)arg);
                         break;
                 case SNDCTL_DSP_SPEED:
                         if ((!drv->ops->set_output_rate) && 
@@ -871,12 +803,12 @@
                                 retval = -EINVAL;
                                 break;
                         }
-                        COPY_IN(arg, i);
+                        get_user(i, (int *)arg)
                         tprintk(("setting speed to %d\n", i));
                         drv->ops->set_input_rate(drv, i);
                         drv->ops->set_output_rate(drv, i);
                         j = drv->ops->get_output_rate(drv);
-                        COPY_OUT(arg, j);
+                        put_user(j, (int *)arg);
                         break;
                 case SNDCTL_DSP_GETCAPS:
                         /* All Sparc audio hardware is full duplex.
@@ -884,19 +816,19 @@
                          * Pause functionality emulates trigger
                          */
                         j = DSP_CAP_DUPLEX | DSP_CAP_TRIGGER | DSP_CAP_REALTIME;
-                        COPY_OUT(arg, j);
+                        put_user(j, (int *)arg);
                         break;
                 case SNDCTL_DSP_GETFMTS:
                         if (drv->ops->get_formats) {
                                 j = drv->ops->get_formats(drv);
-                                COPY_OUT(arg, j);
+                                put_user(j, (int *)arg);
                         } else {
                                 retval = -EINVAL;
                         }
                         break;
                 case SNDCTL_DSP_SETFMT:
                         /* need to decode into encoding, precision */
-                        COPY_IN(arg, i);
+                        get_user(i, (int *)arg);
 	    
                         /* handle special case here */
                         if (i == AFMT_QUERY) {
@@ -926,7 +858,7 @@
                                                 break;
                                         };
                                 } 
-                                COPY_OUT(arg, i);
+                                put_user(i, (int *)arg);
                                 break;
                         }
 
@@ -991,7 +923,7 @@
                                 dprintk(("setting format: failed\n"));
                                 return -EINVAL;
                         }
-                        COPY_OUT(arg, i);
+                        put_user(i, (int *)arg);
                         break;
                 case SNDCTL_DSP_CHANNELS:
                         if ((!drv->ops->set_output_channels) && 
@@ -999,11 +931,11 @@
                                 retval = -EINVAL;
                                 break;
                         }
-                        COPY_IN(arg, i);
+                        get_user(i, (int *)arg);
                         drv->ops->set_input_channels(drv, i);
                         drv->ops->set_output_channels(drv, i);
                         i = drv->ops->get_output_channels(drv);
-                        COPY_OUT(arg, i);
+                        put_user(i, (int *)arg);
                         break;
                 case SNDCTL_DSP_STEREO:
                         if ((!drv->ops->set_output_channels) && 
@@ -1011,11 +943,11 @@
                                 retval = -EINVAL;
                                 break;
                         }
-                        COPY_IN(arg, i);
+                        get_user(i, (int *)arg);
                         drv->ops->set_input_channels(drv, (i + 1));
                         drv->ops->set_output_channels(drv, (i + 1));
                         i = ((drv->ops->get_output_channels(drv)) - 1);
-                        COPY_OUT(arg, i);
+                        put_user(i, (int *)arg);
                         break;
                 case SNDCTL_DSP_POST:
                 case SNDCTL_DSP_SYNC:
@@ -1761,14 +1693,14 @@
 	default:
                 eprintk(("unknown minor device number\n"));
                 retval = -EINVAL;
-	};
+	}
 	
 	return retval;
 }
 
 static struct file_operations sparcaudioctl_fops = {
 	owner:		THIS_MODULE,
-	poll:		sparcaudio_select,
+	poll:		sparcaudio_poll,
 	ioctl:		sparcaudio_ioctl,
 };
 
@@ -1960,10 +1892,10 @@
 
 static struct file_operations sparcaudio_fops = {
 	owner:		THIS_MODULE,
-	llseek:		sparcaudio_lseek,
+	llseek:		sparcaudio_llseek,
 	read:		sparcaudio_read,
 	write:		sparcaudio_write,
-	poll:		sparcaudio_select,
+	poll:		sparcaudio_poll,
 	ioctl:		sparcaudio_ioctl,
 	open:		sparcaudio_open,
 	release:	sparcaudio_release,
@@ -2032,12 +1964,10 @@
          * TODO: Make number of input/output buffers tunable parameters
          */
 
-#if defined (LINUX_VERSION_CODE) && LINUX_VERSION_CODE > 0x202ff
         init_waitqueue_head(&drv->open_wait);
         init_waitqueue_head(&drv->output_write_wait);
         init_waitqueue_head(&drv->output_drain_wait);
         init_waitqueue_head(&drv->input_read_wait);
-#endif
 
         drv->num_output_buffers = 8;
 	drv->output_buffer_size = (4096 * 2);
@@ -2204,20 +2134,6 @@
 		return -EIO;
 
 	devfs_handle = devfs_mk_dir (NULL, "sound", NULL);
-	
-#ifdef CONFIG_SPARCAUDIO_AMD7930
-	amd7930_init();
-#endif
-#ifdef CONFIG_SPARCAUDIO_DBRI
-        dbri_init();
-#endif
-#ifdef CONFIG_SPARCAUDIO_CS4231
-	cs4231_init();
-#endif
-#ifdef CONFIG_SPARCAUDIO_DUMMY
-	dummy_init();
-#endif
-
 	return 0;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)