hid: Port ukbd to HID and attach to build

Reviewed by:	hselasky
Differential revision:  https://reviews.freebsd.org/D27991
This commit is contained in:
Vladimir Kondratyev 2020-10-12 22:52:29 +03:00
parent 08d8840175
commit b93f6bfca3
7 changed files with 623 additions and 796 deletions

View File

@ -183,6 +183,7 @@ MAN= aac.4 \
hidbus.4 \ hidbus.4 \
hidquirk.4 \ hidquirk.4 \
hifn.4 \ hifn.4 \
hkbd.4 \
hmt.4 \ hmt.4 \
hpet.4 \ hpet.4 \
${_hpt27xx.4} \ ${_hpt27xx.4} \

View File

@ -24,37 +24,41 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd April 24, 2018 .Dd September 12, 2020
.Dt UKBD 4 .Dt HKBD 4
.Os .Os
.Sh NAME .Sh NAME
.Nm ukbd .Nm hkbd
.Nd USB keyboard driver .Nd HID keyboard driver
.Sh SYNOPSIS .Sh SYNOPSIS
To compile this driver into the kernel, To compile this driver into the kernel,
place the following line in your place the following line in your
kernel configuration file: kernel configuration file:
.Bd -ragged -offset indent .Bd -ragged -offset indent
.Cd "device ukbd" .Cd "device hkbd"
.Cd "device hid" .Cd "device hid"
.Cd "device usb" .Cd "device hidbus"
.Cd "device evdev"
.Cd "options EVDEV_SUPPORT"
.Ed .Ed
.Pp .Pp
Alternatively, to load the driver as a Alternatively, to load the driver as a
module at boot time, place the following line in module at boot time, place the following line in
.Xr loader.conf 5 : .Xr loader.conf 5 :
.Bd -literal -offset indent .Bd -literal -offset indent
ukbd_load="YES" hkbd_load="YES"
.Ed .Ed
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Nm .Nm
driver provides support for keyboards that attach to the USB port. driver provides support for keyboards that attach to the HID transport
.Xr usb 4 backend.
.Xr hid 4 ,
.Xr hidbus 4 ,
and one of and one of
.Xr uhci 4 .Xr iichid 4
or or
.Xr ohci 4 .Xr usbhid 4
must be configured in the kernel as well. must be configured in the kernel as well.
.Sh CONFIGURATION .Sh CONFIGURATION
By default, the keyboard subsystem does not create the appropriate devices yet. By default, the keyboard subsystem does not create the appropriate devices yet.
@ -63,12 +67,12 @@ config file:
.Pp .Pp
.Dl "options KBD_INSTALL_CDEV" .Dl "options KBD_INSTALL_CDEV"
.Pp .Pp
If both an AT keyboard USB keyboards are used at the same time, the If both an AT keyboard HID keyboards are used at the same time, the
AT keyboard will appear as AT keyboard will appear as
.Pa kbd0 .Pa kbd0
in in
.Pa /dev . .Pa /dev .
The USB keyboards will be The HID keyboards will be
.Pa kbd1 , kbd2 , .Pa kbd1 , kbd2 ,
etc. etc.
You can see some information about the keyboard with the following command: You can see some information about the keyboard with the following command:
@ -87,19 +91,19 @@ You can swap console keyboards by using the command
.Pp .Pp
.Dl "kbdcontrol -k /dev/kbd1" .Dl "kbdcontrol -k /dev/kbd1"
.Pp .Pp
From this point on, the first USB keyboard will be the keyboard From this point on, the first HID keyboard will be the keyboard
to be used by the console. to be used by the console.
.Pp .Pp
If you want to use a USB keyboard as your default and not use an AT keyboard at If you want to use a HID keyboard as your default and not use an AT keyboard at
all, you will have to remove the all, you will have to remove the
.Cd "device atkbd" .Cd "device atkbd"
line from the kernel configuration file. line from the kernel configuration file.
Because of the device initialization order, Because of the device initialization order,
the USB keyboard will be detected the HID keyboard will be detected
.Em after .Em after
the console driver the console driver
initializes itself and you have to explicitly tell the console initializes itself and you have to explicitly tell the console
driver to use the existence of the USB keyboard. driver to use the existence of the HID keyboard.
This can be done in This can be done in
one of the following two ways. one of the following two ways.
.Pp .Pp
@ -107,7 +111,7 @@ Run the following command as a part of system initialization:
.Pp .Pp
.Dl "kbdcontrol -k /dev/kbd0 < /dev/ttyv0 > /dev/null" .Dl "kbdcontrol -k /dev/kbd0 < /dev/ttyv0 > /dev/null"
.Pp .Pp
(Note that as the USB keyboard is the only keyboard, it is accessed as (Note that as the HID keyboard is the only keyboard, it is accessed as
.Pa /dev/kbd0 ) .Pa /dev/kbd0 )
or otherwise tell the console driver to periodically look for a or otherwise tell the console driver to periodically look for a
keyboard by setting a flag in the kernel configuration file: keyboard by setting a flag in the kernel configuration file:
@ -123,8 +127,8 @@ initialized at boot time.
Make the keyboards available through a character device in Make the keyboards available through a character device in
.Pa /dev . .Pa /dev .
.Pp .Pp
.D1 Cd options UKBD_DFLT_KEYMAP .D1 Cd options HKBD_DFLT_KEYMAP
.D1 Cd makeoptions UKBD_DFLT_KEYMAP=fr.iso .D1 Cd makeoptions HKBD_DFLT_KEYMAP=fr.iso
.Pp .Pp
The above lines will put the French ISO keymap in the ukbd driver. The above lines will put the French ISO keymap in the ukbd driver.
You can specify any keymap in You can specify any keymap in
@ -145,28 +149,31 @@ variables and
.Xr loader 8 .Xr loader 8
tunables: tunables:
.Bl -tag -width indent .Bl -tag -width indent
.It Va hw.usb.ukbd.debug .It Va hw.hid.hkbd.debug
Debug output level, where 0 is debugging disabled and larger values increase Debug output level, where 0 is debugging disabled and larger values increase
debug message verbosity. debug message verbosity.
Default is 0. Default is 0.
.El .El
.Sh FILES .Sh FILES
.Bl -tag -width ".Pa /dev/kbd*" -compact .Bl -tag -width ".Pa /dev/input/event*" -compact
.It Pa /dev/kbd* .It Pa /dev/kbd*
blocking device nodes blocking device nodes
.It Pa /dev/input/event*
input event device nodes.
.El .El
.Sh EXAMPLES .Sh EXAMPLES
.D1 Cd "device ukbd" .D1 Cd "device hkbd"
.Pp .Pp
Add the Add the
.Nm .Nm
driver to the kernel. driver to the kernel.
.Sh SEE ALSO .Sh SEE ALSO
.Xr kbdcontrol 1 , .Xr kbdcontrol 1 ,
.Xr ohci 4 , .Xr hid 4 ,
.Xr hidbus 4 ,
.Xr iichid 4 ,
.Xr syscons 4 , .Xr syscons 4 ,
.Xr uhci 4 , .Xr usbhid 4 ,
.Xr usb 4 ,
.Xr vt 4 , .Xr vt 4 ,
.Xr config 8 .Xr config 8
.Sh AUTHORS .Sh AUTHORS

