[{"id":32067,"web_url":"https://patchwork.libcamera.org/comment/32067/","msgid":"<Zyz1bat5ex299V/w@linux.intel.com>","date":"2024-11-07T17:14:21","subject":"Re: [PATCH v6 2/3] libcamera: simple: Track requests in\n\tconversionQueue_","submitter":{"id":211,"url":"https://patchwork.libcamera.org/api/people/211/","name":"Stanislaw Gruszka","email":"stanislaw.gruszka@linux.intel.com"},"content":"On Wed, Nov 06, 2024 at 09:17:20PM +0100, Milan Zamazal wrote:\n> Simple pipeline retrieves the requests to complete from the\n> conversionQueue_.  This patch stores the requests in conversionQueue_\n> explicitly.  This explicit tracking is supposed to be preferred to\n> implicit retrieval and it simplifies the completion code a bit here and\n> in the followup patch that adds request cleanup on stop.\n> \n> The change as implemented assumes that all the buffers in each of the\n> conversionQueue_ elements point to the same request, the one specified.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Reviewed-by: Hans de Goede <hdegoede@redhat.com>\n\nTested-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>\n\n> ---\n>  src/libcamera/pipeline/simple/simple.cpp | 26 ++++++++++++------------\n>  1 file changed, 13 insertions(+), 13 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index 67f583b8a..13c0a1891 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -282,7 +282,11 @@ public:\n>  \tstd::unique_ptr<DelayedControls> delayedCtrls_;\n>  \n>  \tstd::vector<std::unique_ptr<FrameBuffer>> conversionBuffers_;\n> -\tstd::queue<std::map<const Stream *, FrameBuffer *>> conversionQueue_;\n> +\tstruct RequestOutputs {\n> +\t\tRequest *request;\n> +\t\tstd::map<const Stream *, FrameBuffer *> outputs;\n> +\t};\n> +\tstd::queue<RequestOutputs> conversionQueue_;\n>  \tbool useConversion_;\n>  \n>  \tstd::unique_ptr<Converter> converter_;\n> @@ -808,16 +812,12 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n>  \t\tif (conversionQueue_.empty())\n>  \t\t\treturn;\n>  \n> -\t\tRequest *request = nullptr;\n> -\t\tfor (auto &item : conversionQueue_.front()) {\n> -\t\t\tFrameBuffer *outputBuffer = item.second;\n> -\t\t\trequest = outputBuffer->request();\n> -\t\t\tpipe->completeBuffer(request, outputBuffer);\n> -\t\t}\n> +\t\tconst RequestOutputs &outputs = conversionQueue_.front();\n> +\t\tfor (auto &[stream, buf] : outputs.outputs)\n> +\t\t\tpipe->completeBuffer(outputs.request, buf);\n> +\t\tpipe->completeRequest(outputs.request);\n>  \t\tconversionQueue_.pop();\n>  \n> -\t\tif (request)\n> -\t\t\tpipe->completeRequest(request);\n>  \t\treturn;\n>  \t}\n>  \n> @@ -833,7 +833,7 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n>  \n>  \tif (useConversion_ && !conversionQueue_.empty()) {\n>  \t\tconst std::map<const Stream *, FrameBuffer *> &outputs =\n> -\t\t\tconversionQueue_.front();\n> +\t\t\tconversionQueue_.front().outputs;\n>  \t\tif (!outputs.empty()) {\n>  \t\t\tFrameBuffer *outputBuffer = outputs.begin()->second;\n>  \t\t\tif (outputBuffer)\n> @@ -857,7 +857,7 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n>  \t\t}\n>  \n>  \t\tif (converter_)\n> -\t\t\tconverter_->queueBuffers(buffer, conversionQueue_.front());\n> +\t\t\tconverter_->queueBuffers(buffer, conversionQueue_.front().outputs);\n>  \t\telse\n>  \t\t\t/*\n>  \t\t\t * request->sequence() cannot be retrieved from `buffer' inside\n> @@ -865,7 +865,7 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n>  \t\t\t * already here.\n>  \t\t\t */\n>  \t\t\tswIsp_->queueBuffers(request->sequence(), buffer,\n> -\t\t\t\t\t     conversionQueue_.front());\n> +\t\t\t\t\t     conversionQueue_.front().outputs);\n>  \n>  \t\tconversionQueue_.pop();\n>  \t\treturn;\n> @@ -1429,7 +1429,7 @@ int SimplePipelineHandler::queueRequestDevice(Camera *camera, Request *request)\n>  \t}\n>  \n>  \tif (data->useConversion_) {\n> -\t\tdata->conversionQueue_.push(std::move(buffers));\n> +\t\tdata->conversionQueue_.push({ request, std::move(buffers) });\n>  \t\tif (data->swIsp_)\n>  \t\t\tdata->swIsp_->queueRequest(request->sequence(), request->controls());\n>  \t}\n> -- \n> 2.44.1\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 6D154C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 Nov 2024 17:14:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2406765485;\n\tThu,  7 Nov 2024 18:14:29 +0100 (CET)","from mgamail.intel.com (mgamail.intel.com [198.175.65.14])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A024A65478\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Nov 2024 18:14:27 +0100 (CET)","from orviesa009.jf.intel.com ([10.64.159.149])\n\tby orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n\t07 Nov 2024 09:14:26 -0800","from sgruszka-mobl.ger.corp.intel.com (HELO localhost)\n\t([10.246.8.237]) by orviesa009-auth.jf.intel.com with\n\tESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2024 09:14:24 -0800"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=intel.com header.i=@intel.com\n\theader.b=\"nOHYbVMz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n\td=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n\tt=1730999668; x=1762535668;\n\th=date:from:to:cc:subject:message-id:references:\n\tmime-version:in-reply-to;\n\tbh=XMDfG2oovSxZNyIculaH+ALhtZdxs2XCwDEO68YNoog=;\n\tb=nOHYbVMz8Y9epi6qJeR22yaqCA5wCfKmfuo5NYobi64QcalQU5bJwG2f\n\tNasOyAVW+gkgIfkp0bqVnOkTuD+UkoNItNX7dEhQCFlJ2gaM1x39d5F9M\n\tbylLpSs8ta9PUIxozbJzJf2AT8qoZlsKdBNLVb/wusbA/07xaCSc6Rl1o\n\thqCpYB2h2GUugAJtM7IKspbuwnttgYEuKcoHenOOzt/OVblhI6RGQRKgR\n\tanm+de9Bv4av3OIonNtSNbm7jVIdG4kQ1BSvzbRaBA1YsZBr9UzjmV+Zw\n\t1scFA0SM8PHt3yDv79joKkiR9limwwCMB5lAVYmaic06i9X8A/QUaeeMs A==;","X-CSE-ConnectionGUID":["/rqi1ggGQxCO7tSJcV2l6Q==","++OtRxVqQLSEy1+CZrlH4w=="],"X-CSE-MsgGUID":["yUTQfWg0ReSA4YWb5k6zQg==","gynyZdouS0m9LTDMp7Q/4w=="],"X-IronPort-AV":["E=McAfee;i=\"6700,10204,11249\"; a=\"34637891\"","E=Sophos;i=\"6.12,135,1728975600\"; d=\"scan'208\";a=\"34637891\"","E=Sophos;i=\"6.12,135,1728975600\"; d=\"scan'208\";a=\"85094119\""],"X-ExtLoop1":"1","Date":"Thu, 7 Nov 2024 18:14:21 +0100","From":"Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>","To":"Milan Zamazal <mzamazal@redhat.com>","Cc":"libcamera-devel@lists.libcamera.org, robert.mader@posteo.de,\n\tkieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com,\n\thdegoede@redhat.com","Subject":"Re: [PATCH v6 2/3] libcamera: simple: Track requests in\n\tconversionQueue_","Message-ID":"<Zyz1bat5ex299V/w@linux.intel.com>","References":"<20241106201721.1624461-1-mzamazal@redhat.com>\n\t<20241106201721.1624461-3-mzamazal@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20241106201721.1624461-3-mzamazal@redhat.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]