Systemd/tools/make-autosuspend-rules.py

25 lines
945 B
Python
Raw Normal View History

#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# Generate autosuspend rules for devices that have been tested to work properly
# with autosuspend by the Chromium OS team. Based on
# https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/udev/gen_autosuspend_rules.py
2019-10-06 17:59:53 +02:00
import chromiumos.gen_autosuspend_rules
hwdb: add trailing ":*" everywhere No functional change is intended. The general pattern of changes: -usb:v04F3p2B7C* +usb:v04F3p2B7C:* This is mostly a clarification, to make the part that makes the usb vXXXXpYYYY part visually separated. It would only make a difference if we added further keys with a different number of digits, which is unlikely. -usb:v0627p0001:*QEMU USB Keyboard* -usb:v0627p0001:*QEMU USB Mouse* -usb:v0627p0001:*QEMU USB Tablet* +usb:v0627p0001:*QEMU USB Keyboard*:* +usb:v0627p0001:*QEMU USB Mouse*:* +usb:v0627p0001:*QEMU USB Tablet*:* Again, only a clarification. We know that ":" will appear somewhere later in the match key, so anything that matches "…Keyboard*" will also match "…Keyboard*:*". -evdev:name:ETPS/2 Elantech Touchpad:dmi:*svnASUSTeKComputerInc.:pnN53SV* +evdev:name:ETPS/2 Elantech Touchpad:dmi:*svnASUSTeKComputerInc.:pnN53SV:* This makes the match narrower. Previously we would match product "N53SV" and "N53SV2", "N53SV3", and others. Here we are saying that the ':pn' part must match exactly. Most of the changes in this patch match this pattern. I made a few judgement calls and used "pn…*:*" when I wasn't sure if the full pn is included: -evdev:name:Dell WMI hotkeys:dmi:bvn*:bvr*:bd*:svnDell*:pnPrecision* +evdev:name:Dell WMI hotkeys:dmi:bvn*:bvr*:bd*:svnDell*:pnPrecision*:* -evdev:name:Cypress APA Trackpad ?cyapa?:dmi:*:svnHewlett-Packard*:pnFalco*: +evdev:name:Cypress APA Trackpad ?cyapa?:dmi:*:svnHewlett-Packard*:pnFalco*:* This more like the "QEMU" example above, since all dmi strings end in ":", so anything which matches the old version will also match the new version. -evdev:atkbd:dmi:bvn*:bvr*:bd*:svnGateway*:pnA0A1*:pvr* +evdev:atkbd:dmi:bvn*:bvr*:bd*:svnGateway*:pnA0A1*:* I replaced trailing ":pvr*" by ":*". This makes no functional difference because we expect "pvr" to always appear in the dmi string. This makes patterns shorter. -evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn* +evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn*:* OTOH, ":pn*" is kept. This is because almost patterns include ":pn*", and if we skip it, we should make it clear that this is on purpose, that we really want to match any product name. The python script to generate autosuspend rules is updated to use ":*" too. Inspired by https://github.com/systemd/systemd/pull/17281#discussion_r501489750.
2020-10-15 09:23:30 +02:00
print('# pci:v<00VENDOR>d<00DEVICE>:* (8 uppercase hexadecimal digits twice)')
for entry in chromiumos.gen_autosuspend_rules.PCI_IDS:
vendor, device = entry.split(':')
vendor = int(vendor, 16)
device = int(device, 16)
hwdb: add trailing ":*" everywhere No functional change is intended. The general pattern of changes: -usb:v04F3p2B7C* +usb:v04F3p2B7C:* This is mostly a clarification, to make the part that makes the usb vXXXXpYYYY part visually separated. It would only make a difference if we added further keys with a different number of digits, which is unlikely. -usb:v0627p0001:*QEMU USB Keyboard* -usb:v0627p0001:*QEMU USB Mouse* -usb:v0627p0001:*QEMU USB Tablet* +usb:v0627p0001:*QEMU USB Keyboard*:* +usb:v0627p0001:*QEMU USB Mouse*:* +usb:v0627p0001:*QEMU USB Tablet*:* Again, only a clarification. We know that ":" will appear somewhere later in the match key, so anything that matches "…Keyboard*" will also match "…Keyboard*:*". -evdev:name:ETPS/2 Elantech Touchpad:dmi:*svnASUSTeKComputerInc.:pnN53SV* +evdev:name:ETPS/2 Elantech Touchpad:dmi:*svnASUSTeKComputerInc.:pnN53SV:* This makes the match narrower. Previously we would match product "N53SV" and "N53SV2", "N53SV3", and others. Here we are saying that the ':pn' part must match exactly. Most of the changes in this patch match this pattern. I made a few judgement calls and used "pn…*:*" when I wasn't sure if the full pn is included: -evdev:name:Dell WMI hotkeys:dmi:bvn*:bvr*:bd*:svnDell*:pnPrecision* +evdev:name:Dell WMI hotkeys:dmi:bvn*:bvr*:bd*:svnDell*:pnPrecision*:* -evdev:name:Cypress APA Trackpad ?cyapa?:dmi:*:svnHewlett-Packard*:pnFalco*: +evdev:name:Cypress APA Trackpad ?cyapa?:dmi:*:svnHewlett-Packard*:pnFalco*:* This more like the "QEMU" example above, since all dmi strings end in ":", so anything which matches the old version will also match the new version. -evdev:atkbd:dmi:bvn*:bvr*:bd*:svnGateway*:pnA0A1*:pvr* +evdev:atkbd:dmi:bvn*:bvr*:bd*:svnGateway*:pnA0A1*:* I replaced trailing ":pvr*" by ":*". This makes no functional difference because we expect "pvr" to always appear in the dmi string. This makes patterns shorter. -evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn* +evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn*:* OTOH, ":pn*" is kept. This is because almost patterns include ":pn*", and if we skip it, we should make it clear that this is on purpose, that we really want to match any product name. The python script to generate autosuspend rules is updated to use ":*" too. Inspired by https://github.com/systemd/systemd/pull/17281#discussion_r501489750.
2020-10-15 09:23:30 +02:00
print('pci:v{:08X}d{:08X}:*'.format(vendor, device))
hwdb: add trailing ":*" everywhere No functional change is intended. The general pattern of changes: -usb:v04F3p2B7C* +usb:v04F3p2B7C:* This is mostly a clarification, to make the part that makes the usb vXXXXpYYYY part visually separated. It would only make a difference if we added further keys with a different number of digits, which is unlikely. -usb:v0627p0001:*QEMU USB Keyboard* -usb:v0627p0001:*QEMU USB Mouse* -usb:v0627p0001:*QEMU USB Tablet* +usb:v0627p0001:*QEMU USB Keyboard*:* +usb:v0627p0001:*QEMU USB Mouse*:* +usb:v0627p0001:*QEMU USB Tablet*:* Again, only a clarification. We know that ":" will appear somewhere later in the match key, so anything that matches "…Keyboard*" will also match "…Keyboard*:*". -evdev:name:ETPS/2 Elantech Touchpad:dmi:*svnASUSTeKComputerInc.:pnN53SV* +evdev:name:ETPS/2 Elantech Touchpad:dmi:*svnASUSTeKComputerInc.:pnN53SV:* This makes the match narrower. Previously we would match product "N53SV" and "N53SV2", "N53SV3", and others. Here we are saying that the ':pn' part must match exactly. Most of the changes in this patch match this pattern. I made a few judgement calls and used "pn…*:*" when I wasn't sure if the full pn is included: -evdev:name:Dell WMI hotkeys:dmi:bvn*:bvr*:bd*:svnDell*:pnPrecision* +evdev:name:Dell WMI hotkeys:dmi:bvn*:bvr*:bd*:svnDell*:pnPrecision*:* -evdev:name:Cypress APA Trackpad ?cyapa?:dmi:*:svnHewlett-Packard*:pnFalco*: +evdev:name:Cypress APA Trackpad ?cyapa?:dmi:*:svnHewlett-Packard*:pnFalco*:* This more like the "QEMU" example above, since all dmi strings end in ":", so anything which matches the old version will also match the new version. -evdev:atkbd:dmi:bvn*:bvr*:bd*:svnGateway*:pnA0A1*:pvr* +evdev:atkbd:dmi:bvn*:bvr*:bd*:svnGateway*:pnA0A1*:* I replaced trailing ":pvr*" by ":*". This makes no functional difference because we expect "pvr" to always appear in the dmi string. This makes patterns shorter. -evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn* +evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn*:* OTOH, ":pn*" is kept. This is because almost patterns include ":pn*", and if we skip it, we should make it clear that this is on purpose, that we really want to match any product name. The python script to generate autosuspend rules is updated to use ":*" too. Inspired by https://github.com/systemd/systemd/pull/17281#discussion_r501489750.
2020-10-15 09:23:30 +02:00
print('# usb:v<VEND>p<PROD>:* (4 uppercase hexadecimal digits twice)')
for entry in chromiumos.gen_autosuspend_rules.USB_IDS:
vendor, product = entry.split(':')
vendor = int(vendor, 16)
product = int(product, 16)
hwdb: add trailing ":*" everywhere No functional change is intended. The general pattern of changes: -usb:v04F3p2B7C* +usb:v04F3p2B7C:* This is mostly a clarification, to make the part that makes the usb vXXXXpYYYY part visually separated. It would only make a difference if we added further keys with a different number of digits, which is unlikely. -usb:v0627p0001:*QEMU USB Keyboard* -usb:v0627p0001:*QEMU USB Mouse* -usb:v0627p0001:*QEMU USB Tablet* +usb:v0627p0001:*QEMU USB Keyboard*:* +usb:v0627p0001:*QEMU USB Mouse*:* +usb:v0627p0001:*QEMU USB Tablet*:* Again, only a clarification. We know that ":" will appear somewhere later in the match key, so anything that matches "…Keyboard*" will also match "…Keyboard*:*". -evdev:name:ETPS/2 Elantech Touchpad:dmi:*svnASUSTeKComputerInc.:pnN53SV* +evdev:name:ETPS/2 Elantech Touchpad:dmi:*svnASUSTeKComputerInc.:pnN53SV:* This makes the match narrower. Previously we would match product "N53SV" and "N53SV2", "N53SV3", and others. Here we are saying that the ':pn' part must match exactly. Most of the changes in this patch match this pattern. I made a few judgement calls and used "pn…*:*" when I wasn't sure if the full pn is included: -evdev:name:Dell WMI hotkeys:dmi:bvn*:bvr*:bd*:svnDell*:pnPrecision* +evdev:name:Dell WMI hotkeys:dmi:bvn*:bvr*:bd*:svnDell*:pnPrecision*:* -evdev:name:Cypress APA Trackpad ?cyapa?:dmi:*:svnHewlett-Packard*:pnFalco*: +evdev:name:Cypress APA Trackpad ?cyapa?:dmi:*:svnHewlett-Packard*:pnFalco*:* This more like the "QEMU" example above, since all dmi strings end in ":", so anything which matches the old version will also match the new version. -evdev:atkbd:dmi:bvn*:bvr*:bd*:svnGateway*:pnA0A1*:pvr* +evdev:atkbd:dmi:bvn*:bvr*:bd*:svnGateway*:pnA0A1*:* I replaced trailing ":pvr*" by ":*". This makes no functional difference because we expect "pvr" to always appear in the dmi string. This makes patterns shorter. -evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn* +evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pn*:* OTOH, ":pn*" is kept. This is because almost patterns include ":pn*", and if we skip it, we should make it clear that this is on purpose, that we really want to match any product name. The python script to generate autosuspend rules is updated to use ":*" too. Inspired by https://github.com/systemd/systemd/pull/17281#discussion_r501489750.
2020-10-15 09:23:30 +02:00
print('usb:v{:04X}p{:04X}:*'.format(vendor, product))
print(' ID_AUTOSUSPEND=1')