summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libcamera/v4l2_device.cpp28
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;
}