From owner-svn-src-head@FreeBSD.ORG Fri May 29 05:28:25 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AFEBBE5E; Fri, 29 May 2015 05:28:25 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9E8371CD2; Fri, 29 May 2015 05:28:25 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4T5SPvJ011316; Fri, 29 May 2015 05:28:25 GMT (envelope-from rpaulo@FreeBSD.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4T5SPGt011315; Fri, 29 May 2015 05:28:25 GMT (envelope-from rpaulo@FreeBSD.org) Message-Id: <201505290528.t4T5SPGt011315@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: rpaulo set sender to rpaulo@FreeBSD.org using -f From: Rui Paulo Date: Fri, 29 May 2015 05:28:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r283678 - head/sys/dev/acpi_support X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 May 2015 05:28:25 -0000 Author: rpaulo Date: Fri May 29 05:28:24 2015 New Revision: 283678 URL: https://svnweb.freebsd.org/changeset/base/283678 Log: acpi_ibm: add per-model default events mask. Add support for the hotkeys on a Lenovo X1 3rd gen. This also enables event reporting by default. Modified: head/sys/dev/acpi_support/acpi_ibm.c Modified: head/sys/dev/acpi_support/acpi_ibm.c ============================================================================== --- head/sys/dev/acpi_support/acpi_ibm.c Fri May 29 04:22:57 2015 (r283677) +++ head/sys/dev/acpi_support/acpi_ibm.c Fri May 29 05:28:24 2015 (r283678) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include "opt_acpi.h" #include +#include #include #include #include @@ -261,6 +262,37 @@ static struct { { NULL, 0, NULL, 0 } }; +/* + * Per-model default list of event mask. + */ +#define ACPI_IBM_HKEY_RFKILL_MASK (1 << 4) +#define ACPI_IBM_HKEY_DSWITCH_MASK (1 << 6) +#define ACPI_IBM_HKEY_BRIGHTNESS_UP_MASK (1 << 15) +#define ACPI_IBM_HKEY_BRIGHTNESS_DOWN_MASK (1 << 16) +#define ACPI_IBM_HKEY_SEARCH_MASK (1 << 18) +#define ACPI_IBM_HKEY_MICMUTE_MASK (1 << 26) +#define ACPI_IBM_HKEY_SETTINGS_MASK (1 << 28) +#define ACPI_IBM_HKEY_VIEWOPEN_MASK (1 << 30) +#define ACPI_IBM_HKEY_VIEWALL_MASK (1 << 31) + +struct acpi_ibm_models { + const char *maker; + const char *product; + uint32_t eventmask; +} acpi_ibm_models[] = { + { "LENOVO", "20BSCTO1WW", + ACPI_IBM_HKEY_RFKILL_MASK | + ACPI_IBM_HKEY_DSWITCH_MASK | + ACPI_IBM_HKEY_BRIGHTNESS_UP_MASK | + ACPI_IBM_HKEY_BRIGHTNESS_DOWN_MASK | + ACPI_IBM_HKEY_SEARCH_MASK | + ACPI_IBM_HKEY_MICMUTE_MASK | + ACPI_IBM_HKEY_SETTINGS_MASK | + ACPI_IBM_HKEY_VIEWOPEN_MASK | + ACPI_IBM_HKEY_VIEWALL_MASK + } +}; + ACPI_SERIAL_DECL(ibm, "ACPI IBM extras"); static int acpi_ibm_probe(device_t dev); @@ -354,7 +386,9 @@ acpi_ibm_probe(device_t dev) static int acpi_ibm_attach(device_t dev) { + int i; struct acpi_ibm_softc *sc; + char *maker, *product; devclass_t ec_devclass; ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__); @@ -448,6 +482,27 @@ acpi_ibm_attach(device_t dev) sc->led_dev = led_create_state(ibm_led, sc, "thinklight", (sc->light_val ? 1 : 0)); + /* Enable per-model events. */ + maker = kern_getenv("smbios.system.maker"); + product = kern_getenv("smbios.system.product"); + for (i = 0; i < nitems(acpi_ibm_models); i++) { + if (strcmp(maker, acpi_ibm_models[i].maker) == 0 && + strcmp(product, acpi_ibm_models[i].product) == 0) { + ACPI_SERIAL_BEGIN(ibm); + acpi_ibm_sysctl_set(sc, ACPI_IBM_METHOD_EVENTMASK, + acpi_ibm_models[i].eventmask); + ACPI_SERIAL_END(ibm); + } + } + freeenv(maker); + freeenv(product); + + /* Enable events by default. */ + ACPI_SERIAL_BEGIN(ibm); + acpi_ibm_sysctl_set(sc, ACPI_IBM_METHOD_EVENTS, 1); + ACPI_SERIAL_END(ibm); + + return (0); } @@ -770,7 +825,6 @@ acpi_ibm_sysctl_init(struct acpi_ibm_sof switch (method) { case ACPI_IBM_METHOD_EVENTS: - /* Events are disabled by default */ return (TRUE); case ACPI_IBM_METHOD_EVENTMASK: @@ -1229,7 +1283,6 @@ acpi_ibm_notify(ACPI_HANDLE h, UINT32 no for (;;) { acpi_GetInteger(acpi_get_handle(dev), IBM_NAME_EVENTS_GET, &event); - if (event == 0) break;