git: 4cd94c8afb31 - main - atkbdc: Add additional heurstic for Chromebook keyboards

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sat, 09 Sep 2023 17:14:14 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=4cd94c8afb31965c7f18471eaa0b2d5e661c24fb

commit 4cd94c8afb31965c7f18471eaa0b2d5e661c24fb
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-09-09 02:18:33 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-09-09 17:13:25 +0000

    atkbdc: Add additional heurstic for Chromebook keyboards
    
    It turns out that that heurstic used to determine if we have a Google
    coreboot, and thus have the i8042 emulation bugs, is incorrect. At least
    one Acer "Peppy" Chromebook has an issue because Acer space'd out the
    smbios.bios.version string we're using as part of the heuristic. So, if
    the version starts with a space, then enable the workarounds if the
    smbios.bios.reldate is 2018 or earlier. While not perfect, it should be
    a reasonable dividing line and still allow newer core boot-based
    machines that aren't Chromebooks to not have the workaround.
    
    Tested by:      Matthias Apitz
    Sponsored by:   Netflix
    MFC After:      3 days (14.0 candiate)
---
 sys/dev/atkbdc/atkbdc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sys/dev/atkbdc/atkbdc.c b/sys/dev/atkbdc/atkbdc.c
index 6168b389841b..c23afe3323cf 100644
--- a/sys/dev/atkbdc/atkbdc.c
+++ b/sys/dev/atkbdc/atkbdc.c
@@ -147,6 +147,7 @@ atkbdc_getquirks(void)
     char *maker = kern_getenv("smbios.system.maker");
     char *product = kern_getenv("smbios.system.product");
     char *version = kern_getenv("smbios.bios.version");
+    char *reldate = kern_getenv("smbios.bios.reldate");
 
     for (i = 0; i < nitems(quirks); i++)
 	if (QUIRK_STR_EQUAL(quirks[i].bios_vendor, bios_vendor) &&
@@ -154,6 +155,16 @@ atkbdc_getquirks(void)
 	    QUIRK_STR_EQUAL(quirks[i].product, product) &&
 	    QUIRK_STR_MATCH(quirks[i].version, version))
 		return (quirks[i].quirk);
+    /*
+     * Some Chromebooks don't conform to the google comment above so do the
+     * Chromebook workaround for all <= 2018 coreboot systems that have a
+     * 'blank' version.  At least one Acer "Peppy" chromebook has this issue,
+     * with a reldate of 08/13/2014.
+     */
+    if (QUIRK_STR_EQUAL("coreboot", bios_vendor) &&
+	(version != NULL && *version == ' ') &&
+	(reldate != NULL && strlen(reldate) >= 10 && strcmp(reldate + 6, "2018") <= 0))
+	    return (CHROMEBOOK_WORKAROUND);
 
     return (0);
 }