i2c: Declare more i2c_adapter parent devices
[pandora-kernel.git] / drivers / media / video / cafe_ccic.c
index dc6e16c..4dae892 100644 (file)
@@ -549,6 +549,7 @@ static int cafe_smbus_setup(struct cafe_camera *cam)
        adap->client_unregister = cafe_smbus_detach;
        adap->algo = &cafe_smbus_algo;
        strcpy(adap->name, "cafe_ccic");
+       adap->dev.parent = &cam->pdev->dev;
        i2c_set_adapdata(adap, cam);
        ret = i2c_add_adapter(adap);
        if (ret)
@@ -612,16 +613,6 @@ static void cafe_ctlr_image(struct cafe_camera *cam)
                            C0_DF_MASK);
            break;
 
-       /*
-        * For "fake rgb32" get the image pitch right.
-        */
-       case V4L2_PIX_FMT_RGB32:
-           cafe_reg_write_mask(cam, REG_IMGPITCH, fmt->bytesperline/2,
-                           IMGP_YP_MASK);
-           imgsz = ((fmt->height << IMGSZ_V_SHIFT) & IMGSZ_V_MASK) |
-                   ((fmt->bytesperline/2) & IMGSZ_H_MASK);
-           cafe_reg_write(cam, REG_IMGSIZE, imgsz);
-           /* fall into ... */
        case V4L2_PIX_FMT_RGB444:
            cafe_reg_write_mask(cam, REG_CTRL0,
                            C0_DF_RGB|C0_RGBF_444|C0_RGB4_XRGB,
@@ -902,11 +893,8 @@ static int cafe_alloc_dma_bufs(struct cafe_camera *cam, int loadtime)
        cafe_set_config_needed(cam, 1);
        if (loadtime)
                cam->dma_buf_size = dma_buf_size;
-       else {
+       else
                cam->dma_buf_size = cam->pix_format.sizeimage;
-               if (cam->pix_format.pixelformat == V4L2_PIX_FMT_RGB32)
-                       cam->dma_buf_size /= 2;
-       }
        if (n_dma_bufs > 3)
                n_dma_bufs = 3;
 
@@ -1679,22 +1667,40 @@ static int cafe_vidioc_s_input(struct file *filp, void *priv, unsigned int i)
 }
 
 /* from vivi.c */
-static int cafe_vidioc_s_std(struct file *filp, void *priv, v4l2_std_id a)
+static int cafe_vidioc_s_std(struct file *filp, void *priv, v4l2_std_id *a)
 {
        return 0;
 }
 
-
 /*
- * The TV Norm stuff is weird - we're a camera with little to do with TV,
- * really.  The following is what vivi does.
+ * G/S_PARM.  Most of this is done by the sensor, but we are
+ * the level which controls the number of read buffers.
  */
-static struct v4l2_tvnorm cafe_tvnorm[] = {
-       {
-               .name      = "NTSC-M",
-               .id        = V4L2_STD_NTSC_M,
-       }
-};
+static int cafe_vidioc_g_parm(struct file *filp, void *priv,
+               struct v4l2_streamparm *parms)
+{
+       struct cafe_camera *cam = priv;
+       int ret;
+
+       mutex_lock(&cam->s_mutex);
+       ret = __cafe_cam_cmd(cam, VIDIOC_G_PARM, parms);
+       mutex_unlock(&cam->s_mutex);
+       parms->parm.capture.readbuffers = n_dma_bufs;
+       return ret;
+}
+
+static int cafe_vidioc_s_parm(struct file *filp, void *priv,
+               struct v4l2_streamparm *parms)
+{
+       struct cafe_camera *cam = priv;
+       int ret;
+
+       mutex_lock(&cam->s_mutex);
+       ret = __cafe_cam_cmd(cam, VIDIOC_S_PARM, parms);
+       mutex_unlock(&cam->s_mutex);
+       parms->parm.capture.readbuffers = n_dma_bufs;
+       return ret;
+}
 
 
 static void cafe_v4l_dev_release(struct video_device *vd)
@@ -1710,7 +1716,7 @@ static void cafe_v4l_dev_release(struct video_device *vd)
  * clone it for specific real devices.
  */
 
