Commit Graph

336 Commits

Author SHA1 Message Date
Warner Losh
685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh
2ff63af9b8 sys: Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:18 -06:00
Warner Losh
95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Gordon Bergling
7eb8fbfb04 psm(4): Fix a typo in a source code comment
- s/diable/disable/

MFC after:	3 days
2023-08-02 09:14:04 +02:00
Michael
971bac5ace kbd: consolidate kb interfaces (phase one)
Refactor to eliminate duplicated rate and delay tables, with minor style
tweaks for changed lines.  Remove an obsolete comment about needing to
convert from microseconds to ticks (that's done elsewhere). Remove
traiing whitespace in kbdcontrol.c.

Except for the new warning, no change in behavior

Sponsored by: 		DSS GmbH
Reviewed by:		imp [minor style tweaks as well]
Pull Request:		https://github.com/freebsd/pull/683
Differential Revision: 	https://reviews.freebsd.org/D38818
2023-07-06 23:10:18 -06:00
Warner Losh
319d2bf407 atkbc: Better test for old chromebooks
Older Chromebooks have issues in their embedded controller (EC) firmware
which need working around in atkbd and atkbdc. On these systems, rather
than use a standard EC, Google used their own arm-based EC. For a while,
its firmware incorrectly implemented the i8042, requiring workaroundsd
in the driver.

Implement a heuristic recommended by MrChromebox <mrchromebox@gmail.com>
to detect them: If the bios.version starts with Google_, or the maker is
either Google or GOOGLE, assume that it's a chromebook with the affected
bios. While this isn't strictly true, the number of updated systems
without the bug is very small and this will exclude all the non-Google
coreboot user that use a standard EC. There's no simple way to test the
hardware to see if it's implemented with the buggy EC.

Sponsored by:		Netflix
Reviewed by:		jon@thesoo.org, MrChromebox
Differential Revision:	https://reviews.freebsd.org/D40789
2023-06-29 08:34:47 -06:00
Warner Losh
31b3e4f1b4 atkbdc: Minor style nits
'char* ' -> 'char *', per style(9)

Sponsored by:		Netflix
2023-06-28 16:18:47 -06:00
Jon Hopper
599a4548f8 Adds support for Purism coreboot keyboards
On Purism coreboot systems the quirks mode in atkbdc prevents built in
Keyboard from being used. Add quirk to prevent that.

MFC After:		2 weeks
PR:			271737
Reviewed by:		imp
Differential Revision:	https://reviews.freebsd.org/D40405
2023-06-28 11:19:24 -06:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Warner Losh
cd29688e8e kbdreg.h: include opt_kbd.h
This is a kernel-only file, so it's safe to include opt_kbd.h. However,
add #ifdef _KERNEL guards to emphasize that. And also move the include
of opt_kbd.h in atkbdcreg.h to inside the kernel guards. Nothing outside
the kernel in tree uses the rest of that file, but I'm less comfortable
moving the #ifdef _KERNEL to the top of that file.

Sponsored by:		Netflix
2023-02-27 07:37:32 -07:00
Ed Maste
50fce3b4b0 atkbd: correct bogus character in #ifdef
Fixes:		f20058955c ("sys/kbio.h: make pre-unicode keymap...")
Sponsored by:	The FreeBSD Foundation
2023-02-14 11:55:52 -05:00
Stefan Eßer
f20058955c sys/kbio.h: make pre-unicode keymap support optional
FreeBSD-9 had introduced support for the full set of Unicode
characters to the parsing and processing of keymap character tables.

This support has been extended to cover the table for accented
characters that are reached via dead key combinations in FreeBSD-13.2.

New ioctls have been introduced to support both the pre-Unicode and
the Unicode formats and keyboard drivers have been extended to support
those ioctls.

This commit makes the ABI compatibility functions in the kernel
optional and dependent on COMPAT_FREEBSD13 in -CURRENT.

The kbdcontrol command in -CURRENT and 13-STABLE (before 13.2) has
been made ABI compatible with old kernels to allow a new world to be
run on an old kernel (that does not have full Unicode support for
keymaps).

This commit is not to merged back to 12-STABLE or 13-STABLE. It is
part of review D38465, which has been split into 3 separate commits
due to different MFC and life-time requirements of either commit.

Approved by:	imp
Differential Revision:	https://reviews.freebsd.org/D38465
2023-02-14 14:03:28 +01:00
Mateusz Guzik
5173c996bc psm: ansify
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-02-13 18:38:49 +00:00
Stefan Eßer
4972fb9276 Support Unicode characters in keymap dead key tables
Support for Unicode characters had been added to the keyboard code,
but there are keymaps that have accented characters accessed via dead
key combinations, and those were still restricted to 8 bit codes.

This update to kbd.c adds support for Unicode characters and
compatibility code that allows a kbdcontrol command built from kbio.h
without these patches to work on a new kernel.

Compatibility code that allows a new kbdcontrol binary running on an
old kernel to load and display the dead key map will be committed in a
separate commit.

Reviewed by:	imp, brooks
Approved by:	brooks
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38381
2023-02-06 23:48:47 +01:00
Vladimir Kondratyev
183088934a evdev: Extend EVIOCGRAB ioctl scope to cover kbd interface
of various keyboard drivers.
EVIOCGRAB ioctl execution on /dev/input/event# device node gains
exclusive access to this device to caller. It is used mostly for
development purposes and remote control software. See e.g.
https://reviews.freebsd.org/D30020 which is the reason of creation
of this change.
Keyboard grabbing is disabled in KDB and during panics.

MFC with:	4a0db5e292
Tested by:	corvink
Differential revision:	https://reviews.freebsd.org/D30542
2022-11-19 02:54:46 +03:00
Vladimir Kondratyev
4a0db5e292 evdev: Extend EVIOCGRAB ioctl scope to cover sysmouse interface
of psm(4), ums(4) and sysmouse(4) drivers.
EVIOCGRAB ioctl execution on /dev/input/event# device node gains
exclusive access to this device to caller. It is used mostly for
development purposes and remote control software. See e.g.
https://reviews.freebsd.org/D30020 which is the reason of creation
of this change.

MFC after:	2 weeks
Tested by:	corvink
Differential revision:	https://reviews.freebsd.org/D30542
2022-11-18 00:48:42 +03:00
Vladimir Kondratyev
6a26c99f82 atkbd(4): Fix "hancha" and "han/yong" korean keys handling.
The Korean keyboard has two keys, the Korean/Chinese and the
Korean/English toggles, that generate scancodes 0xF1 and 0xF2
(respectively) when pressed, and nothing when released. They do not
repeat.
As Hanyong/Hancha keys are generally greater than 0x80, which is
generally considered a release key, add extra preceding press key event
to generate press/release pair.
Swap Hanyong/Hancha key codes to match reality.

Reported by:	Warioburn <warioburn@yahoo.co.jp>
PR:		265260
MFC after:	1 week
2022-07-20 00:36:20 +03:00
John Baldwin
1c1e88367c atkbd/psm: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-06 15:46:58 -07:00
John Baldwin
a6c09f20e8 psm: Swap the unit member in the softc for a device_t.
This entails various changes to make this driver more "modern"
(new-bus vs pre-new-bus) using device_log() and device_printf() rather
than psm%d.  It also fixes the device_busy/unbusy calls to use sc->dev
directly rather than looking the device_t up via the devclass and
unit.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D35006
2022-04-21 13:52:48 -07:00
John Baldwin
9b0eb55048 psm: Remove write-only variables. 2022-04-06 16:45:28 -07:00
Alexander Motin
ce88117008 atkbd: Disable periodic polling by default.
It is one of the few remaining Giant-locked callouts.  It would be
good to remove it, not mentioning that polling itself is not good.

If this cause keyboard/mouse freezes on some hardware, please set
loader tunable hw.atkbd.hz=1 as workaround and report the issue.

Submitted by:	imp, jhb
2022-01-05 15:12:58 -05:00
Alexander Motin
9e007a88d6 atkbd: Reduce polling rate from 10Hz to ~1Hz.
In my understanding this is only needed to workaround lost interrupts.
I was thinking to remove it completely, but the comment about edge-
triggered interrupt may be true and needs deeper investigation.  ~1Hz
should be often enough to handle the supposedly rare loss cases, but
rare enough to not appear in top.  Add sysctl hw.atkbd.hz to tune it.

MFC after:	1 month
2022-01-05 11:41:26 -05:00
Vladimir Kondratyev
bedf31ad7e psm(4): Disable KVM switch "jitter" clamping for absolute touchpads.
r123442 introduced solution for clamping of PS/2 mice jitter when using
a KVM. Solution is to buffer mouse packets for 0.050ms if mouse activity
has not been seen for more than 0.5 seconds. Then flush that data to driver
if no validation errors found or drop the entire queue otherwise.

While it works well with relative devices it has issues with absolute ones
Depending on history buffering may results in delaying of the touch front
edge for 0.050ms that affects gesture processing (tap detection).

As absolute touchpads usually are built-in devices we can safely disable
bufferization and KVM jitter clamping to avoid such a delays.

MFC after:	2 weeks
2021-09-10 00:37:40 +03:00
Vladimir Kondratyev
744fcd5ad2 psm: Use evdev autorelease feature for Synaptics and Elantech drivers
MFC after:	2 weeks
2021-09-02 22:35:26 +03:00
Vladimir Kondratyev
c21171af68 psm: Enable touch-tracking for late Synaptics PS/2 touchpads.
They are true multitouch internally but Synaptics PS/2 protocol
limitations do not all allow to export touch identificators.

MFC after:	2 weeks
2021-09-02 22:35:26 +03:00
Vladimir Kondratyev
f5998d20ed psm(4): Probe Synaptics touchpad with active multiplexing mode enabled
if it is only multiplexed device. Also enable syncbit checks for them.
This fixes touchpad recognition on Panasonic Toughbook CF-MX4 laptop.

Reported by:	Tomasz "CeDeROM" CEDRO <tomek_AT_cedro_DOT_info>
MFC after:	1 month
PR:		253279
Differential revision:	https://reviews.freebsd.org/D28502
2021-07-14 13:30:26 +03:00
Vladimir Kondratyev
5af73ad51b evdev: Remove useless "initial value" parameter from evdev_support_abs()
It can not be used for setting of state of multitouch events.
If necessary, use evdev_push_event() instead of it.
2021-01-08 02:18:41 +03:00
Vladimir Kondratyev
2ac1c19272 psm(4): Always initialize Synaptics touchpad report range with defaults
Otherwise libinput refuses to recoginize some Synaptics touchpads with
"kernel bug: device has min == max on ABS_X" message in Xorg.log.

PR:		251149
Reported-by:	Jens Grassel <freebsd-ports@jan0sch.de>
Tested-by:	Jens Grassel <freebsd-ports@jan0sch.de>
MFC-after:	2 weeks
2020-12-23 11:10:53 +03:00
Conrad Meyer
3a52ffb8b3 atkbd(4): Just use nitems() for quirk enumeration
Reviewed by:	imp, wulf
X-MFC-With:	r368365
Differential Revision:	https://reviews.freebsd.org/D27489
2020-12-05 22:04:30 +00:00
Vladimir Kondratyev
a5cc5fcef6 atkbd(4): Change quirk table end-of-list marker to NULL vendor/maker/product
This fixes regression introduced in r367349 which effectively resulted in
truncation of quirk table.

PR:		250711
Submitted by:	grembo
Reported by:	Matthias Apitz <guru@unixarea.de>
X-MFC with:	r367349
2020-12-05 10:55:14 +00:00
Vladimir Kondratyev
b33ba83470 psm(4): Disable AUX multiplexer probing on all Lenovo laptops.
Rudimentary AUX multiplexing support was added to kernel to make possible
touchpad initialization on some HP EliteBook laptops with trackpoint.

Disable multiplexer probing on all Lenovo laptops now as they use touchpad
pass-through port rather than AUX multiplexer to connect trackpoint and
at least two model (X120e and X121e) is known for getting PS/2 AUX port
dysfunctional after switching back to hidden multiplexing mode.

AUX MUX probing can be reenabled with setting of hw.psm.mux_disabled loader
tunable to 0.

PR:		249987
Reported by:	jwb
MFC after:	2 weeks
2020-11-20 00:13:30 +00:00
Vladimir Kondratyev
07030f3362 atkbdc(4): Add quirk for "System76 lemur Pro" laptops.
Currently atkbdc(4) assumes all coreboot BIOSes belonging to Chromebooks
and unconditionally sets a number of quirks to workaround known issues.

Exclude "System76" laptops from this set as they appeared to be a
traditional hardware ("lemur Pro" is a rebranded Clevo chassis) with
coreboot firmware on board. KBDC_QUIRK_KEEP_ACTIVATED quirk activated for
Chromebook platform makes keyboard on this devices inoperable.

"Purism Librem" laptops may require the same exclusion too.

PR:		250711
Reported by:	nick.lott@gmail.com
MFC after:	2 weeks
2020-11-04 21:52:10 +00:00
Mateusz Guzik
bf479e1372 atkbdc: clean up empty lines in .c and .h files 2020-09-01 21:41:38 +00:00
Vladimir Kondratyev
ec45be6c36 [psm] Workaround active PS/2 multiplexor hang
which happens on some laptops after returning to legacy multiplexing mode
at initialization stage.

PR:		242542
Reported by:	Felix Palmen <felix@palmen-it.de>
MFC after:	1 week
2020-06-02 01:04:49 +00:00
Vladimir Kondratyev
8137fb2e38 [psm] Do not disable trackpoint when hw.psm.elantech.touchpad_off is enabled
PR:		246117
Reported by:	Alexander Sieg <ports@xanderio.de>
MFC after:	1 week
2020-06-02 00:53:39 +00:00
Vladimir Kondratyev
1130dff9d2 psm(4): Fix wrong key-release event occuring after trackpoint use.
Some models of laptops e.g. "X1 Carbon 3rd Gen Thinkpad" have LRM buttons
wired as so called "Synaptic touchpads extended buttons" rather thah real
trackpoint buttons. Handle this case with merging of events from both
sources.

PR:		245877
Reported by:	Raichoo <raichoo@googlemail.com>
MFC after:	1 week
2020-04-26 20:06:08 +00:00
Pawel Biernacki
7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2020-02-26 14:26:36 +00:00
Kyle Evans
e88f22ff04 psm: use make_dev_s instead of make_dev
This most importantly reduces duplication, but it also removes any potential
race with usage of dev->si_drv1 since it's now set prior to the device being
constructed enough to be accessible.
2020-02-04 18:45:28 +00:00
Kyle Evans
ee20e0605a psm: release resources on attach failure
In exactly 1/3 cases we'll release resources on failure; touch up the other
two to do so as well.
2020-02-04 18:29:06 +00:00
Warner Losh
58aa35d429 Remove sparc64 kernel support
Remove all sparc64 specific files
Remove all sparc64 ifdefs
Removee indireeect sparc64 ifdefs
2020-02-03 17:35:11 +00:00
Kyle Evans
6d3c9beedb psm: properly check for atkbdc_open failure
atkbdc_open can return NULL if the unit's out of bounds or the softc isn't
setup. Check it to be safe.
2019-12-31 13:56:48 +00:00
Kyle Evans
e9305818c1 atkbdc: use proper pointer type for KBDC
Proper locking for atkbdc will likely replace the kbdc_lock mechanism
entirely with a mutex in atkbdc_softc, so that other consumers can also
properly ensure locking protocol is followed (e.g. psm.c:doinitialize).

The first step to doing this neatly is making KBDC less opaque so that
others don't have to jump through weird casting hoops to address the mutex.

No functional change intended; this diff effectively just removes a bunch of
casting. A future change may remove the KBDC typedef entirely and just opt
for using `atkbdc_softc_c *` directly, but this was decidedly a good
intermediate step to make these changes simple to audit.
2019-12-25 15:55:45 +00:00
Kyle Evans
eefc662f0b kbd: provide default implementations of get_fkeystr/diag
Most keyboard drivers are using the genkbd implementations as it is;
formally use them for any that aren't set and make
genkbd_get_fkeystr/genkbd_diag private.
2019-12-16 02:44:56 +00:00
Kyle Evans
1c5c067aad keyboard switch definitions: standardize on c99 initializers
A future change will provide default implementations for some of these where
it makes sense and most of them are already using the genkbd
implementation (e.g. get_fkeystr, diag).
2019-12-16 02:05:44 +00:00
Philip Paeps
5a037b1197 Add macOS-like three finger drag trackpad gesture to psm(4)
Submitted by:	Yan Ka Chiu <nyan@myuji.xyz>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D20648
2019-06-16 03:06:05 +00:00
Niclas Zeising
2dd9a967d2 psm(4): Enable touchpads and trackpads by default
Enable synaptics and elantech touchpads, as well as IBM/Lenovo TrackPoints
by default, instead of having users find and toggle a loader tunable.
This makes things like two finger scroll and other modern features work out
of the box with X.  By enabling these settings by default, we get a better
desktop experience in X, since xserver and evdev can make use of the more
advanced synaptics and elantech features.

Reviewed by:	imp, wulf, 0mp
Approved by:	imp
Sponsored by:	B3 Init (zeising)
Differential Revision:	https://reviews.freebsd.org/D20507
2019-06-10 18:19:49 +00:00
Vladimir Kondratyev
6c53fea7d6 psm(4): Add extra sanity checks to Elantech trackpoint packet parser.
Add strict checks for unused bit states in Elantech trackpoint packet
parser to filter out spurious events produces by some hardware which
are detected as trackpoint packets. See comment on r328191 for example.

Tested by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>
2019-06-08 21:36:22 +00:00
Vladimir Kondratyev
8fa4620039 psm(4): Fix Elantech trackpoint support.
Sign bits for X and Y motion data were taken from wrong places.

PR:		238291
Reported by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>
Tested by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>
MFC after:	2 weeks
2019-06-08 21:33:34 +00:00
Vladimir Kondratyev
3b11e3b6e1 psm(4): Add natural scrolling support to sysmouse protocol
This change enables natural scrolling with two finger scroll enabled
and when user is using a trackpad (mouse and trackpoint are not affected).
Depending on trackpad model it can be activated with setting of
hw.psm.synaptics.natural_scroll or hw.psm.elantech.natural_scroll sysctl
values to 1.

Evdev protocol is not affected by this change too. Tune userland client
e.g. libinput to enable natural scrolling in that case.

Submitted by:	nyan_myuji.xyz
Reviewed by:	wulf
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D20447
2019-06-03 10:04:34 +00:00
Vladimir Kondratyev
9a554d090c psm(4): Add Elantech touchpad IC type 15 found on Thinkpad L480 laptops
PR:		238291
Submitted by:	Andrey Kosachenko <andrey.kosachenko@gmail.com>
MFC after:	2 weeks
2019-06-02 22:27:26 +00:00