[{"id":13479,"web_url":"https://patchwork.libcamera.org/comment/13479/","msgid":"<20201025225847.GG4283@pendragon.ideasonboard.com>","date":"2020-10-25T22:58:47","subject":"Re: [libcamera-devel] [PATCH v5 04/14] libcamera: controls:\n\tConstruct from valid values","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 Sun, Oct 25, 2020 at 05:04:24PM +0100, Jacopo Mondi wrote:\n> Add two constructors to the ControlInfo class that allows creating\n> a class instance from the list of the control valid values with\n> an optional default one.\n\nThere's one constructor only now :-)\n\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nWith the commit message fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  include/libcamera/controls.h |  5 +++++\n>  src/libcamera/controls.cpp   | 33 +++++++++++++++++++++++++++++++++\n>  2 files changed, 38 insertions(+)\n> \n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index a556328cd188..3b7f3347761e 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -12,6 +12,7 @@\n>  #include <stdint.h>\n>  #include <string>\n>  #include <unordered_map>\n> +#include <vector>\n>  \n>  #include <libcamera/geometry.h>\n>  #include <libcamera/span.h>\n> @@ -269,10 +270,13 @@ public:\n>  \texplicit ControlInfo(const ControlValue &min = 0,\n>  \t\t\t     const ControlValue &max = 0,\n>  \t\t\t     const ControlValue &def = 0);\n> +\texplicit ControlInfo(Span<const ControlValue> values,\n> +\t\t\t     const ControlValue &def = {});\n>  \n>  \tconst ControlValue &min() const { return min_; }\n>  \tconst ControlValue &max() const { return max_; }\n>  \tconst ControlValue &def() const { return def_; }\n> +\tconst std::vector<ControlValue> &values() const { return values_; }\n>  \n>  \tstd::string toString() const;\n>  \n> @@ -290,6 +294,7 @@ private:\n>  \tControlValue min_;\n>  \tControlValue max_;\n>  \tControlValue def_;\n> +\tstd::vector<ControlValue> values_;\n>  };\n>  \n>  using ControlIdMap = std::unordered_map<unsigned int, const ControlId *>;\n> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\n> index dca782667d88..aad461121651 100644\n> --- a/src/libcamera/controls.cpp\n> +++ b/src/libcamera/controls.cpp\n> @@ -491,6 +491,28 @@ ControlInfo::ControlInfo(const ControlValue &min,\n>  {\n>  }\n>  \n> +/**\n> + * \\brief Construct a ControlInfo from the list of valid values\n> + * \\param[in] values The control valid values\n> + * \\param[in] def The control default value\n> + *\n> + * Construct a ControlInfo from a list of valid values. The ControlInfo\n> + * minimum and maximum values are set to the first and last members of the\n> + * values list respectively. The default value is set to \\a def if provided, or\n> + * to the minimum value otherwise.\n> + */\n> +ControlInfo::ControlInfo(Span<const ControlValue> values,\n> +\t\t\t const ControlValue &def)\n> +{\n> +\tmin_ = values.front();\n> +\tmax_ = values.back();\n> +\tdef_ = !def.isNone() ? def : values.front();\n> +\n> +\tvalues_.reserve(values.size());\n> +\tfor (const ControlValue &value : values)\n> +\t\tvalues_.push_back(value);\n> +}\n> +\n>  /**\n>   * \\fn ControlInfo::min()\n>   * \\brief Retrieve the minimum value of the control\n> @@ -519,6 +541,17 @@ ControlInfo::ControlInfo(const ControlValue &min,\n>   * \\return A ControlValue with the default value for the control\n>   */\n>  \n> +/**\n> + * \\fn ControlInfo::values()\n> + * \\brief Retrieve the list of valid values\n> + *\n> + * For controls that support a pre-defined number of values, the enumeration of\n> + * those is reported through a vector of ControlValue instances accessible with\n> + * this method.\n> + *\n> + * \\return A vector of ControlValue representing the control valid values\n> + */\n> +\n>  /**\n>   * \\brief Provide a string representation of the ControlInfo\n>   */","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1A2CCBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 25 Oct 2020 22:59:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A01B161E01;\n\tSun, 25 Oct 2020 23:59:36 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1216F61D25\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 25 Oct 2020 23:59:35 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7BD3B9B7;\n\tSun, 25 Oct 2020 23:59:34 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"WIWhTJt9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1603666774;\n\tbh=uMs84u+6Nf5W3PPV91LxwxCE1RAEgO19ZkqjKkPPxIk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=WIWhTJt9F62lCu7mj49uNuiKenuHtunuUvY/SAG7fK35RMbQTujzz1fFhPOKuYFNu\n\trphOQGqHgGfo300Cq1aKzsB6feHlRDXOwGdhoSj4emXe/jzfT6Wi9gZtbX2hh0SrAo\n\tDOCvzRvqIVKKyIV23GWkodLbUlr9+PB9QCgsqfC4=","Date":"Mon, 26 Oct 2020 00:58:47 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20201025225847.GG4283@pendragon.ideasonboard.com>","References":"<20201025160434.25664-1-jacopo@jmondi.org>\n\t<20201025160434.25664-5-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201025160434.25664-5-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v5 04/14] libcamera: controls:\n\tConstruct from valid values","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]