Commit cd257a6f authored by Daniel Drake's avatar Daniel Drake Committed by Mauro Carvalho Chehab

V4L/DVB (8318): OV7670: don't reject unsupported settings

For VIDIOC_G_FMT/VIDIOC_TRY_FMT, the V4L2 API spec states:
"Drivers should not return an error code unless the input is ambiguous"
"Very simple, inflexible devices may even ignore all input and always
return the default parameters."
"When the requested buffer type is not supported drivers return an
EINVAL error code."
i.e. returning errors for unsupported fields is bad, and it's ok to
unconditionally overwrite user-requested settings

This patch makes ov7670 meet that behaviour, and brings it in line with
other drivers e.g. stk-webcam. It also fixes compatibility with (unpatched)
gstreamer.
Signed-off-by: default avatarDaniel Drake <dsd@laptop.org>
Acked-by: default avatarJonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 3f8d6f73
...@@ -682,17 +682,17 @@ static int ov7670_try_fmt(struct i2c_client *c, struct v4l2_format *fmt, ...@@ -682,17 +682,17 @@ static int ov7670_try_fmt(struct i2c_client *c, struct v4l2_format *fmt,
for (index = 0; index < N_OV7670_FMTS; index++) for (index = 0; index < N_OV7670_FMTS; index++)
if (ov7670_formats[index].pixelformat == pix->pixelformat) if (ov7670_formats[index].pixelformat == pix->pixelformat)
break; break;
if (index >= N_OV7670_FMTS) if (index >= N_OV7670_FMTS) {
return -EINVAL; /* default to first format */
index = 0;
pix->pixelformat = ov7670_formats[0].pixelformat;
}
if (ret_fmt != NULL) if (ret_fmt != NULL)
*ret_fmt = ov7670_formats + index; *ret_fmt = ov7670_formats + index;
/* /*
* Fields: the OV devices claim to be progressive. * Fields: the OV devices claim to be progressive.
*/ */
if (pix->field == V4L2_FIELD_ANY) pix->field = V4L2_FIELD_NONE;
pix->field = V4L2_FIELD_NONE;
else if (pix->field != V4L2_FIELD_NONE)
return -EINVAL;
/* /*
* Round requested image size down to the nearest * Round requested image size down to the nearest
* we support, but not below the smallest. * we support, but not below the smallest.
......
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