From patchwork Tue Feb 1 12:38:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15318 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 A2598C325A for ; Tue, 1 Feb 2022 12:38:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B1533609E8; Tue, 1 Feb 2022 13:38:08 +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="PfcJ/vSW"; 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 32482609B9 for ; Tue, 1 Feb 2022 13:38:07 +0100 (CET) Received: from Monstersaurus.ksquared.org.uk.beta.tailscale.net (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B1FF59DE; Tue, 1 Feb 2022 13:38:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1643719086; bh=Rc0WA29DsnXe5mLVbEHTiaYEql8KXGH3klCWXDvVIDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PfcJ/vSWxGSdqFkf+0S+n4MWii5aDOCY1k8gNGk/2C0vTaAm9IEOqRM2ufQyyR/gE jCfOdID0zVN1a9O9jM3qqe5LqWRD+fuHIFPLE+Efht6gr7Ua4VUtZpTuGyr6HHZzhX A5NVnoVrkich+gEUQQ5RuFg1wRFtJATMjEf3GdZc= From: Kieran Bingham To: libcamera devel Date: Tue, 1 Feb 2022 12:38:02 +0000 Message-Id: <20220201123803.281397-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220201123803.281397-1-kieran.bingham@ideasonboard.com> References: <20220201123803.281397-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 1/2] libcamera: pipeline_handler: Register 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" Provide a call allowing requests to be registered and associated with the pipeline handler after being constructed by the camera. This provides an opportunity for the PipelineHandler to connect any signals it may be interested in receiving for the request such as getting notifications when the request is ready for processing when using a fence. While here, update the existing usage of the d pointer in Camera::createRequest() to match the style of other functions. Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/internal/pipeline_handler.h | 1 + src/libcamera/camera.cpp | 13 +++++++++--- src/libcamera/pipeline_handler.cpp | 20 ++++++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index e5b8ffb4db3d..c3e4c2587ecd 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -59,6 +59,7 @@ public: void stop(Camera *camera); bool hasPendingRequests(const Camera *camera) const; + void registerRequest(Request *request); void queueRequest(Request *request); bool completeBuffer(Request *request, FrameBuffer *buffer); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 86d84ac0a77d..bb856d606f4a 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -1074,12 +1074,19 @@ int Camera::configure(CameraConfiguration *config) */ std::unique_ptr Camera::createRequest(uint64_t cookie) { - int ret = _d()->isAccessAllowed(Private::CameraConfigured, - Private::CameraRunning); + Private *const d = _d(); + + int ret = d->isAccessAllowed(Private::CameraConfigured, + Private::CameraRunning); if (ret < 0) return nullptr; - return std::make_unique(this, cookie); + std::unique_ptr request = std::make_unique(this, cookie); + + /* Associate the request with the pipeline handler. */ + d->pipe_->registerRequest(request.get()); + + return request; } /** diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 03e4b9e66aa6..7ebd76ad4704 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -337,6 +337,23 @@ bool PipelineHandler::hasPendingRequests(const Camera *camera) const return !camera->_d()->queuedRequests_.empty(); } +/** + * \fn PipelineHandler::registerRequest() + * \brief Register a request for use by the pipeline handler + * \param[in] request The request to register + * + * This function is called when the request is created, and allows the pipeline + * handler to perform any one-time initialization it requries for the request. + */ +void PipelineHandler::registerRequest(Request *request) +{ + /* + * Connect the request prepared signal to notify the pipeline handler + * when a request is ready to be processed. + */ + request->_d()->prepared.connect(this, &PipelineHandler::doQueueRequests); +} + /** * \fn PipelineHandler::queueRequest() * \brief Queue a request @@ -366,9 +383,6 @@ void PipelineHandler::queueRequest(Request *request) waitingRequests_.push(request); - request->_d()->prepared.connect(this, [this]() { - doQueueRequests(); - }); request->_d()->prepare(300ms); }