From patchwork Wed Dec 28 22:29:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 18064 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 D09A4C3220 for ; Wed, 28 Dec 2022 22:30:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4CA5F625EE; Wed, 28 Dec 2022 23:30:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1672266632; bh=A/v6s9S+6QPq7TXJyUJoD86lQzpWi2AxeuEf8n4vCv4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Yn5cmdmSYIej/tn0rUSxI3vTTITD4VXNfKOx3z5NDRw9eD+wDHCggJXtP6oi6fule Ud1QWN/kImg989r1mRgJDljqNgLrhiS70JH7mXBs/anKS9sMafqjrpVxRMGjHmuBky yDBxdSPowSKs7VgLF8TvLyguUQLssaoyIvaul0I5AAKVsPaaVxxfxeuW7nYflCXu0e lR6EXLnXGMywRlhEAS934Eo/50MekOmdEDfvKgeNCtg11nBuwHxtN8oPb6vtjKONlT vuHWOSSeWU+bzmaKFccv9LR/8zm53hL8zGPknGNmOws/FMap85NGrS+F8uUU+r8Pnj Kz9WEmmhP2Vdw== 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 5C6C7625DE for ; Wed, 28 Dec 2022 23:30:27 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ik78jgyA"; dkim-atps=neutral Received: from pyrite.mediacom.info (unknown [IPv6:2604:2d80:ad8a:9000:1bf9:855b:22de:3645]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0F492109; Wed, 28 Dec 2022 23:30:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1672266627; bh=A/v6s9S+6QPq7TXJyUJoD86lQzpWi2AxeuEf8n4vCv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ik78jgyAUuvDmycuCNKYeSPTvIocRNMjhM/YuWsDwQgG6yT94kLdDLzLVBxSrTrM3 Do8mf0pbmiDaf4EM1foGvJCAYbYVxX+I8NNq6B2dEEAJDn2DHeJAXyL0nPdeJz+h44 6huatWEt4K+wSyLPGFR+suX80eIOXMIyTn8yXyrY= To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Dec 2022 16:29:52 -0600 Message-Id: <20221228223003.2265712-9-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221228223003.2265712-1-paul.elder@ideasonboard.com> References: <20221228223003.2265712-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v10 08/19] libcamera: pipeline: vimc, uvcvideo: Don't rely on bufferCount 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-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: NĂ­colas F. R. A. Prado Instead of using bufferCount as the number of V4L2 buffer slots to reserve in the vimc and uvcvideo pipeline handlers, use a reasonably high constant: 16. Overallocating isn't a problem as buffer slots are cheap. Having too few, on the other hand, could degrade performance. It is expected that this number will be more than enough for most, if not all, use cases. This makes way for removing bufferCount. Signed-off-by: NĂ­colas F. R. A. Prado Reviewed-by: Paul Elder Signed-off-by: Paul Elder Reviewed-by: Jacopo Mondi --- Changes in v9: - rebased Changes in v8: - New --- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 5 +++-- src/libcamera/pipeline/vimc/vimc.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 4ce240a4..18966d01 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -97,6 +97,8 @@ private: { return static_cast(camera->_d()); } + + static constexpr unsigned int kUVCBufferSlotCount = 16; }; UVCCameraConfiguration::UVCCameraConfiguration(UVCCameraData *data) @@ -239,9 +241,8 @@ int PipelineHandlerUVC::exportFrameBuffers(Camera *camera, int PipelineHandlerUVC::start(Camera *camera, [[maybe_unused]] const ControlList *controls) { UVCCameraData *data = cameraData(camera); - unsigned int count = data->stream_.configuration().bufferCount; - int ret = data->video_->importBuffers(count); + int ret = data->video_->importBuffers(kUVCBufferSlotCount); if (ret < 0) return ret; diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index e58caf99..eaa6ebf7 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -106,6 +106,8 @@ private: { return static_cast(camera->_d()); } + + static constexpr unsigned int kVimcBufferSlotCount = 16; }; namespace { @@ -334,9 +336,8 @@ int PipelineHandlerVimc::exportFrameBuffers(Camera *camera, int PipelineHandlerVimc::start(Camera *camera, [[maybe_unused]] const ControlList *controls) { VimcCameraData *data = cameraData(camera); - unsigned int count = data->stream_.configuration().bufferCount; - int ret = data->video_->importBuffers(count); + int ret = data->video_->importBuffers(kVimcBufferSlotCount); if (ret < 0) return ret;