[{"id":3280,"web_url":"https://patchwork.libcamera.org/comment/3280/","msgid":"<20191227144851.GA16041@pendragon.ideasonboard.com>","date":"2019-12-27T14:48:51","subject":"Re: [libcamera-devel] [PATCH v3 3/6] libcamera: pipeline_handler:\n\tuvcvideo: register all Cameras along with a devnum","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, Dec 23, 2019 at 01:26:17AM -0600, Paul Elder wrote:\n> Register all UVC Cameras along with its device number, to eventually\n\ns/its device number/their device numbers/\n\n> allow the V4L2 compatibility layer to match against it.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> ---\n> New in v3\n> ---\n>  src/libcamera/pipeline/uvcvideo.cpp | 7 +++++--\n>  1 file changed, 5 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> index 3043366b..096c1c09 100644\n> --- a/src/libcamera/pipeline/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> @@ -7,6 +7,7 @@\n>  \n>  #include <algorithm>\n>  #include <iomanip>\n> +#include <sys/sysmacros.h>\n>  #include <tuple>\n>  \n>  #include <libcamera/camera.h>\n> @@ -294,17 +295,19 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n>  \t\treturn false;\n>  \n>  \tstd::unique_ptr<UVCCameraData> data = utils::make_unique<UVCCameraData>(this);\n> +\tdev_t devnum = 0;\n>  \n>  \t/* Locate and initialise the camera data with the default video node. */\n>  \tfor (MediaEntity *entity : media->entities()) {\n>  \t\tif (entity->flags() & MEDIA_ENT_FL_DEFAULT) {\n>  \t\t\tif (data->init(entity))\n>  \t\t\t\treturn false;\n> +\t\t\tdevnum = makedev(entity->deviceMajor(), entity->deviceMinor());\n\nYou can move this line after the loop, and merge it with the devnum\nvariable declaration. I would actually move it after the \"Could not find\na default video device\" check and make it a separate check with a\ndedicated error message. Or even drop the check completely as it really\nshouldn't happen (in which case you can move the devnum calculation to\nthe registration below).\n\nWith this fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  \t\t\tbreak;\n>  \t\t}\n>  \t}\n>  \n> -\tif (!data) {\n> +\tif (!data || !devnum) {\n>  \t\tLOG(UVC, Error) << \"Could not find a default video device\";\n>  \t\treturn false;\n>  \t}\n> @@ -312,7 +315,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n>  \t/* Create and register the camera. */\n>  \tstd::set<Stream *> streams{ &data->stream_ };\n>  \tstd::shared_ptr<Camera> camera = Camera::create(this, media->model(), streams);\n> -\tregisterCamera(std::move(camera), std::move(data));\n> +\tregisterCamera(std::move(camera), std::move(data), devnum);\n>  \n>  \t/* Enable hot-unplug notifications. */\n>  \thotplugMediaDevice(media);","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 735006046D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Dec 2019 15:49:03 +0100 (CET)","from pendragon.ideasonboard.com (unknown [91.179.177.25])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0F7A4DD;\n\tFri, 27 Dec 2019 15:49:03 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1577458143;\n\tbh=Cd3Grs4BLqitk8F/RD65p+S9Ase1luZfxhMDnSewDh8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=M3csq94Miq97ZqDJVRNHm1HdM4mCw4EwvCHmm0kcbZBvmFxwr+fuBPB7S95x+koIi\n\tT3c5AMYfftuel8Zf6yQ6l57tai4iVC5c+KSziQlsaJFk6kB5Aqq9tDMzMMowawBoZM\n\ta439IczQhVwBfuNj8wdzuRvXBgIZbIYrw7Ihtreo=","Date":"Fri, 27 Dec 2019 16:48:51 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191227144851.GA16041@pendragon.ideasonboard.com>","References":"<20191223072620.13022-1-paul.elder@ideasonboard.com>\n\t<20191223072620.13022-4-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20191223072620.13022-4-paul.elder@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 3/6] libcamera: pipeline_handler:\n\tuvcvideo: register all Cameras along with a devnum","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>","X-List-Received-Date":"Fri, 27 Dec 2019 14:49:03 -0000"}},{"id":3287,"web_url":"https://patchwork.libcamera.org/comment/3287/","msgid":"<20191230181310.GA15427@localhost.localdomain>","date":"2019-12-30T18:13:10","subject":"Re: [libcamera-devel] [PATCH v3 3/6] libcamera: pipeline_handler:\n\tuvcvideo: register all Cameras along with a devnum","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Laurent,\n\nThank you for the review.\n\nOn Fri, Dec 27, 2019 at 04:48:51PM +0200, Laurent Pinchart wrote:\n> Hi Paul,\n> \n> Thank you for the patch.\n> \n> On Mon, Dec 23, 2019 at 01:26:17AM -0600, Paul Elder wrote:\n> > Register all UVC Cameras along with its device number, to eventually\n> \n> s/its device number/their device numbers/\n\nack\n\n> > allow the V4L2 compatibility layer to match against it.\n> > \n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > \n> > ---\n> > New in v3\n> > ---\n> >  src/libcamera/pipeline/uvcvideo.cpp | 7 +++++--\n> >  1 file changed, 5 insertions(+), 2 deletions(-)\n> > \n> > diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> > index 3043366b..096c1c09 100644\n> > --- a/src/libcamera/pipeline/uvcvideo.cpp\n> > +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> > @@ -7,6 +7,7 @@\n> >  \n> >  #include <algorithm>\n> >  #include <iomanip>\n> > +#include <sys/sysmacros.h>\n> >  #include <tuple>\n> >  \n> >  #include <libcamera/camera.h>\n> > @@ -294,17 +295,19 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n> >  \t\treturn false;\n> >  \n> >  \tstd::unique_ptr<UVCCameraData> data = utils::make_unique<UVCCameraData>(this);\n> > +\tdev_t devnum = 0;\n> >  \n> >  \t/* Locate and initialise the camera data with the default video node. */\n> >  \tfor (MediaEntity *entity : media->entities()) {\n> >  \t\tif (entity->flags() & MEDIA_ENT_FL_DEFAULT) {\n> >  \t\t\tif (data->init(entity))\n> >  \t\t\t\treturn false;\n> > +\t\t\tdevnum = makedev(entity->deviceMajor(), entity->deviceMinor());\n> \n> You can move this line after the loop, and merge it with the devnum\n> variable declaration. I would actually move it after the \"Could not find\n> a default video device\" check and make it a separate check with a\n> dedicated error message. Or even drop the check completely as it really\n> shouldn't happen (in which case you can move the devnum calculation to\n> the registration below).\n\nI don't think I can, because entity is only available inside the loop. I\nwould have to save it, in which case I might as well just extract the\ndevnum here.\n\n> With this fixed,\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> >  \t\t\tbreak;\n> >  \t\t}\n> >  \t}\n> >  \n> > -\tif (!data) {\n> > +\tif (!data || !devnum) {\n> >  \t\tLOG(UVC, Error) << \"Could not find a default video device\";\n> >  \t\treturn false;\n> >  \t}\n> > @@ -312,7 +315,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n> >  \t/* Create and register the camera. */\n> >  \tstd::set<Stream *> streams{ &data->stream_ };\n> >  \tstd::shared_ptr<Camera> camera = Camera::create(this, media->model(), streams);\n> > -\tregisterCamera(std::move(camera), std::move(data));\n> > +\tregisterCamera(std::move(camera), std::move(data), devnum);\n> >  \n> >  \t/* Enable hot-unplug notifications. */\n> >  \thotplugMediaDevice(media);\n\n\nThanks,\n\nPaul","headers":{"Return-Path":"<paul.elder@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A7DA76046B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Dec 2019 19:13:16 +0100 (CET)","from localhost.localdomain (173-16-160-11.client.mchsi.com\n\t[173.16.160.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9534ADF;\n\tMon, 30 Dec 2019 19:13:15 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1577729596;\n\tbh=1m0BZfBPX2pSUY623tcgVbsqE+TwSmJWE/ftdXAHHKg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=PbhBHDDlo9oq2bNvb3+YLk7naFRU5YRVjtTqMzA0uu4Io06SBiqK24M3F1HvsLkTX\n\tk0DB2F0P1usDfietDJV9t+CzW4iuFj/CKOP+pDv2alZYroNgdJsqbnndMM7yik6FMl\n\t+jZRGa1NRlBL6rkDeWrPUn7ODy2f5RzY7m0xhjrA=","Date":"Mon, 30 Dec 2019 12:13:10 -0600","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191230181310.GA15427@localhost.localdomain>","References":"<20191223072620.13022-1-paul.elder@ideasonboard.com>\n\t<20191223072620.13022-4-paul.elder@ideasonboard.com>\n\t<20191227144851.GA16041@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20191227144851.GA16041@pendragon.ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 3/6] libcamera: pipeline_handler:\n\tuvcvideo: register all Cameras along with a devnum","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>","X-List-Received-Date":"Mon, 30 Dec 2019 18:13:16 -0000"}}]