From patchwork Tue Oct 11 10:58:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17586 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 614BDC0DA4 for ; Tue, 11 Oct 2022 10:59:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0D73662D8E; Tue, 11 Oct 2022 12:59:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665485970; bh=eUWxVu6zA8CheNezZiypVMsU5UjYnbSxlGieicPkHCU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Roe2wSViy4Mrc3M5Og/9DRa7Xqr7I9Fk15FD2gkFDAhQTo5wkyPtQUUn87v8ycNA8 bKCmDmLuUqlBm7+pYX/fIPlDdJZTLsqPnocwGYGwo0XeWViEz0mIityRUInII6cODi YHOGFcGzHKqLFh+eFIPKD12Af0EiSiKF9wOUq9ZnhiuPz8g+BO2LhOQ93CoVj4127R Zj1gT4DAu9ghfhTFYeBrHxu5IUAr0XuRHydZYOG0/ReXbtF8o/FoiYEaG+19V/RlHf +4N2IVompgc+ijYp8WtFajPrwj11FItEwQoGSl9NWNqVLW0KrGeDEw8Z/XBabCdTgu vp28UmywFjI9Q== 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 7D87762D8B for ; Tue, 11 Oct 2022 12:59:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ffs1ch6u"; dkim-atps=neutral Received: from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3BD6F907; Tue, 11 Oct 2022 12:59:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665485968; bh=eUWxVu6zA8CheNezZiypVMsU5UjYnbSxlGieicPkHCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ffs1ch6uBMj1EtJnX5KiN6GcdBSmSe53nZISrsAGtHVUel0oHAd3b3bemcmfM4ZwZ pp4w7nLupccXrmoZEEq8TtlzHf98GaUZ4fILvC6Mzyg80ygQ0CPwVqJfhShPaaJ7eW 1vSfMQitgfu+bejHN7jGdYRd7GTvw9a0eq8zjOuY= To: libcamera-devel@lists.libcamera.org Date: Tue, 11 Oct 2022 19:58:58 +0900 Message-Id: <20221011105859.457567-9-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221011105859.457567-1-paul.elder@ideasonboard.com> References: <20221011105859.457567-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 8/9] utils: ipc: Allow the skipHeader attribute on enums 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Currently, enums that are passed between pipeline handlers and their IPA must be defined in a mojom file. However, there is a use case for enum/flags to be defined in a C++ header, such that the enum can be used in a component other than the pipeline handler and its IPA. To support this, add support for the skipHeader attribute for enums. Like structs, it is only allowed in core.mojom. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- New in v5 --- include/libcamera/ipa/core.mojom | 4 +++- include/libcamera/ipa/ipa_interface.h | 4 ++-- .../generators/libcamera_templates/core_ipa_interface.h.tmpl | 2 +- utils/ipc/generators/mojom_libcamera_generator.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom index ef28ff2d..1ff674b0 100644 --- a/include/libcamera/ipa/core.mojom +++ b/include/libcamera/ipa/core.mojom @@ -14,7 +14,7 @@ module libcamera; * - structs * * Attributes: - * - skipHeader - structs only, and only in core.mojom + * - skipHeader - allowed only for structs and enums in core.mojom * - Do not generate a C++ definition for the structure * - Any type used in a mojom interface definition must have a corresponding * definition in a mojom file for the code generator to accept it, except @@ -52,6 +52,8 @@ module libcamera; * then the type definition in the core.mojom file should have the * [skipHeader] attribute only * - A (de)serializer will be generated for the type + * - enums that are defined in a libcamera C++ header also fall in this + * category * - If a type definition has [skipHeader], then the header where the type is * defined must be included in ipa_interface.h * - Types that are solely used as array/map members do not require a mojom diff --git a/include/libcamera/ipa/ipa_interface.h b/include/libcamera/ipa/ipa_interface.h index 8afcfe21..8884f0ed 100644 --- a/include/libcamera/ipa/ipa_interface.h +++ b/include/libcamera/ipa/ipa_interface.h @@ -23,8 +23,8 @@ namespace libcamera { /* - * Structs that are defined in core.mojom and have the skipHeader tag must be - * #included here. + * Structs and enums that are defined in core.mojom that have the skipHeader + * tag must be #included here. */ class IPAInterface diff --git a/utils/ipc/generators/libcamera_templates/core_ipa_interface.h.tmpl b/utils/ipc/generators/libcamera_templates/core_ipa_interface.h.tmpl index a565b59a..c60b99b8 100644 --- a/utils/ipc/generators/libcamera_templates/core_ipa_interface.h.tmpl +++ b/utils/ipc/generators/libcamera_templates/core_ipa_interface.h.tmpl @@ -26,7 +26,7 @@ namespace libcamera { static const {{const.kind|name}} {{const.mojom_name}} = {{const.value}}; {% endfor %} -{% for enum in enums %} +{% for enum in enums_gen_header %} {{funcs.define_enum(enum)}} {% endfor %} diff --git a/utils/ipc/generators/mojom_libcamera_generator.py b/utils/ipc/generators/mojom_libcamera_generator.py index 6c176aba..64987ccd 100644 --- a/utils/ipc/generators/mojom_libcamera_generator.py +++ b/utils/ipc/generators/mojom_libcamera_generator.py @@ -483,7 +483,7 @@ class Generator(generator.Generator): def _GetJinjaExportsForCore(self): return { 'consts': self.module.constants, - 'enums': self.module.enums, + 'enums_gen_header': [x for x in self.module.enums if x.attributes is None or 'skipHeader' not in x.attributes], 'has_array': len([x for x in self.module.kinds.keys() if x[0] == 'a']) > 0, 'has_map': len([x for x in self.module.kinds.keys() if x[0] == 'm']) > 0, 'structs_gen_header': [x for x in self.module.structs if x.attributes is None or 'skipHeader' not in x.attributes],