Re: update pms driver

2010-12-06 Thread Nicholas Marriott
Looks and works fine for me, ok nicm

Cheers


On Tue, Nov 30, 2010 at 09:33:41PM +0500, Alexandr Shadchin wrote:
 On Mon, Nov 29, 2010 at 10:08:22PM +, Nicholas Marriott wrote:
  
  Well, I don't use it so I don't have strong feelings about it, but it
  does work for PS/2 mice and it seems that it would be useful for anyone
  using wsmoused (although there probably aren't many people).
  
  Would it be so hard to leave it, and if it is really not needed remove
  it entirely as a separate change?
  
  Otherwise aside from the char - signed char change I mentioned the diff
  is fine with me.
  
 
 1) fix char - signed char
 2) Returned WSMOUSEIO_SRES
 
 -- 
 Alexandr Shadchin
 
 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.14
 diff -u -p -r1.14 pms.c
 --- pms.c 15 Nov 2010 20:25:31 -  1.14
 +++ pms.c 30 Nov 2010 16:26:20 -
 @@ -40,6 +40,20 @@
  
  #define DEVNAME(sc)  ((sc)-sc_dev.dv_xname)
  
 +struct pms_softc;
 +
 +struct pms_protocol {
 + int type;
 +#define PMS_STANDARD 0
 +#define PMS_INTELLI  1
 + int packetsize;
 + int (*enable)(struct pms_softc *);
 + int (*ioctl)(struct pms_softc *, u_long, caddr_t, int, struct proc *);
 + int (*sync)(struct pms_softc *, int);
 + void (*proc)(struct pms_softc *);
 + void (*disable)(struct pms_softc *);
 +};
 +
  struct pms_softc {   /* driver status information */
   struct device sc_dev;
  
 @@ -52,14 +66,38 @@ struct pms_softc {/* driver status inf
  #define PMS_STATE_SUSPENDED  2
  
   int poll;
 - int intelli;
   int inputstate;
 - u_int buttons, oldbuttons;  /* mouse button status */
 - signed char dx, dy;
 +
 + struct pms_protocol protocol;
 +
 + unsigned char packet[8];
  
   struct device *sc_wsmousedev;
  };
  
 +#define PMS_BUTTON1DOWN  0x0001  /* left */
 +#define PMS_BUTTON2DOWN  0x0002  /* middle */
 +#define PMS_BUTTON3DOWN  0x0004  /* right */
 +
 +static const u_int butmap[8] = {
 + 0,
 + PMS_BUTTON1DOWN,
 + PMS_BUTTON3DOWN,
 + PMS_BUTTON1DOWN | PMS_BUTTON3DOWN,
 + PMS_BUTTON2DOWN,
 + PMS_BUTTON1DOWN | PMS_BUTTON2DOWN,
 + PMS_BUTTON2DOWN | PMS_BUTTON3DOWN,
 + PMS_BUTTON1DOWN | PMS_BUTTON2DOWN | PMS_BUTTON3DOWN
 +};
 +
 +/* PS/2 mouse data packet */
 +#define PMS_PS2_BUTTONSMASK  0x07
 +#define PMS_PS2_BUTTON1  0x01/* left */
 +#define PMS_PS2_BUTTON2  0x04/* middle */
 +#define PMS_PS2_BUTTON3  0x02/* right */
 +#define PMS_PS2_XNEG 0x10
 +#define PMS_PS2_YNEG 0x20
 +
  int  pmsprobe(struct device *, void *, void *);
  void pmsattach(struct device *, struct device *, void *);
  int  pmsactivate(struct device *, int);
 @@ -81,7 +119,11 @@ int   pms_reset(struct pms_softc *);
  int  pms_dev_enable(struct pms_softc *);
  int  pms_dev_disable(struct pms_softc *);
  
 -int  pms_setintellimode(struct pms_softc *sc);
 +int  pms_enable_intelli(struct pms_softc *);
 +
 +int  pms_ioctl_mouse(struct pms_softc *, u_long, caddr_t, int, struct proc 
 *);
 +int  pms_sync_mouse(struct pms_softc *, int);
 +void pms_proc_mouse(struct pms_softc *);
  
  struct cfattach pms_ca = {
   sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
 @@ -98,6 +140,27 @@ const struct wsmouse_accessops pms_acces
   pms_disable,
  };
  
 +const struct pms_protocol pms_mouse[] = {
 + /* Generic PS/2 mouse */
 + {
 + PMS_STANDARD, 3,
 + NULL,
 + pms_ioctl_mouse,
 + pms_sync_mouse,
 + pms_proc_mouse,
 + NULL
 + },
 + /* Microsoft IntelliMouse */
 + {
 + PMS_INTELLI, 4,
 + pms_enable_intelli,
 + pms_ioctl_mouse,
 + pms_sync_mouse,
 + pms_proc_mouse,
 + NULL
 + }
 +};
 +
  int
  pms_cmd(struct pms_softc *sc, u_char *cmd, int len, u_char *resp, int 
 resplen)
  {
 @@ -208,7 +271,7 @@ pms_dev_disable(struct pms_softc *sc)
  }
  
  int
 -pms_setintellimode(struct pms_softc *sc)
 +pms_enable_intelli(struct pms_softc *sc)
  {
   static const int rates[] = {200, 100, 80};
   u_char resp;
 @@ -224,6 +287,78 @@ pms_setintellimode(struct pms_softc *sc)
  }
  
  int
 +pms_ioctl_mouse(struct pms_softc *sc, u_long cmd, caddr_t data, int flag,
 +struct proc *p)
 +{
 + int i;
 +
 + switch (cmd) {
 + case WSMOUSEIO_GTYPE:
 + *(u_int *)data = WSMOUSE_TYPE_PS2;
 + break;
 + case WSMOUSEIO_SRES:
 + i = ((int) *(u_int *)data - 12) / 25;
 + /* valid values are {0,1,2,3} */
 + if (i  0)
 + i = 0;
 + if (i  3)
 + i = 3;
 +
 + if (pms_set_resolution(sc, i))
 + printf(%s: SET_RES command error\n, DEVNAME(sc));
 +

Re: update pms driver

2010-12-01 Thread Mark Kettenis
 Date: Tue, 30 Nov 2010 21:33:41 +0500
 From: Alexandr Shadchin alexandr.shadc...@gmail.com
 
 On Mon, Nov 29, 2010 at 10:08:22PM +, Nicholas Marriott wrote:
  
  Well, I don't use it so I don't have strong feelings about it, but it
  does work for PS/2 mice and it seems that it would be useful for anyone
  using wsmoused (although there probably aren't many people).
  
  Would it be so hard to leave it, and if it is really not needed remove
  it entirely as a separate change?
  
  Otherwise aside from the char - signed char change I mentioned the diff
  is fine with me.
  
 
 1) fix char - signed char
 2) Returned WSMOUSEIO_SRES
 
 -- 
 Alexandr Shadchin
 
 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.14
 diff -u -p -r1.14 pms.c
 --- pms.c 15 Nov 2010 20:25:31 -  1.14
 +++ pms.c 30 Nov 2010 16:26:20 -
 @@ -52,14 +66,38 @@ struct pms_softc {/* driver status inf
  #define PMS_STATE_SUSPENDED  2
  
   int poll;
 - int intelli;
   int inputstate;
 - u_int buttons, oldbuttons;  /* mouse button status */
 - signed char dx, dy;
 +
 + struct pms_protocol protocol;
 +
 + unsigned char packet[8];

Small, and perhaps even irrelevant nit: we tend to use 'u_char'
instead of 'unsigned char' in BSD-specific interfaces.  Saves a few
bytes in the source file and is consistent with the usage of 'u_int'
in this file.

Feel free to ignore.



Re: update pms driver

2010-11-30 Thread Kevin Chadwick
On Mon, 29 Nov 2010 22:08:22 +
Nicholas Marriott nicholas.marri...@gmail.com wrote:

 Well, I don't use it so I don't have strong feelings about it, but it
 does work for PS/2 mice and it seems that it would be useful for anyone
 using wsmoused (although there probably aren't many people).

I use xset m, that isn't affected is it? and so is an alternative,
though maybe it could affect someones current setups?



Re: update pms driver

2010-11-30 Thread Alexandr Shadchin
On Mon, Nov 29, 2010 at 10:08:22PM +, Nicholas Marriott wrote:
 
 Well, I don't use it so I don't have strong feelings about it, but it
 does work for PS/2 mice and it seems that it would be useful for anyone
 using wsmoused (although there probably aren't many people).
 
 Would it be so hard to leave it, and if it is really not needed remove
 it entirely as a separate change?
 
 Otherwise aside from the char - signed char change I mentioned the diff
 is fine with me.
 

1) fix char - signed char
2) Returned WSMOUSEIO_SRES

-- 
Alexandr Shadchin

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.14
diff -u -p -r1.14 pms.c
--- pms.c   15 Nov 2010 20:25:31 -  1.14
+++ pms.c   30 Nov 2010 16:26:20 -
@@ -40,6 +40,20 @@
 
 #define DEVNAME(sc)((sc)-sc_dev.dv_xname)
 
+struct pms_softc;
+
+struct pms_protocol {
+   int type;
+#define PMS_STANDARD   0
+#define PMS_INTELLI1
+   int packetsize;
+   int (*enable)(struct pms_softc *);
+   int (*ioctl)(struct pms_softc *, u_long, caddr_t, int, struct proc *);
+   int (*sync)(struct pms_softc *, int);
+   void (*proc)(struct pms_softc *);
+   void (*disable)(struct pms_softc *);
+};
+
 struct pms_softc { /* driver status information */
struct device sc_dev;
 
@@ -52,14 +66,38 @@ struct pms_softc {  /* driver status inf
 #define PMS_STATE_SUSPENDED2
 
int poll;
-   int intelli;
int inputstate;
-   u_int buttons, oldbuttons;  /* mouse button status */
-   signed char dx, dy;
+
+   struct pms_protocol protocol;
+
+   unsigned char packet[8];
 
struct device *sc_wsmousedev;
 };
 
+#define PMS_BUTTON1DOWN0x0001  /* left */
+#define PMS_BUTTON2DOWN0x0002  /* middle */
+#define PMS_BUTTON3DOWN0x0004  /* right */
+
+static const u_int butmap[8] = {
+   0,
+   PMS_BUTTON1DOWN,
+   PMS_BUTTON3DOWN,
+   PMS_BUTTON1DOWN | PMS_BUTTON3DOWN,
+   PMS_BUTTON2DOWN,
+   PMS_BUTTON1DOWN | PMS_BUTTON2DOWN,
+   PMS_BUTTON2DOWN | PMS_BUTTON3DOWN,
+   PMS_BUTTON1DOWN | PMS_BUTTON2DOWN | PMS_BUTTON3DOWN
+};
+
+/* PS/2 mouse data packet */
+#define PMS_PS2_BUTTONSMASK0x07
+#define PMS_PS2_BUTTON10x01/* left */
+#define PMS_PS2_BUTTON20x04/* middle */
+#define PMS_PS2_BUTTON30x02/* right */
+#define PMS_PS2_XNEG   0x10
+#define PMS_PS2_YNEG   0x20
+
 intpmsprobe(struct device *, void *, void *);
 void   pmsattach(struct device *, struct device *, void *);
 intpmsactivate(struct device *, int);
@@ -81,7 +119,11 @@ int pms_reset(struct pms_softc *);
 intpms_dev_enable(struct pms_softc *);
 intpms_dev_disable(struct pms_softc *);
 
-intpms_setintellimode(struct pms_softc *sc);
+intpms_enable_intelli(struct pms_softc *);
+
+intpms_ioctl_mouse(struct pms_softc *, u_long, caddr_t, int, struct proc 
*);
+intpms_sync_mouse(struct pms_softc *, int);
+void   pms_proc_mouse(struct pms_softc *);
 
 struct cfattach pms_ca = {
sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
@@ -98,6 +140,27 @@ const struct wsmouse_accessops pms_acces
pms_disable,
 };
 
+const struct pms_protocol pms_mouse[] = {
+   /* Generic PS/2 mouse */
+   {
+   PMS_STANDARD, 3,
+   NULL,
+   pms_ioctl_mouse,
+   pms_sync_mouse,
+   pms_proc_mouse,
+   NULL
+   },
+   /* Microsoft IntelliMouse */
+   {
+   PMS_INTELLI, 4,
+   pms_enable_intelli,
+   pms_ioctl_mouse,
+   pms_sync_mouse,
+   pms_proc_mouse,
+   NULL
+   }
+};
+
 int
 pms_cmd(struct pms_softc *sc, u_char *cmd, int len, u_char *resp, int resplen)
 {
@@ -208,7 +271,7 @@ pms_dev_disable(struct pms_softc *sc)
 }
 
 int
-pms_setintellimode(struct pms_softc *sc)
+pms_enable_intelli(struct pms_softc *sc)
 {
static const int rates[] = {200, 100, 80};
u_char resp;
@@ -224,6 +287,78 @@ pms_setintellimode(struct pms_softc *sc)
 }
 
 int
+pms_ioctl_mouse(struct pms_softc *sc, u_long cmd, caddr_t data, int flag,
+struct proc *p)
+{
+   int i;
+
+   switch (cmd) {
+   case WSMOUSEIO_GTYPE:
+   *(u_int *)data = WSMOUSE_TYPE_PS2;
+   break;
+   case WSMOUSEIO_SRES:
+   i = ((int) *(u_int *)data - 12) / 25;
+   /* valid values are {0,1,2,3} */
+   if (i  0)
+   i = 0;
+   if (i  3)
+   i = 3;
+
+   if (pms_set_resolution(sc, i))
+   printf(%s: SET_RES command error\n, DEVNAME(sc));
+   break;
+   default:
+   return (-1);
+   }
+   return (0);
+}
+
+int
+pms_sync_mouse(struct 

Re: update pms driver

2010-11-29 Thread Alexandr Shadchin
On Mon, Nov 29, 2010 at 08:58:31PM +, Nicholas Marriott wrote:
 Hi
 
 Sorry for the delay again :-/.
 
 On Tue, Nov 23, 2010 at 04:10:29PM +0500, Alexandr Shadchin wrote:
  On Mon, Nov 22, 2010 at 09:44:14PM +, Nicholas Marriott wrote:
   Hi Alexandr
   
   This works fine for me with both with X and wsmoused.
   
   A few things:
   
   - Did you deliberately remove WSMOUSEIO_SRES?
   
  
  Yes. WSMOUSEIO_SRES in Xenocara not used, in src - only wsmoused and 
  wsconsctl,
  in drivers - only in pms. I think that now do not need WSMOUSEIO_SRES.
 
 Hmm, I don't understand. Are you saying nobody should use wsconsctl
 mouse.resolution anymore?
 

pms only works with WSMOUSEIO_SRES (this only ps\2 mouse)
Other drivers do not use WSMOUSEIO_SRES, so mouse.resolution irrelevant.
X reset mouse.resolution.
X open mouse - ... - pms_enable - pms_change_state -
 - pms_reset (set default resolution) :-)

Only wsmoused uses WSMOUSEIO_SRES (only ps\2 mouse).
Therefore, I am more than sure that nobody uses mouse.resolution

-- 
Alexandr Shadchin



Re: update pms driver

2010-11-29 Thread Nicholas Marriott
On Tue, Nov 30, 2010 at 02:43:48AM +0500, Alexandr Shadchin wrote:
 On Mon, Nov 29, 2010 at 08:58:31PM +, Nicholas Marriott wrote:
  Hi
  
  Sorry for the delay again :-/.
  
  On Tue, Nov 23, 2010 at 04:10:29PM +0500, Alexandr Shadchin wrote:
   On Mon, Nov 22, 2010 at 09:44:14PM +, Nicholas Marriott wrote:
Hi Alexandr

This works fine for me with both with X and wsmoused.

A few things:

- Did you deliberately remove WSMOUSEIO_SRES?

   
   Yes. WSMOUSEIO_SRES in Xenocara not used, in src - only wsmoused and 
   wsconsctl,
   in drivers - only in pms. I think that now do not need WSMOUSEIO_SRES.
  
  Hmm, I don't understand. Are you saying nobody should use wsconsctl
  mouse.resolution anymore?
  
 
 pms only works with WSMOUSEIO_SRES (this only ps\2 mouse)
 Other drivers do not use WSMOUSEIO_SRES, so mouse.resolution irrelevant.
 X reset mouse.resolution.
 X open mouse - ... - pms_enable - pms_change_state -
  - pms_reset (set default resolution) :-)
 
 Only wsmoused uses WSMOUSEIO_SRES (only ps\2 mouse).
 Therefore, I am more than sure that nobody uses mouse.resolution

Well, I don't use it so I don't have strong feelings about it, but it
does work for PS/2 mice and it seems that it would be useful for anyone
using wsmoused (although there probably aren't many people).

Would it be so hard to leave it, and if it is really not needed remove
it entirely as a separate change?

Otherwise aside from the char - signed char change I mentioned the diff
is fine with me.

 
 -- 
 Alexandr Shadchin



Re: update pms driver

2010-11-23 Thread Alexandr Shadchin
On Mon, Nov 22, 2010 at 09:44:14PM +, Nicholas Marriott wrote:
 Hi Alexandr
 
 This works fine for me with both with X and wsmoused.
 
 A few things:
 
 - Did you deliberately remove WSMOUSEIO_SRES?
 

Yes. WSMOUSEIO_SRES in Xenocara not used, in src - only wsmoused and wsconsctl,
in drivers - only in pms. I think that now do not need WSMOUSEIO_SRES.

 - Do we know what the XFree86 bug was and is it now fixed? Or do the
   PMS_PS2_XNEG/YNEG flags make the bounding unnecessary?
 

In current X.org this error is not observed. 

 - dz = (char)sc-packet[3]; -- shouldn't this be (signed char)?
 

Exactly. I'll correct.

 - So we now call wsmouse_input even if the buttons haven't changed. This
   is fine, right?
 

Previously wsmouse_input also called if the buttons were not changed,
but there were some increment x, y or z. I just removed the unnecessary
check for changes. If packet came from a mouse, it means that something has
changed, check is not needed.

 I take it the overall aim of this is to make it easier to add additional
 mice types in future?
 

Yes

-- 
Alexandr Shadchin



Re: update pms driver

2010-11-22 Thread Nicholas Marriott
Hi Alexandr

This works fine for me with both with X and wsmoused.

A few things:

- Did you deliberately remove WSMOUSEIO_SRES?

- Do we know what the XFree86 bug was and is it now fixed? Or do the
  PMS_PS2_XNEG/YNEG flags make the bounding unnecessary?

- dz = (char)sc-packet[3]; -- shouldn't this be (signed char)?

- So we now call wsmouse_input even if the buttons haven't changed. This
  is fine, right?

I take it the overall aim of this is to make it easier to add additional
mice types in future?

Cheers


On Thu, Nov 18, 2010 at 12:11:09AM +0500, Alexandr Shadchin wrote:
 Add a common interface for various devices
 
 -- 
 Alexandr Shadchin
 
 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.14
 diff -u -p -r1.14 pms.c
 --- pms.c 15 Nov 2010 20:25:31 -  1.14
 +++ pms.c 17 Nov 2010 18:23:35 -
 @@ -40,6 +40,20 @@
  
  #define DEVNAME(sc)  ((sc)-sc_dev.dv_xname)
  
 +struct pms_softc;
 +
 +struct pms_protocol {
 + int type;
 +#define PMS_STANDARD 0
 +#define PMS_INTELLI  1
 + int packetsize;
 + int (*enable)(struct pms_softc *);
 + int (*ioctl)(struct pms_softc *, u_long, caddr_t, int, struct proc *);
 + int (*sync)(struct pms_softc *, int);
 + void (*proc)(struct pms_softc *);
 + void (*disable)(struct pms_softc *);
 +};
 +
  struct pms_softc {   /* driver status information */
   struct device sc_dev;
  
 @@ -52,14 +66,38 @@ struct pms_softc {/* driver status inf
  #define PMS_STATE_SUSPENDED  2
  
   int poll;
 - int intelli;
   int inputstate;
 - u_int buttons, oldbuttons;  /* mouse button status */
 - signed char dx, dy;
 +
 + struct pms_protocol protocol;
 +
 + unsigned char packet[8];
  
   struct device *sc_wsmousedev;
  };
  
 +#define PMS_BUTTON1DOWN  0x0001  /* left */
 +#define PMS_BUTTON2DOWN  0x0002  /* middle */
 +#define PMS_BUTTON3DOWN  0x0004  /* right */
 +
 +static const u_int butmap[8] = {
 + 0,
 + PMS_BUTTON1DOWN,
 + PMS_BUTTON3DOWN,
 + PMS_BUTTON1DOWN | PMS_BUTTON3DOWN,
 + PMS_BUTTON2DOWN,
 + PMS_BUTTON1DOWN | PMS_BUTTON2DOWN,
 + PMS_BUTTON2DOWN | PMS_BUTTON3DOWN,
 + PMS_BUTTON1DOWN | PMS_BUTTON2DOWN | PMS_BUTTON3DOWN
 +};
 +
 +/* PS/2 mouse data packet */
 +#define PMS_PS2_BUTTONSMASK  0x07
 +#define PMS_PS2_BUTTON1  0x01/* left */
 +#define PMS_PS2_BUTTON2  0x04/* middle */
 +#define PMS_PS2_BUTTON3  0x02/* right */
 +#define PMS_PS2_XNEG 0x10
 +#define PMS_PS2_YNEG 0x20
 +
  int  pmsprobe(struct device *, void *, void *);
  void pmsattach(struct device *, struct device *, void *);
  int  pmsactivate(struct device *, int);
 @@ -81,7 +119,11 @@ int   pms_reset(struct pms_softc *);
  int  pms_dev_enable(struct pms_softc *);
  int  pms_dev_disable(struct pms_softc *);
  
 -int  pms_setintellimode(struct pms_softc *sc);
 +int  pms_enable_intelli(struct pms_softc *);
 +
 +int  pms_ioctl_mouse(struct pms_softc *, u_long, caddr_t, int, struct proc 
 *);
 +int  pms_sync_mouse(struct pms_softc *, int);
 +void pms_proc_mouse(struct pms_softc *);
  
  struct cfattach pms_ca = {
   sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
 @@ -98,6 +140,27 @@ const struct wsmouse_accessops pms_acces
   pms_disable,
  };
  
 +const struct pms_protocol pms_mouse[] = {
 + /* Generic PS/2 mouse */
 + {
 + PMS_STANDARD, 3,
 + NULL,
 + pms_ioctl_mouse,
 + pms_sync_mouse,
 + pms_proc_mouse,
 + NULL
 + },
 + /* Microsoft IntelliMouse */
 + {
 + PMS_INTELLI, 4,
 + pms_enable_intelli,
 + pms_ioctl_mouse,
 + pms_sync_mouse,
 + pms_proc_mouse,
 + NULL
 + }
 +};
 +
  int
  pms_cmd(struct pms_softc *sc, u_char *cmd, int len, u_char *resp, int 
 resplen)
  {
 @@ -208,7 +271,7 @@ pms_dev_disable(struct pms_softc *sc)
  }
  
  int
 -pms_setintellimode(struct pms_softc *sc)
 +pms_enable_intelli(struct pms_softc *sc)
  {
   static const int rates[] = {200, 100, 80};
   u_char resp;
 @@ -224,6 +287,65 @@ pms_setintellimode(struct pms_softc *sc)
  }
  
  int
 +pms_ioctl_mouse(struct pms_softc *sc, u_long cmd, caddr_t data, int flag,
 +struct proc *p)
 +{
 + switch (cmd) {
 + case WSMOUSEIO_GTYPE:
 + *(u_int *)data = WSMOUSE_TYPE_PS2;
 + break;
 + default:
 + return (-1);
 + }
 + return (0);
 +}
 +
 +int
 +pms_sync_mouse(struct pms_softc *sc, int data)
 +{
 + if (sc-inputstate != 0)
 + return (0);
 +
 + switch (sc-protocol.type) {
 + case PMS_STANDARD:
 + if ((data  0xc0) != 0)
 + return (-1);
 + break;
 + case PMS_INTELLI:
 + if ((data  0x08) != 0x08)
 + 

Re: update pms driver

2010-11-17 Thread Alexandr Shadchin
Add a common interface for various devices

-- 
Alexandr Shadchin

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.14
diff -u -p -r1.14 pms.c
--- pms.c   15 Nov 2010 20:25:31 -  1.14
+++ pms.c   17 Nov 2010 18:23:35 -
@@ -40,6 +40,20 @@
 
 #define DEVNAME(sc)((sc)-sc_dev.dv_xname)
 
+struct pms_softc;
+
+struct pms_protocol {
+   int type;
+#define PMS_STANDARD   0
+#define PMS_INTELLI1
+   int packetsize;
+   int (*enable)(struct pms_softc *);
+   int (*ioctl)(struct pms_softc *, u_long, caddr_t, int, struct proc *);
+   int (*sync)(struct pms_softc *, int);
+   void (*proc)(struct pms_softc *);
+   void (*disable)(struct pms_softc *);
+};
+
 struct pms_softc { /* driver status information */
struct device sc_dev;
 
@@ -52,14 +66,38 @@ struct pms_softc {  /* driver status inf
 #define PMS_STATE_SUSPENDED2
 
int poll;
-   int intelli;
int inputstate;
-   u_int buttons, oldbuttons;  /* mouse button status */
-   signed char dx, dy;
+
+   struct pms_protocol protocol;
+
+   unsigned char packet[8];
 
struct device *sc_wsmousedev;
 };
 
+#define PMS_BUTTON1DOWN0x0001  /* left */
+#define PMS_BUTTON2DOWN0x0002  /* middle */
+#define PMS_BUTTON3DOWN0x0004  /* right */
+
+static const u_int butmap[8] = {
+   0,
+   PMS_BUTTON1DOWN,
+   PMS_BUTTON3DOWN,
+   PMS_BUTTON1DOWN | PMS_BUTTON3DOWN,
+   PMS_BUTTON2DOWN,
+   PMS_BUTTON1DOWN | PMS_BUTTON2DOWN,
+   PMS_BUTTON2DOWN | PMS_BUTTON3DOWN,
+   PMS_BUTTON1DOWN | PMS_BUTTON2DOWN | PMS_BUTTON3DOWN
+};
+
+/* PS/2 mouse data packet */
+#define PMS_PS2_BUTTONSMASK0x07
+#define PMS_PS2_BUTTON10x01/* left */
+#define PMS_PS2_BUTTON20x04/* middle */
+#define PMS_PS2_BUTTON30x02/* right */
+#define PMS_PS2_XNEG   0x10
+#define PMS_PS2_YNEG   0x20
+
 intpmsprobe(struct device *, void *, void *);
 void   pmsattach(struct device *, struct device *, void *);
 intpmsactivate(struct device *, int);
@@ -81,7 +119,11 @@ int pms_reset(struct pms_softc *);
 intpms_dev_enable(struct pms_softc *);
 intpms_dev_disable(struct pms_softc *);
 
-intpms_setintellimode(struct pms_softc *sc);
+intpms_enable_intelli(struct pms_softc *);
+
+intpms_ioctl_mouse(struct pms_softc *, u_long, caddr_t, int, struct proc 
*);
+intpms_sync_mouse(struct pms_softc *, int);
+void   pms_proc_mouse(struct pms_softc *);
 
 struct cfattach pms_ca = {
sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
@@ -98,6 +140,27 @@ const struct wsmouse_accessops pms_acces
pms_disable,
 };
 
+const struct pms_protocol pms_mouse[] = {
+   /* Generic PS/2 mouse */
+   {
+   PMS_STANDARD, 3,
+   NULL,
+   pms_ioctl_mouse,
+   pms_sync_mouse,
+   pms_proc_mouse,
+   NULL
+   },
+   /* Microsoft IntelliMouse */
+   {
+   PMS_INTELLI, 4,
+   pms_enable_intelli,
+   pms_ioctl_mouse,
+   pms_sync_mouse,
+   pms_proc_mouse,
+   NULL
+   }
+};
+
 int
 pms_cmd(struct pms_softc *sc, u_char *cmd, int len, u_char *resp, int resplen)
 {
@@ -208,7 +271,7 @@ pms_dev_disable(struct pms_softc *sc)
 }
 
 int
-pms_setintellimode(struct pms_softc *sc)
+pms_enable_intelli(struct pms_softc *sc)
 {
static const int rates[] = {200, 100, 80};
u_char resp;
@@ -224,6 +287,65 @@ pms_setintellimode(struct pms_softc *sc)
 }
 
 int
+pms_ioctl_mouse(struct pms_softc *sc, u_long cmd, caddr_t data, int flag,
+struct proc *p)
+{
+   switch (cmd) {
+   case WSMOUSEIO_GTYPE:
+   *(u_int *)data = WSMOUSE_TYPE_PS2;
+   break;
+   default:
+   return (-1);
+   }
+   return (0);
+}
+
+int
+pms_sync_mouse(struct pms_softc *sc, int data)
+{
+   if (sc-inputstate != 0)
+   return (0);
+
+   switch (sc-protocol.type) {
+   case PMS_STANDARD:
+   if ((data  0xc0) != 0)
+   return (-1);
+   break;
+   case PMS_INTELLI:
+   if ((data  0x08) != 0x08)
+   return (-1);
+   break;
+   }
+
+   return (0);
+}
+
+void
+pms_proc_mouse(struct pms_softc *sc)
+{
+   u_int buttons;
+   int  dx, dy, dz;
+
+   buttons = butmap[sc-packet[0]  PMS_PS2_BUTTONSMASK];
+   dx = (sc-packet[0]  PMS_PS2_XNEG) ?
+   sc-packet[1] - 256 : sc-packet[1];
+   dy = (sc-packet[0]  PMS_PS2_YNEG) ?
+   sc-packet[2] - 256 : sc-packet[2];
+
+   switch (sc-protocol.type) {
+   case PMS_STANDARD:
+   dz = 0;
+   break;
+   case PMS_INTELLI:
+

Re: update pms driver

2010-11-06 Thread Alexandr Shadchin
1) Add macros DEVNAME
2) Add generic functions

-- 
Alexandr Shadchin

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.12
diff -u -p -r1.12 pms.c
--- pms.c   5 Nov 2010 16:10:49 -   1.12
+++ pms.c   6 Nov 2010 17:42:02 -
@@ -38,6 +38,8 @@
 #include dev/wscons/wsconsio.h
 #include dev/wscons/wsmousevar.h
 
+#define DEVNAME(sc)((sc)-sc_dev.dv_xname)
+
 struct pms_softc { /* driver status information */
struct device sc_dev;
 
@@ -74,6 +76,14 @@ int  pms_enable(void *);
 void   pms_disable(void *);
 
 intpms_cmd(struct pms_softc *, u_char *, int, u_char *, int);
+intpms_get_devid(struct pms_softc *, u_char *);
+intpms_get_status(struct pms_softc *, u_char *);
+intpms_set_rate(struct pms_softc *, int);
+intpms_set_resolution(struct pms_softc *, int);
+intpms_set_scaling(struct pms_softc *, int);
+intpms_reset(struct pms_softc *);
+intpms_dev_enable(struct pms_softc *);
+intpms_dev_disable(struct pms_softc *);
 
 intpms_setintellimode(struct pms_softc *sc);
 
@@ -96,23 +106,113 @@ pms_cmd(struct pms_softc *sc, u_char *cm
 }
 
 int
-pms_setintellimode(struct pms_softc *sc)
+pms_get_devid(struct pms_softc *sc, u_char *resp)
+{
+   u_char cmd[1];
+
+   cmd[0] = PMS_SEND_DEV_ID;
+   return (pms_cmd(sc, cmd, 1, resp, 1));
+}
+
+int
+pms_get_status(struct pms_softc *sc, u_char *resp)
 {
-   u_char cmd[2], resp[1];
-   int i, res;
-   static const u_char rates[] = {200, 100, 80};
+   u_char cmd[1];
+
+   cmd[0] = PMS_SEND_DEV_STATUS;
+   return (pms_cmd(sc, cmd, 1, resp, 3));
+}
+
+int
+pms_set_rate(struct pms_softc *sc, int value)
+{
+   u_char cmd[2];
 
cmd[0] = PMS_SET_SAMPLE;
-   for (i = 0; i  3; i++) {
-   cmd[1] = rates[i];
-   res = pms_cmd(sc, cmd, 2, NULL, 0);
-   if (res)
-   return (0);
+   cmd[1] = value;
+   return (pms_cmd(sc, cmd, 2, NULL, 0));
+}
+
+int
+pms_set_resolution(struct pms_softc *sc, int value)
+{
+   u_char cmd[2];
+
+   cmd[0] = PMS_SET_RES;
+   cmd[1] = value;
+   return (pms_cmd(sc, cmd, 2, NULL, 0));
+}
+
+int
+pms_set_scaling(struct pms_softc *sc, int scale)
+{
+   u_char cmd[1];
+
+   switch (scale) {
+   case 1:
+   default:
+   cmd[0] = PMS_SET_SCALE11;
+   break;
+   case 2:
+   cmd[0] = PMS_SET_SCALE21;
+   break;
}
+   return (pms_cmd(sc, cmd, 1, NULL, 0));
+}
 
-   cmd[0] = PMS_SEND_DEV_ID;
-   res = pms_cmd(sc, cmd, 1, resp, 1);
-   if (res || resp[0] != 3)
+int
+pms_reset(struct pms_softc *sc)
+{
+   u_char cmd[1], resp[2];
+   int res;
+
+   cmd[0] = PMS_RESET;
+   res = pms_cmd(sc, cmd, 1, resp, 2);
+#ifdef DEBUG
+   if (res || resp[0] != PMS_RSTDONE || resp[1] != 0)
+   printf(%s: reset error %d (response 0x%02x, type 0x%02x)\n,
+   DEVNAME(sc), res, resp[0], resp[1]);
+#endif
+   return (res);
+}
+
+int
+pms_dev_enable(struct pms_softc *sc)
+{
+   u_char cmd[1];
+   int res;
+
+   cmd[0] = PMS_DEV_ENABLE;
+   res = pms_cmd(sc, cmd, 1, NULL, 0);
+   if (res)
+   printf(%s: enable error\n, DEVNAME(sc));
+   return (res);
+}
+
+int
+pms_dev_disable(struct pms_softc *sc)
+{
+   u_char cmd[1];
+   int res;
+
+   cmd[0] = PMS_DEV_DISABLE;
+   res = pms_cmd(sc, cmd, 1, NULL, 0);
+   if (res)
+   printf(%s: disable error\n, DEVNAME(sc));
+   return (res);
+}
+
+int
+pms_setintellimode(struct pms_softc *sc)
+{
+   static const int rates[] = {200, 100, 80};
+   u_char resp;
+
+   if (pms_set_rate(sc, rates[0]) ||
+   pms_set_rate(sc, rates[1]) ||
+   pms_set_rate(sc, rates[2]) ||
+   pms_get_devid(sc, resp) ||
+   resp != 0x03)
return (0);
 
return (1);
@@ -158,7 +258,7 @@ pmsattach(struct device *parent, struct 
printf(\n);
 
pckbc_set_inputhandler(sc-sc_kbctag, sc-sc_kbcslot,
-  pmsinput, sc, sc-sc_dev.dv_xname);
+   pmsinput, sc, DEVNAME(sc));
 
a.accessops = pms_accessops;
a.accesscookie = sc;
@@ -197,9 +297,6 @@ pmsactivate(struct device *self, int act
 int
 pms_change_state(struct pms_softc *sc, int newstate)
 {
-   u_char cmd[1], resp[2];
-   int res;
-
switch (newstate) {
case PMS_STATE_ENABLED:
if (sc-sc_state == PMS_STATE_ENABLED)
@@ -213,22 +310,15 @@ pms_change_state(struct pms_softc *sc, i
if (sc-poll)
pckbc_flush(sc-sc_kbctag, sc-sc_kbcslot);
 
-   cmd[0] = PMS_RESET;
-   res = pms_cmd(sc, cmd, 1, resp, 2);
+   pms_reset(sc);
 
sc-intelli = pms_setintellimode(sc);
 
-   

Re: update pms driver

2010-10-30 Thread Nicholas Marriott
Did this go in?

If not, looks fine and works for me, sorry for the delay testing this
one got lost in my inbox.



On Tue, Oct 19, 2010 at 08:44:47PM +0600, Alexandr Shadchin wrote:
 On Tue, Oct 19, 2010 at 07:01:24AM -0400, Kenneth R Westerback wrote:
  
  Done. Next? :-).
  
   Ken
 
 Clean function pms_change_state():
 1) removed unused code (#if 0)
 2) return to a uniform style ( return (fobar); )
 3) small code optimization
 
 No functional change.
 
 -- 
 Alexandr Shadchin
 
 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.11
 diff -u -p -r1.11 pms.c
 --- pms.c 19 Oct 2010 11:00:50 -  1.11
 +++ pms.c 19 Oct 2010 14:27:49 -
 @@ -203,7 +203,8 @@ pms_change_state(struct pms_softc *sc, i
   switch (newstate) {
   case PMS_STATE_ENABLED:
   if (sc-sc_state == PMS_STATE_ENABLED)
 - return EBUSY;
 + return (EBUSY);
 +
   sc-inputstate = 0;
   sc-oldbuttons = 0;
  
 @@ -221,48 +222,21 @@ pms_change_state(struct pms_softc *sc, i
   res = pms_cmd(sc, cmd, 1, NULL, 0);
   if (res)
   printf(pms_enable: command error\n);
 -#if 0
 - {
 - u_char scmd[2];
 -
 - scmd[0] = PMS_SET_RES;
 - scmd[1] = 3; /* 8 counts/mm */
 - res = pckbc_enqueue_cmd(sc-sc_kbctag, sc-sc_kbcslot, 
 scmd,
 - 2, 0, 1, 0);
 - if (res)
 - printf(pms_enable: setup error1 (%d)\n, res);
 -
 - scmd[0] = PMS_SET_SCALE21;
 - res = pckbc_enqueue_cmd(sc-sc_kbctag, sc-sc_kbcslot, 
 scmd,
 - 1, 0, 1, 0);
 - if (res)
 - printf(pms_enable: setup error2 (%d)\n, res);
 -
 - scmd[0] = PMS_SET_SAMPLE;
 - scmd[1] = 100; /* 100 samples/sec */
 - res = pckbc_enqueue_cmd(sc-sc_kbctag, sc-sc_kbcslot, 
 scmd,
 - 2, 0, 1, 0);
 - if (res)
 - printf(pms_enable: setup error3 (%d)\n, res);
 - }
 -#endif
 - sc-sc_state = newstate;
 - sc-poll = 0;
   break;
   case PMS_STATE_DISABLED:
 -
 - /* FALLTHROUGH */
   case PMS_STATE_SUSPENDED:
   cmd[0] = PMS_DEV_DISABLE;
   res = pms_cmd(sc, cmd, 1, NULL, 0);
   if (res)
   printf(pms_disable: command error\n);
   pckbc_slot_enable(sc-sc_kbctag, sc-sc_kbcslot, 0);
 - sc-sc_state = newstate;
 - sc-poll = (newstate == PMS_STATE_SUSPENDED) ? 1 : 0;
   break;
   }
 - return 0;
 +
 + sc-sc_state = newstate;
 + sc-poll = (newstate == PMS_STATE_SUSPENDED) ? 1 : 0;
 +
 + return (0);
  }
  
  int



Re: update pms driver

2010-10-18 Thread Nicholas Marriott
This seems is fine too.

Cheers



On Sun, Oct 17, 2010 at 05:38:32PM +0600, Alexandr Shadchin wrote:
 On Sun, Oct 17, 2010 at 06:34:23AM -0400, Kenneth R Westerback wrote:
  On Sat, Oct 16, 2010 at 09:00:43PM +0600, Alexandr Shadchin wrote:
   On Sat, Oct 16, 2010 at 03:42:10PM +0100, Nicholas Marriott wrote:
pmsinput could have a newline after the return type like the rest,
otherwise looks good for me.

   
   I agree, did not notice :)
   Fixed
   
   -- 
   Alexandr Shadchin
  
  The diff diddn't compile due to ';' in pmsprobe(). Make sure you at least
  compile diffs, lest we start trusting you and committing without compiling
  ourselves!
 
 Right now wanted to write about this error.
 I have two laptops. Second forgot to sync. I'll try to be more attentive.
 
  
  Done. Next? :-).
  
   Ken
 
 Simplified pmsprobe(), no functional change.
 
 -- 
 Alexandr Shadchin
 
 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.10
 diff -u -p -r1.10 pms.c
 --- pms.c 17 Oct 2010 10:32:00 -  1.10
 +++ pms.c 17 Oct 2010 11:30:24 -
 @@ -134,21 +134,10 @@ pmsprobe(struct device *parent, void *ma
   /* reset the device */
   cmd[0] = PMS_RESET;
   res = pckbc_poll_cmd(pa-pa_tag, pa-pa_slot, cmd, 1, 2, resp, 1);
 - if (res) {
 + if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) {
  #ifdef DEBUG
 - printf(pmsprobe: reset error %d\n, res);
 -#endif
 - return (0);
 - }
 - if (resp[0] != PMS_RSTDONE) {
 - printf(pmsprobe: reset response 0x%x\n, resp[0]);
 - return (0);
 - }
 -
 - /* get type number (0 = mouse) */
 - if (resp[1] != 0) {
 -#ifdef DEBUG
 - printf(pmsprobe: type 0x%x\n, resp[1]);
 + printf(pms: reset error %d (response 0x%02x, type 0x%02x)\n,
 + res, resp[0], resp[1]);
  #endif
   return (0);
   }



Re: update pms driver

2010-10-18 Thread Nicholas Marriott
This doesn't seem to cause any regressions for me.



On Tue, Oct 12, 2010 at 03:56:46PM -0400, Kenneth R Westerback wrote:
 On Fri, Oct 08, 2010 at 01:28:11AM +0600, Alexandr Shadchin wrote:
  On Wed, Oct 06, 2010 at 09:53:47PM -0400, Kenneth R Westerback wrote:
   
   Committed. Next? :-)
   
    Ken
  
  Removed unnecessary code, as the same thing does pms_change_state() when 
  the device enters a state of PMS_STATE_ENABLED
  
  -- 
  Alexandr Shadchin
 
 Works for me, but I'm not completely sure that the state change occurs when
 the attach is going on. If it is, then this should be ok. Any other tests?
 
  Ken
 
  
  Index: pms.c
  ===
  RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
  retrieving revision 1.8
  diff -u -p -r1.8 pms.c
  --- pms.c   7 Oct 2010 01:52:25 -   1.8
  +++ pms.c   7 Oct 2010 18:46:59 -
  @@ -167,29 +167,11 @@ pmsattach(parent, self, aux)
  struct pms_softc *sc = (void *)self;
  struct pckbc_attach_args *pa = aux;
  struct wsmousedev_attach_args a;
  -   u_char cmd[1], resp[2];
  -   int res;
   
  sc-sc_kbctag = pa-pa_tag;
  sc-sc_kbcslot = pa-pa_slot;
   
  printf(\n);
  -
  -   /* Flush any garbage. */
  -   pckbc_flush(pa-pa_tag, pa-pa_slot);
  -
  -   /* reset the device */
  -   cmd[0] = PMS_RESET;
  -   res = pckbc_poll_cmd(pa-pa_tag, pa-pa_slot, cmd, 1, 2, resp, 1);
  -#ifdef DEBUG
  -   if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) {
  -   printf(pmsattach: reset error\n);
  -   return;
  -   }
  -#endif
  -
  -   sc-inputstate = 0;
  -   sc-oldbuttons = 0;
   
  pckbc_set_inputhandler(sc-sc_kbctag, sc-sc_kbcslot,
 pmsinput, sc, sc-sc_dev.dv_xname);



Re: update pms driver

2010-10-17 Thread Alexandr Shadchin
On Sun, Oct 17, 2010 at 06:34:23AM -0400, Kenneth R Westerback wrote:
 On Sat, Oct 16, 2010 at 09:00:43PM +0600, Alexandr Shadchin wrote:
  On Sat, Oct 16, 2010 at 03:42:10PM +0100, Nicholas Marriott wrote:
   pmsinput could have a newline after the return type like the rest,
   otherwise looks good for me.
   
  
  I agree, did not notice :)
  Fixed
  
  -- 
  Alexandr Shadchin
 
 The diff diddn't compile due to ';' in pmsprobe(). Make sure you at least
 compile diffs, lest we start trusting you and committing without compiling
 ourselves!

Right now wanted to write about this error.
I have two laptops. Second forgot to sync. I'll try to be more attentive.

 
 Done. Next? :-).
 
  Ken

Simplified pmsprobe(), no functional change.

-- 
Alexandr Shadchin

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.10
diff -u -p -r1.10 pms.c
--- pms.c   17 Oct 2010 10:32:00 -  1.10
+++ pms.c   17 Oct 2010 11:30:24 -
@@ -134,21 +134,10 @@ pmsprobe(struct device *parent, void *ma
/* reset the device */
cmd[0] = PMS_RESET;
res = pckbc_poll_cmd(pa-pa_tag, pa-pa_slot, cmd, 1, 2, resp, 1);
-   if (res) {
+   if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) {
 #ifdef DEBUG
-   printf(pmsprobe: reset error %d\n, res);
-#endif
-   return (0);
-   }
-   if (resp[0] != PMS_RSTDONE) {
-   printf(pmsprobe: reset response 0x%x\n, resp[0]);
-   return (0);
-   }
-
-   /* get type number (0 = mouse) */
-   if (resp[1] != 0) {
-#ifdef DEBUG
-   printf(pmsprobe: type 0x%x\n, resp[1]);
+   printf(pms: reset error %d (response 0x%02x, type 0x%02x)\n,
+   res, resp[0], resp[1]);
 #endif
return (0);
}



Re: update pms driver

2010-10-16 Thread Alexandr Shadchin
On Sat, Oct 16, 2010 at 07:26:19AM -0400, Kenneth R Westerback wrote:
 
 Committed! Next? :-)
 
  Ken

ansify function definitions, no functional change.

-- 
Alexandr Shadchin

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.9
diff -u -p -r1.9 pms.c
--- pms.c   16 Oct 2010 11:24:04 -  1.9
+++ pms.c   16 Oct 2010 12:30:19 -
@@ -119,10 +119,7 @@ pms_setintellimode(struct pms_softc *sc)
 }
 
 int
-pmsprobe(parent, match, aux)
-   struct device *parent;
-   void *match;
-   void *aux;
+pmsprobe(struct device *parent, void *match, void *aux;)
 {
struct pckbc_attach_args *pa = aux;
u_char cmd[1], resp[2];
@@ -160,9 +157,7 @@ pmsprobe(parent, match, aux)
 }
 
 void
-pmsattach(parent, self, aux)
-   struct device *parent, *self;
-   void *aux;
+pmsattach(struct device *parent, struct device *self, void *aux)
 {
struct pms_softc *sc = (void *)self;
struct pckbc_attach_args *pa = aux;
@@ -282,8 +277,7 @@ pms_change_state(struct pms_softc *sc, i
 }
 
 int
-pms_enable(v)
-   void *v;
+pms_enable(void *v)
 {
struct pms_softc *sc = v;
 
@@ -291,8 +285,7 @@ pms_enable(v)
 }
 
 void
-pms_disable(v)
-   void *v;
+pms_disable(void *v)
 {
struct pms_softc *sc = v;
 
@@ -300,12 +293,7 @@ pms_disable(v)
 }
 
 int
-pms_ioctl(v, cmd, data, flag, p)
-   void *v;
-   u_long cmd;
-   caddr_t data;
-   int flag;
-   struct proc *p;
+pms_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
 {
struct pms_softc *sc = v;
u_char kbcmd[2];
@@ -344,9 +332,7 @@ pms_ioctl(v, cmd, data, flag, p)
 #define PS2RBUTMASK 0x02
 #define PS2MBUTMASK 0x04
 
-void pmsinput(vsc, data)
-void *vsc;
-int data;
+void pmsinput(void *vsc, int data)
 {
struct pms_softc *sc = vsc;
signed char dz = 0;



Re: update pms driver

2010-10-16 Thread Nicholas Marriott
pmsinput could have a newline after the return type like the rest,
otherwise looks good for me.


On Sat, Oct 16, 2010 at 06:36:41PM +0600, Alexandr Shadchin wrote:
 On Sat, Oct 16, 2010 at 07:26:19AM -0400, Kenneth R Westerback wrote:
  
  Committed! Next? :-)
  
   Ken
 
 ansify function definitions, no functional change.
 
 -- 
 Alexandr Shadchin
 
 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.9
 diff -u -p -r1.9 pms.c
 --- pms.c 16 Oct 2010 11:24:04 -  1.9
 +++ pms.c 16 Oct 2010 12:30:19 -
 @@ -119,10 +119,7 @@ pms_setintellimode(struct pms_softc *sc)
  }
  
  int
 -pmsprobe(parent, match, aux)
 - struct device *parent;
 - void *match;
 - void *aux;
 +pmsprobe(struct device *parent, void *match, void *aux;)
  {
   struct pckbc_attach_args *pa = aux;
   u_char cmd[1], resp[2];
 @@ -160,9 +157,7 @@ pmsprobe(parent, match, aux)
  }
  
  void
 -pmsattach(parent, self, aux)
 - struct device *parent, *self;
 - void *aux;
 +pmsattach(struct device *parent, struct device *self, void *aux)
  {
   struct pms_softc *sc = (void *)self;
   struct pckbc_attach_args *pa = aux;
 @@ -282,8 +277,7 @@ pms_change_state(struct pms_softc *sc, i
  }
  
  int
 -pms_enable(v)
 - void *v;
 +pms_enable(void *v)
  {
   struct pms_softc *sc = v;
  
 @@ -291,8 +285,7 @@ pms_enable(v)
  }
  
  void
 -pms_disable(v)
 - void *v;
 +pms_disable(void *v)
  {
   struct pms_softc *sc = v;
  
 @@ -300,12 +293,7 @@ pms_disable(v)
  }
  
  int
 -pms_ioctl(v, cmd, data, flag, p)
 - void *v;
 - u_long cmd;
 - caddr_t data;
 - int flag;
 - struct proc *p;
 +pms_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
  {
   struct pms_softc *sc = v;
   u_char kbcmd[2];
 @@ -344,9 +332,7 @@ pms_ioctl(v, cmd, data, flag, p)
  #define PS2RBUTMASK 0x02
  #define PS2MBUTMASK 0x04
  
 -void pmsinput(vsc, data)
 -void *vsc;
 -int data;
 +void pmsinput(void *vsc, int data)
  {
   struct pms_softc *sc = vsc;
   signed char dz = 0;



Re: update pms driver

2010-10-16 Thread Alexandr Shadchin
On Sat, Oct 16, 2010 at 03:42:10PM +0100, Nicholas Marriott wrote:
 pmsinput could have a newline after the return type like the rest,
 otherwise looks good for me.
 

I agree, did not notice :)
Fixed

-- 
Alexandr Shadchin

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.9
diff -u -p -r1.9 pms.c
--- pms.c   16 Oct 2010 11:24:04 -  1.9
+++ pms.c   16 Oct 2010 14:56:42 -
@@ -119,10 +119,7 @@ pms_setintellimode(struct pms_softc *sc)
 }
 
 int
-pmsprobe(parent, match, aux)
-   struct device *parent;
-   void *match;
-   void *aux;
+pmsprobe(struct device *parent, void *match, void *aux;)
 {
struct pckbc_attach_args *pa = aux;
u_char cmd[1], resp[2];
@@ -160,9 +157,7 @@ pmsprobe(parent, match, aux)
 }
 
 void
-pmsattach(parent, self, aux)
-   struct device *parent, *self;
-   void *aux;
+pmsattach(struct device *parent, struct device *self, void *aux)
 {
struct pms_softc *sc = (void *)self;
struct pckbc_attach_args *pa = aux;
@@ -282,8 +277,7 @@ pms_change_state(struct pms_softc *sc, i
 }
 
 int
-pms_enable(v)
-   void *v;
+pms_enable(void *v)
 {
struct pms_softc *sc = v;
 
@@ -291,8 +285,7 @@ pms_enable(v)
 }
 
 void
-pms_disable(v)
-   void *v;
+pms_disable(void *v)
 {
struct pms_softc *sc = v;
 
@@ -300,12 +293,7 @@ pms_disable(v)
 }
 
 int
-pms_ioctl(v, cmd, data, flag, p)
-   void *v;
-   u_long cmd;
-   caddr_t data;
-   int flag;
-   struct proc *p;
+pms_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
 {
struct pms_softc *sc = v;
u_char kbcmd[2];
@@ -344,9 +332,8 @@ pms_ioctl(v, cmd, data, flag, p)
 #define PS2RBUTMASK 0x02
 #define PS2MBUTMASK 0x04
 
-void pmsinput(vsc, data)
-void *vsc;
-int data;
+void
+pmsinput(void *vsc, int data)
 {
struct pms_softc *sc = vsc;
signed char dz = 0;



Re: update pms driver

2010-10-12 Thread Kenneth R Westerback
On Fri, Oct 08, 2010 at 01:28:11AM +0600, Alexandr Shadchin wrote:
 On Wed, Oct 06, 2010 at 09:53:47PM -0400, Kenneth R Westerback wrote:
  
  Committed. Next? :-)
  
   Ken
 
 Removed unnecessary code, as the same thing does pms_change_state() when 
 the device enters a state of PMS_STATE_ENABLED
 
 -- 
 Alexandr Shadchin

Works for me, but I'm not completely sure that the state change occurs when
the attach is going on. If it is, then this should be ok. Any other tests?

 Ken

 
 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.8
 diff -u -p -r1.8 pms.c
 --- pms.c 7 Oct 2010 01:52:25 -   1.8
 +++ pms.c 7 Oct 2010 18:46:59 -
 @@ -167,29 +167,11 @@ pmsattach(parent, self, aux)
   struct pms_softc *sc = (void *)self;
   struct pckbc_attach_args *pa = aux;
   struct wsmousedev_attach_args a;
 - u_char cmd[1], resp[2];
 - int res;
  
   sc-sc_kbctag = pa-pa_tag;
   sc-sc_kbcslot = pa-pa_slot;
  
   printf(\n);
 -
 - /* Flush any garbage. */
 - pckbc_flush(pa-pa_tag, pa-pa_slot);
 -
 - /* reset the device */
 - cmd[0] = PMS_RESET;
 - res = pckbc_poll_cmd(pa-pa_tag, pa-pa_slot, cmd, 1, 2, resp, 1);
 -#ifdef DEBUG
 - if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) {
 - printf(pmsattach: reset error\n);
 - return;
 - }
 -#endif
 -
 - sc-inputstate = 0;
 - sc-oldbuttons = 0;
  
   pckbc_set_inputhandler(sc-sc_kbctag, sc-sc_kbcslot,
  pmsinput, sc, sc-sc_dev.dv_xname);



Re: update pms driver

2010-10-07 Thread Alexandr Shadchin
On Wed, Oct 06, 2010 at 11:40:45PM -0400, Ian Darwin wrote:
   Also found a new bug:
   wsmoused + X don't work (suspend/resume)
   
   1) wsmoused
   2) startx
   3) suspend/resume
   4) in X mouse don't work
   5) suspend/resume
   6) in X mouse work
 
 Urm, I did say I'd test it later today, and I did so - just after
 the diff got committed :-(  So, I just updated pms.c to the committed
 version and built a kernel. Fortunately, as reported in my earlier test,
 I do not have the above problems on the Dell Studio 1558 laptop.
 
 However, in the process of this testing, I found two problems,
 one related and one maybe related. Both have to do with running
 two X sessions one after another.
 
 1) (might or might not be related to pms) When I terminate X and
 try to re-start it (either under XDM or by running sudo startx
 twice), the second X does not always start - it tries, but it hangs
 just after the basket weave background and the X cursor, before any
 apps or the XDM login screen. Other times it works fine.  Since 
 restarting X is not something I normally do (I'm usually the only
 user of this machine, and I usually either suspend or power it off
 when not using), I cannot say if this started when the pms/pmsi
 merger went in. The last time I can be sure that I had several X's
 in a row without rebooting is Sept 20, according to last(1).  So I
 can try triaging (actually we're bisecting, not triaging, when we
 do this :-) ) on the weekend when I am home and have a cvsync repo
 to build multiple kernels against, and time to do so.
 
 2) (probably related to pms) With wsmoused running, the second X session
 (as above) fails to get /dev/wsmouse. Sadly I captured the wrong
 Xorg.log on this one so I'll have to replicate, but I'm out of time
 for tonight.


this error does not pms driver, but failure mechanism is similar to 
one that I found. At first I will finish with pms, and then take over 
these problems. I think the objection would not be? :)
 
 This machine is Intel core i7, amd64 mode, and running -current
 (userland + X updated earlier today to Oct 6 userland, Oct 3 X
 snapshot).  BIOS is up to date.  Dmesg below; longer dmesg with
 ACPI_DEBUG, and acpidump, on request.
 
 More later, sorry...
 
 Ian
 

-- 
Alexandr Shadchin



Re: update pms driver

2010-10-07 Thread Alexandr Shadchin
On Wed, Oct 06, 2010 at 09:53:47PM -0400, Kenneth R Westerback wrote:
 
 Committed. Next? :-)
 
  Ken

