summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei-Han Chen <stimim@google.com>2018-07-06 15:33:25 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-11-19 01:24:16 +0000
commit7460aafceb269e3ac79b87c7b425a1cae59a275a (patch)
treedf4b016ecf3d89aaf15287ea468e539341216fcc
parent0040af5c9cdfa2f04e748c810faca80863b2c941 (diff)
downloadchrome-ec-7460aafceb269e3ac79b87c7b425a1cae59a275a.tar.gz
stm32: usb_hid_touchpad: add confidence
`confidence` is expected from a PTP-compliant touchpad BRANCH=none BUG=b:70482333 BUG=chromium:904711 TEST=manual Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: Ibe7166f43cae5fb36bbcc4e6dfd9ae6525a7225e Reviewed-on: https://chromium-review.googlesource.com/1188170 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1333949 Commit-Queue: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r--board/hammer/board.h4
-rw-r--r--chip/stm32/usb_hid_touchpad.c65
-rw-r--r--driver/touchpad_elan.c1
-rw-r--r--driver/touchpad_st.c4
-rw-r--r--include/usb_hid_touchpad.h23
5 files changed, 54 insertions, 43 deletions
diff --git a/board/hammer/board.h b/board/hammer/board.h
index a1b2f3175b..2f9e74a527 100644
--- a/board/hammer/board.h
+++ b/board/hammer/board.h
@@ -189,14 +189,14 @@
#if defined(BOARD_HAMMER) || defined(BOARD_WAND)
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 3207
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1783
-#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_PRESSURE 1023
+#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_PRESSURE 511
#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 1018 /* tenth of mm */
#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 566 /* tenth of mm */
#define CONFIG_TOUCHPAD_VIRTUAL_SIZE (48*1024)
#elif defined(BOARD_STAFF)
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 3206
#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1832
-#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_PRESSURE 1023
+#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_PRESSURE 511
#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 1017 /* tenth of mm */
#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 581 /* tenth of mm */
#define CONFIG_TOUCHPAD_VIRTUAL_SIZE (56*1024)
diff --git a/chip/stm32/usb_hid_touchpad.c b/chip/stm32/usb_hid_touchpad.c
index 06082fdb1f..ebb8bd9ef4 100644
--- a/chip/stm32/usb_hid_touchpad.c
+++ b/chip/stm32/usb_hid_touchpad.c
@@ -69,23 +69,24 @@ const struct usb_endpoint_descriptor USB_EP_DESC(USB_IFACE_HID_TOUCHPAD, 81) = {
0x05, 0x0D, /* Usage Page (Digitizer) */ \
0x09, 0x22, /* Usage (Finger) */ \
0xA1, 0x02, /* Collection (Logical) */ \
+ 0x09, 0x47, /* Usage (Confidence) */ \
0x09, 0x42, /* Usage (Tip Switch) */ \
+ 0x09, 0x32, /* Usage (In Range) */ \
0x15, 0x00, /* Logical Minimum (0) */ \
0x25, 0x01, /* Logical Maximum (1) */ \
0x75, 0x01, /* Report Size (1) */ \
- 0x95, 0x01, /* Report Count (1) */ \
- 0x81, 0x02, /* Input (Data,Var,Abs) */ \
- 0x09, 0x32, /* Usage (In Range) */ \
+ 0x95, 0x03, /* Report Count (3) */ \
0x81, 0x02, /* Input (Data,Var,Abs) */ \
- 0x75, 0x04, /* Report Size (4) */ \
0x09, 0x51, /* Usage (0x51) Contact identifier */ \
+ 0x75, 0x04, /* Report Size (4) */ \
+ 0x95, 0x01, /* Report Count (1) */ \
0x25, 0x0F, /* Logical Maximum (15) */ \
0x81, 0x02, /* Input (Data,Var,Abs) */ \
0x05, 0x0D, /* Usage Page (Digitizer) */ \
/* Logical Maximum of Pressure */ \
0x26, (CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_PRESSURE & 0xFF), \
(CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_PRESSURE >> 8), \
- 0x75, 0x0A, /* Report Size (10) */ \
+ 0x75, 0x09, /* Report Size (9) */ \
0x09, 0x30, /* Usage (Tip pressure) */ \
0x81, 0x02, /* Input (Data,Var,Abs) */ \
0x26, 0xFF, 0x00, /* Logical Maximum (255) */ \
@@ -123,10 +124,11 @@ const struct usb_endpoint_descriptor USB_EP_DESC(USB_IFACE_HID_TOUCHPAD, 81) = {
* Finger Usage is repeated 5 times.
*/
static const uint8_t report_desc[] = {
- 0x05, 0x0D, /* Usage Page (Digitizer) */
- 0x09, 0x05, /* Usage (Touch Pad) */
- 0xA1, 0x01, /* Collection (Application) */
- 0x85, 0x01, /* Report ID (1, Touch) */
+ /* Touchpad Collection */
+ 0x05, 0x0D, /* Usage Page (Digitizer) */
+ 0x09, 0x05, /* Usage (Touch Pad) */
+ 0xA1, 0x01, /* Collection (Application) */
+ 0x85, REPORT_ID_TOUCHPAD, /* Report ID (1, Touch) */
/* Finger 0 */
FINGER_USAGE,
/* Finger 1 */
@@ -138,32 +140,33 @@ static const uint8_t report_desc[] = {
/* Finger 4 */
FINGER_USAGE,
/* Contact count */
- 0x05, 0x0D, /* Usage Page (Digitizer) */
- 0x09, 0x54, /* Usage (Contact count) */
- 0x75, 0x07, /* Report Size (7) */
- 0x95, 0x01, /* Report Count (1) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
+ 0x05, 0x0D, /* Usage Page (Digitizer) */
+ 0x09, 0x54, /* Usage (Contact count) */
+ 0x25, MAX_FINGERS, /* Logical Maximum (MAX_FINGERS) */
+ 0x75, 0x07, /* Report Size (7) */
+ 0x95, 0x01, /* Report Count (1) */
+ 0x81, 0x02, /* Input (Data,Var,Abs) */
/* Button */
- 0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */
- 0x05, 0x09, /* Usage (Button) */
- 0x19, 0x01, /* Usage Minimum (0x01) */
- 0x29, 0x01, /* Usage Maximum (0x01) */
- 0x15, 0x00, /* Logical Minimum (0) */
- 0x25, 0x01, /* Logical Maximum (1) */
- 0x75, 0x01, /* Report Size (1) */
- 0x95, 0x01, /* Report Count (1) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
+ 0x05, 0x01, /* Usage Page(Generic Desktop Ctrls) */
+ 0x05, 0x09, /* Usage (Button) */
+ 0x19, 0x01, /* Usage Minimum (0x01) */
+ 0x29, 0x01, /* Usage Maximum (0x01) */
+ 0x15, 0x00, /* Logical Minimum (0) */
+ 0x25, 0x01, /* Logical Maximum (1) */
+ 0x75, 0x01, /* Report Size (1) */
+ 0x95, 0x01, /* Report Count (1) */
+ 0x81, 0x02, /* Input (Data,Var,Abs) */
/* Timestamp */
- 0x05, 0x0D, /* Usage Page (Digitizer) */
- 0x55, 0x0C, /* Unit Exponent (-4) */
- 0x66, 0x01, 0x10, /* Unit (System: SI Linear, Time: Seconds) */
+ 0x05, 0x0D, /* Usage Page (Digitizer) */
+ 0x55, 0x0C, /* Unit Exponent (-4) */
+ 0x66, 0x01, 0x10, /* Unit (Seconds) */
0x47, 0xFF, 0xFF, 0x00, 0x00, /* Physical Maximum (65535) */
0x27, 0xFF, 0xFF, 0x00, 0x00, /* Logical Maximum (65535) */
- 0x75, 0x10, /* Report Size (16) */
- 0x95, 0x01, /* Report Count (1) */
- 0x09, 0x56, /* Usage (0x56, Relative Scan Time) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
- 0xC0, /* End Collection */
+ 0x75, 0x10, /* Report Size (16) */
+ 0x95, 0x01, /* Report Count (1) */
+ 0x09, 0x56, /* Usage (0x56, Relative Scan Time) */
+ 0x81, 0x02, /* Input (Data,Var,Abs) */
+ 0xC0, /* End Collection */
};
const struct usb_hid_descriptor USB_CUSTOM_DESC_VAR(USB_IFACE_HID_TOUCHPAD,
diff --git a/driver/touchpad_elan.c b/driver/touchpad_elan.c
index 9cc399ae6e..8988a99cf0 100644
--- a/driver/touchpad_elan.c
+++ b/driver/touchpad_elan.c
@@ -237,6 +237,7 @@ static int elan_tp_read_report(void)
height = MIN(4095, height * elan_tp_params.width_y);
pressure = MIN(1023, pressure);
+ report.finger[ri].confidence = 1;
report.finger[ri].tip = 1;
report.finger[ri].inrange = 1;
report.finger[ri].id = i;
diff --git a/driver/touchpad_st.c b/driver/touchpad_st.c
index 340923e587..7384e33af9 100644
--- a/driver/touchpad_st.c
+++ b/driver/touchpad_st.c
@@ -99,6 +99,8 @@ static int st_tp_parse_finger(struct usb_hid_touchpad_report *report,
switch (event->evt_id) {
case ST_TP_EVENT_ID_ENTER_POINTER:
case ST_TP_EVENT_ID_MOTION_POINTER:
+ /* Pressure == 255 is a palm. */
+ report->finger[i].confidence = (event->finger.z < 255);
report->finger[i].tip = 1;
report->finger[i].inrange = 1;
report->finger[i].id = event->finger.touch_id;
@@ -145,7 +147,7 @@ static int st_tp_write_hid_report(void)
return ret;
memset(&report, 0, sizeof(report));
- report.id = 0x1;
+ report.id = REPORT_ID_TOUCHPAD;
num_finger = 0;
for (i = 0; i < ARRAY_SIZE(rx_buf.events); i++) {
diff --git a/include/usb_hid_touchpad.h b/include/usb_hid_touchpad.h
index 39b6277b96..3d6207b19e 100644
--- a/include/usb_hid_touchpad.h
+++ b/include/usb_hid_touchpad.h
@@ -10,18 +10,23 @@
#define USB_HID_TOUCHPAD_TIMESTAMP_UNIT 100 /* usec */
+#define REPORT_ID_TOUCHPAD 0x01
+
+#define MAX_FINGERS 5
+
struct usb_hid_touchpad_report {
uint8_t id; /* 0x01 */
struct {
- unsigned tip:1;
- unsigned inrange:1;
- unsigned id:4;
- unsigned pressure:10;
- unsigned width:12;
- unsigned height:12;
- unsigned x:12;
- unsigned y:12;
- } __packed finger[5];
+ uint16_t confidence:1;
+ uint16_t tip:1;
+ uint16_t inrange:1;
+ uint16_t id:4;
+ uint16_t pressure:9;
+ uint16_t width:12;
+ uint16_t height:12;
+ uint16_t x:12;
+ uint16_t y:12;
+ } __packed finger[MAX_FINGERS];
uint8_t count:7;
uint8_t button:1;
uint16_t timestamp;