From a6b15a34296485b2bbd71176697fd2d37f88f9c7 Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Sun, 2 Oct 2016 03:20:31 +0000 Subject: [PATCH] Modularize evdev - Convert "options EVDEV" to "device evdev" and "device uinput", add modules for both new devices. They are isolated subsystems and do not require any compile-time changes to general kernel subsytems - For hybrid drivers that have evdev as an optional way to deliver input events add option EVDEV_SUPPORT. Update all existing hybrid drivers to use it instead of EVDEV - Remove no-op DECLARE_MODULE in evdev, it's not required, MODULE_VERSION is enough - Add evdev module dependency to uinput Submitted by: Vladimir Kondratiev --- sys/arm/conf/BEAGLEBONE | 2 +- sys/arm/ti/ti_adc.c | 16 ++++++++-------- sys/arm/ti/ti_adcvar.h | 2 +- sys/conf/NOTES | 8 +++++--- sys/conf/options | 2 +- sys/dev/evdev/evdev.c | 18 ------------------ sys/dev/evdev/uinput.c | 2 ++ sys/dev/usb/input/ukbd.c | 24 ++++++++++++------------ sys/dev/usb/input/ums.c | 24 ++++++++++++------------ sys/modules/Makefile | 2 ++ sys/modules/evdev/Makefile | 9 +++++++++ sys/modules/uinput/Makefile | 9 +++++++++ 12 files changed, 62 insertions(+), 56 deletions(-) create mode 100644 sys/modules/evdev/Makefile create mode 100644 sys/modules/uinput/Makefile diff --git a/sys/arm/conf/BEAGLEBONE b/sys/arm/conf/BEAGLEBONE index c09f5b901e47..8010aee3473d 100644 --- a/sys/arm/conf/BEAGLEBONE +++ b/sys/arm/conf/BEAGLEBONE @@ -133,4 +133,4 @@ device ukbd device kbdmux # Uncomment to enable evdev support for ti_adc -# options EVDEV +# options EVDEV_SUPPORT diff --git a/sys/arm/ti/ti_adc.c b/sys/arm/ti/ti_adc.c index 48d80a44241c..154cd78b630a 100644 --- a/sys/arm/ti/ti_adc.c +++ b/sys/arm/ti/ti_adc.c @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef EVDEV +#ifdef EVDEV_SUPPORT #include #include #endif @@ -89,7 +89,7 @@ static int ti_adc_samples[5] = { 0, 2, 4, 8, 16 }; static int ti_adc_detach(device_t dev); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT static void ti_adc_ev_report(struct ti_adc_softc *sc) { @@ -472,7 +472,7 @@ ti_adc_tsc_read_data(struct ti_adc_softc *sc) device_printf(sc->sc_dev, "touchscreen x: %d, y: %d\n", x, y); #endif -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if ((sc->sc_x != x) || (sc->sc_y != y)) { sc->sc_x = x; sc->sc_y = y; @@ -516,7 +516,7 @@ ti_adc_intr(void *arg) status |= ADC_IRQ_HW_PEN_ASYNC; ADC_WRITE4(sc, ADC_IRQENABLE_CLR, ADC_IRQ_HW_PEN_ASYNC); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT ti_adc_ev_report(sc); #endif } @@ -524,7 +524,7 @@ ti_adc_intr(void *arg) if (rawstatus & ADC_IRQ_PEN_UP) { sc->sc_pen_down = 0; status |= ADC_IRQ_PEN_UP; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT ti_adc_ev_report(sc); #endif } @@ -874,7 +874,7 @@ ti_adc_attach(device_t dev) ti_adc_setup(sc); TI_ADC_UNLOCK(sc); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_tsc_wires > 0) { sc->sc_evdev = evdev_alloc(); evdev_set_name(sc->sc_evdev, device_get_desc(dev)); @@ -921,7 +921,7 @@ ti_adc_detach(device_t dev) ti_adc_reset(sc); ti_adc_setup(sc); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT evdev_free(sc->sc_evdev); #endif @@ -958,6 +958,6 @@ static devclass_t ti_adc_devclass; DRIVER_MODULE(ti_adc, simplebus, ti_adc_driver, ti_adc_devclass, 0, 0); MODULE_VERSION(ti_adc, 1); MODULE_DEPEND(ti_adc, simplebus, 1, 1, 1); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT MODULE_DEPEND(ti_adc, evdev, 1, 1, 1); #endif diff --git a/sys/arm/ti/ti_adcvar.h b/sys/arm/ti/ti_adcvar.h index 012e1ce89250..b9cc0f0b450b 100644 --- a/sys/arm/ti/ti_adcvar.h +++ b/sys/arm/ti/ti_adcvar.h @@ -55,7 +55,7 @@ struct ti_adc_softc { int sc_yn_bit, sc_yn_inp; uint32_t sc_tsc_enabled; int sc_pen_down; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT int sc_x; int sc_y; struct evdev_dev *sc_evdev; diff --git a/sys/conf/NOTES b/sys/conf/NOTES index dd4711ce82d2..a827fd2ed1a4 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -3054,6 +3054,8 @@ options GZIO options BHND_LOGLEVEL # Logging threshold level # evdev interface -options EVDEV -options EVDEV_DEBUG -options UINPUT_DEBUG +device evdev # input event device support +options EVDEV_SUPPORT # evdev support in legacy drivers +options EVDEV_DEBUG # enable event debug msgs +device uinput # install /dev/uinput cdev +options UINPUT_DEBUG # enable uinput debug msgs diff --git a/sys/conf/options b/sys/conf/options index 6c1e3f106744..a997a53d2ef3 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -989,6 +989,6 @@ BHND_LOGLEVEL opt_global.h GPIO_SPI_DEBUG opt_gpio.h # evdev protocol support -EVDEV opt_evdev.h +EVDEV_SUPPORT opt_evdev.h EVDEV_DEBUG opt_evdev.h UINPUT_DEBUG opt_evdev.h diff --git a/sys/dev/evdev/evdev.c b/sys/dev/evdev/evdev.c index 9b699f5fac01..095552ed26f6 100644 --- a/sys/dev/evdev/evdev.c +++ b/sys/dev/evdev/evdev.c @@ -918,22 +918,4 @@ evdev_stop_repeat(struct evdev_dev *evdev) } } -static int -evdev_modevent(module_t mod, int type, void *unused) -{ - switch (type) { - case MOD_LOAD: - return 0; - case MOD_UNLOAD: - return 0; - } - return EINVAL; -} - -static moduledata_t evdev_mod = { - "evdev", - evdev_modevent, - 0 -}; -DECLARE_MODULE(evdev, evdev_mod, SI_SUB_DRIVERS, SI_ORDER_ANY); MODULE_VERSION(evdev, 1); diff --git a/sys/dev/evdev/uinput.c b/sys/dev/evdev/uinput.c index ffe94e73aca4..77810b75e230 100644 --- a/sys/dev/evdev/uinput.c +++ b/sys/dev/evdev/uinput.c @@ -708,3 +708,5 @@ uinput_modevent(module_t mod __unused, int cmd, void *data) } DEV_MODULE(uinput, uinput_modevent, NULL); +MODULE_VERSION(uinput, 1); +MODULE_DEPEND(uinput, evdev, 1, 1, 1); diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index fa9c5a01caca..893d46b7e0da 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$"); #include -#ifdef EVDEV +#ifdef EVDEV_SUPPORT #include #include #endif @@ -166,7 +166,7 @@ struct ukbd_softc { struct usb_device *sc_udev; struct usb_interface *sc_iface; struct usb_xfer *sc_xfer[UKBD_N_TRANSFER]; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT struct evdev_dev *sc_evdev; #endif @@ -363,7 +363,7 @@ static device_attach_t ukbd_attach; static device_detach_t ukbd_detach; static device_resume_t ukbd_resume; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT static struct evdev_methods ukbd_evdev_methods = { .ev_event = evdev_ev_kbd_event, }; @@ -403,7 +403,7 @@ ukbd_put_key(struct ukbd_softc *sc, uint32_t key) DPRINTF("0x%02x (%d) %s\n", key, key, (key & KEY_RELEASE) ? "released" : "pressed"); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (evdev_rcpt_mask & EVDEV_RCPT_HW_KBD && sc->sc_evdev != NULL) { evdev_push_event(sc->sc_evdev, EV_KEY, evdev_hid2key(KEY_INDEX(key)), !(key & KEY_RELEASE)); @@ -931,7 +931,7 @@ ukbd_set_leds_callback(struct usb_xfer *xfer, usb_error_t error) if (!any) break; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_evdev != NULL) evdev_push_leds(sc->sc_evdev, sc->sc_leds); #endif @@ -1211,7 +1211,7 @@ ukbd_attach(device_t dev) usb_error_t err; uint16_t n; uint16_t hid_len; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT struct evdev_dev *evdev; int i; #endif @@ -1330,7 +1330,7 @@ ukbd_attach(device_t dev) } #endif -#ifdef EVDEV +#ifdef EVDEV_SUPPORT evdev = evdev_alloc(); evdev_set_name(evdev, device_get_desc(dev)); evdev_set_phys(evdev, device_get_nameunit(dev)); @@ -1431,7 +1431,7 @@ ukbd_detach(device_t dev) } #endif -#ifdef EVDEV +#ifdef EVDEV_SUPPORT evdev_free(sc->sc_evdev); #endif @@ -1952,7 +1952,7 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg) */ kbd->kb_delay1 = imax(((int *)arg)[0], 250); kbd->kb_delay2 = imax(((int *)arg)[1], 34); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_evdev != NULL) evdev_push_repeats(sc->sc_evdev, kbd); #endif @@ -2104,7 +2104,7 @@ ukbd_set_leds(struct ukbd_softc *sc, uint8_t leds) static int ukbd_set_typematic(keyboard_t *kbd, int code) { -#ifdef EVDEV +#ifdef EVDEV_SUPPORT struct ukbd_softc *sc = kbd->kb_data; #endif static const int delays[] = {250, 500, 750, 1000}; @@ -2118,7 +2118,7 @@ ukbd_set_typematic(keyboard_t *kbd, int code) } kbd->kb_delay1 = delays[(code >> 5) & 3]; kbd->kb_delay2 = rates[code & 0x1f]; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_evdev != NULL) evdev_push_repeats(sc->sc_evdev, kbd); #endif @@ -2300,7 +2300,7 @@ static driver_t ukbd_driver = { DRIVER_MODULE(ukbd, uhub, ukbd_driver, ukbd_devclass, ukbd_driver_load, 0); MODULE_DEPEND(ukbd, usb, 1, 1, 1); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT MODULE_DEPEND(ukbd, evdev, 1, 1, 1); #endif MODULE_VERSION(ukbd, 1); diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c index ac8a08b45c3f..dc7d37786aa3 100644 --- a/sys/dev/usb/input/ums.c +++ b/sys/dev/usb/input/ums.c @@ -70,7 +70,7 @@ __FBSDID("$FreeBSD$"); #include -#ifdef EVDEV +#ifdef EVDEV_SUPPORT #include #include #endif @@ -142,7 +142,7 @@ struct ums_softc { int sc_pollrate; int sc_fflags; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT int sc_evflags; #define UMS_EVDEV_OPENED 1 #endif @@ -151,7 +151,7 @@ struct ums_softc { uint8_t sc_iid; uint8_t sc_temp[64]; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT struct evdev_dev *sc_evdev; #endif }; @@ -170,7 +170,7 @@ static usb_fifo_open_t ums_fifo_open; static usb_fifo_close_t ums_fifo_close; static usb_fifo_ioctl_t ums_fifo_ioctl; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT static evdev_open_t ums_ev_open; static evdev_close_t ums_ev_close; #endif @@ -190,7 +190,7 @@ static struct usb_fifo_methods ums_fifo_methods = { .basename[0] = "ums", }; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT static struct evdev_methods ums_evdev_methods = { .ev_open = &ums_ev_open, .ev_close = &ums_ev_close, @@ -357,7 +357,7 @@ ums_intr_callback(struct usb_xfer *xfer, usb_error_t error) tr_setup: /* check if we can put more data into the FIFO */ if (usb_fifo_put_bytes_max(sc->sc_fifo.fp[USB_FIFO_RX]) == 0) { -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_evflags == 0) break; #else @@ -690,7 +690,7 @@ ums_attach(device_t dev) if (err) goto detach; -#ifdef EVDEV +#ifdef EVDEV_SUPPORT sc->sc_evdev = evdev_alloc(); evdev_set_name(sc->sc_evdev, device_get_desc(dev)); evdev_set_phys(sc->sc_evdev, device_get_nameunit(dev)); @@ -750,7 +750,7 @@ ums_detach(device_t self) usb_fifo_detach(&sc->sc_fifo); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT evdev_free(sc->sc_evdev); #endif @@ -892,7 +892,7 @@ ums_put_queue(struct ums_softc *sc, int32_t dx, int32_t dy, usb_fifo_put_data_linear(sc->sc_fifo.fp[USB_FIFO_RX], buf, sc->sc_mode.packetsize, 1); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (evdev_rcpt_mask & EVDEV_RCPT_HW_MOUSE) { /* Push evdev event */ evdev_push_event(sc->sc_evdev, EV_REL, REL_X, dx); @@ -919,7 +919,7 @@ ums_reset_buf(struct ums_softc *sc) usb_fifo_reset(sc->sc_fifo.fp[USB_FIFO_RX]); } -#ifdef EVDEV +#ifdef EVDEV_SUPPORT static int ums_ev_open(struct evdev_dev *evdev, void *ev_softc) { @@ -967,7 +967,7 @@ ums_fifo_open(struct usb_fifo *fifo, int fflags) return (EBUSY); /* check for first open */ -#ifdef EVDEV +#ifdef EVDEV_SUPPORT if (sc->sc_fflags == 0 && sc->sc_evflags == 0) ums_reset(sc); #else @@ -1199,7 +1199,7 @@ static driver_t ums_driver = { DRIVER_MODULE(ums, uhub, ums_driver, ums_devclass, NULL, 0); MODULE_DEPEND(ums, usb, 1, 1, 1); -#ifdef EVDEV +#ifdef EVDEV_SUPPORT MODULE_DEPEND(ums, evdev, 1, 1, 1); #endif MODULE_VERSION(ums, 1); diff --git a/sys/modules/Makefile b/sys/modules/Makefile index 0be224ff1747..75bbd0f998fe 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -111,6 +111,7 @@ SUBDIR= \ ${_epic} \ esp \ ${_et} \ + evdev \ ${_ex} \ ${_exca} \ ext2fs \ @@ -371,6 +372,7 @@ SUBDIR= \ udf \ udf_iconv \ ufs \ + uinput \ unionfs \ urtwn \ ${_urtwnfw} \ diff --git a/sys/modules/evdev/Makefile b/sys/modules/evdev/Makefile new file mode 100644 index 000000000000..11091eababa0 --- /dev/null +++ b/sys/modules/evdev/Makefile @@ -0,0 +1,9 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../dev/evdev + +KMOD= evdev +SRCS= cdev.c evdev.c evdev_mt.c evdev_utils.c +SRCS+= opt_evdev.h bus_if.h device_if.h + +.include diff --git a/sys/modules/uinput/Makefile b/sys/modules/uinput/Makefile new file mode 100644 index 000000000000..bdb9739bce25 --- /dev/null +++ b/sys/modules/uinput/Makefile @@ -0,0 +1,9 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../dev/evdev + +KMOD= uinput +SRCS= uinput.c +SRCS+= opt_evdev.h + +.include