From patchwork Fri Jul 23 04:00:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13092 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 7476FC322C for ; Fri, 23 Jul 2021 04:00:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1012A687C0; Fri, 23 Jul 2021 06:00:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pJwx6V/8"; dkim-atps=neutral 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 01E166877A for ; Fri, 23 Jul 2021 06:00:45 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 99F8F255 for ; Fri, 23 Jul 2021 06:00:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627012844; bh=hZHmJc1F8VeVoHYny0nzxnMLTmz4eq976ToNO+jehXQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pJwx6V/8cfvRrwc3V1ef2d9CDTtRnf1owUljqpvNKNEGsn8gs7LSFAkOvVBeNwcqc DcPKyre27BJVbREzfeRXu0AS2kS69y56dGoniywI3om6pxDwEOCT48706iKmnP5cWE T5S+WFeCx4WKRm3LfwdixtrKiOoV+HnhFdWA8xb8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 23 Jul 2021 07:00:25 +0300 Message-Id: <20210723040036.32346-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723040036.32346-1-laurent.pinchart@ideasonboard.com> References: <20210723040036.32346-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 06/17] libcamera: camera: Move Camera::Private to header file 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The Camera::Private class is defined in camera.cpp. To prepare for allowing it to be subclassed by pipeline handlers, move it to a new internal/camera.h header. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- include/libcamera/internal/camera.h | 63 ++++++++++++++++++++++++++ include/libcamera/internal/meson.build | 1 + src/libcamera/camera.cpp | 40 +--------------- 3 files changed, 66 insertions(+), 38 deletions(-) create mode 100644 include/libcamera/internal/camera.h diff --git a/include/libcamera/internal/camera.h b/include/libcamera/internal/camera.h new file mode 100644 index 000000000000..9ef5d8ae98a6 --- /dev/null +++ b/include/libcamera/internal/camera.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Google Inc. + * + * camera.h - Camera private data + */ +#ifndef __LIBCAMERA_INTERNAL_CAMERA_H__ +#define __LIBCAMERA_INTERNAL_CAMERA_H__ + +#include +#include +#include +#include + +#include + +#include + +namespace libcamera { + +class PipelineHandler; +class Stream; + +class Camera::Private : public Extensible::Private +{ + LIBCAMERA_DECLARE_PUBLIC(Camera) + +public: + enum State { + CameraAvailable, + CameraAcquired, + CameraConfigured, + CameraStopping, + CameraRunning, + }; + + Private(PipelineHandler *pipe, const std::string &id, + const std::set &streams); + ~Private(); + + bool isRunning() const; + int isAccessAllowed(State state, bool allowDisconnected = false, + const char *from = __builtin_FUNCTION()) const; + int isAccessAllowed(State low, State high, + bool allowDisconnected = false, + const char *from = __builtin_FUNCTION()) const; + + void disconnect(); + void setState(State state); + + std::shared_ptr pipe_; + std::string id_; + std::set streams_; + std::set activeStreams_; + +private: + bool disconnected_; + std::atomic state_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_INTERNAL_CAMERA_H__ */ diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index 6d4eb7ed3df6..dac1a2d36fa8 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -12,6 +12,7 @@ libcamera_tracepoint_header = custom_target( libcamera_internal_headers = files([ 'bayer_format.h', 'byte_stream_buffer.h', + 'camera.h', 'camera_controls.h', 'camera_sensor.h', 'camera_sensor_properties.h', diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index c126b49290ce..4b5bc891fc37 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -18,10 +18,11 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/pipeline_handler.h" /** - * \file camera.h + * \file libcamera/camera.h * \brief Camera device handling * * \page camera-model Camera Model @@ -331,43 +332,6 @@ std::size_t CameraConfiguration::size() const * \brief The vector of stream configurations */ -class Camera::Private : public Extensible::Private -{ - LIBCAMERA_DECLARE_PUBLIC(Camera) - -public: - enum State { - CameraAvailable, - CameraAcquired, - CameraConfigured, - CameraStopping, - CameraRunning, - }; - - Private(PipelineHandler *pipe, const std::string &id, - const std::set &streams); - ~Private(); - - bool isRunning() const; - int isAccessAllowed(State state, bool allowDisconnected = false, - const char *from = __builtin_FUNCTION()) const; - int isAccessAllowed(State low, State high, - bool allowDisconnected = false, - const char *from = __builtin_FUNCTION()) const; - - void disconnect(); - void setState(State state); - - std::shared_ptr pipe_; - std::string id_; - std::set streams_; - std::set activeStreams_; - -private: - bool disconnected_; - std::atomic state_; -}; - Camera::Private::Private(PipelineHandler *pipe, const std::string &id, const std::set &streams)