diff options
Diffstat (limited to 'drivers/media/usb')
-rw-r--r-- | drivers/media/usb/gspca/gspca.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c index 1bb7901a128c..61cb16d6c988 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; |