From patchwork Thu May 11 22:48:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 18614 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 7D0B4BD16B for ; Thu, 11 May 2023 22:48:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 00060633BA; Fri, 12 May 2023 00:48:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1683845318; bh=PO+khrgkmgH0MRjDkkq/NgIqzlUH7vj7fUnEUdV3wik=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=SdVM3q2hLOSA7EP7JLYFYFjJYtaPWIgU/ywKHt2Az2LKchPwCRvugfiNCH1dewc2l 49Nme9oDTOAmV9FUJCqequaKvbQQN78LMHuUgJIKQKfKp6jizdfeRM+Cds+7NLMRAa PRf9u+8JfTbzyoZtlFTuzI65cXTp4yZeOmi6xB3dxiclRaLx058MbLznplytsrvHfd uQCNmP2JBYmjP7FQce6AOCuMZyCf5X/519/thH532acFcExLxn3dDoLB3fSMND+oF9 npIlsMQ/fX5lmu11v0C8P3TYIRQ7vS4ggid8ikSQoADStBwQTSCpqgIM2y9Qwv9xmh BG24ilOlD1VhA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5AA466039E for ; Fri, 12 May 2023 00:48:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="W5muiTFY"; dkim-atps=neutral Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B17DC132F; Fri, 12 May 2023 00:48:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1683845307; bh=PO+khrgkmgH0MRjDkkq/NgIqzlUH7vj7fUnEUdV3wik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W5muiTFYBtu4/EjyrEz8OQVd5ZlpHK1xGg8MJty4cZoHRWcddJXbUwnnSBcDKk7Qk Yy6nQGvmVwl9EJXi6O0dgf0EIFp7U6kIeSPOgB2Q3h7T+leOs0ULr7VDbvLRgz7N3m qzatWmy3OVo0gT5hMrqatflqkD6XqyS9lYCb7fK0= To: libcamera devel Date: Thu, 11 May 2023 23:48:24 +0100 Message-Id: <20230511224830.356416-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230511224830.356416-1-kieran.bingham@ideasonboard.com> References: <20230511224830.356416-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/4] libcamera: camera_manager: Move private implementation to internal 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: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Cc: George Kiagiadakis , Robert Mader , Wim Taymans Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The CameraManager makes use of the Extensible pattern to provide an internal private implementation that is not exposed in the public API. Move the Private declaration to an internal header to make it available from other internal components in preperation for reducing the surface area of the public interface of the Camera Manager. Signed-off-by: Kieran Bingham --- include/libcamera/internal/camera_manager.h | 66 +++++++++++++++++++++ include/libcamera/internal/meson.build | 1 + src/libcamera/camera_manager.cpp | 49 ++------------- 3 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 include/libcamera/internal/camera_manager.h diff --git a/include/libcamera/internal/camera_manager.h b/include/libcamera/internal/camera_manager.h new file mode 100644 index 000000000000..4bba3ac2eb29 --- /dev/null +++ b/include/libcamera/internal/camera_manager.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Ideas on Board Oy. + * + * camera_manager.h - Camera manager private data + */ +#ifndef __LIBCAMERA_INTERNAL_CAMERA_MANAGER_H__ +#define __LIBCAMERA_INTERNAL_CAMERA_MANAGER_H__ + +#include + +#include +#include + +#include + +#include "libcamera/internal/ipa_manager.h" +#include "libcamera/internal/process.h" + +namespace libcamera { + +class DeviceEnumerator; + +class CameraManager::Private : public Extensible::Private, public Thread +{ + LIBCAMERA_DECLARE_PUBLIC(CameraManager) + +public: + Private(); + + int start(); + void addCamera(std::shared_ptr camera, + const std::vector &devnums) LIBCAMERA_TSA_EXCLUDES(mutex_); + void removeCamera(Camera *camera) LIBCAMERA_TSA_EXCLUDES(mutex_); + + /* + * This mutex protects + * + * - initialized_ and status_ during initialization + * - cameras_ and camerasByDevnum_ after initialization + */ + mutable Mutex mutex_; + std::vector> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_); + std::map> camerasByDevnum_ LIBCAMERA_TSA_GUARDED_BY(mutex_); + +protected: + void run() override; + +private: + int init(); + void createPipelineHandlers(); + void cleanup() LIBCAMERA_TSA_EXCLUDES(mutex_); + + ConditionVariable cv_; + bool initialized_ LIBCAMERA_TSA_GUARDED_BY(mutex_); + int status_ LIBCAMERA_TSA_GUARDED_BY(mutex_); + + std::unique_ptr enumerator_; + + IPAManager ipaManager_; + ProcessManager processManager_; +}; + +} /* namespace libcamera */ + +#endif // __LIBCAMERA_INTERNAL_CAMERA_MANAGER_H__ diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index d75088059996..0028ed0dc27f 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -13,6 +13,7 @@ libcamera_internal_headers = files([ 'bayer_format.h', 'byte_stream_buffer.h', 'camera.h', + 'camera_manager.h', 'camera_controls.h', 'camera_lens.h', 'camera_sensor.h', diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index c1edefdad160..b95284ba5a80 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -9,20 +9,19 @@ #include -#include - #include #include #include #include +#include + +#include "libcamera/internal/camera_manager.h" #include "libcamera/internal/device_enumerator.h" -#include "libcamera/internal/ipa_manager.h" #include "libcamera/internal/pipeline_handler.h" -#include "libcamera/internal/process.h" /** - * \file camera_manager.h + * \file libcamera/camera_manager.h * \brief The camera manager */ @@ -33,46 +32,6 @@ namespace libcamera { LOG_DEFINE_CATEGORY(Camera) -class CameraManager::Private : public Extensible::Private, public Thread -{ - LIBCAMERA_DECLARE_PUBLIC(CameraManager) - -public: - Private(); - - int start(); - void addCamera(std::shared_ptr camera, - const std::vector &devnums) LIBCAMERA_TSA_EXCLUDES(mutex_); - void removeCamera(Camera *camera) LIBCAMERA_TSA_EXCLUDES(mutex_); - - /* - * This mutex protects - * - * - initialized_ and status_ during initialization - * - cameras_ and camerasByDevnum_ after initialization - */ - mutable Mutex mutex_; - std::vector> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_); - std::map> camerasByDevnum_ LIBCAMERA_TSA_GUARDED_BY(mutex_); - -protected: - void run() override; - -private: - int init(); - void createPipelineHandlers(); - void cleanup() LIBCAMERA_TSA_EXCLUDES(mutex_); - - ConditionVariable cv_; - bool initialized_ LIBCAMERA_TSA_GUARDED_BY(mutex_); - int status_ LIBCAMERA_TSA_GUARDED_BY(mutex_); - - std::unique_ptr enumerator_; - - IPAManager ipaManager_; - ProcessManager processManager_; -}; - CameraManager::Private::Private() : initialized_(false) {