[libcamera-devel] [PATCH] libcamera: v4l2_subdevice: use G_FORMAT if ENUM_FRAME_SIZE isn't implemented
Andrey Konovalov
andrey.konovalov at linaro.org
Fri Oct 25 15:32:08 CEST 2019
Many camera sensor drivers support only one frame size, and don't
implement VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl. And libcamera fails
to enumerate such cameras as it doesn't get the list of resolutions
the sensor driver supports. Fix this by using VIDIOC_SUBDEV_G_FORMAT
to get the size of the sensor's active format when the ENUM_FRAME_SIZE
ioctl isn't implemented by the sensor driver.
Signed-off-by: Andrey Konovalov <andrey.konovalov at linaro.org>
---
src/libcamera/v4l2_subdevice.cpp | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index f2bcd7f..fac7586 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -317,7 +317,25 @@ std::vector<SizeRange> V4L2Subdevice::enumPadSizes(unsigned int pad,
sizeEnum.max_width, sizeEnum.max_height);
}
- if (ret < 0 && ret != -EINVAL && ret != -ENOTTY) {
+ if (ret == -ENOTTY) {
+ struct v4l2_subdev_format format = {};
+
+ LOG(V4L2, Debug)
+ << "VIDIOC_SUBDEV_ENUM_FRAME_SIZE not implemented "
+ << "- trying VIDIOC_SUBDEV_G_FMT";
+ format.pad = pad;
+ format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+
+ ret = ioctl(VIDIOC_SUBDEV_G_FMT, &format);
+ if (ret == 0) {
+ sizes.emplace_back(format.format.width,
+ format.format.height,
+ format.format.width,
+ format.format.height);
+ }
+ }
+
+ if (ret < 0 && ret != -EINVAL) {
LOG(V4L2, Error)
<< "Unable to enumerate sizes on pad " << pad
<< ": " << strerror(-ret);
--
2.17.1
More information about the libcamera-devel
mailing list