[{"id":4115,"web_url":"https://patchwork.libcamera.org/comment/4115/","msgid":"<20200320004033.GS14585@pendragon.ideasonboard.com>","date":"2020-03-20T00:40:33","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: pipeline: rkisp1: Use\n\tcorrect buffer count when importing buffers","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Fri, Mar 20, 2020 at 01:32:24AM +0100, Niklas Söderlund wrote:\n> When folding buffer management with start/stop the wrong variable was\n> passed to importBuffers() resulting in only one buffer being imported\n> for the video node making capture impossible. Fix this by first renaming\n> the confusingly named variable 'count' to 'ipaBufferId'. And then\n> reusing the 'count' name for the buffer count.\n> \n> While at it remove the loop to find the maximum value of buffers from\n> the single stream used by the pipeline. Once we add more stream this\n> needs to be reworked anyhow so keep it simple for now.\n> \n> Fixes: 33fedea818e2b6a9 (\"libcamera: pipeline_handler: Fold buffer management with start/stop\")\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 15 ++++++---------\n>  1 file changed, 6 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 97bb4f72cde5423e..ec54291db416a669 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -668,34 +668,31 @@ int PipelineHandlerRkISP1::exportFrameBuffers(Camera *camera, Stream *stream,\n>  int PipelineHandlerRkISP1::allocateBuffers(Camera *camera)\n>  {\n>  \tRkISP1CameraData *data = cameraData(camera);\n> -\tunsigned int count = 1;\n> +\tunsigned int count = data->stream_.configuration().bufferCount;\n> +\tunsigned int ipaBufferId = 1;\n>  \tint ret;\n>  \n> -\tunsigned int maxBuffers = 0;\n> -\tfor (const Stream *s : camera->streams())\n> -\t\tmaxBuffers = std::max(maxBuffers, s->configuration().bufferCount);\n> -\n>  \tret = video_->importBuffers(count);\n>  \tif (ret < 0)\n>  \t\tgoto error;\n>  \n> -\tret = param_->allocateBuffers(maxBuffers, &paramBuffers_);\n> +\tret = param_->allocateBuffers(count, &paramBuffers_);\n>  \tif (ret < 0)\n>  \t\tgoto error;\n>  \n> -\tret = stat_->allocateBuffers(maxBuffers, &statBuffers_);\n> +\tret = stat_->allocateBuffers(count, &statBuffers_);\n>  \tif (ret < 0)\n>  \t\tgoto error;\n>  \n>  \tfor (std::unique_ptr<FrameBuffer> &buffer : paramBuffers_) {\n> -\t\tbuffer->setCookie(count++);\n> +\t\tbuffer->setCookie(ipaBufferId++);\n>  \t\tdata->ipaBuffers_.push_back({ .id = buffer->cookie(),\n>  \t\t\t\t\t      .planes = buffer->planes() });\n>  \t\tavailableParamBuffers_.push(buffer.get());\n>  \t}\n>  \n>  \tfor (std::unique_ptr<FrameBuffer> &buffer : statBuffers_) {\n> -\t\tbuffer->setCookie(count++);\n> +\t\tbuffer->setCookie(ipaBufferId++);\n>  \t\tdata->ipaBuffers_.push_back({ .id = buffer->cookie(),\n>  \t\t\t\t\t      .planes = buffer->planes() });\n>  \t\tavailableStatBuffers_.push(buffer.get());","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B6C0960415\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Mar 2020 01:40:39 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 35264A53;\n\tFri, 20 Mar 2020 01:40:39 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584664839;\n\tbh=isJNPgzJRGMmGVxjUJdhx2UB6AzRBotoGlK/qmHA5fs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=X9xjiqNvJIwEYetyLbeiqly57nkRUWVIOwPbjxTa+lu9BiNCXmNBptjXYaBL9pk8j\n\tHaUBlhRoJWcwRaCZKDKdxv0DrsqH/zdPscCnSqjkVHXdYYvHCP/PkPFV7vtFEfCs9w\n\tLOrk7ks6VpU3XyZdzI6JXjyAm12lHfyyIQa/w4g8=","Date":"Fri, 20 Mar 2020 02:40:33 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200320004033.GS14585@pendragon.ideasonboard.com>","References":"<20200320003224.3536634-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200320003224.3536634-1-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: pipeline: rkisp1: Use\n\tcorrect buffer count when importing buffers","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>","X-List-Received-Date":"Fri, 20 Mar 2020 00:40:39 -0000"}},{"id":4117,"web_url":"https://patchwork.libcamera.org/comment/4117/","msgid":"<20200320005328.GB3553651@oden.dyn.berto.se>","date":"2020-03-20T00:53:28","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: pipeline: rkisp1: Use\n\tcorrect buffer count when importing buffers","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Pushed to master.\n\nOn 2020-03-20 01:32:24 +0100, Niklas Söderlund wrote:\n> When folding buffer management with start/stop the wrong variable was\n> passed to importBuffers() resulting in only one buffer being imported\n> for the video node making capture impossible. Fix this by first renaming\n> the confusingly named variable 'count' to 'ipaBufferId'. And then\n> reusing the 'count' name for the buffer count.\n> \n> While at it remove the loop to find the maximum value of buffers from\n> the single stream used by the pipeline. Once we add more stream this\n> needs to be reworked anyhow so keep it simple for now.\n> \n> Fixes: 33fedea818e2b6a9 (\"libcamera: pipeline_handler: Fold buffer management with start/stop\")\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 15 ++++++---------\n>  1 file changed, 6 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 97bb4f72cde5423e..ec54291db416a669 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -668,34 +668,31 @@ int PipelineHandlerRkISP1::exportFrameBuffers(Camera *camera, Stream *stream,\n>  int PipelineHandlerRkISP1::allocateBuffers(Camera *camera)\n>  {\n>  \tRkISP1CameraData *data = cameraData(camera);\n> -\tunsigned int count = 1;\n> +\tunsigned int count = data->stream_.configuration().bufferCount;\n> +\tunsigned int ipaBufferId = 1;\n>  \tint ret;\n>  \n> -\tunsigned int maxBuffers = 0;\n> -\tfor (const Stream *s : camera->streams())\n> -\t\tmaxBuffers = std::max(maxBuffers, s->configuration().bufferCount);\n> -\n>  \tret = video_->importBuffers(count);\n>  \tif (ret < 0)\n>  \t\tgoto error;\n>  \n> -\tret = param_->allocateBuffers(maxBuffers, &paramBuffers_);\n> +\tret = param_->allocateBuffers(count, &paramBuffers_);\n>  \tif (ret < 0)\n>  \t\tgoto error;\n>  \n> -\tret = stat_->allocateBuffers(maxBuffers, &statBuffers_);\n> +\tret = stat_->allocateBuffers(count, &statBuffers_);\n>  \tif (ret < 0)\n>  \t\tgoto error;\n>  \n>  \tfor (std::unique_ptr<FrameBuffer> &buffer : paramBuffers_) {\n> -\t\tbuffer->setCookie(count++);\n> +\t\tbuffer->setCookie(ipaBufferId++);\n>  \t\tdata->ipaBuffers_.push_back({ .id = buffer->cookie(),\n>  \t\t\t\t\t      .planes = buffer->planes() });\n>  \t\tavailableParamBuffers_.push(buffer.get());\n>  \t}\n>  \n>  \tfor (std::unique_ptr<FrameBuffer> &buffer : statBuffers_) {\n> -\t\tbuffer->setCookie(count++);\n> +\t\tbuffer->setCookie(ipaBufferId++);\n>  \t\tdata->ipaBuffers_.push_back({ .id = buffer->cookie(),\n>  \t\t\t\t\t      .planes = buffer->planes() });\n>  \t\tavailableStatBuffers_.push(buffer.get());\n> -- \n> 2.25.1\n>","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x144.google.com (mail-lf1-x144.google.com\n\t[IPv6:2a00:1450:4864:20::144])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DB83B60418\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Mar 2020 01:53:29 +0100 (CET)","by mail-lf1-x144.google.com with SMTP id t21so3193673lfe.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Mar 2020 17:53:29 -0700 (PDT)","from localhost (h-200-138.A463.priv.bahnhof.se. [176.10.200.138])\n\tby smtp.gmail.com with ESMTPSA id\n\tf23sm2391963lja.42.2020.03.19.17.53.28\n\tfor <libcamera-devel@lists.libcamera.org>\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 19 Mar 2020 17:53:28 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=Gyctg9Yo86tezPeWi9SPGdhWMTovz0bGDeAzR485nj0=;\n\tb=YeWMu6C2bRxFPqaJwQDosQcF5XpBbyHiZEZAJERCdb0K/aTHx28n/qtUY/i1LEk5vc\n\tYNGTOGKES3A3p9M2x6B560JgmU23P7viUfnSirtvlChPxOlDuzpykjEUtc9I1Ebk+M5B\n\tVNsFQNAKW0DiZMDExunUaiYZXyfw8FxlS54riomN6Fx9qTKFTVlcKXYcrJqirpct02Ie\n\tJ2Iy70+/dzqVadpk8hVcotJwaUK99EN8Uoq03JxDiCiU2D4rgtGl03W669O6d1TMfZsU\n\tVKUD0Dmh7De3ZifhMtyUg2LHL97u4iH3UYggoBIQ+j16YQPHNkURYT9GM1uNIE7cunyq\n\twtcg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=Gyctg9Yo86tezPeWi9SPGdhWMTovz0bGDeAzR485nj0=;\n\tb=plDlRD35BZb2TpNFBTxzM3Bg5vlZkeyrMzkW+bquIhWunFP319GfQVg8B3VVpCiVDE\n\tofaEQOHwOLOG8wnJqHpUOja+PV+LxJngE3CYMhessZDWa+SCNtb11Bj/2e31Uy8NUIpn\n\tFo5kmcDccwdzs1iJsr0ZWlYEDFUpn5jS6cZEAB8RFIiLkklboIsS5eZYSLQvw5M/hBDj\n\tWuHYY3kk8G76CVZC0/nqFghLibu9SnnngjUJK1n8Oa0mjH2h+5O632ZSBG4WqUWe8hPC\n\t3fdZFIUQoqdEL81dVTcy1rHinYtnadBVkvF5GWO3YLzC9OAQlEczjJCt1o3HJHYPg0kp\n\t+6Jw==","X-Gm-Message-State":"ANhLgQ1fnwS9ZlTDaghPGew05wbscNZ0HVwqz/RtIqSfcfqGfnbOkyRG\n\toD2z+TtIgcMh2p16/FugERS9EOKFe+g=","X-Google-Smtp-Source":"ADFU+vsJsVe8uGUevc4FR5RKNadllA3BsArfIPG/8aaKqoSF6Xf3dyDVUjXX2W/kYm+htNa5+YFUew==","X-Received":"by 2002:a19:8491:: with SMTP id\n\tg139mr1857128lfd.28.1584665609044; \n\tThu, 19 Mar 2020 17:53:29 -0700 (PDT)","Date":"Fri, 20 Mar 2020 01:53:28 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200320005328.GB3553651@oden.dyn.berto.se>","References":"<20200320003224.3536634-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200320003224.3536634-1-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: pipeline: rkisp1: Use\n\tcorrect buffer count when importing buffers","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>","X-List-Received-Date":"Fri, 20 Mar 2020 00:53:30 -0000"}}]