{"id":22902,"url":"https://patchwork.libcamera.org/api/1.1/patches/22902/?format=json","web_url":"https://patchwork.libcamera.org/patch/22902/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20250303134234.699293-2-barnabas.pocze@ideasonboard.com>","date":"2025-03-03T13:42:33","name":"[v3,1/2] libcamera: pipeline: uvcvideo: Fix `ExposureTimeMode` control setup","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"6e1f7899bdaeae082b7b04543141dacedb00d615","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/1.1/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22902/mbox/","series":[{"id":5031,"url":"https://patchwork.libcamera.org/api/1.1/series/5031/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5031","date":"2025-03-03T13:42:32","name":"libcamera: pipeline: uvcvideo: Fix `ExposureTimeMode` control","version":3,"mbox":"https://patchwork.libcamera.org/series/5031/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22902/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22902/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 9A8BAC3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Mar 2025 13:42:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7423D68823;\n\tMon,  3 Mar 2025 14:42:41 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C22D368777\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Mar 2025 14:42:38 +0100 (CET)","from pb-laptop.local (185.221.143.4.nat.pool.zt.hu [185.221.143.4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4B9AB8DB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Mar 2025 14:41:07 +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=\"JGwMN7RW\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1741009267;\n\tbh=yCkkRz99Dyyu3/Hsic6OpQXgGnpJb6tTK447ziHbVrY=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=JGwMN7RWKtCzOFe9X+9myt2iYVNlyKiy51FoF7t+WJ6G2hVlAoLINgP1B1klC4mJP\n\tXy6SmaC18/xswE4LkJ2MlZ+dstaXXKykSL0mnWg9vR4PO5jejTo9HlqMxPzPG9+dW+\n\tdqixPGy5BmrUYRSReUNtkXzogsorTBjUv0ydEo/0=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v3 1/2] libcamera: pipeline: uvcvideo: Fix `ExposureTimeMode`\n\tcontrol setup","Date":"Mon,  3 Mar 2025 14:42:33 +0100","Message-ID":"<20250303134234.699293-2-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.48.1","In-Reply-To":"<20250303134234.699293-1-barnabas.pocze@ideasonboard.com>","References":"<20250303134234.699293-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":"`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 set.\n\nTo fix this, convert the array to contain `ControlValue` objects and use\na separate variable to keep track of which element to set next.\n\nFor each of `ExposureTimeMode{Auto,Manual}` save the V4L2 control value\nthat is to be used when the libcamera control is set.\n\nFixes: bad8d591f8acfa (\"libcamera: uvcvideo: Register ExposureTimeMode control\")\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 61 ++++++++++++++------\n 1 file changed, 42 insertions(+), 19 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex 7470b5627..a6cc37366 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@@ -56,6 +57,9 @@ public:\n \tStream stream_;\n \tstd::map<PixelFormat, std::vector<SizeRange>> formats_;\n \n+\tstd::optional<v4l2_exposure_auto_type> autoExposureMode_;\n+\tstd::optional<v4l2_exposure_auto_type> manualExposureMode_;\n+\n private:\n \tbool generateId();\n \n@@ -723,25 +727,44 @@ 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+\n+\t\tstd::bitset<\n+\t\t\tstd::max(V4L2_EXPOSURE_AUTO,\n+\t\t\tstd::max(V4L2_EXPOSURE_APERTURE_PRIORITY,\n+\t\t\tstd::max(V4L2_EXPOSURE_MANUAL,\n+\t\t\t\t V4L2_EXPOSURE_SHUTTER_PRIORITY))) + 1\n+\t\t> exposureModes;\n+\n+\t\tfor (const ControlValue &value : v4l2Values) {\n+\t\t\tauto x = value.get<int32_t>();\n+\n+\t\t\tif (0 <= x && static_cast<std::size_t>(x) < exposureModes.size())\n+\t\t\t\texposureModes[x] = true;\n+\t\t}\n+\n+\t\tif (exposureModes[V4L2_EXPOSURE_AUTO])\n+\t\t\tautoExposureMode_ = V4L2_EXPOSURE_AUTO;\n+\t\telse if (exposureModes[V4L2_EXPOSURE_APERTURE_PRIORITY])\n+\t\t\tautoExposureMode_ = V4L2_EXPOSURE_APERTURE_PRIORITY;\n+\n+\t\tif (exposureModes[V4L2_EXPOSURE_MANUAL])\n+\t\t\tmanualExposureMode_ = V4L2_EXPOSURE_MANUAL;\n+\t\telse if (exposureModes[V4L2_EXPOSURE_SHUTTER_PRIORITY])\n+\t\t\tmanualExposureMode_ = V4L2_EXPOSURE_SHUTTER_PRIORITY;\n+\n+\t\tstd::array<ControlValue, 2> values;\n+\t\tstd::size_t count = 0;\n+\n+\t\tif (autoExposureMode_)\n+\t\t\tvalues[count++] = controls::ExposureTimeModeAuto;\n+\n+\t\tif (manualExposureMode_)\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":["v3","1/2"]}