From patchwork Thu Jan 15 11:16:28 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: 25813 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 037BABDCBF for ; Thu, 15 Jan 2026 11:16:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E7B3C61FC7; Thu, 15 Jan 2026 12:16:34 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="v27YSQ6k"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DCEDF61F84 for ; Thu, 15 Jan 2026 12:16:32 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 754B84D3 for ; Thu, 15 Jan 2026 12:16:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768475765; bh=aFssBQ4ulwikszOYeI0WUH0iFsVXXcpXGOTy9DPams8=; h=From:To:Subject:Date:From; b=v27YSQ6kBXzp0VFdCcC2S21ElcZIkBT2yDxkwYhaFG9IQ0QLpI1qR4Dlndv+kFA9O gIU8I+cnhYG9P/N4hGGEcZgmE+Hwl5ITy6t0KjiS5ZyUEZHMt3ws8ZHf/XDh4TAm1Q AEZGR2fQs3A3D/BckOe3RjxSANf0LsQviNMwWI+o= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 1/3] libcamera: base: utils: Simplify `operator<<` for `Duration` Date: Thu, 15 Jan 2026 12:16:28 +0100 Message-ID: <20260115111630.1892890-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 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" There is no real need for a function template. It is not defined in a header file, so it has limited availability, and there exists only a single instantion. So convert it to use `std::ostream` directly, like most `operator<<` in the code base. Signed-off-by: Barnabás Pőcze --- include/libcamera/base/utils.h | 4 +--- src/libcamera/base/utils.cpp | 11 ++--------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 0b7407f77..6ce1ace43 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -426,9 +426,7 @@ scope_exit(EF) -> scope_exit; } /* namespace utils */ #ifndef __DOXYGEN__ -template -std::basic_ostream &operator<<(std::basic_ostream &os, - const utils::Duration &d); +std::ostream &operator<<(std::ostream &os, const utils::Duration &d); #endif } /* namespace libcamera */ diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp index 65d9181c9..2c3f2b7e6 100644 --- a/src/libcamera/base/utils.cpp +++ b/src/libcamera/base/utils.cpp @@ -658,11 +658,9 @@ void ScopeExitActions::release() } /* namespace utils */ #ifndef __DOXYGEN__ -template -std::basic_ostream &operator<<(std::basic_ostream &os, - const utils::Duration &d) +std::ostream &operator<<(std::ostream &os, const utils::Duration &d) { - std::basic_ostringstream s; + std::ostringstream s; s.flags(os.flags()); s.imbue(os.getloc()); @@ -671,11 +669,6 @@ std::basic_ostream &operator<<(std::basic_ostream s << d.get() << "us"; return os << s.str(); } - -template -std::basic_ostream> & -operator<< >(std::basic_ostream> &os, - const utils::Duration &d); #endif } /* namespace libcamera */ From patchwork Thu Jan 15 11:16:29 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: 25814 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 78C33BDCBF for ; Thu, 15 Jan 2026 11:16:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 60F1B61FC6; Thu, 15 Jan 2026 12:16:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="A1H+zMzH"; 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 23ABA61FA3 for ; Thu, 15 Jan 2026 12:16:33 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AA13A766 for ; Thu, 15 Jan 2026 12:16:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768475765; bh=YWISlLfLzrI0iP3LF4n9GCMmntpC4NRHoH7kPM9FUGI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=A1H+zMzHdZE2IRRQ/gWPgNDDXp4In1gafATvE0sZUAJj4NUXq+vzvf1MaB+4yWvAC 1EZq8Wmkq0W9KwbQsUIL8+lYSDErolnpk0OiFCvCqSbrPJRsOAfEwtf9foNsjlKN5C N31ilOtC92w9Xt0qddOekuPoawMgfxKhHIo+etGw= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 2/3] ipa: rpi: Fix printing of `utils::Duration` Date: Thu, 15 Jan 2026 12:16:29 +0100 Message-ID: <20260115111630.1892890-2-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115111630.1892890-1-barnabas.pocze@ideasonboard.com> References: <20260115111630.1892890-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" `utils::Duration` derives from `std::chrono::duration<...>`, but multiplying it yields an `std::chrono::duration<...>`, not `Duration`. chrono duration types only have `operator<<` in C++20 or later, so this usage should not compile. It only did so because the `operator<<` for `Duration` was in the `libcamera` namespace and `Duration` has an implicit constructor from any chrono duration type. This will cease to work when that operator is moved into the `utils` namespace for ADL purposes. So fix it by making the cast to `Duration` explicit. Signed-off-by: Barnabás Pőcze --- src/ipa/rpi/common/ipa_base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 14aba4500..f95a0f838 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -602,7 +602,7 @@ void IpaBase::setMode(const IPACameraSensorInfo &sensorInfo) mode_.minLineLength = adjustedLineLength; } else { LOG(IPARPI, Error) - << "Sensor minimum line length of " << pixelTime * mode_.width + << "Sensor minimum line length of " << Duration(pixelTime * mode_.width) << " (" << 1us / pixelTime << " MPix/s)" << " is below the minimum allowable ISP limit of " << adjustedLineLength From patchwork Thu Jan 15 11:16:30 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: 25815 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 7BD80C3274 for ; Thu, 15 Jan 2026 11:16:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F2A9461FBC; Thu, 15 Jan 2026 12:16:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="d5qth5Tu"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5202E61FBB for ; Thu, 15 Jan 2026 12:16:33 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DCBF14D3 for ; Thu, 15 Jan 2026 12:16:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1768475765; bh=ANyZ0k0cKLK4B/teK0xo6/5jNKA5jRhJmA+LsaNSOgw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=d5qth5TuYsY3mAfNOzwxmCFbfrlK2bjy84TBcROh8CwnJ85KtQMIxZrZT/97bmBJ9 K05OM5lBQ9KwUq7teGBHbXMJG4xgm3WyyLZbcnt1j7c9CC9GA8zNlnALiHkHnqUEzt 1PByy8HwqwEFh0QgF/RkM2DlOSTVzxL0fsgcM5gM= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 3/3] libcamera: base: utils: Fix names of `operator<<` for `Duration` Date: Thu, 15 Jan 2026 12:16:30 +0100 Message-ID: <20260115111630.1892890-3-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115111630.1892890-1-barnabas.pocze@ideasonboard.com> References: <20260115111630.1892890-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 for ADL to find the function, it must be in the namespace of any of its arguments. Previously, however, that was not the case, and it has only really worked by accident and could be easily made to fail by introducing other `operator<<` overloads. For example, a user of this function in `libcamera::ipa` would no longer compile after introducing an `operator<<` into the `libcamera::ipa` namespace as that would essentially hide this overload, and without ADL it would not be found. So move the function into the `utils` namespace. Fixes: 5055ca747c4c ("libcamera: utils: Add helper class for std::chrono::duration") Signed-off-by: Barnabás Pőcze --- include/libcamera/base/utils.h | 6 +++--- src/libcamera/base/utils.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 6ce1ace43..fc4f5079c 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -423,10 +423,10 @@ scope_exit(EF) -> scope_exit; #endif /* __DOXYGEN__ */ -} /* namespace utils */ - #ifndef __DOXYGEN__ -std::ostream &operator<<(std::ostream &os, const utils::Duration &d); +std::ostream &operator<<(std::ostream &os, const Duration &d); #endif +} /* namespace utils */ + } /* namespace libcamera */ diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp index 2c3f2b7e6..42a516097 100644 --- a/src/libcamera/base/utils.cpp +++ b/src/libcamera/base/utils.cpp @@ -655,10 +655,8 @@ void ScopeExitActions::release() actions_.clear(); } -} /* namespace utils */ - #ifndef __DOXYGEN__ -std::ostream &operator<<(std::ostream &os, const utils::Duration &d) +std::ostream &operator<<(std::ostream &os, const Duration &d) { std::ostringstream s; @@ -671,4 +669,6 @@ std::ostream &operator<<(std::ostream &os, const utils::Duration &d) } #endif +} /* namespace utils */ + } /* namespace libcamera */