Commit Graph

272 Commits

Author SHA1 Message Date
Brooks Davis
6469bdcdb6 Move most of the contents of opt_compat.h to opt_global.h.
opt_compat.h is mentioned in nearly 180 files. In-progress network
driver compabibility improvements may add over 100 more so this is
closer to "just about everywhere" than "only some files" per the
guidance in sys/conf/options.

Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
sys/compat/linux/*.c.  A fake _COMPAT_LINUX option ensure opt_compat.h
is created on all architectures.

Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
set of compiled files.

Reviewed by:	kib, cem, jhb, jtl
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14941
2018-04-06 17:35:35 +00:00
Conrad Meyer
015ab09843 psm(4): Initialize variables before use
dxp/dyp could have been used uninitialized in the subsequent debugging log
invocation.

Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
2018-03-06 20:31:14 +00:00
Conrad Meyer
893daee680 psm(4): Always initialize used values in debug print
'status' array passed to get_mouse_status() is usually uninitialized by
callers.

Fully populating it with values in get_mouse_status() can fail due to
read_aux_data().

Additionally, nothing in API constrains 'len' to be >= 3.  In practice,
every caller passes three, so perhaps that argument should just be removed.
Refactoring is a larger change, though.

Remove use of potentially uninitialized values by:
1. Only printing 3 debug statuses if the passed array was at least
   'len' >= 3;
2. Populating 'status' array up to first three elements, if read_aux_data()
   failed.

No functional change intended.

Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
2018-03-01 00:58:59 +00:00
Vladimir Kondratyev
74a53bd131 psm(4): Fix panic occuring soon after PS/2 packet has been rejected by
synaptics or elantech sanity checker.

After packet has been rejected contents of packet buffer is not cleared
with setting of inputbytes counter to 0. So when this packet buffer is
filled again being an element of circular queue, new data appends to old
data rather than overwrites it. This leads to packet buffer overflow
after 10 rounds.

Fix it with setting of packet's inputbytes counter to 0 after rejection.

While here add extra logging of rejected packets.

PR:		222667 (for reference)
Reported by:	Neel Chauhan <neel@neelc.org>
Tested by:	Neel Chauhan <neel@neelc.org>
MFC after:	1 week
2018-02-04 23:01:48 +00:00
Vladimir Kondratyev
f20ad0fa5b psm: Add a kludge to support 0x46 identity middle byte Synaptics touchpads
Most synaptics touchpads return 0x47 in middle byte in responce to identify
command as stated in p.4.4 of "Synaptics PS/2 TouchPad Interfacing Guide".
But some devices e.g. found on HP EliteBook 9470m return 0x46 here.
Allow them to be identified as Synaptics as well as 0x47.
ExtendedQueries return incorrect data on such a touchpads so we ignore
their result and set conservative defaults.

PR:		222667
Reported by:	Neel Chauhan <neel@neelc.org>
Tested by:	Neel Chauhan <neel@neelc.org>
Approved by:	gonzo
2018-01-31 22:17:52 +00:00
Vladimir Kondratyev
f451e00544 psm(4): Reduce psm watchdog verbosity
Modern touchpads do not issue interrupts on inactivity so "lost interrupt"
message became annoying spam nowadays. This change quiets the message
if debug.psm.loglevel=5 (or less) is set in /boot/loader.conf

Approved by:	gonzo
2018-01-31 21:46:37 +00:00
Vladimir Kondratyev
7d1460a4b1 psm(4): Add support for HP EliteBook 1040 ForcePads.
ForcePads do not have any physical buttons, instead they detect click
based on finger pressure. Forcepads erroneously report button click
if there are 2 or more fingers on the touchpad breaking multifinger
gestures. To workaround this start reporting a click only after
4 consecutive single touch packets has been received. Skip these packets
in case more contacts appear.

PR:		223369
Reported by:	Neel Chauhan <neel@neelc.org>
Tested by:	Neel Chauhan <neel@neelc.org>
Reviewed by:	gonzo
Approved by:	gonzo
2018-01-31 21:14:59 +00:00
Warner Losh
d6b6639713 Add ISA PNP tables to ISA drivers. Fix a few incidental comments.
ACPI ISA PBP tables not tagged, there's bigger issues with them.
2018-01-29 00:22:30 +00:00
Jean-Sébastien Pédron
90b0eb9b4a psm: Log syncmask[1], not syncmask[0] twice
MFC after:	1 week
2018-01-20 19:04:21 +00:00
Jean-Sébastien Pédron
b9b766ae47 psm: Don't try to detect trackpoint packets if the Elantech device has none
This fixes a panic when `EVDEV_SUPPORT` is enabled: if a trackpoint
packet was detected but there was no trackpoint, we still tried to emit an
evdev event even though the associated relative evdev device (`evdev_r`)
was not initialized.

PR:		225339
MFC after:	1 week
2018-01-20 11:21:22 +00:00
Jean-Sébastien Pédron
9402bd96df psm: Skip sync check when PSM_CONFIG_NOCHECKSYNC is set
In psmprobe(), we set the initial `syncmask` to the vendor default value
if the `PSM_CONFIG_NOCHECKSYNC` bit is unset. However, we currently only
set it for the Elantech touchpad later in psmattach(), thus `syncmask`
is always configured.

Now, we check `PSM_CONFIG_NOCHECKSYNC` and skip sync check if it is set.
This fixes Elantech touchpad support for units which have `hascrc` set.

To clarify that, when we log the `syncmask` and `syncbits` fields, also
mention if they are actually used.

Finally, when we set `PSM_CONFIG_NOCHECKSYNC`, clear `PSM_NEED_SYNCBITS`
flag.

PR:		225338
MFC after:	1 week
2018-01-20 11:02:18 +00:00
Warner Losh
5fe4723c70 Create a new ISA_PNP_INFO macro. Use this macro every where we have
ISA PNP card support (replace by hand version in if_ed). Move module
declarations to the end of some files. Fix PCCARD_PNP_INFO to use
nitems(). Remove some stale comments about pc98, turns out the comment
was simply wrong.
2017-12-23 06:49:27 +00:00
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Vladimir Kondratyev
8352f326c3 psm(4): Add sanity checks to Synaptics touchpad driver resolution parser.
This fixes "Kernel has only x or y resolution, not both" libinput error.

Reported by:	Ivan <bsd@abinet.ru>
Tested by:	Ivan <bsd@abinet.ru>
Approved by:	gonzo (mentor)
MFC after:	2 weeks
2017-10-19 21:07:28 +00:00
Vladimir Kondratyev
0f78004261 psm: add support for evdev protocol
Both relative and absolute multitouch modes are supported.
To enable psm(4) evdev support one should:
1. Add `device evdev` and `options EVDEV_SUPPORT` to kernel config file
2. Add hw.psm.elantech_support=1 or hw.psm.synaptics_support=1 to
   /boot/loader.conf for activation of absolute mode on touchpads
3. Add kern.evdev.rcpt_mask=12 to /etc/sysctl.conf to enable psm event
   sourcing and disable sysmouse

Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10265
Tested by:	wulf, Jan Kokemueller (Lenovo devs)
2017-05-29 20:43:00 +00:00
Vladimir Kondratyev
ae3b1e4a34 Reduce synaptics touch sensitivity
Increase hw.psm.synaptics.min_pressure default value from 16 to 32
to nearly match Linux driver (30-35 hysteresis loop).
This makes libinput tap detection more reliable.

Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	2 weeks
2017-05-04 23:19:27 +00:00
Vladimir Kondratyev
bc2b1516be psm(4): Remove sys/libkern.h header inclusion
It is already included via sys/systm.h

Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10266
2017-05-04 23:17:21 +00:00
Vladimir Kondratyev
21cb8f6288 Set predefined logical touchpad sizes for several ancient Elan hw v.2
models. This change is based on Linux driver.
Determine logical trace size. It used for calculation of touch sizes
in surface units for MT-protocol type B evdev reports.

Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10266
2017-05-04 23:12:45 +00:00
Vladimir Kondratyev
6c85d7cb32 Report 3-rd and 4-th fingers as first finger for Elan hw v.2 and v.3 as
Linux does. It should not affect gesture processing in current state as it
ignores finger coords on 3-finger tap detection but it should make evdev
reports looking more Linux-alike.

Reviewed by:	gonzo
Approved by:	gonzo
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10266
2017-05-04 23:08:55 +00:00
Vladimir Kondratyev
eb65854355 Enable palm detection on two finger touches for multitouch trackpads.
Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10266
2017-05-04 23:04:52 +00:00
Vladimir Kondratyev
848714bcb4 psm(4): reduce cursor jumping on palm detection
This is done with discarding pointer movements rather then mouse packets

Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10266
2017-05-04 23:02:34 +00:00
Vladimir Kondratyev
8a98c8c412 Adjust Elantech palm width threshold to nearly match synaptics defaults
Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10266
2017-05-04 22:53:45 +00:00
Vladimir Kondratyev
51de77dd3d Reduce default tap_min_queue size for Elan touchpads
Elan hw v.4 touchpads often sends touchpad release packet right after
touchpad touch one. Most probably this happens due to PS/2 limited bandwith.
Reducing of tap_min_queue size to 1 makes multifinger tap detection
more reliable in this case.

Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10266
2017-05-04 22:51:22 +00:00
Vladimir Kondratyev
933ef2d3b2 Fix triple-finger taps reported as double-finger for Elan hw v.4 touchpads
Wait for all advertised head packets after status packet have been received.
This fixes rare but quite annoying issue in Elan hw v.4 touchpads support
when triple-finger taps are reported as double-finger taps under several
circumstances.

Reviewed by:	gonzo
Approved by:	gonzo (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D10266
2017-05-04 22:47:18 +00:00
Oleksandr Tymoshenko
f3bae0ea25 [psm] Fix calculation for clickpad softbuttons at the top
On laptops like the ThinkPad X240, ClickPad buttons are located at the
top. The hw.psm.synaptics.softbuttons_y sysctl was supposed to allow this
by setting the value to a negative one (e.g. -1700). However, the
condition was wrong (double negative), and doing that placed the buttons
in an unreachable area.

PR:		216342
Submitted by:	Greg V <greg@unrelenting.technology>
MFC after:	1 week
2017-02-15 02:52:43 +00:00
Oleksandr Tymoshenko
38ae0c59b9 [evdev] Add evdev support to atkbd(4) driver
To enable event sourcing from atkbd kern.evdev.rcpt_mask value
should have bit 3 set.

Submitted by:	Vladimir Kondratiev <wulf@cicgroup.ru>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D8381
2016-11-03 00:56:59 +00:00
Oleksandr Tymoshenko
dcc414b888 [psm] Fix choosing wrong mode for synaptic device + trackpoint
With guest trackpoint present trackpoint probing switched synaptics
device to absolute mode with different protocol instead of keeping it
in relative mode.

PR:		213757
Submitted by:	Vladimir Kondratyev <wulf@cicgroup.ru>
MFC after:	1 week
2016-11-02 01:27:20 +00:00
Warner Losh
013da020e2 Assume all coreboot BIOSes have the need for these workarounds because
coreboot implements the keyboard controller and it's common to all
Chromebooks. The workaround won't hurt and may help.
2016-10-17 04:07:12 +00:00
Oleksandr Tymoshenko
0901b57792 Fix extended buttons support on synaptic clickpad
Fix regression introduced by r306355 on synaptic clickpads with
extended buttons (buttons stopped working)

PR:		205690
Submitted by:	Vladimir Kondratyev <wulf@cicgroup.ru>
2016-10-06 01:01:00 +00:00
Gleb Smirnoff
37d0ac15e6 Fix indentation.
CID:	1363671
2016-10-04 16:44:40 +00:00
Oleksandr Tymoshenko
da464e7181 Replace explicit TUNABLE_INT to sysctl with CTLFLAG_TUN
- Replace tunables-only hw.psm.synaptics_support, hw.psm.trackpoint_support,
    and hw.psm.elantech_support with respective sysctls declared with
    CTLFLAG_TUN. It simplifies checking them in userland, also makes them
    easier to get discovered by user
- Get rid of debug.psm.loglevel and hw.psm.tap_enabled TUNABLE_INT
    declaration by adding CTLFLAG_TUN to read/write sysctls that were
    already declared for these tunables.

Suggested by: jhb
2016-09-30 03:03:42 +00:00
Oleksandr Tymoshenko
0fe98e8f2c Add Elantech trackpad support
Elantech trackpads are found in some laptops like the Asus UX31E. They
are "synaptics compatible" but use a slightly different protocol.

Elantech hardware support is not enabled by default and just like
Synaptic or TrackPoint devices it should be enabled by setting
tunable, in this case hw.psm.elantech_support, to non-zero value

PR:		205690
Submitted by:	Vladimir Kondratyev <wulf@cicgroup.ru>
MFC after:	1 week
2016-09-26 22:06:19 +00:00
Oleksandr Tymoshenko
14131c0ba4 Use OF_prop_free instead of direct call to free(9)
Reviewed by:	marius
2016-05-18 23:39:31 +00:00
Pedro F. Giffuni
453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Pedro F. Giffuni
73a1170a8c sys/dev: use our nitems() macro when it is avaliable through param.h.
No functional change, only trivial cases are done in this sweep,
Drivers that can get further enhancements will be done independently.

Discussed in:	freebsd-current
2016-04-19 23:37:24 +00:00
Justin Hibbits
da1b038af9 Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.
On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit.  This extends rman's resources to uintmax_t.  With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).

Why uintmax_t and not something machine dependent, or uint64_t?  Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures.  64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead.  That being said, uintmax_t was chosen for source
clarity.  If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros.  Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros.  Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.

Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)

Tested PAE and devinfo on virtualbox (live CD)

Special thanks to bz for his testing on ARM.

Reviewed By: bz, jhb (previous)
Relnotes:	Yes
Sponsored by:	Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544
2016-03-18 01:28:41 +00:00
Justin Hibbits
2dd1bdf183 Convert rman to use rman_res_t instead of u_long
Summary:
Migrate to using the semi-opaque type rman_res_t to specify rman resources.  For
now, this is still compatible with u_long.

This is step one in migrating rman to use uintmax_t for resources instead of
u_long.

Going forward, this could feasibly be used to specify architecture-specific
definitions of resource ranges, rather than baking a specific integer type into
the API.

This change has been broken out to facilitate MFC'ing drivers back to 10 without
breaking ABI.

Reviewed By: jhb
Sponsored by:	Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5075
2016-01-27 02:23:54 +00:00
Andrew Turner
b6d2c99a09 When exiting two-finger scroll the Synaptics device may report a jump in
absolute position. This seems to be correlated with only removing a single
finger. To work around this report no movement on from the first packet
when the user exits scrolling.
2015-12-14 11:13:50 +00:00
Rui Paulo
3bf6d93962 Synaptics: fix a problem with trackpoint passthrough.
There was a inconsistency which led to enable passthrough commands
being interpreted as actual touchpad commands.

Submitted by:	Jan Kokemüller <jan.kokemueller at gmail.com>
MFC after:	1 week
2015-06-19 00:10:30 +00:00
Gleb Smirnoff
a57b51f99a Fix miss from r284320.
Coverity:	1018895
2015-06-16 15:39:34 +00:00
Gleb Smirnoff
b63720c613 Unbreak mouse on resume on Thinkpads when hw.psm.trackpoint_support=0,
which is default.  It was broken in r281441.

It appears that set_trackpoint_parameters() call on resume disables the
mouse.  So, we need not call it on resume if hw.psm.trackpoint_support=0.

The problem is that the probe functions are used both for probing and
for reiniting on resume. And the absense of the softc parameter is used
as a mark to distinguish reinit and probe, which is quite ugly. At the
same time the softc parameter is needed to call set_trackpoint_parameters().

o Change the arguments of probefunc_t to always supply the softc, and
  use additional enum argument to tell probing from initing.
o Don't call set_trackpoint_parameters() from global doinitialize(),
  instead call it from the enable_trackpoint() only.
o In enable_synaptics() call enable_trackpoint() in both probe and
  reinit cases.

Together with:  Jan Kokemüller <jan.kokemueller gmail.com>
2015-06-12 13:57:04 +00:00
Rui Paulo
017d485987 synaptics: more support for semi-MT trackpads.
Several improvements to the Synaptics driver to support
semi-multitouch trackpads and some other fixes:

- Two finger scrolling support for "semi-MT" touchpads. Those include
many of the older Synaptics touchpads before "true" multitouch support
(indicated by capMultiFinger). Semi-MT touchpads can report a second
finger position, but the X or Y coordinate may be swapped with some
coordinate of the first finger. This is a result of how the hardware
works internally. Therefore, all that can be reliably extracted is the
bounding box of the two finger positions. Semi-MT touchpads can be
recognized by the capAdvancedGestures capability bit. After setting the
mode byte, advanced gestures mode has to be enabled. Then, data packets
compatible with the capMultiFinger format are sent, so the same two
finger scrolling code can be leveraged. Enabling advanced gestures mode
on true multitouch touchpads should be harmless. Linux seems to always
enable advanced gestures mode.

- Put mode setting logic into own functions synaptics_preferred_mode()
and synaptics_set_mode() to have this in one place.
synaptics_passthrough_on() and synaptics_passthrough_off() currently
always use 0xc1 as the mode byte, which may be wrong for touchpads that
don't have capExtended.

- Expose X and Y resolution of touchpad to userland. Also expose minimum
and maximum X and Y coordinates. This is useful for programs in
userspace that read raw PSM packets (with PSM_LEVEL_NATIVE enabled) and
need to interpret the coordinates.

- Also send "extended w mode" packets (see section 3.2.9 of
511-000275-01_RevB.pdf) to userspace if PSM_LEVEL_NATIVE is enabled.
This is useful for userspace programs/drivers such as
xf86-input-synaptics that can handle these packets.

- Fix parsing of nExtendedQueries, and request extended/continued
capability bits depending on this value.

- capReportsMax, capClearPad, capAdvancedGestures and capCoveredPad must
be extracted from status[0] and not status[2], I think.

Submitted by:	Jan Kokemüller jan.kokemueller at gmail.com
2015-05-10 20:36:57 +00:00
Jung-uk Kim
59023e6ce2 Remove leftover from r282269.
MFC after:	2 weeks
X-MFC with:	r282269
2015-04-30 17:49:35 +00:00
Roger Pau Monné
b19f7eece6 atkbd: remove usage of x86bios
Instead of trying to get the keyboard repeat rate set by the BIOS just set a
default one. This allows removing the usage of x86bios from atkbd.

Sponsored by: Citrix Systems R&D
Reviewed by: jkim, delphij
Differential Revision: https://reviews.freebsd.org/D2399
MFC after: 2 weeks
2015-04-30 07:00:25 +00:00
Rui Paulo
1321d68db0 Synaptics: don't report the middle button when clickPad is used.
On trackpads that had support for both, we were sending two button
events when the trackpad was pressed.

Tested by:	Jakob Alvermark <jakob at alvermark.net>
MFC after:	1 week
2015-04-18 20:55:55 +00:00
Rui Paulo
e6ef49ea68 Add support for controlling the trackpoint when Synaptics is enabled.
To accomplish this, we must put the Synaptics hardware in passthrough
mode when talking to the trackpoint.

I only performed minor style modifications.

Submitted by:	Jan Kokemüller <jan.kokemueller at gmail.com>
MFC after:	1 week
2015-04-11 18:45:22 +00:00
Rui Paulo
e197118083 Improve Synaptics support for newer touchpads.
Enable two finger scrolling by default and disable the edge scrolling if
the touchpad has no physical zone for it.  Disable directional scrolling
by default to avoid using extended buttons as scroll buttons.

Add support for ClickPad.  On Lenovo laptops, this is the button
reported when one presses the touchpad.

While there, fix a problem where the extended buttons were not reporting
the button release event correctly: we need to save the state of the
buttons and report it to sysmouse until we receive a packet from the
touchpad indicating the button has been released.  This makes it
possible to use an extended button to resize a window.  On Lenovo
laptops, the major buttons are actually reported as extended buttons.

Tested by:	many (current@)
MFC after:	1 week
2015-04-11 18:44:07 +00:00
Rui Paulo
c282164d42 psm: print newer Synaptics Touchpad capabilities. 2015-04-06 01:04:08 +00:00
Michael Gmelin
6c176113bb Quirk based support of Chromebook keyboard found in Acer C720
This probably supports other devices based on SeaBIOS, which need
to be added to the smbios based quirks table.

The functionality has been ported from DragonFlyBSD and adapted
to FreeBSD's more general purpose environment.

Devices not covered by a quirk shouldn't be affected at all. Thanks
to jhb and kostikbel for reviewing the code.

Reviewed by:	kostikbel, jhb
Approved by:	jhb, kostikbel
Differential Revision: https://reviews.freebsd.org/D1802
2015-02-14 22:12:17 +00:00
John Baldwin
fadf3fb98c Convert from timeout(9) to callout(9). 2014-09-22 14:27:26 +00:00