[{"id":1967,"web_url":"https://patchwork.libcamera.org/comment/1967/","msgid":"<20190622202736.GE8156@pendragon.ideasonboard.com>","date":"2019-06-22T20:27:36","subject":"Re: [libcamera-devel] [PATCH v5 4/6] libcamera: camera_sensor: Add\n\tV4L2 control operations","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Thu, Jun 20, 2019 at 05:31:42PM +0200, Jacopo Mondi wrote:\n> Add operations to get and set control and to retrieve the informations\n> on a V4L2 control. For simple camera sensors, the operations are\n> directly called on the underlying V4L2 subdevice.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/camera_sensor.cpp       | 65 +++++++++++++++++++++++++++\n>  src/libcamera/include/camera_sensor.h |  6 +++\n>  2 files changed, 71 insertions(+)\n> \n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index a804a68c9d91..637f86b05701 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -247,6 +247,71 @@ int CameraSensor::setFormat(V4L2SubdeviceFormat *format)\n>  \treturn subdev_->setFormat(0, format);\n>  }\n>  \n> +/**\n> + * \\brief Retrieve information about a control\n> + * \\param[in] id The control ID\n> + * \\return A pointer to the V4L2ControlInfo for control \\a id, or nullptr\n> + * if the sensor doesn't have such a control\n> + */\n> +const V4L2ControlInfo *CameraSensor::getControlInfo(unsigned int id) const\n> +{\n> +\treturn subdev_->getControlInfo(id);\n> +}\n> +\n> +/**\n> + * \\brief Read controls from the sensor\n> + * \\param[inout] ctrls The list of controls to read\n> + *\n> + * Read the value of each control contained in \\a ctrls, and store the\n> + * value in the corresponding \\a ctrls entry.\n> + *\n> + * If an integer number less than the requested number of controls is returned,\n> + * only controls up to that index have been successfully read.\n> + *\n> + * Each V4L2Control instance in \\a ctrls should be supported by the sensor and\n> + * accessible (ie the V4L2_CTRL_FLAG_DISABLED flag should not be set), otherwise\n> + * a negative error code (-EINVAL) is returned\n> + *\n> + * \\sa V4L2Device::getControls()\n> + *\n> + * \\return 0 on success or an error code otherwise\n> + * \\retval -EINVAL One of the control is not supported or not accessible\n> + * \\retval i The index of the control that failed\n> + */\n\nLet's copy the documentation for getControls() and setControls() from\npatch 3/6 once we agree on it, and\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +int CameraSensor::getControls(V4L2Controls *ctrls)\n> +{\n> +\treturn subdev_->getControls(ctrls);\n> +}\n> +\n> +/**\n> + * \\brief Write controls to the sensor\n> + * \\param[in] ctrls The list of controls to write\n> + *\n> + * Write the value of each V4L2Control contained in \\a ctrls. Each\n> + * control should be initialized by the caller with a value, otherwise\n> + * the result of the operation is undefined.\n> + *\n> + * The value of each control is updated to reflect what has been\n> + * actually applied on the sensor.\n> + *\n> + * If an integer number less than the requested number of controls is returned,\n> + * only controls up to that index have been successfully applied.\n> + *\n> + * Each V4L2Control instance in \\a ctrls should be supported by the sensor and\n> + * accessible (ie the V4L2_CTRL_FLAG_DISABLED flag should not be set), otherwise\n> + * a negative error code (-EINVAL) is returned\n> + *\n> + * \\sa V4L2Device::setControls()\n> + *\n> + * \\return 0 on success or an error code otherwise\n> + * \\retval -EINVAL One of the control is not supported or not accessible\n> + * \\retval i The index of the control that failed\n> + */\n> +int CameraSensor::setControls(V4L2Controls *ctrls)\n> +{\n> +\treturn subdev_->setControls(ctrls);\n> +}\n> +\n>  std::string CameraSensor::logPrefix() const\n>  {\n>  \treturn \"'\" + subdev_->entity()->name() + \"'\";\n> diff --git a/src/libcamera/include/camera_sensor.h b/src/libcamera/include/camera_sensor.h\n> index b823480241a7..b4f4b66e96c4 100644\n> --- a/src/libcamera/include/camera_sensor.h\n> +++ b/src/libcamera/include/camera_sensor.h\n> @@ -17,6 +17,8 @@\n>  namespace libcamera {\n>  \n>  class MediaEntity;\n> +class V4L2ControlInfo;\n> +class V4L2Controls;\n>  class V4L2Subdevice;\n>  \n>  struct V4L2SubdeviceFormat;\n> @@ -41,6 +43,10 @@ public:\n>  \t\t\t\t      const Size &size) const;\n>  \tint setFormat(V4L2SubdeviceFormat *format);\n>  \n> +\tconst V4L2ControlInfo *getControlInfo(unsigned int id) const;\n> +\tint getControls(V4L2Controls *ctrls);\n> +\tint setControls(V4L2Controls *ctrls);\n> +\n>  protected:\n>  \tstd::string logPrefix() const;\n>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A5D4261580\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 22 Jun 2019 22:27:54 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3021567;\n\tSat, 22 Jun 2019 22:27:54 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1561235274;\n\tbh=xROlicP88dwIsNfTe3sy2RNca0yecP3afm6pyI21l9g=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Cn5RT6uQdBfp9H44BtgLW5NG7GXJTNncJisiZTxhZNs5f5LueBE/rFNSvLQ1D89Gj\n\tspP5E2/35AhfCwYL9PHtDBJtghO8sR6iILZC10iow1llnMzE5oWvkQdFQ2TMXzez7S\n\tppXciQF1OlyjK8J3kCIMq5W1lrntAj2TlLahzTS4=","Date":"Sat, 22 Jun 2019 23:27:36 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190622202736.GE8156@pendragon.ideasonboard.com>","References":"<20190620153144.5394-1-jacopo@jmondi.org>\n\t<20190620153144.5394-5-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190620153144.5394-5-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v5 4/6] libcamera: camera_sensor: Add\n\tV4L2 control operations","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sat, 22 Jun 2019 20:27:54 -0000"}}]