On Sat, Mar 14, 2020 at 04:28:26AM +0100, Alexandre Ratchov wrote:
> On ASUS 1001PXD, _BQC returns an out of range value which makes
> acpivout_get_brightness() return -1, in turn breaking the
> display.brightness control (wsconsctl displays a mangled value).
>
> This diff ignores the out of range value and makes the brighness
> control just work again.
>
> OK?
With the current code _BQC is only called on attach, where we
probably want a value higher than the lowest one. I wonder if
maybe we should move this check into the attach functions, and
in case of an error like this, set a reasonable brightness?
Otherwise, if we want to do that in acpivout_get_brightness(),
I guess we can update acpivout_select_brightness() and its caller
to remove the check for -1, since there will be no -1 anymore?
> Index: acpivout.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/acpi/acpivout.c,v
> retrieving revision 1.19
> diff -u -p -r1.19 acpivout.c
> --- acpivout.c 8 Feb 2020 19:08:17 -0000 1.19
> +++ acpivout.c 14 Mar 2020 03:19:02 -0000
> @@ -227,8 +227,10 @@ acpivout_get_brightness(struct acpivout_
> aml_freevalue(&res);
> DPRINTF(("%s: BQC = %d\n", DEVNAME(sc), level));
>
> - if (level < sc->sc_bcl[0] || level > sc->sc_bcl[sc->sc_bcl_len -1])
> - level = -1;
> + if (level < sc->sc_bcl[0])
> + level = sc->sc_bcl[0];
> + else if (level > sc->sc_bcl[sc->sc_bcl_len - 1])
> + level = sc->sc_bcl[sc->sc_bcl_len - 1];
>
> return (level);
> }
>