media: tegra: Tegra V4L2 camera
[linux-2.6.git] / drivers / media / video / v4l2-subdev.c
index 207cc5c..b7967c9 100644 (file)
@@ -75,20 +75,7 @@ static int subdev_open(struct file *file)
                return ret;
        }
 
-       ret = v4l2_fh_init(&subdev_fh->vfh, vdev);
-       if (ret)
-               goto err;
-
-       if (sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS) {
-               ret = v4l2_event_init(&subdev_fh->vfh);
-               if (ret)
-                       goto err;
-
-               ret = v4l2_event_alloc(&subdev_fh->vfh, sd->nevents);
-               if (ret)
-                       goto err;
-       }
-
+       v4l2_fh_init(&subdev_fh->vfh, vdev);
        v4l2_fh_add(&subdev_fh->vfh);
        file->private_data = &subdev_fh->vfh;
 #if defined(CONFIG_MEDIA_CONTROLLER)
@@ -155,25 +142,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 
        switch (cmd) {
        case VIDIOC_QUERYCTRL:
-               return v4l2_subdev_queryctrl(sd, arg);
+               return v4l2_queryctrl(vfh->ctrl_handler, arg);
 
        case VIDIOC_QUERYMENU:
-               return v4l2_subdev_querymenu(sd, arg);
+               return v4l2_querymenu(vfh->ctrl_handler, arg);
 
        case VIDIOC_G_CTRL:
-               return v4l2_subdev_g_ctrl(sd, arg);
+               return v4l2_g_ctrl(vfh->ctrl_handler, arg);
 
        case VIDIOC_S_CTRL:
-               return v4l2_subdev_s_ctrl(sd, arg);
+               return v4l2_s_ctrl(vfh, vfh->ctrl_handler, arg);
 
        case VIDIOC_G_EXT_CTRLS:
-               return v4l2_subdev_g_ext_ctrls(sd, arg);
+               return v4l2_g_ext_ctrls(vfh->ctrl_handler, arg);
 
        case VIDIOC_S_EXT_CTRLS:
-               return v4l2_subdev_s_ext_ctrls(sd, arg);
+               return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, arg);
 
        case VIDIOC_TRY_EXT_CTRLS:
-               return v4l2_subdev_try_ext_ctrls(sd, arg);
+               return v4l2_try_ext_ctrls(vfh->ctrl_handler, arg);
 
        case VIDIOC_DQEVENT:
                if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
@@ -213,6 +200,32 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
                return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh, format);
        }
 
+       case VIDIOC_SUBDEV_G_CROP: {
+               struct v4l2_subdev_crop *crop = arg;
+
+               if (crop->which != V4L2_SUBDEV_FORMAT_TRY &&
+                   crop->which != V4L2_SUBDEV_FORMAT_ACTIVE)
+                       return -EINVAL;
+
+               if (crop->pad >= sd->entity.num_pads)
+                       return -EINVAL;
+
+               return v4l2_subdev_call(sd, pad, get_crop, subdev_fh, crop);
+       }
+
+       case VIDIOC_SUBDEV_S_CROP: {
+               struct v4l2_subdev_crop *crop = arg;
+
+               if (crop->which != V4L2_SUBDEV_FORMAT_TRY &&
+                   crop->which != V4L2_SUBDEV_FORMAT_ACTIVE)
+                       return -EINVAL;
+
+               if (crop->pad >= sd->entity.num_pads)
+                       return -EINVAL;
+
+               return v4l2_subdev_call(sd, pad, set_crop, subdev_fh, crop);
+       }
+
        case VIDIOC_SUBDEV_ENUM_MBUS_CODE: {
                struct v4l2_subdev_mbus_code_enum *code = arg;
 
@@ -232,9 +245,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
                return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh,
                                        fse);
        }
+
+       case VIDIOC_SUBDEV_G_FRAME_INTERVAL:
+               return v4l2_subdev_call(sd, video, g_frame_interval, arg);
+
+       case VIDIOC_SUBDEV_S_FRAME_INTERVAL:
+               return v4l2_subdev_call(sd, video, s_frame_interval, arg);
+
+       case VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL: {
+               struct v4l2_subdev_frame_interval_enum *fie = arg;
+
+               if (fie->pad >= sd->entity.num_pads)
+                       return -EINVAL;
+
+               return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh,
+                                       fie);
+       }
 #endif
        default:
-               return -ENOIOCTLCMD;
+               return v4l2_subdev_call(sd, core, ioctl, cmd, arg);
        }
 
        return 0;
@@ -255,7 +284,7 @@ static unsigned int subdev_poll(struct file *file, poll_table *wait)
        if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
                return POLLERR;
 
-       poll_wait(file, &fh->events->wait, wait);
+       poll_wait(file, &fh->wait, wait);
 
        if (v4l2_event_pending(fh))
                return POLLPRI;