-   Ubuntu (
-   -   Ubuntu 10.04 - Suddenly /dev/video0 Fails to open (

Linux31 09-14-2010 10:45 AM

Ubuntu 10.04 - Suddenly /dev/video0 Fails to open
I'm running Ubuntu Lynx on an AMD dual-core machine that has a Hauppauge PVR-150 card and a Logitech webcam (recently installed).

The webcam seemed to preempt the /dev/video0 identity but ran fine under Cheese for about 2 weeks. Suddenly, yesterday neither the webcam nor the PVR will run. I removed Cheese and the webcam but still no success.

When I run ivtv-tune c-3 to check video0 I get:
Failed to open /dev/video0

I checked and there is a /dev/video0 file.

I tried creating a udev rule and making the webcam video5 but that didn't help.

I still get the video0 failure message even after doing a complete removal of Cheese and the webcam so that takes care of any conflict.

I have no idea what is wrong or how to fix it. Does anyone have any suggestions?

Thanks for any help that you can provide.

Rambo_Tribble 09-14-2010 03:35 PM

Does dmesg offer any salient information?

Linux31 09-14-2010 04:10 PM

Thanks for the suggestion.

dmesg shows entries indicating that it sees both the Haupaugge card and the webcam so I seem to have a problem with /dev/video0 rather than a HW problem.

Rambo_Tribble 09-14-2010 04:46 PM

I'm not sure it will accomplish anything, but I might try removing the webcam, booting and fetching the contents of dmesg. Then I'd attach the cam and do a new reading of dmesg to see if any difference between the two shed any light on what seems to look like an assignment conflict.

I'm afraid I'm kind of shooting in the dark here, as I don't have a webcam. I do have a system with Lucid that has a Hauppauge card, (I'm not sure which model, offhand), and it shows /dev/video0, as well as video24 and 32.

Linux31 09-15-2010 10:15 AM

Thanks for the suggestions. That's what I ended up trying and I have the webcam back.

I think the original problem may have been caused by trying to hook up two of the same kind of webcams (same Logitech models). The OS couldn't tell them apart even when I assigned them each a different video number in a udev rule. The manufacturer and model id is the same. Maybe the problem would have gone away in the udev rule if they were different models or manufacturers.

Anyway, just one webcam and things are working again.

By any chance, do you know if there's a way of solving this problem of multiple copies of the same model HW with a udev rule?

Thanks again for the help.

Rambo_Tribble 09-15-2010 11:12 AM

I'm glad to hear you have made some progress. Unfortunately, my knowledge of udev isn't sufficient to answer your question. My only thought is, that if the cameras have different MAC addresses, that might make it possible to get udev to differentiate between them.

tredegar 09-15-2010 12:58 PM

"Identical" devices can still be differentiated with udev rules by matching on the physical USB socket they are plugged into. You'll have to make a note to yourself so you remember which socket to plug which device into.

It's a while since I played with this but try looking at your cameras like this (I have a single USB cam (= 2 "virtual" identical devices, as long as I only use one at a time ;) ), that is registered as /dev/video1 when I plug it in):

Plug it into "front USB socket" then

tred@laptop:~$ udevadm info -ap $(udevadm info -q path -n /dev/video1) > frontvid
Unplug it, wait a moment, plug it into "rear USB socket" then

tred@laptop:~$ udevadm info -ap $(udevadm info -q path -n /dev/video1) > rearvid

tred@laptop:~$ diff frontvid rearvid
<  looking at device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/video4linux/video1':
>  looking at device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5:1.0/video4linux/video1':
<  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0':
<    KERNELS=="2-1.2:1.0"
>  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5/2-1.5:1.0':
>    KERNELS=="2-1.5:1.0"
<  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2':
<    KERNELS=="2-1.2"
>  looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5':
>    KERNELS=="2-1.5"
<    ATTRS{urbnum}=="5140"
>    ATTRS{urbnum}=="5139"
<    ATTRS{devnum}=="5"
>    ATTRS{devnum}=="6"
<    ATTRS{urbnum}=="113"
>    ATTRS{urbnum}=="152"
<    ATTRS{urbnum}=="39"
>    ATTRS{urbnum}=="46"

The interesting bits are coloured,
Once you have established what the positional information you need to differentiate between the cameras is, you'll need a udev rule something like this:

BUS="usb", ID=="2-1.5:1.0", SYMLINK+="camfront"
BUS="usb", ID=="2-1.2:1.0", SYMLINK+="camrear"

Please let us know how you get on.

washakie 08-29-2011 11:23 AM

same problem on laptop
Hello, I'm raising an old thread here because it seems to be the most relevant my search has turned up...

I'm having a similar problem on a laptop, but I don't have the option of 'disconnecting' the camera to reset it. I was using it with Cheese, just fine, but for some reason it has recently stopped functioning.

Looking at dmesg, udevadm, etc. doesn't seem to reveal anything obvious. So I'm at a loss... also, note that if I do plug in another USB camera, it mounts at /dev/video1 and functions as expected.

Is there a way to 'simulate' an internal camera being disconnected? Or something else I can try?

Thank you.

tredegar 08-29-2011 11:46 AM

Your laptop camera is probably seen as a USB device.
lsusb should list it, along with vendor : product ID codes. If it is listed,
please tell us what it says.

It is surprising that a second USB camera appears at /dev/video1 as
this suggests the built-in one was detected (presumably as /dev/video0).

It is unusual for cameras to stop working suddenly.

What distro of linux are you using, have you changed anything since the
camera was last working?

Is there anything in the BIOS to enable it? Or a function-key combination?

You could try booting a live distro from CD, and see if that can use your
built-in camera.


Is there a way to 'simulate' an internal camera being disconnected?
Not as far as I know.

washakie 08-29-2011 12:52 PM

Hello, the attached file is output from udevadm with lsusb appended below.

I'm writing from a usb distro now, and there's no difference.

ubuntu@ubuntu:~$ lsusb
Bus 002 Device 003: ID 1005:b113 Apacer Technology, Inc. Handy Steno 2.0/HT203
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 005: ID 04f2:b183 Chicony Electronics Co., Ltd
Bus 001 Device 004: ID 138a:0007 DigitalPersona, Inc
Bus 001 Device 003: ID 03f0:231d Hewlett-Packard
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

and udevadm seems to provide similar values as well...

Cheese also has the same response, no Error messages, it opens fine, but then just shows a blank empty screen... if I didn't know better, I'd think I left the lens cap on!! ;)

