summaryrefslogtreecommitdiff
path: root/rules
diff options
context:
space:
mode:
authorMario Limonciello <mario.limonciello@dell.com>2019-09-09 22:49:35 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-04 08:57:29 +0200
commitb61d777abeecd8b6c76035e11899aae210633534 (patch)
treefceadec42baa379b4c6c92789361d713aa2e4584 /rules
parent3a77f9fb4c2ff8d26ef772c7426fcbc37ad4d023 (diff)
downloadsystemd-b61d777abeecd8b6c76035e11899aae210633534.tar.gz
rules: Add automatic suspend udev rules
The ChromeOS ecosystem has a large amount of testing, both automated and manual across devices including measurement of power regressions. It's safe to assume that any of these devices will handle USB auto-suspend appropriately. Use the script from ChromeOS https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/udev/gen_autosuspend_rules.py to generate udev rules at build time. This script in systemd `tools/chromeos/gen_autosuspend_rules.py` should be kept in sync with the ChromeOS version of the script. Manually added autosuspend devices should be placed in the new template `rules/61-autosuspend-manual.rules` Suggested-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
Diffstat (limited to 'rules')
-rw-r--r--rules/61-autosuspend-manual.rules20
-rw-r--r--rules/meson.build9
2 files changed, 29 insertions, 0 deletions
diff --git a/rules/61-autosuspend-manual.rules b/rules/61-autosuspend-manual.rules
new file mode 100644
index 0000000000..dcc0405d19
--- /dev/null
+++ b/rules/61-autosuspend-manual.rules
@@ -0,0 +1,20 @@
+# This udev rule is for any devices that should enter automatic suspend
+# but are not already included in generated rules from ChromeOS via
+# tools/make-autosuspend-rules.py
+#
+
+ACTION!="add", GOTO="autosuspend_manual_end"
+SUBSYSTEM!="usb", GOTO="autosuspend_manual_end"
+
+SUBSYSTEM=="usb", GOTO="autosuspend_manual_usb"
+
+# USB rules
+LABEL="autosuspend_manual_usb"
+GOTO="autosuspend_manual_end"
+
+# Enable autosuspend
+LABEL="autosuspend_manual_enable"
+TEST=="power/control", ATTR{power/control}="auto", GOTO="autosuspend_manual_end"
+
+LABEL="autosuspend_manual_end"
+
diff --git a/rules/meson.build b/rules/meson.build
index 79423cc2c4..57896aa1a4 100644
--- a/rules/meson.build
+++ b/rules/meson.build
@@ -14,6 +14,7 @@ rules = files('''
60-persistent-v4l.rules
60-sensor.rules
60-serial.rules
+ 61-autosuspend-manual.rules
70-joystick.rules
70-mouse.rules
70-touchpad.rules
@@ -44,3 +45,11 @@ foreach file : rules_in
install_dir : udevrulesdir)
all_rules += gen
endforeach
+
+auto_suspend_rules = custom_target(
+ '60-autosuspend-chromeos.rules',
+ output : '60-autosuspend-chromeos.rules',
+ command : make_autosuspend_rules_py,
+ capture : true,
+ install : true,
+ install_dir: [udevrulesdir])