{"id":10357,"url":"https://patchwork.libcamera.org/api/patches/10357/?format=json","web_url":"https://patchwork.libcamera.org/patch/10357/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20201106103707.49660-10-paul.elder@ideasonboard.com>","date":"2020-11-06T10:36:39","name":"[libcamera-devel,v4,09/37] libcamera: Add IPAIPC","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"f91c14323df904dbb7a6461c996de6e2c0d005f0","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/10357/mbox/","series":[{"id":1448,"url":"https://patchwork.libcamera.org/api/series/1448/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1448","date":"2020-11-06T10:36:30","name":"IPA isolation implementation","version":4,"mbox":"https://patchwork.libcamera.org/series/1448/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10357/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10357/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7D470BDB89\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Nov 2020 10:37:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 45FE162D25;\n\tFri,  6 Nov 2020 11:37:44 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A4A2662D2C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Nov 2020 11:37:42 +0100 (CET)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DE571B16;\n\tFri,  6 Nov 2020 11:37:40 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Z/8qL08E\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1604659062;\n\tbh=UDU2ZwB2e8BWvwrqAlLiX9mIs4+kL8J0eZ95I0SNQ6A=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Z/8qL08EzBSrkPqy2uILTkUzx0a/LhgnriJTzEWyATNAertGT4o7Q5PXPwPCG/jXR\n\tWSxgjNI5QT1PRQRpRGG9dWLsLlMpIILN1OZsTIvSqa7Ap8xXbLGBFQQmcj/BFWmPs9\n\tt0wsMUMbWSNjLLouHlD/6Vol3Vry9ENU2egHtcjs=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  6 Nov 2020 19:36:39 +0900","Message-Id":"<20201106103707.49660-10-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20201106103707.49660-1-paul.elder@ideasonboard.com>","References":"<20201106103707.49660-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v4 09/37] libcamera: Add IPAIPC","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Create a virtual IPAIPC class that models an IPC/RPC system. IPA proxies\nand proxy workers will call into the IPAIPC, rather than implementing\nthe IPC themselves.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\n---\nChange in v4:\n- change snake_case to camelCase\n- remove ipaModulePath and ipaProxyWorkerPath from parameters in the\n  IPAIPC base contructor\n- include signal.h\n\nChanges in v3:\n- expand documentation a bit\n- move [[maybe_unused]] to after the parameters in the IPAIPC\n  constructor, to appease gcc <= 9.1\n\nChanges in v2:\n- add documentation\n---\n include/libcamera/internal/ipa_ipc.h |  42 ++++++++++\n src/libcamera/ipa_ipc.cpp            | 110 +++++++++++++++++++++++++++\n src/libcamera/meson.build            |   1 +\n 3 files changed, 153 insertions(+)\n create mode 100644 include/libcamera/internal/ipa_ipc.h\n create mode 100644 src/libcamera/ipa_ipc.cpp","diff":"diff --git a/include/libcamera/internal/ipa_ipc.h b/include/libcamera/internal/ipa_ipc.h\nnew file mode 100644\nindex 00000000..f83a90a3\n--- /dev/null\n+++ b/include/libcamera/internal/ipa_ipc.h\n@@ -0,0 +1,42 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * ipa_ipc.h - Image Processing Algorithm IPC module for IPA proxies\n+ */\n+#ifndef __LIBCAMERA_INTERNAL_IPA_IPC_H__\n+#define __LIBCAMERA_INTERNAL_IPA_IPC_H__\n+\n+#include <vector>\n+\n+#include <libcamera/signal.h>\n+\n+namespace libcamera {\n+\n+class IPAIPC\n+{\n+public:\n+\tIPAIPC();\n+\tvirtual ~IPAIPC();\n+\n+\tbool isValid() const { return valid_; }\n+\n+\tvirtual int sendSync(uint32_t cmd,\n+\t\t\t     const std::vector<uint8_t> &dataIn,\n+\t\t\t     const std::vector<int32_t> &fdsIn,\n+\t\t\t     std::vector<uint8_t> *dataOut = nullptr,\n+\t\t\t     std::vector<int32_t> *fdsOut = nullptr) = 0;\n+\n+\tvirtual int sendAsync(uint32_t cmd,\n+\t\t\t      const std::vector<uint8_t> &dataIn,\n+\t\t\t      const std::vector<int32_t> &fdsIn) = 0;\n+\n+\tSignal<std::vector<uint8_t> &, std::vector<int32_t> &> recvIPC;\n+\n+protected:\n+\tbool valid_;\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_INTERNAL_IPA_IPC_H__ */\ndiff --git a/src/libcamera/ipa_ipc.cpp b/src/libcamera/ipa_ipc.cpp\nnew file mode 100644\nindex 00000000..964d4ac1\n--- /dev/null\n+++ b/src/libcamera/ipa_ipc.cpp\n@@ -0,0 +1,110 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * ipa_ipc.cpp - Image Processing Algorithm IPC module for IPA proxies\n+ */\n+\n+#include <vector>\n+\n+#include \"libcamera/internal/ipc_unixsocket.h\"\n+#include \"libcamera/internal/log.h\"\n+#include \"libcamera/internal/process.h\"\n+#include \"libcamera/internal/thread.h\"\n+\n+#include <libcamera/event_dispatcher.h>\n+#include <libcamera/timer.h>\n+\n+#include \"libcamera/internal/ipa_ipc.h\"\n+\n+/**\n+ * \\file ipa_ipc.h\n+ * \\brief IPC mechanism for IPA isolation\n+ */\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(IPAIPC)\n+\n+/**\n+ * \\class IPAIPC\n+ * \\brief IPC mechanism for IPA isolation\n+ *\n+ * Virtual class to model an IPC mechanism for use by IPA proxies for IPA\n+ * isolation. sendSync() and sendAsync() must be implemented, and the recvIPC\n+ * signal must be emitted whenever new data is available.\n+ */\n+\n+/**\n+ * \\brief Construct an IPAIPC instance\n+ */\n+IPAIPC::IPAIPC() : valid_(false)\n+{\n+}\n+\n+IPAIPC::~IPAIPC()\n+{\n+}\n+\n+/**\n+ * \\fn IPAIPC::isValid()\n+ * \\brief Check if the IPAIPC instance is valid\n+ *\n+ * An IPAIPC instance is valid if the IPA interface is successfully created in\n+ * isolation, and IPC is successfully set up.\n+ *\n+ * \\return True if the IPAIPC is valid, false otherwise\n+ */\n+\n+/**\n+ * \\fn IPAIPC::sendSync()\n+ * \\brief Send a message over IPC synchronously\n+ * \\param[in] cmd Command ID\n+ * \\param[in] dataIn Data to send, as a byte vector\n+ * \\param[in] fdsIn Fds to send, in a vector\n+ * \\param[in] dataOut Byte vector in which to receive data, if applicable\n+ * \\param[in] fdsOut Fds vector in which to receive fds, if applicable\n+ *\n+ * This function will not return until a response is received. The event loop\n+ * will still continue to execute, however.\n+ *\n+ * \\return Zero on success, negative error code otherwise\n+ */\n+\n+/**\n+ * \\fn IPAIPC::sendAsync()\n+ * \\brief Send a message over IPC asynchronously\n+ * \\param[in] cmd Command ID\n+ * \\param[in] dataIn Data to send, as a byte vector\n+ * \\param[in] fdsIn Fds to send, in a vector\n+ *\n+ * This function will return immediately after sending the message.\n+ *\n+ * \\return Zero on success, negative error code otherwise\n+ */\n+\n+/**\n+ * \\var IPAIPC::recvIPC\n+ * \\brief Signal to be emitted when data is received over IPC\n+ *\n+ * When data is received over IPC, this signal shall be emitted. Users must\n+ * connect to this to receive new data.\n+ *\n+ * The parameters of the signal are a vector of bytes and a vector of file\n+ * descriptors.\n+ */\n+\n+/**\n+ * \\var IPAIPC::valid_\n+ * \\brief Flag to indicate if the IPAIPC instance is valid\n+ *\n+ * An IPAIPC instance is valid if the IPA interface is successfully created in\n+ * isolation, and IPC is successfully set up.\n+ *\n+ * This flag can be read via IPAIPC::isValid().\n+ *\n+ * Implementations of the IPAIPC class should set this flag upon successful\n+ * construction.\n+ */\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 01bcffd4..85f3a202 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -25,6 +25,7 @@ libcamera_sources = files([\n     'ipa_context_wrapper.cpp',\n     'ipa_controls.cpp',\n     'ipa_data_serializer.cpp',\n+    'ipa_ipc.cpp',\n     'ipa_interface.cpp',\n     'ipa_manager.cpp',\n     'ipa_module.cpp',\n","prefixes":["libcamera-devel","v4","09/37"]}