diff -dur -N /sys/isa/psm.c sys-synaptics/isa/psm.c --- /sys/isa/psm.c Thu Dec 11 12:28:11 2003 +++ sys-synaptics/isa/psm.c Thu Jan 1 14:13:56 2004 @@ -44,6 +44,8 @@ * Modified for PS/2 AUX mouse by Shoji Yuen * - 24 October 1993 * + * + * * Hardware access routines and probe logic rewritten by * Kazutaka Yokota * - 3, 14, 22 October 1996. @@ -56,6 +58,11 @@ * - 5 March 1997. Defined driver configuration flags (PSM_CONFIG_XXX). * Improved sync check logic. * Vendor specific support routines. + * + * hacks for using the XFree Synaptics Driver + * - Arne Schwabe 31. December 2003 + * + * */ #include @@ -92,7 +99,7 @@ /* debugging */ #ifndef PSM_DEBUG -#define PSM_DEBUG 0 /* logging: 0: none, 1: brief, 2: verbose */ +#define PSM_DEBUG 2 /* logging: 0: none, 1: brief, 2: verbose */ #endif #ifndef PSM_SYNCERR_THRESHOLD1 @@ -290,6 +297,7 @@ static probefunc_t enable_4dmouse; static probefunc_t enable_4dplus; static probefunc_t enable_mmanplus; +static probefunc_t enable_synaptics; static probefunc_t enable_versapad; static int tame_mouse(struct psm_softc *, packetbuf_t *, mousestatus_t *, unsigned char *); @@ -303,6 +311,11 @@ * WARNING: the order of probe is very important. Don't mess it * unless you know what you are doing. */ + { MOUSE_MODEL_SYNAPTICS, /* Synaptics Touchpad */ + 0x00, MOUSE_SYNAPTICS_PACKETSIZE, enable_synaptics, }, + /* There is no real working static syncmask, 3 byte versus 6 byte, + * absolute versus relative, I versus work ;) + */ { MOUSE_MODEL_NET, /* Genius NetMouse */ 0x08, MOUSE_PS2INTELLI_PACKETSIZE, enable_gmouse, }, { MOUSE_MODEL_NETSCROLL, /* Genius NetScroll */ @@ -361,6 +374,7 @@ /* debug message level */ static int verbose = PSM_DEBUG; + /* device I/O routines */ static int enable_aux_dev(KBDC kbdc) @@ -568,6 +582,7 @@ int model_code; char *model_name; } models[] = { + { MOUSE_MODEL_SYNAPTICS, "Synaptics Touchpad" }, { MOUSE_MODEL_NETSCROLL, "NetScroll" }, { MOUSE_MODEL_NET, "NetMouse/NetScroll Optical" }, { MOUSE_MODEL_GLIDEPOINT, "GlidePoint" }, @@ -701,7 +716,7 @@ /* other parameters */ for (i = 0; vendortype[i].probefunc != NULL; ++i) { if ((*vendortype[i].probefunc)(sc)) { - if (verbose >= 2) + if (verbose >= 2) log(LOG_ERR, "psm%d: found %s\n", sc->unit, model_name(vendortype[i].model)); break; @@ -1639,7 +1654,7 @@ dropqueue(struct psm_softc *sc) { - sc->queue.count = 0; + sc->queue.count = 0; sc->queue.head = 0; sc->queue.tail = 0; if ((sc->state & PSM_SOFTARMED) != 0) { @@ -1697,6 +1712,7 @@ int command_byte; int error = 0; int s; + /* Perform IOCTL command */ switch (cmd) { @@ -1712,13 +1728,17 @@ case MOUSE_GETHWINFO: s = spltty(); - *(mousehw_t *)addr = sc->hw; + *(mousehw_t *)addr = sc->hw; + if (sc->mode.level == PSM_LEVEL_BASE) ((mousehw_t *)addr)->model = MOUSE_MODEL_GENERIC; splx(s); - break; + + + printf("mousgetinfo model: %d",sc->hw.model); + break; - case OLD_MOUSE_GETMODE: + case OLD_MOUSE_GETMODE: s = spltty(); switch (sc->mode.level) { case PSM_LEVEL_BASE: @@ -1880,6 +1900,26 @@ return ENODEV; #endif /* MOUSE_GETVARS */ + case MOUSE_SYNAPTICS_INFO: + case MOUSE_SYNAPTICS_CMD: + if (sc->hw.model != 13 || sc->mode.level < PSM_LEVEL_NATIVE) + return EINVAL; + + mouse_ext_command(sc->kbdc,*(int *) addr); + + if (cmd == MOUSE_SYNAPTICS_INFO) + send_aux_command(sc->kbdc, PSMC_SEND_DEV_STATUS); + else + set_mouse_sampling_rate(sc->kbdc,0x0014); + break; + + case MOUSE_SYNAPTICS_ENABLE_PASSTHROUGH: + if (sc->hw.model != 13 || sc->mode.level < PSM_LEVEL_NATIVE) + return EINVAL; + + + break; + case MOUSE_READSTATE: case MOUSE_READDATA: data = (mousedata_t *)addr; @@ -2054,7 +2094,7 @@ c = pb->ipacket[0]; if ((c & sc->mode.syncmask[0]) != sc->mode.syncmask[1]) { - log(LOG_DEBUG, "psmintr: out of sync (%04x != %04x) %d" + log(LOG_DEBUG, "psmintr: out of sync (%04x != %04x) %d" " cmds since last error.\n", c & sc->mode.syncmask[0], sc->mode.syncmask[1], sc->cmdcount - sc->lasterr); @@ -2210,6 +2250,7 @@ ? MOUSE_BUTTON5DOWN : 0; break; + case MOUSE_MODEL_MOUSEMANPLUS: /* * PS2++ protocl packet @@ -2518,6 +2559,9 @@ /* vendor/model specific routines */ + + + static int mouse_id_proc1(KBDC kbdc, int res, int scale, int *status) { if (set_mouse_resolution(kbdc, res) != res) @@ -2530,11 +2574,12 @@ return FALSE; } + + static int mouse_ext_command(KBDC kbdc, int command) { int c; - c = (command >> 6) & 0x03; if (set_mouse_resolution(kbdc, c) != c) return FALSE; @@ -2653,6 +2698,46 @@ return FALSE; return TRUE; } + +/* Synaptics Touchpad */ +static int +enable_synaptics(struct psm_softc *sc) +{ + int status[3]; + + KBDC kbdc = sc->kbdc; + + disable_aux_dev(kbdc); + set_mouse_scaling(kbdc,1); // Just to be on the safe side + + + if(mouse_ext_command(kbdc, 0)) + { + get_mouse_status(kbdc, status, 0, 3); + // If it is a Synaptics byte2 is $47 + if (status[1] == 0x0047) + { // XXX Check for excat model and use its features + /* 1 (absolute) + 1 rate (0 = 40/1 = 80) + 0 + 0 (reserved) + 0 (Sleep (Only buttons)) + 0 DisGest (not for absolute Mode) + 0 pktsize (0 for ps2) + 1 wmode + */ + + // + mouse_ext_command(kbdc,0x04); + set_mouse_sampling_rate(kbdc,0x0014); + + return TRUE; + } + } + return FALSE; +} + + /* Kensington ThinkingMouse/Trackball */ static int diff -dur -N /sys/sys/mouse.h sys-synaptics/sys/mouse.h --- /sys/sys/mouse.h Sun Mar 24 04:07:07 2002 +++ sys-synaptics/sys/mouse.h Thu Jan 1 14:13:43 2004 @@ -40,6 +40,9 @@ #define MOUSE_SETVARS _IOW('M', 7, mousevar_t) #define MOUSE_READSTATE _IOWR('M', 8, mousedata_t) #define MOUSE_READDATA _IOWR('M', 9, mousedata_t) +#define MOUSE_SYNAPTICS_CMD _IOW('M', 10, char) +#define MOUSE_SYNAPTICS_INFO _IOW('M', 11, char) +#define MOUSE_SYNAPTICS_ENABLE_PASSTHROUGH _IOW('M', 12, char) #if notyet #define MOUSE_SETRESOLUTION _IOW('M', 10, int) @@ -119,6 +122,8 @@ #define MOUSE_MODEL_EXPLORER 10 #define MOUSE_MODEL_4D 11 #define MOUSE_MODEL_4DPLUS 12 +#define MOUSE_MODEL_SYNAPTICS 13 + typedef struct mousemode { int protocol; /* MOUSE_PROTO_XXX */ @@ -184,6 +189,10 @@ #define MOUSE_VARS_INPORT_SIG 0x00504e49 /* 'INP' */ #endif /* MOUSE_GETVARS */ + +/* Synaptics Touchpad */ +#define MOUSE_SYNAPTICS_PACKETSIZE 3 +/* Packetsize 6 is the real packetsize but that 3 works better :) */ /* Microsoft Serial mouse data packet */ #define MOUSE_MSS_PACKETSIZE 3