Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jun 2014 09:07:50 -0400
From:      Anthony Jenkins <Scoobi_doo@yahoo.com>
To:        Eric McCorkle <eric@metricspace.net>,  Ivan Rokotov <ivan.rokotov.bsd@gmail.com>
Cc:        "freebsd-mobile@freebsd.org" <freebsd-mobile@freebsd.org>
Subject:   Re: [Patch] psm(4) ClickPad detection (was Re: Lenovo W540 so far)
Message-ID:  <53A03DA6.90904@yahoo.com>
In-Reply-To: <53A03BAF.3020807@yahoo.com>
References:  <539DA73B.7050709@metricspace.net>	<CAOTTJKEamc=tsFJxz0H43wxhJpowy0Nm-4JBCjozzi%2Brfcp=6Q@mail.gmail.com>	<1402931204.35984.YahooMailNeo@web140703.mail.bf1.yahoo.com>	<58DCAA2E-44DA-48F3-87B3-366301F55138@metricspace.net> <CAOTTJKFwXJOyaW-7fX3300jfBu4WQYqgte%2BuE9cvej_NxULAPw@mail.gmail.com> <53A02532.60201@metricspace.net> <53A03BAF.3020807@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 06/17/2014 08:59, Anthony Jenkins wrote:
> On 06/17/2014 07:23, Eric McCorkle wrote:
>> Thanks again.  That did it.  The touchpad is now completely working :D
>>
>> Only thing is it seems you can't use it along with moused/sysmouse.  I assume this is because whatever protocol moused speaks is pre-multitouch.
>>
>> I suppose that would also mean that you couldn't plug in a USB mouse and have it just work with this setup.  This also seems to keep the trackpoint from working (not that I ever use it...)
>>
>> On 06/16/2014 19:21, Ivan Rokotov wrote:
>>> 2014-06-16 21:41 GMT+02:00 Eric McCorkle <eric@metricspace.net>:
>>>> There's no virtual scrolling though.  Has that been added to the driver yet,
>>>> or am I missing some config items?
>>> Eric, what do you mean by virtual scrolling? In my case, two-finger
>>> scrolling and edge scrolling are working (both horizontal and
>>> vertical).
>>>
>>> Option "VertEdgeScroll" "on"
>>> Option "HorizEdgeScroll" "on"
>>> Option "VertTwoFingerScroll" "1"
>>> Option "HorizTwoFingerScroll" "1"
>>> Option "VertScrollDelta" "-50"
>>> Option "HorizScrollDelta" "-60"
>>>
>>> (minus is for mac-style 'natural scrolling').
>>>
>>> Or you mean something else?
>>> Ivan
>>>
> The moused/sysmouse bit is what I was going to work on first.  I used to have patches to sysutils/hald and x11-drivers/xf86-input-synaptics that would check moused(8) to see if Synaptics functionality was enabled and report the input device as a "touchpad" rather than a "mouse", which would allow the Synaptics driver to load.  The move from hald to our homebrew device detection code means I have to re-learn how to do this.
>
> In the meantime, I did manage to patch psm(4) to at least detect a ClickPad (and some other properties we weren't detecting).  No idea if it'd make a difference to software higher up; it'd have to know about the new struct fields I added.  I'm also pretty sure I'd have to add code to handle the ClickPad clicks and report it as an additional button.
>
> Patch /shouldn't/ represent an ABA change because I stuck the additional fields at the end of the synapticshw_t struct and advertise/guard their availability with a HAS_EXT_0C_CAPS macro, but I'm new to submitting driver patches...anyway it's not ready yet, just showing I'm workin' on it :-)
>
> [root@ajenkins-hplaptop /usr/src]# svn diff sys/sys/mouse.h sys/dev/atkbdc/psm.c
> Index: sys/sys/mouse.h
> ===================================================================
> --- sys/sys/mouse.h    (revision 267519)
> +++ sys/sys/mouse.h    (working copy)
> @@ -49,6 +49,7 @@
>  #endif
>  
>  #define MOUSE_SYN_GETHWINFO    _IOR('M', 100, synapticshw_t)
> +#define HAS_EXT_0C_CAPS 1
>  
>  /* mouse status block */
>  typedef struct mousestatus {
> @@ -110,6 +111,16 @@
>      int capMiddle;
>      int nExtendedButtons;
>      int nExtendedQueries;
> +#ifdef HAS_EXT_0C_CAPS
> +    /* Extended (0x0c query) capabilities */
> +    int capClickPad;
> +    int capClickPad2Btn;
> +    int capMaxDimensions;
> +    int capMinDimensions;
> +    int capAdvGesture;
> +    int capReducedFiltering;
> +    int capImageSensor;
> +#endif
>  } synapticshw_t;
>  
>  /* iftype */
> Index: sys/dev/atkbdc/psm.c
> ===================================================================
> --- sys/dev/atkbdc/psm.c    (revision 267519)
> +++ sys/dev/atkbdc/psm.c    (working copy)
> @@ -3623,20 +3623,13 @@
>  static int
>  mouse_ext_command(KBDC kbdc, int command)
>  {
> -    int c;
> +    int c, i;
>  
> -    c = (command >> 6) & 0x03;
> -    if (set_mouse_resolution(kbdc, c) != c)
> -        return (FALSE);
> -    c = (command >> 4) & 0x03;
> -    if (set_mouse_resolution(kbdc, c) != c)
> -        return (FALSE);
> -    c = (command >> 2) & 0x03;
> -    if (set_mouse_resolution(kbdc, c) != c)
> -        return (FALSE);
> -    c = (command >> 0) & 0x03;
> -    if (set_mouse_resolution(kbdc, c) != c)
> -        return (FALSE);
> +    for (i = 6; i >= 0; i -= 2) {
> +        c = (command >> i) & 0x03;
> +        if (set_mouse_resolution(kbdc, c) != c)
> +            return (FALSE);
> +    }
>      return (TRUE);
>  }
>  
> @@ -4470,7 +4463,7 @@
>      buttons = 0;
>      synhw.capExtended = (status[0] & 0x80) != 0;
>      if (synhw.capExtended) {
> -        synhw.nExtendedQueries = (status[0] & 0x70) != 0;
> +        synhw.nExtendedQueries = (status[0] & 0x70) >> 4;
>          synhw.capMiddle        = (status[0] & 0x04) != 0;
>          synhw.capPassthrough   = (status[2] & 0x80) != 0;
>          synhw.capSleep         = (status[2] & 0x10) != 0;
> @@ -4480,15 +4473,19 @@
>  
>          if (verbose >= 2) {
>              printf("  Extended capabilities:\n");
> -            printf("   capExtended: %d\n", synhw.capExtended);
> -            printf("   capMiddle: %d\n", synhw.capMiddle);
> +            printf("   capExtended:      %d\n", synhw.capExtended);
> +            printf("   capMiddle:        %d\n", synhw.capMiddle);
>              printf("   nExtendedQueries: %d\n",
>                  synhw.nExtendedQueries);
> -            printf("   capPassthrough: %d\n", synhw.capPassthrough);
> -            printf("   capSleep: %d\n", synhw.capSleep);
> -            printf("   capFourButtons: %d\n", synhw.capFourButtons);
> -            printf("   capMultiFinger: %d\n", synhw.capMultiFinger);
> -            printf("   capPalmDetect: %d\n", synhw.capPalmDetect);
> +            printf("   capPassthrough:   %d\n",
> +                synhw.capPassthrough);
> +            printf("   capSleep:         %d\n", synhw.capSleep);
> +            printf("   capFourButtons:   %d\n",
> +                synhw.capFourButtons);
> +            printf("   capMultiFinger:   %d\n",
> +                synhw.capMultiFinger);
> +            printf("   capPalmDetect:    %d\n",
> +                synhw.capPalmDetect);
>          }
>  
>          /*
> @@ -4496,7 +4493,7 @@
>           * supports this number of extended queries. We can load
>           * more information about buttons using query 0x09.
>           */
> -        if (synhw.capExtended && synhw.nExtendedQueries) {
> +        if (synhw.capExtended && synhw.nExtendedQueries >= 1) {
>              if (mouse_ext_command(kbdc, 0x09) == 0)
>                  return (FALSE);
>              if (get_mouse_status(kbdc, status, 0, 3) != 3)
> @@ -4508,12 +4505,45 @@
>               * if capMiddle support bit is set.
>               */
>              buttons = synhw.nExtendedButtons + synhw.capMiddle;
> -        } else
> +        } else {
>              /*
>               * If the capFourButtons support bit is set,
>               * add a fourth button to the total button count.
>               */
>              buttons = synhw.capFourButtons ? 1 : 0;
> +        }
> +#ifdef HAS_EXT_0C_CAPS
> +        if (synhw.capExtended && synhw.nExtendedQueries >= 4) {
> +            if (mouse_ext_command(kbdc, 0x0c) == 0)
> +                return (FALSE);
> +            if (get_mouse_status(kbdc, status, 0, 3) != 3)
> +                return (FALSE);
> +            synhw.capClickPad         = (status[0] & 0x10) != 0;
> +            synhw.capClickPad2Btn     = (status[1] & 0x01) != 0;
> +            synhw.capMaxDimensions    = (status[0] & 0x02) != 0;
> +            synhw.capMinDimensions    = (status[1] & 0x20) != 0;
> +            synhw.capAdvGesture       = (status[0] & 0x08) != 0;
> +            synhw.capReducedFiltering = (status[1] & 0x04) != 0;
> +            synhw.capImageSensor      = (status[1] & 0x08) != 0;
> +            if (verbose >= 2) {
> +                printf("  Extended capabilities (0x0c query):\n");
> +                printf("   capClickPad:         %d\n",
> +                    synhw.capClickPad);
> +                printf("   capClickPad2Btn:     %d\n",
> +                    synhw.capClickPad2Btn);
> +                printf("   capMaxDimensions:    %d\n",
> +                    synhw.capMaxDimensions);
> +                printf("   capMinDimensions:    %d\n",
> +                    synhw.capMinDimensions);
> +                printf("   capAdvGesture:       %d\n",
> +                    synhw.capAdvGesture);
> +                printf("   capReducedFiltering: %d\n",
> +                    synhw.capReducedFiltering);
> +                printf("   capImageSensor:      %d\n",
> +                    synhw.capImageSensor);
> +            }
> +        }
> +#endif    /* HAS_EXT_0C_CAPS */
>      }
>      if (verbose >= 2) {
>          if (synhw.capExtended)
>
>
...also you'd have to add 'options PSM_DEBUG=2' to your kernel config to actually see the detected extended capabilities in dmesg(8), but here's what it looks like on mine.  I should add a "ClickPad option detected" bit to the low verbosity string.

psm0: current command byte:0067
Synaptics Touchpad v8.1
  Model information:
   infoRot180: 0
   infoPortrait: 0
   infoSensor: 1
   infoHardware: 113
   infoNewAbs: 1
   capPen: 0
   infoSimplC: 1
   infoGeometry: 1
  Extended capabilities:
   capExtended:      1
   capMiddle:        0
   nExtendedQueries: 5
   capPassthrough:   0
   capSleep:         0
   capFourButtons:   0
   capMultiFinger:   1
   capPalmDetect:    1
  Extended capabilities (0x0c query):
   capClickPad:         1
   capClickPad2Btn:     0
   capMaxDimensions:    1
   capMinDimensions:    1
   capAdvGesture:       0
   capReducedFiltering: 1
   capImageSensor:      1
  Additional Buttons: 0
psm0: found Synaptics Touchpad
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model Synaptics Touchpad, device ID 0-00, 3 buttons
psm0: config:00004000, flags:00000008, packet size:6
psm0: syncmask:c0, syncbits:00

Anthony



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53A03DA6.90904>