[EXT] Re: [PATCH] libcamera: device_enumerator: exclude uvcvideo device when enumerate

Anle Pan anle.pan at nxp.com
Tue Mar 26 11:44:34 CET 2024


Hi Jacopo,

    It is the code added by our own project for debug that causes the crash. Not related to libcamera, please omit the patch. Thanks.

Best Regards
Anle Pan

-----Original Message-----
From: Jacopo Mondi <jacopo.mondi at ideasonboard.com> 
Sent: 2024年3月26日 17:03
To: Anle Pan <anle.pan at nxp.com>
Cc: libcamera-devel at lists.libcamera.org; Hui Fang <hui.fang at nxp.com>
Subject: [EXT] Re: [PATCH] libcamera: device_enumerator: exclude uvcvideo device when enumerate

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


Hi Anle

On Tue, Mar 26, 2024 at 05:38:04PM +0900, Anle Pan wrote:
> Camera service startup crash when camera and usb camera are connected 
> at the same time, service will always reboot due to the null pointer 
> in populateEntities.

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 ?

>
> In this case, a UVC device was used to populate the related entities, 
> pads and links, which was not reasonable.

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 ?

>
> To fix the issue, ensure the media node is not a "uvcvideo" device 
> when enumerate before createDevice.

So this is disabling uvc support in libcamera completely, preventing uvcvideo devices from being enumerated ?

What about uvcvideo users ? :)

>
> Change-Id: I656a542e83449df287d34a4e358ae2e26e784f17
> Signed-off-by: Anle Pan <anle.pan at nxp.com>
> ---
>  src/libcamera/device_enumerator_sysfs.cpp | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/src/libcamera/device_enumerator_sysfs.cpp 
> b/src/libcamera/device_enumerator_sysfs.cpp
> index 9979d68a..224ec8c8 100644
> --- a/src/libcamera/device_enumerator_sysfs.cpp
> +++ b/src/libcamera/device_enumerator_sysfs.cpp
> @@ -73,6 +73,27 @@ int DeviceEnumeratorSysfs::enumerate()
>                       continue;
>               }
>
> +             /* Check that the device node not a uvcvideo. */
> +             struct media_device_info devinfo;
> +             int fd = open(devnode.c_str(), O_RDWR | O_CLOEXEC);
> +             if (fd < 0) {
> +                     LOG(DeviceEnumerator, Warning)
> +                             << "Failed to open media device:" + devnode
> +                             << " (" << strerror(errno) << "), skipping";
> +                     continue;
> +             }
> +             int retval = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &devinfo);
> +             close(fd);
> +             if (retval != 0) {
> +                     LOG(DeviceEnumerator, Warning)
> +                             << "Failed to get info from device:" + devnode
> +                             << " (" << strerror(errno) << "), skipping";
> +                     continue;
> +             }
> +             if (strstr("uvcvideo", devinfo.driver)) {
> +                     continue;
> +             }
> +
>               std::unique_ptr<MediaDevice> media = createDevice(devnode);
>               if (!media)
>                       continue;
> --
> 2.34.1
>


More information about the libcamera-devel mailing list