[{"id":23158,"web_url":"https://patchwork.libcamera.org/comment/23158/","msgid":"<165357382779.989479.11276980533141819616@Monstersaurus>","date":"2022-05-26T14:03:47","subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: uvcvideo: Infer\n\tcamera location from removable attribute","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart via libcamera-devel (2022-05-26 14:30:25)\n> Use the removable attribute exposed by the USB device in sysfs to infer\n> if the camera is an external (when removable) or front (when\n> non-removable) camera. This is likely not perfect as the removable\n> attribute is derived from ACPI data which may not always be accurate,\n> and non-ACPI platforms likely report all devices as removable. Still,\n> this is a first step upon which a better method could be built.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 33 +++++++++++++++++---\n>  1 file changed, 28 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> index 2ebf2788c3b4..53b2f23ab029 100644\n> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> @@ -501,13 +501,36 @@ int UVCCameraData::init(MediaDevice *media)\n>  \n>         video_->bufferReady.connect(this, &UVCCameraData::bufferReady);\n>  \n> -       /*\n> -        * \\todo Find a way to tell internal and external UVC cameras apart.\n> -        * Until then, treat all UVC cameras as external.\n> -        */\n> -       properties_.set(properties::Location, properties::CameraLocationExternal);\n>         properties_.set(properties::Model, utils::toAscii(media->model()));\n>  \n> +       /*\n> +        * Derive the location from the device removable attribute in sysfs.\n> +        * Non-removable devices are assumed to be front as we lack detailed\n> +        * location information, and removable device are considered external.\n> +        *\n> +        * The sysfs removable attribute is derived from the ACPI _UPC attribute\n> +        * if available, or from the USB hub descriptors otherwise. ACPI data\n> +        * may not be very reliable, and the USB hub descriptors may not be\n> +        * accurate on DT-based platforms. A heuristic may need to be\n> +        * implemented later if too many devices end up being miscategorized.\n> +        *\n> +        * \\todo Find a way to tell front and back devices apart. This could\n> +        * come from the ACPI _PLD, but that may be even more unreliable than\n> +        * the _UPC.\n> +        */\n> +       properties::LocationEnum location = properties::CameraLocationExternal;\n> +       std::ifstream file(video_->devicePath() + \"/../removable\");\n\nI expected this devicePath() to be /dev/video0 ... but given the above,\nI presume it's mapping elsewhere. Is it guaranteed to map to the sysfs\npath? or do we need to build it with the information we have?\n\nAnyway, if it fails, it will fail to what we have anyway so - if it\nworks in some cases, that's still 'progress'...\n\nWith the path understood, (which I'm sure you do anyway...)\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> +       if (file.is_open()) {\n> +               std::string value;\n> +               std::getline(file, value);\n> +               file.close();\n> +\n> +               if (value == \"fixed\")\n> +                       location = properties::CameraLocationFront;\n> +       }\n> +\n> +       properties_.set(properties::Location, location);\n> +\n>         /*\n>          * Get the current format in order to initialize the sensor array\n>          * properties.\n> \n> base-commit: f8e4649680303ce9b7dace5ad1344fcb450013ac\n> prerequisite-patch-id: edbf31ed9d7f5374e17b34936fe1aa8dea2eac44\n> -- \n> Regards,\n> \n> Laurent Pinchart\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 CD6FFBD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 May 2022 14:03:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 87DFE611BF;\n\tThu, 26 May 2022 16:03:51 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AD24660DB0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 May 2022 16:03:50 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 58EAF898;\n\tThu, 26 May 2022 16:03:50 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653573831;\n\tbh=ewi0zfMLOYvZHbHYmbwNDsHzRApszHjwsq7+BrsAe5A=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=SB5F29FvyFcNgveoOqaoq0MHYDgvSLF6Pz22TIhT7Y8vcbBJERZgN+UoI5brHku4m\n\t0EhY/uCaA1/ykoWZjxgZwGFo+d/RVpoQzeFyTugdEiY86b7D49RHKDv8C7OJAGOQ/c\n\tZSXyzah7kEZchPMFy9T2NpUNIu4UV6T0iyZ/6ENcp4Bx4exeEnCJx31tmlHXLhfclS\n\trb69jl0JH2Yz5tEB2mrsZXyyg0mvJiIpgYVTjDyUWfZWO+XGQNacDRmBRVvHYYWydI\n\t8TaJiK+anoFvnsuXHLYIXdo2tue2+o8kZgALY67AhHNQ8QuHITturOXj8ejhS9UbG3\n\taFmBcxC1YWCpg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653573830;\n\tbh=ewi0zfMLOYvZHbHYmbwNDsHzRApszHjwsq7+BrsAe5A=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=h4HVagduu3QFYuiT9S4Rhbd/2UZ2LZ1ezrTcjGlxIyko1E/+eC/l2pnRzI0GL7w7s\n\towKE9dNDZ6pa1BWrk7wZLNbf+Q5+FdUIlaaMfAFDGKHMnEkaw8a2gZAXyWUSswIK0H\n\tFBPkWP2XjaHcJeY6Atih8dmUhDShyYRuvixqPgzs="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"h4HVagdu\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220526133025.18746-1-laurent.pinchart@ideasonboard.com>","References":"<20220526133025.18746-1-laurent.pinchart@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 26 May 2022 15:03:47 +0100","Message-ID":"<165357382779.989479.11276980533141819616@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: uvcvideo: Infer\n\tcamera location from removable attribute","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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"George Kiagiadakis <george.kiagiadakis@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23159,"web_url":"https://patchwork.libcamera.org/comment/23159/","msgid":"<Yo+T2QuNKJcV5WEI@pendragon.ideasonboard.com>","date":"2022-05-26T14:51:05","subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: uvcvideo: Infer\n\tcamera location from removable attribute","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, May 26, 2022 at 03:03:47PM +0100, Kieran Bingham wrote:\n> Quoting Laurent Pinchart via libcamera-devel (2022-05-26 14:30:25)\n> > Use the removable attribute exposed by the USB device in sysfs to infer\n> > if the camera is an external (when removable) or front (when\n> > non-removable) camera. This is likely not perfect as the removable\n> > attribute is derived from ACPI data which may not always be accurate,\n> > and non-ACPI platforms likely report all devices as removable. Still,\n> > this is a first step upon which a better method could be built.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 33 +++++++++++++++++---\n> >  1 file changed, 28 insertions(+), 5 deletions(-)\n> > \n> > diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> > index 2ebf2788c3b4..53b2f23ab029 100644\n> > --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> > +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> > @@ -501,13 +501,36 @@ int UVCCameraData::init(MediaDevice *media)\n> >  \n> >         video_->bufferReady.connect(this, &UVCCameraData::bufferReady);\n> >  \n> > -       /*\n> > -        * \\todo Find a way to tell internal and external UVC cameras apart.\n> > -        * Until then, treat all UVC cameras as external.\n> > -        */\n> > -       properties_.set(properties::Location, properties::CameraLocationExternal);\n> >         properties_.set(properties::Model, utils::toAscii(media->model()));\n> >  \n> > +       /*\n> > +        * Derive the location from the device removable attribute in sysfs.\n> > +        * Non-removable devices are assumed to be front as we lack detailed\n> > +        * location information, and removable device are considered external.\n> > +        *\n> > +        * The sysfs removable attribute is derived from the ACPI _UPC attribute\n> > +        * if available, or from the USB hub descriptors otherwise. ACPI data\n> > +        * may not be very reliable, and the USB hub descriptors may not be\n> > +        * accurate on DT-based platforms. A heuristic may need to be\n> > +        * implemented later if too many devices end up being miscategorized.\n> > +        *\n> > +        * \\todo Find a way to tell front and back devices apart. This could\n> > +        * come from the ACPI _PLD, but that may be even more unreliable than\n> > +        * the _UPC.\n> > +        */\n> > +       properties::LocationEnum location = properties::CameraLocationExternal;\n> > +       std::ifstream file(video_->devicePath() + \"/../removable\");\n> \n> I expected this devicePath() to be /dev/video0 ... but given the above,\n> I presume it's mapping elsewhere. Is it guaranteed to map to the sysfs\n> path? or do we need to build it with the information we have?\n\nQuoting\nhttps://libcamera.org/api-html/classlibcamera_1_1V4L2Device.html#a8454df564fffa7ad160468709aa172ff,\n\n\"This function returns the sysfs path to the physical device backing the\nV4L2 device. The path is guaranteed to be an absolute path, without any\nsymbolic link.\"\n\nSo we're good :-)\n\n> Anyway, if it fails, it will fail to what we have anyway so - if it\n> works in some cases, that's still 'progress'...\n> \n> With the path understood, (which I'm sure you do anyway...)\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> > +       if (file.is_open()) {\n> > +               std::string value;\n> > +               std::getline(file, value);\n> > +               file.close();\n> > +\n> > +               if (value == \"fixed\")\n> > +                       location = properties::CameraLocationFront;\n> > +       }\n> > +\n> > +       properties_.set(properties::Location, location);\n> > +\n> >         /*\n> >          * Get the current format in order to initialize the sensor array\n> >          * properties.\n> > \n> > base-commit: f8e4649680303ce9b7dace5ad1344fcb450013ac\n> > prerequisite-patch-id: edbf31ed9d7f5374e17b34936fe1aa8dea2eac44","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 25B32BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 May 2022 14:51:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6254660DB0;\n\tThu, 26 May 2022 16:51:14 +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 4B95460DB0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 May 2022 16:51:12 +0200 (CEST)","from pendragon.ideasonboard.com (unknown [37.120.212.14])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9DD9632A;\n\tThu, 26 May 2022 16:51:11 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653576674;\n\tbh=69024D5cEZmDMOhwBt+HktQulwTgJdDrcYm4GFlhZzg=;\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=2wVFtt6fqJdieaGGrR4HVZDMH5qSIkV8MTQbf4omGcQd1LbsTkuVjfvdu4PVONAbf\n\t/gzRfraMyzUtcxPJ8AVQwpjclF4IDRsoFk0hWPiYqYEXxYoSX5gXRb5KYrG0+LjV26\n\tWUzcFnd8wRfjs01aC0pvjUumzVHOxxSp5IaNrh+EXG7vs2uU0RKsZbv1Itcos6a+Z5\n\tK8095lgaUXzDtRxksk+YO6xRfGr+OmFgejsYcFx0weGT63ZKKFX736hMO/JdxEvS+6\n\tYxWAbO3XOnFzBp/yQELh7I3bQ+J+nufbO3Etb8t93mIujr6YfhAWYBLqOJ4ToGg/C1\n\tLIOMNUtabd1uA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653576671;\n\tbh=69024D5cEZmDMOhwBt+HktQulwTgJdDrcYm4GFlhZzg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=STYWhL3eMhNYhRqrKrkSZX/8cXZ/60fVa2iX0ZOp3aEyUMD/OjIjLis3lRSvpFy9D\n\thtw9F5QllEf7GxYCqTNLWZwY6XfMkwDzivVrw8ggNj2ztyMzT04ik4x1Na78Yi1llg\n\tzH0QXPcFntB1rmFaoHx3cFiXjOrwtx15GyBhqXJ4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"STYWhL3e\"; dkim-atps=neutral","Date":"Thu, 26 May 2022 17:51:05 +0300","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<Yo+T2QuNKJcV5WEI@pendragon.ideasonboard.com>","References":"<20220526133025.18746-1-laurent.pinchart@ideasonboard.com>\n\t<165357382779.989479.11276980533141819616@Monstersaurus>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<165357382779.989479.11276980533141819616@Monstersaurus>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: uvcvideo: Infer\n\tcamera location from removable attribute","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":"George Kiagiadakis <george.kiagiadakis@collabora.com>,\n\tlibcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23171,"web_url":"https://patchwork.libcamera.org/comment/23171/","msgid":"<20220527030921.GD4117012@pyrite.rasen.tech>","date":"2022-05-27T03:09:21","subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: uvcvideo: Infer\n\tcamera location from removable attribute","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Laurent,\n\nOn Thu, May 26, 2022 at 04:30:25PM +0300, Laurent Pinchart via libcamera-devel wrote:\n> Use the removable attribute exposed by the USB device in sysfs to infer\n> if the camera is an external (when removable) or front (when\n> non-removable) camera. This is likely not perfect as the removable\n> attribute is derived from ACPI data which may not always be accurate,\n> and non-ACPI platforms likely report all devices as removable. Still,\n> this is a first step upon which a better method could be built.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 33 +++++++++++++++++---\n>  1 file changed, 28 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> index 2ebf2788c3b4..53b2f23ab029 100644\n> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> @@ -501,13 +501,36 @@ int UVCCameraData::init(MediaDevice *media)\n>  \n>  \tvideo_->bufferReady.connect(this, &UVCCameraData::bufferReady);\n>  \n> -\t/*\n> -\t * \\todo Find a way to tell internal and external UVC cameras apart.\n> -\t * Until then, treat all UVC cameras as external.\n> -\t */\n> -\tproperties_.set(properties::Location, properties::CameraLocationExternal);\n>  \tproperties_.set(properties::Model, utils::toAscii(media->model()));\n>  \n> +\t/*\n> +\t * Derive the location from the device removable attribute in sysfs.\n> +\t * Non-removable devices are assumed to be front as we lack detailed\n> +\t * location information, and removable device are considered external.\n> +\t *\n> +\t * The sysfs removable attribute is derived from the ACPI _UPC attribute\n> +\t * if available, or from the USB hub descriptors otherwise. ACPI data\n> +\t * may not be very reliable, and the USB hub descriptors may not be\n> +\t * accurate on DT-based platforms. A heuristic may need to be\n> +\t * implemented later if too many devices end up being miscategorized.\n> +\t *\n> +\t * \\todo Find a way to tell front and back devices apart. This could\n> +\t * come from the ACPI _PLD, but that may be even more unreliable than\n> +\t * the _UPC.\n> +\t */\n> +\tproperties::LocationEnum location = properties::CameraLocationExternal;\n> +\tstd::ifstream file(video_->devicePath() + \"/../removable\");\n> +\tif (file.is_open()) {\n> +\t\tstd::string value;\n> +\t\tstd::getline(file, value);\n> +\t\tfile.close();\n> +\n> +\t\tif (value == \"fixed\")\n> +\t\t\tlocation = properties::CameraLocationFront;\n> +\t}\n> +\n> +\tproperties_.set(properties::Location, location);\n> +\n>  \t/*\n>  \t * Get the current format in order to initialize the sensor array\n>  \t * properties.\n> \n> base-commit: f8e4649680303ce9b7dace5ad1344fcb450013ac\n> prerequisite-patch-id: edbf31ed9d7f5374e17b34936fe1aa8dea2eac44","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 3A847BD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 May 2022 03:09:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9EABE633A1;\n\tFri, 27 May 2022 05:09: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 D6B3F61FB6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 May 2022 05:09:28 +0200 (CEST)","from pyrite.rasen.tech (softbank036240126034.bbtec.net\n\t[36.240.126.34])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EF72E2A5;\n\tFri, 27 May 2022 05:09:26 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653620969;\n\tbh=u4N7ueEzAkxO+KgpvDF8erxdrzap5/nB1yyI39aVjMQ=;\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=Bq1RruNjokDqoyd9E05EQ6J/+EAdFhPv6YG+0AUV6qH9yC9L+KEoKlTf57IET4rTl\n\tCRuBa78mrHP46IZz24Uc9MgQvdMJCB4Oxqvn/K55VLPbOlvqXXwzXpGy66Tk6vlT6M\n\tLNCVJiSxATsmI1DNVX4fBZBic23z4S9xc8Qg0wMfVOleAZCPpRJzfPZaD7NZK7JJjW\n\t7IW8ZwV5WtAnLVMx/6DqVupw0SxXIht06Z07wSUknPczCyc3t8vdS5o/b4gtaL7he9\n\t/M7phmwZqoRFoBPV5C6rk6eZrYDirX2t71RIBoKVuTcngtKFqMskfQbikmTh6rTEGY\n\tOIanlH0+46xVg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653620968;\n\tbh=u4N7ueEzAkxO+KgpvDF8erxdrzap5/nB1yyI39aVjMQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=F+YzGNEnutcEFKvF0w5hby75y5TaZqqj1OC7syy1vbpys8KdCCPoY646vMmJi9Kq8\n\tJB/cpxLgzphZq3dQesR5bV0nQ2DjZfY+Xfpv0rxVIYISN4ivNM6ExH++o2TpTVuntF\n\tmSOTiPHXnms/eh2s1DwcmflN9tMa3Omqnb0GhbCE="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"F+YzGNEn\"; dkim-atps=neutral","Date":"Fri, 27 May 2022 12:09:21 +0900","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220527030921.GD4117012@pyrite.rasen.tech>","References":"<20220526133025.18746-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20220526133025.18746-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: uvcvideo: Infer\n\tcamera location from removable attribute","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":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"George Kiagiadakis <george.kiagiadakis@collabora.com>,\n\tlibcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23201,"web_url":"https://patchwork.libcamera.org/comment/23201/","msgid":"<833b0fd1745fc3c107f6a2366597f12f80bfaaa1.camel@collabora.com>","date":"2022-05-27T18:40:47","subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: uvcvideo: Infer\n\tcamera location from removable attribute","submitter":{"id":124,"url":"https://patchwork.libcamera.org/api/people/124/","name":"George Kiagiadakis","email":"george.kiagiadakis@collabora.com"},"content":"Hi Laurent,\n\nOn Thu, 2022-05-26 at 16:30 +0300, Laurent Pinchart wrote:\n> Use the removable attribute exposed by the USB device in sysfs to infer\n> if the camera is an external (when removable) or front (when\n> non-removable) camera. This is likely not perfect as the removable\n> attribute is derived from ACPI data which may not always be accurate,\n> and non-ACPI platforms likely report all devices as removable. Still,\n> this is a first step upon which a better method could be built.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nThanks, this makes my internal laptop uvc webcam be reported properly as a\n\"front\" camera instead of an external one.\n\nTested-by: George Kiagiadakis <george.kiagiadakis@collabora.com>\n\n> ---\n>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 33 +++++++++++++++++---\n>  1 file changed, 28 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> index 2ebf2788c3b4..53b2f23ab029 100644\n> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> @@ -501,13 +501,36 @@ int UVCCameraData::init(MediaDevice *media)\n>  \n>  \tvideo_->bufferReady.connect(this, &UVCCameraData::bufferReady);\n>  \n> -\t/*\n> -\t * \\todo Find a way to tell internal and external UVC cameras apart.\n> -\t * Until then, treat all UVC cameras as external.\n> -\t */\n> -\tproperties_.set(properties::Location, properties::CameraLocationExternal);\n>  \tproperties_.set(properties::Model, utils::toAscii(media->model()));\n>  \n> +\t/*\n> +\t * Derive the location from the device removable attribute in sysfs.\n> +\t * Non-removable devices are assumed to be front as we lack detailed\n> +\t * location information, and removable device are considered external.\n> +\t *\n> +\t * The sysfs removable attribute is derived from the ACPI _UPC attribute\n> +\t * if available, or from the USB hub descriptors otherwise. ACPI data\n> +\t * may not be very reliable, and the USB hub descriptors may not be\n> +\t * accurate on DT-based platforms. A heuristic may need to be\n> +\t * implemented later if too many devices end up being miscategorized.\n> +\t *\n> +\t * \\todo Find a way to tell front and back devices apart. This could\n> +\t * come from the ACPI _PLD, but that may be even more unreliable than\n> +\t * the _UPC.\n> +\t */\n> +\tproperties::LocationEnum location = properties::CameraLocationExternal;\n> +\tstd::ifstream file(video_->devicePath() + \"/../removable\");\n> +\tif (file.is_open()) {\n> +\t\tstd::string value;\n> +\t\tstd::getline(file, value);\n> +\t\tfile.close();\n> +\n> +\t\tif (value == \"fixed\")\n> +\t\t\tlocation = properties::CameraLocationFront;\n> +\t}\n> +\n> +\tproperties_.set(properties::Location, location);\n> +\n>  \t/*\n>  \t * Get the current format in order to initialize the sensor array\n>  \t * properties.\n> \n> base-commit: f8e4649680303ce9b7dace5ad1344fcb450013ac\n> prerequisite-patch-id: edbf31ed9d7f5374e17b34936fe1aa8dea2eac44","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 5424ABD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 May 2022 18:50:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6FE5B633A2;\n\tFri, 27 May 2022 20:50:13 +0200 (CEST)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2B0B5633A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 May 2022 20:40:53 +0200 (CEST)","from [127.0.0.1] (localhost [127.0.0.1])\n\t(Authenticated sender: gkiagia) with ESMTPSA id 73EA01F41B75"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653677413;\n\tbh=r53XOo5W0q2OS5tQndUeF/FFASvDIDuc427DrQvwfZU=;\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=U6+gKT07PSra6PGTFMiJeoPDZ7kNAFHRSGpEKsnvWS2Ti9k8YKy5KbzefjXSXPGZd\n\tDD2jXkyxb6s11Jyz3WPhxCBQQM3icDmM3s2J5c+Sn1sJvIdQZTy16LahyGBLg6muwm\n\tCVQ9W5pWPFNVigEeMyTxH4i+9WpX6kj5C4cyV8q3LkLIkxaln2AEt1tI3p78HmVAiT\n\toBaYcsKgV//SsYVwVWp6hdNg0RK7vAZMOBs4slPHubvmZr4GlWoAA3Gnpu9HbrD5LT\n\ttGgUKSA5haZFYt+FxCF/5JGhBwvvtu2xC1ZFfFCG5PwMapTAgQtq30lvuQUjDl645U\n\tjBYRQ7NHYSJyg==","v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com;\n\ts=mail; t=1653676852;\n\tbh=r53XOo5W0q2OS5tQndUeF/FFASvDIDuc427DrQvwfZU=;\n\th=Subject:From:To:Date:In-Reply-To:References:From;\n\tb=azjTNjHEwH6ceWH2GrmjEVeJKMzQWIbnaYF0sagHa5QWnAALfLTze16h0l0u1CxxS\n\tzPXhDxnpuS8XTPNwCNsFQbvhG6JQSPUG2hmP8dvFGYGmdjJenxibdeZrhRfqvAeoNs\n\ta0zO8IR4tYj6y8dSl5NabHay+yK+MssY++PndbmU929EFPqQWJihhDnoz2c0vwI3RF\n\teiSBcBiOS5FBRijiAWmAmlktD4AzC+t/1rB3i6xDQBcKFVBf03QF7ywTAqcM7787ca\n\tfqD0kB8+XnCS2bNXOZhNrDUi569o6vQLwn7YLYa3ux898ueLREYsOMtGCAfTs9nu1B\n\trYuhkaFVOiPjw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=collabora.com\n\theader.i=@collabora.com\n\theader.b=\"azjTNjHE\"; dkim-atps=neutral","Message-ID":"<833b0fd1745fc3c107f6a2366597f12f80bfaaa1.camel@collabora.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 27 May 2022 21:40:47 +0300","In-Reply-To":"<20220526133025.18746-1-laurent.pinchart@ideasonboard.com>","References":"<20220526133025.18746-1-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","User-Agent":"Evolution 3.44.1 (by Flathub.org)) ","MIME-Version":"1.0","X-Mailman-Approved-At":"Fri, 27 May 2022 20:50:12 +0200","Subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: uvcvideo: Infer\n\tcamera location from removable attribute","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":"George Kiagiadakis via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"George Kiagiadakis <george.kiagiadakis@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]