Debian #260 - Doubt on /dev/video1 and /dev/video2

Hello,

I am developing a program which uses v4l2 libs to feed the H264 internal encoder.
I can get frames from my camera but i have a doubt regarding the /dev/video1 and /dev/video2 devices, specifically who is the encoder.

udevadm returns the same relevant information for boths:

# udevadm info --attribute-walk --name=/dev/video2

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/platform/soc/1d00000.video-codec/video4linux/video2':
    KERNEL=="video2"
    SUBSYSTEM=="video4linux"
    DRIVER==""
    ATTR{dev_debug}=="0"
    ATTR{index}=="1"
    ATTR{name}==""

  looking at parent device '/devices/platform/soc/1d00000.video-codec':
    KERNELS=="1d00000.video-codec"
    SUBSYSTEMS=="platform"
    DRIVERS=="qcom-venus"
    ATTRS{driver_override}=="(null)"

  looking at parent device '/devices/platform/soc':
    KERNELS=="soc"
    SUBSYSTEMS=="platform"
    DRIVERS==""
    ATTRS{driver_override}=="(null)"

  looking at parent device '/devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""

# udevadm info --attribute-walk --name=/dev/video1

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/platform/soc/1d00000.video-codec/video4linux/video1':
    KERNEL=="video1"
    SUBSYSTEM=="video4linux"
    DRIVER==""
    ATTR{dev_debug}=="0"
    ATTR{index}=="0"
    ATTR{name}==""

  looking at parent device '/devices/platform/soc/1d00000.video-codec':
    KERNELS=="1d00000.video-codec"
    SUBSYSTEMS=="platform"
    DRIVERS=="qcom-venus"
    ATTRS{driver_override}=="(null)"

  looking at parent device '/devices/platform/soc':
    KERNELS=="soc"
    SUBSYSTEMS=="platform"
    DRIVERS==""
    ATTRS{driver_override}=="(null)"

  looking at parent device '/devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""

The doubt comes when I check the lsmod output:

lsmod | grep venus
venus_dec              20480  0
venus_enc              24576  0
venus_core             61440  2 venus_dec,venus_enc
mdt_loader             16384  2 qcom_wcnss_pil,venus_core
videobuf2_dma_sg       24576  3 venus_dec,qcom_camss,venus_enc
v4l2_mem2mem           24576  3 venus_dec,venus_enc,venus_core
videobuf2_v4l2         24576  5 uvcvideo,venus_dec,qcom_camss,venus_enc,v4l2_mem2mem
videobuf2_core         45056  7 uvcvideo,venus_dec,qcom_camss,venus_enc,venus_core,v4l2_mem2mem,videobuf2_v4l2

Where we can see references to venus_enc and venus_dec.
So is correct to say that /dev/video1 could be the encoder and /dev/video2 could be the decoder ?
If so, how to recognize each one at boot since the names can change ?

Best regards and happy Christmas to all of you.
Simon

I solved using v4l2 libs.
Simon

hi,

the assignment between video1 and video2 is done by the kernel during init, and it is not deterministic. you cannot rely on any specific mapping. You need to query each device for its capabilities, which is probably what you ended up doing. I am just sending this message to confirm you’ve done the right thing.

Hello @anon91830841,

Yes, I used the code by Stanimir Varbanov (https://git.linaro.org/people/stanimir.varbanov/v4l2-encode.git) to retrieve parameters.

Thank you for interesting on it.
Simon