ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
8d419f
From fab29ebaa62cfae9f56a7a108b35d17e4d2a16cd Mon Sep 17 00:00:00 2001
8d419f
From: Mario Limonciello <superm1@gmail.com>
8d419f
Date: Mon, 9 May 2022 20:16:22 -0500
8d419f
Subject: [PATCH] Add support to set autosuspend delay via hwdb
8d419f
8d419f
(cherry picked from commit fa9a43a6905187195c9e86a61a906647726c3e55)
8d419f
8d419f
Related: #2087778
8d419f
---
8d419f
 hwdb.d/60-autosuspend.hwdb   | 4 ++++
8d419f
 hwdb.d/parse_hwdb.py         | 1 +
8d419f
 rules.d/60-autosuspend.rules | 4 ++++
8d419f
 3 files changed, 9 insertions(+)
8d419f
8d419f
diff --git a/hwdb.d/60-autosuspend.hwdb b/hwdb.d/60-autosuspend.hwdb
8d419f
index 1b6c1e1c8f..323611d000 100644
8d419f
--- a/hwdb.d/60-autosuspend.hwdb
8d419f
+++ b/hwdb.d/60-autosuspend.hwdb
8d419f
@@ -24,8 +24,12 @@
8d419f
 #
8d419f
 # Allowed properties are:
8d419f
 #    ID_AUTOSUSPEND=1
8d419f
+#    ID_AUTOSUSPEND_DELAY_MS=####
8d419f
 #    ID_PERSIST=0
8d419f
 #
8d419f
+# ID_AUTOSUSPEND_DELAY_MS adjusts the delay for autosuspend to something
8d419f
+# different than the kernel default of 2000ms.
8d419f
+#
8d419f
 # ID_PERSIST=0 allows disabling the kernels USB "persist" feature, which allows
8d419f
 # the continued use of devices after a power loss (due to suspend). Disable it
8d419f
 # if the device will loose state without a USB power session and the driver
8d419f
diff --git a/hwdb.d/parse_hwdb.py b/hwdb.d/parse_hwdb.py
8d419f
index 93179b675c..7bad559699 100755
8d419f
--- a/hwdb.d/parse_hwdb.py
8d419f
+++ b/hwdb.d/parse_hwdb.py
8d419f
@@ -135,6 +135,7 @@ def property_grammar():
8d419f
              ('MOUSE_WHEEL_CLICK_COUNT', INTEGER),
8d419f
              ('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', INTEGER),
8d419f
              ('ID_AUTOSUSPEND', Or((Literal('0'), Literal('1')))),
8d419f
+             ('ID_AUTOSUSPEND_DELAY_MS', INTEGER),
8d419f
              ('ID_AV_PRODUCTION_CONTROLLER', Or((Literal('0'), Literal('1')))),
8d419f
              ('ID_PERSIST', Or((Literal('0'), Literal('1')))),
8d419f
              ('ID_PDA', Or((Literal('0'), Literal('1')))),
8d419f
diff --git a/rules.d/60-autosuspend.rules b/rules.d/60-autosuspend.rules
8d419f
index 332d052caa..ce31a920ed 100644
8d419f
--- a/rules.d/60-autosuspend.rules
8d419f
+++ b/rules.d/60-autosuspend.rules
8d419f
@@ -15,4 +15,8 @@ ENV{ID_AUTOSUSPEND}=="1", TEST=="power/control", \
8d419f
 ENV{ID_PERSIST}=="0", TEST=="power/persist", \
8d419f
   ATTR{power/persist}="0"
8d419f
 
8d419f
+# Set up an autosuspend delay if hwdb say so
8d419f
+ENV{ID_AUTOSUSPEND_DELAY_MS}!="", TEST=="power/control", \
8d419f
+  ATTR{power/autosuspend_delay_ms}="$env{ID_AUTOSUSPEND_DELAY_MS}"
8d419f
+
8d419f
 LABEL="autosuspend_end"