xref: /freebsd/share/man/man4/psm.4 (revision 952d112864d8008aa87278a30a539d888a8493cd)
1.\"	$Id$
2.\"
3.Dd January 13, 1997
4.Dt PSM 4 i386
5.Os FreeBSD
6.Sh NAME
7.Nm psm
8.Nd
9PS/2 mouse style pointing device driver
10.Sh SYNOPSIS
11.Cd "options PSM_CHECKSYNC"
12.\".Cd "options PSM_EMULATION"
13.Cd "options" \&"PSM_ACCEL=N\&"
14.Cd "options" \&"KBD_RESETDELAY=N\&"
15.Cd "options" \&"KBD_MAXWAIT=N\&"
16.Cd "options" \&"PSM_DEBUG=N\&"
17.Cd "options" \&"KBDIO_DEBUG=N\&"
18.Cd "device psm0 at isa? port" \&"IO_KBD\&" conflicts tty irq 12 vector psmintr
19.Sh DESCRIPTION
20The
21.Nm
22driver provides support for the PS/2 mouse style pointing device.
23
24.Em port \&"IO_KBD\&"
25and
26.Em conflicts
27are required,
28as the PS/2 mouse port is located
29at the auxiliary port of the keyboard controller, thus, the
30.Nm
31driver has to share the same I/O ports with the keyboard driver.
32Note also that there is currently no provision of changing the
33.Em irq
34number.
35.Pp
36A series of data packets is read from the
37.Nm
38driver. A data packet from the PS/2 mouse style pointing device
39is three bytes long:
40.Pp
41.Bl -tag -width Byte_1 -compact
42.It Byte 1
43.Bl -tag -width bit_7 -compact
44.It bit 7
45One indicates overflow in the vertical movement count.
46.It bit 6
47One indicates overflow in the horizontal movement count.
48.It bit 5
49Set if the vertical movement count is negative.
50.It bit 4
51Set if the horizontal movement count is negative.
52.It bit 3
53The ALPS GlidePoint clears this bit when the user `taps' the surface of
54the pad, otherwise the bit is set.
55Most, if not all, other devices always sets this bit.
56.It bit 2
57Middle button status; set if pressed. For devices without the middle
58button, this bit seems to be always zero.
59.It bit 1
60Right button status; set if pressed.
61.It bit 0
62Left button status; set if pressed.
63.El
64.It Byte 2
65Horizontal movement count in two's compliment;
66-256 through 255.
67Note that the sign bit is in the first byte.
68.It Byte 3
69Vertical movement count in two's compliment;
70-256 through 255.
71Note that the sign bit is in the first byte.
72.El
73.Pp
74The minor device number of the
75.Nm
76is made up of:
77.Bd -literal -offset indent
78minor = (`unit' << 1) | `non-blocking'
79.Ed
80.Pp
81where `unit' is the device number (usually 0) and the `non-blocking' bit
82is set to indicate ``don't block waiting for mouse input,
83return immediately''.
84The `non-blocking' bit should be set for \fIXFree86\fP,
85therefore the minor device number usually used for \fIXFree86\fP is 1.
86See
87.Sx FILES
88for device node names.
89.Sh KERNEL CONFIGURATION
90There are following options to control the
91.Nm
92driver.
93.Bl -tag -width MOUSE
94.It Em PSM_CHECKSYNC
95If this option is defined, the driver tries to detect the first byte of
96the three-byte data packet, by checking the bit pattern of that byte.
97This may be useful if you often experience wierd mouse movement
98cased by unsynchronization between the application program and the mouse.
99However, the
100.Em PSM_CHECKSYNC
101code may not always work; some systems, mostly notebooks, set the bit
102pattern differently from the others.
103Note also that the `tapping' feature of the ALPS GlidePoint will be
104lost when this option is used.
105.\".It Em PSM_EMULATION
106.\"The
107.\".Nm
108.\"driver can emulate the Microsoft Serial Mouse's three-byte
109.\"data packet and the Mouse Systems Corp's five-byte data packet
110.\"when data is read by user programs, if so specified by the
111.\".Fn ioctl
112.\"command
113.\".Dv MOUSE_SETMODE .
114.\"To enable the emulation feature, define this option.
115.It Em PSM_ACCEL=N
116The
117.Nm
118driver can somewhat `accelerate' the movement of the pointing device.
119That is, the faster you move the device, the further the pointer
120travels on the screen. This option controls the amount of acceleration.
121The smaller
122.Fa N
123is, more sensitive the movement becomes.
124The minimum value allowed, thus the value for the most sensitive setting,
125is 1. Setting this option to zero will completely disables the
126acceleration effect. The default value is 0 (acceleration disabled).
127The acceleration effect can also be controlled via the
128.Fn ioctl
129command
130.Dv MOUSE_SETMODE .
131.It Em KBD_RESETDELAY=X, KBD_MAXWAIT=Y
132The
133.Nm
134driver will attempt to reset the pointing device during the boot process.
135It sometimes takes a long while before the device will respond after
136reset. These options control how long the driver should wait before
137it eventually gives up waiting. The driver will wait
138.Fa X
139*
140.Fa Y
141msecs at most. If the driver seems unable to detect your pointing
142device, you may want to increase these values. The default values are
143200 msec for
144.Fa X
145and 5
146for
147.Fa Y .
148.It Em PSM_DEBUG=N, KBDIO_DEBUG=N
149Sets the debug level to
150.Fa N .
151The default debug level is zero. See
152.Sx DIAGNOSTICS
153for debug logging.
154.El
155.Sh IOCTL
156There are only few ioctls for the
157.Nm
158driver. These are defined in
159.Ao Pa machine/mouse.h Ac .
160.Bl -tag -width MOUSE
161.It Dv MOUSEIOCREAD
162The
163.Dv MOUSEIOCREAD
164command did NOT work before and does NOT work now. It is obsolete.
165Use the
166.Dv MOUSE_GETSTATE
167command instead.
168.It Dv MOUSE_GETSTATE
169The command returns the current mouse state in the following structure
170and remove the state information from the internal queue.
171.Bd -literal
172typedef struct mousestatus {
173    int button;     /* button status */
174    int obutton;    /* previous button status */
175    int dx;         /* x movement */
176    int dy;         /* y movement */
177} mousestatus_t;
178.Ed
179.Pp
180The
181.Dv button
182and the
183.Dv obutton
184fields hold the current and the previous state of the mouse buttons.
185When a button is pressed, the corresponding bit is set.
186These bits are defined as
187.Dv MOUSE_BUTTON1DOWN
188through
189.Dv MOUSE_BUTTON8DOWN .
190The first three buttons are left, middle and right buttons.
191.Pp
192Note that this command and
193.Fn read
194operation on the
195.Nm
196driver uses the same internal queue. Therefore, interleaving the
197.Dv MOUSE_GETSTATE
198command and
199.Fn read
200operation is not recommended.
201.It Dv MOUSE_GETINFO
202Returns the hardware information in the following structure.
203.Bd -literal
204typedef struct mousehw {
205    int buttons;    /* number of buttons */
206    int iftype;     /* I/F type */
207    int type;       /* mouse/track ball/pad... */
208    int hwid;       /* I/F dependent hardware ID */
209} mousehw_t;
210.Ed
211.Pp
212The
213.Dv iftype
214is
215.Dv MOUSE_IF_PS2
216for the
217.Nm
218driver. The
219.Dv type
220tells the device type:
221.Dv MOUSE_MOUSE ,
222.Dv MOUSE_TRACKBALL ,
223.Dv MOUSE_STICK ,
224.Dv MOUSE_PAD ,
225or
226.Dv MOUSE_UNKNOWN .
227The user should not heavily rely on this field, as the
228.Nm
229driver may not always, in fact it is very rarely able to, identify
230the device type.
231The
232.Dv hwid
233is the ID value returned by the pointing device.
234Known IDs include:
235.Bl -tag -width 0__ -compact
236.It Em 0
237Mouse (Microsoft, Logitech and many other manufacturers)
238.It Em 2
239Microsoft Ballpoint mouse
240.El
241.It Dv MOUSE_GETMODE, MOUSE_SETMODE
242The commands get and set the operation mode of the
243.Nm
244driver.
245.Bd -literal
246typedef struct mousemode {
247    int protocol;    /* MOUSE_PROTO_XXX */
248    int rate;        /* report rate (per sec), -1 if unknown */
249    int resolution;  /* 1:low, 2:medium low, 3:medium high
250                      * 4:high, 0: default, -1 if unknown
251                      */
252    int accelfactor; /* acceleration factor (must be 1 or greater) */
253} mousemode_t;
254.Ed
255.Pp
256The
257.Dv protocol
258selects the format with which the device status is returned by
259.Fn read .
260The default is
261.Dv MOUSE_PROTO_PS2 ,
262that is, the data byte from the pointing device is read by user
263programs as is.
264No other value is allowed at the moment.
265.\"Other possible values are:
266.\".Dv MOUSE_PROTO_MSS
267.\"and
268.\".Dv MOUSE_PROTO_MSC ,
269.\"which specifies Microsoft Serial Mouse three-byte format and
270.\"Mouse Systems Corp.'s five-byte format respectively.
271.\"Note that the protocol cannot be set to anything other than
272.\".Dv MOUSE_PROTO_PS2
273.\"unless the
274.\".Em PSM_EMULATION
275.\"option is specified in the kernel configuration file.
276.Pp
277The
278.Dv rate
279is the status report rate (reports/sec) at which the device will send
280movement report to the host computer.
281.Pp
282The
283.Dv resolution
284of the pointing device must be zero through four. The higher the value
285is, the finer resolution the mouse will select. Zero selects the
286default resolution.
287.Pp
288The
289.Dv accelfactor
290holds a value to control acceleration feature (see description on
291.Em PSM_ACCEL
292above). It must be zero or greater.
293If it is zero, acceleration is disabled.
294.El
295.Sh DIAGNOSTICS
296.Pp
297At debug level 0, little information is logged except for the following
298line during boot process:
299.Bd -literal -offset indent
300psm0: device ID X
301.Ed
302.Pp
303where
304.Fa X
305the device ID code returned by the found pointing device.
306See
307.Dv MOUSE_GETINFO
308for known IDs.
309.Pp
310At debug level 1 more information will be logged
311while the driver probes the auxiliary port (mouse port).
312Messages are logged with the LOG_KERN facility at the LOG_DEBUG level.
313(See
314.Xr syslogd 8 . )
315.Bd -literal -offset indent
316psm0: current command byte:xxxx
317kbdio: new command byte:yyyy (set_controller...)
318kbdio: TEST_AUX_PORT status:0000
319kbdio: RESET_AUX return code:00fa
320kbdio: RESET_AUX status:00aa
321kbdio: RESET_AUX ID:0000
322psm0: status after reset 00 02 64
323psm: device ID: X
324psm: status xx yy zz (get_mouse_buttons)
325psm0: status 00 02 64
326kbdio: new command byte:zzzz (set_controller...)
327psm0 at 0x60-0x64 irq 12 on motherboard
328psm0: device ID X, N buttons
329.Ed
330.Pp
331The first line shows the command byte value of the keyboard
332controller just before the auxiliary port is probed.
333It usually is 4D, 45, 47 or 65, depending on how the motherboard BIOS
334initialized the keyboard controller upon power-up.
335.Pp
336The third line shows the result of the keyboard controller's
337test on the auxiliary port interface, with zero indicating
338no error; note that some controllers report no error even if
339the port does not exist in the system, however.
340.Pp
341The forth to sixth lines show the reset status of the pointing device.
342The functioning device should return the sequence of FA AA <ID>.
343The ID code is described above.
344.Pp
345The tenth line shows the current hardware settings; it consists
346of three bytes:
347.Pp
348.Bl -tag -width Byte_1 -compact
349.It Byte 1
350.Bl -tag -width bit_6 -compact
351.It bit 7
352Reserved.
353.It bit 6
3540 - stream mode, 1 - remote mode.
355In the stream mode, the pointing device sends the device status
356whenever its state changes. In the remote mode, the host computer
357must request the status to be sent.
358.It bit 5
359Set if the pointing device is currently enabled. Otherwise zero.
360.It bit 4
3610 - 1:1 scaling, 1 - 2:1 scaling.
362.It bit 3
363Reserved.
364.It bit 2
365Left button status; set if pressed.
366.It bit 1
367Middle button status; set if pressed.
368.It bit 0
369Right button status; set if pressed.
370.El
371.It Byte 2
372.Bl -tag -width bit_6_0 -compact
373.It bit 7
374Reserved.
375.It bit 6-0
376Resolution code: zero through three. The higher the number is,
377the finer resolution the device has. Actual resolution for
378the resolution code varies from one device to another.
379The typical values are:
380.Bl -tag -width 100 -compact
381.It 0
38225 pulse per inch (ppi)
383.It 1
38450 ppi
385.It 2
386100 ppi
387.It 3
388200 ppi
389.El
390.El
391.It Byte 3
392The status report rate (reports/sec) at which the device will send
393movement report to the host computer.
394.El
395.Pp
396Note that the pointing device will not be enabled until the
397.Nm
398driver is opened by the user programs.
399.Pp
400The last line shows the device ID code and the number of detected
401buttons. Currently the
402.Nm
403driver can detect the 3 button mouse from Logitech and report
404accordingly.
405The 3 button mouse from the other manufacturer may or may not be
406reported correctly. However, it will not affect the operation of
407the driver.
408.Pp
409At debug level 2, much more detailed information is logged.
410.Sh FILES
411.Bl -tag -width /dev/npsm0 -compact
412.It Pa /dev/psm0
413`non-blocking' device node in the system without
414.Em devfs ,
415`blocking' under
416.Em devfs .
417.It Pa /dev/npsm0
418`non-blocking' device node under
419.Em devfs .
420.El
421.Sh CAVEATS
422There is not a guaranteed way to re-synchronize with the first byte
423of the packet once we are out of synchronization with the data
424stream. However, if you are using the \fIXFree86\fP server and experiencing
425the problem, you may be able to make the X server synchronize with the mouse
426by switching away to a virtual terminal and getting back to the X server,
427unless the X server is accessing the mouse via
428.Xr moused 1 .
429If you have specified the
430.Em PSM_CHECKSYNC
431option, clicking any button without moving the mouse may also work.
432.Sh BUGS
433The
434.Fn ioctl
435command
436.Dv MOUSEIOCREAD
437(see
438.Sx IOCTL
439above) was never functional and will not be. The command name
440still remains for compatibility reasons but may be removed in the future.
441.Sh SEE ALSO
442.Xr moused 1 ,
443.Xr syslog 3 ,
444.Xr mse 4 ,
445.Xr syslogd 8
446.\" .Sh HISTORY
447.\" .Sh AUTHOR
448