tpconfig-3.1.3.orig/0040775001167100001440000000000007450251056012774 5ustar cphuserstpconfig-3.1.3.orig/aclocal.m40100664001167100001440000000672307326032227014640 0ustar cphusersdnl aclocal.m4 generated automatically by aclocal 1.4 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A dnl PARTICULAR PURPOSE. # Do all the work for Automake. This macro actually does too much -- # some checks are only needed if your package does certain things. # But this isn't really a big deal. # serial 1 dnl Usage: dnl AM_INIT_AUTOMAKE(package,version, [no-define]) AC_DEFUN(AM_INIT_AUTOMAKE, [AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) VERSION=[$2] AC_SUBST(VERSION) dnl test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi ifelse([$3],, AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) AC_REQUIRE([AM_SANITY_CHECK]) AC_REQUIRE([AC_ARG_PROGRAM]) dnl FIXME This is truly gross. missing_dir=`cd $ac_aux_dir && pwd` AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) AC_REQUIRE([AC_PROG_MAKE_SET])]) # # Check to make sure that the build environment is sane. # AC_DEFUN(AM_SANITY_CHECK, [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "[$]*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "[$]*" != "X $srcdir/configure conftestfile" \ && test "[$]*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "[$]2" = conftestfile ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi rm -f conftest* AC_MSG_RESULT(yes)]) dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) dnl The program must properly implement --version. AC_DEFUN(AM_MISSING_PROG, [AC_MSG_CHECKING(for working $2) # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if ($2 --version) < /dev/null > /dev/null 2>&1; then $1=$2 AC_MSG_RESULT(found) else $1="$3/missing $2" AC_MSG_RESULT(missing) fi AC_SUBST($1)]) tpconfig-3.1.3.orig/ALPS.c0100644001167100001440000003123007435525154013677 0ustar cphusers/*********************************************************************** * File name: ALPS.c * * Written by: Bruce Kall * * Created: 2/2000 * * Language: C * * Version: 1.0 * * Purpose: Routines for manipulating the ALPS Glidepad/Stickpointer * * * ***********************************************************************/ /* Copyright (c) 1998-2000 Bruce Kalk * * Currently maintained by: Bruce Kall, * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: ALPS.c,v 1.4 2000/10/31 18:02:45 cph Exp bruce $ */ /*$Log: ALPS.c,v $ *Revision 1.4 2000/10/31 18:02:45 cph *Move copyright into --help screen. * *Revision 1.3 2000/10/31 17:43:12 cph *ACK now AUX_ACK. * *Revision 1.2 2000/09/29 20:18:13 bruce *Added in code for ALPS_GLIDEPAD (single pad, no stick). * *Revision 1.1 2000/09/28 13:44:35 bruce *Initial revision **/ static char rcsid[]="$Header: /home/bruce/linux-stuff/tpconfig/tpconfig-3.1.1/RCS/ALPS.c,v 1.4 2000/10/31 18:02:45 cph Exp bruce $"; #include #include #include #include #include #include #include #include #include #include "tpconfig.h" extern int ps2_write(int fd,char *buffer,int num_bytes); extern int ps2_read(int fd,char *buffer,int num_bytes); extern void version_info(void); extern void putbyte(int fd, byte b); extern byte getbyte(int fd); int ALPS_status(int fd,char *status) { /* ALPS_status */ byte c; int num_written; int num_read; int i; for(i = 0;i < 3;i++) { c = 0xf5; putbyte(fd,c); } c = 0xe9; if(DEBUG_LEVEL) printf("Writing [%x]\n",c); num_written = ps2_write(fd,&c,1); if(num_written != 1) { fprintf(stderr,"Error writing byte\n"); return(ERROR); } num_read = ps2_read(fd,status,4); if(num_read != 4) { fprintf(stderr,"Error reading initial 4 byte response\n"); return(ERROR); } /* resend enable command for xmission of external mouse data */ c = 0xf4; if(DEBUG_LEVEL) { printf("Resending Enable command\n"); printf("Writing [%x]\n",c); } num_written = ps2_write(fd,&c,1); if(num_written != 1) { fprintf(stderr,"Error writing byte\n"); return(0); } if(DEBUG_LEVEL) { printf("Response 0 [%x]\n",status[0]); printf("Response 1 [%x]\n",status[1]); printf("Response 2 [%x]\n",status[2]); printf("Response 3 [%x]\n",status[3]); } return(!ERROR); } /* ALPS_status */ int is_ALPS_tap_enabled(int fd) { /* is_ALPS_tap_enabled */ byte response[4]; int tap_on = TRUE; int error; if(DEBUG_LEVEL) printf("\n\nChecking Whether ALPS Tap status is enabled or disabled\n"); error = ALPS_status(fd,response); if(error) return(0); if(touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT) { if(response[3] & 0x4) tap_on = TRUE; else tap_on = FALSE; } else if(touchpad_type == ALPS_GLIDEPAD) { if(response[1] & 0x4) tap_on = TRUE; else tap_on = FALSE; } if(DEBUG_LEVEL) { if(tap_on) printf("Done Checking Status of Tap Enabled/Disable, Tap is ON \n"); else printf("Done Checking Status of Tap Enabled/Disable, Tap is OFF \n"); } return(tap_on); } /* is_ALPS_tap_enabled */ int reset_ALPS(int fd) { /* reset_ALPS */ byte c; int num_written; c = 0xff; if(DEBUG_LEVEL) printf("\nWriting Reset [%x], Reading Nothing\n",(int)c); num_written = ps2_write(fd,&c,1); if(num_written != 1) { fprintf(stderr,"Error writing reset byte\n"); return(FALSE); } /* need to wait 1.5 sec here for reset to complete */ usleep(1600000); return(TRUE); } /* reset_ALPS */ int ALPS_SP_tap(int fd,char enable) { /* ALPS_SP_tap */ byte c; int i; if(DEBUG_LEVEL) { if(enable) printf("\n\nEnabling SP tap\n"); else printf("\n\nDisabling SP tap\n"); } for(i = 0;i < 3;i++) { c = 0xE6; putbyte(fd,c); } c = 0xF3; putbyte(fd,c); if(enable) c = 0x14; else c = 0x0a; putbyte(fd,c); if(DEBUG_LEVEL) printf("Done Enabling/Disabling SP tap\n"); return(!ERROR); } /* ALPS_SP_tap */ int ALPS_through_mode(int fd,char set) { /* ALPS_through_mode */ byte c; int i; if(DEBUG_LEVEL) { if(set) printf("\n\nEnabling ALPS_through_mode\n"); else printf("\n\nDisabling ALPS_through_mode\n"); } for(i = 0;i < 3;i++) { if(set) c = 0xE7; else c = 0xE6; putbyte(fd,c); } c = 0xF5; putbyte(fd,c); /* We may receive 3 more bytes, ignore them */ tcflush(fd,TCIOFLUSH); if(DEBUG_LEVEL) { if(set) printf("Done Enabling ALPS_through_mode\n\n\n"); else printf("Done Disabling ALPS_through_mode\n\n\n"); } return(0); } /* ALPS_through_mode */ int ALPS_GP_tap(int fd,char enable) { /* ALPS_GP_tap */ byte c; byte response[4]; int i; int num_read; int num_written; int error; if(DEBUG_LEVEL) { if(enable) printf("\n\nEnabling GP tap\n"); else printf("\n\nDisabling GP tap\n"); } if(touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT) { error = ALPS_through_mode(fd,(char) 1); if(error) { printf("Error turning on through mode\n"); return(ERROR); } } c = 0xE9; if(DEBUG_LEVEL) printf("Writing Initial [%x]\n",(int)c); num_written = ps2_write(fd,&c,1); num_read = ps2_read(fd,response,4); if(DEBUG_LEVEL) { printf("Just Read num = [%d] bytes",num_read); printf("\n"); } if((num_read != 4) || (response[0] != AUX_ACK)) { printf("-----> Invalid response from Alps Glidepad/Glidepoint [%x] \n",(int)response[0]); return(ERROR); } if(DEBUG_LEVEL) printf("Current Settings [%x] [%x] [%x]\n",response[1],response[2],response[3]); for(i = 0;i < 2;i++) { c = 0xF5; putbyte(fd,c); } if(enable) { if(DEBUG_LEVEL) printf("Enabling Tap\n"); c = 0xF3; } else { if(DEBUG_LEVEL) printf("Disabling Tap\n"); c = 0xE8; } putbyte(fd,c); if(enable) c = 0x0A; else c = 0x00; putbyte(fd,c); if(touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT) { error = ALPS_through_mode(fd,(char) 0); if(error) { printf("Error turning off through mode\n"); return(ERROR); } if(DEBUG_LEVEL) printf("Done Enabling/Disabling GP tap\n"); } return(NO_ERROR); } /* ALPS_GP_tap */ int is_ALPS(int fd) { #define NUM_SINGLES 10 static int singles[NUM_SINGLES * 3] ={ 0x33,0x2,0xa, 0x53,0x2,0x0a, 0x53,0x2,0x14, 0x63,0x2,0xa, 0x63,0x2,0x14, 0x73,0x2,0xa, 0x63,0x2,0x28, 0x63,0x2,0x3c, 0x63,0x2,0x50, 0x63,0x2,0x64}; #define NUM_DUALS 3 static int duals[NUM_DUALS * 3]={ 0x20,0x2,0xe, /* as reported by William Moran, billm@adv-techcenter.com CPxH*/ 0x22,0x2,0xa, 0x22,0x2,0x14}; byte c; byte response[4]; int i; int num_read,num_written; int return_value = 0; int tap_on; int error; tap_on = TRUE; /* Get initial statis of ALPS device so we can reset after reset below */ /* tap_on = is_ALPS_tap_enabled(fd);*/ for(i = 0;i < 3;i++) { c = 0xe7; putbyte(fd,c); } c = 0xe9; if(DEBUG_LEVEL) printf("Writing Initial [%x] in is_ALPS\n",(int)c); num_written = ps2_write(fd,&c,1); if(num_written != 1) { fprintf(stderr,"Error writing Secondary Initial response\n"); return(0); } num_read = ps2_read(fd,response,4); if(num_read != 4) { fprintf(stderr,"Error reading Initial 4 byte response\n"); return(0); } if(DEBUG_LEVEL) printf("ALPS Configuration Info [%2x][%2x][%2x]\n",response[1],response[2],response[3]); return_value = 0; for(i = 0;i < NUM_SINGLES;i++) { if((response[1] == singles[i * 3] && (response[2] == singles[i * 3 + 1]) && response[3] == singles[i * 3 + 2])) { touchpad_type = ALPS_GLIDEPAD; return_value = 1; } } if(return_value == 0) { for(i = 0;i < NUM_DUALS;i++) { if((response[1] == duals[i * 3]) && (response[2] == duals[i * 3 + 1]) && (response[3] == duals[i * 3 + 2])) { touchpad_type = ALPS_STICKPOINTER_AND_GLIDEPOINT; return_value = 1; } } } /* Older kernels may need this .. <2.4.x */ /* Newer kernels get an assertion error if this reset_ALPS */ /* is performed. With 2.4.9 commenting this out fixes the */ /* assertion error on ALPS dual (touchpad/glidestick) */ /* I don't have one, but a single ALPS touchpad may need this */ /* reset_ALPS(fd); */ if(return_value) { if(!tap_on) { /* reset tap_on to off since we just had to do a reset */ if(DEBUG_LEVEL) printf("Turning ALPS Tap Back OFF\n"); if(touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT) { error = ALPS_GP_tap(fd,(char) 0); error = ALPS_SP_tap(fd,(char) 0); } else if(touchpad_type == ALPS_GLIDEPAD) error = ALPS_GP_tap(fd,(char) 0); } } return(return_value); } /* is_ALPS */ void ALPS_usage(char *progname) { copyright (); printf ("Usage: %s [OPTION]...\n", progname); printf ("Configure an ALPS GlidePad/GlidePoint.\n" "\n" " -i, --info display current TouchPad configuration\n" " -t, --tapmode=[0-1] display/set tapping mode:\n" " 0 = tapping off\n" " 1 = tapping on\n" " -r, --reset reset ALPS device\n" " --help display this help and exit\n" " --version output version information\n" "\n" "Report bugs to '3')) fprintf(stderr, "Invalid tap mode. [Use 0-3]\n"); else { mode = optarg[0]-'0'; if(DEBUG_LEVEL) printf("User Asked to set Tap mode to [%d]\n",mode); if(mode > 0) { if(DEBUG_LEVEL) printf("Turning ALPS Tap ON\n"); if(touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT) { error = ALPS_GP_tap(fd,(char) 1); error = ALPS_SP_tap(fd,(char) 1); } else if(touchpad_type == ALPS_GLIDEPAD) error = ALPS_GP_tap(fd,(char) 1); } else { /* disable tap mode */ if(DEBUG_LEVEL) printf("Turning ALPS Tap OFF\n"); if(touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT) { error = ALPS_GP_tap(fd,(char) 0); error = ALPS_SP_tap(fd,(char) 0); } else if(touchpad_type == ALPS_GLIDEPAD) error = ALPS_GP_tap(fd,(char) 0); } status = is_ALPS_tap_enabled(fd); if(status) printf("ALPS Tap is ON\n"); else printf("ALPS Tap is OFF\n"); } } break; case 'v': /* --version */ version_info(); break; default: fprintf(stderr, "Unknown option %c.\n", (char)c); break; } } tpconfig-3.1.3.orig/touchpad0100755001167100001440000000125307305727072014532 0ustar cphusers#!/bin/bash # # touchpad Configure touchpad # chkconfig: 35 84 84 # description: Startup script to disable touchpad tapping \ # for Synaptics or ALPS touchpads. # # $Log$ # # $Id$ # # # Source function library. . /etc/init.d/functions case "$1" in start) echo "" echo -n "Turning off Touch-Pad 'tapping' " if [ -f /usr/bin/tpconfig ]; then /usr/bin/tpconfig --tapmode=0 if [ $? ]; then echo_success else echo_failure fi else echo_failure fi ;; stop) echo_success ;; restart) echo_success ;; esac exit 0 tpconfig-3.1.3.orig/AUTHORS0100664001167100001440000000107107435526134014045 0ustar cphusersAuthor of this package: Current release is 3.1.3. Maintained by Bruce Kall kall@compass.com Release is 3.1.2. Maintained by Bruce Kall kall@compass.com Release 3.1. Maintained by Bruce Kall kall@compass.com Release 3.0. Maintained by Bruce Kall kall@compass.com Prior release is: 2.2. Maintained by Bruce Kall, kall@compass.com. Original Author of this package: C. Scott Ananian Bug-fixes and contributions by: * Derek W Poon (8 Dec 1997) Found & corrected bitmask typo. tpconfig-3.1.3.orig/ChangeLog0100664001167100001440000000306507435526351014555 0ustar cphusers 2/22/02 - Version 3.1.3 Fixed assertion error that some ALPS users were getting with newer 2.4.x kernels (this has been tested on 2.4.9). 4/23/01 - Version 3.1.2 Fixed to work with 2.4 kernel. Added diffs and pc_keyb.c patched files for /usr/src/linux/drivers/char/pc_keyb.c file for 2.4.2 and 2.2.17 kernels (patches from cph@zurich.ai.mit.edu). 11/14/00 Version 3.1 - Bruce Kall (kall@compass.com) Incorporated changes by Chris Hanson (cph@zurich.ai.mit.edu): 1) Added 2.2.17 kernel patch that provide mechanism for access the aux device while another process (e.g., X server) has it open. tpconfig can now be run under X. 2) Implemented --sleep option for Synaptics to allow reading and and writing sleep mode on touchpads that support it. 3) rewrite of synaptics.c to clean it up, use symbolic constants, increase abstraction level etc. 9/29/00 Version 3.0 - Bruce Kall (kall@compass.com): Added first support for ALPS Glidepad/Stickpointer 9/1/99 Version 2.3 - Bruce Kall (kall@compass.com): Incorporated changes by Tim Underwood for kernels above 2.2.7. 2/16/99 Version 2.2 - Bruce Kall (kall@compass.com): Modified to work with 2.2.x kernel as well as 2.0.x kernels. This version also now will time out gracefully if being run on top of gpm or X. 7/8/98 Version 2.0: - Bruce Kall (kall@compass.com): Changed to work with modern Synaptic touchpads which contain newer firmware (that have a single mode byte). Also added detection of newer touchpad info ('Super' 'Ultrathin', 'Widepad','Stamppad','Submini','Multiswich'). tpconfig-3.1.3.orig/configure0100775001167100001440000013144007326032230014674 0ustar cphusers#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir="$ac_optarg" ;; -build | --build | --buil | --bui | --bu) ac_prev=build ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$ac_optarg" ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file="$ac_optarg" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "enable_${ac_feature}='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix="$ac_optarg" ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he) # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF if test -n "$ac_help"; then echo "--enable and --with options recognized:$ac_help" fi exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$ac_optarg" ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir="$ac_optarg" ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir="$ac_optarg" ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir="$ac_optarg" ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir="$ac_optarg" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir="$ac_optarg" ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir="$ac_optarg" ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir="$ac_optarg" ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix="$ac_optarg" ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix="$ac_optarg" ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix="$ac_optarg" ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name="$ac_optarg" ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir="$ac_optarg" ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir="$ac_optarg" ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site="$ac_optarg" ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir="$ac_optarg" ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir="$ac_optarg" ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` eval "with_${ac_package}=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes="$ac_optarg" ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries="$ac_optarg" ;; -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file=tpconfig.c # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break fi done if test -z "$ac_aux_dir"; then { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:556: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then INSTALL="$ac_cv_path_install" else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 echo "configure:609: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "$*" != "X $srcdir/configure conftestfile" \ && test "$*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". { echo "configure: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" 1>&2; exit 1; } fi test "$2" = conftestfile ) then # Ok. : else { echo "configure: error: newly created file is older than distributed files! Check your system clock" 1>&2; exit 1; } fi rm -f conftest* echo "$ac_t""yes" 1>&6 if test "$program_transform_name" = s,x,x,; then program_transform_name= else # Double any \ or $. echo might interpret backslashes. cat <<\EOF_SED > conftestsed s,\\,\\\\,g; s,\$,$$,g EOF_SED program_transform_name="`echo $program_transform_name|sed -f conftestsed`" rm -f conftestsed fi test "$program_prefix" != NONE && program_transform_name="s,^,${program_prefix},; $program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s,\$\$,${program_suffix},; $program_transform_name" # sed with no file args requires a program. test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 echo "configure:666: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftestmake <<\EOF all: @echo 'ac_maketemp="${MAKE}"' EOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi rm -f conftestmake fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then echo "$ac_t""yes" 1>&6 SET_MAKE= else echo "$ac_t""no" 1>&6 SET_MAKE="MAKE=${MAKE-make}" fi PACKAGE=tpconfig VERSION=3.1.3 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } fi cat >> confdefs.h <> confdefs.h <&6 echo "configure:712: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (aclocal --version) < /dev/null > /dev/null 2>&1; then ACLOCAL=aclocal echo "$ac_t""found" 1>&6 else ACLOCAL="$missing_dir/missing aclocal" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 echo "configure:725: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoconf --version) < /dev/null > /dev/null 2>&1; then AUTOCONF=autoconf echo "$ac_t""found" 1>&6 else AUTOCONF="$missing_dir/missing autoconf" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 echo "configure:738: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (automake --version) < /dev/null > /dev/null 2>&1; then AUTOMAKE=automake echo "$ac_t""found" 1>&6 else AUTOMAKE="$missing_dir/missing automake" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 echo "configure:751: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoheader --version) < /dev/null > /dev/null 2>&1; then AUTOHEADER=autoheader echo "$ac_t""found" 1>&6 else AUTOHEADER="$missing_dir/missing autoheader" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 echo "configure:764: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (makeinfo --version) < /dev/null > /dev/null 2>&1; then MAKEINFO=makeinfo echo "$ac_t""found" 1>&6 else MAKEINFO="$missing_dir/missing makeinfo" echo "$ac_t""missing" 1>&6 fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:781: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:811: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_save_ifs" if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# -gt 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:862: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:894: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 905 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:910: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:936: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:941: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:969: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo "configure:1003: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1024: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1041: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1058: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 for ac_hdr in fcntl.h unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1086: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1096: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done if test "$ac_cv_header_fcntl_h" = "no"; then { echo "configure: error: Could not find " 1>&2; exit 1; } fi if test "$ac_cv_header_unistd_h" = "no"; then { echo "configure: error: Could not find " 1>&2; exit 1; } fi trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. cat > conftest.defs <<\EOF s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g s%\[%\\&%g s%\]%\\&%g s%\$%$$%g EOF DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` rm -f conftest.defs # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@PACKAGE@%$PACKAGE%g s%@VERSION@%$VERSION%g s%@ACLOCAL@%$ACLOCAL%g s%@AUTOCONF@%$AUTOCONF%g s%@AUTOMAKE@%$AUTOMAKE%g s%@AUTOHEADER@%$AUTOHEADER%g s%@MAKEINFO@%$MAKEINFO%g s%@SET_MAKE@%$SET_MAKE%g s%@CC@%$CC%g s%@CPP@%$CPP%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac case "$ac_given_INSTALL" in [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 tpconfig-3.1.3.orig/configure.in0100664001167100001440000000115107326032214015273 0ustar cphusersdnl Process this file with autoconf to produce a configure script. dnl dnl $Id: configure.in,v 1.2 2000/11/05 21:50:47 cph Exp $ AC_INIT(tpconfig.c) AM_INIT_AUTOMAKE(tpconfig, 3.1.3) dnl Checks for programs. AC_PROG_CC dnl Checks for libraries. dnl Checks for header files. AC_CHECK_HEADERS(fcntl.h unistd.h) if test "$ac_cv_header_fcntl_h" = "no"; then AC_MSG_ERROR([Could not find ]) fi if test "$ac_cv_header_unistd_h" = "no"; then AC_MSG_ERROR([Could not find ]) fi dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for library functions. AC_OUTPUT(Makefile) tpconfig-3.1.3.orig/COPYING0100644001167100001440000004310507211741753014030 0ustar cphusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. tpconfig-3.1.3.orig/INSTALL0100644001167100001440000002167507211741753014036 0ustar cphusersBasic Installation ================== Short Method: Install the executable rpm or - untar the tar file - ./configure - make - make install Install the kernel patch and reinstall your kernel (if you want the ability to run tpconfig under X or when gpm is running). Then invoke /usr/local/bin/tpconfig from the startup script 'touchpad' before gpm and/or X Windows are started. Also can be run in single-user mode. Long Method: These are generic installation instructions. See 'Running tpconfig' at the end for an example on how to set up and run tpconfig for Linux systems. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. Running tpconfig ================ tpconfig needs to be run in the startup area (as in /etc/rc.d/rc5.d for RH Linux). I run it before S85gpm as S84tpconfig (which is a link to /etc/rc.d/init.d/touchpad). An example /etc/rc.d/init.d/touchpad would look like (to disable the Synaptics 'tapping' feature [which drives me crazy]): #!/bin/sh # touchpad # description: Startup script to disable touchpad tapping # For Synaptics or ALPS touchpads. # # $Log$ # # $Id$ # # test -r /etc/rc.d/init.d/functions && . /etc/rc.d/init.d/functions echo "" echo -n "Turning off Touch-Pad 'tapping' " if [ -f /usr/bin/tpconfig ]; then /usr/bin/tpconfig --tapmode=0 if [ $? ]; then echo_failure else echo_success fi else echo_failure fi echo "" exit 0 Have fun - !! tpconfig-3.1.3.orig/install-sh0100755001167100001440000001272007211741753015000 0ustar cphusers#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 tpconfig-3.1.3.orig/kernel-2.2.17-psaux-exclusive.patch0100664001167100001440000002546407211741753021200 0ustar cphusers--- linux/drivers/char/pc_keyb.c.orig Mon Sep 4 13:39:17 2000 +++ linux/drivers/char/pc_keyb.c Sun Nov 5 15:15:58 2000 @@ -13,6 +13,14 @@ * Code fixes to handle mouse ACKs properly. * C. Scott Ananian 1999-01-29. * + * Code fixes to *really* handle mouse ACKs properly. + * Julian Bradfield 1999-04-30. + * + * Implement exclusive access mechanism for aux device. + * This permits grabbing the mouse away from the X server, + * which is needed by fancy mice that have configurable features. + * Chris Hanson 2000-10-30. + * */ #include @@ -58,6 +66,8 @@ static void kbd_write_output_w(int data); #ifdef CONFIG_PSMOUSE static void aux_write_ack(int val); +static void aux_kill_fasync(struct fasync_struct *fasync, int s); +static int aux_release_ioctl(struct file *file); #endif spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED; @@ -81,13 +91,25 @@ static struct aux_queue *queue; /* Mouse data buffer. */ static int aux_count = 0; -/* used when we send commands to the mouse that expect an ACK. */ +/* used when we (as opposed to the user programs using the aux device) + send commands to the mouse that expect an ACK. */ static unsigned char mouse_reply_expected = 0; +/* used to make sure we read acks from the mouse before we write + another byte */ +static unsigned char mouse_ack_pending = 0; +#define MOUSE_ACK_TIMEOUT 5 /* actually, 1 seems to be enough usually */ #define AUX_INTS_OFF (KBD_MODE_KCC | KBD_MODE_DISABLE_MOUSE | KBD_MODE_SYS | KBD_MODE_KBD_INT) #define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT) #define MAX_RETRIES 60 /* some aux operations take long time*/ + +/* Support for exclusive access to the AUX device. */ +static struct file *aux_exclusive = 0; +static struct wait_queue *aux_exclusive_wait = NULL; +static unsigned long aux_last_write = 0; +#define AUX_GRAB _IO('M', 1) +#define AUX_RELEASE _IO('M', 2) #endif /* CONFIG_PSMOUSE */ /* @@ -392,6 +414,10 @@ static inline void handle_mouse_event(unsigned char scancode) { #ifdef CONFIG_PSMOUSE + if (mouse_ack_pending) + /* It needn't actually be an ack, it could be an echo; + but every byte sent to the mouse results in a byte back. */ + mouse_ack_pending = 0; if (mouse_reply_expected) { if (scancode == AUX_ACK) { mouse_reply_expected--; @@ -399,19 +425,18 @@ } mouse_reply_expected = 0; } - else if(scancode == AUX_RECONNECT){ - queue->head = queue->tail = 0; /* Flush input queue */ - /* ping the mouse :) */ - kb_wait(); - kbd_write_command(KBD_CCMD_WRITE_MOUSE); - kb_wait(); - kbd_write_output(AUX_ENABLE_DEV); - /* we expect an ACK in response. */ - mouse_reply_expected++; - kb_wait(); - return; - } - + else if (scancode == AUX_RECONNECT) { + queue->head = queue->tail = 0; /* Flush input queue */ + /* ping the mouse :) */ + kb_wait(); + kbd_write_command(KBD_CCMD_WRITE_MOUSE); + kb_wait(); + kbd_write_output(AUX_ENABLE_DEV); + /* we expect an ACK in response. */ + mouse_reply_expected++; + kb_wait(); + return; + } add_mouse_randomness(scancode); if (aux_count) { int head = queue->head; @@ -421,7 +446,7 @@ if (head != queue->tail) { queue->head = head; if (queue->fasync) - kill_fasync(queue->fasync, SIGIO); + aux_kill_fasync(queue->fasync, SIGIO); wake_up_interruptible(&queue->proc_list); } } @@ -440,31 +465,33 @@ unsigned char status = kbd_read_status(); unsigned int work = 10000; - while (status & KBD_STAT_OBF) { + while ((--work > 0) && (status & KBD_STAT_OBF)) { unsigned char scancode; scancode = kbd_read_input(); -# ifdef CHECK_RECONNECT_SCANCODE - printk(KERN_INFO "-=db=-: kbd_read_input() : scancode == %d\n",scancode); -# endif - if (status & KBD_STAT_MOUSE_OBF) { - handle_mouse_event(scancode); - } else { - if (do_acknowledge(scancode)) - handle_scancode(scancode, !(scancode & 0x80)); - mark_bh(KEYBOARD_BH); - } - status = kbd_read_status(); - - if(!work--) + /* Error bytes must be ignored to make the + Synaptics touchpads compaq use work */ +#if 1 + /* Ignore error bytes */ + if (!(status & (KBD_STAT_GTO | KBD_STAT_PERR))) +#endif { - printk(KERN_ERR "pc_keyb: controller jammed (0x%02X).\n", - status); - break; + if (status & KBD_STAT_MOUSE_OBF) + handle_mouse_event(scancode); + else { + if (do_acknowledge(scancode)) + handle_scancode(scancode, !(scancode & 0x80)); + mark_bh(KEYBOARD_BH); + } } + + status = kbd_read_status(); } + if (!work) + printk(KERN_ERR "pc_keyb: controller jammed (0x%02X).\n", status); + return status; } @@ -791,12 +818,23 @@ static void aux_write_dev(int val) { unsigned long flags; + int loop = 0; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); + /* If we haven't yet received the ack from the previous + write, we must wait for it to arrive; otherwise we + lose it. (At least, I think this is what is happening.) */ + while (mouse_ack_pending && loop++ < MOUSE_ACK_TIMEOUT ) { + mdelay(1); + handle_kbd_event(); + } + if (mouse_ack_pending) + printk(KERN_WARNING "mouse ack timeout\n"); kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); + mouse_ack_pending = 1; spin_unlock_irqrestore(&kbd_controller_lock, flags); } @@ -806,18 +844,52 @@ static void aux_write_ack(int val) { unsigned long flags; + int loop = 0; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); + while (mouse_ack_pending && loop++ < MOUSE_ACK_TIMEOUT) { + mdelay(1); + handle_kbd_event(); + } + if (mouse_ack_pending) + printk(KERN_WARNING "mouse ack timeout\n"); kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); - /* we expect an ACK in response. */ + mouse_ack_pending = 1; + /* we will deal with the ACK ourselves. */ mouse_reply_expected++; kb_wait(); spin_unlock_irqrestore(&kbd_controller_lock, flags); } +static void aux_kill_fasync(struct fasync_struct *fasync, int s) +{ + struct fasync_struct * fp; + struct fasync_struct fa; + + fp = fasync; + /* If someone has grabbed the AUX device, send signal only to + them and not to other processes. We could do this directly + if send_sigio was exported, but since it isn't we must + synthesize a "struct fasync_struct" to pass to + kill_fasync. */ + if (aux_exclusive) { + while (1) { + if (!fp) + return; + if (fp->fa_file == aux_exclusive) + break; + fp = fp->fa_next; + } + fa = (*fp); + fa.fa_next = NULL; + fp = &fa; + } + kill_fasync(fp, s); +} + static unsigned char get_from_queue(void) { unsigned char result; @@ -855,6 +927,8 @@ static int release_aux(struct inode * inode, struct file * file) { fasync_aux(-1, file, 0); + if (aux_exclusive == file) + aux_release_ioctl(file); if (--aux_count) return 0; kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints */ @@ -888,6 +962,33 @@ } /* + * Implement exclusive access mechanism. + */ + +#define AUX_ACCESS_ALLOWED(file) (!aux_exclusive || aux_exclusive == (file)) + +static ssize_t aux_wait_for_access(struct file * file) +{ + struct wait_queue wait = { current, NULL }; + + if (!AUX_ACCESS_ALLOWED(file)) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + add_wait_queue(&aux_exclusive_wait, &wait); + do { + current->state = TASK_INTERRUPTIBLE; + schedule(); + } + while (!AUX_ACCESS_ALLOWED(file) + && !signal_pending(current)); + remove_wait_queue(&aux_exclusive_wait, &wait); + } + if (!AUX_ACCESS_ALLOWED(file)) + return -ERESTARTSYS; + return 0; +} + +/* * Put bytes from input queue to buffer. */ @@ -897,7 +998,11 @@ struct wait_queue wait = { current, NULL }; ssize_t i = count; unsigned char c; + ssize_t retval; + retval = aux_wait_for_access(file); + if (retval < 0) + return retval; if (queue_empty()) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; @@ -932,8 +1037,11 @@ static ssize_t write_aux(struct file * file, const char * buffer, size_t count, loff_t *ppos) { - ssize_t retval = 0; + ssize_t retval; + retval = aux_wait_for_access(file); + if (retval < 0) + return retval; if (count) { ssize_t written = 0; @@ -949,6 +1057,7 @@ if (written) { retval = written; file->f_dentry->d_inode->i_mtime = CURRENT_TIME; + aux_last_write = jiffies; } } @@ -958,18 +1067,82 @@ static unsigned int aux_poll(struct file *file, poll_table * wait) { poll_wait(file, &queue->proc_list, wait); - if (!queue_empty()) + if (AUX_ACCESS_ALLOWED(file) && !queue_empty()) return POLLIN | POLLRDNORM; return 0; } +/* Wait this long after last write to mouse before allowing AUX_GRAB + to happen. This ensures that any outstanding mouse command is + completed. The ACK from the command is supposed to arrive in 25 + msec, and each subsequent status bytes are supposed to arrive + within 20 msec, so a command with 5 status bytes (I don't know any + this long) might take 125 msec. Fudge this up a bit to account for + additional delay introduced by bus locking. */ +#define AUX_GRAB_MIN_TIME (aux_last_write + (((200 * HZ) + 500) / 1000)) +#define AUX_GRAB_ALLOWED (aux_exclusive == 0 && (jiffies >= AUX_GRAB_MIN_TIME)) + +static void aux_grab_timeout(unsigned long data) +{ + wake_up_interruptible(&aux_exclusive_wait); +} + +static int aux_grab_ioctl(struct file *file) +{ + struct wait_queue wait = { current, NULL }; + struct timer_list timer; + + if (aux_exclusive == file) + return -EINVAL; + if (!AUX_GRAB_ALLOWED) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + init_timer (&timer); + timer.expires = AUX_GRAB_MIN_TIME; + timer.data = 0; + timer.function = aux_grab_timeout; + add_wait_queue(&aux_exclusive_wait, &wait); + add_timer(&timer); + do { + current->state = TASK_INTERRUPTIBLE; + schedule(); + } + while (!AUX_GRAB_ALLOWED && !signal_pending(current)); + del_timer(&timer); + remove_wait_queue(&aux_exclusive_wait, &wait); + } + if (!AUX_GRAB_ALLOWED) + return -ERESTARTSYS; + aux_exclusive = file; + return 0; +} + +static int aux_release_ioctl(struct file *file) +{ + if (aux_exclusive != file) + return -ENOENT; + aux_exclusive = 0; + wake_up_interruptible(&aux_exclusive_wait); + return 0; +} + +static int aux_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + switch (cmd) { + case AUX_GRAB: return aux_grab_ioctl(file); + case AUX_RELEASE: return aux_release_ioctl(file); + default: return -EINVAL; + } +} + struct file_operations psaux_fops = { NULL, /* seek */ read_aux, write_aux, NULL, /* readdir */ aux_poll, - NULL, /* ioctl */ + aux_ioctl, NULL, /* mmap */ open_aux, NULL, /* flush */ @@ -1006,6 +1179,8 @@ #endif /* INITIALIZE_MOUSE */ kbd_write_command(KBD_CCMD_MOUSE_DISABLE); /* Disable aux device. */ kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints. */ + + aux_last_write = jiffies; return 0; } tpconfig-3.1.3.orig/Makefile.am0100664001167100001440000000064107211741753015031 0ustar cphusers## Process this file with automake to produce Makefile.in # Source: $Id: Makefile.am,v 1.2 2000/11/05 21:50:25 cph Exp $ AUTOMAKE_OPTIONS = "VERSION=1.2" bin_PROGRAMS = tpconfig tpconfig_SOURCES = tpconfig.c synaptics.c ALPS.c utils.c MAINTAINERCLEANFILES = Makefile.in configure aclocal.m4 \ install-sh missing mkinstalldirs \ COPYING INSTALL # don't know why this is being omitted... EXTRA_DIST = configure tpconfig-3.1.3.orig/Makefile.in0100664001167100001440000002415707326032227015046 0ustar cphusers# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. # Source: $Id: Makefile.am,v 1.2 2000/11/05 21:50:25 cph Exp $ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : CC = @CC@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ AUTOMAKE_OPTIONS = "VERSION=1.2" bin_PROGRAMS = tpconfig tpconfig_SOURCES = tpconfig.c synaptics.c ALPS.c utils.c MAINTAINERCLEANFILES = Makefile.in configure aclocal.m4 install-sh missing mkinstalldirs COPYING INSTALL # don't know why this is being omitted... EXTRA_DIST = configure ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_CLEAN_FILES = PROGRAMS = $(bin_PROGRAMS) DEFS = @DEFS@ -I. -I$(srcdir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ tpconfig_OBJECTS = tpconfig.o synaptics.o ALPS.o utils.o tpconfig_LDADD = $(LDADD) tpconfig_DEPENDENCIES = tpconfig_LDFLAGS = CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \ Makefile.in NEWS aclocal.m4 configure configure.in install-sh missing \ mkinstalldirs DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = gtar GZIP_ENV = --best DEP_FILES = .deps/ALPS.P .deps/synaptics.P .deps/tpconfig.P \ .deps/utils.P SOURCES = $(tpconfig_SOURCES) OBJECTS = $(tpconfig_OBJECTS) all: all-redirect .SUFFIXES: .SUFFIXES: .S .c .o .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status $(ACLOCAL_M4): configure.in cd $(srcdir) && $(ACLOCAL) config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) mostlyclean-binPROGRAMS: clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) distclean-binPROGRAMS: maintainer-clean-binPROGRAMS: install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) list='$(bin_PROGRAMS)'; for p in $$list; do \ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ done .s.o: $(COMPILE) -c $< .S.o: $(COMPILE) -c $< mostlyclean-compile: -rm -f *.o core *.core clean-compile: distclean-compile: -rm -f *.tab.c maintainer-clean-compile: tpconfig: $(tpconfig_OBJECTS) $(tpconfig_DEPENDENCIES) @rm -f tpconfig $(LINK) $(tpconfig_LDFLAGS) $(tpconfig_OBJECTS) $(tpconfig_LDADD) $(LIBS) tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) mostlyclean-tags: clean-tags: distclean-tags: -rm -f TAGS ID maintainer-clean-tags: distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist -rm -rf $(distdir) GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz mkdir $(distdir)/=build mkdir $(distdir)/=inst dc_install_base=`cd $(distdir)/=inst && pwd`; \ cd $(distdir)/=build \ && ../configure --srcdir=.. --prefix=$$dc_install_base \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) dist -rm -rf $(distdir) @banner="$(distdir).tar.gz is ready for distribution"; \ dashes=`echo "$$banner" | sed s/./=/g`; \ echo "$$dashes"; \ echo "$$banner"; \ echo "$$dashes" dist: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) dist-all: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) distdir: $(DISTFILES) -rm -rf $(distdir) mkdir $(distdir) -chmod 777 $(distdir) here=`cd $(top_builddir) && pwd`; \ top_distdir=`cd $(distdir) && pwd`; \ distdir=`cd $(distdir) && pwd`; \ cd $(top_srcdir) \ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) -include $(DEP_FILES) mostlyclean-depend: clean-depend: distclean-depend: -rm -rf .deps maintainer-clean-depend: %.o: %.c @echo '$(COMPILE) -c $<'; \ $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< @-cp .deps/$(*F).pp .deps/$(*F).P; \ tr ' ' '\012' < .deps/$(*F).pp \ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ >> .deps/$(*F).P; \ rm .deps/$(*F).pp %.lo: %.c @echo '$(LTCOMPILE) -c $<'; \ $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ < .deps/$(*F).pp > .deps/$(*F).P; \ tr ' ' '\012' < .deps/$(*F).pp \ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ >> .deps/$(*F).P; \ rm -f .deps/$(*F).pp info-am: info: info-am dvi-am: dvi: dvi-am check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am install-exec-am: install-binPROGRAMS install-exec: install-exec-am install-data-am: install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am uninstall-am: uninstall-binPROGRAMS uninstall: uninstall-am all-am: Makefile $(PROGRAMS) all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: $(mkinstalldirs) $(DESTDIR)$(bindir) mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ mostlyclean-tags mostlyclean-depend mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \ clean-generic mostlyclean-am clean: clean-am distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ distclean-depend distclean-generic clean-am distclean: distclean-am -rm -f config.status maintainer-clean-am: maintainer-clean-binPROGRAMS \ maintainer-clean-compile maintainer-clean-tags \ maintainer-clean-depend maintainer-clean-generic \ distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am -rm -f config.status .PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile tags mostlyclean-tags distclean-tags \ clean-tags maintainer-clean-tags distdir mostlyclean-depend \ distclean-depend clean-depend maintainer-clean-depend info-am info \ dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ install-exec install-data-am install-data install-am install \ uninstall-am uninstall all-redirect all-am all installdirs \ mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: tpconfig-3.1.3.orig/missing0100755001167100001440000001105207211741753014370 0ustar cphusers#! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997 Free Software Foundation, Inc. # Franc,ois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison touch file \`y.tab.c' makeinfo touch the output file yacc touch file \`y.tab.c'" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing - GNU libit 0.0" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`configure.in'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`configure.in'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`configure.in'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch config.h.in ;; automake) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print \ | sed 's/^\(.*\).am$/touch \1.in/' \ | sh ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." touch y.tab.c ;; makeinfo) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequirements for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 tpconfig-3.1.3.orig/mkinstalldirs0100755001167100001440000000133407211741753015601 0ustar cphusers#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.10 1996/05/03 07:37:52 friedman Exp $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" 1>&2 mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here tpconfig-3.1.3.orig/NEWS0100664001167100001440000000322607435526232013477 0ustar cphusersRelease 3.1.3 2/22/02 - Fixed assertion error that some ALPS users were getting with newer 2.4.x kernels (this has been tested on 2.4.9). Release 3.1.2 4/23/01 - Fixed to work with 2.4 kernel. Added diffs and pc_keyb.c patched files for /usr/src/linux/drivers/char/pc_keyb.c file for 2.4.2 and 2.2.17 kernels (patches from cph@zurich.ai.mit.edu). Release 3.1 11/15/00 Incorporated changes by Chris Hanson (cph@zurich.ai.mit.edu): 1) Added 2.2.17 kernel patch that provide mechanism for access the aux device while another process (e.g., X server) has it open. tpconfig can now be run under X. 2) Implemented --sleep option for Synaptics to allow reading and and writing sleep mode on touchpads that support it. 3) rewrite of synaptics.c to clean it up, use symbolic constants, increase abstraction level etc. Release 3.0 9/25/00: Added limited support for the ALPS Glidepad/Stickpointer. Only features enabled are: --tapmode=0 (off) or --tapmode=1 (on) --reset --version -- info (will reset tap mode to 'on' even if you shut it off on a separate run). Release 2.2 2/16/99: Modified by Bruce Kall Modification of 2.0 release to work with the newer 2.2.x kernels. This version will now also time out gracefully if being run on top of gpm and/or X. Release 2.0 7/8/98: Modified by Bruce Kall This is the first release for Synaptics Firmware > 3.2 This release does not support port sharing of the PS/2 port, nor does it have an X windows control panel Release 0.0.2: This is the first public release of the synaptics package. Missing features: mouse port sharing utility; X windows control panel. tpconfig-3.1.3.orig/RCS.LOG0100664001167100001440000001754107435525644014005 0ustar cphusers *************************************************************** CHECKED-IN =====> tpconfig.c [Wed Jul 8 15:23:37 1998] Initial revision by C. Scott Ananian *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Fri Nov 27 08:20:07 1998] Changed to work with modern Synaptic touchpads which contain newer firmware (that have a single mode byte). Also added detection of newer touchpad info ('Super' 'Ultrathin', 'Widepad','Stamppad','Submini','Multiswich'). *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Sat Feb 13 22:30:02 1999] Modified to work with newer 2.2.x kernel. *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Tue Feb 16 17:53:17 1999] Changed check for 2.2.1 kernel in is_touchpad(). *************************************************************** *************************************************************** CHECKED-IN =====> synaptics.c [Thu Sep 28 08:37:47 2000] Initial revision *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Thu Sep 28 08:38:18 2000] Exatracted synaptics code into synaptics.c. Added support for ALPS Glidepad/Stickpointer *************************************************************** *************************************************************** CHECKED-IN =====> utils.c [Thu Sep 28 08:44:30 2000] Initial revision *************************************************************** *************************************************************** CHECKED-IN =====> ALPS.c [Thu Sep 28 08:44:51 2000] Initial revision *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.h [Thu Sep 28 13:51:01 2000] Initial revision *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Fri Sep 29 15:17:50 2000] Changed ALPS_GLIDEPOINT to ALPS_GLIDEPAD. *************************************************************** *************************************************************** CHECKED-IN =====> ALPS.c [Fri Sep 29 15:18:24 2000] Added in code for ALPS_GLIDEPAD (single pad, no stick). *************************************************************** *************************************************************** CHECKED-IN =====> utils.c [Mon Oct 23 11:28:01 2000] Removed extraneuos code. *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Mon Oct 23 11:28:20 2000] Fixed tcflush call. *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Tue Oct 31 15:19:49 2000] Add support for Linux kernel patch to grab the mouse device. *************************************************************** *************************************************************** CHECKED-IN =====> utils.c [Tue Oct 31 15:20:04 2000] Add convenient byte-level I/O. *************************************************************** *************************************************************** CHECKED-IN =====> ALPS.c [Tue Oct 31 17:43:12 2000] ACK now AUX_ACK. *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Tue Oct 31 18:03:22 2000] Move copyright into --help screen. Move variable declarations from .h file to .c file. *************************************************************** *************************************************************** CHECKED-IN =====> utils.c [Tue Oct 31 18:04:24 2000] Simplify byte-level I/O. Fix alignment bug in copyright output. *************************************************************** *************************************************************** CHECKED-IN =====> synaptics.c [Tue Oct 31 18:07:49 2000] Extern declarations for utilities are now in .h file. *************************************************************** *************************************************************** CHECKED-IN =====> synaptics.c [Tue Oct 31 18:17:40 2000] Fix error in usage message. Add comments back to option switch. *************************************************************** *************************************************************** CHECKED-IN =====> synaptics.c [Tue Oct 31 18:29:00 2000] Fix bug: was calling show_tap_mode in two places that should have been calling show_packet_mode. Fix bug: disallow -m for single_mode_byte pads. Adjust usage message to show options appropriate for this pad. *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Tue Oct 31 18:38:12 2000] Implement --sleep option to control sleep mode. *************************************************************** *************************************************************** CHECKED-IN =====> synaptics.c [Tue Oct 31 18:38:15 2000] Implement --sleep option to control sleep mode. *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Tue Oct 31 18:57:53 2000] Use symbolic value for DEBUG_LEVEL. *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Tue Oct 31 19:29:45 2000] Unpatched kernel signals ENOTTY for ioctl. *************************************************************** *************************************************************** CHECKED-IN =====> utils.c [Wed Nov 15 09:30:00 2000] Changed last modified message *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Wed Nov 15 09:37:59 2000] Added back in copyright call(). *************************************************************** *************************************************************** CHECKED-IN =====> utils.c [Wed Nov 15 09:41:49 2000] Added to time out message about kernel patch. *************************************************************** *************************************************************** CHECKED-IN =====> utils.c [Mon Apr 23 15:37:31 2001] Changed version string. *************************************************************** *************************************************************** CHECKED-IN =====> synaptics.c [Mon Apr 23 15:38:01 2001] Chanegd if(b1=AUX_ACK) to while(b1=AUX_ACK) to get around kernel ack problem. *************************************************************** *************************************************************** CHECKED-IN =====> synaptics.c [Fri Feb 22 14:31:42 2002] Added for Mode 4 and Mode 4 options .. -M *************************************************************** *************************************************************** CHECKED-IN =====> tpconfig.c [Fri Feb 22 14:33:18 2002] Aded for Mode 3 and Mode 4 options. *************************************************************** *************************************************************** CHECKED-IN =====> utils.c [Fri Feb 22 14:35:48 2002] Changed version number in message *************************************************************** tpconfig-3.1.3.orig/README0100664001167100001440000000242307211741753013655 0ustar cphusersSynaptics tpconfig is a package to drive support for the Synaptics TouchPad and ALPS Glidepad/Stickpointer under various flavors of UNIX, although Linux is currently the primary target. Linux does not like to share the PS/2 port. Currently you must kill gpm before invoking tpconfig. For the same reason, tpconfig will not currently run under X. Suggested usage is to invoke tpconfig with your desired options immediately before launching gpm in your startup sequence. e.g., tpconfig --tapmode=0 The file 'touchpad' can be placed in /etc/rc.d/init.d (or whereever your system startup scripts are stored) and then linking to it in the correct directory for a particular run level. TO DEBUG PROBLEMS: a) bring up your system in single user mode. b) run tpconfig manually (without gpm and X running). If it still does not work, set DEBUG_LEVEL = DEBUG_HIGH and pipe the output into a file to send to me (kall@compass.com). Read the file COPYING to learn the terms under which this software is distributed. Read INSTALL for installation instructions. Mail suggestions and bug reports for this package to kall@compass.com. Please include the package version number, which you can get by running "tpconfig --version". Current maintainer is: Bruce Kall: kall@compass.com tpconfig-3.1.3.orig/tpconfig.c0100444001167100001440000002134107435525416014752 0ustar cphusers/************************************************************************ * File name: tpconfig.c * * Written by: C. Scott Ananian modified by Bruce Kall * * Now Supported by: Bruce Kall (kall@compass.com) * * Language: C * * Purpose: This programs configures synaptics touchpads and is compati- * * ble with version 3.2+ firmware supporting a single mode byte. * ************************************************************************/ /*$Log: tpconfig.c,v $ *Revision 2.13 2002/02/22 20:33:11 bruce *Aded for Mode 3 and Mode 4 options. * *Revision 2.12 2000/11/15 15:37:50 bruce *Added back in copyright call(). * *Revision 2.11 2000/11/01 19:56:38 cph *Change call to ioctl AUX_GRAB to handle case where it returns EAGAIN. * *Revision 2.10 2000/10/31 19:29:45 cph *Unpatched kernel signals ENOTTY for ioctl. * *Revision 2.9 2000/10/31 18:57:53 cph *Use symbolic value for DEBUG_LEVEL. * *Revision 2.8 2000/10/31 18:38:12 cph *Implement --sleep option to control sleep mode. * *Revision 2.7 2000/10/31 18:03:22 cph *Move copyright into --help screen. Move variable declarations from .h *file to .c file. * *Revision 2.6 2000/10/31 15:19:49 cph *Add support for Linux kernel patch to grab the mouse device. * *Revision 2.5 2000/10/23 16:28:14 bruce *Fixed tcflush call. * *Revision 2.4 2000/09/29 20:17:39 bruce *Changed ALPS_GLIDEPOINT to ALPS_GLIDEPAD. * *Revision 2.3 2000/09/28 13:37:57 bruce *Exatracted synaptics code into synaptics.c. Added support for *ALPS Glidepad/Stickpointer * *Revision 2.2 1999/02/16 17:52:56 bruce *Changed check for 2.2.1 kernel in is_Synaptics(). *Added to time-out gracefully. * *Revision 2.1 1999/02/13 22:29:52 bruce *Modified to work with newer 2.2.x kernel. * *Revision 2.0 1998/11/27 14:16:50 bruce *Changed to work with modern Synaptic touchpads which contain *newer firmware (that have a single mode byte). Also added *detection of newer touchpad info ('Super' 'Ultrathin', *'Widepad','Stamppad','Submini','Multiswich'). * *Revision 0.1 1998/07/08 15:23:33 bruce *Initial revision by C. Scott Ananian **/ static char rcsid[]="$Id: tpconfig.c,v 2.13 2002/02/22 20:33:11 bruce Exp $"; /* tpconfig --- Command-line TouchPad configuration utility. * Copyright (C) 1997 C. Scott Ananian * Copyright (c) 1998-1999 Bruce Kalk * * Currently maintained by: Bruce Kall, * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: tpconfig.c,v 2.13 2002/02/22 20:33:11 bruce Exp $ */ #include #include #include #include #include #include #include #include #include #ifdef __linux #include #include #define AUX_GRAB _IO('M', 1) #endif #include "tpconfig.h" extern void synaptics_usage(char *progname); extern void set_firmware_options(int fd, FILE *out); extern void ALPS_usage(char *progname); extern void synaptics_functions(int c,int fd,char **argv); extern void alps_functions(int c,int fd,char **argv); extern int is_ALPS(int fd); extern int is_Synaptics(int fd); int DEBUG_LEVEL; int silent; float firmware_rev; char single_mode_byte; int touchpad_type; /* initialize file description if hasn't already been done. */ void init_fd(int *fd) { /* init_fd*/ int status; if (*fd<0) { *fd = open("/dev/psaux", O_RDWR|O_NDELAY); if (*fd < 0) fatal("Could not open PS/2 Port [/dev/psaux]"); #ifdef __linux /* If AUX_GRAB kernel patch present, use it. */ while (ioctl (*fd, AUX_GRAB, 0) < 0) { if (errno == ENOTTY) break; if (errno != EAGAIN) { perror ("/dev/psaux"); fatal ("Unable to get exclusive access to PS/2 Port."); exit (1); } } #endif tcflush(*fd,TCIOFLUSH); if (!is_Synaptics(*fd)) { status = is_ALPS(*fd); if(status == 0) { fatal("\n\nNo Synaptics or ALPS touchpad device found\n\n"); exit(-1); } else { if(touchpad_type == ALPS_GLIDEPAD) printf ("Found ALPS GlidePad.\n"); else if (touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT) printf ("Found ALPS Dual StickPoint/Glidepad.\n"); else { fprintf (stderr, "Undefined touchpad found[%d]\n", touchpad_type); exit(-1); } } } else { printf ("Found Synaptics Touchpad.\n"); touchpad_type = SYNAPTICS_TOUCHPAD; } } } /* init_fd*/ int main(int argc, char **argv) { /* main */ int fd = -1; int c = 0; int option_index = 0; silent = 0; firmware_rev = 0.0; single_mode_byte = TRUE; DEBUG_LEVEL = DEBUG_NONE; #ifdef DEBUG DEBUG_LEVEL = DEBUG_LOW; #endif copyright(); /* Open file descriptor and determine if we are connected to a touchpad */ init_fd(&fd); if(touchpad_type == SYNAPTICS_TOUCHPAD) set_firmware_options(fd,stdout); if((argc < 2) && (touchpad_type == SYNAPTICS_TOUCHPAD)) synaptics_usage(argv[0]); /* no command line options */ else if((argc < 2) && ((touchpad_type == ALPS_GLIDEPAD) || (touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT))) ALPS_usage(argv[0]); opterr=1; while (1) { static struct option synaptics_long_options[] = { {"help", no_argument, NULL, 'h'}, {"silent", no_argument, NULL, 'q'}, /* -q */ {"quiet", no_argument, NULL, 'q'}, /* -q */ {"info", no_argument, NULL, 'i'}, /* -i */ {"version", no_argument, NULL, 'v'}, /* -v */ {"reset", no_argument, NULL, 'x'}, /* -x */ /* Mode 1 options */ {"zthreshold", optional_argument, NULL, 'z'}, /* -z */ {"threshold", optional_argument, NULL, 'z'}, /* -z */ {"corner", optional_argument, NULL, 'c'}, /* -c */ {"tapmode", optional_argument, NULL, 't'}, /* -t */ {"edgemode", optional_argument, NULL, 'e'}, /* -e */ /* Mode 2 options */ {"absolute", no_argument, NULL, 'A'}, /* similar to -a */ {"relative", no_argument, NULL, 'R'}, /* similar to -a */ {"rate", optional_argument, NULL, 'r'}, /* -r */ {"two-button", no_argument, NULL, '2'}, /* -2 */ {"three-button", no_argument, NULL, '3'}, /* -3 */ {"middle-button", no_argument, NULL, '<'}, /* similar to -m */ {"right-button", no_argument, NULL, '>'}, /* similar to -m */ {"sleep", optional_argument, NULL, 's'}, /* -s */ /* Mode 3 options */ {"right-margin", optional_argument, NULL, '4'}, /* similar to -M */ {"left-margin", optional_argument, NULL, '5'}, /* similar to -M */ /* Mode 4 options */ {"top-margin", optional_argument, NULL, '6'}, /* similar to -M */ {"bottom-margin", optional_argument, NULL, '7'}, /* similar to -M */ {NULL, no_argument, NULL, 0} }; static struct option ALPS_long_options[] = { {"help", no_argument, NULL, 'h'}, {"info", no_argument, NULL, 'i'}, /* -i */ {"reset", no_argument, NULL, 'x'}, /* -x */ {"tapmode", optional_argument, NULL, 't'}, /* -t */ {"version", no_argument, NULL, 'v'}, /* -v */ {NULL, no_argument, NULL, 0} }; if(touchpad_type == SYNAPTICS_TOUCHPAD) c = getopt_long (argc, argv, "qivzx::c::t::e::a::r::23m::s::M", synaptics_long_options, &option_index); else if((touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT) || (touchpad_type == ALPS_GLIDEPAD)) c = getopt_long (argc, argv, "hirtv", ALPS_long_options, &option_index); if (c == -1) break; if(touchpad_type == SYNAPTICS_TOUCHPAD) synaptics_functions(c,fd,argv); else if((touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT) || (touchpad_type == ALPS_GLIDEPAD)) alps_functions(c,fd,argv); } if (optind < argc) { fprintf(stderr, "Extra options: "); while (optind < argc) fprintf(stderr, "%s ", argv[optind++]); fprintf(stderr, "\n"); } if (!(fd<0)) close(fd); return 1; } /* main */ tpconfig-3.1.3.orig/tpconfig.h0100444001167100001440000000634207211741753014757 0ustar cphusers/*********************************************************************** * File name: * * Written by: * * Created: * * Language: C * * Version: 1.0 * * Purpose: * * Callable Module: * * * * Parameters: * * Input: * * * * Input/Output: * * * * Output: * * * * * * * ***********************************************************************/ /*$Log: tpconfig.h,v $ *Revision 1.3 2000/10/31 18:03:46 cph *Move variable declarations from .h file to .c file. Add exports for utilities. * *Revision 1.2 2000/10/31 15:20:54 cph *Define PS/2 mouse commands. Add support for Linux kernel patch. Put *newline at end of fatal error message. * *Revision 1.1 2000/09/28 18:50:57 bruce *Initial revision **/ /* $Header: /usr/local/src/tpconfig-3.0.1/RCS/tpconfig.h,v 1.3 2000/10/31 18:03:46 cph Exp $ */ #define DEBUG_HIGH 3 #define DEBUG_MEDIUM 2 #define DEBUG_LOW 1 #define DEBUG_NONE 0 #define TRUE 1 #define FALSE 0 #define ERROR 1 #define NO_ERROR 0 #ifdef __linux /* Define this if you've patched your kernel. */ #define PATCHED_LINUX_KERNEL #endif /* Standard PS/2 mouse commands */ #define AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */ #define AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */ #define AUX_SET_RES 0xE8 /* Set resolution */ #define AUX_GET_STATUS 0xE9 /* Get scaling factor */ #define AUX_SET_STREAM 0xEA /* Set stream mode */ #define AUX_SET_SAMPLE 0xF3 /* Set sample rate */ #define AUX_ENABLE_DEV 0xF4 /* Enable aux device */ #define AUX_DISABLE_DEV 0xF5 /* Disable aux device */ #define AUX_ACK 0xFA /* Command byte ACK. */ #define AUX_RESET 0xFF /* Reset aux device */ #define AUX_RESET_ACK1 0xAA #define AUX_RESET_ACK2 0x00 #define SYNAPTICS_TOUCHPAD 1 #define ALPS_GLIDEPAD 2 #define ALPS_STICKPOINTER_AND_GLIDEPOINT 3 #define fatal(string) \ { fprintf(stderr, "fatal: %s\n", string); exit(1); } /* Prototypes for PS/2 utility functions */ typedef unsigned char byte; extern int DEBUG_LEVEL; extern int silent; extern float firmware_rev; extern char single_mode_byte; extern int touchpad_type; extern void version_info (void); extern void copyright (void); extern void putbyte (int fd, byte b); extern byte getbyte (int fd); extern void getbyte_expected (int fd, byte expected, const char * what); tpconfig-3.1.3.orig/utils.c0100444001167100001440000001613007435525644014304 0ustar cphusers/*********************************************************************** * File name: util.c * * Written by: Bruce Kall * * Created: 2/2000 (portions extracted from tpconfig.c) * * Language: C * * Version: 1.0 * * Purpose: Utility functions for manipulating touchpads. * * * ***********************************************************************/ /* Copyright (C) 1997 C. Scott Ananian * Copyright (c) 1998-2001 Bruce Kalk * * Currently maintained by: Bruce Kall, * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: utils.c,v 1.9 2002/02/22 20:35:42 bruce Exp $ */ /*$Log: utils.c,v $ *Revision 1.9 2002/02/22 20:35:42 bruce *Changed version number in message * *Revision 1.8 2001/04/23 20:37:25 bruce *Changed version string. * *Revision 1.7 2000/11/15 15:41:34 bruce *Added to time out message about kernel patch. * *Revision 1.6 2000/11/15 15:29:53 bruce *Changed last modified message * *Revision 1.5 2000/10/31 18:57:29 cph *Change timeout logic to use gettimeofday rather than deprecated ftime. *Simplify debugging messages to make high-volume dump easier to scan. * *Revision 1.4 2000/10/31 18:04:24 cph *Simplify byte-level I/O. Fix alignment bug in copyright output. * *Revision 1.3 2000/10/31 15:20:04 cph *Add convenient byte-level I/O. * *Revision 1.2 2000/10/23 16:27:53 bruce *Removed extraneuos code. * *Revision 1.1 2000/09/28 13:44:18 bruce *Initial revision **/ static char rcsid[]="$Header: /home/bruce/linux-stuff/tpconfig/tpconfig-3.1.3/RCS/utils.c,v 1.9 2002/02/22 20:35:42 bruce Exp $"; #include #include #include #include #include #include #include #include #include #include "tpconfig.h" #define TRUE 1 #define FALSE 0 #define TIMEOUT 3.0 /* wait for up to 3 seconds for a reply*/ /* General Rourines for PS2 port */ int ps2_write(int fd,unsigned char *buffer,int num_bytes) { /* ps2_write */ int bytes_written; struct timeval start; struct timeval now; int at; int left; int i; if (DEBUG_LEVEL == DEBUG_HIGH) printf ("PS2_write: %d bytes\n", num_bytes); /* Use the temporary buffer to store the data as it arrives */ gettimeofday(&start, 0); at = 0; left = num_bytes; if (DEBUG_LEVEL == DEBUG_HIGH) { printf ("PS2_write:"); for (i = 0; i < num_bytes; i++) printf(" %#2x", *(buffer + i)); printf("\n"); } do { bytes_written = write(fd,(buffer + at),left); if(bytes_written > 0) { left = left - bytes_written; at = at + bytes_written; } gettimeofday(&now, 0); if ((((((double) now.tv_sec) * 1000000.0 + ((double) now.tv_usec)) - (((double) start.tv_sec) * 1000000.0 + ((double) start.tv_usec))) / 1000000.0) > TIMEOUT) { printf ("\nTimed out waiting to write to device.\n"); exit (-1); } } while(left > 0); if (DEBUG_LEVEL == DEBUG_HIGH) printf ("PS2_write: done\n"); return(at); } /* ps2_write */ int ps2_read(int fd,unsigned char *buffer,int num_bytes) { /* ps2_read */ int bytes_read; struct timeval start; struct timeval now; int at; int left; int i; if (DEBUG_LEVEL == DEBUG_HIGH) printf ("PS2_read: %d bytes\n", num_bytes); /* Use the temporary buffer to store the data as it arrives */ gettimeofday(&start, 0); at = 0; left = num_bytes; do { bytes_read = read(fd,(buffer + at),left); if(bytes_read > 0) { left = left - bytes_read; at = at + bytes_read; } gettimeofday(&now, 0); if ((((((double) now.tv_sec) * 1000000.0 + ((double) now.tv_usec)) - (((double) start.tv_sec) * 1000000.0 + ((double) start.tv_usec))) / 1000000.0) > TIMEOUT) { printf("\nTimed out waiting to read from device (is pc_keyb.c kernel patch installed?)\n"); exit(-1); } } while(left > 0); if (DEBUG_LEVEL == DEBUG_HIGH) { printf("PS2_read:"); for (i = 0; i < at; i++) printf (" %#2x", *(buffer + i)); printf ("\n"); printf ("PS2_read: read %d\n", at); } return(at); } /* ps2_read */ void version_info(void) { /* version_info */ printf( "\nSynaptics Touchpad and ALPS GlidePad/Glidepoint configuration tool\n"); printf(" version: " VERSION "\n\n"); } /* version_info */ void copyright(void) { /* copyright */ printf("\n========================================================================\n"); printf("= =\n"); printf("= tpconfig version: %-9s =\n", VERSION); printf("= =\n"); printf("= Synaptics Touchpad and ALPS GlidePad/Stickpointer configuration tool =\n"); printf("= =\n"); printf("= Copyright (C) 1997 C. Scott Ananian =\n"); printf("= Copyright (C) 1998-2001 Bruce Kall =\n"); printf("= Last Modified (Version 3.1.3) by Bruce Kall, 2/22/2002 =\n"); printf("= =\n"); printf("= tpconfig comes with ABSOLUTELY NO WARRANTY. This is free software, =\n"); printf("= and you are welcome to redistribute it under the terms of the GPL. =\n"); printf("= =\n"); printf("========================================================================\n\n"); } /* copyright */ /* write a byte to the ps/2 port, handling ACK */ void putbyte (int fd, byte b) { if (DEBUG_LEVEL > DEBUG_LOW) printf ("putbyte: write %#02x\n", b); ps2_write (fd, &b, 1); getbyte_expected (fd, AUX_ACK, "putbyte"); } /* read a byte from the ps/2 port */ byte getbyte (int fd) { byte b; ps2_read (fd, &b, 1); if (DEBUG_LEVEL > DEBUG_LOW) printf ("ps2_read_byte: read %#02x\n", b); return b; } void getbyte_expected (int fd, byte expected, const char * what) { byte b = getbyte (fd); if (DEBUG_LEVEL && b != expected) printf ("Read %#02x, expected %#02x in %s.\n", b, expected, what); assert (b == expected); } tpconfig-3.1.3.orig/synaptics.c0100444001167100001440000006775407435525256015202 0ustar cphusers/*********************************************************************** * File name: synaptics.c * * Written by: Bruce Kall (extracted from tpconfig.c by C. Scott Ananian* * Language: C * * Version: 1.0 * * Purpose: Routines to manipulate the Synaptics touchpad. * * * * * ***********************************************************************/ /* Copyright (C) 1997 C. Scott Ananian * Copyright (c) 1998-2000 Bruce Kalk * * Currently maintained by: Bruce Kall, * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: synaptics.c,v 1.9 2002/02/22 20:31:30 bruce Exp $ */ /*$Log: synaptics.c,v $ *Revision 1.9 2002/02/22 20:31:30 bruce *Added for Mode 4 and Mode 4 options .. -M * *Revision 1.8 2001/04/23 20:37:38 bruce *Chanegd if(b1=AUX_ACK) to while(b1=AUX_ACK) to get *around kernel ack problem. * *Revision 1.7 2000/10/31 18:39:15 cph *Fix tab problem. * *Revision 1.6 2000/10/31 18:38:15 cph *Implement --sleep option to control sleep mode. * *Revision 1.5 2000/10/31 18:29:00 cph *Fix bug: was calling show_tap_mode in two places that should have been *calling show_packet_mode. *Fix bug: disallow -m for single_mode_byte pads. *Adjust usage message to show options appropriate for this pad. * *Revision 1.4 2000/10/31 18:17:40 cph *Fix error in usage message. Add comments back to option switch. * *Revision 1.3 2000/10/31 18:07:49 cph ** Extern declarations for utilities are now in .h file. * ** Fix typo in usage. * ** Fix bug in send_cmd. * ** Add high-level debugging output. * ** Capture version information in is_Synaptics to eliminate unneeded * additional identify request in set_firmware_options. * *Revision 1.2 2000/10/31 15:18:32 cph *Complete rewrite. Modularized code, added symbolic definitions for *commands and bit layouts. * *Revision 1.1 2000/09/28 13:37:36 bruce *Initial revision **/ static char rcsid[]="$Header: /home/bruce/linux-stuff/tpconfig/tpconfig-3.1.3/RCS/synaptics.c,v 1.9 2002/02/22 20:31:30 bruce Exp $"; #include #include #include #include #include #include #include #include #include #include "tpconfig.h" /* Capability bits */ #define STP_CAP_EXTENDED 0x8000 /* 1 = other cap bits supported */ #define STP_CAP_SLEEP 0x0010 /* 1 = sleep mode */ #define STP_CAP_FOUR_BUTTON 0x0004 /* 1 = four buttons */ #define STP_CAP_MULTI_FINGER 0x0002 /* 1 = multi-finger detection */ #define STP_CAP_PALM_DETECT 0x0001 /* 1 = palm detection */ /* Mode bits */ #define STP_MODE_ABSOLUTE(m) (((m) & 0x80) != 0) #define STP_MODE_RATE(m) (((m) & 0x40) != 0) #define STP_MODE_SLEEP(m) (((m) & 0x08) != 0) #define STP_MODE_GESTURE(m) (((m) & 0x04) == 0) #define STP_MODE_WMODE(m) (((m) & 0x01) != 0) /* STP_MODE_WMODE valid only in absolute mode when STP_CAP_EXTENDED is set. */ #define STP_SET_MODE_ABSOLUTE(m, a) (((m) &~ 0x80) | ((a) << 7)) #define STP_SET_MODE_RATE(m, a) (((m) &~ 0x40) | ((a) << 6)) #define STP_SET_MODE_SLEEP(m, a) (((m) &~ 0x08) | ((a) << 3)) #define STP_SET_MODE_GESTURE(m, a) (((m) &~ 0x04) | ((!a) << 2)) #define STP_SET_MODE_WMODE(m, a) (((m) &~ 0x01) | (a)) /* Old-style mode bits */ #define STP_OMODE_CORNER(m) (((m) & 0x80000000) >> 31) #define STP_OMODE_Z_THRESH(m) (((m) & 0x70000000) >> 28) #define STP_OMODE_TAP_MODE(m) (((m) & 0x0C000000) >> 26) #define STP_OMODE_EDGE_MOTN(m) (((m) & 0x03000000) >> 24) #define STP_OMODE_ABSOLUTE(m) (((m) & 0x00800000) >> 23) #define STP_OMODE_RATE(m) (((m) & 0x00400000) >> 22) #define STP_OMODE_BAUD(m) (((m) & 0x00080000) >> 19) #define STP_OMODE_3_BUTTON(m) (((m) & 0x00040000) >> 18) #define STP_OMODE_MIDDLE(m) (((m) & 0x00020000) >> 17) #define STP_OMODE_HOP(m) (((m) & 0x00010000) >> 16) #define STP_OMODE_RIGHT_MGN(m) (((m) & 0x0000F000) >> 12) #define STP_OMODE_LEFT_MGN(m) (((m) & 0x00000F00) >> 8) #define STP_OMODE_TOP_MGN(m) (((m) & 0x000000F0) >> 4) #define STP_OMODE_BOTTOM_MGN(m) ((m) & 0x0000000F) #define STP_SET_OMODE_CORNER(m, a) (((m) &~ 0x80000000) | ((a) << 31)) #define STP_SET_OMODE_Z_THRESH(m, a) (((m) &~ 0x70000000) | ((a) << 28)) #define STP_SET_OMODE_TAP_MODE(m, a) (((m) &~ 0x0C000000) | ((a) << 26)) #define STP_SET_OMODE_EDGE_MOTN(m, a) (((m) &~ 0x03000000) | ((a) << 24)) #define STP_SET_OMODE_ABSOLUTE(m, a) (((m) &~ 0x00800000) | ((a) << 23)) #define STP_SET_OMODE_RATE(m, a) (((m) &~ 0x00400000) | ((a) << 22)) #define STP_SET_OMODE_BAUD(m, a) (((m) &~ 0x00080000) | ((a) << 19)) #define STP_SET_OMODE_3_BUTTON(m, a) (((m) &~ 0x00040000) | ((a) << 18)) #define STP_SET_OMODE_MIDDLE(m, a) (((m) &~ 0x00020000) | ((a) << 17)) #define STP_SET_OMODE_HOP(m, a) (((m) &~ 0x00010000) | ((a) << 16)) #define STP_SET_OMODE_RIGHT_MGN(m, a) (((m) &~ 0x0000F000) | ((a) << 12)) #define STP_SET_OMODE_LEFT_MGN(m, a) (((m) &~ 0x00000F00) | ((a) << 8)) #define STP_SET_OMODE_TOP_MGN(m, a) (((m) &~ 0x000000F0) | ((a) << 4)) #define STP_SET_OMODE_BOTTOM_MGN(m, a) (((m) &~ 0x0000000F) | (a)) /* Model ID bits */ #define STP_INFO_ROT180(id) (((id) & 0x800000) >> 23) #define STP_INFO_PORTRAIT(id) (((id) & 0x400000) >> 22) #define STP_INFO_SENSOR(id) (((id) & 0x3F0000) >> 16) #define STP_INFO_HARDWARE(id) (((id) & 0x00FE00) >> 9) #define STP_INFO_NEW_ABS(id) (((id) & 0x000080) >> 7) #define STP_INFO_CAP_PEN(id) (((id) & 0x000040) >> 6) #define STP_INFO_SIMPLE_CMD(id) (((id) & 0x000020) >> 5) #define STP_INFO_GEOMETRY(id) ((id) & 0x00000F) /* Sensor types */ #define STP_SENSOR_UNKNOWN 0 #define STP_SENSOR_STANDARD 1 #define STP_SENSOR_MINI 2 #define STP_SENSOR_SUPER 3 #define STP_SENSOR_FLEXIBLE 7 #define STP_SENSOR_ULTRA_THIN 8 #define STP_SENSOR_WIDE_MODULE 9 #define STP_SENSOR_STAMP_MODULE 11 #define STP_SENSOR_SUBMINI 12 #define STP_SENSOR_MULTISWITCH 13 #define STP_SENSOR_ADV_TECH 15 #define STP_SENSOR_ULTRA_THIN_R 16 /* Geometry types */ #define STP_GEOMETRY_UNKNOWN 0 #define STP_GEOMETRY_STANDARD 1 #define STP_GEOMETRY_OVAL 2 /* Synaptics special queries */ #define STP_QRY_IDENTIFY 0x00 #define STP_QRY_READ_MODES 0x01 #define STP_QRY_READ_CAPS 0x02 #define STP_QRY_READ_MODEL_ID 0x03 #define STP_QRY_READ_SN_PREFIX 0x06 #define STP_QRY_READ_SN_SUFFIX 0x07 #define STP_QRY_READ_RES 0x08 static unsigned int fw_version_major; static unsigned int fw_version_minor; static unsigned int fw_version; static unsigned int model_id; /* Firmware prior to version 3.2 has four mode bytes */ #define QUAD_MODE_BYTE 0x0302 void synaptics_usage (char *progname) { copyright (); printf ("Usage: %s [OPTION]...\n", progname); printf ("Configure a Synaptics TouchPad.\n" "\n" " -i, --info display current TouchPad configuration\n" " -x, --reset perform a software reset on the TouchPad\n" " -q, --quiet, --silent suppress verbose output\n" "\n" " -a display absolute/relative mode\n" " --absolute, --relative set absolute/relative mode\n" " -r, --rate=[0,1] display/set reporting rate\n" " 0 = normal, 1 = high\n"); if (single_mode_byte) printf (" -t, --tapmode=[0-1] display/set tapping mode:\n" " 0 = no tap gestures\n" " 1 = tap and drag\n" " -s, --sleep=[0-1] display/set sleep mode:\n" " 0 = disable, 1 = enable\n"); else { printf (" -t, --tapmode=[0-3] display/set tapping mode:\n" " 0 = no tap gestures\n" " 1 = tap-to-click only\n" " 2 = tap and non-locking drag\n" " 3 = tap and locking drag\n" " -2, --two-button set two-button mode\n" " -3, --three-button set three-button mode\n" " -c, --corner=[0-1] display/enable corner taps:\n" " 0 = disable, 1 = enable\n" " -e, --edgemode=[0,1,3] display/set edge motion:\n" " 0 = never\n" " 1 = always\n" " 3 = only during drag\n" " -m display which button corner taps simulate\n" " --middle-button make corner taps simulate middle button\n" " --right-button make corner taps simulate right button\n" " -z display z threshold setting\n" " --zthreshold=[0-7] set z threshold (tap sensitivity; 0=light)\n" " --threshold=[0-7] same as --zthreshold\n"); if (fw_version < QUAD_MODE_BYTE) { printf (" -M display edge margins\n" " --right-margin=[0-15] set right edge margin (0=narrow)\n" " --left-margin=[0-15] set left edge margin (0=narrow)\n" " --top-margin=[0-15] set top edge margin (0=narrow)\n" " --bottom-margin=[0-15] set bottom edge margin (0=narrow)\n"); } } printf ("\n" " --help display this help and exit\n" " --version output version information\n" "\n" "Report bugs to \n"); exit(1); } /******************** Synaptics Specific Functions ****************************/ /* use the Synaptics extended ps/2 syntax to write a special command byte */ static void send_cmd (int fd, byte cmd) { putbyte (fd, AUX_SET_SCALE11); putbyte (fd, AUX_SET_RES); putbyte (fd, (cmd & 0xC0) >> 6); putbyte (fd, AUX_SET_RES); putbyte (fd, (cmd & 0x30) >> 4); putbyte (fd, AUX_SET_RES); putbyte (fd, (cmd & 0x0C) >> 2); putbyte (fd, AUX_SET_RES); putbyte (fd, cmd & 0x03); } static void status_rqst (int fd, byte cmd, byte *byte1, byte *byte2, byte *byte3) { send_cmd (fd, cmd); putbyte (fd, AUX_GET_STATUS); *byte1 = getbyte (fd); *byte2 = getbyte (fd); *byte3 = getbyte (fd); if (DEBUG_LEVEL) fprintf (stderr, "[query %#02x => %#02x %#02x %#02x]\n", cmd, *byte1, *byte2, *byte3); } static void set_modes (int fd, unsigned int modes) { if (DEBUG_LEVEL) fprintf (stderr, "[set modes: %#02x]\n", modes); if (single_mode_byte) { send_cmd (fd, modes); putbyte (fd, AUX_SET_SAMPLE); putbyte (fd, 20); } else { send_cmd (fd, (modes & 0xFF000000) >> 24); putbyte (fd, AUX_SET_SAMPLE); putbyte (fd, 10); send_cmd (fd, (modes & 0x00FF0000) >> 16); putbyte (fd, AUX_SET_SAMPLE); putbyte (fd, 20); if (fw_version < QUAD_MODE_BYTE) { send_cmd (fd, (modes & 0x0000FF00) >> 8); putbyte (fd, AUX_SET_SAMPLE); putbyte (fd, 40); send_cmd (fd, (modes & 0x000000FF)); putbyte (fd, AUX_SET_SAMPLE); putbyte (fd, 60); } } } static void query_identify (int fd, unsigned int *version_major, unsigned int *version_minor, unsigned int *model_code) { byte b1, b2, b3; status_rqst (fd, STP_QRY_IDENTIFY, &b1, &b2, &b3); assert (b2 == 0x47); if (version_major) (*version_major) = (b3 & 0x0F); if (version_minor) (*version_minor) = b1; if (model_code) (*model_code) = ((b3 & 0xF0) >> 4); } static unsigned int query_modes (int fd) { byte b1, b2, b3; byte b4, b5, b6; status_rqst (fd, STP_QRY_READ_MODES, &b1, &b2, &b3); assert (b2 == 0x47); if (single_mode_byte) { assert (b1 == 0x3B); return b3; } else { /* Firmware prior to version 3.2 has four mode bytes */ if (fw_version < QUAD_MODE_BYTE) { status_rqst (fd, STP_QRY_READ_CAPS, &b4, &b5, &b6); assert (b5 == 0x47); return ((unsigned int) b1 << 24) | ((unsigned int) b3 << 16) | ((unsigned int) b4 << 8) | (unsigned int) b6; } return ((unsigned int) b1 << 24) | ((unsigned int) b3 << 16); } } static unsigned int query_caps (int fd) { byte b1, b2, b3; status_rqst (fd, STP_QRY_READ_CAPS, &b1, &b2, &b3); assert (b2 == 0x47); return ((unsigned int) b1 << 8) | (unsigned int) b3; } static unsigned int query_model_id (int fd) { byte b1, b2, b3; unsigned int id; status_rqst (fd, STP_QRY_READ_MODEL_ID, &b1, &b2, &b3); id = ((b2 & 1) ? 0x000001 : (((unsigned int) b1 << 16) | ((unsigned int) b2 << 8) | (unsigned int) b3)); single_mode_byte = STP_INFO_SIMPLE_CMD (id); return id; } static void query_serial_number (int fd, unsigned int *sn_high, unsigned int *sn_low) { byte b1, b2, b3, b4, b5, b6; status_rqst (fd, STP_QRY_READ_SN_PREFIX, &b1, &b2, &b3); status_rqst (fd, STP_QRY_READ_SN_SUFFIX, &b4, &b5, &b6); (*sn_high) = (b2 & 0xF0) >> 4; (*sn_low) = (((unsigned int) b1 << 24) | ((unsigned int) b4 << 16) | ((unsigned int) b5 << 8) | (unsigned int) b6); } static void query_resolutions (int fd, unsigned int *xres, unsigned int *yres) { byte b1, b2, b3; status_rqst (fd, STP_QRY_READ_RES, &b1, &b2, &b3); assert ((b2 & 0x80) != 0); (*xres) = b1; (*yres) = b3; } /* initialize and determine whether this is a synaptics touchpad */ int is_Synaptics (int fd) { byte b1, b2, b3; int retval; status_rqst (fd, STP_QRY_IDENTIFY, &b1, &b2, &b3); #if defined(__linux) && !defined(PATCHED_LINUX_KERNEL) while (b1 == AUX_ACK) { /* 2.2.x kernel fix an extra ack preceeded the status */ b1 = b2; b2 = b3; b3 = getbyte (fd); } #endif retval = (b2 == 0x47); if (retval) { fw_version_major = (b3 & 0x0F); fw_version_minor = b1; fw_version = (fw_version_major << 8) | fw_version_minor; } return retval; } void reset_synaptics (int fd) { fprintf (stderr,"Performing software reset on TouchPad.\n"); putbyte (fd, AUX_RESET); getbyte_expected (fd, AUX_RESET_ACK1, "software reset ACK 1"); getbyte_expected (fd, AUX_RESET_ACK2, "software reset ACK 2"); fprintf (stderr, "Software reset of TouchPad complete.\n"); } void set_firmware_options (int fd, FILE *out) { model_id = query_model_id (fd); firmware_rev = ((float) fw_version_major) + ((float) fw_version_minor / 10.0); fprintf (out, "Firmware: %d.%d (%s-byte mode).\n", fw_version_major, fw_version_minor, single_mode_byte ? "single" : "multiple"); } static void show_packet_mode (unsigned int modes, FILE *info) { if (single_mode_byte) fprintf (info, "Packets: %s, %d packets per second.\n", (STP_MODE_ABSOLUTE (modes) ? (STP_INFO_NEW_ABS (model_id) ? "absolute (new style)" : "absolute (old style)") : "relative"), STP_MODE_RATE (modes) ? 80 : 40); else fprintf (info, "Packets: %s, %d packets per second.\n", STP_OMODE_ABSOLUTE (modes) ? "absolute" : "relative", STP_OMODE_RATE (modes) ? 80 : 40); } static void show_sleep_mode (unsigned int modes, FILE *info) { fprintf (info, "Sleep mode: %s.\n", STP_MODE_SLEEP (modes) ? "on" : "off"); } static void show_tap_mode (unsigned int modes, FILE *info) { if (single_mode_byte) fprintf (info, "Tap gestures: %s.\n", STP_MODE_GESTURE (modes) ? "enabled" : "disabled"); else { fprintf (info, "Corner taps %s;\t\t", STP_OMODE_CORNER (modes) ? "enabled" : "disabled"); switch (STP_OMODE_TAP_MODE (modes)) { case 0: fprintf (info, "no tap gestures"); break; case 1: fprintf (info, "tap-to-click only"); break; case 2: fprintf (info, "tap and non-locking drag"); break; case 3: fprintf (info, "tap and locking drag"); break; } fprintf (info, ".\n"); } } static void show_edge_motion (unsigned int modes, FILE *info) { fprintf (info, "Edge motion: "); switch (STP_OMODE_EDGE_MOTN (modes)) { case 0: fprintf (info, "none"); break; case 1: fprintf (info, "always"); break; case 2: fprintf (info, "[illegal value 2]"); break; case 3: fprintf (info, "during drag"); break; } fprintf (info, ".\n"); } static void show_z_threshold (unsigned int modes, FILE *info) { fprintf (info, "Z threshold: %d of 7.\n", STP_OMODE_Z_THRESH (modes)); } static void show_button_mode (unsigned int modes, FILE *info) { fprintf (info, "%d button mode; corner tap is %s button click.\n", STP_OMODE_3_BUTTON (modes) ? 3 : 2, STP_OMODE_MIDDLE (modes) ? "middle" : "right"); } static void show_margins (unsigned int modes, FILE *info) { fprintf (info, "Right margin: %ld, Left margin: %ld,\n", STP_OMODE_RIGHT_MGN (modes), STP_OMODE_LEFT_MGN (modes)); fprintf (info, "Top margin: %ld, Bottom margin: %ld.\n", STP_OMODE_TOP_MGN (modes), STP_OMODE_BOTTOM_MGN (modes)); } static int get_argument (unsigned int limit) { int delta; if (optarg[0] == '\0') return -1; else if (optarg[1] == '\0') { delta = optarg[0] - '0'; return (delta >= 0 && delta <= limit ? delta : -1); } else if (optarg[2] == '\0') { delta = (optarg[0] - '0') * 10 + optarg[1] - '0'; return (delta >= 0 && delta <= limit ? delta : -1); } else return -1; } static void set_z_threshold (int fd) { if (single_mode_byte) { fprintf (stderr, "Z threshold not supported on this TouchPad.\n"); return; } if (optarg) { int a = get_argument (7); if (a < 0) { fprintf (stderr, "Invalid Z threshold \"%s\" [use 0-7].\n", optarg); return; } set_modes (fd, STP_SET_OMODE_Z_THRESH (query_modes (fd), a)); } if (!silent) show_z_threshold (query_modes (fd), stderr); } static void set_tap_mode (int fd) { unsigned int limit = single_mode_byte ? 1 : 3; if (optarg) { int a = get_argument (limit); if (a < 0) { fprintf (stderr, "Invalid tap mode \"%s\" [use 0-%d].\n", optarg, limit); return; } if (single_mode_byte) set_modes (fd, STP_SET_MODE_GESTURE (query_modes (fd), a)); else set_modes (fd, STP_SET_OMODE_TAP_MODE (query_modes (fd), a)); } if (!silent) show_tap_mode (query_modes (fd), stderr); } static void set_edge_motion (int fd) { if (single_mode_byte) { fprintf (stderr, "Edge motion not supported on this TouchPad.\n"); return; } if (optarg) { int a = get_argument (3); if (a < 0 || a == 2) { fprintf (stderr, "Invalid edge motion \"%s\" [use 0, 1, 3].\n", optarg); return; } set_modes (fd, STP_SET_OMODE_EDGE_MOTN (query_modes (fd), a)); } if (!silent) show_edge_motion (query_modes (fd), stderr); } static void set_corner_mode (int fd) { if (single_mode_byte) { fprintf (stderr, "Corner mode not supported on this TouchPad.\n"); return; } if (optarg) { int a = get_argument (1); if (a < 0) { fprintf (stderr, "Invalid corner mode \"%s\" [use 0-1].\n", optarg); return; } set_modes (fd, STP_SET_OMODE_CORNER (query_modes (fd), a)); } if (!silent) show_tap_mode (query_modes (fd), stderr); } static void set_packet_mode (int fd, int absolute) { if (single_mode_byte) set_modes (fd, STP_SET_MODE_ABSOLUTE (query_modes (fd), absolute)); else set_modes (fd, STP_SET_OMODE_ABSOLUTE (query_modes (fd), absolute)); if (!silent) show_packet_mode (query_modes (fd), stderr); } static void set_rate (int fd) { if (optarg) { int a = get_argument (1); if (a < 0) { fprintf (stderr, "Invalid rate \"%s\" [use 0-%c].\n", optarg); return; } if (single_mode_byte) set_modes (fd, STP_SET_MODE_RATE (query_modes (fd), a)); else set_modes (fd, STP_SET_OMODE_RATE (query_modes (fd), a)); } if (!silent) show_packet_mode (query_modes (fd), stderr); } static void set_button_mode (int fd, int three) { if (single_mode_byte) { fprintf (stderr, "Button mode not supported on this TouchPad.\n"); return; } set_modes (fd, STP_SET_OMODE_3_BUTTON (query_modes (fd), three)); if (!silent) show_button_mode (query_modes (fd), stderr); } static void set_corner_click (int fd, int middle) { if (single_mode_byte) { fprintf (stderr, "Corner click not supported on this TouchPad.\n"); return; } set_modes (fd, STP_SET_OMODE_MIDDLE (query_modes (fd), middle)); if (!silent) show_button_mode (query_modes (fd), stderr); } static void set_sleep_mode (int fd) { if (!single_mode_byte) { fprintf (stderr, "Sleep mode not supported on this TouchPad.\n"); return; } if (optarg) { int a = get_argument (1); if (a < 0) { fprintf (stderr, "Invalid sleep mode \"%s\" [use 0-1].\n", optarg); return; } set_modes (fd, STP_SET_MODE_SLEEP (query_modes (fd), a)); } if (!silent) show_sleep_mode (query_modes (fd), stderr); } static void set_right_margin (int fd) { if (single_mode_byte || (fw_version >= QUAD_MODE_BYTE)) { fprintf (stderr, "Adjustable margins not supported on this TouchPad.\n"); return; } if (optarg) { int a = get_argument (15); if (a < 0) { fprintf (stderr, "Invalid right margin \"%s\" [use 0-15].\n", optarg); return; } set_modes (fd, STP_SET_OMODE_RIGHT_MGN (query_modes (fd), a)); } if (!silent) show_margins (query_modes (fd), stderr); } static void set_left_margin (int fd) { if (single_mode_byte || (fw_version >= QUAD_MODE_BYTE)) { fprintf (stderr, "Adjustable margins not supported on this TouchPad.\n"); return; } if (optarg) { int a = get_argument (15); if (a < 0) { fprintf (stderr, "Invalid left margin \"%s\" [use 0-15].\n", optarg); return; } set_modes (fd, STP_SET_OMODE_LEFT_MGN (query_modes (fd), a)); } if (!silent) show_margins (query_modes (fd), stderr); } static void set_top_margin (int fd) { if (single_mode_byte || (fw_version >= QUAD_MODE_BYTE)) { fprintf (stderr, "Adjustable margins not supported on this TouchPad.\n"); return; } if (optarg) { int a = get_argument (15); if (a < 0) { fprintf (stderr, "Invalid top margin \"%s\" [use 0-15].\n", optarg); return; } set_modes (fd, STP_SET_OMODE_TOP_MGN (query_modes (fd), a)); } if (!silent) show_margins (query_modes (fd), stderr); } static void set_bottom_margin (int fd) { if (single_mode_byte || (fw_version >= QUAD_MODE_BYTE)) { fprintf (stderr, "Adjustable margins not supported on this TouchPad.\n"); return; } if (optarg) { int a = get_argument (15); if (a < 0) { fprintf (stderr, "Invalid bottom margin \"%s\" [use 0-15].\n", optarg); return; } set_modes (fd, STP_SET_OMODE_BOTTOM_MGN (query_modes (fd), a)); } if (!silent) show_margins (query_modes (fd), stderr); } static void synaptics_info (int fd, FILE *info) { unsigned int modes; fprintf (info, "Sensor type: "); switch (STP_INFO_SENSOR (model_id)) { case STP_SENSOR_STANDARD: fprintf (info, "Standard TouchPad"); break; case STP_SENSOR_MINI: fprintf (info, "Mini module"); break; case STP_SENSOR_SUPER: fprintf (info, "Super module"); break; case STP_SENSOR_FLEXIBLE: fprintf (info, "Flexible pad"); break; case STP_SENSOR_ULTRA_THIN: fprintf (info, "Ultra-thin module"); break; case STP_SENSOR_WIDE_MODULE: fprintf (info, "Wide pad module"); break; case STP_SENSOR_STAMP_MODULE: fprintf (info, "Stamp pad module"); break; case STP_SENSOR_SUBMINI: fprintf (info, "SubMini module"); break; case STP_SENSOR_MULTISWITCH: fprintf (info, "MultiSwitch module"); break; case STP_SENSOR_ADV_TECH: fprintf (info, "Advanced Technology Pad"); break; case STP_SENSOR_ULTRA_THIN_R: fprintf (info, "Ultra-thin module, connector reversed"); break; default: fprintf (info, "unknown (%d)", STP_INFO_SENSOR (model_id)); break; } fprintf (info, ".\n"); fprintf (info, "Geometry: "); switch (STP_INFO_GEOMETRY (model_id)) { case STP_GEOMETRY_STANDARD: fprintf (info, "rectangular"); break; case STP_GEOMETRY_OVAL: fprintf (info, "oval"); break; default: fprintf (info, "unknown (%d)", STP_INFO_GEOMETRY (model_id)); break; } fprintf (info, "/%s/%s.\n", (STP_INFO_PORTRAIT (model_id)) ? "portrait" : "landscape", (STP_INFO_ROT180 (model_id)) ? "down" : "up"); modes = query_modes (fd); show_packet_mode (modes, info); show_tap_mode (modes, info); if (single_mode_byte) show_sleep_mode (modes, info); else { show_edge_motion (modes, info); show_z_threshold (modes, info); show_button_mode (modes, info); if (fw_version < QUAD_MODE_BYTE) show_margins (modes, info); } } void synaptics_functions (int c, int fd, char **argv) { switch (c) { case 'h': /* --help */ synaptics_usage (argv[0]); break; case 'q': /* --quiet */ silent = 1; break; case 'x': /* --reset */ reset_synaptics (fd); break; case 'v': /* --version */ version_info (); break; case 'i': /* --info */ if (!silent) synaptics_info (fd, stderr); break; case 'z': /* --zthreshold */ set_z_threshold (fd); break; case 't': /* --tapmode */ set_tap_mode (fd); break; case 'e': /* --edgemode */ set_edge_motion (fd); break; case 'c': /* --corner */ set_corner_mode (fd); break; case 'A': /* --absolute */ set_packet_mode (fd, 1); break; case 'R': /* --relative */ set_packet_mode (fd, 0); break; case 'a': if (optarg) { int a = get_argument (1); if (a < 0) fprintf (stderr, "Invalid packet mode \"%s\" [use 0-1].\n", optarg); else set_packet_mode (fd, a); } else if (!silent) show_tap_mode (query_modes (fd), stderr); break; case 'r': /* --rate */ set_rate (fd); break; case '2': /* --two-button */ set_button_mode (fd, 0); break; case '3': /* --three-button */ set_button_mode (fd, 1); break; case '<': /* --middle-button */ set_corner_click (fd, 1); break; case '>': /* --right-button */ set_corner_click (fd, 0); break; case 'm': if (single_mode_byte) fprintf (stderr, "Corner click not supported on this TouchPad.\n"); else if (optarg) { int a = get_argument (1); if (a < 0) fprintf (stderr, "Invalid corner-click mode \"%s\" [use 0-1].\n", optarg); else set_corner_click (fd, a); } else if (!silent) show_button_mode (query_modes (fd), stderr); break; case 's': /* --sleep */ set_sleep_mode (fd); break; case 'M': if (single_mode_byte || (fw_version >= QUAD_MODE_BYTE)) fprintf (stderr, "Adjustable margins not supported on this TouchPad.\n"); else if (!silent) /* Firmware prior to version 3.2 has four mode bytes */ show_margins (query_modes (fd), stderr); break; case '4': /* --right-margin */ set_right_margin (fd); break; case '5': /* --left-margin */ set_left_margin (fd); break; case '6': /* --top-margin */ set_top_margin (fd); break; case '7': /* --bottom-margin */ set_bottom_margin (fd); break; case '?': break; default: fprintf (stderr, "Unknown option %c.\n", c); break; } } tpconfig-3.1.3.orig/c0100664001167100001440000000000007435524763013137 0ustar cphuserstpconfig-3.1.3.orig/psaux-2.2.17-combined.diff0100664001167100001440000003155007271106105017265 0ustar cphusers--- linux/drivers/char/pc_keyb.c.orig Wed Dec 13 10:21:43 2000 +++ linux/drivers/char/pc_keyb.c Wed Dec 13 10:38:23 2000 @@ -13,6 +13,15 @@ * Code fixes to handle mouse ACKs properly. * C. Scott Ananian 1999-01-29. * + * More work to handle mouse ACKs properly. (Modified version of + * patch by Julian Bradfield .) + * Chris Hanson 2000-12-11. + * + * Implement exclusive access mechanism for aux device. + * This permits grabbing the mouse away from the X server, + * which is needed by fancy mice that have configurable features. + * Chris Hanson 2000-10-30. + * */ #include @@ -57,7 +66,9 @@ static void kbd_write_command_w(int data); static void kbd_write_output_w(int data); #ifdef CONFIG_PSMOUSE -static void aux_write_ack(int val); +static void __aux_write_ack(int val); +static void aux_kill_fasync(struct fasync_struct *fasync, int s); +static int aux_release_ioctl(struct file *file); #endif spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED; @@ -81,13 +92,30 @@ static struct aux_queue *queue; /* Mouse data buffer. */ static int aux_count = 0; -/* used when we send commands to the mouse that expect an ACK. */ +/* Used when we (as opposed to user programs using the aux device) + send commands to the mouse. */ static unsigned char mouse_reply_expected = 0; +/* Used to make sure we have received an ACK from the byte last + written to the mouse before writing another. */ +static unsigned long mouse_ack_pending = 0; +static struct wait_queue *mouse_ack_wait = NULL; +/* How many jiffies to wait for the mouse to respond to a command with + an ACK. 25 msec is the maximum allowed delay for the hardware to + respond. We round that up to the nearest jiffy. */ +#define MOUSE_ACK_TIMEOUT ((25 * HZ + 999) / 1000) + #define AUX_INTS_OFF (KBD_MODE_KCC | KBD_MODE_DISABLE_MOUSE | KBD_MODE_SYS | KBD_MODE_KBD_INT) #define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT) #define MAX_RETRIES 60 /* some aux operations take long time*/ + +/* Support for exclusive access to the AUX device. */ +static struct file *aux_exclusive = 0; +static struct wait_queue *aux_exclusive_wait = NULL; +static unsigned long aux_last_write = 0; +#define AUX_GRAB _IO('M', 1) +#define AUX_RELEASE _IO('M', 2) #endif /* CONFIG_PSMOUSE */ /* @@ -392,6 +420,13 @@ static inline void handle_mouse_event(unsigned char scancode) { #ifdef CONFIG_PSMOUSE + if (mouse_ack_pending) { + /* It needn't actually be an ack, it could be an echo; + but every byte sent to the mouse results in a byte + back. */ + wake_up_interruptible(&mouse_ack_wait); + mouse_ack_pending = 0; + } if (mouse_reply_expected) { if (scancode == AUX_ACK) { mouse_reply_expected--; @@ -401,14 +436,7 @@ } else if(scancode == AUX_RECONNECT){ queue->head = queue->tail = 0; /* Flush input queue */ - /* ping the mouse :) */ - kb_wait(); - kbd_write_command(KBD_CCMD_WRITE_MOUSE); - kb_wait(); - kbd_write_output(AUX_ENABLE_DEV); - /* we expect an ACK in response. */ - mouse_reply_expected++; - kb_wait(); + __aux_write_ack(AUX_ENABLE_DEV); /* ping the mouse :) */ return; } @@ -421,7 +449,7 @@ if (head != queue->tail) { queue->head = head; if (queue->fasync) - kill_fasync(queue->fasync, SIGIO); + aux_kill_fasync(queue->fasync, SIGIO); wake_up_interruptible(&queue->proc_list); } } @@ -429,6 +457,7 @@ } static unsigned char kbd_exists = 1; +static unsigned char status_mask = 0; /* At probe time we want all */ /* * This reads the keyboard status port, and does the @@ -446,18 +475,21 @@ unsigned char scancode; scancode = kbd_read_input(); -# ifdef CHECK_RECONNECT_SCANCODE - printk(KERN_INFO "-=db=-: kbd_read_input() : scancode == %d\n",scancode); -# endif - if (status & KBD_STAT_MOUSE_OBF) { - handle_mouse_event(scancode); - } else { - kbd_exists = 1; - if (do_acknowledge(scancode)) - handle_scancode(scancode, !(scancode & 0x80)); - mark_bh(KEYBOARD_BH); + + /* Check for errors. Shouldnt ever happen but it does on Compaq + Presario 16[89]. */ + + if(!(status& status_mask)) + { + if (status & KBD_STAT_MOUSE_OBF) { + handle_mouse_event(scancode); + } else { + kbd_exists = 1; + if (do_acknowledge(scancode)) + handle_scancode(scancode, !(scancode & 0x80)); + mark_bh(KEYBOARD_BH); + } } - status = kbd_read_status(); if(!work--) @@ -741,7 +773,8 @@ #if defined CONFIG_PSMOUSE psaux_init(); #endif - + /* Switch keyboard processing to checking error bits */ + status_mask = KBD_STAT_GTO|KBD_STAT_PERR; /* Ok, finally allocate the IRQ, and off we go.. */ kbd_request_irq(keyboard_interrupt); } @@ -790,38 +823,128 @@ return retval; } +static void mouse_ack_timeout(unsigned long data) +{ + wake_up_interruptible(&mouse_ack_wait); +} + /* * Send a byte to the mouse. */ -static void aux_write_dev(int val) +static int aux_write_dev(int val, int dont_block, int handle_ack) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); + /* If we haven't yet received the ACK from the previous write, + we must wait for it. */ + if (mouse_ack_pending) { + unsigned long expires; + struct timer_list timer; + struct wait_queue wait = { current, NULL }; + + if (dont_block) { + spin_unlock_irqrestore(&kbd_controller_lock, flags); + return -EAGAIN; + } + expires = mouse_ack_pending + MOUSE_ACK_TIMEOUT; + if (jiffies >= expires) + goto timed_out; + + add_wait_queue(&mouse_ack_wait, &wait); + init_timer (&timer); + timer.expires = expires; + timer.data = 0; + timer.function = mouse_ack_timeout; + add_timer(&timer); + + do { + current->state = TASK_INTERRUPTIBLE; + spin_unlock_irqrestore(&kbd_controller_lock, flags); + schedule(); + spin_lock_irqsave(&kbd_controller_lock, flags); + } while (mouse_ack_pending + && jiffies < expires + && !signal_pending(current)); + + del_timer(&timer); + remove_wait_queue(&mouse_ack_wait, &wait); + + if (mouse_ack_pending && jiffies >= expires) { + timed_out: + printk(KERN_WARNING "mouse ack timeout\n"); + mouse_ack_pending = 0; + spin_unlock_irqrestore(&kbd_controller_lock, flags); + return -EIO; + } + if (signal_pending(current)) { + spin_unlock_irqrestore(&kbd_controller_lock, flags); + return -ERESTARTSYS; + } + } kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); + mouse_ack_pending = jiffies; + if (handle_ack) + /* We will deal with the ACK ourselves. */ + mouse_reply_expected++; spin_unlock_irqrestore(&kbd_controller_lock, flags); + return 0; } /* * Send a byte to the mouse & handle returned ack */ -static void aux_write_ack(int val) +static void __aux_write_ack(int val) { - unsigned long flags; - - spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); - /* we expect an ACK in response. */ + mouse_ack_pending = jiffies; + /* We will deal with the ACK ourselves. */ mouse_reply_expected++; kb_wait(); +} + +#ifdef INITIALIZE_MOUSE +static void aux_write_ack(int val) +{ + unsigned long flags; + + spin_lock_irqsave(&kbd_controller_lock, flags); + __aux_write_ack(val); spin_unlock_irqrestore(&kbd_controller_lock, flags); } +#endif /* INITIALIZE_MOUSE */ + +static void aux_kill_fasync(struct fasync_struct *fasync, int s) +{ + struct fasync_struct * fp; + struct fasync_struct fa; + + fp = fasync; + /* If someone has grabbed the AUX device, send signal only to + them and not to other processes. We could do this directly + if send_sigio was exported, but since it isn't we must + synthesize a "struct fasync_struct" to pass to + kill_fasync. */ + if (aux_exclusive) { + while (1) { + if (!fp) + return; + if (fp->fa_file == aux_exclusive) + break; + fp = fp->fa_next; + } + fa = (*fp); + fa.fa_next = NULL; + fp = &fa; + } + kill_fasync(fp, s); +} static unsigned char get_from_queue(void) { @@ -860,6 +983,8 @@ static int release_aux(struct inode * inode, struct file * file) { fasync_aux(-1, file, 0); + if (aux_exclusive == file) + aux_release_ioctl(file); if (--aux_count) return 0; kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints */ @@ -886,13 +1011,40 @@ kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable the auxiliary port on controller. */ - aux_write_ack(AUX_ENABLE_DEV); /* Enable aux device */ + aux_write_dev(AUX_ENABLE_DEV, 0, 1); /* Enable aux device */ kbd_write_cmd(AUX_INTS_ON); /* Enable controller ints */ return 0; } /* + * Implement exclusive access mechanism. + */ + +#define AUX_ACCESS_ALLOWED(file) (!aux_exclusive || aux_exclusive == (file)) + +static ssize_t aux_wait_for_access(struct file * file) +{ + struct wait_queue wait = { current, NULL }; + + if (!AUX_ACCESS_ALLOWED(file)) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + add_wait_queue(&aux_exclusive_wait, &wait); + do { + current->state = TASK_INTERRUPTIBLE; + schedule(); + } + while (!AUX_ACCESS_ALLOWED(file) + && !signal_pending(current)); + remove_wait_queue(&aux_exclusive_wait, &wait); + } + if (!AUX_ACCESS_ALLOWED(file)) + return -ERESTARTSYS; + return 0; +} + +/* * Put bytes from input queue to buffer. */ @@ -902,7 +1054,11 @@ struct wait_queue wait = { current, NULL }; ssize_t i = count; unsigned char c; + ssize_t retval; + retval = aux_wait_for_access(file); + if (retval < 0) + return retval; if (queue_empty()) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; @@ -937,23 +1093,32 @@ static ssize_t write_aux(struct file * file, const char * buffer, size_t count, loff_t *ppos) { - ssize_t retval = 0; - + ssize_t retval; + + retval = aux_wait_for_access(file); + if (retval < 0) + return retval; if (count) { ssize_t written = 0; + retval = -EIO; if (count > 32) count = 32; /* Limit to 32 bytes. */ do { char c; + int write_result; get_user(c, buffer++); - aux_write_dev(c); + write_result = aux_write_dev(c, file->f_flags & O_NONBLOCK, 0); + if (write_result) { + retval = write_result; + break; + } written++; } while (--count); - retval = -EIO; if (written) { retval = written; file->f_dentry->d_inode->i_mtime = CURRENT_TIME; + aux_last_write = jiffies; } } @@ -963,18 +1128,82 @@ static unsigned int aux_poll(struct file *file, poll_table * wait) { poll_wait(file, &queue->proc_list, wait); - if (!queue_empty()) + if (AUX_ACCESS_ALLOWED(file) && !queue_empty()) return POLLIN | POLLRDNORM; return 0; } +/* Wait this long after last write to mouse before allowing AUX_GRAB + to happen. This ensures that any outstanding mouse command is + completed. The ACK from the command is supposed to arrive in 25 + msec, and each subsequent status bytes are supposed to arrive + within 20 msec, so a command with 5 status bytes (I don't know any + this long) might take 125 msec. Fudge this up a bit to account for + additional delay introduced by bus locking. */ +#define AUX_GRAB_MIN_TIME (aux_last_write + (((200 * HZ) + 500) / 1000)) +#define AUX_GRAB_ALLOWED (aux_exclusive == 0 && (jiffies >= AUX_GRAB_MIN_TIME)) + +static void aux_grab_timeout(unsigned long data) +{ + wake_up_interruptible(&aux_exclusive_wait); +} + +static int aux_grab_ioctl(struct file *file) +{ + struct wait_queue wait = { current, NULL }; + struct timer_list timer; + + if (aux_exclusive == file) + return -EINVAL; + if (!AUX_GRAB_ALLOWED) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + init_timer (&timer); + timer.expires = AUX_GRAB_MIN_TIME; + timer.data = 0; + timer.function = aux_grab_timeout; + add_wait_queue(&aux_exclusive_wait, &wait); + add_timer(&timer); + do { + current->state = TASK_INTERRUPTIBLE; + schedule(); + } + while (!AUX_GRAB_ALLOWED && !signal_pending(current)); + del_timer(&timer); + remove_wait_queue(&aux_exclusive_wait, &wait); + } + if (!AUX_GRAB_ALLOWED) + return -ERESTARTSYS; + aux_exclusive = file; + return 0; +} + +static int aux_release_ioctl(struct file *file) +{ + if (aux_exclusive != file) + return -ENOENT; + aux_exclusive = 0; + wake_up_interruptible(&aux_exclusive_wait); + return 0; +} + +static int aux_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + switch (cmd) { + case AUX_GRAB: return aux_grab_ioctl(file); + case AUX_RELEASE: return aux_release_ioctl(file); + default: return -EINVAL; + } +} + struct file_operations psaux_fops = { NULL, /* seek */ read_aux, write_aux, NULL, /* readdir */ aux_poll, - NULL, /* ioctl */ + aux_ioctl, NULL, /* mmap */ open_aux, NULL, /* flush */ @@ -1011,6 +1240,8 @@ #endif /* INITIALIZE_MOUSE */ kbd_write_command(KBD_CCMD_MOUSE_DISABLE); /* Disable aux device. */ kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints. */ + + aux_last_write = jiffies; return 0; } tpconfig-3.1.3.orig/psaux-2.2.17.new.combined.diff0100644001167100001440000007624507271106105020066 0ustar cphusers/* * linux/drivers/char/pc_keyb.c * * Separation of the PC low-level part by Geert Uytterhoeven, May 1997 * See keyboard.c for the whole history. * * Major cleanup by Martin Mares, May 1997 * * Combined the keyboard and PS/2 mouse handling into one file, * because they share the same hardware. * Johan Myreen 1998-10-08. * * Code fixes to handle mouse ACKs properly. * C. Scott Ananian 1999-01-29. * * More work to handle mouse ACKs properly. (Modified version of * patch by Julian Bradfield .) * Chris Hanson 2000-12-11. * * Implement exclusive access mechanism for aux device. * This permits grabbing the mouse away from the X server, * which is needed by fancy mice that have configurable features. * Chris Hanson 2000-10-30. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* Some configuration switches are present in the include file... */ #include /* Simple translation table for the SysRq keys */ #ifdef CONFIG_MAGIC_SYSRQ unsigned char pckbd_sysrq_xlate[128] = "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */ "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */ "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */ "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */ "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */ "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */ "\r\000/"; /* 0x60 - 0x6f */ #endif static void kbd_write_command_w(int data); static void kbd_write_output_w(int data); #ifdef CONFIG_PSMOUSE static void __aux_write_ack(int val); static void aux_kill_fasync(struct fasync_struct *fasync, int s); static int aux_release_ioctl(struct file *file); #endif spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED; static unsigned char handle_kbd_event(void); /* used only by send_data - set by keyboard_interrupt */ static volatile unsigned char reply_expected = 0; static volatile unsigned char acknowledge = 0; static volatile unsigned char resend = 0; #if defined CONFIG_PSMOUSE /* * PS/2 Auxiliary Device */ static int __init psaux_init(void); #define AUX_RECONNECT 170 /* #define CHECK_RECONNECT_SCANCODE 1 */ static struct aux_queue *queue; /* Mouse data buffer. */ static int aux_count = 0; /* Used when we (as opposed to user programs using the aux device) send commands to the mouse. */ static unsigned char mouse_reply_expected = 0; /* Used to make sure we have received an ACK from the byte last written to the mouse before writing another. */ static unsigned long mouse_ack_pending = 0; static struct wait_queue *mouse_ack_wait = NULL; /* How many jiffies to wait for the mouse to respond to a command with an ACK. 25 msec is the maximum allowed delay for the hardware to respond. We round that up to the nearest jiffy. */ #define MOUSE_ACK_TIMEOUT ((25 * HZ + 999) / 1000) #define AUX_INTS_OFF (KBD_MODE_KCC | KBD_MODE_DISABLE_MOUSE | KBD_MODE_SYS | KBD_MODE_KBD_INT) #define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT) #define MAX_RETRIES 60 /* some aux operations take long time*/ /* Support for exclusive access to the AUX device. */ static struct file *aux_exclusive = 0; static struct wait_queue *aux_exclusive_wait = NULL; static unsigned long aux_last_write = 0; #define AUX_GRAB _IO('M', 1) #define AUX_RELEASE _IO('M', 2) #endif /* CONFIG_PSMOUSE */ /* * Wait for keyboard controller input buffer to drain. * * Don't use 'jiffies' so that we don't depend on * interrupts.. * * Quote from PS/2 System Reference Manual: * * "Address hex 0060 and address hex 0064 should be written only when * the input-buffer-full bit and output-buffer-full bit in the * Controller Status register are set 0." */ static void kb_wait(void) { unsigned long timeout = KBC_TIMEOUT; do { /* * "handle_kbd_event()" will handle any incoming events * while we wait - keypresses or mouse movement. */ unsigned char status = handle_kbd_event(); if (! (status & KBD_STAT_IBF)) return; mdelay(1); timeout--; } while (timeout); #ifdef KBD_REPORT_TIMEOUTS printk(KERN_WARNING "Keyboard timed out[1]\n"); #endif } /* * Translation of escaped scancodes to keycodes. * This is now user-settable. * The keycodes 1-88,96-111,119 are fairly standard, and * should probably not be changed - changing might confuse X. * X also interprets scancode 0x5d (KEY_Begin). * * For 1-88 keycode equals scancode. */ #define E0_KPENTER 96 #define E0_RCTRL 97 #define E0_KPSLASH 98 #define E0_PRSCR 99 #define E0_RALT 100 #define E0_BREAK 101 /* (control-pause) */ #define E0_HOME 102 #define E0_UP 103 #define E0_PGUP 104 #define E0_LEFT 105 #define E0_RIGHT 106 #define E0_END 107 #define E0_DOWN 108 #define E0_PGDN 109 #define E0_INS 110 #define E0_DEL 111 #define E1_PAUSE 119 /* * The keycodes below are randomly located in 89-95,112-118,120-127. * They could be thrown away (and all occurrences below replaced by 0), * but that would force many users to use the `setkeycodes' utility, where * they needed not before. It does not matter that there are duplicates, as * long as no duplication occurs for any single keyboard. */ #define SC_LIM 89 #define FOCUS_PF1 85 /* actual code! */ #define FOCUS_PF2 89 #define FOCUS_PF3 90 #define FOCUS_PF4 91 #define FOCUS_PF5 92 #define FOCUS_PF6 93 #define FOCUS_PF7 94 #define FOCUS_PF8 95 #define FOCUS_PF9 120 #define FOCUS_PF10 121 #define FOCUS_PF11 122 #define FOCUS_PF12 123 #define JAP_86 124 /* tfj@olivia.ping.dk: * The four keys are located over the numeric keypad, and are * labelled A1-A4. It's an rc930 keyboard, from * Regnecentralen/RC International, Now ICL. * Scancodes: 59, 5a, 5b, 5c. */ #define RGN1 124 #define RGN2 125 #define RGN3 126 #define RGN4 127 static unsigned char high_keys[128 - SC_LIM] = { RGN1, RGN2, RGN3, RGN4, 0, 0, 0, /* 0x59-0x5f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */ 0, 0, 0, 0, 0, FOCUS_PF11, 0, FOCUS_PF12, /* 0x68-0x6f */ 0, 0, 0, FOCUS_PF2, FOCUS_PF9, 0, 0, FOCUS_PF3, /* 0x70-0x77 */ FOCUS_PF4, FOCUS_PF5, FOCUS_PF6, FOCUS_PF7, /* 0x78-0x7b */ FOCUS_PF8, JAP_86, FOCUS_PF10, 0 /* 0x7c-0x7f */ }; /* BTC */ #define E0_MACRO 112 /* LK450 */ #define E0_F13 113 #define E0_F14 114 #define E0_HELP 115 #define E0_DO 116 #define E0_F17 117 #define E0_KPMINPLUS 118 /* * My OmniKey generates e0 4c for the "OMNI" key and the * right alt key does nada. [kkoller@nyx10.cs.du.edu] */ #define E0_OK 124 /* * New microsoft keyboard is rumoured to have * e0 5b (left window button), e0 5c (right window button), * e0 5d (menu button). [or: LBANNER, RBANNER, RMENU] * [or: Windows_L, Windows_R, TaskMan] */ #define E0_MSLW 125 #define E0_MSRW 126 #define E0_MSTM 127 static unsigned char e0_keys[128] = { 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00-0x07 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x08-0x0f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10-0x17 */ 0, 0, 0, 0, E0_KPENTER, E0_RCTRL, 0, 0, /* 0x18-0x1f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20-0x27 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x28-0x2f */ 0, 0, 0, 0, 0, E0_KPSLASH, 0, E0_PRSCR, /* 0x30-0x37 */ E0_RALT, 0, 0, 0, 0, E0_F13, E0_F14, E0_HELP, /* 0x38-0x3f */ E0_DO, E0_F17, 0, 0, 0, 0, E0_BREAK, E0_HOME, /* 0x40-0x47 */ E0_UP, E0_PGUP, 0, E0_LEFT, E0_OK, E0_RIGHT, E0_KPMINPLUS, E0_END,/* 0x48-0x4f */ E0_DOWN, E0_PGDN, E0_INS, E0_DEL, 0, 0, 0, 0, /* 0x50-0x57 */ 0, 0, 0, E0_MSLW, E0_MSRW, E0_MSTM, 0, 0, /* 0x58-0x5f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */ 0, 0, 0, 0, 0, 0, 0, E0_MACRO, /* 0x68-0x6f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77 */ 0, 0, 0, 0, 0, 0, 0, 0 /* 0x78-0x7f */ }; int pckbd_setkeycode(unsigned int scancode, unsigned int keycode) { if (scancode < SC_LIM || scancode > 255 || keycode > 127) return -EINVAL; if (scancode < 128) high_keys[scancode - SC_LIM] = keycode; else e0_keys[scancode - 128] = keycode; return 0; } int pckbd_getkeycode(unsigned int scancode) { return (scancode < SC_LIM || scancode > 255) ? -EINVAL : (scancode < 128) ? high_keys[scancode - SC_LIM] : e0_keys[scancode - 128]; } static int do_acknowledge(unsigned char scancode) { if (reply_expected) { /* Unfortunately, we must recognise these codes only if we know they * are known to be valid (i.e., after sending a command), because there * are some brain-damaged keyboards (yes, FOCUS 9000 again) which have * keys with such codes :( */ if (scancode == KBD_REPLY_ACK) { acknowledge = 1; reply_expected = 0; return 0; } else if (scancode == KBD_REPLY_RESEND) { resend = 1; reply_expected = 0; return 0; } /* Should not happen... */ #if 0 printk(KERN_DEBUG "keyboard reply expected - got %02x\n", scancode); #endif } return 1; } int pckbd_translate(unsigned char scancode, unsigned char *keycode, char raw_mode) { static int prev_scancode = 0; /* special prefix scancodes.. */ if (scancode == 0xe0 || scancode == 0xe1) { prev_scancode = scancode; return 0; } /* 0xFF is sent by a few keyboards, ignore it. 0x00 is error */ if (scancode == 0x00 || scancode == 0xff) { prev_scancode = 0; return 0; } scancode &= 0x7f; if (prev_scancode) { /* * usually it will be 0xe0, but a Pause key generates * e1 1d 45 e1 9d c5 when pressed, and nothing when released */ if (prev_scancode != 0xe0) { if (prev_scancode == 0xe1 && scancode == 0x1d) { prev_scancode = 0x100; return 0; } else if (prev_scancode == 0x100 && scancode == 0x45) { *keycode = E1_PAUSE; prev_scancode = 0; } else { #ifdef KBD_REPORT_UNKN if (!raw_mode) printk(KERN_INFO "keyboard: unknown e1 escape sequence\n"); #endif prev_scancode = 0; return 0; } } else { prev_scancode = 0; /* * The keyboard maintains its own internal caps lock and * num lock statuses. In caps lock mode E0 AA precedes make * code and E0 2A follows break code. In num lock mode, * E0 2A precedes make code and E0 AA follows break code. * We do our own book-keeping, so we will just ignore these. */ /* * For my keyboard there is no caps lock mode, but there are * both Shift-L and Shift-R modes. The former mode generates * E0 2A / E0 AA pairs, the latter E0 B6 / E0 36 pairs. * So, we should also ignore the latter. - aeb@cwi.nl */ if (scancode == 0x2a || scancode == 0x36) return 0; if (e0_keys[scancode]) *keycode = e0_keys[scancode]; else { #ifdef KBD_REPORT_UNKN if (!raw_mode) printk(KERN_INFO "keyboard: unknown scancode e0 %02x\n", scancode); #endif return 0; } } } else if (scancode >= SC_LIM) { /* This happens with the FOCUS 9000 keyboard Its keys PF1..PF12 are reported to generate 55 73 77 78 79 7a 7b 7c 74 7e 6d 6f Moreover, unless repeated, they do not generate key-down events, so we have to zero up_flag below */ /* Also, Japanese 86/106 keyboards are reported to generate 0x73 and 0x7d for \ - and \ | respectively. */ /* Also, some Brazilian keyboard is reported to produce 0x73 and 0x7e for \ ? and KP-dot, respectively. */ *keycode = high_keys[scancode - SC_LIM]; if (!*keycode) { if (!raw_mode) { #ifdef KBD_REPORT_UNKN printk(KERN_INFO "keyboard: unrecognized scancode (%02x)" " - ignored\n", scancode); #endif } return 0; } } else *keycode = scancode; return 1; } char pckbd_unexpected_up(unsigned char keycode) { /* unexpected, but this can happen: maybe this was a key release for a FOCUS 9000 PF key; if we want to see it, we have to clear up_flag */ if (keycode >= SC_LIM || keycode == 85) return 0; else return 0200; } static inline void handle_mouse_event(unsigned char scancode) { #ifdef CONFIG_PSMOUSE if (mouse_ack_pending) { /* It needn't actually be an ack, it could be an echo; but every byte sent to the mouse results in a byte back. */ wake_up_interruptible(&mouse_ack_wait); mouse_ack_pending = 0; } if (mouse_reply_expected) { if (scancode == AUX_ACK) { mouse_reply_expected--; return; } mouse_reply_expected = 0; } else if(scancode == AUX_RECONNECT){ queue->head = queue->tail = 0; /* Flush input queue */ __aux_write_ack(AUX_ENABLE_DEV); /* ping the mouse :) */ return; } add_mouse_randomness(scancode); if (aux_count) { int head = queue->head; queue->buf[head] = scancode; head = (head + 1) & (AUX_BUF_SIZE-1); if (head != queue->tail) { queue->head = head; if (queue->fasync) kill_fasync(queue->fasync, SIGIO, POLL_IN); wake_up_interruptible(&queue->proc_list); } } #endif } static unsigned char kbd_exists = 1; static unsigned char status_mask = 0; /* At probe time we want all */ /* * This reads the keyboard status port, and does the * appropriate action. * * It requires that we hold the keyboard controller * spinlock. */ static unsigned char handle_kbd_event(void) { unsigned char status = kbd_read_status(); unsigned int work = 10000; while (status & KBD_STAT_OBF) { unsigned char scancode; scancode = kbd_read_input(); /* Check for errors. Shouldnt ever happen but it does on Compaq Presario 16[89]. */ if(!(status& status_mask)) { if (status & KBD_STAT_MOUSE_OBF) { handle_mouse_event(scancode); } else { kbd_exists = 1; if (do_acknowledge(scancode)) handle_scancode(scancode, !(scancode & 0x80)); mark_bh(KEYBOARD_BH); } } status = kbd_read_status(); if(!work--) { printk(KERN_ERR "pc_keyb: controller jammed (0x%02X).\n", status); break; } } return status; } static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs) { unsigned long flags; kbd_pt_regs = regs; spin_lock_irqsave(&kbd_controller_lock, flags); handle_kbd_event(); spin_unlock_irqrestore(&kbd_controller_lock, flags); } /* * send_data sends a character to the keyboard and waits * for an acknowledge, possibly retrying if asked to. Returns * the success status. * * Don't use 'jiffies', so that we don't depend on interrupts */ static int send_data(unsigned char data) { int retries = 3; do { unsigned long timeout = KBD_TIMEOUT; acknowledge = 0; /* Set by interrupt routine on receipt of ACK. */ resend = 0; reply_expected = 1; kbd_write_output_w(data); for (;;) { if (acknowledge) return 1; if (resend) break; mdelay(1); if (!--timeout) { #ifdef KBD_REPORT_TIMEOUTS printk(KERN_WARNING "keyboard: Timeout - AT keyboard not present?\n"); #endif return 0; } } } while (retries-- > 0); #ifdef KBD_REPORT_TIMEOUTS printk(KERN_WARNING "keyboard: Too many NACKs -- noisy kbd cable?\n"); #endif return 0; } void pckbd_leds(unsigned char leds) { if (kbd_exists && (!send_data(KBD_CMD_SET_LEDS) || !send_data(leds))) { send_data(KBD_CMD_ENABLE); /* re-enable kbd if any errors */ kbd_exists = 0; } } /* * In case we run on a non-x86 hardware we need to initialize both the * keyboard controller and the keyboard. On a x86, the BIOS will * already have initialized them. * * Some x86 BIOSes do not correctly initialize the keyboard, so the * "kbd-reset" command line options can be given to force a reset. * [Ranger] */ #ifdef __i386__ int kbd_startup_reset __initdata = 0; #else int kbd_startup_reset __initdata = 1; #endif /* for "kbd-reset" cmdline param */ void __init kbd_reset_setup(char *str, int *ints) { kbd_startup_reset = 1; } #define KBD_NO_DATA (-1) /* No data */ #define KBD_BAD_DATA (-2) /* Parity or other error */ static int __init kbd_read_data(void) { int retval = KBD_NO_DATA; unsigned char status; status = kbd_read_status(); if (status & KBD_STAT_OBF) { unsigned char data = kbd_read_input(); retval = data; if (status & (KBD_STAT_GTO | KBD_STAT_PERR)) retval = KBD_BAD_DATA; } return retval; } static void __init kbd_clear_input(void) { int maxread = 100; /* Random number */ do { if (kbd_read_data() == KBD_NO_DATA) break; } while (--maxread); } static int __init kbd_wait_for_input(void) { long timeout = KBD_INIT_TIMEOUT; do { int retval = kbd_read_data(); if (retval >= 0) return retval; mdelay(1); } while (--timeout); return -1; } static void kbd_write_command_w(int data) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); kbd_write_command(data); spin_unlock_irqrestore(&kbd_controller_lock, flags); } static void kbd_write_output_w(int data) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); kbd_write_output(data); spin_unlock_irqrestore(&kbd_controller_lock, flags); } #if defined CONFIG_PSMOUSE static void kbd_write_cmd(int cmd) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); kbd_write_command(KBD_CCMD_WRITE_MODE); kb_wait(); kbd_write_output(cmd); spin_unlock_irqrestore(&kbd_controller_lock, flags); } #endif /* CONFIG_PSMOUSE */ static char * __init initialize_kbd(void) { int status; /* * Test the keyboard interface. * This seems to be the only way to get it going. * If the test is successful a x55 is placed in the input buffer. */ kbd_write_command_w(KBD_CCMD_SELF_TEST); if (kbd_wait_for_input() != 0x55) return "Keyboard failed self test"; /* * Perform a keyboard interface test. This causes the controller * to test the keyboard clock and data lines. The results of the * test are placed in the input buffer. */ kbd_write_command_w(KBD_CCMD_KBD_TEST); if (kbd_wait_for_input() != 0x00) return "Keyboard interface failed self test"; /* * Enable the keyboard by allowing the keyboard clock to run. */ kbd_write_command_w(KBD_CCMD_KBD_ENABLE); /* * Reset keyboard. If the read times out * then the assumption is that no keyboard is * plugged into the machine. * This defaults the keyboard to scan-code set 2. * * Set up to try again if the keyboard asks for RESEND. */ do { kbd_write_output_w(KBD_CMD_RESET); status = kbd_wait_for_input(); if (status == KBD_REPLY_ACK) break; if (status != KBD_REPLY_RESEND) return "Keyboard reset failed, no ACK"; } while (1); if (kbd_wait_for_input() != KBD_REPLY_POR) return "Keyboard reset failed, no POR"; /* * Set keyboard controller mode. During this, the keyboard should be * in the disabled state. * * Set up to try again if the keyboard asks for RESEND. */ do { kbd_write_output_w(KBD_CMD_DISABLE); status = kbd_wait_for_input(); if (status == KBD_REPLY_ACK) break; if (status != KBD_REPLY_RESEND) return "Disable keyboard: no ACK"; } while (1); kbd_write_command_w(KBD_CCMD_WRITE_MODE); kbd_write_output_w(KBD_MODE_KBD_INT | KBD_MODE_SYS | KBD_MODE_DISABLE_MOUSE | KBD_MODE_KCC); /* ibm powerpc portables need this to use scan-code set 1 -- Cort */ kbd_write_command_w(KBD_CCMD_READ_MODE); if (!(kbd_wait_for_input() & KBD_MODE_KCC)) { /* * If the controller does not support conversion, * Set the keyboard to scan-code set 1. */ kbd_write_output_w(0xF0); kbd_wait_for_input(); kbd_write_output_w(0x01); kbd_wait_for_input(); } kbd_write_output_w(KBD_CMD_ENABLE); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Enable keyboard: no ACK"; /* * Finally, set the typematic rate to maximum. */ kbd_write_output_w(KBD_CMD_SET_RATE); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Set rate: no ACK"; kbd_write_output_w(0x00); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Set rate: no ACK"; return NULL; } void __init pckbd_init_hw(void) { kbd_request_region(); /* Flush any pending input. */ kbd_clear_input(); if (kbd_startup_reset) { char *msg = initialize_kbd(); if (msg) printk(KERN_WARNING "initialize_kbd: %s\n", msg); } #if defined CONFIG_PSMOUSE psaux_init(); #endif /* Switch keyboard processing to checking error bits */ status_mask = KBD_STAT_GTO|KBD_STAT_PERR; /* Ok, finally allocate the IRQ, and off we go.. */ kbd_request_irq(keyboard_interrupt); } #if defined CONFIG_PSMOUSE /* * Check if this is a dual port controller. */ static int __init detect_auxiliary_port(void) { unsigned long flags; int loops = 10; int retval = 0; spin_lock_irqsave(&kbd_controller_lock, flags); /* Put the value 0x5A in the output buffer using the "Write * Auxiliary Device Output Buffer" command (0xD3). Poll the * Status Register for a while to see if the value really * turns up in the Data Register. If the KBD_STAT_MOUSE_OBF * bit is also set to 1 in the Status Register, we assume this * controller has an Auxiliary Port (a.k.a. Mouse Port). */ kb_wait(); kbd_write_command(KBD_CCMD_WRITE_AUX_OBUF); kb_wait(); kbd_write_output(0x5a); /* 0x5a is a random dummy value. */ do { unsigned char status = kbd_read_status(); if (status & KBD_STAT_OBF) { (void) kbd_read_input(); if (status & KBD_STAT_MOUSE_OBF) { printk(KERN_INFO "Detected PS/2 Mouse Port.\n"); retval = 1; } break; } mdelay(1); } while (--loops); spin_unlock_irqrestore(&kbd_controller_lock, flags); return retval; } static void mouse_ack_timeout(unsigned long data) { wake_up_interruptible(&mouse_ack_wait); } /* * Send a byte to the mouse. */ static int aux_write_dev(int val, int dont_block, int handle_ack) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); /* If we haven't yet received the ACK from the previous write, we must wait for it. */ if (mouse_ack_pending) { unsigned long expires; struct timer_list timer; struct wait_queue wait = { current, NULL }; if (dont_block) { spin_unlock_irqrestore(&kbd_controller_lock, flags); return -EAGAIN; } expires = mouse_ack_pending + MOUSE_ACK_TIMEOUT; if (jiffies >= expires) goto timed_out; add_wait_queue(&mouse_ack_wait, &wait); init_timer (&timer); timer.expires = expires; timer.data = 0; timer.function = mouse_ack_timeout; add_timer(&timer); do { current->state = TASK_INTERRUPTIBLE; spin_unlock_irqrestore(&kbd_controller_lock, flags); schedule(); spin_lock_irqsave(&kbd_controller_lock, flags); } while (mouse_ack_pending && jiffies < expires && !signal_pending(current)); del_timer(&timer); remove_wait_queue(&mouse_ack_wait, &wait); if (mouse_ack_pending && jiffies >= expires) { timed_out: printk(KERN_WARNING "mouse ack timeout\n"); mouse_ack_pending = 0; spin_unlock_irqrestore(&kbd_controller_lock, flags); return -EIO; } if (signal_pending(current)) { spin_unlock_irqrestore(&kbd_controller_lock, flags); return -ERESTARTSYS; } } kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); mouse_ack_pending = jiffies; if (handle_ack) /* We will deal with the ACK ourselves. */ mouse_reply_expected++; spin_unlock_irqrestore(&kbd_controller_lock, flags); return 0; } /* * Send a byte to the mouse & handle returned ack */ static void __aux_write_ack(int val) { kb_wait(); kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); mouse_ack_pending = jiffies; /* We will deal with the ACK ourselves. */ mouse_reply_expected++; kb_wait(); } #ifdef INITIALIZE_MOUSE static void aux_write_ack(int val) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); __aux_write_ack(val); spin_unlock_irqrestore(&kbd_controller_lock, flags); } #endif /* INITIALIZE_MOUSE */ static void aux_kill_fasync(struct fasync_struct *fasync, int s) { struct fasync_struct * fp; struct fasync_struct fa; fp = fasync; /* If someone has grabbed the AUX device, send signal only to them and not to other processes. We could do this directly if send_sigio was exported, but since it isn't we must synthesize a "struct fasync_struct" to pass to kill_fasync. */ if (aux_exclusive) { while (1) { if (!fp) return; if (fp->fa_file == aux_exclusive) break; fp = fp->fa_next; } fa = (*fp); fa.fa_next = NULL; fp = &fa; } kill_fasync(fp, s); } static unsigned char get_from_queue(void) { unsigned char result; unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); result = queue->buf[queue->tail]; queue->tail = (queue->tail + 1) & (AUX_BUF_SIZE-1); spin_unlock_irqrestore(&kbd_controller_lock, flags); return result; } static inline int queue_empty(void) { return queue->head == queue->tail; } static int fasync_aux(int fd, struct file *filp, int on) { int retval; retval = fasync_helper(fd, filp, on, &queue->fasync); if (retval < 0) return retval; return 0; } /* * Random magic cookie for the aux device */ #define AUX_DEV ((void *)queue) static int release_aux(struct inode * inode, struct file * file) { fasync_aux(-1, file, 0); if (aux_exclusive == file) aux_release_ioctl(file); if (--aux_count) return 0; kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints */ kbd_write_command_w(KBD_CCMD_MOUSE_DISABLE); aux_free_irq(AUX_DEV); return 0; } /* * Install interrupt handler. * Enable auxiliary device. */ static int open_aux(struct inode * inode, struct file * file) { if (aux_count++) { return 0; } queue->head = queue->tail = 0; /* Flush input queue */ if (aux_request_irq(keyboard_interrupt, AUX_DEV)) { aux_count--; return -EBUSY; } kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable the auxiliary port on controller. */ aux_write_dev(AUX_ENABLE_DEV, 0, 1); /* Enable aux device */ kbd_write_cmd(AUX_INTS_ON); /* Enable controller ints */ return 0; } /* * Implement exclusive access mechanism. */ #define AUX_ACCESS_ALLOWED(file) (!aux_exclusive || aux_exclusive == (file)) static ssize_t aux_wait_for_access(struct file * file) { struct wait_queue wait = { current, NULL }; if (!AUX_ACCESS_ALLOWED(file)) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; add_wait_queue(&aux_exclusive_wait, &wait); do { current->state = TASK_INTERRUPTIBLE; schedule(); } while (!AUX_ACCESS_ALLOWED(file) && !signal_pending(current)); remove_wait_queue(&aux_exclusive_wait, &wait); } if (!AUX_ACCESS_ALLOWED(file)) return -ERESTARTSYS; return 0; } /* * Put bytes from input queue to buffer. */ static ssize_t read_aux(struct file * file, char * buffer, size_t count, loff_t *ppos) { struct wait_queue wait = { current, NULL }; ssize_t i = count; unsigned char c; ssize_t retval; retval = aux_wait_for_access(file); if (retval < 0) return retval; if (queue_empty()) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; add_wait_queue(&queue->proc_list, &wait); repeat: current->state = TASK_INTERRUPTIBLE; if (queue_empty() && !signal_pending(current)) { schedule(); goto repeat; } current->state = TASK_RUNNING; remove_wait_queue(&queue->proc_list, &wait); } while (i > 0 && !queue_empty()) { c = get_from_queue(); put_user(c, buffer++); i--; } if (count-i) { file->f_dentry->d_inode->i_atime = CURRENT_TIME; return count-i; } if (signal_pending(current)) return -ERESTARTSYS; return 0; } /* * Write to the aux device. */ static ssize_t write_aux(struct file * file, const char * buffer, size_t count, loff_t *ppos) { ssize_t retval; retval = aux_wait_for_access(file); if (retval < 0) return retval; if (count) { ssize_t written = 0; retval = -EIO; if (count > 32) count = 32; /* Limit to 32 bytes. */ do { char c; int write_result; get_user(c, buffer++); write_result = aux_write_dev(c, file->f_flags & O_NONBLOCK, 0); if (write_result) { retval = write_result; break; } written++; } while (--count); if (written) { retval = written; file->f_dentry->d_inode->i_mtime = CURRENT_TIME; aux_last_write = jiffies; } } return retval; } static unsigned int aux_poll(struct file *file, poll_table * wait) { poll_wait(file, &queue->proc_list, wait); if (AUX_ACCESS_ALLOWED(file) && !queue_empty()) return POLLIN | POLLRDNORM; return 0; } /* Wait this long after last write to mouse before allowing AUX_GRAB to happen. This ensures that any outstanding mouse command is completed. The ACK from the command is supposed to arrive in 25 msec, and each subsequent status bytes are supposed to arrive within 20 msec, so a command with 5 status bytes (I don't know any this long) might take 125 msec. Fudge this up a bit to account for additional delay introduced by bus locking. */ #define AUX_GRAB_MIN_TIME (aux_last_write + (((200 * HZ) + 500) / 1000)) #define AUX_GRAB_ALLOWED (aux_exclusive == 0 && (jiffies >= AUX_GRAB_MIN_TIME)) static void aux_grab_timeout(unsigned long data) { wake_up_interruptible(&aux_exclusive_wait); } static int aux_grab_ioctl(struct file *file) { struct wait_queue wait = { current, NULL }; struct timer_list timer; if (aux_exclusive == file) return -EINVAL; if (!AUX_GRAB_ALLOWED) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; init_timer (&timer); timer.expires = AUX_GRAB_MIN_TIME; timer.data = 0; timer.function = aux_grab_timeout; add_wait_queue(&aux_exclusive_wait, &wait); add_timer(&timer); do { current->state = TASK_INTERRUPTIBLE; schedule(); } while (!AUX_GRAB_ALLOWED && !signal_pending(current)); del_timer(&timer); remove_wait_queue(&aux_exclusive_wait, &wait); } if (!AUX_GRAB_ALLOWED) return -ERESTARTSYS; aux_exclusive = file; return 0; } static int aux_release_ioctl(struct file *file) { if (aux_exclusive != file) return -ENOENT; aux_exclusive = 0; wake_up_interruptible(&aux_exclusive_wait); return 0; } static int aux_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { switch (cmd) { case AUX_GRAB: return aux_grab_ioctl(file); case AUX_RELEASE: return aux_release_ioctl(file); default: return -EINVAL; } } struct file_operations psaux_fops = { NULL, /* seek */ read_aux, write_aux, NULL, /* readdir */ aux_poll, aux_ioctl, NULL, /* mmap */ open_aux, NULL, /* flush */ release_aux, NULL, fasync_aux, }; /* * Initialize driver. */ static struct miscdevice psaux_mouse = { PSMOUSE_MINOR, "psaux", &psaux_fops }; static int __init psaux_init(void) { if (!detect_auxiliary_port()) return -EIO; misc_register(&psaux_mouse); queue = (struct aux_queue *) kmalloc(sizeof(*queue), GFP_KERNEL); memset(queue, 0, sizeof(*queue)); queue->head = queue->tail = 0; queue->proc_list = NULL; #ifdef INITIALIZE_MOUSE kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable Aux. */ aux_write_ack(AUX_SET_SAMPLE); aux_write_ack(100); /* 100 samples/sec */ aux_write_ack(AUX_SET_RES); aux_write_ack(3); /* 8 counts per mm */ aux_write_ack(AUX_SET_SCALE21); /* 2:1 scaling */ #endif /* INITIALIZE_MOUSE */ kbd_write_command(KBD_CCMD_MOUSE_DISABLE); /* Disable aux device. */ kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints. */ aux_last_write = jiffies; return 0; } #endif /* CONFIG_PSMOUSE */ tpconfig-3.1.3.orig/psaux-2.2.18-combined.diff0100664001167100001440000002746707271106105017302 0ustar cphusers--- linux/drivers/char/pc_keyb.c.orig Sat Dec 9 13:49:36 2000 +++ linux/drivers/char/pc_keyb.c Mon Dec 11 13:59:20 2000 @@ -13,6 +13,15 @@ * Code fixes to handle mouse ACKs properly. * C. Scott Ananian 1999-01-29. * + * More work to handle mouse ACKs properly. (Modified version of + * patch by Julian Bradfield .) + * Chris Hanson 2000-12-11. + * + * Implement exclusive access mechanism for aux device. + * This permits grabbing the mouse away from the X server, + * which is needed by fancy mice that have configurable features. + * Chris Hanson 2000-10-30. + * */ #include @@ -57,8 +66,10 @@ static void kbd_write_command_w(int data); static void kbd_write_output_w(int data); #ifdef CONFIG_PSMOUSE -static void aux_write_ack(int val); +static void __aux_write_ack(int val); static int aux_reconnect = 0; +static void aux_kill_fasync(struct fasync_struct *fasync, int s); +static int aux_release_ioctl(struct file *file); #endif spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED; @@ -82,13 +93,30 @@ static struct aux_queue *queue; /* Mouse data buffer. */ static int aux_count = 0; -/* used when we send commands to the mouse that expect an ACK. */ +/* Used when we (as opposed to user programs using the aux device) + send commands to the mouse. */ static unsigned char mouse_reply_expected = 0; +/* Used to make sure we have received an ACK from the byte last + written to the mouse before writing another. */ +static unsigned long mouse_ack_pending = 0; +static struct wait_queue *mouse_ack_wait = NULL; +/* How many jiffies to wait for the mouse to respond to a command with + an ACK. 25 msec is the maximum allowed delay for the hardware to + respond. We round that up to the nearest jiffy. */ +#define MOUSE_ACK_TIMEOUT ((25 * HZ + 999) / 1000) + #define AUX_INTS_OFF (KBD_MODE_KCC | KBD_MODE_DISABLE_MOUSE | KBD_MODE_SYS | KBD_MODE_KBD_INT) #define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT) #define MAX_RETRIES 60 /* some aux operations take long time*/ + +/* Support for exclusive access to the AUX device. */ +static struct file *aux_exclusive = 0; +static struct wait_queue *aux_exclusive_wait = NULL; +static unsigned long aux_last_write = 0; +#define AUX_GRAB _IO('M', 1) +#define AUX_RELEASE _IO('M', 2) #endif /* CONFIG_PSMOUSE */ /* @@ -393,6 +421,13 @@ static inline void handle_mouse_event(unsigned char scancode) { #ifdef CONFIG_PSMOUSE + if (mouse_ack_pending) { + /* It needn't actually be an ack, it could be an echo; + but every byte sent to the mouse results in a byte + back. */ + wake_up_interruptible(&mouse_ack_wait); + mouse_ack_pending = 0; + } if (mouse_reply_expected) { if (scancode == AUX_ACK) { mouse_reply_expected--; @@ -401,18 +436,10 @@ mouse_reply_expected = 0; } - else if(scancode == AUX_RECONNECT && aux_reconnect) - { - queue->head = queue->tail = 0; /* Flush input queue */ - /* ping the mouse :) */ - kb_wait(); - kbd_write_command(KBD_CCMD_WRITE_MOUSE); - kb_wait(); - kbd_write_output(AUX_ENABLE_DEV); - /* we expect an ACK in response. */ - mouse_reply_expected++; - kb_wait(); - return; + else if(scancode == AUX_RECONNECT && aux_reconnect) { + queue->head = queue->tail = 0; /* Flush input queue */ + __aux_write_ack(AUX_ENABLE_DEV); /* ping the mouse :) */ + return; } add_mouse_randomness(scancode); @@ -424,7 +451,7 @@ if (head != queue->tail) { queue->head = head; if (queue->fasync) - kill_fasync(queue->fasync, SIGIO); + aux_kill_fasync(queue->fasync, SIGIO); wake_up_interruptible(&queue->proc_list); } } @@ -804,38 +831,128 @@ return retval; } +static void mouse_ack_timeout(unsigned long data) +{ + wake_up_interruptible(&mouse_ack_wait); +} + /* * Send a byte to the mouse. */ -static void aux_write_dev(int val) +static int aux_write_dev(int val, int dont_block, int handle_ack) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); + /* If we haven't yet received the ACK from the previous write, + we must wait for it. */ + if (mouse_ack_pending) { + unsigned long expires; + struct timer_list timer; + struct wait_queue wait = { current, NULL }; + + if (dont_block) { + spin_unlock_irqrestore(&kbd_controller_lock, flags); + return -EAGAIN; + } + expires = mouse_ack_pending + MOUSE_ACK_TIMEOUT; + if (jiffies >= expires) + goto timed_out; + + add_wait_queue(&mouse_ack_wait, &wait); + init_timer (&timer); + timer.expires = expires; + timer.data = 0; + timer.function = mouse_ack_timeout; + add_timer(&timer); + + do { + current->state = TASK_INTERRUPTIBLE; + spin_unlock_irqrestore(&kbd_controller_lock, flags); + schedule(); + spin_lock_irqsave(&kbd_controller_lock, flags); + } while (mouse_ack_pending + && jiffies < expires + && !signal_pending(current)); + + del_timer(&timer); + remove_wait_queue(&mouse_ack_wait, &wait); + + if (mouse_ack_pending && jiffies >= expires) { + timed_out: + printk(KERN_WARNING "mouse ack timeout\n"); + mouse_ack_pending = 0; + spin_unlock_irqrestore(&kbd_controller_lock, flags); + return -EIO; + } + if (signal_pending(current)) { + spin_unlock_irqrestore(&kbd_controller_lock, flags); + return -ERESTARTSYS; + } + } kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); + mouse_ack_pending = jiffies; + if (handle_ack) + /* we will deal with the ACK ourselves. */ + mouse_reply_expected++; spin_unlock_irqrestore(&kbd_controller_lock, flags); + return 0; } /* * Send a byte to the mouse & handle returned ack */ -static void aux_write_ack(int val) +static void __aux_write_ack(int val) { - unsigned long flags; - - spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); - /* we expect an ACK in response. */ + mouse_ack_pending = jiffies; + /* we will deal with the ACK ourselves. */ mouse_reply_expected++; kb_wait(); +} + +#ifdef INITIALIZE_MOUSE +static void aux_write_ack(int val) +{ + unsigned long flags; + + spin_lock_irqsave(&kbd_controller_lock, flags); + __aux_write_ack(val); spin_unlock_irqrestore(&kbd_controller_lock, flags); } +#endif /* INITIALIZE_MOUSE */ + +static void aux_kill_fasync(struct fasync_struct *fasync, int s) +{ + struct fasync_struct * fp; + struct fasync_struct fa; + + fp = fasync; + /* If someone has grabbed the AUX device, send signal only to + them and not to other processes. We could do this directly + if send_sigio was exported, but since it isn't we must + synthesize a "struct fasync_struct" to pass to + kill_fasync. */ + if (aux_exclusive) { + while (1) { + if (!fp) + return; + if (fp->fa_file == aux_exclusive) + break; + fp = fp->fa_next; + } + fa = (*fp); + fa.fa_next = NULL; + fp = &fa; + } + kill_fasync(fp, s); +} static unsigned char get_from_queue(void) { @@ -874,6 +991,8 @@ static int release_aux(struct inode * inode, struct file * file) { fasync_aux(-1, file, 0); + if (aux_exclusive == file) + aux_release_ioctl(file); if (--aux_count) return 0; kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints */ @@ -900,13 +1019,40 @@ kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable the auxiliary port on controller. */ - aux_write_ack(AUX_ENABLE_DEV); /* Enable aux device */ + aux_write_dev(AUX_ENABLE_DEV, 0, 1); /* Enable aux device */ kbd_write_cmd(AUX_INTS_ON); /* Enable controller ints */ return 0; } /* + * Implement exclusive access mechanism. + */ + +#define AUX_ACCESS_ALLOWED(file) (!aux_exclusive || aux_exclusive == (file)) + +static ssize_t aux_wait_for_access(struct file * file) +{ + struct wait_queue wait = { current, NULL }; + + if (!AUX_ACCESS_ALLOWED(file)) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + add_wait_queue(&aux_exclusive_wait, &wait); + do { + current->state = TASK_INTERRUPTIBLE; + schedule(); + } + while (!AUX_ACCESS_ALLOWED(file) + && !signal_pending(current)); + remove_wait_queue(&aux_exclusive_wait, &wait); + } + if (!AUX_ACCESS_ALLOWED(file)) + return -ERESTARTSYS; + return 0; +} + +/* * Put bytes from input queue to buffer. */ @@ -916,7 +1062,11 @@ struct wait_queue wait = { current, NULL }; ssize_t i = count; unsigned char c; + ssize_t retval; + retval = aux_wait_for_access(file); + if (retval < 0) + return retval; if (queue_empty()) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; @@ -951,23 +1101,32 @@ static ssize_t write_aux(struct file * file, const char * buffer, size_t count, loff_t *ppos) { - ssize_t retval = 0; - + ssize_t retval; + + retval = aux_wait_for_access(file); + if (retval < 0) + return retval; if (count) { ssize_t written = 0; + retval = -EIO; if (count > 32) count = 32; /* Limit to 32 bytes. */ do { char c; + int write_result; get_user(c, buffer++); - aux_write_dev(c); + write_result = aux_write_dev(c, file->f_flags & O_NONBLOCK, 0); + if (write_result) { + retval = write_result; + break; + } written++; } while (--count); - retval = -EIO; if (written) { retval = written; file->f_dentry->d_inode->i_mtime = CURRENT_TIME; + aux_last_write = jiffies; } } @@ -977,18 +1136,82 @@ static unsigned int aux_poll(struct file *file, poll_table * wait) { poll_wait(file, &queue->proc_list, wait); - if (!queue_empty()) + if (AUX_ACCESS_ALLOWED(file) && !queue_empty()) return POLLIN | POLLRDNORM; return 0; } +/* Wait this long after last write to mouse before allowing AUX_GRAB + to happen. This ensures that any outstanding mouse command is + completed. The ACK from the command is supposed to arrive in 25 + msec, and each subsequent status bytes are supposed to arrive + within 20 msec, so a command with 5 status bytes (I don't know any + this long) might take 125 msec. Fudge this up a bit to account for + additional delay introduced by bus locking. */ +#define AUX_GRAB_MIN_TIME (aux_last_write + (((200 * HZ) + 500) / 1000)) +#define AUX_GRAB_ALLOWED (aux_exclusive == 0 && (jiffies >= AUX_GRAB_MIN_TIME)) + +static void aux_grab_timeout(unsigned long data) +{ + wake_up_interruptible(&aux_exclusive_wait); +} + +static int aux_grab_ioctl(struct file *file) +{ + struct wait_queue wait = { current, NULL }; + struct timer_list timer; + + if (aux_exclusive == file) + return -EINVAL; + if (!AUX_GRAB_ALLOWED) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + init_timer (&timer); + timer.expires = AUX_GRAB_MIN_TIME; + timer.data = 0; + timer.function = aux_grab_timeout; + add_wait_queue(&aux_exclusive_wait, &wait); + add_timer(&timer); + do { + current->state = TASK_INTERRUPTIBLE; + schedule(); + } + while (!AUX_GRAB_ALLOWED && !signal_pending(current)); + del_timer(&timer); + remove_wait_queue(&aux_exclusive_wait, &wait); + } + if (!AUX_GRAB_ALLOWED) + return -ERESTARTSYS; + aux_exclusive = file; + return 0; +} + +static int aux_release_ioctl(struct file *file) +{ + if (aux_exclusive != file) + return -ENOENT; + aux_exclusive = 0; + wake_up_interruptible(&aux_exclusive_wait); + return 0; +} + +static int aux_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + switch (cmd) { + case AUX_GRAB: return aux_grab_ioctl(file); + case AUX_RELEASE: return aux_release_ioctl(file); + default: return -EINVAL; + } +} + struct file_operations psaux_fops = { NULL, /* seek */ read_aux, write_aux, NULL, /* readdir */ aux_poll, - NULL, /* ioctl */ + aux_ioctl, NULL, /* mmap */ open_aux, NULL, /* flush */ @@ -1025,6 +1248,8 @@ #endif /* INITIALIZE_MOUSE */ kbd_write_command(KBD_CCMD_MOUSE_DISABLE); /* Disable aux device. */ kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints. */ + + aux_last_write = jiffies; return 0; } tpconfig-3.1.3.orig/psaux-2.4.0-combined.diff0100664001167100001440000002614607271106105017204 0ustar cphusers--- linux/drivers/char/pc_keyb.c.orig Mon Oct 23 18:51:36 2000 +++ linux/drivers/char/pc_keyb.c Sat Dec 16 21:43:18 2000 @@ -13,6 +13,15 @@ * Code fixes to handle mouse ACKs properly. * C. Scott Ananian 1999-01-29. * + * More work to handle mouse ACKs properly. (Modified version of + * patch by Julian Bradfield .) + * Chris Hanson 2000-12-11. + * + * Implement exclusive access mechanism for aux device. + * This permits grabbing the mouse away from the X server, + * which is needed by fancy mice that have configurable features. + * Chris Hanson 2000-10-30. + * */ #include @@ -63,6 +72,8 @@ #ifdef CONFIG_PSMOUSE static void aux_write_ack(int val); static void __aux_write_ack(int val); +static void aux_kill_fasync(struct fasync_struct **fasync, int sig, int band); +static int aux_release_ioctl(struct file *file); #endif static spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED; @@ -85,13 +96,30 @@ static struct aux_queue *queue; /* Mouse data buffer. */ static int aux_count; -/* used when we send commands to the mouse that expect an ACK. */ +/* Used when we (as opposed to user programs using the aux device) + send commands to the mouse. */ static unsigned char mouse_reply_expected; +/* Used to make sure we have received an ACK from the byte last + written to the mouse before writing another. */ +static unsigned long mouse_ack_pending; +static wait_queue_head_t mouse_ack_wait; +/* How many jiffies to wait for the mouse to respond to a command with + an ACK. 25 msec is the maximum allowed delay for the hardware to + respond. We round that up to the nearest jiffy. */ +#define MOUSE_ACK_TIMEOUT ((25 * HZ + 999) / 1000) + #define AUX_INTS_OFF (KBD_MODE_KCC | KBD_MODE_DISABLE_MOUSE | KBD_MODE_SYS | KBD_MODE_KBD_INT) #define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT) #define MAX_RETRIES 60 /* some aux operations take long time*/ + +/* Support for exclusive access to the AUX device. */ +static struct file *aux_exclusive; +static wait_queue_head_t aux_exclusive_wait; +static unsigned long aux_last_write; +#define AUX_GRAB _IO('M', 1) +#define AUX_RELEASE _IO('M', 2) #endif /* CONFIG_PSMOUSE */ /* @@ -396,6 +424,13 @@ static inline void handle_mouse_event(unsigned char scancode) { #ifdef CONFIG_PSMOUSE + if (mouse_ack_pending) { + /* It needn't actually be an ack, it could be an echo; + but every byte sent to the mouse results in a byte + back. */ + wake_up_interruptible(&mouse_ack_wait); + mouse_ack_pending = 0; + } if (mouse_reply_expected) { if (scancode == AUX_ACK) { mouse_reply_expected--; @@ -417,7 +452,7 @@ head = (head + 1) & (AUX_BUF_SIZE-1); if (head != queue->tail) { queue->head = head; - kill_fasync(&queue->fasync, SIGIO, POLL_IN); + aux_kill_fasync(&queue->fasync, SIGIO, POLL_IN); wake_up_interruptible(&queue->proc_list); } } @@ -801,19 +836,75 @@ return retval; } +static void mouse_ack_timeout(unsigned long data) +{ + wake_up_interruptible(&mouse_ack_wait); +} + /* * Send a byte to the mouse. */ -static void aux_write_dev(int val) +static int aux_write_dev(int val, int dont_block, int handle_ack) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); + /* If we haven't yet received the ACK from the previous write, + we must wait for it. */ + if (mouse_ack_pending) { + unsigned long expires; + struct timer_list timer; + DECLARE_WAITQUEUE(wait, current); + + if (dont_block) { + spin_unlock_irqrestore(&kbd_controller_lock, flags); + return -EAGAIN; + } + expires = mouse_ack_pending + MOUSE_ACK_TIMEOUT; + if (jiffies >= expires) + goto timed_out; + + add_wait_queue(&mouse_ack_wait, &wait); + init_timer (&timer); + timer.expires = expires; + timer.data = 0; + timer.function = mouse_ack_timeout; + add_timer(&timer); + + do { + current->state = TASK_INTERRUPTIBLE; + spin_unlock_irqrestore(&kbd_controller_lock, flags); + schedule(); + spin_lock_irqsave(&kbd_controller_lock, flags); + } while (mouse_ack_pending + && jiffies < expires + && !signal_pending(current)); + + del_timer(&timer); + remove_wait_queue(&mouse_ack_wait, &wait); + + if (mouse_ack_pending && jiffies >= expires) { + timed_out: + printk(KERN_WARNING "mouse ack timeout\n"); + mouse_ack_pending = 0; + spin_unlock_irqrestore(&kbd_controller_lock, flags); + return -EIO; + } + if (signal_pending(current)) { + spin_unlock_irqrestore(&kbd_controller_lock, flags); + return -ERESTARTSYS; + } + } kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); + mouse_ack_pending = jiffies; + if (handle_ack) + /* We will deal with the ACK ourselves. */ + mouse_reply_expected++; spin_unlock_irqrestore(&kbd_controller_lock, flags); + return 0; } /* @@ -825,11 +916,13 @@ kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); - /* we expect an ACK in response. */ + mouse_ack_pending = jiffies; + /* We will deal with the ACK ourselves. */ mouse_reply_expected++; kb_wait(); } +#ifdef INITIALIZE_MOUSE static void aux_write_ack(int val) { unsigned long flags; @@ -838,6 +931,33 @@ __aux_write_ack(val); spin_unlock_irqrestore(&kbd_controller_lock, flags); } +#endif /* INITIALIZE_MOUSE */ + +static void aux_kill_fasync(struct fasync_struct **fasync, int sig, int band) +{ + struct fasync_struct * fp; + struct fasync_struct fa; + + fp = *fasync; + /* If someone has grabbed the AUX device, send signal only to + them and not to other processes. We could do this directly + if send_sigio was exported, but since it isn't we must + synthesize a "struct fasync_struct" to pass to + kill_fasync. */ + if (aux_exclusive) { + while (1) { + if (!fp) + return; + if (fp->fa_file == aux_exclusive) + break; + fp = fp->fa_next; + } + fa = (*fp); + fa.fa_next = NULL; + fp = &fa; + } + kill_fasync(&fp, sig, band); +} static unsigned char get_from_queue(void) { @@ -877,6 +997,8 @@ { lock_kernel(); fasync_aux(-1, file, 0); + if (aux_exclusive == file) + aux_release_ioctl(file); if (--aux_count) { unlock_kernel(); return 0; @@ -906,7 +1028,7 @@ kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable the auxiliary port on controller. */ - aux_write_ack(AUX_ENABLE_DEV); /* Enable aux device */ + aux_write_dev(AUX_ENABLE_DEV, 0, 1); /* Enable aux device */ kbd_write_cmd(AUX_INTS_ON); /* Enable controller ints */ send_data(KBD_CMD_ENABLE); /* try to workaround toshiba4030cdt problem */ @@ -915,6 +1037,33 @@ } /* + * Implement exclusive access mechanism. + */ + +#define AUX_ACCESS_ALLOWED(file) (!aux_exclusive || aux_exclusive == (file)) + +static ssize_t aux_wait_for_access(struct file * file) +{ + DECLARE_WAITQUEUE(wait, current); + + if (!AUX_ACCESS_ALLOWED(file)) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + add_wait_queue(&aux_exclusive_wait, &wait); + do { + current->state = TASK_INTERRUPTIBLE; + schedule(); + } + while (!AUX_ACCESS_ALLOWED(file) + && !signal_pending(current)); + remove_wait_queue(&aux_exclusive_wait, &wait); + } + if (!AUX_ACCESS_ALLOWED(file)) + return -ERESTARTSYS; + return 0; +} + +/* * Put bytes from input queue to buffer. */ @@ -924,7 +1073,11 @@ DECLARE_WAITQUEUE(wait, current); ssize_t i = count; unsigned char c; + ssize_t retval; + retval = aux_wait_for_access(file); + if (retval < 0) + return retval; if (queue_empty()) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; @@ -959,23 +1112,32 @@ static ssize_t write_aux(struct file * file, const char * buffer, size_t count, loff_t *ppos) { - ssize_t retval = 0; + ssize_t retval; + retval = aux_wait_for_access(file); + if (retval < 0) + return retval; if (count) { ssize_t written = 0; + retval = -EIO; if (count > 32) count = 32; /* Limit to 32 bytes. */ do { char c; + int write_result; get_user(c, buffer++); - aux_write_dev(c); + write_result = aux_write_dev(c, file->f_flags & O_NONBLOCK, 0); + if (write_result) { + retval = write_result; + break; + } written++; } while (--count); - retval = -EIO; if (written) { retval = written; file->f_dentry->d_inode->i_mtime = CURRENT_TIME; + aux_last_write = jiffies; } } @@ -986,15 +1148,80 @@ static unsigned int aux_poll(struct file *file, poll_table * wait) { poll_wait(file, &queue->proc_list, wait); - if (!queue_empty()) + if (AUX_ACCESS_ALLOWED(file) && !queue_empty()) return POLLIN | POLLRDNORM; return 0; } +/* Wait this long after last write to mouse before allowing AUX_GRAB + to happen. This ensures that any outstanding mouse command is + completed. The ACK from the command is supposed to arrive in 25 + msec, and each subsequent status bytes are supposed to arrive + within 20 msec, so a command with 5 status bytes (I don't know any + this long) might take 125 msec. Fudge this up a bit to account for + additional delay introduced by bus locking. */ +#define AUX_GRAB_MIN_TIME (aux_last_write + (((200 * HZ) + 500) / 1000)) +#define AUX_GRAB_ALLOWED (aux_exclusive == 0 && (jiffies >= AUX_GRAB_MIN_TIME)) + +static void aux_grab_timeout(unsigned long data) +{ + wake_up_interruptible(&aux_exclusive_wait); +} + +static int aux_grab_ioctl(struct file *file) +{ + DECLARE_WAITQUEUE(wait, current); + struct timer_list timer; + + if (aux_exclusive == file) + return -EINVAL; + if (!AUX_GRAB_ALLOWED) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + init_timer (&timer); + timer.expires = AUX_GRAB_MIN_TIME; + timer.data = 0; + timer.function = aux_grab_timeout; + add_wait_queue(&aux_exclusive_wait, &wait); + add_timer(&timer); + do { + current->state = TASK_INTERRUPTIBLE; + schedule(); + } + while (!AUX_GRAB_ALLOWED && !signal_pending(current)); + del_timer(&timer); + remove_wait_queue(&aux_exclusive_wait, &wait); + } + if (!AUX_GRAB_ALLOWED) + return -ERESTARTSYS; + aux_exclusive = file; + return 0; +} + +static int aux_release_ioctl(struct file *file) +{ + if (aux_exclusive != file) + return -ENOENT; + aux_exclusive = 0; + wake_up_interruptible(&aux_exclusive_wait); + return 0; +} + +static int aux_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) +{ + switch (cmd) { + case AUX_GRAB: return aux_grab_ioctl(file); + case AUX_RELEASE: return aux_release_ioctl(file); + default: return -EINVAL; + } +} + struct file_operations psaux_fops = { read: read_aux, write: write_aux, poll: aux_poll, + ioctl: aux_ioctl, open: open_aux, release: release_aux, fasync: fasync_aux, @@ -1017,6 +1244,8 @@ memset(queue, 0, sizeof(*queue)); queue->head = queue->tail = 0; init_waitqueue_head(&queue->proc_list); + init_waitqueue_head(&mouse_ack_wait); + init_waitqueue_head(&aux_exclusive_wait); #ifdef INITIALIZE_MOUSE kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable Aux. */ @@ -1028,6 +1257,8 @@ #endif /* INITIALIZE_MOUSE */ kbd_write_command(KBD_CCMD_MOUSE_DISABLE); /* Disable aux device. */ kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints. */ + + aux_last_write = jiffies; return 0; } tpconfig-3.1.3.orig/synaptics.c-diff0100664001167100001440000000215407271106105016055 0ustar cphusers--- tpconfig-3.1.orig/synaptics.c +++ tpconfig-3.1/synaptics.c @@ -28,10 +28,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: synaptics.c,v 1.7 2000/10/31 18:39:15 cph Exp $ + * $Id: synaptics.c,v 1.8 2000/12/11 22:12:36 cph Exp $ */ /*$Log: synaptics.c,v $ + *Revision 1.8 2000/12/11 22:12:36 cph + *Must re-enable data reporting after a RESET command. + * *Revision 1.7 2000/10/31 18:39:15 cph *Fix tab problem. * @@ -67,7 +70,7 @@ *Initial revision **/ -static char rcsid[]="$Header: /usr/local/src/tpconfig-3.0.1/RCS/synaptics.c,v 1.7 2000/10/31 18:39:15 cph Exp $"; +static char rcsid[]="$Header: /usr/local/src/tpconfig-3.1/RCS/synaptics.c,v 1.8 2000/12/11 22:12:36 cph Exp $"; #include #include @@ -388,6 +391,7 @@ putbyte (fd, AUX_RESET); getbyte_expected (fd, AUX_RESET_ACK1, "software reset ACK 1"); getbyte_expected (fd, AUX_RESET_ACK2, "software reset ACK 2"); + putbyte (fd, AUX_ENABLE_DEV); fprintf (stderr, "Software reset of TouchPad complete.\n"); } tpconfig-3.1.3.orig/pc_keyb.c.2.2.17.patched0100644001167100001440000007304507271106126016713 0ustar cphusers/* * linux/drivers/char/pc_keyb.c * * Separation of the PC low-level part by Geert Uytterhoeven, May 1997 * See keyboard.c for the whole history. * * Major cleanup by Martin Mares, May 1997 * * Combined the keyboard and PS/2 mouse handling into one file, * because they share the same hardware. * Johan Myreen 1998-10-08. * * Code fixes to handle mouse ACKs properly. * C. Scott Ananian 1999-01-29. * * Code fixes to *really* handle mouse ACKs properly. * Julian Bradfield 1999-04-30. * * Implement exclusive access mechanism for aux device. * This permits grabbing the mouse away from the X server, * which is needed by fancy mice that have configurable features. * Chris Hanson 2000-10-30. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* Some configuration switches are present in the include file... */ #include /* Simple translation table for the SysRq keys */ #ifdef CONFIG_MAGIC_SYSRQ unsigned char pckbd_sysrq_xlate[128] = "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */ "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */ "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */ "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */ "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */ "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */ "\r\000/"; /* 0x60 - 0x6f */ #endif static void kbd_write_command_w(int data); static void kbd_write_output_w(int data); #ifdef CONFIG_PSMOUSE static void aux_write_ack(int val); static void aux_kill_fasync(struct fasync_struct *fasync, int s); static int aux_release_ioctl(struct file *file); #endif spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED; static unsigned char handle_kbd_event(void); /* used only by send_data - set by keyboard_interrupt */ static volatile unsigned char reply_expected = 0; static volatile unsigned char acknowledge = 0; static volatile unsigned char resend = 0; #if defined CONFIG_PSMOUSE /* * PS/2 Auxiliary Device */ static int __init psaux_init(void); #define AUX_RECONNECT 170 /* #define CHECK_RECONNECT_SCANCODE 1 */ static struct aux_queue *queue; /* Mouse data buffer. */ static int aux_count = 0; /* used when we (as opposed to the user programs using the aux device) send commands to the mouse that expect an ACK. */ static unsigned char mouse_reply_expected = 0; /* used to make sure we read acks from the mouse before we write another byte */ static unsigned char mouse_ack_pending = 0; #define MOUSE_ACK_TIMEOUT 5 /* actually, 1 seems to be enough usually */ #define AUX_INTS_OFF (KBD_MODE_KCC | KBD_MODE_DISABLE_MOUSE | KBD_MODE_SYS | KBD_MODE_KBD_INT) #define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT) #define MAX_RETRIES 60 /* some aux operations take long time*/ /* Support for exclusive access to the AUX device. */ static struct file *aux_exclusive = 0; static struct wait_queue *aux_exclusive_wait = NULL; static unsigned long aux_last_write = 0; #define AUX_GRAB _IO('M', 1) #define AUX_RELEASE _IO('M', 2) #endif /* CONFIG_PSMOUSE */ /* * Wait for keyboard controller input buffer to drain. * * Don't use 'jiffies' so that we don't depend on * interrupts.. * * Quote from PS/2 System Reference Manual: * * "Address hex 0060 and address hex 0064 should be written only when * the input-buffer-full bit and output-buffer-full bit in the * Controller Status register are set 0." */ static void kb_wait(void) { unsigned long timeout = KBC_TIMEOUT; do { /* * "handle_kbd_event()" will handle any incoming events * while we wait - keypresses or mouse movement. */ unsigned char status = handle_kbd_event(); if (! (status & KBD_STAT_IBF)) return; mdelay(1); timeout--; } while (timeout); #ifdef KBD_REPORT_TIMEOUTS printk(KERN_WARNING "Keyboard timed out[1]\n"); #endif } /* * Translation of escaped scancodes to keycodes. * This is now user-settable. * The keycodes 1-88,96-111,119 are fairly standard, and * should probably not be changed - changing might confuse X. * X also interprets scancode 0x5d (KEY_Begin). * * For 1-88 keycode equals scancode. */ #define E0_KPENTER 96 #define E0_RCTRL 97 #define E0_KPSLASH 98 #define E0_PRSCR 99 #define E0_RALT 100 #define E0_BREAK 101 /* (control-pause) */ #define E0_HOME 102 #define E0_UP 103 #define E0_PGUP 104 #define E0_LEFT 105 #define E0_RIGHT 106 #define E0_END 107 #define E0_DOWN 108 #define E0_PGDN 109 #define E0_INS 110 #define E0_DEL 111 #define E1_PAUSE 119 /* * The keycodes below are randomly located in 89-95,112-118,120-127. * They could be thrown away (and all occurrences below replaced by 0), * but that would force many users to use the `setkeycodes' utility, where * they needed not before. It does not matter that there are duplicates, as * long as no duplication occurs for any single keyboard. */ #define SC_LIM 89 #define FOCUS_PF1 85 /* actual code! */ #define FOCUS_PF2 89 #define FOCUS_PF3 90 #define FOCUS_PF4 91 #define FOCUS_PF5 92 #define FOCUS_PF6 93 #define FOCUS_PF7 94 #define FOCUS_PF8 95 #define FOCUS_PF9 120 #define FOCUS_PF10 121 #define FOCUS_PF11 122 #define FOCUS_PF12 123 #define JAP_86 124 /* tfj@olivia.ping.dk: * The four keys are located over the numeric keypad, and are * labelled A1-A4. It's an rc930 keyboard, from * Regnecentralen/RC International, Now ICL. * Scancodes: 59, 5a, 5b, 5c. */ #define RGN1 124 #define RGN2 125 #define RGN3 126 #define RGN4 127 static unsigned char high_keys[128 - SC_LIM] = { RGN1, RGN2, RGN3, RGN4, 0, 0, 0, /* 0x59-0x5f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */ 0, 0, 0, 0, 0, FOCUS_PF11, 0, FOCUS_PF12, /* 0x68-0x6f */ 0, 0, 0, FOCUS_PF2, FOCUS_PF9, 0, 0, FOCUS_PF3, /* 0x70-0x77 */ FOCUS_PF4, FOCUS_PF5, FOCUS_PF6, FOCUS_PF7, /* 0x78-0x7b */ FOCUS_PF8, JAP_86, FOCUS_PF10, 0 /* 0x7c-0x7f */ }; /* BTC */ #define E0_MACRO 112 /* LK450 */ #define E0_F13 113 #define E0_F14 114 #define E0_HELP 115 #define E0_DO 116 #define E0_F17 117 #define E0_KPMINPLUS 118 /* * My OmniKey generates e0 4c for the "OMNI" key and the * right alt key does nada. [kkoller@nyx10.cs.du.edu] */ #define E0_OK 124 /* * New microsoft keyboard is rumoured to have * e0 5b (left window button), e0 5c (right window button), * e0 5d (menu button). [or: LBANNER, RBANNER, RMENU] * [or: Windows_L, Windows_R, TaskMan] */ #define E0_MSLW 125 #define E0_MSRW 126 #define E0_MSTM 127 static unsigned char e0_keys[128] = { 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00-0x07 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x08-0x0f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10-0x17 */ 0, 0, 0, 0, E0_KPENTER, E0_RCTRL, 0, 0, /* 0x18-0x1f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20-0x27 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x28-0x2f */ 0, 0, 0, 0, 0, E0_KPSLASH, 0, E0_PRSCR, /* 0x30-0x37 */ E0_RALT, 0, 0, 0, 0, E0_F13, E0_F14, E0_HELP, /* 0x38-0x3f */ E0_DO, E0_F17, 0, 0, 0, 0, E0_BREAK, E0_HOME, /* 0x40-0x47 */ E0_UP, E0_PGUP, 0, E0_LEFT, E0_OK, E0_RIGHT, E0_KPMINPLUS, E0_END,/* 0x48-0x4f */ E0_DOWN, E0_PGDN, E0_INS, E0_DEL, 0, 0, 0, 0, /* 0x50-0x57 */ 0, 0, 0, E0_MSLW, E0_MSRW, E0_MSTM, 0, 0, /* 0x58-0x5f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */ 0, 0, 0, 0, 0, 0, 0, E0_MACRO, /* 0x68-0x6f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77 */ 0, 0, 0, 0, 0, 0, 0, 0 /* 0x78-0x7f */ }; int pckbd_setkeycode(unsigned int scancode, unsigned int keycode) { if (scancode < SC_LIM || scancode > 255 || keycode > 127) return -EINVAL; if (scancode < 128) high_keys[scancode - SC_LIM] = keycode; else e0_keys[scancode - 128] = keycode; return 0; } int pckbd_getkeycode(unsigned int scancode) { return (scancode < SC_LIM || scancode > 255) ? -EINVAL : (scancode < 128) ? high_keys[scancode - SC_LIM] : e0_keys[scancode - 128]; } static int do_acknowledge(unsigned char scancode) { if (reply_expected) { /* Unfortunately, we must recognise these codes only if we know they * are known to be valid (i.e., after sending a command), because there * are some brain-damaged keyboards (yes, FOCUS 9000 again) which have * keys with such codes :( */ if (scancode == KBD_REPLY_ACK) { acknowledge = 1; reply_expected = 0; return 0; } else if (scancode == KBD_REPLY_RESEND) { resend = 1; reply_expected = 0; return 0; } /* Should not happen... */ #if 0 printk(KERN_DEBUG "keyboard reply expected - got %02x\n", scancode); #endif } return 1; } int pckbd_translate(unsigned char scancode, unsigned char *keycode, char raw_mode) { static int prev_scancode = 0; /* special prefix scancodes.. */ if (scancode == 0xe0 || scancode == 0xe1) { prev_scancode = scancode; return 0; } /* 0xFF is sent by a few keyboards, ignore it. 0x00 is error */ if (scancode == 0x00 || scancode == 0xff) { prev_scancode = 0; return 0; } scancode &= 0x7f; if (prev_scancode) { /* * usually it will be 0xe0, but a Pause key generates * e1 1d 45 e1 9d c5 when pressed, and nothing when released */ if (prev_scancode != 0xe0) { if (prev_scancode == 0xe1 && scancode == 0x1d) { prev_scancode = 0x100; return 0; } else if (prev_scancode == 0x100 && scancode == 0x45) { *keycode = E1_PAUSE; prev_scancode = 0; } else { #ifdef KBD_REPORT_UNKN if (!raw_mode) printk(KERN_INFO "keyboard: unknown e1 escape sequence\n"); #endif prev_scancode = 0; return 0; } } else { prev_scancode = 0; /* * The keyboard maintains its own internal caps lock and * num lock statuses. In caps lock mode E0 AA precedes make * code and E0 2A follows break code. In num lock mode, * E0 2A precedes make code and E0 AA follows break code. * We do our own book-keeping, so we will just ignore these. */ /* * For my keyboard there is no caps lock mode, but there are * both Shift-L and Shift-R modes. The former mode generates * E0 2A / E0 AA pairs, the latter E0 B6 / E0 36 pairs. * So, we should also ignore the latter. - aeb@cwi.nl */ if (scancode == 0x2a || scancode == 0x36) return 0; if (e0_keys[scancode]) *keycode = e0_keys[scancode]; else { #ifdef KBD_REPORT_UNKN if (!raw_mode) printk(KERN_INFO "keyboard: unknown scancode e0 %02x\n", scancode); #endif return 0; } } } else if (scancode >= SC_LIM) { /* This happens with the FOCUS 9000 keyboard Its keys PF1..PF12 are reported to generate 55 73 77 78 79 7a 7b 7c 74 7e 6d 6f Moreover, unless repeated, they do not generate key-down events, so we have to zero up_flag below */ /* Also, Japanese 86/106 keyboards are reported to generate 0x73 and 0x7d for \ - and \ | respectively. */ /* Also, some Brazilian keyboard is reported to produce 0x73 and 0x7e for \ ? and KP-dot, respectively. */ *keycode = high_keys[scancode - SC_LIM]; if (!*keycode) { if (!raw_mode) { #ifdef KBD_REPORT_UNKN printk(KERN_INFO "keyboard: unrecognized scancode (%02x)" " - ignored\n", scancode); #endif } return 0; } } else *keycode = scancode; return 1; } char pckbd_unexpected_up(unsigned char keycode) { /* unexpected, but this can happen: maybe this was a key release for a FOCUS 9000 PF key; if we want to see it, we have to clear up_flag */ if (keycode >= SC_LIM || keycode == 85) return 0; else return 0200; } static inline void handle_mouse_event(unsigned char scancode) { #ifdef CONFIG_PSMOUSE if (mouse_ack_pending) /* It needn't actually be an ack, it could be an echo; but every byte sent to the mouse results in a byte back. */ mouse_ack_pending = 0; if (mouse_reply_expected) { if (scancode == AUX_ACK) { mouse_reply_expected--; return; } mouse_reply_expected = 0; } else if (scancode == AUX_RECONNECT) { queue->head = queue->tail = 0; /* Flush input queue */ /* ping the mouse :) */ kb_wait(); kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(AUX_ENABLE_DEV); /* we expect an ACK in response. */ mouse_reply_expected++; kb_wait(); return; } add_mouse_randomness(scancode); if (aux_count) { int head = queue->head; queue->buf[head] = scancode; head = (head + 1) & (AUX_BUF_SIZE-1); if (head != queue->tail) { queue->head = head; if (queue->fasync) aux_kill_fasync(queue->fasync, SIGIO); wake_up_interruptible(&queue->proc_list); } } #endif } /* * This reads the keyboard status port, and does the * appropriate action. * * It requires that we hold the keyboard controller * spinlock. */ static unsigned char handle_kbd_event(void) { unsigned char status = kbd_read_status(); unsigned int work = 10000; while ((--work > 0) && (status & KBD_STAT_OBF)) { unsigned char scancode; scancode = kbd_read_input(); /* Error bytes must be ignored to make the Synaptics touchpads compaq use work */ #if 1 /* Ignore error bytes */ if (!(status & (KBD_STAT_GTO | KBD_STAT_PERR))) #endif { if (status & KBD_STAT_MOUSE_OBF) handle_mouse_event(scancode); else { if (do_acknowledge(scancode)) handle_scancode(scancode, !(scancode & 0x80)); mark_bh(KEYBOARD_BH); } } status = kbd_read_status(); } if (!work) printk(KERN_ERR "pc_keyb: controller jammed (0x%02X).\n", status); return status; } static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs) { unsigned long flags; kbd_pt_regs = regs; spin_lock_irqsave(&kbd_controller_lock, flags); handle_kbd_event(); spin_unlock_irqrestore(&kbd_controller_lock, flags); } /* * send_data sends a character to the keyboard and waits * for an acknowledge, possibly retrying if asked to. Returns * the success status. * * Don't use 'jiffies', so that we don't depend on interrupts */ static int send_data(unsigned char data) { int retries = 3; do { unsigned long timeout = KBD_TIMEOUT; acknowledge = 0; /* Set by interrupt routine on receipt of ACK. */ resend = 0; reply_expected = 1; kbd_write_output_w(data); for (;;) { if (acknowledge) return 1; if (resend) break; mdelay(1); if (!--timeout) { #ifdef KBD_REPORT_TIMEOUTS printk(KERN_WARNING "Keyboard timeout[2]\n"); #endif return 0; } } } while (retries-- > 0); #ifdef KBD_REPORT_TIMEOUTS printk(KERN_WARNING "keyboard: Too many NACKs -- noisy kbd cable?\n"); #endif return 0; } void pckbd_leds(unsigned char leds) { if (!send_data(KBD_CMD_SET_LEDS) || !send_data(leds)) send_data(KBD_CMD_ENABLE); /* re-enable kbd if any errors */ } /* * In case we run on a non-x86 hardware we need to initialize both the * keyboard controller and the keyboard. On a x86, the BIOS will * already have initialized them. * * Some x86 BIOSes do not correctly initialize the keyboard, so the * "kbd-reset" command line options can be given to force a reset. * [Ranger] */ #ifdef __i386__ int kbd_startup_reset __initdata = 0; #else int kbd_startup_reset __initdata = 1; #endif /* for "kbd-reset" cmdline param */ void __init kbd_reset_setup(char *str, int *ints) { kbd_startup_reset = 1; } #define KBD_NO_DATA (-1) /* No data */ #define KBD_BAD_DATA (-2) /* Parity or other error */ static int __init kbd_read_data(void) { int retval = KBD_NO_DATA; unsigned char status; status = kbd_read_status(); if (status & KBD_STAT_OBF) { unsigned char data = kbd_read_input(); retval = data; if (status & (KBD_STAT_GTO | KBD_STAT_PERR)) retval = KBD_BAD_DATA; } return retval; } static void __init kbd_clear_input(void) { int maxread = 100; /* Random number */ do { if (kbd_read_data() == KBD_NO_DATA) break; } while (--maxread); } static int __init kbd_wait_for_input(void) { long timeout = KBD_INIT_TIMEOUT; do { int retval = kbd_read_data(); if (retval >= 0) return retval; mdelay(1); } while (--timeout); return -1; } static void kbd_write_command_w(int data) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); kbd_write_command(data); spin_unlock_irqrestore(&kbd_controller_lock, flags); } static void kbd_write_output_w(int data) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); kbd_write_output(data); spin_unlock_irqrestore(&kbd_controller_lock, flags); } #if defined CONFIG_PSMOUSE static void kbd_write_cmd(int cmd) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); kbd_write_command(KBD_CCMD_WRITE_MODE); kb_wait(); kbd_write_output(cmd); spin_unlock_irqrestore(&kbd_controller_lock, flags); } #endif /* CONFIG_PSMOUSE */ static char * __init initialize_kbd(void) { int status; /* * Test the keyboard interface. * This seems to be the only way to get it going. * If the test is successful a x55 is placed in the input buffer. */ kbd_write_command_w(KBD_CCMD_SELF_TEST); if (kbd_wait_for_input() != 0x55) return "Keyboard failed self test"; /* * Perform a keyboard interface test. This causes the controller * to test the keyboard clock and data lines. The results of the * test are placed in the input buffer. */ kbd_write_command_w(KBD_CCMD_KBD_TEST); if (kbd_wait_for_input() != 0x00) return "Keyboard interface failed self test"; /* * Enable the keyboard by allowing the keyboard clock to run. */ kbd_write_command_w(KBD_CCMD_KBD_ENABLE); /* * Reset keyboard. If the read times out * then the assumption is that no keyboard is * plugged into the machine. * This defaults the keyboard to scan-code set 2. * * Set up to try again if the keyboard asks for RESEND. */ do { kbd_write_output_w(KBD_CMD_RESET); status = kbd_wait_for_input(); if (status == KBD_REPLY_ACK) break; if (status != KBD_REPLY_RESEND) return "Keyboard reset failed, no ACK"; } while (1); if (kbd_wait_for_input() != KBD_REPLY_POR) return "Keyboard reset failed, no POR"; /* * Set keyboard controller mode. During this, the keyboard should be * in the disabled state. * * Set up to try again if the keyboard asks for RESEND. */ do { kbd_write_output_w(KBD_CMD_DISABLE); status = kbd_wait_for_input(); if (status == KBD_REPLY_ACK) break; if (status != KBD_REPLY_RESEND) return "Disable keyboard: no ACK"; } while (1); kbd_write_command_w(KBD_CCMD_WRITE_MODE); kbd_write_output_w(KBD_MODE_KBD_INT | KBD_MODE_SYS | KBD_MODE_DISABLE_MOUSE | KBD_MODE_KCC); /* ibm powerpc portables need this to use scan-code set 1 -- Cort */ kbd_write_command_w(KBD_CCMD_READ_MODE); if (!(kbd_wait_for_input() & KBD_MODE_KCC)) { /* * If the controller does not support conversion, * Set the keyboard to scan-code set 1. */ kbd_write_output_w(0xF0); kbd_wait_for_input(); kbd_write_output_w(0x01); kbd_wait_for_input(); } kbd_write_output_w(KBD_CMD_ENABLE); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Enable keyboard: no ACK"; /* * Finally, set the typematic rate to maximum. */ kbd_write_output_w(KBD_CMD_SET_RATE); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Set rate: no ACK"; kbd_write_output_w(0x00); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Set rate: no ACK"; return NULL; } void __init pckbd_init_hw(void) { kbd_request_region(); /* Flush any pending input. */ kbd_clear_input(); if (kbd_startup_reset) { char *msg = initialize_kbd(); if (msg) printk(KERN_WARNING "initialize_kbd: %s\n", msg); } #if defined CONFIG_PSMOUSE psaux_init(); #endif /* Ok, finally allocate the IRQ, and off we go.. */ kbd_request_irq(keyboard_interrupt); } #if defined CONFIG_PSMOUSE /* * Check if this is a dual port controller. */ static int __init detect_auxiliary_port(void) { unsigned long flags; int loops = 10; int retval = 0; spin_lock_irqsave(&kbd_controller_lock, flags); /* Put the value 0x5A in the output buffer using the "Write * Auxiliary Device Output Buffer" command (0xD3). Poll the * Status Register for a while to see if the value really * turns up in the Data Register. If the KBD_STAT_MOUSE_OBF * bit is also set to 1 in the Status Register, we assume this * controller has an Auxiliary Port (a.k.a. Mouse Port). */ kb_wait(); kbd_write_command(KBD_CCMD_WRITE_AUX_OBUF); kb_wait(); kbd_write_output(0x5a); /* 0x5a is a random dummy value. */ do { unsigned char status = kbd_read_status(); if (status & KBD_STAT_OBF) { (void) kbd_read_input(); if (status & KBD_STAT_MOUSE_OBF) { printk(KERN_INFO "Detected PS/2 Mouse Port.\n"); retval = 1; } break; } mdelay(1); } while (--loops); spin_unlock_irqrestore(&kbd_controller_lock, flags); return retval; } /* * Send a byte to the mouse. */ static void aux_write_dev(int val) { unsigned long flags; int loop = 0; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); /* If we haven't yet received the ack from the previous write, we must wait for it to arrive; otherwise we lose it. (At least, I think this is what is happening.) */ while (mouse_ack_pending && loop++ < MOUSE_ACK_TIMEOUT ) { mdelay(1); handle_kbd_event(); } if (mouse_ack_pending) printk(KERN_WARNING "mouse ack timeout\n"); kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); mouse_ack_pending = 1; spin_unlock_irqrestore(&kbd_controller_lock, flags); } /* * Send a byte to the mouse & handle returned ack */ static void aux_write_ack(int val) { unsigned long flags; int loop = 0; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); while (mouse_ack_pending && loop++ < MOUSE_ACK_TIMEOUT) { mdelay(1); handle_kbd_event(); } if (mouse_ack_pending) printk(KERN_WARNING "mouse ack timeout\n"); kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); mouse_ack_pending = 1; /* we will deal with the ACK ourselves. */ mouse_reply_expected++; kb_wait(); spin_unlock_irqrestore(&kbd_controller_lock, flags); } static void aux_kill_fasync(struct fasync_struct *fasync, int s) { struct fasync_struct * fp; struct fasync_struct fa; fp = fasync; /* If someone has grabbed the AUX device, send signal only to them and not to other processes. We could do this directly if send_sigio was exported, but since it isn't we must synthesize a "struct fasync_struct" to pass to kill_fasync. */ if (aux_exclusive) { while (1) { if (!fp) return; if (fp->fa_file == aux_exclusive) break; fp = fp->fa_next; } fa = (*fp); fa.fa_next = NULL; fp = &fa; } kill_fasync(fp, s,POLL_IN); } static unsigned char get_from_queue(void) { unsigned char result; unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); result = queue->buf[queue->tail]; queue->tail = (queue->tail + 1) & (AUX_BUF_SIZE-1); spin_unlock_irqrestore(&kbd_controller_lock, flags); return result; } static inline int queue_empty(void) { return queue->head == queue->tail; } static int fasync_aux(int fd, struct file *filp, int on) { int retval; retval = fasync_helper(fd, filp, on, &queue->fasync); if (retval < 0) return retval; return 0; } /* * Random magic cookie for the aux device */ #define AUX_DEV ((void *)queue) static int release_aux(struct inode * inode, struct file * file) { fasync_aux(-1, file, 0); if (aux_exclusive == file) aux_release_ioctl(file); if (--aux_count) return 0; kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints */ kbd_write_command_w(KBD_CCMD_MOUSE_DISABLE); aux_free_irq(AUX_DEV); return 0; } /* * Install interrupt handler. * Enable auxiliary device. */ static int open_aux(struct inode * inode, struct file * file) { if (aux_count++) { return 0; } queue->head = queue->tail = 0; /* Flush input queue */ if (aux_request_irq(keyboard_interrupt, AUX_DEV)) { aux_count--; return -EBUSY; } kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable the auxiliary port on controller. */ aux_write_ack(AUX_ENABLE_DEV); /* Enable aux device */ kbd_write_cmd(AUX_INTS_ON); /* Enable controller ints */ return 0; } /* * Implement exclusive access mechanism. */ #define AUX_ACCESS_ALLOWED(file) (!aux_exclusive || aux_exclusive == (file)) static ssize_t aux_wait_for_access(struct file * file) { struct wait_queue wait = { current, NULL }; if (!AUX_ACCESS_ALLOWED(file)) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; add_wait_queue(&aux_exclusive_wait, &wait); do { current->state = TASK_INTERRUPTIBLE; schedule(); } while (!AUX_ACCESS_ALLOWED(file) && !signal_pending(current)); remove_wait_queue(&aux_exclusive_wait, &wait); } if (!AUX_ACCESS_ALLOWED(file)) return -ERESTARTSYS; return 0; } /* * Put bytes from input queue to buffer. */ static ssize_t read_aux(struct file * file, char * buffer, size_t count, loff_t *ppos) { struct wait_queue wait = { current, NULL }; ssize_t i = count; unsigned char c; ssize_t retval; retval = aux_wait_for_access(file); if (retval < 0) return retval; if (queue_empty()) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; add_wait_queue(&queue->proc_list, &wait); repeat: current->state = TASK_INTERRUPTIBLE; if (queue_empty() && !signal_pending(current)) { schedule(); goto repeat; } current->state = TASK_RUNNING; remove_wait_queue(&queue->proc_list, &wait); } while (i > 0 && !queue_empty()) { c = get_from_queue(); put_user(c, buffer++); i--; } if (count-i) { file->f_dentry->d_inode->i_atime = CURRENT_TIME; return count-i; } if (signal_pending(current)) return -ERESTARTSYS; return 0; } /* * Write to the aux device. */ static ssize_t write_aux(struct file * file, const char * buffer, size_t count, loff_t *ppos) { ssize_t retval; retval = aux_wait_for_access(file); if (retval < 0) return retval; if (count) { ssize_t written = 0; if (count > 32) count = 32; /* Limit to 32 bytes. */ do { char c; get_user(c, buffer++); aux_write_dev(c); written++; } while (--count); retval = -EIO; if (written) { retval = written; file->f_dentry->d_inode->i_mtime = CURRENT_TIME; aux_last_write = jiffies; } } return retval; } static unsigned int aux_poll(struct file *file, poll_table * wait) { poll_wait(file, &queue->proc_list, wait); if (AUX_ACCESS_ALLOWED(file) && !queue_empty()) return POLLIN | POLLRDNORM; return 0; } /* Wait this long after last write to mouse before allowing AUX_GRAB to happen. This ensures that any outstanding mouse command is completed. The ACK from the command is supposed to arrive in 25 msec, and each subsequent status bytes are supposed to arrive within 20 msec, so a command with 5 status bytes (I don't know any this long) might take 125 msec. Fudge this up a bit to account for additional delay introduced by bus locking. */ #define AUX_GRAB_MIN_TIME (aux_last_write + (((200 * HZ) + 500) / 1000)) #define AUX_GRAB_ALLOWED (aux_exclusive == 0 && (jiffies >= AUX_GRAB_MIN_TIME)) static void aux_grab_timeout(unsigned long data) { wake_up_interruptible(&aux_exclusive_wait); } static int aux_grab_ioctl(struct file *file) { struct wait_queue wait = { current, NULL }; struct timer_list timer; if (aux_exclusive == file) return -EINVAL; if (!AUX_GRAB_ALLOWED) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; init_timer (&timer); timer.expires = AUX_GRAB_MIN_TIME; timer.data = 0; timer.function = aux_grab_timeout; add_wait_queue(&aux_exclusive_wait, &wait); add_timer(&timer); do { current->state = TASK_INTERRUPTIBLE; schedule(); } while (!AUX_GRAB_ALLOWED && !signal_pending(current)); del_timer(&timer); remove_wait_queue(&aux_exclusive_wait, &wait); } if (!AUX_GRAB_ALLOWED) return -ERESTARTSYS; aux_exclusive = file; return 0; } static int aux_release_ioctl(struct file *file) { if (aux_exclusive != file) return -ENOENT; aux_exclusive = 0; wake_up_interruptible(&aux_exclusive_wait); return 0; } static int aux_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { switch (cmd) { case AUX_GRAB: return aux_grab_ioctl(file); case AUX_RELEASE: return aux_release_ioctl(file); default: return -EINVAL; } } struct file_operations psaux_fops = { NULL, /* seek */ read_aux, write_aux, NULL, /* readdir */ aux_poll, aux_ioctl, NULL, /* mmap */ open_aux, NULL, /* flush */ release_aux, NULL, fasync_aux, }; /* * Initialize driver. */ static struct miscdevice psaux_mouse = { PSMOUSE_MINOR, "psaux", &psaux_fops }; static int __init psaux_init(void) { if (!detect_auxiliary_port()) return -EIO; misc_register(&psaux_mouse); queue = (struct aux_queue *) kmalloc(sizeof(*queue), GFP_KERNEL); memset(queue, 0, sizeof(*queue)); queue->head = queue->tail = 0; queue->proc_list = NULL; #ifdef INITIALIZE_MOUSE kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable Aux. */ aux_write_ack(AUX_SET_SAMPLE); aux_write_ack(100); /* 100 samples/sec */ aux_write_ack(AUX_SET_RES); aux_write_ack(3); /* 8 counts per mm */ aux_write_ack(AUX_SET_SCALE21); /* 2:1 scaling */ #endif /* INITIALIZE_MOUSE */ kbd_write_command(KBD_CCMD_MOUSE_DISABLE); /* Disable aux device. */ kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints. */ aux_last_write = jiffies; return 0; } #endif /* CONFIG_PSMOUSE */ tpconfig-3.1.3.orig/pc_keyb.c.2.4.2.patched0100644001167100001440000007701707271106105016627 0ustar cphusers/* * linux/drivers/char/pc_keyb.c * * Separation of the PC low-level part by Geert Uytterhoeven, May 1997 * See keyboard.c for the whole history. * * Major cleanup by Martin Mares, May 1997 * * Combined the keyboard and PS/2 mouse handling into one file, * because they share the same hardware. * Johan Myreen 1998-10-08. * * Code fixes to handle mouse ACKs properly. * C. Scott Ananian 1999-01-29. * * More work to handle mouse ACKs properly. (Modified version of * patch by Julian Bradfield .) * Chris Hanson 2000-12-11. * * Implement exclusive access mechanism for aux device. * This permits grabbing the mouse away from the X server, * which is needed by fancy mice that have configurable features. * Chris Hanson 2000-10-30. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* Some configuration switches are present in the include file... */ #include /* Simple translation table for the SysRq keys */ #ifdef CONFIG_MAGIC_SYSRQ unsigned char pckbd_sysrq_xlate[128] = "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */ "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */ "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */ "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */ "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */ "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */ "\r\000/"; /* 0x60 - 0x6f */ #endif static void kbd_write_command_w(int data); static void kbd_write_output_w(int data); #ifdef CONFIG_PSMOUSE static void aux_write_ack(int val); static void __aux_write_ack(int val); static void aux_kill_fasync(struct fasync_struct **fasync, int sig, int band); static int aux_release_ioctl(struct file *file); #endif static spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED; static unsigned char handle_kbd_event(void); /* used only by send_data - set by keyboard_interrupt */ static volatile unsigned char reply_expected; static volatile unsigned char acknowledge; static volatile unsigned char resend; #if defined CONFIG_PSMOUSE /* * PS/2 Auxiliary Device */ static int __init psaux_init(void); #define AUX_RECONNECT 170 /* scancode when ps2 device is plugged (back) in */ static struct aux_queue *queue; /* Mouse data buffer. */ static int aux_count; /* Used when we (as opposed to user programs using the aux device) send commands to the mouse. */ static unsigned char mouse_reply_expected; /* Used to make sure we have received an ACK from the byte last written to the mouse before writing another. */ static unsigned long mouse_ack_pending; static wait_queue_head_t mouse_ack_wait; /* How many jiffies to wait for the mouse to respond to a command with an ACK. 25 msec is the maximum allowed delay for the hardware to respond. We round that up to the nearest jiffy. */ #define MOUSE_ACK_TIMEOUT ((25 * HZ + 999) / 1000) #define AUX_INTS_OFF (KBD_MODE_KCC | KBD_MODE_DISABLE_MOUSE | KBD_MODE_SYS | KBD_MODE_KBD_INT) #define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT) #define MAX_RETRIES 60 /* some aux operations take long time*/ /* Support for exclusive access to the AUX device. */ static struct file *aux_exclusive; static wait_queue_head_t aux_exclusive_wait; static unsigned long aux_last_write; #define AUX_GRAB _IO('M', 1) #define AUX_RELEASE _IO('M', 2) #endif /* CONFIG_PSMOUSE */ /* * Wait for keyboard controller input buffer to drain. * * Don't use 'jiffies' so that we don't depend on * interrupts.. * * Quote from PS/2 System Reference Manual: * * "Address hex 0060 and address hex 0064 should be written only when * the input-buffer-full bit and output-buffer-full bit in the * Controller Status register are set 0." */ static void kb_wait(void) { unsigned long timeout = KBC_TIMEOUT; do { /* * "handle_kbd_event()" will handle any incoming events * while we wait - keypresses or mouse movement. */ unsigned char status = handle_kbd_event(); if (! (status & KBD_STAT_IBF)) return; mdelay(1); timeout--; } while (timeout); #ifdef KBD_REPORT_TIMEOUTS printk(KERN_WARNING "Keyboard timed out[1]\n"); #endif } /* * Translation of escaped scancodes to keycodes. * This is now user-settable. * The keycodes 1-88,96-111,119 are fairly standard, and * should probably not be changed - changing might confuse X. * X also interprets scancode 0x5d (KEY_Begin). * * For 1-88 keycode equals scancode. */ #define E0_KPENTER 96 #define E0_RCTRL 97 #define E0_KPSLASH 98 #define E0_PRSCR 99 #define E0_RALT 100 #define E0_BREAK 101 /* (control-pause) */ #define E0_HOME 102 #define E0_UP 103 #define E0_PGUP 104 #define E0_LEFT 105 #define E0_RIGHT 106 #define E0_END 107 #define E0_DOWN 108 #define E0_PGDN 109 #define E0_INS 110 #define E0_DEL 111 #define E1_PAUSE 119 /* * The keycodes below are randomly located in 89-95,112-118,120-127. * They could be thrown away (and all occurrences below replaced by 0), * but that would force many users to use the `setkeycodes' utility, where * they needed not before. It does not matter that there are duplicates, as * long as no duplication occurs for any single keyboard. */ #define SC_LIM 89 #define FOCUS_PF1 85 /* actual code! */ #define FOCUS_PF2 89 #define FOCUS_PF3 90 #define FOCUS_PF4 91 #define FOCUS_PF5 92 #define FOCUS_PF6 93 #define FOCUS_PF7 94 #define FOCUS_PF8 95 #define FOCUS_PF9 120 #define FOCUS_PF10 121 #define FOCUS_PF11 122 #define FOCUS_PF12 123 #define JAP_86 124 /* tfj@olivia.ping.dk: * The four keys are located over the numeric keypad, and are * labelled A1-A4. It's an rc930 keyboard, from * Regnecentralen/RC International, Now ICL. * Scancodes: 59, 5a, 5b, 5c. */ #define RGN1 124 #define RGN2 125 #define RGN3 126 #define RGN4 127 static unsigned char high_keys[128 - SC_LIM] = { RGN1, RGN2, RGN3, RGN4, 0, 0, 0, /* 0x59-0x5f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */ 0, 0, 0, 0, 0, FOCUS_PF11, 0, FOCUS_PF12, /* 0x68-0x6f */ 0, 0, 0, FOCUS_PF2, FOCUS_PF9, 0, 0, FOCUS_PF3, /* 0x70-0x77 */ FOCUS_PF4, FOCUS_PF5, FOCUS_PF6, FOCUS_PF7, /* 0x78-0x7b */ FOCUS_PF8, JAP_86, FOCUS_PF10, 0 /* 0x7c-0x7f */ }; /* BTC */ #define E0_MACRO 112 /* LK450 */ #define E0_F13 113 #define E0_F14 114 #define E0_HELP 115 #define E0_DO 116 #define E0_F17 117 #define E0_KPMINPLUS 118 /* * My OmniKey generates e0 4c for the "OMNI" key and the * right alt key does nada. [kkoller@nyx10.cs.du.edu] */ #define E0_OK 124 /* * New microsoft keyboard is rumoured to have * e0 5b (left window button), e0 5c (right window button), * e0 5d (menu button). [or: LBANNER, RBANNER, RMENU] * [or: Windows_L, Windows_R, TaskMan] */ #define E0_MSLW 125 #define E0_MSRW 126 #define E0_MSTM 127 static unsigned char e0_keys[128] = { 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00-0x07 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x08-0x0f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10-0x17 */ 0, 0, 0, 0, E0_KPENTER, E0_RCTRL, 0, 0, /* 0x18-0x1f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20-0x27 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x28-0x2f */ 0, 0, 0, 0, 0, E0_KPSLASH, 0, E0_PRSCR, /* 0x30-0x37 */ E0_RALT, 0, 0, 0, 0, E0_F13, E0_F14, E0_HELP, /* 0x38-0x3f */ E0_DO, E0_F17, 0, 0, 0, 0, E0_BREAK, E0_HOME, /* 0x40-0x47 */ E0_UP, E0_PGUP, 0, E0_LEFT, E0_OK, E0_RIGHT, E0_KPMINPLUS, E0_END,/* 0x48-0x4f */ E0_DOWN, E0_PGDN, E0_INS, E0_DEL, 0, 0, 0, 0, /* 0x50-0x57 */ 0, 0, 0, E0_MSLW, E0_MSRW, E0_MSTM, 0, 0, /* 0x58-0x5f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */ 0, 0, 0, 0, 0, 0, 0, E0_MACRO, /* 0x68-0x6f */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77 */ 0, 0, 0, 0, 0, 0, 0, 0 /* 0x78-0x7f */ }; int pckbd_setkeycode(unsigned int scancode, unsigned int keycode) { if (scancode < SC_LIM || scancode > 255 || keycode > 127) return -EINVAL; if (scancode < 128) high_keys[scancode - SC_LIM] = keycode; else e0_keys[scancode - 128] = keycode; return 0; } int pckbd_getkeycode(unsigned int scancode) { return (scancode < SC_LIM || scancode > 255) ? -EINVAL : (scancode < 128) ? high_keys[scancode - SC_LIM] : e0_keys[scancode - 128]; } static int do_acknowledge(unsigned char scancode) { if (reply_expected) { /* Unfortunately, we must recognise these codes only if we know they * are known to be valid (i.e., after sending a command), because there * are some brain-damaged keyboards (yes, FOCUS 9000 again) which have * keys with such codes :( */ if (scancode == KBD_REPLY_ACK) { acknowledge = 1; reply_expected = 0; return 0; } else if (scancode == KBD_REPLY_RESEND) { resend = 1; reply_expected = 0; return 0; } /* Should not happen... */ #if 0 printk(KERN_DEBUG "keyboard reply expected - got %02x\n", scancode); #endif } return 1; } int pckbd_translate(unsigned char scancode, unsigned char *keycode, char raw_mode) { static int prev_scancode; /* special prefix scancodes.. */ if (scancode == 0xe0 || scancode == 0xe1) { prev_scancode = scancode; return 0; } /* 0xFF is sent by a few keyboards, ignore it. 0x00 is error */ if (scancode == 0x00 || scancode == 0xff) { prev_scancode = 0; return 0; } scancode &= 0x7f; if (prev_scancode) { /* * usually it will be 0xe0, but a Pause key generates * e1 1d 45 e1 9d c5 when pressed, and nothing when released */ if (prev_scancode != 0xe0) { if (prev_scancode == 0xe1 && scancode == 0x1d) { prev_scancode = 0x100; return 0; } else if (prev_scancode == 0x100 && scancode == 0x45) { *keycode = E1_PAUSE; prev_scancode = 0; } else { #ifdef KBD_REPORT_UNKN if (!raw_mode) printk(KERN_INFO "keyboard: unknown e1 escape sequence\n"); #endif prev_scancode = 0; return 0; } } else { prev_scancode = 0; /* * The keyboard maintains its own internal caps lock and * num lock statuses. In caps lock mode E0 AA precedes make * code and E0 2A follows break code. In num lock mode, * E0 2A precedes make code and E0 AA follows break code. * We do our own book-keeping, so we will just ignore these. */ /* * For my keyboard there is no caps lock mode, but there are * both Shift-L and Shift-R modes. The former mode generates * E0 2A / E0 AA pairs, the latter E0 B6 / E0 36 pairs. * So, we should also ignore the latter. - aeb@cwi.nl */ if (scancode == 0x2a || scancode == 0x36) return 0; if (e0_keys[scancode]) *keycode = e0_keys[scancode]; else { #ifdef KBD_REPORT_UNKN if (!raw_mode) printk(KERN_INFO "keyboard: unknown scancode e0 %02x\n", scancode); #endif return 0; } } } else if (scancode >= SC_LIM) { /* This happens with the FOCUS 9000 keyboard Its keys PF1..PF12 are reported to generate 55 73 77 78 79 7a 7b 7c 74 7e 6d 6f Moreover, unless repeated, they do not generate key-down events, so we have to zero up_flag below */ /* Also, Japanese 86/106 keyboards are reported to generate 0x73 and 0x7d for \ - and \ | respectively. */ /* Also, some Brazilian keyboard is reported to produce 0x73 and 0x7e for \ ? and KP-dot, respectively. */ *keycode = high_keys[scancode - SC_LIM]; if (!*keycode) { if (!raw_mode) { #ifdef KBD_REPORT_UNKN printk(KERN_INFO "keyboard: unrecognized scancode (%02x)" " - ignored\n", scancode); #endif } return 0; } } else *keycode = scancode; return 1; } char pckbd_unexpected_up(unsigned char keycode) { /* unexpected, but this can happen: maybe this was a key release for a FOCUS 9000 PF key; if we want to see it, we have to clear up_flag */ if (keycode >= SC_LIM || keycode == 85) return 0; else return 0200; } static inline void handle_mouse_event(unsigned char scancode) { #ifdef CONFIG_PSMOUSE if (mouse_ack_pending) { /* It needn't actually be an ack, it could be an echo; but every byte sent to the mouse results in a byte back. */ wake_up_interruptible(&mouse_ack_wait); mouse_ack_pending = 0; } if (mouse_reply_expected) { if (scancode == AUX_ACK) { mouse_reply_expected--; return; } mouse_reply_expected = 0; } else if(scancode == AUX_RECONNECT){ queue->head = queue->tail = 0; /* Flush input queue */ __aux_write_ack(AUX_ENABLE_DEV); /* ping the mouse :) */ return; } add_mouse_randomness(scancode); if (aux_count) { int head = queue->head; queue->buf[head] = scancode; head = (head + 1) & (AUX_BUF_SIZE-1); if (head != queue->tail) { queue->head = head; aux_kill_fasync(&queue->fasync, SIGIO, POLL_IN); wake_up_interruptible(&queue->proc_list); } } #endif } static unsigned char kbd_exists = 1; static inline void handle_keyboard_event(unsigned char scancode) { #ifdef CONFIG_VT kbd_exists = 1; if (do_acknowledge(scancode)) handle_scancode(scancode, !(scancode & 0x80)); #endif tasklet_schedule(&keyboard_tasklet); } /* * This reads the keyboard status port, and does the * appropriate action. * * It requires that we hold the keyboard controller * spinlock. */ static unsigned char handle_kbd_event(void) { unsigned char status = kbd_read_status(); unsigned int work = 10000; while ((--work > 0) && (status & KBD_STAT_OBF)) { unsigned char scancode; scancode = kbd_read_input(); /* Error bytes must be ignored to make the Synaptics touchpads compaq use work */ #if 1 /* Ignore error bytes */ if (!(status & (KBD_STAT_GTO | KBD_STAT_PERR))) #endif { if (status & KBD_STAT_MOUSE_OBF) handle_mouse_event(scancode); else handle_keyboard_event(scancode); } status = kbd_read_status(); } if (!work) printk(KERN_ERR "pc_keyb: controller jammed (0x%02X).\n", status); return status; } static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs) { #ifdef CONFIG_VT kbd_pt_regs = regs; #endif spin_lock_irq(&kbd_controller_lock); handle_kbd_event(); spin_unlock_irq(&kbd_controller_lock); } /* * send_data sends a character to the keyboard and waits * for an acknowledge, possibly retrying if asked to. Returns * the success status. * * Don't use 'jiffies', so that we don't depend on interrupts */ static int send_data(unsigned char data) { int retries = 3; do { unsigned long timeout = KBD_TIMEOUT; acknowledge = 0; /* Set by interrupt routine on receipt of ACK. */ resend = 0; reply_expected = 1; kbd_write_output_w(data); for (;;) { if (acknowledge) return 1; if (resend) break; mdelay(1); if (!--timeout) { return 0; } } } while (retries-- > 0); #ifdef KBD_REPORT_TIMEOUTS printk(KERN_WARNING "keyboard: Too many NACKs -- noisy kbd cable?\n"); #endif return 0; } void pckbd_leds(unsigned char leds) { if (kbd_exists && (!send_data(KBD_CMD_SET_LEDS) || !send_data(leds))) { send_data(KBD_CMD_ENABLE); /* re-enable kbd if any errors */ kbd_exists = 0; } } /* * In case we run on a non-x86 hardware we need to initialize both the * keyboard controller and the keyboard. On a x86, the BIOS will * already have initialized them. * * Some x86 BIOSes do not correctly initialize the keyboard, so the * "kbd-reset" command line options can be given to force a reset. * [Ranger] */ #ifdef __i386__ int kbd_startup_reset __initdata = 0; #else int kbd_startup_reset __initdata = 1; #endif /* for "kbd-reset" cmdline param */ static int __init kbd_reset_setup(char *str) { kbd_startup_reset = 1; return 1; } __setup("kbd-reset", kbd_reset_setup); #define KBD_NO_DATA (-1) /* No data */ #define KBD_BAD_DATA (-2) /* Parity or other error */ static int __init kbd_read_data(void) { int retval = KBD_NO_DATA; unsigned char status; status = kbd_read_status(); if (status & KBD_STAT_OBF) { unsigned char data = kbd_read_input(); retval = data; if (status & (KBD_STAT_GTO | KBD_STAT_PERR)) retval = KBD_BAD_DATA; } return retval; } static void __init kbd_clear_input(void) { int maxread = 100; /* Random number */ do { if (kbd_read_data() == KBD_NO_DATA) break; } while (--maxread); } static int __init kbd_wait_for_input(void) { long timeout = KBD_INIT_TIMEOUT; do { int retval = kbd_read_data(); if (retval >= 0) return retval; mdelay(1); } while (--timeout); return -1; } static void kbd_write_command_w(int data) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); kbd_write_command(data); spin_unlock_irqrestore(&kbd_controller_lock, flags); } static void kbd_write_output_w(int data) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); kbd_write_output(data); spin_unlock_irqrestore(&kbd_controller_lock, flags); } #if defined CONFIG_PSMOUSE static void kbd_write_cmd(int cmd) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); kbd_write_command(KBD_CCMD_WRITE_MODE); kb_wait(); kbd_write_output(cmd); spin_unlock_irqrestore(&kbd_controller_lock, flags); } #endif /* CONFIG_PSMOUSE */ static char * __init initialize_kbd(void) { int status; /* * Test the keyboard interface. * This seems to be the only way to get it going. * If the test is successful a x55 is placed in the input buffer. */ kbd_write_command_w(KBD_CCMD_SELF_TEST); if (kbd_wait_for_input() != 0x55) return "Keyboard failed self test"; /* * Perform a keyboard interface test. This causes the controller * to test the keyboard clock and data lines. The results of the * test are placed in the input buffer. */ kbd_write_command_w(KBD_CCMD_KBD_TEST); if (kbd_wait_for_input() != 0x00) return "Keyboard interface failed self test"; /* * Enable the keyboard by allowing the keyboard clock to run. */ kbd_write_command_w(KBD_CCMD_KBD_ENABLE); /* * Reset keyboard. If the read times out * then the assumption is that no keyboard is * plugged into the machine. * This defaults the keyboard to scan-code set 2. * * Set up to try again if the keyboard asks for RESEND. */ do { kbd_write_output_w(KBD_CMD_RESET); status = kbd_wait_for_input(); if (status == KBD_REPLY_ACK) break; if (status != KBD_REPLY_RESEND) return "Keyboard reset failed, no ACK"; } while (1); if (kbd_wait_for_input() != KBD_REPLY_POR) return "Keyboard reset failed, no POR"; /* * Set keyboard controller mode. During this, the keyboard should be * in the disabled state. * * Set up to try again if the keyboard asks for RESEND. */ do { kbd_write_output_w(KBD_CMD_DISABLE); status = kbd_wait_for_input(); if (status == KBD_REPLY_ACK) break; if (status != KBD_REPLY_RESEND) return "Disable keyboard: no ACK"; } while (1); kbd_write_command_w(KBD_CCMD_WRITE_MODE); kbd_write_output_w(KBD_MODE_KBD_INT | KBD_MODE_SYS | KBD_MODE_DISABLE_MOUSE | KBD_MODE_KCC); /* ibm powerpc portables need this to use scan-code set 1 -- Cort */ kbd_write_command_w(KBD_CCMD_READ_MODE); if (!(kbd_wait_for_input() & KBD_MODE_KCC)) { /* * If the controller does not support conversion, * Set the keyboard to scan-code set 1. */ kbd_write_output_w(0xF0); kbd_wait_for_input(); kbd_write_output_w(0x01); kbd_wait_for_input(); } kbd_write_output_w(KBD_CMD_ENABLE); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Enable keyboard: no ACK"; /* * Finally, set the typematic rate to maximum. */ kbd_write_output_w(KBD_CMD_SET_RATE); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Set rate: no ACK"; kbd_write_output_w(0x00); if (kbd_wait_for_input() != KBD_REPLY_ACK) return "Set rate: no ACK"; return NULL; } void __init pckbd_init_hw(void) { kbd_request_region(); /* Flush any pending input. */ kbd_clear_input(); if (kbd_startup_reset) { char *msg = initialize_kbd(); if (msg) printk(KERN_WARNING "initialize_kbd: %s\n", msg); } #if defined CONFIG_PSMOUSE psaux_init(); #endif /* Ok, finally allocate the IRQ, and off we go.. */ kbd_request_irq(keyboard_interrupt); } #if defined CONFIG_PSMOUSE /* * Check if this is a dual port controller. */ static int __init detect_auxiliary_port(void) { unsigned long flags; int loops = 10; int retval = 0; /* Check if the BIOS detected a device on the auxiliary port. */ if (aux_device_present == 0xaa) return 1; spin_lock_irqsave(&kbd_controller_lock, flags); /* Put the value 0x5A in the output buffer using the "Write * Auxiliary Device Output Buffer" command (0xD3). Poll the * Status Register for a while to see if the value really * turns up in the Data Register. If the KBD_STAT_MOUSE_OBF * bit is also set to 1 in the Status Register, we assume this * controller has an Auxiliary Port (a.k.a. Mouse Port). */ kb_wait(); kbd_write_command(KBD_CCMD_WRITE_AUX_OBUF); kb_wait(); kbd_write_output(0x5a); /* 0x5a is a random dummy value. */ do { unsigned char status = kbd_read_status(); if (status & KBD_STAT_OBF) { (void) kbd_read_input(); if (status & KBD_STAT_MOUSE_OBF) { printk(KERN_INFO "Detected PS/2 Mouse Port.\n"); retval = 1; } break; } mdelay(1); } while (--loops); spin_unlock_irqrestore(&kbd_controller_lock, flags); return retval; } static void mouse_ack_timeout(unsigned long data) { wake_up_interruptible(&mouse_ack_wait); } /* * Send a byte to the mouse. */ static int aux_write_dev(int val, int dont_block, int handle_ack) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); kb_wait(); /* If we haven't yet received the ACK from the previous write, we must wait for it. */ if (mouse_ack_pending) { unsigned long expires; struct timer_list timer; DECLARE_WAITQUEUE(wait, current); if (dont_block) { spin_unlock_irqrestore(&kbd_controller_lock, flags); return -EAGAIN; } expires = mouse_ack_pending + MOUSE_ACK_TIMEOUT; if (jiffies >= expires) goto timed_out; add_wait_queue(&mouse_ack_wait, &wait); init_timer (&timer); timer.expires = expires; timer.data = 0; timer.function = mouse_ack_timeout; add_timer(&timer); do { current->state = TASK_INTERRUPTIBLE; spin_unlock_irqrestore(&kbd_controller_lock, flags); schedule(); spin_lock_irqsave(&kbd_controller_lock, flags); } while (mouse_ack_pending && jiffies < expires && !signal_pending(current)); del_timer(&timer); remove_wait_queue(&mouse_ack_wait, &wait); if (mouse_ack_pending && jiffies >= expires) { timed_out: printk(KERN_WARNING "mouse ack timeout\n"); mouse_ack_pending = 0; spin_unlock_irqrestore(&kbd_controller_lock, flags); return -EIO; } if (signal_pending(current)) { spin_unlock_irqrestore(&kbd_controller_lock, flags); return -ERESTARTSYS; } } kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); mouse_ack_pending = jiffies; if (handle_ack) /* We will deal with the ACK ourselves. */ mouse_reply_expected++; spin_unlock_irqrestore(&kbd_controller_lock, flags); return 0; } /* * Send a byte to the mouse & handle returned ack */ static void __aux_write_ack(int val) { kb_wait(); kbd_write_command(KBD_CCMD_WRITE_MOUSE); kb_wait(); kbd_write_output(val); mouse_ack_pending = jiffies; /* We will deal with the ACK ourselves. */ mouse_reply_expected++; kb_wait(); } #ifdef INITIALIZE_MOUSE static void aux_write_ack(int val) { unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); __aux_write_ack(val); spin_unlock_irqrestore(&kbd_controller_lock, flags); } #endif /* INITIALIZE_MOUSE */ static void aux_kill_fasync(struct fasync_struct **fasync, int sig, int band) { struct fasync_struct * fp; struct fasync_struct fa; fp = *fasync; /* If someone has grabbed the AUX device, send signal only to them and not to other processes. We could do this directly if send_sigio was exported, but since it isn't we must synthesize a "struct fasync_struct" to pass to kill_fasync. */ if (aux_exclusive) { while (1) { if (!fp) return; if (fp->fa_file == aux_exclusive) break; fp = fp->fa_next; } fa = (*fp); fa.fa_next = NULL; fp = &fa; } kill_fasync(&fp, sig, band); } static unsigned char get_from_queue(void) { unsigned char result; unsigned long flags; spin_lock_irqsave(&kbd_controller_lock, flags); result = queue->buf[queue->tail]; queue->tail = (queue->tail + 1) & (AUX_BUF_SIZE-1); spin_unlock_irqrestore(&kbd_controller_lock, flags); return result; } static inline int queue_empty(void) { return queue->head == queue->tail; } static int fasync_aux(int fd, struct file *filp, int on) { int retval; retval = fasync_helper(fd, filp, on, &queue->fasync); if (retval < 0) return retval; return 0; } /* * Random magic cookie for the aux device */ #define AUX_DEV ((void *)queue) static int release_aux(struct inode * inode, struct file * file) { lock_kernel(); fasync_aux(-1, file, 0); if (aux_exclusive == file) aux_release_ioctl(file); if (--aux_count) { unlock_kernel(); return 0; } kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints */ kbd_write_command_w(KBD_CCMD_MOUSE_DISABLE); aux_free_irq(AUX_DEV); unlock_kernel(); return 0; } /* * Install interrupt handler. * Enable auxiliary device. */ static int open_aux(struct inode * inode, struct file * file) { if (aux_count++) { return 0; } queue->head = queue->tail = 0; /* Flush input queue */ if (aux_request_irq(keyboard_interrupt, AUX_DEV)) { aux_count--; return -EBUSY; } kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable the auxiliary port on controller. */ aux_write_dev(AUX_ENABLE_DEV, 0, 1); /* Enable aux device */ kbd_write_cmd(AUX_INTS_ON); /* Enable controller ints */ mdelay(2); /* Ensure we follow the kbc access delay rules.. */ send_data(KBD_CMD_ENABLE); /* try to workaround toshiba4030cdt problem */ return 0; } /* * Implement exclusive access mechanism. */ #define AUX_ACCESS_ALLOWED(file) (!aux_exclusive || aux_exclusive == (file)) static ssize_t aux_wait_for_access(struct file * file) { DECLARE_WAITQUEUE(wait, current); if (!AUX_ACCESS_ALLOWED(file)) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; add_wait_queue(&aux_exclusive_wait, &wait); do { current->state = TASK_INTERRUPTIBLE; schedule(); } while (!AUX_ACCESS_ALLOWED(file) && !signal_pending(current)); remove_wait_queue(&aux_exclusive_wait, &wait); } if (!AUX_ACCESS_ALLOWED(file)) return -ERESTARTSYS; return 0; } /* * Put bytes from input queue to buffer. */ static ssize_t read_aux(struct file * file, char * buffer, size_t count, loff_t *ppos) { DECLARE_WAITQUEUE(wait, current); ssize_t i = count; unsigned char c; ssize_t retval; retval = aux_wait_for_access(file); if (retval < 0) return retval; if (queue_empty()) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; add_wait_queue(&queue->proc_list, &wait); repeat: set_current_state(TASK_INTERRUPTIBLE); if (queue_empty() && !signal_pending(current)) { schedule(); goto repeat; } current->state = TASK_RUNNING; remove_wait_queue(&queue->proc_list, &wait); } while (i > 0 && !queue_empty()) { c = get_from_queue(); put_user(c, buffer++); i--; } if (count-i) { file->f_dentry->d_inode->i_atime = CURRENT_TIME; return count-i; } if (signal_pending(current)) return -ERESTARTSYS; return 0; } /* * Write to the aux device. */ static ssize_t write_aux(struct file * file, const char * buffer, size_t count, loff_t *ppos) { ssize_t retval; retval = aux_wait_for_access(file); if (retval < 0) return retval; if (count) { ssize_t written = 0; retval = -EIO; if (count > 32) count = 32; /* Limit to 32 bytes. */ do { char c; int write_result; get_user(c, buffer++); write_result = aux_write_dev(c, file->f_flags & O_NONBLOCK, 0); if (write_result) { retval = write_result; break; } written++; } while (--count); if (written) { retval = written; file->f_dentry->d_inode->i_mtime = CURRENT_TIME; aux_last_write = jiffies; } } return retval; } /* No kernel lock held - fine */ static unsigned int aux_poll(struct file *file, poll_table * wait) { poll_wait(file, &queue->proc_list, wait); if (AUX_ACCESS_ALLOWED(file) && !queue_empty()) return POLLIN | POLLRDNORM; return 0; } /* Wait this long after last write to mouse before allowing AUX_GRAB to happen. This ensures that any outstanding mouse command is completed. The ACK from the command is supposed to arrive in 25 msec, and each subsequent status bytes are supposed to arrive within 20 msec, so a command with 5 status bytes (I don't know any this long) might take 125 msec. Fudge this up a bit to account for additional delay introduced by bus locking. */ #define AUX_GRAB_MIN_TIME (aux_last_write + (((200 * HZ) + 500) / 1000)) #define AUX_GRAB_ALLOWED (aux_exclusive == 0 && (jiffies >= AUX_GRAB_MIN_TIME)) static void aux_grab_timeout(unsigned long data) { wake_up_interruptible(&aux_exclusive_wait); } static int aux_grab_ioctl(struct file *file) { DECLARE_WAITQUEUE(wait, current); struct timer_list timer; if (aux_exclusive == file) return -EINVAL; if (!AUX_GRAB_ALLOWED) { if (file->f_flags & O_NONBLOCK) return -EAGAIN; init_timer (&timer); timer.expires = AUX_GRAB_MIN_TIME; timer.data = 0; timer.function = aux_grab_timeout; add_wait_queue(&aux_exclusive_wait, &wait); add_timer(&timer); do { current->state = TASK_INTERRUPTIBLE; schedule(); } while (!AUX_GRAB_ALLOWED && !signal_pending(current)); del_timer(&timer); remove_wait_queue(&aux_exclusive_wait, &wait); } if (!AUX_GRAB_ALLOWED) return -ERESTARTSYS; aux_exclusive = file; return 0; } static int aux_release_ioctl(struct file *file) { if (aux_exclusive != file) return -ENOENT; aux_exclusive = 0; wake_up_interruptible(&aux_exclusive_wait); return 0; } static int aux_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { switch (cmd) { case AUX_GRAB: return aux_grab_ioctl(file); case AUX_RELEASE: return aux_release_ioctl(file); default: return -EINVAL; } } struct file_operations psaux_fops = { read: read_aux, write: write_aux, poll: aux_poll, ioctl: aux_ioctl, open: open_aux, release: release_aux, fasync: fasync_aux, }; /* * Initialize driver. */ static struct miscdevice psaux_mouse = { PSMOUSE_MINOR, "psaux", &psaux_fops }; static int __init psaux_init(void) { if (!detect_auxiliary_port()) return -EIO; misc_register(&psaux_mouse); queue = (struct aux_queue *) kmalloc(sizeof(*queue), GFP_KERNEL); memset(queue, 0, sizeof(*queue)); queue->head = queue->tail = 0; init_waitqueue_head(&queue->proc_list); init_waitqueue_head(&mouse_ack_wait); init_waitqueue_head(&aux_exclusive_wait); #ifdef INITIALIZE_MOUSE kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); /* Enable Aux. */ aux_write_ack(AUX_SET_SAMPLE); aux_write_ack(100); /* 100 samples/sec */ aux_write_ack(AUX_SET_RES); aux_write_ack(3); /* 8 counts per mm */ aux_write_ack(AUX_SET_SCALE21); /* 2:1 scaling */ #endif /* INITIALIZE_MOUSE */ kbd_write_command(KBD_CCMD_MOUSE_DISABLE); /* Disable aux device. */ kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints. */ aux_last_write = jiffies; return 0; } #endif /* CONFIG_PSMOUSE */ tpconfig-3.1.3.orig/tpconfig-3.1.3.spec0100644001167100001440000000156507435470456016135 0ustar cphusersName: tpconfig Version: 3.1.3 Release: 1 Summary: Synaptics/ALPS TouchPad configuration tool Copyright: GPL Group: Utilities/System Packager: Bruce Kall Source: tpconfig-3.1.3.tar.gz %description This is a configuration tool for the Synaptics TouchPad and the ALPS Glidepad/Stickpointer used on many PC laptops. %prep %setup %build sh ./configure --prefix=/usr make %install make install # install docs by hand rm -rf /usr/doc/tpconfig-3.1.3 mkdir -p /usr/doc/tpconfig-3.1.3 cp -ar README AUTHORS COPYING INSTALL NEWS ChangeLog /usr/doc/tpconfig-3.1.3 cp -ar touchpad /etc/rc.d/init.d %post rm -f /etc/rc.d/rc5.d/S84touchpad rm -f /etc/rc.d/rc3.d/S84touchpad ln -s /etc/rc.d/init.d/touchpad /etc/rc.d/rc5.d/S84touchpad ln -s /etc/rc.d/init.d/touchpad /etc/rc.d/rc3.d/S84touchpad %files %doc /usr/doc/tpconfig-3.1.3 /usr/bin/tpconfig /etc/rc.d/init.d/touchpad