Skip to content

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

@whvneo

Description

@whvneo

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions