12

I have a laptop with faulty LCD-panel cable. This cable is routed to LCD-panel and web-cam with microphone. The LCD-panel works normally, but webcam and microphone are faulty. I do not plan to visit repair, so I hope to get software based solution. Really I do not use this webcam and have bluetooth handset for mic replacement.

Currently I know that webcam is at /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.5.
I want do blacklist this port.

If it matters, lsusb says currently the following about this device:

Bus 002 Device 053: ID 04f2:b330 Chicony Electronics Co., Ltd Asus 720p CMOS webcam

and Device 053 has an increment.

It floods syslog with messages like

  • usb 2-1.5: new high-speed USB device number 29 using ehci-pci
  • usb 2-1.5: device descriptor read/64, error -71
  • usb 2-1.5: USB disconnect, device number 23.

Without uvcvideo driver blacklisting it floods the uvcdynctrl-udev.log file:

$ ls -alh /var/log/uvcdynctrl-udev.log 
-rw-r--r-- 1 root root 8,1G Apr 17 18:20 /var/log/uvcdynctrl-udev.log

So I have already blacklisted uvcvideo kernel driver by placing blacklist uvcvideo to /etc/modprobe.d/blacklist-uvc.conf. But this single measure does not help.

How should I blacklist faulty internal USB port with connected webcam completely?

N0rbert
  • 99,918

2 Answers2

13

Yes, this can be done with just a couple of commands in the terminal:

  1. Disable the USB port:
    echo disabled | sudo tee /sys/bus/usb/devices/usb2/power/wakeup
    
  2. Remove power from the port:
    echo suspend | sudo tee /sys/bus/usb/devices/usb2/power/level
    

In the event this doesn’t work, a udev rule may be necessary:

  1. Create a new file in /lib/udev/rules.d using a text editor of your choice. For example:
    sudo vi /lib/udev/rules.d/20-block-webcam.rules
    
  2. Revoke authorization for the webcam to be accessed:
    # Chicony Webcam
    SUBSYSTEM=="usb", ATTRS{idVendor}=="04f2", ATTRS{idProduct}=="b330", ATTR{authorized}="0"
    
    Looks like the output of lsusb did matter
  3. Reboot

From comments:

Also it then maybe fixed by echo 0 | sudo tee /sys/bus/usb/devices/2-1.5/authorized as per https://www.kernel.org/doc/Documentation/usb/authorization.txt .
Put echo 0 > /sys/bus/usb/devices/2-1.5/authorized to /etc/rc.local.

Also, the port can be disabled completely (kernel will stop enumerating of any devices connected to this port, but will keep power on port) using the command like following (this command disables the USB port 1-6 on my system):

echo 1 | sudo tee /sys/bus/usb/devices/usb1/1-0:1.0/usb1-port6/disable

matigo
  • 22,138
  • 7
  • 45
  • 75
  • 1
    I have already read something that you are going to recommend. The first command works, but not enough. The second fails - echo suspend | sudo tee /sys/bus/usb/devices/usb2/power/level it returns suspend with tee: /sys/bus/usb/devices/usb2/power/level: Invalid argument. How should we fix the second command? – N0rbert May 16 '21 at 14:17
  • This command will remove power from just the camera, which may get you closer to where you want to go: echo suspend | sudo tee /sys/bus/usb/devices/2-1/power/level – matigo May 16 '21 at 14:24
  • 1
    It says Invalid argument too. Do we have other flags in sysfs? – N0rbert May 16 '21 at 14:26
  • Updated answer to use a udev rule. It’s an older technique, but should work – matigo May 16 '21 at 14:37
  • Great! Also it then maybe fixed by echo 0 | sudo tee /sys/bus/usb/devices/2-1/authorized as per https://www.kernel.org/doc/Documentation/usb/authorization.txt . I put echo 0 > /sys/bus/usb/devices/2-1/authorized to /etc/rc.local. – N0rbert May 16 '21 at 14:38
  • I’ll have to update my “Notebook of Ubuntu Cheats” for that – matigo May 16 '21 at 14:40
  • 1
    Note that the "level" file is deprecated since 2.6.35 and replaced by a "control" file, but that no longer supports the "suspend" value since 2.6.32. See https://www.kernel.org/doc/html/v5.0/driver-api/usb/power-management.html#the-user-interface-for-dynamic-pm – Matthijs Kooijman Dec 09 '22 at 17:20
  • @matigo do you know if it is possible to turn off a Wacom touch device but not the stylus/tablet devices? please see my question https://unix.stackexchange.com/questions/756097/extra-udev-rule-to-keep-wacom-stylus-turned-on-while-disabling-touchscreen-libi – Johan Sep 09 '23 at 11:38
2

I ended up here twice having the same issue with the fingerprint reader but the other options didn't work as the suspend was not the answer.

What I ended up doing was starting powertop and using their tunables features to see how they got rid of the device consuming power.

In my case, the offender was Bus 001 Device 004: ID 27c6:5395 Shenzhen Goodix Technology Co.,Ltd. Fingerprint Reader

So using this command taken from powertop it works

echo "auto" | sudo tee /sys/bus/usb/devices/1-7/power/control

fredden
  • 103