make-autosuspend-rules.py 939 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python3
  2. # SPDX-License-Identifier: LGPL-2.1+
  3. # Generate autosuspend rules for devices that have been tested to work properly
  4. # with autosuspend by the Chromium OS team. Based on
  5. # https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/udev/gen_autosuspend_rules.py
  6. import chromiumos.gen_autosuspend_rules
  7. print('# pci:v<00VENDOR>d<00DEVICE> (8 uppercase hexadecimal digits twice)')
  8. for entry in chromiumos.gen_autosuspend_rules.PCI_IDS:
  9. vendor, device = entry.split(':')
  10. vendor = int(vendor, 16)
  11. device = int(device, 16)
  12. print('pci:v{:08X}d{:08X}*'.format(vendor, device))
  13. print('# usb:v<VEND>p<PROD> (4 uppercase hexadecimal digits twice)')
  14. for entry in chromiumos.gen_autosuspend_rules.USB_IDS:
  15. vendor, product = entry.split(':')
  16. vendor = int(vendor, 16)
  17. product = int(product, 16)
  18. print('usb:v{:04X}p{:04X}*'.format(vendor, product))
  19. print(' ID_AUTOSUSPEND=1')