retitle 237984 Should be able to use /dev/misc/psaux
tags patch
thanks

Hi,

So far I have not been succesful using tpconfig under 2.6 system.

Since assertion error is sometimes needs to be skipped under debug and
DEBUG LEVEL = 1 should be less noisy, I improved patch further.

Since 0x03 for b2 value is true for 2.6 kernels with my synaptic equiped
machine, I added it to synaptic.c while making it easy to remove if it
is wrong.

I also made all HEX output to use %#02x for consistency.

(I still do not like mixed byte and char type in code but left them as
is)

Now i option and a A s options are documented too.

Here we go.

diff -Nru tpconfig-3.1.3-orig/ALPS.c tpconfig-3.1.3/ALPS.c
--- tpconfig-3.1.3-orig/ALPS.c  2005-04-10 01:06:03.000000000 +0200
+++ tpconfig-3.1.3/ALPS.c       2005-04-10 02:07:28.000000000 +0200
@@ -80,8 +80,8 @@
   putbyte(fd,c);
   }
 c = 0xe9;
-if(DEBUG_LEVEL)
-  printf("Writing [%x]\n",c);
+if(DEBUG_LEVEL > DEBUG_LOW)
+  printf("Writing [%#02x]\n",c);
 num_written = ps2_write(fd,&c,1);
 if(num_written != 1)
   {
@@ -97,10 +97,10 @@
 
 /* resend enable command for xmission of external mouse data */
 c = 0xf4;
-if(DEBUG_LEVEL)
+if(DEBUG_LEVEL > DEBUG_LOW)
   {
   printf("Resending Enable command\n");
-  printf("Writing [%x]\n",c);
+  printf("Writing [%#02x]\n",c);
   }
 num_written = ps2_write(fd,&c,1);
 if(num_written != 1)
@@ -108,12 +108,12 @@
   fprintf(stderr,"Error writing byte\n");
   return(0);
   }
-if(DEBUG_LEVEL)
+if(DEBUG_LEVEL > DEBUG_LOW)
   {
-  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]);
+  printf("Response 0 [%#02x]\n",status[0]);
+  printf("Response 1 [%#02x]\n",status[1]);
+  printf("Response 2 [%#02x]\n",status[2]);
+  printf("Response 3 [%#02x]\n",status[3]);
   }
 return(!ERROR);
 } /* ALPS_status */
@@ -124,7 +124,7 @@
 int tap_on = TRUE;
 int error;
 
-if(DEBUG_LEVEL)
+if(DEBUG_LEVEL > DEBUG_LOW)
   printf("\n\nChecking Whether ALPS Tap status is enabled or disabled\n");
 
 
@@ -148,7 +148,7 @@
   }
 
 
