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; From patchwork Mon Mar 3 19:33:49 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: 22918 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 67B6BC3263 for ; Mon, 3 Mar 2025 19:33:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C92EB68895; 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="AklhdbUR"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F52D68891 for ; Mon, 3 Mar 2025 20:33:53 +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 A06F911E9 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=7n0YDvf+2+SJjizV45sha3UemDNZ8dcscR5BeWaU4G8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AklhdbURNYJuvbeUu6Yz0M02UGWjh4EiO8Mgd0oTMyT08Pp/M5l/eiTCFGzvp+EjN OuO7+2uMBMhMW2xZhR19GQzBb96+F75/3icoc8f0suuU5blovKut5Lb/eFqGepMwhP kN5+FYuehx6+xvzRy3dqaVK9GE7OS8ALUfHJCJ/g= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 2/2] libcamera: camera_sensor: getFormat(): Use span Date: Mon, 3 Mar 2025 20:33:49 +0100 Message-ID: <20250303193349.785692-2-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250303193349.785692-1-barnabas.pocze@ideasonboard.com> References: <20250303193349.785692-1-barnabas.pocze@ideasonboard.com> 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 | 2 +- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 4 ++-- src/libcamera/sensor/camera_sensor_legacy.cpp | 4 ++-- src/libcamera/sensor/camera_sensor_raw.cpp | 4 ++-- test/camera-sensor.cpp | 11 +++++++---- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 59a1604c5..f6ef4df17 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -54,7 +54,7 @@ public: virtual Size resolution() const = 0; virtual V4L2SubdeviceFormat - getFormat(const std::vector &mbusCodes, + getFormat(Span mbusCodes, const Size &size, const Size maxSize = Size()) const = 0; virtual int setFormat(V4L2SubdeviceFormat *format, Transform transform = Transform::Identity) = 0; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index eee5b09e2..ba702b454 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -339,7 +339,7 @@ RkISP1Path::validate(const CameraSensor *sensor, : cfg->size; V4L2SubdeviceFormat sensorFormat = - sensor->getFormat({ mbusCode }, rawSize); + sensor->getFormat(std::array{ mbusCode }, rawSize); if (sensorConfig && sensorConfig->outputSize != sensorFormat.size) @@ -360,7 +360,7 @@ RkISP1Path::validate(const CameraSensor *sensor, uint32_t mbusCode = formatToMediaBus.at(rawFormat); V4L2SubdeviceFormat sensorFormat = - sensor->getFormat({ mbusCode }, sensorSize); + sensor->getFormat(std::array{ mbusCode }, sensorSize); if (sensorFormat.size != sensorSize) return CameraConfiguration::Invalid; diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp index 1eccca519..1b9b5c9a0 100644 --- a/src/libcamera/sensor/camera_sensor_legacy.cpp +++ b/src/libcamera/sensor/camera_sensor_legacy.cpp @@ -73,7 +73,7 @@ public: std::vector sizes(unsigned int mbusCode) const override; Size resolution() const override; - V4L2SubdeviceFormat getFormat(const std::vector &mbusCodes, + V4L2SubdeviceFormat getFormat(Span mbusCodes, const Size &size, const Size maxSize) const override; int setFormat(V4L2SubdeviceFormat *format, @@ -699,7 +699,7 @@ Size CameraSensorLegacy::resolution() const } V4L2SubdeviceFormat -CameraSensorLegacy::getFormat(const std::vector &mbusCodes, +CameraSensorLegacy::getFormat(Span mbusCodes, const Size &size, Size maxSize) const { unsigned int desiredArea = size.width * size.height; diff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp index c65ecbb86..7ac0f563d 100644 --- a/src/libcamera/sensor/camera_sensor_raw.cpp +++ b/src/libcamera/sensor/camera_sensor_raw.cpp @@ -74,7 +74,7 @@ public: std::vector sizes(unsigned int mbusCode) const override; Size resolution() const override; - V4L2SubdeviceFormat getFormat(const std::vector &mbusCodes, + V4L2SubdeviceFormat getFormat(Span mbusCodes, const Size &size, const Size maxSize) const override; int setFormat(V4L2SubdeviceFormat *format, @@ -757,7 +757,7 @@ Size CameraSensorRaw::resolution() const } V4L2SubdeviceFormat -CameraSensorRaw::getFormat(const std::vector &mbusCodes, +CameraSensorRaw::getFormat(Span mbusCodes, const Size &size, Size maxSize) const { unsigned int desiredArea = size.width * size.height; diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp index 869c78896..c30a2212e 100644 --- a/test/camera-sensor.cpp +++ b/test/camera-sensor.cpp @@ -96,10 +96,13 @@ protected: } /* Use an invalid format and make sure it's not selected. */ - V4L2SubdeviceFormat format = sensor_->getFormat({ 0xdeadbeef, - MEDIA_BUS_FMT_SBGGR10_1X10, - MEDIA_BUS_FMT_BGR888_1X24 }, - Size(1024, 768)); + static constexpr uint32_t mbusCodes[] = { + 0xdeadbeef, + MEDIA_BUS_FMT_SBGGR10_1X10, + MEDIA_BUS_FMT_BGR888_1X24, + }; + + V4L2SubdeviceFormat format = sensor_->getFormat(mbusCodes, Size(1024, 768)); if (format.code != MEDIA_BUS_FMT_SBGGR10_1X10 || format.size != Size(4096, 2160)) { cerr << "Failed to get a suitable format, expected 4096x2160-0x"