@@ -389,9 +389,12 @@ static int fimc_m2m_cropcap(struct file *file, void *fh,
struct fimc_ctx *ctx = fh_to_ctx(fh);
struct fimc_frame *frame;
- frame = ctx_get_frame(ctx, cr->type);
- if (IS_ERR(frame))
- return PTR_ERR(frame);
+ if (cr->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
+ frame = &ctx->s_frame;
+ else if (cr->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+ frame = &ctx->d_frame;
+ else
+ return -EINVAL;
cr->bounds.left = 0;
cr->bounds.top = 0;
@@ -2251,6 +2251,7 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops,
{
struct v4l2_cropcap *p = arg;
struct v4l2_selection s = { .type = p->type };
+ u32 old_type = p->type;
int ret = 0;
/* setting trivial pixelaspect */
@@ -2264,8 +2265,14 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops,
if (WARN_ON(!ops->vidioc_cropcap && !ops->vidioc_g_selection))
return -ENOTTY;
- if (ops->vidioc_cropcap)
+ if (ops->vidioc_cropcap) {
+ if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+ p->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
+ p->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
ret = ops->vidioc_cropcap(file, fh, p);
+ p->type = old_type;
+ }
if (!ops->vidioc_g_selection)
return ret;
The type field in struct v4l2_cropcap is supposed to never use the _MPLANE variants. E.g. if the driver supports V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, then userspace should still pass V4L2_BUF_TYPE_VIDEO_CAPTURE. To fix that code is added to the v4l2 core that maps the _MPLANE buffer types to their regular equivalents before calling the driver. Effectively this allows for userspace to use either _MPLANE or the regular buffer type. This keeps backwards compatibility while making things easier for userspace. Since drivers now never see the _MPLANE buffer types the exynos driver had to be adapted as well. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> --- Hi, This solves the v4l2-compliance failure on R-Car platforms which became apparent on with the v4l-utils commit [1]. I have checked all vidioc_cropcap callers and I can only find the exynos driver who do not already do the right thing. Please note that the exynos driver change is only compile tested. 1. d26e4941419b05fc ("v4l2-compliance: allow both regular and mplane variants for crop API") Regards, Niklas --- drivers/media/platform/exynos4-is/fimc-m2m.c | 9 ++++++--- drivers/media/v4l2-core/v4l2-ioctl.c | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-)