Mario Limonciello | b61d777 | 2019-09-09 22:49:35 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Yu Watanabe | db9ecf0 | 2020-11-09 13:23:58 +0900 | [diff] [blame] | 2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
Mario Limonciello | b61d777 | 2019-09-09 22:49:35 +0100 | [diff] [blame] | 3 | |
Zbigniew Jędrzejewski-Szmek | 7b33ff7 | 2020-06-22 14:41:50 +0200 | [diff] [blame] | 4 | # Generate autosuspend rules for devices that have been tested to work properly |
| 5 | # with autosuspend by the Chromium OS team. Based on |
Mario Limonciello | b61d777 | 2019-09-09 22:49:35 +0100 | [diff] [blame] | 6 | # https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/udev/gen_autosuspend_rules.py |
| 7 | |
Tim Teichmann | 0490b44 | 2019-10-06 17:59:53 +0200 | [diff] [blame] | 8 | import chromiumos.gen_autosuspend_rules |
Mario Limonciello | b61d777 | 2019-09-09 22:49:35 +0100 | [diff] [blame] | 9 | |
Zbigniew Jędrzejewski-Szmek | 3a7771c | 2020-11-03 14:17:53 +0100 | [diff] [blame] | 10 | print('# pci:v<00VENDOR>d<00DEVICE> (8 uppercase hexadecimal digits twice)') |
Zbigniew Jędrzejewski-Szmek | 79dc5d3 | 2020-06-13 17:52:41 +0200 | [diff] [blame] | 11 | for entry in chromiumos.gen_autosuspend_rules.PCI_IDS: |
| 12 | vendor, device = entry.split(':') |
| 13 | vendor = int(vendor, 16) |
| 14 | device = int(device, 16) |
Zbigniew Jędrzejewski-Szmek | 3a7771c | 2020-11-03 14:17:53 +0100 | [diff] [blame] | 15 | print('pci:v{:08X}d{:08X}*'.format(vendor, device)) |
Lennart Poettering | b456464 | 2020-06-09 17:00:56 +0200 | [diff] [blame] | 16 | |
Zbigniew Jędrzejewski-Szmek | 3a7771c | 2020-11-03 14:17:53 +0100 | [diff] [blame] | 17 | print('# usb:v<VEND>p<PROD> (4 uppercase hexadecimal digits twice)') |
Zbigniew Jędrzejewski-Szmek | 79dc5d3 | 2020-06-13 17:52:41 +0200 | [diff] [blame] | 18 | for entry in chromiumos.gen_autosuspend_rules.USB_IDS: |
| 19 | vendor, product = entry.split(':') |
| 20 | vendor = int(vendor, 16) |
| 21 | product = int(product, 16) |
Zbigniew Jędrzejewski-Szmek | 3a7771c | 2020-11-03 14:17:53 +0100 | [diff] [blame] | 22 | print('usb:v{:04X}p{:04X}*'.format(vendor, product)) |
Lennart Poettering | b456464 | 2020-06-09 17:00:56 +0200 | [diff] [blame] | 23 | |
Zbigniew Jędrzejewski-Szmek | 79dc5d3 | 2020-06-13 17:52:41 +0200 | [diff] [blame] | 24 | print(' ID_AUTOSUSPEND=1') |