History log of /freebsd-11-stable/sys/dev/atkbdc/psm.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 362209 15-Jun-2020 wulf

MFC r361715:

[psm] Do not disable trackpoint when hw.psm.elantech.touchpad_off is enabled

PR: 246117
Reported by: Alexander Sieg <ports@xanderio.de>

MFC r361718:

[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>


# 360782 07-May-2020 dim

MFC r306679 (by glebius):

Fix indentation.

CID: 1363671


# 360617 03-May-2020 wulf

MFC r360353:

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>


# 357666 07-Feb-2020 kevans

MFC r357509-r357510: small psm cleanup

r357509:
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.

r357510:
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.


# 349541 29-Jun-2019 wulf

MFC r346455-r346458, r348520, r348529, r348817, r348818

r346455:
psm(4): Add support for 4 and 5 finger touches in synaptics driver

While 4-th and 5-th finger positions are not exported through PS/2
interface, total number of touches is reported by MT trackpads.

r346456:
psm(4): do not process gestures when palm is present

Ignoring of gesture processing when the palm is detected helps to reduce
some of the erratic pointer behavior.

This fixes regression introduced in r317814

Reported by: Ben LeMasurier <ben@crypt.ly>

r346457:
psm(4): respect tap_disabled configuration with enabled Extended support

This fixes a bug where, even when hw.psm.tap_enabled=0, touchpad taps
were processed.
tap_enabled has three states: unconfigured, disabled, and enabled (-1, 0, 1).
To respect PR kern/139272, taps are ignored only when explicity disabled.

Submitted by: Ben LeMasurier <ben@crypt.ly> (initial version)

r346458:
psm(4): give names to synaptics commands

Submitted by: Ben LeMasurier <ben@crypt.ly>

r348520:
psm(4): Add Elantech touchpad IC type 15 found on Thinkpad L480 laptops

PR: 238291
Submitted by: Andrey Kosachenko <andrey.kosachenko@gmail.com>

r348529:
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
Differential Revision: https://reviews.freebsd.org/D20447

r348817:
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>

r348818:
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>


# 344165 15-Feb-2019 wulf

MFC r343163:

psm(4): detect Lenovo top-button clickpads

libinput has special handling for Lenovo ThinkPad *40 series, where it
treats clicks on the top button area as if they came from the TrackPoint:
https://wayland.freedesktop.org/libinput/doc/latest/t440-support.html

Detect these devices and set the corresponding evdev property.

Submitted by: Greg V <greg@unrelenting.technology>
Differential Revision: https://reviews.freebsd.org/D18676


# 343158 18-Jan-2019 wulf

MFC r340912,r340913:

psm(4): Revert r328640 and add minimal support for active AUX port
multiplexers

Active PS/2 multiplexing is a method for attaching up to four PS/2
pointing devices to a computer. Enabling of multiplexed mode allows
commands to be directed to individual devices using routing prefixes.
Multiplexed mode reports input with each byte tagged to identify
its source. This method differs from one currently supported by psm(4)
where so called guest device (trackpoint) is attached to special
interface located on the host device (touchpad) and latter performs
guest protocol conversion to special encapsulation packet format.

At present time active PS/2 multiplexing is used in some models of
HP laptops e.g. EliteBook 8560w, 9470m. Enabling of absolute operation
mode on such touchpads is connected with following problems:
1. Touchpad's port priority is lower than trackpoint's. That blocks
information queries thus prevents touchpad detection and configuration.
2. Touchpad and trackpoint have different protocol packet sizes and
sync bytes.

As PS/2 usage is on decline only minimal possible set of changes to
support Synaptics touchpad and generic mouses is implemented.
Active multiplexing mode is enabled only at probe stage to scan through
attached PS/2 devices to query and configure Synaptics touchpad.
After touchpad has been configured, mux is switched back to legacy
(hidden multiplexing) mode to perform normal interrupt-driven input
data processing. Overflow bit values rather than tags are used to
separate packets produced by different devices. Switching back to
legacy mode allows to avoid psm(4) and atkbd(4) rework to support
4 instances of mouse driver.

Note: While in hidden multiplexing mode KBC does some editing of the
packet stream. It remembers the button bits from the last packet
received from each device, and replaces the button bits of every
packet with the logical OR of all devices’ most recent button bits.
This sort of button crosstalk results in spurious button events
which are inhibitted with various tricks. E.g. trackpoint middle
button events are suppressed while trackpad surface is touched and
touchpad left and right button events are suppressed if corresponding
trackpoint buttons are pressed.

PR: 231058
Reported by: Michael Figiel <mifigiel at gmail.com>
Tested by: Michael Figiel <mifigiel at gmail.com>


# 334763 07-Jun-2018 hselasky

MFC r334422:
Correct argument for evdev_push_rel().

This is a regression issue after r319162.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies


# 331172 19-Mar-2018 eadler

MFC r328640:

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


# 331171 19-Mar-2018 eadler

MFC r328638:

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


# 331170 19-Mar-2018 eadler

MFC r328636:

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


# 329532 18-Feb-2018 wulf

MFC r328864:

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>


# 328484 27-Jan-2018 dumbbell

psm: Log syncmask[1], not syncmask[0] twice

MFC of: r328208


# 328482 27-Jan-2018 dumbbell

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 of: r328191


# 328481 27-Jan-2018 dumbbell

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 of: r328190


# 325345 02-Nov-2017 wulf

MFC: r324774
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)


# 321060 16-Jul-2017 wulf

MFC r319162:
psm: add support for evdev protocol

Approved by: gonzo (mentor)


# 318500 18-May-2017 wulf

MFC r317811:

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.

