From patchwork Fri Mar 20 00:32:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 3204 Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 928B160415 for ; Fri, 20 Mar 2020 01:32:29 +0100 (CET) X-Halon-ID: 45e8eb65-6a42-11ea-89d0-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 45e8eb65-6a42-11ea-89d0-0050569116f7; Fri, 20 Mar 2020 01:32:28 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 20 Mar 2020 01:32:24 +0100 Message-Id: <20200320003224.3536634-1-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] libcamera: pipeline: rkisp1: Use correct buffer count when importing buffers 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: , X-List-Received-Date: Fri, 20 Mar 2020 00:32:29 -0000 When folding buffer management with start/stop the wrong variable was passed to importBuffers() resulting in only one buffer being imported for the video node making capture impossible. Fix this by first renaming the confusingly named variable 'count' to 'ipaBufferId'. And then reusing the 'count' name for the buffer count. While at it remove the loop to find the maximum value of buffers from the single stream used by the pipeline. Once we add more stream this needs to be reworked anyhow so keep it simple for now. Fixes: 33fedea818e2b6a9 ("libcamera: pipeline_handler: Fold buffer management with start/stop") Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 97bb4f72cde5423e..ec54291db416a669 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -668,34 +668,31 @@ int PipelineHandlerRkISP1::exportFrameBuffers(Camera *camera, Stream *stream, int PipelineHandlerRkISP1::allocateBuffers(Camera *camera) { RkISP1CameraData *data = cameraData(camera); - unsigned int count = 1; + unsigned int count = data->stream_.configuration().bufferCount; + unsigned int ipaBufferId = 1; int ret; - unsigned int maxBuffers = 0; - for (const Stream *s : camera->streams()) - maxBuffers = std::max(maxBuffers, s->configuration().bufferCount); - ret = video_->importBuffers(count); if (ret < 0) goto error; - ret = param_->allocateBuffers(maxBuffers, ¶mBuffers_); + ret = param_->allocateBuffers(count, ¶mBuffers_); if (ret < 0) goto error; - ret = stat_->allocateBuffers(maxBuffers, &statBuffers_); + ret = stat_->allocateBuffers(count, &statBuffers_); if (ret < 0) goto error; for (std::unique_ptr &buffer : paramBuffers_) { - buffer->setCookie(count++); + buffer->setCookie(ipaBufferId++); data->ipaBuffers_.push_back({ .id = buffer->cookie(), .planes = buffer->planes() }); availableParamBuffers_.push(buffer.get()); } for (std::unique_ptr &buffer : statBuffers_) { - buffer->setCookie(count++); + buffer->setCookie(ipaBufferId++); data->ipaBuffers_.push_back({ .id = buffer->cookie(), .planes = buffer->planes() }); availableStatBuffers_.push(buffer.get());