Show a patch.

GET /api/1.1/patches/10239/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 10239,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/10239/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10239/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20201025160434.25664-5-jacopo@jmondi.org>",
    "date": "2020-10-25T16:04:24",
    "name": "[libcamera-devel,v5,04/14] libcamera: controls: Construct from valid values",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "1153067afabf693acef465f503ade25a9a48da8e",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/10239/mbox/",
    "series": [
        {
            "id": 1414,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1414/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1414",
            "date": "2020-10-25T16:04:20",
            "name": "libcamera: Introduce draft controls",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/1414/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10239/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10239/checks/",
    "tags": {},
    "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 A2971C3B5F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 25 Oct 2020 16:04:48 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6336B61E91;\n\tSun, 25 Oct 2020 17:04:48 +0100 (CET)",
            "from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6CAC361E01\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 25 Oct 2020 17:04:45 +0100 (CET)",
            "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay10.mail.gandi.net (Postfix) with ESMTPSA id CDFE2240003;\n\tSun, 25 Oct 2020 16:04:44 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun, 25 Oct 2020 17:04:24 +0100",
        "Message-Id": "<20201025160434.25664-5-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.28.0",
        "In-Reply-To": "<20201025160434.25664-1-jacopo@jmondi.org>",
        "References": "<20201025160434.25664-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v5 04/14] libcamera: controls: Construct\n\tfrom 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>",
        "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>"
    },
    "content": "Add two constructors to the ControlInfo class that allows creating\na class instance from the list of the control valid values with\nan optional default one.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/controls.h |  5 +++++\n src/libcamera/controls.cpp   | 33 +++++++++++++++++++++++++++++++++\n 2 files changed, 38 insertions(+)",
    "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 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 *>;\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 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  */\n",
    "prefixes": [
        "libcamera-devel",
        "v5",
        "04/14"
    ]
}