From owner-svn-src-head@freebsd.org Sun Jun 17 20:44:22 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CDFB91009473; Sun, 17 Jun 2018 20:44:21 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7589D7E435; Sun, 17 Jun 2018 20:44:21 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3F81A1A716; Sun, 17 Jun 2018 20:44:21 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5HKiLIo027105; Sun, 17 Jun 2018 20:44:21 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5HKiLOl027104; Sun, 17 Jun 2018 20:44:21 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806172044.w5HKiLOl027104@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 17 Jun 2018 20:44:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335304 - head/sys/dev/acpi_support X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/sys/dev/acpi_support X-SVN-Commit-Revision: 335304 X-SVN-Commit-Repository: base 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.26 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: Sun, 17 Jun 2018 20:44:22 -0000 Author: eadler Date: Sun Jun 17 20:44:20 2018 New Revision: 335304 URL: https://svnweb.freebsd.org/changeset/base/335304 Log: acpi: Add support for Thinkpads Mic led PR: 229074 Submitted by: "Ali Abdallah" 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 Sun Jun 17 20:33:02 2018 (r335303) +++ head/sys/dev/acpi_support/acpi_ibm.c Sun Jun 17 20:44:20 2018 (r335304) @@ -74,6 +74,7 @@ ACPI_MODULE_NAME("IBM") #define ACPI_IBM_METHOD_FANSTATUS 12 #define ACPI_IBM_METHOD_THERMAL 13 #define ACPI_IBM_METHOD_HANDLEREVENTS 14 +#define ACPI_IBM_METHOD_MIC_LED 15 /* Hotkeys/Buttons */ #define IBM_RTC_HOTKEY1 0x64 @@ -175,6 +176,10 @@ struct acpi_ibm_softc { int led_busy; int led_state; + /* Mic led handle */ + ACPI_HANDLE mic_led_handle; + int mic_led_state; + int wlan_bt_flags; int thermal_updt_supported; @@ -258,7 +263,11 @@ static struct { .method = ACPI_IBM_METHOD_FANSTATUS, .description = "Fan enable", }, - + { + .name = "mic_led", + .method = ACPI_IBM_METHOD_MIC_LED, + .description = "Mic led", + }, { NULL, 0, NULL, 0 } }; @@ -371,6 +380,35 @@ ibm_led_task(struct acpi_ibm_softc *sc, int pending __ } static int +acpi_ibm_mic_led_set (struct acpi_ibm_softc *sc, int arg) +{ + ACPI_OBJECT_LIST input; + ACPI_OBJECT params[1]; + ACPI_STATUS status; + + if (arg < 0 || arg > 1) + return (EINVAL); + + if (sc->mic_led_handle) { + params[0].Type = ACPI_TYPE_INTEGER; + params[0].Integer.Value = 0; + /* mic led: 0 off, 2 on */ + if (arg == 1) + params[0].Integer.Value = 2; + + input.Pointer = params; + input.Count = 1; + + status = AcpiEvaluateObject (sc->handle, "MMTS", &input, NULL); + if (ACPI_SUCCESS(status)) + sc->mic_led_state = arg; + return(status); + } + + return (0); +} + +static int acpi_ibm_probe(device_t dev) { if (acpi_disabled("ibm") || @@ -552,6 +590,9 @@ acpi_ibm_resume(device_t dev) } ACPI_SERIAL_END(ibm); + /* The mic led does not turn back on when sysctl_set is called in the above loop */ + acpi_ibm_mic_led_set(sc, sc->mic_led_state); + return (0); } @@ -739,6 +780,12 @@ acpi_ibm_sysctl_get(struct acpi_ibm_softc *sc, int met else val = -1; break; + case ACPI_IBM_METHOD_MIC_LED: + if (sc->mic_led_handle) + return sc->mic_led_state; + else + val = -1; + break; } return (val); @@ -783,6 +830,10 @@ acpi_ibm_sysctl_set(struct acpi_ibm_softc *sc, int met return acpi_ibm_mute_set(sc, arg); break; + case ACPI_IBM_METHOD_MIC_LED: + return acpi_ibm_mic_led_set (sc, arg); + break; + case ACPI_IBM_METHOD_THINKLIGHT: return acpi_ibm_thinklight_set(sc, arg); break; @@ -841,6 +892,17 @@ acpi_ibm_sysctl_init(struct acpi_ibm_softc *sc, int me case ACPI_IBM_METHOD_MUTE: /* EC is required here, which was already checked before */ return (TRUE); + + case ACPI_IBM_METHOD_MIC_LED: + if (ACPI_SUCCESS(AcpiGetHandle(sc->handle, "MMTS", &sc->mic_led_handle))) + { + /* Turn off mic led by default */ + acpi_ibm_mic_led_set (sc, 0); + return(TRUE); + } + else + sc->mic_led_handle = NULL; + return (FALSE); case ACPI_IBM_METHOD_THINKLIGHT: sc->cmos_handle = NULL;