acpi: Add support for Thinkpads Mic led

PR:		229074
Submitted by:	"Ali Abdallah" <aliovx@gmail.com>
This commit is contained in:
Eitan Adler 2018-06-17 20:44:20 +00:00
parent e4defe55a8
commit 9cd818a3f4

View File

@ -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 }
};
@ -370,6 +379,35 @@ ibm_led_task(struct acpi_ibm_softc *sc, int pending __unused)
sc->led_busy = 0;
}
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)
{
@ -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 method)
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 method, int arg)
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;
@ -842,6 +893,17 @@ acpi_ibm_sysctl_init(struct acpi_ibm_softc *sc, int method)
/* 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;
sc->light_get_supported = ACPI_SUCCESS(acpi_GetInteger(