summaryrefslogtreecommitdiff
path: root/src
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-09-30 11:12:07 +0300
commit72e8139dd21d5c9edd54db362f6a6f5841bf1a23 (patch)
tree1297a845666007e896f53fe33b94a14bb74edb50 /src
parent875d2e0c3d60458f6ce240f1717bb0401f8b2069 (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>
Diffstat (limited to 'src')
-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 14eba056..db7fd86e 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -888,7 +888,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_;
@@ -898,12 +898,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;
}
@@ -911,12 +911,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)
@@ -929,12 +932,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;
}