{"id":16886,"url":"https://patchwork.libcamera.org/api/patches/16886/?format=json","web_url":"https://patchwork.libcamera.org/patch/16886/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220801000543.3501-10-laurent.pinchart@ideasonboard.com>","date":"2022-08-01T00:05:39","name":"[libcamera-devel,09/13] libcamera: pipeline: simple: Reset routing table of subdevs","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"db2cd5d8ba7e3f790626432bce45a23fc7e14724","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16886/mbox/","series":[{"id":3352,"url":"https://patchwork.libcamera.org/api/series/3352/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3352","date":"2022-08-01T00:05:30","name":"libcamera: pipeline: simple: Support the NXP i.MX8 ISI","version":1,"mbox":"https://patchwork.libcamera.org/series/3352/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16886/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16886/checks/","tags":{},"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 A6AACBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Aug 2022 00:06:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6955763323;\n\tMon,  1 Aug 2022 02:06:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BD32363312\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Aug 2022 02:06:01 +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 59A179AA;\n\tMon,  1 Aug 2022 02:06:01 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659312363;\n\tbh=BGs5kBdaYnaJfdCOWHtVIvMsV7Xv5oEdih+wQ8J0gaY=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=OKtksVnwz03naIOFV3I7qP6NpT2B9sCip65mjlqKVlSiLZaTfqz003I+NCJGaOZRy\n\t0HQ3D1lCJe6iRpEt+hEdmBQ4qaG0SUgAWpmw+EjRdrAbBwpYrR/2iATXAZMRazWwgv\n\t3/2oV9sLV25i6XXMJM3TCHrLaSmO4BWSc90TVi8KCGO/9FENKkOtrMaFesRzRt3Cll\n\tfMoEfsyy1d4QxXzU51WahpoNftQ/REWZLhKrJVZu44Fi4h+1b5IqURGrzquC2aL0ym\n\taTSb768T6li5bsqenlzVQD9EI9E1yl+8ky7jSEZTljla19wUC20ZM4+ga/U55LNO3P\n\t9FlX6igQ8uzgA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659312361;\n\tbh=BGs5kBdaYnaJfdCOWHtVIvMsV7Xv5oEdih+wQ8J0gaY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=lIUI80fiiP+49S4H6rS5xHxAKRqbmc67frbgQOGfkYRKbQpm5abJfsE/gmeXaS9ei\n\tYEfYs5g/t7PVKyt16Xoe7CxOtP1vEinYXi6fULivBk3XmL10AsPa1iXLkl7+O6N7wJ\n\tDQNAeyX7ODtjgrZ/g5nRZ3BZvOQwqrN7PEGes0xM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"lIUI80fi\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Mon,  1 Aug 2022 03:05:39 +0300","Message-Id":"<20220801000543.3501-10-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220801000543.3501-1-laurent.pinchart@ideasonboard.com>","References":"<20220801000543.3501-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 09/13] libcamera: pipeline: simple: Reset\n\trouting table of subdevs","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Jacopo Mondi <jacopo@jmondi.org>\n\nReset the routing table of subdevices supporting the V4L2 streams API to\nits default state when initializing the pipeline handler. This avoids\nissues caused by usage of leftover state.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/simple/simple.cpp | 49 ++++++++++++++++++++++++\n 1 file changed, 49 insertions(+)","diff":"diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex bc0cb1a00c2a..731d355efda6 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -332,6 +332,7 @@ private:\n \t}\n \n \tstd::vector<MediaEntity *> locateSensors();\n+\tstatic int resetRoutingTable(V4L2Subdevice *subdev);\n \n \tconst MediaPad *acquirePipeline(SimpleCameraData *data);\n \tvoid releasePipeline(SimpleCameraData *data);\n@@ -1260,6 +1261,37 @@ std::vector<MediaEntity *> SimplePipelineHandler::locateSensors()\n \treturn sensors;\n }\n \n+int SimplePipelineHandler::resetRoutingTable(V4L2Subdevice *subdev)\n+{\n+\t/* Reset the media entity routing table to its default state. */\n+\tV4L2Subdevice::Routing routing = {};\n+\n+\tint ret = subdev->getRouting(&routing, V4L2Subdevice::TryFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = subdev->setRouting(&routing, V4L2Subdevice::ActiveFormat);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/*\n+\t * If the routing table is empty we won't be able to meaningfully use\n+\t * the subdev.\n+\t */\n+\tif (routing.empty()) {\n+\t\tLOG(SimplePipeline, Error)\n+\t\t\t<< \"Default routing table of \" << subdev->deviceNode()\n+\t\t\t<< \" is empty\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tLOG(SimplePipeline, Debug)\n+\t\t<< \"Routing table of \" << subdev->deviceNode()\n+\t\t<< \" reset to \" << routing.toString();\n+\n+\treturn 0;\n+}\n+\n bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n {\n \tconst SimplePipelineInfo *info = nullptr;\n@@ -1352,6 +1384,23 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n \t\t\t\t\t<< \": \" << strerror(-ret);\n \t\t\t\treturn false;\n \t\t\t}\n+\n+\t\t\tif (subdev->caps().hasStreams()) {\n+\t\t\t\t/*\n+\t\t\t\t * Reset the routing table to its default state\n+\t\t\t\t * to make sure entities are enumerate according\n+\t\t\t\t * to the defaul routing configuration.\n+\t\t\t\t */\n+\t\t\t\tret = resetRoutingTable(subdev.get());\n+\t\t\t\tif (ret) {\n+\t\t\t\t\tLOG(SimplePipeline, Error)\n+\t\t\t\t\t\t<< \"Failed to reset routes for \"\n+\t\t\t\t\t\t<< subdev->deviceNode() << \": \"\n+\t\t\t\t\t\t<< strerror(-ret);\n+\t\t\t\t\treturn false;\n+\t\t\t\t}\n+\t\t\t}\n+\n \t\t\tbreak;\n \n \t\tdefault:\n","prefixes":["libcamera-devel","09/13"]}