[media] v4l2: uvcvideo: Allow using larger buffers
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Tue, 9 Sep 2014 07:42:43 +0000 (04:42 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sun, 21 Sep 2014 23:37:55 +0000 (20:37 -0300)
A test in uvc_video_decode_isoc() checks whether an image has been
received from the camera completely. For this the data amount is compared
to the buffer length, which, however, doesn't have to be equal to the
image size. Switch to using formats .sizeimage field for an exact
expected image size.

[Renamed image_size to frame_size]

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/usb/uvc/uvc_v4l2.c
drivers/media/usb/uvc/uvc_video.c
drivers/media/usb/uvc/uvcvideo.h

index 378ae02e593b93a19bb9010a23f62175029bbefd..60a8e2c3631e0b155b241e624092ccef271ae030 100644 (file)
@@ -318,6 +318,7 @@ static int uvc_v4l2_set_format(struct uvc_streaming *stream,
        stream->ctrl = probe;
        stream->cur_format = format;
        stream->cur_frame = frame;
+       stream->frame_size = fmt->fmt.pix.sizeimage;
 
 done:
        mutex_unlock(&stream->mutex);
index a2bddf48171f48bcc6df3412c8541c0b2d6ec510..9ace520bb079792b840d8aff38b68945fef0eeb0 100644 (file)
@@ -1143,7 +1143,7 @@ static int uvc_video_encode_data(struct uvc_streaming *stream,
 static void uvc_video_validate_buffer(const struct uvc_streaming *stream,
                                      struct uvc_buffer *buf)
 {
-       if (buf->length != buf->bytesused &&
+       if (stream->frame_size != buf->bytesused &&
            !(stream->cur_format->flags & UVC_FMT_FLAG_COMPRESSED))
                buf->error = 1;
 }
index 39c4f941b63d9b9c6ecd8e3e5029a4e446beac9e..6f676c29ec09fd997b8833d78df1b8b72fdf0d91 100644 (file)
@@ -457,6 +457,8 @@ struct uvc_streaming {
        struct uvc_format *def_format;
        struct uvc_format *cur_format;
        struct uvc_frame *cur_frame;
+       size_t frame_size;
+
        /* Protect access to ctrl, cur_format, cur_frame and hardware video
         * probe control.
         */