libcamera: v4l2_device: Fix control enumeration bug

When enumerating the available V4L2 controls at video device open
time set the V4L2_CTRL_FLAG_NEXT_CTRL flag if an unsupported control
type is encountered to prevent infinite loops.

While at it, downgrade the message reporting the unsupported control
type to Debug, as it is not an error worth being reported unconditionally.

Fixes: 030ce6491e ("libcamera: v4l2_device: List valid controls at open")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jacopo Mondi 2019-06-26 12:05:02 +02:00
parent caf25dc5cf
commit 6948ec44c7

View file

@ -321,13 +321,14 @@ void V4L2Device::listControls()
struct v4l2_query_ext_ctrl ctrl = {}; struct v4l2_query_ext_ctrl ctrl = {};
/* \todo Add support for menu and compound controls. */ /* \todo Add support for menu and compound controls. */
ctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL; while (1) {
while (ioctl(VIDIOC_QUERY_EXT_CTRL, &ctrl) == 0) { ctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
if (ioctl(VIDIOC_QUERY_EXT_CTRL, &ctrl))
break;
if (ctrl.type == V4L2_CTRL_TYPE_CTRL_CLASS || if (ctrl.type == V4L2_CTRL_TYPE_CTRL_CLASS ||
ctrl.flags & V4L2_CTRL_FLAG_DISABLED) { ctrl.flags & V4L2_CTRL_FLAG_DISABLED)
ctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
continue; continue;
}
V4L2ControlInfo info(ctrl); V4L2ControlInfo info(ctrl);
switch (info.type()) { switch (info.type()) {
@ -341,13 +342,12 @@ void V4L2Device::listControls()
break; break;
/* \todo Support compound controls. */ /* \todo Support compound controls. */
default: default:
LOG(V4L2, Error) << "Control type '" << info.type() LOG(V4L2, Debug) << "Control type '" << info.type()
<< "' not supported"; << "' not supported";
continue; continue;
} }
controls_.emplace(ctrl.id, info); controls_.emplace(ctrl.id, info);
ctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
} }
} }