Staging: saa7134-go7007: replace dma_sync_single with dma_sync_single_for_cpu
[linux-2.6.git] / drivers / staging / go7007 / saa7134-go7007.c
index c4a6d8e..cf7c34a 100644 (file)
@@ -27,7 +27,7 @@
 #include <linux/usb.h>
 #include <linux/i2c.h>
 #include <asm/byteorder.h>
-#include <media/audiochip.h>
+#include <media/v4l2-common.h>
 
 #include "saa7134-reg.h"
 #include "saa7134.h"
@@ -84,6 +84,7 @@ static struct go7007_board_info board_voyager = {
                },
        },
 };
+MODULE_FIRMWARE("go7007tv.bin");
 
 /********************* Driver for GPIO HPI interface *********************/
 
@@ -241,13 +242,13 @@ static void saa7134_go7007_irq_ts_done(struct saa7134_dev *dev,
                printk(KERN_DEBUG "saa7134-go7007: irq: lost %ld\n",
                                (status >> 16) & 0x0f);
        if (status & 0x100000) {
-               dma_sync_single(&dev->pci->dev,
-                               saa->bottom_dma, PAGE_SIZE, DMA_FROM_DEVICE);
+               dma_sync_single_for_cpu(&dev->pci->dev,
+                                       saa->bottom_dma, PAGE_SIZE, DMA_FROM_DEVICE);
                go7007_parse_video_stream(go, saa->bottom, PAGE_SIZE);
                saa_writel(SAA7134_RS_BA2(5), cpu_to_le32(saa->bottom_dma));
        } else {
-               dma_sync_single(&dev->pci->dev,
-                               saa->top_dma, PAGE_SIZE, DMA_FROM_DEVICE);
+               dma_sync_single_for_cpu(&dev->pci->dev,
+                                       saa->top_dma, PAGE_SIZE, DMA_FROM_DEVICE);
                go7007_parse_video_stream(go, saa->top, PAGE_SIZE);
                saa_writel(SAA7134_RS_BA1(5), cpu_to_le32(saa->top_dma));
        }
@@ -314,7 +315,13 @@ static int saa7134_go7007_stream_start(struct go7007 *go)
 static int saa7134_go7007_stream_stop(struct go7007 *go)
 {
        struct saa7134_go7007 *saa = go->hpi_context;
-       struct saa7134_dev *dev = saa->dev;
+       struct saa7134_dev *dev;
+
+       if (!saa)
+               return -EINVAL;
+       dev = saa->dev;
+       if (!dev)
+               return -EINVAL;
 
        /* Shut down TS FIFO */
        saa_clearl(SAA7134_MAIN_CTRL, SAA7134_MAIN_CTRL_TE5);
@@ -373,6 +380,47 @@ static int saa7134_go7007_send_firmware(struct go7007 *go, u8 *data, int len)
        return 0;
 }
 
+static int saa7134_go7007_send_command(struct go7007 *go, unsigned int cmd,
+                                       void *arg)
+{
+       struct saa7134_go7007 *saa = go->hpi_context;
+       struct saa7134_dev *dev = saa->dev;
+
+       switch (cmd) {
+       case VIDIOC_S_STD:
+       {
+               v4l2_std_id *std = arg;
+               return saa7134_s_std_internal(dev, NULL, std);
+       }
+       case VIDIOC_G_STD:
+       {
+               v4l2_std_id *std = arg;
+               *std = dev->tvnorm->id;
+               return 0;
+       }
+       case VIDIOC_QUERYCTRL:
+       {
+               struct v4l2_queryctrl *ctrl = arg;
+               if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_USER)
+                       return saa7134_queryctrl(NULL, NULL, ctrl);
+       }
+       case VIDIOC_G_CTRL:
+       {
+               struct v4l2_control *ctrl = arg;
+               if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_USER)
+                       return saa7134_g_ctrl_internal(dev, NULL, ctrl);
+       }
+       case VIDIOC_S_CTRL:
+       {
+               struct v4l2_control *ctrl = arg;
+               if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_USER)
+                       return saa7134_s_ctrl_internal(dev, NULL, ctrl);
+       }
+       }
+       return -EINVAL;
+
+}
+
 static struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
        .interface_reset        = saa7134_go7007_interface_reset,
        .write_interrupt        = saa7134_go7007_write_interrupt,
@@ -380,6 +428,7 @@ static struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
        .stream_start           = saa7134_go7007_stream_start,
        .stream_stop            = saa7134_go7007_stream_stop,
        .send_firmware          = saa7134_go7007_send_firmware,
+       .send_command           = saa7134_go7007_send_command,
 };
 
 /********************* Add/remove functions *********************/
@@ -391,10 +440,9 @@ static int saa7134_go7007_init(struct saa7134_dev *dev)
 
        printk(KERN_DEBUG "saa7134-go7007: probing new SAA713X board\n");
 
-       saa = kmalloc(sizeof(struct saa7134_go7007), GFP_KERNEL);
+       saa = kzalloc(sizeof(struct saa7134_go7007), GFP_KERNEL);
        if (saa == NULL)
                return -ENOMEM;
-       memset(saa, 0, sizeof(struct saa7134_go7007));
 
        /* Allocate a couple pages for receiving the compressed stream */
        saa->top = (u8 *)get_zeroed_page(GFP_KERNEL);