Re: synaptics touchpad with no multifinger support

2023-05-22 Thread Ulf Brosziewski
Sorry for being so late with my reply.

Checking SYNAPTICS_CAP_MULTIFINGER is not sufficient.  There are Synaptics
touchpads that don't report this capability but do provide contact counts
(and that's not a rare case).

Adding a test for AGM support seems to be a viable workaround, see

https://github.com/torvalds/linux/blob/v6.3/drivers/input/mouse/synaptics.c#L1051

So the code should look like:


Index: dev/pckbc/pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.97
diff -u -p -r1.97 pms.c
--- dev/pckbc/pms.c 23 Jul 2022 05:55:16 -  1.97
+++ dev/pckbc/pms.c 22 May 2023 18:03:30 -
@@ -1075,7 +1075,11 @@ synaptics_get_hwinfo(struct pms_softc *s
hw->y_max = (max_coords ?
SYNAPTICS_Y_LIMIT(max_coords) : SYNAPTICS_YMAX_BEZEL);

-   hw->contacts_max = SYNAPTICS_MAX_FINGERS;
+   if ((syn->capabilities & SYNAPTICS_CAP_MULTIFINGER) ||
+   SYNAPTICS_SUPPORTS_AGM(syn->ext_capabilities))
+   hw->contacts_max = SYNAPTICS_MAX_FINGERS;
+   else
+   hw->contacts_max = 1;

syn->sec_buttons = 0;

---

Tests and OKs would be welcome.


On 4/18/23 23:41, la ninpre wrote:
> Hello, tech@
> 
> So I installed OpenBSD on old Compaq laptop and noticed that scrolling
> with touchpad is not working. I started investigating to see why it
> is the case and found out a few odd things in wscons(4) and pckbc(4)
> drivers.
> 
> Basically, the laptop's touchpad lacks multifinger support (see dmesg
> below), but nevertheless, wscons(4) sets it to two-finger mode, which
> doesn't work, obviously. Initially, I thought about adding something
> like mouse.tp.edgescroll to wsconsctl(8). I then found out that there
> is already undocumented mouse.tp.param option, that can be used to
> force the edgescroll mode by setting 67 (WSMOUSECFG_TWOFINGERSCROLL)
> to 0 and 68 (WSMOUSECFG_EDGESCROLL) to 1, but I don't think it is
> very convenient and readable.
> 
> Later I continued to investigate, why wscons(4) defaults to two-finger
> mode and found that it does so by examining a field of a touchpad data
> structure called 'contacts_max' [1], which, I assumed, represents
> a number of maximum simultaneous touches. But when I grepped for
> this name to see where this value is set, I found that it is set
> in pckbc(4). It is done in a very simple way, so it sets it to 3
> (well, actually SYNAPTICS_MAX_FINGERS, but it is defined to be 3
> only there and nowhere else) if the device in question is a synaptics
> touchpad (!) [2], even though the touchpad has a capabilities field
> and it is recognized correctly (SYNAPTICS_CAP_MULTIFINGER is set
> to 0 in my case). So I think a solution would be at least checking
> SYNAPTIC_CAP_MULTIFINGER and setting contacts_max depending on that
> (3 if true, 1 if false). Maybe it is a bodge, but it works.
> 
> Index: pms.c
> ===
> RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
> retrieving revision 1.97
> diff -u -p -r1.97 pms.c
> --- pms.c    23 Jul 2022 05:55:16 -    1.97
> +++ pms.c    18 Apr 2023 21:36:10 -
> @@ -1075,7 +1075,10 @@ synaptics_get_hwinfo(struct pms_softc *s
>  hw->y_max = (max_coords ?
>  SYNAPTICS_Y_LIMIT(max_coords) : SYNAPTICS_YMAX_BEZEL);
> 
> -    hw->contacts_max = SYNAPTICS_MAX_FINGERS;
> +    if(syn->capabilities & SYNAPTICS_CAP_MULTIFINGER)
> +    hw->contacts_max = SYNAPTICS_MAX_FINGERS;
> +    else
> +    hw->contacts_max = 1;
> 
>  syn->sec_buttons = 0;
> 
> 
> 
> [1]: /sys/dev/wscons/wstpad.c:1573
> [2]: /sys/dev/pckbc/psm.c:1078
> 
> Here are relevant lines from dmesg(8):
> 
> pms0 at pckbc0 (aux slot)
> wsmouse0 at pms0 mux 0
> pms0: Synaptics touchpad, firmware 6.5, 0x1c0b1 0xa0 0x0 0xa04751 0x0
> 
> So I'm looking forward for comments on this. Has anybody experienced
> something similar?
> 



synaptics touchpad with no multifinger support

2023-04-18 Thread la ninpre

Hello, tech@

So I installed OpenBSD on old Compaq laptop and noticed that scrolling
with touchpad is not working. I started investigating to see why it
is the case and found out a few odd things in wscons(4) and pckbc(4)
drivers.

Basically, the laptop's touchpad lacks multifinger support (see dmesg
below), but nevertheless, wscons(4) sets it to two-finger mode, which
doesn't work, obviously. Initially, I thought about adding something
like mouse.tp.edgescroll to wsconsctl(8). I then found out that there
is already undocumented mouse.tp.param option, that can be used to
force the edgescroll mode by setting 67 (WSMOUSECFG_TWOFINGERSCROLL)
to 0 and 68 (WSMOUSECFG_EDGESCROLL) to 1, but I don't think it is
very convenient and readable.

Later I continued to investigate, why wscons(4) defaults to two-finger
mode and found that it does so by examining a field of a touchpad data
structure called 'contacts_max' [1], which, I assumed, represents
a number of maximum simultaneous touches. But when I grepped for
this name to see where this value is set, I found that it is set
in pckbc(4). It is done in a very simple way, so it sets it to 3
(well, actually SYNAPTICS_MAX_FINGERS, but it is defined to be 3
only there and nowhere else) if the device in question is a synaptics
touchpad (!) [2], even though the touchpad has a capabilities field
and it is recognized correctly (SYNAPTICS_CAP_MULTIFINGER is set
to 0 in my case). So I think a solution would be at least checking
SYNAPTIC_CAP_MULTIFINGER and setting contacts_max depending on that
(3 if true, 1 if false). Maybe it is a bodge, but it works.

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.97
diff -u -p -r1.97 pms.c
--- pms.c   23 Jul 2022 05:55:16 -  1.97
+++ pms.c   18 Apr 2023 21:36:10 -
@@ -1075,7 +1075,10 @@ synaptics_get_hwinfo(struct pms_softc *s
hw->y_max = (max_coords ?
SYNAPTICS_Y_LIMIT(max_coords) : SYNAPTICS_YMAX_BEZEL);

-   hw->contacts_max = SYNAPTICS_MAX_FINGERS;
+   if(syn->capabilities & SYNAPTICS_CAP_MULTIFINGER)
+   hw->contacts_max = SYNAPTICS_MAX_FINGERS;
+   else
+   hw->contacts_max = 1;

syn->sec_buttons = 0;



[1]: /sys/dev/wscons/wstpad.c:1573
[2]: /sys/dev/pckbc/psm.c:1078

Here are relevant lines from dmesg(8):

pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
pms0: Synaptics touchpad, firmware 6.5, 0x1c0b1 0xa0 0x0 0xa04751 0x0

So I'm looking forward for comments on this. Has anybody experienced
something similar?

--
best regards,
la ninpre.



Re: pms: synaptics touchpad resume fix

2013-09-03 Thread Martin Pieuchot
On 02/09/13(Mon) 18:51, Stefan Sperling wrote:
 On Mon, Sep 02, 2013 at 02:32:50PM +0200, Martin Pieuchot wrote:
  You might also rely on the fact that if you have a sc-synaptics
  already allocated to try harder.  Because in this case you know
  that you have a synaptic touchpad.
 
 That works. Here's a simpler diff that fixes my issue, too.

I like it, I'd still prefer to introduce *_knock() function instead of
duplicating the magic sequence, but if you prefer it this way, go for
it. ok mpi@ either way.

 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.45
 diff -u -p -r1.45 pms.c
 --- pms.c 16 Jul 2013 08:11:39 -  1.45
 +++ pms.c 2 Sep 2013 16:44:48 -
 @@ -937,15 +937,38 @@ pms_enable_synaptics(struct pms_softc *s
   struct synaptics_softc *syn = sc-synaptics;
   struct wsmousedev_attach_args a;
   u_char resp[3];
 - int mode;
 + int mode, i;
  
   if (pms_set_resolution(sc, 0) ||
   pms_set_resolution(sc, 0) ||
   pms_set_resolution(sc, 0) ||
   pms_set_resolution(sc, 0) ||
   pms_get_status(sc, resp) ||
 - resp[1] != SYNAPTICS_ID_MAGIC)
 - goto err;
 + resp[1] != SYNAPTICS_ID_MAGIC) {
 + if (sc-synaptics == NULL)
 + goto err;
 + /* 
 +  * Some synaptics touchpads don't resume quickly.
 +  * Retry a few times.
 +  */
 + for (i = 10; i  0; --i) {
 + printf(%s: device not resuming, retrying\n,
 + DEVNAME(sc));
 + pms_reset(sc);
 + if (pms_set_resolution(sc, 0) ||
 + pms_set_resolution(sc, 0) ||
 + pms_set_resolution(sc, 0) ||
 + pms_set_resolution(sc, 0) ||
 + pms_get_status(sc, resp) ||
 + resp[1] == SYNAPTICS_ID_MAGIC)
 + break;
 + delay(10);
 + }
 + if (i == 0) {
 + printf(%s: lost device\n, DEVNAME(sc));
 + goto err;
 + }
 + }
  
   if (sc-synaptics == NULL) {
   sc-synaptics = syn = malloc(sizeof(struct synaptics_softc),
 



pms: synaptics touchpad resume fix

2013-09-02 Thread Stefan Sperling
I've got a synaptics touchpad which is taking a relatively large
amount of time to respond to the synaptics magic query during resume.

pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
wsmouse1 at pms0 mux 0
pms0: Synaptics clickpad, firmware 8.0

The pms(4) driver gives up on it quickly, and then I end up with no
mouse in X after resume. I have to restart X to get the mouse back,
which works because at that time the touchpad has become responsive again.

This diff fixes that issue by making the pms driver wait longer.
But I don't want it to wait this long during usual touchpad detection,
since that would get in the way when no synaptics touchpad is present.

I had to tweak the state machine to always go into 'suspend' state
to allow the driver to decide to wait longer only when resuming.
Before this change, the driver only transitioned into 'suspend'
state if the device was still open when pmsactivate() was called.
But since apparently the X server closes mouse devices on suspend,
the current state is already 'disabled' when we get to pmsactivate().
I could never see the driver go into 'suspend' state without this diff.

FWIW, I usually see 3 'pms0: device not resuming, retrying' lines
during resume but I gave it some additional headroom. Does anyone
using a synaptics touchpad see a different number of one or more lines?

Testing with any touchpad appreciated.

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.45
diff -u -p -r1.45 pms.c
--- pms.c   16 Jul 2013 08:11:39 -  1.45
+++ pms.c   2 Sep 2013 09:16:56 -
@@ -220,6 +220,8 @@ int pmsactivate(struct device *, int);
 void   pmsinput(void *, int);
 
 intpms_change_state(struct pms_softc *, int, int);
+void   pms_suspend_device(struct pms_softc *);
+void   pms_resume_device(struct pms_softc *);
 
 intpms_ioctl(void *, u_long, caddr_t, int, struct proc *);
 intpms_enable(void *);
@@ -685,14 +687,10 @@ pmsactivate(struct device *self, int act
 
switch (act) {
case DVACT_SUSPEND:
-   if (sc-sc_state == PMS_STATE_ENABLED)
-   pms_change_state(sc, PMS_STATE_SUSPENDED,
-   PMS_DEV_IGNORE);
+   pms_change_state(sc, PMS_STATE_SUSPENDED, PMS_DEV_IGNORE);
break;
case DVACT_RESUME:
-   if (sc-sc_state == PMS_STATE_SUSPENDED)
-   pms_change_state(sc, PMS_STATE_ENABLED,
-   PMS_DEV_IGNORE);
+   pms_change_state(sc, PMS_STATE_ENABLED, PMS_DEV_IGNORE);
break;
}
return (0);
@@ -725,37 +723,61 @@ pms_change_state(struct pms_softc *sc, i
 
switch (newstate) {
case PMS_STATE_ENABLED:
-   sc-inputstate = 0;
-
-   pckbc_slot_enable(sc-sc_kbctag, PCKBC_AUX_SLOT, 1);
-
-   if (sc-poll)
-   pckbc_flush(sc-sc_kbctag, PCKBC_AUX_SLOT);
-
-   pms_reset(sc);
-   if (sc-protocol-type == PMS_STANDARD ||
-   sc-protocol-enable(sc) == 0)
-   pms_protocol_lookup(sc);
-
-   pms_dev_enable(sc);
+   pms_resume_device(sc);
break;
case PMS_STATE_DISABLED:
case PMS_STATE_SUSPENDED:
-   pms_dev_disable(sc);
-
-   if (sc-protocol-disable)
-   sc-protocol-disable(sc);
-
-   pckbc_slot_enable(sc-sc_kbctag, PCKBC_AUX_SLOT, 0);
+   pms_suspend_device(sc);
break;
}
 
-   sc-sc_state = newstate;
+   if (sc-sc_state == PMS_STATE_SUSPENDED) {
+   /* 
+* We enabled the device during resume to re-detect it.
+* If the device isn't open we can disable it again now.
+*/
+   if (sc-sc_dev_enable == 0) {
+   pms_suspend_device(sc);
+   sc-sc_state = PMS_STATE_DISABLED;
+   } else
+   sc-sc_state = newstate;
+   } else
+   sc-sc_state = newstate;
+
sc-poll = (newstate == PMS_STATE_SUSPENDED) ? 1 : 0;
 
return (0);
 }
 
+void
+pms_resume_device(struct pms_softc *sc)
+{
+   sc-inputstate = 0;
+
+   pckbc_slot_enable(sc-sc_kbctag, PCKBC_AUX_SLOT, 1);
+
+   if (sc-poll)
+   pckbc_flush(sc-sc_kbctag, PCKBC_AUX_SLOT);
+
+   pms_reset(sc);
+   if (sc-protocol-type == PMS_STANDARD ||
+   sc-protocol-enable(sc) == 0)
+   pms_protocol_lookup(sc);
+
+   pms_dev_enable(sc);
+}
+
+void
+pms_suspend_device(struct pms_softc *sc)
+{
+   pms_dev_disable(sc);
+
+   if (sc-protocol-disable)
+   sc-protocol-disable(sc);
+
+   pckbc_slot_enable(sc-sc_kbctag, PCKBC_AUX_SLOT, 0);
+}
+
 int
 pms_enable(void *v)
 {
@@ -937,15 +959,38 @@ pms_enable_synaptics(struct pms_softc

Re: pms: synaptics touchpad resume fix

2013-09-02 Thread Martin Pieuchot
On 02/09/13(Mon) 11:44, Stefan Sperling wrote:
 I've got a synaptics touchpad which is taking a relatively large
 amount of time to respond to the synaptics magic query during resume.
 
 pms0 at pckbc0 (aux slot)
 wsmouse0 at pms0 mux 0
 wsmouse1 at pms0 mux 0
 pms0: Synaptics clickpad, firmware 8.0
 
 The pms(4) driver gives up on it quickly, and then I end up with no
 mouse in X after resume. I have to restart X to get the mouse back,
 which works because at that time the touchpad has become responsive again.
 
 This diff fixes that issue by making the pms driver wait longer.
 But I don't want it to wait this long during usual touchpad detection,
 since that would get in the way when no synaptics touchpad is present.

Did you consider checking for the value of 'cold' instead?

You might also rely on the fact that if you have a sc-synaptics
already allocated to try harder.  Because in this case you know
that you have a synaptic touchpad.

More generically I don't think that we need to resend the magic
sequence at every resume because the device should not change ;)

Martin



Re: pms: synaptics touchpad resume fix

2013-09-02 Thread Stefan Sperling
On Mon, Sep 02, 2013 at 02:32:50PM +0200, Martin Pieuchot wrote:
 You might also rely on the fact that if you have a sc-synaptics
 already allocated to try harder.  Because in this case you know
 that you have a synaptic touchpad.

That works. Here's a simpler diff that fixes my issue, too.

Index: pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.45
diff -u -p -r1.45 pms.c
--- pms.c   16 Jul 2013 08:11:39 -  1.45
+++ pms.c   2 Sep 2013 16:44:48 -
@@ -937,15 +937,38 @@ pms_enable_synaptics(struct pms_softc *s
struct synaptics_softc *syn = sc-synaptics;
struct wsmousedev_attach_args a;
u_char resp[3];
-   int mode;
+   int mode, i;
 
if (pms_set_resolution(sc, 0) ||
pms_set_resolution(sc, 0) ||
pms_set_resolution(sc, 0) ||
pms_set_resolution(sc, 0) ||
pms_get_status(sc, resp) ||
-   resp[1] != SYNAPTICS_ID_MAGIC)
-   goto err;
+   resp[1] != SYNAPTICS_ID_MAGIC) {
+   if (sc-synaptics == NULL)
+   goto err;
+   /* 
+* Some synaptics touchpads don't resume quickly.
+* Retry a few times.
+*/
+   for (i = 10; i  0; --i) {
+   printf(%s: device not resuming, retrying\n,
+   DEVNAME(sc));
+   pms_reset(sc);
+   if (pms_set_resolution(sc, 0) ||
+   pms_set_resolution(sc, 0) ||
+   pms_set_resolution(sc, 0) ||
+   pms_set_resolution(sc, 0) ||
+   pms_get_status(sc, resp) ||
+   resp[1] == SYNAPTICS_ID_MAGIC)
+   break;
+   delay(10);
+   }
+   if (i == 0) {
+   printf(%s: lost device\n, DEVNAME(sc));
+   goto err;
+   }
+   }
 
if (sc-synaptics == NULL) {
sc-synaptics = syn = malloc(sizeof(struct synaptics_softc),



Re: pms: synaptics touchpad resume fix

2013-09-02 Thread Alexandr Shadchin
On Mon, Sep 02, 2013 at 06:51:36PM +0200, Stefan Sperling wrote:
 On Mon, Sep 02, 2013 at 02:32:50PM +0200, Martin Pieuchot wrote:
  You might also rely on the fact that if you have a sc-synaptics
  already allocated to try harder.  Because in this case you know
  that you have a synaptic touchpad.
 
 That works. Here's a simpler diff that fixes my issue, too.
 

Maybe it makes sense to try to increase the response time

Index: pckbc.c
===
RCS file: /cvs/src/sys/dev/ic/pckbc.c,v
retrieving revision 1.36
diff -u -p -r1.36 pckbc.c
--- pckbc.c 23 May 2013 18:29:51 -  1.36
+++ pckbc.c 2 Sep 2013 18:24:19 -
@@ -616,7 +616,7 @@ pckbc_poll_cmd1(struct pckbc_internal *t
 
while (cmd-responseidx  cmd-responselen) {
if (cmd-flags  KBC_CMDFLAG_SLOW)
-   i = 100; /* 10s ??? */
+   i = 1000; /* 100s ??? */
else
i = 10; /* 1s ??? */
while (i--) {


or

Index: pckbc.c
===
RCS file: /cvs/src/sys/dev/ic/pckbc.c,v
retrieving revision 1.36
diff -u -p -r1.36 pckbc.c
--- pckbc.c 23 May 2013 18:29:51 -  1.36
+++ pckbc.c 2 Sep 2013 18:28:43 -
@@ -144,8 +144,8 @@ pckbc_poll_data1(bus_space_tag_t iot, bu
int i;
u_char stat;
 
-   /* polls for ~100ms */
-   for (i = 100; i; i--, delay(1000)) {
+   /* polls for ~1s */
+   for (i = 100; i; i--, delay(1)) {
stat = bus_space_read_1(iot, ioh_c, 0);
if (stat  KBS_DIB) {
register u_char c;



 Index: pms.c
 ===
 RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
 retrieving revision 1.45
 diff -u -p -r1.45 pms.c
 --- pms.c 16 Jul 2013 08:11:39 -  1.45
 +++ pms.c 2 Sep 2013 16:44:48 -
 @@ -937,15 +937,38 @@ pms_enable_synaptics(struct pms_softc *s
   struct synaptics_softc *syn = sc-synaptics;
   struct wsmousedev_attach_args a;
   u_char resp[3];
 - int mode;
 + int mode, i;
  
   if (pms_set_resolution(sc, 0) ||
   pms_set_resolution(sc, 0) ||
   pms_set_resolution(sc, 0) ||
   pms_set_resolution(sc, 0) ||
   pms_get_status(sc, resp) ||
 - resp[1] != SYNAPTICS_ID_MAGIC)
 - goto err;
 + resp[1] != SYNAPTICS_ID_MAGIC) {
 + if (sc-synaptics == NULL)
 + goto err;
 + /* 
 +  * Some synaptics touchpads don't resume quickly.
 +  * Retry a few times.
 +  */
 + for (i = 10; i  0; --i) {
 + printf(%s: device not resuming, retrying\n,
 + DEVNAME(sc));
 + pms_reset(sc);
 + if (pms_set_resolution(sc, 0) ||
 + pms_set_resolution(sc, 0) ||
 + pms_set_resolution(sc, 0) ||
 + pms_set_resolution(sc, 0) ||
 + pms_get_status(sc, resp) ||
 + resp[1] == SYNAPTICS_ID_MAGIC)
 + break;
 + delay(10);
 + }
 + if (i == 0) {
 + printf(%s: lost device\n, DEVNAME(sc));
 + goto err;
 + }
 + }
  
   if (sc-synaptics == NULL) {
   sc-synaptics = syn = malloc(sizeof(struct synaptics_softc),
 

-- 
Alexandr Shadchin



Re: pms: synaptics touchpad resume fix

2013-09-02 Thread Stefan Sperling
On Tue, Sep 03, 2013 at 12:22:32AM +0600, Alexandr Shadchin wrote:
 Maybe it makes sense to try to increase the response time

Changing these timeouts doesn't seem to make any difference.
It's still retrying 3 or 4 times after resume, then works.



Re: Synaptics touchpad

2011-07-22 Thread Alexander Polakov
* Alexandr Shadchin alexandr.shadc...@gmail.com [110719 22:52]:
 Hi,
 
 Please test latest patch for support Synaptics touchpad
 (or http://koba.devio.us/distfiles/synaptics.v5.diff)
 Patch for snapshot from 18-Jul-2011 or newer.
 
 It seems everything regression eliminated.

Works fine here:

pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
wsmouse1 at pms0 mux 0
pms0: Synaptics touchpad, firmware 7.4
 
-- 
Alexander Polakov | plhk.ru



Re: Synaptics touchpad

2011-07-20 Thread Alexandr Shadchin
On Tue, Jul 19, 2011 at 06:12:13PM -0400, Brynet wrote:
 Still works for me, will the wscons backend for xf86-input-synaptics be sent 
 upstream eventually? :-)
 

Thanks for test. I plan to send patch after testing is complete.

 pms0: Synaptics touchpad, firmware 7.2
 ..
 
 .xinitrc/.xsession:
 xinput set-int-prop /dev/wsmouse0 Synaptics Tap Action 8 3 0 2 0 1 0 0
 xinput set-int-prop /dev/wsmouse0 Synaptics Edge Scrolling 8 1 0 0
 xinput set-int-prop /dev/wsmouse0 Synaptics Two-Finger Scrolling 8 0 0
 syndaemon -d -t -K
 
 This enables scrolling in xterm etc and left button tapping.
 
 -Bryan.
 

-- 
Alexandr Shadchin



Synaptics touchpad

2011-07-19 Thread Alexandr Shadchin
Hi,

Please test latest patch for support Synaptics touchpad
(or http://koba.devio.us/distfiles/synaptics.v5.diff)
Patch for snapshot from 18-Jul-2011 or newer.

It seems everything regression eliminated.

-- 
Alexandr Shadchin

Index: dev/pckbc/pms.c
===
RCS file: /cvs/src/sys/dev/pckbc/pms.c,v
retrieving revision 1.18
diff -u -p -r1.18 pms.c
--- dev/pckbc/pms.c 3 Jan 2011 19:46:34 -   1.18
+++ dev/pckbc/pms.c 6 Jul 2011 06:35:28 -
@@ -28,6 +28,7 @@
 #include sys/systm.h
 #include sys/device.h
 #include sys/ioctl.h
+#include sys/malloc.h
 
 #include machine/bus.h
 
@@ -40,12 +41,15 @@
 
 #define DEVNAME(sc)((sc)-sc_dev.dv_xname)
 
+#define WSMOUSE_BUTTON(x)  (1  ((x) - 1))
+
 struct pms_softc;
 
 struct pms_protocol {
int type;
 #define PMS_STANDARD   0
 #define PMS_INTELLI1
+#define PMS_SYNAPTICS  2
u_int packetsize;
int (*enable)(struct pms_softc *);
int (*ioctl)(struct pms_softc *, u_long, caddr_t, int, struct proc *);
@@ -54,6 +58,26 @@ struct pms_protocol {
void (*disable)(struct pms_softc *);
 };
 
+struct synaptics_softc {
+   int identify;
+   int capabilities, ext_capabilities;
+   int model, ext_model;
+   int resolution, dimension;
+
+   int mode;
+
+   int res_x, res_y;
+   int min_x, min_y;
+   int max_x, max_y;
+
+   /* Compat mode */
+   int wsmode;
+   int old_x, old_y;
+   u_int old_buttons;
+#define SYNAPTICS_SCALE4
+#define SYNAPTICS_PRESSURE 30
+};
+
 struct pms_softc { /* driver status information */
struct device sc_dev;
 
@@ -64,56 +88,47 @@ struct pms_softc {  /* driver status inf
 #define PMS_STATE_ENABLED  1
 #define PMS_STATE_SUSPENDED2
 
+   int sc_dev_enable;
+#define PMS_DEV_IGNORE 0x00
+#define PMS_DEV_PRIMARY0x01
+#define PMS_DEV_SECONDARY  0x02
+
int poll;
int inputstate;
 
const struct pms_protocol *protocol;
+   struct synaptics_softc *synaptics;
 
u_char packet[8];
 
struct device *sc_wsmousedev;
+   struct device *sc_pt_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
+   WSMOUSE_BUTTON(1),
+   WSMOUSE_BUTTON(3),
+   WSMOUSE_BUTTON(1) | WSMOUSE_BUTTON(3),
+   WSMOUSE_BUTTON(2),
+   WSMOUSE_BUTTON(1) | WSMOUSE_BUTTON(2),
+   WSMOUSE_BUTTON(2) | WSMOUSE_BUTTON(3),
+   WSMOUSE_BUTTON(1) | WSMOUSE_BUTTON(2) | WSMOUSE_BUTTON(3)
 };
 
-/* 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
-
-#define PMS_INTELLI_MAGIC1 200
-#define PMS_INTELLI_MAGIC2 100
-#define PMS_INTELLI_MAGIC3 80
-#define PMS_INTELLI_ID 0x03
-
 intpmsprobe(struct device *, void *, void *);
 void   pmsattach(struct device *, struct device *, void *);
 intpmsactivate(struct device *, int);
 
 void   pmsinput(void *, int);
 
-intpms_change_state(struct pms_softc *, int);
+intpms_change_state(struct pms_softc *, int, int);
 intpms_ioctl(void *, u_long, caddr_t, int, struct proc *);
 intpms_enable(void *);
 void   pms_disable(void *);
 
 intpms_cmd(struct pms_softc *, u_char *, int, u_char *, int);
+intpms_spec_cmd(struct pms_softc *, int);
 intpms_get_devid(struct pms_softc *, u_char *);
 intpms_get_status(struct pms_softc *, u_char *);
 intpms_set_rate(struct pms_softc *, int);
@@ -129,6 +144,22 @@ intpms_ioctl_mouse(struct pms_softc *, 
 intpms_sync_mouse(struct pms_softc *, int);
 void   pms_proc_mouse(struct pms_softc *);
 
+intpms_enable_synaptics(struct pms_softc *);
+intpms_ioctl_synaptics(struct pms_softc *, u_long, caddr_t, int, struct 
proc *);
+intpms_sync_synaptics(struct pms_softc *, int);
+void   pms_proc_synaptics(struct pms_softc *);
+void   pms_disable_synaptics(struct pms_softc *);
+
+intsynaptics_set_mode(struct pms_softc *, int);
+intsynaptics_query(struct pms_softc *, int, int *);
+intsynaptics_get_hwinfo(struct pms_softc *);
+
+void   synaptics_pt_proc(struct pms_softc *);
+
+intsynaptics_pt_ioctl(void *, u_long, caddr_t, int, struct proc *);
+intsynaptics_pt_enable(void *);
+void   synaptics_pt_disable(void *);
+
 struct

Re: Synaptics touchpad

2011-06-15 Thread Alexandr Shadchin
On Tue, Jun 14, 2011 at 09:35:04PM +0200, Matthieu Herrb wrote:
 On Mon, Jun 13, 2011 at 08:23:16PM -0500, joshua stein wrote:
   I find the mouse emulation code for synaptics touch pads in your patch 
   really weird. I've tried to understand what it does, and why it
   behaves badly for me on the first tap (move the pointer in the upper
   right direction every time), but I fail to understand the logic.
  
  your change makes the problem worse on 2 laptops (samsung series 9
  and thinkpad x220), where the cursor now jumps to the lower left
  after every movement.  these seem to be due to events that come
  through after removing all the fingers from the touchpad that need
  to be ignored.  i checked linux and they also ignore these events:
  
  http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4f56ce929cab45a3a6e1a81700da52bb9bdbfc0f
  
  this also adds support for clickpads where there is only one
  physical button and it's the entire trackpad that moves down, which
  both of those laptops have.  without this change, the click gets
  ignored.
 
 With your patch my synaptics driver is recognized as a clickpad, but I
 can't get no click from it. Otherwise the emulation works fine for
 me. 
 
 Hopefully with the configuration changes I'm working on, most people
 will get the synaptics driver and thus won't need this emulation mode.
 
  
  
  --- pms.c.new   Mon Jun 13 16:26:39 2011
  +++ pms.c   Mon Jun 13 20:06:59 2011
  @@ -799,7 +799,9 @@
  syn-wsmode = WSMOUSE_COMPAT;
  syn-count = 0;
   
  -   printf(%s: Synaptics touchpad, firmware %d.%d\n, DEVNAME(sc),
  +   printf(%s: Synaptics %s, firmware %d.%d\n, DEVNAME(sc),
  +   (syn-capabilities  SYNAPTICS_EXT_CAP_CLICKPAD ?
 ^
   should be syn-ext_capabilities ;-)

-- 
Alexandr Shadchin



Re: Synaptics touchpad

2011-06-14 Thread Matthieu Herrb
On Mon, Jun 13, 2011 at 08:23:16PM -0500, joshua stein wrote:
  I find the mouse emulation code for synaptics touch pads in your patch 
  really weird. I've tried to understand what it does, and why it
  behaves badly for me on the first tap (move the pointer in the upper
  right direction every time), but I fail to understand the logic.
 
 your change makes the problem worse on 2 laptops (samsung series 9
 and thinkpad x220), where the cursor now jumps to the lower left
 after every movement.  these seem to be due to events that come
 through after removing all the fingers from the touchpad that need
 to be ignored.  i checked linux and they also ignore these events:
 
 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4f56ce929cab45a3a6e1a81700da52bb9bdbfc0f
 
 this also adds support for clickpads where there is only one
 physical button and it's the entire trackpad that moves down, which
 both of those laptops have.  without this change, the click gets
 ignored.

With your patch my synaptics driver is recognized as a clickpad, but I
can't get no click from it. Otherwise the emulation works fine for
me. 

Hopefully with the configuration changes I'm working on, most people
will get the synaptics driver and thus won't need this emulation mode.

 
 
 --- pms.c.new Mon Jun 13 16:26:39 2011
 +++ pms.c Mon Jun 13 20:06:59 2011
 @@ -799,7 +799,9 @@
   syn-wsmode = WSMOUSE_COMPAT;
   syn-count = 0;
  
 - printf(%s: Synaptics touchpad, firmware %d.%d\n, DEVNAME(sc),
 + printf(%s: Synaptics %s, firmware %d.%d\n, DEVNAME(sc),
 + (syn-capabilities  SYNAPTICS_EXT_CAP_CLICKPAD ?
 + clickpad : touchpad),
   SYNAPTICS_ID_MAJOR(syn-identify),
   SYNAPTICS_ID_MINOR(syn-identify));
   }
 @@ -882,8 +884,11 @@
   buttons |= ((sc-packet[0]  0x02)  (sc-packet[3]  0x02)) ?
   WSMOUSE_BUTTON(3) : 0;
  
 - if (syn-capabilities  SYNAPTICS_CAP_MIDDLE_BUTTON) {
 + if (syn-ext_capabilities  SYNAPTICS_EXT_CAP_CLICKPAD) {
   buttons |= ((sc-packet[0]  0x01) ^ (sc-packet[3]  0x01)) ?
 + WSMOUSE_BUTTON(1) : 0;
 + } else if (syn-capabilities  SYNAPTICS_CAP_MIDDLE_BUTTON) {
 + buttons |= ((sc-packet[0]  0x01) ^ (sc-packet[3]  0x01)) ?
   WSMOUSE_BUTTON(2) : 0;
   }
  
 @@ -906,6 +911,14 @@
   y = ~0x0f;
   }
  
 + /* ignore final events that happen when removing all fingers */
 + if (x = 1  !z) {
 + x = syn-old_x;
 + y = syn-old_y;
 + w = 0;
 + buttons = 0;
 + }
 +
   if (syn-wsmode == WSMOUSE_NATIVE) {
   wsmouse_input(sc-sc_wsmousedev, buttons, x, y, z, w,
   WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y |
 @@ -925,10 +938,11 @@
   if (dx || dy || buttons != syn-old_buttons) 
   wsmouse_input(sc-sc_wsmousedev, buttons, dx, dy, 0, 0,
   WSMOUSE_INPUT_DELTA);
 - syn-old_x = x;
 - syn-old_y = y;
   syn-old_buttons = buttons;
   }
 +
 + syn-old_x = x;
 + syn-old_y = y;
  }
  
  void
 

-- 
Matthieu Herrb



Re: Synaptics touchpad

2011-06-13 Thread joshua stein
 I find the mouse emulation code for synaptics touch pads in your patch 
 really weird. I've tried to understand what it does, and why it
 behaves badly for me on the first tap (move the pointer in the upper
 right direction every time), but I fail to understand the logic.

your change makes the problem worse on 2 laptops (samsung series 9
and thinkpad x220), where the cursor now jumps to the lower left
after every movement.  these seem to be due to events that come
through after removing all the fingers from the touchpad that need
to be ignored.  i checked linux and they also ignore these events:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4f56ce929cab45a3a6e1a81700da52bb9bdbfc0f

this also adds support for clickpads where there is only one
physical button and it's the entire trackpad that moves down, which
both of those laptops have.  without this change, the click gets
ignored.


--- pms.c.new   Mon Jun 13 16:26:39 2011
+++ pms.c   Mon Jun 13 20:06:59 2011
@@ -799,7 +799,9 @@
syn-wsmode = WSMOUSE_COMPAT;
syn-count = 0;
 
-   printf(%s: Synaptics touchpad, firmware %d.%d\n, DEVNAME(sc),
+   printf(%s: Synaptics %s, firmware %d.%d\n, DEVNAME(sc),
+   (syn-capabilities  SYNAPTICS_EXT_CAP_CLICKPAD ?
+   clickpad : touchpad),
SYNAPTICS_ID_MAJOR(syn-identify),
SYNAPTICS_ID_MINOR(syn-identify));
}
@@ -882,8 +884,11 @@
buttons |= ((sc-packet[0]  0x02)  (sc-packet[3]  0x02)) ?
WSMOUSE_BUTTON(3) : 0;
 
-   if (syn-capabilities  SYNAPTICS_CAP_MIDDLE_BUTTON) {
+   if (syn-ext_capabilities  SYNAPTICS_EXT_CAP_CLICKPAD) {
buttons |= ((sc-packet[0]  0x01) ^ (sc-packet[3]  0x01)) ?
+   WSMOUSE_BUTTON(1) : 0;
+   } else if (syn-capabilities  SYNAPTICS_CAP_MIDDLE_BUTTON) {
+   buttons |= ((sc-packet[0]  0x01) ^ (sc-packet[3]  0x01)) ?
WSMOUSE_BUTTON(2) : 0;
}
 
@@ -906,6 +911,14 @@
y = ~0x0f;
}
 
+   /* ignore final events that happen when removing all fingers */
+   if (x = 1  !z) {
+   x = syn-old_x;
+   y = syn-old_y;
+   w = 0;
+   buttons = 0;
+   }
+
if (syn-wsmode == WSMOUSE_NATIVE) {
wsmouse_input(sc-sc_wsmousedev, buttons, x, y, z, w,
WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y |
@@ -925,10 +938,11 @@
if (dx || dy || buttons != syn-old_buttons) 
wsmouse_input(sc-sc_wsmousedev, buttons, dx, dy, 0, 0,
WSMOUSE_INPUT_DELTA);
-   syn-old_x = x;
-   syn-old_y = y;
syn-old_buttons = buttons;
}
+
+   syn-old_x = x;
+   syn-old_y = y;
 }
 
 void



Re: Synaptics touchpad

2011-05-10 Thread Alexandr Shadchin
On Mon, May 09, 2011 at 11:29:14PM +0200, Matthieu Herrb wrote:
 On Mon, May 09, 2011 at 04:14:32PM -0400, Brynet wrote:
  I noticed the following in my Xorg.0.log:
  
  Touchpad0: invalid pressure range. defaulting to 0 - 256
  Touchpad0: invalid finger width range. defaulting to 0 - 16
  
  Just curious if that's normal.
 
 More or less. The test and the error message are lame, to say that the 
 hw specific layer (wsconscomm.c) didn't set the values. 
 
 Alexandr, I wonder if it's possible to get these filled from the pms
 driver (it probably means adding more ioctls :()
 -- 
 Matthieu Herrb

The ranges for pressure and width specified in datasheet.
I do not see a need for new ioctls. I think is better to explicitly 
define minp, maxp (etc.) in wsconscomm.c. This will remove confusing 
messages. 

-- 
Alexandr Shadchin

Index: wsconscomm.c
===
RCS file: /cvs/xenocara/driver/xf86-input-synaptics/src/wsconscomm.c,v
retrieving revision 1.2
diff -u -p -r1.2 wsconscomm.c
--- wsconscomm.c7 May 2011 17:30:31 -   1.2
+++ wsconscomm.c10 May 2011 07:09:20 -
@@ -243,6 +243,12 @@ WSConsReadDevDimensions(InputInfoPtr pIn
 xf86Msg(X_PROBED, %s: y-axis range %d - %d resolution %d\n,
 pInfo-name, priv-miny, priv-maxy, priv-resy);
 
+priv-minp = 0;
+priv-maxp = 256;
+
+priv-minw = 0;
+priv-maxw = 16;
+
 priv-has_pressure = TRUE;
 priv-has_width = TRUE;
 priv-has_left = TRUE;



Re: Synaptics touchpad

2011-05-09 Thread jirib
On Sun, 8 May 2011 06:36:46 +0600
Alexandr Shadchin alexandr.shadc...@gmail.com wrote:

 Driver xf86-input-synaptics need to build manually:
 
 update src and xenocara tree
 cd /usr/src
 make obj includes
 cd /usr/xenocara/driver/xf86-input-synaptics
 make -f Makefile.bsd-wrapper obj build

Looks like it is now linked to build by default, great!

Log message:
Enable xf86-input-synaptics on i386 and amd64.

Thx all!

jirib



Re: Synaptics touchpad

2011-05-09 Thread Alexandr Shadchin
On Sun, May 08, 2011 at 11:16:40AM +0200, Matthieu Herrb wrote:
 Hi again,
 
 I find the mouse emulation code for synaptics touch pads in your patch 
 really weird. I've tried to understand what it does, and why it
 behaves badly for me on the first tap (move the pointer in the upper
 right direction every time), but I fail to understand the logic.
 
 So I've written a different code which produces better results and is
 simpler to understand. It computes relative motion events
 after the 2nd one, and sends any event with relative motion or button
 state changes.
 
 This is a diff against the pms.c resulting of your previous patch to tech@
 

I agree, my implementation weird, your best :-)
Thanks.

-- 
Alexandr Shadchin



Re: Synaptics touchpad

2011-05-09 Thread Matthieu Herrb
On Sun, May 08, 2011 at 09:58:44PM -0400, Brynet wrote:
 Thanks to both of you, it works fairly well on my Acer Aspire 5551 laptop 
 with 
 Synaptics 7.2 firmware.
 
 What's the prefered method of configuration? xorg.conf/synclient or
 xinput?

It depends on a lot of things. If you're using Gnome/KDE/XFCE and it
has a builting configuration widget for synaptics, use whatever they
provide. Otherwise, xorg.conf is good for defaults you want to keep
for all users.

The synclient program should be mostly useless now that xinput
provides a device-independant way to configure input
devices. Unfortunatly the 'xinput(1)' command is not really
user-friendly, so synclient may still be useful in a .xsession or
.xinitrc if someone wants to setup things for one session only.

 
 I use the following from .xintrc/.xsession:
 synclient TapButton1=1
 synclient TapButton2=2
 synclient TapButton3=3
 synclient VertEdgeScroll=1
 synclient VertTwoFingerScroll=0
 syndaemon -d -t -K
 
 The sensitivity is a bit high for tap-to-click though, especially for buttons 
 2 
 and 3.. for bringing up cwm menu's, etc.

There are several parameters (FingerLow/FingerHigh, 
MaxTapTIme, MaxDoubleTapTime) that can influnce this. Play with them. 

 
 It's still something that has been missing for a long time, the physical 
 buttons are annoying to use on my laptop.. fortunately button 1 was 
 implemented 
 in the firmware (..and hence worked with xf86-input-mouse).

That's not too hard to add to the emulation mode. I just don't want to
add too many features to that mode (that would end up implementing the whole
xf86-input-synaptics driver in the kernel).

-- 
Matthieu Herrb



Re: Synaptics touchpad

2011-05-09 Thread Brynet
I noticed the following in my Xorg.0.log:

Touchpad0: invalid pressure range. defaulting to 0 - 256
Touchpad0: invalid finger width range. defaulting to 0 - 16

Just curious if that's normal.

-Bryan.



Re: Synaptics touchpad

2011-05-08 Thread Matthieu Herrb
On Sun, May 08, 2011 at 06:36:46AM +0600, Alexandr Shadchin wrote:
 Hi,
 
 Default touchpad behaves as mouse (compatible with xf86-input-mouse)
 for full power need used xf86-input-synaptics. 
 
 Please check work of touchpad in compat mode (xf86-input-mouse),
 who are interested check xf86-input-synaptics.
 
 Driver xf86-input-synaptics need to build manually:

We will provide some xserver patch in the future to automatically
generate it when no xorg.conf is present and a synaptics touchpad is
deteced, but in the mean time you need this sample xorg.conf
fragment (which can be used alone if you don't have any xorg.conf) to
enable the xf86-input-synaptics driver for the touchpad, while still
allowing an external (usb or ps/2) mouse to be used with the
xf86-input-mouse driver:

Section InputDevice
Identifier  Touchpad0
Driver  synaptics
Option  Device /dev/wsmouse0
Option  AutoServerLayout True
EndSection

Section InputDevice
Identifier  Mouse0
Driver  mouse
Option  Device /dev/wsmouse
Option  AutoServerLayout True
EndSection

(the Device sections are important).

If you don't explicitely setup the xf86-input-synaptics driver in
xorg.conf, the xf86-input-mouse driver will still handle all
wsmouse(4) input events, and you won't benifit of any enhanced
features for the synaptics driver.

when a synaptics touchpad is detected by the pms(4) driver, it will
enable all the synaptics firmware features, but still provide a
standard relative pointer to wsmouse(4) until a specific ioctl() is
issued to switch to the native synaptics protocol. This ioctl is used
by the xf86-input-synaptics driver to unleash the extra features.
-- 
Matthieu Herrb



Re: Synaptics touchpad

2011-05-08 Thread Matthieu Herrb
Hi again,

I find the mouse emulation code for synaptics touch pads in your patch 
really weird. I've tried to understand what it does, and why it
behaves badly for me on the first tap (move the pointer in the upper
right direction every time), but I fail to understand the logic.

So I've written a different code which produces better results and is
simpler to understand. It computes relative motion events
after the 2nd one, and sends any event with relative motion or button
state changes.

This is a diff against the pms.c resulting of your previous patch to tech@

--- pms.c.asSun May  8 10:49:02 2011
+++ pms.c   Sun May  8 11:14:05 2011
@@ -73,11 +73,10 @@
/* Compat mode */
int wsmode;
int old_x, old_y;
+   u_int old_buttons;
int count;
-#define SYNAPTICS_COUNT2
 #define SYNAPTICS_SCALE4
 #define SYNAPTICS_PRESSURE 30
-#define SYNAPTICS_MAXSPEED 30
 
int dev_pt_attach;
 };
@@ -912,36 +911,23 @@
WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y |
WSMOUSE_INPUT_ABSOLUTE_Z | WSMOUSE_INPUT_ABSOLUTE_W);
} else {
-   if (syn-count  SYNAPTICS_COUNT) {
-   syn-old_x += x;
-   syn-old_y += y;
-   syn-count++;
-   return;
+   dx = dy = 0;
+   if (syn-count != 0) {
+   dx = x - syn-old_x;
+   dy = y - syn-old_y;
+   dx /= SYNAPTICS_SCALE;
+   dy /= SYNAPTICS_SCALE;
}
-
-   syn-old_x /= SYNAPTICS_COUNT;
-   syn-old_y /= SYNAPTICS_COUNT;
-   dx = x - syn-old_x;
-   dy = y - syn-old_y;
-   syn-old_x = (dx % SYNAPTICS_SCALE) * SYNAPTICS_COUNT;
-   syn-old_y = (dy % SYNAPTICS_SCALE) * SYNAPTICS_COUNT;
-   dx /= SYNAPTICS_SCALE;
-   dy /= SYNAPTICS_SCALE;
-   syn-count = 0;
-
-   if (z  SYNAPTICS_PRESSURE) {
-   dx = dy = 0;
-   syn-old_x = syn-old_y = 0;
+   if (z  SYNAPTICS_PRESSURE)
syn-count = 0;
-   }
-
-   if (abs(dx)  SYNAPTICS_MAXSPEED)
-   dx = SYNAPTICS_MAXSPEED * dx / abs(dx);
-   if (abs(dy)  SYNAPTICS_MAXSPEED)
-   dy = SYNAPTICS_MAXSPEED * dy / abs(dy);
-
-   wsmouse_input(sc-sc_wsmousedev, buttons, dx, dy, 0, 0,
-   WSMOUSE_INPUT_DELTA);
+   else
+   syn-count++;
+   if (dx || dy || buttons != syn-old_buttons) 
+   wsmouse_input(sc-sc_wsmousedev, buttons, dx, dy, 0, 0,
+   WSMOUSE_INPUT_DELTA);
+   syn-old_x = x;
+   syn-old_y = y;
+   syn-old_buttons = buttons;
}
 }
 

-- 
Matthieu Herrb



Re: Synaptics touchpad

2011-05-08 Thread Brynet
Thanks to both of you, it works fairly well on my Acer Aspire 5551 laptop with 
Synaptics 7.2 firmware.

What's the prefered method of configuration? xorg.conf/synclient or xinput?

I use the following from .xintrc/.xsession:
synclient TapButton1=1
synclient TapButton2=2
synclient TapButton3=3
synclient VertEdgeScroll=1
synclient VertTwoFingerScroll=0
syndaemon -d -t -K

The sensitivity is a bit high for tap-to-click though, especially for buttons 2 
and 3.. for bringing up cwm menu's, etc.

It's still something that has been missing for a long time, the physical 
buttons are annoying to use on my laptop.. fortunately button 1 was implemented 
in the firmware (..and hence worked with xf86-input-mouse).

-Bryan.



Synaptics touchpad

2011-05-07 Thread Alexandr Shadchin
 *, int);
+intsynaptics_query(struct pms_softc *, int, int *);
+
+void   synaptics_pt_proc(struct pms_softc *);
+
+intsynaptics_pt_ioctl(void *, u_long, caddr_t, int, struct proc *);
+intsynaptics_pt_enable(void *);
+void   synaptics_pt_disable(void *);
+
 struct cfattach pms_ca = {
sizeof(struct pms_softc), pmsprobe, pmsattach, NULL,
pmsactivate
@@ -144,6 +179,12 @@ const struct wsmouse_accessops pms_acces
pms_disable,
 };
 
+const struct wsmouse_accessops synaptics_pt_accessops = {
+   synaptics_pt_enable,
+   synaptics_pt_ioctl,
+   synaptics_pt_disable,
+};
+
 const struct pms_protocol pms_mouse[] = {
/* Generic PS/2 mouse */
{
@@ -165,6 +206,18 @@ const struct pms_protocol pms_mouse[] = 
}
 };
 
+const struct pms_protocol pms_touchpad[] = {
+   /* Synaptics touchpad */
+   {
+   PMS_SYNAPTICS, 6,
+   pms_enable_synaptics,
+   pms_ioctl_synaptics,
+   pms_sync_synaptics,
+   pms_proc_synaptics,
+   pms_disable_synaptics
+   }
+};
+
 int
 pms_cmd(struct pms_softc *sc, u_char *cmd, int len, u_char *resp, int resplen)
 {
@@ -178,6 +231,18 @@ pms_cmd(struct pms_softc *sc, u_char *cm
 }
 
 int
+pms_spec_cmd(struct pms_softc *sc, int cmd)
+{
+   if (pms_set_scaling(sc, 1) ||
+   pms_set_resolution(sc, (cmd  6)  0x03) ||
+   pms_set_resolution(sc, (cmd  4)  0x03) ||
+   pms_set_resolution(sc, (cmd  2)  0x03) ||
+   pms_set_resolution(sc, (cmd  0)  0x03))
+   return (-1);
+   return (0);
+}
+
+int
 pms_get_devid(struct pms_softc *sc, u_char *resp)
 {
u_char cmd[1];
@@ -395,6 +460,7 @@ pmsattach(struct device *parent, struct 
struct pms_softc *sc = (void *)self;
struct pckbc_attach_args *pa = aux;
struct wsmousedev_attach_args a;
+   int i;
 
sc-sc_kbctag = pa-pa_tag;
 
@@ -414,11 +480,26 @@ pmsattach(struct device *parent, struct 
 */
sc-sc_wsmousedev = config_found(self, a, wsmousedevprint);
 
-   /* no interrupts until enabled */
sc-poll = 1;
-   pms_change_state(sc, PMS_STATE_ENABLED);
-   sc-poll = 1; /* XXX */
-   pms_change_state(sc, PMS_STATE_DISABLED);
+
+   sc-sc_dev_enable = 0;
+
+   /* init protocol as generic mouse */
+   sc-protocol = pms_mouse[0];
+
+   /* try detect touchpad */
+   sc-is_touchpad = 0;
+   for (i = 0; i  nitems(pms_touchpad); i++) {
+   pms_reset(sc);
+   if (pms_touchpad[i].enable(sc)) {
+   sc-protocol = pms_touchpad[i];
+   sc-is_touchpad = 1;
+   break;
+   }
+   }
+
+   /* no interrupts until enabled */
+   pms_change_state(sc, PMS_STATE_DISABLED, PMS_DEV_IGNORE);
 }
 
 int
@@ -429,26 +510,47 @@ pmsactivate(struct device *self, int act
switch (act) {
case DVACT_SUSPEND:
if (sc-sc_state == PMS_STATE_ENABLED)
-   pms_change_state(sc, PMS_STATE_SUSPENDED);
+   pms_change_state(sc, PMS_STATE_SUSPENDED,
+   PMS_DEV_IGNORE);
break;
case DVACT_RESUME:
if (sc-sc_state == PMS_STATE_SUSPENDED)
-   pms_change_state(sc, PMS_STATE_ENABLED);
+   pms_change_state(sc, PMS_STATE_ENABLED,
+   PMS_DEV_IGNORE);
break;
}
return (0);
 }
 
 int
-pms_change_state(struct pms_softc *sc, int newstate)
+pms_change_state(struct pms_softc *sc, int newstate, int dev)
 {
int i;
 
+   if (dev != PMS_DEV_IGNORE) {
+   switch (newstate) {
+   case PMS_STATE_ENABLED:
+   if (sc-sc_dev_enable  dev)
+   return (EBUSY);
+
+   sc-sc_dev_enable |= dev;
+
+   if (sc-sc_state == PMS_STATE_ENABLED)
+   return (0);
+
+   break;
+   case PMS_STATE_DISABLED:
+   sc-sc_dev_enable = ~dev;
+
+   if (sc-sc_dev_enable)
+   return (0);
+
+   break;
+   }
+   }
+
switch (newstate) {
case PMS_STATE_ENABLED:
-   if (sc-sc_state == PMS_STATE_ENABLED)
-   return (EBUSY);
-
sc-inputstate = 0;
 
pckbc_slot_enable(sc-sc_kbctag, PCKBC_AUX_SLOT, 1);
@@ -458,10 +560,14 @@ pms_change_state(struct pms_softc *sc, i
 
pms_reset(sc);
 
-   sc-protocol = pms_mouse[0];
-   for (i = 1; i  nitems(pms_mouse); i++)
-   if (pms_mouse[i].enable(sc))
-   sc-protocol = pms_mouse[i];
+   if (sc-is_touchpad) {
+   sc-protocol-enable(sc

WIP: Support Synaptics touchpad

2011-03-15 Thread Aaron Bieber
Hi 

I am running the synaptics patch on -current amd64. Seems to be running
great! 

dmesg:
pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
wsmouse1 at pms0 mux 0

I have touchpad+trackpoint enabled on a lenovo t410 

Cheers,
Aaron



WIP: Support Synaptics touchpad

2010-11-03 Thread Alexandr Shadchin
Hi!

Add support Synaptics touchpad (includes rework pms)

Build:

cd /tmp
ftp http://koba.devio.us/distfiles/synaptics.diff
cd /usr/src/sys
patch -p0 /tmp/synaptics.diff
...
(build and install kernel, reboot)
...
cd /tmp
ftp http://koba.devio.us/distfiles/xf86-input-synaptics.tgz
cd /usr/src
make includes
cd /usr/xenocara/driver
tar zxf /tmp/xf86-input-synaptics.tgz
cd xf86-input-synaptics
env XENOCARA_RERUN_AUTOCONF=Yes make -f Makefile.bsd-wrapper build

xorg.conf:

If only touchpad:

Section ServerLayout
...
InputDevice Mouse0 CorePointer
...
EndSection

# Touchpad
Section InputDevice
Identifier  Mouse0
Driver  synaptics
Option  Protocol wsmouse
Option  Device /dev/wsmouse0
...
EndSection

If touchpad+trackpoint:

Section ServerLayout
...
InputDevice Mouse0 CorePointer
InputDevice Mouse1 SendCoreEvents
...
EndSection

# Touchpad
Section InputDevice
Identifier  Mouse0
Driver  synaptics
Option  Protocol wsmouse
Option  Device /dev/wsmouse0
...
EndSection

# Trackpoint
Section InputDevice
Identifier  Mouse1
Driver  mouse
Option  Protocol wsmouse
Option  Device /dev/wsmouse1
...
EndSection

Test, comment ;-)
Who will test, send your dmesg (sufficient grep pms0)

-- 
Alexandr Shadchin