summaryrefslogtreecommitdiff
path: root/subdev.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2010-06-29 12:09:35 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2010-06-29 12:09:35 +0200
commitc13258a74fd7345828fce8fab117247e3f61e6e5 (patch)
treeb29a1420ce9648b283cc32fc35ff9504f93e229b /subdev.c
parent0c4da2bb2f4d7d3cd2cdea1369374d5b4f7e3b29 (diff)
V4L2 subdev crop support
Extend the V4L2 media bus format syntax to support an optional crop rectangle. If specified, the crop rectangle is set on the subdev pad. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'subdev.c')
-rw-r--r--subdev.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/subdev.c b/subdev.c
index c35b5b4..ac14324 100644
--- a/subdev.c
+++ b/subdev.c
@@ -133,3 +133,48 @@ int v4l2_subdev_set_format(struct media_entity *entity,
return 0;
}
+int v4l2_subdev_get_crop(struct media_entity *entity, struct v4l2_rect *rect,
+ unsigned int pad, enum v4l2_subdev_format which)
+{
+ struct v4l2_subdev_pad_crop crop;
+ int ret;
+
+ ret = v4l2_subdev_open(entity);
+ if (ret < 0)
+ return ret;
+
+ memset(&crop, 0, sizeof(crop));
+ crop.pad = pad;
+ crop.which = which;
+
+ ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_CROP, &crop);
+ if (ret < 0)
+ return -errno;
+
+ *rect = crop.rect;
+ return 0;
+}
+
+int v4l2_subdev_set_crop(struct media_entity *entity, struct v4l2_rect *rect,
+ unsigned int pad, enum v4l2_subdev_format which)
+{
+ struct v4l2_subdev_pad_crop crop;
+ int ret;
+
+ ret = v4l2_subdev_open(entity);
+ if (ret < 0)
+ return ret;
+
+ memset(&crop, 0, sizeof(crop));
+ crop.pad = pad;
+ crop.which = which;
+ crop.rect = *rect;
+
+ ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_CROP, &crop);
+ if (ret < 0)
+ return -errno;
+
+ *rect = crop.rect;
+ return 0;
+}
+