Define a new wscons mouse type for Synaptics clickpad devices that lack
authorjsg <jsg@openbsd.org>
Thu, 15 Jan 2015 01:19:28 +0000 (01:19 +0000)
committerjsg <jsg@openbsd.org>
Thu, 15 Jan 2015 01:19:28 +0000 (01:19 +0000)
physical buttons.  This will be used if the acpi pnpid for the mouse
matches a list provided by Synaptics found in Linux.

Combined with the xenocara changes this will remove the need for an xorg
config file for the x240/t440/t540 generation of thinkpads.

ok matthieu@ shadchin@ kettenis@

sys/dev/acpi/acpi.c
sys/dev/acpi/acpireg.h
sys/dev/pckbc/pms.c
sys/dev/wscons/wsconsio.h

index 4860aa2..28e0e2a 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.279 2015/01/11 19:59:56 kettenis Exp $ */
+/* $OpenBSD: acpi.c,v 1.280 2015/01/15 01:19:28 jsg Exp $ */
 /*
  * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
  * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -170,6 +170,55 @@ struct acpi_softc *acpi_softc;
 #define acpi_bus_space_map     _bus_space_map
 #define acpi_bus_space_unmap   _bus_space_unmap
 
+#ifndef SMALL_KERNEL
+/*
+ * This is a list of Synaptics devices with a 'top button area'
+ * based on the list in Linux supplied by Synaptics
+ * Synaptics clickpads with the following pnp ids will get a unique
+ * wscons mouse type that is used to define trackpad regions that will
+ * emulate mouse buttons
+ */
+static const char *sbtn_pnp[] = {
+       "LEN0017",
+       "LEN0018",
+       "LEN0019",
+       "LEN0023",
+       "LEN002A",
+       "LEN002B",
+       "LEN002C",
+       "LEN002D",
+       "LEN002E",
+       "LEN0033",
+       "LEN0034",
+       "LEN0035",
+       "LEN0036",
+       "LEN0037",
+       "LEN0038",
+       "LEN0039",
+       "LEN0041",
+       "LEN0042",
+       "LEN0045",
+       "LEN0046",
+       "LEN0047",
+       "LEN0048",
+       "LEN0049",
+       "LEN2000",
+       "LEN2001",
+       "LEN2002",
+       "LEN2003",
+       "LEN2004",
+       "LEN2005",
+       "LEN2006",
+       "LEN2007",
+       "LEN2008",
+       "LEN2009",
+       "LEN200A",
+       "LEN200B",
+};
+
+int    mouse_has_softbtn;
+#endif
+
 int
 acpi_gasio(struct acpi_softc *sc, int iodir, int iospace, uint64_t address,
     int access_size, int len, void *buffer)
@@ -2458,8 +2507,31 @@ acpi_foundhid(struct aml_node *node, void *arg)
        struct acpi_softc       *sc = (struct acpi_softc *)arg;
        struct device           *self = (struct device *)arg;
        const char              *dev;
+       char                     cdev[16];
        struct aml_value         res;
-       struct acpi_attach_args aaa;
+       struct acpi_attach_args  aaa;
+       int                      i;
+
+       /* NB aml_eisaid returns a static buffer, this must come first */
+       if (aml_evalname(acpi_softc, node->parent, "_CID", 0, NULL, &res) == 0) {
+               switch (res.type) {
+               case AML_OBJTYPE_STRING:
+                       dev = res.v_string;
+                       break;
+               case AML_OBJTYPE_INTEGER:
+                       dev = aml_eisaid(aml_val2int(&res));
+                       break;
+               default:
+                       dev = "unknown";
+                       break;
+               }
+               strlcpy(cdev, dev, sizeof(cdev));
+               aml_freevalue(&res);
+               
+               dnprintf(10, "compatible with device: %s\n", cdev);
+       } else {
+               cdev[0] = '\0';
+       }
 
        dnprintf(10, "found hid device: %s ", node->parent->name);
        if (aml_evalnode(sc, node, 0, NULL, &res) != 0)
@@ -2508,6 +2580,14 @@ acpi_foundhid(struct aml_node *node, void *arg)
                acpi_toshiba_enabled = 1;
        }
 
