Commit Graph

26 Commits

Author SHA1 Message Date
Niclas Zeising
e38977381f Fix kern.evdev.rcpt_mask on powerpc
In r360126, I meant to have a different mask only on powerpc, not powerpc64.
Update the check to check that we're not compiling for powerpc64.

Reported by:	jhibbits
Approved by:	wulf (implicit)
MFC after:	2 weeks
X-MFC-Note:	12 only
X-MFC-With:	r360126
Differential Revision:	D24370 (followup)
2020-04-20 18:23:31 +00:00
Niclas Zeising
f8ae734005 Change kern.evdev.rcpt_mask to 12 by default
Change kern.evdev.rcpt_mask from 3 to 12 by default.  This makes us much
more evdev-friendly, and will prevent everyone using xorg and wayland with
evdev devices (the default) from needing to change this locally.

powerpc32 still uses the old value for the keyboard part, becaues the adb
keyboard driver used there is not evdev compatible.

Reviewed by:	wulf
Approved by:	wulf
MFC after:	2 weeks
X-MFC-Note:	12 only
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D24370
2020-04-20 16:17:16 +00:00
Xin LI
5396856ee0 Use LIST_FOREACH_SAFE instead of LIST_FOREACH as we are removing
elements in the middle.

This fixes a panic when detaching USB mouse.

