Commit Graph

69 Commits

Author SHA1 Message Date
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
Brooks Davis
45b48cbc2b usb: real freebsd32 support for most ioctls
Use thunks or alternative access methods to support ioctls without
the COMPAT_32BIT hacks that store pointers in uint64_t's on 32-bit
platforms.  This should allow a normal i386 libusb to work.

On CheriBSD, the sizes of the structs will differ between CheriABI
(the default) and freebsd64 no matter what so we need proper compat
support there.  This change paves the way.

Reviewed by:	hselasky, jrtc27 (prior version)
2021-12-17 21:28:13 +00:00
Warner Losh
d14bc7230b newbus: add bus_topo_assert
Add bus_topo_assert() and implmement it as GIANT_REQUIRED for the
moment. This will allow us to change more easily to a newbus-specific
lock int he future.

Sponsored by:		Netflix
Reviewed by:		wulf, mav, jhb
Differential Revision:	https://reviews.freebsd.org/D31833
2021-12-09 17:04:57 -07:00
Vladimir Kondratyev
38d2e9314b hkbd(4): Fix build on 32bit platforms
MFC after:	2 weeks
2021-09-10 01:51:25 +03:00
Vladimir Kondratyev
598f0580f6 hkbd(4): Fix key repeats on multireport keyboards
Currently hkbd counts all key states to be "Up" at the start of
interrupt callback. That results in generation of "Key Up" event for
each key that has been downed before but is not listed in current
report while is still downed.

Fix that with clearing of temporary key data storage bits only for
keys contained in processed report.

Reported by:	Greg V
Obtained from:	sysutils/iichid
MFC after:	2 weeks
2021-09-10 00:40:13 +03:00
Vladimir Kondratyev
04918395f1 hkbd(4): Use bitstring(3) KPI for key bitmaps processing.
No functional changes intended.

MFC after:	2 weeks
2021-09-10 00:39:46 +03:00
Vladimir Kondratyev
3ef9023f93 hkbd(4): Reduce diff with ukbd(4)
MFC after:	2 weeks
2021-09-10 00:39:05 +03:00
Mateusz Guzik
007724cbca hpen(4): removed leftover hpen_final_digi_cb declaration 2021-09-05 17:31:34 +00:00
Vladimir Kondratyev
9d04336b61 hmt(4): Add support for touchpads with no "button type" or
"maximum number of contacts" usages.

Assume touchpad to be a clickpad if it has only internal button.
Set number of contacts to 5 for touchpads and to 10 for touchscreens.
Check for fetched report length to avoid reading of stalled data.
Fixes Dell Precision 7550 laptop.

Tested by:	Shawn Webb <shawn.webb_AT_hardenedbsd_DOT_org>
PR:		257992
MFC after:	2 week
2021-09-02 22:35:27 +03:00
Vladimir Kondratyev
a36bdfc2b6 hpen(4): Add support for legacy MS-compatible single touch protocol
It is used by many pre- and post- 2014 eGalax touchscreens.

Tested by:	Mark Kane <mark_AT_kane_DOT_mn>
MFC after:	2 week
2021-09-02 22:35:27 +03:00
Vladimir Kondratyev
d51e437669 hidbus(4): Add routine to check presence of collection of given usage
MFC after:	2 week
2021-09-02 22:35:27 +03:00
Vladimir Kondratyev
bbed4b41c9 hidmap: Do not forget to initialize bitmap items to unset state
MFC after:	2 week
2021-09-02 22:35:27 +03:00
Vladimir Kondratyev
cded1fdb37 hidmap: Implement forbidden flag for hidmap item.
If HID usage is mapped to evdev event by hidmap item marked with this
flag than entire driver attachment is blocked.

MFC after:	2 week
2021-09-02 22:35:27 +03:00
Vladimir Kondratyev
0075742d18 hmt(4): Add support for serial packet reporting mode
In Serial mode, each packet contains information that describes a
single physical contact point. Multiple contacts are streamed
serially. In this mode, devices report all contact information in a
series of packets. The device sends a separate packet for each
concurrent contact.

Serial packet reporting mode is used by post-2014 eGalax touchscreens.

Tested by:	Mark Kane <mark_AT_kane_DOT_mn>
MFC after:	2 weeks
2021-09-02 22:35:27 +03:00
Vladimir Kondratyev
9d8ebe5ea1 hmt(4): Adapt to recent KPI changes
MFC after:	2 weeks
2021-09-02 22:35:26 +03:00
Vladimir Kondratyev
9b78891df1 hms(4): Allow attachment to pointer top level collection.
to be in line with Microsoft mouse driver [1]

