summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Scally <dan.scally@ideasonboard.com>2022-11-22 15:34:20 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2022-11-22 16:08:24 +0000
commitbca24b4b5b2c18b844e8da80ac19819944f80a93 (patch)
treefcbe9579ded3a124f4ee26a1ddc83e17fc3e9194 /lib
parentd47c0701f2250889970afa6b5af025ea0a02b3be (diff)
lib: uvc: Drop maxsize
The maxsize field of struct uvc_device is probably unecessary even if it weren't currently fixed at 0. It's used to set dwMaxVideoFrameSize in addition to the sizeimage member of a struct v4l2_pix_fmt (multiplied in the latter instance by 1.5x). The documentary definitions for those two values are such that they should be identical though, so simply set dwMaxVideoFrameSize to width*height*2 (to maintain commonality with other UVC Video devices) and use that to set the sizeimage. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/uvc.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/uvc.c b/lib/uvc.c
index 975413a..a9d0e69 100644
--- a/lib/uvc.c
+++ b/lib/uvc.c
@@ -39,7 +39,6 @@ struct uvc_device
unsigned int fcc;
unsigned int width;
unsigned int height;
- unsigned int maxsize;
};
struct uvc_device *uvc_open(const char *devname, struct uvc_stream *stream)
@@ -112,12 +111,15 @@ uvc_fill_streaming_control(struct uvc_device *dev,
ctrl->bFrameIndex = iframe ;
ctrl->dwFrameInterval = ival;
+ /*
+ * The maximum size in bytes for a single frame depends on the format.
+ * This switch will need extending for any new formats that are added
+ * to ensure the buffer size calculations are done correctly.
+ */
switch (format->fcc) {
case V4L2_PIX_FMT_YUYV:
- ctrl->dwMaxVideoFrameSize = frame->width * frame->height * 2;
- break;
case V4L2_PIX_FMT_MJPEG:
- ctrl->dwMaxVideoFrameSize = dev->maxsize;
+ ctrl->dwMaxVideoFrameSize = frame->width * frame->height * 2;
break;
}
@@ -287,7 +289,7 @@ uvc_events_process_data(struct uvc_device *dev,
pixfmt.pixelformat = format->fcc;
pixfmt.field = V4L2_FIELD_NONE;
if (format->fcc == V4L2_PIX_FMT_MJPEG)
- pixfmt.sizeimage = dev->maxsize * 1.5;
+ pixfmt.sizeimage = target->dwMaxVideoFrameSize;
uvc_stream_set_format(dev->stream, &pixfmt);
@@ -373,8 +375,6 @@ void uvc_events_init(struct uvc_device *dev, struct events *events)
void uvc_set_config(struct uvc_device *dev, struct uvc_function_config *fc)
{
- /* FIXME: The maximum size should be specified per format and frame. */
- dev->maxsize = 0;
dev->fc = fc;
}