View File

@ -1820,6 +1820,7 @@ dev/hid/hid.c optional hid
dev/hid/hid_if.m optional hid dev/hid/hid_if.m optional hid
dev/hid/hidbus.c optional hidbus dev/hid/hidbus.c optional hidbus
dev/hid/hidquirk.c optional hid dev/hid/hidquirk.c optional hid
dev/hid/hkbd.c optional hkbd
dev/hid/hmt.c optional hmt hconf dev/hid/hmt.c optional hmt hconf
dev/hifn/hifn7751.c optional hifn dev/hifn/hifn7751.c optional hifn
dev/hptiop/hptiop.c optional hptiop scbus dev/hptiop/hptiop.c optional hptiop scbus
@ -2327,7 +2328,7 @@ dev/ixgbe/ixgbe_dcb_82599.c optional ix inet | ixv inet \
compile-with "${NORMAL_C} -I$S/dev/ixgbe" compile-with "${NORMAL_C} -I$S/dev/ixgbe"
dev/jedec_dimm/jedec_dimm.c optional jedec_dimm smbus dev/jedec_dimm/jedec_dimm.c optional jedec_dimm smbus
dev/jme/if_jme.c optional jme pci dev/jme/if_jme.c optional jme pci
dev/kbd/kbd.c optional atkbd | pckbd | sc | ukbd | vt dev/kbd/kbd.c optional atkbd | pckbd | sc | ukbd | vt | hkbd
dev/kbdmux/kbdmux.c optional kbdmux dev/kbdmux/kbdmux.c optional kbdmux
dev/ksyms/ksyms.c optional ksyms dev/ksyms/ksyms.c optional ksyms
dev/le/am7990.c optional le dev/le/am7990.c optional le

View File

@ -1019,3 +1019,4 @@ LINDEBUGFS
HID_DEBUG opt_hid.h HID_DEBUG opt_hid.h
IICHID_DEBUG opt_hid.h IICHID_DEBUG opt_hid.h
IICHID_SAMPLING opt_hid.h IICHID_SAMPLING opt_hid.h
HKBD_DFLT_KEYMAP opt_hkbd.h

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@ SUBDIR = \
SUBDIR += \ SUBDIR += \
hconf \ hconf \
hkbd \
hmt hmt
.include <bsd.subdir.mk> .include <bsd.subdir.mk>

View File

@ -0,0 +1,10 @@
# $FreeBSD$
.PATH: ${SRCTOP}/sys/dev/hid
KMOD= hkbd
SRCS= hkbd.c
SRCS+= opt_evdev.h opt_kbd.h opt_hkbd.h
SRCS+= bus_if.h device_if.h
.include <bsd.kmod.mk>