[{"id":36018,"web_url":"https://patchwork.libcamera.org/comment/36018/","msgid":"<4d05c678-e5a0-4a2a-81fb-889cbde68b74@ideasonboard.com>","date":"2025-09-29T09:43:55","subject":"Re: [PATCH v2] pipeline: simple: Allow buffer counts from 1 to 32","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2025. 09. 27. 22:39 keltezéssel, Robert Mader írta:\n> While a default value of 4 buffers appears to be a good default that is\n> used by other pipelines as well, allowing both higher and lower values\n> can be desirable, notably for:\n> 1. Video encoding, e.g. encoding multiple buffers in parallel.\n> 2. Clients requesting a single buffer - e.g. in multi-stream scenarios.\n> \n> Thus allow up to 32 buffers - following the default from vb2 core - while\n> keeping the default to the previous 4.\n> \n> While on it:\n> 1. mark the config as adjusted when appropriate.\n> 2. increase the number of internal buffer used by the swISP to 4 as well.\n>     This has been shipped downstream in postmarketOS for a while and, in\n>     some cases, seems to improve stability on no-so-great drivers.\n\nI feel like (2) should be a separate change.\n\n\n> \n> Signed-off-by: Robert Mader <robert.mader@collabora.com>\n> \n> ---\n> \n> Changes since v1 with title \"pipeline: simple: Allow buffer counts from 1 to 16 for swISP\"\n> 1: Cover all cases, not just the swISP one.\n> 2: Increase maximum to 32 to match vb2 core.\n> 3: Change constant naming to better match similar ones.\n> 4: Bump kNumInternalBuffers to 4.\n> ---\n>   src/libcamera/pipeline/simple/simple.cpp | 21 ++++++++++++++++++---\n>   1 file changed, 18 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index c816cffc9..23585692c 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -378,6 +378,9 @@ public:\n>   \tconst Transform &combinedTransform() const { return combinedTransform_; }\n>   \n>   private:\n> +\tstatic constexpr unsigned int kNumBuffersDefault = 4;\n> +\tstatic constexpr unsigned int kNumBuffersMax = 32;\n> +\n>   \t/*\n>   \t * The SimpleCameraData instance is guaranteed to be valid as long as\n>   \t * the corresponding Camera instance is valid. In order to borrow a\n> @@ -417,7 +420,7 @@ protected:\n>   \tint queueRequestDevice(Camera *camera, Request *request) override;\n>   \n>   private:\n> -\tstatic constexpr unsigned int kNumInternalBuffers = 3;\n> +\tstatic constexpr unsigned int kNumInternalBuffers = 4;\n>   \n>   \tstruct EntityData {\n>   \t\tstd::unique_ptr<V4L2VideoDevice> video;\n> @@ -1239,7 +1242,7 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()\n>   \t\t    cfg.size != pipeConfig_->captureSize)\n>   \t\t\tneedConversion_ = true;\n>   \n> -\t\t/* Set the stride, frameSize and bufferCount. */\n> +\t\t/* Set the stride and frameSize. */\n>   \t\tif (needConversion_) {\n>   \t\t\tstd::tie(cfg.stride, cfg.frameSize) =\n>   \t\t\t\tdata_->converter_\n> @@ -1262,7 +1265,19 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()\n>   \t\t\tcfg.frameSize = format.planes[0].size;\n>   \t\t}\n>   \n> -\t\tcfg.bufferCount = 4;\n> +\t\tif (cfg.bufferCount == 0) {\n> +\t\t\tLOG(SimplePipeline, Debug)\n> +\t\t\t\t<< \"Adjusting bufferCount from \" << cfg.bufferCount\n> +\t\t\t\t<< \" to \" << kNumBuffersDefault;\n> +\t\t\tcfg.bufferCount = kNumBuffersDefault;\n> +\t\t\tstatus = Adjusted;\n> +\t\t} else if (cfg.bufferCount > kNumBuffersMax) {\n> +\t\t\tLOG(SimplePipeline, Debug)\n> +\t\t\t\t<< \"Adjusting bufferCount from \" << cfg.bufferCount\n> +\t\t\t\t<< \" to \" << kNumBuffersMax;\n> +\t\t\tcfg.bufferCount = kNumBuffersMax;\n> +\t\t\tstatus = Adjusted;\n> +\t\t}\n\nI think maybe I would\n\n   const auto bufferCount = cfg.bufferCount;\n   if (bufferCount <= 0)\n     cfg.bufferCount = kNumBuffersDefault;\n   else if (bufferCount > kNumBuffersMax)\n     cfg.bufferCount = kNumBuffersMax;\n\n   if (cfg.bufferCount != bufferCount) {\n     LOG(SimplePipeline, Debug) << ...;\n     status = Adjusted;\n   }\n\n\nRegards,\nBarnabás Pőcze\n\n>   \t}\n>   \n>   \treturn status;","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 2C0F0C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Sep 2025 09:44:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B5CD76B5F3;\n\tMon, 29 Sep 2025 11:44:01 +0200 (CEST)","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 D83716B58E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Sep 2025 11:43:59 +0200 (CEST)","from [192.168.33.13] (185.221.142.146.nat.pool.zt.hu\n\t[185.221.142.146])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 169034C7;\n\tMon, 29 Sep 2025 11:42:32 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"SNO2YjjP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1759138952;\n\tbh=NrDTnfTFN66MKgGYLDfOnG+LELN8AN3j9Xi+S425u0k=;\n\th=Date:Subject:To:References:From:Cc:In-Reply-To:From;\n\tb=SNO2YjjPnqf0If6ttZ8eEwOB6Ssu0tVHncSFHKWkAEZubdJD6Yzm1AEXg44+zCd4Q\n\tQtd0Dw6ZLUVWxM1pj6Y532+Z8/Od67FVCosqTKrC9nKslTk0uUd2722uEPxXVD+UrN\n\teMtd5PfdtrObwBM4qsynmebxpz0mP7F6n0qxgm64=","Message-ID":"<4d05c678-e5a0-4a2a-81fb-889cbde68b74@ideasonboard.com>","Date":"Mon, 29 Sep 2025 11:43:55 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2] pipeline: simple: Allow buffer counts from 1 to 32","To":"Robert Mader <robert.mader@collabora.com>","References":"<20250927203947.126092-1-robert.mader@collabora.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","Cc":"libcamera-devel@lists.libcamera.org","In-Reply-To":"<20250927203947.126092-1-robert.mader@collabora.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":36021,"web_url":"https://patchwork.libcamera.org/comment/36021/","msgid":"<858qhxr2ln.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-09-29T10:10:28","subject":"Re: [PATCH v2] pipeline: simple: Allow buffer counts from 1 to 32","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi Robert,\n\nRobert Mader <robert.mader@collabora.com> writes:\n\n> While a default value of 4 buffers appears to be a good default that is\n> used by other pipelines as well, allowing both higher and lower values\n> can be desirable, notably for:\n> 1. Video encoding, e.g. encoding multiple buffers in parallel.\n> 2. Clients requesting a single buffer - e.g. in multi-stream scenarios.\n>\n> Thus allow up to 32 buffers - following the default from vb2 core - while\n> keeping the default to the previous 4.\n>\n> While on it:\n> 1. mark the config as adjusted when appropriate.\n> 2. increase the number of internal buffer used by the swISP to 4 as well.\n>    This has been shipped downstream in postmarketOS for a while and, in\n>    some cases, seems to improve stability on no-so-great drivers.\n>\n> Signed-off-by: Robert Mader <robert.mader@collabora.com>\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\n\n> ---\n>\n> Changes since v1 with title \"pipeline: simple: Allow buffer counts from 1 to 16 for swISP\"\n> 1: Cover all cases, not just the swISP one.\n> 2: Increase maximum to 32 to match vb2 core.\n> 3: Change constant naming to better match similar ones.\n> 4: Bump kNumInternalBuffers to 4.\n> ---\n>  src/libcamera/pipeline/simple/simple.cpp | 21 ++++++++++++++++++---\n>  1 file changed, 18 insertions(+), 3 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index c816cffc9..23585692c 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -378,6 +378,9 @@ public:\n>  \tconst Transform &combinedTransform() const { return combinedTransform_; }\n>  \n>  private:\n> +\tstatic constexpr unsigned int kNumBuffersDefault = 4;\n> +\tstatic constexpr unsigned int kNumBuffersMax = 32;\n> +\n>  \t/*\n>  \t * The SimpleCameraData instance is guaranteed to be valid as long as\n>  \t * the corresponding Camera instance is valid. In order to borrow a\n> @@ -417,7 +420,7 @@ protected:\n>  \tint queueRequestDevice(Camera *camera, Request *request) override;\n>  \n>  private:\n> -\tstatic constexpr unsigned int kNumInternalBuffers = 3;\n> +\tstatic constexpr unsigned int kNumInternalBuffers = 4;\n>  \n>  \tstruct EntityData {\n>  \t\tstd::unique_ptr<V4L2VideoDevice> video;\n> @@ -1239,7 +1242,7 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()\n>  \t\t    cfg.size != pipeConfig_->captureSize)\n>  \t\t\tneedConversion_ = true;\n>  \n> -\t\t/* Set the stride, frameSize and bufferCount. */\n> +\t\t/* Set the stride and frameSize. */\n>  \t\tif (needConversion_) {\n>  \t\t\tstd::tie(cfg.stride, cfg.frameSize) =\n>  \t\t\t\tdata_->converter_\n> @@ -1262,7 +1265,19 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()\n>  \t\t\tcfg.frameSize = format.planes[0].size;\n>  \t\t}\n>  \n> -\t\tcfg.bufferCount = 4;\n> +\t\tif (cfg.bufferCount == 0) {\n> +\t\t\tLOG(SimplePipeline, Debug)\n> +\t\t\t\t<< \"Adjusting bufferCount from \" << cfg.bufferCount\n> +\t\t\t\t<< \" to \" << kNumBuffersDefault;\n> +\t\t\tcfg.bufferCount = kNumBuffersDefault;\n> +\t\t\tstatus = Adjusted;\n> +\t\t} else if (cfg.bufferCount > kNumBuffersMax) {\n> +\t\t\tLOG(SimplePipeline, Debug)\n> +\t\t\t\t<< \"Adjusting bufferCount from \" << cfg.bufferCount\n> +\t\t\t\t<< \" to \" << kNumBuffersMax;\n> +\t\t\tcfg.bufferCount = kNumBuffersMax;\n> +\t\t\tstatus = Adjusted;\n> +\t\t}\n>  \t}\n>  \n>  \treturn status;","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 E6453C328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Sep 2025 10:10:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F1BD76B5F3;\n\tMon, 29 Sep 2025 12:10:36 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B675D6B599\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Sep 2025 12:10:35 +0200 (CEST)","from mail-wr1-f71.google.com (mail-wr1-f71.google.com\n\t[209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-498--Oex9EsKN2CzzngqHj2fdA-1; Mon, 29 Sep 2025 06:10:31 -0400","by mail-wr1-f71.google.com with SMTP id\n\tffacd0b85a97d-3ecdc9dbc5fso2937262f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Sep 2025 03:10:31 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-40fb9e1bd14sm18277665f8f.28.2025.09.29.03.10.28\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 29 Sep 2025 03:10:28 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"No14eVc1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1759140634;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=Zznz1koYKS9P1g/XxbszZ7Tlr7U3Tzqx2Y5jQnwGqDY=;\n\tb=No14eVc1jUkBN/y0O5EKCIX6KZ782ev9YrFm6tru3oOTWRc4y1poFYMTcAKS/HxtWFRO1q\n\tS+ye88gkfCPEbljeLZBylGg6kTnQJU9jShuiQLCH37NrmsQphPMeEKqjG3J6fqyDcfb8y0\n\toNr/H9ZtbIws6tLVHRX/GqrUNjjyijk=","X-MC-Unique":"-Oex9EsKN2CzzngqHj2fdA-1","X-Mimecast-MFC-AGG-ID":"-Oex9EsKN2CzzngqHj2fdA_1759140630","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1759140630; x=1759745430;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=Zznz1koYKS9P1g/XxbszZ7Tlr7U3Tzqx2Y5jQnwGqDY=;\n\tb=KrSapPKyt8gzHU4CGl1YhlWvLWc0QqLm4DxzdyCsvX7Ooo3DubbSpkuIIZUb08T3tw\n\t7hSCYBchCLJ6G/LvyvJfnzbSnqHrNjWV/92MXQnLPAdRq2uLSCDPvv8XKmxifOOSElKi\n\tsayVhjw3XSp6/saUcxGqSIqeuCEDMtxn26gsXzfFyzAINwD2ssz1yw9OyDe6CLF0PRn0\n\tPTSPq2DZ2QKorffl5H2S2bdcKVsCqmrnD17nF5PClgVQlb5ErDV+Nq85cg+YCiRyjxxF\n\tSdsz/GnOpoVRcwA8VJYSoJTSj5Jg1oUTrTsZxDD/oaatfzXdJnZJj4J+RbHJPlU/40/X\n\t3E9w==","X-Gm-Message-State":"AOJu0Yz2muvCHjIgp1/Qrq8hr7vW3CTG2Pkf83Zw27Xw4mzcV/3U0FLl\n\t6CsyBFfOaScYgfD4zDYw2diBlXu9gQ8+KR+hL7QndCHD0odyMQxAcqt2RZkabCnoijrpJ1DmCej\n\tsJya6iKcpC+yTl6g9nbqgALvKSj17hS84cvAqXRoAES+Eiw8jWMu9GlDkdzbao+6vS8s1gfOcfF\n\tb070ukklWYQnd+YqlnHAL2TYKvBQF+HkRXrO9KPKzEknQnJl3dMxFFSlhWBgY=","X-Gm-Gg":"ASbGnctHo8wF6V87ctIh6NQ+pZh/NhNf12ghoDhWy/cy7G2LqGmpMGPCzc8y9+LWnBC\n\tEGej2xHAZFxuEjyvzzNJwJW3dw4RFXhEAfwa926sKA51kQnd4WxXjfn+cKtp4KkTmgxqxx4tQko\n\tFiHZlYxnpPrm1Wzt5vFpj/zB64Jf4ILmtOt37X3xHJb4SsdWGs7qE13AxQfoqPEmxE9/WlJoRMk\n\tGeuNycKd5b7FcN/uRIyexnex8lAsJbazLAPhXgzmZmWd4hFmQFByAnPaC85B3IWtsERVJmdob4m\n\tpZpoL1UBT923lVdKu4vczCX56jKLVYIN5W5fW0aA3du0Hdps5TxF3zZOcV4PQn1WzCgI+EoNC4p\n\tgsfVAh2QBoEx4kZvsow==","X-Received":["by 2002:a05:6000:1844:b0:3d9:70cc:6dd0 with SMTP id\n\tffacd0b85a97d-40e47ee0475mr14164988f8f.33.1759140629934; \n\tMon, 29 Sep 2025 03:10:29 -0700 (PDT)","by 2002:a05:6000:1844:b0:3d9:70cc:6dd0 with SMTP id\n\tffacd0b85a97d-40e47ee0475mr14164958f8f.33.1759140629414; \n\tMon, 29 Sep 2025 03:10:29 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IE2TLqbXfxyOa1aSIhShiFShLqxBfJKkCxlAAkqqly3zZXV2G/ooOL+2jEd3Fbhw/YhUuLYQQ==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Robert Mader <robert.mader@collabora.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2] pipeline: simple: Allow buffer counts from 1 to 32","In-Reply-To":"<20250927203947.126092-1-robert.mader@collabora.com> (Robert\n\tMader's message of \"Sat, 27 Sep 2025 22:39:47 +0200\")","References":"<20250927203947.126092-1-robert.mader@collabora.com>","Date":"Mon, 29 Sep 2025 12:10:28 +0200","Message-ID":"<858qhxr2ln.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"7Ak0pJ0vj6mrkRUEFauLkP6Ruc36CWf8VpyhoMnDLGs_1759140630","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":36055,"web_url":"https://patchwork.libcamera.org/comment/36055/","msgid":"<85a8f410-c118-43de-b5c6-4ec6ed6c0d49@collabora.com>","date":"2025-09-30T12:46:24","subject":"Re: [PATCH v2] pipeline: simple: Allow buffer counts from 1 to 32","submitter":{"id":140,"url":"https://patchwork.libcamera.org/api/people/140/","name":"Robert Mader","email":"robert.mader@collabora.com"},"content":"Hi Barnabás,\n\nOn 9/29/25 11:43, Barnabás Pőcze wrote:\n> Hi\n>\n> 2025. 09. 27. 22:39 keltezéssel, Robert Mader írta:\n>> While a default value of 4 buffers appears to be a good default that is\n>> used by other pipelines as well, allowing both higher and lower values\n>> can be desirable, notably for:\n>> 1. Video encoding, e.g. encoding multiple buffers in parallel.\n>> 2. Clients requesting a single buffer - e.g. in multi-stream scenarios.\n>>\n>> Thus allow up to 32 buffers - following the default from vb2 core - \n>> while\n>> keeping the default to the previous 4.\n>>\n>> While on it:\n>> 1. mark the config as adjusted when appropriate.\n>> 2. increase the number of internal buffer used by the swISP to 4 as \n>> well.\n>>     This has been shipped downstream in postmarketOS for a while and, in\n>>     some cases, seems to improve stability on no-so-great drivers.\n>\n> I feel like (2) should be a separate change.\nSplit it into its own commit in v3.\n>>\n>> Signed-off-by: Robert Mader <robert.mader@collabora.com>\n>>\n>> ---\n>>\n>> Changes since v1 with title \"pipeline: simple: Allow buffer counts \n>> from 1 to 16 for swISP\"\n>> 1: Cover all cases, not just the swISP one.\n>> 2: Increase maximum to 32 to match vb2 core.\n>> 3: Change constant naming to better match similar ones.\n>> 4: Bump kNumInternalBuffers to 4.\n>> ---\n>>   src/libcamera/pipeline/simple/simple.cpp | 21 ++++++++++++++++++---\n>>   1 file changed, 18 insertions(+), 3 deletions(-)\n>>\n>> diff --git a/src/libcamera/pipeline/simple/simple.cpp \n>> b/src/libcamera/pipeline/simple/simple.cpp\n>> index c816cffc9..23585692c 100644\n>> --- a/src/libcamera/pipeline/simple/simple.cpp\n>> +++ b/src/libcamera/pipeline/simple/simple.cpp\n>> @@ -378,6 +378,9 @@ public:\n>>       const Transform &combinedTransform() const { return \n>> combinedTransform_; }\n>>     private:\n>> +    static constexpr unsigned int kNumBuffersDefault = 4;\n>> +    static constexpr unsigned int kNumBuffersMax = 32;\n>> +\n>>       /*\n>>        * The SimpleCameraData instance is guaranteed to be valid as \n>> long as\n>>        * the corresponding Camera instance is valid. In order to \n>> borrow a\n>> @@ -417,7 +420,7 @@ protected:\n>>       int queueRequestDevice(Camera *camera, Request *request) override;\n>>     private:\n>> -    static constexpr unsigned int kNumInternalBuffers = 3;\n>> +    static constexpr unsigned int kNumInternalBuffers = 4;\n>>         struct EntityData {\n>>           std::unique_ptr<V4L2VideoDevice> video;\n>> @@ -1239,7 +1242,7 @@ CameraConfiguration::Status \n>> SimpleCameraConfiguration::validate()\n>>               cfg.size != pipeConfig_->captureSize)\n>>               needConversion_ = true;\n>>   -        /* Set the stride, frameSize and bufferCount. */\n>> +        /* Set the stride and frameSize. */\n>>           if (needConversion_) {\n>>               std::tie(cfg.stride, cfg.frameSize) =\n>>                   data_->converter_\n>> @@ -1262,7 +1265,19 @@ CameraConfiguration::Status \n>> SimpleCameraConfiguration::validate()\n>>               cfg.frameSize = format.planes[0].size;\n>>           }\n>>   -        cfg.bufferCount = 4;\n>> +        if (cfg.bufferCount == 0) {\n>> +            LOG(SimplePipeline, Debug)\n>> +                << \"Adjusting bufferCount from \" << cfg.bufferCount\n>> +                << \" to \" << kNumBuffersDefault;\n>> +            cfg.bufferCount = kNumBuffersDefault;\n>> +            status = Adjusted;\n>> +        } else if (cfg.bufferCount > kNumBuffersMax) {\n>> +            LOG(SimplePipeline, Debug)\n>> +                << \"Adjusting bufferCount from \" << cfg.bufferCount\n>> +                << \" to \" << kNumBuffersMax;\n>> +            cfg.bufferCount = kNumBuffersMax;\n>> +            status = Adjusted;\n>> +        }\n>\n> I think maybe I would\n>\n>   const auto bufferCount = cfg.bufferCount;\n>   if (bufferCount <= 0)\n>     cfg.bufferCount = kNumBuffersDefault;\n>   else if (bufferCount > kNumBuffersMax)\n>     cfg.bufferCount = kNumBuffersMax;\n>\n>   if (cfg.bufferCount != bufferCount) {\n>     LOG(SimplePipeline, Debug) << ...;\n>     status = Adjusted;\n>   }\nThat's indeed better, thanks!\n>\n>\n> Regards,\n> Barnabás Pőcze\n>\n>>       }\n>>         return status;\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 7ED28C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Sep 2025 12:46:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1A6E46B5F8;\n\tTue, 30 Sep 2025 14:46:34 +0200 (CEST)","from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com\n\t[136.143.188.112])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 62FFD6936E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Sep 2025 14:46:32 +0200 (CEST)","by mx.zohomail.com with SMTPS id 1759236387074408.84058050071644; \n\tTue, 30 Sep 2025 05:46:27 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=collabora.com\n\theader.i=robert.mader@collabora.com header.b=\"cYBGgdwQ\"; \n\tdkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; t=1759236388; cv=none; \n\td=zohomail.com; s=zohoarc; \n\tb=COJiS7qKMUnEWZKlKGO+qAyplZG/kCD5hhMf23edEqZqvya4mFwubZU8yjVb6AJ9KBCdwfZ4AHqL/4Ef+4iDe34ZcXWqsNI8TRziY/LiRAp6cHgJw187tfG7hLsfqKXJVUzbph3avuE4jPokD0Uw50+2Tm4xjbENEWbDqrlS2Nw=","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; \n\ts=zohoarc; t=1759236388;\n\th=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To;\n\tbh=sw/OL+I/q6+strfoFuVjIi8TjtgrBT2vQF26LSW4kRI=; \n\tb=A2ixMQihcd4BsstVe4w/akn6aguWHmMEUn1CVTeUeBLDCwScmhhdVlx18b3N44NzTciCOT0hXVMT8W5JQxHLaw/pPpQeKo80TKidYGwTVDkUzS0pRvP0nBvp21Ar/3PI0ysQnv5y3exBDFm09FiDC/743z10BsFqTWdVaT1siTo=","ARC-Authentication-Results":"i=1; mx.zohomail.com;\n\tdkim=pass  header.i=collabora.com;\n\tspf=pass  smtp.mailfrom=robert.mader@collabora.com;\n\tdmarc=pass header.from=<robert.mader@collabora.com>","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1759236388;\n\ts=zohomail; d=collabora.com; i=robert.mader@collabora.com;\n\th=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:Cc:Cc:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To;\n\tbh=sw/OL+I/q6+strfoFuVjIi8TjtgrBT2vQF26LSW4kRI=;\n\tb=cYBGgdwQJlTqw3w/keeAxwFREn3gMWSi2XrgROhjsaV+01ayYrEj5fdUtEsAZXii\n\tYUF2wagw0rCv/Ivpw97pzj7ZqbkemQK/Htqz7jIZZRio6rcuW/BJWQDTbcGUunV6zTU\n\tJ0STEz5YtBZmLbVOsKAW6L/5i511ggmqKJ0a1AqE=","Message-ID":"<85a8f410-c118-43de-b5c6-4ec6ed6c0d49@collabora.com>","Date":"Tue, 30 Sep 2025 14:46:24 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2] pipeline: simple: Allow buffer counts from 1 to 32","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20250927203947.126092-1-robert.mader@collabora.com>\n\t<4d05c678-e5a0-4a2a-81fb-889cbde68b74@ideasonboard.com>","Content-Language":"en-US, de-DE, en-GB","From":"Robert Mader <robert.mader@collabora.com>","In-Reply-To":"<4d05c678-e5a0-4a2a-81fb-889cbde68b74@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]