From e1ccded8336e86c9cb5a458e3d52892d52782fc3 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Sat, 5 Dec 2020 19:30:49 +0900 Subject: libcamera: Add IPCPipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create a virtual IPCPipe class that models an IPC/RPC system. IPA proxies and proxy workers will call into the IPCPipe, rather than implementing the IPC themselves. Signed-off-by: Paul Elder Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- include/libcamera/internal/ipc_pipe.h | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 include/libcamera/internal/ipc_pipe.h (limited to 'include/libcamera') diff --git a/include/libcamera/internal/ipc_pipe.h b/include/libcamera/internal/ipc_pipe.h new file mode 100644 index 00000000..c9a84b78 --- /dev/null +++ b/include/libcamera/internal/ipc_pipe.h @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2020, Google Inc. + * + * ipc_pipe.h - Image Processing Algorithm IPC module for IPA proxies + */ +#ifndef __LIBCAMERA_INTERNAL_IPA_IPC_H__ +#define __LIBCAMERA_INTERNAL_IPA_IPC_H__ + +#include + +#include "libcamera/internal/ipc_unixsocket.h" + +#include + +namespace libcamera { + +class IPCMessage +{ +public: + struct Header { + uint32_t cmd; + uint32_t cookie; + }; + + IPCMessage(); + IPCMessage(uint32_t cmd); + IPCMessage(const Header &header); + IPCMessage(const IPCUnixSocket::Payload &payload); + + IPCUnixSocket::Payload payload() const; + + Header &header() { return header_; } + std::vector &data() { return data_; } + std::vector &fds() { return fds_; } + + const Header &header() const { return header_; } + const std::vector &data() const { return data_; } + const std::vector &fds() const { return fds_; } + +private: + Header header_; + + std::vector data_; + std::vector fds_; +}; + +class IPCPipe +{ +public: + IPCPipe(); + virtual ~IPCPipe(); + + bool isConnected() const { return connected_; } + + virtual int sendSync(const IPCMessage &in, + IPCMessage *out) = 0; + + virtual int sendAsync(const IPCMessage &data) = 0; + + Signal recv; + +protected: + bool connected_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_INTERNAL_IPA_IPC_H__ */ -- cgit v1.2.1