Commit b3f18ec6 authored by Antonio Ospite's avatar Antonio Ospite Committed by Mauro Carvalho Chehab

[media] gspca: fix a v4l2-compliance failure about VIDIOC_ENUM_FRAMEINTERVALS

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: default avatarAntonio Ospite <ao2@ao2.it>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 9a08e461
...@@ -991,6 +991,19 @@ static void gspca_set_default_mode(struct gspca_dev *gspca_dev) ...@@ -991,6 +991,19 @@ static void gspca_set_default_mode(struct gspca_dev *gspca_dev)
v4l2_ctrl_handler_setup(gspca_dev->vdev.ctrl_handler); 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, static int wxh_to_nearest_mode(struct gspca_dev *gspca_dev,
int width, int height) int width, int height)
{ {
...@@ -1233,9 +1246,13 @@ static int vidioc_enum_frameintervals(struct file *filp, void *priv, ...@@ -1233,9 +1246,13 @@ static int vidioc_enum_frameintervals(struct file *filp, void *priv,
struct v4l2_frmivalenum *fival) struct v4l2_frmivalenum *fival)
{ {
struct gspca_dev *gspca_dev = video_drvdata(filp); struct gspca_dev *gspca_dev = video_drvdata(filp);
int mode = wxh_to_nearest_mode(gspca_dev, fival->width, fival->height); int mode;
__u32 i; __u32 i;
mode = wxh_to_mode(gspca_dev, fival->width, fival->height);
if (mode < 0)
return -EINVAL;
if (gspca_dev->cam.mode_framerates == NULL || if (gspca_dev->cam.mode_framerates == NULL ||
gspca_dev->cam.mode_framerates[mode].nrates == 0) gspca_dev->cam.mode_framerates[mode].nrates == 0)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment