From: Antonio Ospite <ao2@ao2.it>
To: Linux Media <linux-media@vger.kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
Hans Verkuil <hverkuil@xs4all.nl>, Antonio Ospite <ao2@ao2.it>
Subject: [PATCH 4/7] [media] gspca: fix a v4l2-compliance failure about VIDIOC_ENUM_FRAMEINTERVALS
Date: Wed, 9 Mar 2016 17:03:18 +0100 [thread overview]
Message-ID: <1457539401-11515-5-git-send-email-ao2@ao2.it> (raw)
In-Reply-To: <1457539401-11515-1-git-send-email-ao2@ao2.it>
According to v4l2-compliance VIDIOC_ENUM_FRAMEINTERVALS should fail for
unsupported frame sizes, but gspca is too tolerant and tries to find
the frame intervals for the frame size nearest to the requested one.
This makes v4l2-compliance fail with this message:
fail: v4l2-test-formats.cpp(123): \
found frame intervals for invalid size 321x240
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL
Fix this by using an exact match for the frame size when enumerating
frame intervals, and retuning an error if the frame size for which the
frame intervals have been asked is not supported.
Signed-off-by: Antonio Ospite <ao2@ao2.it>
---
drivers/media/usb/gspca/gspca.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 1bb7901..61cb16d 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -991,6 +991,19 @@ static void gspca_set_default_mode(struct gspca_dev *gspca_dev)
v4l2_ctrl_handler_setup(gspca_dev->vdev.ctrl_handler);
}
+static int wxh_to_mode(struct gspca_dev *gspca_dev,
+ int width, int height)
+{
+ int i;
+
+ for (i = 0; i < gspca_dev->cam.nmodes; i++) {
+ if (width == gspca_dev->cam.cam_mode[i].width
+ && height == gspca_dev->cam.cam_mode[i].height)
+ return i;
+ }
+ return -EINVAL;
+}
+
static int wxh_to_nearest_mode(struct gspca_dev *gspca_dev,
int width, int height)
{
@@ -1233,9 +1246,13 @@ static int vidioc_enum_frameintervals(struct file *filp, void *priv,
struct v4l2_frmivalenum *fival)
{
struct gspca_dev *gspca_dev = video_drvdata(filp);
- int mode = wxh_to_nearest_mode(gspca_dev, fival->width, fival->height);
+ int mode;
__u32 i;
+ mode = wxh_to_mode(gspca_dev, fival->width, fival->height);
+ if (mode < 0)
+ return -EINVAL;
+
if (gspca_dev->cam.mode_framerates == NULL ||
gspca_dev->cam.mode_framerates[mode].nrates == 0)
return -EINVAL;
--
2.7.0
next prev parent reply other threads:[~2016-03-09 16:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-09 16:03 [PATCH 0/7] gspca: pass all v4l2-compliance tests + minor fixes Antonio Ospite
2016-03-09 16:03 ` [PATCH 1/7] [media] gspca: ov534/topro: use a define for the default framerate Antonio Ospite
2016-03-09 16:03 ` [PATCH 2/7] [media] gspca: fix setting frame interval type in vidioc_enum_frameintervals() Antonio Ospite
2016-03-09 16:03 ` [PATCH 3/7] [media] gspca: rename wxh_to_mode() to wxh_to_nearest_mode() Antonio Ospite
2016-03-09 16:03 ` Antonio Ospite [this message]
2016-03-09 16:03 ` [PATCH 5/7] [media] gspca: fix a v4l2-compliance failure about buffer timestamp Antonio Ospite
2016-03-09 16:03 ` [PATCH 6/7] [media] gspca: fix a v4l2-compliance failure during VIDIOC_REQBUFS Antonio Ospite
2016-03-09 16:10 ` Hans Verkuil
2016-03-10 14:54 ` Hans de Goede
2016-03-14 15:02 ` Antonio Ospite
2016-03-14 15:34 ` Hans de Goede
2016-03-09 16:03 ` [PATCH 7/7] [media] gspca: fix a v4l2-compliance failure during read() Antonio Ospite
2016-03-10 15:59 ` Hans de Goede
2016-03-14 15:11 ` Antonio Ospite
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1457539401-11515-5-git-send-email-ao2@ao2.it \
--to=ao2@ao2.it \
--cc=hdegoede@redhat.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).