summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-03-01 18:43:27 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-04-24 20:44:24 +0300
commit0fd7d941955dee55be2104c8143b5fbe42178fd3 (patch)
treeaaf2bbce0c63327d02905a0000878c1903e9d046
parentc46703e56a89bf0dbadba1b4b57ad4caf6fc0331 (diff)
libcamera: v4l2_videodevice: Update to the new kernel metadata API
With support for metadata in the streams API, the v4l2_meta_format structure has been extended with width, height and bytesperline fields. Support them in the V4L2VideoDevice getFormat() and setFormat() functions. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/libcamera/v4l2_videodevice.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index a72ef64d..9d4a0a3c 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -863,7 +863,7 @@ int V4L2VideoDevice::setFormat(V4L2DeviceFormat *format)
int V4L2VideoDevice::getFormatMeta(V4L2DeviceFormat *format)
{
struct v4l2_format v4l2Format = {};
- struct v4l2_meta_format *pix = &v4l2Format.fmt.meta;
+ struct v4l2_meta_format *meta = &v4l2Format.fmt.meta;
int ret;
v4l2Format.type = bufferType_;
@@ -873,12 +873,12 @@ int V4L2VideoDevice::getFormatMeta(V4L2DeviceFormat *format)
return ret;
}
- format->size.width = 0;
- format->size.height = 0;
- format->fourcc = V4L2PixelFormat(pix->dataformat);
+ format->size.width = meta->width;
+ format->size.height = meta->height;
+ format->fourcc = V4L2PixelFormat(meta->dataformat);
format->planesCount = 1;
- format->planes[0].bpl = pix->buffersize;
- format->planes[0].size = pix->buffersize;
+ format->planes[0].bpl = meta->bytesperline;
+ format->planes[0].size = meta->buffersize;
return 0;
}
@@ -886,12 +886,15 @@ int V4L2VideoDevice::getFormatMeta(V4L2DeviceFormat *format)
int V4L2VideoDevice::trySetFormatMeta(V4L2DeviceFormat *format, bool set)
{
struct v4l2_format v4l2Format = {};
- struct v4l2_meta_format *pix = &v4l2Format.fmt.meta;
+ struct v4l2_meta_format *meta = &v4l2Format.fmt.meta;
int ret;
v4l2Format.type = bufferType_;
- pix->dataformat = format->fourcc;
- pix->buffersize = format->planes[0].size;
+ meta->width = format->size.width;
+ meta->height = format->size.height;
+ meta->dataformat = format->fourcc;
+ meta->bytesperline = format->planes[0].bpl;
+ meta->buffersize = format->planes[0].size;
ret = ioctl(set ? VIDIOC_S_FMT : VIDIOC_TRY_FMT, &v4l2Format);
if (ret) {
LOG(V4L2, Error)
@@ -904,12 +907,12 @@ int V4L2VideoDevice::trySetFormatMeta(V4L2DeviceFormat *format, bool set)
* Return to caller the format actually applied on the video device,
* which might differ from the requested one.
*/
- format->size.width = 0;
- format->size.height = 0;
- format->fourcc = V4L2PixelFormat(pix->dataformat);
+ format->size.width = meta->width;
+ format->size.height = meta->height;
+ format->fourcc = V4L2PixelFormat(meta->dataformat);
format->planesCount = 1;
- format->planes[0].bpl = pix->buffersize;
- format->planes[0].size = pix->buffersize;
+ format->planes[0].bpl = meta->bytesperline;
+ format->planes[0].size = meta->buffersize;
return 0;
}