From patchwork Sun Jan 31 22:46:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11096 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 154C7BD808 for ; Sun, 31 Jan 2021 22:47:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D6B5B68405; Sun, 31 Jan 2021 23:47:46 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="P8+x1yF3"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D0601683FB for ; Sun, 31 Jan 2021 23:47:34 +0100 (CET) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5B0B71837; Sun, 31 Jan 2021 23:47:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1612133254; bh=M6YJCT5HNDQZjXGdDinaNuEli/O+JV1gaSEG9v1m1RA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P8+x1yF3HqglBT11dDT6oc+tmSESlQsEF2N2rFts3Hzh/mQ44wn0Sio989k7eb09M TqReggXTuqUBGIyWzMRfMFadu85xH5e8xqwrQD8TUIDYKclNXnc+w6H4QS09aVT8sk jlv36YPhMuFpSrWgFSbFnHaGVY9w/4ya4PglT1/E= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 1 Feb 2021 00:46:59 +0200 Message-Id: <20210131224702.8838-18-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210131224702.8838-1-laurent.pinchart@ideasonboard.com> References: <20210131224702.8838-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 17/20] libcamera: pipeline: simple: Hardcode the number of internal 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: , Cc: Phi-Bang Nguyen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The number of internal buffers, used between the capture device and the converter, doesn't need to depend on the number of buffers allocated for the output stream of the pipeline. Hardcode it to a fixed value. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/simple/simple.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 9dffe64ee870..c987e1a0d9cb 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -228,6 +228,8 @@ protected: int queueRequestDevice(Camera *camera, Request *request) override; private: + static constexpr unsigned int kNumInternalBuffers = 3; + SimpleCameraData *cameraData(const Camera *camera) { return static_cast( @@ -699,7 +701,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) inputCfg.pixelFormat = pipeConfig->captureFormat; inputCfg.size = pipeConfig->captureSize; inputCfg.stride = captureFormat.planes[0].bpl; - inputCfg.bufferCount = cfg.bufferCount; + inputCfg.bufferCount = kNumInternalBuffers; ret = converter_->configure(inputCfg, { cfg }); if (ret < 0) { @@ -736,13 +738,20 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] ControlList *c { SimpleCameraData *data = cameraData(camera); V4L2VideoDevice *video = data->video_; - unsigned int count = data->streams_[0].configuration().bufferCount; int ret; - if (data->useConverter_) - ret = video->allocateBuffers(count, &data->converterBuffers_); - else - ret = video->importBuffers(count); + if (data->useConverter_) { + /* + * When using the converter allocate a fixed number of internal + * buffers. + */ + ret = video->allocateBuffers(kNumInternalBuffers, + &data->converterBuffers_); + } else { + /* Otherwise, prepare for using buffers from the only stream. */ + Stream *stream = &data->streams_[0]; + ret = video->importBuffers(stream->configuration().bufferCount); + } if (ret < 0) return ret;