Show a patch.

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

{
    "id": 22959,
    "url": "https://patchwork.libcamera.org/api/patches/22959/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22959/",
    "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": "<20250314174248.1015718-5-barnabas.pocze@ideasonboard.com>",
    "date": "2025-03-14T17:42:48",
    "name": "[v3,4/4] libcamera: pipeline: uvcvideo: Fix `ExposureTime` control handling",
    "commit_ref": null,
    "pull_url": null,
    "state": "deferred",
    "archived": false,
    "hash": "def29e4e373427afb6d14b6486b2de8a6879b8bf",
    "submitter": {
        "id": 216,
        "url": "https://patchwork.libcamera.org/api/people/216/?format=api",
        "name": "Barnabás Pőcze",
        "email": "barnabas.pocze@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/22959/mbox/",
    "series": [
        {
            "id": 5061,
            "url": "https://patchwork.libcamera.org/api/series/5061/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5061",
            "date": "2025-03-14T17:42:44",
            "name": "libcamera: pipeline: uvcvideo: Fix `ExposureTimeMode` control",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/5061/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22959/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22959/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 848FFC32F7\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Mar 2025 17:42:57 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D6BA66895A;\n\tFri, 14 Mar 2025 18:42:56 +0100 (CET)",
            "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 9BBF06894D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Mar 2025 18:42:52 +0100 (CET)",
            "from pb-laptop.local (185.221.143.221.nat.pool.zt.hu\n\t[185.221.143.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2DC66606\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Mar 2025 18:41:13 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"f3xLEkwe\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1741974073;\n\tbh=67/K44/eDRlEHwKTL+1GBN2Sg83yl7CLohkRF8CvJzA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=f3xLEkwe6k4LkGThQQJ1nAQJoXggm1kiNe43kRpG7PONa+xFFxxEMq2eHpmVpq80r\n\ty4htDFlnTyHrCTEWWQ2Ls96pCEmVopzLu8gcwcw1s2RQqsZ0g90BtQ3G7LoHaoAb52\n\tXrHO5QKj0I8Guw1cegNvHPGpZht22PZEqXtTkJqs=",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Subject": "[PATCH v3 4/4] libcamera: pipeline: uvcvideo: Fix `ExposureTime`\n\tcontrol handling",
        "Date": "Fri, 14 Mar 2025 18:42:48 +0100",
        "Message-ID": "<20250314174248.1015718-5-barnabas.pocze@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.48.1",
        "In-Reply-To": "<20250314174248.1015718-1-barnabas.pocze@ideasonboard.com>",
        "References": "<20250314174248.1015718-1-barnabas.pocze@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "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": "The documentation of `ExposureTime` states that its value is ignored if\n`ExposureTimeMode` is not manual. This is currently not handled, and if\n`ExposureTimeMode` is automatic and `ExposureTime` is set, then the\ncontrols will be rejected, as expected.\n\nOnly try to set `V4L2_CID_EXPOSURE_ABSOLUTE` if the current exposure mode\nis manual. To be able to handle requests that set both `ExposureTime{,Mode}`,\nprocess `ExposureTimeMode` first directly in `processControls()`, and store\nthis new mode in a temporary location. Then have `processControl()` act on\nthis temporary state, and only persist the temporary state if `setControls()`\non the video device succeeds.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=242\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 52 ++++++++++++--------\n 1 file changed, 31 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex 7d882ebe1..22d286e49 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -108,7 +108,7 @@ public:\n \tbool match(DeviceEnumerator *enumerator) override;\n \n private:\n-\tint processControl(const UVCCameraData *data, ControlList *controls,\n+\tint processControl(const UVCCameraData::State &state, ControlList *controls,\n \t\t\t   unsigned int id, const ControlValue &value);\n \tint processControls(UVCCameraData *data, Request *request);\n \n@@ -333,7 +333,7 @@ void PipelineHandlerUVC::stopDevice(Camera *camera)\n \tdata->state_.reset();\n }\n \n-int PipelineHandlerUVC::processControl(const UVCCameraData *data, ControlList *controls,\n+int PipelineHandlerUVC::processControl(const UVCCameraData::State &state, ControlList *controls,\n \t\t\t\t       unsigned int id, const ControlValue &value)\n {\n \tuint32_t cid;\n@@ -378,26 +378,13 @@ int PipelineHandlerUVC::processControl(const UVCCameraData *data, ControlList *c\n \t}\n \n \tcase V4L2_CID_EXPOSURE_AUTO: {\n-\t\tstd::optional<v4l2_exposure_auto_type> mode;\n-\n-\t\tswitch (value.get<int32_t>()) {\n-\t\tcase controls::ExposureTimeModeAuto:\n-\t\t\tmode = data->autoExposureMode_;\n-\t\t\tbreak;\n-\t\tcase controls::ExposureTimeModeManual:\n-\t\t\tmode = data->manualExposureMode_;\n-\t\t\tbreak;\n-\t\t}\n-\n-\t\tif (!mode)\n-\t\t\treturn -EINVAL;\n-\n-\t\tcontrols->set(V4L2_CID_EXPOSURE_AUTO, static_cast<int32_t>(*mode));\n+\t\t/* Handled directly in `processControls()`. */\n \t\tbreak;\n \t}\n \n \tcase V4L2_CID_EXPOSURE_ABSOLUTE:\n-\t\tcontrols->set(cid, value.get<int32_t>() / 100);\n+\t\tif (state.exp == controls::ExposureTimeModeManual)\n+\t\t\tcontrols->set(cid, value.get<int32_t>() / 100);\n \t\tbreak;\n \n \tcase V4L2_CID_CONTRAST:\n@@ -428,9 +415,30 @@ int PipelineHandlerUVC::processControl(const UVCCameraData *data, ControlList *c\n int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)\n {\n \tControlList controls(data->video_->controls());\n+\tconst auto &reqControls = request->controls();\n+\tauto newState = data->state_;\n+\n+\tif (const auto exp = reqControls.get(controls::ExposureTimeMode)) {\n+\t\tstd::optional<v4l2_exposure_auto_type> mode;\n \n-\tfor (const auto &[id, value] : request->controls())\n-\t\tprocessControl(data, &controls, id, value);\n+\t\tswitch (*exp) {\n+\t\tcase controls::ExposureTimeModeAuto:\n+\t\t\tmode = data->autoExposureMode_;\n+\t\t\tbreak;\n+\t\tcase controls::ExposureTimeModeManual:\n+\t\t\tmode = data->manualExposureMode_;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (!mode)\n+\t\t\treturn -EINVAL;\n+\n+\t\tcontrols.set(V4L2_CID_EXPOSURE_AUTO, static_cast<int32_t>(*mode));\n+\t\tnewState.exp = static_cast<controls::ExposureTimeModeEnum>(*exp);\n+\t}\n+\n+\tfor (const auto &[id, value] : reqControls)\n+\t\tprocessControl(newState, &controls, id, value);\n \n \tfor (const auto &ctrl : controls)\n \t\tLOG(UVC, Debug)\n@@ -443,7 +451,9 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)\n \t\treturn ret < 0 ? ret : -EINVAL;\n \t}\n \n-\treturn ret;\n+\tdata->state_ = newState;\n+\n+\treturn 0;\n }\n \n int PipelineHandlerUVC::queueRequestDevice(Camera *camera, Request *request)\n",
    "prefixes": [
        "v3",
        "4/4"
    ]
}