-if(DEBUG_LEVEL)
+if(DEBUG_LEVEL > DEBUG_LOW)
   {
   if(tap_on)
     printf("Done Checking Status of Tap Enabled/Disable, Tap is ON \n");
@@ -165,8 +165,8 @@
 int num_written;
 
 c = 0xff;
-if(DEBUG_LEVEL)
-  printf("\nWriting Reset [%x], Reading Nothing\n",(int)c);
+if(DEBUG_LEVEL > DEBUG_LOW)
+  printf("\nWriting Reset [%#02x], Reading Nothing\n",(int)c);
 num_written = ps2_write(fd,&c,1);
 if(num_written != 1)
   {
@@ -182,7 +182,7 @@
 { /* ALPS_SP_tap */
 byte c;
 int i;
-if(DEBUG_LEVEL)
+if(DEBUG_LEVEL > DEBUG_LOW)
   {
   if(enable)
     printf("\n\nEnabling SP tap\n");
@@ -203,7 +203,7 @@
   c = 0x0a;
 
 putbyte(fd,c);
-if(DEBUG_LEVEL)
+if(DEBUG_LEVEL > DEBUG_LOW)
   printf("Done Enabling/Disabling SP tap\n");
 return(!ERROR);
 } /* ALPS_SP_tap */
@@ -213,7 +213,7 @@
 { /* ALPS_through_mode */
 byte c;
 int i;
-if(DEBUG_LEVEL)
+if(DEBUG_LEVEL > DEBUG_LOW)
   {
   if(set)
     printf("\n\nEnabling ALPS_through_mode\n");
@@ -235,7 +235,7 @@
 
 /* We may receive 3 more bytes, ignore them */
 tcflush(fd,TCIOFLUSH);
-if(DEBUG_LEVEL)
+if(DEBUG_LEVEL > DEBUG_LOW)
   {
   if(set)
     printf("Done Enabling ALPS_through_mode\n\n\n");
@@ -255,7 +255,7 @@
 int num_written;
 int error;
 
-if(DEBUG_LEVEL)
+if(DEBUG_LEVEL > DEBUG_LOW)
   {
   if(enable)
     printf("\n\nEnabling GP tap\n");
@@ -274,22 +274,22 @@
   }
 
 c = 0xE9;
-if(DEBUG_LEVEL)
-  printf("Writing Initial [%x]\n",(int)c);
+if(DEBUG_LEVEL > DEBUG_LOW)
+  printf("Writing Initial [%#02x]\n",(int)c);
 num_written = ps2_write(fd,&c,1);
 num_read = ps2_read(fd,response,4);
-if(DEBUG_LEVEL)
+if(DEBUG_LEVEL > DEBUG_LOW)
   {
   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]);
+    printf("-----> Invalid response from Alps Glidepad/Glidepoint [%#02x] 
\n",(int)response[0]);
     return(ERROR);
     }
-if(DEBUG_LEVEL)
-  printf("Current Settings [%x] [%x] 
[%x]\n",response[1],response[2],response[3]);
+if(DEBUG_LEVEL > DEBUG_LOW)
+  printf("Current Settings [%#02x] [%#02x] 
[%#02x]\n",response[1],response[2],response[3]);
 
 for(i = 0;i < 2;i++)
   {
@@ -299,13 +299,13 @@
 
 if(enable)
   {
-  if(DEBUG_LEVEL)
+  if(DEBUG_LEVEL > DEBUG_LOW)
     printf("Enabling Tap\n");
   c = 0xF3;
   }
 else
   {
-  if(DEBUG_LEVEL)
+  if(DEBUG_LEVEL > DEBUG_LOW)
     printf("Disabling Tap\n");
   c = 0xE8;
   }
@@ -372,8 +372,8 @@
   putbyte(fd,c);
   }
 c = 0xe9;
-if(DEBUG_LEVEL)
-  printf("Writing Initial [%x] in is_ALPS\n",(int)c);
+if(DEBUG_LEVEL > DEBUG_LOW)
+  printf("Writing Initial [%#02x] in is_ALPS\n",(int)c);
 num_written = ps2_write(fd,&c,1);
 if(num_written != 1)
   {
@@ -388,7 +388,7 @@
   }
 
 if(DEBUG_LEVEL)
-  printf("ALPS Configuration Info 
[%2x][%2x][%2x]\n",response[1],response[2],response[3]);
+  printf("ALPS Configuration Info 
[%#02x][%#02x][%#02x]\n",response[1],response[2],response[3]);
 
 return_value = 0;
 for(i = 0;i < NUM_SINGLES;i++)
@@ -426,7 +426,7 @@
   { 
   if(!tap_on)
     { /* reset tap_on to off since we just had to do a reset */
-    if(DEBUG_LEVEL)
+    if(DEBUG_LEVEL > DEBUG_LOW)
       printf("Turning ALPS Tap Back OFF\n");
     if(touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT)
       {
@@ -494,11 +494,11 @@
                 else
                   {
                  mode = optarg[0]-'0';
-                  if(DEBUG_LEVEL)
+                  if(DEBUG_LEVEL > DEBUG_LOW)
                     printf("User Asked to set Tap mode to [%d]\n",mode);
                   if(mode > 0)
                     {
-                    if(DEBUG_LEVEL)
+                    if(DEBUG_LEVEL > DEBUG_LOW)
                       printf("Turning ALPS Tap ON\n");
                     if(touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT)
                       {
@@ -510,7 +510,7 @@
                     }
                   else
                     { /* disable tap mode */
-                    if(DEBUG_LEVEL)
+                    if(DEBUG_LEVEL > DEBUG_LOW)
                       printf("Turning ALPS Tap OFF\n");
                     if(touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT)
                       {
diff -Nru tpconfig-3.1.3-orig/debian/README.Debian 
tpconfig-3.1.3/debian/README.Debian
--- tpconfig-3.1.3-orig/debian/README.Debian    2005-04-10 01:06:03.000000000 
+0200
+++ tpconfig-3.1.3/debian/README.Debian 2005-04-08 02:30:18.000000000 +0200
@@ -7,14 +7,18 @@
 debian installer RC3, March 2005).  You should use a kernel newer than
 2.6.11.  There may still be more fixes even after this kernel version.
 
-The device name /dev/psaux is hard coded to tpconfig currently.  This
-means tpconfig will not work under the deprecated devfs system in
-which /dev/misc/psaux is used as the PS/2 mouse device name, or under
-unusual udev setups in which devfs-like device names are used.
-Classic device naming or normal udev naming should not cause any
-problem.
+If you want to use mouse device name other than /dev/psaux, you must give
+its device name as the initial command line argument before normal options.
+This should enable device names such /dev/misc/psaux etc. and hopefully
+should support devices like USB touch pads.
 
-USB touch pads aren't currently supported.
+ $ sudo tpconfig /dev/misc/psaux -i
 
-  Osamu Aoki <[EMAIL PROTECTED]>  Wed, 30 Mar 2005 23:47:18 +0200
+If you face difficulty running tpconfig, please use tpconfig with its 
+initial arguments to be number 1 to 3 to get diagonostic info.
+
+ $ sudo tpconfig 3 -i
+
+  Osamu Aoki <[EMAIL PROTECTED]>  Fri, 08 Apr 2005 02:27:19 +0200
   Chris Hanson <[EMAIL PROTECTED]>  Thu, 31 Mar 2005 15:14:52 -0500
+
diff -Nru tpconfig-3.1.3-orig/debian/changelog tpconfig-3.1.3/debian/changelog
--- tpconfig-3.1.3-orig/debian/changelog        2005-04-10 01:06:03.000000000 
+0200
+++ tpconfig-3.1.3/debian/changelog     2005-04-08 02:15:17.000000000 +0200
@@ -1,3 +1,10 @@
+tpconfig (3.1.3-6.1) unstable; urgency=low
+
+  * Make target device and debug mode configurable from command
+    line arguments. (closes: Bug#237984, #139640)
+
+ -- Osamu Aoki <[EMAIL PROTECTED]>  Fri,  8 Apr 2005 00:19:54 +0200
+
 tpconfig (3.1.3-6) unstable; urgency=low
 
   From Osamu Aoki <[EMAIL PROTECTED]>:
diff -Nru tpconfig-3.1.3-orig/debian/tpconfig.1 tpconfig-3.1.3/debian/tpconfig.1
--- tpconfig-3.1.3-orig/debian/tpconfig.1       2005-04-10 01:06:03.000000000 
+0200
+++ tpconfig-3.1.3/debian/tpconfig.1    2005-04-10 01:53:29.000000000 +0200
@@ -1,10 +1,10 @@
-.TH "tpconfig" "1" "3.1.2" "" ""
+.TH "tpconfig" "1" "3.1.3" "" ""
 .SH "NAME"
 .LP 
 tpconfig \- Configure touchpad devices
 .SH "SYNOPSIS"
 .LP 
-\fBtpconfig\fP [ \fIOPTIONS\fP ]
+\fBtpconfig\fP [123saAi] [/dev/mouse] [ \fIOPTIONS\fP ]
 .br 
 .br
 .SH "DESCRIPTION"
@@ -15,6 +15,30 @@
 .LP
 Options for all touchpads:
 .TP
+\fB1\fP
+Debug level 1
+.TP
+\fB2\fP
+Debug level 2
+.TP
+\fB3\fP
+Debug level 3
+.TP
+\fBs\fP
+Force device to be Synaptics Touchpad.
+.TP
+\fBa\fP
+Force device to be ALPS GlidePad.
+.TP
+\fBA\fP
+Force device to be ALPS Dual StickPoint/Glidepad.
+.TP
+\fBi\fP
+Ignore assert result.
+.TP
+\fB/dev/mouse\fP
+Force input mouse device to be /dev/mouse . [default=/dev/psaux]
+.TP
 \fB--help\fP
 Display a help summary and exit.
 .TP
diff -Nru tpconfig-3.1.3-orig/synaptics.c tpconfig-3.1.3/synaptics.c
--- tpconfig-3.1.3-orig/synaptics.c     2005-04-10 01:06:03.000000000 +0200
+++ tpconfig-3.1.3/synaptics.c  2005-04-10 03:37:37.000000000 +0200
@@ -278,7 +278,7 @@
 static void
 set_modes (int fd, unsigned int modes)
 {
-  if (DEBUG_LEVEL)
+  if (DEBUG_LEVEL > DEBUG_LOW)
     fprintf (stderr, "[set modes: %#02x]\n", modes);
   if (single_mode_byte)
     {
@@ -314,7 +314,13 @@
 {
   byte b1, b2, b3;
   status_rqst (fd, STP_QRY_IDENTIFY, &b1, &b2, &b3);
+#if 1
+  /* 2.6 kernel return 0x03 instead */
+  if (!IGNORE_ASSERT) assert (b2 == 0x47 || b2 == 0x03);
+#endif
+#if 0
   assert (b2 == 0x47);
+#endif
   if (version_major) (*version_major) = (b3 & 0x0F);
   if (version_minor) (*version_minor) = b1;
   if (model_code)    (*model_code)    = ((b3 & 0xF0) >> 4);
@@ -326,10 +332,16 @@
   byte b1, b2, b3;
   byte b4, b5, b6;
   status_rqst (fd, STP_QRY_READ_MODES, &b1, &b2, &b3);
+#if 1
+  /* 2.6 kernel return 0x03 instead */
+  if (!IGNORE_ASSERT) assert (b2 == 0x47 || b2 == 0x03);
+#endif
+#if 0
   assert (b2 == 0x47);
+#endif
   if (single_mode_byte)
     {
-      assert (b1 == 0x3B);
+      if (!IGNORE_ASSERT) assert (b1 == 0x3B);
       return b3;
     }
   else
@@ -338,7 +350,13 @@
       if (fw_version < QUAD_MODE_BYTE)
        {
          status_rqst (fd, STP_QRY_READ_CAPS, &b4, &b5, &b6);
+#if 1
+          /* 2.6 kernel return 0x03 instead */
+          if (!IGNORE_ASSERT) assert (b5 == 0x47 || b5 == 0x03);
+#endif
+#if 0
          assert (b5 == 0x47);
+#endif
          return ((unsigned int) b1 << 24) | ((unsigned int) b3 << 16) |
            ((unsigned int) b4 << 8) | (unsigned int) b6;
        }
@@ -351,7 +369,13 @@
 {
   byte b1, b2, b3;
   status_rqst (fd, STP_QRY_READ_CAPS, &b1, &b2, &b3);
+#if 1
+  /* 2.6 kernel return 0x03 instead */
+  if (!IGNORE_ASSERT) assert (b2 == 0x47 || b2 == 0x03);
+#endif
+#if 0
   assert (b2 == 0x47);
+#endif
   return ((unsigned int) b1 << 8) | (unsigned int) b3;
 }
 
@@ -388,7 +412,7 @@
 {
   byte b1, b2, b3;
   status_rqst (fd, STP_QRY_READ_RES, &b1, &b2, &b3);
-  assert ((b2 & 0x80) != 0);
+  if (!IGNORE_ASSERT) assert ((b2 & 0x80) != 0);
   (*xres) = b1;
   (*yres) = b3;
 }
@@ -409,7 +433,14 @@
       b3 = getbyte (fd);
     }
 #endif
+#if 1
+  /* 2.6 kernel return 0x03 instead */
+  retval = (b2 == 0x47 || b2 == 0x03);
+#endif
+#if 0
   retval = (b2 == 0x47);
+#endif
+  retval = (b2 == 0x47 || b2 == 0x03); /* 2.6 kernel return 0x03 instead */
   if (retval)
     {
       fw_version_major = (b3 & 0x0F);
diff -Nru tpconfig-3.1.3-orig/tpconfig.c tpconfig-3.1.3/tpconfig.c
--- tpconfig-3.1.3-orig/tpconfig.c      2005-04-10 01:06:03.000000000 +0200
+++ tpconfig-3.1.3/tpconfig.c   2005-04-10 01:55:54.000000000 +0200
@@ -9,8 +9,11 @@
 
 
 /*$Log: tpconfig.c,v $
+ *Revision 2.13.1  2005-04-08T00:21:38 CEST osamu
+ *Added DEBUG and device name
+ *
  *Revision 2.13  2002/02/22 20:33:11  bruce
- *Aded for Mode 3 and Mode 4 options.
+ *Added for Mode 3 and Mode 4 options.
  *
  *Revision 2.12  2000/11/15 15:37:50  bruce
  *Added back in copyright call().
@@ -114,7 +117,11 @@
 extern int is_ALPS(int fd);
 extern int is_Synaptics(int fd);
 
+/* global flags */
 int DEBUG_LEVEL;
+int FORCE_DEVICE;
+int IGNORE_ASSERT;
+char mousedev[128] = "/dev/psaux";
 int silent;
 float firmware_rev;
 char single_mode_byte;
@@ -126,28 +133,32 @@
 int status;
 if (*fd<0)
   {
-  *fd = open("/dev/psaux", O_RDWR|O_NDELAY);
+  if (DEBUG_LEVEL) printf ("Probing mouse port at '%s'\n", mousedev);
+  *fd = open(mousedev, O_RDWR|O_NDELAY);
   if (*fd < 0)
-    fatal("Could not open PS/2 Port [/dev/psaux]");
+    fatal("Could not open PS/2 PortPort.");
 #ifdef __linux
   /* If AUX_GRAB kernel patch present, use it. */
+  if (DEBUG_LEVEL) printf ("Grabing mouse port at '%s'\n", mousedev);
   while (ioctl (*fd, AUX_GRAB, 0) < 0)
     {
       if (errno == ENOTTY)
        break;
       if (errno != EAGAIN)
        {
-         perror ("/dev/psaux");
+         perror (mousedev);
          fatal ("Unable to get exclusive access to PS/2 Port.");
          exit (1);
        }
     }
 #endif
   tcflush(*fd,TCIOFLUSH);
+  if (DEBUG_LEVEL) printf ("Trying Synaptics detection.\n");
   if (!is_Synaptics(*fd))
     {
+    if (DEBUG_LEVEL) printf ("Trying Alps detection.\n");
     status = is_ALPS(*fd);
-    if(status == 0)
+    if(status == 0 && FORCE_DEVICE == 0)
       {
       fatal("\n\nNo Synaptics or ALPS touchpad device found\n\n");
       exit(-1);
@@ -158,6 +169,21 @@
         printf ("Found ALPS GlidePad.\n");
       else if (touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT)
         printf ("Found ALPS Dual StickPoint/Glidepad.\n");
+      else if (FORCE_DEVICE == ALPS_GLIDEPAD)
+        {
+         touchpad_type = ALPS_GLIDEPAD; /*fake value*/
+          printf ("Force device to be ALPS GlidePad.\n");
+       }
+      else if (FORCE_DEVICE == ALPS_STICKPOINTER_AND_GLIDEPOINT)
+        {
+         touchpad_type = ALPS_STICKPOINTER_AND_GLIDEPOINT; /*fake value*/
+          printf ("Force device to be ALPS Dual StickPoint/Glidepad.\n");
+       }
+      else if (FORCE_DEVICE == SYNAPTICS_TOUCHPAD)
+        {
+         touchpad_type = SYNAPTICS_TOUCHPAD; /*fake value*/
+          printf ("Force device to be Synaptics Touchpad.\n");
+       }
       else
         {
         fprintf (stderr, "Undefined touchpad found[%d]\n", touchpad_type);
@@ -181,6 +207,7 @@
 int fd = -1;
 int c = 0;
 int option_index = 0;
+int i;
 
 silent = 0;
 firmware_rev = 0.0;
@@ -190,6 +217,8 @@
 #ifdef DEBUG
 DEBUG_LEVEL = DEBUG_LOW;
 #endif
+FORCE_DEVICE = FALSE;
+IGNORE_ASSERT = FALSE;
 
 if ((argc == 2)
     && (((strcmp ((argv[1]), "--version")) == 0)
@@ -208,6 +237,29 @@
     return (0);
   }
 
+while (argc > 0)
+  {
+    if (argv[1][0] == '1') DEBUG_LEVEL = 1;
+    else if (argv[1][0] == '2') DEBUG_LEVEL = 2;
+    else if (argv[1][0] == '3') DEBUG_LEVEL = 3;
+    else if (strncmp (argv[1], "/dev/", 5) == 0) strncpy (mousedev, argv[1], 
127);
+    /* Following will be undocumented options for Debug */
+    else if (argv[1][0] == '0') DEBUG_LEVEL = 0;
+    else if (argv[1][0] == 's') FORCE_DEVICE = SYNAPTICS_TOUCHPAD;
+    else if (argv[1][0] == 'a') FORCE_DEVICE = ALPS_GLIDEPAD;
+    else if (argv[1][0] == 'A') FORCE_DEVICE = 
ALPS_STICKPOINTER_AND_GLIDEPOINT;
+    else if (argv[1][0] == 'z') FORCE_DEVICE = FALSE;
+    else if (argv[1][0] == 'i') IGNORE_ASSERT = TRUE;
+    else break; /* - found, exit while-loop */
+    /* shift */
+    if (DEBUG_LEVEL) printf ("DEBUG: %i, mousedev='%s'\n", DEBUG_LEVEL, 
mousedev);
+    argc--;
+    for (i=1; i<argc; i++) 
+      {
+        argv[i]=argv[i+1];
+      }
+  }
+
 /* Open file descriptor and determine if we are connected to a touchpad */
 init_fd(&fd);
 
diff -Nru tpconfig-3.1.3-orig/tpconfig.h tpconfig-3.1.3/tpconfig.h
--- tpconfig-3.1.3-orig/tpconfig.h      2000-12-01 16:29:47.000000000 +0100
+++ tpconfig-3.1.3/tpconfig.h   2005-04-10 01:57:18.000000000 +0200
@@ -73,6 +73,7 @@
 typedef unsigned char byte;
 
 extern int DEBUG_LEVEL;
+extern int IGNORE_ASSERT;
 extern int silent;
 extern float firmware_rev;
 extern char single_mode_byte;
diff -Nru tpconfig-3.1.3-orig/utils.c tpconfig-3.1.3/utils.c
--- tpconfig-3.1.3-orig/utils.c 2005-04-10 01:06:03.000000000 +0200
+++ tpconfig-3.1.3/utils.c      2005-04-10 01:42:11.000000000 +0200
@@ -98,7 +98,7 @@
   {
     fprintf (stderr, "PS2_write:");
     for (i = 0; i < num_bytes; i++)
-      fprintf (stderr, " %#2x", *(buffer + i));
+      fprintf (stderr, " %#02x", *(buffer + i));
     fprintf (stderr, "\n");
   }
 
@@ -218,6 +218,6 @@
     fprintf (stderr, "Read %#02x, expected %#02x in %s.\n", b, expected, what);
 #if 0
   /* Upstream recommends commenting this out for 2.6 kernels.  */
-  assert (b == expected);
+  if (!IGNORE_ASSERT) assert (&& b == expected);
 #endif
 }

Reply via email to