diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-08-28 17:38:58 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-11-28 07:27:49 -0500 |
commit | 815adc465de9c8cd1967d0d9d538ed30925423a0 (patch) | |
tree | 5a21ecf655f3ce9fb0e16182e98bdbb7f5f4da78 | |
parent | 30ecb936cbcd83e3735625ac63e1b4466546f5fe (diff) |
[media] uvcvideo: Don't fail when an unsupported format is requested
Return the default format in that case.
This issue was found by the v4l2-compliance tool.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/usb/uvc/uvc_v4l2.c | 11 | ||||
-rw-r--r-- | drivers/media/usb/uvc/uvc_video.c | 1 | ||||
-rw-r--r-- | drivers/media/usb/uvc/uvcvideo.h | 1 |
3 files changed, 8 insertions, 5 deletions
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index e5817b953938..3bd93736a82a 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c | |||
@@ -165,17 +165,18 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, | |||
165 | fcc[0], fcc[1], fcc[2], fcc[3], | 165 | fcc[0], fcc[1], fcc[2], fcc[3], |
166 | fmt->fmt.pix.width, fmt->fmt.pix.height); | 166 | fmt->fmt.pix.width, fmt->fmt.pix.height); |
167 | 167 | ||
168 | /* Check if the hardware supports the requested format. */ | 168 | /* Check if the hardware supports the requested format, use the default |
169 | * format otherwise. | ||
170 | */ | ||
169 | for (i = 0; i < stream->nformats; ++i) { | 171 | for (i = 0; i < stream->nformats; ++i) { |
170 | format = &stream->format[i]; | 172 | format = &stream->format[i]; |
171 | if (format->fcc == fmt->fmt.pix.pixelformat) | 173 | if (format->fcc == fmt->fmt.pix.pixelformat) |
172 | break; | 174 | break; |
173 | } | 175 | } |
174 | 176 | ||
175 | if (format == NULL || format->fcc != fmt->fmt.pix.pixelformat) { | 177 | if (i == stream->nformats) { |
176 | uvc_trace(UVC_TRACE_FORMAT, "Unsupported format 0x%08x.\n", | 178 | format = stream->def_format; |
177 | fmt->fmt.pix.pixelformat); | 179 | fmt->fmt.pix.pixelformat = format->fcc; |
178 | return -EINVAL; | ||
179 | } | 180 | } |
180 | 181 | ||
181 | /* Find the closest image size. The distance between image sizes is | 182 | /* Find the closest image size. The distance between image sizes is |
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index 57c3076a4625..3394c3432011 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c | |||
@@ -1812,6 +1812,7 @@ int uvc_video_init(struct uvc_streaming *stream) | |||
1812 | probe->bFormatIndex = format->index; | 1812 | probe->bFormatIndex = format->index; |
1813 | probe->bFrameIndex = frame->bFrameIndex; | 1813 | probe->bFrameIndex = frame->bFrameIndex; |
1814 | 1814 | ||
1815 | stream->def_format = format; | ||
1815 | stream->cur_format = format; | 1816 | stream->cur_format = format; |
1816 | stream->cur_frame = frame; | 1817 | stream->cur_frame = frame; |
1817 | 1818 | ||
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index af216ec45e39..d83b6baf703a 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h | |||
@@ -436,6 +436,7 @@ struct uvc_streaming { | |||
436 | struct uvc_format *format; | 436 | struct uvc_format *format; |
437 | 437 | ||
438 | struct uvc_streaming_control ctrl; | 438 | struct uvc_streaming_control ctrl; |
439 | struct uvc_format *def_format; | ||
439 | struct uvc_format *cur_format; | 440 | struct uvc_format *cur_format; |
440 | struct uvc_frame *cur_frame; | 441 | struct uvc_frame *cur_frame; |
441 | /* Protect access to ctrl, cur_format, cur_frame and hardware video | 442 | /* Protect access to ctrl, cur_format, cur_frame and hardware video |