Sorry, also should mention I'm running 11.04 ubuntu

tredegar 08-29-2011 01:29 PM

Your camera seems to be 04F2:B183 = "HP Webcam [2 MP Macro]" (took me a while to search on this, can you confirm it?)

Searching google returns precious little for this device, which might mean that it works perfectly with linux (as most HP stuff does), or that yours is just broken.

Can you boot to win? Does it work there?

washakie 08-29-2011 02:11 PM

Eeek. Hadn't thought of that possibility.

No, I'm committed. Third laptop with *nix. Haven't dual booted in several years. This is a weird issue, and I'm at a loss where to look.

washakie 08-29-2011 02:50 PM

I've googled around to see other ways to test. The only I've come across that is helpful so far is VLC. Trying to open /dev/video0 I get the following output on the command line:

[0x17693c0] v4l2 demux error: cannot set input (Device or resource busy)
[0x17693c0] v4l2 demux error: cannot set input (Device or resource busy)
[0x1589b20] v4l2 access error: cannot set input (Device or resource busy)
libv4l2: error attempting to open more then 16 video devices
[0x1589b20] v4l2 access error: cannot set input (Device or resource busy)
[0x174f830] main input error: open of `v4l2:///dev/video0' failed: (null)

Then I thought to go back to cheese and run it from the command line to capture some output. I get this:

ubuntu@ubuntu:~$ cheese
libv4l2: error setting pixformat: Device or resource busy

So it seems somehow that /dev/video0 is getting 'grabbed' up by something else, but I don't know what?! It's as if the fix could be what the OP did, just unplug it and replug it, but I can't do that in this case... any further suggestions?

tredegar 08-29-2011 04:20 PM


No, I'm committed.
Ok. So am I.


So it seems somehow that /dev/video0 is getting 'grabbed' up by something else, but I don't know what?
What other stuff have you recently installed? (motion maybe,) before your camera broke?

lsof /dev/video0 may give you some idea as to what might be grabbing the device.

If this does not help you, please start a new thread, with a suitable title, the body containing good information: your distro, camera details (please confirm these, as above) from lsusb

If you do this (and I think you should) I'd appreciate it if you posted a link to your new thread here, so I can be informed, and then follow it up.

I suspect the OP's to this original post have solved it, are long gone, or have lost interest.

Best wishes.

washakie 08-29-2011 04:48 PM

Unfortunately, I'm quite sure it is a hardware problem. My last post was in error (too many terminals open). On one terminal as a regular user I was trying to use streamer to take a picture with the web cam. In another terminal (tab) as root, I was doing the tests that produced the results I posted... thus, it was 'streamer' that was grabbing the device. Once I CTRL-C'd streamer (which was 'waiting for output', but otherwise showed no errors associated with /dev/video0), the other tests ran, but also only provided a black screen.

The last clue, is that the little blue LED light doesn't come on either. So I'm just not sure what is happening, but suspect it must be a connection that has gone bad. I plugged in two other webcams (one embedded in my second monitor and another external) and everything worked fine!

Thanks for your feedback. I learned about udevadm and now lsof ;)

All times are GMT -5. The time now is 12:34 PM.