[{"id":21082,"web_url":"https://patchwork.libcamera.org/comment/21082/","msgid":"<YZq9Ys++gNZ4phAp@pendragon.ideasonboard.com>","date":"2021-11-21T21:42:58","subject":"Re: [libcamera-devel] [PATCH v2 09/12] libcamera: pipeline_handler:\n\tPrepare Request","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Sat, Nov 20, 2021 at 12:13:10PM +0100, Jacopo Mondi wrote:\n> Before queueing a request to the device, any synchronization fence from\n> the Request' framebuffers has to be waited on.\n> \n> Connect the Request::Private::prepared signal to the function that\n> queues requests to the hardware and call Request::Private::prepare().\n> \n> When the waiting request queue is inspected, verify the Request::Private\n> status to discern if a Request has failed preparing or it can be queued\n> to the hardware.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/pipeline_handler.cpp | 32 +++++++++++++++++++++++++++---\n>  1 file changed, 29 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index 3b9145992c8f..82ef214d16f2 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -7,6 +7,7 @@\n>  \n>  #include \"libcamera/internal/pipeline_handler.h\"\n>  \n> +#include <chrono>\n>  #include <sys/sysmacros.h>\n>  \n>  #include <libcamera/base/log.h>\n> @@ -17,6 +18,7 @@\n>  #include <libcamera/framebuffer.h>\n>  \n>  #include \"libcamera/internal/camera.h\"\n> +#include \"libcamera/internal/framebuffer.h\"\n\ncheckstyle.py didn't warn about the alphabetical order ?\n\n>  #include \"libcamera/internal/device_enumerator.h\"\n>  #include \"libcamera/internal/media_device.h\"\n>  #include \"libcamera/internal/request.h\"\n> @@ -36,6 +38,8 @@\n>   * the REGISTER_PIPELINE_HANDLER() macro.\n>   */\n>  \n> +using namespace std::chrono_literals;\n> +\n>  namespace libcamera {\n>  \n>  LOG_DEFINE_CATEGORY(Pipeline)\n> @@ -338,7 +342,14 @@ void PipelineHandler::queueRequest(Request *request)\n>  \tLIBCAMERA_TRACEPOINT(request_queue, request);\n>  \n>  \twaitingRequests_.push_back(request);\n> -\tdoQueueRequests();\n> +\n> +\trequest->_d()->prepared.connect(this, [this]() {\n> +\t\t\t\t\t\tdoQueueRequests();\n> +\t\t\t\t\t});\n> +\n> +\tRequest::Private::Status status = request->_d()->prepare(300ms);\n> +\tif (status == Request::Private::Status::Ready)\n> +\t\tdoQueueRequests();\n>  }\n>  \n>  /**\n> @@ -354,6 +365,12 @@ void PipelineHandler::doQueueRequest(Request *request)\n>  \n>  \trequest->_d()->sequence_ = data->requestSequence_++;\n>  \n> +\tif (request->_d()->privateStatus() == Request::Private::Status::Failed) {\n> +\t\trequest->_d()->cancel();\n> +\t\tcompleteRequest(request);\n> +\t\treturn;\n> +\t}\n> +\n>  \tint ret = queueRequestDevice(camera, request);\n>  \tif (ret) {\n>  \t\trequest->_d()->cancel();\n> @@ -371,9 +388,18 @@ void PipelineHandler::doQueueRequests()\n>  \t\t\treturn;\n>  \n>  \t\tRequest *request = waitingRequests_.front();\n> -\t\twaitingRequests_.pop_front();\n> +\t\tRequest::Private::Status status = request->_d()->privateStatus();\n> +\n> +\t\tswitch (status) {\n> +\t\tcase Request::Private::Status::Pending:\n> +\t\t\treturn;\n>  \n> -\t\tdoQueueRequest(request);\n> +\t\tcase Request::Private::Status::Failed:\n> +\t\tcase Request::Private::Status::Ready:\n> +\t\t\twaitingRequests_.pop_front();\n> +\t\t\tdoQueueRequest(request);\n> +\t\t\tbreak;\n> +\t\t}\n>  \t}\n\nThe patch looks fine overall, but will likely change with the removal\n(or refactoring) of privateStatus().\n\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 B75E3BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 21 Nov 2021 21:43:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 074CB60371;\n\tSun, 21 Nov 2021 22:43:24 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 05F9760233\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 21 Nov 2021 22:43:22 +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 63BBF9DD;\n\tSun, 21 Nov 2021 22:43:21 +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=\"b4zutbe9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1637531001;\n\tbh=GfN4o7dZshW7uhsdEMlsReWLtrg3GaqLcekY3pfHAtE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=b4zutbe9UNfk3PFpJqejQ6K/60CWtyfBeVp7Fwt1Wpv7RKxDlWVw9bRN8WhTpxhcf\n\tUNn6v2OAY5TJXpL9EwyAsTa51FtpprDG/2Ss/KLYfp392x5Wwjc4ZtifFefYNReH7z\n\tW17NnLLp0Hto8BAefFTGZg0mIGJ+rRtVTPdrMg3M=","Date":"Sun, 21 Nov 2021 23:42:58 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YZq9Ys++gNZ4phAp@pendragon.ideasonboard.com>","References":"<20211120111313.106621-1-jacopo@jmondi.org>\n\t<20211120111313.106621-10-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211120111313.106621-10-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v2 09/12] libcamera: pipeline_handler:\n\tPrepare Request","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@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]