From patchwork Mon Aug 29 23:30:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17243 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 A0D91C327D for ; Mon, 29 Aug 2022 23:30:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EADAC61FC7; Tue, 30 Aug 2022 01:30:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1661815834; bh=F/6XAvTyZBjVFq/yAo/+7z/8mDpIfsJZ8h1zXWNbvVQ=; 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=BtQEY+zo+OrsdiZEbJxK4aSyctYLO049MxD16zPKsxlkc63h+IgWokyIZanoa9nip FpzmO+d4NdNpimza00OakGYQ4aG2kLKGG4D79ukqpgnhA2qPFUw/NfUzFsGwKy3TD1 JmFOrYUP1wClZbK39xShkkNiEPmgBsQ/5gpHdIbggdFOsPNItQV/xsvJcD2W0rWWaR RxlU3on9XTPGDj2XvIp5FOQQ94o15+IzYbFd0ijgB8hJN9q7UX0DTj/1k/sSx/3aI0 tD7A5Xf86TVwB3NAK8m/vKKRW2DflQ9zNLfN8lgDv1KdRtJfOtVnbt5Z5/0WEfCMBA XeUP/UFfa3y+g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 413D561F9C for ; Tue, 30 Aug 2022 01:30:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Dbj5cvP7"; dkim-atps=neutral Received: from pyrite.mediacom.info (unknown [IPv6:2604:2d80:ad8a:9000:1bf9:855b:22de:3645]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4E4CF6F2; Tue, 30 Aug 2022 01:30:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1661815830; bh=F/6XAvTyZBjVFq/yAo/+7z/8mDpIfsJZ8h1zXWNbvVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dbj5cvP7MBF4qiFKKf/LamjU+PTMtN7dT+8NQWgzS4rjaCL7Cj3DRSGbrfRdkjPSl gseO7JOdTxxC2VH55y0ihWykglnoVTPz7NNS4uIEMHkPZPg43S39pY4MPrhBeuiV7c Yet3Kza/0TZ1byDyLdtDciYyhXmsJbEvnXiFG9fg= To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Aug 2022 18:30:13 -0500 Message-Id: <20220829233017.2699444-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220829233017.2699444-1-paul.elder@ideasonboard.com> References: <20220829233017.2699444-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 3/7] 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 --- 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 */