Re: Thinkpad display brightness control

2015-12-21 Thread Marcus MERIGHI
Please disregard my message below, sorry for the noise.

The facts are wrong, I'm still having those plug/unplug brightness
jumps. (no idea what coincidence took place yesterday.)

Sorry, Marcus

mcmer-open...@tor.at (Marcus MERIGHI), 2015.12.20 (Sun) 16:04 (CET):
> I am somewhat confused; there were two recent changes that might cause
> the improvement:
> 
> - tedu@ 2015-12-16 acpi/dsdt.c
> - kettenis@ 2015-12-17 acpi/acpithinkpad.c
> 
> since tedu@s commit was inspired by kettenis@ I reply to this thread.
> 
> mark.kette...@xs4all.nl (Mark Kettenis), 2015.12.16 (Wed) 19:48 (CET):
> > Most, if not all, somewhat recent Thinkpads have some subtle issues
> > with display brightness control.  For example,if you change the
> > display brightness using wsconsctl(8) or cbacklight(1), and later use
> > the brightness control buttons on the keyboard, you're likely to see a
> > big jump in brightness.  or if you plug or unplug the power, the
> > display brightness will suddenly change.  The problem here is that on
> 
> hw.version=ThinkPad X200s
> 
> plug/unplug brightness jumps are gone, thank you!
> 
> But:
> - I cannot reach 100% with Fn+PgUp. 
> - Fn+PgUp/PgDown does not care about what I've set via software
>   (wsconsctl display.brightness=XYZ). It always changes based on the
>   value set by the last Fn+PgUp/PgDown, regardless of display.brightness
>   settings.
> 
> Thanks, Marcus
> 
> OpenBSD 5.8-current (GENERIC.MP) #1757: Sat Dec 19 08:17:18 MST 2015
> dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> real mem = 4166717440 (3973MB)
> avail mem = 4036304896 (3849MB)
> mpath0 at root
> scsibus0 at mpath0: 256 targets
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xe0010 (68 entries)
> bios0: vendor LENOVO version "6DET72WW (3.22 )" date 10/25/2012
> bios0: LENOVO 7470W1W
> acpi0 at bios0: rev 2
> acpi0: sleep states S0 S3 S4 S5
> acpi0: tables DSDT FACP SSDT ECDT APIC MCFG HPET SLIC BOOT ASF! SSDT TCPA 
> DMAR SSDT SSDT SSDT
> acpi0: wakeup devices LID_(S3) SLPB(S3) IGBE(S4) EXP0(S4) EXP1(S4) EXP2(S4) 
> EXP3(S4) USB0(S3) USB3(S3) USB5(S3) EHC0(S3) EHC1(S3) HDEF(S4)
> acpitimer0 at acpi0: 3579545 Hz, 24 bits
> acpiec0 at acpi0
> acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
> cpu0 at mainbus0: apid 0 (boot processor)
> cpu0: Intel(R) Core(TM)2 Duo CPU L9400 @ 1.86GHz, 1862.25 MHz
> cpu0: 
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,XSAVE,NXE,LONG,LAHF,PERF,SENSOR
> cpu0: 6MB 64b/line 16-way L2 cache
> cpu0: smt 0, core 0, package 0
> mtrr: Pentium Pro MTRR support, 7 var ranges, 88 fixed ranges
> cpu0: apic clock running at 265MHz
> cpu0: mwait min=64, max=64, C-substates=0.2.2.2.2.1.3, IBE
> cpu1 at mainbus0: apid 1 (application processor)
> cpu1: Intel(R) Core(TM)2 Duo CPU L9400 @ 1.86GHz, 1862.00 MHz
> cpu1: 
> FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,XSAVE,NXE,LONG,LAHF,PERF,SENSOR
> cpu1: 6MB 64b/line 16-way L2 cache
> cpu1: smt 0, core 1, package 0
> ioapic0 at mainbus0: apid 1 pa 0xfec0, version 20, 24 pins
> ioapic0: misconfigured as apic 2, remapped to apid 1
> acpimcfg0 at acpi0 addr 0xe000, bus 0-63
> acpihpet0 at acpi0: 14318179 Hz
> acpiprt0 at acpi0: bus 0 (PCI0)
> acpiprt1 at acpi0: bus -1 (AGP_)
> acpiprt2 at acpi0: bus 2 (EXP0)
> acpiprt3 at acpi0: bus 3 (EXP1)
> acpiprt4 at acpi0: bus -1 (EXP2)
> acpiprt5 at acpi0: bus 5 (EXP3)
> acpicpu0 at acpi0: !C3(100@57 mwait.3@0x30), !C2(500@1 mwait.1@0x10), 
> C1(1000@1 mwait.1), PSS
> acpicpu1 at acpi0: !C3(100@57 mwait.3@0x30), !C2(500@1 mwait.1@0x10), 
> C1(1000@1 mwait.1), PSS
> acpipwrres0 at acpi0: PUBS, resource for USB0, USB3, USB5, EHC0, EHC1
> acpitz0 at acpi0: critical temperature is 127 degC
> acpitz1 at acpi0: critical temperature is 104 degC
> acpibtn0 at acpi0: LID_
> acpibtn1 at acpi0: SLPB
> acpibat0 at acpi0: BAT0 model "93P5030" serial   165 type LION oem "SANYO"
> acpibat1 at acpi0: BAT1 not present
> acpiac0 at acpi0: AC unit online
> acpithinkpad0 at acpi0
> acpidock0 at acpi0: GDCK not docked (0)
> cpu0: Enhanced SpeedStep 1862 MHz: speeds: 1867, 1866, 1600, 800 MHz
> pci0 at mainbus0 bus 0
> pchb0 at pci0 dev 0 function 0 "Intel GM45 Host" rev 0x07
> inteldrm0 at pci0 dev 2 function 0 "Intel GM45 Video" rev 0x07
> drm0 at inteldrm0
> intagp0 at inteldrm0
> agp0 at intagp0: aperture at 0xd000, size 0x1000
> inteldrm0: msi
> inteldrm0: 1280x800
> wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation)
> wsdisplay0: screen 1-5 added (std, vt100 emulation)
> "Intel GM45 Video" rev 0x07 at pci0 dev 2 function 1 not configured
> "Intel GM45 HECI" rev 0x07 at pci0 dev 3 function 0 not configured
> em0 at pci0 dev 25 function 0 "Intel ICH9 IGP M AMT" rev 0x03: msi, address 
> 

