From patchwork Thu Sep 3 09:18:39 2026 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: 28179 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 971B7C3348 for ; Thu, 3 Sep 2026 09:18:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4E63C685EB; Thu, 3 Sep 2026 11:18:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="u7j/TdwD"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A9FA8685D5 for ; Thu, 3 Sep 2026 11:18:47 +0200 (CEST) Received: from pb-laptop.local (185.221.143.32.nat.pool.zt.hu [185.221.143.32]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 42C8C20EA; Thu, 3 Sep 2026 11:17:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788427035; bh=0aPdCzPliFY+ogeG9xpvgdBmhI3cZT6mO26528Nr5Yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u7j/TdwDzRuiai+V/IiTtsFDmKykJfVj7UsMJh8Utc8o5KFUc/Ibm5kaZWFNrk24A qwazdtYG4+5TgymQtoB6N6u/Sql5yIOVLjc6f2Gy317luc/26d2WjFhHma72dlfTuQ wiW94Hsae73ph0Ox2KNymBqiCdDSM3wklcmw4Xkc= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Jacopo Mondi , Laurent Pinchart Subject: [PATCH v3 1/5] libcamera: controls: Give name to the union containing storage Date: Thu, 3 Sep 2026 11:18:39 +0200 Message-ID: <20260903091843.85548-2-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260903091843.85548-1-barnabas.pocze@ideasonboard.com> References: <20260903091843.85548-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" In order to be able to copy the storage as one unit, regardless of which member is active give a name to the union member. Also rename the union member to internal/external to clarify which is used for in-place/dynamically allocated storage. And finally drop some unnecessary `reinterpret_cast`s. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/controls.h | 6 +++--- src/libcamera/controls.cpp | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 4485c228d3..da73e41848 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -246,9 +246,9 @@ private: bool isArray_; std::size_t numElements_ : 32; union { - uint64_t value_; - void *storage_; - }; + uint64_t internal; + void *external; + } storage_; void release(); void set(ControlType type, bool isArray, const void *data, diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index f5581dbb88..e9d4e7eb47 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -122,9 +122,9 @@ void ControlValue::release() { std::size_t size = numElements_ * ControlValueSize[type_]; - if (size > sizeof(value_)) { - delete[] reinterpret_cast(storage_); - storage_ = nullptr; + if (size > sizeof(storage_.internal)) { + delete[] reinterpret_cast(storage_.external); + storage_.external = nullptr; } } @@ -192,9 +192,9 @@ ControlValue &ControlValue::operator=(const ControlValue &other) std::span ControlValue::data() const { std::size_t size = numElements_ * ControlValueSize[type_]; - const uint8_t *data = size > sizeof(value_) - ? reinterpret_cast(storage_) - : reinterpret_cast(&value_); + const uint8_t *data = size > sizeof(storage_.internal) + ? reinterpret_cast(storage_.external) + : reinterpret_cast(&storage_.internal); return { data, size }; } @@ -391,8 +391,8 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen if (oldSize == newSize) return; - if (newSize > sizeof(value_)) - storage_ = reinterpret_cast(new uint8_t[newSize]); + if (newSize > sizeof(storage_.internal)) + storage_.external = new uint8_t[newSize]; } /** From patchwork Thu Sep 3 09:18:40 2026 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: 28181 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 3812EC3349 for ; Thu, 3 Sep 2026 09:18:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 63F42685E6; Thu, 3 Sep 2026 11:18:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PDcrAGYv"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F14D0685D8 for ; Thu, 3 Sep 2026 11:18:47 +0200 (CEST) Received: from pb-laptop.local (185.221.143.32.nat.pool.zt.hu [185.221.143.32]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9266A2335 for ; Thu, 3 Sep 2026 11:17:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788427035; bh=c+4Dnv2JVO/1259DeVJ9EuVZ6GzrAuIFkY961PdA2nc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PDcrAGYvOkheCTZhu7RbEjBqD29odoigbJsa3rYIF3RIIF8TRoSoAvOp9iEPKNIIE SeXFuYjAeCBdCOgosQZg/6ZrYThrQ2HkxvUvRd65Eh2t3UBl+q3i3bh/kt31WQxSbu eh9cKTUlFg7M5UiUOfjWj2Dexo6rgPPV1AGVWMio= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v3 2/5] libcamera: controls: Remove bit fields Date: Thu, 3 Sep 2026 11:18:40 +0200 Message-ID: <20260903091843.85548-3-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260903091843.85548-1-barnabas.pocze@ideasonboard.com> References: <20260903091843.85548-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" Bit fields are inconvenient to use with references, e.g. `std::swap()`, so remove them from the `Control` type as a preparation. `size_t : 32` is replaced with just `uint32_t`, and `ControlType`'s underlying type is forced to be `uint8_t` so that bit field can also be removed. Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/controls.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index da73e41848..e4d5d13a2c 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -26,7 +26,7 @@ namespace libcamera { class ControlValidator; -enum ControlType { +enum ControlType : uint8_t { ControlTypeNone, ControlTypeBool, ControlTypeByte, @@ -242,9 +242,9 @@ public: std::size_t numElements = 1); private: - ControlType type_ : 8; + ControlType type_; bool isArray_; - std::size_t numElements_ : 32; + uint32_t numElements_; union { uint64_t internal; void *external; From patchwork Thu Sep 3 09:18:41 2026 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: 28182 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 5DCA2C334A for ; Thu, 3 Sep 2026 09:18:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2063E685D8; Thu, 3 Sep 2026 11:18:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Y/g3TYzp"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F1377685D7 for ; Thu, 3 Sep 2026 11:18:47 +0200 (CEST) Received: from pb-laptop.local (185.221.143.32.nat.pool.zt.hu [185.221.143.32]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CB472233B; Thu, 3 Sep 2026 11:17:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788427036; bh=5E4PqNZs5SlUYdqcDT1B5Kk7GujaqPPo61Waw0gPMU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y/g3TYzpNvvY66wICqlwaI7XMJeKsGrMN58VSM72DO7BqA/1IrBY5Ngb5OXe3G6YS RsGN1LYmT9icGPb89Q+VsRfVTvkzKqS/5KDoL/SIr+klqkyxG8wE+7RcGCp5rYf3OK zju7EYebKulsoqxYmt67AR98F9AJPiKxo0cHHcRg= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Jacopo Mondi , Laurent Pinchart Subject: [PATCH v3 3/5] libcamera: controls: Implement move ctor/assignment Date: Thu, 3 Sep 2026 11:18:41 +0200 Message-ID: <20260903091843.85548-4-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260903091843.85548-1-barnabas.pocze@ideasonboard.com> References: <20260903091843.85548-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" Implement a move constructor and move assignment operator for `ControlValue`. The `ControlValue` type already has an "empty" state that is used when creating a default constructed `ControlValue`, so have the moved-from instance return to that state after move construction/assignment. This is useful, for example, for `std::vector` as most implementations will use the copy constructor when reallocating if no nothrow move constructor is available. Having a nothrow move constructor avoids the extra copies. It is also useful when using temporaries of `ControlValue` with other containers such as `std::optional`, and it also makes `ControlInfo` "cheaply" move constructible/assignable. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/controls.h | 23 +++++++++++++++++++++++ src/libcamera/controls.cpp | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index e4d5d13a2c..aef17abe07 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -173,6 +174,28 @@ public: ControlValue(const ControlValue &other); ControlValue &operator=(const ControlValue &other); + ControlValue(ControlValue &&other) noexcept + : type_(std::exchange(other.type_, ControlTypeNone)), + isArray_(std::exchange(other.isArray_, false)), + numElements_(std::exchange(other.numElements_, 0)), + storage_(std::exchange(other.storage_, {})) + { + } + + ControlValue &operator=(ControlValue &&other) noexcept + { + if (this != &other) { + release(); + + type_ = std::exchange(other.type_, ControlTypeNone); + isArray_ = std::exchange(other.isArray_, false); + numElements_ = std::exchange(other.numElements_, 0); + storage_ = std::exchange(other.storage_, {}); + } + + return *this; + } + ControlType type() const { return type_; } bool isNone() const { return type_ == ControlTypeNone; } bool isArray() const { return isArray_; } diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index e9d4e7eb47..588b609373 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -156,6 +156,24 @@ ControlValue &ControlValue::operator=(const ControlValue &other) return *this; } +/** + * \fn ControlValue::ControlValue(ControlValue &&other) noexcept + * \brief Move constructor for ControlValue + * \param[in] other The ControlValue object to move from + * + * Move constructs a ControlValue instance from \a other. + * After this operation \a other will be in the same state + * as a default constructed ControlValue instance. + */ + +/** + * \fn ControlValue &ControlValue::operator=(ControlValue &&other) noexcept + * \brief Move assignment operator for ControlValue + * \param[in] other The ControlValue object to move from + * + * \sa ControlValue::ControlValue(ControlValue &&other) + */ + /** * \fn ControlValue::type() * \brief Retrieve the data type of the value From patchwork Thu Sep 3 09:18:42 2026 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: 28183 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 E6AFFC3348 for ; Thu, 3 Sep 2026 09:18:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A8EC8685F0; Thu, 3 Sep 2026 11:18:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BFM7NYhn"; 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 4500D685DA for ; Thu, 3 Sep 2026 11:18:48 +0200 (CEST) Received: from pb-laptop.local (185.221.143.32.nat.pool.zt.hu [185.221.143.32]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2708823B9; Thu, 3 Sep 2026 11:17:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788427036; bh=ZLXAjLas2jfyeVmN5XjyZbjgQHju5RtIu3qfAN5iGJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BFM7NYhnQO2X9YBXQnKRtQ3dRVLRysyZHHzxhKj+z0mZJimKdNY1788xIlrB1A2yM 8n3yxKIR7sOYpyV8ZVDVdEIPDgexnBX6LJoIBDo1Y9oBP4birD5oElhtHcyCCT3bx8 UZTKTtfnEyBaBwR2r/TMQEaTSy5Bd0MFx0dM8m5A= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Jacopo Mondi Subject: [PATCH v3 4/5] libcamera: controls: Implement `swap()` Date: Thu, 3 Sep 2026 11:18:42 +0200 Message-ID: <20260903091843.85548-5-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260903091843.85548-1-barnabas.pocze@ideasonboard.com> References: <20260903091843.85548-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" Implement both free and member function `swap()` for `ControlValue`. The general `std::swap()` swaps two values by combining a move construction and two move assignments, but for `ControlValue` a simpler implementation can be provided by just swapping the members. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/controls.h | 13 +++++++++++++ src/libcamera/controls.cpp | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index aef17abe07..190a28970c 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -264,6 +264,19 @@ public: void reserve(ControlType type, bool isArray = false, std::size_t numElements = 1); + void swap(ControlValue &other) noexcept + { + std::swap(type_, other.type_); + std::swap(isArray_, other.isArray_); + std::swap(numElements_, other.numElements_); + std::swap(storage_, other.storage_); + } + + friend void swap(ControlValue &a, ControlValue &b) noexcept + { + a.swap(b); + } + private: ControlType type_; bool isArray_; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 588b609373..242072778b 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -413,6 +413,21 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen storage_.external = new uint8_t[newSize]; } +/** + * \fn ControlValue::swap(ControlValue &other) noexcept + * \brief Swap two control values + * + * This function swaps the contained value of \a this with that of \a other. + */ + +/** + * \fn ControlValue::swap(ControlValue &a, ControlValue &b) noexcept + * \brief Swap two control values + * + * This function swaps the contained value of \a a with that of \a b. + * \sa ControlValue::swap() + */ + /** * \class ControlId * \brief Control static metadata From patchwork Thu Sep 3 09:18:43 2026 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: 28184 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 8C7F2C334B for ; Thu, 3 Sep 2026 09:18:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4D226685EB; Thu, 3 Sep 2026 11:18:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mfuyH033"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4987A685DB for ; Thu, 3 Sep 2026 11:18:48 +0200 (CEST) Received: from pb-laptop.local (185.221.143.32.nat.pool.zt.hu [185.221.143.32]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7AF271CF5; Thu, 3 Sep 2026 11:17:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788427036; bh=mvLMk8HaxPpjPVa+2s+ZI0E7AuIGQfR/+9NKEJxB3Ss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mfuyH033L2nEyLrwGLt6laNybhb6xJD6EFR3EpYCk/nkBp5DPjtesbm1SwtXITF75 mkGv7otWJocWI2k9zwh6lXa+u/rcziTsyZ+9ElkZ/dbiehek6X15+w+/o7vFbxgdlD uNWOTM5V3qbdJZLVRwgFbkmFyV5y1AeQGlUiAloc= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Jacopo Mondi , Laurent Pinchart Subject: [PATCH v3 5/5] libcamera: controls: Add rvalue overload for `ControlList::set()` Date: Thu, 3 Sep 2026 11:18:43 +0200 Message-ID: <20260903091843.85548-6-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260903091843.85548-1-barnabas.pocze@ideasonboard.com> References: <20260903091843.85548-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" Add an overload of `ControlList::set()` that takes the `ControlValue` argument as an rvalue reference, therefore enabling the use of move assignment. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/controls.h | 1 + src/libcamera/controls.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 190a28970c..e7278b4965 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -513,6 +513,7 @@ public: const ControlValue &get(unsigned int id) const; void set(unsigned int id, const ControlValue &value); + void set(unsigned int id, ControlValue &&value); const ControlInfoMap *infoMap() const { return infoMap_; } const ControlIdMap *idMap() const { return idmap_; } diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 242072778b..ce10e4bbe1 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -1153,6 +1153,18 @@ void ControlList::set(unsigned int id, const ControlValue &value) *val = value; } +/** + * \copydoc ControlList::set(unsigned int, const ControlValue &) + */ +void ControlList::set(unsigned int id, ControlValue &&value) +{ + ControlValue *val = find(id); + if (!val) + return; + + *val = std::move(value); +} + /** * \fn ControlList::infoMap() * \brief Retrieve the ControlInfoMap used to construct the ControlList