Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make use persistent device path /dev/v4l/by-id/.* #78

Open
whvneo opened this issue Aug 23, 2023 · 0 comments
Open

Make use persistent device path /dev/v4l/by-id/.* #78

whvneo opened this issue Aug 23, 2023 · 0 comments

Comments

@whvneo
Copy link

whvneo commented Aug 23, 2023

The ordering of video devices is not persistent.

In akvconfig.ini it is only possible to use a number.

This is because of the following lines attributes.c:

static ssize_t akvcam_attributes_connected_devices_show(struct device *dev,
                                                        struct device_attribute *attribute,
                                                        char *buffer)
{
    struct video_device *vdev = to_video_device(dev);
    akvcam_device_t device = video_get_drvdata(vdev);
    akvcam_devices_list_t devices;
    akvcam_list_element_t it = NULL;
    size_t n = 0;
    size_t i;

    UNUSED(attribute);
    devices = akvcam_device_connected_devices_nr(device);
    memset(buffer, 0, PAGE_SIZE);

    for (i = 0; i < 64 && PAGE_SIZE > n; i++) {
        device = akvcam_list_next(devices, &it);

        if (!it)
            break;

        n = snprintf(buffer + n,
                     PAGE_SIZE - n,
                     "/dev/video%d\n",
                     akvcam_device_num(device));
    }   

    return n;
}

It would make more sense to use a path instead a number.
When listing all capable devices:

ls -l /dev/v4l/*/*
lrwxrwxrwx 1 root root 12 Aug 23 09:27 /dev/v4l/by-id/usb-046d_HD_Pro_Webcam_C920-video-index0 -> ../../video1
lrwxrwxrwx 1 root root 12 Aug 23 09:27 /dev/v4l/by-id/usb-046d_HD_Pro_Webcam_C920-video-index1 -> ../../video3
lrwxrwxrwx 1 root root 12 Aug 23 09:27 /dev/v4l/by-id/usb-Sonix_Technology_Co.__Ltd._BisonCam_NB_Pro-video-index0 -> ../../video4
lrwxrwxrwx 1 root root 12 Aug 23 09:27 /dev/v4l/by-id/usb-Sonix_Technology_Co.__Ltd._BisonCam_NB_Pro-video-index1 -> ../../video5
lrwxrwxrwx 1 root root 12 Aug 23 09:27 /dev/v4l/by-path/pci-0000:00:14.0-usb-0:2:1.0-video-index0 -> ../../video1
lrwxrwxrwx 1 root root 12 Aug 23 09:27 /dev/v4l/by-path/pci-0000:00:14.0-usb-0:2:1.0-video-index1 -> ../../video3
lrwxrwxrwx 1 root root 12 Aug 23 09:27 /dev/v4l/by-path/pci-0000:00:14.0-usb-0:8:1.0-video-index0 -> ../../video4
lrwxrwxrwx 1 root root 12 Aug 23 09:27 /dev/v4l/by-path/pci-0000:00:14.0-usb-0:8:1.0-video-index1 -> ../../video5

So when specifying a new config parameter saying "path" we could easily enter the meaningfull path by id and akvcam will use this instead.

Thanks for checking

@hipersayanX hipersayanX transferred this issue from webcamoid/akvcam Oct 29, 2023
@hipersayanX hipersayanX transferred this issue from another repository Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants