> Date: Sat, 22 Oct 2022 11:26:31 +0300
> From: Mikhail <mp39...@gmail.com>
> 
> I continue my fight with ACPI on Lenovo IdeaPad 3 14ITL05, now, when
> battery status problem has been resolved[1] next target is backlight
> brightness keys.

Well it hasn't been resolved yet.  The firmware is clearly broken, and
we still have to find a workaround that doesn't break other
machines...

> With the inlined patch and explicitly specified correct EC_ID in the
> code I'm able to control brightness with functional keys. The patch
> moves _INI methods evaluation "immediately before" table-defined device
> attach, before the patch it was "immediately after".
> 
> Only reference which I found in the spec is [2], and it doesn't make it
> clear when _INI should be eval'ed: "This control method is located under
> a device object and is run only when OSPM loads a description table."
> Another reference in the same chapter: "_INI - Device initialization
> method that is run shortly after ACPI has been enabled." Term "shortly"
> isn't very precise description of when to run _INI either.

Welcome to ACPI.  More than 1000 pages of documentation and still
woefully underspecified.

Your interpretation doesn't make a lot of sense to me.  The whole
purpose of the tables is to have certain things (such as access to PCI
config space or accessing the Embedded Controller) work before running
any of the AML methods.

> I understand that this isn't very grown up engineering attitude "I do
> this and everything works", but currently I lack explanation why this
> approach helps.  If anyone has ideas how to investigate this further - I
> will be appreciated.

Identifying which of the "table-driven" device attachments is the
culprit here might help.

> If your brightness keys or other ACPI stuff doesn't work, you can give
> this patch a try.
> 
> Will be grateful for testing and reviews.
> 
> [1] - https://marc.info/?l=openbsd-tech&m=166600434429788&w=2
> [2] - https://uefi.org/specs/ACPI/6.5/06_Device_Configuration.html#ini-init
> 
> diff /usr/src
> commit - 3fb2197480c345a19f2098d1b787c28b9c717dcb
> path + /usr/src
> blob - fc3c1d160ee0ccc7217d77be184c253b29422983
> file + sys/dev/acpi/acpi.c
> --- sys/dev/acpi/acpi.c
> +++ sys/dev/acpi/acpi.c
> @@ -1203,6 +1203,9 @@ acpi_attach_common(struct acpi_softc *sc, paddr_t base
>       }
>  #endif /* SMALL_KERNEL */
>  
> +     /* initialize runtime environment */
> +     aml_find_node(sc->sc_root, "_INI", acpi_inidev, sc);
> +
>       /*
>        * Attach table-defined devices
>        */
> @@ -1217,9 +1220,6 @@ acpi_attach_common(struct acpi_softc *sc, paddr_t base
>               config_found_sm(&sc->sc_dev, &aaa, acpi_print, acpi_submatch);
>       }
>  
> -     /* initialize runtime environment */
> -     aml_find_node(sc->sc_root, "_INI", acpi_inidev, sc);
> -
>       /* Get PCI mapping */
>       aml_walknodes(sc->sc_root, AML_WALK_PRE, acpi_getpci, sc);
>  
> 
> 

Reply via email to