> Date: Wed, 10 Feb 2016 20:10:41 +0100 > From: Martin Pieuchot <m...@openbsd.org> > > On 09/02/16(Tue) 21:06, Christian Weisgerber wrote: > > On 2016-02-09, Martin Pieuchot <m...@openbsd.org> wrote: > > > > > Since brightness support has been added to acpithinkpad(4) I can easily > > > trigger a regression on my x220: > > > > > > - Switching to the first virtual console just after xdm starts using the > > > Ctrl+Alt+F1 key combination turns my screen dark. > > > - Killing X just after xdm start, by using Ctrl+Alt+Del, also turns my > > > screen Dark. > > > > Yes, I also see this on my X230. > > > > > The problem seems to be a race related to multiple events, diff below > > > fixes that for me. > > > > With that diff the brightness is stuck at 100%. > > The diff is broken. > > I couldn't spot a way to fix this. Maybe it's a bug in the firmware?
Does the following diff work? Index: acpithinkpad.c =================================================================== RCS file: /cvs/src/sys/dev/acpi/acpithinkpad.c,v retrieving revision 1.51 diff -u -p -r1.51 acpithinkpad.c --- acpithinkpad.c 10 Jan 2016 16:30:43 -0000 1.51 +++ acpithinkpad.c 16 Feb 2016 19:42:58 -0000 @@ -126,6 +126,7 @@ struct acpithinkpad_softc { const char *sc_thinklight_set; uint64_t sc_brightness; + int sc_newbrightness; }; extern void acpiec_read(struct acpiec_softc *, u_int8_t, int, u_int8_t *); @@ -667,7 +668,7 @@ thinkpad_set_brightness(void *arg0, int memset(&arg, 0, sizeof(arg)); arg.type = AML_OBJTYPE_INTEGER; - arg.v_integer = sc->sc_brightness & 0xff; + arg.v_integer = sc->sc_newbrightness; aml_evalname(sc->sc_acpi, sc->sc_devnode, "PBLS", 1, &arg, NULL); } @@ -708,6 +709,7 @@ thinkpad_set_param(struct wsdisplay_para dp->curval = maxval; sc->sc_brightness &= ~0xff; sc->sc_brightness |= dp->curval; + sc->sc_newbrightness = dp->curval; acpi_addtask(sc->sc_acpi, thinkpad_set_brightness, sc, 0); acpi_wakeup(sc->sc_acpi); return 0;