[{"id":25932,"web_url":"https://patchwork.libcamera.org/comment/25932/","msgid":"<Y4c8hiri4eldYwtd@pyrite.rasen.tech>","date":"2022-11-30T11:20:38","subject":"Re: [libcamera-devel] [PATCH v8 07/17] libcamera: pipeline: vimc,\n\tuvcvideo: Don't rely on bufferCount","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Tue, Aug 24, 2021 at 04:56:26PM -0300, Nícolas F. R. A. Prado wrote:\n> Instead of using bufferCount as the number of V4L2 buffer slots to\n> reserve in the vimc and uvcvideo pipeline handlers, use a reasonably\n> high constant: 16. Overallocating isn't a problem as buffer slots are\n> cheap. Having too few, on the other hand, could degrade performance. It\n> is expected that this number will be more than enough for most, if not\n> all, use cases.\n> \n> This makes way for removing bufferCount.\n> \n> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \n> ---\n> \n> Changes in v8:\n> - New\n> \n>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 5 +++--\n>  src/libcamera/pipeline/vimc/vimc.cpp         | 5 +++--\n>  2 files changed, 6 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> index 7821cacfa883..c210cf57750f 100644\n> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> @@ -91,6 +91,8 @@ private:\n>  \t{\n>  \t\treturn static_cast<UVCCameraData *>(camera->_d());\n>  \t}\n> +\n> +\tstatic constexpr unsigned int kUVCBufferSlotCount = 16;\n>  };\n>  \n>  UVCCameraConfiguration::UVCCameraConfiguration(UVCCameraData *data)\n> @@ -236,9 +238,8 @@ int PipelineHandlerUVC::exportFrameBuffers(Camera *camera,\n>  int PipelineHandlerUVC::start(Camera *camera, [[maybe_unused]] const ControlList *controls)\n>  {\n>  \tUVCCameraData *data = cameraData(camera);\n> -\tunsigned int count = data->stream_.configuration().bufferCount;\n>  \n> -\tint ret = data->video_->importBuffers(count);\n> +\tint ret = data->video_->importBuffers(kUVCBufferSlotCount);\n>  \tif (ret < 0)\n>  \t\treturn ret;\n>  \n> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> index eebdfd1a4c01..d2943f61a745 100644\n> --- a/src/libcamera/pipeline/vimc/vimc.cpp\n> +++ b/src/libcamera/pipeline/vimc/vimc.cpp\n> @@ -105,6 +105,8 @@ private:\n>  \t{\n>  \t\treturn static_cast<VimcCameraData *>(camera->_d());\n>  \t}\n> +\n> +\tstatic constexpr unsigned int kVimcBufferSlotCount = 16;\n>  };\n>  \n>  namespace {\n> @@ -331,9 +333,8 @@ int PipelineHandlerVimc::exportFrameBuffers(Camera *camera,\n>  int PipelineHandlerVimc::start(Camera *camera, [[maybe_unused]] const ControlList *controls)\n>  {\n>  \tVimcCameraData *data = cameraData(camera);\n> -\tunsigned int count = data->stream_.configuration().bufferCount;\n>  \n> -\tint ret = data->video_->importBuffers(count);\n> +\tint ret = data->video_->importBuffers(kVimcBufferSlotCount);\n>  \tif (ret < 0)\n>  \t\treturn ret;\n>  \n> -- \n> 2.33.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B1D46BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 30 Nov 2022 11:20:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 77A9863336;\n\tWed, 30 Nov 2022 12:20:46 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7046861F23\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 30 Nov 2022 12:20:45 +0100 (CET)","from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B181313EA;\n\tWed, 30 Nov 2022 12:20:43 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669807246;\n\tbh=cRFHyyQbnKtLoRo2X1Nfq7wrZC3L+ExVoQeVaINeeR8=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=INAP/pBXkuwiwV6fQDwhKG/nJFILyiUgr3U2QLTXm1L4zE2/uQUWAxm5NOkIYClPt\n\tvwFRX1KA2DBCy+BmZiDxu6KJwT9H6z5RCgLtaAJQAhk59D22TvMNX1185nVp9R+wV/\n\tUf6atW+74RRpDpUOBjNi9aY0ZcbwFInekKgB/04tm3dHaV5RWLi3kL4ji8q0Tymt0i\n\tYxIwF4XWesBfO+UP7id+KOUle4g5sUbTGJW1GEfZ6IkJm4J++8lYMngKJWUrUVTRgC\n\tVjeZ0mC7/aTCX5hFINzo3ahwkfpRzUFFO5A1nl0ZmSiJDvFlmllwlpeOOrJtND/R/2\n\tMdYQ0z1kw04Dg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669807245;\n\tbh=cRFHyyQbnKtLoRo2X1Nfq7wrZC3L+ExVoQeVaINeeR8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=hUMPyVj31Vk40t1u4S1WsaHxuWJgHp5lB8T4BmOsrhZ+bJBDKC9VLJOkHW9Bvn4GR\n\tSw4g3+Z1114Xsrjs/XorjQ+VbZVSgGbqsT03Vx6bnVE5A82QtFHo3Z4ItWzA3+8d6O\n\tj3sgAgME6+ybswUMk6b0FPhGkg9guILibQsOsDmY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"hUMPyVj3\"; dkim-atps=neutral","Date":"Wed, 30 Nov 2022 20:20:38 +0900","To":"=?iso-8859-1?q?N=EDcolas_F=2E_R=2E_A=2E?= Prado <nfraprado@collabora.com>","Message-ID":"<Y4c8hiri4eldYwtd@pyrite.rasen.tech>","References":"<20210824195636.1110845-1-nfraprado@collabora.com>\n\t<20210824195636.1110845-8-nfraprado@collabora.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20210824195636.1110845-8-nfraprado@collabora.com>","Subject":"Re: [libcamera-devel] [PATCH v8 07/17] libcamera: pipeline: vimc,\n\tuvcvideo: Don't rely on bufferCount","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, kernel@collabora.com,\n\t=?iso-8859-1?q?Andr=E9?= Almeida <andrealmeid@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]