linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] V4L2: UVC: allow using larger buffers
@ 2014-09-09  7:42 Guennadi Liakhovetski
  2014-09-09 22:51 ` Laurent Pinchart
  0 siblings, 1 reply; 3+ messages in thread
From: Guennadi Liakhovetski @ 2014-09-09  7:42 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Laurent Pinchart

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.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

Thanks to Laurent for the idea

 drivers/media/usb/uvc/uvc_v4l2.c  | 1 +
 drivers/media/usb/uvc/uvc_video.c | 2 +-
 drivers/media/usb/uvc/uvcvideo.h  | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 3b548b8..87d15c2 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -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->image_size = fmt->fmt.pix.sizeimage;
 
 done:
 	mutex_unlock(&stream->mutex);
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index e568e07..60abf6f 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1172,7 +1172,7 @@ static void uvc_video_decode_isoc(struct urb *urb, struct uvc_streaming *stream,
 			urb->iso_frame_desc[i].actual_length);
 
 		if (buf->state == UVC_BUF_STATE_READY) {
-			if (buf->length != buf->bytesused &&
+			if (stream->image_size != buf->bytesused &&
 			    !(stream->cur_format->flags &
 			      UVC_FMT_FLAG_COMPRESSED))
 				buf->error = 1;
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 404793b..d3a3b71 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -480,6 +480,7 @@ struct uvc_streaming {
 	struct uvc_format *def_format;
 	struct uvc_format *cur_format;
 	struct uvc_frame *cur_frame;
+	size_t image_size;
 	/* Protect access to ctrl, cur_format, cur_frame and hardware video
 	 * probe control.
 	 */
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] V4L2: UVC: allow using larger buffers
  2014-09-09  7:42 [PATCH] V4L2: UVC: allow using larger buffers Guennadi Liakhovetski
@ 2014-09-09 22:51 ` Laurent Pinchart
  2014-09-10  8:53   ` Guennadi Liakhovetski
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2014-09-09 22:51 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: Linux Media Mailing List

Hi Guennadi,

Thank you for the patch.

On Tuesday 09 September 2014 09:42:43 Guennadi Liakhovetski wrote:
> 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.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
> 
> Thanks to Laurent for the idea
> 
>  drivers/media/usb/uvc/uvc_v4l2.c  | 1 +
>  drivers/media/usb/uvc/uvc_video.c | 2 +-
>  drivers/media/usb/uvc/uvcvideo.h  | 1 +
>  3 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c
> b/drivers/media/usb/uvc/uvc_v4l2.c index 3b548b8..87d15c2 100644
> --- a/drivers/media/usb/uvc/uvc_v4l2.c
> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
> @@ -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->image_size = fmt->fmt.pix.sizeimage;
> 
>  done:
>  	mutex_unlock(&stream->mutex);
> diff --git a/drivers/media/usb/uvc/uvc_video.c
> b/drivers/media/usb/uvc/uvc_video.c index e568e07..60abf6f 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -1172,7 +1172,7 @@ static void uvc_video_decode_isoc(struct urb *urb,
> struct uvc_streaming *stream, urb->iso_frame_desc[i].actual_length);
> 
>  		if (buf->state == UVC_BUF_STATE_READY) {
> -			if (buf->length != buf->bytesused &&
> +			if (stream->image_size != buf->bytesused &&
>  			    !(stream->cur_format->flags &
>  			      UVC_FMT_FLAG_COMPRESSED))
>  				buf->error = 1;
> diff --git a/drivers/media/usb/uvc/uvcvideo.h
> b/drivers/media/usb/uvc/uvcvideo.h index 404793b..d3a3b71 100644
> --- a/drivers/media/usb/uvc/uvcvideo.h
> +++ b/drivers/media/usb/uvc/uvcvideo.h
> @@ -480,6 +480,7 @@ struct uvc_streaming {
>  	struct uvc_format *def_format;
>  	struct uvc_format *cur_format;
>  	struct uvc_frame *cur_frame;
> +	size_t image_size;

As UVC uses the term frame size instead of image size, would you mind renaming 
that field ? I can do that while applying the patch, there's no need to 
resubmit if you're fine with the change.

>  	/* Protect access to ctrl, cur_format, cur_frame and hardware video
>  	 * probe control.
>  	 */

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] V4L2: UVC: allow using larger buffers
  2014-09-09 22:51 ` Laurent Pinchart
