Re: [PATCH] psmouse: added BYD touchpad driver
Ok I think this about covers it. The line length issues remain, but the script repors them as warnings so I'm not to worried about it. Patch follows: --- Input: BYD: Added proper touch support Implemented absolute position and touch reporting. Now BYD touchpads will use the synaptics/libinput xorg touchpad drivers. Added documenatation for all known gesture packets and initialization commands. Signed-off-by: Richard Pospesel --- >From c0d0ece9ace3939691831eb20c2a5f01343781f1 Mon Sep 17 00:00:00 2001 From: pospeselr Date: Wed, 10 Feb 2016 18:24:00 -0800 Subject: [PATCH] byd changes --- drivers/input/mouse/byd.c | 577 - drivers/input/mouse/psmouse-base.c | 2 +- 2 files changed, 378 insertions(+), 201 deletions(-) diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c index 9425e0f..4c388ed 100644 --- a/drivers/input/mouse/byd.c +++ b/drivers/input/mouse/byd.c @@ -2,20 +2,32 @@ * BYD TouchPad PS/2 mouse driver * * Copyright (C) 2015 Chris Diamand + * Copyright (C) 2015 Richard Pospesel + * Copyright (C) 2015 Tai Chi Minh Ralph Eastwood + * Copyright (C) 2015 Martin Wimpress + * Copyright (C) 2015 Jay Kuri * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. + * + * Protocol of BYD Touch Pad reverse-engineered from windows driver: + * filename: "byd touchpad driver - win7, 8, 8.1 - 2.4.1.102.zip" + * md5: 0d5e4660b98fca9587a0df212fca3048 + * sha1: 97a0eca8edc482bf9d08ab9509084a514dad4c4b + * datasheet: http://bydit.com/userfiles/file/BTP10463-XXX.pdf */ #include #include #include #include +#include #include "psmouse.h" #include "byd.h" +/* PS2 Bits */ #define PS2_Y_OVERFLOW BIT_MASK(7) #define PS2_X_OVERFLOW BIT_MASK(6) #define PS2_Y_SIGN BIT_MASK(5) @@ -26,69 +38,246 @@ #define PS2_LEFT BIT_MASK(0) /* - * The touchpad reports gestures in the last byte of each packet. It can take - * any of the following values: + * BYD pad constants */ -/* One-finger scrolling in one of the edge scroll zones. */ -#define BYD_SCROLLUP 0xCA -#define BYD_SCROLLDOWN 0x36 -#define BYD_SCROLLLEFT 0xCB -#define BYD_SCROLLRIGHT0x35 -/* Two-finger scrolling. */ -#define BYD_2DOWN 0x2B -#define BYD_2UP0xD5 -#define BYD_2LEFT 0xD6 -#define BYD_2RIGHT 0x2A -/* Pinching in or out. */ -#define BYD_ZOOMOUT0xD8 -#define BYD_ZOOMIN 0x28 -/* Three-finger swipe. */ -#define BYD_3UP0xD3 -#define BYD_3DOWN 0x2D -#define BYD_3LEFT 0xD4 -#define BYD_3RIGHT 0x2C -/* Four-finger swipe. */ -#define BYD_4UP0xCD -#define BYD_4DOWN 0x33 +/* + * True device resolution is unknown, however experiments show the + * resolution is about 111 units/mm. + * Absolute coordinate packets are in the range 0-255 for both X and Y + * we pick ABS_X/ABS_Y dimensions which are multiples of 256 and in + * the right ballpark given the touchpad's physical dimensions and estimate + * resolution per spec sheet, device active area dimensions are + * 101.6 x 60.1 mm. + */ +#define BYD_PAD_WIDTH 11264 +#define BYD_PAD_HEIGHT 6656 +#define BYD_PAD_RESOLUTION 111 -int byd_detect(struct psmouse *psmouse, bool set_properties) -{ - struct ps2dev *ps2dev = &psmouse->ps2dev; - unsigned char param[4]; +/* + * Given the above dimensions, relative packets velocity is in multiples of + * 1 unit / 11 milliseconds. We use this dt to estimate distance traveled + */ +#define BYD_DT 11 +/* Time in milliseconds used to timeout various touch events */ +#define BYD_TOUCH_TIMEOUT 64 - param[0] = 0x03; - param[1] = 0x00; - param[2] = 0x00; - param[3] = 0x00; +/* BYD commands reverse engineered from windows driver */ - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) - return -1; - - if (param[1] != 0x03 || param[2] != 0x64) - return -ENODEV; +/* + * Swipe gesture from off-pad to on-pad + * 0 : disable + * 1 : enable + */ +#define BYD_CMD_SET_OFFSCREEN_SWIPE0x10cc +/* + * Tap and drag delay time + * 0 : disable + * 1 - 8 : least to most delay + */ +#define BYD_CMD_SET_TAP_DRAG_DELAY_TIME0x10cf +/* + * Physical buttons function mapping + * 0 : enable + * 4 : normal + * 5 : left button custom command + * 6 :
Re: [PATCH] psmouse: added BYD touchpad driver
Hi Richard, The patch applies! So your email client is working at last :) Looks good, just some style issues to fix now. > Updated BYD driver to report absolute coordinates and single-touch events. > init and gesture packet documentation. Confirmed working with both synaptics > and libinput xorg touchpad drivers. Patched against > 98ee377144935857d8ad5d7d70cdab1da4ede32e on > git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input. > > Signed-off-by: Richard Pospesel > ---o I think the commit message needs to follow some style guidelines as well. Something like: Input: byd - report absolute coordinates More details... Also can you use `git format-patch' to create your patches? That'll include your name and email so people can commit the patch directly with `git am'. > diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c > index 9425e0f..2900a3d 100644 > --- a/drivers/input/mouse/byd.c > +++ b/drivers/input/mouse/byd.c > @@ -2,20 +2,32 @@ > * BYD TouchPad PS/2 mouse driver > * > * Copyright (C) 2015 Chris Diamand > + * Copyright (C) 2015 Richard Pospesel > + * Copyright (C) 2015 Tai Chi Minh Ralph Eastwood > + * Copyright (C) 2015 Martin Wimpress > + * Copyright (C) 2015 Jay Kuri > * > * This program is free software; you can redistribute it and/or modify it > * under the terms of the GNU General Public License version 2 as published > by > * the Free Software Foundation. > + * > + * Protocol of BYD Touch Pad reverse-engineered from windows driver: > + * filename: "byd touchpad driver - win7, 8, 8.1 - 2.4.1.102.zip" > + * md5: 0d5e4660b98fca9587a0df212fca3048 > + * sha1: 97a0eca8edc482bf9d08ab9509084a514dad4c4b > + * datasheet: http://bydit.com/userfiles/file/BTP10463-XXX.pdf > */ > > #include > #include > #include > #include > +#include > > #include "psmouse.h" > #include "byd.h" > > +/* PS2 Bits */ > #define PS2_Y_OVERFLOW BIT_MASK(7) > #define PS2_X_OVERFLOW BIT_MASK(6) > #define PS2_Y_SIGN BIT_MASK(5) > @@ -26,69 +38,246 @@ > #define PS2_LEFT BIT_MASK(0) > > /* > - * The touchpad reports gestures in the last byte of each packet. It can take > - * any of the following values: > + * BYD pad constants > */ > > -/* One-finger scrolling in one of the edge scroll zones. */ > -#define BYD_SCROLLUP 0xCA > -#define BYD_SCROLLDOWN 0x36 > -#define BYD_SCROLLLEFT 0xCB > -#define BYD_SCROLLRIGHT 0x35 > -/* Two-finger scrolling. */ > -#define BYD_2DOWN0x2B > -#define BYD_2UP 0xD5 > -#define BYD_2LEFT0xD6 > -#define BYD_2RIGHT 0x2A > -/* Pinching in or out. */ > -#define BYD_ZOOMOUT 0xD8 > -#define BYD_ZOOMIN 0x28 > -/* Three-finger swipe. */ > -#define BYD_3UP 0xD3 > -#define BYD_3DOWN0x2D > -#define BYD_3LEFT0xD4 > -#define BYD_3RIGHT 0x2C > -/* Four-finger swipe. */ > -#define BYD_4UP 0xCD > -#define BYD_4DOWN0x33 > +/* > + * True device resolution is unknown, however experiments show the > + * resolution is about 111 units/mm. > + * Absolute coordinate packets are in the range 0-255 for both X and Y > + * we pick ABS_X/ABS_Y dimensions which are multiples of 256 and in > + * the right ballpark given the touchpad's physical dimensions and estimate > + * resolution per spec sheet, device active area dimensions are > + * 101.6 x 60.1 mm. > + */ > +#define BYD_PAD_WIDTH11264 > +#define BYD_PAD_HEIGHT 6656 > +#define BYD_PAD_RESOLUTION 111 > > -int byd_detect(struct psmouse *psmouse, bool set_properties) > -{ > - struct ps2dev *ps2dev = &psmouse->ps2dev; > - unsigned char param[4]; > +/* > + * Given the above dimensions, relative packets velocity is in multiples of > + * 1 unit / 11 milliseconds. We use this dt to estimate distance traveled > + */ > +#define BYD_DT 11 > +/* Time in milliseconds used to timeout various touch events */ > +#define BYD_TOUCH_TIMEOUT 64 > > - param[0] = 0x03; > - param[1] = 0x00; > - param[2] = 0x00; > - param[3] = 0x00; > +/* BYD commands reverse engineered from windows driver */ > > - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) > - return -1; > - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) > - return -1; > - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) > - return -1; > - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) > - return -1; > - if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) > - return -1; > - > - if (param[1] != 0x03 || param[2] != 0x64) > - return -ENODEV; > +/* > + * Swipe gesture from off-pad to on-pad > + * 0 : disable > + * 1 : enable > + */ > +#define BYD_CMD_SET_OFFSCREEN_SWIPE0x10cc > +/* > + * Tap and drag delay time > + * 0 : disable > + * 1 -
Re: [PATCH] psmouse: added BYD touchpad driver
Updated BYD driver to report absolute coordinates and single-touch events. init and gesture packet documentation. Confirmed working with both synaptics and libinput xorg touchpad drivers. Patched against 98ee377144935857d8ad5d7d70cdab1da4ede32e on git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input. Signed-off-by: Richard Pospesel --- diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c index 9425e0f..2900a3d 100644 --- a/drivers/input/mouse/byd.c +++ b/drivers/input/mouse/byd.c @@ -2,20 +2,32 @@ * BYD TouchPad PS/2 mouse driver * * Copyright (C) 2015 Chris Diamand + * Copyright (C) 2015 Richard Pospesel + * Copyright (C) 2015 Tai Chi Minh Ralph Eastwood + * Copyright (C) 2015 Martin Wimpress + * Copyright (C) 2015 Jay Kuri * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. + * + * Protocol of BYD Touch Pad reverse-engineered from windows driver: + * filename: "byd touchpad driver - win7, 8, 8.1 - 2.4.1.102.zip" + * md5: 0d5e4660b98fca9587a0df212fca3048 + * sha1: 97a0eca8edc482bf9d08ab9509084a514dad4c4b + * datasheet: http://bydit.com/userfiles/file/BTP10463-XXX.pdf */ #include #include #include #include +#include #include "psmouse.h" #include "byd.h" +/* PS2 Bits */ #define PS2_Y_OVERFLOW BIT_MASK(7) #define PS2_X_OVERFLOW BIT_MASK(6) #define PS2_Y_SIGN BIT_MASK(5) @@ -26,69 +38,246 @@ #define PS2_LEFT BIT_MASK(0) /* - * The touchpad reports gestures in the last byte of each packet. It can take - * any of the following values: + * BYD pad constants */ -/* One-finger scrolling in one of the edge scroll zones. */ -#define BYD_SCROLLUP 0xCA -#define BYD_SCROLLDOWN 0x36 -#define BYD_SCROLLLEFT 0xCB -#define BYD_SCROLLRIGHT0x35 -/* Two-finger scrolling. */ -#define BYD_2DOWN 0x2B -#define BYD_2UP0xD5 -#define BYD_2LEFT 0xD6 -#define BYD_2RIGHT 0x2A -/* Pinching in or out. */ -#define BYD_ZOOMOUT0xD8 -#define BYD_ZOOMIN 0x28 -/* Three-finger swipe. */ -#define BYD_3UP0xD3 -#define BYD_3DOWN 0x2D -#define BYD_3LEFT 0xD4 -#define BYD_3RIGHT 0x2C -/* Four-finger swipe. */ -#define BYD_4UP0xCD -#define BYD_4DOWN 0x33 +/* + * True device resolution is unknown, however experiments show the + * resolution is about 111 units/mm. + * Absolute coordinate packets are in the range 0-255 for both X and Y + * we pick ABS_X/ABS_Y dimensions which are multiples of 256 and in + * the right ballpark given the touchpad's physical dimensions and estimate + * resolution per spec sheet, device active area dimensions are + * 101.6 x 60.1 mm. + */ +#define BYD_PAD_WIDTH 11264 +#define BYD_PAD_HEIGHT 6656 +#define BYD_PAD_RESOLUTION 111 -int byd_detect(struct psmouse *psmouse, bool set_properties) -{ - struct ps2dev *ps2dev = &psmouse->ps2dev; - unsigned char param[4]; +/* + * Given the above dimensions, relative packets velocity is in multiples of + * 1 unit / 11 milliseconds. We use this dt to estimate distance traveled + */ +#define BYD_DT 11 +/* Time in milliseconds used to timeout various touch events */ +#define BYD_TOUCH_TIMEOUT 64 - param[0] = 0x03; - param[1] = 0x00; - param[2] = 0x00; - param[3] = 0x00; +/* BYD commands reverse engineered from windows driver */ - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) - return -1; - - if (param[1] != 0x03 || param[2] != 0x64) - return -ENODEV; +/* + * Swipe gesture from off-pad to on-pad + * 0 : disable + * 1 : enable + */ +#define BYD_CMD_SET_OFFSCREEN_SWIPE0x10cc +/* + * Tap and drag delay time + * 0 : disable + * 1 - 8 : least to most delay + */ +#define BYD_CMD_SET_TAP_DRAG_DELAY_TIME0x10cf +/* + * Physical buttons function mapping + * 0 : enable + * 4 : normal + * 5 : left button custom command + * 6 : right button custom command + * 8 : disable + */ +#define BYD_CMD_SET_PHYSICAL_BUTTONS 0x10d0 +/* + * Absolute mode (1 byte X/Y resolution) + * 0 : disable + * 2 : enable + */ +#define BYD_CMD_SET_ABSOLUTE_MODE 0x10d1 +/* + * Two finger scrolling + * 1 : vertical + * 2 : horizontal + * 3 : vertical + horizontal + * 4 : disable + */ +#define BYD_CMD_SET_TWO_FINGER_SCROLL 0x10d2 +/* + * Handedness + * 1 : right handed + * 2 : left h
Re: [PATCH] psmouse: added BYD touchpad driver
Hy Chris, I'll send updated patch in a follow-up once I've verified thunderbird hasn't messed up the formatting yet again (seems like there are 3 separate settings I have to set, argh). On 02/05/2016 10:55 AM, Chris Diamand wrote: Hi Richard, Thanks for this. Rebased patch against 98ee377144935857d8ad5d7d70cdab1da4ede32e: Can you include a proper commit message and Signed-off-by line? diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c index 9425e0f..f213a08 100644 --- a/drivers/input/mouse/byd.c +++ b/drivers/input/mouse/byd.c @@ -2,93 +2,276 @@ * BYD TouchPad PS/2 mouse driver * * Copyright (C) 2015 Chris Diamand + * Copyright (C) 2015 Richard Pospesel + * Copyright (C) 2015 Tai Chi Minh Ralph Eastwood + * Copyright (C) 2015 Martin Wimpress + * Copyright (C) 2015 Jay Kuri * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. Your email client is still mangling the patch - use git send-email or similar next time. Also try sending it to yourself and then applying the patch to check it's worked. + * + * Protocol of BYD Touch Pad reverse-engineered from windows driver: + * filename: "byd touchpad driver - win7, 8, 8.1 - 2.4.1.102.zip" + * md5: 0d5e4660b98fca9587a0df212fca3048 + * sha1: 97a0eca8edc482bf9d08ab9509084a514dad4c4b + * datasheet: http://bydit.com/userfiles/file/BTP10463-XXX.pdf */ #include #include #include #include +#include #include "psmouse.h" #include "byd.h" -#define PS2_Y_OVERFLOW BIT_MASK(7) -#define PS2_X_OVERFLOW BIT_MASK(6) -#define PS2_Y_SIGN BIT_MASK(5) -#define PS2_X_SIGN BIT_MASK(4) -#define PS2_ALWAYS_1 BIT_MASK(3) -#define PS2_MIDDLE BIT_MASK(2) -#define PS2_RIGHT BIT_MASK(1) -#define PS2_LEFT BIT_MASK(0) +/* PS2 Bits */ +#define PS2_Y_OVERFLOW BIT_MASK(7) +#define PS2_X_OVERFLOW BIT_MASK(6) +#define PS2_Y_SIGN BIT_MASK(5) +#define PS2_X_SIGN BIT_MASK(4) +#define PS2_ALWAYS_1 BIT_MASK(3) +#define PS2_MIDDLE BIT_MASK(2) +#define PS2_RIGHT BIT_MASK(1) +#define PS2_LEFT BIT_MASK(0) The tabs between these were deliberate - no need to change them. Do you have your tab width set to eight spaces? If you've got it set to four then it'll look wrong. I am using the proper 8 spaces/tab width. However, I've always used the guideline of 'tabs for indentation, spaces for formatting.' The kernel coding style doesn't seem to cover this but I can revert these bits for the sake of a smaller diff. /* - * The touchpad reports gestures in the last byte of each packet. It can take - * any of the following values: Another example of your email client wrapping lines incorrectly. + * BYD pad constants + * + * True device resolution is unknown, however experiments show the + * resolution is about 111 units/mm. + * Absolute coordinate packets are in the range 0-255 for both X and Y + * we pick ABS_X/ABS_Y dimensions which are multiples of 256 and in + * the right ballpark given the touchpad's physical dimensions and estimate + * resolution per spec sheet, device active area dimensions are + * 101.6 x 60.1 mm. */ +#define BYD_CONST_PAD_WIDTH 11264 +#define BYD_CONST_PAD_HEIGHT 6656 +#define BYD_CONST_PAD_RESOLUTION 111 Do these need to include "CONST"? It's pretty obvious that they're constant from the capitalization. True enough, will fix. -/* One-finger scrolling in one of the edge scroll zones. */ -#define BYD_SCROLLUP 0xCA -#define BYD_SCROLLDOWN 0x36 -#define BYD_SCROLLLEFT 0xCB -#define BYD_SCROLLRIGHT0x35 -/* Two-finger scrolling. */ -#define BYD_2DOWN 0x2B -#define BYD_2UP0xD5 -#define BYD_2LEFT 0xD6 -#define BYD_2RIGHT 0x2A -/* Pinching in or out. */ -#define BYD_ZOOMOUT0xD8 -#define BYD_ZOOMIN 0x28 -/* Three-finger swipe. */ -#define BYD_3UP0xD3 -#define BYD_3DOWN 0x2D -#define BYD_3LEFT 0xD4 -#define BYD_3RIGHT 0x2C -/* Four-finger swipe. */ -#define BYD_4UP0xCD -#define BYD_4DOWN 0x33 - -int byd_detect(struct psmouse *psmouse, bool set_properties) -{ - struct ps2dev *ps2dev = &psmouse->ps2dev; - unsigned char param[4]; +/* BYD commands reverse engineered from windows driver */ - param[0] = 0x03; - param[1] = 0x00; - param[2] = 0x00; - param[3] = 0x00; - - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param
Re: [PATCH] psmouse: added BYD touchpad driver
Hi Richard, Thanks for this. > Rebased patch against 98ee377144935857d8ad5d7d70cdab1da4ede32e: Can you include a proper commit message and Signed-off-by line? > diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c > index 9425e0f..f213a08 100644 > --- a/drivers/input/mouse/byd.c > +++ b/drivers/input/mouse/byd.c > @@ -2,93 +2,276 @@ > * BYD TouchPad PS/2 mouse driver > * > * Copyright (C) 2015 Chris Diamand > + * Copyright (C) 2015 Richard Pospesel > + * Copyright (C) 2015 Tai Chi Minh Ralph Eastwood > + * Copyright (C) 2015 Martin Wimpress > + * Copyright (C) 2015 Jay Kuri > * > * This program is free software; you can redistribute it and/or modify it > * under the terms of the GNU General Public License version 2 as published > by > * the Free Software Foundation. Your email client is still mangling the patch - use git send-email or similar next time. Also try sending it to yourself and then applying the patch to check it's worked. > + * > + * Protocol of BYD Touch Pad reverse-engineered from windows driver: > + * filename: "byd touchpad driver - win7, 8, 8.1 - 2.4.1.102.zip" > + * md5: 0d5e4660b98fca9587a0df212fca3048 > + * sha1: 97a0eca8edc482bf9d08ab9509084a514dad4c4b > + * datasheet: http://bydit.com/userfiles/file/BTP10463-XXX.pdf > */ > > #include > #include > #include > #include > +#include > > #include "psmouse.h" > #include "byd.h" > > -#define PS2_Y_OVERFLOW BIT_MASK(7) > -#define PS2_X_OVERFLOW BIT_MASK(6) > -#define PS2_Y_SIGN BIT_MASK(5) > -#define PS2_X_SIGN BIT_MASK(4) > -#define PS2_ALWAYS_1 BIT_MASK(3) > -#define PS2_MIDDLE BIT_MASK(2) > -#define PS2_RIGHTBIT_MASK(1) > -#define PS2_LEFT BIT_MASK(0) > +/* PS2 Bits */ > +#define PS2_Y_OVERFLOW BIT_MASK(7) > +#define PS2_X_OVERFLOW BIT_MASK(6) > +#define PS2_Y_SIGN BIT_MASK(5) > +#define PS2_X_SIGN BIT_MASK(4) > +#define PS2_ALWAYS_1 BIT_MASK(3) > +#define PS2_MIDDLE BIT_MASK(2) > +#define PS2_RIGHT BIT_MASK(1) > +#define PS2_LEFT BIT_MASK(0) The tabs between these were deliberate - no need to change them. Do you have your tab width set to eight spaces? If you've got it set to four then it'll look wrong. > > /* > - * The touchpad reports gestures in the last byte of each packet. It can > take > - * any of the following values: Another example of your email client wrapping lines incorrectly. > + * BYD pad constants > + * > + * True device resolution is unknown, however experiments show the > + * resolution is about 111 units/mm. > + * Absolute coordinate packets are in the range 0-255 for both X and Y > + * we pick ABS_X/ABS_Y dimensions which are multiples of 256 and in > + * the right ballpark given the touchpad's physical dimensions and estimate > + * resolution per spec sheet, device active area dimensions are > + * 101.6 x 60.1 mm. > */ > +#define BYD_CONST_PAD_WIDTH 11264 > +#define BYD_CONST_PAD_HEIGHT 6656 > +#define BYD_CONST_PAD_RESOLUTION 111 Do these need to include "CONST"? It's pretty obvious that they're constant from the capitalization. > > -/* One-finger scrolling in one of the edge scroll zones. */ > -#define BYD_SCROLLUP 0xCA > -#define BYD_SCROLLDOWN 0x36 > -#define BYD_SCROLLLEFT 0xCB > -#define BYD_SCROLLRIGHT 0x35 > -/* Two-finger scrolling. */ > -#define BYD_2DOWN0x2B > -#define BYD_2UP 0xD5 > -#define BYD_2LEFT0xD6 > -#define BYD_2RIGHT 0x2A > -/* Pinching in or out. */ > -#define BYD_ZOOMOUT 0xD8 > -#define BYD_ZOOMIN 0x28 > -/* Three-finger swipe. */ > -#define BYD_3UP 0xD3 > -#define BYD_3DOWN0x2D > -#define BYD_3LEFT0xD4 > -#define BYD_3RIGHT 0x2C > -/* Four-finger swipe. */ > -#define BYD_4UP 0xCD > -#define BYD_4DOWN0x33 > - > -int byd_detect(struct psmouse *psmouse, bool set_properties) > -{ > - struct ps2dev *ps2dev = &psmouse->ps2dev; > - unsigned char param[4]; > +/* BYD commands reverse engineered from windows driver */ > > - param[0] = 0x03; > - param[1] = 0x00; > - param[2] = 0x00; > - param[3] = 0x00; > - > - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) > - return -1; > - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) > - return -1; > - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) > - return -1; > - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) > - return -1; > - if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) > - return -1; Did you need to move this function? No technical objections, but it confuses the patch a bit. > +/* > + * Swipe gesture from off-pad to on-pad > + * 0 : disable > + * 1 : enable > + */ > +#define BYD_CMD_SET_OFFSCREEN_SWIPE0x10cc > +/* > + * Tap and drag delay time > + * 0 : disable > + * 1 - 8 :
Re: [PATCH] psmouse: added BYD touchpad driver
Rebased patch against 98ee377144935857d8ad5d7d70cdab1da4ede32e: --- diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c index 9425e0f..f213a08 100644 --- a/drivers/input/mouse/byd.c +++ b/drivers/input/mouse/byd.c @@ -2,93 +2,276 @@ * BYD TouchPad PS/2 mouse driver * * Copyright (C) 2015 Chris Diamand + * Copyright (C) 2015 Richard Pospesel + * Copyright (C) 2015 Tai Chi Minh Ralph Eastwood + * Copyright (C) 2015 Martin Wimpress + * Copyright (C) 2015 Jay Kuri * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. + * + * Protocol of BYD Touch Pad reverse-engineered from windows driver: + * filename: "byd touchpad driver - win7, 8, 8.1 - 2.4.1.102.zip" + * md5: 0d5e4660b98fca9587a0df212fca3048 + * sha1: 97a0eca8edc482bf9d08ab9509084a514dad4c4b + * datasheet: http://bydit.com/userfiles/file/BTP10463-XXX.pdf */ #include #include #include #include +#include #include "psmouse.h" #include "byd.h" -#define PS2_Y_OVERFLOW BIT_MASK(7) -#define PS2_X_OVERFLOW BIT_MASK(6) -#define PS2_Y_SIGN BIT_MASK(5) -#define PS2_X_SIGN BIT_MASK(4) -#define PS2_ALWAYS_1 BIT_MASK(3) -#define PS2_MIDDLE BIT_MASK(2) -#define PS2_RIGHT BIT_MASK(1) -#define PS2_LEFT BIT_MASK(0) +/* PS2 Bits */ +#define PS2_Y_OVERFLOW BIT_MASK(7) +#define PS2_X_OVERFLOW BIT_MASK(6) +#define PS2_Y_SIGN BIT_MASK(5) +#define PS2_X_SIGN BIT_MASK(4) +#define PS2_ALWAYS_1 BIT_MASK(3) +#define PS2_MIDDLE BIT_MASK(2) +#define PS2_RIGHT BIT_MASK(1) +#define PS2_LEFT BIT_MASK(0) /* - * The touchpad reports gestures in the last byte of each packet. It can take - * any of the following values: + * BYD pad constants + * + * True device resolution is unknown, however experiments show the + * resolution is about 111 units/mm. + * Absolute coordinate packets are in the range 0-255 for both X and Y + * we pick ABS_X/ABS_Y dimensions which are multiples of 256 and in + * the right ballpark given the touchpad's physical dimensions and estimate + * resolution per spec sheet, device active area dimensions are + * 101.6 x 60.1 mm. */ +#define BYD_CONST_PAD_WIDTH 11264 +#define BYD_CONST_PAD_HEIGHT 6656 +#define BYD_CONST_PAD_RESOLUTION 111 -/* One-finger scrolling in one of the edge scroll zones. */ -#define BYD_SCROLLUP 0xCA -#define BYD_SCROLLDOWN 0x36 -#define BYD_SCROLLLEFT 0xCB -#define BYD_SCROLLRIGHT0x35 -/* Two-finger scrolling. */ -#define BYD_2DOWN 0x2B -#define BYD_2UP0xD5 -#define BYD_2LEFT 0xD6 -#define BYD_2RIGHT 0x2A -/* Pinching in or out. */ -#define BYD_ZOOMOUT0xD8 -#define BYD_ZOOMIN 0x28 -/* Three-finger swipe. */ -#define BYD_3UP0xD3 -#define BYD_3DOWN 0x2D -#define BYD_3LEFT 0xD4 -#define BYD_3RIGHT 0x2C -/* Four-finger swipe. */ -#define BYD_4UP0xCD -#define BYD_4DOWN 0x33 - -int byd_detect(struct psmouse *psmouse, bool set_properties) -{ - struct ps2dev *ps2dev = &psmouse->ps2dev; - unsigned char param[4]; +/* BYD commands reverse engineered from windows driver */ - param[0] = 0x03; - param[1] = 0x00; - param[2] = 0x00; - param[3] = 0x00; - - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES)) - return -1; - if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) - return -1; +/* + * Swipe gesture from off-pad to on-pad + * 0 : disable + * 1 : enable + */ +#define BYD_CMD_SET_OFFSCREEN_SWIPE0x10cc +/* + * Tap and drag delay time + * 0 : disable + * 1 - 8 : least to most delay + */ +#define BYD_CMD_SET_TAP_DRAG_DELAY_TIME0x10cf +/* + * Physical buttons function mapping + * 0 : enable + * 4 : normal + * 5 : left button custom command + * 6 : right button custom command + * 8 : disable + */ +#define BYD_CMD_SET_PHYSICAL_BUTTONS 0x10d0 +/* + * Absolute mode (1 byte X/Y resolution) + * 0 : disable + * 2 : enable + */ +#define BYD_CMD_SET_ABSOLUTE_MODE 0x10d1 +/* + * Two finger scrolling + * 1 : vertical + * 2 : horizontal + * 3 : vertical + horizontal + * 4 : disable + */ +#define BYD_CMD_SET_TWO_FINGER_SCROLL 0x10d2 +/* + * Handedness + * 1 : right handed + * 2 : left handed + */ +#define BYD_CMD_SET_HANDEDNESS 0x10d3 +/* + * Tap to click + * 1 : enable + * 2 : disable + */ +#define BYD_CMD_SET_TAP0x10d4 +/* + * Tap and drag + * 1 : tap and hold to drag + * 2 : t
Re: [PATCH] psmouse: added BYD touchpad driver
> The Windows driver provides a visualization of the regions for the hardware > edge scrolling capability. When entering that screen, a particular command > pair is sent, and the touchpad starts sending interleaved REL and ABS > packets. When leaving that screen, another particular command pair is sent, > and the touchpad resumes the normal REL only stream. Good find! That's very crafty. I've managed to apply your patch, and can confirm that it works - my initial impressions (using it for 15 mins...) are that even 256x256 resolution absolute mode + synaptics is much better than the touchpad's built-in gesture detection. Let's work your patch into something which applies on top of the existing driver, and get it merged. Cheers! Chris
Re: [PATCH] psmouse: added BYD touchpad driver
Hi Chris, See inline: On 02/03/2016 12:58 AM, Chris Diamand wrote: Hi Richard, Reporting absolute position allows the synaptics and libinput xorg drivers to treat the BYD touchpad as a touchpad, rather than a mouse. This allows edge scrolling, tap to click, natural scrolling and any other location based single touch gesture to work. I opted to completely disable the hardware multitouch gesture recognition (including two finger scroll) for a couple of reasons: 1. time delta between gesture packets was very large resulting in a rather jerky scrolling experience, especially compared to touchpad with real multitouch reporting. 2. Reporting absolute position and touch support enables the users to configure the touchpad in the touchpad settings section of gnome, cinnamon, etc because those applets configure synaptics and libinput. Otherwise xorg thinks it's just a mouse. This all sounds good - I look forward to trying your patch! Also, how did you figure out how to enable the absolute packets? I couldn't find anything like that with the Windows driver I was using. The Windows driver provides a visualization of the regions for the hardware edge scrolling capability. When entering that screen, a particular command pair is sent, and the touchpad starts sending interleaved REL and ABS packets. When leaving that screen, another particular command pair is sent, and the touchpad resumes the normal REL only stream. 3. Enabling multitouch gesture recognition results in the mouse cursor freezing up when the user uses two fingers, one to move the mouse cursor and another to click. This is because movement packets stop getting sent while a gesture (such as pinch, rotate, etc) is being detected and/or reported. So with your patch, how will this gesture work, if it can only recognise one finger at a time? I guess you'd have to enable the "double-tap then drag" thing in synaptics and use that? With multi-touch gestures disabled and two fingers on the pad, the touchpad sends ONLY a stream of REL packets, even when in absolute mode. When this occurs I just anchor the start position at the middle of the pad. Its not 100% accurate obviously, but in practice it works. One side note, it's also possible for this driver to send ABS_X/Y packets with positions OUTSIDE the touchpad's supposed range due to the scheme where we anchor with a low-res ABS packet and update with hi-res REL packets. I've talked about this potential issue with Peter Hutterer (from xorg input) and have been assured that this is fine and isn't taking advantage of an undefined behaviour in synaptics or libinput. Disabling all hardware gesture detection, including two finger scroll, provides the most fluid user experience. Yep, I agree that if it works, good one-finger scrolling would be much better than the touchpad's internal gesture recognition. Regarding serio_pause_rx(), I was following a pattern similar to another touchpad driver in psmouse. That whole callback mechanism is required to report the touch had ended, since the BYD hardware only sends packets when a touch is occurring. Is there a better way? You're right, actually - I was worried that the input_report_* functions might sleep, but I just had a proper look and they don't. I'll try to rebase and post an updated patch tonight. Cheers! Chris best, -Richard
Re: [PATCH] psmouse: added BYD touchpad driver
Hi Richard, > Reporting absolute position allows the synaptics and libinput xorg drivers > to treat the BYD touchpad as a touchpad, rather than a mouse. This allows > edge scrolling, tap to click, natural scrolling and any other location > based single touch gesture to work. > > I opted to completely disable the hardware multitouch gesture recognition > (including two finger scroll) for a couple of reasons: > > 1. time delta between gesture packets was very large resulting in a rather > jerky scrolling experience, especially compared to touchpad with real > multitouch reporting. > 2. Reporting absolute position and touch support enables the users to > configure the touchpad in the touchpad settings section of gnome, cinnamon, > etc because those applets configure synaptics and libinput. Otherwise xorg > thinks it's just a mouse. This all sounds good - I look forward to trying your patch! Also, how did you figure out how to enable the absolute packets? I couldn't find anything like that with the Windows driver I was using. > 3. Enabling multitouch gesture recognition results in the mouse cursor > freezing up when the user uses two fingers, one to move the mouse cursor > and another to click. This is because movement packets stop getting sent > while a gesture (such as pinch, rotate, etc) is being detected and/or > reported. So with your patch, how will this gesture work, if it can only recognise one finger at a time? I guess you'd have to enable the "double-tap then drag" thing in synaptics and use that? > Disabling all hardware gesture detection, including two finger > scroll, provides the most fluid user experience. Yep, I agree that if it works, good one-finger scrolling would be much better than the touchpad's internal gesture recognition. > Regarding serio_pause_rx(), I was following a pattern similar to another > touchpad driver in psmouse. That whole callback mechanism is required to > report the touch had ended, since the BYD hardware only sends packets when > a touch is occurring. Is there a better way? You're right, actually - I was worried that the input_report_* functions might sleep, but I just had a proper look and they don't. > I'll try to rebase and post an updated patch tonight. Cheers! Chris
Re: [PATCH] psmouse: added BYD touchpad driver
New patch vs 98ee377144935857d8ad5d7d70cdab1da4ede32e on git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input follows. Confirmed builds and works as expected with that kernel branch. Signed-off-by: Richard Pospesel --- diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c index 9425e0f..a880adb 100644 --- a/drivers/input/mouse/byd.c +++ b/drivers/input/mouse/byd.c @@ -1,337 +1,586 @@ /* - * BYD TouchPad PS/2 mouse driver + * BYD BTP-10463 touchpad PS/2 mouse driver * - * Copyright (C) 2015 Chris Diamand + * Copyright (C) 2015, Tai Chi Minh Ralph Eastwood + * Copyright (C) 2015, Martin Wimpress + * Copyright (C) 2015, Jay Kuri + * Copyright (C) 2015, Richard Pospesel * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. + * + * Protocol of BYD Touch Pad reverse-engineered from windows driver: + * filename: "byd touchpad driver - win7, 8, 8.1 - 2.4.1.102.zip" + * sha1: 97a0eca8edc482bf9d08ab9509084a514dad4c4b + * datasheet: http://bydit.com/userfiles/file/BTP10463-XXX.pdf + * */ +#include +#include -#include #include -#include #include +#include +#include #include "psmouse.h" #include "byd.h" -#define PS2_Y_OVERFLOW BIT_MASK(7) -#define PS2_X_OVERFLOW BIT_MASK(6) -#define PS2_Y_SIGN BIT_MASK(5) -#define PS2_X_SIGN BIT_MASK(4) -#define PS2_ALWAYS_1 BIT_MASK(3) -#define PS2_MIDDLE BIT_MASK(2) -#define PS2_RIGHT BIT_MASK(1) -#define PS2_LEFT BIT_MASK(0) +#define BYD_MODEL_ID_LEN2 +#define BYD_CMD_PAIR(c)((1 << 12) | (c)) +#define BYD_CMD_PAIR_R(r, c) ((1 << 12) | (r << 8) | (c)) + +/* BYD pad constants */ /* - * The touchpad reports gestures in the last byte of each packet. It can take - * any of the following values: + * true device resolution is unknown, however experiments show the + * resolution is about 111 units/mm + * absolute coordinate packets are in the range 0-255 for both X and y + * we pick ABS_X/ABS_Y dimensions which are multiples of 256 and in + * the right ballpark given the touchpad's physical dimensions and estimate + * resolution per spec sheet, device active area dimensions are + * 101.6 x 60.1 mm */ -/* One-finger scrolling in one of the edge scroll zones. */ -#define BYD_SCROLLUP 0xCA -#define BYD_SCROLLDOWN 0x36 -#define BYD_SCROLLLEFT 0xCB -#define BYD_SCROLLRIGHT0x35 -/* Two-finger scrolling. */ -#define BYD_2DOWN 0x2B -#define BYD_2UP0xD5 -#define BYD_2LEFT 0xD6 -#define BYD_2RIGHT 0x2A -/* Pinching in or out. */ -#define BYD_ZOOMOUT0xD8 -#define BYD_ZOOMIN 0x28 -/* Three-finger swipe. */ -#define BYD_3UP0xD3 -#define BYD_3DOWN 0x2D -#define BYD_3LEFT 0xD4 -#define BYD_3RIGHT 0x2C -/* Four-finger swipe. */ -#define BYD_4UP0xCD -#define BYD_4DOWN 0x33 +#define BYD_CONST_PAD_WIDTH 11264 +#define BYD_CONST_PAD_HEIGHT6656 +#define BYD_CONST_PAD_RESOLUTION111 -int byd_detect(struct psmouse *psmouse, bool set_properties) + +/* BYD commands reverse engineered from windows driver */ + +/* + * swipe gesture from off-pad to on-pad + * 0 : disable + * 1 : enable + */ +#define BYD_CMD_SET_OFFSCREEN_SWIPE 0xcc +/* + * tap and drag delay time + * 0 : disable + * 1 - 8 : least to most delay + */ +#define BYD_CMD_SET_TAP_DRAG_DELAY_TIME 0xcf +/* + * physical buttons function mapping + * 0 : enable + * 4 : normal + * 5 : left button custom command + * 6 : right button custom command + * 8 : disable + */ +#define BYD_CMD_SET_PHYSICAL_BUTTONS0xd0 +/* + * absolute mode (1 byte X/Y resolution) + * 0 : disable + * 2 : enable + */ +#define BYD_CMD_SET_ABSOLUTE_MODE 0xd1 +/* + * two finger scrolling + * 1 : vertical + * 2 : horizontal + * 3 : vertical + horizontal + * 4 : disable + */ +#define BYD_CMD_SET_TWO_FINGER_SCROLL 0xd2 +/* + * handedness + * 1 : right handed + * 2 : left handed + */ +#define BYD_CMD_SET_HANDEDNESS 0xd3 +/* + * tap to click + * 1 : enable + * 2 : disable + */ +#define BYD_CMD_SET_TAP 0xd4 +/* + * tap and drag + * 1 : tap and hold to drag + * 2 : tap and hold to drag + lock + * 3 : disable + */ +#define BYD_CMD_SET_TAP_DRAG0xd5 +/* + * touch sensitivity + * 1 - 7 : least to most sensitive + */ +#define BYD_CMD_SET_TOUCH_SENSITIVITY 0xd6 +/* + * one finger scrolling + * 1 : vertical + * 2 : horizontal + * 3 : vertical + horizontal + * 4 : disable + */ +#define BYD_CMD_SET_ONE_FINGER_SCROLL 0xd7 +/* + * one finger scrolling function + * 1 : free scrolling + * 2 : edge motion + * 3 : free scrolling +
Re: [PATCH] psmouse: added BYD touchpad driver
Hi Chris, Reporting absolute position allows the synaptics and libinput xorg drivers to treat the BYD touchpad as a touchpad, rather than a mouse. This allows edge scrolling, tap to click, natural scrolling and any other location based single touch gesture to work. I opted to completely disable the hardware multitouch gesture recognition (including two finger scroll) for a couple of reasons: 1. time delta between gesture packets was very large resulting in a rather jerky scrolling experience, especially compared to touchpad with real multitouch reporting. 2. Reporting absolute position and touch support enables the users to configure the touchpad in the touchpad settings section of gnome, cinnamon, etc because those applets configure synaptics and libinput. Otherwise xorg thinks it's just a mouse. 3. Enabling multitouch gesture recognition results in the mouse cursor freezing up when the user uses two fingers, one to move the mouse cursor and another to click. This is because movement packets stop getting sent while a gesture (such as pinch, rotate, etc) is being detected and/or reported. Disabling all hardware gesture detection, including two finger scroll, provides the most fluid user experience. Regarding serio_pause_rx(), I was following a pattern similar to another touchpad driver in psmouse. That whole callback mechanism is required to report the touch had ended, since the BYD hardware only sends packets when a touch is occurring. Is there a better way? I'll try to rebase and post an updated patch tonight. best, Richard On Tue, Feb 2, 2016 at 4:41 PM, Chris Diamand wrote: > Hi Richard, > >> This adds proper single-touch support for BYD touchpads to the psmouse input >> driver. > > I posted a driver for the same touchpad a few weeks ago, which has been merged > into linux-next. There's some stuff in this patch which is missing in my > driver > though, so we should definitely try and include that, and I'm very curious > about the pseudo-absolute mode. > >> This patch is against commit b82dde0230439215b55e545880e90337ee16f51a (Merge >> tag >> 'please-pull-copy_file_range' of >> git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux ) of Linus' kernel >> branch. > > Can you rebase against > 'git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input'? > >> +/* BYD commands reverse engineered from windows driver */ >> + >> +/* >> + * swipe gesture from off-pad to on-pad >> + * 0 : disable >> + * 1 : enable >> + */ >> +#define BYD_CMD_SET_OFFSCREEN_SWIPE 0xcc >> +/* >> + * tap and drag delay time >> + * 0 : disable >> + * 1 - 8 : least to most delay >> + */ >> +#define BYD_CMD_SET_TAP_DRAG_DELAY_TIME 0xcf >> +/* >> + * physical buttons function mapping >> + * 0 : enable >> + * 4 : normal >> + * 5 : left button custom command >> + * 6 : right button custom command >> + * 8 : disable >> + */ >> +#define BYD_CMD_SET_PHYSICAL_BUTTONS0xd0 >> +/* >> + * absolute mode (1 byte X/Y resolution) >> + * 0 : disable >> + * 2 : enable >> + */ >> +#define BYD_CMD_SET_ABSOLUTE_MODE 0xd1 >> +/* >> + * two finger scrolling >> + * 1 : vertical >> + * 2 : horizontal >> + * 3 : vertical + horizontal >> + * 4 : disable >> + */ >> +#define BYD_CMD_SET_TWO_FINGER_SCROLL 0xd2 >> +/* >> + * handedness >> + * 1 : right handed >> + * 2 : left handed >> + */ >> +#define BYD_CMD_SET_HANDEDNESS 0xd3 >> +/* >> + * tap to click >> + * 1 : enable >> + * 2 : disable >> + */ >> +#define BYD_CMD_SET_TAP 0xd4 >> +/* >> + * tap and drag >> + * 1 : tap and hold to drag >> + * 2 : tap and hold to drag + lock >> + * 3 : disable >> + */ >> +#define BYD_CMD_SET_TAP_DRAG0xd5 >> +/* >> + * touch sensitivity >> + * 1 - 7 : least to most sensitive >> + */ >> +#define BYD_CMD_SET_TOUCH_SENSITIVITY 0xd6 >> +/* >> + * one finger scrolling >> + * 1 : vertical >> + * 2 : horizontal >> + * 3 : vertical + horizontal >> + * 4 : disable >> + */ >> +#define BYD_CMD_SET_ONE_FINGER_SCROLL 0xd7 >> +/* >> + * one finger scrolling function >> + * 1 : free scrolling >> + * 2 : edge motion >> + * 3 : free scrolling + edge motion >> + * 4 : disable >> + */ >> +#define BYD_CMD_SET_ONE_FINGER_SCROLL_FUNC 0xd8 >> +/* >> + * sliding speed >> + * 1 - 5 : slowest to fastest >> + */ >> +#define BYD_CMD_SET_SLIDING_SPEED 0xda >> +/* >> + * edge motion >> + * 1 : disable >> + * 2 : enable when dragging >> + * 3 : enable when dragging and pointing >> + */ >> +#define BYD_CMD_SET_EDGE_MOTION 0xdb >> +/* >> + * left edge region size >> + * 0 - 7 : smallest to largest width >> + */ >> +#define BYD_CMD_SET_LEFT_EDGE_REGION0xdc >> +/* >> + * top edge region size >> + * 0 - 9 : smallest to largest height >> + */ >> +#define BYD_CMD_SET_TOP_EDGE_REGION 0xdd >> +/* >> + * disregard palm press as clicks >> + * 1 - 6 : smallest to largest >> +
Re: [PATCH] psmouse: added BYD touchpad driver
Hi Richard, > This adds proper single-touch support for BYD touchpads to the psmouse input > driver. I posted a driver for the same touchpad a few weeks ago, which has been merged into linux-next. There's some stuff in this patch which is missing in my driver though, so we should definitely try and include that, and I'm very curious about the pseudo-absolute mode. > This patch is against commit b82dde0230439215b55e545880e90337ee16f51a (Merge > tag > 'please-pull-copy_file_range' of > git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux ) of Linus' kernel > branch. Can you rebase against 'git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input'? > +/* BYD commands reverse engineered from windows driver */ > + > +/* > + * swipe gesture from off-pad to on-pad > + * 0 : disable > + * 1 : enable > + */ > +#define BYD_CMD_SET_OFFSCREEN_SWIPE 0xcc > +/* > + * tap and drag delay time > + * 0 : disable > + * 1 - 8 : least to most delay > + */ > +#define BYD_CMD_SET_TAP_DRAG_DELAY_TIME 0xcf > +/* > + * physical buttons function mapping > + * 0 : enable > + * 4 : normal > + * 5 : left button custom command > + * 6 : right button custom command > + * 8 : disable > + */ > +#define BYD_CMD_SET_PHYSICAL_BUTTONS0xd0 > +/* > + * absolute mode (1 byte X/Y resolution) > + * 0 : disable > + * 2 : enable > + */ > +#define BYD_CMD_SET_ABSOLUTE_MODE 0xd1 > +/* > + * two finger scrolling > + * 1 : vertical > + * 2 : horizontal > + * 3 : vertical + horizontal > + * 4 : disable > + */ > +#define BYD_CMD_SET_TWO_FINGER_SCROLL 0xd2 > +/* > + * handedness > + * 1 : right handed > + * 2 : left handed > + */ > +#define BYD_CMD_SET_HANDEDNESS 0xd3 > +/* > + * tap to click > + * 1 : enable > + * 2 : disable > + */ > +#define BYD_CMD_SET_TAP 0xd4 > +/* > + * tap and drag > + * 1 : tap and hold to drag > + * 2 : tap and hold to drag + lock > + * 3 : disable > + */ > +#define BYD_CMD_SET_TAP_DRAG0xd5 > +/* > + * touch sensitivity > + * 1 - 7 : least to most sensitive > + */ > +#define BYD_CMD_SET_TOUCH_SENSITIVITY 0xd6 > +/* > + * one finger scrolling > + * 1 : vertical > + * 2 : horizontal > + * 3 : vertical + horizontal > + * 4 : disable > + */ > +#define BYD_CMD_SET_ONE_FINGER_SCROLL 0xd7 > +/* > + * one finger scrolling function > + * 1 : free scrolling > + * 2 : edge motion > + * 3 : free scrolling + edge motion > + * 4 : disable > + */ > +#define BYD_CMD_SET_ONE_FINGER_SCROLL_FUNC 0xd8 > +/* > + * sliding speed > + * 1 - 5 : slowest to fastest > + */ > +#define BYD_CMD_SET_SLIDING_SPEED 0xda > +/* > + * edge motion > + * 1 : disable > + * 2 : enable when dragging > + * 3 : enable when dragging and pointing > + */ > +#define BYD_CMD_SET_EDGE_MOTION 0xdb > +/* > + * left edge region size > + * 0 - 7 : smallest to largest width > + */ > +#define BYD_CMD_SET_LEFT_EDGE_REGION0xdc > +/* > + * top edge region size > + * 0 - 9 : smallest to largest height > + */ > +#define BYD_CMD_SET_TOP_EDGE_REGION 0xdd > +/* > + * disregard palm press as clicks > + * 1 - 6 : smallest to largest > + */ > +#define BYD_CMD_SET_PALM_CHECK 0xde > +/* right edge region size > + * 0 - 7 : smallest to largest width > + */ > +#define BYD_CMD_SET_RIGHT_EDGE_REGION 0xdf > +/* > + * bottom edge region size > + * 0 - 9 : smallest to largest height > + */ > +#define BYD_CMD_SET_BOTTOM_EDGE_REGION 0xe1 > +/* > + * multitouch gestures > + * 1 : enable > + * 2 : disable > + */ > +#define BYD_CMD_SET_MULTITOUCH 0xe3 > +/* > + * edge motion speed > + * 0 : control with finger pressure > + * 1 - 9 : slowest to fastest > + */ > +#define BYD_CMD_SET_EDGE_MOTION_SPEED 0xe4 > +/* > + * two finger scolling function > + * 0 : free scrolling > + * 1 : free scrolling (with momentum) > + * 2 : edge motion > + * 3 : free scrolling (with momentum) + edge motion > + * 4 : disable > + */ > +#define BYD_CMD_SET_TWO_FINGER_SCROLL_FUNC 0xe5 These are definitely worth merging into the existing driver - I never got the time to figure out all of the different settings. > + > +struct byd_data { > + struct timer_list timer; > + int32_t abs_x; > + int32_t abs_y; > + uint32_t last_touch_time; > + uint32_t button_left : 1; > + uint32_t button_right : 1; > + uint32_t touch: 1; > +}; > + It looks like whatever email client you used has broken the formatting - when you resend, can you use something which will preserve whitespace properly? See 'Documentation/email-clients.txt'. > +static void byd_report_input(struct psmouse *psmouse) > +{ > + struct byd_data *priv = (struct byd_data *)psmouse->private; > + struct input_dev *dev = psmouse->dev; > + > + input_report_abs(dev, ABS_X, priv->abs_x); > + input_report_abs(dev, ABS_Y, priv->abs_y); > + input_report_key(d
[PATCH] psmouse: added BYD touchpad driver
This adds proper single-touch support for BYD touchpads to the psmouse input driver. This patch is against commit b82dde0230439215b55e545880e90337ee16f51a (Merge tag 'please-pull-copy_file_range' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux ) of Linus' kernel branch. Signed-off-by: Richard Pospesel --- Kconfig|9 Makefile |1 byd.c | 586 + byd.h | 33 +++ psmouse-base.c | 17 + psmouse.h |1 6 files changed, 647 insertions(+) diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig index 17f97e5..63d5349 100644 --- a/drivers/input/mouse/Kconfig +++ b/drivers/input/mouse/Kconfig @@ -161,6 +161,15 @@ config MOUSE_PS2_VMMOUSE If unsure, say N. +config MOUSE_PS2_BYD + bool "BYD PS/2 protocol extension" + depends on MOUSE_PS2 + help + Say Y here if you have a BYD PS/2 touchpad + connected to your system. + + If unsure, say N. + config MOUSE_SERIAL tristate "Serial mouse" select SERIO diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile index ee6a6e9..67f22cc 100644 --- a/drivers/input/mouse/Makefile +++ b/drivers/input/mouse/Makefile @@ -37,6 +37,7 @@ psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o psmouse-$(CONFIG_MOUSE_PS2_TOUCHKIT) += touchkit_ps2.o psmouse-$(CONFIG_MOUSE_PS2_CYPRESS) += cypress_ps2.o psmouse-$(CONFIG_MOUSE_PS2_VMMOUSE) += vmmouse.o +psmouse-$(CONFIG_MOUSE_PS2_BYD) += byd.o elan_i2c-objs := elan_i2c_core.o elan_i2c-$(CONFIG_MOUSE_ELAN_I2C_I2C) += elan_i2c_i2c.o diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c new file mode 100644 index 000..a880adb --- /dev/null +++ b/drivers/input/mouse/byd.c @@ -0,0 +1,586 @@ +/* + * BYD BTP-10463 touchpad PS/2 mouse driver + * + * Copyright (C) 2015, Tai Chi Minh Ralph Eastwood + * Copyright (C) 2015, Martin Wimpress + * Copyright (C) 2015, Jay Kuri + * Copyright (C) 2015, Richard Pospesel + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * Protocol of BYD Touch Pad reverse-engineered from windows driver: + * filename: "byd touchpad driver - win7, 8, 8.1 - 2.4.1.102.zip" + * sha1: 97a0eca8edc482bf9d08ab9509084a514dad4c4b + * datasheet: http://bydit.com/userfiles/file/BTP10463-XXX.pdf + * + */ +#include +#include + +#include +#include +#include +#include + +#include "psmouse.h" +#include "byd.h" + +#define BYD_MODEL_ID_LEN2 +#define BYD_CMD_PAIR(c) ((1 << 12) | (c)) +#define BYD_CMD_PAIR_R(r, c) ((1 << 12) | (r << 8) | (c)) + +/* BYD pad constants */ + +/* + * true device resolution is unknown, however experiments show the + * resolution is about 111 units/mm + * absolute coordinate packets are in the range 0-255 for both X and y + * we pick ABS_X/ABS_Y dimensions which are multiples of 256 and in + * the right ballpark given the touchpad's physical dimensions and estimate + * resolution per spec sheet, device active area dimensions are + * 101.6 x 60.1 mm + */ + +#define BYD_CONST_PAD_WIDTH 11264 +#define BYD_CONST_PAD_HEIGHT6656 +#define BYD_CONST_PAD_RESOLUTION111 + + +/* BYD commands reverse engineered from windows driver */ + +/* + * swipe gesture from off-pad to on-pad + * 0 : disable + * 1 : enable + */ +#define BYD_CMD_SET_OFFSCREEN_SWIPE 0xcc +/* + * tap and drag delay time + * 0 : disable + * 1 - 8 : least to most delay + */ +#define BYD_CMD_SET_TAP_DRAG_DELAY_TIME 0xcf +/* + * physical buttons function mapping + * 0 : enable + * 4 : normal + * 5 : left button custom command + * 6 : right button custom command + * 8 : disable + */ +#define BYD_CMD_SET_PHYSICAL_BUTTONS0xd0 +/* + * absolute mode (1 byte X/Y resolution) + * 0 : disable + * 2 : enable + */ +#define BYD_CMD_SET_ABSOLUTE_MODE 0xd1 +/* + * two finger scrolling + * 1 : vertical + * 2 : horizontal + * 3 : vertical + horizontal + * 4 : disable + */ +#define BYD_CMD_SET_TWO_FINGER_SCROLL 0xd2 +/* + * handedness + * 1 : right handed + * 2 : left handed + */ +#define BYD_CMD_SET_HANDEDNESS 0xd3 +/* + * tap to click + * 1 : enable + * 2 : disable + */ +#define BYD_CMD_SET_TAP 0xd4 +/* + * tap and drag + * 1 : tap and hold to drag + * 2 : tap and hold to drag + lock + * 3 : disable + */ +#define BYD_CMD_SET_TAP_DRAG0xd5 +/* + * touch sensitivity + * 1 - 7 : least to most sensitive + */ +#define BYD_CMD_SET_TOUCH_SENSITIVITY 0xd6 +/* + * one finger scrolling + * 1 : vertical + * 2 : horizontal + * 3 : vertical + horizontal + * 4 : disable + */ +#define BYD_CMD_SET_ONE_FINGER_SCROLL 0xd7 +/* + * one finger scrolling function + * 1 : free scrolling + * 2 : edge motion + * 3 : free scrolling + edge motion