Commit graph

102 commits

Author SHA1 Message Date
Mark Johnston 3f795763e4 hidbus: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Zhenlei Huang 4eb82e65a7 hidbus(4): Fix wrong assertion of bus
Reviewed by:	wulf
Fixes:		4151ac9f12 hidbus(4): Use generic hid methods to ...
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D45496
2024-06-05 20:03:27 +08:00
Vladimir Kondratyev 9097284b98 bcm5974(4): Properly assign MT-slot on Apple Magic Trackpad
Assign multi-touch slot number based on internal evdev MT state and
reported tracking ID of contact rather than on sequentional number of
contact in report.

Sponsored by:	Serenity Cyber Security
Fixes:		ef8397c28e ("add Magic Trackpad 2 (USB only) support")
MFC after:	1 month
2024-02-21 23:31:39 +03:00
Vladimir Kondratyev 4f34598970 bcm5974(4): Respect HID_DEBUG option and fix debugging printf
Sponsored by:	Serenity Cyber Security
MFC after:	1 month
2024-02-21 23:31:39 +03:00
Vladimir Kondratyev c85e6a5c22 bcm5974(4): Report proper width and depth for Apple Magic Trackpads
The size of modern Apple Magic Trackpad is about 160x110mm

Sponsored by:	Serenity Cyber Security
MFC after:	1 month
2024-02-21 23:31:38 +03:00
Mark Johnston e452fa70d5 hid: Handle errors from copyin() in ioctl handlers
If copyin() fails, the driver will proceed blindly with a zeroed buffer,
which is not what we want.  In preparation for annotating copyin() with
__result_use_check, start checking for errors.

Reviewed by:	wulf
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43102
2023-12-25 21:04:00 -05:00
Warner Losh fdafd315ad sys: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Vladimir Kondratyev 1d46c8e5c2 hmt(4): Do not require input report HID usages to be a member of TLC
Some touchpads places button usages (in HID report descriptor) in to
the 2-nd level collection rather than in to the top level one. That
confuses current code. Remove collection level check in HID report
descriptor parser to fix device detection.

Reported by:	Peter Much <pmc@citylink.dinoex.sub.org>
PR:		267094
MFC after:	1 week
2023-11-02 09:20:20 +03:00
Val Packett 64fbda90da Add atopcase, the Apple HID over SPI input driver
The driver provides support for Human Interface Devices (HID) on
Serial Peripheral Interface (SPI) buses on Apple Intel Macs
produced in 2015-2018.

The driver appears to work more stable after installation of Darwin OSI
in acpi(4) driver.
To install Darwin OSI insert following lines into /boot/loader.conf:

hw.acpi.install_interface="Darwin"
hw.acpi.remove_interface="Windows 2009, Windows 2012"

Reviewed by:	wulf
Differential revision:	https://reviews.freebsd.org/D39863
2023-08-20 12:53:32 +03:00
Val Packett 1c4edee342 bcm5974(4): add support for devices attached over SPI bus
Reviewed by:	wulf
2023-08-20 12:53:32 +03:00
Warner Losh 031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06:00
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 71625ec9ad sys: Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:24 -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
Vladimir Kondratyev f1d955be2a hidraw(4): Implement HIDRAW_GET_DEVICEINFO ioctl
In commit c77bfaa750 uhid(4) gained support for ioctl from
USB_GET_DEVICEINFO. This is used in libraries like libfido2 to
retrieve information about a device.

This commit adds binary compatible version to hidraw(4).

PR:		264843
MFC after:	1 month
Requested by:	grembo
2023-08-06 14:51:08 +03:00
Vladimir Kondratyev 4151ac9f12 hidbus(4): Use generic hid methods to start and stop interrupts 2023-08-03 19:10:50 +03:00
Vladimir Kondratyev 4b1712817e hid: Add child device parameter to HID methods
Some devices like Apple HID-over-SPI may contain more than one report
descriptors necessitating creation of multiple hidbus children.
Add indentificator of child devices to distinct them.
No functional changes intended.

Differential Revision:	https://reviews.freebsd.org/D41246
2023-08-03 19:10:50 +03: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 b61a573019 spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD 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:04 -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
Vladimir Kondratyev 19c804b74f bcm5974(4): Make Magic Trackpad 2 support endian-safe.
While here make touch orientation event matching with Linux

MFC after:	1 month
2023-04-25 12:20:53 +03:00
Val Packett ef8397c28e bcm5974(4): add Magic Trackpad 2 (USB only) support
The MT2 uses a compact report format, but otherwise is similar in many
ways to the internal trackpads, it even uses the same mode switching
commands.

Reviewed by:	wulf
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D34437
2023-04-25 12:20:53 +03:00
Hu Shunchao 6ed3b9ca25 hid: fix typo in hid_is_collection
hid_input is equal to 0. It is leftover from NetBSD code.

Reviewed by:	hselasky, wulf
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D28149
2023-04-24 14:17:51 +03:00
Val Packett 176939bd36 bcm5974: fix wellspring9 pressure settings to handle force sensitivity
Reviewed by:	wulf
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D34435
2023-04-24 12:41:52 +03: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
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
Aymeric Wibo 8d5fef85f0 ietp(4): Load dummy HID report descriptor if mangled
Some Elantech trackpads have a mangled HID report descriptor, which
reads as having an incorrect input size (i.e. < IETP_REPORT_LEN_LO).
If the input size is incorrect, load a dummy report descriptor.

