From patchwork Wed Aug 11 23:26:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13309 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 F0259BD87D for ; Wed, 11 Aug 2021 23:26:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BCFBE68864; Thu, 12 Aug 2021 01:26:35 +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="N4wFZPAW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 31BCF687F0 for ; Thu, 12 Aug 2021 01:26:33 +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 C76A4268 for ; Thu, 12 Aug 2021 01:26:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724393; bh=H2u5dhstkCecZM9hLjgVY+1bubA1b/nvotS1plmbePs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=N4wFZPAWivV3CGVhGcE2oVgODg7pFmqMcHtyqcB47tY4vHf2+A45Iz/ufiHrw22ec sH5Erv8gz8MZFZ7dKY4Tw7SVmXraWiX5yGCj69uBe3tOr/HYPiOHZNSk5+R68Q62vS 3HjyaIWRradmzFDvYluVNe9CqfM68EzS3lsLIYA4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:12 +0300 Message-Id: <20210811232625.17280-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 01/14] libcamera: base: extensible: Pass private pointer as unique_ptr<> 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 Extensible constructor takes a pointer to a Private instance, whose lifetime it then manages. Make this explicit in the API by passing the pointer as a std::unique_ptr. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- include/libcamera/base/class.h | 2 +- src/android/camera_buffer.h | 2 +- src/android/camera_hal_config.cpp | 2 +- src/libcamera/base/class.cpp | 11 +++++++++-- src/libcamera/camera.cpp | 2 +- src/libcamera/camera_manager.cpp | 2 +- src/libcamera/framebuffer.cpp | 3 ++- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/libcamera/base/class.h b/include/libcamera/base/class.h index a5946836d2b9..9a82d61472c1 100644 --- a/include/libcamera/base/class.h +++ b/include/libcamera/base/class.h @@ -87,7 +87,7 @@ public: Extensible *const o_; }; - Extensible(Private *d); + Extensible(std::unique_ptr d); protected: template diff --git a/src/android/camera_buffer.h b/src/android/camera_buffer.h index 21373fa25bf8..c4e3a9e7b912 100644 --- a/src/android/camera_buffer.h +++ b/src/android/camera_buffer.h @@ -32,7 +32,7 @@ public: #define PUBLIC_CAMERA_BUFFER_IMPLEMENTATION \ CameraBuffer::CameraBuffer(buffer_handle_t camera3Buffer, int flags) \ - : Extensible(new Private(this, camera3Buffer, flags)) \ + : Extensible(std::make_unique(this, camera3Buffer, flags)) \ { \ } \ CameraBuffer::~CameraBuffer() \ diff --git a/src/android/camera_hal_config.cpp b/src/android/camera_hal_config.cpp index 14549083a97a..aa90dac78075 100644 --- a/src/android/camera_hal_config.cpp +++ b/src/android/camera_hal_config.cpp @@ -341,7 +341,7 @@ int CameraHalConfig::Private::parseConfigFile(FILE *fh, } CameraHalConfig::CameraHalConfig() - : Extensible(new Private()), exists_(false), valid_(false) + : Extensible(std::make_unique()), exists_(false), valid_(false) { parseConfigurationFile(); } diff --git a/src/libcamera/base/class.cpp b/src/libcamera/base/class.cpp index d24043c20e55..9c2d9f218bd4 100644 --- a/src/libcamera/base/class.cpp +++ b/src/libcamera/base/class.cpp @@ -147,9 +147,12 @@ namespace libcamera { /** * \brief Construct an instance of an Extensible class * \param[in] d Pointer to the private data instance + * + * The private data lifetime is managed by the Extensible class, which destroys + * it when the Extensible instance is destroyed. */ -Extensible::Extensible(Extensible::Private *d) - : d_(d) +Extensible::Extensible(std::unique_ptr d) + : d_(std::move(d)) { *const_cast(&d_->o_) = this; } @@ -163,6 +166,10 @@ Extensible::Extensible(Extensible::Private *d) * overriden _d() functions that return the correct pointer type to the * corresponding derived Private class. * + * The lifetime of the private data is tied to the Extensible class. The caller + * shall not retain any reference to the returned pointer for longer than it + * holds a reference to the Extensible instance. + * * \return A pointer to the private data instance */ diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 6281e92057e4..8e99e2a96eaf 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -596,7 +596,7 @@ const std::string &Camera::id() const Camera::Camera(PipelineHandler *pipe, const std::string &id, const std::set &streams) - : Extensible(new Private(pipe, id, streams)) + : Extensible(std::make_unique(pipe, id, streams)) { } diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index 893aa6067171..fe80a46f5d20 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -258,7 +258,7 @@ void CameraManager::Private::removeCamera(Camera *camera) CameraManager *CameraManager::self_ = nullptr; CameraManager::CameraManager() - : Extensible(new CameraManager::Private()) + : Extensible(std::make_unique()) { if (self_) LOG(Camera, Fatal) diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index 42c73134152b..b401c50efd53 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -181,7 +181,8 @@ FrameBuffer::Private::Private() * \param[in] cookie Cookie */ FrameBuffer::FrameBuffer(const std::vector &planes, unsigned int cookie) - : Extensible(new Private()), planes_(planes), cookie_(cookie) + : Extensible(std::make_unique()), planes_(planes), + cookie_(cookie) { } From patchwork Wed Aug 11 23:26:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13310 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 12454BD87D for ; Wed, 11 Aug 2021 23:26:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 51C2E687F0; Thu, 12 Aug 2021 01:26:36 +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="BV/G5Uzy"; 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 80E1E687F0 for ; Thu, 12 Aug 2021 01:26:33 +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 2A3CFEE for ; Thu, 12 Aug 2021 01:26:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724393; bh=FNA7O1Up6D8gnz+bVhpqHIknbRwrfyHk+wKLeMh8T4I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BV/G5UzyzPARHaaGBwv5LxVsEIzirxlA4chDzHrcXP8GvBeTj1weOr48aVcXpT/Uz sChKuUEfn/Xg26AkjiT5xT0U0DDm2/Au9unLEcAIzk2q5RIZu59Fp0khLKWAhB00wm Twc02ZyR0t+xrW/+vMQTO6NL7I4JY9VeifQWNvo4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:13 +0300 Message-Id: <20210811232625.17280-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 02/14] libcamera: camera: Pass Private pointer to Camera constructor 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" In order to allow subclassing Camera::Private in pipeline handlers, pass the pointer to the private data to the Camera constructor, and to the Camera::createCamera() function. The Camera::Private id_ and streams_ members now need to be initialized by the Camera constructor instead of the Camera::Private constructor, to allow storage of the streams in a pipeline handler-specific subclass of Camera::Private. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- include/libcamera/camera.h | 4 +-- include/libcamera/internal/camera.h | 3 +-- src/libcamera/camera.cpp | 26 ++++++++++++------- src/libcamera/pipeline/ipu3/ipu3.cpp | 4 ++- .../pipeline/raspberrypi/raspberrypi.cpp | 4 ++- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 ++- src/libcamera/pipeline/simple/simple.cpp | 4 ++- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 5 +++- src/libcamera/pipeline/vimc/vimc.cpp | 4 ++- 9 files changed, 38 insertions(+), 20 deletions(-) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index b081907e0cb1..05cdab724b10 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -78,7 +78,7 @@ class Camera final : public Object, public std::enable_shared_from_this, LIBCAMERA_DECLARE_PRIVATE() public: - static std::shared_ptr create(PipelineHandler *pipe, + static std::shared_ptr create(std::unique_ptr d, const std::string &id, const std::set &streams); @@ -107,7 +107,7 @@ public: private: LIBCAMERA_DISABLE_COPY(Camera) - Camera(PipelineHandler *pipe, const std::string &id, + Camera(std::unique_ptr d, const std::string &id, const std::set &streams); ~Camera(); diff --git a/include/libcamera/internal/camera.h b/include/libcamera/internal/camera.h index b60ed140356a..9ec8321a9a21 100644 --- a/include/libcamera/internal/camera.h +++ b/include/libcamera/internal/camera.h @@ -26,8 +26,7 @@ class Camera::Private : public Extensible::Private LIBCAMERA_DECLARE_PUBLIC(Camera) public: - Private(PipelineHandler *pipe, const std::string &id, - const std::set &streams); + Private(PipelineHandler *pipe); ~Private(); private: diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 8e99e2a96eaf..d9f6b784e0dc 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -332,11 +332,13 @@ std::size_t CameraConfiguration::size() const * \brief The vector of stream configurations */ -Camera::Private::Private(PipelineHandler *pipe, - const std::string &id, - const std::set &streams) - : pipe_(pipe->shared_from_this()), id_(id), streams_(streams), - disconnected_(false), state_(CameraAvailable) +/** + * \brief Construct a Camera::Private instance + * \param[in] pipe The pipeline handler responsible for the camera device + */ +Camera::Private::Private(PipelineHandler *pipe) + : pipe_(pipe->shared_from_this()), disconnected_(false), + state_(CameraAvailable) { } @@ -513,7 +515,7 @@ void Camera::Private::setState(State state) /** * \brief Create a camera instance - * \param[in] pipe The pipeline handler responsible for the camera device + * \param[in] d Camera private data * \param[in] id The ID of the camera device * \param[in] streams Array of streams the camera provides * @@ -527,10 +529,12 @@ void Camera::Private::setState(State state) * * \return A shared pointer to the newly created camera object */ -std::shared_ptr Camera::create(PipelineHandler *pipe, +std::shared_ptr Camera::create(std::unique_ptr d, const std::string &id, const std::set &streams) { + ASSERT(d); + struct Deleter : std::default_delete { void operator()(Camera *camera) { @@ -541,7 +545,7 @@ std::shared_ptr Camera::create(PipelineHandler *pipe, } }; - Camera *camera = new Camera(pipe, id, streams); + Camera *camera = new Camera(std::move(d), id, streams); return std::shared_ptr(camera, Deleter()); } @@ -594,10 +598,12 @@ const std::string &Camera::id() const * application API calls by returning errors immediately. */ -Camera::Camera(PipelineHandler *pipe, const std::string &id, +Camera::Camera(std::unique_ptr d, const std::string &id, const std::set &streams) - : Extensible(std::make_unique(pipe, id, streams)) + : Extensible(std::move(d)) { + _d()->id_ = id; + _d()->streams_ = streams; } Camera::~Camera() diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 19cb5c4ec9c3..b9c0941c5ea8 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -23,6 +23,7 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" @@ -1199,7 +1200,8 @@ int PipelineHandlerIPU3::registerCameras() /* Create and register the Camera instance. */ std::string cameraId = cio2->sensor()->id(); std::shared_ptr camera = - Camera::create(this, cameraId, streams); + Camera::create(std::make_unique(this), + cameraId, streams); registerCamera(std::move(camera), std::move(data)); diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 2e8774ae360d..91e906ef14ce 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -29,6 +29,7 @@ #include #include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/camera.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" @@ -1105,7 +1106,8 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) /* Create and register the camera. */ std::shared_ptr camera = - Camera::create(this, data->sensor_->id(), streams); + Camera::create(std::make_unique(this), + data->sensor_->id(), streams); registerCamera(std::move(camera), std::move(data)); return true; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 42911a8fdfdb..c2872289337b 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -27,6 +27,7 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" @@ -970,7 +971,8 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) &data->selfPathStream_, }; std::shared_ptr camera = - Camera::create(this, data->sensor_->id(), streams); + Camera::create(std::make_unique(this), + data->sensor_->id(), streams); registerCamera(std::move(camera), std::move(data)); return 0; diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index b29fff9820e5..ad581969fca1 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -28,6 +28,7 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/media_device.h" @@ -1046,7 +1047,8 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) [](Stream &stream) { return &stream; }); std::shared_ptr camera = - Camera::create(this, data->sensor_->id(), streams); + Camera::create(std::make_unique(this), + data->sensor_->id(), streams); registerCamera(std::move(camera), std::move(data)); registered = true; } diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 0f634b8da609..a9b6af4b5bdf 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -22,6 +22,7 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" @@ -470,7 +471,9 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) } std::set streams{ &data->stream_ }; - std::shared_ptr camera = Camera::create(this, id, streams); + std::shared_ptr camera = + Camera::create(std::make_unique(this), id, + streams); registerCamera(std::move(camera), std::move(data)); /* Enable hot-unplug notifications. */ diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 12f7517fd0ae..999d975716fa 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -29,6 +29,7 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/ipa_manager.h" @@ -438,7 +439,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) /* Create and register the camera. */ std::set streams{ &data->stream_ }; std::shared_ptr camera = - Camera::create(this, data->sensor_->id(), streams); + Camera::create(std::make_unique(this), + data->sensor_->id(), streams); registerCamera(std::move(camera), std::move(data)); return true; From patchwork Wed Aug 11 23:26:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13311 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 D230FBD87D for ; Wed, 11 Aug 2021 23:26:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7461968887; Thu, 12 Aug 2021 01:26:42 +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="PvVyRGua"; 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 CEFE0687F0 for ; Thu, 12 Aug 2021 01:26:33 +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 78EB2268 for ; Thu, 12 Aug 2021 01:26:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724393; bh=p0vPqWAF8VvJseCOi1oxT1WEpxkDb5n04tMRGELGIOw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PvVyRGuanq8RMOsbezkm8SNNFX2CxlEbj0QoprE6qK6WcaO+MU/3c+6hSJK41wlSi m4fCWQ3conO+Q9PVyly9yx2EGe2T+mjGtz0a6KntQ3jpoB0MTCyBKhUhGktfvfSOcr aJI4MVcXW006KOXnxQJnzJTdDRn44W+QncPBmLi4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:14 +0300 Message-Id: <20210811232625.17280-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 03/14] libcamera: pipeline_handler: Move CameraData members to Camera::Private 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" With pipeline handlers now being able to subclass Camera::Private, start the migration from CameraData to Camera::Private by moving the members of the base CameraData class. The controlInfo_, properties_ and pipe_ members are duplicated for now, to allow migrating pipeline handlers one by one. The Camera::Private class is now properly documented, don't exclude it from documentation generation. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- Changes since v2: - Include where appropriate - Minor documentation update Changes since v1: - Add \todo comment for controlInfo_ --- Documentation/Doxyfile.in | 1 - include/libcamera/internal/camera.h | 9 +++ include/libcamera/internal/pipeline_handler.h | 6 +- src/libcamera/camera.cpp | 65 ++++++++++++++++++- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +- src/libcamera/pipeline_handler.cpp | 45 +++++-------- 6 files changed, 89 insertions(+), 39 deletions(-) diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in index fb321ad25f6f..e3b77428cd4f 100644 --- a/Documentation/Doxyfile.in +++ b/Documentation/Doxyfile.in @@ -882,7 +882,6 @@ EXCLUDE_SYMBOLS = libcamera::BoundMethodArgs \ libcamera::BoundMethodPack \ libcamera::BoundMethodPackBase \ libcamera::BoundMethodStatic \ - libcamera::Camera::Private \ libcamera::CameraManager::Private \ libcamera::SignalBase \ *::details \ diff --git a/include/libcamera/internal/camera.h b/include/libcamera/internal/camera.h index 9ec8321a9a21..1a08da0cedc4 100644 --- a/include/libcamera/internal/camera.h +++ b/include/libcamera/internal/camera.h @@ -8,6 +8,7 @@ #define __LIBCAMERA_INTERNAL_CAMERA_H__ #include +#include #include #include #include @@ -29,6 +30,14 @@ public: Private(PipelineHandler *pipe); ~Private(); + PipelineHandler *pipe() { return pipe_.get(); } + + std::list queuedRequests_; + ControlInfoMap controlInfo_; + ControlList properties_; + + uint32_t requestSequence_; + private: enum State { CameraAvailable, diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 9e2d65d6f2c5..24b0c5ca081c 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -7,7 +7,6 @@ #ifndef __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__ #define __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__ -#include #include #include #include @@ -39,18 +38,15 @@ class CameraData { public: explicit CameraData(PipelineHandler *pipe) - : pipe_(pipe), requestSequence_(0) + : pipe_(pipe) { } virtual ~CameraData() = default; PipelineHandler *pipe_; - std::list queuedRequests_; ControlInfoMap controlInfo_; ControlList properties_; - uint32_t requestSequence_; - private: LIBCAMERA_DISABLE_COPY(CameraData) }; diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index d9f6b784e0dc..4080da151af1 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -332,13 +332,25 @@ std::size_t CameraConfiguration::size() const * \brief The vector of stream configurations */ +/** + * \class Camera::Private + * \brief Base class for camera private data + * + * The Camera::Private class stores all private data associated with a camera. + * In addition to hiding core Camera data from the public API, it is expected to + * be subclassed by pipeline handlers to store pipeline-specific data. + * + * Pipeline handlers can obtain the Camera::Private instance associated with a + * camera by calling Camera::_d(). + */ + /** * \brief Construct a Camera::Private instance * \param[in] pipe The pipeline handler responsible for the camera device */ Camera::Private::Private(PipelineHandler *pipe) - : pipe_(pipe->shared_from_this()), disconnected_(false), - state_(CameraAvailable) + : requestSequence_(0), pipe_(pipe->shared_from_this()), + disconnected_(false), state_(CameraAvailable) { } @@ -348,6 +360,55 @@ Camera::Private::~Private() LOG(Camera, Error) << "Removing camera while still in use"; } +/** + * \fn Camera::Private::pipe() + * \brief Retrieve the pipeline handler related to this camera + * \return The pipeline handler that created this camera + */ + +/** + * \var Camera::Private::queuedRequests_ + * \brief The list of queued and not yet completed request + * + * The list of queued request is used to track requests queued in order to + * ensure completion of all requests when the pipeline handler is stopped. + * + * \sa PipelineHandler::queueRequest(), PipelineHandler::stop(), + * PipelineHandler::completeRequest() + */ + +/** + * \var Camera::Private::controlInfo_ + * \brief The set of controls supported by the camera + * + * The control information shall be initialised by the pipeline handler when + * creating the camera. + * + * \todo This member was initially meant to stay constant after the camera is + * created. Several pipeline handlers are already updating it when the camera + * is configured. Update the documentation accordingly, and possibly the API as + * well, when implementing official support for control info updates. + */ + +/** + * \var Camera::Private::properties_ + * \brief The list of properties supported by the camera + * + * The list of camera properties shall be initialised by the pipeline handler + * when creating the camera, and shall not be modified afterwards. + */ + +/** + * \var Camera::Private::requestSequence_ + * \brief The queuing sequence of the request + * + * When requests are queued, they are given a per-camera sequence number to + * facilitate debugging of internal request usage. + * + * The requestSequence_ tracks the number of requests queued to a camera + * over its lifetime. + */ + static const char *const camera_state_names[] = { "Available", "Acquired", diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index c2872289337b..cebd94b2c18b 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -847,7 +847,7 @@ void PipelineHandlerRkISP1::stop(Camera *camera) LOG(RkISP1, Warning) << "Failed to stop parameters for " << camera->id(); - ASSERT(data->queuedRequests_.empty()); + ASSERT(camera->_d()->queuedRequests_.empty()); data->frameInfo_.clear(); freeBuffers(camera); diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 1ab237c8052e..0e571d8981df 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -16,6 +16,7 @@ #include #include +#include "libcamera/internal/camera.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/tracepoints.h" @@ -71,17 +72,6 @@ LOG_DEFINE_CATEGORY(Pipeline) * and remains valid until the instance is destroyed. */ -/** - * \var CameraData::queuedRequests_ - * \brief The list of queued and not yet completed request - * - * The list of queued request is used to track requests queued in order to - * ensure completion of all requests when the pipeline handler is stopped. - * - * \sa PipelineHandler::queueRequest(), PipelineHandler::stop(), - * PipelineHandler::completeRequest() - */ - /** * \var CameraData::controlInfo_ * \brief The set of controls supported by the camera @@ -98,17 +88,6 @@ LOG_DEFINE_CATEGORY(Pipeline) * when creating the camera, and shall not be modified afterwards. */ -/** - * \var CameraData::requestSequence_ - * \brief The queuing sequence of the request - * - * When requests are queued, they are given a per-camera sequence number to - * facilitate debugging of internal request usage. - * - * The requestSequence_ tracks the number of requests queued to a camera - * over its lifetime. - */ - /** * \class PipelineHandler * \brief Create and manage cameras based on a set of media devices @@ -254,8 +233,7 @@ void PipelineHandler::unlock() */ const ControlInfoMap &PipelineHandler::controls(const Camera *camera) const { - const CameraData *data = cameraData(camera); - return data->controlInfo_; + return camera->_d()->controlInfo_; } /** @@ -265,8 +243,7 @@ const ControlInfoMap &PipelineHandler::controls(const Camera *camera) const */ const ControlList &PipelineHandler::properties(const Camera *camera) const { - const CameraData *data = cameraData(camera); - return data->properties_; + return camera->_d()->properties_; } /** @@ -380,8 +357,7 @@ const ControlList &PipelineHandler::properties(const Camera *camera) const */ bool PipelineHandler::hasPendingRequests(const Camera *camera) const { - const CameraData *data = cameraData(camera); - return !data->queuedRequests_.empty(); + return !camera->_d()->queuedRequests_.empty(); } /** @@ -406,7 +382,7 @@ void PipelineHandler::queueRequest(Request *request) LIBCAMERA_TRACEPOINT(request_queue, request); Camera *camera = request->camera_; - CameraData *data = cameraData(camera); + Camera::Private *data = camera->_d(); data->queuedRequests_.push_back(request); request->sequence_ = data->requestSequence_++; @@ -479,7 +455,7 @@ void PipelineHandler::completeRequest(Request *request) request->complete(); - CameraData *data = cameraData(camera); + Camera::Private *data = camera->_d(); while (!data->queuedRequests_.empty()) { Request *req = data->queuedRequests_.front(); @@ -507,6 +483,15 @@ void PipelineHandler::completeRequest(Request *request) void PipelineHandler::registerCamera(std::shared_ptr camera, std::unique_ptr data) { + /* + * To be removed once all pipeline handlers will have migrated from + * CameraData to Camera::Private. + */ + if (data) { + camera->_d()->controlInfo_ = std::move(data->controlInfo_); + camera->_d()->properties_ = std::move(data->properties_); + } + cameraData_[camera.get()] = std::move(data); cameras_.push_back(camera); From patchwork Wed Aug 11 23:26:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13312 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 4F774C3241 for ; Wed, 11 Aug 2021 23:26:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EA9706888B; Thu, 12 Aug 2021 01:26:42 +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="eUf7RzWZ"; 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 27D22687F0 for ; Thu, 12 Aug 2021 01:26:34 +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 C700FEE for ; Thu, 12 Aug 2021 01:26:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724393; bh=rbWljtLYSDK1ASJ/mFttH/jM8vA2aYlWxaPCVTUL8WE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eUf7RzWZk2hv6R2mgw8TYdDN6NqvN3ozlqzejh5l+BZWM2oNR4RlEtF6th2RzxNaY AF72NN/cNFgYg22esLF7DrPY0KsSrgEx1wL+Ztk1N8F5mZgrRZFwYgYBiPLFAKk9Zy TJalrG/ahNUdXzPi0MgFwyurVv+kTrdTYEoEfUmg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:15 +0300 Message-Id: <20210811232625.17280-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 04/14] libcamera: camera: Fix minor issues in Camera::Private documentation 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" Improve the Camera::Private documentation by fixing minor spelling or style issues. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/camera.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 4080da151af1..a22cc7b8e49d 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -368,10 +368,10 @@ Camera::Private::~Private() /** * \var Camera::Private::queuedRequests_ - * \brief The list of queued and not yet completed request + * \brief The list of queued and not yet completed requests * - * The list of queued request is used to track requests queued in order to - * ensure completion of all requests when the pipeline handler is stopped. + * This list tracks requests queued in order to ensure completion of all + * requests when the pipeline handler is stopped. * * \sa PipelineHandler::queueRequest(), PipelineHandler::stop(), * PipelineHandler::completeRequest() @@ -400,7 +400,7 @@ Camera::Private::~Private() /** * \var Camera::Private::requestSequence_ - * \brief The queuing sequence of the request + * \brief The queuing sequence number of the request * * When requests are queued, they are given a per-camera sequence number to * facilitate debugging of internal request usage. From patchwork Wed Aug 11 23:26:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13313 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 E1679C3242 for ; Wed, 11 Aug 2021 23:26:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 538D06888F; Thu, 12 Aug 2021 01:26:43 +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="m2P0JSsa"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 915F8687F0 for ; Thu, 12 Aug 2021 01:26:34 +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 468A3EE for ; Thu, 12 Aug 2021 01:26:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724394; bh=aPSQ/QEScBaGvkF9RWNIl+V6njvJDzUPiTILR1VFIsA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=m2P0JSsaJ1WAziwu3ps5cXgaPKW86lMLx8tqASgd7VoIbDpOaN/BNjRUMtznSkY/6 lF+oUatXePRFwbjMFEN+0yNNosFkAmWZ/0mMRV6wPFqrKRXhLu+FNC4QdyW/KqveFU 3ZbNSnBIX/1pgFU3f4PZ1Mh7o0sJ0Lzm6sgbyM38= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:16 +0300 Message-Id: <20210811232625.17280-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 05/14] libcamera: pipeline: simple: Migrate to Camera::Private 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" As part of the effort to remove the CameraData class, migrate the pipeline handler-specific camera data from CameraData to the Camera::Private class. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/simple/simple.cpp | 25 ++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index ad581969fca1..947f3f1f8bd6 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -147,7 +147,7 @@ static const SimplePipelineInfo supportedDevices[] = { } /* namespace */ -class SimpleCameraData : public CameraData +class SimpleCameraData : public Camera::Private { public: SimpleCameraData(SimplePipelineHandler *pipe, @@ -213,7 +213,7 @@ private: * reference to the camera data, store a new reference to the camera. */ std::shared_ptr camera_; - const SimpleCameraData *data_; + SimpleCameraData *data_; const SimpleCameraData::Configuration *pipeConfig_; bool needConversion_; @@ -246,10 +246,9 @@ protected: private: static constexpr unsigned int kNumInternalBuffers = 3; - SimpleCameraData *cameraData(const Camera *camera) + SimpleCameraData *cameraData(Camera *camera) { - return static_cast( - PipelineHandler::cameraData(camera)); + return static_cast(camera->_d()); } std::vector locateSensors(); @@ -274,7 +273,7 @@ private: SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, unsigned int numStreams, MediaEntity *sensor) - : CameraData(pipe), streams_(numStreams) + : Camera::Private(pipe), streams_(numStreams) { int ret; @@ -355,7 +354,8 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, int SimpleCameraData::init() { - SimplePipelineHandler *pipe = static_cast(pipe_); + SimplePipelineHandler *pipe = + static_cast(this->pipe()); SimpleConverter *converter = pipe->converter(); int ret; @@ -480,7 +480,8 @@ int SimpleCameraData::setupLinks() int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, V4L2Subdevice::Whence whence) { - SimplePipelineHandler *pipe = static_cast(pipe_); + SimplePipelineHandler *pipe = + static_cast(this->pipe()); int ret; /* @@ -581,7 +582,7 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() } /* Adjust the requested streams. */ - SimplePipelineHandler *pipe = static_cast(data_->pipe_); + SimplePipelineHandler *pipe = static_cast(data_->pipe()); SimpleConverter *converter = pipe->converter(); /* @@ -1046,10 +1047,10 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) std::inserter(streams, streams.end()), [](Stream &stream) { return &stream; }); + const std::string &id = data->sensor_->id(); std::shared_ptr camera = - Camera::create(std::make_unique(this), - data->sensor_->id(), streams); - registerCamera(std::move(camera), std::move(data)); + Camera::create(std::move(data), id, streams); + registerCamera(std::move(camera), nullptr); registered = true; } From patchwork Wed Aug 11 23:26:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13314 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 2D2D2C3243 for ; Wed, 11 Aug 2021 23:26:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 99F6B68886; Thu, 12 Aug 2021 01:26:43 +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="s/hdh77H"; 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 1209C6888D for ; Thu, 12 Aug 2021 01:26:35 +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 93B1B268 for ; Thu, 12 Aug 2021 01:26:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724394; bh=NZpG5rySvIEdW+gmcYCpfdInkc13UxFVO27tQdI5mVQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=s/hdh77HERkbyLiyBQTMx+VeoZeFuX3IEviubKgw8nKozWbJKSefFwGBOo9cV+6ZN iGSsPz8rAF+iwWw0gsTdf7svGsmqgvr4bOOLFgF7yBQFVaEyByOsrmR0dMTGEObS4/ cR0IibkFHRs/CK4Ild+sw1R48plWrs9qVKJnmmmM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:17 +0300 Message-Id: <20210811232625.17280-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 06/14] libcamera: pipeline: uvcvideo: Migrate to Camera::Private 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" As part of the effort to remove the CameraData class, migrate the pipeline handler-specific camera data from CameraData to the Camera::Private class. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index a9b6af4b5bdf..5ee2357d262a 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -33,11 +33,11 @@ namespace libcamera { LOG_DEFINE_CATEGORY(UVC) -class UVCCameraData : public CameraData +class UVCCameraData : public Camera::Private { public: UVCCameraData(PipelineHandler *pipe) - : CameraData(pipe) + : Camera::Private(pipe) { } @@ -87,10 +87,9 @@ private: const ControlValue &value); int processControls(UVCCameraData *data, Request *request); - UVCCameraData *cameraData(const Camera *camera) + UVCCameraData *cameraData(Camera *camera) { - return static_cast( - PipelineHandler::cameraData(camera)); + return static_cast(camera->_d()); } }; @@ -472,9 +471,8 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) std::set streams{ &data->stream_ }; std::shared_ptr camera = - Camera::create(std::make_unique(this), id, - streams); - registerCamera(std::move(camera), std::move(data)); + Camera::create(std::move(data), id, streams); + registerCamera(std::move(camera), nullptr); /* Enable hot-unplug notifications. */ hotplugMediaDevice(media); @@ -669,8 +667,8 @@ void UVCCameraData::bufferReady(FrameBuffer *buffer) request->metadata().set(controls::SensorTimestamp, buffer->metadata().timestamp); - pipe_->completeBuffer(request, buffer); - pipe_->completeRequest(request); + pipe()->completeBuffer(request, buffer); + pipe()->completeRequest(request); } REGISTER_PIPELINE_HANDLER(PipelineHandlerUVC) From patchwork Wed Aug 11 23:26:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13315 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 6D8B8BD87D for ; Wed, 11 Aug 2021 23:26:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E185B68890; Thu, 12 Aug 2021 01:26:43 +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="mKC6XSJ5"; 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 4E49D68855 for ; Thu, 12 Aug 2021 01:26:35 +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 E3434EE for ; Thu, 12 Aug 2021 01:26:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724395; bh=Ry+ToS4cgAu8WRDGIe64ticp5fo7TojLPk+26acZtiQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mKC6XSJ5Qze30gEbx0CUWh4L5Ppu/Oc+qXlAgSU/ropmgOLlrbfI4PMzcTmRQ+OK/ nZui/5Hohc96BkPd8rOn0MQUi6ndZRZOBnMr3TYlCdOVTrwjiRNh/XCFgGlzvkyuCV ZW7h/E5bdbsOtgJmvxiDewjv3pjp5w9t+PHjzhZ8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:18 +0300 Message-Id: <20210811232625.17280-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 07/14] libcamera: pipeline: vimc: Migrate to Camera::Private 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" As part of the effort to remove the CameraData class, migrate the pipeline handler-specific camera data from CameraData to the Camera::Private class. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/vimc/vimc.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 999d975716fa..0ce467e8e520 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -42,11 +42,11 @@ namespace libcamera { LOG_DEFINE_CATEGORY(VIMC) -class VimcCameraData : public CameraData +class VimcCameraData : public Camera::Private { public: VimcCameraData(PipelineHandler *pipe, MediaDevice *media) - : CameraData(pipe), media_(media) + : Camera::Private(pipe), media_(media) { } @@ -97,10 +97,9 @@ public: private: int processControls(VimcCameraData *data, Request *request); - VimcCameraData *cameraData(const Camera *camera) + VimcCameraData *cameraData(Camera *camera) { - return static_cast( - PipelineHandler::cameraData(camera)); + return static_cast(camera->_d()); } }; @@ -438,10 +437,10 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) /* Create and register the camera. */ std::set streams{ &data->stream_ }; + const std::string &id = data->sensor_->id(); std::shared_ptr camera = - Camera::create(std::make_unique(this), - data->sensor_->id(), streams); - registerCamera(std::move(camera), std::move(data)); + Camera::create(std::move(data), id, streams); + registerCamera(std::move(camera), nullptr); return true; } @@ -530,8 +529,8 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer) request->metadata().set(controls::SensorTimestamp, buffer->metadata().timestamp); - pipe_->completeBuffer(request, buffer); - pipe_->completeRequest(request); + pipe()->completeBuffer(request, buffer); + pipe()->completeRequest(request); } REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc) From patchwork Wed Aug 11 23:26:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13316 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 7CFC1C3244 for ; Wed, 11 Aug 2021 23:26:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 38475688A6; Thu, 12 Aug 2021 01:26:44 +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="aLtuWOsB"; 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 9CCB868890 for ; Thu, 12 Aug 2021 01:26:35 +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 4516D268 for ; Thu, 12 Aug 2021 01:26:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724395; bh=307YZt/lZTG6ihHfLQ0N1Cg+F7UDUwwqFFelOtW8FIM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aLtuWOsBetnzN0gnJErcYriUVOXiffQUr4Q9f/qOeI7RG8fGbFQgZE/3Gn6GCqd1B +3m7BhxjsivxWLYAXQypevxENL5GshFLYBbIML+f51wiIXpyFdgBNkkP9h+zQz/ant PEqXq6qPNQbvp20WDz1pxCmWUV+BmKybWx0bvJ2M= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:19 +0300 Message-Id: <20210811232625.17280-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 08/14] libcamera: pipeline: rkisp1: Migrate to Camera::Private 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" As part of the effort to remove the CameraData class, migrate the pipeline handler-specific camera data from CameraData to the Camera::Private class. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index cebd94b2c18b..bcaec77eca26 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -77,12 +77,12 @@ private: std::map frameInfo_; }; -class RkISP1CameraData : public CameraData +class RkISP1CameraData : public Camera::Private { public: RkISP1CameraData(PipelineHandler *pipe, RkISP1MainPath *mainPath, RkISP1SelfPath *selfPath) - : CameraData(pipe), frame_(0), frameInfo_(pipe), + : Camera::Private(pipe), frame_(0), frameInfo_(pipe), mainPath_(mainPath), selfPath_(selfPath) { } @@ -152,16 +152,15 @@ public: bool match(DeviceEnumerator *enumerator) override; private: - RkISP1CameraData *cameraData(const Camera *camera) + RkISP1CameraData *cameraData(Camera *camera) { - return static_cast( - PipelineHandler::cameraData(camera)); + return static_cast(camera->_d()); } friend RkISP1CameraData; friend RkISP1Frames; - int initLinks(const Camera *camera, const CameraSensor *sensor, + int initLinks(Camera *camera, const CameraSensor *sensor, const RkISP1CameraConfiguration &config); int createCamera(MediaEntity *sensor); void tryCompleteRequest(Request *request); @@ -307,7 +306,7 @@ RkISP1FrameInfo *RkISP1Frames::find(Request *request) int RkISP1CameraData::loadIPA(unsigned int hwRevision) { - ipa_ = IPAManager::createIPA(pipe_, 1, 1); + ipa_ = IPAManager::createIPA(pipe(), 1, 1); if (!ipa_) return -ENOENT; @@ -333,7 +332,8 @@ void RkISP1CameraData::queueFrameAction(unsigned int frame, break; } case ipa::rkisp1::ActionParamFilled: { - PipelineHandlerRkISP1 *pipe = static_cast(pipe_); + PipelineHandlerRkISP1 *pipe = + static_cast(this->pipe()); RkISP1FrameInfo *info = frameInfo_.find(frame); if (!info) break; @@ -361,7 +361,7 @@ void RkISP1CameraData::queueFrameAction(unsigned int frame, void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &metadata) { PipelineHandlerRkISP1 *pipe = - static_cast(pipe_); + static_cast(this->pipe()); RkISP1FrameInfo *info = frameInfo_.find(frame); if (!info) @@ -847,7 +847,7 @@ void PipelineHandlerRkISP1::stop(Camera *camera) LOG(RkISP1, Warning) << "Failed to stop parameters for " << camera->id(); - ASSERT(camera->_d()->queuedRequests_.empty()); + ASSERT(data->queuedRequests_.empty()); data->frameInfo_.clear(); freeBuffers(camera); @@ -879,7 +879,7 @@ int PipelineHandlerRkISP1::queueRequestDevice(Camera *camera, Request *request) * Match and Setup */ -int PipelineHandlerRkISP1::initLinks(const Camera *camera, +int PipelineHandlerRkISP1::initLinks(Camera *camera, const CameraSensor *sensor, const RkISP1CameraConfiguration &config) { @@ -970,10 +970,10 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) &data->mainPathStream_, &data->selfPathStream_, }; + const std::string &id = data->sensor_->id(); std::shared_ptr camera = - Camera::create(std::make_unique(this), - data->sensor_->id(), streams); - registerCamera(std::move(camera), std::move(data)); + Camera::create(std::move(data), id, streams); + registerCamera(std::move(camera), nullptr); return 0; } From patchwork Wed Aug 11 23:26:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13317 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 F2DEDC3245 for ; Wed, 11 Aug 2021 23:26:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9717A68911; Thu, 12 Aug 2021 01:26:44 +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="uU9+IIs3"; 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 ECCE268892 for ; Thu, 12 Aug 2021 01:26:35 +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 923F5EE for ; Thu, 12 Aug 2021 01:26:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724395; bh=1ZLIxh7QtXdT+PZwdPTrQibz+FtVy4UnGF7SFpYPl3c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=uU9+IIs3HltiXSFFQ9Px7F/t/OiHEAW62LGdMwoJ+7hQu8zrQHQqQel+Dg6zwA8Xb Vme4wxWodnigNipaDaJa4bC0bEJHknW6x1/Z3nmUro/20klLp2UTLSmIY3zEpT9KUz wAR/sWAQVXYOlQA7dwBBSnzwVwUXh1cA6OCXdPYM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:20 +0300 Message-Id: <20210811232625.17280-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 09/14] libcamera: pipeline: raspberrypi: Migrate to Camera::Private 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" As part of the effort to remove the CameraData class, migrate the pipeline handler-specific camera data from CameraData to the Camera::Private class. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- .../pipeline/raspberrypi/raspberrypi.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 91e906ef14ce..b615e4fa12c2 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -134,11 +134,11 @@ enum class Isp : unsigned int { Input, Output0, Output1, Stats }; } /* namespace */ -class RPiCameraData : public CameraData +class RPiCameraData : public Camera::Private { public: RPiCameraData(PipelineHandler *pipe) - : CameraData(pipe), state_(State::Stopped), + : Camera::Private(pipe), state_(State::Stopped), supportsFlips_(false), flipsAlterBayerOrder_(false), dropFrameCount_(0), ispOutputCount_(0) { @@ -262,9 +262,9 @@ public: bool match(DeviceEnumerator *enumerator) override; private: - RPiCameraData *cameraData(const Camera *camera) + RPiCameraData *cameraData(Camera *camera) { - return static_cast(PipelineHandler::cameraData(camera)); + return static_cast(camera->_d()); } int queueAllBuffers(Camera *camera); @@ -1105,10 +1105,10 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) streams.insert(&data->isp_[Isp::Output1]); /* Create and register the camera. */ + const std::string &id = data->sensor_->id(); std::shared_ptr camera = - Camera::create(std::make_unique(this), - data->sensor_->id(), streams); - registerCamera(std::move(camera), std::move(data)); + Camera::create(std::move(data), id, streams); + registerCamera(std::move(camera), nullptr); return true; } @@ -1223,7 +1223,7 @@ void RPiCameraData::frameStarted(uint32_t sequence) int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig) { - ipa_ = IPAManager::createIPA(pipe_, 1, 1); + ipa_ = IPAManager::createIPA(pipe(), 1, 1); if (!ipa_) return -ENOENT; @@ -1527,11 +1527,11 @@ void RPiCameraData::clearIncompleteRequests() */ if (buffer->request()) { buffer->cancel(); - pipe_->completeBuffer(request, buffer); + pipe()->completeBuffer(request, buffer); } } - pipe_->completeRequest(request); + pipe()->completeRequest(request); requestQueue_.pop_front(); } } @@ -1555,7 +1555,7 @@ void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, RPi::Stream *stream) * Tag the buffer as completed, returning it to the * application. */ - pipe_->completeBuffer(request, buffer); + pipe()->completeBuffer(request, buffer); } else { /* * This buffer was not part of the Request, or there is no @@ -1618,7 +1618,7 @@ void RPiCameraData::checkRequestCompleted() if (state_ != State::IpaComplete) return; - pipe_->completeRequest(request); + pipe()->completeRequest(request); requestQueue_.pop_front(); requestCompleted = true; } From patchwork Wed Aug 11 23:26:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13318 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 55422C3246 for ; Wed, 11 Aug 2021 23:26:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F18BD68918; Thu, 12 Aug 2021 01:26:44 +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="PfWfWoMT"; 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 4369768886 for ; Thu, 12 Aug 2021 01:26:36 +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 E0D6F268 for ; Thu, 12 Aug 2021 01:26:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724396; bh=rXSaRM0K1auWBt1ooiii8P2SStVn+jVh5lFOQeep07g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PfWfWoMTUJDxfRp621ZtkDiJSgoLIrg4RRDaHFcnK1Kpvx+0sXQFTR+6JVMmhNPry EyjwY/xhyO5wFjedi8OsTPpG1rv9X6NWZFrPLZWpqP0sJjYBb7chkzpgduJESJXI6A oC336f3zkggCzSb3KUaX7gHAvshmErKYzpwbkPe4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:21 +0300 Message-Id: <20210811232625.17280-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 10/14] libcamera: pipeline: ipu3: Migrate to Camera::Private 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" As part of the effort to remove the CameraData class, migrate the pipeline handler-specific camera data from CameraData to the Camera::Private class. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 38 +++++++++++++--------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index b9c0941c5ea8..4d07592e0c7e 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -53,11 +53,11 @@ static const ControlInfoMap::Map IPU3Controls = { { &controls::draft::PipelineDepth, ControlInfo(2, 3) }, }; -class IPU3CameraData : public CameraData +class IPU3CameraData : public Camera::Private { public: IPU3CameraData(PipelineHandler *pipe) - : CameraData(pipe), exposureTime_(0), supportsFlips_(false) + : Camera::Private(pipe), exposureTime_(0), supportsFlips_(false) { } @@ -146,10 +146,9 @@ public: bool match(DeviceEnumerator *enumerator) override; private: - IPU3CameraData *cameraData(const Camera *camera) + IPU3CameraData *cameraData(Camera *camera) { - return static_cast( - PipelineHandler::cameraData(camera)); + return static_cast(camera->_d()); } int initControls(IPU3CameraData *data); @@ -814,10 +813,10 @@ void IPU3CameraData::cancelPendingRequests() for (auto it : request->buffers()) { FrameBuffer *buffer = it.second; buffer->cancel(); - pipe_->completeBuffer(request, buffer); + pipe()->completeBuffer(request, buffer); } - pipe_->completeRequest(request); + pipe()->completeRequest(request); pendingRequests_.pop(); } } @@ -1198,12 +1197,11 @@ int PipelineHandlerIPU3::registerCameras() &IPU3CameraData::statBufferReady); /* Create and register the Camera instance. */ - std::string cameraId = cio2->sensor()->id(); + const std::string &cameraId = cio2->sensor()->id(); std::shared_ptr camera = - Camera::create(std::make_unique(this), - cameraId, streams); + Camera::create(std::move(data), cameraId, streams); - registerCamera(std::move(camera), std::move(data)); + registerCamera(std::move(camera), nullptr); LOG(IPU3, Info) << "Registered Camera[" << numCameras << "] \"" @@ -1218,7 +1216,7 @@ int PipelineHandlerIPU3::registerCameras() int IPU3CameraData::loadIPA() { - ipa_ = IPAManager::createIPA(pipe_, 1, 1); + ipa_ = IPAManager::createIPA(pipe(), 1, 1); if (!ipa_) return -ENOENT; @@ -1275,7 +1273,7 @@ void IPU3CameraData::queueFrameAction(unsigned int id, info->metadataProcessed = true; if (frameInfos_.tryComplete(info)) - pipe_->completeRequest(request); + pipe()->completeRequest(request); break; } @@ -1303,7 +1301,7 @@ void IPU3CameraData::imguOutputBufferReady(FrameBuffer *buffer) Request *request = info->request; - pipe_->completeBuffer(request, buffer); + pipe()->completeBuffer(request, buffer); request->metadata().set(controls::draft::PipelineDepth, 3); /* \todo Move the ExposureTime control to the IPA. */ @@ -1314,7 +1312,7 @@ void IPU3CameraData::imguOutputBufferReady(FrameBuffer *buffer) request->metadata().set(controls::ScalerCrop, cropRegion_); if (frameInfos_.tryComplete(info)) - pipe_->completeRequest(request); + pipe()->completeRequest(request); } /** @@ -1346,16 +1344,16 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer) for (auto it : request->buffers()) { FrameBuffer *b = it.second; b->cancel(); - pipe_->completeBuffer(request, b); + pipe()->completeBuffer(request, b); } frameInfos_.remove(info); - pipe_->completeRequest(request); + pipe()->completeRequest(request); return; } if (request->findBuffer(&rawStream_)) - pipe_->completeBuffer(request, buffer); + pipe()->completeBuffer(request, buffer); ipa::ipu3::IPU3Event ev; ev.op = ipa::ipu3::EventFillParams; @@ -1381,7 +1379,7 @@ void IPU3CameraData::paramBufferReady(FrameBuffer *buffer) Request *request = info->request; if (frameInfos_.tryComplete(info)) - pipe_->completeRequest(request); + pipe()->completeRequest(request); } void IPU3CameraData::statBufferReady(FrameBuffer *buffer) @@ -1400,7 +1398,7 @@ void IPU3CameraData::statBufferReady(FrameBuffer *buffer) * In that event, we must have obtained the Request before hand. */ if (frameInfos_.tryComplete(info)) - pipe_->completeRequest(request); + pipe()->completeRequest(request); return; } From patchwork Wed Aug 11 23:26:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13319 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 C350AC3241 for ; Wed, 11 Aug 2021 23:26:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 746FF688CA; Thu, 12 Aug 2021 01:26:45 +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="n4UfiY8z"; 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 9163C68893 for ; Thu, 12 Aug 2021 01:26:36 +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 3AD28EE for ; Thu, 12 Aug 2021 01:26:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724396; bh=Uyq9uvRvom7KApb33lNcLqjofStEveAZppiatBVwlGk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=n4UfiY8zgvirXYfup2WOGXq8sYtZbnrW6UlucYNpxciAg/xe9ZYkI0/VKO4yaJEts tL84y0aHc0r2Rktp4rJxgg3jWi8MFytGoWd748Whmfy5OB8JYZZ1pXGv7idnL4SDQB 1Fs0lXbZfVrTSmEut8lEuRoyQfKGfWPIUFdiIWck= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:22 +0300 Message-Id: <20210811232625.17280-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 11/14] libcamera: pipeline_handler: Drop CameraData class 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 CameraData class isn't used anymore. Drop it. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- include/libcamera/internal/pipeline_handler.h | 26 +---- src/libcamera/pipeline/ipu3/ipu3.cpp | 2 +- .../pipeline/raspberrypi/raspberrypi.cpp | 2 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +- src/libcamera/pipeline/simple/simple.cpp | 2 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 2 +- src/libcamera/pipeline/vimc/vimc.cpp | 2 +- src/libcamera/pipeline_handler.cpp | 94 +------------------ 8 files changed, 9 insertions(+), 123 deletions(-) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 24b0c5ca081c..1e48f7076d18 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -7,14 +7,12 @@ #ifndef __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__ #define __LIBCAMERA_INTERNAL_PIPELINE_HANDLER_H__ -#include #include #include #include #include #include -#include #include #include @@ -34,23 +32,6 @@ class MediaDevice; class PipelineHandler; class Request; -class CameraData -{ -public: - explicit CameraData(PipelineHandler *pipe) - : pipe_(pipe) - { - } - virtual ~CameraData() = default; - - PipelineHandler *pipe_; - ControlInfoMap controlInfo_; - ControlList properties_; - -private: - LIBCAMERA_DISABLE_COPY(CameraData) -}; - class PipelineHandler : public std::enable_shared_from_this, public Object { @@ -87,15 +68,11 @@ public: const char *name() const { return name_; } protected: - void registerCamera(std::shared_ptr camera, - std::unique_ptr data); + void registerCamera(std::shared_ptr camera); void hotplugMediaDevice(MediaDevice *media); virtual int queueRequestDevice(Camera *camera, Request *request) = 0; - CameraData *cameraData(const Camera *camera); - const CameraData *cameraData(const Camera *camera) const; - CameraManager *manager_; private: @@ -104,7 +81,6 @@ private: std::vector> mediaDevices_; std::vector> cameras_; - std::map> cameraData_; const char *name_; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 4d07592e0c7e..cd790f5fb234 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1201,7 +1201,7 @@ int PipelineHandlerIPU3::registerCameras() std::shared_ptr camera = Camera::create(std::move(data), cameraId, streams); - registerCamera(std::move(camera), nullptr); + registerCamera(std::move(camera)); LOG(IPU3, Info) << "Registered Camera[" << numCameras << "] \"" diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index b615e4fa12c2..b2674ac02109 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1108,7 +1108,7 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) const std::string &id = data->sensor_->id(); std::shared_ptr camera = Camera::create(std::move(data), id, streams); - registerCamera(std::move(camera), nullptr); + registerCamera(std::move(camera)); return true; } diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index bcaec77eca26..3c37a8ccad8f 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -973,7 +973,7 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) const std::string &id = data->sensor_->id(); std::shared_ptr camera = Camera::create(std::move(data), id, streams); - registerCamera(std::move(camera), nullptr); + registerCamera(std::move(camera)); return 0; } diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 947f3f1f8bd6..ef7687eaf502 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1050,7 +1050,7 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) const std::string &id = data->sensor_->id(); std::shared_ptr camera = Camera::create(std::move(data), id, streams); - registerCamera(std::move(camera), nullptr); + registerCamera(std::move(camera)); registered = true; } diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 5ee2357d262a..eee06b6e753f 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -472,7 +472,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) std::set streams{ &data->stream_ }; std::shared_ptr camera = Camera::create(std::move(data), id, streams); - registerCamera(std::move(camera), nullptr); + registerCamera(std::move(camera)); /* Enable hot-unplug notifications. */ hotplugMediaDevice(media); diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 0ce467e8e520..37e34d2e1962 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -440,7 +440,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) const std::string &id = data->sensor_->id(); std::shared_ptr camera = Camera::create(std::move(data), id, streams); - registerCamera(std::move(camera), nullptr); + registerCamera(std::move(camera)); return true; } diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 0e571d8981df..62d29cbeff02 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -39,55 +39,6 @@ namespace libcamera { LOG_DEFINE_CATEGORY(Pipeline) -/** - * \class CameraData - * \brief Base class for platform-specific data associated with a camera - * - * The CameraData base abstract class represents platform specific-data - * a pipeline handler might want to associate with a Camera to access them - * at a later time. - * - * Pipeline handlers are expected to extend this base class with platform - * specific implementation, associate instances of the derived classes - * using the registerCamera() function, and access them at a later time - * with cameraData(). - */ - -/** - * \fn CameraData::CameraData(PipelineHandler *pipe) - * \brief Construct a CameraData instance for the given pipeline handler - * \param[in] pipe The pipeline handler - * - * The reference to the pipeline handler is stored internally, the caller shall - * guarantee that the pointer remains valid as long as the CameraData instance - * exists. - */ - -/** - * \var CameraData::pipe_ - * \brief The pipeline handler related to this CameraData instance - * - * The pipe_ pointer provides access to the PipelineHandler object that this - * instance is related to. It is set when the CameraData instance is created - * and remains valid until the instance is destroyed. - */ - -/** - * \var CameraData::controlInfo_ - * \brief The set of controls supported by the camera - * - * The control information shall be initialised by the pipeline handler when - * creating the camera, and shall not be modified afterwards. - */ - -/** - * \var CameraData::properties_ - * \brief The list of properties supported by the camera - * - * The list of camera properties shall be initialised by the pipeline handler - * when creating the camera, and shall not be modified afterwards. - */ - /** * \class PipelineHandler * \brief Create and manage cameras based on a set of media devices @@ -471,28 +422,14 @@ void PipelineHandler::completeRequest(Request *request) /** * \brief Register a camera to the camera manager and pipeline handler * \param[in] camera The camera to be added - * \param[in] data Pipeline-specific data for the camera * * This function is called by pipeline handlers to register the cameras they - * handle with the camera manager. It associates the pipeline-specific \a data - * with the camera, for later retrieval with cameraData(). Ownership of \a data - * is transferred to the PipelineHandler. + * handle with the camera manager. * * \context This function shall be called from the CameraManager thread. */ -void PipelineHandler::registerCamera(std::shared_ptr camera, - std::unique_ptr data) +void PipelineHandler::registerCamera(std::shared_ptr camera) { - /* - * To be removed once all pipeline handlers will have migrated from - * CameraData to Camera::Private. - */ - if (data) { - camera->_d()->controlInfo_ = std::move(data->controlInfo_); - camera->_d()->properties_ = std::move(data->properties_); - } - - cameraData_[camera.get()] = std::move(data); cameras_.push_back(camera); if (mediaDevices_.empty()) @@ -586,33 +523,6 @@ void PipelineHandler::disconnect() } } -/** - * \brief Retrieve the pipeline-specific data associated with a Camera - * \param[in] camera The camera whose data to retrieve - * \return A pointer to the pipeline-specific data passed to registerCamera(). - * The returned pointer is a borrowed reference and is guaranteed to remain - * valid until the pipeline handler is destroyed. It shall not be deleted - * manually by the caller. - */ -CameraData *PipelineHandler::cameraData(const Camera *camera) -{ - ASSERT(cameraData_.count(camera)); - return cameraData_[camera].get(); -} - -/** - * \brief Retrieve the pipeline-specific data associated with a Camera - * \param[in] camera The camera whose data to retrieve - * \sa cameraData() - * \return A const pointer to the pipeline-specific data passed to - * registerCamera(). - */ -const CameraData *PipelineHandler::cameraData(const Camera *camera) const -{ - ASSERT(cameraData_.count(camera)); - return cameraData_.at(camera).get(); -} - /** * \var PipelineHandler::manager_ * \brief The Camera manager associated with the pipeline handler From patchwork Wed Aug 11 23:26:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13320 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 87F52C3247 for ; Wed, 11 Aug 2021 23:26:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 218096891B; Thu, 12 Aug 2021 01:26:46 +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="DMK/x6MG"; 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 E195B68889 for ; Thu, 12 Aug 2021 01:26:36 +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 88F1A268 for ; Thu, 12 Aug 2021 01:26:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724396; bh=g9AgRfz9xzgF4vUVob/uEjlfhPVRQGhG8OnTJlzBtUM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DMK/x6MGqo9RLGmoSAbx93PPgKZ3lmA0yelhDhecMmQvAAGHPM9tOvrXlBqXD+a4E yMbZPj5v2Pzq9XmnyOCLMqqnQekq4UFuxiohipgl/bjfhY4OjmkzPy8NRilIGtveNZ 73ibhmv16fFh44BJE/cpUgMhNWzSLnik7pZGiYsM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:23 +0300 Message-Id: <20210811232625.17280-13-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 12/14] Documentation: guides: pipeline-handler: Migrate to Camera::Private 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" Update the pipeline handler guide following the migration from the CameraData class to the Camera::Private class. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- Changes since v2: - Fix indentiation --- Documentation/guides/pipeline-handler.rst | 67 ++++++++++++----------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst index 5c5cf5a9cdc3..54c8e7f1f553 100644 --- a/Documentation/guides/pipeline-handler.rst +++ b/Documentation/guides/pipeline-handler.rst @@ -106,7 +106,7 @@ functionalities descibed above. Below is a brief overview of each of those: Abstracts camera sensor handling by hiding the details of the V4L2 subdevice kernel API and caching sensor information. -- `CameraData `_: +- `Camera::Private `_: Represents device-specific data a pipeline handler associates to each Camera instance. @@ -416,26 +416,26 @@ receivers port output. The Pipeline Handler is responsible for defining the set of Streams associated with the Camera. -Each Camera has instance-specific data represented using the `CameraData`_ +Each Camera has instance-specific data represented using the `Camera::Private`_ class, which can be extended for the specific needs of the pipeline handler. -.. _CameraData: http://libcamera.org/api-html/classlibcamera_1_1CameraData.html +.. _Camera::Private: http://libcamera.org/api-html/classlibcamera_1_1Camera_1_1Private.html -To support the Camera we will later register, we need to create a CameraData +To support the Camera we will later register, we need to create a Camera::Private class that we can implement for our specific Pipeline Handler. -Define a new ``VividCameraData()`` class derived from ``CameraData`` by adding -the following code before the PipelineHandlerVivid class definition where it -will be used: +Define a new ``VividCameraPrivate()`` class derived from ``Camera::Private`` by +adding the following code before the PipelineHandlerVivid class definition where +it will be used: .. code-block:: cpp - class VividCameraData : public CameraData + class VividCameraData : public Camera::Private { public: VividCameraData(PipelineHandler *pipe, MediaDevice *media) - : CameraData(pipe), media_(media), video_(nullptr) + : Camera::Private(pipe), media_(media), video_(nullptr) { } @@ -457,17 +457,17 @@ single stream, represented by the ``VividCameraData`` class members. More complex pipeline handlers might register cameras composed of several video devices and sub-devices, or multiple streams per camera that represent the several components of the image capture pipeline. You should represent all these -components in the ``CameraData`` derived class when developing a custom +components in the ``Camera::Private`` derived class when developing a custom PipelineHandler. In our example VividCameraData we implement an ``init()`` function to prepare -the object from our PipelineHandler, however the CameraData class does not +the object from our PipelineHandler, however the Camera::Private class does not specify the interface for initialisation and PipelineHandlers can manage this -based on their own needs. Derived CameraData classes are used only by their +based on their own needs. Derived Camera::Private classes are used only by their respective pipeline handlers. -The CameraData class stores the context required for each camera instance and -is usually responsible for opening all Devices used in the capture pipeline. +The Camera::Private class stores the context required for each camera instance +and is usually responsible for opening all Devices used in the capture pipeline. We can now implement the ``init`` function for our example Pipeline Handler to create a new V4L2 video device from the media entity, which we can specify using @@ -488,11 +488,11 @@ single capture device named 'vivid-000-vid-cap' by the device. return 0; } -The CameraData should be created and initialised before we move on to register a -new Camera device so we need to construct and initialise our +The VividCameraData should be created and initialised before we move on to +register a new Camera device so we need to construct and initialise our VividCameraData after we have identified our device within PipelineHandlerVivid::match(). The VividCameraData is wrapped by a -std::unique_ptr to help manage the lifetime of our CameraData instance. +std::unique_ptr to help manage the lifetime of the instance. If the camera data initialization fails, return ``false`` to indicate the failure to the ``match()`` function and prevent retrying of the pipeline @@ -509,9 +509,9 @@ handler. Once the camera data has been initialized, the Camera device instances and the associated streams have to be registered. Create a set of streams for the camera, which for this device is only one. You create a camera using the static -`Camera::create`_ function, passing the pipeline handler, the id of the camera, -and the streams available. Then register the camera and its data with the -pipeline handler and camera manager using `registerCamera`_. +`Camera::create`_ function, passing the Camera::Private instance, the id of the +camera, and the streams available. Then register the camera with the pipeline +handler and camera manager using `registerCamera`_. Finally with a successful construction, we return 'true' indicating that the PipelineHandler successfully matched and constructed a device. @@ -549,23 +549,24 @@ Our match function should now look like the following: /* Create and register the camera. */ std::set streams{ &data->stream_ }; - std::shared_ptr camera = Camera::create(this, data->video_->deviceName(), streams); - registerCamera(std::move(camera), std::move(data)); + const std::string &id = data->video_->deviceName(); + std::shared_ptr camera = Camera::create(data.release(), id, streams); + registerCamera(std::move(camera)); return true; } -We will need to use our custom CameraData class frequently throughout the +We will need to use our custom VividCameraData class frequently throughout the pipeline handler, so we add a private convenience helper to our Pipeline handler -to obtain and cast the custom CameraData instance from a Camera instance. +to obtain and cast the custom VividCameraData instance from a Camera::Private +instance. .. code-block:: cpp private: - VividCameraData *cameraData(const Camera *camera) + VividCameraData *cameraData(Camera *camera) { - return static_cast( - PipelineHandler::cameraData(camera)); + return static_cast(camera->_d()); } At this point, you need to add the following new includes to provide the Camera @@ -595,12 +596,12 @@ are defined by src/libcamera/`properties_ids.yaml`_. Pipeline handlers can optionally register the list of controls an application can set as well as a list of immutable camera properties. Being both -Camera-specific values, they are represented in the ``CameraData`` base class, -which provides two members for this purpose: the `CameraData::controlInfo_`_ and -the `CameraData::properties_`_ fields. +Camera-specific values, they are represented in the ``Camera::Private`` base +class, which provides two members for this purpose: the +`Camera::Private::controlInfo_`_ and the `Camera::Private::properties_`_ fields. -.. _CameraData::controlInfo_: http://libcamera.org/api-html/classlibcamera_1_1CameraData.html#ab9fecd05c655df6084a2233872144a52 -.. _CameraData::properties_: http://libcamera.org/api-html/classlibcamera_1_1CameraData.html#a84002c29f45bd35566c172bb65e7ec0b +.. _Camera::Private::controlInfo_: http://libcamera.org/api-html/classlibcamera_1_1Camera_1_1Private.html#ab4e183eb4dabe929d1b2bbbb519b969f +.. _Camera::Private::properties_: http://libcamera.org/api-html/classlibcamera_1_1Camera_1_1Private.html#ad31f12f5ed9c1fbe25750902f4791064 The ``controlInfo_`` field represents a map of ``ControlId`` instances associated with the limits of valid values supported for the control. More @@ -618,7 +619,7 @@ Complete the initialization of the ``VividCameraData`` class by adding the following code to the ``VividCameraData::init()`` function to initialise the controls. For more complex control configurations, this could of course be broken out to a separate function, but for now we just initialise the small set -inline in our CameraData init: +inline in our VividCameraData init: .. code-block:: cpp From patchwork Wed Aug 11 23:26:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13321 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 D5716C3248 for ; Wed, 11 Aug 2021 23:26:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7BD16688E5; Thu, 12 Aug 2021 01:26:46 +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="XCiBQxkk"; 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 3BC1E688AC for ; Thu, 12 Aug 2021 01:26:37 +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 D8EB34A1 for ; Thu, 12 Aug 2021 01:26:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724397; bh=pMqhPl6racZhTK89jsnbWM/yhKRswAXCp4lVqRJosuM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XCiBQxkkJsCEi/brf8AnXCeDIfRTkce4efBnXFR+TJQ7CkOyeKIhf5b67PV5j2Ihr cni7p0iFtm6QA9uhm0xdvOWKALKVuIGCt7waQfz+wQ9fHHAIa/H5bOhlf9GlQa5P+T Gt19istgNnTyHvpwrGBFgFdKFLb8cFcU834jVIDw= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:24 +0300 Message-Id: <20210811232625.17280-14-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 13/14] libcamera: pipeline_handler: Drop controls() and properties() functions 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 PipelineHandler controls() and properties() functions are only used by the Camera class. Now that the controls and properties are stored in the Camera::Private class, we can drop those functions and access the private data directly in Camera::controls() and Camera::properties(). Suggested-by: Jacopo Mondi Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/internal/pipeline_handler.h | 3 --- src/libcamera/camera.cpp | 4 ++-- src/libcamera/pipeline_handler.cpp | 21 ------------------- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 1e48f7076d18..41cba44d990f 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -46,9 +46,6 @@ public: bool lock(); void unlock(); - const ControlInfoMap &controls(const Camera *camera) const; - const ControlList &properties(const Camera *camera) const; - virtual CameraConfiguration *generateConfiguration(Camera *camera, const StreamRoles &roles) = 0; virtual int configure(Camera *camera, CameraConfiguration *config) = 0; diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index a22cc7b8e49d..c20e05014fb9 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -800,7 +800,7 @@ int Camera::release() */ const ControlInfoMap &Camera::controls() const { - return _d()->pipe_->controls(this); + return _d()->controlInfo_; } /** @@ -813,7 +813,7 @@ const ControlInfoMap &Camera::controls() const */ const ControlList &Camera::properties() const { - return _d()->pipe_->properties(this); + return _d()->properties_; } /** diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 62d29cbeff02..597d4c6a578a 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -176,27 +176,6 @@ void PipelineHandler::unlock() media->unlock(); } -/** - * \brief Retrieve the list of controls for a camera - * \param[in] camera The camera - * \context This function is \threadsafe. - * \return A ControlInfoMap listing the controls support by \a camera - */ -const ControlInfoMap &PipelineHandler::controls(const Camera *camera) const -{ - return camera->_d()->controlInfo_; -} - -/** - * \brief Retrieve the list of properties for a camera - * \param[in] camera The camera - * \return A ControlList of properties supported by \a camera - */ -const ControlList &PipelineHandler::properties(const Camera *camera) const -{ - return camera->_d()->properties_; -} - /** * \fn PipelineHandler::generateConfiguration() * \brief Generate a camera configuration for a specified camera From patchwork Wed Aug 11 23:26:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13322 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 3FF56C3249 for ; Wed, 11 Aug 2021 23:26:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D668468889; Thu, 12 Aug 2021 01:26:46 +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="SOXsT760"; 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 89EED6884D for ; Thu, 12 Aug 2021 01:26:37 +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 33092268 for ; Thu, 12 Aug 2021 01:26:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1628724397; bh=v4l0TfJGrIWZzQA8je2kLRBPT8RmYSVNN/nSfIdhqVY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SOXsT760cMtgZnMCSW70WmNk5hpABy5xOeJOxUeLMxADpx25tiFe4+v1TnsuTBeF4 CqTVuRlOgdcfiunqZ8Jm7ZpHq/WfSn10xTLAvZWr1EicSlzZI4s04DGCTq2g+im+HH d32Wcw1RdwH+3c9P6y4kqTB+zOYqLz/8vt6uj93Q= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 12 Aug 2021 02:26:25 +0300 Message-Id: <20210811232625.17280-15-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> References: <20210811232625.17280-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 14/14] libcamera: pipeline: Cast to derived pipeline handler with helpers 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" Replace manual static casts from the PipelineHandler pointer to a derived class pointer with helper functions in the camera data classes. This simplifies code accessing the pipeline from the camera data. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 14 ++++++++------ src/libcamera/pipeline/simple/simple.cpp | 16 +++++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 3c37a8ccad8f..2dbd6304acce 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -87,6 +87,7 @@ public: { } + PipelineHandlerRkISP1 *pipe(); int loadIPA(unsigned int hwRevision); Stream mainPathStream_; @@ -304,6 +305,11 @@ RkISP1FrameInfo *RkISP1Frames::find(Request *request) return nullptr; } +PipelineHandlerRkISP1 *RkISP1CameraData::pipe() +{ + return static_cast(Camera::Private::pipe()); +} + int RkISP1CameraData::loadIPA(unsigned int hwRevision) { ipa_ = IPAManager::createIPA(pipe(), 1, 1); @@ -332,8 +338,7 @@ void RkISP1CameraData::queueFrameAction(unsigned int frame, break; } case ipa::rkisp1::ActionParamFilled: { - PipelineHandlerRkISP1 *pipe = - static_cast(this->pipe()); + PipelineHandlerRkISP1 *pipe = RkISP1CameraData::pipe(); RkISP1FrameInfo *info = frameInfo_.find(frame); if (!info) break; @@ -360,9 +365,6 @@ void RkISP1CameraData::queueFrameAction(unsigned int frame, void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &metadata) { - PipelineHandlerRkISP1 *pipe = - static_cast(this->pipe()); - RkISP1FrameInfo *info = frameInfo_.find(frame); if (!info) return; @@ -370,7 +372,7 @@ void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &meta info->request->metadata().merge(metadata); info->metadataProcessed = true; - pipe->tryCompleteRequest(info->request); + pipe()->tryCompleteRequest(info->request); } RkISP1CameraConfiguration::RkISP1CameraConfiguration(Camera *camera, diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index ef7687eaf502..8ff954722fed 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -155,6 +155,7 @@ public: MediaEntity *sensor); bool isValid() const { return sensor_ != nullptr; } + SimplePipelineHandler *pipe(); int init(); int setupLinks(); @@ -352,11 +353,14 @@ SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe, [](const Entity &e) { return e.entity->name(); }); } +SimplePipelineHandler *SimpleCameraData::pipe() +{ + return static_cast(Camera::Private::pipe()); +} + int SimpleCameraData::init() { - SimplePipelineHandler *pipe = - static_cast(this->pipe()); - SimpleConverter *converter = pipe->converter(); + SimpleConverter *converter = pipe()->converter(); int ret; /* @@ -480,8 +484,7 @@ int SimpleCameraData::setupLinks() int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, V4L2Subdevice::Whence whence) { - SimplePipelineHandler *pipe = - static_cast(this->pipe()); + SimplePipelineHandler *pipe = SimpleCameraData::pipe(); int ret; /* @@ -582,8 +585,7 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() } /* Adjust the requested streams. */ - SimplePipelineHandler *pipe = static_cast(data_->pipe()); - SimpleConverter *converter = pipe->converter(); + SimpleConverter *converter = data_->pipe()->converter(); /* * Enable usage of the converter when producing multiple streams, as