Hi,
The brightness on my PowerBook6,4 prior pressing either the brightness
down/up key looks odd:

  $ wsconsctl display.brightness
  display.brightness=4294967271.4294967235%

Since cons_brightness is initialized to 0 and MIN_BRIGHTNESS is greater
than 0, the percentage calculation performed by wsconsctl blows up.

This diff makes sure to initialize cons_brightness if a backlight is
found. I chose to initialize it to MAX_BRIGHTNESS since the brightness
on my machine is not restored on boot and therefore initially always set
to MAX_BRIGHTNESS. This also fixes another problem: pressing either
brightness down/up will set the brightness to MIN_BRIGHTNESS since
cons_brightness is below MIN_BRIGHTNESS initially.

Comments? OK?

Index: ofw_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/macppc/macppc/ofw_machdep.c,v
retrieving revision 1.55
diff -u -p -r1.55 ofw_machdep.c
--- ofw_machdep.c       21 Jul 2015 05:58:34 -0000      1.55
+++ ofw_machdep.c       22 Jul 2017 09:17:01 -0000
@@ -469,8 +469,10 @@ of_display_console(void)
                }
        }
 
-       if (OF_getnodebyname(0, "backlight") != 0)
+       if (OF_getnodebyname(0, "backlight") != 0) {
                cons_backlight_available = 1;
+               cons_brightness = MAX_BRIGHTNESS;
+       }
 
 #if 1
        printf(": memaddr %x, size %x ", addr[0].phys_lo, addr[0].size_lo);

Reply via email to