Reviewed by:	wulf
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38387
2023-02-05 18:32:08 +03:00
Yuri e4d3f1e40a hv_hid: Hyper-V HID driver
Hyper-V HID driver using hidbus/hms.

Reviewed by:	wulf
MFC after:	1 week
PR:		221074
Differential revision:	https://reviews.freebsd.org/D38140
2023-02-05 18:32:08 +03:00
Yuri 6f7b5d5d3c hms(4): Fix a copy/paste issue and check both _X and _Y
instead of checking _X 2 times.

Reviewed by:	wulf
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D38135
2023-01-20 23:29:53 +03:00
Val Packett 0b4531511e copyright: chase my name and email change
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37945
2023-01-06 15:28:42 -05:00
Vladimir Kondratyev 1522062bad hidraw(4): Drop unneeded usb kernel module dependency
HID is not a part of usb subsystem for a while.

MFC after:	2 weeks
2022-12-30 18:24:53 +03:00
Vladimir Kondratyev 7c4c5368ae hidraw(4): Replace Giant with bus_topo_lock 2022-12-24 12:51:13 +03:00
Vladimir Kondratyev 0661cf74e6 hms(4): Disable vendor usage page button support
for all devices except Kensington Slimblade Trackball as it brokes
some other devices like Contour Rollermouse Red

Add a quirk for it as well.

Reported by:	Atte Peltomäki <koston_AT_iki_DOT_fi>
PR:		267922
MFC after:	2 weeks
2022-12-24 12:01:20 +03: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
Gordon Bergling f76a02886c hid: Remove a double word in a source code comment
- s/the the/the/

MFC after:	3 days
2022-09-04 13:45:50 +02:00
Hans Petter Selasky c019a1690b hidbus(4): Align refcount checks for hidbus_intr_start() and hidbus_intr_stop().
No functional change intended.

Discussed with:	wulf @
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-07-28 21:28:36 +02:00
Michael Gmelin ed87ff4e95 hidraw: Return string lengths for certain ioctls
Make HIDIOCGRAWPHYS, HIDIOCGRAWNAME, and HIDIOCGRAWUNIQ return
the length of the copied out string (including the trailing NUL
character), so they behave like their Linux hidraw counterparts.

Reviewed by:	wulf
Differential Revision:	https://reviews.freebsd.org/D35233
2022-05-18 12:12:19 +02:00
John Baldwin 7eeede1586 hid: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-06 15:46:57 -07:00
John Baldwin a4777bb437 Remove unused hidraw_devclass. 2022-05-06 15:46:57 -07:00
John Baldwin e9d92100c7 hidbus: Use devclass_find to lookup the devclass for hidbus.
Reviewed by:	wulf, imp
Differential Revision:	https://reviews.freebsd.org/D35000
2022-04-21 10:29:14 -07:00
Warner Losh 92ec9782ac hpen_battery_strenght_cb: eliminate write only data variable
Sponsored by:		Netflix
2022-04-04 22:29:31 -06:00
Gordon Bergling 9094c3a71b usb(3): Fix a few typos in source code comments
- s/paniced/panicked/

MFC after:	3 days
2022-04-02 10:14:32 +02:00
Greg V 45b6c31a38 bcm5974(4): set mode again on resume
This is necessary to not break SPI devices on suspend-resume.

Reviewed by:    wulf
MFC with:       5aa839c9e2
Differential revision:  https://reviews.freebsd.org/D34434
2022-03-08 15:51:07 +03:00
Greg V fda9ac06aa bcm5974(4): fix endian conversion signedness bug
This fixes wrong coordinates resulting in weird behavior.

Reviewed by:	wulf
MFC with:	5aa839c9e2
Differential revision:	https://reviews.freebsd.org/D34433
2022-03-08 15:51:06 +03:00
Vladimir Kondratyev 42e2a173c7 hms(4): Change probe priority to BUS_PROBE_GENERIC
to give ietp(4) and bcm5974(4) drivers precedence over hms(4).

MFC after:	2 month
2022-03-03 02:35:24 +03:00
Vladimir Kondratyev d5add41d4d ietp(4): Driver for Elantech I2C touchpad
MFC after:	2 month
Tested by:	Matt Daw <matt.daw_AT_gmail_DOT_com>
2022-03-03 02:35:24 +03:00
Vladimir Kondratyev 5aa839c9e2 bcm5974: wsp(4) driver version with HID attachment.
MFC after:	2 month
Tested by:	Greg V (Type 4 touchpads)
2022-03-03 02:35:23 +03:00
Vladimir Kondratyev 5f47c5a3a3 hid: Add hid_ioctl method to HID interface
hid_ioctl method executes arbitrary transport backend command.
Format of the command is defined by hardware transport driver.

It is intended to assist HID device drivers to execute non-HID commands
on hybrid devices like Elan and Apple touchpads which can be switched
between HID and proprietary modes.

MFC after:	2 month
2022-03-03 02:35:23 +03:00
Hans Petter Selasky 34077a8ed3 usb(4): Fix build after 45b48cbc2b.
Make sure local variable is initialized when COMPAT_32BIT is not defined.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2021-12-18 21:31:03 +01:00
Brooks Davis ea972feea2 usb: remove COMPAT_32BIT ifdefs
Now that we have proper 32-bit compat support, remove COMPAT_32BIT
ifdefs to allow 32-bit code to use the 64-bit layout of USB ioctl
structs and struct usb_fs_endpoint.

This includes the removal of redundant alignment directives that had
no effect in practice.

Reviewed by:	hselasky, jrtc27 (prior version)
2021-12-17 21:28:39 +00:00