{"id":22799,"url":"https://patchwork.libcamera.org/api/patches/22799/?format=json","web_url":"https://patchwork.libcamera.org/patch/22799/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","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-3-pobrn@protonmail.com>","date":"2025-02-17T18:53:39","name":"[v2,2/2] libcamera: pipeline: uvcvideo: Fix `ExposureTimeMode` control setting","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"5b65d938a0a33fa9c3603a6a4ad7edbf59eb0c10","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/people/133/?format=json","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22799/mbox/","series":[{"id":5006,"url":"https://patchwork.libcamera.org/api/series/5006/?format=json","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/22799/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22799/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 09CE3C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Feb 2025 18:53:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B348768688;\n\tMon, 17 Feb 2025 19:53:45 +0100 (CET)","from mail-4316.protonmail.ch (mail-4316.protonmail.ch\n\t[185.70.43.16])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6FD3361865\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Feb 2025 19:53:43 +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=\"QQYezlda\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1739818422; x=1740077622;\n\tbh=zHoIEDaDOGUvDYe/IV0z5ARBxOdRvW4cNCYionKzpz0=;\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=QQYezldaNwOGw996QkWJ9qBV7DRAUv4Bz4J+k5DS7Rf6WJpA1HqgSm3aiL17u13U6\n\t1jWYqi+agm9Nmx/QQ6r3n1GMZ8hpob8n3hyOls/7rtoh7/51cZw9vs3d1TUO4JoY2P\n\tU5Df4zim/R4qhC69OhpIonSLQaRVAmOZ10K3+xf8w5pLWIYWHV7OKhcnKnVPFfd93V\n\tPQg1RxCLtoXKuhAhRHEZbY7qlGr39F7t53gOophHo8qxp5NkTRwR//Imdd9vCPXAbr\n\tMl93v9kkAw5ZbVaEDfpUx5QPVtLtjguR3ymqfOqbl4gzY2NI1vlfA5wXgQHesKieGg\n\tjQmsnN2p/bKEg==","Date":"Mon, 17 Feb 2025 18:53:39 +0000","To":"libcamera-devel@lists.libcamera.org","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Subject":"[PATCH v2 2/2] libcamera: pipeline: uvcvideo: Fix `ExposureTimeMode`\n\tcontrol setting","Message-ID":"<20250217185327.306509-3-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":"e0315efea8086eee23569feb191d46dd17cf465b","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":"The mapping in `UVCCameraData::processControl()` is not entirely correct\nbecause the control value is retrieved as a `bool` instead of `int32_t`.\nAdditionally, the available modes are not taken into account.\n\nTo fix this, retrieve the control with the proper type - `int32_t` -,\nand use the available modes stored in `UVCCameraData` to determine\nwhich value to use for the V4L2 control.\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 | 38 +++++++++++++++-----\n 1 file changed, 29 insertions(+), 9 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex 1f604b91e..adab6aa18 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -103,8 +103,8 @@ public:\n \tbool match(DeviceEnumerator *enumerator) override;\n \n private:\n-\tint processControl(ControlList *controls, unsigned int id,\n-\t\t\t   const ControlValue &value);\n+\tint processControl(UVCCameraData *data, ControlList *controls,\n+\t\t\t   unsigned int id, const ControlValue &value);\n \tint processControls(UVCCameraData *data, Request *request);\n \n \tbool acquireDevice(Camera *camera) override;\n@@ -297,8 +297,8 @@ void PipelineHandlerUVC::stopDevice(Camera *camera)\n \tdata->video_->releaseBuffers();\n }\n \n-int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id,\n-\t\t\t\t       const ControlValue &value)\n+int PipelineHandlerUVC::processControl(UVCCameraData *data, ControlList *controls,\n+\t\t\t\t       unsigned int id, const ControlValue &value)\n {\n \tuint32_t cid;\n \n@@ -342,10 +342,30 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id,\n \t}\n \n \tcase V4L2_CID_EXPOSURE_AUTO: {\n-\t\tint32_t ivalue = value.get<bool>()\n-\t\t\t       ? V4L2_EXPOSURE_APERTURE_PRIORITY\n-\t\t\t       : V4L2_EXPOSURE_MANUAL;\n-\t\tcontrols->set(V4L2_CID_EXPOSURE_AUTO, ivalue);\n+\t\tv4l2_exposure_auto_type exposureMode = {};\n+\n+\t\tswitch (value.get<int32_t>()) {\n+\t\tcase controls::ExposureTimeModeAuto:\n+\t\t\tif (data->availableExposureModes_[V4L2_EXPOSURE_AUTO])\n+\t\t\t\texposureMode = V4L2_EXPOSURE_AUTO;\n+\t\t\telse if (data->availableExposureModes_[V4L2_EXPOSURE_APERTURE_PRIORITY])\n+\t\t\t\texposureMode = V4L2_EXPOSURE_APERTURE_PRIORITY;\n+\t\t\telse\n+\t\t\t\tASSERT(false);\n+\t\t\tbreak;\n+\t\tcase controls::ExposureTimeModeManual:\n+\t\t\tif (data->availableExposureModes_[V4L2_EXPOSURE_MANUAL])\n+\t\t\t\texposureMode = V4L2_EXPOSURE_MANUAL;\n+\t\t\telse if (data->availableExposureModes_[V4L2_EXPOSURE_SHUTTER_PRIORITY])\n+\t\t\t\texposureMode = V4L2_EXPOSURE_SHUTTER_PRIORITY;\n+\t\t\telse\n+\t\t\t\tASSERT(false);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tcontrols->set(V4L2_CID_EXPOSURE_AUTO, exposureMode);\n \t\tbreak;\n \t}\n \n@@ -383,7 +403,7 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)\n \tControlList controls(data->video_->controls());\n \n \tfor (const auto &[id, value] : request->controls())\n-\t\tprocessControl(&controls, id, value);\n+\t\tprocessControl(data, &controls, id, value);\n \n \tfor (const auto &ctrl : controls)\n \t\tLOG(UVC, Debug)\n","prefixes":["v2","2/2"]}