[{"id":22084,"web_url":"https://patchwork.libcamera.org/comment/22084/","msgid":"<Yfj2TgwrzoJ3h352@pendragon.ideasonboard.com>","date":"2022-02-01T08:58:54","subject":"Re: [libcamera-devel] [PATCH v3 1/2] libcamera: pipeline_handler:\n\tRegister requests","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Fri, Jan 21, 2022 at 02:24:19PM +0000, Kieran Bingham wrote:\n> Provide a call allowing requests to be registered and associated with\n> the pipeline handler after being constructed by the camera.\n> \n> This provides an opportunity for the Pipeline Handler to connect any\n\ns/Pipeline Handler/pipeline handler/ (or PipelineHandler)\n\n> signals it may be interested in receiving for the request such as\n> getting notifications when the request is ready for processing when\n> using a fence.\n> \n> While here, update the existing usage of the d pointer in\n> Camera::createRequest() to match the style of other functions.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n> \n> v3:\n>  - Remove unneeded conditional on construction of the request.\n> \n> v2:\n>  - Rename function to 'registerRequest' rather than 'prepareRequest'.\n> \n>  include/libcamera/internal/pipeline_handler.h |  1 +\n>  src/libcamera/camera.cpp                      | 13 ++++++++++---\n>  src/libcamera/pipeline_handler.cpp            | 19 ++++++++++++++++---\n>  3 files changed, 27 insertions(+), 6 deletions(-)\n> \n> diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> index e5b8ffb4db3d..c3e4c2587ecd 100644\n> --- a/include/libcamera/internal/pipeline_handler.h\n> +++ b/include/libcamera/internal/pipeline_handler.h\n> @@ -59,6 +59,7 @@ public:\n>  \tvoid stop(Camera *camera);\n>  \tbool hasPendingRequests(const Camera *camera) const;\n>  \n> +\tvoid registerRequest(Request *request);\n>  \tvoid queueRequest(Request *request);\n>  \n>  \tbool completeBuffer(Request *request, FrameBuffer *buffer);\n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 86d84ac0a77d..bb856d606f4a 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -1074,12 +1074,19 @@ int Camera::configure(CameraConfiguration *config)\n>   */\n>  std::unique_ptr<Request> Camera::createRequest(uint64_t cookie)\n>  {\n> -\tint ret = _d()->isAccessAllowed(Private::CameraConfigured,\n> -\t\t\t\t\tPrivate::CameraRunning);\n> +\tPrivate *const d = _d();\n> +\n> +\tint ret = d->isAccessAllowed(Private::CameraConfigured,\n> +\t\t\t\t     Private::CameraRunning);\n>  \tif (ret < 0)\n>  \t\treturn nullptr;\n>  \n> -\treturn std::make_unique<Request>(this, cookie);\n> +\tstd::unique_ptr<Request> request = std::make_unique<Request>(this, cookie);\n> +\n> +\t/* Associate the request with the pipeline handler. */\n> +\td->pipe_->registerRequest(request.get());\n> +\n> +\treturn request;\n>  }\n>  \n>  /**\n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index 03e4b9e66aa6..e27dc182c128 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -337,6 +337,22 @@ bool PipelineHandler::hasPendingRequests(const Camera *camera) const\n>  \treturn !camera->_d()->queuedRequests_.empty();\n>  }\n>  \n> +/**\n> + * \\fn PipelineHandler::registerRequest()\n> + * \\brief Register a request for use by the Pipeline Handler\n\ns/Pipeline Handler/pipeline handler/\n\n> + * \\param[in] request The request to register\n\nMaybe we could add\n\n * This function is called when the request is created, and allows the pipeline\n * handler to perform any one-time initialization it requires for the request.\n\n> + */\n> +void PipelineHandler::registerRequest(Request *request)\n> +{\n> +\t/*\n> +\t * Connect the request prepared signal to notify the pipeline handler\n> +\t * when a request is ready to be processed.\n> +\t */\n> +\trequest->_d()->prepared.connect(this, [this]() {\n> +\t\t\t\t\t\tdoQueueRequests();\n> +\t\t\t\t\t});\n\nWhile at it, this be simplified to\n\n\trequest->_d()->prepared.connect(this, &PipelineHandler::doQueueRequests);\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +}\n> +\n>  /**\n>   * \\fn PipelineHandler::queueRequest()\n>   * \\brief Queue a request\n> @@ -366,9 +382,6 @@ void PipelineHandler::queueRequest(Request *request)\n>  \n>  \twaitingRequests_.push(request);\n>  \n> -\trequest->_d()->prepared.connect(this, [this]() {\n> -\t\t\t\t\t\tdoQueueRequests();\n> -\t\t\t\t\t});\n>  \trequest->_d()->prepare(300ms);\n>  }\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E84BABF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Feb 2022 08:59:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4EA8E609D6;\n\tTue,  1 Feb 2022 09:59:20 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9E3F660986\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Feb 2022 09:59:18 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 10687332;\n\tTue,  1 Feb 2022 09:59:17 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZUbaRvpS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1643705958;\n\tbh=7qozY47QhN8creJItHP2h6p6D+FMTTWNBiKHtp7ByX4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ZUbaRvpSnn+6vDM3cDYEP2rrXrMyINzIAkugaUhkEcIjPL3LaXgLwUhJOMR7vKUmW\n\tx2ZjBJtt7jmgi/Bp78x8bldhkZXo0VKV3E1fJsRIydc7FWq5iPh2bVaOvv398AiIuh\n\tc11jP95o0UyOYums9gJ+H0EFzB/jybSe2P2s1ZOg=","Date":"Tue, 1 Feb 2022 10:58:54 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<Yfj2TgwrzoJ3h352@pendragon.ideasonboard.com>","References":"<20220121142420.3531497-1-kieran.bingham@ideasonboard.com>\n\t<20220121142420.3531497-2-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220121142420.3531497-2-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 1/2] libcamera: pipeline_handler:\n\tRegister requests","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]