mirror of
https://github.com/opnsense/src.git
synced 2026-04-01 15:35:10 -04:00
acpi_ibm: pass brightness events to evdev(4)
unless the dev.acpi_ibm.0.handlerevents sysctl is set to process them internally. The default for the latter is to ignore them, so passing to evdev(4) is enabled by default. Reviewed by: wulf, imp Tested on: Lenovo Thinpad X11 Carbon 7Th Gen Differential Revision: https://reviews.freebsd.org/D48174 (cherry picked from commit c21f5751ef0932796676e55953461e0679020e28)
This commit is contained in:
parent
1bda3fae78
commit
886fcbde46
2 changed files with 44 additions and 1 deletions
|
|
@ -37,6 +37,7 @@
|
|||
*/
|
||||
|
||||
#include "opt_acpi.h"
|
||||
#include "opt_evdev.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
|
|
@ -55,6 +56,11 @@
|
|||
#include <sys/sysctl.h>
|
||||
#include <isa/rtc.h>
|
||||
|
||||
#ifdef EVDEV_SUPPORT
|
||||
#include <dev/evdev/input.h>
|
||||
#include <dev/evdev/evdev.h>
|
||||
#endif
|
||||
|
||||
#define _COMPONENT ACPI_OEM
|
||||
ACPI_MODULE_NAME("IBM")
|
||||
|
||||
|
|
@ -198,6 +204,9 @@ struct acpi_ibm_softc {
|
|||
|
||||
struct sysctl_ctx_list *sysctl_ctx;
|
||||
struct sysctl_oid *sysctl_tree;
|
||||
#ifdef EVDEV_SUPPORT
|
||||
struct evdev_dev *evdev;
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct {
|
||||
|
|
@ -363,6 +372,9 @@ static driver_t acpi_ibm_driver = {
|
|||
|
||||
DRIVER_MODULE(acpi_ibm, acpi, acpi_ibm_driver, 0, 0);
|
||||
MODULE_DEPEND(acpi_ibm, acpi, 1, 1, 1);
|
||||
#ifdef EVDEV_SUPPORT
|
||||
MODULE_DEPEND(acpi_ibm, evdev, 1, 1, 1);
|
||||
#endif
|
||||
static char *ibm_ids[] = {"IBM0068", "LEN0068", "LEN0268", NULL};
|
||||
|
||||
static int
|
||||
|
|
@ -482,6 +494,20 @@ acpi_ibm_attach(device_t dev)
|
|||
}
|
||||
sc->ec_handle = acpi_get_handle(sc->ec_dev);
|
||||
|
||||
#ifdef EVDEV_SUPPORT
|
||||
sc->evdev = evdev_alloc();
|
||||
evdev_set_name(sc->evdev, device_get_desc(dev));
|
||||
evdev_set_phys(sc->evdev, device_get_nameunit(dev));
|
||||
evdev_set_id(sc->evdev, BUS_HOST, 0, 0, 1);
|
||||
evdev_support_event(sc->evdev, EV_SYN);
|
||||
evdev_support_event(sc->evdev, EV_KEY);
|
||||
evdev_support_key(sc->evdev, KEY_BRIGHTNESSUP);
|
||||
evdev_support_key(sc->evdev, KEY_BRIGHTNESSDOWN);
|
||||
|
||||
if (evdev_register(sc->evdev) != 0)
|
||||
return (ENXIO);
|
||||
#endif
|
||||
|
||||
/* Get the sysctl tree */
|
||||
sc->sysctl_ctx = device_get_sysctl_ctx(dev);
|
||||
sc->sysctl_tree = device_get_sysctl_tree(dev);
|
||||
|
|
@ -627,6 +653,10 @@ acpi_ibm_detach(device_t dev)
|
|||
if (sc->led_dev != NULL)
|
||||
led_destroy(sc->led_dev);
|
||||
|
||||
#ifdef EVDEV_SUPPORT
|
||||
evdev_free(sc->evdev);
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -1499,6 +1529,19 @@ acpi_ibm_notify(ACPI_HANDLE h, UINT32 notify, void *context)
|
|||
/* Execute event handler */
|
||||
if (sc->handler_events & (1 << (arg - 1)))
|
||||
acpi_ibm_eventhandler(sc, (arg & 0xff));
|
||||
#ifdef EVDEV_SUPPORT
|
||||
else if ((arg & 0xff) == IBM_EVENT_BRIGHTNESS_UP ||
|
||||
(arg & 0xff) == IBM_EVENT_BRIGHTNESS_DOWN) {
|
||||
uint16_t key;
|
||||
|
||||
key = arg == IBM_EVENT_BRIGHTNESS_UP ?
|
||||
KEY_BRIGHTNESSUP : KEY_BRIGHTNESSDOWN;
|
||||
evdev_push_key(sc->evdev, key, 1);
|
||||
evdev_sync(sc->evdev);
|
||||
evdev_push_key(sc->evdev, key, 0);
|
||||
evdev_sync(sc->evdev);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Notify devd(8) */
|
||||
acpi_UserNotify("IBM", h, (arg & 0xff));
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
.PATH: ${SRCTOP}/sys/dev/acpi_support
|
||||
KMOD= acpi_ibm
|
||||
SRCS= acpi_ibm.c opt_acpi.h device_if.h bus_if.h acpi_if.h
|
||||
SRCS+= opt_ddb.h
|
||||
SRCS+= opt_ddb.h opt_evdev.h
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
|
|
|
|||
Loading…
Reference in a new issue