From 45bd1f20f6a9c9b97972944358c75beb9dfafb9c Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 3 Jul 2024 22:26:35 +0300 Subject: libcamera: base: utils: Implement hex() for 8-bit and 16-bit values 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 Reviewed-by: Stefan Klug --- include/libcamera/base/utils.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 4ae02dc9..734ff81e 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) { -- cgit v1.2.1