Pull acpica into release branch
[pandora-kernel.git] / drivers / media / video / em28xx / em28xx-video.c
index 780342f..cf7cdf9 100644 (file)
@@ -38,6 +38,7 @@
 #include "em28xx.h"
 #include <media/tuner.h>
 #include <media/v4l2-common.h>
+#include <media/msp3400.h>
 
 #define DRIVER_AUTHOR "Ludovico Cavedon <cavedon@sssup.it>, " \
                      "Markus Rechberger <mrechberger@gmail.com>, " \
@@ -216,9 +217,14 @@ static void video_mux(struct em28xx *dev, int index)
        em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,input,dev->ctl_ainput);
 
        if (dev->has_msp34xx) {
+               struct v4l2_routing route;
+
                if (dev->i2s_speed)
                        em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed);
-               em28xx_i2c_call_clients(dev, VIDIOC_S_AUDIO, &dev->ctl_ainput);
+               route.input = dev->ctl_ainput;
+               route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
+               /* Note: this is msp3400 specific */
+               em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route);
                ainput = EM28XX_AUDIO_SRC_TUNER;
                em28xx_audio_source(dev, ainput);
        } else {
@@ -1135,26 +1141,16 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
        case VIDIOC_G_TUNER:
        {
                struct v4l2_tuner *t = arg;
-               int status = 0;
 
                if (0 != t->index)
                        return -EINVAL;
 
                memset(t, 0, sizeof(*t));
                strcpy(t->name, "Tuner");
-               t->type = V4L2_TUNER_ANALOG_TV;
-               t->capability = V4L2_TUNER_CAP_NORM;
-               t->rangehigh = 0xffffffffUL;    /* FIXME: set correct range */
-/*             t->signal = 0xffff;*/
-/*             em28xx_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/
-               /* No way to get signal strength? */
                mutex_lock(&dev->lock);
-               em28xx_i2c_call_clients(dev, DECODER_GET_STATUS,
-                                       &status);
+               /* let clients fill in the remainder of this struct */
+               em28xx_i2c_call_clients(dev, cmd, t);
                mutex_unlock(&dev->lock);
-               t->signal =
-                       (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0;
-
                em28xx_videodbg("VIDIO_G_TUNER: signal=%x, afc=%x\n", t->signal,
                                t->afc);
                return 0;
@@ -1162,26 +1158,13 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
        case VIDIOC_S_TUNER:
        {
                struct v4l2_tuner *t = arg;
-               int status = 0;
 
                if (0 != t->index)
                        return -EINVAL;
-               memset(t, 0, sizeof(*t));
-               strcpy(t->name, "Tuner");
-               t->type = V4L2_TUNER_ANALOG_TV;
-               t->capability = V4L2_TUNER_CAP_NORM;
-               t->rangehigh = 0xffffffffUL;    /* FIXME: set correct range */
-/*             t->signal = 0xffff; */
-               /* No way to get signal strength? */
                mutex_lock(&dev->lock);
-               em28xx_i2c_call_clients(dev, DECODER_GET_STATUS,
-                                       &status);
+               /* let clients handle this */
+               em28xx_i2c_call_clients(dev, cmd, t);
                mutex_unlock(&dev->lock);
-               t->signal =
-                       (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0;
-
-               em28xx_videodbg("VIDIO_S_TUNER: signal=%x, afc=%x\n",
-                               t->signal, t->afc);
                return 0;
        }
        case VIDIOC_G_FREQUENCY:
@@ -1593,8 +1576,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
        errCode = em28xx_config(dev);
        if (errCode) {
                em28xx_errdev("error configuring device\n");
-               kfree(dev);
                em28xx_devused&=~(1<<dev->devno);
+               kfree(dev);
                return -ENOMEM;
        }
 
@@ -1620,8 +1603,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
        dev->vdev = video_device_alloc();
        if (NULL == dev->vdev) {
                em28xx_errdev("cannot allocate video_device.\n");
-               kfree(dev);
                em28xx_devused&=~(1<<dev->devno);
+               kfree(dev);
                return -ENOMEM;
        }
 
@@ -1629,8 +1612,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
        if (NULL == dev->vbi_dev) {
                em28xx_errdev("cannot allocate video_device.\n");
                kfree(dev->vdev);
-               kfree(dev);
                em28xx_devused&=~(1<<dev->devno);
+               kfree(dev);
                return -ENOMEM;
        }
 
@@ -1667,8 +1650,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
                mutex_unlock(&dev->lock);
                list_del(&dev->devlist);
                video_device_release(dev->vdev);
-               kfree(dev);
                em28xx_devused&=~(1<<dev->devno);
+               kfree(dev);
                return -ENODEV;
        }
 
@@ -1679,8 +1662,8 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
                list_del(&dev->devlist);
                video_device_release(dev->vbi_dev);
                video_device_release(dev->vdev);
-               kfree(dev);
                em28xx_devused&=~(1<<dev->devno);
+               kfree(dev);
                return -ENODEV;
        } else {
                printk("registered VBI\n");