History log of /freebsd-9.3-release/sys/dev/atkbdc/psm.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

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

# 250610 13-May-2013 jkim

MFC: r248479

List TrackPoint device before generic model.


# 250078 29-Apr-2013 jkim

MFC: r248478

Add preliminary support for IBM/Lenovo TrackPoint.


# 248085 09-Mar-2013 marius

MFC: r227309 (partial)

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.


# 244976 02-Jan-2013 dumbbell

MFC r244405:
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>


# 242820 09-Nov-2012 hselasky

MFC r240743 and r234418:
Fix some typos.


# 234713 26-Apr-2012 jkim

MFC: r233580

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


# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 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.