Skip to content

Commit

Permalink
Add support to set autosuspend delay via hwdb
Browse files Browse the repository at this point in the history
  • Loading branch information
superm1 committed May 10, 2022
1 parent 31090c1 commit fa9a43a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hwdb.d/60-autosuspend.hwdb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
#
# Allowed properties are:
# ID_AUTOSUSPEND=1
# ID_AUTOSUSPEND_DELAY_MS=####
# ID_PERSIST=0
#
# ID_AUTOSUSPEND_DELAY_MS adjusts the delay for autosuspend to something
# different than the kernel default of 2000ms.
#
# ID_PERSIST=0 allows disabling the kernels USB "persist" feature, which allows
# the continued use of devices after a power loss (due to suspend). Disable it
# if the device will loose state without a USB power session and the driver
Expand Down
1 change: 1 addition & 0 deletions hwdb.d/parse_hwdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def property_grammar():
('MOUSE_WHEEL_CLICK_COUNT', INTEGER),
('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', INTEGER),
('ID_AUTOSUSPEND', Or((Literal('0'), Literal('1')))),
('ID_AUTOSUSPEND_DELAY_MS', INTEGER),
('ID_AV_PRODUCTION_CONTROLLER', Or((Literal('0'), Literal('1')))),
('ID_PERSIST', Or((Literal('0'), Literal('1')))),
('ID_PDA', Or((Literal('0'), Literal('1')))),
Expand Down
4 changes: 4 additions & 0 deletions rules.d/60-autosuspend.rules
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ ENV{ID_AUTOSUSPEND}=="1", TEST=="power/control", \
ENV{ID_PERSIST}=="0", TEST=="power/persist", \
ATTR{power/persist}="0"

# Set up an autosuspend delay if hwdb say so
ENV{ID_AUTOSUSPEND_DELAY_MS}!="", TEST=="power/control", \
ATTR{power/autosuspend_delay_ms}="$env{ID_AUTOSUSPEND_DELAY_MS}"

LABEL="autosuspend_end"

0 comments on commit fa9a43a

Please sign in to comment.