From 21f1b555b7a1bc0c482774cecedce3ffa84be6a1 Mon Sep 17 00:00:00 2001
From: Paul Elder <paul.elder@ideasonboard.com>
Date: Sat, 5 Dec 2020 19:30:50 +0900
Subject: libcamera: Add IPCPipe implementation based on unix socket
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add an implementation of IPCPipe using unix socket.

[Original patch]
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[Error fix from Niklas]
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
---
 include/libcamera/internal/ipc_pipe_unixsocket.h | 49 ++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 include/libcamera/internal/ipc_pipe_unixsocket.h

(limited to 'include')

diff --git a/include/libcamera/internal/ipc_pipe_unixsocket.h b/include/libcamera/internal/ipc_pipe_unixsocket.h
new file mode 100644
index 00000000..4ffdddcc
--- /dev/null
+++ b/include/libcamera/internal/ipc_pipe_unixsocket.h
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2020, Google Inc.
+ *
+ * ipc_pipe_unixsocket.h - Image Processing Algorithm IPC module using unix socket
+ */
+#ifndef __LIBCAMERA_INTERNAL_IPA_IPC_UNIXSOCKET_H__
+#define __LIBCAMERA_INTERNAL_IPA_IPC_UNIXSOCKET_H__
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include "libcamera/internal/ipc_pipe.h"
+#include "libcamera/internal/ipc_unixsocket.h"
+
+namespace libcamera {
+
+class Process;
+
+class IPCPipeUnixSocket : public IPCPipe
+{
+public:
+	IPCPipeUnixSocket(const char *ipaModulePath, const char *ipaProxyWorkerPath);
+	~IPCPipeUnixSocket();
+
+	int sendSync(const IPCMessage &in,
+		     IPCMessage *out = nullptr) override;
+
+	int sendAsync(const IPCMessage &data) override;
+
+private:
+	struct CallData {
+		IPCUnixSocket::Payload *response;
+		bool done;
+	};
+
+	void readyRead(IPCUnixSocket *socket);
+	int call(const IPCUnixSocket::Payload &message,
+		 IPCUnixSocket::Payload *response, uint32_t seq);
+
+	std::unique_ptr<Process> proc_;
+	std::unique_ptr<IPCUnixSocket> socket_;
+	std::map<uint32_t, CallData> callData_;
+};
+
+} /* namespace libcamera */
+
+#endif /* __LIBCAMERA_INTERNAL_IPA_IPC_UNIXSOCKET_H__ */
-- 
cgit v1.2.1