LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   USB Camera mount and unmount, like Android (https://www.linuxquestions.org/questions/linux-hardware-18/usb-camera-mount-and-unmount-like-android-4175458724/)

jhdalben 04-19-2013 12:23 AM

USB Camera mount and unmount, like Android
 
Hi. I would like to know what does Android (4.0.3) do to mount and unmount (basically offer power supply to it) camera when needed. If you do a lsusb on a terminal after booting, it says there is no camera at all. But when you launch the camera application, if you check lsusb again (and dmesg) it is mounted upon request. As soon as you close the application, it unmounts the camera, probably to save power.

Does anyone know anything about this Android trick to power devices just when it needs a specific device?

Why am I asking this:

On my single-board notebook, I have 32-bit Ubuntu 10.04 running on SD Card and Android 4.0.3 on flash memory.

Ubuntu doesn't recognize the camera, because apparently it doesn't offer any power supply to it (like Android, to save power). If I connect a wire between a powered USB port and the camera USB port, then it recognizes the camera, but if I disconect the wire, it unmounts.

If I remove the SD Card and reboot, then Android comes up. It also doesn't recognize the camera after boot. But as soon as I launch the camera application, somehow the USB gets powered and the camera is recognised.

(If possible, where could I find the source code containing the operations executed by the camera app?)

EDIT:

This is the lsusb output on Ubuntu when the USB camera port gets a power supply through the wire I connect

Code:

$ lsusb
Bus 003 Device 002: ID 04d9:2ba0 Holtek Semiconductor, Inc.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 013: ID 1e4e:0102 
Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp.
Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Here is the normal lsusb output on Ubuntu, without the USB camera/port being recognized

Code:

$ lsusb
Bus 003 Device 002: ID 04d9:2ba0 Holtek Semiconductor, Inc.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp.
Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

This is dmesg on Ubuntu when I connect the wire. Notice it disconnects cause it's not easy to stand still holding the wire :P

Code:

$ dmesg | tail   
[  483.790202] uvcvideo: Found UVC 1.00 device USB2.0 Camera (1e4e:0102)   
[  483.797666] input: USB2.0 Camera as /devices/pci0000:00/0000:00:04.0/usb1/1-1/1-1:1.0/input/input4   
[  484.608278] usb 1-1: USB disconnect, device number 8   
[  486.123368] usb 1-1: new high speed USB device number 9 using ehci_hcd
[  486.258975] usb 1-1: device descriptor read/all, error -71   
[  486.320237] hub 1-0:1.0: unable to enumerate USB device on port 1   
[  486.896696] usb 1-1: new high speed USB device number 11 using ehci_hcd   
[  487.040213] uvcvideo: Found UVC 1.00 device USB2.0 Camera (1e4e:0102)   
[  487.047682] input: USB2.0 Camera as /devices/pci0000:00/0000:00:04.0/usb1/1-1/1-1:1.0
/input/input5   
[  491.890035] usb 1-1: USB disconnect, device number 11


bigrigdriver 04-19-2013 05:14 PM

Quote:

I would like to know what does Android (4.0.3) do to mount and unmount (basically offer power supply to it) camera when needed. If you do a lsusb on a terminal after booting, it says there is no camera at all. But when you launch the camera application, if you check lsusb again (and dmesg) it is mounted upon request. As soon as you close the application, it unmounts the camera, probably to save power.

Does anyone know anything about this Android trick to power devices just when it needs a specific device?
The behavior you describe is controlled by udev.

To identify your camera, with the camera unplugged, open a terminal and run this command: udevadm monitor. That will setup a monitor to watch for udev events.

Now plug in the camera. The mount event will identify the camera as a device.

You can do some research on writing udev rules, and write a rule to automount/umount the camera.


All times are GMT -5. The time now is 09:25 PM.