]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
backlight: also change clamp percentage on ID_BACKLIGHT_CLAMP/ID_LEDS_CLAMP=yes
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 16 Feb 2026 10:16:35 +0000 (19:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 16 Feb 2026 12:24:55 +0000 (21:24 +0900)
Follow-up for 4ed1e2ea17e0f29a23d7a3dd65af192def9b3214.

src/backlight/backlight.c

index 15e0d17b8dda3c6a3e7abfa03b711203e7d57f0e..027379809d10f16ecacfafeced29d7bc9cfab4d7 100644 (file)
@@ -372,6 +372,9 @@ static int clamp_brightness(
         return 0;
 }
 
+/* used as the default for devices in the backlight subsystem, or when ID_BACKLIGHT_CLAMP/ID_LEDS_CLAMP=yes. */
+#define DEFAULT_CLAMP_PERCENT 1u
+
 static int shall_clamp(sd_device *device, unsigned *ret) {
         const char *property, *s;
         unsigned default_percent;
@@ -385,10 +388,10 @@ static int shall_clamp(sd_device *device, unsigned *ret) {
                 return r;
         if (r > 0) {
                 property = "ID_BACKLIGHT_CLAMP";
-                default_percent = 1;
+                default_percent = DEFAULT_CLAMP_PERCENT;
         } else {
                 property = "ID_LEDS_CLAMP";
-                default_percent = 0;
+                default_percent = 0; /* The clamping is disabled by default. */
         }
 
         r = sd_device_get_property_value(device, property, &s);
@@ -401,7 +404,7 @@ static int shall_clamp(sd_device *device, unsigned *ret) {
 
         r = parse_boolean(s);
         if (r >= 0) {
-                *ret = r ? 5 : 0;
+                *ret = r ? DEFAULT_CLAMP_PERCENT : 0;
                 return r;
         }