From patchwork Thu Sep 26 00:24:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 21375 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 89287C3257 for ; Thu, 26 Sep 2024 00:24:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 373956350E; Thu, 26 Sep 2024 02:24:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TGWlrpxs"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2DA72634FB for ; Thu, 26 Sep 2024 02:24:29 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4DEC3169; Thu, 26 Sep 2024 02:23:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1727310181; bh=dwRd3fdu1qyXuryVrqVtIC2yGupFz63B18yPfSsqySM=; h=From:To:Cc:Subject:Date:From; b=TGWlrpxsmKpVSwRySGGuK2LuefbeRSBA/7J/Xx+u0B+pWjv1Ydp9Ear4UroRr3YXE Z3KbATcX1Cw0HfkAjd6JS03NBV1bh7Q0HLNWHKH9bcSVcsr46wVpwbENwZ4XCjFnPc KD3Fo6YXnw/pb8mknVmMoYQnG1T2Kv9eRKl1T8/k= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Cl=C3=A1udio_Paulo?= Subject: [PATCH] libcamera: controls: Handle enum values without a cast Date: Thu, 26 Sep 2024 03:24:27 +0300 Message-ID: <20240926002427.27703-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.2 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" When constructing a ControlValue from an enum value, an explicit cast to int32_t is needed as we use int32_t as the underlying type for all enumerated controls. This makes users of ControlValue more complex. To simplify them, specialize the control_type template for enum types, to support construction of ControlValue directly without a cast. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- include/libcamera/controls.h | 6 +++++- src/libcamera/pipeline/ipu3/ipu3.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) base-commit: f2088eb91fd6477b152233b9031cb115ca1ae824 diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 25f67ed948a3..c5131870d402 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -39,7 +39,7 @@ enum ControlType { namespace details { -template +template> struct control_type { }; @@ -102,6 +102,10 @@ struct control_type> : public control_type> { static constexpr std::size_t size = N; }; +template +struct control_type>> : public control_type { +}; + } /* namespace details */ class ControlValue diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 430aa902eec8..29d3c6c194c1 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -958,7 +958,7 @@ int PipelineHandlerIPU3::updateControls(IPU3CameraData *data) values.reserve(testPatternModes.size()); for (auto pattern : testPatternModes) - values.emplace_back(static_cast(pattern)); + values.emplace_back(pattern); controls[&controls::draft::TestPatternMode] = ControlInfo(values); }