Patch Detail
Show a patch.
GET /api/patches/22917/?format=api
{ "id": 22917, "url": "https://patchwork.libcamera.org/api/patches/22917/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22917/", "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": "<20250303193349.785692-1-barnabas.pocze@ideasonboard.com>", "date": "2025-03-03T19:33:48", "name": "[v1,1/2] libcamera: camera_sensor: getControls(): Use span", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "9f721ca0bd0868bdf9c93b99ae698171779546db", "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/22917/mbox/", "series": [ { "id": 5042, "url": "https://patchwork.libcamera.org/api/series/5042/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5042", "date": "2025-03-03T19:33:48", "name": "[v1,1/2] libcamera: camera_sensor: getControls(): Use span", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5042/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22917/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22917/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 620A0BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 3 Mar 2025 19:33:56 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 28B1668889;\n\tMon, 3 Mar 2025 20:33:56 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EADC268889\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 3 Mar 2025 20:33:52 +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 623CC346\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 3 Mar 2025 20:32:21 +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=\"f3CnClkW\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1741030341;\n\tbh=9YEIq0YLC32UWjETs+EpYGOKJeLs4WQNomeAioYqovw=;\n\th=From:To:Subject:Date:From;\n\tb=f3CnClkWnDqYO+ZnJh91JZhvdOKsxPrtdrVzoRmH5bgEtPnV8IaxTy8Fwm9aoPfTf\n\tA/dY0ViB/fEuMjOUQ/YQOJAI5whhBR2rTDs/mgFgbBsOVef/6W7A89cdh1HplcE+Tg\n\t853LTy8xpdhqxNNkbyiCFBhbs2tKtb4WfAq1GWQM=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v1 1/2] libcamera: camera_sensor: getControls(): Use span", "Date": "Mon, 3 Mar 2025 20:33:48 +0100", "Message-ID": "<20250303193349.785692-1-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.48.1", "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": "Do not force the caller to construct a vector.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n include/libcamera/internal/camera_sensor.h | 3 ++-\n include/libcamera/internal/v4l2_device.h | 2 +-\n src/libcamera/sensor/camera_sensor_legacy.cpp | 14 +++++++++-----\n src/libcamera/sensor/camera_sensor_raw.cpp | 14 +++++++++-----\n src/libcamera/v4l2_device.cpp | 2 +-\n test/v4l2_videodevice/controls.cpp | 14 +++++++++-----\n 6 files changed, 31 insertions(+), 18 deletions(-)", "diff": "diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex 13048f327..59a1604c5 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -14,6 +14,7 @@\n #include <vector>\n \n #include <libcamera/base/class.h>\n+#include <libcamera/base/span.h>\n \n #include <libcamera/control_ids.h>\n #include <libcamera/controls.h>\n@@ -74,7 +75,7 @@ public:\n \tvirtual BayerFormat::Order bayerOrder(Transform t) const = 0;\n \n \tvirtual const ControlInfoMap &controls() const = 0;\n-\tvirtual ControlList getControls(const std::vector<uint32_t> &ids) = 0;\n+\tvirtual ControlList getControls(Span<const uint32_t> ids) = 0;\n \tvirtual int setControls(ControlList *ctrls) = 0;\n \n \tvirtual const std::vector<controls::draft::TestPatternModeEnum> &\ndiff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h\nindex affe52c2a..4ab818d90 100644\n--- a/include/libcamera/internal/v4l2_device.h\n+++ b/include/libcamera/internal/v4l2_device.h\n@@ -37,7 +37,7 @@ public:\n \n \tconst ControlInfoMap &controls() const { return controls_; }\n \n-\tControlList getControls(const std::vector<uint32_t> &ids);\n+\tControlList getControls(Span<const uint32_t> ids);\n \tint setControls(ControlList *ctrls);\n \n \tconst struct v4l2_query_ext_ctrl *controlInfo(uint32_t id) const;\ndiff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp\nindex 32989c19c..1eccca519 100644\n--- a/src/libcamera/sensor/camera_sensor_legacy.cpp\n+++ b/src/libcamera/sensor/camera_sensor_legacy.cpp\n@@ -90,7 +90,7 @@ public:\n \tBayerFormat::Order bayerOrder(Transform t) const override;\n \n \tconst ControlInfoMap &controls() const override;\n-\tControlList getControls(const std::vector<uint32_t> &ids) override;\n+\tControlList getControls(Span<const uint32_t> ids) override;\n \tint setControls(ControlList *ctrls) override;\n \n \tconst std::vector<controls::draft::TestPatternModeEnum> &\n@@ -907,9 +907,13 @@ int CameraSensorLegacy::sensorInfo(IPACameraSensorInfo *info) const\n \t * duration through V4L2 controls. Support for the V4L2_CID_PIXEL_RATE,\n \t * V4L2_CID_HBLANK and V4L2_CID_VBLANK controls is mandatory.\n \t */\n-\tControlList ctrls = subdev_->getControls({ V4L2_CID_PIXEL_RATE,\n-\t\t\t\t\t\t V4L2_CID_HBLANK,\n-\t\t\t\t\t\t V4L2_CID_VBLANK });\n+\tstatic constexpr uint32_t cids[] = {\n+\t\tV4L2_CID_PIXEL_RATE,\n+\t\tV4L2_CID_HBLANK,\n+\t\tV4L2_CID_VBLANK,\n+\t};\n+\n+\tControlList ctrls = subdev_->getControls(cids);\n \tif (ctrls.empty()) {\n \t\tLOG(CameraSensor, Error)\n \t\t\t<< \"Failed to retrieve camera info controls\";\n@@ -983,7 +987,7 @@ const ControlInfoMap &CameraSensorLegacy::controls() const\n \treturn subdev_->controls();\n }\n \n-ControlList CameraSensorLegacy::getControls(const std::vector<uint32_t> &ids)\n+ControlList CameraSensorLegacy::getControls(Span<const uint32_t> ids)\n {\n \treturn subdev_->getControls(ids);\n }\ndiff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp\nindex ab75b1f82..c65ecbb86 100644\n--- a/src/libcamera/sensor/camera_sensor_raw.cpp\n+++ b/src/libcamera/sensor/camera_sensor_raw.cpp\n@@ -96,7 +96,7 @@ public:\n \tBayerFormat::Order bayerOrder(Transform t) const override;\n \n \tconst ControlInfoMap &controls() const override;\n-\tControlList getControls(const std::vector<uint32_t> &ids) override;\n+\tControlList getControls(Span<const uint32_t> ids) override;\n \tint setControls(ControlList *ctrls) override;\n \n \tconst std::vector<controls::draft::TestPatternModeEnum> &\n@@ -1022,9 +1022,13 @@ int CameraSensorRaw::sensorInfo(IPACameraSensorInfo *info) const\n \t * duration through V4L2 controls. Support for the V4L2_CID_PIXEL_RATE,\n \t * V4L2_CID_HBLANK and V4L2_CID_VBLANK controls is mandatory.\n \t */\n-\tControlList ctrls = subdev_->getControls({ V4L2_CID_PIXEL_RATE,\n-\t\t\t\t\t\t V4L2_CID_HBLANK,\n-\t\t\t\t\t\t V4L2_CID_VBLANK });\n+\tstatic constexpr uint32_t cids[] = {\n+\t\tV4L2_CID_PIXEL_RATE,\n+\t\tV4L2_CID_HBLANK,\n+\t\tV4L2_CID_VBLANK,\n+\t};\n+\n+\tControlList ctrls = subdev_->getControls(cids);\n \tif (ctrls.empty()) {\n \t\tLOG(CameraSensor, Error)\n \t\t\t<< \"Failed to retrieve camera info controls\";\n@@ -1095,7 +1099,7 @@ const ControlInfoMap &CameraSensorRaw::controls() const\n \treturn subdev_->controls();\n }\n \n-ControlList CameraSensorRaw::getControls(const std::vector<uint32_t> &ids)\n+ControlList CameraSensorRaw::getControls(Span<const uint32_t> ids)\n {\n \treturn subdev_->getControls(ids);\n }\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 2f65a43a0..089f45afd 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -174,7 +174,7 @@ void V4L2Device::close()\n * \\return The control values in a ControlList on success, or an empty list on\n * error\n */\n-ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)\n+ControlList V4L2Device::getControls(Span<const uint32_t> ids)\n {\n \tif (ids.empty())\n \t\treturn {};\ndiff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp\nindex b0130295e..7990f37dc 100644\n--- a/test/v4l2_videodevice/controls.cpp\n+++ b/test/v4l2_videodevice/controls.cpp\n@@ -60,11 +60,15 @@ protected:\n \t\tconst ControlInfo &u8 = infoMap.find(VIVID_CID_U8_4D_ARRAY)->second;\n \n \t\t/* Test getting controls. */\n-\t\tControlList ctrls = capture_->getControls({ V4L2_CID_BRIGHTNESS,\n-\t\t\t\t\t\t\t V4L2_CID_CONTRAST,\n-\t\t\t\t\t\t\t V4L2_CID_SATURATION,\n-\t\t\t\t\t\t\t VIVID_CID_INTEGER64,\n-\t\t\t\t\t\t\t VIVID_CID_U8_4D_ARRAY });\n+\t\tstatic constexpr uint32_t cids[] = {\n+\t\t\tV4L2_CID_BRIGHTNESS,\n+\t\t\tV4L2_CID_CONTRAST,\n+\t\t\tV4L2_CID_SATURATION,\n+\t\t\tVIVID_CID_INTEGER64,\n+\t\t\tVIVID_CID_U8_4D_ARRAY,\n+\t\t};\n+\n+\t\tControlList ctrls = capture_->getControls(cids);\n \t\tif (ctrls.empty()) {\n \t\t\tcerr << \"Failed to get controls\" << endl;\n \t\t\treturn TestFail;\n", "prefixes": [ "v1", "1/2" ] }