[libcamera-devel] [PATCH v4 30/37] libcamera: proxy: Remove IPAProxyLinux and IPAProxyThread
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Thu Nov 26 16:48:16 CET 2020
Hi Paul,
Thank you for the patch.
On Fri, Nov 06, 2020 at 07:37:00PM +0900, Paul Elder wrote:
> We have now changed the proxy from per-IPC mechanism to per-pipeline.
> The per-IPC mechanism proxies are thus no longer needed; remove them.
>
> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
> Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
>
> ---
> No change in v4
>
> No change in v3
>
> No change in v2
> ---
> src/libcamera/proxy/ipa_proxy_linux.cpp | 103 -----------
> src/libcamera/proxy/ipa_proxy_thread.cpp | 172 ------------------
> src/libcamera/proxy/meson.build | 5 -
> .../proxy/worker/ipa_proxy_linux_worker.cpp | 90 ---------
> src/libcamera/proxy/worker/meson.build | 4 -
With an additional change to drop the reference to
@TOP_SRCDIR@/src/libcamera/proxy/ in Documentation/Doxyfile.in,
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> 5 files changed, 374 deletions(-)
> delete mode 100644 src/libcamera/proxy/ipa_proxy_linux.cpp
> delete mode 100644 src/libcamera/proxy/ipa_proxy_thread.cpp
> delete mode 100644 src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp
>
> diff --git a/src/libcamera/proxy/ipa_proxy_linux.cpp b/src/libcamera/proxy/ipa_proxy_linux.cpp
> deleted file mode 100644
> index b78a0e45..00000000
> --- a/src/libcamera/proxy/ipa_proxy_linux.cpp
> +++ /dev/null
> @@ -1,103 +0,0 @@
> -/* SPDX-License-Identifier: LGPL-2.1-or-later */
> -/*
> - * Copyright (C) 2019, Google Inc.
> - *
> - * ipa_proxy_linux.cpp - Default Image Processing Algorithm proxy for Linux
> - */
> -
> -#include <vector>
> -
> -#include <libcamera/ipa/ipa_interface.h>
> -#include <libcamera/ipa/ipa_module_info.h>
> -
> -#include "libcamera/internal/ipa_module.h"
> -#include "libcamera/internal/ipa_proxy.h"
> -#include "libcamera/internal/ipc_unixsocket.h"
> -#include "libcamera/internal/log.h"
> -#include "libcamera/internal/process.h"
> -
> -namespace libcamera {
> -
> -LOG_DECLARE_CATEGORY(IPAProxy)
> -
> -class IPAProxyLinux : public IPAProxy
> -{
> -public:
> - IPAProxyLinux(IPAModule *ipam);
> - ~IPAProxyLinux();
> -
> - int init([[maybe_unused]] const IPASettings &settings) override
> - {
> - return 0;
> - }
> - int start() override { return 0; }
> - void stop() override {}
> - void configure([[maybe_unused]] const CameraSensorInfo &sensorInfo,
> - [[maybe_unused]] const std::map<unsigned int, IPAStream> &streamConfig,
> - [[maybe_unused]] const std::map<unsigned int, const ControlInfoMap &> &entityControls,
> - [[maybe_unused]] const IPAOperationData &ipaConfig,
> - [[maybe_unused]] IPAOperationData *result) override {}
> - void mapBuffers([[maybe_unused]] const std::vector<IPABuffer> &buffers) override {}
> - void unmapBuffers([[maybe_unused]] const std::vector<unsigned int> &ids) override {}
> - void processEvent([[maybe_unused]] const IPAOperationData &event) override {}
> -
> -private:
> - void readyRead(IPCUnixSocket *ipc);
> -
> - Process *proc_;
> -
> - IPCUnixSocket *socket_;
> -};
> -
> -IPAProxyLinux::IPAProxyLinux(IPAModule *ipam)
> - : IPAProxy(ipam), proc_(nullptr), socket_(nullptr)
> -{
> - LOG(IPAProxy, Debug)
> - << "initializing dummy proxy: loading IPA from "
> - << ipam->path();
> -
> - std::vector<int> fds;
> - std::vector<std::string> args;
> - args.push_back(ipam->path());
> - const std::string path = resolvePath("ipa_proxy_linux");
> - if (path.empty()) {
> - LOG(IPAProxy, Error)
> - << "Failed to get proxy worker path";
> - return;
> - }
> -
> - socket_ = new IPCUnixSocket();
> - int fd = socket_->create();
> - if (fd < 0) {
> - LOG(IPAProxy, Error)
> - << "Failed to create socket";
> - return;
> - }
> - socket_->readyRead.connect(this, &IPAProxyLinux::readyRead);
> - args.push_back(std::to_string(fd));
> - fds.push_back(fd);
> -
> - proc_ = new Process();
> - int ret = proc_->start(path, args, fds);
> - if (ret) {
> - LOG(IPAProxy, Error)
> - << "Failed to start proxy worker process";
> - return;
> - }
> -
> - valid_ = true;
> -}
> -
> -IPAProxyLinux::~IPAProxyLinux()
> -{
> - delete proc_;
> - delete socket_;
> -}
> -
> -void IPAProxyLinux::readyRead([[maybe_unused]] IPCUnixSocket *ipc)
> -{
> -}
> -
> -REGISTER_IPA_PROXY(IPAProxyLinux)
> -
> -} /* namespace libcamera */
> diff --git a/src/libcamera/proxy/ipa_proxy_thread.cpp b/src/libcamera/proxy/ipa_proxy_thread.cpp
> deleted file mode 100644
> index eead2883..00000000
> --- a/src/libcamera/proxy/ipa_proxy_thread.cpp
> +++ /dev/null
> @@ -1,172 +0,0 @@
> -/* SPDX-License-Identifier: LGPL-2.1-or-later */
> -/*
> - * Copyright (C) 2020, Google Inc.
> - *
> - * ipa_proxy_thread.cpp - Proxy running an Image Processing Algorithm in a thread
> - */
> -
> -#include <memory>
> -
> -#include <libcamera/ipa/ipa_interface.h>
> -#include <libcamera/ipa/ipa_module_info.h>
> -
> -#include "libcamera/internal/ipa_context_wrapper.h"
> -#include "libcamera/internal/ipa_module.h"
> -#include "libcamera/internal/ipa_proxy.h"
> -#include "libcamera/internal/log.h"
> -#include "libcamera/internal/thread.h"
> -
> -namespace libcamera {
> -
> -LOG_DECLARE_CATEGORY(IPAProxy)
> -
> -class IPAProxyThread : public IPAProxy, public Object
> -{
> -public:
> - IPAProxyThread(IPAModule *ipam);
> -
> - int init(const IPASettings &settings) override;
> - int start() override;
> - void stop() override;
> -
> - void configure(const CameraSensorInfo &sensorInfo,
> - const std::map<unsigned int, IPAStream> &streamConfig,
> - const std::map<unsigned int, const ControlInfoMap &> &entityControls,
> - const IPAOperationData &ipaConfig,
> - IPAOperationData *result) override;
> - void mapBuffers(const std::vector<IPABuffer> &buffers) override;
> - void unmapBuffers(const std::vector<unsigned int> &ids) override;
> - void processEvent(const IPAOperationData &event) override;
> -
> -private:
> - void queueFrameAction(unsigned int frame, const IPAOperationData &data);
> -
> - /* Helper class to invoke processEvent() in another thread. */
> - class ThreadProxy : public Object
> - {
> - public:
> - void setIPA(IPAInterface *ipa)
> - {
> - ipa_ = ipa;
> - }
> -
> - int start()
> - {
> - return ipa_->start();
> - }
> -
> - void stop()
> - {
> - ipa_->stop();
> - }
> -
> - void processEvent(const IPAOperationData &event)
> - {
> - ipa_->processEvent(event);
> - }
> -
> - private:
> - IPAInterface *ipa_;
> - };
> -
> - bool running_;
> - Thread thread_;
> - ThreadProxy proxy_;
> - std::unique_ptr<IPAInterface> ipa_;
> -};
> -
> -IPAProxyThread::IPAProxyThread(IPAModule *ipam)
> - : IPAProxy(ipam), running_(false)
> -{
> - if (!ipam->load())
> - return;
> -
> - struct ipa_context *ctx = ipam->createContext();
> - if (!ctx) {
> - LOG(IPAProxy, Error)
> - << "Failed to create IPA context for " << ipam->path();
> - return;
> - }
> -
> - ipa_ = std::make_unique<IPAContextWrapper>(ctx);
> - proxy_.setIPA(ipa_.get());
> -
> - /*
> - * Proxy the queueFrameAction signal to dispatch it in the caller's
> - * thread.
> - */
> - ipa_->queueFrameAction.connect(this, &IPAProxyThread::queueFrameAction);
> -
> - valid_ = true;
> -}
> -
> -int IPAProxyThread::init(const IPASettings &settings)
> -{
> - int ret = ipa_->init(settings);
> - if (ret)
> - return ret;
> -
> - proxy_.moveToThread(&thread_);
> -
> - return 0;
> -}
> -
> -int IPAProxyThread::start()
> -{
> - running_ = true;
> - thread_.start();
> -
> - return proxy_.invokeMethod(&ThreadProxy::start, ConnectionTypeBlocking);
> -}
> -
> -void IPAProxyThread::stop()
> -{
> - if (!running_)
> - return;
> -
> - running_ = false;
> -
> - proxy_.invokeMethod(&ThreadProxy::stop, ConnectionTypeBlocking);
> -
> - thread_.exit();
> - thread_.wait();
> -}
> -
> -void IPAProxyThread::configure(const CameraSensorInfo &sensorInfo,
> - const std::map<unsigned int, IPAStream> &streamConfig,
> - const std::map<unsigned int, const ControlInfoMap &> &entityControls,
> - const IPAOperationData &ipaConfig,
> - IPAOperationData *result)
> -{
> - ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig,
> - result);
> -}
> -
> -void IPAProxyThread::mapBuffers(const std::vector<IPABuffer> &buffers)
> -{
> - ipa_->mapBuffers(buffers);
> -}
> -
> -void IPAProxyThread::unmapBuffers(const std::vector<unsigned int> &ids)
> -{
> - ipa_->unmapBuffers(ids);
> -}
> -
> -void IPAProxyThread::processEvent(const IPAOperationData &event)
> -{
> - if (!running_)
> - return;
> -
> - /* Dispatch the processEvent() call to the thread. */
> - proxy_.invokeMethod(&ThreadProxy::processEvent, ConnectionTypeQueued,
> - event);
> -}
> -
> -void IPAProxyThread::queueFrameAction(unsigned int frame, const IPAOperationData &data)
> -{
> - IPAInterface::queueFrameAction.emit(frame, data);
> -}
> -
> -REGISTER_IPA_PROXY(IPAProxyThread)
> -
> -} /* namespace libcamera */
> diff --git a/src/libcamera/proxy/meson.build b/src/libcamera/proxy/meson.build
> index f27b453a..8ad78115 100644
> --- a/src/libcamera/proxy/meson.build
> +++ b/src/libcamera/proxy/meson.build
> @@ -1,10 +1,5 @@
> # SPDX-License-Identifier: CC0-1.0
>
> -libcamera_sources += files([
> - 'ipa_proxy_linux.cpp',
> - 'ipa_proxy_thread.cpp',
> -])
> -
> # generate ipa_proxy_{pipeline}.cpp
> foreach mojom : ipa_mojoms
> proxy = custom_target(mojom['name'] + '_proxy_cpp',
> diff --git a/src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp b/src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp
> deleted file mode 100644
> index 0c4687f7..00000000
> --- a/src/libcamera/proxy/worker/ipa_proxy_linux_worker.cpp
> +++ /dev/null
> @@ -1,90 +0,0 @@
> -/* SPDX-License-Identifier: LGPL-2.1-or-later */
> -/*
> - * Copyright (C) 2019, Google Inc.
> - *
> - * ipa_proxy_linux_worker.cpp - Default Image Processing Algorithm proxy worker for Linux
> - */
> -
> -#include <iostream>
> -#include <sys/types.h>
> -#include <unistd.h>
> -
> -#include <libcamera/event_dispatcher.h>
> -#include <libcamera/ipa/ipa_interface.h>
> -#include <libcamera/logging.h>
> -
> -#include "libcamera/internal/ipa_module.h"
> -#include "libcamera/internal/ipc_unixsocket.h"
> -#include "libcamera/internal/log.h"
> -#include "libcamera/internal/thread.h"
> -
> -using namespace libcamera;
> -
> -LOG_DEFINE_CATEGORY(IPAProxyLinuxWorker)
> -
> -void readyRead(IPCUnixSocket *ipc)
> -{
> - IPCUnixSocket::Payload message;
> - int ret;
> -
> - ret = ipc->receive(&message);
> - if (ret) {
> - LOG(IPAProxyLinuxWorker, Error)
> - << "Receive message failed: " << ret;
> - return;
> - }
> -
> - LOG(IPAProxyLinuxWorker, Debug) << "Received a message!";
> -}
> -
> -int main(int argc, char **argv)
> -{
> - /* Uncomment this for debugging. */
> -#if 0
> - std::string logPath = "/tmp/libcamera.worker." +
> - std::to_string(getpid()) + ".log";
> - logSetFile(logPath.c_str());
> -#endif
> -
> - if (argc < 3) {
> - LOG(IPAProxyLinuxWorker, Debug)
> - << "Tried to start worker with no args";
> - return EXIT_FAILURE;
> - }
> -
> - int fd = std::stoi(argv[2]);
> - LOG(IPAProxyLinuxWorker, Debug)
> - << "Starting worker for IPA module " << argv[1]
> - << " with IPC fd = " << fd;
> -
> - std::unique_ptr<IPAModule> ipam = std::make_unique<IPAModule>(argv[1]);
> - if (!ipam->isValid() || !ipam->load()) {
> - LOG(IPAProxyLinuxWorker, Error)
> - << "IPAModule " << argv[1] << " should be valid but isn't";
> - return EXIT_FAILURE;
> - }
> -
> - IPCUnixSocket socket;
> - if (socket.bind(fd) < 0) {
> - LOG(IPAProxyLinuxWorker, Error) << "IPC socket binding failed";
> - return EXIT_FAILURE;
> - }
> - socket.readyRead.connect(&readyRead);
> -
> - struct ipa_context *ipac = ipam->createContext();
> - if (!ipac) {
> - LOG(IPAProxyLinuxWorker, Error) << "Failed to create IPA context";
> - return EXIT_FAILURE;
> - }
> -
> - LOG(IPAProxyLinuxWorker, Debug) << "Proxy worker successfully started";
> -
> - /* \todo upgrade listening loop */
> - EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
> - while (1)
> - dispatcher->processEvents();
> -
> - ipac->ops->destroy(ipac);
> -
> - return 0;
> -}
> diff --git a/src/libcamera/proxy/worker/meson.build b/src/libcamera/proxy/worker/meson.build
> index 628bb050..74aca795 100644
> --- a/src/libcamera/proxy/worker/meson.build
> +++ b/src/libcamera/proxy/worker/meson.build
> @@ -1,9 +1,5 @@
> # SPDX-License-Identifier: CC0-1.0
>
> -ipa_proxy_sources = [
> - ['ipa_proxy_linux', 'ipa_proxy_linux_worker.cpp']
> -]
> -
> proxy_install_dir = join_paths(get_option('libexecdir'), 'libcamera')
>
> # generate ipa_proxy_{pipeline}_worker.cpp
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list