Show a patch.

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

{
    "id": 22798,
    "url": "https://patchwork.libcamera.org/api/patches/22798/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22798/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20250217185327.306509-2-pobrn@protonmail.com>",
    "date": "2025-02-17T18:53:34",
    "name": "[v2,1/2] libcamera: pipeline: uvcvideo: Fix `ExposureTimeMode` control setup",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "d5e6251ca35868679f02a49e1a4448461f523ba7",
    "submitter": {
        "id": 133,
        "url": "https://patchwork.libcamera.org/api/people/133/?format=api",
        "name": "Pőcze Barnabás",
        "email": "pobrn@protonmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22798/mbox/",
    "series": [
        {
            "id": 5006,
            "url": "https://patchwork.libcamera.org/api/series/5006/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5006",
            "date": "2025-02-17T18:53:29",
            "name": "libcamera: pipeline: uvcvideo: Fix `ExposureTimeMode` control",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5006/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22798/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22798/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 9F255C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Feb 2025 18:53:42 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4EAF868681;\n\tMon, 17 Feb 2025 19:53:42 +0100 (CET)",
            "from mail-10631.protonmail.ch (mail-10631.protonmail.ch\n\t[79.135.106.31])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AEFCB61865\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Feb 2025 19:53:40 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"qBkVCvH2\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1739818420; x=1740077620;\n\tbh=W3kXEG4CVS9x8wIs8L3t6X8PiWkNwz/iR/pvgT10KVQ=;\n\th=Date:To:From:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=qBkVCvH24mj+Z2VpEtCp2h0ulHAg3+8KUZhCnVm8pPEKhWaH1cxd19hhDfaKsiizQ\n\ty0gYj35p7j/gzLWcQjQvqe+1tuAZpwDQaQkTA3GskKWw+BfxjObLRsVBYBkzbPs8Ih\n\t0uqUExqgkW6iH1sMtA/ChOdY0wbY6ujYqnmO36M6TESOquu/X7AmgpFv+rHtdS1oLB\n\tnPh52fGWKTWoGUjUGByDZ4Zr+PzWnEFCxCcT4q/Y8OdwaL/h5tigixl+g3aIMMgGmP\n\tAe0IvjWTt2ia1oR2zygH3akWdsF3TH2z2W2lb/ydb4VNmxD3GI9Q6rpvQmJUAfeQ1i\n\tR0XfXiYFyeVKA==",
        "Date": "Mon, 17 Feb 2025 18:53:34 +0000",
        "To": "libcamera-devel@lists.libcamera.org",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>",
        "Subject": "[PATCH v2 1/2] libcamera: pipeline: uvcvideo: Fix `ExposureTimeMode`\n\tcontrol setup",
        "Message-ID": "<20250217185327.306509-2-pobrn@protonmail.com>",
        "In-Reply-To": "<20250217185327.306509-1-pobrn@protonmail.com>",
        "References": "<20250217185327.306509-1-pobrn@protonmail.com>",
        "Feedback-ID": "20568564:user:proton",
        "X-Pm-Message-ID": "0ca59c9146b2b7a74c5c5e060aaa0739cd6a4529",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=utf-8",
        "Content-Transfer-Encoding": "quoted-printable",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "`ControlInfo(Span<const int32_t>{...})` calls the incorrect constructor\nof `ControlInfo`. The intended constructor to be called is\n`ControlInfo(Span<const ControlValue>, ...)` however that is not called\nbecause a span of `const int32_t` is passed. Instead, the constructor\n`ControlInfo(const ControlValue &min, const ControlValue &max, ...)`\nwill be called.\n\nFurthermore, since `values.back()` is used, only the last element of\nthe array is actually populated.\n\nTo fix this, convert the array to contain `ControlValue` objects\nand use a separate variable to keep track of which element is to\nbe populated next.\n\nThe available modes are saved for later so that the appropriate mode\ncan be selected when the control is set.\n\nFixes: bad8d591f8acfa (\"libcamera: uvcvideo: Register ExposureTimeMode control\")\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 46 ++++++++++++--------\n 1 file changed, 27 insertions(+), 19 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex dedcac89b..1f604b91e 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -6,6 +6,7 @@\n  */\n \n #include <algorithm>\n+#include <bitset>\n #include <cmath>\n #include <fstream>\n #include <map>\n@@ -58,6 +59,13 @@ public:\n \tStream stream_;\n \tstd::map<PixelFormat, std::vector<SizeRange>> formats_;\n \n+\tstd::bitset<\n+\t\tstd::max(V4L2_EXPOSURE_AUTO,\n+\t\tstd::max(V4L2_EXPOSURE_MANUAL,\n+\t\tstd::max(V4L2_EXPOSURE_APERTURE_PRIORITY,\n+\t\t\t V4L2_EXPOSURE_SHUTTER_PRIORITY))) + 1\n+\t> availableExposureModes_;\n+\n private:\n \tbool generateId();\n \n@@ -725,25 +733,25 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info,\n \t\t * ExposureTimeModeManual = { V4L2_EXPOSURE_MANUAL,\n \t\t *\t\t\t      V4L2_EXPOSURE_SHUTTER_PRIORITY }\n \t\t */\n-\t\tstd::array<int32_t, 2> values{};\n-\n-\t\tauto it = std::find_if(v4l2Values.begin(), v4l2Values.end(),\n-\t\t\t[&](const ControlValue &val) {\n-\t\t\t\treturn (val.get<int32_t>() == V4L2_EXPOSURE_APERTURE_PRIORITY ||\n-\t\t\t\t\tval.get<int32_t>() == V4L2_EXPOSURE_AUTO) ? true : false;\n-\t\t\t});\n-\t\tif (it != v4l2Values.end())\n-\t\t\tvalues.back() = static_cast<int32_t>(controls::ExposureTimeModeAuto);\n-\n-\t\tit = std::find_if(v4l2Values.begin(), v4l2Values.end(),\n-\t\t\t[&](const ControlValue &val) {\n-\t\t\t\treturn (val.get<int32_t>() == V4L2_EXPOSURE_SHUTTER_PRIORITY ||\n-\t\t\t\t\tval.get<int32_t>() == V4L2_EXPOSURE_MANUAL) ? true : false;\n-\t\t\t});\n-\t\tif (it != v4l2Values.end())\n-\t\t\tvalues.back() = static_cast<int32_t>(controls::ExposureTimeModeManual);\n-\n-\t\tinfo = ControlInfo{Span<int32_t>{values}, values[0]};\n+\t\tfor (const ControlValue &value : v4l2Values) {\n+\t\t\tauto x = value.get<int32_t>();\n+\t\t\tif (0 <= x && static_cast<size_t>(x) < availableExposureModes_.size())\n+\t\t\t\tavailableExposureModes_[x] = true;\n+\t\t}\n+\n+\t\tstd::array<ControlValue, 2> values;\n+\t\tstd::size_t count = 0;\n+\n+\t\tif (availableExposureModes_[V4L2_EXPOSURE_AUTO] || availableExposureModes_[V4L2_EXPOSURE_APERTURE_PRIORITY])\n+\t\t\tvalues[count++] = controls::ExposureTimeModeAuto;\n+\n+\t\tif (availableExposureModes_[V4L2_EXPOSURE_MANUAL] || availableExposureModes_[V4L2_EXPOSURE_SHUTTER_PRIORITY])\n+\t\t\tvalues[count++] = controls::ExposureTimeModeManual;\n+\n+\t\tif (count == 0)\n+\t\t\treturn;\n+\n+\t\tinfo = ControlInfo{ Span<const ControlValue>{ values.data(), count }, values[0] };\n \t\tbreak;\n \t}\n \tcase V4L2_CID_EXPOSURE_ABSOLUTE:\n",
    "prefixes": [
        "v2",
        "1/2"
    ]
}