[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/top-level-collections-opened-by-windows-for-system-use

MFC after:	1 week
2021-08-16 23:24:05 +03:00
Vladimir Kondratyev
9b2b5f42b4 ps4dshock(4): Fix touchpad width in HID report descriptor
MFC after:	1 week
2021-08-16 23:24:05 +03:00
Greg V
51b2216114 hid: move proper hat switch handling from ps4dshock to hgame
Generic "DirectInput" HID gamepads need this handling too.

Reviewed by:	wulf
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31398
2021-08-16 23:24:05 +03:00
Jack
cb910670ac hmt(4): Do not ignore constant usages in HID report descriptor parser
This fixes hmt to work with MELF0411 1FD2:7012 touchscreen

Obtained from:	sysutils/iichid
MFC after:	1 week
2021-08-16 23:24:05 +03:00
Vladimir Kondratyev
be75951af1 hid: Add extra constant to units of measurement
Some devices like eGalax touchscreens use value of 0x33 instead of 0x13
for inches as unit of measure.

Reported by:	Mark Kane <mark_AT_kane_DOT_mn>
MFC after:	1 week
2021-08-16 23:13:24 +03:00
Vladimir Kondratyev
95add157e3 hmt(4): Store Contact Count in separate variable.
No functional changes.

MFC after:	1 week
2021-08-16 23:11:36 +03:00
Gordon Bergling
4b4850aefe hms(4): Fix a typo in sysctl description
- s/threshhold/threshold/

MFC after:	3 days
2021-08-12 15:37:47 +02:00
Warner Losh
ddfc9c4c59 newbus: Move from bus_child_{pnpinfo,location}_src to bus_child_{pnpinfo,location} with sbuf
Now that the upper layers all go through a layer to tie into these
information functions that translates an sbuf into char * and len. The
current interface suffers issues of what to do in cases of truncation,
etc. Instead, migrate all these functions to using struct sbuf and these
issues go away. The caller is also in charge of any memory allocation
and/or expansion that's needed during this process.

Create a bus_generic_child_{pnpinfo,location} and make it default. It
just returns success. This is for those busses that have no information
for these items. Migrate the now-empty routines to using this as
appropriate.

Document these new interfaces with man pages, and oversight from before.

Reviewed by:		jhb, bcr
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D29937
2021-06-22 20:52:06 -06:00
Vladimir Kondratyev
9aa0e5af75 usbhid(4): Add second set of USB transfers to work in polled mode.
The second set of USB transfer is requested by hkbd(4) and
should improve HID keyboard handling in kdb and panic contexts.

MFC after:	1 week
Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D30486
2021-05-28 23:29:42 +03:00
Vladimir Kondratyev
e68d76c054 hkbd: Fix typo which disables keyboard input in kdb
Reported by:	Greg V
MFC after:	1 week
2021-04-24 22:01:14 +03:00
Vladimir Kondratyev
6241b57131 hid: add opt_hid.h to modules that use HID_DEBUG
Submitted by:	Greg V <greg_AT_unrelenting_DOT_technology>
Reviewed by:	imp, wulf
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D28995
2021-03-04 01:43:29 +03:00
Vladimir Kondratyev
f988d7fa05 hidraw: Make HIDIOCGRDESCSIZE ioctl return report descriptor size
defined by hardware rather than cached one to match HIDIOCGRDESC ioctl.
This fixes errors reported by hid-tools being run against /dev/hidraw#
device node belonging to driver which overloads report descriptor.

MFC after:	1 week
2021-02-13 21:19:02 +03:00
Vladimir Kondratyev
812c59ed61 hkbd: Fix handling of keyboard ErrorRollOver reports
Ignore fantom keyboard state reports entirelly rather than ignore
RollOver states for each key separatelly.  Latter results in spurious
release/push pairs of events on each fantom keyboard state report.

Reported by:	Jan Martin Mikkelsen <janm_AT_transactionware_DOT_com>
Submitted by:	Jan Martin Mikkelsen (initial version)
PR:		253249
MFC after:	1 week
2021-02-13 21:18:07 +03:00
Warner Losh
db2f512381 hid: bump HID_ITEM_MAXUSAGES to 8
My YOGA requires a minimum of 7 to parse w/o an error. Since the memory savings
are trivial and the yoga a popular system, bump the default up to 8. There's no
API/ABI issues in doing this. This hid_item struct isn't exported to userland
and the one libusbhid has is different and only shares a name...

MFC After: 3 days
Reviewed by: wulf@
Differential Revision: https://reviews.freebsd.org/D28543
2021-02-08 15:31:39 -07:00
Vladimir Kondratyev
5cc21ab994 hmt: Allow I2C sampling mode support to be compiled out. 2021-01-20 23:10:07 +03:00
Vladimir Kondratyev
3e954a8bc6 hms: Workaround idle mouse drift in I2C sampling mode.
Many I2C "compatibility" mouse devices found on touchpads continue to
return last report data in sampling mode after touch has been ended.
That results in cursor drift.  Filter out such a reports with comparing
content of current report with content of previous one.

Reported by:	many
Tested by:	omatsuda, gllb (github.com)
Obtained from:	sysutils/iichid
2021-01-20 23:10:07 +03:00
Vladimir Kondratyev
fa656aefe4 hconf(4): Do not fetch report before writing new usage values back.
There is a report that reading of surface/button switch feature report
causes SYN1B7D touchpad malfunction.  As specs does not require it to
be readable assume that report usages have default value on attach and
last written value during operation. Do not apply default usage values
on attachment and resume.
While here fix manpage typos and add avg@ to copyright header.

Reported by:	Jakob Alvermark <jakob_AT_alvermark_DOT_net>
Reviewed by:	avg
Differential revision:	https://reviews.freebsd.org/D28196
2021-01-20 23:10:06 +03:00
Vladimir Kondratyev
b360682ac9 hid: Add missing input enter/exit epoch pairs.
This was affecting unloading keyboard driver and kdb-related code.
2021-01-14 23:04:47 +03:00
Ryan Libby
16079c7233 hid: quiet -Wswitch
Gcc builds complained that not all switch cases are handled.  Add
default cases to appease gcc.

Reviewed by:	hselasky (previous version), wulf
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D28082
2021-01-10 21:53:15 -08:00