[{"id":24305,"web_url":"https://patchwork.libcamera.org/comment/24305/","msgid":"<6ceef669-d2d2-b6a8-1bab-8a1d0b9387f2@ideasonboard.com>","date":"2022-08-02T11:05:16","subject":"Re: [libcamera-devel] [PATCH 09/13] libcamera: pipeline: simple:\n\tReset routing table of subdevs","submitter":{"id":109,"url":"https://patchwork.libcamera.org/api/people/109/","name":"Tomi Valkeinen","email":"tomi.valkeinen@ideasonboard.com"},"content":"On 01/08/2022 03:05, Laurent Pinchart via libcamera-devel wrote:\n> From: Jacopo Mondi <jacopo@jmondi.org>\n> \n> Reset the routing table of subdevices supporting the V4L2 streams API to\n> its default state when initializing the pipeline handler. This avoids\n> issues caused by usage of leftover state.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>   src/libcamera/pipeline/simple/simple.cpp | 49 ++++++++++++++++++++++++\n>   1 file changed, 49 insertions(+)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index 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\nIs this a normal way to reset things in v4l2? Say, if you want to reset \nthe fmt on a pad?\n\nReviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n\n  Tomi","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 6DBB8BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Aug 2022 11:05:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D08B963313;\n\tTue,  2 Aug 2022 13:05:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 41ACB603E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Aug 2022 13:05:20 +0200 (CEST)","from [192.168.1.111] (91-158-154-79.elisa-laajakaista.fi\n\t[91.158.154.79])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BD51225B;\n\tTue,  2 Aug 2022 13:05:19 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659438321;\n\tbh=D2bPQ0eTQAiGEODeqrRR0IkG+oeq4KoQF00pgsPpzAA=;\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:\n\tFrom;\n\tb=VXa2tP26LovuONd+XQSEBPJsPSUiSIBGmB0DfyXNaztIL8hDLjGJGWsHHKQyPe1Xn\n\tY9D3BSdgK/qA50bCG1HJwTZdotUXzyBNIdymPiT2YDAluv3w3qqzWo3UUUAgVjR99q\n\tvB3eNlIRD6gebPRBqn7DXC6A7IToj8MtWISMfUrPGsl0FdgVSKMum8afB0xUJMEn8R\n\tTbiPrOqMSKn9j7i5swqitvIlSQ442sXicpQux+EG5B66HKxIk/vhmM1b+rkqqqJNpu\n\tM1hiixFbo5CwSdhEzxpMp+S9Olcu/Xi7WYIbzjySx1SM3MqRuRq3JeC/pBQYNVBMPE\n\twD9x8dPDa/5Ow==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659438319;\n\tbh=D2bPQ0eTQAiGEODeqrRR0IkG+oeq4KoQF00pgsPpzAA=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=OZlkSK83F2fy+koXJuvUDF+5EfRhcklekdJgi8CTC+MC6dTt9mB9q4KqwnGixa7sB\n\tOiU9Cp6iEjC8IQ8ZEGF/bebpR9UW8nHyUrwE+f4+m3fXtWSGbaPM+3LqiSDEBEJt/C\n\tJUsyHM9ia1k4Xr91HWq7LP45LVkupFP2kaFmEqT0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"OZlkSK83\"; dkim-atps=neutral","Message-ID":"<6ceef669-d2d2-b6a8-1bab-8a1d0b9387f2@ideasonboard.com>","Date":"Tue, 2 Aug 2022 14:05:16 +0300","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.11.0","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20220801000543.3501-1-laurent.pinchart@ideasonboard.com>\n\t<20220801000543.3501-10-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20220801000543.3501-10-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH 09/13] libcamera: pipeline: simple:\n\tReset routing 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":"Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24306,"web_url":"https://patchwork.libcamera.org/comment/24306/","msgid":"<Yukbfi2W4hT9GD53@pendragon.ideasonboard.com>","date":"2022-08-02T12:41:34","subject":"Re: [libcamera-devel] [PATCH 09/13] libcamera: pipeline: simple:\n\tReset routing table of subdevs","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Tomi,\n\nOn Tue, Aug 02, 2022 at 02:05:16PM +0300, Tomi Valkeinen wrote:\n> On 01/08/2022 03:05, Laurent Pinchart via libcamera-devel wrote:\n> > From: Jacopo Mondi <jacopo@jmondi.org>\n> > \n> > Reset the routing table of subdevices supporting the V4L2 streams API to\n> > its default state when initializing the pipeline handler. This avoids\n> > issues caused by usage of leftover state.\n> > \n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >   src/libcamera/pipeline/simple/simple.cpp | 49 ++++++++++++++++++++++++\n> >   1 file changed, 49 insertions(+)\n> > \n> > diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> > index 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> Is this a normal way to reset things in v4l2? Say, if you want to reset \n> the fmt on a pad?\n\nThere's no explicit reset API, getting the default value using a try\ncontext is the best way I know of. This only works if the try context\nisn't modified of course, which is fine here.\n\n> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","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 F21C6C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Aug 2022 12:41:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5858C63313;\n\tTue,  2 Aug 2022 14:41:41 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B91B603E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Aug 2022 14:41:39 +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 0B92925B;\n\tTue,  2 Aug 2022 14:41:38 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659444101;\n\tbh=64RDNKHq+wSYyX5Oe2cBQvpGl8yQBpxB39TCunj1tUs=;\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=TsJCSrJ0qwZ4LNOulG8hCNfGQKWYRm+F+090tuWcGldRYSV3db+G0oJYLkn7ybZE7\n\tQrPKfNan2AEsf4sA/XXM6167GLneb7FY9S3jThoFcEAlTg1AcpquiNuUGJCGqc+8E4\n\tC8Yy4myDlVCYzibx4W2mw9hXIKMzsG10b2FFeEO9nxjPqd1QtsrPIDC2uaMhjQlSPf\n\tNsv0HW+uYeKMI40zm25MHTvH8NjS7vQy10F4UDzCn7z+iu7d9GzP1z2VDcBWScOXIi\n\tX8Gj0vEGfS9JHXtyHiRlkH1aSzaQub/SHGizspuOy/AuIe5H4z8b6EYS2/EF877WEl\n\tguutxloLpw2HQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659444099;\n\tbh=64RDNKHq+wSYyX5Oe2cBQvpGl8yQBpxB39TCunj1tUs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=MskVysMRihsyEZJ9QIFWeQEIF+/J6GYZnuHFysCFF5tzxtjLKVKkmW2X5DGCKCzMe\n\tz8DBwwvHhEm/2gt/MetRJgh7QTvfSejnwEiedhroy4Yg8T9iTt3ROwnVmSh+HQr5tt\n\tbDGdaUMRL8RYHVIiXAnxYGYaWLIdC250oPKmDpzA="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"MskVysMR\"; dkim-atps=neutral","Date":"Tue, 2 Aug 2022 15:41:34 +0300","To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Message-ID":"<Yukbfi2W4hT9GD53@pendragon.ideasonboard.com>","References":"<20220801000543.3501-1-laurent.pinchart@ideasonboard.com>\n\t<20220801000543.3501-10-laurent.pinchart@ideasonboard.com>\n\t<6ceef669-d2d2-b6a8-1bab-8a1d0b9387f2@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<6ceef669-d2d2-b6a8-1bab-8a1d0b9387f2@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 09/13] libcamera: pipeline: simple:\n\tReset routing 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]