[{"id":30560,"web_url":"https://patchwork.libcamera.org/comment/30560/","msgid":"<20240803204912.GI3319@pendragon.ideasonboard.com>","date":"2024-08-03T20:49:12","subject":"Re: [PATCH v7 2/7] libcamera: Remove PipelineHandler Fatal check of\n\tnon-empty MediaDevices","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Chenghao,\n\nThank you for the patch.\n\nOn Thu, Aug 01, 2024 at 07:30:58AM +0000, Harvey Yang wrote:\n> The Fatal check of having at least one MediaDevice was to prevent\n> pipeline handler implementations searching and owning media devices with\n> custom conventions, instead of using the base function\n> |acquireMediaDevice|. It also has the assumption that there's at least\n> one media device to make a camera work.\n> \n> Now that the assumption will be broken by the virtual pipeline handler\n> added in the following patches, and developers should be aware of the\n> available functions in the base class to handle media devices, the Fatal\n> check is no longer needed.\n> \n> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>\n\nThat's a bit of a hack. It would be nicer to rework the device matching\nlogic to support other types of devices than media devices. That would\nbe quite a lot of yak shaving though, I suppose we can live with this\npatch for now.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/pipeline_handler.cpp | 11 ++++++++---\n>  1 file changed, 8 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index 5ea2ca78..125cf9d5 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -605,9 +605,14 @@ void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera)\n>  {\n>  \tcameras_.push_back(camera);\n>  \n> -\tif (mediaDevices_.empty())\n> -\t\tLOG(Pipeline, Fatal)\n> -\t\t\t<< \"Registering camera with no media devices!\";\n> +\tif (mediaDevices_.empty()) {\n> +\t\t/*\n> +\t\t * For virtual devices with no MediaDevice, there are no system\n> +\t\t * devices to register.\n> +\t\t */\n> +\t\tmanager_->_d()->addCamera(std::move(camera));\n> +\t\treturn;\n> +\t}\n>  \n>  \t/*\n>  \t * Walk the entity list and map the devnums of all capture video nodes","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 01DFBBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  3 Aug 2024 20:49:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1956E63381;\n\tSat,  3 Aug 2024 22:49:37 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 352D36336E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  3 Aug 2024 22:49:35 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B1880564;\n\tSat,  3 Aug 2024 22:48:44 +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=\"p6mpO14I\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1722718124;\n\tbh=6xkbT1nWGWyzkNUBKmK3k+hmiGco/LA2/maxJnITC6w=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=p6mpO14IpaoxaF2Ix/nX1h/cdrJ7br2UEbLlLHOgYidcxMkU1Hw08Zi2aD4RgOmE9\n\tV2hptgD+SVXu0iXP9EPyL8RYWKkhuQtZYpRYhuWZgh42a4obh6w3zij7rtGzrWGtpz\n\t1u4pQf0xIu07Id775D88lwaEemDczxR44AzJWyng=","Date":"Sat, 3 Aug 2024 23:49:12 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Harvey Yang <chenghaoyang@chromium.org>","Cc":"libcamera-devel@lists.libcamera.org,\n\tHarvey Yang <chenghaoyang@google.com>","Subject":"Re: [PATCH v7 2/7] libcamera: Remove PipelineHandler Fatal check of\n\tnon-empty MediaDevices","Message-ID":"<20240803204912.GI3319@pendragon.ideasonboard.com>","References":"<20240801073339.4061027-1-chenghaoyang@google.com>\n\t<20240801073339.4061027-3-chenghaoyang@google.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240801073339.4061027-3-chenghaoyang@google.com>","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":30598,"web_url":"https://patchwork.libcamera.org/comment/30598/","msgid":"<qqsu524dwh7cop5hzc2gzncu4egsw3quloos6ao4zxza7ilw6l@zib5nwxs6ln4>","date":"2024-08-05T14:33:23","subject":"Re: [PATCH v7 2/7] libcamera: Remove PipelineHandler Fatal check of\n\tnon-empty MediaDevices","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi\n\nOn Sat, Aug 03, 2024 at 11:49:12PM GMT, Laurent Pinchart wrote:\n> Hi Chenghao,\n>\n> Thank you for the patch.\n>\n> On Thu, Aug 01, 2024 at 07:30:58AM +0000, Harvey Yang wrote:\n> > The Fatal check of having at least one MediaDevice was to prevent\n> > pipeline handler implementations searching and owning media devices with\n> > custom conventions, instead of using the base function\n> > |acquireMediaDevice|. It also has the assumption that there's at least\n> > one media device to make a camera work.\n> >\n> > Now that the assumption will be broken by the virtual pipeline handler\n> > added in the following patches, and developers should be aware of the\n> > available functions in the base class to handle media devices, the Fatal\n> > check is no longer needed.\n> >\n> > Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>\n>\n> That's a bit of a hack. It would be nicer to rework the device matching\n> logic to support other types of devices than media devices. That would\n> be quite a lot of yak shaving though, I suppose we can live with this\n> patch for now.\n>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nMore or less 1 year ago I worked on generalizing device matching\nto support non-UVC compatible USB devices.\n\nIs there anything that can be useful here ?\nhttps://git.libcamera.org/libcamera/jmondi/libcamera.git/log/?h=jmondi/device-match-generalize\n\n>\n> > ---\n> >  src/libcamera/pipeline_handler.cpp | 11 ++++++++---\n> >  1 file changed, 8 insertions(+), 3 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> > index 5ea2ca78..125cf9d5 100644\n> > --- a/src/libcamera/pipeline_handler.cpp\n> > +++ b/src/libcamera/pipeline_handler.cpp\n> > @@ -605,9 +605,14 @@ void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera)\n> >  {\n> >  \tcameras_.push_back(camera);\n> >\n> > -\tif (mediaDevices_.empty())\n> > -\t\tLOG(Pipeline, Fatal)\n> > -\t\t\t<< \"Registering camera with no media devices!\";\n> > +\tif (mediaDevices_.empty()) {\n> > +\t\t/*\n> > +\t\t * For virtual devices with no MediaDevice, there are no system\n> > +\t\t * devices to register.\n> > +\t\t */\n> > +\t\tmanager_->_d()->addCamera(std::move(camera));\n> > +\t\treturn;\n> > +\t}\n> >\n> >  \t/*\n> >  \t * Walk the entity list and map the devnums of all capture video nodes\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 97904BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  5 Aug 2024 14:33:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A18F363369;\n\tMon,  5 Aug 2024 16:33:29 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B75D26195D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  5 Aug 2024 16:33:27 +0200 (CEST)","from ideasonboard.com (mob-5-91-31-107.net.vodafone.it\n\t[5.91.31.107])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CD2FE581;\n\tMon,  5 Aug 2024 16:32:35 +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=\"VrUeP5pV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1722868356;\n\tbh=fNDxBsPRjyrJbCFmVJqxb7la1HQ62n5vh8TCkRJW76w=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VrUeP5pV/rnKr7SVL4dHj0+HPeppw5vQIUUjEfWJ7KsXU5cm+hzYBkaRobUEkNeZb\n\tcgI/Q+m5JR6x9IE45qCfJ4BwkUAmGxMS3V4Fg9FaZPDUywXUibsUyzWTWhupUyTJWr\n\tHy3Q8W7axJxB70u12dJJlEe5BJz0KiDZXdWgAKQA=","Date":"Mon, 5 Aug 2024 16:33:23 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Harvey Yang <chenghaoyang@chromium.org>, \n\tlibcamera-devel@lists.libcamera.org,\n\tHarvey Yang <chenghaoyang@google.com>","Subject":"Re: [PATCH v7 2/7] libcamera: Remove PipelineHandler Fatal check of\n\tnon-empty MediaDevices","Message-ID":"<qqsu524dwh7cop5hzc2gzncu4egsw3quloos6ao4zxza7ilw6l@zib5nwxs6ln4>","References":"<20240801073339.4061027-1-chenghaoyang@google.com>\n\t<20240801073339.4061027-3-chenghaoyang@google.com>\n\t<20240803204912.GI3319@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240803204912.GI3319@pendragon.ideasonboard.com>","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>"}}]