diff options
author | Jacopo Mondi <jacopo@jmondi.org> | 2019-02-05 08:45:27 +0100 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2019-02-05 14:08:03 +0100 |
commit | cbbc315fe9bab6bfbfafa5952a51a259b243d5ef (patch) | |
tree | 81cebb95b26889461a17584ae8411a96c67617fa /src | |
parent | f7e75d9e7081f6e1c0379cca5585b771e64a8ac6 (diff) |
libcamera: v4l2_device: s_format: Return the device format
Return the device format actually applied to the device on setFormat().
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/v4l2_device.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
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; } |