From patchwork Mon Mar 3 19:33:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 22917 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 620A0BD808 for ; Mon, 3 Mar 2025 19:33:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 28B1668889; Mon, 3 Mar 2025 20:33:56 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="f3CnClkW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EADC268889 for ; Mon, 3 Mar 2025 20:33:52 +0100 (CET) Received: from pb-laptop.local (185.221.143.4.nat.pool.zt.hu [185.221.143.4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 623CC346 for ; Mon, 3 Mar 2025 20:32:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1741030341; bh=9YEIq0YLC32UWjETs+EpYGOKJeLs4WQNomeAioYqovw=; h=From:To:Subject:Date:From; b=f3CnClkWnDqYO+ZnJh91JZhvdOKsxPrtdrVzoRmH5bgEtPnV8IaxTy8Fwm9aoPfTf A/dY0ViB/fEuMjOUQ/YQOJAI5whhBR2rTDs/mgFgbBsOVef/6W7A89cdh1HplcE+Tg 853LTy8xpdhqxNNkbyiCFBhbs2tKtb4WfAq1GWQM= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= 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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Do not force the caller to construct a vector. Signed-off-by: Barnabás Pőcze --- include/libcamera/internal/camera_sensor.h | 3 ++- include/libcamera/internal/v4l2_device.h | 2 +- src/libcamera/sensor/camera_sensor_legacy.cpp | 14 +++++++++----- src/libcamera/sensor/camera_sensor_raw.cpp | 14 +++++++++----- src/libcamera/v4l2_device.cpp | 2 +- test/v4l2_videodevice/controls.cpp | 14 +++++++++----- 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 13048f327..59a1604c5 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -74,7 +75,7 @@ public: virtual BayerFormat::Order bayerOrder(Transform t) const = 0; virtual const ControlInfoMap &controls() const = 0; - virtual ControlList getControls(const std::vector &ids) = 0; + virtual ControlList getControls(Span ids) = 0; virtual int setControls(ControlList *ctrls) = 0; virtual const std::vector & diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index affe52c2a..4ab818d90 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -37,7 +37,7 @@ public: const ControlInfoMap &controls() const { return controls_; } - ControlList getControls(const std::vector &ids); + ControlList getControls(Span ids); int setControls(ControlList *ctrls); const struct v4l2_query_ext_ctrl *controlInfo(uint32_t id) const; diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index 32989c19c..1eccca519 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -90,7 +90,7 @@ public: BayerFormat::Order bayerOrder(Transform t) const override; const ControlInfoMap &controls() const override; - ControlList getControls(const std::vector &ids) override; + ControlList getControls(Span ids) override; int setControls(ControlList *ctrls) override; const std::vector & @@ -907,9 +907,13 @@ int CameraSensorLegacy::sensorInfo(IPACameraSensorInfo *info) const * duration through V4L2 controls. Support for the V4L2_CID_PIXEL_RATE, * V4L2_CID_HBLANK and V4L2_CID_VBLANK controls is mandatory. */ - ControlList ctrls = subdev_->getControls({ V4L2_CID_PIXEL_RATE, - V4L2_CID_HBLANK, - V4L2_CID_VBLANK }); + static constexpr uint32_t cids[] = { + V4L2_CID_PIXEL_RATE, + V4L2_CID_HBLANK, + V4L2_CID_VBLANK, + }; + + ControlList ctrls = subdev_->getControls(cids); if (ctrls.empty()) { LOG(CameraSensor, Error) << "Failed to retrieve camera info controls"; @@ -983,7 +987,7 @@ const ControlInfoMap &CameraSensorLegacy::controls() const return subdev_->controls(); } -ControlList CameraSensorLegacy::getControls(const std::vector &ids) +ControlList CameraSensorLegacy::getControls(Span ids) { return subdev_->getControls(ids); } diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index ab75b1f82..c65ecbb86 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -96,7 +96,7 @@ public: BayerFormat::Order bayerOrder(Transform t) const override; const ControlInfoMap &controls() const override; - ControlList getControls(const std::vector &ids) override; + ControlList getControls(Span ids) override; int setControls(ControlList *ctrls) override; const std::vector & @@ -1022,9 +1022,13 @@ int CameraSensorRaw::sensorInfo(IPACameraSensorInfo *info) const * duration through V4L2 controls. Support for the V4L2_CID_PIXEL_RATE, * V4L2_CID_HBLANK and V4L2_CID_VBLANK controls is mandatory. */ - ControlList ctrls = subdev_->getControls({ V4L2_CID_PIXEL_RATE, - V4L2_CID_HBLANK, - V4L2_CID_VBLANK }); + static constexpr uint32_t cids[] = { + V4L2_CID_PIXEL_RATE, + V4L2_CID_HBLANK, + V4L2_CID_VBLANK, + }; + + ControlList ctrls = subdev_->getControls(cids); if (ctrls.empty()) { LOG(CameraSensor, Error) << "Failed to retrieve camera info controls"; @@ -1095,7 +1099,7 @@ const ControlInfoMap &CameraSensorRaw::controls() const return subdev_->controls(); } -ControlList CameraSensorRaw::getControls(const std::vector &ids) +ControlList CameraSensorRaw::getControls(Span ids) { return subdev_->getControls(ids); } diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 2f65a43a0..089f45afd 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -174,7 +174,7 @@ void V4L2Device::close() * \return The control values in a ControlList on success, or an empty list on * error */ -ControlList V4L2Device::getControls(const std::vector &ids) +ControlList V4L2Device::getControls(Span ids) { if (ids.empty()) return {}; diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp index b0130295e..7990f37dc 100644 --- a/test/v4l2_videodevice/controls.cpp +++ b/test/v4l2_videodevice/controls.cpp @@ -60,11 +60,15 @@ protected: const ControlInfo &u8 = infoMap.find(VIVID_CID_U8_4D_ARRAY)->second; /* Test getting controls. */ - ControlList ctrls = capture_->getControls({ V4L2_CID_BRIGHTNESS, - V4L2_CID_CONTRAST, - V4L2_CID_SATURATION, - VIVID_CID_INTEGER64, - VIVID_CID_U8_4D_ARRAY }); + static constexpr uint32_t cids[] = { + V4L2_CID_BRIGHTNESS, + V4L2_CID_CONTRAST, + V4L2_CID_SATURATION, + VIVID_CID_INTEGER64, + VIVID_CID_U8_4D_ARRAY, + }; + + ControlList ctrls = capture_->getControls(cids); if (ctrls.empty()) { cerr << "Failed to get controls" << endl; return TestFail;