hid: Replace USBHID_ENABLED kernel config option with loader tunable

usbhid(4) is disabled by default to avoid conflicts with existing USB HID
drivers. To enable it place following lines to /boot/loader.conf:

hw.usb.usbhid.enable=1
usbhid_load="YES"

Suggested by:	jhb
Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D28124
This commit is contained in:
Vladimir Kondratyev 2021-01-12 22:36:21 +03:00
parent d2b3ceddcc
commit b62f6dfaed
10 changed files with 15 additions and 29 deletions

View File

@ -23,7 +23,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd September 21, 2020
.Dd January 12, 2021
.Dt USBHID 4
.Os
.Sh NAME
@ -54,6 +54,13 @@ variables and
.Xr loader 8
tunables:
.Bl -tag -width indent
.It Va hw.usb.usbhid.enable
Enable
.Nm
and make its priority greater than other USB HID drivers have.
Default is 0.
.El
.Bl -tag -width indent
.It Va hw.usb.usbhid.debug
Debug output level, where 0 is debugging disabled and larger values increase
debug message verbosity.

View File

@ -385,6 +385,3 @@ device uinput # install /dev/uinput cdev
options HID_DEBUG # enable debug msgs
device hid # Generic HID support
options IICHID_SAMPLING # Workaround missing GPIO INTR support
#device usbhid # USB transport support.
#device hidbus # HID bus (required by usbhid/iichid)
#options USBHID_ENABLED # Prefer usbhid to other USB drivers

View File

@ -2594,9 +2594,6 @@ options UVSCOM_DEFAULT_OPKTSIZE=8 # default output packet size
options UVSCOM_INTR_INTERVAL=100 # interrupt pipe interval
# in milliseconds
# options for usbhid:
options USBHID_ENABLED # Prefer usbhid to other USBHID drivers
#####################################################################
# FireWire support

View File

@ -669,7 +669,6 @@ UKBD_DFLT_KEYMAP opt_ukbd.h
UPLCOM_INTR_INTERVAL opt_uplcom.h
UVSCOM_DEFAULT_OPKTSIZE opt_uvscom.h
UVSCOM_INTR_INTERVAL opt_uvscom.h
USBHID_ENABLED opt_usb.h
# options for the Realtek rtwn driver
RTWN_DEBUG opt_rtwn.h

View File

@ -923,6 +923,4 @@ DRIVER_MODULE(uhid, uhub, uhid_driver, uhid_devclass, NULL, 0);
MODULE_DEPEND(uhid, usb, 1, 1, 1);
MODULE_DEPEND(uhid, hid, 1, 1, 1);
MODULE_VERSION(uhid, 1);
#ifndef USBHID_ENABLED
USB_PNP_HOST_INFO(uhid_devs);
#endif

View File

@ -2192,6 +2192,4 @@ MODULE_DEPEND(ukbd, hid, 1, 1, 1);
MODULE_DEPEND(ukbd, evdev, 1, 1, 1);
#endif
MODULE_VERSION(ukbd, 1);
#ifndef USBHID_ENABLED
USB_PNP_HOST_INFO(ukbd_devs);
#endif

View File

@ -1220,6 +1220,4 @@ MODULE_DEPEND(ums, hid, 1, 1, 1);
MODULE_DEPEND(ums, evdev, 1, 1, 1);
#endif
MODULE_VERSION(ums, 1);
#ifndef USBHID_ENABLED
USB_PNP_HOST_INFO(ums_devs);
#endif

View File

@ -75,10 +75,12 @@ __FBSDID("$FreeBSD$");
#include "hid_if.h"
static SYSCTL_NODE(_hw_usb, OID_AUTO, usbhid, CTLFLAG_RW, 0, "USB usbhid");
static int usbhid_enable = 0;
SYSCTL_INT(_hw_usb_usbhid, OID_AUTO, enable, CTLFLAG_RWTUN,
&usbhid_enable, 0, "Enable usbhid and prefer it to other USB HID drivers");
#ifdef USB_DEBUG
static int usbhid_debug = 0;
static SYSCTL_NODE(_hw_usb, OID_AUTO, usbhid, CTLFLAG_RW, 0, "USB usbhid");
SYSCTL_INT(_hw_usb_usbhid, OID_AUTO, debug, CTLFLAG_RWTUN,
&usbhid_debug, 0, "Debug level");
#endif
@ -664,6 +666,9 @@ usbhid_probe(device_t dev)
DPRINTFN(11, "\n");
if (usbhid_enable == 0)
return (ENXIO);
if (uaa->usb_mode != USB_MODE_HOST)
return (ENXIO);
@ -683,11 +688,7 @@ usbhid_probe(device_t dev)
if (hid_test_quirk(&sc->sc_hw, HQ_HID_IGNORE))
return (ENXIO);
#ifdef USBHID_ENABLED
return (BUS_PROBE_GENERIC + 1);
#else
return (BUS_PROBE_GENERIC - 1);
#endif
}
static int
@ -781,6 +782,4 @@ MODULE_DEPEND(usbhid, usb, 1, 1, 1);
MODULE_DEPEND(usbhid, hid, 1, 1, 1);
MODULE_DEPEND(usbhid, hidbus, 1, 1, 1);
MODULE_VERSION(usbhid, 1);
#ifdef USBHID_ENABLED
USB_PNP_HOST_INFO(usbhid_devs);
#endif

View File

@ -1009,13 +1009,11 @@ wmt_set_input_mode(struct wmt_softc *sc, enum wmt_input_mode mode)
return (err);
}
#ifndef USBHID_ENABLED
static const STRUCT_USB_HOST_ID wmt_devs[] = {
/* generic HID class w/o boot interface */
{USB_IFACE_CLASS(UICLASS_HID),
USB_IFACE_SUBCLASS(0),},
};
#endif
static devclass_t wmt_devclass;
@ -1038,6 +1036,4 @@ MODULE_DEPEND(wmt, usb, 1, 1, 1);
MODULE_DEPEND(wmt, hid, 1, 1, 1);
MODULE_DEPEND(wmt, evdev, 1, 1, 1);
MODULE_VERSION(wmt, 1);
#ifndef USBHID_ENABLED
USB_PNP_HOST_INFO(wmt_devs);
#endif

View File

@ -354,6 +354,3 @@ device uinput # install /dev/uinput cdev
options HID_DEBUG # enable debug msgs
device hid # Generic HID support
options IICHID_SAMPLING # Workaround missing GPIO INTR support
#device usbhid # USB transport support.
#device hidbus # HID bus (required by usbhid/iichid)
#options USBHID_ENABLED # Prefer usbhid to other USB drivers