1994-09-09 11:27:50 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1992, 1993 Erik Forsberg.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
|
|
|
* NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1996-11-15 05:30:52 +00:00
|
|
|
*
|
1997-11-21 11:36:21 +00:00
|
|
|
* $Id: psm.c,v 1.45 1997/11/18 12:21:32 bde Exp $
|
1994-09-09 11:27:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* Ported to 386bsd Oct 17, 1992
|
1994-09-09 11:27:50 +00:00
|
|
|
* Sandi Donno, Computer Science, University of Cape Town, South Africa
|
|
|
|
* Please send bug reports to sandi@cs.uct.ac.za
|
|
|
|
*
|
|
|
|
* Thanks are also due to Rick Macklem, rick@snowhite.cis.uoguelph.ca -
|
|
|
|
* although I was only partially successful in getting the alpha release
|
1995-05-30 08:16:23 +00:00
|
|
|
* of his "driver for the Logitech and ATI Inport Bus mice for use with
|
|
|
|
* 386bsd and the X386 port" to work with my Microsoft mouse, I nevertheless
|
|
|
|
* found his code to be an invaluable reference when porting this driver
|
1994-09-09 11:27:50 +00:00
|
|
|
* to 386bsd.
|
|
|
|
*
|
|
|
|
* Further modifications for latest 386BSD+patchkit and port to NetBSD,
|
|
|
|
* Andrew Herbert <andrew@werple.apana.org.au> - 8 June 1993
|
|
|
|
*
|
|
|
|
* Cloned from the Microsoft Bus Mouse driver, also by Erik Forsberg, by
|
1995-05-30 08:16:23 +00:00
|
|
|
* Andrew Herbert - 12 June 1993
|
1994-09-09 11:27:50 +00:00
|
|
|
*
|
|
|
|
* Modified for PS/2 mouse by Charles Hannum <mycroft@ai.mit.edu>
|
|
|
|
* - 13 June 1993
|
|
|
|
*
|
|
|
|
* Modified for PS/2 AUX mouse by Shoji Yuen <yuen@nuie.nagoya-u.ac.jp>
|
|
|
|
* - 24 October 1993
|
1996-11-15 05:30:52 +00:00
|
|
|
*
|
|
|
|
* Hardware access routines and probe logic rewritten by
|
|
|
|
* Kazutaka Yokota <yokota@zodiac.mech.utsunomiya-u.ac.jp>
|
1996-11-15 06:17:36 +00:00
|
|
|
* - 3 October 1996.
|
1996-11-15 05:30:52 +00:00
|
|
|
* - 14 October 1996.
|
|
|
|
* - 22 October 1996.
|
|
|
|
* - 12 November 1996. IOCTLs and rearranging `psmread', `psmioctl'...
|
|
|
|
* - 14 November 1996. Uses `kbdio.c'.
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
* - 30 November 1996. More fixes.
|
1997-01-15 18:16:32 +00:00
|
|
|
* - 13 December 1996. Uses queuing version of `kbdio.c'.
|
1994-09-09 11:27:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "psm.h"
|
1997-06-30 12:52:57 +00:00
|
|
|
#include "apm.h"
|
1997-01-15 18:16:32 +00:00
|
|
|
#include "opt_psm.h"
|
1994-09-09 11:27:50 +00:00
|
|
|
|
|
|
|
#if NPSM > 0
|
|
|
|
|
1995-02-26 05:14:53 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
1995-12-08 11:19:42 +00:00
|
|
|
#include <sys/conf.h>
|
1997-09-14 03:19:42 +00:00
|
|
|
#include <sys/poll.h>
|
1996-11-15 05:30:52 +00:00
|
|
|
#include <sys/syslog.h>
|
1996-11-27 22:52:25 +00:00
|
|
|
#include <sys/malloc.h>
|
1995-12-08 11:19:42 +00:00
|
|
|
#ifdef DEVFS
|
|
|
|
#include <sys/devfsext.h>
|
1996-11-15 06:17:36 +00:00
|
|
|
#endif
|
1997-11-18 12:21:32 +00:00
|
|
|
#include <sys/select.h>
|
1994-09-09 11:27:50 +00:00
|
|
|
|
1997-11-18 12:21:32 +00:00
|
|
|
#include <machine/apm_bios.h>
|
|
|
|
#include <machine/clock.h>
|
|
|
|
#include <machine/mouse.h>
|
1994-09-09 11:27:50 +00:00
|
|
|
|
1995-02-26 05:14:53 +00:00
|
|
|
#include <i386/isa/isa_device.h>
|
1996-11-15 05:30:52 +00:00
|
|
|
#include <i386/isa/kbdio.h>
|
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
/*
|
|
|
|
* driver specific options: the following options may be set by
|
|
|
|
* `options' statements in the kernel configuration file.
|
|
|
|
*/
|
1996-11-15 05:30:52 +00:00
|
|
|
|
|
|
|
/* debugging */
|
|
|
|
#ifndef PSM_DEBUG
|
1996-11-15 06:17:36 +00:00
|
|
|
#define PSM_DEBUG 0 /* logging: 0: none, 1: brief, 2: verbose */
|
1996-11-15 05:30:52 +00:00
|
|
|
#endif
|
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* #define PSM_CHECKSYNC if defined, check the header data byte */
|
1996-11-15 05:30:52 +00:00
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* features */
|
1996-11-15 05:30:52 +00:00
|
|
|
#ifndef PSM_ACCEL
|
1996-11-15 17:30:29 +00:00
|
|
|
#define PSM_ACCEL 0 /* must be one or greater; acceleration will be
|
1996-11-15 06:17:36 +00:00
|
|
|
* disabled if zero */
|
1996-11-15 05:30:52 +00:00
|
|
|
#endif
|
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* #define PSM_EMULATION enables protocol emulation */
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1997-06-30 12:52:57 +00:00
|
|
|
/* #define PSM_HOOKAPM hook the APM resume event */
|
|
|
|
/* #define PSM_RESETAFTERSUSPEND reset the device at the resume event */
|
|
|
|
|
|
|
|
#if NAPM <= 0
|
|
|
|
#undef PSM_HOOKAPM
|
|
|
|
#endif /* NAPM */
|
|
|
|
|
|
|
|
#ifndef PSM_HOOKAPM
|
|
|
|
#undef PSM_RESETAFTERSUSPEND
|
|
|
|
#endif /* PSM_HOOKAPM */
|
|
|
|
|
1996-11-15 05:30:52 +00:00
|
|
|
/* end of driver specific options */
|
|
|
|
|
|
|
|
/* some macros */
|
|
|
|
#define PSM_UNIT(dev) (minor(dev) >> 1)
|
|
|
|
#define PSM_NBLOCKIO(dev) (minor(dev) & 1)
|
|
|
|
#define PSM_MKMINOR(unit,block) (((unit) << 1) | ((block) ? 0:1))
|
|
|
|
|
|
|
|
#ifndef max
|
1996-11-15 06:17:36 +00:00
|
|
|
#define max(x,y) ((x) > (y) ? (x) : (y))
|
1996-11-15 05:30:52 +00:00
|
|
|
#endif
|
1994-09-09 11:27:50 +00:00
|
|
|
#ifndef min
|
1996-11-15 06:17:36 +00:00
|
|
|
#define min(x,y) ((x) < (y) ? (x) : (y))
|
1996-11-15 05:30:52 +00:00
|
|
|
#endif
|
1994-09-09 11:27:50 +00:00
|
|
|
|
1996-11-15 05:30:52 +00:00
|
|
|
/* ring buffer */
|
1996-11-15 06:17:36 +00:00
|
|
|
#define PSM_BUFSIZE 256
|
1996-11-15 05:30:52 +00:00
|
|
|
|
|
|
|
typedef struct ringbuf {
|
1996-11-15 06:17:36 +00:00
|
|
|
int count;
|
|
|
|
int head;
|
|
|
|
int tail;
|
|
|
|
mousestatus_t buf[PSM_BUFSIZE];
|
1996-11-15 05:30:52 +00:00
|
|
|
} ringbuf_t;
|
|
|
|
|
|
|
|
/* driver control block */
|
1996-11-15 05:41:34 +00:00
|
|
|
typedef int (*packetfunc_t) __P((unsigned char *, int *, int, mousestatus_t *));
|
1994-09-09 11:27:50 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
static struct psm_softc { /* Driver status information */
|
|
|
|
struct selinfo rsel; /* Process selecting for Input */
|
|
|
|
unsigned char state; /* Mouse driver state */
|
1997-01-15 18:16:32 +00:00
|
|
|
KBDC kbdc;
|
1996-11-15 06:17:36 +00:00
|
|
|
int addr; /* I/O port address */
|
|
|
|
mousehw_t hw; /* hardware information */
|
|
|
|
mousemode_t mode; /* operation mode */
|
1997-01-15 18:16:32 +00:00
|
|
|
mousemode_t dflt_mode; /* default operation mode */
|
1996-11-15 06:17:36 +00:00
|
|
|
ringbuf_t queue; /* mouse status queue */
|
|
|
|
packetfunc_t mkpacket; /* func. to turn queued data into output format */
|
1997-01-15 18:16:32 +00:00
|
|
|
unsigned char ipacket[MOUSE_PS2_PACKETSIZE];/* interim input buffer */
|
1996-11-15 06:17:36 +00:00
|
|
|
unsigned char opacket[PSM_BUFSIZE]; /* output buffer */
|
|
|
|
int inputbytes; /* # of bytes in the input buffer */
|
|
|
|
int outputbytes; /* # of bytes in the output buffer */
|
|
|
|
int outputhead; /* points the head of the output buffer */
|
|
|
|
int button; /* the latest button state */
|
1995-12-08 11:19:42 +00:00
|
|
|
#ifdef DEVFS
|
1996-11-15 06:17:36 +00:00
|
|
|
void *devfs_token;
|
|
|
|
void *n_devfs_token;
|
1995-12-08 11:19:42 +00:00
|
|
|
#endif
|
1997-06-30 12:52:57 +00:00
|
|
|
#ifdef PSM_HOOKAPM
|
|
|
|
struct apmhook resumehook;
|
|
|
|
#endif
|
1996-11-27 22:52:25 +00:00
|
|
|
} *psm_softc[NPSM];
|
1994-09-09 11:27:50 +00:00
|
|
|
|
1996-11-15 05:30:52 +00:00
|
|
|
/* driver state flags (state) */
|
1996-11-15 06:17:36 +00:00
|
|
|
#define PSM_VALID 0x80
|
|
|
|
#define PSM_OPEN 1 /* Device is open */
|
|
|
|
#define PSM_ASLP 2 /* Waiting for mouse data */
|
1996-11-15 05:30:52 +00:00
|
|
|
|
|
|
|
/* function prototypes */
|
|
|
|
static int psmprobe __P((struct isa_device *));
|
|
|
|
static int psmattach __P((struct isa_device *));
|
1997-06-30 12:52:57 +00:00
|
|
|
static void psm_drvinit __P((void *));
|
|
|
|
#ifdef PSM_HOOKAPM
|
|
|
|
static int psmresume __P((void *));
|
|
|
|
#endif
|
1996-11-15 05:30:52 +00:00
|
|
|
|
|
|
|
static d_open_t psmopen;
|
|
|
|
static d_close_t psmclose;
|
|
|
|
static d_read_t psmread;
|
|
|
|
static d_ioctl_t psmioctl;
|
1997-09-14 03:19:42 +00:00
|
|
|
static d_poll_t psmpoll;
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1997-06-30 12:52:57 +00:00
|
|
|
static int enable_aux_dev __P((KBDC));
|
|
|
|
static int disable_aux_dev __P((KBDC));
|
|
|
|
static int get_mouse_status __P((KBDC, int *));
|
|
|
|
static int get_aux_id __P((KBDC));
|
|
|
|
static int set_mouse_sampling_rate __P((KBDC, int));
|
|
|
|
static int set_mouse_scaling __P((KBDC));
|
|
|
|
static int set_mouse_resolution __P((KBDC, int));
|
|
|
|
static int set_mouse_mode __P((KBDC));
|
|
|
|
static int get_mouse_buttons __P((KBDC));
|
|
|
|
static int is_a_mouse __P((int));
|
|
|
|
static void recover_from_error __P((KBDC));
|
|
|
|
static int restore_controller __P((KBDC, int));
|
|
|
|
static int reinitialize __P((int, mousemode_t *));
|
|
|
|
static int doopen __P((int, int));
|
|
|
|
static int mkms __P((unsigned char *, int *, int, mousestatus_t *));
|
|
|
|
static int mkman __P((unsigned char *, int *, int, mousestatus_t *));
|
|
|
|
static int mkmsc __P((unsigned char *, int *, int, mousestatus_t *));
|
|
|
|
static int mkmm __P((unsigned char *, int *, int, mousestatus_t *));
|
|
|
|
static int mkps2 __P((unsigned char *, int *, int, mousestatus_t *));
|
|
|
|
|
1996-11-15 05:30:52 +00:00
|
|
|
/* device driver declarateion */
|
|
|
|
struct isa_driver psmdriver = { psmprobe, psmattach, "psm", FALSE };
|
1996-11-15 06:17:36 +00:00
|
|
|
#define CDEV_MAJOR 21
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
static struct cdevsw psm_cdevsw = {
|
1996-11-15 05:30:52 +00:00
|
|
|
psmopen, psmclose, psmread, nowrite, /* 21 */
|
1996-11-15 06:17:36 +00:00
|
|
|
psmioctl, nostop, nullreset, nodevtotty,
|
1997-09-14 03:19:42 +00:00
|
|
|
psmpoll, nommap, NULL, "psm", NULL, -1
|
1996-11-15 05:30:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* debug message level */
|
|
|
|
static int verbose = PSM_DEBUG;
|
|
|
|
|
|
|
|
/* device I/O routines */
|
|
|
|
static int
|
1997-01-15 18:16:32 +00:00
|
|
|
enable_aux_dev(KBDC kbdc)
|
1996-11-15 05:30:52 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
int res;
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
res = send_aux_command(kbdc, PSMC_ENABLE_DEV);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm: ENABLE_DEV return code:%04x\n", res);
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
return (res == PSM_ACK);
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-01-15 18:16:32 +00:00
|
|
|
disable_aux_dev(KBDC kbdc)
|
1996-11-15 05:30:52 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
int res;
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
res = send_aux_command(kbdc, PSMC_DISABLE_DEV);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm: DISABLE_DEV return code:%04x\n", res);
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
return (res == PSM_ACK);
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-01-15 18:16:32 +00:00
|
|
|
get_mouse_status(KBDC kbdc, int *status)
|
1996-11-15 05:30:52 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
int res;
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
empty_aux_buffer(kbdc, 5);
|
|
|
|
res = send_aux_command(kbdc, PSMC_SEND_DEV_STATUS);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm: SEND_AUX_STATUS return code:%04x\n", res);
|
|
|
|
if (res != PSM_ACK)
|
|
|
|
return FALSE;
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
status[0] = read_aux_data(kbdc);
|
|
|
|
status[1] = read_aux_data(kbdc);
|
|
|
|
status[2] = read_aux_data(kbdc);
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
return TRUE;
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-01-15 18:16:32 +00:00
|
|
|
get_aux_id(KBDC kbdc)
|
1996-11-15 05:30:52 +00:00
|
|
|
{
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
int res;
|
1996-11-15 06:17:36 +00:00
|
|
|
int id;
|
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
empty_aux_buffer(kbdc, 5);
|
|
|
|
res = send_aux_command(kbdc, PSMC_SEND_DEV_ID);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm: SEND_DEV_ID return code:%04x\n", res);
|
|
|
|
if (res != PSM_ACK)
|
|
|
|
return (-1);
|
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
/* 10ms delay */
|
|
|
|
DELAY(10000);
|
1996-11-15 06:17:36 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
id = read_aux_data(kbdc);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm: device ID: %04x\n", id);
|
|
|
|
|
|
|
|
return id;
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-01-15 18:16:32 +00:00
|
|
|
set_mouse_sampling_rate(KBDC kbdc, int rate)
|
1996-11-15 05:30:52 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
int res;
|
1994-09-09 11:27:50 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
res = send_aux_command_and_data(kbdc, PSMC_SET_SAMPLING_RATE, rate);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm: SET_SAMPLING_RATE (%d) %04x\n", rate, res);
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
return ((res == PSM_ACK) ? rate : -1);
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-01-15 18:16:32 +00:00
|
|
|
set_mouse_scaling(KBDC kbdc)
|
1996-11-15 05:30:52 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
int res;
|
1994-09-09 11:27:50 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
res = send_aux_command(kbdc, PSMC_SET_SCALING11);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm: SET_SCALING11 return code:%04x\n", res);
|
1995-12-08 11:19:42 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
return (res == PSM_ACK);
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
/* `val' must be 0 through PSMD_MAX_RESOLUTION */
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
static int
|
1997-01-15 18:16:32 +00:00
|
|
|
set_mouse_resolution(KBDC kbdc, int val)
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
{
|
1997-01-15 18:16:32 +00:00
|
|
|
int res;
|
1996-11-15 06:17:36 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
res = send_aux_command_and_data(kbdc, PSMC_SET_RESOLUTION, val);
|
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm: SET_RESOLUTION (%d) %04x\n", val, res);
|
1996-11-15 06:17:36 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
return ((res == PSM_ACK) ? val : -1);
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
/*
|
|
|
|
* NOTE: once `set_mouse_mode()' is called, the mouse device must be
|
|
|
|
* re-enabled by calling `enable_aux_dev()'
|
|
|
|
*/
|
1996-11-15 05:30:52 +00:00
|
|
|
static int
|
1997-01-15 18:16:32 +00:00
|
|
|
set_mouse_mode(KBDC kbdc)
|
1996-11-15 05:30:52 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
int res;
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
res = send_aux_command(kbdc, PSMC_SET_STREAM_MODE);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm: SET_STREAM_MODE return code:%04x\n", res);
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
return (res == PSM_ACK);
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1997-01-15 18:16:32 +00:00
|
|
|
get_mouse_buttons(KBDC kbdc)
|
1996-11-15 05:30:52 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
int c = 2; /* assume two buttons by default */
|
|
|
|
int status[3];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: a special sequence to obtain Logitech-Mouse-specific
|
|
|
|
* information: set resolution to 25 ppi, set scaling to 1:1, set
|
|
|
|
* scaling to 1:1, set scaling to 1:1. Then the second byte of the
|
|
|
|
* mouse status bytes is the number of available buttons.
|
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
if (set_mouse_resolution(kbdc, PSMD_RES_LOW) != PSMD_RES_LOW)
|
1996-11-15 06:17:36 +00:00
|
|
|
return c;
|
1997-01-15 18:16:32 +00:00
|
|
|
if (set_mouse_scaling(kbdc) && set_mouse_scaling(kbdc)
|
|
|
|
&& set_mouse_scaling(kbdc) && get_mouse_status(kbdc, status)) {
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose) {
|
|
|
|
log(LOG_DEBUG, "psm: status %02x %02x %02x (get_mouse_buttons)\n",
|
|
|
|
status[0], status[1], status[2]);
|
|
|
|
}
|
1997-01-15 18:16:32 +00:00
|
|
|
if (status[1] != 0)
|
|
|
|
return status[1];
|
1996-11-15 06:17:36 +00:00
|
|
|
}
|
|
|
|
return c;
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
/*
|
|
|
|
* FIXME:XXX
|
|
|
|
* someday, I will get the list of valid pointing devices and
|
|
|
|
* their IDs...
|
|
|
|
*/
|
1996-11-15 05:30:52 +00:00
|
|
|
static int
|
|
|
|
is_a_mouse(int id)
|
|
|
|
{
|
1997-11-07 08:53:44 +00:00
|
|
|
#if 0
|
1996-11-15 06:17:36 +00:00
|
|
|
static int valid_ids[] = {
|
|
|
|
PSM_MOUSE_ID, /* mouse */
|
|
|
|
PSM_BALLPOINT_ID, /* ballpoint device */
|
|
|
|
-1 /* end of table */
|
|
|
|
};
|
1997-01-15 18:16:32 +00:00
|
|
|
int i;
|
1996-11-15 06:17:36 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
for (i = 0; valid_ids[i] >= 0; ++i)
|
|
|
|
if (valid_ids[i] == id)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
#else
|
1996-11-15 06:17:36 +00:00
|
|
|
return TRUE;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
#endif
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
1995-12-08 11:19:42 +00:00
|
|
|
|
1996-05-07 19:01:31 +00:00
|
|
|
static void
|
1997-01-15 18:16:32 +00:00
|
|
|
recover_from_error(KBDC kbdc)
|
1994-09-09 11:27:50 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
/* discard anything left in the output buffer */
|
1997-01-15 18:16:32 +00:00
|
|
|
empty_both_buffers(kbdc, 10);
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* NOTE: KBDC_RESET_KBD may not restore the communication between the
|
|
|
|
* keyboard and the controller.
|
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
reset_kbd(kbdc);
|
1996-11-15 06:17:36 +00:00
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* NOTE: somehow diagnostic and keyboard port test commands bring the
|
|
|
|
* keyboard back.
|
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
if (!test_controller(kbdc))
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
log(LOG_ERR, "psm: keyboard controller failed.\n");
|
|
|
|
/* if there isn't a keyboard in the system, the following error is OK */
|
1997-01-15 18:16:32 +00:00
|
|
|
if (test_kbd_port(kbdc) != 0) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
if (verbose)
|
|
|
|
log(LOG_ERR, "psm: keyboard port failed.\n");
|
|
|
|
}
|
1996-11-15 06:17:36 +00:00
|
|
|
#endif
|
1994-09-09 11:27:50 +00:00
|
|
|
}
|
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
static int
|
1997-01-15 18:16:32 +00:00
|
|
|
restore_controller(KBDC kbdc, int command_byte)
|
1994-09-09 11:27:50 +00:00
|
|
|
{
|
1997-01-15 18:16:32 +00:00
|
|
|
if (!set_controller_command_byte(kbdc, 0xff, command_byte)) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
log(LOG_ERR, "psm: failed to restore the keyboard controller "
|
|
|
|
"command byte.\n");
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Re-initialize the aux port and device. The aux port must be enabled
|
|
|
|
* and its interrupt must be disabled before calling this routine.
|
|
|
|
* The aux device will be disabled before returning.
|
1997-01-15 18:16:32 +00:00
|
|
|
* The keyboard controller must be locked via `kbdc_lock()' before
|
|
|
|
* calling this routine.
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
*/
|
|
|
|
static int
|
1997-06-30 12:52:57 +00:00
|
|
|
reinitialize(int unit, mousemode_t *mode)
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
{
|
1997-06-30 12:52:57 +00:00
|
|
|
KBDC kbdc = psm_softc[unit]->kbdc;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
int stat[3];
|
|
|
|
int i;
|
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
switch((i = test_aux_port(kbdc))) {
|
|
|
|
case 1: /* ignore this error */
|
|
|
|
if (verbose)
|
|
|
|
log(LOG_DEBUG, "psm%d: strange result for test aux port (%d).\n",
|
1997-06-30 12:52:57 +00:00
|
|
|
unit, i);
|
1997-01-15 18:16:32 +00:00
|
|
|
/* fall though */
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
case 0: /* no error */
|
|
|
|
break;
|
|
|
|
case -1: /* time out */
|
|
|
|
default: /* error */
|
1997-01-15 18:16:32 +00:00
|
|
|
recover_from_error(kbdc);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
log(LOG_ERR, "psm%d: the aux port is not functioning (%d).\n",
|
1997-06-30 12:52:57 +00:00
|
|
|
unit,i);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: some controllers appears to hang the `keyboard' when
|
|
|
|
* the aux port doesn't exist and `PSMC_RESET_DEV' is issued.
|
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
if (!reset_aux_dev(kbdc)) {
|
|
|
|
recover_from_error(kbdc);
|
1997-06-30 12:52:57 +00:00
|
|
|
log(LOG_ERR, "psm%d: failed to reset the aux device.\n", unit);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* both the aux port and the aux device is functioning, see
|
|
|
|
* if the device can be enabled.
|
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
if (!enable_aux_dev(kbdc) || !disable_aux_dev(kbdc)) {
|
1997-06-30 12:52:57 +00:00
|
|
|
log(LOG_ERR, "psm%d: failed to enable the aux device.\n", unit);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
1997-01-15 18:16:32 +00:00
|
|
|
empty_both_buffers(kbdc, 10); /* remove stray data if any */
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
|
|
|
|
/* set mouse parameters */
|
|
|
|
if (mode != (mousemode_t *)NULL) {
|
|
|
|
if (mode->rate > 0)
|
1997-01-15 18:16:32 +00:00
|
|
|
mode->rate = set_mouse_sampling_rate(kbdc, mode->rate);
|
|
|
|
if (mode->resolution >= 0)
|
|
|
|
mode->resolution = set_mouse_resolution(kbdc, mode->resolution);
|
|
|
|
set_mouse_scaling(kbdc);
|
|
|
|
set_mouse_mode(kbdc);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* just check the status of the mouse */
|
1997-01-15 18:16:32 +00:00
|
|
|
i = get_mouse_status(kbdc, stat);
|
|
|
|
if (!i) {
|
1997-06-30 12:52:57 +00:00
|
|
|
log(LOG_DEBUG, "psm%d: failed to get status.\n", unit);
|
1997-01-15 18:16:32 +00:00
|
|
|
} else if (verbose) {
|
1997-06-30 12:52:57 +00:00
|
|
|
log(LOG_DEBUG, "psm%d: status %02x %02x %02x\n", unit,
|
|
|
|
stat[0], stat[1], stat[2]);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
1994-09-09 11:27:50 +00:00
|
|
|
}
|
|
|
|
|
1997-06-30 12:52:57 +00:00
|
|
|
static int
|
|
|
|
doopen(int unit, int command_byte)
|
|
|
|
{
|
|
|
|
struct psm_softc *sc = psm_softc[unit];
|
|
|
|
int stat[3];
|
|
|
|
|
|
|
|
/* enable the mouse device */
|
|
|
|
if (!enable_aux_dev(sc->kbdc)) {
|
|
|
|
/* MOUSE ERROR: failed to enable the mouse because:
|
|
|
|
* 1) the mouse is faulty,
|
|
|
|
* 2) the mouse has been removed(!?)
|
|
|
|
* In the latter case, the keyboard may have hung, and need
|
|
|
|
* recovery procedure...
|
|
|
|
*/
|
|
|
|
recover_from_error(sc->kbdc);
|
|
|
|
#if 0
|
|
|
|
/* FIXME: we could reset the mouse here and try to enable
|
|
|
|
* it again. But it will take long time and it's not a good
|
|
|
|
* idea to disable the keyboard that long...
|
|
|
|
*/
|
|
|
|
if (!reinitialize(unit, &sc->mode)) {
|
|
|
|
if (!enable_aux_dev(sc->kbdc))
|
|
|
|
recover_from_error(sc->kbdc);
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
restore_controller(sc->kbdc, command_byte);
|
|
|
|
/* mark this device is no longer available */
|
|
|
|
sc->state &= ~PSM_VALID;
|
|
|
|
log(LOG_ERR, "psm%d: failed to enable the device (doopen).\n",
|
|
|
|
unit);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!get_mouse_status(sc->kbdc, stat))
|
|
|
|
log(LOG_DEBUG, "psm%d: failed to get status (doopen).\n", unit);
|
|
|
|
|
|
|
|
/* enable the aux port and interrupt */
|
|
|
|
if (!set_controller_command_byte(sc->kbdc,
|
|
|
|
kbdc_get_device_mask(sc->kbdc),
|
|
|
|
(command_byte & KBD_KBD_CONTROL_BITS)
|
|
|
|
| KBD_ENABLE_AUX_PORT | KBD_ENABLE_AUX_INT)) {
|
|
|
|
/* CONTROLLER ERROR */
|
|
|
|
disable_aux_dev(sc->kbdc);
|
|
|
|
restore_controller(sc->kbdc, command_byte);
|
|
|
|
log(LOG_ERR, "psm%d: failed to enable the aux interrupt (doopen).\n",
|
|
|
|
unit);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1996-11-15 05:30:52 +00:00
|
|
|
/* psm driver entry points */
|
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
#define endprobe(v) { if (bootverbose) \
|
|
|
|
--verbose; \
|
|
|
|
kbdc_set_device_mask(sc->kbdc, mask); \
|
|
|
|
kbdc_lock(sc->kbdc, FALSE); \
|
1997-05-27 11:55:41 +00:00
|
|
|
free(sc, M_DEVBUF); \
|
1997-01-15 18:16:32 +00:00
|
|
|
return (v); \
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
}
|
|
|
|
|
1996-11-15 05:30:52 +00:00
|
|
|
static int
|
1995-12-10 13:40:44 +00:00
|
|
|
psmprobe(struct isa_device *dvp)
|
1994-09-09 11:27:50 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
int unit = dvp->id_unit;
|
|
|
|
struct psm_softc *sc;
|
|
|
|
int stat[3];
|
1997-01-15 18:16:32 +00:00
|
|
|
int command_byte;
|
|
|
|
int mask;
|
1996-11-15 06:17:36 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* validate unit number */
|
|
|
|
if (unit >= NPSM)
|
|
|
|
return (0);
|
|
|
|
|
1997-01-16 18:57:19 +00:00
|
|
|
psm_softc[unit] = NULL;
|
|
|
|
|
1996-11-28 17:18:56 +00:00
|
|
|
sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT);
|
1997-11-18 12:21:32 +00:00
|
|
|
if (sc == NULL)
|
|
|
|
return (0);
|
1996-11-28 17:18:56 +00:00
|
|
|
bzero(sc, sizeof *sc);
|
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
sc->addr = dvp->id_iobase;
|
|
|
|
sc->kbdc = kbdc_open(sc->addr);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (bootverbose)
|
|
|
|
++verbose;
|
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
if (!kbdc_lock(sc->kbdc, TRUE)) {
|
|
|
|
printf("psm%d: unable to lock the controller.\n", unit);
|
|
|
|
if (bootverbose)
|
|
|
|
--verbose;
|
1997-05-27 11:55:41 +00:00
|
|
|
free(sc, M_DEVBUF);
|
1997-01-15 18:16:32 +00:00
|
|
|
return (0);
|
|
|
|
}
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: two bits in the command byte controls the operation of the
|
|
|
|
* aux port (mouse port): the aux port disable bit (bit 5) and the aux
|
|
|
|
* port interrupt (IRQ 12) enable bit (bit 2). When this probe routine
|
|
|
|
* is called, there are following possibilities about the presence of
|
|
|
|
* the aux port and the PS/2 mouse.
|
|
|
|
*
|
|
|
|
* Case 1: aux port disabled (bit 5:1), aux int. disabled (bit 2:0) The
|
|
|
|
* aux port most certainly exists. A device may or may not be
|
|
|
|
* connected to the port. No driver is probably installed yet.
|
|
|
|
*
|
|
|
|
* Case 2: aux port enabled (bit 5:0), aux int. disabled (bit 2:0) Three
|
|
|
|
* possibile situations here:
|
|
|
|
*
|
|
|
|
* Case 2a: The aux port does not exist, therefore, is not explicitly
|
|
|
|
* disabled. Case 2b: The aux port exists. A device and a driver may
|
|
|
|
* exist, using the device in the polling(remote) mode. Case 2c: The
|
|
|
|
* aux port exists. A device may exist, but someone who knows nothing
|
1997-01-15 18:16:32 +00:00
|
|
|
* about the aux port has set the command byte this way.
|
1996-11-15 06:17:36 +00:00
|
|
|
*
|
|
|
|
* Case 3: aux port disabled (bit 5:1), aux int. enabled (bit 2:1) The
|
|
|
|
* aux port exists, but someone is controlloing the device and
|
|
|
|
* temporalily disabled the port.
|
|
|
|
*
|
|
|
|
* Case 4: aux port enabled (bit 5:0), aux int. enabled (bit 2:1) The aux
|
|
|
|
* port exists, a device is attached to the port, and someone is
|
|
|
|
* controlling the device. Some BIOS set the bits this way after boot.
|
|
|
|
*
|
|
|
|
* All in all, it is no use examing the bits for detecting the presence
|
|
|
|
* of the port and the mouse device.
|
|
|
|
*/
|
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
/* discard anything left after the keyboard initialization */
|
|
|
|
empty_both_buffers(sc->kbdc, 10);
|
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
/* save the current command byte; it will be used later */
|
1997-01-15 18:16:32 +00:00
|
|
|
mask = kbdc_get_device_mask(sc->kbdc) & ~KBD_AUX_CONTROL_BITS;
|
|
|
|
command_byte = get_controller_command_byte(sc->kbdc);
|
|
|
|
if (verbose)
|
|
|
|
printf("psm%d: current command byte:%04x\n", unit, command_byte);
|
|
|
|
if (command_byte == -1) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* CONTROLLER ERROR */
|
1996-11-15 06:17:36 +00:00
|
|
|
printf("psm%d: unable to get the current command byte value.\n",
|
|
|
|
unit);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
endprobe(0);
|
1996-11-15 06:17:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* disable the keyboard port while probing the aux port, which must be
|
|
|
|
* enabled during this routine
|
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
if (!set_controller_command_byte(sc->kbdc,
|
|
|
|
KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS,
|
|
|
|
KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
|
|
|
|
| KBD_ENABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/*
|
|
|
|
* this is CONTROLLER ERROR; I don't know how to recover
|
|
|
|
* from this error...
|
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
restore_controller(sc->kbdc, command_byte);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
printf("psm%d: unable to set the command byte.\n", unit);
|
|
|
|
endprobe(0);
|
|
|
|
}
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: `test_aux_port()' is designed to return with zero if the aux
|
|
|
|
* port exists and is functioning. However, some controllers appears
|
|
|
|
* to respond with zero even when the aux port doesn't exist. (It may
|
|
|
|
* be that this is only the case when the controller DOES have the aux
|
|
|
|
* port but the port is not wired on the motherboard.) The keyboard
|
|
|
|
* controllers without the port, such as the original AT, are
|
|
|
|
* supporsed to return with an error code or simply time out. In any
|
|
|
|
* case, we have to continue probing the port even when the controller
|
|
|
|
* passes this test.
|
1997-01-15 18:16:32 +00:00
|
|
|
*
|
|
|
|
* XXX: some controllers erroneously return the error code 1 when
|
|
|
|
* it has the perfectly functional aux port. We have to ignore this
|
|
|
|
* error code. Even if the controller HAS error with the aux port,
|
|
|
|
* it will be detected later...
|
1996-11-15 06:17:36 +00:00
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
switch ((i = test_aux_port(sc->kbdc))) {
|
|
|
|
case 1: /* ignore this error */
|
|
|
|
if (verbose)
|
|
|
|
printf("psm%d: strange result for test aux port (%d).\n",
|
|
|
|
unit, i);
|
|
|
|
/* fall though */
|
1996-11-15 06:17:36 +00:00
|
|
|
case 0: /* no error */
|
|
|
|
break;
|
|
|
|
case -1: /* time out */
|
|
|
|
default: /* error */
|
1997-01-15 18:16:32 +00:00
|
|
|
recover_from_error(sc->kbdc);
|
|
|
|
restore_controller(sc->kbdc, command_byte);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose)
|
|
|
|
printf("psm%d: the aux port is not functioning (%d).\n",
|
|
|
|
unit, i);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
endprobe(0);
|
1996-11-15 06:17:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: some controllers appears to hang the `keyboard' when the aux
|
|
|
|
* port doesn't exist and `PSMC_RESET_DEV' is issued.
|
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
if (!reset_aux_dev(sc->kbdc)) {
|
|
|
|
recover_from_error(sc->kbdc);
|
|
|
|
restore_controller(sc->kbdc, command_byte);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose)
|
|
|
|
printf("psm%d: failed to reset the aux device.\n", unit);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
endprobe(0);
|
1996-11-15 06:17:36 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* both the aux port and the aux device is functioning, see if the
|
|
|
|
* device can be enabled. NOTE: when enabled, the device will start
|
|
|
|
* sending data; we shall immediately disable the device once we know
|
|
|
|
* the device can be enabled.
|
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
if (!enable_aux_dev(sc->kbdc) || !disable_aux_dev(sc->kbdc)) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* MOUSE ERROR */
|
1997-01-15 18:16:32 +00:00
|
|
|
restore_controller(sc->kbdc, command_byte);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose)
|
|
|
|
printf("psm%d: failed to enable the aux device.\n", unit);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
endprobe(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* save the default values after reset */
|
1997-01-15 18:16:32 +00:00
|
|
|
if (get_mouse_status(sc->kbdc, stat)) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
if (verbose)
|
|
|
|
printf("psm%d: status after reset %02x %02x %02x\n",
|
|
|
|
unit, stat[0], stat[1], stat[2]);
|
1997-01-15 18:16:32 +00:00
|
|
|
sc->dflt_mode.rate = sc->mode.rate = stat[2];
|
|
|
|
sc->dflt_mode.resolution = sc->mode.resolution = stat[1];
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
} else {
|
1997-01-15 18:16:32 +00:00
|
|
|
sc->dflt_mode.rate = sc->mode.rate = -1;
|
|
|
|
sc->dflt_mode.resolution = sc->mode.resolution = -1;
|
1996-11-15 06:17:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* hardware information */
|
|
|
|
sc->hw.iftype = MOUSE_IF_PS2;
|
|
|
|
|
|
|
|
/* verify the device is a mouse */
|
1997-01-15 18:16:32 +00:00
|
|
|
sc->hw.hwid = get_aux_id(sc->kbdc);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (!is_a_mouse(sc->hw.hwid)) {
|
1997-01-15 18:16:32 +00:00
|
|
|
restore_controller(sc->kbdc, command_byte);
|
1996-11-15 06:17:36 +00:00
|
|
|
if (verbose)
|
|
|
|
printf("psm%d: unknown device type (%d).\n", unit, sc->hw.hwid);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
endprobe(0);
|
1996-11-15 06:17:36 +00:00
|
|
|
}
|
|
|
|
switch (sc->hw.hwid) {
|
|
|
|
case PSM_BALLPOINT_ID:
|
|
|
|
sc->hw.type = MOUSE_TRACKBALL;
|
|
|
|
break;
|
|
|
|
case PSM_MOUSE_ID:
|
|
|
|
sc->hw.type = MOUSE_MOUSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sc->hw.type = MOUSE_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* # of buttons */
|
1997-01-15 18:16:32 +00:00
|
|
|
sc->hw.buttons = get_mouse_buttons(sc->kbdc);
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
/* set mouse parameters */
|
|
|
|
/* FIXME:XXX should we set them in `psmattach()' rather than here? */
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* FIXME:XXX I don't know if these parameters are reasonable */
|
1997-01-15 18:16:32 +00:00
|
|
|
i = send_aux_command(sc->kbdc, PSMC_SET_DEFAULTS);
|
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm%d: SET_DEFAULTS return code:%04x\n",
|
|
|
|
unit, i);
|
1997-11-21 11:36:21 +00:00
|
|
|
#ifdef PSM_MSCKLUDGE
|
|
|
|
set_mouse_resolution(sc->kbdc, PSMD_RES_HIGH);
|
|
|
|
#endif
|
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
#if 0
|
|
|
|
set_mouse_scaling(sc->kbdc); /* 1:1 scaling */
|
|
|
|
set_mouse_mode(sc->kbdc); /* stream mode */
|
|
|
|
#endif
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
/* just check the status of the mouse */
|
1997-01-15 18:16:32 +00:00
|
|
|
/*
|
|
|
|
* NOTE: XXX there are some arcane controller/mouse combinations out
|
|
|
|
* there, which hung the controller unless there is data transmission
|
|
|
|
* after ACK from the mouse.
|
|
|
|
*/
|
|
|
|
i = get_mouse_status(sc->kbdc, stat);
|
|
|
|
if (!i) {
|
|
|
|
log(LOG_DEBUG, "psm%d: failed to get status.\n", unit);
|
|
|
|
} else if (verbose) {
|
1996-11-15 06:17:36 +00:00
|
|
|
log(LOG_DEBUG, "psm%d: status %02x %02x %02x\n",
|
|
|
|
unit, stat[0], stat[1], stat[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disable the aux port for now... */
|
1997-01-15 18:16:32 +00:00
|
|
|
if (!set_controller_command_byte(sc->kbdc,
|
|
|
|
KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS,
|
|
|
|
(command_byte & KBD_KBD_CONTROL_BITS)
|
|
|
|
| KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/*
|
|
|
|
* this is CONTROLLER ERROR; I don't know the proper way to
|
|
|
|
* recover from this error...
|
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
restore_controller(sc->kbdc, command_byte);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
printf("psm%d: unable to set the command byte.\n", unit);
|
|
|
|
endprobe(0);
|
|
|
|
}
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
/* done */
|
1996-11-28 17:18:56 +00:00
|
|
|
psm_softc[unit] = sc;
|
1997-01-15 18:16:32 +00:00
|
|
|
kbdc_set_device_mask(sc->kbdc, mask | KBD_AUX_CONTROL_BITS);
|
|
|
|
kbdc_lock(sc->kbdc, FALSE);
|
1996-11-15 06:17:36 +00:00
|
|
|
return (IO_PSMSIZE);
|
1994-09-09 11:27:50 +00:00
|
|
|
}
|
|
|
|
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
|
|
|
psmattach(struct isa_device *dvp)
|
1994-09-09 11:27:50 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
int unit = dvp->id_unit;
|
1996-11-28 17:18:56 +00:00
|
|
|
struct psm_softc *sc = psm_softc[unit];
|
1996-11-15 06:17:36 +00:00
|
|
|
|
1997-01-16 18:57:19 +00:00
|
|
|
if (sc == NULL) /* shouldn't happen */
|
|
|
|
return (0);
|
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
/* initial operation mode */
|
1997-01-15 18:16:32 +00:00
|
|
|
sc->dflt_mode.accelfactor = sc->mode.accelfactor = PSM_ACCEL;
|
|
|
|
sc->dflt_mode.protocol = sc->mode.protocol = MOUSE_PROTO_PS2;
|
1996-11-15 06:17:36 +00:00
|
|
|
sc->mkpacket = mkps2;
|
|
|
|
|
|
|
|
/* Setup initial state */
|
|
|
|
sc->state = PSM_VALID;
|
|
|
|
|
|
|
|
/* Done */
|
|
|
|
#ifdef DEVFS
|
|
|
|
sc->devfs_token =
|
|
|
|
devfs_add_devswf(&psm_cdevsw, PSM_MKMINOR(unit, TRUE),
|
|
|
|
DV_CHR, 0, 0, 0666, "psm%d", unit);
|
|
|
|
sc->n_devfs_token =
|
|
|
|
devfs_add_devswf(&psm_cdevsw, PSM_MKMINOR(unit, FALSE),
|
|
|
|
DV_CHR, 0, 0, 0666, "npsm%d", unit);
|
1997-06-30 12:52:57 +00:00
|
|
|
#endif /* DEVFS */
|
|
|
|
|
|
|
|
#ifdef PSM_HOOKAPM
|
|
|
|
sc->resumehook.ah_name = "PS/2 mouse";
|
|
|
|
sc->resumehook.ah_fun = psmresume;
|
|
|
|
sc->resumehook.ah_arg = (void *)unit;
|
|
|
|
sc->resumehook.ah_order = APM_MID_ORDER;
|
|
|
|
apm_hook_establish(APM_HOOK_RESUME , &sc->resumehook);
|
|
|
|
if (verbose)
|
|
|
|
printf("psm%d: APM hooks installed.\n", unit);
|
|
|
|
#endif /* PSM_HOOKAPM */
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1997-05-27 11:55:41 +00:00
|
|
|
if (verbose)
|
|
|
|
printf("psm%d: device ID %d, %d buttons\n",
|
|
|
|
unit, sc->hw.hwid, sc->hw.buttons);
|
|
|
|
else
|
|
|
|
printf("psm%d: device ID %d\n", unit, sc->hw.hwid);
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
if (bootverbose)
|
|
|
|
--verbose;
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
return (1);
|
1994-09-09 11:27:50 +00:00
|
|
|
}
|
|
|
|
|
1996-11-15 05:41:34 +00:00
|
|
|
static int
|
1995-12-08 11:19:42 +00:00
|
|
|
psmopen(dev_t dev, int flag, int fmt, struct proc *p)
|
1994-09-09 11:27:50 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
int unit = PSM_UNIT(dev);
|
|
|
|
struct psm_softc *sc;
|
1997-01-15 18:16:32 +00:00
|
|
|
int command_byte;
|
1997-06-30 12:52:57 +00:00
|
|
|
int err;
|
1997-01-15 18:16:32 +00:00
|
|
|
int s;
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
/* Validate unit number */
|
|
|
|
if (unit >= NPSM)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
/* Get device data */
|
1996-11-27 22:52:25 +00:00
|
|
|
sc = psm_softc[unit];
|
1997-01-16 18:57:19 +00:00
|
|
|
if ((sc == NULL) || (sc->state & PSM_VALID) == 0)
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* the device is no longer valid/functioning */
|
1996-11-15 06:17:36 +00:00
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
/* Disallow multiple opens */
|
|
|
|
if (sc->state & PSM_OPEN)
|
|
|
|
return (EBUSY);
|
|
|
|
|
|
|
|
/* Initialize state */
|
|
|
|
sc->rsel.si_flags = 0;
|
|
|
|
sc->rsel.si_pid = 0;
|
|
|
|
|
|
|
|
/* flush the event queue */
|
|
|
|
sc->queue.count = 0;
|
|
|
|
sc->queue.head = 0;
|
|
|
|
sc->queue.tail = 0;
|
|
|
|
sc->button = 0;
|
|
|
|
|
|
|
|
/* empty input/output buffers */
|
|
|
|
sc->inputbytes = 0;
|
|
|
|
sc->outputbytes = 0;
|
|
|
|
sc->outputhead = 0;
|
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
/* don't let timeout routines in the keyboard driver to poll the kbdc */
|
|
|
|
if (!kbdc_lock(sc->kbdc, TRUE))
|
|
|
|
return (EIO);
|
|
|
|
|
|
|
|
/* save the current controller command byte */
|
|
|
|
s = spltty();
|
|
|
|
command_byte = get_controller_command_byte(sc->kbdc);
|
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
/* enable the aux port and temporalily disable the keyboard */
|
1997-01-15 18:16:32 +00:00
|
|
|
if ((command_byte == -1)
|
|
|
|
|| !set_controller_command_byte(sc->kbdc,
|
|
|
|
kbdc_get_device_mask(sc->kbdc),
|
|
|
|
KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
|
|
|
|
| KBD_ENABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* CONTROLLER ERROR; do you know how to get out of this? */
|
1997-01-15 18:16:32 +00:00
|
|
|
kbdc_lock(sc->kbdc, FALSE);
|
|
|
|
splx(s);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
log(LOG_ERR, "psm%d: unable to set the command byte (psmopen).\n",
|
|
|
|
unit);
|
|
|
|
return (EIO);
|
|
|
|
}
|
1997-01-15 18:16:32 +00:00
|
|
|
/*
|
|
|
|
* Now that the keyboard controller is told not to generate
|
|
|
|
* the keyboard and mouse interrupts, call `splx()' to allow
|
|
|
|
* the other tty interrupts. The clock interrupt may also occur,
|
|
|
|
* but timeout routines will be blocked by the poll flag set
|
|
|
|
* via `kbdc_lock()'
|
|
|
|
*/
|
|
|
|
splx(s);
|
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
/* enable the mouse device */
|
1997-06-30 12:52:57 +00:00
|
|
|
err = doopen(unit, command_byte);
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
/* done */
|
1997-06-30 12:52:57 +00:00
|
|
|
if (err == 0)
|
|
|
|
sc->state |= PSM_OPEN;
|
1997-01-15 18:16:32 +00:00
|
|
|
kbdc_lock(sc->kbdc, FALSE);
|
1997-06-30 12:52:57 +00:00
|
|
|
return (err);
|
1994-09-09 11:27:50 +00:00
|
|
|
}
|
|
|
|
|
1996-11-15 05:41:34 +00:00
|
|
|
static int
|
1996-11-15 05:30:52 +00:00
|
|
|
psmclose(dev_t dev, int flag, int fmt, struct proc *p)
|
1994-09-09 11:27:50 +00:00
|
|
|
{
|
1996-11-27 22:52:25 +00:00
|
|
|
struct psm_softc *sc = psm_softc[PSM_UNIT(dev)];
|
1997-01-15 18:16:32 +00:00
|
|
|
int stat[3];
|
|
|
|
int command_byte;
|
|
|
|
int ret;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
/* don't let timeout routines in the keyboard driver to poll the kbdc */
|
|
|
|
if (!kbdc_lock(sc->kbdc, TRUE))
|
|
|
|
return (EIO);
|
1994-09-09 11:27:50 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
/* save the current controller command byte */
|
|
|
|
s = spltty();
|
|
|
|
command_byte = get_controller_command_byte(sc->kbdc);
|
|
|
|
if (command_byte == -1) {
|
|
|
|
kbdc_lock(sc->kbdc, FALSE);
|
|
|
|
splx(s);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disable the aux interrupt and temporalily disable the keyboard */
|
|
|
|
if (!set_controller_command_byte(sc->kbdc,
|
|
|
|
kbdc_get_device_mask(sc->kbdc),
|
|
|
|
KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
|
|
|
|
| KBD_ENABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
log(LOG_ERR, "psm%d: failed to disable the aux int (psmclose).\n",
|
|
|
|
PSM_UNIT(dev));
|
|
|
|
/* CONTROLLER ERROR;
|
|
|
|
* NOTE: we shall force our way through. Because the only
|
|
|
|
* ill effect we shall see is that we may not be able
|
|
|
|
* to read ACK from the mouse, and it doesn't matter much
|
|
|
|
* so long as the mouse will accept the DISABLE command.
|
|
|
|
*/
|
|
|
|
}
|
1997-01-15 18:16:32 +00:00
|
|
|
splx(s);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
/* remove anything left in the output buffer */
|
1997-01-15 18:16:32 +00:00
|
|
|
empty_aux_buffer(sc->kbdc, 10);
|
1994-09-09 11:27:50 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
/* disable the aux device, port and interrupt */
|
1997-01-15 18:16:32 +00:00
|
|
|
if (!disable_aux_dev(sc->kbdc)) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* MOUSE ERROR;
|
|
|
|
* NOTE: we don't return error and continue, pretending
|
|
|
|
* we have successfully disabled the device. It's OK because
|
|
|
|
* the interrupt routine will discard any data from the mouse
|
|
|
|
* hereafter.
|
|
|
|
*/
|
|
|
|
log(LOG_ERR, "psm%d: failed to disable the device (psmclose).\n",
|
|
|
|
PSM_UNIT(dev));
|
|
|
|
}
|
1997-01-15 18:16:32 +00:00
|
|
|
|
|
|
|
ret = get_mouse_status(sc->kbdc, stat);
|
|
|
|
if (!ret) {
|
|
|
|
log(LOG_DEBUG, "psm%d: failed to get status (psmclose).\n",
|
|
|
|
PSM_UNIT(dev));
|
|
|
|
} else if (verbose >= 2) {
|
|
|
|
log(LOG_DEBUG, "psm%d: status %02x %02x %02x (psmclose)\n",
|
|
|
|
PSM_UNIT(dev), stat[0], stat[1], stat[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!set_controller_command_byte(sc->kbdc,
|
|
|
|
kbdc_get_device_mask(sc->kbdc),
|
|
|
|
(command_byte & KBD_KBD_CONTROL_BITS)
|
|
|
|
| KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* CONTROLLER ERROR;
|
|
|
|
* we shall ignore this error; see the above comment.
|
|
|
|
*/
|
|
|
|
log(LOG_ERR, "psm%d: failed to disable the aux port (psmclose).\n",
|
|
|
|
PSM_UNIT(dev));
|
|
|
|
}
|
1994-09-09 11:27:50 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
/* remove anything left in the output buffer */
|
1997-01-15 18:16:32 +00:00
|
|
|
empty_aux_buffer(sc->kbdc, 10);
|
1994-09-09 11:27:50 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
/* close is almost always successful */
|
1997-06-30 12:52:57 +00:00
|
|
|
sc->state &= ~(PSM_OPEN | PSM_ASLP);
|
1997-01-15 18:16:32 +00:00
|
|
|
kbdc_lock(sc->kbdc, FALSE);
|
1996-11-15 06:17:36 +00:00
|
|
|
return (0);
|
1994-09-09 11:27:50 +00:00
|
|
|
}
|
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
#ifdef PSM_EMULATION
|
1996-05-07 19:40:47 +00:00
|
|
|
static int
|
1996-11-15 05:41:34 +00:00
|
|
|
mkms(unsigned char *buf, int *len, int maxlen, register mousestatus_t *status)
|
1996-11-15 05:30:52 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
static int butmap[] = {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
0, MOUSE_MSS_BUTTON1DOWN,
|
|
|
|
0, MOUSE_MSS_BUTTON1DOWN ,
|
|
|
|
MOUSE_MSS_BUTTON3DOWN, MOUSE_MSS_BUTTON1DOWN | MOUSE_MSS_BUTTON3DOWN,
|
|
|
|
MOUSE_MSS_BUTTON3DOWN, MOUSE_MSS_BUTTON1DOWN | MOUSE_MSS_BUTTON3DOWN,
|
1996-11-15 06:17:36 +00:00
|
|
|
};
|
|
|
|
unsigned char delta;
|
|
|
|
|
|
|
|
if (maxlen - *len < MOUSE_MSS_PACKETSIZE)
|
|
|
|
return FALSE;
|
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
buf[0] = MOUSE_MSS_SYNC | butmap[status->button & MOUSE_STDBUTTONS];
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
if (status->dx < -128)
|
|
|
|
delta = 0x80; /* -128 */
|
|
|
|
else
|
|
|
|
if (status->dx > 127)
|
|
|
|
delta = 0x7f; /* 127 */
|
|
|
|
else
|
|
|
|
delta = (unsigned char) status->dx;
|
|
|
|
buf[0] |= (delta & 0xc0) >> 6; /* bit 6-7 */
|
|
|
|
buf[1] = delta & 0x3f; /* bit 0-5 */
|
|
|
|
|
|
|
|
if (status->dy < -128)
|
|
|
|
delta = 0x80; /* -128 */
|
|
|
|
else
|
|
|
|
if (status->dy > 127)
|
|
|
|
delta = 0x7f; /* 127 */
|
|
|
|
else
|
|
|
|
delta = (unsigned char) status->dy;
|
|
|
|
buf[0] |= (delta & 0xc0) >> 4; /* bit 6-7 */
|
|
|
|
buf[2] = delta & 0x3f; /* bit 0-5 */
|
|
|
|
|
|
|
|
*len += MOUSE_MSS_PACKETSIZE;
|
|
|
|
|
|
|
|
return TRUE;
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
mkman(unsigned char *buf, int *len, int maxlen, register mousestatus_t *status)
|
1996-11-15 05:30:52 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
static int butmap[] = {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
0, MOUSE_MSS_BUTTON1DOWN,
|
|
|
|
0, MOUSE_MSS_BUTTON1DOWN,
|
|
|
|
MOUSE_MSS_BUTTON3DOWN, MOUSE_MSS_BUTTON1DOWN | MOUSE_MSS_BUTTON3DOWN,
|
|
|
|
MOUSE_MSS_BUTTON3DOWN, MOUSE_MSS_BUTTON1DOWN | MOUSE_MSS_BUTTON3DOWN,
|
1996-11-15 06:17:36 +00:00
|
|
|
};
|
|
|
|
unsigned char delta;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
int l;
|
1996-11-15 06:17:36 +00:00
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
l = ((status->button ^ status->obutton) & MOUSE_BUTTON2DOWN) ?
|
|
|
|
MOUSE_MSS_PACKETSIZE + 1: MOUSE_MSS_PACKETSIZE;
|
|
|
|
if (maxlen - *len < l)
|
1996-11-15 06:17:36 +00:00
|
|
|
return FALSE;
|
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
buf[0] = MOUSE_MSS_SYNC | butmap[status->button & MOUSE_STDBUTTONS];
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
if (status->dx < -128)
|
|
|
|
delta = 0x80; /* -128 */
|
|
|
|
else
|
|
|
|
if (status->dx > 127)
|
|
|
|
delta = 0x7f; /* 127 */
|
|
|
|
else
|
|
|
|
delta = (unsigned char) status->dx;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
buf[0] |= (delta & 0xc0) >> 6; /* bit 6-7 */
|
|
|
|
buf[1] = delta & 0x3f; /* bit 0-5 */
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
if (status->dy < -128)
|
|
|
|
delta = 0x80; /* -128 */
|
|
|
|
else
|
|
|
|
if (status->dy > 127)
|
|
|
|
delta = 0x7f; /* 127 */
|
|
|
|
else
|
|
|
|
delta = (unsigned char) status->dy;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
buf[0] |= (delta & 0xc0) >> 4; /* bit 6-7 */
|
|
|
|
buf[2] = delta & 0x3f; /* bit 0-5 */
|
|
|
|
|
|
|
|
if (l > MOUSE_MSS_PACKETSIZE)
|
|
|
|
buf[3] = (status->button & MOUSE_BUTTON2DOWN)
|
|
|
|
? MOUSE_LMAN_BUTTON2DOWN : 0;
|
|
|
|
|
|
|
|
*len += l;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mkmsc(unsigned char *buf, int *len, int maxlen, register mousestatus_t *status)
|
|
|
|
{
|
|
|
|
static int butmap[] = {
|
|
|
|
0,
|
|
|
|
MOUSE_MSC_BUTTON1UP, MOUSE_MSC_BUTTON2UP,
|
|
|
|
MOUSE_MSC_BUTTON1UP | MOUSE_MSC_BUTTON2UP,
|
|
|
|
MOUSE_MSC_BUTTON3UP,
|
|
|
|
MOUSE_MSC_BUTTON1UP | MOUSE_MSC_BUTTON3UP,
|
|
|
|
MOUSE_MSC_BUTTON2UP | MOUSE_MSC_BUTTON3UP,
|
|
|
|
MOUSE_MSC_BUTTON1UP | MOUSE_MSC_BUTTON2UP | MOUSE_MSC_BUTTON3UP,
|
|
|
|
};
|
|
|
|
register int delta;
|
|
|
|
|
|
|
|
if (maxlen - *len < MOUSE_MSC_PACKETSIZE)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
buf[0] = MOUSE_MSC_SYNC
|
|
|
|
| (~butmap[status->button & MOUSE_STDBUTTONS] & MOUSE_MSC_BUTTONS);
|
|
|
|
|
|
|
|
/* data bytes cannot be between 80h (-128) and 87h (-120).
|
|
|
|
* values we can return is 255 (0ffh) through -251 (10fh = 87h*2 + 1).
|
|
|
|
*/
|
|
|
|
if (status->dx < -251)
|
|
|
|
delta = -251;
|
|
|
|
else
|
|
|
|
if (status->dx > 255)
|
|
|
|
delta = 255;
|
|
|
|
else
|
|
|
|
delta = status->dx;
|
|
|
|
buf[1] = delta/2;
|
|
|
|
buf[3] = delta - buf[1];
|
|
|
|
|
|
|
|
if (status->dy < -251)
|
|
|
|
delta = -251;
|
|
|
|
else
|
|
|
|
if (status->dy > 255)
|
|
|
|
delta = 255;
|
|
|
|
else
|
|
|
|
delta = status->dy;
|
|
|
|
buf[2] = delta/2;
|
1996-11-15 06:17:36 +00:00
|
|
|
buf[4] = delta - buf[2];
|
|
|
|
|
|
|
|
*len += MOUSE_MSC_PACKETSIZE;
|
|
|
|
|
|
|
|
return TRUE;
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
static int
|
|
|
|
mkmm(unsigned char *buf, int *len, int maxlen, register mousestatus_t *status)
|
|
|
|
{
|
|
|
|
static int butmap[] = {
|
|
|
|
0,
|
|
|
|
MOUSE_MM_BUTTON1DOWN, MOUSE_MM_BUTTON2DOWN,
|
|
|
|
MOUSE_MM_BUTTON1DOWN | MOUSE_MM_BUTTON2DOWN,
|
|
|
|
MOUSE_MM_BUTTON3DOWN,
|
|
|
|
MOUSE_MM_BUTTON1DOWN | MOUSE_MM_BUTTON3DOWN,
|
|
|
|
MOUSE_MM_BUTTON2DOWN | MOUSE_MM_BUTTON3DOWN,
|
|
|
|
MOUSE_MM_BUTTON1DOWN | MOUSE_MM_BUTTON2DOWN | MOUSE_MM_BUTTON3DOWN,
|
|
|
|
};
|
|
|
|
int delta;
|
|
|
|
|
|
|
|
if (maxlen - *len < MOUSE_MM_PACKETSIZE)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
buf[0] = MOUSE_MM_SYNC
|
|
|
|
| butmap[status->button & MOUSE_STDBUTTONS]
|
|
|
|
| ((status->dx > 0) ? MOUSE_MM_XPOSITIVE : 0)
|
|
|
|
| ((status->dy > 0) ? MOUSE_MM_YPOSITIVE : 0);
|
|
|
|
|
|
|
|
delta = (status->dx < 0) ? -status->dx : status->dx;
|
|
|
|
buf[1] = min(delta, 127);
|
|
|
|
delta = (status->dy < 0) ? -status->dy : status->dy;
|
|
|
|
buf[2] = min(delta, 127);
|
|
|
|
|
|
|
|
*len += MOUSE_MM_PACKETSIZE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif /* PSM_EMULATION */
|
|
|
|
|
1996-11-15 05:30:52 +00:00
|
|
|
static int
|
1996-11-15 06:17:36 +00:00
|
|
|
mkps2(unsigned char *buf, int *len, int maxlen, register mousestatus_t *status)
|
1996-11-15 05:30:52 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
static int butmap[] = {
|
|
|
|
0,
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
MOUSE_PS2_BUTTON1DOWN, MOUSE_PS2_BUTTON2DOWN,
|
|
|
|
MOUSE_PS2_BUTTON1DOWN | MOUSE_PS2_BUTTON2DOWN,
|
|
|
|
MOUSE_PS2_BUTTON3DOWN,
|
|
|
|
MOUSE_PS2_BUTTON1DOWN | MOUSE_PS2_BUTTON3DOWN,
|
|
|
|
MOUSE_PS2_BUTTON2DOWN | MOUSE_PS2_BUTTON3DOWN,
|
|
|
|
MOUSE_PS2_BUTTON1DOWN | MOUSE_PS2_BUTTON2DOWN | MOUSE_PS2_BUTTON3DOWN,
|
1996-11-15 06:17:36 +00:00
|
|
|
};
|
|
|
|
register int delta;
|
|
|
|
|
|
|
|
if (maxlen - *len < MOUSE_PS2_PACKETSIZE)
|
|
|
|
return FALSE;
|
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
buf[0] = ((status->button & MOUSE_BUTTON4DOWN) ? 0 : MOUSE_PS2_BUTTON4UP)
|
|
|
|
| butmap[status->button & MOUSE_STDBUTTONS];
|
|
|
|
if ((verbose >= 2) && ((buf[0] & MOUSE_PS2_BUTTON4UP) == 0))
|
|
|
|
log(LOG_DEBUG, "psm: button 4 down (%04x) (mkps2)\n", buf[0]);
|
1996-11-15 06:17:36 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
if (status->dx < -256)
|
|
|
|
delta = -256;
|
1996-11-15 06:17:36 +00:00
|
|
|
else
|
1997-01-15 18:16:32 +00:00
|
|
|
if (status->dx > 255)
|
|
|
|
delta = 255;
|
1996-11-15 06:17:36 +00:00
|
|
|
else
|
|
|
|
delta = status->dx;
|
|
|
|
if (delta < 0)
|
|
|
|
buf[0] |= MOUSE_PS2_XNEG;
|
|
|
|
buf[1] = delta;
|
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
if (status->dy < -256)
|
|
|
|
delta = -256;
|
1996-11-15 06:17:36 +00:00
|
|
|
else
|
1997-01-15 18:16:32 +00:00
|
|
|
if (status->dy > 255)
|
|
|
|
delta = 255;
|
1996-11-15 06:17:36 +00:00
|
|
|
else
|
|
|
|
delta = status->dy;
|
|
|
|
if (delta < 0)
|
|
|
|
buf[0] |= MOUSE_PS2_YNEG;
|
|
|
|
buf[2] = delta;
|
|
|
|
|
|
|
|
*len += MOUSE_PS2_PACKETSIZE;
|
|
|
|
|
|
|
|
return TRUE;
|
1996-11-15 05:30:52 +00:00
|
|
|
}
|
|
|
|
|
1996-11-15 05:41:34 +00:00
|
|
|
static int
|
1995-12-08 11:19:42 +00:00
|
|
|
psmread(dev_t dev, struct uio *uio, int flag)
|
1994-09-09 11:27:50 +00:00
|
|
|
{
|
1996-11-27 22:52:25 +00:00
|
|
|
register struct psm_softc *sc = psm_softc[PSM_UNIT(dev)];
|
1996-11-15 06:17:36 +00:00
|
|
|
unsigned int length;
|
|
|
|
int error;
|
|
|
|
int s;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* block until mouse activity occured */
|
|
|
|
s = spltty();
|
|
|
|
if ((sc->outputbytes <= 0) && (sc->queue.count <= 0)) {
|
|
|
|
while (sc->queue.count <= 0) {
|
|
|
|
if (PSM_NBLOCKIO(dev)) {
|
|
|
|
splx(s);
|
|
|
|
return (EWOULDBLOCK);
|
|
|
|
}
|
|
|
|
sc->state |= PSM_ASLP;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
error = tsleep((caddr_t) sc, PZERO | PCATCH, "psmread", 0);
|
1997-01-15 18:16:32 +00:00
|
|
|
sc->state &= ~PSM_ASLP;
|
1996-11-15 06:17:36 +00:00
|
|
|
if (error) {
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
if (sc->outputbytes >= uio->uio_resid) {
|
|
|
|
/* nothing to be done */
|
|
|
|
} else {
|
|
|
|
if (sc->outputbytes > 0) {
|
|
|
|
bcopy(&sc->opacket[sc->outputhead], sc->opacket,
|
|
|
|
sc->outputbytes);
|
|
|
|
}
|
|
|
|
sc->outputhead = 0;
|
|
|
|
for (i = sc->queue.head; sc->queue.count > 0;
|
|
|
|
i = (i + 1) % PSM_BUFSIZE, --sc->queue.count) {
|
|
|
|
if (!(*sc->mkpacket) (&sc->opacket[sc->outputbytes],
|
|
|
|
&sc->outputbytes, PSM_BUFSIZE, &sc->queue.buf[i]))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sc->queue.head = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allow interrupts again */
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
/* copy data to user process */
|
|
|
|
length = min(sc->outputbytes, uio->uio_resid);
|
|
|
|
error = uiomove(&sc->opacket[sc->outputhead], length, uio);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
sc->outputhead += length;
|
|
|
|
sc->outputbytes -= length;
|
|
|
|
|
|
|
|
return (error);
|
1994-09-09 11:27:50 +00:00
|
|
|
}
|
|
|
|
|
1996-11-15 05:41:34 +00:00
|
|
|
static int
|
1995-12-08 11:19:42 +00:00
|
|
|
psmioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p)
|
1994-09-09 11:27:50 +00:00
|
|
|
{
|
1996-11-27 22:52:25 +00:00
|
|
|
struct psm_softc *sc = psm_softc[PSM_UNIT(dev)];
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
mousemode_t mode;
|
|
|
|
mousestatus_t status;
|
1996-11-15 06:17:36 +00:00
|
|
|
packetfunc_t func;
|
1997-01-15 18:16:32 +00:00
|
|
|
int command_byte;
|
1996-11-15 06:17:36 +00:00
|
|
|
int error = 0;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
/* Perform IOCTL command */
|
|
|
|
switch (cmd) {
|
|
|
|
|
1997-10-19 10:45:18 +00:00
|
|
|
case MOUSE_GETHWINFO:
|
1996-11-15 06:17:36 +00:00
|
|
|
*(mousehw_t *) addr = sc->hw;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MOUSE_GETMODE:
|
|
|
|
*(mousemode_t *) addr = sc->mode;
|
1997-01-15 18:16:32 +00:00
|
|
|
if (sc->mode.resolution >= 0)
|
|
|
|
((mousemode_t *) addr)->resolution = sc->mode.resolution + 1;
|
1996-11-15 06:17:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MOUSE_SETMODE:
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
mode = *(mousemode_t *) addr;
|
|
|
|
if (mode.rate == 0) {
|
1997-01-15 18:16:32 +00:00
|
|
|
mode.rate = sc->dflt_mode.rate;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
} else if (mode.rate > 0) {
|
|
|
|
mode.rate = min(mode.rate, PSMD_MAX_RATE);
|
|
|
|
} else { /* mode.rate < 0 */
|
|
|
|
mode.rate = sc->mode.rate;
|
|
|
|
}
|
|
|
|
if (mode.resolution == 0) {
|
1997-01-15 18:16:32 +00:00
|
|
|
mode.resolution = sc->dflt_mode.resolution;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
} else if (mode.resolution > 0) {
|
1997-01-15 18:16:32 +00:00
|
|
|
mode.resolution = min(mode.resolution - 1, PSMD_MAX_RESOLUTION);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
} else { /* mode.resolution < 0 */
|
|
|
|
mode.resolution = sc->mode.resolution;
|
1997-01-15 18:16:32 +00:00
|
|
|
}
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
#ifdef PSM_EMULATION
|
|
|
|
switch (mode.protocol) {
|
1996-11-15 06:17:36 +00:00
|
|
|
case MOUSE_PROTO_MS:
|
|
|
|
func = mkms;
|
|
|
|
break;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
case MOUSE_PROTO_LOGIMOUSEMAN:
|
|
|
|
func = mkman;
|
|
|
|
break;
|
1996-11-15 06:17:36 +00:00
|
|
|
case MOUSE_PROTO_MSC:
|
|
|
|
func = mkmsc;
|
|
|
|
break;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
case MOUSE_PROTO_MM:
|
|
|
|
func = mkmm;
|
|
|
|
break;
|
1996-11-15 06:17:36 +00:00
|
|
|
case MOUSE_PROTO_PS2:
|
|
|
|
func = mkps2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
func = (packetfunc_t) NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (error)
|
|
|
|
break;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
#else
|
|
|
|
mode.protocol = sc->mode.protocol;
|
|
|
|
#endif /* PSM_EMULATION */
|
|
|
|
if (mode.accelfactor < 0) {
|
1996-11-15 06:17:36 +00:00
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
/* don't allow anybody to poll the keyboard controller */
|
|
|
|
if (!kbdc_lock(sc->kbdc, TRUE)) {
|
|
|
|
error = EIO;
|
|
|
|
break;
|
|
|
|
}
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
/* temporalily disable the keyboard */
|
1997-01-15 18:16:32 +00:00
|
|
|
s = spltty();
|
|
|
|
command_byte = get_controller_command_byte(sc->kbdc);
|
|
|
|
if ((command_byte == -1)
|
|
|
|
|| !set_controller_command_byte(sc->kbdc,
|
|
|
|
kbdc_get_device_mask(sc->kbdc),
|
|
|
|
KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
|
|
|
|
| KBD_ENABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* this is CONTROLLER ERROR; I don't know how to recover
|
1997-01-15 18:16:32 +00:00
|
|
|
* from this error.
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
kbdc_lock(sc->kbdc, FALSE);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
splx(s);
|
|
|
|
log(LOG_ERR, "psm%d: failed to set the command byte (psmioctl).\n",
|
|
|
|
PSM_UNIT(dev));
|
|
|
|
error = EIO;
|
|
|
|
break;
|
|
|
|
}
|
1997-01-15 18:16:32 +00:00
|
|
|
/*
|
|
|
|
* The device may be in the middle of status data transmission.
|
|
|
|
* The transmission will be interrupted, thus, incomplete status
|
|
|
|
* data must be discarded. Although the aux interrupt is disabled
|
|
|
|
* at the keyboard controller level, at most one aux interrupt
|
|
|
|
* may have already been pending and a data byte is in the
|
|
|
|
* output buffer; throw it away. Note that the second argument
|
|
|
|
* to `empty_aux_buffer()' is zero, so that the call will just
|
|
|
|
* flush the internal queue.
|
|
|
|
* `psmintr()' will be invoked after `splx()' if an interrupt is
|
|
|
|
* pending; it will see no data and returns immediately.
|
|
|
|
*/
|
|
|
|
empty_aux_buffer(sc->kbdc, 0); /* flush the queue */
|
|
|
|
read_aux_data_no_wait(sc->kbdc); /* throw away data if any */
|
|
|
|
sc->inputbytes = 0;
|
|
|
|
splx(s);
|
1996-11-15 06:17:36 +00:00
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
if (mode.rate > 0)
|
1997-01-15 18:16:32 +00:00
|
|
|
mode.rate = set_mouse_sampling_rate(sc->kbdc, mode.rate);
|
|
|
|
if (mode.resolution >= 0)
|
|
|
|
mode.resolution = set_mouse_resolution(sc->kbdc, mode.resolution);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We may have seen a part of status data, which is queued,
|
|
|
|
* during `set_mouse_XXX()'; flush it.
|
|
|
|
*/
|
|
|
|
empty_aux_buffer(sc->kbdc, 0);
|
1996-11-15 06:17:36 +00:00
|
|
|
|
1997-01-15 18:16:32 +00:00
|
|
|
/* restore ports and interrupt */
|
|
|
|
if (!set_controller_command_byte(sc->kbdc,
|
|
|
|
kbdc_get_device_mask(sc->kbdc),
|
|
|
|
command_byte & (KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS))) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
/* CONTROLLER ERROR; this is serious, we may have
|
|
|
|
* been left with the unaccessible keyboard and
|
|
|
|
* the disabled mouse interrupt.
|
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
kbdc_lock(sc->kbdc, FALSE);
|
|
|
|
log(LOG_ERR, "psm%d: failed to re-enable "
|
|
|
|
"the aux port and int (psmioctl).\n", PSM_UNIT(dev));
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
error = EIO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->mode = mode;
|
|
|
|
#ifdef PSM_EMULATION
|
1996-11-15 06:17:36 +00:00
|
|
|
sc->mkpacket = func;
|
|
|
|
sc->outputbytes = 0;
|
|
|
|
sc->outputhead = 0;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
#endif /* PSM_EMULATION */
|
1997-01-15 18:16:32 +00:00
|
|
|
kbdc_lock(sc->kbdc, FALSE);
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MOUSEIOCREAD: /* FIXME:XXX this should go... */
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MOUSE_GETSTATE:
|
|
|
|
s = spltty();
|
|
|
|
if (sc->queue.count > 0) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
status = sc->queue.buf[sc->queue.head];
|
1996-11-15 06:17:36 +00:00
|
|
|
sc->queue.head = (sc->queue.head + 1) % PSM_BUFSIZE;
|
|
|
|
--sc->queue.count;
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
} else {
|
|
|
|
status.button = status.obutton = sc->button;
|
|
|
|
status.dx = status.dy = 0;
|
1997-01-15 18:16:32 +00:00
|
|
|
}
|
1996-11-15 06:17:36 +00:00
|
|
|
splx(s);
|
|
|
|
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
*(mousestatus_t *) addr = status;
|
1996-11-15 06:17:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return error code */
|
|
|
|
return (error);
|
1994-09-09 11:27:50 +00:00
|
|
|
}
|
|
|
|
|
1996-05-07 19:40:47 +00:00
|
|
|
void
|
|
|
|
psmintr(int unit)
|
1994-09-09 11:27:50 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
/*
|
|
|
|
* the table to turn PS/2 mouse button bits (MOUSE_PS2_BUTTON?DOWN)
|
1997-01-15 18:16:32 +00:00
|
|
|
* into `mousestatus' button bits (MOUSE_BUTTON?DOWN).
|
1996-11-15 06:17:36 +00:00
|
|
|
*/
|
1997-01-15 18:16:32 +00:00
|
|
|
static int butmap[8] = {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
0,
|
|
|
|
MOUSE_BUTTON1DOWN, MOUSE_BUTTON3DOWN,
|
|
|
|
MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN,
|
|
|
|
MOUSE_BUTTON2DOWN,
|
|
|
|
MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN,
|
|
|
|
MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN,
|
|
|
|
MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN
|
1996-11-15 06:17:36 +00:00
|
|
|
};
|
1996-11-27 22:52:25 +00:00
|
|
|
register struct psm_softc *sc = psm_softc[unit];
|
1996-11-15 06:17:36 +00:00
|
|
|
mousestatus_t *ms;
|
1997-01-15 18:16:32 +00:00
|
|
|
int c;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
/* read until there is nothing to read */
|
|
|
|
while((c = read_aux_data_no_wait(sc->kbdc)) != -1) {
|
|
|
|
|
|
|
|
/* discard the byte if the device is not open */
|
|
|
|
if ((sc->state & PSM_OPEN) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME: there seems no way to reliably
|
|
|
|
* re-synchronize with the PS/2 mouse once we are out of sync. Sure,
|
|
|
|
* there is a sync bit in the first data byte, but the second and the
|
|
|
|
* third bytes may have these bits on (oh, it's not functioning as
|
|
|
|
* sync bit then!). There need to be two consequtive bytes with this
|
|
|
|
* bit off to re-sync. (This can be done if the user clicks buttons
|
|
|
|
* without moving the mouse?)
|
|
|
|
*/
|
|
|
|
if (sc->inputbytes == 0) {
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
#ifdef PSM_CHECKSYNC
|
1997-01-15 18:16:32 +00:00
|
|
|
if ((c & MOUSE_PS2_SYNCMASK) == MOUSE_PS2_SYNC)
|
|
|
|
sc->ipacket[sc->inputbytes++] = c;
|
|
|
|
else
|
|
|
|
log(LOG_DEBUG, "psmintr: sync. bit is off (%04x).\n", c);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
#else
|
1997-01-15 18:16:32 +00:00
|
|
|
sc->ipacket[sc->inputbytes++] = c;
|
|
|
|
#endif /* PSM_CHECKSYNC */
|
|
|
|
} else {
|
|
|
|
sc->ipacket[sc->inputbytes++] = c;
|
|
|
|
if (sc->inputbytes >= MOUSE_PS2_PACKETSIZE) {
|
|
|
|
if (sc->queue.count >= PSM_BUFSIZE) {
|
|
|
|
/* no room in the queue */
|
|
|
|
sc->inputbytes = 0;
|
|
|
|
return;
|
1996-11-15 06:17:36 +00:00
|
|
|
}
|
1997-01-15 18:16:32 +00:00
|
|
|
#if 0
|
1996-11-15 06:17:36 +00:00
|
|
|
x = (sc->ipacket[0] & MOUSE_PS2_XOVERFLOW) ?
|
1997-01-15 18:16:32 +00:00
|
|
|
((sc->ipacket[0] & MOUSE_PS2_XNEG) ? -256 : 255) :
|
1996-11-15 06:17:36 +00:00
|
|
|
((sc->ipacket[0] & MOUSE_PS2_XNEG) ?
|
1997-01-15 18:16:32 +00:00
|
|
|
sc->ipacket[1] - 256 : sc->ipacket[1]);
|
1996-11-15 06:17:36 +00:00
|
|
|
y = (sc->ipacket[0] & MOUSE_PS2_YOVERFLOW) ?
|
1997-01-15 18:16:32 +00:00
|
|
|
((sc->ipacket[0] & MOUSE_PS2_YNEG) ? -256 : 255) :
|
1996-11-15 06:17:36 +00:00
|
|
|
((sc->ipacket[0] & MOUSE_PS2_YNEG) ?
|
1997-01-15 18:16:32 +00:00
|
|
|
sc->ipacket[2] - 256 : sc->ipacket[2]);
|
|
|
|
#else
|
|
|
|
/* it seems OK to ignore the OVERFLOW bits... */
|
|
|
|
x = (sc->ipacket[0] & MOUSE_PS2_XNEG) ?
|
|
|
|
sc->ipacket[1] - 256 : sc->ipacket[1];
|
|
|
|
y = (sc->ipacket[0] & MOUSE_PS2_YNEG) ?
|
|
|
|
sc->ipacket[2] - 256 : sc->ipacket[2];
|
|
|
|
#endif
|
|
|
|
if (sc->mode.accelfactor >= 1) {
|
|
|
|
if (x != 0) {
|
|
|
|
x = x * x / sc->mode.accelfactor;
|
|
|
|
if (x == 0)
|
|
|
|
x = 1;
|
|
|
|
if (sc->ipacket[0] & MOUSE_PS2_XNEG)
|
|
|
|
x = -x;
|
|
|
|
}
|
|
|
|
if (y != 0) {
|
|
|
|
y = y * y / sc->mode.accelfactor;
|
|
|
|
if (y == 0)
|
|
|
|
y = 1;
|
|
|
|
if (sc->ipacket[0] & MOUSE_PS2_YNEG)
|
|
|
|
y = -y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME:XXX
|
|
|
|
* we shouldn't store data if no movement and
|
|
|
|
* no button status change is detected?
|
|
|
|
*/
|
|
|
|
ms = &sc->queue.buf[sc->queue.tail];
|
|
|
|
ms->dx = x;
|
|
|
|
ms->dy = y;
|
|
|
|
ms->obutton = sc->button; /* previous button state */
|
|
|
|
sc->button = ms->button = /* latest button state */
|
|
|
|
butmap[sc->ipacket[0] & MOUSE_PS2_BUTTONS]
|
|
|
|
| ((sc->ipacket[0] & MOUSE_PS2_BUTTON4UP)
|
|
|
|
? 0 : MOUSE_BUTTON4DOWN);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
#if 0
|
1997-01-15 18:16:32 +00:00
|
|
|
if ((verbose >= 2)
|
|
|
|
&& ((sc->ipacket[0] & MOUSE_PS2_BUTTON4UP) == 0))
|
|
|
|
log(LOG_DEBUG, "psm%d: button 4 down (%04x) (psmintr)\n",
|
|
|
|
unit, sc->ipacket[0]);
|
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols,
stricter error checking, removing redundant code, etc.
2. The `psm' driver preserves the default counter resolution and
report rate, whatever they are after reset. (Based on reports and
suggestion from Nate and Rob Bolin).
3. The `psm' driver now does not check the so-called sync. bit in the
first byte of the data packet by default, so that the tapping feature
of ALPUS GlidePoint works (based on reports from Louis Mamakos). I
tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found
no problem; tapping worked. It appears ALPUS produces several models
of GlidePoint. I hope the other models are OK too.
The check code can still be activated by defining the PSM_CHECKSYNC
option in the config file. (The bit checking slightly reduces, if not
completely eliminates, weird mouse behavior cased by unsynchronized
mouse data packets. It also helps us to detect if the mouse interrupt
can ever be lost. But, well, if there are devices which cannot be
supported this way...)
4. The `psm' driver does not include the protocol emulation code by
default. The code can still be compiled in if the PSM_EMULATION option
is specified in the config file. Louis Mamakos suggests the emulation
code is putting too much in the kernel, and `moused' works well.
I will think about this later and decide if the entire emulation
code should be removed.
5. And, of course, the fix in `scprobe()' from Bruce to cure the
UserConfig problem. My code in `kbdio.c' is slightly different from
his patch, but has the same effect. There still is a possibility that
`scprobe()' gets confused, if, for whatever reasons, the user holds
down a key for very long time during the boot process. But we cannot
cope with everything, can we?
Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
1996-12-01 19:05:50 +00:00
|
|
|
#endif
|
1997-01-15 18:16:32 +00:00
|
|
|
sc->queue.tail = (sc->queue.tail + 1) % PSM_BUFSIZE;
|
|
|
|
++sc->queue.count;
|
|
|
|
sc->inputbytes = 0;
|
|
|
|
|
|
|
|
if (sc->state & PSM_ASLP) {
|
|
|
|
sc->state &= ~PSM_ASLP;
|
|
|
|
wakeup((caddr_t) sc);
|
|
|
|
}
|
|
|
|
selwakeup(&sc->rsel);
|
|
|
|
}
|
1996-11-15 06:17:36 +00:00
|
|
|
}
|
|
|
|
}
|
1994-09-09 11:27:50 +00:00
|
|
|
}
|
|
|
|
|
1996-11-15 05:41:34 +00:00
|
|
|
static int
|
1997-09-14 03:19:42 +00:00
|
|
|
psmpoll(dev_t dev, int events, struct proc *p)
|
1994-09-09 11:27:50 +00:00
|
|
|
{
|
1996-11-27 22:52:25 +00:00
|
|
|
struct psm_softc *sc = psm_softc[PSM_UNIT(dev)];
|
1997-01-15 18:16:32 +00:00
|
|
|
int s;
|
1997-09-14 03:19:42 +00:00
|
|
|
int revents = 0;
|
1996-11-15 06:17:36 +00:00
|
|
|
|
|
|
|
/* Return true if a mouse event available */
|
|
|
|
s = spltty();
|
1997-09-14 03:19:42 +00:00
|
|
|
if (events & (POLLIN | POLLRDNORM))
|
|
|
|
if ((sc->outputbytes > 0) || (sc->queue.count > 0))
|
|
|
|
revents |= events & (POLLIN | POLLRDNORM);
|
|
|
|
else
|
|
|
|
selrecord(p, &sc->rsel);
|
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
splx(s);
|
|
|
|
|
1997-09-14 03:19:42 +00:00
|
|
|
return (revents);
|
1994-09-09 11:27:50 +00:00
|
|
|
}
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
|
1996-11-15 05:30:52 +00:00
|
|
|
static int psm_devsw_installed = FALSE;
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
|
1996-05-07 19:01:31 +00:00
|
|
|
static void
|
1996-05-07 19:40:47 +00:00
|
|
|
psm_drvinit(void *unused)
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
{
|
1996-11-15 06:17:36 +00:00
|
|
|
dev_t dev;
|
1995-11-29 10:49:16 +00:00
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
if (!psm_devsw_installed) {
|
|
|
|
dev = makedev(CDEV_MAJOR, 0);
|
|
|
|
cdevsw_add(&dev, &psm_cdevsw, NULL);
|
|
|
|
psm_devsw_installed = TRUE;
|
|
|
|
}
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
}
|
1995-11-29 10:49:16 +00:00
|
|
|
|
1997-06-30 12:52:57 +00:00
|
|
|
#ifdef PSM_HOOKAPM
|
|
|
|
static int
|
|
|
|
psmresume(void *dummy)
|
|
|
|
{
|
|
|
|
struct psm_softc *sc = psm_softc[(int)dummy];
|
|
|
|
int unit = (int)dummy;
|
|
|
|
int err = 0;
|
|
|
|
int s;
|
|
|
|
int c;
|
|
|
|
|
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_NOTICE, "psm%d: APM resume hook called.\n", unit);
|
|
|
|
|
|
|
|
/* don't let anybody mess with the aux device */
|
|
|
|
if (!kbdc_lock(sc->kbdc, TRUE))
|
|
|
|
return (EIO);
|
|
|
|
s = spltty();
|
|
|
|
|
|
|
|
/* save the current controller command byte */
|
|
|
|
empty_both_buffers(sc->kbdc, 10);
|
|
|
|
c = get_controller_command_byte(sc->kbdc);
|
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm%d: current command byte: %04x (psmresume).\n",
|
|
|
|
unit, c);
|
|
|
|
|
|
|
|
/* enable the aux port but disable the aux interrupt and the keyboard */
|
|
|
|
if ((c == -1) || !set_controller_command_byte(sc->kbdc,
|
|
|
|
kbdc_get_device_mask(sc->kbdc),
|
|
|
|
KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
|
|
|
|
| KBD_ENABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
|
|
|
|
/* CONTROLLER ERROR */
|
|
|
|
splx(s);
|
|
|
|
kbdc_lock(sc->kbdc, FALSE);
|
|
|
|
log(LOG_ERR, "psm%d: unable to set the command byte (psmresume).\n",
|
|
|
|
unit);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* flush any data */
|
|
|
|
if (sc->state & PSM_VALID) {
|
|
|
|
disable_aux_dev(sc->kbdc); /* this may fail; but never mind... */
|
|
|
|
empty_aux_buffer(sc->kbdc, 10);
|
|
|
|
}
|
|
|
|
sc->inputbytes = 0;
|
|
|
|
|
|
|
|
#ifdef PSM_RESETAFTERSUSPEND
|
|
|
|
/* try to detect the aux device; are you still there? */
|
|
|
|
if (reinitialize(unit, &sc->mode)) {
|
|
|
|
/* yes */
|
|
|
|
sc->state |= PSM_VALID;
|
|
|
|
} else {
|
|
|
|
/* the device has gone! */
|
|
|
|
restore_controller(sc->kbdc, c);
|
|
|
|
sc->state &= ~PSM_VALID;
|
|
|
|
log(LOG_ERR, "psm%d: the aux device has gone! (psmresume).\n",
|
|
|
|
unit);
|
|
|
|
err = ENXIO;
|
|
|
|
}
|
|
|
|
#endif /* PSM_RESETAFTERSUSPEND */
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
/* restore the driver state */
|
|
|
|
if ((sc->state & PSM_OPEN) && (err == 0)) {
|
|
|
|
/* enable the aux device and the port again */
|
|
|
|
err = doopen(unit, c);
|
|
|
|
if (err != 0)
|
|
|
|
log(LOG_ERR, "psm%d: failed to enable the device (psmresume).\n",
|
|
|
|
unit);
|
|
|
|
} else {
|
|
|
|
/* restore the keyboard port and disable the aux port */
|
|
|
|
if (!set_controller_command_byte(sc->kbdc,
|
|
|
|
kbdc_get_device_mask(sc->kbdc),
|
|
|
|
(c & KBD_KBD_CONTROL_BITS)
|
|
|
|
| KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
|
|
|
|
/* CONTROLLER ERROR */
|
|
|
|
log(LOG_ERR, "psm%d: failed to disable the aux port (psmresume).\n",
|
|
|
|
unit);
|
|
|
|
err = EIO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* done */
|
|
|
|
kbdc_lock(sc->kbdc, FALSE);
|
|
|
|
if ((sc->state & PSM_ASLP) && !(sc->state & PSM_VALID)) {
|
|
|
|
/*
|
|
|
|
* Release the blocked process; it must be notified that the device
|
|
|
|
* cannot be accessed anymore.
|
|
|
|
*/
|
|
|
|
sc->state &= ~PSM_ASLP;
|
|
|
|
wakeup((caddr_t)sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (verbose >= 2)
|
|
|
|
log(LOG_DEBUG, "psm%d: APM resume hook exiting.\n", unit);
|
|
|
|
|
|
|
|
return (err);
|
|
|
|
}
|
|
|
|
#endif /* PSM_HOOKAPM */
|
|
|
|
|
1996-11-15 06:17:36 +00:00
|
|
|
SYSINIT(psmdev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE + CDEV_MAJOR, psm_drvinit, NULL)
|
1996-11-15 05:30:52 +00:00
|
|
|
|
1996-05-07 19:40:47 +00:00
|
|
|
#endif /* NPSM > 0 */
|