Removed unnecessary code, as the same thing does pms_change_state() when 
the device enters a state of PMS_STATE_ENABLED

-- 
Alexandr Shadchin

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.8
diff -u -p -r1.8 pms.c
--- pms.c   7 Oct 2010 01:52:25 -   1.8
+++ pms.c   7 Oct 2010 18:46:59 -
@@ -167,29 +167,11 @@ pmsattach(parent, self, aux)
struct pms_softc *sc = (void *)self;
struct pckbc_attach_args *pa = aux;
struct wsmousedev_attach_args a;
-   u_char cmd[1], resp[2];
-   int res;
 
sc-sc_kbctag = pa-pa_tag;
sc-sc_kbcslot = pa-pa_slot;
 
printf(\n);
-
-   /* Flush any garbage. */
-   pckbc_flush(pa-pa_tag, pa-pa_slot);
-
-   /* reset the device */
-   cmd[0] = PMS_RESET;
-   res = pckbc_poll_cmd(pa-pa_tag, pa-pa_slot, cmd, 1, 2, resp, 1);
-#ifdef DEBUG
-   if (res || resp[0] != PMS_RSTDONE || resp[1] != 0) {
-   printf(pmsattach: reset error\n);
-   return;
-   }
-#endif
-
-   sc-inputstate = 0;
-   sc-oldbuttons = 0;
 