MFC r317812:

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.

MFC r317813:

Adjust Elantech palm width threshold to nearly match synaptics defaults

MFC r317814:

psm(4): reduce cursor jumping on palm detection

This is done with discarding pointer movements rather then mouse packets

MFC r317815:

Enable palm detection on two finger touches for multitouch trackpads.

MFC r317816:

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.

MFC r317817:

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.

MFC r317818:

psm(4): Remove sys/libkern.h header inclusion

It is already included via sys/systm.h

MFC r317819:

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.


# 314361 27-Feb-2017 gonzo

MFC r313757:

[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>


# 308652 14-Nov-2016 gonzo

MFC r308189:

[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


# 307576 18-Oct-2016 gonzo

MFC r306355, r306474, r306746:

r306355:
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

r306474:
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

r306746:
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>


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 298955 03-May-2016 pfg

sys/dev: minor spelling fixes.

Most affect comments, very few have user-visible effects.


# 298307 19-Apr-2016 pfg

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


# 292197 14-Dec-2015 andrew

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.


# 284585 18-Jun-2015 rpaulo

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


# 284450 16-Jun-2015 glebius

Fix miss from r284320.

Coverity: 1018895


# 284320 12-Jun-2015 glebius

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>


# 282734 10-May-2015 rpaulo

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


# 281704 18-Apr-2015 rpaulo

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


# 281441 11-Apr-2015 rpaulo

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


# 281440 11-Apr-2015 rpaulo

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


# 281127 05-Apr-2015 rpaulo

psm: print newer Synaptics Touchpad capabilities.


# 278787 14-Feb-2015 grembo

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


# 255210 04-Sep-2013 eadler

Revert r255152:

It turns out that synaptics_support was turned off by default
because its probing method is too intrusive not because it was unstable.

Once this is fixed it should be enabled once again.

Reported by: delphij, jkim


# 255153 02-Sep-2013 dumbbell

psm: Add support for middle and extended buttons on Synaptics touchpads

PR: kern/170834
Submitted by: Brandon Gooch <jamesbrandongooch@gmail.com>
Tested by: Artyom Mirgorodskiy <artyom.mirgorodsky@gmail.com>
MFC after: 1 month


# 255152 02-Sep-2013 eadler

synaptics and trackpoint support are stable enough to be on by default.

Eventually both options should be removed.

Reviewed by: dumbbell


# 250615 13-May-2013 jkim

Remove a bogus re-assignment.

MFC after: 3 days


# 248479 18-Mar-2013 jkim

List TrackPoint device before generic model.


# 248478 18-Mar-2013 jkim

Add preliminary support for IBM/Lenovo TrackPoint.

PR: kern/147237 (based on the initial patch for 8.x)
Tested by: glebius (device detection and suspend/resume)
MFC after: 1 month


# 244405 18-Dec-2012 dumbbell

psm: Support detection of Synaptics touchpad v7.5 and above

Starting with firmware v7.5, the "Read TouchPad Modes" ($01) and "Read
Capabilities" ($02) commands changed: previously constant bytes now
carry variable information.

We now compare those bytes to expected constants only for firmware prior
to v7.5.

Tested by: Zeus Panchenko <zeus@gnu.org.ua>
MFC after: 1 week


# 240743 20-Sep-2012 kevlo

Fix typo: s/protocl/protocol


# 240211 07-Sep-2012 jhb

Use callout(9) instead of timeout(9) to manage timers.


# 233580 27-Mar-2012 jkim

- Do not clobber softc when psm(4) is reintialized.
- Make INITAFTERSUSPEND flag independent of HOOKRESUME flag.
- Automatically set INITAFTERSUSPEND flag when ALPS GlidePoint is detected.
- Always probe Synaptics Touchpad. Allow MOUSE_SYN_GETHWINFO ioctl and
automatically set INITAFTERSUSPEND flag when a supported device is detected,
regardless of "hw.psm.synaptics_support" tunable setting.
- Update psm(4) to reflect the above changes.
- Remove long-time defunct SYNCHACK flag while I am in the neighborhood.

MFC after: 1 month


# 227309 07-Nov-2011 ed

Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.

The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.


# 216491 16-Dec-2010 jhb

- When moving the IRQ resource from the psmcpnp device to the psm device,
delete the IRQ resource from the psmcpnp device completely.
- Don't allocate the IRQ resource shared. It is not a shareable interrupt
on ISA. The bus driver can set RF_SHAREABLE if the IRQ is actually
shareable on a non-ISA bus.


# 215473 18-Nov-2010 jhb

Various small typos and grammar nits in comments.


# 212355 09-Sep-2010 ed

Let psm(4) use si_drv1 to refer to its softc.


# 200674 18-Dec-2009 dumbbell

Add new "hw.psm.tap_enabled" tunable and sysctl.

This tunable allows one to enable (1) or disable (0) gestures like tap
and tap-hold on Synaptics TouchPad when the Extended mode isn't enabled
(ie. "hw.psm.synaptics_support" not set).

By default, the value is -1 in order to keep the current behaviour of
not enabling/disabling gestures explicitly.

PR: kern/139272
Submitted by: David Horn <dhorn2000 AT gmail DOT com>
Reviewed by: David Horn <dhorn2000 AT gmail DOT com>


# 196403 20-Aug-2009 jhb

Temporarily revert the new-bus locking for 8.0 release. It will be
reintroduced after HEAD is reopened for commits by re@.

Approved by: re (kib), attilio


# 196037 02-Aug-2009 attilio

Make the newbus subsystem Giant free by adding the new newbus sxlock.
The newbus lock is responsible for protecting newbus internIal structures,
device states and devclass flags. It is necessary to hold it when all
such datas are accessed. For the other operations, softc locking should
ensure enough protection to avoid races.

Newbus lock is automatically held when virtual operations on the device
and bus are invoked when loading the driver or when the suspend/resume
take place. For other 'spourious' operations trying to access/modify
the newbus topology, newbus lock needs to be automatically acquired and
dropped.

For the moment Giant is also acquired in some key point (modules subsystem)
in order to avoid problems before the 8.0 release as module handlers could
make assumptions about it. This Giant locking should go just after
the release happens.

Please keep in mind that the public interface can be expanded in order
to provide more support, if there are really necessities at some point
and also some bugs could arise as long as the patch needs a bit of
further testing.

Bump __FreeBSD_version in order to reflect the newbus lock introduction.

Reviewed by: ed, hps, jhb, imp, mav, scottl
No answer by: ariff, thompsa, yongari
Tested by: pho,
G. Trematerra <giovanni dot trematerra at gmail dot com>,
Brandon Gooch <jamesbrandongooch at gmail dot com>
Sponsored by: Yahoo! Incorporated
Approved by: re (ksmith)


# 189870 16-Mar-2009 rnoland

Teach psm about O_ASYNC

This makes Xorg happy if you aren't using moused.

MFC after: 3 days


# 186218 17-Dec-2008 dumbbell

Synaptics touchpads must be reinitialized after suspend/resume.

This fixes touchpad resume on Asus EeePC among others.

Submitted by: rpaulo


# 186175 16-Dec-2008 dumbbell

Rephrase and/or fix some comments in Synaptics touchpad initialization
function.


# 183888 14-Oct-2008 dumbbell

Rewrite Synaptics touchpads support with the following goals in mind:
o better quality of the movement smoothing
o more features such as tap-hold and virtual scrolling

Support must still be enabled with this line in your /boot/loader.conf:
hw.psm.synaptics_support="1"

The following sysctls were removed:
hw.psm.synaptics.low_speed_threshold
hw.psm.synaptics.min_movement
hw.psm.synaptics.squelch_level

An overview of this new driver and a short documentation about the added
sysctls is available on the wiki:
http://wiki.freebsd.org/SynapticsTouchpad


# 183397 27-Sep-2008 ed

Replace all calls to minor() with dev2unit().

After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by: kib


# 180818 25-Jul-2008 trhodes

Fill in sysctl descriptions.

Approved by: philip


# 179474 01-Jun-2008 philip

Try to detect a Synaptics touchpad before IntelliMouse. Some touchpads will
pretend to be IntelliMouse (which have a few more features than generic mice)
causing the IntelliMouse probe to work and the Synaptics code never to be
called.

This should not break "real" IntelliMouse because the Synaptics detection code
is fairly specific.

PR: kern/120833
Submitted by: Eygene Ryabinkin <rea-fbsd -at- codelabs.ru>
MFC after: 1 week


# 178019 08-Apr-2008 jkim

Clean up and fix style(9) nits.


# 178017 08-Apr-2008 jkim

- Add write(2) support for psm(4) in native operation level. Now arbitrary
commands can be written to /dev/psm%d and status can be read back from it.
- Reflect the change in psm(4) and bump version for ports.

MFC after: 1 week


# 176554 25-Feb-2008 rink

Some PS/2 mice (at least the A4Tech X-7xx) need to be set to Intelli mode
first before they can be set to Explorer mode.

PR: kern/118578
Submitted by: Andriy Gapon <avg@icyb.net.ua> (I added some comments)
Reviewed by: philip
MFC after: 1 month


# 170868 17-Jun-2007 mjacob

Initialize mouse resolution to zero if converting from
OLD to NEW.


# 166901 23-Feb-2007 piso

o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@


# 166492 04-Feb-2007 dumbbell

Synaptics TouchPad seems to go back to Relative Mode after the call
to set_controller_command_byte() call; by issueing a Read Mode Byte
command, the touchpad is in Absolute Mode again.

This problem occursed at least on Asus V6V laptops.


# 165335 18-Dec-2006 keramida

Spell "Kensington Thinking Mouse" correctly.


# 156730 15-Mar-2006 takawata

Add ALPS glide point ID and some compatibility IDs.

PR: kern/75008


# 154059 05-Jan-2006 dumbbell

Fix a bug in Synaptics Touchapd support where psm(4) will enter an infinite
loop if it receives an out of sync packet.

Reviewed by: mux (mentor)
MFC after: 4 days


# 153072 04-Dec-2005 ru

Fix -Wundef.


# 147271 10-Jun-2005 marius

- Hook up the new locations of the atkbdc(4), atkbd(4) and psm(4) source
files after they were repo-copied to sys/dev/atkbdc. The sources of
atkbdc(4) and its children were moved to the new location in preparation
for adding an EBus front-end to atkbdc(4) for use on sparc64; i.e. in
order to not further scatter them over the whole tree which would have
been the result of adding atkbdc_ebus.c in e.g. sys/sparc64/ebus. Another
reason for the repo-copies was that some of the sources were misfiled,
e.g. sys/isa/atkbd_isa.c wasn't ISA-specific at all but for hanging
atkbd(4) off of atkbdc(4) and was renamed to atkbd_atkbdc.c accordingly.
Most of sys/isa/psm.c, i.e. expect for its PSMC PNP part, also isn't
ISA-specific.
- Separate the parts of atkbdc_isa.c which aren't actually ISA-specific
but are shareable between different atkbdc(4) bus front-ends into
atkbdc_subr.c (repo-copied from atkbdc_isa.c). While here use
bus_generic_rl_alloc_resource() and bus_generic_rl_release_resource()
respectively in atkbdc_isa.c instead of rolling own versions.
- Add sparc64 MD bits to atkbdc(4) and atkbd(4) and an EBus front-end for
atkbdc(4). PS/2 controllers and input devices are used on a couple of
Sun OEM boards and occur on either the EBus or the ISA bus. Depending on
the board it's either the only on-board mean to connect a keyboard and
mouse or an alternative to either RS232 or USB devices.
- Wrap the PSMC PNP part of psm.c in #ifdef DEV_ISA so it can be compiled
without isa(4) (e.g. for EBus-only machines). This ISA-specific part
isn't separated into its own source file, yet, as it requires more work
than was feasible for 6.0 in order to do it in a clean way. Actually
philip@ is working on a rewrite of psm(4) so a more comprehensive
clean-up and separation of hardware dependent and independent parts is
expected to happen after 6.0.

Tested on: i386, sparc64 (AX1105, AXe and AXi boards)
Reviewed by: philip


# 147263 10-Jun-2005 marius

Forced commit to denote that the following repo-copies have taken place:

sys/dev/kbd/atkbd.c -> sys/dev/atkbdc/atkbd.c
sys/dev/kbd/atkbdc.c -> sys/dev/atkbdc/atkbdc.c
sys/dev/kbd/atkbdcreg.h -> sys/dev/atkbdc/atkbdcreg.h
sys/dev/kbd/atkbdreg.h -> sys/dev/atkbdc/atkbdreg.h
sys/isa/atkbd_isa.c -> sys/dev/atkbdc/atkbd_atkbdc.c
sys/isa/atkbdc_isa.c -> sys/dev/atkbdc/atkbdc_isa.c
sys/isa/atkbdc_isa.c -> sys/dev/atkbdc/atkbdc_subr.c
sys/isa/psm.c -> sys/dev/atkbdc/psm.c

Repo-copies done by: markm


# 139982 10-Jan-2005 philip

Make life for owners of Synaptics Touchpads more pleasant :-)

o Implement a shiny new algorithm to keep track of finger movement at
slow speeds. This dramatically reduces the level of questionable
language from users trying to resize windows.

o Properly catch the many extra buttons and dials which manufacturers
are known to screw onto Synaptics touchpad controllers. Currently,
up to seven buttons are known to work, more should work too.

o Add a number of sysctls allowing one to tune the driver to taste in
a simple way:

# Should the extra buttons act as axes or as middle button
hw.psm.synaptics.directional_scrolls

# These control the 'stickiness' at low speeds
hw.psm.synaptics.low_speed_threshold
hw.psm.synaptics.min_movement
hw.psm.synaptics.squelch_level

PR: kern/75725
Submitted by: Jason Kuri <jay@oneway.com>
MFC after: 1 month


# 139628 03-Jan-2005 philip

Reduce diffs to work in progress before checking in serious changes.

o Move the sysctls under debug.psm.* and hw.psm.* making them a bit
clearer and more consistent with other drivers.

o Remove the debug.psm_soft_timeout sysctl. It was introduced many
moons ago in r1.64 but never referenced anywhere.

o Introduce hw.psm.tap_threshold and hw.psm.tap_timeout to control
the behaviour of taps on touchpads. People might like to fiddle
with these if tapping seems to slow or too fast for them.

o Add debug.psm.loglevel as a tunable so that verbosity can be set
easily at boot-time (to watch probes and such) without having to
compile a kernel with options PSM_DEBUG=N.


# 135945 29-Sep-2004 philip

Introduce a tunable to disable support for Synaptics touchpads. A number of
people have reported problems (stickyness, aiming difficulty) which is proving
difficult to fix, so this will default to disable until sometime after 5.3R.

To enable Synaptics support, set the 'hw.psm.synaptics_support=1' tunable.

MT5 candidate.

Approved by: njl


# 134409 27-Aug-2004 gibbs

Forced commit to add additional comment.
o Add MOUSE_PS2_TAP into syncmask[0] correctly when we're built with
PSM_CONFIG_FORCETAP. The previous code from revision 1.56 attempted
to do this but updated the a mask variable that would be clobbered later.
o If syncmask[1] hasn't yet been set when ioctl(MOUSE_GETMODE) is called,
zero syncmask[0] and syncmask[1] so that sync validation is effectively
disabled in userland applications and moused doesn't misbehave. The
psm driver performs sync validation so there is no loss in functionality
in clearing the sync mask.
o If PSM_NEED_SYNCBITS is set, setup syncmask[1], even if it's already
correct. This prevents the PSM_NEED_SYNCBITS bit from being left on
after a re-initialisation and erroneously causing a subsequent
out-of-sync packet to mis-set syncmask[1].


# 134405 27-Aug-2004 gibbs

Improve sync recovery algorithm:
o Remove PSM_SYNCERR_THRESHOLD1. This value specified how many sync
errors were required before the mouse is re-initialised.
Re-initialisation is now done after (packetsize * 2) sync errors as
things aren't likely to improve after that.

o Reset lastinputerror when re-initialisation occurs. We don't want
to continue to drop data after re-initialisation.

o Count the number of failed packets independently of the syncerrors
statistic. syncerrors is useful for recovering sync within a single
packet. pkterrors allows us to detect when the mouse changes its
packet mode due to some external event (e.g. KVM switch).

o Reinitialize the mouse if we see more than psmpkterrthresh errors
during the validation period. The validation period begins as soon
as a sync error is detected and continues until psmerrsecs/msecs
time has elapsed. The defaults for these two values force a reset
if we see two packet errors in a 2 second period. This allows rapid
detection of packet framing errors caused by the mouse changing packet
modes.

o Export psmpkterrthresh as a sysctl

o Export psmloglevel as a sysctl.

o Enable more debugging code to be enabled at runtime via psmloglevel.

o Simplify verbose conditioned loging by using a VLOG macro.

o Add several comments describing the sync recovery algorithm of
this driver.

Large Portions by: Brian Somers <brian@Awfulhak.org>
Inspired and Frustrated by: Belkin KVMs
Reviewed by: njl, philip


# 133918 17-Aug-2004 gibbs

Defer the capture of the "expected sync bits" until the first "normal"
data packet is received from the mouse. In the case of many KVM's,
this avoids a bug in their mouse emulation that sends back incorrect
sync when you explicitly request a data packet from the mouse. Without
this change, you must force the driver into stock PS/2 mode or be flooded
with a never ending stream of "out of sync" messages on these KVMs.

Approved by: re


# 133882 16-Aug-2004 philip

Don't initialize static variables to 0 (C should just take care of that).

Spotted by: njl


# 133868 16-Aug-2004 philip

Update support for Synaptics Touchpads (Volume V)

o Add (long awaited) support for guest devices

Submitted by: Arne Schwabe <arne@rfc2549.org>
Approved by: njl (in a former revision)


# 133301 07-Aug-2004 philip

Assume a finger of regular width when no width value is reported by
the touchpad (which happens when it has no extended capabilities).

Spotted by: dhw
Forgotten by: philip


# 133298 07-Aug-2004 philip

Update support for Synaptics Touchpads (Volume IV)

o Change the motion calculation to result in
a more reasonable speed of motion

This should fix the 'aiming' problems people have reported. It also
mitigates (but doesn't completely solve) the 'stalling' problems at
very low speeds.

Tested by: many subscribers to -current
Approved by: njl


# 133297 07-Aug-2004 philip

Update support for Synaptics Touchpads (Volume III)

o Catch 'taps' as button presses

o One finger sends button1, two fingers send button3,
three fingers send button2 (double-click)

Tested by: many subscribers to -current
Approved by: njl


# 133296 07-Aug-2004 philip

Update support for Synaptics Touchpads (Volume II)

o Handle the 'up/down' buttons some touchpads have as
a z-axis (scrollwheel) as recommended by the specs

o Report the buttons as button4 and button5 instead
of button2 and button4, button2 can be emulated by
pressing button1 and button3 simultaneously. This
allows one to use the two extra buttons for other
purposes if one so desires.

Tested by: many subscribers to -current
Approved by: njl


# 133295 07-Aug-2004 philip

Update support for Synaptics Touchpads (Volume I)

o Clean up whitespace and comments in the
enable_synaptics() probing function

o Only use (and rely on) the extended capability
bits when we are told they actually exist

o Partly ignore the (possibly dated?) part of the
specification about the mode byte so that we
can support 'guest devices' too.

Tested by: many subscribers to -current
Approved by: njl


# 132865 29-Jul-2004 njl

Add support for the Synaptics Touchpad mouse driver. I reworked the
submitted version with style cleanups and changes to comments. I also
modified the ioctl interface. This version only has one ioctl (to get
the Synaptics-specific config parameters) since this is the only
information a user might want.

Submitted by: Arne Schwabe <arne -at- rfc2549.org>


# 132270 16-Jul-2004 mux

Ignore more strange return values of the test_aux_port() function,
because some notebooks (apparently Compaq, Toshiba and Acer ones)
erroneously return 2 or 3 there.

PR: kern/61482, kern/54188
Submitted by: Ulf Lilleengen <lulf@kerneled.org>,
Victor Balada Diaz <victor@alf.dyndns.ws>
MFC after: 3 days


# 130585 16-Jun-2004 phk

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


# 128353 17-Apr-2004 mux

Don't check for device_get_softc() returning NULL, it can't happen.


# 127841 04-Apr-2004 markm

Put a bunch of output that us really only useful in a debug
scenario into #ifdef DEBUG. This makes my cluster with Belkin
KVM switch completely usable, even if the KVM switch and mouse
get a bit confused sometimes.

Without this, when the mouse gets confused, all sorts of crud
gets spammed all over the screen. With this, the mouse may appear
dead for a second or three, but it recovers silently.


# 127135 17-Mar-2004 njl

Convert callers to the new bus_alloc_resource_any(9) API.

Submitted by: Mark Santcroos <marks@ripe.net>
Reviewed by: imp, dfr, bde


# 126080 21-Feb-2004 phk

Device megapatch 4/6:

Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.


# 126076 21-Feb-2004 phk

Device megapatch 1/6:

Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.


# 123442 11-Dec-2003 alfred

Significantly reduce the "jitter" that is typical for PS/2 mice
when using a KVM.

There is no actual solution possible, but this gets us pretty close.

Typically when switching back to a FreeBSD box and moving the mouse
wild data is produced, because the protocol's validation/checksum
system is extremely weak it is impossible to determine that we're
out of sync before dropping several bogus packets to user land.

The actual solution that appears to offer the best clamping of
jitter is to buffer the mouse packets if we've not seen mouse
activity for more than .5 seconds. Then waiting to flush that data
for 1/20th of a second. If within that 20th of a second we get any
packets that do fail the weak test we drop the entire queue and
back off accepting data from the mouse for 2 seconds and then repeat
the whole deal.

You can still get _some_ jitter, notably if you switch to the FreeBSD
box, then move the mouse just enough to generate one or two packets.
Those packets may be bogus, but may still pass the validity check.

One way to finally kill the problem once and for all is to check
the initial packets for "wild" values. Typically one sees packets
in the +/-60 range during normal operation, however when bogus data
is generated it's typically near the outer range of +/-120 or more,
those packets would be a good candidate for dropping or clamping.

I've been running with this for several weeks now and it has
significantly helped me stay sane even with a piece of junk Belkin
KVM causing wild jitter each and every time I switch.

Lastly I'd like to note that my experience with Windows shows me that
somehow the Microsoft PS/2 driver typically avoids this problem, but
that may only be possible when running the mouse in a dumb-ed down PS/2
mode that Belkin recommends on their site.


# 122352 09-Nov-2003 tanimura

- Implement selwakeuppri() which allows raising the priority of a
thread being waken up. The thread waken up can run at a priority as
high as after tsleep().

- Replace selwakeup()s with selwakeuppri()s and pass appropriate
priorities.

- Add cv_broadcastpri() which raises the priority of the broadcast
threads. Used by selwakeuppri() if collision occurs.

Not objected in: -arch, -current


# 117478 12-Jul-2003 mikeh

Add support for the A4 Tech RFSW-35 mouse wheel. Probe is similar to
4D Plus.

PR: 44333


# 117302 07-Jul-2003 mikeh

Reset the PSM aux device twice to help pierce through some KVM's to
get the correct data from the attached mouse. Multiple resets should
be harmless, but just in case, the second one is non-fatal and is just
ignored.


# 117117 01-Jul-2003 mikeh

Add PnP PS/2 id for Dell Latitude X200.

PR: 48516
MFC after: 2 weeks


# 116181 10-Jun-2003 obrien

Use __FBSDID().


# 115569 31-May-2003 phk

wrap macro in do {...} while(0)


# 115480 31-May-2003 phk

Remove extra ';'

Found by: FlexeLint


# 114293 30-Apr-2003 markm

Fix some easy, global, lint warnings. In most cases, this means
making some local variables static. In a couple of cases, this means
removing an unused variable.


# 114216 29-Apr-2003 kan

Deprecate machine/limits.h in favor of new sys/limits.h.
Change all in-tree consumers to include <sys/limits.h>

Discussed on: standards@
Partially submitted by: Craig Rodrigues <rodrigc@attbi.com>


# 111815 03-Mar-2003 phk

Gigacommit to improve device-driver source compatibility between
branches:

Initialize struct cdevsw using C99 sparse initializtion and remove
all initializations to default values.

This patch is automatically generated and has been tested by compiling
LINT with all the fields in struct cdevsw in reverse order on alpha,
sparc64 and i386.

Approved by: re(scottl)


# 111748 02-Mar-2003 des

More low-hanging fruit: kill caddr_t in calls to wakeup(9) / [mt]sleep(9).


# 109710 22-Jan-2003 marcel

YAM: This id is found in a Sony Vaio GRX-670. When will this end?

Submitted by: Chuck McCrobie <mccrobie2000@yahoo.com>


# 109679 22-Jan-2003 hsu

Add yet another Sony Vaio PS/2 mouse ID. This one is found on a VX88.

Submitted by: marcel


# 109626 21-Jan-2003 marcel

Add yet another Sony Vaio PS/2 mouse ID. This one is found in a R505GL.
The ACPI data for the mouse includes the compatibility ID, but we
apparently don't make use of it.


# 109269 15-Jan-2003 mdodd

- GC a few more hand-rolled 'abs' macros.
- GC a few hand-rolled min()/max() macros while I'm here.


# 102412 25-Aug-2002 charnier

Replace various spelling with FALLTHROUGH which is lint()able


# 92756 20-Mar-2002 alfred

Remove __P.


# 92252 13-Mar-2002 alfred

Fixes to make select/poll mpsafe.

Problem:
selwakeup required calling pfind which would cause lock order
reversals with the allproc_lock and the per-process filedesc lock.
Solution:
Instead of recording the pid of the select()'ing process into the
selinfo structure, actually record a pointer to the thread. To
avoid dereferencing a bad address all the selinfo structures that
are in use by a thread are kept in a list hung off the thread
(protected by sellock). When a selwakeup occurs the selinfo is
removed from that threads list, it is also removed on the way out
of select or poll where the thread will traverse its list removing
all the selinfos from its own list.

Problem:
Previously the PROC_LOCK was used to provide the mutual exclusion
needed to ensure proper locking, this couldn't work because there
was a single condvar used for select and poll and condvars can
only be used with a single mutex.
Solution:
Introduce a global mutex 'sellock' which is used to provide mutual
exclusion when recording events to wait on as well as performing
notification when an event occurs.

Interesting note:
schedlock is required to manipulate the per-thread TDF_SELECT
flag, however if given its own field it would not need schedlock,
also because TDF_SELECT is only manipulated under sellock one
doesn't actually use schedlock for syncronization, only to protect
against corruption.

Proc locks are no longer used in select/poll.

Portions contributed by: davidc


# 92000 10-Mar-2002 takawata

Add SONY VAIO psm controller ISA-PnP ID.


# 88188 19-Dec-2001 sheldonh

Add another PS2 PNP id.

PR: 32973
Submitted by: KT Sin <ktsin@acm.org>


# 84880 13-Oct-2001 yokota

Hack for the "out-of-sync" error.

- Count the number of this error.
- When the error is detected for the first time, the psm driver will
throw few data bytes (up to entire packet size) and see if it can
get back to sync.
- If the error still persists, the psm driver disable/enable the mouse
and see if it works.
- If the error still persists and the count goes up to 20,
the psm driver reset and reinitialize the mouse. The counter
is reset to zero.
- It also discards an incomplete data packet when the interval
between two consequtive bytes are longer than pre-defined timeout
(2 seconds). The last byte which arrived late will be regarded as
the first byte of a new packet. This is louie's idea.

You may see the following error logs during the above operations:

"psmintr: delay too long; resetting byte count"
"psmintr: out of sync (%04x != %04x)"
"psmintr: discard a byte (%d)"
"psmintr: re-enable the mouse"
"psmintr: reset the mouse"

MFC after: 1 month


# 84407 03-Oct-2001 takawata

Add PnP ID 'IBM3781' for TP240 mouse.


# 83931 25-Sep-2001 yokota

Yet another turn of workaround for psm/ACPI/PnP BIOS
problems currently experienced in -CURRENT.

This should fix the problem that the PS/2 mouse is detected
twice if the acpi module is not loaded on some systems.


# 83492 15-Sep-2001 yokota

Refine ACPI/PnP BIOS probe/attach routines a bit.

- Add workaround for the problematic PnP BIOS which does not assign
irq resource for the PS/2 mouse device node; if there is no irq
assigned for the PS/2 mouse node, refer to device.hints for an
irq number. If we still don't find an irq number in the hints
database, use a hard-coded value.
- Delete unused ivars.
- Bit of clean up in probe/attach.
- Add PnP ID for the PS/2 mouse port on some IBM ThinkPad models.


# 83366 12-Sep-2001 julian

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


# 83147 06-Sep-2001 yokota

Update the atkbdc, atkbd, and psm drivers to probe/attach
more cleanly and consistently in all APCI, PnP BIOS, and "hint"
cases.

NOTE: this doesn't necessarily solve the problem that the PS/2
mouse is not detected after the recent ACPI update.


# 74810 26-Mar-2001 phk

Send the remains (such as I have located) of "block major numbers" to
the bit-bucket.


# 70834 09-Jan-2001 wollman

select() DKI is now in <sys/selinfo.h>.


# 69439 01-Dec-2000 yokota

- Add a hack for "psmintr: out of sync.." This is NOT a fix,
but a hack! Add `flags 0x8000' to the psm driver to enable it.
The psm driver will try to get out of out-of-sync situation
by disabling the mouse and immediately enable it again.

If you are seeing this out-of-sync problem because of an
incompetent(?!) KVM switch, this hack will NOT be good
for you. However, if you are occasionally seeing the
problem because of lost mouse interrupt, this might help.


# 69438 01-Dec-2000 yokota

- Slightly rearrnage IntelliMouse Explorer and Logitech
MouseMan+ identification routines for efficiency.
No functional change.


# 67164 15-Oct-2000 phk

Remove unneeded #include <machine/clock.h>


# 66860 09-Oct-2000 phk

Initiate deorbit burn sequence for <machine/mouse.h>.

Replace all in-tree uses with <sys/mouse.h> which repo-copied a few
moments ago from src/sys/i386/include/mouse.h by peter.
This is also the appropriate fix for exo-tree sources.

Put warnings in <machine/mouse.h> to discourage use.
November 15th 2000 the warnings will be converted to errors.
January 15th 2001 the <machine/mouse.h> files will be removed.


# 66229 22-Sep-2000 jhb

Fix several 64-bit-ism warnings due to sizeof(int) != sizeof(void *) on
the alpha.


# 65045 24-Aug-2000 yokota

Add spltty()/splx() in the watchdog timer routine.


# 63951 28-Jul-2000 yokota

Fix GENERIC_MOUSE_ENTRY.

Submitted by: Graham Wheeler <gram@cequrux.com> and gibbs


# 63746 22-Jul-2000 yokota

This is yet another attempt to fix "psmintr out of sync.." problems.

- Properly protect the watchdog timer routine.
- Relocate the sync check statement so that we don't see too many
error messages.


# 59391 19-Apr-2000 phk

Remove ~25 unneeded #include <sys/conf.h>
Remove ~60 unneeded #include <sys/malloc.h>


# 58923 02-Apr-2000 yokota

- Add temporary workaround to fool some "clever" KVM switch products
which think they know the IntelliMouse 4-byte packet and believe,
wrongly, that any other protocols use 3-byte packets.
- Update a couple of comment lines for A4 Tech mice.


# 58230 18-Mar-2000 yokota

- Add Support for the following PS/2 mice:
- Microsoft IntelliMouse Explorer: 2 buttons on top, 2 side buttons
and a wheel which also acts as the middle button. The mouse is
recognized as "IntelliMouse Explorer".
- Genius NetScroll Optical: 2 buttons on top, 2 side buttons and a
wheel which also acts as the middle button. The mouse is recognized
as "NetMouse/NetScroll Optical".
- MouseSystems SmartScroll Mouse (OEM from Genius?): 3 buttons on top,
1 side button and a wheel. The mouse is recognized as Genius
"NetScroll".
- IBM ScrollPoint: 2 buttons on top and a stick between the buttons.
The stick can perform "horizontal scroll" in W*ndows environment.
The horizontal movement of the stick is detected. It is currently
mapped to the Z axis movement in the same way as the first wheel.
The mouse is recognized as "MouseMan+", as it is considered to be
a variation of MouseMan.
- A4 Tech 4D and 4D+ mice. These mice have two wheels! The movement
of the second wheel is reported as the Z axis movement in the
same way as the first wheel. These mice are recognized as "4D
Mouse" and "4D+ Mouse".
- Tweak IntelliMouse support code a bit so that less-than-compatible
wheel mice can work properly with the psm driver.
- Add driver configuration flags which correspond to the kernel
options PSM_HOOKRESUME and PSM_RESETAFTERSUSPEND, so that we don't
need to recompile the kernel when we need these functions.
- Properly keep track of the irq resource.
- Add a watchdog timer in case interrupts are lost (experimental).
- Add `detach' function (experimental).


# 57677 01-Mar-2000 peter

Don't free(sc) before returning an error from probe, it does not "belong"
to us, subr_bus.c will free it. This bug (panic: freeing already free)
was exposed by kern/subr_bus.c rev 1.54

Not explicitly approved by: jkh (but this is a showstopper and fallout of
the above approved change)


# 56836 29-Jan-2000 peter

Use config's conditional compilation rather than using #ifdefs that make
modular compilation harder. I'm doing this because people seem to like
cut/pasting examples of bad practices in existing code.


# 54629 15-Dec-1999 yokota

- Add the device resume method. It supercedes the existing resume
routine which hooks the apm driver.
- Rename the PSM_HOOKAPM option to PSM_HOOKRESUME.
- Delete unnecessary #include.


# 52997 08-Nov-1999 peter

Use DEVICE_MODULE() directly instead of DEV_DRIVER_MODULE. psm.c uses
make_dev() already.


# 51658 25-Sep-1999 phk

Remove five now unused fields from struct cdevsw. They should never
have been there in the first place. A GENERIC kernel shrinks almost 1k.

Add a slightly different safetybelt under nostop for tty drivers.

Add some missing FreeBSD tags


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 50254 23-Aug-1999 phk

Convert DEVFS hooks in (most) drivers to make_dev().

Diskslice/label code not yet handled.

Vinum, i4b, alpha, pc98 not dealt with (left to respective Maintainers)

Add the correct hook for devfs to kern_conf.c

The net result of this excercise is that a lot less files depends on DEVFS,
and devtoname() gets more sensible output in many cases.

A few drivers had minor additional cleanups performed relating to cdevsw
registration.

A few drivers don't register a cdevsw{} anymore, but only use make_dev().


# 50149 22-Aug-1999 yokota

Improve the detection code for GlidePoint. This is still a kludge,
but better than before...

PR: kern/13215


# 49965 17-Aug-1999 yokota

Recognize Interlink VersaPad. `Tap' action will be recognized
as the button 4.

Submitted by: Masachika ISHIZUKA <ishizuka@ish.org>


# 48778 12-Jul-1999 yokota

Improve Logitech MouseMan+ protocol support.


# 48773 12-Jul-1999 yokota

Implement a kludge for some wheeled mice for which infamous "psmintr:
out of sync..." messages is generated and the wheel movement is not
recognized.

The trick is found by Takashi Nishida.


# 48557 04-Jul-1999 phk

Remove cmaj and bmaj args from DEV_DRIVER_MODULE.


# 47705 03-Jun-1999 yokota

Fix PS/2 MouseMan+ protocol. We have been looking at a wrong place
for the sign bit for roller movement!


# 47625 30-May-1999 phk

This commit should be a extensive NO-OP:

Reformat and initialize correctly all "struct cdevsw".

Initialize the d_maj and d_bmaj fields.

The d_reset field was not removed, although it is never used.

I used a program to do most of this, so all the files now use the
same consistent format. Please keep it that way.

Vinum and i4b not modified, patches emailed to respective authors.


# 46792 09-May-1999 phk

Unconfuse DEV_MODULE() and DEV_DRIVER_MODULE() about the difference between
a major number for a dev_t.


# 46763 09-May-1999 yokota

Revive APM hooking code for i386 arch now that the same source file is
used for both i386 and alpha (the code was in sys/i386/isa/psm.c, but
was disabled when ported to alpha.)


# 46743 08-May-1999 dfr

Move the declaration of the interrupt type from the driver structure
to the BUS_SETUP_INTR call.


# 46635 07-May-1999 phk

Continue where Julian left off in July 1998:

Virtualize bdevsw[] from cdevsw. bdevsw() is now an (inline)
function.

Join CDEV_MODULE and BDEV_MODULE to DEV_MODULE (please pay attention
to the order of the cmaj/bmaj arguments!)

Join CDEV_DRIVER_MODULE and BDEV_DRIVER_MODULE to DEV_DRIVER_MODULE
(ditto!)

(Next step will be to convert all bdev dev_t's to cdev dev_t's
before they get to do any damage^H^H^H^H^H^Hwork in the kernel.)


# 45789 18-Apr-1999 peter

Merge revs 1.57 and 1.60 of i386/isa/psm.c


# 45720 16-Apr-1999 peter

Bring the 'new-bus' to the i386. This extensively changes the way the
i386 platform boots, it is no longer ISA-centric, and is fully dynamic.
Most old drivers compile and run without modification via 'compatability
shims' to enable a smoother transition. eisa, isapnp and pccard* are
not yet using the new resource manager. Once fully converted, all drivers
will be loadable, including PCI and ISA.

(Some other changes appear to have snuck in, including a port of Soren's
ATA driver to the Alpha. Soren, back this out if you need to.)

This is a checkpoint of work-in-progress, but is quite functional.

The bulk of the work was done over the last few years by Doug Rabson and
Garrett Wollman.

Approved by: core


# 43105 23-Jan-1999 dfr

Update the alpha port to use the new syscons.

Submitted by: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> (partly)


# 41181 15-Nov-1998 dfr

* Add hooks to allow the X server to access I/O ports and memory.
* Update drivers to the latest version of the bus interface.

The ISA drivers' use of the new resource api is minimal. Garrett has
some much cleaner drivers which should be more easily shared between
i386 and alpha. This has only been tested on cia based machines. It
should work on lca and apecs but I might have broken something.


# 41016 08-Nov-1998 dfr

Port the ps/2 mouse driver to the alpha.