summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2022-11-01 18:00:51 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2022-11-28 17:15:35 +0000
commit96ed45b9711e5c70afc4f91eab0ed657ccfb9695 (patch)
tree2f96fdeb8fa3751ce68d6c9fb38f5f006156b086 /include
parent1cd7646f970d90f3c8bec02259a2415c5cf89016 (diff)
libcamera: v4l2_device: Workaround faulty control menus
Some UVC cameras have been identified that can provide V4L2 menu controls without any menu items. This leads to a segfault where we try to construct a ControlInfo(Span<>,default) with an empty span. Convert the v4l2ControlInfo and v4l2MenuControlInfo helper functions to return std::optional<ControlInfo> to be able to account in the caller if the control is valid, and only add acceptable controls to the supported control list. Menu controls without a list of menu items are no longer added as a valid control and a warning is logged. This also fixes a potential crash that would have occured in the unlikely event that a ctrl.minimum was set to less than 0. Bug: https://bugs.libcamera.org/show_bug.cgi?id=167 Reported-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/internal/v4l2_device.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h
index 75304be1..50d4adbc 100644
--- a/include/libcamera/internal/v4l2_device.h
+++ b/include/libcamera/internal/v4l2_device.h
@@ -70,8 +70,8 @@ protected:
private:
static ControlType v4l2CtrlType(uint32_t ctrlType);
static std::unique_ptr<ControlId> v4l2ControlId(const v4l2_query_ext_ctrl &ctrl);
- ControlInfo v4l2ControlInfo(const v4l2_query_ext_ctrl &ctrl);
- ControlInfo v4l2MenuControlInfo(const v4l2_query_ext_ctrl &ctrl);
+ std::optional<ControlInfo> v4l2ControlInfo(const v4l2_query_ext_ctrl &ctrl);
+ std::optional<ControlInfo> v4l2MenuControlInfo(const v4l2_query_ext_ctrl &ctrl);
void listControls();
void updateControls(ControlList *ctrls,