@@ -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: