From patchwork Tue Oct 11 10:58:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17581 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 93365C0DA4 for ; Tue, 11 Oct 2022 10:59:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4EA6362D7E; Tue, 11 Oct 2022 12:59:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665485960; bh=7PNSd1rNWaPCtaLZIWIxfkRODfiSBRN65VR0qRxbGVw=; 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=szWtHwGo+/dRI0TRz9+lZhGftFW3bzqAuv8G60gvSIUHGTlzZi2c6D/LTB2ynLUxB GAXbz9mGFtqduB/QhFQuTCixtMD62AIRJQaukh9rxOpYlWZppC0eyDn102eHF72zC8 T4KjhTvv0yNCLakCQIL0P59Y0NZR+KGOcrNLuZwH/D3BQjTrh8eC+/aUGnYZnG36zh T3QgB6LL59lpbQSHVlAoFY5ZvsYIYW8N++0RB7+mJdXtGnaP7NIt+LaOuf3Ox3hCdz 3PAvRuvQJx+bgHFQlxy6NqRGGjo86tG0zkR8sdkAoQGsRFz1mWLZlUD6XEVfzjUSQ/ 4xlwmixnBQfHg== 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 02C2962D4E for ; Tue, 11 Oct 2022 12:59:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fh/xy85d"; 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 52111907; Tue, 11 Oct 2022 12:59:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665485958; bh=7PNSd1rNWaPCtaLZIWIxfkRODfiSBRN65VR0qRxbGVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fh/xy85dShYnH40l/hZwSdHowPw52fmABuqbjfepx5L/N74UaQpS0eTOpx1QuxRCC ZIealsL7DKGlU558fkNOvYlrBZM/pw70EEM4ZJrGG/Mepm7APN5ZZX3p1oZHAQq5hd 7uymBlEMaRrG07CKhOgAiWs9TCmGdhlh7XNbbgzY= To: libcamera-devel@lists.libcamera.org Date: Tue, 11 Oct 2022 19:58:53 +0900 Message-Id: <20221011105859.457567-4-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 3/9] libcamera: ipa_data_serializer: Add serializer for Flags 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" Implement an IPADataSerializer for Flags. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- No change in v5 No change in v4 No change in v3 Changes in v2: - use Flags's Type cast to avoid friend class --- .../libcamera/internal/ipa_data_serializer.h | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/include/libcamera/internal/ipa_data_serializer.h b/include/libcamera/internal/ipa_data_serializer.h index 30bdaebc..981d2f5c 100644 --- a/include/libcamera/internal/ipa_data_serializer.h +++ b/include/libcamera/internal/ipa_data_serializer.h @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -301,6 +302,51 @@ public: } }; +/* Serialization format for Flags is same as for PODs */ +template +class IPADataSerializer> +{ +public: + static std::tuple, std::vector> + serialize(const Flags &data, [[maybe_unused]] ControlSerializer *cs = nullptr) + { + std::vector dataVec; + dataVec.reserve(sizeof(Flags)); + appendPOD(dataVec, static_cast::Type>(data)); + + return { dataVec, {} }; + } + + static Flags deserialize(std::vector &data, + [[maybe_unused]] ControlSerializer *cs = nullptr) + { + return deserialize(data.cbegin(), data.end()); + } + + static Flags deserialize(std::vector::const_iterator dataBegin, + std::vector::const_iterator dataEnd, + [[maybe_unused]] ControlSerializer *cs = nullptr) + { + return Flags{ static_cast(readPOD(dataBegin, 0, dataEnd)) }; + } + + static Flags deserialize(std::vector &data, + [[maybe_unused]] std::vector &fds, + [[maybe_unused]] ControlSerializer *cs = nullptr) + { + return deserialize(data.cbegin(), data.end()); + } + + static Flags 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, + [[maybe_unused]] ControlSerializer *cs = nullptr) + { + return deserialize(dataBegin, dataEnd); + } +}; + #endif /* __DOXYGEN__ */ } /* namespace libcamera */