[{"id":29064,"web_url":"https://patchwork.libcamera.org/comment/29064/","msgid":"<pkpgk3fk427r3frs45t23lsenps4mzdwlezcziml3lejrhg4bm@i7wbgp3sh5w4>","date":"2024-03-26T09:03:07","subject":"Re: [PATCH] libcamera: device_enumerator: exclude uvcvideo device\n\twhen enumerate","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Anle\n\nOn Tue, Mar 26, 2024 at 05:38:04PM +0900, Anle Pan wrote:\n> Camera service startup crash when camera and\n> usb camera are connected at the same time,\n> service will always reboot due to the null pointer\n> in populateEntities.\n\nThis is weird, libcamera has been used with uvcvideo devices since the\nvery beginning. As far as I understand, this is not related to Android\nor its CameraService, right ? Just loading the library fails ?\n\n>\n> In this case, a UVC device was used to populate the\n> related entities, pads and links, which was not reasonable.\n\nNot a UVC expert, but why this is not reasonable ? uvc devices have a\nmedia graph with entities, links and pads like every other device,\ndon't they ?\n\n>\n> To fix the issue, ensure the media node is not\n> a \"uvcvideo\" device when enumerate before createDevice.\n\nSo this is disabling uvc support in libcamera completely, preventing\nuvcvideo devices from being enumerated ?\n\nWhat about uvcvideo users ? :)\n\n>\n> Change-Id: I656a542e83449df287d34a4e358ae2e26e784f17\n> Signed-off-by: Anle Pan <anle.pan@nxp.com>\n> ---\n>  src/libcamera/device_enumerator_sysfs.cpp | 21 +++++++++++++++++++++\n>  1 file changed, 21 insertions(+)\n>\n> diff --git a/src/libcamera/device_enumerator_sysfs.cpp b/src/libcamera/device_enumerator_sysfs.cpp\n> index 9979d68a..224ec8c8 100644\n> --- a/src/libcamera/device_enumerator_sysfs.cpp\n> +++ b/src/libcamera/device_enumerator_sysfs.cpp\n> @@ -73,6 +73,27 @@ int DeviceEnumeratorSysfs::enumerate()\n>  \t\t\tcontinue;\n>  \t\t}\n>\n> +\t\t/* Check that the device node not a uvcvideo. */\n> +\t\tstruct media_device_info devinfo;\n> +\t\tint fd = open(devnode.c_str(), O_RDWR | O_CLOEXEC);\n> +\t\tif (fd < 0) {\n> +\t\t\tLOG(DeviceEnumerator, Warning)\n> +\t\t\t\t<< \"Failed to open media device:\" + devnode\n> +\t\t\t\t<< \" (\" << strerror(errno) << \"), skipping\";\n> +\t\t\tcontinue;\n> +\t\t}\n> +\t\tint retval = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &devinfo);\n> +\t\tclose(fd);\n> +\t\tif (retval != 0) {\n> +\t\t\tLOG(DeviceEnumerator, Warning)\n> +\t\t\t\t<< \"Failed to get info from device:\" + devnode\n> +\t\t\t\t<< \" (\" << strerror(errno) << \"), skipping\";\n> +\t\t\tcontinue;\n> +\t\t}\n> +\t\tif (strstr(\"uvcvideo\", devinfo.driver)) {\n> +\t\t\tcontinue;\n> +\t\t}\n> +\n>  \t\tstd::unique_ptr<MediaDevice> media = createDevice(devnode);\n>  \t\tif (!media)\n>  \t\t\tcontinue;\n> --\n> 2.34.1\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 CD77CBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Mar 2024 09:03:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D9718632EA;\n\tTue, 26 Mar 2024 10:03:12 +0100 (CET)","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 34E3A63079\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Mar 2024 10:03:10 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8C22C497;\n\tTue, 26 Mar 2024 10:02:38 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZjxP5boZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1711443758;\n\tbh=JbgnJXcHTOh8WmKjv6CWKsyNdWUONrN3RVn1EjspeV4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ZjxP5boZBlsqY9UTIPKjWPm87Uo6iPdv88nuJiBxQGNwqwm6KNzl5bJ40fcjOExMQ\n\tqi15j4NilaS+sfUrlnS9/KybdrTdOVEE2RDZMh7xRUSS3/RiKq8qBwAojO9f1P/we+\n\tQFhs7WtUFia1jdaauPeeLNslUXSRcI4///7GupPs=","Date":"Tue, 26 Mar 2024 10:03:07 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Anle Pan <anle.pan@nxp.com>","Cc":"libcamera-devel@lists.libcamera.org, hui.fang@nxp.com","Subject":"Re: [PATCH] libcamera: device_enumerator: exclude uvcvideo device\n\twhen enumerate","Message-ID":"<pkpgk3fk427r3frs45t23lsenps4mzdwlezcziml3lejrhg4bm@i7wbgp3sh5w4>","References":"<20240326083804.3718161-1-anle.pan@nxp.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240326083804.3718161-1-anle.pan@nxp.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":29066,"web_url":"https://patchwork.libcamera.org/comment/29066/","msgid":"<DU2PR04MB8967B7799D312BEF13EBF35784352@DU2PR04MB8967.eurprd04.prod.outlook.com>","date":"2024-03-26T10:44:34","subject":"RE: [EXT] Re: [PATCH] libcamera: device_enumerator: exclude uvcvideo\n\tdevice when enumerate","submitter":{"id":189,"url":"https://patchwork.libcamera.org/api/people/189/","name":"Anle Pan","email":"anle.pan@nxp.com"},"content":"Hi Jacopo,\n\n    It is the code added by our own project for debug that causes the crash. Not related to libcamera, please omit the patch. Thanks.\n\nBest Regards\nAnle Pan\n\n-----Original Message-----\nFrom: Jacopo Mondi <jacopo.mondi@ideasonboard.com> \nSent: 2024年3月26日 17:03\nTo: Anle Pan <anle.pan@nxp.com>\nCc: libcamera-devel@lists.libcamera.org; Hui Fang <hui.fang@nxp.com>\nSubject: [EXT] Re: [PATCH] libcamera: device_enumerator: exclude uvcvideo device when enumerate\n\nCaution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button\n\n\nHi Anle\n\nOn Tue, Mar 26, 2024 at 05:38:04PM +0900, Anle Pan wrote:\n> Camera service startup crash when camera and usb camera are connected \n> at the same time, service will always reboot due to the null pointer \n> in populateEntities.\n\nThis is weird, libcamera has been used with uvcvideo devices since the very beginning. As far as I understand, this is not related to Android or its CameraService, right ? Just loading the library fails ?\n\n>\n> In this case, a UVC device was used to populate the related entities, \n> pads and links, which was not reasonable.\n\nNot a UVC expert, but why this is not reasonable ? uvc devices have a media graph with entities, links and pads like every other device, don't they ?\n\n>\n> To fix the issue, ensure the media node is not a \"uvcvideo\" device \n> when enumerate before createDevice.\n\nSo this is disabling uvc support in libcamera completely, preventing uvcvideo devices from being enumerated ?\n\nWhat about uvcvideo users ? :)\n\n>\n> Change-Id: I656a542e83449df287d34a4e358ae2e26e784f17\n> Signed-off-by: Anle Pan <anle.pan@nxp.com>\n> ---\n>  src/libcamera/device_enumerator_sysfs.cpp | 21 +++++++++++++++++++++\n>  1 file changed, 21 insertions(+)\n>\n> diff --git a/src/libcamera/device_enumerator_sysfs.cpp \n> b/src/libcamera/device_enumerator_sysfs.cpp\n> index 9979d68a..224ec8c8 100644\n> --- a/src/libcamera/device_enumerator_sysfs.cpp\n> +++ b/src/libcamera/device_enumerator_sysfs.cpp\n> @@ -73,6 +73,27 @@ int DeviceEnumeratorSysfs::enumerate()\n>                       continue;\n>               }\n>\n> +             /* Check that the device node not a uvcvideo. */\n> +             struct media_device_info devinfo;\n> +             int fd = open(devnode.c_str(), O_RDWR | O_CLOEXEC);\n> +             if (fd < 0) {\n> +                     LOG(DeviceEnumerator, Warning)\n> +                             << \"Failed to open media device:\" + devnode\n> +                             << \" (\" << strerror(errno) << \"), skipping\";\n> +                     continue;\n> +             }\n> +             int retval = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &devinfo);\n> +             close(fd);\n> +             if (retval != 0) {\n> +                     LOG(DeviceEnumerator, Warning)\n> +                             << \"Failed to get info from device:\" + devnode\n> +                             << \" (\" << strerror(errno) << \"), skipping\";\n> +                     continue;\n> +             }\n> +             if (strstr(\"uvcvideo\", devinfo.driver)) {\n> +                     continue;\n> +             }\n> +\n>               std::unique_ptr<MediaDevice> media = createDevice(devnode);\n>               if (!media)\n>                       continue;\n> --\n> 2.34.1\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 2A5C0C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Mar 2024 10:44:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 02ED8632EA;\n\tTue, 26 Mar 2024 11:44:41 +0100 (CET)","from EUR04-VI1-obe.outbound.protection.outlook.com\n\t(mail-vi1eur04on20701.outbound.protection.outlook.com\n\t[IPv6:2a01:111:f403:2611::701])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 093BE63037\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Mar 2024 11:44:39 +0100 (CET)","from DU2PR04MB8967.eurprd04.prod.outlook.com (2603:10a6:10:2e2::19)\n\tby AS5PR04MB9923.eurprd04.prod.outlook.com (2603:10a6:20b:67f::21)\n\twith Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.30;\n\tTue, 26 Mar 2024 10:44:34 +0000","from DU2PR04MB8967.eurprd04.prod.outlook.com\n\t([fe80::863b:1be2:4278:3470]) by\n\tDU2PR04MB8967.eurprd04.prod.outlook.com\n\t([fe80::863b:1be2:4278:3470%4]) with mapi id 15.20.7409.031;\n\tTue, 26 Mar 2024 10:44:34 +0000"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=nxp.com header.i=@nxp.com header.b=\"isNkmqX1\";\n\tdkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n\tb=GlcL9shLNcIyR//6AORs2wsBNvUKzPDn9NHh1bmEAeTyZcbs9RTTyxEQAapS/5mFOHVPUfygM4rmZYUT6ll5kdnkYLtoc/yIDVBGWWy3yLUz3LDpzvsDiykKOwqNV7q+SN13sTSCdcfKDYMrXYhz5BU2xv0PBGJYrAEjG5MEp2H1wBWT84Ly/rqrfy6OGg0ps28W911OFkymQkzcFEO587M9S9a9L5v5bJ8ucuFyUbUey0su+2riPB6NMmUE95GfrHgx8J5K5tbPX5gFG6JtTDIfSWOI6P2eYhtms7BOfTEY0DdG8eKiUHNQKcNnDDcEtC3PBCkk+9aqRRCh/yieMA==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n\ts=arcselector9901;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n\tbh=XBQpwYUBJjOZHYIRXi+TB+Z7XEBNsqpzC9J4WHp4jvo=;\n\tb=n49AljzgF9ydVrkVeYlTb9+c07NzUmAvSDls8DaJ+5SMPVn/++5YMnw03vf7ZxUGcvSVUaC+sxJxkx1S5wh+5TQy16kfAUtBK5duWoWg/oluwSw5biJu2V5br+/gTSVOq2vRNfDZgRVrkUIjjPqSPY2DKdTHW54j/XkMwkltF1gEoW1pjchwjR5pIOipP92kRgOKYUbeySqkgakTpnQ+KpnZ/h7VAlnl3rLXFADGxaWN6swbLv4sPmS8v43l6O/R0AVaimoNHlWSjvwDNLRDlGaaacq6hJ+tdQ0idN1m3GLoHtCgkSKKny8uRotcSXm8ym8+YIuQ8XORErddUREaPw==","ARC-Authentication-Results":"i=1; mx.microsoft.com 1; spf=pass\n\tsmtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com;\n\tdkim=pass header.d=nxp.com; arc=none","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n\tbh=XBQpwYUBJjOZHYIRXi+TB+Z7XEBNsqpzC9J4WHp4jvo=;\n\tb=isNkmqX1uO03Rz/rzaEKgSsmAyIbDM9/QftcUEJ/hZbdnYJ97x7w9CXRaz8KI6AWbPrW2PQZl012jbe6j/OLERq520blRf+gfBGjdTd1g3ecnxOUUOCtUNIxpRoWAVkrCsL+bBdPfoGn2VeMxYIeDd2632CBHUjgx2rQZI8sArk=","From":"Anle Pan <anle.pan@nxp.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","CC":"\"libcamera-devel@lists.libcamera.org\"\n\t<libcamera-devel@lists.libcamera.org>, Hui Fang <hui.fang@nxp.com>","Subject":"RE: [EXT] Re: [PATCH] libcamera: device_enumerator: exclude uvcvideo\n\tdevice when enumerate","Thread-Topic":"[EXT] Re: [PATCH] libcamera: device_enumerator: exclude\n\tuvcvideo device when enumerate","Thread-Index":"AQHaf1j11J52PKaSGkem9NOhxzWbIrFJuiSAgAAcJ3A=","Date":"Tue, 26 Mar 2024 10:44:34 +0000","Message-ID":"<DU2PR04MB8967B7799D312BEF13EBF35784352@DU2PR04MB8967.eurprd04.prod.outlook.com>","References":"<20240326083804.3718161-1-anle.pan@nxp.com>\n\t<pkpgk3fk427r3frs45t23lsenps4mzdwlezcziml3lejrhg4bm@i7wbgp3sh5w4>","In-Reply-To":"<pkpgk3fk427r3frs45t23lsenps4mzdwlezcziml3lejrhg4bm@i7wbgp3sh5w4>","Accept-Language":"en-US","Content-Language":"en-US","X-MS-Has-Attach":"","X-MS-TNEF-Correlator":"","x-ms-publictraffictype":"Email","x-ms-traffictypediagnostic":"DU2PR04MB8967:EE_|AS5PR04MB9923:EE_","x-ms-exchange-senderadcheck":"1","x-ms-exchange-antispam-relay":"0","x-microsoft-antispam":"BCL:0;","x-microsoft-antispam-message-info":"LqfD3VVhIK28vwmUE5j1sjE2c4+osDo+j9A7dKs5rV4G2+87aQj+rhWXEpuOxVhFUCTApAwEzpkYRDnqqnUp0R7ygJjDcxj0o50D5QPWc7206WYbdQtO/WRyqqDHYSMCvP3BjHnIyoENm1gJQ/W5KGfnP+wG+Ns1WOSsH+p7Ws/je6W9ojO/HTj85HuehFWds3tOjqxJkQm86Oo1W3ZKuASWnYDdCUeKk9fTcgr63a2OpaoUOk7obMKBG2mHepw4YD07+H+AGCLsFoj/xk251XAQZnj1XS+yGFKdBb3luH/BB47+7ZfAwNnSoV/8ftDs4/8h62Sh08fVZVRQgBof7LTaMDQ1NeK8l4jXRvyZlQy9U+UyjYIGAgNuEL6QGR7nKWjUlg0RU+YSi/qj3lgSlpaddhRh2WID7AKiBZcRUoG8CzF2JjxFLeJPQRRsK/To1MVQDw9j+qWo/KlWa8kc1MP8g9ObbEYOISE780DttYnI79kYBLqFilejrrwJAQUhUt8pJFwb3swSFiTrJtamgKhPXT7Cfk3s2uGoWC3X1vFPcaUY82o+kXzd3SU8r7Aczur8dmFTyxMzAPowd14deI+b4fHOmqlKlIOffYa6XdfwrCykFVoexDS//rjyrA9vuumGDNlH8XoUQ2m4OcbCufsEPd2CIpmT8tEZt2iWN5M=","x-forefront-antispam-report":"CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;\n\tIPV:NLI; SFV:NSPM; H:DU2PR04MB8967.eurprd04.prod.outlook.com; PTR:;\n\tCAT:NONE; \n\tSFS:(13230031)(376005)(1800799015)(366007); DIR:OUT; SFP:1102; ","x-ms-exchange-antispam-messagedata-chunkcount":"1","x-ms-exchange-antispam-messagedata-0":"=?utf-8?q?PULdtqHyyY9wxkwEY3MP9+J5Y?=\n\t=?utf-8?q?coIdf9JY6eeLMtEdCkDe5TAVEzmS1FleZGgUQJL7FAQD/l2JoDZtVKRC?=\n\t=?utf-8?q?ldR0AemOVsyJIC0wbOGHu4bSg/1aTYg+47bsuxuhHfOmnPuzhn2NJAyc?=\n\t=?utf-8?q?fkHE98lEAO501sTSTWOO8hFQwdRhnvZC8EwvsA0Tu8rRzKiAKcqBibx7?=\n\t=?utf-8?q?oUmPsgty9IoN4MKq98e8GgIxByc7q67HmtVls1f3CJD+iy1dOI40F0jd?=\n\t=?utf-8?q?hXBKrZDoYgejV2emJwN6+Sm8J6piop8H9+Lp9k4fDaeKwOIFMeiDcdL0?=\n\t=?utf-8?q?jdDEY3yhKjMrRuC1SAFbeGUsfn++4npbkqi+vCz2ykOShDenNag3qRO/?=\n\t=?utf-8?q?G+5f1jFU28x7hzX8NTIPfoXoNZmjo5FDOjHKSHi1iF69tZfHdNJnEHqA?=\n\t=?utf-8?q?FbMwnhLdcP3LesrXsaMsKbxhT1KW2vzHq11YaAvZOQMMZaEXoPTC20Kr?=\n\t=?utf-8?q?YJ14kI6eRl8JMhxn8LKwTSfxyJOxERG+1UX5H1eW2v1SVVNy1AkHDrdM?=\n\t=?utf-8?q?imLK/p1Y/rVfWVsS0EI3wJ4kskHhH0SAaJUs9jG49JdVudRM9d8KR169?=\n\t=?utf-8?q?u+MNw3hLIV0xAz5ddauw8EGWvGbgcV7DTor8LOt2OOJDL/ip7Xw8FnC/?=\n\t=?utf-8?q?RJhLDf/yiQgZAHng6JSP8U6pJ/iGhuF5Ip63LtCWC7wKGL2Ly56yXSiZ?=\n\t=?utf-8?q?mDv+q8icXXL/dAqFvWsjBI5LdYAx1/iI52mKRlDwCo8CRGEs9Jsk4pFV?=\n\t=?utf-8?q?EjOK9pdTADAz+tI4ij/9XC2WKPaIWeSQWsBpsRt2pmEaGq8aMahp+uV2?=\n\t=?utf-8?q?MLVnmIyWO0Qs5prmFKpwDdBF6s5o9hgQyJDRAJi/R/HffsDUNCFLdibS?=\n\t=?utf-8?q?TmNHV/zensm/dtL3JEaMcY5fJdD0EYar1jvMtKz9GWGpxllEtuLZdX/v?=\n\t=?utf-8?q?GepjFc6/12w7lo8qwNRSg0gniNBJGptL3LidzPIPjrK/icMgfqNP7LCW?=\n\t=?utf-8?q?zjIbNNdRMo3WKNJkdv+tPLDiEX/9sLBmjjnaLO2FLqIDtIDEQhZwxbzK?=\n\t=?utf-8?q?sL+6YoU/F5sccllj5MHQj0A/r8R2669QS764cSe4f80xNGsiN3Tz5aSS?=\n\t=?utf-8?q?wOmWNEN65oE3pw7/SP3I7l8Nnt8HxHH1m/q+muLaHjFe9NfjYzQ2c43n?=\n\t=?utf-8?q?UQW7sYN8/AC7V1jluE4eCg5lSxgNVpFHHYM355jdpTmbZaHCNW8JJ67+?=\n\t=?utf-8?q?kztgA+/6mgxqrcRme9/PyiyM2tCuSTJmoQ8SQecLi01DHk4dJSqKouPU?=\n\t=?utf-8?q?aFkZKN4xdFrKBCmWFeQ49XS/WvnSR4XKutJnStcizdlgHhpw8YTsOtDS?=\n\t=?utf-8?q?TDzSdtRe8mcTIU8jyGObsjMA7dcVggz/A83Yf0BHUlH+FoRx9VAXfofP?=\n\t=?utf-8?q?gYH8hjd6ZOgkeBaES5AWriGFPNahlMG6hSv30g9oW3U+5Ryku15a0azr?=\n\t=?utf-8?q?N54uRZ4BATiLtIEqvHe9FJDgYu4Eo2hOXe2ymUhUC8j1mo0yjevxfu4V?=\n\t=?utf-8?q?aiPSuviK+n8k9mWXZwgLSruSkl4Uw3JI8nFCcxOMpu5LXNdVorcMclxg?=\n\t=?utf-8?q?XIYiE4srX/7wO3S9fCXqBRKgd1XTri2306A8MUbhLQ=3D?=","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","MIME-Version":"1.0","X-OriginatorOrg":"nxp.com","X-MS-Exchange-CrossTenant-AuthAs":"Internal","X-MS-Exchange-CrossTenant-AuthSource":"DU2PR04MB8967.eurprd04.prod.outlook.com","X-MS-Exchange-CrossTenant-Network-Message-Id":"cb864b87-e0bd-4518-1ba2-08dc4d81ba1a","X-MS-Exchange-CrossTenant-originalarrivaltime":"26 Mar 2024 10:44:34.7925\n\t(UTC)","X-MS-Exchange-CrossTenant-fromentityheader":"Hosted","X-MS-Exchange-CrossTenant-id":"686ea1d3-bc2b-4c6f-a92c-d99c5c301635","X-MS-Exchange-CrossTenant-mailboxtype":"HOSTED","X-MS-Exchange-CrossTenant-userprincipalname":"JAsuUYIf/Ue5T4myejahpcPWQwKshH8xvHpK92J1J2FMAZ6MQ4euhLDqjebz7jmQfpPoLHDkkcdq80fhZcodtw==","X-MS-Exchange-Transport-CrossTenantHeadersStamped":"AS5PR04MB9923","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":29067,"web_url":"https://patchwork.libcamera.org/comment/29067/","msgid":"<m4aavipn7a52sqjavmnpcdycsu6ewg2b7rmf3lqbdnuuxri6ng@5owo4k24qpzl>","date":"2024-03-26T10:50:51","subject":"Re: [EXT] Re: [PATCH] libcamera: device_enumerator: exclude uvcvideo\n\tdevice when enumerate","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"No worries, happy you got it solved!\n\nCheers\n   j\n\nOn Tue, Mar 26, 2024 at 10:44:34AM +0000, Anle Pan wrote:\n> Hi Jacopo,\n>\n>     It is the code added by our own project for debug that causes the crash. Not related to libcamera, please omit the patch. Thanks.\n>\n> Best Regards\n> Anle Pan\n>\n> -----Original Message-----\n> From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Sent: 2024年3月26日 17:03\n> To: Anle Pan <anle.pan@nxp.com>\n> Cc: libcamera-devel@lists.libcamera.org; Hui Fang <hui.fang@nxp.com>\n> Subject: [EXT] Re: [PATCH] libcamera: device_enumerator: exclude uvcvideo device when enumerate\n>\n> Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button\n>\n>\n> Hi Anle\n>\n> On Tue, Mar 26, 2024 at 05:38:04PM +0900, Anle Pan wrote:\n> > Camera service startup crash when camera and usb camera are connected\n> > at the same time, service will always reboot due to the null pointer\n> > in populateEntities.\n>\n> This is weird, libcamera has been used with uvcvideo devices since the very beginning. As far as I understand, this is not related to Android or its CameraService, right ? Just loading the library fails ?\n>\n> >\n> > In this case, a UVC device was used to populate the related entities,\n> > pads and links, which was not reasonable.\n>\n> Not a UVC expert, but why this is not reasonable ? uvc devices have a media graph with entities, links and pads like every other device, don't they ?\n>\n> >\n> > To fix the issue, ensure the media node is not a \"uvcvideo\" device\n> > when enumerate before createDevice.\n>\n> So this is disabling uvc support in libcamera completely, preventing uvcvideo devices from being enumerated ?\n>\n> What about uvcvideo users ? :)\n>\n> >\n> > Change-Id: I656a542e83449df287d34a4e358ae2e26e784f17\n> > Signed-off-by: Anle Pan <anle.pan@nxp.com>\n> > ---\n> >  src/libcamera/device_enumerator_sysfs.cpp | 21 +++++++++++++++++++++\n> >  1 file changed, 21 insertions(+)\n> >\n> > diff --git a/src/libcamera/device_enumerator_sysfs.cpp\n> > b/src/libcamera/device_enumerator_sysfs.cpp\n> > index 9979d68a..224ec8c8 100644\n> > --- a/src/libcamera/device_enumerator_sysfs.cpp\n> > +++ b/src/libcamera/device_enumerator_sysfs.cpp\n> > @@ -73,6 +73,27 @@ int DeviceEnumeratorSysfs::enumerate()\n> >                       continue;\n> >               }\n> >\n> > +             /* Check that the device node not a uvcvideo. */\n> > +             struct media_device_info devinfo;\n> > +             int fd = open(devnode.c_str(), O_RDWR | O_CLOEXEC);\n> > +             if (fd < 0) {\n> > +                     LOG(DeviceEnumerator, Warning)\n> > +                             << \"Failed to open media device:\" + devnode\n> > +                             << \" (\" << strerror(errno) << \"), skipping\";\n> > +                     continue;\n> > +             }\n> > +             int retval = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &devinfo);\n> > +             close(fd);\n> > +             if (retval != 0) {\n> > +                     LOG(DeviceEnumerator, Warning)\n> > +                             << \"Failed to get info from device:\" + devnode\n> > +                             << \" (\" << strerror(errno) << \"), skipping\";\n> > +                     continue;\n> > +             }\n> > +             if (strstr(\"uvcvideo\", devinfo.driver)) {\n> > +                     continue;\n> > +             }\n> > +\n> >               std::unique_ptr<MediaDevice> media = createDevice(devnode);\n> >               if (!media)\n> >                       continue;\n> > --\n> > 2.34.1\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 8699BBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Mar 2024 10:50:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6CD9863311;\n\tTue, 26 Mar 2024 11:50:56 +0100 (CET)","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 B87866303D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Mar 2024 11:50:54 +0100 (CET)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EDCCC497;\n\tTue, 26 Mar 2024 11:50:22 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"tYdISwsC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1711450223;\n\tbh=I+2PuHsjJuiYltMy13jwtY/YbHIvvtW22brk2JWqZd8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=tYdISwsCsHeAjXQda1+6WJOMrvCRWw1LCcgEt0U/iH3ilcTt5vE1iq/PLVKEZj59z\n\tsH4oKtHDPg8R9GLhtLgVXip6rDoWqMcrWFocxJE5LG0KuQGtVuUAeuBH5zSBFEbGWZ\n\t0NU7K/W3NgeJ+bfW5BOAjGaBne/LWAR7OwpX4ZHg=","Date":"Tue, 26 Mar 2024 11:50:51 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Anle Pan <anle.pan@nxp.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>, \n\t\"libcamera-devel@lists.libcamera.org\"\n\t<libcamera-devel@lists.libcamera.org>, Hui Fang <hui.fang@nxp.com>","Subject":"Re: [EXT] Re: [PATCH] libcamera: device_enumerator: exclude uvcvideo\n\tdevice when enumerate","Message-ID":"<m4aavipn7a52sqjavmnpcdycsu6ewg2b7rmf3lqbdnuuxri6ng@5owo4k24qpzl>","References":"<20240326083804.3718161-1-anle.pan@nxp.com>\n\t<pkpgk3fk427r3frs45t23lsenps4mzdwlezcziml3lejrhg4bm@i7wbgp3sh5w4>\n\t<DU2PR04MB8967B7799D312BEF13EBF35784352@DU2PR04MB8967.eurprd04.prod.outlook.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<DU2PR04MB8967B7799D312BEF13EBF35784352@DU2PR04MB8967.eurprd04.prod.outlook.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>"}}]