32 lines
1 KiB
Python
32 lines
1 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
"""Enable the Sargo Qualcomm low-power states when the kernel exposes them."""
|
|
from pathlib import Path
|
|
import time
|
|
|
|
|
|
PARAMETER = Path('/sys/module/lpm_levels/parameters/sleep_disabled')
|
|
|
|
|
|
def main():
|
|
deadline = time.monotonic() + 8
|
|
while time.monotonic() < deadline and not PARAMETER.exists():
|
|
time.sleep(.1)
|
|
if not PARAMETER.exists():
|
|
print('Qualcomm lpm_levels parameter unavailable; leaving kernel defaults')
|
|
return
|
|
current = PARAMETER.read_text().strip()
|
|
if current == 'N':
|
|
print('Qualcomm low-power states are already enabled')
|
|
return
|
|
if current != 'Y':
|
|
print('Unknown sleep_disabled value; leaving kernel setting unchanged:', current)
|
|
return
|
|
PARAMETER.write_text('N')
|
|
if PARAMETER.read_text().strip() != 'N':
|
|
raise RuntimeError('Could not enable Qualcomm CPU low-power states')
|
|
print('Enabled Qualcomm CPU low-power states')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|