From patchwork Thu Jun 15 17:26:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 18739 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 B6295C322E for ; Thu, 15 Jun 2023 17:26:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9AE82628C5; Thu, 15 Jun 2023 19:26:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1686849979; bh=ILfgxCfABmcZN1IjyphsLSa4qnildleu7G4z01OhYdk=; 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=ngmUa0p6RBRcCNzMgJaE4jt3bsjHjmXc4m7W16Viu0K9pZIEXxmhJZeyVUNYmFTBS nMG1LUUdCid/8DSo7L0g1PA9cBPrI8GTTq4gAWPS+WyDZZXe+u5AU/Y7ErlKK9JcnI Gab5G5YVpXdp5SC8mcobkuzxkPLqQKPbT/GG8KTBhn5fvKUYIyJKcc14qOkP9nP6T3 yljvS597ktbz+JPtCz/3tedz8KtdInaj1UCHORVKhg1S042QdS5uMA4EX6N0a+kdv+ KejJd6AYiS05AyhWVOy8g40G3l2yZD7ZY7ruoWePHqhwxCw90LhIvEgsEJ4NF1MC6t 6Mubcw6itwCag== 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 4C34D61E4F for ; Thu, 15 Jun 2023 19:26:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="q6+ZvJ4v"; 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 A5ABF547; Thu, 15 Jun 2023 19:25:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1686849944; bh=ILfgxCfABmcZN1IjyphsLSa4qnildleu7G4z01OhYdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q6+ZvJ4vLcRwlLbmBqDQSK1zS3G4g4UcmaHob/KYJmgsnKVYolhSi8OG7mz3E6xQ8 w4CX/1pcYXArNZ2L2B6qh/HtQ0jKA3giVjY/pvO/nFQL4YE1SS3vktRFC5i1MZ8VPp AMfteKKc6dvElZzXYSysatwEXCdI+4mol8HRLr3Y= To: libcamera devel Date: Thu, 15 Jun 2023 18:26:05 +0100 Message-Id: <20230615172608.378258-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230615172608.378258-1-kieran.bingham@ideasonboard.com> References: <20230615172608.378258-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 2/5] 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: Jacopo Mondi , Ashok Sidipotu 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 CameraManager. Reviewed-by: Jacopo Mondi Tested-by: Ashok Sidipotu Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v4 - Fix includes - Fix sort order of header in meson.build - Fix doxygen file references Signed-off-by: Kieran Bingham --- include/libcamera/internal/camera_manager.h | 70 +++++++++++++++++++++ include/libcamera/internal/meson.build | 1 + src/libcamera/camera_manager.cpp | 59 +++-------------- 3 files changed, 80 insertions(+), 50 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..96a83bd7ef3c --- /dev/null +++ b/include/libcamera/internal/camera_manager.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Ideas on Board Oy. + * + * camera_manager.h - Camera manager private data + */ + +#pragma once + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/ipa_manager.h" +#include "libcamera/internal/process.h" + +namespace libcamera { + +class 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_; +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index d75088059996..4b2756a4a251 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -15,6 +15,7 @@ libcamera_internal_headers = files([ 'camera.h', 'camera_controls.h', 'camera_lens.h', + 'camera_manager.h', 'camera_sensor.h', 'camera_sensor_properties.h', 'control_serializer.h', diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index c1edefdad160..882b2d4b234c 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -5,27 +5,26 @@ * camera_manager.h - Camera management */ -#include - -#include - -#include +#include "libcamera/internal/camera_manager.h" #include -#include -#include #include +#include + #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 */ +/** + * \file libcamera/internal/camera_manager.h + * \brief Internal camera manager support + */ + /** * \brief Top-level libcamera namespace */ @@ -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) {