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.

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.

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.

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