From 7373b7bc0b6069775eddb6da1023d0e45969d7fd Mon Sep 17 00:00:00 2001 From: Praveen AC Date: Fri, 9 Aug 2024 09:42:28 +0000 Subject: [PATCH] camera: Fix v4l2-compliance test fails Fix following test cases: 1.test invalid ioctls test 2.test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF return proper error value from the driver. Bug 4587577 Change-Id: Iee1114d4cc74ba27c3bef30190f936f69cbc32ac Signed-off-by: Praveen AC Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3191238 Reviewed-by: Narendra Kondapalli Reviewed-by: Anubhav Rai Reviewed-by: Ankur Pawar GVS: buildbot_gerritrpt --- .../media/platform/tegra/camera/vi/channel.c | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/tegra/camera/vi/channel.c b/drivers/media/platform/tegra/camera/vi/channel.c index bb60ba4a..6f98c645 100644 --- a/drivers/media/platform/tegra/camera/vi/channel.c +++ b/drivers/media/platform/tegra/camera/vi/channel.c @@ -692,16 +692,33 @@ tegra_channel_queue_setup(struct vb2_queue *vq, { struct tegra_channel *chan = vb2_get_drv_priv(vq); struct tegra_mc_vi *vi = chan->vi; + int ret = 0; + + + /* In some cases, if nplanes is valid + * and the requested image size is less than the + * actual image size, we need to return EINVAL. + * Previously, we were just updating sizes[0] irrespective + * of the requested image size. Although this did not harm the + * flow, according to "v4l2-compliance", we need to check if + * the requested size is invalid. + */ + if (*nplanes) { + if (sizes[0] < chan->format.sizeimage) { + pr_err("%s: sizes[0] = %d chan->format.sizeimage = %d ...\n" + ,__func__,sizes[0],chan->format.sizeimage); + return -EINVAL; + } + } else { + sizes[0] = chan->format.sizeimage; + } *nplanes = 1; - - sizes[0] = chan->format.sizeimage; alloc_devs[0] = tegra_channel_get_vi_unit(chan); if (vi->fops && vi->fops->vi_setup_queue) return vi->fops->vi_setup_queue(chan, nbuffers); - else - return -EINVAL; + return ret; } int tegra_channel_alloc_buffer_queue(struct tegra_channel *chan, @@ -2256,7 +2273,7 @@ static long tegra_channel_default_ioctl(struct file *file, void *fh, { struct tegra_channel *chan = video_drvdata(file); struct tegra_mc_vi *vi = chan->vi; - long ret = 0; + long ret = -ENOTTY; if (vi->fops && vi->fops->vi_default_ioctl) ret = vi->fops->vi_default_ioctl(file, fh, use_prio, cmd, arg);