From patchwork Mon Sep 1 09:23:20 2025 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: 24276 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 3AB56BEFBE for ; Mon, 1 Sep 2025 09:23:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 75E4669333; Mon, 1 Sep 2025 11:23:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wUURHAgk"; 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 EDDC46931D for ; Mon, 1 Sep 2025 11:23:23 +0200 (CEST) Received: from pb-laptop.local (185.221.143.232.nat.pool.zt.hu [185.221.143.232]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B5D3BF52 for ; Mon, 1 Sep 2025 11:22:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1756718536; bh=JYdj6/BAO7KfMuGdl9thg4EuFbQ99vcs6KN7hhGUGEY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wUURHAgknIKRTxJc7pMMl+z/SJZ4hYAG5i6FOVegxhP5oROFqspYYps3WYXGKcZct BikSK8TaTsvPgbRIVU2GvDOgjeiB5nVGSo8C0D7zEigyztHcwSk1miLYJJcvG6n1gn vGO7l8d/oiHp2USNMmvmJSXRXaKQOgOTZ9X7QXm8= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 2/2] utils: codegen: gen-formats.py: Fix big endian formats Date: Mon, 1 Sep 2025 11:23:20 +0200 Message-ID: <20250901092320.44615-2-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250901092320.44615-1-barnabas.pocze@ideasonboard.com> References: <20250901092320.44615-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" First there is a single big endian format defined in `formats.yaml`: RGB565_BE. However, while the yaml file specifies "big_endian: true", the python script looks for a key named "big-endian". Causing `RGB565{,_BE}` both to be the same. Second, the python script simply appends " | DRM_FORMAT_BIG_ENDIAN" to the fourcc of the format. However, there is no definition of that macro is available in the only user, `formats.h.in`. Fix the first one by checking for "big_endian" in the script as well, and fix the second one by defining a constant with the same value and using that. Signed-off-by: Barnabás Pőcze Fixes: 7c496f1c54dd58 ("utils: gen-formats: Support big-endian DRM formats") Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/formats.h.in | 4 +++- utils/codegen/gen-formats.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/libcamera/formats.h.in b/include/libcamera/formats.h.in index 5ff9c3bf4..c821ffbb1 100644 --- a/include/libcamera/formats.h.in +++ b/include/libcamera/formats.h.in @@ -33,10 +33,12 @@ constexpr uint64_t __mod(unsigned int vendor, unsigned int mod) (static_cast(mod) << 0); } +constexpr uint32_t kDrmFormatBigEndian = uint32_t(1) << 31; /* DRM_FORMAT_BIG_ENDIAN */ + } /* namespace */ {% for f in formats %} -constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}), __mod({{f.mod}})); +constexpr PixelFormat {{f.name}}(__fourcc({{f.fourcc}}){{ ' | kDrmFormatBigEndian' if f.big_endian }}, __mod({{f.mod}})); {%- endfor %} } /* namespace formats */ diff --git a/utils/codegen/gen-formats.py b/utils/codegen/gen-formats.py index 872f3fe34..01adf5e1f 100755 --- a/utils/codegen/gen-formats.py +++ b/utils/codegen/gen-formats.py @@ -59,13 +59,12 @@ def generate_formats(formats, drm_fourcc): for format in formats: name, format = format.popitem() fourcc = drm_fourcc.fourcc(format['fourcc']) - if format.get('big-endian'): - fourcc += '| DRM_FORMAT_BIG_ENDIAN' data = { 'name': name, 'fourcc': fourcc, 'mod': '0, 0', + 'big_endian': format.get('big_endian') == True, } mod = format.get('mod')