]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/core/pcm_native.c
Pull sem2mutex-ioc4 into release branch
[linux-2.6-omap-h63xx.git] / sound / core / pcm_native.c
index 7bac1cbe38da4a122478ace0af3855422f805e83..f3d5de7b55acd3ee46fa01ebb2519c5ab2eac3df 100644 (file)
@@ -55,6 +55,7 @@ struct snd_pcm_hw_params_old {
        unsigned char reserved[64];
 };
 
+#ifdef CONFIG_SND_SUPPORT_OLD_API
 #define SNDRV_PCM_IOCTL_HW_REFINE_OLD _IOWR('A', 0x10, struct snd_pcm_hw_params_old)
 #define SNDRV_PCM_IOCTL_HW_PARAMS_OLD _IOWR('A', 0x11, struct snd_pcm_hw_params_old)
 
@@ -62,6 +63,8 @@ static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream,
                                      struct snd_pcm_hw_params_old __user * _oparams);
 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream,
                                      struct snd_pcm_hw_params_old __user * _oparams);
+#endif
+static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream);
 
 /*
  *
@@ -1554,7 +1557,8 @@ static struct file *snd_pcm_file_fd(int fd)
 {
        struct file *file;
        struct inode *inode;
-       unsigned short minor;
+       unsigned int minor;
+
        file = fget(fd);
        if (!file)
                return NULL;
@@ -1565,8 +1569,8 @@ static struct file *snd_pcm_file_fd(int fd)
                return NULL;
        }
        minor = iminor(inode);
-       if (minor >= 256 || 
-           minor % SNDRV_MINOR_DEVICES < SNDRV_MINOR_PCM_PLAYBACK) {
+       if (!snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_PLAYBACK) &&
+           !snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_CAPTURE)) {
                fput(file);
                return NULL;
        }
@@ -2071,18 +2075,30 @@ static int snd_pcm_open_file(struct file *file,
        return 0;
 }
 
-static int snd_pcm_open(struct inode *inode, struct file *file)
+static int snd_pcm_playback_open(struct inode *inode, struct file *file)
+{
+       struct snd_pcm *pcm;
+
+       pcm = snd_lookup_minor_data(iminor(inode),
+                                   SNDRV_DEVICE_TYPE_PCM_PLAYBACK);
+       return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK);
+}
+
+static int snd_pcm_capture_open(struct inode *inode, struct file *file)
 {
-       int cardnum = SNDRV_MINOR_CARD(iminor(inode));
-       int device = SNDRV_MINOR_DEVICE(iminor(inode));
-       int err;
        struct snd_pcm *pcm;
+
+       pcm = snd_lookup_minor_data(iminor(inode),
+                                   SNDRV_DEVICE_TYPE_PCM_CAPTURE);
+       return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE);
+}
+
+static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream)
+{
+       int err;
        struct snd_pcm_file *pcm_file;
        wait_queue_t wait;
 
-       if (device < SNDRV_MINOR_PCM_PLAYBACK || device >= SNDRV_MINOR_DEVICES)
-               return -ENXIO;
-       pcm = snd_pcm_devices[(cardnum * SNDRV_PCM_DEVICES) + (device % SNDRV_MINOR_PCMS)];
        if (pcm == NULL) {
                err = -ENODEV;
                goto __error1;
@@ -2098,7 +2114,7 @@ static int snd_pcm_open(struct inode *inode, struct file *file)
        add_wait_queue(&pcm->open_wait, &wait);
        down(&pcm->open_mutex);
        while (1) {
-               err = snd_pcm_open_file(file, pcm, device >= SNDRV_MINOR_PCM_CAPTURE ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK, &pcm_file);
+               err = snd_pcm_open_file(file, pcm, stream, &pcm_file);
                if (err >= 0)
                        break;
                if (err == -EAGAIN) {
@@ -2513,10 +2529,12 @@ static int snd_pcm_common_ioctl1(struct snd_pcm_substream *substream,
                return snd_pcm_delay(substream, arg);
        case SNDRV_PCM_IOCTL_SYNC_PTR:
                return snd_pcm_sync_ptr(substream, arg);
+#ifdef CONFIG_SND_SUPPORT_OLD_API
        case SNDRV_PCM_IOCTL_HW_REFINE_OLD:
                return snd_pcm_hw_refine_old_user(substream, arg);
        case SNDRV_PCM_IOCTL_HW_PARAMS_OLD:
                return snd_pcm_hw_params_old_user(substream, arg);
+#endif
        case SNDRV_PCM_IOCTL_DRAIN:
                return snd_pcm_drain(substream);
        case SNDRV_PCM_IOCTL_DROP:
@@ -3256,6 +3274,7 @@ static int snd_pcm_fasync(int fd, struct file * file, int on)
  *  To be removed helpers to keep binary compatibility
  */
 
