From 6a1ff2615ba14eb70bec501270aacb531cb4c210 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 27 Oct 2019 23:42:56 +0200 Subject: libcamera: v4l2_controls: Fix control range construction for bool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit V4L2 controls of type V4L2_CTRL_TYPE_BOOLEAN are incorrectly described with a ControlRange of int32_t values. Fix it. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund Reviewed-by: Kieran Bingham --- src/libcamera/v4l2_controls.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index 2462c3e2..b6547a7c 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -118,12 +118,22 @@ V4L2ControlId::V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl) */ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) { - if (ctrl.type == V4L2_CTRL_TYPE_INTEGER64) + switch (ctrl.type) { + case V4L2_CTRL_TYPE_BOOLEAN: + ControlRange::operator=(ControlRange(static_cast(ctrl.minimum), + static_cast(ctrl.maximum))); + break; + + case V4L2_CTRL_TYPE_INTEGER64: ControlRange::operator=(ControlRange(static_cast(ctrl.minimum), static_cast(ctrl.maximum))); - else + break; + + default: ControlRange::operator=(ControlRange(static_cast(ctrl.minimum), static_cast(ctrl.maximum))); + break; + } } } /* namespace libcamera */ -- cgit v1.2.1