PR:		245732
Reviewed by:	wulf
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D24500
2020-04-19 17:28:42 +00:00
Vladimir Kondratyev
68cc053763 [evdev] Use proper mutex reference in autorepeat callout initialization.
This fixes panic occuring when evdev key autorepeat is enabled by driver
which initializes evdev with external mutex.
2020-04-13 22:06:28 +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
Vladimir Kondratyev
dd3a67a078 Fix build when EVDEV_SUPPORT is option disabled after r344494
MFC with:	344494
2019-02-24 19:31:42 +00:00
Vladimir Kondratyev
f99e7b1aed evdev: export event device properties through sysctl interface
A big security advantage of Wayland is not allowing applications to read
input devices all the time. Having /dev/input/* accessible to the user
account subverts this advantage.

libudev-devd was opening the evdev devices to detect their types (mouse,
keyboard, touchpad, etc). This don't work if /dev/input/* is inaccessible.
With the kernel exposing this information as sysctls (kern.evdev.input.*),
we can work w/o /dev/input/* access, preserving the Wayland security model.

Submitted by:		Greg V <greg@unrelenting.technology>
Reviewed by:		wulf, imp
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D18694
2019-02-24 18:47:04 +00:00
Vladimir Kondratyev
5ef2488947 evdev: disable evdev if it is invoked from KDB or panic context
This allow to prevent deadlock on entering KDB if one of evdev locks is
already taken by userspace process.

Also this change discards all but LED console events produced by KDB as
unrelated to userspace.

Tested by:	dumbbell (as part of D15070)
Objected by:	bde (as 'KDB lock an already locked mutex' problem solution)
MFC after:	1 month
2018-10-27 21:04:34 +00:00
Vladimir Kondratyev
911aed94fa evdev: remove soft context from evdev methods parameter list.
Now softc should be retrieved from struct edvev * pointer
with evdev_get_softc() helper.

wmt(4) is a sample of driver that support both KPI.

Reviewed by:	hselasky, gonzo
Differential Revision:	https://reviews.freebsd.org/D16614
2018-08-13 19:00:42 +00:00
Vladimir Kondratyev
303dbb854f evdev: Export EVDEV_SUPPORT kernel option through feature facility
Suggested by:	netchild
Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	1 week
2017-11-20 19:17:43 +00:00
Vladimir Kondratyev
37ff334548 evdev: Do not start/stop softrepeat callout if no clients attached
Reviewed by:		gonzo
Approved by:		gonzo (mentor)
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D12676
2017-11-01 22:37:43 +00:00
Vladimir Kondratyev
c6e809423f evdev: Disable value normalization and state filtering for SND events.
Some events can take sound pitch as a value so can not be represented
as binary on/off events. Tracking for on/off state is left in place
as it is a part of the evdev API.

Reviewed by:		gonzo
Approved by:		gonzo (mentor)
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D12676
2017-11-01 22:33:44 +00:00
Vladimir Kondratyev
f3f8069493 evdev: Take driver's lock in cdev write handler if necessary
Reviewed by:		gonzo
Approved by:		gonzo (mentor)
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D12676
2017-11-01 22:19:19 +00:00
Vladimir Kondratyev
233e10741a evdev: Hide "kern.evdev.rcpt_mask" sysctl if kernel is compiled
w/o EVDEV_SUPPORT as it's value has no meaning in this case.

Now presence of this sysctl can be used for discovery if evdev support
for hybrid devices is compiled into kernel or not.
Hide "kern.evdev.sysmouse_t_axis" sysctl for the same reason.

Reviewed by:		gonzo
Approved by:		gonzo (mentor)
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D12676
2017-11-01 22:09:10 +00:00
Vladimir Kondratyev
e650280282 Change my email address to wulf@FreeBSD.org in copyright headers.
Approved by:	gonzo (mentor)
MFC after:	2 weeks
2017-07-23 20:41:58 +00:00
Vladimir Kondratyev
4c0a4665b8 evdev: Macroize common locking sequences
Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	2 weeks
2017-07-23 20:35:26 +00:00
Vladimir Kondratyev
ea2e26b1ed evdev: style(9), sort headers alphabetically
Pointed out by:	bde
Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	2 weeks
2017-07-23 20:32:54 +00:00
Oleksandr Tymoshenko
4af79d4f2b [evdev] Adds evdev support to sysmouse(4) driver
For horizontal (T-axis) wheel reporting which is not supported by
sysmouse protocol kern.evdev.sysmouse_t_axis sysctl is introduced.
It can take following values:

0 - no T-axis events (default)
1 - T-axis events are originated in ums(4) driver.
2 - T-axis events are originated in psm(4) driver.

Submitted by:	Vladimir Kondratiev <wulf@cicgroup.ru>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D8597
2016-12-10 18:07:16 +00:00
Oleksandr Tymoshenko
73362d0e56 EVDEV: Add shortcut functions for event types
Add wrappers around generic evdev_push_event for specific event types:
EV_KEY/EV_REL/EV_ABS etc...

Submitted by:	Vladimir Kondratiev <wulf@cicgroup.ru>
2016-10-22 22:52:50 +00:00
Oleksandr Tymoshenko
c736a75712 Implement EVDEV_FLAG_MT_AUTOREL flag (autorelease touchpoints)
Automaticaly release (send ABS_MT_TRACKING_ID = -1) MT-slots
that has not been listed in current MT protocol type B report.

Slot is counted as listed if corresponding ABS_MT_SLOT event
has been sent regardless of other MT events.

Events are sent on SYN_REPORT event.

Submitted by:	Vladimir Kondratiev <wulf@cicgroup.ru>
2016-10-08 17:59:53 +00:00
Oleksandr Tymoshenko
bfbd1bb744 Allow using of driver's mutex instead internal one for evdev locking.
Add new API call: evdev_register_mtx which takes lock argument that
should be used instead of internal one for evdev locking. Useful for
cases if evdev_push_event() is always called with driver's lock taken
and reduces amount of lock aquisitions. This allows to avoid LOR
between ev_open/ev_close invocations and evdev_push_event() Such LOR
can happen when ev_open/ev_close methods acquire driver lock and
evdev_push_event() is called with this lock taken.

Submitted by:	Vladimir Kondratiev <wulf@cicgroup.ru>
2016-10-08 17:58:26 +00:00
Oleksandr Tymoshenko
5163e77fad const-ify struct evdev_methods
Submitted by:	Vladimir Kondratiev <wulf@cicgroup.ru>
Suggested by:	hselasky
2016-10-03 17:20:34 +00:00
Oleksandr Tymoshenko
a6b15a3429 Modularize evdev
- Convert "options EVDEV" to "device evdev" and "device uinput", add
    modules for both new devices. They are isolated subsystems and do not
    require any compile-time changes to general kernel subsytems
- For hybrid drivers that have evdev as an optional way to deliver input
    events add option EVDEV_SUPPORT. Update all existing hybrid drivers
    to use it instead of EVDEV
- Remove no-op DECLARE_MODULE in evdev, it's not required, MODULE_VERSION
    is enough
- Add evdev module dependency to uinput

Submitted by:	Vladimir Kondratiev <wulf@cicgroup.ru>
2016-10-02 03:20:31 +00:00
Oleksandr Tymoshenko
fa26e8edee Declare a module for evdev and add dependency to ukbd(4) and ums(4)
Prepare for making evdev a module. "Pure" evdev device drivers (like
touchscreen) and evdev itself can be built as a modules regardless of
"options EVDEV" in kernel config. So if people does not require evdev
functionality in hybrid drivers like ums and ukbd they can, for instance,
kldload evdev and utouchscreen to run FreeBSD in kiosk mode.
2016-09-30 21:04:56 +00:00
Oleksandr Tymoshenko
c3f2135cfc Handle NULL argument in evdev_free
Add check for evdev argument of evdev_free being NULL. This is valid
value and should not cause crash. In this case evdev_free does nothing

Submitted by:	Vladimir Kondratiev <wulf@cicgroup.ru>
2016-09-23 18:54:08 +00:00
Oleksandr Tymoshenko
2b3f6d6650 Add evdev protocol implementation
evdev is a generic input event interface compatible with Linux
evdev API at ioctl level. It allows using unmodified (apart from
header name) input evdev drivers in Xorg, Wayland, Qt.

This commit has only generic kernel API. evdev support for individual
hardware drivers like ukbd, ums, atkbd, etc. will be committed later.

Project was started by Jakub Klama as part of GSoC 2014. Jakub's
evdev implementation was later used as a base, updated and finished
by Vladimir Kondratiev.

Submitted by:	Vladimir Kondratiev <wulf@cicgroup.ru>
Reviewed by:	adrian, hans
Differential Revision:	https://reviews.freebsd.org/D6998
2016-09-11 18:56:38 +00:00