diff options
-rw-r--r-- | sys/dev/pckbc/pms.c | 117 |
1 files changed, 56 insertions, 61 deletions
diff --git a/sys/dev/pckbc/pms.c b/sys/dev/pckbc/pms.c index 5c08ad97774..262941037ed 100644 --- a/sys/dev/pckbc/pms.c +++ b/sys/dev/pckbc/pms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pms.c,v 1.71 2016/10/23 22:59:19 bru Exp $ */ +/* $OpenBSD: pms.c,v 1.72 2017/02/27 16:21:47 bru Exp $ */ /* $NetBSD: psm.c,v 1.11 2000/06/05 22:20:57 sommerfeld Exp $ */ /*- @@ -95,17 +95,13 @@ struct synaptics_softc { #define SYNAPTICS_VALID_NEWABS_FIRST 0x80 #define SYNAPTICS_VALID_NEWABS_NEXT 0xc0 - 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; u_int sec_buttons; -#define SYNAPTICS_SCALE 4 -#define SYNAPTICS_PRESSURE 30 + +#define SYNAPTICS_PRESSURE_HI 30 +#define SYNAPTICS_PRESSURE_LO 25 +#define SYNAPTICS_PRESSURE SYNAPTICS_PRESSURE_HI +#define SYNAPTICS_SCALE 4 +#define SYNAPTICS_MAX_FINGERS 3 }; struct alps_softc { @@ -235,6 +231,12 @@ static const struct alps_model { #endif }; +static struct wsmouse_param synaptics_params[] = { + { WSMOUSECFG_PRESSURE_LO, SYNAPTICS_PRESSURE_LO }, + { WSMOUSECFG_PRESSURE_HI, SYNAPTICS_PRESSURE_HI } +}; +#define SYNAPTICS_NPARAMS 2 + static const struct wsmouse_param elantech_v4_cfg[] = { { WSMOUSECFG_DX_SCALE, (4096 / SYNAPTICS_SCALE) }, { WSMOUSECFG_DY_SCALE, (4096 / SYNAPTICS_SCALE) }, @@ -913,6 +915,9 @@ int synaptics_get_hwinfo(struct pms_softc *sc) { struct synaptics_softc *syn = sc->synaptics; + struct wsmousehw *hw; + + hw = wsmouse_get_hw(sc->sc_wsmousedev); if (synaptics_query(sc, SYNAPTICS_QUE_IDENTIFY, &syn->identify)) return (-1); @@ -944,17 +949,29 @@ synaptics_get_hwinfo(struct pms_softc *sc) return (-1); } + if ((syn->ext_capabilities & SYNAPTICS_EXT_CAP_CLICKPAD) && + !(syn->ext2_capabilities & SYNAPTICS_EXT2_CAP_BUTTONS_STICK) + && mouse_has_softbtn) + hw->type = WSMOUSE_TYPE_SYNAP_SBTN; + else + hw->type = WSMOUSE_TYPE_SYNAPTICS; + + hw->hw_type = (syn->ext_capabilities & SYNAPTICS_EXT_CAP_CLICKPAD) + ? WSMOUSEHW_CLICKPAD : WSMOUSEHW_TOUCHPAD; + if (syn->resolution & SYNAPTICS_RESOLUTION_VALID) { - syn->res_x = SYNAPTICS_RESOLUTION_X(syn->resolution); - syn->res_y = SYNAPTICS_RESOLUTION_Y(syn->resolution); + hw->h_res = SYNAPTICS_RESOLUTION_X(syn->resolution); + hw->v_res = SYNAPTICS_RESOLUTION_Y(syn->resolution); } - syn->min_x = SYNAPTICS_XMIN_BEZEL; - syn->min_y = SYNAPTICS_YMIN_BEZEL; - syn->max_x = (syn->dimension) ? + hw->x_min = SYNAPTICS_XMIN_BEZEL; + hw->y_min = SYNAPTICS_YMIN_BEZEL; + hw->x_max = (syn->dimension) ? SYNAPTICS_DIM_X(syn->dimension) : SYNAPTICS_XMAX_BEZEL; - syn->max_y = (syn->dimension) ? + hw->y_max = (syn->dimension) ? SYNAPTICS_DIM_Y(syn->dimension) : SYNAPTICS_YMAX_BEZEL; + hw->contacts_max = SYNAPTICS_MAX_FINGERS; + syn->sec_buttons = 0; if (SYNAPTICS_EXT_MODEL_BUTTONS(syn->ext_model) > 8) @@ -1062,7 +1079,9 @@ pms_enable_synaptics(struct pms_softc *sc) wsmousedevprint); } - syn->wsmode = WSMOUSE_COMPAT; + if (wsmouse_configure(sc->sc_wsmousedev, + synaptics_params, SYNAPTICS_NPARAMS)) + goto err; printf("%s: Synaptics %s, firmware %d.%d\n", DEVNAME(sc), (syn->ext_capabilities & SYNAPTICS_EXT_CAP_CLICKPAD ? @@ -1097,33 +1116,30 @@ int pms_ioctl_synaptics(struct pms_softc *sc, u_long cmd, caddr_t data, int flag, struct proc *p) { - struct synaptics_softc *syn = sc->synaptics; struct wsmouse_calibcoords *wsmc = (struct wsmouse_calibcoords *)data; + struct wsmousehw *hw; int wsmode; + hw = wsmouse_get_hw(sc->sc_wsmousedev); + switch (cmd) { case WSMOUSEIO_GTYPE: - if ((syn->ext_capabilities & SYNAPTICS_EXT_CAP_CLICKPAD) && - !(syn->ext2_capabilities & SYNAPTICS_EXT2_CAP_BUTTONS_STICK) - && mouse_has_softbtn) - *(u_int *)data = WSMOUSE_TYPE_SYNAP_SBTN; - else - *(u_int *)data = WSMOUSE_TYPE_SYNAPTICS; + *(u_int *)data = hw->type; break; case WSMOUSEIO_GCALIBCOORDS: - wsmc->minx = syn->min_x; - wsmc->maxx = syn->max_x; - wsmc->miny = syn->min_y; - wsmc->maxy = syn->max_y; + wsmc->minx = hw->x_min; + wsmc->maxx = hw->x_max; + wsmc->miny = hw->y_min; + wsmc->maxy = hw->y_max; wsmc->swapxy = 0; - wsmc->resx = syn->res_x; - wsmc->resy = syn->res_y; + wsmc->resx = hw->h_res; + wsmc->resy = hw->v_res; break; case WSMOUSEIO_SETMODE: wsmode = *(u_int *)data; if (wsmode != WSMOUSE_COMPAT && wsmode != WSMOUSE_NATIVE) return (EINVAL); - syn->wsmode = wsmode; + wsmouse_set_mode(sc->sc_wsmousedev, wsmode); break; default: return (-1); @@ -1155,7 +1171,7 @@ pms_proc_synaptics(struct pms_softc *sc) { struct synaptics_softc *syn = sc->synaptics; u_int buttons; - int x, y, z, w, dx, dy, width; + int x, y, z, w, fingerwidth; w = ((sc->packet[0] & 0x30) >> 2) | ((sc->packet[0] & 0x04) >> 1) | ((sc->packet[3] & 0x04) >> 2); @@ -1241,36 +1257,15 @@ pms_proc_synaptics(struct pms_softc *sc) y &= ~0x0f; } - /* ignore final events that happen when removing all fingers */ - if (x <= 1 || y <= 1) { - x = syn->old_x; - y = syn->old_y; - } - - if (syn->wsmode == WSMOUSE_NATIVE) { - if (z) { - width = imax(w, 4); - w = (w < 2 ? w + 2 : 1); - } else { - width = w = 0; - } - wsmouse_set(sc->sc_wsmousedev, WSMOUSE_TOUCH_WIDTH, width, 0); - WSMOUSE_TOUCH(sc->sc_wsmousedev, buttons, x, y, z, w); + if (z) { + fingerwidth = max(w, 4); + w = (w < 2 ? w + 2 : 1); } else { - dx = dy = 0; - if (z > SYNAPTICS_PRESSURE) { - dx = x - syn->old_x; - dy = y - syn->old_y; - dx /= SYNAPTICS_SCALE; - dy /= SYNAPTICS_SCALE; - } - if (dx || dy || buttons != syn->old_buttons) - WSMOUSE_INPUT(sc->sc_wsmousedev, buttons, dx, dy, 0, 0); - syn->old_buttons = buttons; + fingerwidth = 0; + w = 0; } - - syn->old_x = x; - syn->old_y = y; + wsmouse_set(sc->sc_wsmousedev, WSMOUSE_TOUCH_WIDTH, fingerwidth, 0); + WSMOUSE_TOUCH(sc->sc_wsmousedev, buttons, x, y, z, w); } void |