@ 2014-09-10  8:53   ` Guennadi Liakhovetski
  0 siblings, 0 replies; 3+ messages in thread
From: Guennadi Liakhovetski @ 2014-09-10  8:53 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Linux Media Mailing List

Hi Laurent,

On Wed, 10 Sep 2014, Laurent Pinchart wrote:

> Hi Guennadi,
> 
> Thank you for the patch.
> 
> On Tuesday 09 September 2014 09:42:43 Guennadi Liakhovetski wrote:
> > 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.
> > 
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > ---
> > 
> > Thanks to Laurent for the idea
> > 
> >  drivers/media/usb/uvc/uvc_v4l2.c  | 1 +
> >  drivers/media/usb/uvc/uvc_video.c | 2 +-
> >  drivers/media/usb/uvc/uvcvideo.h  | 1 +
> >  3 files changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/usb/uvc/uvc_v4l2.c
> > b/drivers/media/usb/uvc/uvc_v4l2.c index 3b548b8..87d15c2 100644
> > --- a/drivers/media/usb/uvc/uvc_v4l2.c
> > +++ b/drivers/media/usb/uvc/uvc_v4l2.c
> > @@ -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->image_size = fmt->fmt.pix.sizeimage;
> > 
> >  done:
> >  	mutex_unlock(&stream->mutex);
> > diff --git a/drivers/media/usb/uvc/uvc_video.c
> > b/drivers/media/usb/uvc/uvc_video.c index e568e07..60abf6f 100644
> > --- a/drivers/media/usb/uvc/uvc_video.c
> > +++ b/drivers/media/usb/uvc/uvc_video.c
> > @@ -1172,7 +1172,7 @@ static void uvc_video_decode_isoc(struct urb *urb,
> > struct uvc_streaming *stream, urb->iso_frame_desc[i].actual_length);
> > 
> >  		if (buf->state == UVC_BUF_STATE_READY) {
> > -			if (buf->length != buf->bytesused &&
> > +			if (stream->image_size != buf->bytesused &&
> >  			    !(stream->cur_format->flags &
> >  			      UVC_FMT_FLAG_COMPRESSED))
> >  				buf->error = 1;
> > diff --git a/drivers/media/usb/uvc/uvcvideo.h
> > b/drivers/media/usb/uvc/uvcvideo.h index 404793b..d3a3b71 100644
> > --- a/drivers/media/usb/uvc/uvcvideo.h
> > +++ b/drivers/media/usb/uvc/uvcvideo.h
> > @@ -480,6 +480,7 @@ struct uvc_streaming {
> >  	struct uvc_format *def_format;
> >  	struct uvc_format *cur_format;
> >  	struct uvc_frame *cur_frame;
> > +	size_t image_size;
> 
> As UVC uses the term frame size instead of image size, would you mind renaming 
> that field ? I can do that while applying the patch, there's no need to 
> resubmit if you're fine with the change.

Sure, np, go ahead with the change.

Thanks
Guennadi

> 
> >  	/* Protect access to ctrl, cur_format, cur_frame and hardware video
> >  	 * probe control.
> >  	 */
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-10  8:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-09  7:42 [PATCH] V4L2: UVC: allow using larger buffers Guennadi Liakhovetski
2014-09-09 22:51 ` Laurent Pinchart
2014-09-10  8:53   ` Guennadi Liakhovetski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).