Merge tag 'mmc-v4.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
[cascardo/linux.git] / drivers / media / platform / omap3isp / ispvideo.c
index 7d9f359..7354469 100644 (file)
@@ -772,40 +772,45 @@ isp_video_try_format(struct file *file, void *fh, struct v4l2_format *format)
 }
 
 static int
-isp_video_cropcap(struct file *file, void *fh, struct v4l2_cropcap *cropcap)
-{
-       struct isp_video *video = video_drvdata(file);
-       struct v4l2_subdev *subdev;
-       int ret;
-
-       subdev = isp_video_remote_subdev(video, NULL);
-       if (subdev == NULL)
-               return -EINVAL;
-
-       mutex_lock(&video->mutex);
-       ret = v4l2_subdev_call(subdev, video, cropcap, cropcap);
-       mutex_unlock(&video->mutex);
-
-       return ret == -ENOIOCTLCMD ? -ENOTTY : ret;
-}
-
-static int
-isp_video_get_crop(struct file *file, void *fh, struct v4l2_crop *crop)
+isp_video_get_selection(struct file *file, void *fh, struct v4l2_selection *sel)
 {
        struct isp_video *video = video_drvdata(file);
        struct v4l2_subdev_format format;
        struct v4l2_subdev *subdev;
+       struct v4l2_subdev_selection sdsel = {
+               .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+               .target = sel->target,
+       };
        u32 pad;
        int ret;
 
+       switch (sel->target) {
+       case V4L2_SEL_TGT_CROP:
+       case V4L2_SEL_TGT_CROP_BOUNDS:
+       case V4L2_SEL_TGT_CROP_DEFAULT:
+               if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
+                       return -EINVAL;
+               break;
+       case V4L2_SEL_TGT_COMPOSE:
+       case V4L2_SEL_TGT_COMPOSE_BOUNDS:
+       case V4L2_SEL_TGT_COMPOSE_DEFAULT:
+               if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+                       return -EINVAL;
+               break;
+       default:
+               return -EINVAL;
+       }
        subdev = isp_video_remote_subdev(video, &pad);
        if (subdev == NULL)
                return -EINVAL;
 
-       /* Try the get crop operation first and fallback to get format if not
+       /* Try the get selection operation first and fallback to get format if not
         * implemented.
         */
-       ret = v4l2_subdev_call(subdev, video, g_crop, crop);
+       sdsel.pad = pad;
+       ret = v4l2_subdev_call(subdev, pad, get_selection, NULL, &sdsel);
+       if (!ret)
+               sel->r = sdsel.r;
        if (ret != -ENOIOCTLCMD)
                return ret;
 
@@ -815,28 +820,50 @@ isp_video_get_crop(struct file *file, void *fh, struct v4l2_crop *crop)
        if (ret < 0)
                return ret == -ENOIOCTLCMD ? -ENOTTY : ret;
 
-       crop->c.left = 0;
-       crop->c.top = 0;
-       crop->c.width = format.format.width;
-       crop->c.height = format.format.height;
+       sel->r.left = 0;
+       sel->r.top = 0;
+       sel->r.width = format.format.width;
+       sel->r.height = format.format.height;
 
        return 0;
 }
 
 static int
-isp_video_set_crop(struct file *file, void *fh, const struct v4l2_crop *crop)
+isp_video_set_selection(struct file *file, void *fh, struct v4l2_selection *sel)
 {
        struct isp_video *video = video_drvdata(file);
        struct v4l2_subdev *subdev;
+       struct v4l2_subdev_selection sdsel = {
+               .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+               .target = sel->target,
+               .flags = sel->flags,
+               .r = sel->r,
+       };
+       u32 pad;
        int ret;
 
-       subdev = isp_video_remote_subdev(video, NULL);
+       switch (sel->target) {
+       case V4L2_SEL_TGT_CROP:
+               if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
+                       return -EINVAL;
+               break;
+       case V4L2_SEL_TGT_COMPOSE:
+               if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+                       return -EINVAL;
+               break;
+       default:
+               return -EINVAL;
+       }
+       subdev = isp_video_remote_subdev(video, &pad);
        if (subdev == NULL)
                return -EINVAL;
 
+       sdsel.pad = pad;
        mutex_lock(&video->mutex);
-       ret = v4l2_subdev_call(subdev, video, s_crop, crop);
+       ret = v4l2_subdev_call(subdev, pad, set_selection, NULL, &sdsel);
        mutex_unlock(&video->mutex);
+       if (!ret)
+               sel->r = sdsel.r;
 
        return ret == -ENOIOCTLCMD ? -ENOTTY : ret;
 }
@@ -1252,9 +1279,8 @@ static const struct v4l2_ioctl_ops isp_video_ioctl_ops = {
        .vidioc_g_fmt_vid_out           = isp_video_get_format,
        .vidioc_s_fmt_vid_out           = isp_video_set_format,
        .vidioc_try_fmt_vid_out         = isp_video_try_format,
-       .vidioc_cropcap                 = isp_video_cropcap,
-       .vidioc_g_crop                  = isp_video_get_crop,
-       .vidioc_s_crop                  = isp_video_set_crop,
+       .vidioc_g_selection             = isp_video_get_selection,
+       .vidioc_s_selection             = isp_video_set_selection,
        .vidioc_g_parm                  = isp_video_get_param,
        .vidioc_s_parm                  = isp_video_set_param,
        .vidioc_reqbufs                 = isp_video_reqbufs,