From cbbc315fe9bab6bfbfafa5952a51a259b243d5ef Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Tue, 5 Feb 2019 08:45:27 +0100 Subject: libcamera: v4l2_device: s_format: Return the device format Return the device format actually applied to the device on setFormat(). Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- src/libcamera/v4l2_device.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/libcamera/v4l2_device.cpp') diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index acb25586..853baf1a 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -289,6 +289,10 @@ int V4L2Device::getFormat(V4L2DeviceFormat *format) /** * \brief Configure an image format on the V4L2 device + * + * Apply the supplied \a format to the device, and return the actually + * applied format parameters, as \ref V4L2Device::getFormat would do. + * * \return 0 for success, a negative error code otherwise */ int V4L2Device::setFormat(V4L2DeviceFormat *format) @@ -340,6 +344,17 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format) return ret; } + /* + * Return to caller the format actually applied on the device, + * which might differ from the requested one. + */ + format->width = pix->width; + format->height = pix->height; + format->fourcc = pix->pixelformat; + format->planesCount = 1; + format->planes[0].bpl = pix->bytesperline; + format->planes[0].size = pix->sizeimage; + return 0; } @@ -394,6 +409,19 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format) return ret; } + /* + * Return to caller the format actually applied on the device, + * which might differ from the requested one. + */ + format->width = pix->width; + format->height = pix->height; + format->fourcc = pix->pixelformat; + format->planesCount = pix->num_planes; + for (unsigned int i = 0; i < format->planesCount; ++i) { + format->planes[i].bpl = pix->plane_fmt[i].bytesperline; + format->planes[i].size = pix->plane_fmt[i].sizeimage; + } + return 0; } -- cgit v1.2.1