[{"id":34362,"web_url":"https://patchwork.libcamera.org/comment/34362/","msgid":"<174836037869.433416.9227880848619164582@ping.linuxembedded.co.uk>","date":"2025-05-27T15:39:38","subject":"Re: [RFC PATCH 4/4] pipeline: rkisp1: Prperly handle the bufferCount\n\tset in the stream configuration","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-05-26 22:42:18)\n> The bufferCount is reset to a hardcoded value of 4 in RkISP1Path::validate().\n> Keep the default value of 4 but do not reset it, if it was changed.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp      | 5 +++--\n>  src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 6 ++----\n>  src/libcamera/pipeline/rkisp1/rkisp1_path.h   | 4 +---\n>  3 files changed, 6 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index af9117c83630..ea94bccd252d 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -791,6 +791,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,\n>                         return nullptr;\n>  \n>                 cfg.colorSpace = colorSpace;\n> +               cfg.bufferCount = kPipelineDepth;\n\nDoes the user setting this larger now have any effect anywhere at all ?\nor does cfg.bufferCount become unused ?\n\n>                 config->addConfiguration(cfg);\n>         }\n>  \n> @@ -1124,14 +1125,14 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL\n>         }\n>  \n>         if (data->mainPath_->isEnabled()) {\n> -               ret = mainPath_.start();\n> +               ret = mainPath_.start(maxQueuedRequestsDevice());\n>                 if (ret)\n>                         return ret;\n>                 actions += [&]() { mainPath_.stop(); };\n>         }\n>  \n>         if (hasSelfPath_ && data->selfPath_->isEnabled()) {\n> -               ret = selfPath_.start();\n> +               ret = selfPath_.start(maxQueuedRequestsDevice());\n>                 if (ret)\n>                         return ret;\n>         }\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n> index 64018dc5b2f4..2f482fcc1834 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n> @@ -249,7 +249,6 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size,\n>         StreamConfiguration cfg(formats);\n>         cfg.pixelFormat = format;\n>         cfg.size = streamSize;\n> -       cfg.bufferCount = RKISP1_BUFFER_COUNT;\n>  \n>         return cfg;\n>  }\n> @@ -383,7 +382,6 @@ RkISP1Path::validate(const CameraSensor *sensor,\n>  \n>         cfg->size.boundTo(maxResolution);\n>         cfg->size.expandTo(minResolution);\n> -       cfg->bufferCount = RKISP1_BUFFER_COUNT;\n>  \n>         V4L2DeviceFormat format;\n>         format.fourcc = video_->toV4L2PixelFormat(cfg->pixelFormat);\n> @@ -480,7 +478,7 @@ int RkISP1Path::configure(const StreamConfiguration &config,\n>         return 0;\n>  }\n>  \n> -int RkISP1Path::start()\n> +int RkISP1Path::start(unsigned int bufferCount)\n>  {\n>         int ret;\n>  \n> @@ -488,7 +486,7 @@ int RkISP1Path::start()\n>                 return -EBUSY;\n>  \n>         /* \\todo Make buffer count user configurable. */\n> -       ret = video_->importBuffers(RKISP1_BUFFER_COUNT);\n> +       ret = video_->importBuffers(bufferCount);\n\n\nSo - I think we should do some extra digging here.\n\nI think we might actually want to 'import' the V4L2 maximum here (and in\ngeneral, always) as that's more about setting up the structures that let\nus use externally provided dmabufs and get them into libcamera.\n\nIf we now restrict this to '4' but we have '8' separate iterating\nbuffers we blow through the v4l2-buffer-cache each iteration.\n\nI think the maximum is something like 32 - and this is a small memory\ncost to allocote so we should be doing this automatically at the\nV4L2VideoDevice::importBuffers() operation.\n\n\n\n>         if (ret)\n>                 return ret;\n>  \n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n> index 430181d371a7..0b60c499ac64 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n> @@ -58,7 +58,7 @@ public:\n>                 return video_->exportBuffers(bufferCount, buffers);\n>         }\n>  \n> -       int start();\n> +       int start(unsigned int bufferCount);\n>         void stop();\n>  \n>         int queueBuffer(FrameBuffer *buffer) { return video_->queueBuffer(buffer); }\n> @@ -69,8 +69,6 @@ private:\n>         void populateFormats();\n>         Size filterSensorResolution(const CameraSensor *sensor);\n>  \n> -       static constexpr unsigned int RKISP1_BUFFER_COUNT = 4;\n> -\n>         const char *name_;\n>         bool running_;\n>  \n> -- \n> 2.43.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 B969AC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 May 2025 15:39:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6B99F68DA0;\n\tTue, 27 May 2025 17:39:43 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6403468D94\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 May 2025 17:39:41 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A8BBB2B3;\n\tTue, 27 May 2025 17:39:15 +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=\"IS9ghYQm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1748360355;\n\tbh=l30e90lHUvAk5Ge5hQPGlSNmgP3Cd8U1SOdNEAUr9CU=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=IS9ghYQmE1K6etWdw2N52uO7UQYQ7fg5tlb9mai200q/CCFYhxgUCQxJWE0+PDobs\n\t6Zc/09QGuBksH3uFJw0yTYdelxZvlO8V8qseFEJX5UP+jWEWTElLPSbqOSH7Pk7HAr\n\tqI7NtLlBnB7cuOZuJa4QpOFLNmsqXC8Q8/xL0iJA=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250526214224.13631-5-stefan.klug@ideasonboard.com>","References":"<20250526214224.13631-1-stefan.klug@ideasonboard.com>\n\t<20250526214224.13631-5-stefan.klug@ideasonboard.com>","Subject":"Re: [RFC PATCH 4/4] pipeline: rkisp1: Prperly handle the bufferCount\n\tset in the stream configuration","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 27 May 2025 16:39:38 +0100","Message-ID":"<174836037869.433416.9227880848619164582@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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":34383,"web_url":"https://patchwork.libcamera.org/comment/34383/","msgid":"<84d8de88-d055-4894-9768-20b9c226ccdf@pengutronix.de>","date":"2025-05-30T05:48:25","subject":"Re: [RFC PATCH 4/4] pipeline: rkisp1: Prperly handle the bufferCount\n\tset in the stream configuration","submitter":{"id":225,"url":"https://patchwork.libcamera.org/api/people/225/","name":"Sven Püschel","email":"s.pueschel@pengutronix.de"},"content":"Hi Stefan,\n\njust noticed a typo in the commit title Prperly -> Properly\n\nOn 5/26/25 23:42, Stefan Klug wrote:\n> The bufferCount is reset to a hardcoded value of 4 in RkISP1Path::validate().\n> Keep the default value of 4 but do not reset it, if it was changed.\n>\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>   src/libcamera/pipeline/rkisp1/rkisp1.cpp      | 5 +++--\n>   src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 6 ++----\n>   src/libcamera/pipeline/rkisp1/rkisp1_path.h   | 4 +---\n>   3 files changed, 6 insertions(+), 9 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index af9117c83630..ea94bccd252d 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -791,6 +791,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,\n>   \t\t\treturn nullptr;\n>   \n>   \t\tcfg.colorSpace = colorSpace;\n> +\t\tcfg.bufferCount = kPipelineDepth;\n>   \t\tconfig->addConfiguration(cfg);\n>   \t}\n>   \n> @@ -1124,14 +1125,14 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL\n>   \t}\n>   \n>   \tif (data->mainPath_->isEnabled()) {\n> -\t\tret = mainPath_.start();\n> +\t\tret = mainPath_.start(maxQueuedRequestsDevice());\n>   \t\tif (ret)\n>   \t\t\treturn ret;\n>   \t\tactions += [&]() { mainPath_.stop(); };\n>   \t}\n>   \n>   \tif (hasSelfPath_ && data->selfPath_->isEnabled()) {\n> -\t\tret = selfPath_.start();\n> +\t\tret = selfPath_.start(maxQueuedRequestsDevice());\n>   \t\tif (ret)\n>   \t\t\treturn ret;\n>   \t}\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n> index 64018dc5b2f4..2f482fcc1834 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n> @@ -249,7 +249,6 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size,\n>   \tStreamConfiguration cfg(formats);\n>   \tcfg.pixelFormat = format;\n>   \tcfg.size = streamSize;\n> -\tcfg.bufferCount = RKISP1_BUFFER_COUNT;\n>   \n>   \treturn cfg;\n>   }\n> @@ -383,7 +382,6 @@ RkISP1Path::validate(const CameraSensor *sensor,\n>   \n>   \tcfg->size.boundTo(maxResolution);\n>   \tcfg->size.expandTo(minResolution);\n> -\tcfg->bufferCount = RKISP1_BUFFER_COUNT;\n>   \n>   \tV4L2DeviceFormat format;\n>   \tformat.fourcc = video_->toV4L2PixelFormat(cfg->pixelFormat);\n> @@ -480,7 +478,7 @@ int RkISP1Path::configure(const StreamConfiguration &config,\n>   \treturn 0;\n>   }\n>   \n> -int RkISP1Path::start()\n> +int RkISP1Path::start(unsigned int bufferCount)\n>   {\n>   \tint ret;\n>   \n> @@ -488,7 +486,7 @@ int RkISP1Path::start()\n>   \t\treturn -EBUSY;\n>   \n>   \t/* \\todo Make buffer count user configurable. */\n> -\tret = video_->importBuffers(RKISP1_BUFFER_COUNT);\n> +\tret = video_->importBuffers(bufferCount);\n\nThe todo can also be removed with this change.\n\n\nSincerely\n\n     Sven\n\n>   \tif (ret)\n>   \t\treturn ret;\n>   \n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n> index 430181d371a7..0b60c499ac64 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n> @@ -58,7 +58,7 @@ public:\n>   \t\treturn video_->exportBuffers(bufferCount, buffers);\n>   \t}\n>   \n> -\tint start();\n> +\tint start(unsigned int bufferCount);\n>   \tvoid stop();\n>   \n>   \tint queueBuffer(FrameBuffer *buffer) { return video_->queueBuffer(buffer); }\n> @@ -69,8 +69,6 @@ private:\n>   \tvoid populateFormats();\n>   \tSize filterSensorResolution(const CameraSensor *sensor);\n>   \n> -\tstatic constexpr unsigned int RKISP1_BUFFER_COUNT = 4;\n> -\n>   \tconst char *name_;\n>   \tbool running_;\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 50503C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 30 May 2025 05:48:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2466168DA6;\n\tFri, 30 May 2025 07:48:28 +0200 (CEST)","from metis.whiteo.stw.pengutronix.de\n\t(metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1DBE36163C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 30 May 2025 07:48:26 +0200 (CEST)","from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77]\n\thelo=[127.0.0.1])\n\tby metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92)\n\t(envelope-from <s.pueschel@pengutronix.de>) id 1uKsbR-0007Cp-Kj\n\tfor libcamera-devel@lists.libcamera.org;\n\tFri, 30 May 2025 07:48:25 +0200"],"Message-ID":"<84d8de88-d055-4894-9768-20b9c226ccdf@pengutronix.de>","Date":"Fri, 30 May 2025 07:48:25 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [RFC PATCH 4/4] pipeline: rkisp1: Prperly handle the bufferCount\n\tset in the stream configuration","To":"libcamera-devel@lists.libcamera.org","References":"<20250526214224.13631-1-stefan.klug@ideasonboard.com>\n\t<20250526214224.13631-5-stefan.klug@ideasonboard.com>","Content-Language":"en-US","From":"=?utf-8?q?Sven_P=C3=BCschel?= <s.pueschel@pengutronix.de>","In-Reply-To":"<20250526214224.13631-5-stefan.klug@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","X-SA-Exim-Connect-IP":"2a0a:edc0:0:900:1d::77","X-SA-Exim-Mail-From":"s.pueschel@pengutronix.de","X-SA-Exim-Scanned":"No (on metis.whiteo.stw.pengutronix.de);\n\tSAEximRunCond expanded to false","X-PTX-Original-Recipient":"libcamera-devel@lists.libcamera.org","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":34390,"web_url":"https://patchwork.libcamera.org/comment/34390/","msgid":"<wj5poa4azs46k3nv65qhiusidnbswv6fsd77wfpqyuzb467hjp@33nzy2bx2nxj>","date":"2025-05-30T09:58:10","subject":"Re: [RFC PATCH 4/4] pipeline: rkisp1: Prperly handle the bufferCount\n\tset in the stream configuration","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Kieran\n\nOn Tue, May 27, 2025 at 04:39:38PM +0100, Kieran Bingham wrote:\n> Quoting Stefan Klug (2025-05-26 22:42:18)\n> > The bufferCount is reset to a hardcoded value of 4 in RkISP1Path::validate().\n> > Keep the default value of 4 but do not reset it, if it was changed.\n> >\n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> >  src/libcamera/pipeline/rkisp1/rkisp1.cpp      | 5 +++--\n> >  src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 6 ++----\n> >  src/libcamera/pipeline/rkisp1/rkisp1_path.h   | 4 +---\n> >  3 files changed, 6 insertions(+), 9 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > index af9117c83630..ea94bccd252d 100644\n> > --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > @@ -791,6 +791,7 @@ PipelineHandlerRkISP1::generateConfiguration(Camera *camera,\n> >                         return nullptr;\n> >\n> >                 cfg.colorSpace = colorSpace;\n> > +               cfg.bufferCount = kPipelineDepth;\n>\n> Does the user setting this larger now have any effect anywhere at all ?\n> or does cfg.bufferCount become unused ?\n>\n> >                 config->addConfiguration(cfg);\n> >         }\n> >\n> > @@ -1124,14 +1125,14 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL\n> >         }\n> >\n> >         if (data->mainPath_->isEnabled()) {\n> > -               ret = mainPath_.start();\n> > +               ret = mainPath_.start(maxQueuedRequestsDevice());\n> >                 if (ret)\n> >                         return ret;\n> >                 actions += [&]() { mainPath_.stop(); };\n> >         }\n> >\n> >         if (hasSelfPath_ && data->selfPath_->isEnabled()) {\n> > -               ret = selfPath_.start();\n> > +               ret = selfPath_.start(maxQueuedRequestsDevice());\n> >                 if (ret)\n> >                         return ret;\n> >         }\n> > diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n> > index 64018dc5b2f4..2f482fcc1834 100644\n> > --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n> > +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n> > @@ -249,7 +249,6 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size,\n> >         StreamConfiguration cfg(formats);\n> >         cfg.pixelFormat = format;\n> >         cfg.size = streamSize;\n> > -       cfg.bufferCount = RKISP1_BUFFER_COUNT;\n> >\n> >         return cfg;\n> >  }\n> > @@ -383,7 +382,6 @@ RkISP1Path::validate(const CameraSensor *sensor,\n> >\n> >         cfg->size.boundTo(maxResolution);\n> >         cfg->size.expandTo(minResolution);\n> > -       cfg->bufferCount = RKISP1_BUFFER_COUNT;\n> >\n> >         V4L2DeviceFormat format;\n> >         format.fourcc = video_->toV4L2PixelFormat(cfg->pixelFormat);\n> > @@ -480,7 +478,7 @@ int RkISP1Path::configure(const StreamConfiguration &config,\n> >         return 0;\n> >  }\n> >\n> > -int RkISP1Path::start()\n> > +int RkISP1Path::start(unsigned int bufferCount)\n> >  {\n> >         int ret;\n> >\n> > @@ -488,7 +486,7 @@ int RkISP1Path::start()\n> >                 return -EBUSY;\n> >\n> >         /* \\todo Make buffer count user configurable. */\n> > -       ret = video_->importBuffers(RKISP1_BUFFER_COUNT);\n> > +       ret = video_->importBuffers(bufferCount);\n>\n>\n> So - I think we should do some extra digging here.\n>\n> I think we might actually want to 'import' the V4L2 maximum here (and in\n> general, always) as that's more about setting up the structures that let\n> us use externally provided dmabufs and get them into libcamera.\n>\n> If we now restrict this to '4' but we have '8' separate iterating\n> buffers we blow through the v4l2-buffer-cache each iteration.\n>\n> I think the maximum is something like 32 - and this is a small memory\n> cost to allocote so we should be doing this automatically at the\n> V4L2VideoDevice::importBuffers() operation.\n>\n\nvideobuf2 defines\n\n#define VB2_MAX_FRAME\t(32)\n\nbut drivers can override it (I only see the Hantro driver actually\noverriding that value, but other drivers could do that in future).\n\nDrivers using the CREATE_BUF ioctl can report the max number of\nbuffers, but drivers using REQBUFS don't as far as I can tell.\n\nAll of this to say that we should probably set the max number of\nbuffers in the pipeline and not automatically in the V4L2VideoDevice\nclass.\n\n>\n>\n> >         if (ret)\n> >                 return ret;\n> >\n> > diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n> > index 430181d371a7..0b60c499ac64 100644\n> > --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n> > +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h\n> > @@ -58,7 +58,7 @@ public:\n> >                 return video_->exportBuffers(bufferCount, buffers);\n> >         }\n> >\n> > -       int start();\n> > +       int start(unsigned int bufferCount);\n> >         void stop();\n> >\n> >         int queueBuffer(FrameBuffer *buffer) { return video_->queueBuffer(buffer); }\n> > @@ -69,8 +69,6 @@ private:\n> >         void populateFormats();\n> >         Size filterSensorResolution(const CameraSensor *sensor);\n> >\n> > -       static constexpr unsigned int RKISP1_BUFFER_COUNT = 4;\n> > -\n> >         const char *name_;\n> >         bool running_;\n> >\n> > --\n> > 2.43.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 8BDDBC31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 30 May 2025 09:58:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B495E68DA8;\n\tFri, 30 May 2025 11:58:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A6E4D614D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 30 May 2025 11:58:14 +0200 (CEST)","from ideasonboard.com (mob-5-90-143-247.net.vodafone.it\n\t[5.90.143.247])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BBB6982E;\n\tFri, 30 May 2025 11:57:46 +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=\"FEQuwc0k\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1748599066;\n\tbh=zVnfSK/Zm7yaGoocU+444MrYN0DLGwU69j88ALFa57g=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FEQuwc0k0nK0HzqOyEEOcXqW/wI4Xn+HvpqhzYFragw7dYBF7Bv6b6C+BMYR6xOVd\n\txWGpyuqbVnV5JuJRn8RW67o9NIJHpto9tZ3/YBXvxZ4b34U4HKumfZLpemYnEQyZTf\n\t3vHXzGxp813XeHS2AXLaQ56vtaaw3Zm8VOaA977M=","Date":"Fri, 30 May 2025 11:58:10 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH 4/4] pipeline: rkisp1: Prperly handle the bufferCount\n\tset in the stream configuration","Message-ID":"<wj5poa4azs46k3nv65qhiusidnbswv6fsd77wfpqyuzb467hjp@33nzy2bx2nxj>","References":"<20250526214224.13631-1-stefan.klug@ideasonboard.com>\n\t<20250526214224.13631-5-stefan.klug@ideasonboard.com>\n\t<174836037869.433416.9227880848619164582@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<174836037869.433416.9227880848619164582@ping.linuxembedded.co.uk>","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>"}}]