From patchwork Thu Apr 22 08:08:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12065 X-Patchwork-Delegate: paul.elder@ideasonboard.com 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 8BFE4BDB17 for ; Thu, 22 Apr 2021 08:08:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 447326885C; Thu, 22 Apr 2021 10:08:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fRXDVN0R"; 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 C558268848 for ; Thu, 22 Apr 2021 10:08:37 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1CB8E3EE; Thu, 22 Apr 2021 10:08:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1619078917; bh=WVxoreeIGKky1RfKHnVJRAk804OdfMX+iJ2PtdhnyYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fRXDVN0R9kZAYN5A8pq406ze8uCJFu2PCyLAp2KgFYYc2fN4SxpZDzOni/YGPALRf tX6rcXHHlWgLK2gnRhrqad1dH9EaMsuwDUSHGDAFGimhAtwlE4H6CGJXqAXPFBe580 RTw1ZDE5qBtJEl5yWeNk6YC9x2wC3i7BdhHPwNYg= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 22 Apr 2021 17:08:15 +0900 Message-Id: <20210422080816.364948-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210422080816.364948-1-paul.elder@ideasonboard.com> References: <20210422080816.364948-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/2] utils: ipc: Support types defined in core.mojom with skipHeader only 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" Previously, types that were defined in core.mojom with skipHeader only and no skipSerdes would cause serializer generation to fail due to the generated IPA namespace being used for mojom-defined types instead of the libcamera namespace. This doesn't work because skipHeader means that the type is defined in the libcamera (or some other) namespace elsewhere. Fix this by using "using namespace" in the generated serializer header, so that mojom-defined IPA types can be used without the full namespace qualifier. Signed-off-by: Paul Elder --- No change in v2 .../module_ipa_serializer.h.tmpl | 6 +++ .../libcamera_templates/serializer.tmpl | 38 +++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl index 64ae99dc..d0bac62d 100644 --- a/utils/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl +++ b/utils/ipc/generators/libcamera_templates/module_ipa_serializer.h.tmpl @@ -27,6 +27,12 @@ namespace libcamera { +{%- if has_namespace %} +{% for ns in namespace -%} +using namespace {{ns}}; +{% endfor %} +{%- endif %} + LOG_DECLARE_CATEGORY(IPADataSerializer) {% for struct in structs_nonempty %} template<> diff --git a/utils/ipc/generators/libcamera_templates/serializer.tmpl b/utils/ipc/generators/libcamera_templates/serializer.tmpl index af35b9e3..afabd8e3 100644 --- a/utils/ipc/generators/libcamera_templates/serializer.tmpl +++ b/utils/ipc/generators/libcamera_templates/serializer.tmpl @@ -63,12 +63,10 @@ {%- else %} std::tie({{field.mojom_name}}, std::ignore) = {%- endif %} - {%- if field|is_array or field|is_map %} - IPADataSerializer<{{field|name}}>::serialize(data.{{field.mojom_name}}, cs); - {%- elif field|is_str %} + {%- if field|is_str %} IPADataSerializer<{{field|name}}>::serialize(data.{{field.mojom_name}}); {%- else %} - IPADataSerializer<{{field|name_full(namespace)}}>::serialize(data.{{field.mojom_name}}, cs); + IPADataSerializer<{{field|name}}>::serialize(data.{{field.mojom_name}}, cs); {%- endif %} appendPOD(retData, {{field.mojom_name}}.size()); {%- if field|has_fd %} @@ -97,7 +95,7 @@ {%- if field|is_pod %} ret.{{field.mojom_name}} = IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field_size}}); {%- else %} - ret.{{field.mojom_name}} = static_cast<{{field|name_full(namespace)}}>(IPADataSerializer::deserialize(m, m + {{field_size}})); + ret.{{field.mojom_name}} = static_cast<{{field|name}}>(IPADataSerializer::deserialize(m, m + {{field_size}})); {%- endif %} {%- if not loop.last %} m += {{field_size}}; @@ -150,11 +148,11 @@ {%- elif field|has_fd and (field|is_array or field|is_map) %} IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field.mojom_name}}Size, n, n + {{field.mojom_name}}FdsSize, cs); {%- elif field|has_fd and (not (field|is_array or field|is_map)) %} - IPADataSerializer<{{field|name_full(namespace)}}>::deserialize(m, m + {{field.mojom_name}}Size, n, n + {{field.mojom_name}}FdsSize, cs); + IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field.mojom_name}}Size, n, n + {{field.mojom_name}}FdsSize, cs); {%- elif (not field|has_fd) and (field|is_array or field|is_map) %} IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field.mojom_name}}Size, cs); {%- else %} - IPADataSerializer<{{field|name_full(namespace)}}>::deserialize(m, m + {{field.mojom_name}}Size, cs); + IPADataSerializer<{{field|name}}>::deserialize(m, m + {{field.mojom_name}}Size, cs); {%- endif %} {%- if not loop.last %} m += {{field_size}}; @@ -178,7 +176,7 @@ #} {%- macro serializer(struct, namespace) %} static std::tuple, std::vector> - serialize(const {{struct|name_full(namespace)}} &data, + serialize(const {{struct|name}} &data, {%- if struct|needs_control_serializer %} ControlSerializer *cs) {%- else %} @@ -208,7 +206,7 @@ # \a struct, in the case that \a struct has file descriptors. #} {%- macro deserializer_fd(struct, namespace) %} - static {{struct|name_full(namespace)}} + static {{struct|name}} deserialize(std::vector &data, std::vector &fds, {%- if struct|needs_control_serializer %} @@ -217,11 +215,11 @@ ControlSerializer *cs = nullptr) {%- endif %} { - return IPADataSerializer<{{struct|name_full(namespace)}}>::deserialize(data.cbegin(), data.cend(), fds.cbegin(), fds.cend(), cs); + return IPADataSerializer<{{struct|name}}>::deserialize(data.cbegin(), data.cend(), fds.cbegin(), fds.cend(), cs); } {# \todo Don't inline this function #} - static {{struct|name_full(namespace)}} + static {{struct|name}} deserialize(std::vector::const_iterator dataBegin, std::vector::const_iterator dataEnd, std::vector::const_iterator fdsBegin, @@ -232,7 +230,7 @@ [[maybe_unused]] ControlSerializer *cs = nullptr) {%- endif %} { - {{struct|name_full(namespace)}} ret; + {{struct|name}} ret; std::vector::const_iterator m = dataBegin; std::vector::const_iterator n = fdsBegin; @@ -253,22 +251,22 @@ # deserializers with file descriptors. #} {%- macro deserializer_fd_simple(struct, namespace) %} - static {{struct|name_full(namespace)}} + static {{struct|name}} deserialize(std::vector &data, [[maybe_unused]] std::vector &fds, ControlSerializer *cs = nullptr) { - return IPADataSerializer<{{struct|name_full(namespace)}}>::deserialize(data.cbegin(), data.cend(), cs); + return IPADataSerializer<{{struct|name}}>::deserialize(data.cbegin(), data.cend(), cs); } - static {{struct|name_full(namespace)}} + static {{struct|name}} deserialize(std::vector::const_iterator dataBegin, std::vector::const_iterator dataEnd, [[maybe_unused]] std::vector::const_iterator fdsBegin, [[maybe_unused]] std::vector::const_iterator fdsEnd, ControlSerializer *cs = nullptr) { - return IPADataSerializer<{{struct|name_full(namespace)}}>::deserialize(dataBegin, dataEnd, cs); + return IPADataSerializer<{{struct|name}}>::deserialize(dataBegin, dataEnd, cs); } {%- endmacro %} @@ -280,7 +278,7 @@ # \a struct, in the case that \a struct does not have file descriptors. #} {%- macro deserializer_no_fd(struct, namespace) %} - static {{struct|name_full(namespace)}} + static {{struct|name}} deserialize(std::vector &data, {%- if struct|needs_control_serializer %} ControlSerializer *cs) @@ -288,11 +286,11 @@ ControlSerializer *cs = nullptr) {%- endif %} { - return IPADataSerializer<{{struct|name_full(namespace)}}>::deserialize(data.cbegin(), data.cend(), cs); + return IPADataSerializer<{{struct|name}}>::deserialize(data.cbegin(), data.cend(), cs); } {# \todo Don't inline this function #} - static {{struct|name_full(namespace)}} + static {{struct|name}} deserialize(std::vector::const_iterator dataBegin, std::vector::const_iterator dataEnd, {%- if struct|needs_control_serializer %} @@ -301,7 +299,7 @@ [[maybe_unused]] ControlSerializer *cs = nullptr) {%- endif %} { - {{struct|name_full(namespace)}} ret; + {{struct|name}} ret; std::vector::const_iterator m = dataBegin; size_t dataSize = std::distance(dataBegin, dataEnd); From patchwork Thu Apr 22 08:08:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12066 X-Patchwork-Delegate: paul.elder@ideasonboard.com 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 83139BDB17 for ; Thu, 22 Apr 2021 08:08:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3E4336885B; Thu, 22 Apr 2021 10:08:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NC4ywZ9W"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C2A886885F for ; Thu, 22 Apr 2021 10:08:39 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E83B3EE; Thu, 22 Apr 2021 10:08:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1619078919; bh=SOzuJjUTvZpXQuuKs08dmNZm2d6VLGX2/il63teBihs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NC4ywZ9WbiKEZtE0f89yc6KPy0xunV6xvDbn1aHsQxfXVZwPYA1j1MbawwIaBIdba whgKZtee1tU94+sv6IRZXxGeMqxLZcU9uxwgDLiO1UJy7OTwXJRNy2gsMFHFTpBqfV CLBZtC5kP6XPV4EO+zvDhhVF2eJJ0U0uVERmSpe4= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 22 Apr 2021 17:08:16 +0900 Message-Id: <20210422080816.364948-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210422080816.364948-1-paul.elder@ideasonboard.com> References: <20210422080816.364948-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] utils: ipc: Include instead of forward-declare CameraSensorInfo 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" For structs defined in core.mojom that have the skipHeader tag, if they're only used in function parameters (in a mojom file) then a forward-declaration is sufficient. However, if the struct is used in another struct in a mojom file, then the forward-declaration is insufficient, and the definition needs to be included. Do so for CameraSensorInfo, which is the only forward-declared struct in ipa_interface.h, and update the documentation comment. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- New in v2 include/libcamera/ipa/ipa_interface.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/libcamera/ipa/ipa_interface.h b/include/libcamera/ipa/ipa_interface.h index 5d99e2cf..dfe1b40a 100644 --- a/include/libcamera/ipa/ipa_interface.h +++ b/include/libcamera/ipa/ipa_interface.h @@ -18,15 +18,15 @@ #include #include +#include "libcamera/internal/camera_sensor.h" + namespace libcamera { /* * Structs that are defined in core.mojom and have the skipHeader tag must be - * forward-declared or #included here. + * #included here. */ -struct CameraSensorInfo; - class IPAInterface { public: