[{"id":23604,"web_url":"https://patchwork.libcamera.org/comment/23604/","msgid":"<YrmWtKNU9kRaa8ZM@pendragon.ideasonboard.com>","date":"2022-06-27T11:38:28","subject":"Re: [libcamera-devel] [PATCH] pipeline: rkisp1: Support devices\n\twithout self path","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Mon, Jun 27, 2022 at 08:08:59PM +0900, Paul Elder via libcamera-devel wrote:\n> Some hardware supported by the rkisp1 driver, such as the ISP in the\n> i.MX8MP, don't have a self path. Although at the moment the driver still\n> exposes the self path, prepare the rkisp1 pipeline handler for when the\n> self path will be removed for devices that don't support it.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 45 ++++++++++++++++--------\n>  1 file changed, 31 insertions(+), 14 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 7cf36524..83977fbc 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -179,6 +179,8 @@ private:\n>  \tstd::unique_ptr<V4L2VideoDevice> param_;\n>  \tstd::unique_ptr<V4L2VideoDevice> stat_;\n>  \n> +\tbool hasSelfPath_;\n> +\n>  \tRkISP1MainPath mainPath_;\n>  \tRkISP1SelfPath selfPath_;\n>  \n> @@ -343,7 +345,7 @@ void RkISP1CameraData::paramFilled(unsigned int frame)\n>  \tif (info->mainPathBuffer)\n>  \t\tmainPath_->queueBuffer(info->mainPathBuffer);\n>  \n> -\tif (info->selfPathBuffer)\n> +\tif (info->selfPathBuffer && selfPath_)\n>  \t\tselfPath_->queueBuffer(info->selfPathBuffer);\n>  }\n>  \n> @@ -382,7 +384,7 @@ bool RkISP1CameraConfiguration::fitsAllPaths(const StreamConfiguration &cfg)\n>  \t\treturn false;\n>  \n>  \tconfig = cfg;\n> -\tif (data_->selfPath_->validate(&config) != Valid)\n> +\tif (data_->selfPath_ && data_->selfPath_->validate(&config) != Valid)\n>  \t\treturn false;\n>  \n>  \treturn true;\n> @@ -420,7 +422,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n>  \t\tstd::reverse(order.begin(), order.end());\n>  \n>  \tbool mainPathAvailable = true;\n> -\tbool selfPathAvailable = true;\n> +\tbool selfPathAvailable = data_->selfPath_;\n\nA bit above in the same function, I think you should resize the config_\nvector based on the number of available paths.\n\n>  \tfor (unsigned int index : order) {\n>  \t\tStreamConfiguration &cfg = config_[index];\n>  \n> @@ -499,7 +501,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n>  }\n>  \n>  PipelineHandlerRkISP1::PipelineHandlerRkISP1(CameraManager *manager)\n> -\t: PipelineHandler(manager)\n> +\t: PipelineHandler(manager), hasSelfPath_(true)\n>  {\n>  }\n>  \n> @@ -516,7 +518,7 @@ CameraConfiguration *PipelineHandlerRkISP1::generateConfiguration(Camera *camera\n>  \t\treturn config;\n>  \n>  \tbool mainPathAvailable = true;\n> -\tbool selfPathAvailable = true;\n> +\tbool selfPathAvailable = data->selfPath_;\n>  \tfor (const StreamRole role : roles) {\n>  \t\tbool useMainPath;\n>  \n> @@ -619,7 +621,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n>  \t\t\tret = mainPath_.configure(cfg, format);\n>  \t\t\tstreamConfig[0] = IPAStream(cfg.pixelFormat,\n>  \t\t\t\t\t\t    cfg.size);\n> -\t\t} else {\n> +\t\t} else if (hasSelfPath_) {\n>  \t\t\tret = selfPath_.configure(cfg, format);\n>  \t\t\tstreamConfig[1] = IPAStream(cfg.pixelFormat,\n>  \t\t\t\t\t\t    cfg.size);\n\nThis won't work correctly if two roles are specified.\n\n> @@ -670,7 +672,7 @@ int PipelineHandlerRkISP1::exportFrameBuffers([[maybe_unused]] Camera *camera, S\n>  \n>  \tif (stream == &data->mainPathStream_)\n>  \t\treturn mainPath_.exportBuffers(count, buffers);\n> -\telse if (stream == &data->selfPathStream_)\n> +\telse if (hasSelfPath_ && stream == &data->selfPathStream_)\n\nI think this change could be skipped as the function should never get\ncalled for the self path if not available, but it doesn't hurt to keep\nit.\n\n>  \t\treturn selfPath_.exportBuffers(count, buffers);\n>  \n>  \treturn -EINVAL;\n> @@ -799,7 +801,7 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL\n>  \t\t}\n>  \t}\n>  \n> -\tif (data->selfPath_->isEnabled()) {\n> +\tif (hasSelfPath_ && data->selfPath_->isEnabled()) {\n>  \t\tret = selfPath_.start();\n>  \t\tif (ret) {\n>  \t\t\tmainPath_.stop();\n> @@ -826,7 +828,8 @@ void PipelineHandlerRkISP1::stopDevice(Camera *camera)\n>  \n>  \tdata->ipa_->stop();\n>  \n> -\tselfPath_.stop();\n> +\tif (hasSelfPath_)\n> +\t\tselfPath_.stop();\n>  \tmainPath_.stop();\n>  \n>  \tret = stat_->streamOff();\n> @@ -917,7 +920,8 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)\n>  \tint ret;\n>  \n>  \tstd::unique_ptr<RkISP1CameraData> data =\n> -\t\tstd::make_unique<RkISP1CameraData>(this, &mainPath_, &selfPath_);\n> +\t\tstd::make_unique<RkISP1CameraData>(this, &mainPath_,\n> +\t\t\t\t\t\t   hasSelfPath_ ? &selfPath_ : nullptr);\n>  \n>  \tControlInfoMap::Map ctrls;\n>  \tctrls.emplace(std::piecewise_construct,\n> @@ -980,9 +984,21 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)\n>  \tdm.add(\"rkisp1_stats\");\n>  \tdm.add(\"rkisp1_params\");\n>  \n> +\tDeviceMatch dmNoSelf(\"rkisp1\");\n> +\tdmNoSelf.add(\"rkisp1_isp\");\n> +\tdmNoSelf.add(\"rkisp1_resizer_mainpath\");\n> +\tdmNoSelf.add(\"rkisp1_mainpath\");\n> +\tdmNoSelf.add(\"rkisp1_stats\");\n> +\tdmNoSelf.add(\"rkisp1_params\");\n> +\n>  \tmedia_ = acquireMediaDevice(enumerator, dm);\n> -\tif (!media_)\n> -\t\treturn false;\n> +\tif (!media_) {\n> +\t\tmedia_ = acquireMediaDevice(enumerator, dmNoSelf);\n> +\t\tif (!media_)\n> +\t\t\treturn false;\n> +\n> +\t\thasSelfPath_ = false;\n> +\t}\n\nYou can make this simpler, use a single DeviceMatch that has no\nselfpath, and add\n\n\thasSelfPath_ = !!media_->getEntityByName(\"rkisp1_selfpath\");\n\n>  \n>  \tif (!media_->hwRevision()) {\n>  \t\tLOG(RkISP1, Error)\n> @@ -1008,11 +1024,12 @@ bool PipelineHandlerRkISP1::match(DeviceEnumerator *enumerator)\n>  \tif (!mainPath_.init(media_))\n>  \t\treturn false;\n>  \n> -\tif (!selfPath_.init(media_))\n> +\tif (hasSelfPath_ && !selfPath_.init(media_))\n>  \t\treturn false;\n>  \n>  \tmainPath_.bufferReady().connect(this, &PipelineHandlerRkISP1::bufferReady);\n> -\tselfPath_.bufferReady().connect(this, &PipelineHandlerRkISP1::bufferReady);\n> +\tif (hasSelfPath_)\n> +\t\tselfPath_.bufferReady().connect(this, &PipelineHandlerRkISP1::bufferReady);\n>  \tstat_->bufferReady.connect(this, &PipelineHandlerRkISP1::statReady);\n>  \tparam_->bufferReady.connect(this, &PipelineHandlerRkISP1::paramReady);\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 9998FBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Jun 2022 11:38:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DB10C65635;\n\tMon, 27 Jun 2022 13:38:48 +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 75B626059B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Jun 2022 13:38:47 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 916791C82;\n\tMon, 27 Jun 2022 13:38:46 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656329928;\n\tbh=8/rhnxEOquQE6Vu3xTCN30kln+/ShaUATZnc/Kr7N5E=;\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=t3FFBLeSO4xGlNxIXUQNsJff+M+fXyBApsdYh0Tq+N0P+eNDYJsPclpp3ga2OwdV+\n\t2u9bhJBYUG7ZvvQRkpMPOuPu1oqLI/b3PwTGMzHh/fj5igGZbgmlltNt2XqjoV3Hh5\n\tR2NYh/vuh7AfOt2vVmkHypu517Y0YWwEWJh+PWSe8cESmQmS53tw0jMy4ut+/w3nmr\n\tRq6O7qcf8CZs45shfRIe7UPGWDUypGm/PFJVll9ZYsZuPRa2pBaGNwicW7616ToitG\n\t6rI6737LKhth1IaA+MK/JQ6GNsFn9chAYFoiWAgTeQNYA0F/3cEyAk1ieJqh22l84x\n\t34yPImivx+rlg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656329927;\n\tbh=8/rhnxEOquQE6Vu3xTCN30kln+/ShaUATZnc/Kr7N5E=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=YOVGzLxYXwUvA2ynquuZTJkBbfDpJXcWljaGkWYses5tE4aI6CJsth5az2pQQhvKt\n\ttZk9zvct/6iQd2hen2w/zUSqkuzL7BD8+cKWGfUrEckqHSJSiNdxKE06a4dFXQqw78\n\tjCuJrHW9e21ZSpWQJkq4g4fjC/BNhD8RN8I3/v20="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"YOVGzLxY\"; dkim-atps=neutral","Date":"Mon, 27 Jun 2022 14:38:28 +0300","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<YrmWtKNU9kRaa8ZM@pendragon.ideasonboard.com>","References":"<20220627110859.1543239-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220627110859.1543239-1-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] pipeline: rkisp1: Support devices\n\twithout self path","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]