#!/bin/sh # Fix ASUS 5M webcam after suspend/resume. # The webcam USB device fails to resume (error -22) and disconnects. # Rebinding the xHCI controller forces re-enumeration. set -e CONTROLLER="/sys/bus/pci/drivers/xhci_hcd/0000:c4:00.4" if [ ! -e "$CONTROLLER" ]; then echo "fix-webcam-resume: xHCI controller not found at $CONTROLLER" >&2 exit 1 fi echo "fix-webcam-resume: rebinding xHCI controller..." echo "0000:c4:00.4" > /sys/bus/pci/drivers/xhci_hcd/unbind sleep 1 echo "0000:c4:00.4" > /sys/bus/pci/drivers/xhci_hcd/bind # Wait for USB devices to settle sleep 2 if [ -e /dev/video0 ]; then echo "fix-webcam-resume: webcam is back at /dev/video0" else echo "fix-webcam-resume: /dev/video0 still missing after rebind" >&2 fi