mirror of
https://github.com/commaai/agnos-builder.git
synced 2026-08-04 15:55:42 +08:00
+1
-1
Submodule agnos-kernel-sdm845 updated: b75f6c29a4...00fee24ee2
@@ -2,3 +2,5 @@ ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/ch
|
||||
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
|
||||
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/bl_power"
|
||||
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/bl_power"
|
||||
ACTION=="add", SUBSYSTEM=="platform", KERNEL=="soc:qcom,dsi-display@0", RUN+="/bin/chgrp video /sys/devices/platform/soc/%k/max_brightness_percent"
|
||||
ACTION=="add", SUBSYSTEM=="platform", KERNEL=="soc:qcom,dsi-display@0", RUN+="/bin/chmod g+w /sys/devices/platform/soc/%k/max_brightness_percent"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Limit display brightness with uptime
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
ExecStart=/usr/local/pyenv/shims/python -u /usr/comma/brightnessd.py
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -17,6 +17,7 @@ systemctl enable weston.service
|
||||
systemctl enable wifi.service
|
||||
systemctl enable init-qcom.service
|
||||
systemctl enable power_drop_monitor.service
|
||||
systemctl enable brightnessd.service
|
||||
systemctl enable ssh-param-watcher.path
|
||||
systemctl enable ssh-param-watcher.service
|
||||
systemctl enable home.mount
|
||||
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
import time
|
||||
|
||||
# limit display brightness with display uptime to prevent burn in
|
||||
|
||||
BL_OFF = 4
|
||||
BL_POWER_PATH = "/sys/class/backlight/panel0-backlight/bl_power"
|
||||
BRIGHTNESS_PATH = "/sys/class/backlight/panel0-backlight/brightness"
|
||||
MAX_BRIGHTNESS_PATH= "/sys/devices/platform/soc/soc:qcom,dsi-display@0/max_brightness_percent"
|
||||
|
||||
MAX_PERCENT = 90
|
||||
MIN_PERCENT = 30
|
||||
HOURLY_PERC_DECREASE = 5
|
||||
|
||||
def read(path: str) -> int:
|
||||
try:
|
||||
with open(path) as f:
|
||||
return int(f.read())
|
||||
except Exception:
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
last_perc = None
|
||||
last_off_ts = time.monotonic()
|
||||
|
||||
while True:
|
||||
try:
|
||||
# sample brightness and backlight power
|
||||
bl_power = read(BL_POWER_PATH)
|
||||
brightness = read(BRIGHTNESS_PATH)
|
||||
if bl_power == BL_OFF or brightness == 0:
|
||||
last_off_ts = time.monotonic()
|
||||
|
||||
# calculate new max
|
||||
uptime_hours = (time.monotonic() - last_off_ts) / 60*60
|
||||
clipped_perc = MAX_PERCENT - (HOURLY_PERC_DECREASE*uptime_hours)
|
||||
clipped_perc = int(max(min(clipped_perc, MAX_PERCENT), MIN_PERCENT))
|
||||
|
||||
if clipped_perc != last_perc:
|
||||
with open(MAX_BRIGHTNESS_PATH, 'w') as f:
|
||||
f.write(f"{int(clipped_perc)}\n")
|
||||
last_perc = clipped_perc
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
time.sleep(5)
|
||||
Reference in New Issue
Block a user