From patchwork Wed Jul 3 19:29:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20561 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 9B64DBD87C for ; Wed, 3 Jul 2024 19:29:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CA30962C96; Wed, 3 Jul 2024 21:29:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="u942kQrh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4BA0962C95 for ; Wed, 3 Jul 2024 21:29:46 +0200 (CEST) Received: from pendragon.ideasonboard.com (117.145-247-81.adsl-dyn.isp.belgacom.be [81.247.145.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DBC723E6 for ; Wed, 3 Jul 2024 21:29:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720034957; bh=40gXhFRiu8FxUwdSxfFO1V7ZZlqZk+Qky4RF9Jjw3wY=; h=From:To:Subject:Date:From; b=u942kQrh+mYjKydexWdk9UIx3x50LEIdYuu0H19uZttJVRMD7/Uq9CS6+BO+sx08h vt8fpgaXzHxRM7MsF4mX3eMZ2tO1UtpgmA2/C//sf9kAG/QhW+enuhJGKKYoqlGRoG v+njwZwJkDi2v9pwX7Gb7fYzeP3xojqUZQYl+81g= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH] libcamera: base: utils: Implement hex() for 8-bit and 16-bit values Date: Wed, 3 Jul 2024 22:29:24 +0300 Message-ID: <20240703192924.10643-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.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" The utils::hex() function is implemented for 32-bit and 64-bit integers, but not for 8-bit and 16-bit. This causes a link error (possibly at runtime for IPA modules due to lazy linking) when trying to print 8-bit or 16-bit integers. Implement additional specializations to fix it. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- include/libcamera/base/utils.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) base-commit: 196abb8d1d6e0fe9d190315e72a85eb12d16a554 diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 4ae02dc97478..734ff81e2860 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -90,6 +90,30 @@ template +inline _hex hex(int8_t value, unsigned int width) +{ + return { static_cast(value), width ? width : 2 }; +} + +template<> +inline _hex hex(uint8_t value, unsigned int width) +{ + return { static_cast(value), width ? width : 2 }; +} + +template<> +inline _hex hex(int16_t value, unsigned int width) +{ + return { static_cast(value), width ? width : 4 }; +} + +template<> +inline _hex hex(uint16_t value, unsigned int width) +{ + return { static_cast(value), width ? width : 4 }; +} + template<> inline _hex hex(int32_t value, unsigned int width) {