From patchwork Fri Dec 16 12:29:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 18022 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 0112AC31E9 for ; Fri, 16 Dec 2022 12:30:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BF79B633A9; Fri, 16 Dec 2022 13:30:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1671193817; bh=tWJBA3ZzmkGxJdFje1EEjYVPBGmeYjY0ojq/kBPOLBY=; 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=p4LGgptsXzIUHzAvmuoDbInrRyeF2+y8rQpAm7JoJmTnFb9dOBFkNFH9NjZ/2EKqt TmfLFRIdd7MHthTzdncu12vhqKnmoWt+eImzQIYO/Zu7mUuN8UKIsZAkSnQLZK9gvD WoE8DrQpJuWDlJRv2jNzM3a9riDxL10z74idBxvOSpdVQNoffc3/UBdoiC5/lds+lB LIP++So1Glo8gdEC+ImC1NpziUAt0YbKHm2gljxA6spjDegMUkvxzOZHo5VwDyESIP hqd3JtNAdP1/aiOjV1I8Febvm0NDiftrk6LNHZXLwb3yKZDQUoRg8A5Islf24+/IWh t+YfrN1CqzX/w== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 02484633A5 for ; Fri, 16 Dec 2022 13:30:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="f/4vqUtU"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8F07BA31; Fri, 16 Dec 2022 13:30:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671193815; bh=tWJBA3ZzmkGxJdFje1EEjYVPBGmeYjY0ojq/kBPOLBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f/4vqUtUusR3QI8wuBxJiZA8c9hPEYCrJFyWLBsaxVQLPVIDrK+7FKp3QvQ/1OvQh OZg/fOhty4W797OYRq0ED7iRo2gdV9ZSeRAGWe1raUDXYkM3yDxA4XFgekjBRMXcDM x1jQCsUGmfwEUW57l2aTnOJUXBdhi9q7CnoZbiDs= To: libcamera-devel@lists.libcamera.org Date: Fri, 16 Dec 2022 21:29:29 +0900 Message-Id: <20221216122939.256534-9-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221216122939.256534-1-paul.elder@ideasonboard.com> References: <20221216122939.256534-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v9 08/18] 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;