Re: Thinkpad display brightness control

2015-12-20 Thread Marcus MERIGHI
I am somewhat confused; there were two recent changes that might cause
the improvement:

- tedu@ 2015-12-16 acpi/dsdt.c
- kettenis@ 2015-12-17 acpi/acpithinkpad.c

since tedu@s commit was inspired by kettenis@ I reply to this thread.

mark.kette...@xs4all.nl (Mark Kettenis), 2015.12.16 (Wed) 19:48 (CET):
> Most, if not all, somewhat recent Thinkpads have some subtle issues
> with display brightness control.  For example,if you change the
> display brightness using wsconsctl(8) or cbacklight(1), and later use
> the brightness control buttons on the keyboard, you're likely to see a
> big jump in brightness.  or if you plug or unplug the power, the
> display brightness will suddenly change.  The problem here is that on

hw.version=ThinkPad X200s

plug/unplug brightness jumps are gone, thank you!

But:
- I cannot reach 100% with Fn+PgUp. 
- Fn+PgUp/PgDown does not care about what I've set via software
  (wsconsctl display.brightness=XYZ). It always changes based on the
  value set by the last Fn+PgUp/PgDown, regardless of display.brightness
  settings.

Thanks, Marcus

OpenBSD 5.8-current (GENERIC.MP) #1757: Sat Dec 19 08:17:18 MST 2015
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 4166717440 (3973MB)
avail mem = 4036304896 (3849MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xe0010 (68 entries)
bios0: vendor LENOVO version "6DET72WW (3.22 )" date 10/25/2012
bios0: LENOVO 7470W1W
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SSDT ECDT APIC MCFG HPET SLIC BOOT ASF! SSDT TCPA DMAR 
SSDT SSDT SSDT
acpi0: wakeup devices LID_(S3) SLPB(S3) IGBE(S4) EXP0(S4) EXP1(S4) EXP2(S4) 
EXP3(S4) USB0(S3) USB3(S3) USB5(S3) EHC0(S3) EHC1(S3) HDEF(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpiec0 at acpi0
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM)2 Duo CPU L9400 @ 1.86GHz, 1862.25 MHz
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,XSAVE,NXE,LONG,LAHF,PERF,SENSOR
cpu0: 6MB 64b/line 16-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 7 var ranges, 88 fixed ranges
cpu0: apic clock running at 265MHz
cpu0: mwait min=64, max=64, C-substates=0.2.2.2.2.1.3, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 Duo CPU L9400 @ 1.86GHz, 1862.00 MHz
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,XSAVE,NXE,LONG,LAHF,PERF,SENSOR
cpu1: 6MB 64b/line 16-way L2 cache
cpu1: smt 0, core 1, package 0
ioapic0 at mainbus0: apid 1 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 2, remapped to apid 1
acpimcfg0 at acpi0 addr 0xe000, bus 0-63
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (AGP_)
acpiprt2 at acpi0: bus 2 (EXP0)
acpiprt3 at acpi0: bus 3 (EXP1)
acpiprt4 at acpi0: bus -1 (EXP2)
acpiprt5 at acpi0: bus 5 (EXP3)
acpicpu0 at acpi0: !C3(100@57 mwait.3@0x30), !C2(500@1 mwait.1@0x10), C1(1000@1 
mwait.1), PSS
acpicpu1 at acpi0: !C3(100@57 mwait.3@0x30), !C2(500@1 mwait.1@0x10), C1(1000@1 
mwait.1), PSS
acpipwrres0 at acpi0: PUBS, resource for USB0, USB3, USB5, EHC0, EHC1
acpitz0 at acpi0: critical temperature is 127 degC
acpitz1 at acpi0: critical temperature is 104 degC
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibat0 at acpi0: BAT0 model "93P5030" serial   165 type LION oem "SANYO"
acpibat1 at acpi0: BAT1 not present
acpiac0 at acpi0: AC unit online
acpithinkpad0 at acpi0
acpidock0 at acpi0: GDCK not docked (0)
cpu0: Enhanced SpeedStep 1862 MHz: speeds: 1867, 1866, 1600, 800 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel GM45 Host" rev 0x07
inteldrm0 at pci0 dev 2 function 0 "Intel GM45 Video" rev 0x07
drm0 at inteldrm0
intagp0 at inteldrm0
agp0 at intagp0: aperture at 0xd000, size 0x1000
inteldrm0: msi
inteldrm0: 1280x800
wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
"Intel GM45 Video" rev 0x07 at pci0 dev 2 function 1 not configured
"Intel GM45 HECI" rev 0x07 at pci0 dev 3 function 0 not configured
em0 at pci0 dev 25 function 0 "Intel ICH9 IGP M AMT" rev 0x03: msi, address 
00:1f:16:32:df:5c
uhci0 at pci0 dev 26 function 0 "Intel 82801I USB" rev 0x03: apic 1 int 20
uhci1 at pci0 dev 26 function 1 "Intel 82801I USB" rev 0x03: apic 1 int 21
uhci2 at pci0 dev 26 function 2 "Intel 82801I USB" rev 0x03: apic 1 int 22
ehci0 at pci0 dev 26 function 7 "Intel 82801I USB" rev 0x03: apic 1 int 23
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
azalia0 at pci0 dev 27 function 0 "Intel 82801I HD Audio" rev 

Re: Thinkpad display brightness control

2015-12-17 Thread Mark Kettenis
> From: Christian Weisgerber 
> Date: Thu, 17 Dec 2015 11:50:53 + (UTC)
> 
> On 2015-12-16, Mark Kettenis  wrote:
> 
> > The downside of this diff is that number of levels is limited to 16
> > whereas we currently have much finer granularity.  But I think that is
> > acceptable.  The levels are probably better calibrated and we now have
> > proper coordination between the OS and the firmware when it comes to
> > brightness changes.
> 
> I'm in favor of this change since it fixes various niggling problems.
> 
> FWIW, the 16 levels also scale differently than the previous range.
> Stepping through with the brightness keys on my X230, I get
> respectively this:
> 
>new old
>   0.00%   1.17%  min
>   6.66%   2.34%
>  13.33%   3.51%
>  20.00%   4.68%
>  26.66%   5.88%
>  33.33%   7.43%
>  40.00%   9.01%
>  46.66%  10.97%
>  53.33%  12.93%
>  60.00%  15.68%
>  66.66%  19.60%
>  73.33%  25.49%
>  80.00%  34.50%
>  86.66%  49.01%
>  93.33%  72.54%
> 100.00% 100.00%  max
> 
> For instance, if you previously used wsconsctl display.brightness=20%,
> you'd now find your display much darker and would want to use 67%
> instead.

Indeed.  As far as the brightness keys are concerned, the actual
levels should be the same, but they translate into different
percentages.

Also thanks for pointing out the issue with the thinkpad_get_param()
code.  I've committed a version with that fixed.



Re: Thinkpad display brightness control

2015-12-17 Thread Christian Weisgerber
On 2015-12-16, Mark Kettenis  wrote:

> The downside of this diff is that number of levels is limited to 16
> whereas we currently have much finer granularity.  But I think that is
> acceptable.  The levels are probably better calibrated and we now have
> proper coordination between the OS and the firmware when it comes to
> brightness changes.

I'm in favor of this change since it fixes various niggling problems.

FWIW, the 16 levels also scale differently than the previous range.
Stepping through with the brightness keys on my X230, I get
respectively this:

   new old
  0.00%   1.17%  min
  6.66%   2.34%
 13.33%   3.51%
 20.00%   4.68%
 26.66%   5.88%
 33.33%   7.43%
 40.00%   9.01%
 46.66%  10.97%
 53.33%  12.93%
 60.00%  15.68%
 66.66%  19.60%
 73.33%  25.49%
 80.00%  34.50%
 86.66%  49.01%
 93.33%  72.54%
100.00% 100.00%  max

For instance, if you previously used wsconsctl display.brightness=20%,
you'd now find your display much darker and would want to use 67%
instead.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: Thinkpad display brightness control

2015-12-16 Thread Mike Larkin
On Wed, Dec 16, 2015 at 07:48:23PM +0100, Mark Kettenis wrote:
> Most, if not all, somewhat recent Thinkpads have some subtle issues
> with display brightness control.  For example,if you change the
> display brightness using wsconsctl(8) or cbacklight(1), and later use
> the brightness control buttons on the keyboard, you're likely to see a
> big jump in brightness.  or if you plug or unplug the power, the
> display brightness will suddenly change.  The problem here is that on
> these machines we us the display brightness interface provided by
> inteldrm(4), which doesn't coordinate changes with the firmware.
> 
> In principle these machines support the standard acpi brightness
> control interface.  However that interface is quite badly broken if
> the OS claims to be Windows 8.  Unfortunately that is what we do on
> OpenBSD because otherwise some other machines don't work properly.
> 
> Fortunately Thinkpads provide an alternative acpi interface through
> the "hotkey" device that is handled by acpithinkpad(4).  The diff
> below implements that interface.
> 
> The downside of this diff is that number of levels is limited to 16
> whereas we currently have much finer granularity.  But I think that is
> acceptable.  The levels are probably better calibrated and we now have
> proper coordination between the OS and the firmware when it comes to
> brightness changes.  On top of that, this diff will almost certainly
> result in working brightness control on machines that don't have Intel
> graphics.
> 
> ok?
> 

I'm ok with this. Didn't test it but I don't have objections to moving
in this direction. Diff looks ok too.

-ml

> 
> Index: acpithinkpad.c
> ===
> RCS file: /home/cvs/src/sys/dev/acpi/acpithinkpad.c,v
> retrieving revision 1.49
> diff -u -p -r1.49 acpithinkpad.c
> --- acpithinkpad.c16 Dec 2015 15:43:14 -  1.49
> +++ acpithinkpad.c16 Dec 2015 18:00:03 -
> @@ -122,6 +122,8 @@ struct acpithinkpad_softc {
>   uint64_t sc_thinklight;
>   const char  *sc_thinklight_get;
>   const char  *sc_thinklight_set;
> +
> + uint64_t sc_brightness;
>  };
>  
>  extern void acpiec_read(struct acpiec_softc *, u_int8_t, int, u_int8_t *);
> @@ -141,13 +143,19 @@ int thinkpad_brightness_down(struct acpi
>  int  thinkpad_adaptive_change(struct acpithinkpad_softc *);
>  int  thinkpad_activate(struct device *, int);
>  
> -/* wskbd hook functions */
> +/* wscons hook functions */
>  void thinkpad_get_thinklight(struct acpithinkpad_softc *);
>  void thinkpad_set_thinklight(void *, int);
>  int  thinkpad_get_backlight(struct wskbd_backlight *);
>  int  thinkpad_set_backlight(struct wskbd_backlight *);
>  extern int (*wskbd_get_backlight)(struct wskbd_backlight *);
>  extern int (*wskbd_set_backlight)(struct wskbd_backlight *);
> +void thinkpad_get_brightness(struct acpithinkpad_softc *);
> +void thinkpad_set_brightness(void *, int);
> +int  thinkpad_get_param(struct wsdisplay_param *);
> +int  thinkpad_set_param(struct wsdisplay_param *);
> +extern int (*ws_get_param)(struct wsdisplay_param *);
> +extern int (*ws_set_param)(struct wsdisplay_param *);
>  
>  voidthinkpad_sensor_attach(struct acpithinkpad_softc *sc);
>  voidthinkpad_sensor_refresh(void *);
> @@ -267,6 +275,12 @@ thinkpad_attach(struct device *parent, s
>   wskbd_set_backlight = thinkpad_set_backlight;
>   }
>  
> + if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "PBLG",
> + 0, NULL, >sc_brightness) == 0) {
> + ws_get_param = thinkpad_get_param;
> + ws_set_param = thinkpad_set_param;
> + }
> +
>   /* Run thinkpad_hotkey on button presses */
>   aml_register_notify(sc->sc_devnode, aa->aaa_dev,
>   thinkpad_hotkey, sc, ACPIDEV_POLL);
> @@ -391,6 +405,9 @@ thinkpad_hotkey(struct aml_node *node, i
>   thinkpad_adaptive_change(sc);
>   handled = 1;
>   break;
> + case THINKPAD_BACKLIGHT_CHANGED:
> + thinkpad_get_brightness(sc);
> + break;
>   case THINKPAD_ADAPTIVE_BACK:
>   case THINKPAD_ADAPTIVE_GESTURES:
>   case THINKPAD_ADAPTIVE_REFRESH:
> @@ -398,7 +415,6 @@ thinkpad_hotkey(struct aml_node *node, i
>   case THINKPAD_ADAPTIVE_SNIP:
>   case THINKPAD_ADAPTIVE_TAB:
>   case THINKPAD_ADAPTIVE_VOICE:
> - case THINKPAD_BACKLIGHT_CHANGED:
>   case THINKPAD_KEYLIGHT_CHANGED:
>   case THINKPAD_BRIGHTNESS_CHANGED:
>   case THINKPAD_BUTTON_BATTERY_INFO:
> @@ -630,4 +646,63 @@ thinkpad_set_backlight(struct wskbd_back
>   acpi_addtask(sc->sc_acpi, thinkpad_set_thinklight, sc, 0);
>   acpi_wakeup(sc->sc_acpi);
>   return 0;
> +}
> +
> +void
> +thinkpad_get_brightness(struct acpithinkpad_softc *sc)
> 

Thinkpad display brightness control

2015-12-16 Thread Mark Kettenis
Most, if not all, somewhat recent Thinkpads have some subtle issues
with display brightness control.  For example,if you change the
display brightness using wsconsctl(8) or cbacklight(1), and later use
the brightness control buttons on the keyboard, you're likely to see a
big jump in brightness.  or if you plug or unplug the power, the
display brightness will suddenly change.  The problem here is that on
these machines we us the display brightness interface provided by
inteldrm(4), which doesn't coordinate changes with the firmware.

In principle these machines support the standard acpi brightness
control interface.  However that interface is quite badly broken if
the OS claims to be Windows 8.  Unfortunately that is what we do on
OpenBSD because otherwise some other machines don't work properly.

Fortunately Thinkpads provide an alternative acpi interface through
the "hotkey" device that is handled by acpithinkpad(4).  The diff
below implements that interface.

The downside of this diff is that number of levels is limited to 16
whereas we currently have much finer granularity.  But I think that is
acceptable.  The levels are probably better calibrated and we now have
proper coordination between the OS and the firmware when it comes to
brightness changes.  On top of that, this diff will almost certainly
result in working brightness control on machines that don't have Intel
graphics.

ok?


Index: acpithinkpad.c
===
RCS file: /home/cvs/src/sys/dev/acpi/acpithinkpad.c,v
retrieving revision 1.49
diff -u -p -r1.49 acpithinkpad.c
--- acpithinkpad.c  16 Dec 2015 15:43:14 -  1.49
+++ acpithinkpad.c  16 Dec 2015 18:00:03 -
@@ -122,6 +122,8 @@ struct acpithinkpad_softc {
uint64_t sc_thinklight;
const char  *sc_thinklight_get;
const char  *sc_thinklight_set;
+
+   uint64_t sc_brightness;
 };
 
 extern void acpiec_read(struct acpiec_softc *, u_int8_t, int, u_int8_t *);
@@ -141,13 +143,19 @@ int   thinkpad_brightness_down(struct acpi
 intthinkpad_adaptive_change(struct acpithinkpad_softc *);
 intthinkpad_activate(struct device *, int);
 
-/* wskbd hook functions */
+/* wscons hook functions */
 void   thinkpad_get_thinklight(struct acpithinkpad_softc *);
 void   thinkpad_set_thinklight(void *, int);
 intthinkpad_get_backlight(struct wskbd_backlight *);
 intthinkpad_set_backlight(struct wskbd_backlight *);
 extern int (*wskbd_get_backlight)(struct wskbd_backlight *);
 extern int (*wskbd_set_backlight)(struct wskbd_backlight *);
+void   thinkpad_get_brightness(struct acpithinkpad_softc *);
+void   thinkpad_set_brightness(void *, int);
+intthinkpad_get_param(struct wsdisplay_param *);
+intthinkpad_set_param(struct wsdisplay_param *);
+extern int (*ws_get_param)(struct wsdisplay_param *);
+extern int (*ws_set_param)(struct wsdisplay_param *);
 
 voidthinkpad_sensor_attach(struct acpithinkpad_softc *sc);
 voidthinkpad_sensor_refresh(void *);
@@ -267,6 +275,12 @@ thinkpad_attach(struct device *parent, s
wskbd_set_backlight = thinkpad_set_backlight;
}
 
+   if (aml_evalinteger(sc->sc_acpi, sc->sc_devnode, "PBLG",
+   0, NULL, >sc_brightness) == 0) {
+   ws_get_param = thinkpad_get_param;
+   ws_set_param = thinkpad_set_param;
+   }
+
/* Run thinkpad_hotkey on button presses */
aml_register_notify(sc->sc_devnode, aa->aaa_dev,
thinkpad_hotkey, sc, ACPIDEV_POLL);
@@ -391,6 +405,9 @@ thinkpad_hotkey(struct aml_node *node, i
thinkpad_adaptive_change(sc);
handled = 1;
break;
+   case THINKPAD_BACKLIGHT_CHANGED:
+   thinkpad_get_brightness(sc);
+   break;
case THINKPAD_ADAPTIVE_BACK:
case THINKPAD_ADAPTIVE_GESTURES:
case THINKPAD_ADAPTIVE_REFRESH:
@@ -398,7 +415,6 @@ thinkpad_hotkey(struct aml_node *node, i
case THINKPAD_ADAPTIVE_SNIP:
case THINKPAD_ADAPTIVE_TAB:
case THINKPAD_ADAPTIVE_VOICE:
-   case THINKPAD_BACKLIGHT_CHANGED:
case THINKPAD_KEYLIGHT_CHANGED:
case THINKPAD_BRIGHTNESS_CHANGED:
case THINKPAD_BUTTON_BATTERY_INFO:
@@ -630,4 +646,63 @@ thinkpad_set_backlight(struct wskbd_back
acpi_addtask(sc->sc_acpi, thinkpad_set_thinklight, sc, 0);
acpi_wakeup(sc->sc_acpi);
return 0;
+}
+
+void
+thinkpad_get_brightness(struct acpithinkpad_softc *sc)
+{
+   aml_evalinteger(sc->sc_acpi, sc->sc_devnode,
+   "PBLG", 0, NULL, >sc_brightness);
+}
+
+void
+thinkpad_set_brightness(void *arg0, int arg1)
+{
+   struct acpithinkpad_softc *sc = arg0;
+   struct aml_value arg;
+
+   memset(, 0, sizeof(arg));
+   arg.type =