From: Hans Verkuil Date: Sun, 3 Jul 2016 11:28:43 +0000 (-0300) Subject: [media] vpfe_capture: convert g/s_crop to g/s_selection X-Git-Tag: v4.14-rc1~332^2~1837 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ffc2a6bb55b2b7c873535c35b7e1ced763ff8bfe;p=platform%2Fkernel%2Flinux-rpi.git [media] vpfe_capture: convert g/s_crop to g/s_selection This is part of a final push to convert all drivers to g/s_selection. Signed-off-by: Hans Verkuil Cc: Prabhakar Lad Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c index 7767e07..6efb2f1 100644 --- a/drivers/media/platform/davinci/vpfe_capture.c +++ b/drivers/media/platform/davinci/vpfe_capture.c @@ -1610,38 +1610,53 @@ static int vpfe_cropcap(struct file *file, void *priv, v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_cropcap\n"); - if (vpfe_dev->std_index >= ARRAY_SIZE(vpfe_standards)) + if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; + /* If std_index is invalid, then just return (== 1:1 aspect) */ + if (vpfe_dev->std_index >= ARRAY_SIZE(vpfe_standards)) + return 0; - memset(crop, 0, sizeof(struct v4l2_cropcap)); - crop->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - crop->bounds.width = crop->defrect.width = - vpfe_standards[vpfe_dev->std_index].width; - crop->bounds.height = crop->defrect.height = - vpfe_standards[vpfe_dev->std_index].height; crop->pixelaspect = vpfe_standards[vpfe_dev->std_index].pixelaspect; return 0; } -static int vpfe_g_crop(struct file *file, void *priv, - struct v4l2_crop *crop) +static int vpfe_g_selection(struct file *file, void *priv, + struct v4l2_selection *sel) { struct vpfe_device *vpfe_dev = video_drvdata(file); - v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_crop\n"); + v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_selection\n"); - crop->c = vpfe_dev->crop; + if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + sel->r = vpfe_dev->crop; + break; + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.width = vpfe_standards[vpfe_dev->std_index].width; + sel->r.height = vpfe_standards[vpfe_dev->std_index].height; + break; + default: + return -EINVAL; + } return 0; } -static int vpfe_s_crop(struct file *file, void *priv, - const struct v4l2_crop *crop) +static int vpfe_s_selection(struct file *file, void *priv, + struct v4l2_selection *sel) { struct vpfe_device *vpfe_dev = video_drvdata(file); - struct v4l2_rect rect = crop->c; + struct v4l2_rect rect = sel->r; int ret = 0; - v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_crop\n"); + v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_selection\n"); + + if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || + sel->target != V4L2_SEL_TGT_CROP) + return -EINVAL; if (vpfe_dev->started) { /* make sure streaming is not started */ @@ -1669,7 +1684,7 @@ static int vpfe_s_crop(struct file *file, void *priv, vpfe_dev->std_info.active_pixels) || (rect.top + rect.height > vpfe_dev->std_info.active_lines)) { - v4l2_err(&vpfe_dev->v4l2_dev, "Error in S_CROP params\n"); + v4l2_err(&vpfe_dev->v4l2_dev, "Error in S_SELECTION params\n"); ret = -EINVAL; goto unlock_out; } @@ -1682,6 +1697,7 @@ static int vpfe_s_crop(struct file *file, void *priv, vpfe_dev->fmt.fmt.pix.bytesperline * vpfe_dev->fmt.fmt.pix.height; vpfe_dev->crop = rect; + sel->r = rect; unlock_out: mutex_unlock(&vpfe_dev->lock); return ret; @@ -1760,8 +1776,8 @@ static const struct v4l2_ioctl_ops vpfe_ioctl_ops = { .vidioc_streamon = vpfe_streamon, .vidioc_streamoff = vpfe_streamoff, .vidioc_cropcap = vpfe_cropcap, - .vidioc_g_crop = vpfe_g_crop, - .vidioc_s_crop = vpfe_s_crop, + .vidioc_g_selection = vpfe_g_selection, + .vidioc_s_selection = vpfe_s_selection, .vidioc_default = vpfe_param_handler, };