From 79ab0e925a782a6781d38237435fcfc29ddd2e20 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 26 Apr 2020 02:08:37 +0300 Subject: libcamera: v4l2_device: Simplify usage of getControls() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The V4L2Device::getControls() function takes a ControlList that needs to be pre-populated with dummy entries for the controls that need to be read. This is a cumbersome API, especially when reading a single control. Make it nicer by passing the list of V4L2 controls as a vector of control IDs, and returning a ControlList. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/camera_sensor.cpp | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'src/libcamera/camera_sensor.cpp') diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 2219a430..7c1d9b9e 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -299,30 +299,24 @@ const ControlInfoMap &CameraSensor::controls() const /** * \brief Read controls from the sensor - * \param[inout] ctrls The list of controls to read + * \param[in] ids The list of control to read, specified by their ID * - * This method reads the value of all controls contained in \a ctrls, and stores - * their values in the corresponding \a ctrls entry. + * This method reads the value of all controls contained in \a ids, and returns + * their values as a ControlList. * - * If any control in \a ctrls is not supported by the device, is disabled (i.e. - * has the V4L2_CTRL_FLAG_DISABLED flag set), is a compound control, or if any - * other error occurs during validation of the requested controls, no control is - * read and this method returns -EINVAL. - * - * If an error occurs while reading the controls, the index of the first control - * that couldn't be read is returned. The value of all controls below that index - * are updated in \a ctrls, while the value of all the other controls are not - * changed. + * If any control in \a ids is not supported by the device, is disabled (i.e. + * has the V4L2_CTRL_FLAG_DISABLED flag set), or if any other error occurs + * during validation of the requested controls, no control is read and this + * method returns an empty control list. * * \sa V4L2Device::getControls() * - * \return 0 on success or an error code otherwise - * \retval -EINVAL One of the control is not supported or not accessible - * \retval i The index of the control that failed + * \return The control values in a ControlList on success, or an empty list on + * error */ -int CameraSensor::getControls(ControlList *ctrls) +ControlList CameraSensor::getControls(const std::vector &ids) { - return subdev_->getControls(ctrls); + return subdev_->getControls(ids); } /** @@ -340,10 +334,9 @@ int CameraSensor::getControls(ControlList *ctrls) * \a ctrls entry. * * If any control in \a ctrls is not supported by the device, is disabled (i.e. - * has the V4L2_CTRL_FLAG_DISABLED flag set), is read-only, is a - * compound control, or if any other error occurs during validation of - * the requested controls, no control is written and this method returns - * -EINVAL. + * has the V4L2_CTRL_FLAG_DISABLED flag set), is read-only, or if any other + * error occurs during validation of the requested controls, no control is + * written and this method returns -EINVAL. * * If an error occurs while writing the controls, the index of the first * control that couldn't be written is returned. All controls below that index -- cgit v1.2.1