pckbc_set_inputhandler(sc-sc_kbctag, sc-sc_kbcslot,
   pmsinput, sc, sc-sc_dev.dv_xname);



Re: update pms driver

2010-10-07 Thread Ian Darwin
  1) (might or might not be related to pms) When I terminate X and
  try to re-start it (either under XDM or by running sudo startx
  twice), the second X does not always start - it tries, but it hangs
  just after the basket weave background and the X cursor, before any
  apps or the XDM login screen. Other times it works fine.  Since 
  restarting X is not something I normally do (I'm usually the only
  user of this machine, and I usually either suspend or power it off
  when not using), I cannot say if this started when the pms/pmsi
  merger went in. The last time I can be sure that I had several X's
  in a row without rebooting is Sept 20, according to last(1).  So I
  can try triaging (actually we're bisecting, not triaging, when we
  do this :-) ) on the weekend when I am home and have a cvsync repo
  to build multiple kernels against, and time to do so.
  
  2) (probably related to pms) With wsmoused running, the second X session
  (as above) fails to get /dev/wsmouse. Sadly I captured the wrong
  Xorg.log on this one so I'll have to replicate, but I'm out of time
  for tonight.
 
 this error does not pms driver, but failure mechanism is similar to 
 one that I found. At first I will finish with pms, and then take over 
 these problems. I think the objection would not be? :)

