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 -0000 1.7 +++ pms.c 5 Oct 2010 05:54:01 -0000 @@ -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);
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 -- Alexandr Shadchin
I really doubt if anyone would object to your fixing problems! :-) Thanks for your contributions. Keep at it! Ian
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 -0000 1.8
+++ pms.c 7 Oct 2010 18:46:59 -0000
@@ -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);
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?
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 -0000 1.9
+++ pms.c 16 Oct 2010 12:30:19 -0000
@@ -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;
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 -0000 1.9
+++ pms.c 16 Oct 2010 14:56:42 -0000
@@ -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;
Right now wanted to write about this error.
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 -0000 1.10
+++ pms.c 17 Oct 2010 11:30:24 -0000
@@ -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);
}
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 -0000 1.11
+++ pms.c 19 Oct 2010 14:27:49 -0000
@@ -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 ...Did this go in? If not, looks fine and works for me, sorry for the delay testing this one got lost in my inbox.
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 -0000 1.12
+++ pms.c 6 Nov 2010 17:42:02 -0000
@@ -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 *);
int pms_cmd(struct pms_softc *, u_char *, int, u_char *, int);
+int pms_get_devid(struct pms_softc *, u_char *);
+int pms_get_status(struct pms_softc *, u_char *);
+int pms_set_rate(struct pms_softc *, int);
+int pms_set_resolution(struct pms_softc *, int);
+int pms_set_scaling(struct pms_softc *, int);
+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);
@@ -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] = ...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 -0000 1.14
+++ pms.c 17 Nov 2010 18:23:35 -0000
@@ -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 @@ ...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
Yes. WSMOUSEIO_SRES in Xenocara not used, in src - only wsmoused and wsconsctl, 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 Yes -- Alexandr Shadchin
Hi Sorry for the delay again :-/. Hmm, I don't understand. Are you saying nobody should use wsconsctl
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
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
On Mon, 29 Nov 2010 22:08:22 +0000 I use xset m, that isn't affected is it? and so is an alternative, though maybe it could affect someones current setups?
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 -0000 1.14
+++ pms.c 30 Nov 2010 16:26:20 -0000
@@ -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 ...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.
On Wed, Dec 1, 2010 at 3:33 PM, Mark Kettenis <mark.kettenis@xs4all.nl> ok, I like more with u_char. -- Alexandr Shadchin
I disagree with this change (yes, I know it has been commited). Either you do not use option DEBUG, and your diff causes no change in the generated code, or you do, and your diff makes the error message less readable. I do not see any benefit in this. Miod
I prefer the new error message and find the newer code easier to read, but obviously a matter of taste. If you have really strong feelings we can revert since it doesn't make functional changes. .... Ken
Thanks, Ken. I even did not have to translate :) This is about the same that I wanted to say. -- Alexandr Shadchin
| Greg KH | Og dreams of kernels |
| Jens Axboe | [PATCH 31/33] Fusion: sg chaining support |
| Arnd Bergmann | Re: finding your own dead "CONFIG_" variables |
| Mark Brown | [PATCH 2/2] Subject: natsemi: Allow users to disable workaround for DspCfg reset |
| Tony Breeds | [LGUEST] Look in object dir for .config |
git: | |
| Brian Downing | Re: Git in a Nutshell guide |
| John Benes | Re: master has some toys |
| Matthias Lederhofer | [PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree |
| Alexander Sulfrian | [RFC/PATCH] RE: git calls SSH_ASKPASS even if DISPLAY is not set |
| Junio C Hamano | Re: Rss produced by git is not valid xml? |
| Linux Kernel Mailing List | iSeries: fix section mismatch in iseries_veth |
| Linux Kernel Mailing List | ixbge: remove TX lock and redo TX accounting. |
| Linux Kernel Mailing List | ixgbe: fix several counter register errata |
| Linux Kernel Mailing List | b43: fix build with CONFIG_SSB_PCIHOST=n |
| Linux Kernel Mailing List | 9p: block-based virtio client |