+#ifdef CONFIG_SND_SUPPORT_OLD_API
 #define __OLD_TO_NEW_MASK(x) ((x&7)|((x&0x07fffff8)<<5))
 #define __NEW_TO_OLD_MASK(x) ((x&7)|((x&0xffffff00)>>5))
 
@@ -3365,45 +3384,35 @@ out:
        kfree(oparams);
        return err;
 }
+#endif /* CONFIG_SND_SUPPORT_OLD_API */
 
 /*
  *  Register section
  */
 
-static struct file_operations snd_pcm_f_ops_playback = {
-       .owner =        THIS_MODULE,
-       .write =        snd_pcm_write,
-       .writev =       snd_pcm_writev,
-       .open =         snd_pcm_open,
-       .release =      snd_pcm_release,
-       .poll =         snd_pcm_playback_poll,
-       .unlocked_ioctl =       snd_pcm_playback_ioctl,
-       .compat_ioctl = snd_pcm_ioctl_compat,
-       .mmap =         snd_pcm_mmap,
-       .fasync =       snd_pcm_fasync,
-};
-
-static struct file_operations snd_pcm_f_ops_capture = {
-       .owner =        THIS_MODULE,
-       .read =         snd_pcm_read,
-       .readv =        snd_pcm_readv,
-       .open =         snd_pcm_open,
-       .release =      snd_pcm_release,
-       .poll =         snd_pcm_capture_poll,
-       .unlocked_ioctl =       snd_pcm_capture_ioctl,
-       .compat_ioctl = snd_pcm_ioctl_compat,
-       .mmap =         snd_pcm_mmap,
-       .fasync =       snd_pcm_fasync,
-};
-
-struct snd_minor snd_pcm_reg[2] =
-{
+struct file_operations snd_pcm_f_ops[2] = {
        {
-               .comment =      "digital audio playback",
-               .f_ops =        &snd_pcm_f_ops_playback,
+               .owner =                THIS_MODULE,
+               .write =                snd_pcm_write,
+               .writev =               snd_pcm_writev,
+               .open =                 snd_pcm_playback_open,
+               .release =              snd_pcm_release,
+               .poll =                 snd_pcm_playback_poll,
+               .unlocked_ioctl =       snd_pcm_playback_ioctl,
+               .compat_ioctl =         snd_pcm_ioctl_compat,
+               .mmap =                 snd_pcm_mmap,
+               .fasync =               snd_pcm_fasync,
        },
        {
-               .comment =      "digital audio capture",
-               .f_ops =        &snd_pcm_f_ops_capture,
+               .owner =                THIS_MODULE,
+               .read =                 snd_pcm_read,
+               .readv =                snd_pcm_readv,
+               .open =                 snd_pcm_capture_open,
+               .release =              snd_pcm_release,
+               .poll =                 snd_pcm_capture_poll,
+               .unlocked_ioctl =       snd_pcm_capture_ioctl,
+               .compat_ioctl =         snd_pcm_ioctl_compat,
+               .mmap =                 snd_pcm_mmap,
+               .fasync =               snd_pcm_fasync,
        }
 };