This patch allows new drivers to work correctly with applications that use old-style crop API. The old crop ioctl is simulated by using extcrop/compose. Signed-off-by: Tomasz Stanislawski <t.stanislaws@xxxxxxxxxxx> --- drivers/media/video/v4l2-ioctl.c | 46 ++++++++++++++++++++++++++++++++----- 1 files changed, 39 insertions(+), 7 deletions(-) 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: -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html