From patchwork Thu Mar 25 13:42:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11719 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 E250CC32E9 for ; Thu, 25 Mar 2021 13:42:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9E99A68D94; Thu, 25 Mar 2021 14:42:49 +0100 (CET) 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="FI8Q3kwg"; 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 181C6602D9 for ; Thu, 25 Mar 2021 14:42:39 +0100 (CET) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 776009E2; Thu, 25 Mar 2021 14:42:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1616679758; bh=xdRm2p4suosxsWk6793Kifkf8epaM/MJJjtDVNTULmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FI8Q3kwghS24OKmzJ/N2/USea9KV1CnvMsMu8ixbXHV8qcyK01bnpwq0vylwt7QvR RXwrgkGRVQzUz2PicTYoxcJpozQI+ficJOOsOz4q+K9aRALQhS1pJRP02Yl8pswMAE bOtP7qIIoR/I0i2U3KA6Iz4yV8bV3QE2JuXyHD6w= From: Kieran Bingham To: libcamera devel Date: Thu, 25 Mar 2021 13:42:29 +0000 Message-Id: <20210325134231.1400051-12-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210325134231.1400051-1-kieran.bingham@ideasonboard.com> References: <20210325134231.1400051-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 09/11] libcamera: camera: Assert pipelines complete all requests 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" When the camera manager calls stop on a pipeline, it is expected that the pipeline handler guarantees all requests are returned back to the application before the camera has stopped. Ensure that this guarantee is met by providing an accessor on the pipeline handler to validate that all pending requests are removed. Signed-off-by: Kieran Bingham --- Note: I wanted to make PipelineHandler::active() a const function, but then I'm unable to call it through invokeMethod(). Does invokeMethod support calling const functions? Or did I do something obviously wrong? --- include/libcamera/internal/pipeline_handler.h | 1 + src/libcamera/camera.cpp | 3 +++ src/libcamera/pipeline_handler.cpp | 17 +++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 9bdda8f3b799..1410a06ebabe 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -80,6 +80,7 @@ public: virtual int start(Camera *camera, const ControlList *controls) = 0; virtual void stop(Camera *camera) = 0; + bool active(const Camera *camera); int queueRequest(Request *request); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 7f7956ba732f..99b01633ff5f 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -1086,6 +1086,9 @@ int Camera::stop() d->pipe_->invokeMethod(&PipelineHandler::stop, ConnectionTypeBlocking, this); + ASSERT(!d->pipe_->invokeMethod(&PipelineHandler::active, + ConnectionTypeBlocking, this)); + d->setState(Private::CameraConfigured); return 0; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index e3d4975d9ffd..c1ea4374b445 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -357,6 +357,23 @@ const ControlList &PipelineHandler::properties(const Camera *camera) const * \context This function is called from the CameraManager thread. */ +/** + * \brief Determine if the camera has any requests pending + * \param[in] camera The camera to check + * + * This method determines if there are any requests queued to the pipeline + * awaiting processing. + * + * \context This function is called from the CameraManager thread. + * + * \return True if there are pending requests, or false otherwise + */ +bool PipelineHandler::active(const Camera *camera) +{ + const CameraData *data = cameraData(camera); + return !data->queuedRequests_.empty(); +} + /** * \fn PipelineHandler::queueRequest() * \brief Queue a request