提交 dc9455ff 编写于 作者: L Laurent Pinchart 提交者: Mauro Carvalho Chehab

media: uvcvideo: Accept invalid bFormatIndex and bFrameIndex values

The Renkforce RF AC4K 300 Action Cam 4K reports invalid bFormatIndex and
bFrameIndex values when negotiating the video probe and commit controls.
The UVC descriptors report a single supported format and frame size,
with bFormatIndex and bFrameIndex both equal to 2, but the video probe
and commit controls report bFormatIndex and bFrameIndex set to 1.

The device otherwise operates correctly, but the driver rejects the
values and fails the format try operation. Fix it by ignoring the
invalid indices, and assuming that the format and frame requested by the
driver are accepted by the device.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=210767

Fixes: 8a652a17 ("media: uvcvideo: Ensure all probed info is returned to v4l2")
Reported-by: NTill Dörges <doerges@pre-sense.de>
Signed-off-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab+huawei@kernel.org>
上级 b400b6f2
...@@ -248,7 +248,9 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, ...@@ -248,7 +248,9 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
goto done; goto done;
/* After the probe, update fmt with the values returned from /* After the probe, update fmt with the values returned from
* negotiation with the device. * negotiation with the device. Some devices return invalid bFormatIndex
* and bFrameIndex values, in which case we can only assume they have
* accepted the requested format as-is.
*/ */
for (i = 0; i < stream->nformats; ++i) { for (i = 0; i < stream->nformats; ++i) {
if (probe->bFormatIndex == stream->format[i].index) { if (probe->bFormatIndex == stream->format[i].index) {
...@@ -257,11 +259,10 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, ...@@ -257,11 +259,10 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
} }
} }
if (i == stream->nformats) { if (i == stream->nformats)
uvc_trace(UVC_TRACE_FORMAT, "Unknown bFormatIndex %u\n", uvc_trace(UVC_TRACE_FORMAT,
"Unknown bFormatIndex %u, using default\n",
probe->bFormatIndex); probe->bFormatIndex);
return -EINVAL;
}
for (i = 0; i < format->nframes; ++i) { for (i = 0; i < format->nframes; ++i) {
if (probe->bFrameIndex == format->frame[i].bFrameIndex) { if (probe->bFrameIndex == format->frame[i].bFrameIndex) {
...@@ -270,11 +271,10 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, ...@@ -270,11 +271,10 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
} }
} }
if (i == format->nframes) { if (i == format->nframes)
uvc_trace(UVC_TRACE_FORMAT, "Unknown bFrameIndex %u\n", uvc_trace(UVC_TRACE_FORMAT,
"Unknown bFrameIndex %u, using default\n",
probe->bFrameIndex); probe->bFrameIndex);
return -EINVAL;
}
fmt->fmt.pix.width = frame->wWidth; fmt->fmt.pix.width = frame->wWidth;
fmt->fmt.pix.height = frame->wHeight; fmt->fmt.pix.height = frame->wHeight;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册