How to know the commercial name of a device?

Asked by smurf

Hi, I'm using Ubuntu 12.04 (AMD64).
I have an usb web cam and a pci Tv card on my system, so I use programs like Tvtime, Skype, Guvcview, and others.
The great problem I encountered is that udev assign randomly /dev/videoX device to the video devices, so sometimes I have the tv card on /dev/video0 and the web cam on /dev/video1 or vice versa. I try to fix the /dev/videoX with local rules, but it is not working (there is another question opened https://answers.launchpad.net/ubuntu/+source/udev/+question/220806).
So I need to have a script that check which physical device is connected to the /dev/videoX, in order to instruct the program to open pointing to the right device (i.e.: tvtime -d /dev/video1).
Presently I made something querying udevadm but is quite intricate and most of all it is based on the localization of a string that starts with the substring "DRIVERS==", tomorrow they may change something and my script doesn't work any more.
So, my question is:
There is a system file or a bash command or query that lets me know which physical device is connected to /dev/videoX?
It could be useful the commercial name or HW typology or any other info.
Thx a lot.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Dave Gilbert
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

lsusb; lspci

will show you. You need to know the chip. Make and model doesn't mean much when it comes to drivers

Revision history for this message
smurf (luca-dgh) said :
#2

lspci and lsusb are not useful, because they don't have any connection to /dev/videoX

luca@pc-sala:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 046d:0826 Logitech, Inc.
luca@pc-sala:~$ lspci
00:00.0 RAM memory: NVIDIA Corporation MCP61 Host Bridge (rev a1)
00:01.0 ISA bridge: NVIDIA Corporation MCP61 LPC Bridge (rev a2)
00:01.1 SMBus: NVIDIA Corporation MCP61 SMBus (rev a2)
00:01.2 RAM memory: NVIDIA Corporation MCP61 Memory Controller (rev a2)
00:02.0 USB controller: NVIDIA Corporation MCP61 USB 1.1 Controller (rev a3)
00:02.1 USB controller: NVIDIA Corporation MCP61 USB 2.0 Controller (rev a3)
00:04.0 PCI bridge: NVIDIA Corporation MCP61 PCI bridge (rev a1)
00:05.0 Audio device: NVIDIA Corporation MCP61 High Definition Audio (rev a2)
00:06.0 IDE interface: NVIDIA Corporation MCP61 IDE (rev a2)
00:07.0 Bridge: NVIDIA Corporation MCP61 Ethernet (rev a2)
00:08.0 IDE interface: NVIDIA Corporation MCP61 SATA Controller (rev a2)
00:08.1 IDE interface: NVIDIA Corporation MCP61 SATA Controller (rev a2)
00:09.0 PCI bridge: NVIDIA Corporation MCP61 PCI Express bridge (rev a2)
00:0b.0 PCI bridge: NVIDIA Corporation MCP61 PCI Express bridge (rev a2)
00:0c.0 PCI bridge: NVIDIA Corporation MCP61 PCI Express bridge (rev a2)
00:18.0 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration
00:18.1 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Address Map
00:18.2 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Miscellaneous Control
01:08.0 Multimedia controller: Philips Semiconductors SAA7134/SAA7135HL Video Broadcast Decoder (rev 01)
02:00.0 VGA compatible controller: NVIDIA Corporation GT218 [GeForce 210] (rev a2)
02:00.1 Audio device: NVIDIA Corporation High Definition Audio Controller (rev a1)
luca@pc-sala:~$

Revision history for this message
Best Dave Gilbert (ubuntu-treblig) said :
#3

I think the best bet is to follow it from /sys/class/video4linux - for example on my machine:

dg@major:/sys/class/video4linux$ ls -l
total 0
lrwxrwxrwx 1 root root 0 Feb 11 18:35 video0 -> ../../devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/video4linux/video0

now if I follow that part of the way (yeh that's partly by gut as where to break it unfortunately):

dg@major:/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4$ cat manufacturer
Sonix Technology Co., Ltd.
dg@major:/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4$ cat product
USB 2.0 Camera
dg@major:/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4$ cat idProduct
62f0
dg@major:/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4$ cat idVendor
0c45

That won't necessary tell you what the name on the pack was though; this one was a supermarket own brand; so they've just taken some bulk OEM camera and had their label put on it.

Revision history for this message
smurf (luca-dgh) said :
#4

Thanks Dave Gilbert, that solved my question.

Revision history for this message
smurf (luca-dgh) said :
#5

thanks a lot Dave, you gave me the right answer.

luca@pc-sala:~$ ls /sys/class/video4linux/video0/device/driver/module/drivers/
usb:uvcvideo
luca@pc-sala:~$ ls /sys/class/video4linux/video1/device/driver/module/drivers/
pci:saa7134
luca@pc-sala:~$ cat /sys/class//video4linux/video0/name
HD Webcam C525
luca@pc-sala:~$ cat /sys/class//video4linux/video1/name
saa7134[0] video (Kworld Plus T
luca@pc-sala:~$