I really doubt if anyone would object to your fixing problems! :-)

Thanks for your contributions. Keep at it!

Ian



Re: update pms driver

2010-10-05 Thread Alexandr Shadchin
Hi!

Try new diff. Fix for me (Lenovo X201)
1) reboot and login (text-mode)
2) wsmoused
3) the behavior is as if I'm holding down Enter 

Also found a new bug:
wsmoused + X don't work (suspend/resume)

1) wsmoused
2) startx
3) suspend/resume
4) in X mouse don't work
5) suspend/resume
6) in X mouse work

this error does not pms driver. Check the job pms driver separately:
1) wsmoused only
2) X only
 
-- 
Alexandr Shadchin

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.7
diff -u -p -r1.7 pms.c
--- pms.c   2 Oct 2010 00:28:57 -   1.7
+++ pms.c   5 Oct 2010 05:54:01 -
@@ -243,7 +243,8 @@ pms_change_state(struct pms_softc *sc, i
 
pckbc_slot_enable(sc-sc_kbctag, sc-sc_kbcslot, 1);
 
-   pckbc_flush(sc-sc_kbctag, sc-sc_kbcslot);
+   if (sc-poll)
+   pckbc_flush(sc-sc_kbctag, sc-sc_kbcslot);
 
cmd[0] = PMS_RESET;
res = pms_cmd(sc, cmd, 1, resp, 2);



Re: update pms driver

2010-10-01 Thread Alexandr Shadchin
On Fri, Oct 01, 2010 at 01:23:17AM -0400, Kenneth R Westerback wrote:
 
 And it keeps my eeePC 1000HE working. Excellent!!
 
 Anyone else have problems left after this diff? If not, then let's get it
 in and go forward from here.
 
  Ken

I was having problems with pckbc_flush() in pms_change_state(), 
but now everything is normal. Try this diff.

-- 
Alexandr Shadchin

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.6
diff -u -p -r1.6 pms.c
--- pms.c   29 Sep 2010 19:39:18 -  1.6
+++ pms.c   1 Oct 2010 14:00:35 -
@@ -49,6 +49,7 @@ struct pms_softc {/* driver status inf
 #define PMS_STATE_ENABLED  1
 #define PMS_STATE_SUSPENDED2
 
+   int poll;
int intelli;
int inputstate;
u_int buttons, oldbuttons;  /* mouse button status */
@@ -72,7 +73,9 @@ int   pms_ioctl(void *, u_long, caddr_t, i
 intpms_enable(void *);
 void   pms_disable(void *);
 
-intpms_setintellimode(pckbc_tag_t, pckbc_slot_t);
+intpms_cmd(struct pms_softc *, u_char *, int, u_char *, int);
+
+intpms_setintellimode(struct pms_softc *sc);
 
 const struct wsmouse_accessops pms_accessops = {
pms_enable,
@@ -81,7 +84,19 @@ const struct wsmouse_accessops pms_acces
 };
 
 int
-pms_setintellimode(pckbc_tag_t tag, pckbc_slot_t slot)
+pms_cmd(struct pms_softc *sc, u_char *cmd, int len, u_char *resp, int resplen)
+{
+   if (sc-poll) {
+   return pckbc_poll_cmd(sc-sc_kbctag, sc-sc_kbcslot,
+   cmd, len, resplen, resp, 1);
+   } else {
+   return pckbc_enqueue_cmd(sc-sc_kbctag, sc-sc_kbcslot,
+   cmd, len, resplen, 1, resp);
+   }
+}
+
+int
+pms_setintellimode(struct pms_softc *sc)
 {
u_char cmd[2], resp[1];
int i, res;
@@ -90,13 +105,13 @@ pms_setintellimode(pckbc_tag_t tag, pckb
cmd[0] = PMS_SET_SAMPLE;
for (i = 0; i  3; i++) {
cmd[1] = rates[i];
-   res = pckbc_enqueue_cmd(tag, slot, cmd, 2, 0, 0, NULL);
+   res = pms_cmd(sc, cmd, 2, NULL, 0);
if (res)
return (0);
}
 
cmd[0] = PMS_SEND_DEV_ID;
-   res = pckbc_enqueue_cmd(tag, slot, cmd, 1, 1, 1, resp);
+   res = pms_cmd(sc, cmd, 1, resp, 1);
if (res || resp[0] != 3)
return (0);
 
@@ -191,11 +206,8 @@ pmsattach(parent, self, aux)
sc-sc_wsmousedev = config_found(self, a, wsmousedevprint);
 
/* no interrupts until enabled */
-   cmd[0] = PMS_DEV_DISABLE;
-   res = pckbc_poll_cmd(pa-pa_tag, pa-pa_slot, cmd, 1, 0, NULL, 0);
-   if (res)
-   printf(pmsattach: disable error\n);
-   pckbc_slot_enable(sc-sc_kbctag, sc-sc_kbcslot, 0);
+   sc-poll = 1;
+   pms_change_state(sc, PMS_STATE_DISABLED);
 }
 
 int
@@ -219,7 +231,7 @@ pmsactivate(struct device *self, int act
 int
 pms_change_state(struct pms_softc *sc, int newstate)
 {
-   u_char cmd[1];
+   u_char cmd[1], resp[2];
int res;
 
switch (newstate) {
@@ -232,11 +244,14 @@ pms_change_state(struct pms_softc *sc, i
pckbc_slot_enable(sc-sc_kbctag, sc-sc_kbcslot, 1);
 
pckbc_flush(sc-sc_kbctag, sc-sc_kbcslot);
-   sc-intelli = pms_setintellimode(sc-sc_kbctag, sc-sc_kbcslot);
+
+   cmd[0] = PMS_RESET;
+   res = pms_cmd(sc, cmd, 1, resp, 2);
+
+   sc-intelli = pms_setintellimode(sc);
 
cmd[0] = PMS_DEV_ENABLE;
-   res = pckbc_enqueue_cmd(sc-sc_kbctag, sc-sc_kbcslot,
-   cmd, 1, 0, 1, 0);
+   res = pms_cmd(sc, cmd, 1, NULL, 0);
if (res)
printf(pms_enable: command error\n);
 #if 0
@@ -265,18 +280,19 @@ pms_change_state(struct pms_softc *sc, i
}
 #endif
sc-sc_state = newstate;
+   sc-poll = 0;
break;
case PMS_STATE_DISABLED:
 
/* FALLTHROUGH */
case PMS_STATE_SUSPENDED:
cmd[0] = PMS_DEV_DISABLE;
-   res = pckbc_enqueue_cmd(sc-sc_kbctag, sc-sc_kbcslot,
-   cmd, 1, 0, 1, 0);
+   res = pms_cmd(sc, cmd, 1, NULL, 0);
if (res)
printf(pms_disable: command error\n);
pckbc_slot_enable(sc-sc_kbctag, sc-sc_kbcslot, 0);
sc-sc_state = newstate;
+   sc-poll = (newstate == PMS_STATE_SUSPENDED) ? 1 : 0;
break;
}
return 0;



update pms driver

2010-09-30 Thread Alexandr Shadchin
I'll try to start over, I'll make a small diff. They will be easier for you
to check and I did not mix everything in one pile.

Removed unnecessary code, as the same thing does pms_change_state() when 
the device enters a state of PMS_STATE_ENABLED

-- 
Alexandr Shadchin


Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.6
diff -u -p -r1.6 pms.c
--- pms.c   29 Sep 2010 19:39:18 -  1.6
+++ pms.c   30 Sep 2010 07:40:39 -
@@ -173,9 +173,6 @@ pmsattach(parent, self, aux)
}
 #endif
 
-   sc-inputstate = 0;
-   sc-oldbuttons = 0;
-
pckbc_set_inputhandler(sc-sc_kbctag, sc-sc_kbcslot,
   pmsinput, sc, sc-sc_dev.dv_xname);



Re: update pms driver

2010-09-30 Thread Alexandr Shadchin
On Thu, Sep 30, 2010 at 08:04:44PM -0400, Kenneth R Westerback wrote:
 
 This is a bit too small. :-). I've copied mikeb@ in to ensure we
 are not losing too much in translation.
 
 The primary focus right now has to be to fix the regressions Ian@
 and no doubt others are experiencing. If we can't fix those regressions
 we will have to revert your diffs and figure out what was wrong
 before putting them back into the tree. The philosophy here is to
 commit early but un-commit quickly if something regresses. Especially
 when Theo is completely buried in something and will neither respond
 to queries about other stuff or suffer any lengthy periods of
 breakage that would distract him.
 
 We also face a bit of a deadline as the person who understands this
 code and these devices the most (miod@) will shortly vanish for a
 couple of months of moving. There would be reluctance to make big
 changes in those months. Code cleanup and formatting, etc. would
 be ideal for that time period.
 
 But first, the regressions. Do you have enough information from
 ian@ to suggest a test plan or code to tweak?
 
  Ken

OK. This diff resolves Ian problem, Ian has already checked it out.

-- 
Alexandr Shadchin

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.6
diff -u -p -r1.6 pms.c
--- pms.c   29 Sep 2010 19:39:18 -  1.6
+++ pms.c   30 Sep 2010 19:47:12 -
@@ -49,6 +49,7 @@ struct pms_softc {/* driver status inf
 #define PMS_STATE_ENABLED  1
 #define PMS_STATE_SUSPENDED2
 
+   int poll;
int intelli;
int inputstate;
u_int buttons, oldbuttons;  /* mouse button status */
@@ -72,7 +73,9 @@ int   pms_ioctl(void *, u_long, caddr_t, i
 intpms_enable(void *);
 void   pms_disable(void *);
 
-intpms_setintellimode(pckbc_tag_t, pckbc_slot_t);
+intpms_cmd(struct pms_softc *, u_char *, int, u_char *, int);
+
+intpms_setintellimode(struct pms_softc *sc);
 
 const struct wsmouse_accessops pms_accessops = {
pms_enable,
@@ -81,7 +84,19 @@ const struct wsmouse_accessops pms_acces
 };
 
 int
-pms_setintellimode(pckbc_tag_t tag, pckbc_slot_t slot)
+pms_cmd(struct pms_softc *sc, u_char *cmd, int len, u_char *resp, int resplen)
+{
+   if (sc-poll) {
+   return pckbc_poll_cmd(sc-sc_kbctag, sc-sc_kbcslot,
+   cmd, len, resplen, resp, 1);
+   } else {
+   return pckbc_enqueue_cmd(sc-sc_kbctag, sc-sc_kbcslot,
+   cmd, len, resplen, 1, resp);
+   }
+}
+
+int
+pms_setintellimode(struct pms_softc *sc)
 {
u_char cmd[2], resp[1];
int i, res;
@@ -90,13 +105,13 @@ pms_setintellimode(pckbc_tag_t tag, pckb
cmd[0] = PMS_SET_SAMPLE;
for (i = 0; i  3; i++) {
cmd[1] = rates[i];
-   res = pckbc_enqueue_cmd(tag, slot, cmd, 2, 0, 0, NULL);
+   res = pms_cmd(sc, cmd, 2, NULL, 0);
if (res)
return (0);
}
 
cmd[0] = PMS_SEND_DEV_ID;
-   res = pckbc_enqueue_cmd(tag, slot, cmd, 1, 1, 1, resp);
+   res = pms_cmd(sc, cmd, 1, resp, 1);
if (res || resp[0] != 3)
return (0);
 
@@ -191,11 +206,8 @@ pmsattach(parent, self, aux)
sc-sc_wsmousedev = config_found(self, a, wsmousedevprint);
 
/* no interrupts until enabled */
-   cmd[0] = PMS_DEV_DISABLE;
-   res = pckbc_poll_cmd(pa-pa_tag, pa-pa_slot, cmd, 1, 0, NULL, 0);
-   if (res)
-   printf(pmsattach: disable error\n);
-   pckbc_slot_enable(sc-sc_kbctag, sc-sc_kbcslot, 0);
+   sc-poll = 1;
+   pms_change_state(sc, PMS_STATE_DISABLED);
 }
 
 int
@@ -219,7 +231,7 @@ pmsactivate(struct device *self, int act
 int
 pms_change_state(struct pms_softc *sc, int newstate)
 {
-   u_char cmd[1];
+   u_char cmd[1], resp[2];
int res;
 
switch (newstate) {
@@ -231,12 +243,13 @@ pms_change_state(struct pms_softc *sc, i
 
pckbc_slot_enable(sc-sc_kbctag, sc-sc_kbcslot, 1);
 
-   pckbc_flush(sc-sc_kbctag, sc-sc_kbcslot);
-   sc-intelli = pms_setintellimode(sc-sc_kbctag, sc-sc_kbcslot);
+   cmd[0] = PMS_RESET;
+   res = pms_cmd(sc, cmd, 1, resp, 2);
+
+   sc-intelli = pms_setintellimode(sc);
 
cmd[0] = PMS_DEV_ENABLE;
-   res = pckbc_enqueue_cmd(sc-sc_kbctag, sc-sc_kbcslot,
-   cmd, 1, 0, 1, 0);
+   res = pms_cmd(sc, cmd, 1, NULL, 0);
if (res)
printf(pms_enable: command error\n);
 #if 0
@@ -265,18 +278,19 @@ pms_change_state(struct pms_softc *sc, i
}
 #endif
sc-sc_state = newstate;
+   sc-poll = 0;
break;
case PMS_STATE_DISABLED:
 
/* FALLTHROUGH */
case PMS_STATE_SUSPENDED:
cmd[0] = 

Re: update pms driver

2010-09-30 Thread Kenneth R Westerback
On Fri, Oct 01, 2010 at 04:27:05PM +0600, Alexandr Shadchin wrote:
 On Thu, Sep 30, 2010 at 08:04:44PM -0400, Kenneth R Westerback wrote:
  
  This is a bit too small. :-). I've copied mikeb@ in to ensure we
  are not losing too much in translation.
  
  The primary focus right now has to be to fix the regressions Ian@
  and no doubt others are experiencing. If we can't fix those regressions
  we will have to revert your diffs and figure out what was wrong
  before putting them back into the tree. The philosophy here is to
  commit early but un-commit quickly if something regresses. Especially
  when Theo is completely buried in something and will neither respond
  to queries about other stuff or suffer any lengthy periods of
  breakage that would distract him.
  
  We also face a bit of a deadline as the person who understands this
  code and these devices the most (miod@) will shortly vanish for a
  couple of months of moving. There would be reluctance to make big
  changes in those months. Code cleanup and formatting, etc. would
  be ideal for that time period.
  
  But first, the regressions. Do you have enough information from
  ian@ to suggest a test plan or code to tweak?
  
   Ken
 
 OK. This diff resolves Ian problem, Ian has already checked it out.

And it keeps my eeePC 1000HE working. Excellent!!

Anyone else have problems left after this diff? If not, then let's get it
in and go forward from here.

 Ken

 
 -- 
 Alexandr Shadchin
 
 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.6
 diff -u -p -r1.6 pms.c
 --- pms.c 29 Sep 2010 19:39:18 -  1.6
 +++ pms.c 30 Sep 2010 19:47:12 -
 @@ -49,6 +49,7 @@ struct pms_softc {  /* driver status inf
  #define PMS_STATE_ENABLED1
  #define PMS_STATE_SUSPENDED  2
  
 + int poll;
   int intelli;
   int inputstate;
   u_int buttons, oldbuttons;  /* mouse button status */
 @@ -72,7 +73,9 @@ int pms_ioctl(void *, u_long, caddr_t, i
  int  pms_enable(void *);
  void pms_disable(void *);
  
 -int  pms_setintellimode(pckbc_tag_t, pckbc_slot_t);
 +int  pms_cmd(struct pms_softc *, u_char *, int, u_char *, int);
 +
 +int  pms_setintellimode(struct pms_softc *sc);
  
  const struct wsmouse_accessops pms_accessops = {
   pms_enable,
 @@ -81,7 +84,19 @@ const struct wsmouse_accessops pms_acces
  };
  
  int
 -pms_setintellimode(pckbc_tag_t tag, pckbc_slot_t slot)
 +pms_cmd(struct pms_softc *sc, u_char *cmd, int len, u_char *resp, int 
 resplen)
 +{
 + if (sc-poll) {
 + return pckbc_poll_cmd(sc-sc_kbctag, sc-sc_kbcslot,
 + cmd, len, resplen, resp, 1);
 + } else {
 + return pckbc_enqueue_cmd(sc-sc_kbctag, sc-sc_kbcslot,
 + cmd, len, resplen, 1, resp);
 + }
 +}
 +
 +int
 +pms_setintellimode(struct pms_softc *sc)
  {
   u_char cmd[2], resp[1];
   int i, res;
 @@ -90,13 +105,13 @@ pms_setintellimode(pckbc_tag_t tag, pckb
   cmd[0] = PMS_SET_SAMPLE;
   for (i = 0; i  3; i++) {
   cmd[1] = rates[i];
 - res = pckbc_enqueue_cmd(tag, slot, cmd, 2, 0, 0, NULL);
 + res = pms_cmd(sc, cmd, 2, NULL, 0);
   if (res)
   return (0);
   }
  
   cmd[0] = PMS_SEND_DEV_ID;
 - res = pckbc_enqueue_cmd(tag, slot, cmd, 1, 1, 1, resp);
 + res = pms_cmd(sc, cmd, 1, resp, 1);
   if (res || resp[0] != 3)
   return (0);
  
 @@ -191,11 +206,8 @@ pmsattach(parent, self, aux)
   sc-sc_wsmousedev = config_found(self, a, wsmousedevprint);
  
   /* no interrupts until enabled */
 - cmd[0] = PMS_DEV_DISABLE;
 - res = pckbc_poll_cmd(pa-pa_tag, pa-pa_slot, cmd, 1, 0, NULL, 0);
 - if (res)
 - printf(pmsattach: disable error\n);
 - pckbc_slot_enable(sc-sc_kbctag, sc-sc_kbcslot, 0);
 + sc-poll = 1;
 + pms_change_state(sc, PMS_STATE_DISABLED);
  }
  
  int
 @@ -219,7 +231,7 @@ pmsactivate(struct device *self, int act
  int
  pms_change_state(struct pms_softc *sc, int newstate)
  {
 - u_char cmd[1];
 + u_char cmd[1], resp[2];
   int res;
  
   switch (newstate) {
 @@ -231,12 +243,13 @@ pms_change_state(struct pms_softc *sc, i
  
   pckbc_slot_enable(sc-sc_kbctag, sc-sc_kbcslot, 1);
  
 - pckbc_flush(sc-sc_kbctag, sc-sc_kbcslot);
 - sc-intelli = pms_setintellimode(sc-sc_kbctag, sc-sc_kbcslot);
 + cmd[0] = PMS_RESET;
 + res = pms_cmd(sc, cmd, 1, resp, 2);
 +
 + sc-intelli = pms_setintellimode(sc);
  
   cmd[0] = PMS_DEV_ENABLE;
 - res = pckbc_enqueue_cmd(sc-sc_kbctag, sc-sc_kbcslot,
 - cmd, 1, 0, 1, 0);
 + res = pms_cmd(sc, cmd, 1, NULL, 0);
   if (res)
   printf(pms_enable: command error\n);
  #if 0
 @@ -265,18 +278,19 @@ pms_change_state(struct pms_softc *sc, i