Date: Sun, 17 Jun 2018 20:44:21 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335304 - head/sys/dev/acpi_support Message-ID: <201806172044.w5HKiLOl027104@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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" <aliovx@gmail.com> 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806172044.w5HKiLOl027104>