-static struct file_operations cafe_v4l_fops = {
+static const struct file_operations cafe_v4l_fops = {
        .owner = THIS_MODULE,
        .open = cafe_v4l_open,
        .release = cafe_v4l_release,
@@ -1726,8 +1732,7 @@ static struct video_device cafe_v4l_template = {
        .type = VFL_TYPE_GRABBER,
        .type2 = VID_TYPE_CAPTURE,
        .minor = -1, /* Get one dynamically */
-       .tvnorms = cafe_tvnorm,
-       .tvnormsize = 1,
+       .tvnorms = V4L2_STD_NTSC_M,
        .current_norm = V4L2_STD_NTSC_M,  /* make mplayer happy */
 
        .fops = &cafe_v4l_fops,
@@ -1751,7 +1756,8 @@ static struct video_device cafe_v4l_template = {
        .vidioc_queryctrl       = cafe_vidioc_queryctrl,
        .vidioc_g_ctrl          = cafe_vidioc_g_ctrl,
        .vidioc_s_ctrl          = cafe_vidioc_s_ctrl,
-       /* Do cropping someday */
+       .vidioc_g_parm          = cafe_vidioc_g_parm,
+       .vidioc_s_parm          = cafe_vidioc_s_parm,
 };
 
 
@@ -1765,26 +1771,6 @@ static struct video_device cafe_v4l_template = {
  * Interrupt handler stuff
  */
 
-/*
- * Create RGB32 from RGB444 so it can be displayed before the applications
- * know about the latter format.
- */
-static void cafe_fake_rgb32(struct cafe_camera *cam, char *dest, char *src)
-{
-       int i;
-       u16 *ssrc = (u16 *) src;
-
-       /* RGB444 version */
-       for (i = 0; i < cam->pix_format.sizeimage; i += 4) {
-       //              dest[0] = (*ssrc & 0xf000) >> 8;
-               dest[0] = (*ssrc & 0x000f) << 4;
-               dest[1] = (*ssrc & 0x00f0);
-               dest[2] = (*ssrc & 0x0f00) >> 4;
-               dest[3] = (*ssrc & 0xf000);   /* Alpha */
-               dest += 4;
-               ssrc++;
-       }
-}
 
 
 static void cafe_frame_tasklet(unsigned long data)
@@ -1814,11 +1800,8 @@ static void cafe_frame_tasklet(unsigned long data)
                 */
                sbuf = list_entry(cam->sb_avail.next,
                                struct cafe_sio_buffer, list);
-               if (cam->pix_format.pixelformat == V4L2_PIX_FMT_RGB32)
-                       cafe_fake_rgb32(cam, sbuf->buffer, cam->dma_bufs[bufno]);
-               else
-                       memcpy(sbuf->buffer, cam->dma_bufs[bufno],
-                                       cam->pix_format.sizeimage);
+               memcpy(sbuf->buffer, cam->dma_bufs[bufno],
+                               cam->pix_format.sizeimage);
                sbuf->v4lbuf.bytesused = cam->pix_format.sizeimage;
                sbuf->v4lbuf.sequence = cam->buf_seq[bufno];
                sbuf->v4lbuf.flags &= ~V4L2_BUF_FLAG_QUEUED;
@@ -1987,7 +1970,7 @@ static ssize_t cafe_dfs_read_regs(struct file *file,
                        s - cafe_debug_buf);
 }
 
-static struct file_operations cafe_dfs_reg_ops = {
+static const struct file_operations cafe_dfs_reg_ops = {
        .owner = THIS_MODULE,
        .read = cafe_dfs_read_regs,
        .open = cafe_dfs_open
@@ -2013,7 +1996,7 @@ static ssize_t cafe_dfs_read_cam(struct file *file,
                        s - cafe_debug_buf);
 }
 
-static struct file_operations cafe_dfs_cam_ops = {
+static const struct file_operations cafe_dfs_cam_ops = {
        .owner = THIS_MODULE,
        .read = cafe_dfs_read_cam,
        .open = cafe_dfs_open
@@ -2184,7 +2167,7 @@ static void cafe_pci_remove(struct pci_dev *pdev)
        struct cafe_camera *cam = cafe_find_by_pdev(pdev);
 
        if (cam == NULL) {
-               cam_warn(cam, "pci_remove on unknown pdev %p\n", pdev);
+               printk(KERN_WARNING "pci_remove on unknown pdev %p\n", pdev);
                return;
        }
        mutex_lock(&cam->s_mutex);