From ac6c6540d26596317e413dc6a2e4c09ac8a28a3e Mon Sep 17 00:00:00 2001 From: jsg Date: Thu, 15 Jan 2015 01:19:28 +0000 Subject: [PATCH] Define a new wscons mouse type for Synaptics clickpad devices that lack 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 | 84 ++++++++++++++++++++++++++++++++++++++- sys/dev/acpi/acpireg.h | 3 +- sys/dev/pckbc/pms.c | 18 ++++++++- sys/dev/wscons/wsconsio.h | 3 +- 4 files changed, 102 insertions(+), 6 deletions(-) diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index 4860aa2cdf7..28e0e2ac186 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -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 * Copyright (c) 2005 Jordan Hargrave @@ -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); diff --git a/sys/dev/acpi/acpireg.h b/sys/dev/acpi/acpireg.h index 420fe9173e8..839a954a859 100644 --- a/sys/dev/acpi/acpireg.h +++ b/sys/dev/acpi/acpireg.h @@ -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 * Copyright (c) 2005 Marco Peereboom @@ -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 */ diff --git a/sys/dev/pckbc/pms.c b/sys/dev/pckbc/pms.c index 7b8a3b67576..ed0b5acc6d2 100644 --- a/sys/dev/pckbc/pms.c +++ b/sys/dev/pckbc/pms.c @@ -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 $ */ /*- @@ -40,6 +40,16 @@ #include #include +#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; diff --git a/sys/dev/wscons/wsconsio.h b/sys/dev/wscons/wsconsio.h index 1e21d20fca2..c027a166fc7 100644 --- a/sys/dev/wscons/wsconsio.h +++ b/sys/dev/wscons/wsconsio.h @@ -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) -- 2.20.1