summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6123450)
raw | patch | inline | side by side (parent: 6123450)
author | Archit Taneja <archit@ti.com> | |
Thu, 19 Dec 2013 09:35:31 +0000 (15:05 +0530) | ||
committer | Anand Balagopalakrishnan <anandb@ti.com> | |
Mon, 15 Jun 2015 08:06:05 +0000 (13:36 +0530) |
Add crop ioctl ops. For VPE, cropping only makes sense with the input to VPE, or
the V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE buffer type.
For the CAPTURE type, a S_CROP ioctl results in setting the crop region as the
whole image itself, hence making crop dimensions same as the pix dimensions.
Setting the crop successfully should result in re-configuration of those
registers which are affected when either source or destination dimensions
change, set_srcdst_params() is called for thist purpose.
Some standard crop parameter checks are done in __vpe_try_crop().
Change-Id: I9329dee27db526bde54000552b1184e8f061244f
Signed-off-by: Archit Taneja <archit@ti.com>
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
the V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE buffer type.
For the CAPTURE type, a S_CROP ioctl results in setting the crop region as the
whole image itself, hence making crop dimensions same as the pix dimensions.
Setting the crop successfully should result in re-configuration of those
registers which are affected when either source or destination dimensions
change, set_srcdst_params() is called for thist purpose.
Some standard crop parameter checks are done in __vpe_try_crop().
Change-Id: I9329dee27db526bde54000552b1184e8f061244f
Signed-off-by: Archit Taneja <archit@ti.com>
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
drivers/media/platform/ti-vpe/vpe.c | patch | blob | history |
index 1eba39738231821d8e758fb9f3ed7391fc08ed0d..f88a00e314e85da4c59cc658743f4f6f44b8833a 100644 (file)
return set_srcdst_params(ctx);
}
return set_srcdst_params(ctx);
}
+static int __vpe_try_crop(struct vpe_ctx *ctx, struct v4l2_crop *cr)
+{
+ struct vpe_q_data *q_data;
+
+ q_data = get_q_data(ctx, cr->type);
+ if (!q_data)
+ return -EINVAL;
+
+ /* we don't support crop on capture plane */
+ if (cr->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+ cr->c.top = cr->c.left = 0;
+ cr->c.width = q_data->width;
+ cr->c.height = q_data->height;
+ return 0;
+ }
+
+ if (cr->c.top < 0 || cr->c.left < 0) {
+ vpe_err(ctx->dev, "negative values for top and left\n");
+ cr->c.top = cr->c.left = 0;
+ }
+
+ v4l_bound_align_image(&cr->c.width, MIN_W, q_data->width, 1,
+ &cr->c.height, MIN_H, q_data->height, H_ALIGN, S_ALIGN);
+
+ /* adjust left/top if cropping rectangle is out of bounds */
+ if (cr->c.left + cr->c.width > q_data->width)
+ cr->c.left = q_data->width - cr->c.width;
+ if (cr->c.top + cr->c.height > q_data->height)
+ cr->c.top = q_data->height - cr->c.height;
+
+ return 0;
+}
+
+static int vpe_cropcap(struct file *file, void *priv, struct v4l2_cropcap *cr)
+{
+ struct vpe_ctx *ctx = file2ctx(file);
+ struct vpe_q_data *q_data;
+
+ q_data = get_q_data(ctx, cr->type);
+ if (!q_data)
+ return -EINVAL;
+
+ cr->bounds.left = 0;
+ cr->bounds.top = 0;
+ cr->bounds.width = q_data->width;
+ cr->bounds.height = q_data->height;
+ cr->defrect = cr->bounds;
+
+ return 0;
+}
+
+static int vpe_g_crop(struct file *file, void *fh, struct v4l2_crop *cr)
+{
+ struct vpe_ctx *ctx = file2ctx(file);
+ struct vpe_q_data *q_data;
+
+ q_data = get_q_data(ctx, cr->type);
+ if (!q_data)
+ return -EINVAL;
+
+ cr->c = q_data->c_rect;
+
+ return 0;
+}
+
+static int vpe_s_crop(struct file *file, void *priv,
+ const struct v4l2_crop *crop)
+{
+ struct vpe_ctx *ctx = file2ctx(file);
+ struct vpe_q_data *q_data;
+ struct v4l2_crop cr = *crop;
+ int ret;
+
+ ret = __vpe_try_crop(ctx, &cr);
+ if (ret)
+ return ret;
+
+ q_data = get_q_data(ctx, cr.type);
+
+ q_data->c_rect = cr.c;
+
+ return set_srcdst_params(ctx);
+}
+
static int vpe_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *reqbufs)
{
static int vpe_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *reqbufs)
{
.vidioc_g_selection = vpe_g_selection,
.vidioc_s_selection = vpe_s_selection,
.vidioc_g_selection = vpe_g_selection,
.vidioc_s_selection = vpe_s_selection,
+ .vidioc_cropcap = vpe_cropcap,
+ .vidioc_g_crop = vpe_g_crop,
+ .vidioc_s_crop = vpe_s_crop,
+
.vidioc_reqbufs = vpe_reqbufs,
.vidioc_querybuf = vpe_querybuf,
.vidioc_reqbufs = vpe_reqbufs,
.vidioc_querybuf = vpe_querybuf,