+       if (!strcmp(cdev, ACPI_DEV_MOUSE)) {
+               for (i = 0; i < nitems(sbtn_pnp); i++) {
+                       if (!strcmp(dev, sbtn_pnp[i])) {
+                               mouse_has_softbtn = 1;
+                               break;
+                       }
+               }
+       }
 
        if (aaa.aaa_name)
                config_found(self, &aaa, acpi_print);
index 420fe91..839a954 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: acpireg.h,v 1.29 2013/11/06 10:40:36 mpi Exp $        */
+/*     $OpenBSD: acpireg.h,v 1.30 2015/01/15 01:19:28 jsg Exp $        */
 /*
  * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
  * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
@@ -729,6 +729,7 @@ struct acpi_ivrs {
 #define ACPI_DEV_SBD   "PNP0C0E"       /* Sleep Button Device */
 #define ACPI_DEV_PILD  "PNP0C0F"       /* PCI Interrupt Link Device */
 #define ACPI_DEV_MEMD  "PNP0C80"       /* Memory Device */
+#define ACPI_DEV_MOUSE "PNP0F13"       /* PS/2 Mouse */
 #define ACPI_DEV_SHC   "ACPI0001"      /* SMBus 1.0 Host Controller */
 #define ACPI_DEV_SMS1  "ACPI0002"      /* Smart Battery Subsystem */
 #define ACPI_DEV_AC    "ACPI0003"      /* AC Device */
index 7b8a3b6..ed0b5ac 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: pms.c,v 1.55 2015/01/07 10:32:13 mpi Exp $ */
+/* $OpenBSD: pms.c,v 1.56 2015/01/15 01:19:28 jsg Exp $ */
 /* $NetBSD: psm.c,v 1.11 2000/06/05 22:20:57 sommerfeld Exp $ */
 
 /*-
 #include <dev/wscons/wsconsio.h>
 #include <dev/wscons/wsmousevar.h>
 
+#if defined(__i386__) || defined(__amd64__)
+#include "acpi.h"
+#endif
+
+#if !defined(SMALL_KERNEL) && NACPI > 0
+extern int mouse_has_softbtn;
+#else
+int mouse_has_softbtn;
+#endif
+
 #ifdef DEBUG
 #define DPRINTF(x...)  do { printf(x); } while (0);
 #else
@@ -1073,7 +1083,11 @@ pms_ioctl_synaptics(struct pms_softc *sc, u_long cmd, caddr_t data, int flag,
 
        switch (cmd) {
        case WSMOUSEIO_GTYPE:
-               *(u_int *)data = WSMOUSE_TYPE_SYNAPTICS;
+               if ((syn->ext_capabilities & SYNAPTICS_EXT_CAP_CLICKPAD) &&
+                   mouse_has_softbtn)
+                       *(u_int *)data = WSMOUSE_TYPE_SYNAP_SBTN;
+               else
+                       *(u_int *)data = WSMOUSE_TYPE_SYNAPTICS;
                break;
        case WSMOUSEIO_GCALIBCOORDS:
                wsmc->minx = syn->min_x;
index 1e21d20..c027a16 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsconsio.h,v 1.70 2014/12/21 18:25:07 shadchin Exp $ */
+/* $OpenBSD: wsconsio.h,v 1.71 2015/01/15 01:19:29 jsg Exp $ */
 /* $NetBSD: wsconsio.h,v 1.74 2005/04/28 07:15:44 martin Exp $ */
 
 /*
@@ -210,6 +210,7 @@ struct wskbd_map_data {
 #define                WSMOUSE_TYPE_ALPS       16      /* ALPS touchpad */
 #define                WSMOUSE_TYPE_SGI        17      /* SGI serial mouse */
 #define                WSMOUSE_TYPE_ELANTECH   18      /* Elantech touchpad */
+#define                WSMOUSE_TYPE_SYNAP_SBTN 19      /* Synaptics soft buttons */
 
 /* Set resolution.  Not applicable to all mouse types. */
 #define        WSMOUSEIO_SRES          _IOW('W', 33, u_int)