diff mbox

[2/2] v4l: simulate old crop API using extcrop/compose

Message ID 1301325596-18166-3-git-send-email-t.stanislaws@samsung.com (mailing list archive)
State RFC
Headers show

Commit Message

Tomasz Stanislawski March 28, 2011, 3:19 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 3f69218..a2b0b27 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -1725,11 +1725,27 @@  static long __video_do_ioctl(struct file *file,
 	{
 		struct v4l2_crop *p = arg;
 
-		if (!ops->vidioc_g_crop)
-			break;
-
 		dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
-		ret = ops->vidioc_g_crop(file, fh, p);
+
+		if (ops->vidioc_g_crop) {
+			ret = ops->vidioc_g_crop(file, fh, p);
+		} else {
+			struct v4l2_selection s = { .type = p->type };
+			/* simulate capture crop using extcrop */
+			if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE
+				&& ops->vidioc_g_extcrop) {
+				ret = ops->vidioc_g_extcrop(file, fh, &s);
+			}
+			/* simulate output crop using compose */
+			if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT
+				&& ops->vidioc_g_compose) {
+				ret = ops->vidioc_g_compose(file, fh, &s);
+			}
+			/* copying results to old structure */
+			if (ret == 0)
+				p->c = s.r;
+		}
+
 		if (!ret)
 			dbgrect(vfd, "", &p->c);
 		break;
@@ -1738,11 +1754,27 @@  static long __video_do_ioctl(struct file *file,
 	{
 		struct v4l2_crop *p = arg;
 
-		if (!ops->vidioc_s_crop)
-			break;
 		dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
 		dbgrect(vfd, "", &p->c);
-		ret = ops->vidioc_s_crop(file, fh, p);
+
+		if (ops->vidioc_s_crop) {
+			ret = ops->vidioc_s_crop(file, fh, p);
+		} else {
+			struct v4l2_selection s = {
+				.type = p->type,
+				.r = p->c,
+			};
+			/* simulate capture crop using extcrop */
+			if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE
+				&& ops->vidioc_s_extcrop) {
+				ret = ops->vidioc_s_extcrop(file, fh, &s);
+			}
+			/* simulate output crop using compose */
+			if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT
+				&& ops->vidioc_s_compose) {
+				ret = ops->vidioc_s_compose(file, fh, &s);
+			}
+		}
 		break;
 	}
 	case VIDIOC_G_EXTCROP: