Assign /dev/video0

I have Jetson TX2 kit .how can i assign /dev/video0 to my webcam which is assigned to /dev/video1 ?

how can i write udev rule for the usb camera to assign it to specific /dev/video
i tried this method in this link https://www.linuxquestions.org/questions/linux-hardware-18/how-can-i-assign-a-webcam-to-a-specific-dev-video-669507/ but it does not work

Why do you need for it? You may need to check which device have allocate the video0 to disable it to have webcam assigned to video0.

Thank you for your response .I need that because i use application that uses specific /dev/video* for example /dev/video1 so every time i boot the jetson ,the jetson assigns the usb camera to different /dev/video* every time that makes the application does not work so i want to assign specific /dev/video* to the usb camera

You can use v4l2 API or v4l2-ctl to query the video to check the vendor for your case.

that what i did

nvidia@jetson:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 011: ID 1a2c:2d23 China Resource Semico Co., Ltd
Bus 001 Device 012: ID 1e4e:0103 Cubeternet
Bus 001 Device 003: ID 0000:3825
Bus 001 Device 002: ID 214b:7250
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

nvidia@jetson:~$ nano /etc/udev/rules.d/83-name-video-devices.rules

I put this udev rule in this file:

KERNEL=="video[0-9]*, SUBSYSTEM==“video4linux”, SUBSYSTEMS==“usb”, ATTRS{idVendor}==“1e4e”, ATTRS{idProduct}==“0103”, NAME=“video1”

i got ATTRS{idVendor}==“1e4e”, ATTRS{idProduct}==“0103” from lsusb command because Cubeternet is the name of the usb camera but this does not work so could you please tell me the udev rule for doing that

I don’t think the udev rule can apply to the uvc driver due to the uvc driver register video node allocate from the first free number.

What I suggest is to use v4l2 API to query every videoX to get the vendor information then your APP can open the right video node depend on it.

Could you please show me the steps of doing that or refer me to link

Using tools maybe python script to issue v4l2-ctl like below then parser the output to check the “Bus info” or "Card type to recognize your webcam. The pass the video node number to you APP.

nvidia@nvidia-desktop:~$ v4l2-ctl -d /dev/video0 -D
Driver Info (not using libv4l2):
        Driver name   : tegra-video
        Card type     : vi-output, ov5693 30-0036
        Bus info      : platform:15700000.vi:0
        Driver version: 4.9.140
        Capabilities  : 0x84200001
                Video Capture
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps   : 0x04200001
                Video Capture
                Streaming
                Extended Pix Format


Thanks for your reply that is what i get when i run this command tor video0 and video1 .video1 is jetson camera ,video0 is usb camera

nvidia@jetson:~$ v4l2-ctl -d /dev/video0 -D
Driver Info (not using libv4l2):
Driver name : uvcvideo
Card type : USB2.0 Camera
Bus info : usb-3530000.xhci-2.1
Driver version: 4.9.140
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format

nvidia@jetson:~$ v4l2-ctl -d /dev/video1 -D
Driver Info (not using libv4l2):
Driver name : tegra-video
Card type : vi-output, ov5693 2-0036
Bus info : platform:15700000.vi:2
Driver version: 4.9.140
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format

so now how can i assign video1 for the usb camera and video0 for jetson built-in camera

You can plug in the USB camera after booting to system, then it will be the video1.

yes i do this now but is their anyway to assign video1 to usb camera in booting

You can modify the video_register_device() in the tegra_vi_graph_notify_complete() to assign 1 for CSI camera.

could you please show me the steps of assigning CSI camera to video0 and usb camera to video1