summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2017-05-16 12:01:51 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-05-18 02:26:08 -0700
commit12a8ab8a5c59f754caa098a2ac09d6a2db4fcc2a (patch)
treed44bb984f07627c9d36b3560b5429c7662004a08
parent760c89fe3746278c9324c981d0adf6d3e79562d0 (diff)
downloadchrome-ec-12a8ab8a5c59f754caa098a2ac09d6a2db4fcc2a.tar.gz
usb_hid_touchpad: Add config options to set dimensions
In principle, trackpad dimensions (logical and physical), can be probed from the trackpad at runtime, but this would slow down setup time, as we need to wait for the trackpad to be initialized to read those. Also, we do not have a framework to generate HID report at runtime, and a new base with new trackpad would probably require a new overlay anyway. Also, set appropriate (temporary) values for both hammer and staff. BRANCH=none BUG=b:38277869 TEST=Connect hammer/staff to host, correct logical dimensions are shown in evtest, and resolution is always 32. Change-Id: I39b84274d71ca2f4e285f3324c0841331aae9bc1 Reviewed-on: https://chromium-review.googlesource.com/505856 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/hammer/board.h16
-rw-r--r--chip/stm32/usb_hid_touchpad.c102
-rw-r--r--include/config.h7
3 files changed, 52 insertions, 73 deletions
diff --git a/board/hammer/board.h b/board/hammer/board.h
index 4debd1d10f..b7d2b57f89 100644
--- a/board/hammer/board.h
+++ b/board/hammer/board.h
@@ -135,6 +135,22 @@
#define CONFIG_USB_HID_KEYBOARD
#define CONFIG_USB_HID_TOUCHPAD
+#ifdef BOARD_STAFF
+/* TODO(b:38277869): Adjust values to match hardware. */
+#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 3214
+#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1840
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 1020 /* tenth of mm */
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 584 /* tenth of mm */
+#elif defined(BOARD_HAMMER)
+/* TODO(b:35582031): Adjust values to match hardware. */
+#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 2948
+#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1600
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 935 /* tenth of mm */
+#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 508 /* tenth of mm */
+#else
+#error "No trackpad information for board."
+#endif
+
#define CONFIG_KEYBOARD_DEBUG
#undef CONFIG_KEYBOARD_BOOT_KEYS
#undef CONFIG_KEYBOARD_RUNTIME_KEYS
diff --git a/chip/stm32/usb_hid_touchpad.c b/chip/stm32/usb_hid_touchpad.c
index af2334e0f1..8f2d2c4dad 100644
--- a/chip/stm32/usb_hid_touchpad.c
+++ b/chip/stm32/usb_hid_touchpad.c
@@ -53,12 +53,33 @@ const struct usb_endpoint_descriptor USB_EP_DESC(USB_IFACE_HID_TOUCHPAD, 81) = {
.bInterval = HID_TOUCHPAD_EP_INTERVAL_MS /* polling interval */
};
+#define FINGER_USAGE_X_Y \
+ 0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */ \
+ 0x75, 0x0C, /* Report Size (12) */ \
+ 0x55, 0x0E, /* Unit Exponent (-2) */ \
+ 0x65, 0x11, /* Unit (System: SI Linear, Length: cm) */ \
+ 0x09, 0x30, /* Usage (X) */ \
+ 0x35, 0x00, /* Physical Minimum (0) */ \
+ 0x26, (CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X & 0xff), \
+ (CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X >> 8), \
+ /* Logical Maximum */ \
+ 0x46, (CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X & 0xff), \
+ (CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X >> 8), \
+ /* Physical Maximum (tenth of mm) */ \
+ 0x81, 0x02, /* Input (Data,Var,Abs) */ \
+ 0x26, (CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y & 0xff), \
+ (CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y >> 8), \
+ /* Logical Maximum */ \
+ 0x46, (CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y & 0xff), \
+ (CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y >> 8), \
+ /* Physical Maximum (tenth of mm) */ \
+ 0x09, 0x31, /* Usage (Y) */ \
+ 0x81, 0x02 /* Input (Data,Var,Abs) */
+
/*
* HID: Report Descriptor
- * TODO(crosbug.com/p/59083): There are ways to reduce flash usage, as the
+ * TODO(b/35582031): There are ways to reduce flash usage, as the
* Finger Usage is repeated 5 times.
- * TODO(crosbug.com/p/59083): Touchpad specific values should be probed from
- * touchpad itself.
*/
static const uint8_t report_desc[] = {
0x05, 0x0D, /* Usage Page (Digitizer) */
@@ -87,20 +108,7 @@ static const uint8_t report_desc[] = {
0x81, 0x02, /* Input (Data,Var,Abs) */
0x09, 0x49, /* Usage (HEIGHT) */
0x81, 0x02, /* Input (Data,Var,Abs) */
- 0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */
- 0x75, 0x0C, /* Report Size (12) */
- 0x55, 0x0E, /* Unit Exponent (-2) */
- 0x65, 0x11, /* Unit (System: SI Linear, Length: cm) */
- 0x09, 0x30, /* Usage (X) */
- /* FIXME: Physical/logical dimensions should come from trackpad info */
- 0x35, 0x00, /* Physical Minimum (0) */
- 0x26, 0x86, 0x0C, /* Logical Maximum (3206) */
- 0x46, 0xF8, 0x03, /* Physical Maximum (10.16 cm) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
- 0x26, 0xf7, 0x06, /* Logical Maximum (1783) */
- 0x46, 0x36, 0x02, /* Physical Maximum (5.66 cm) */
- 0x09, 0x31, /* Usage (Y) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
+ FINGER_USAGE_X_Y,
0x05, 0x0D, /* Usage Page (Digitizer) */
0x26, 0xFF, 0x00, /* Logical Maximum (255) */
0x75, 0x08, /* Report Size (8) */
@@ -129,20 +137,7 @@ static const uint8_t report_desc[] = {
0x81, 0x02, /* Input (Data,Var,Abs) */
0x09, 0x49, /* Usage (HEIGHT) */
0x81, 0x02, /* Input (Data,Var,Abs) */
- 0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */
- 0x75, 0x0C, /* Report Size (12) */
- 0x55, 0x0E, /* Unit Exponent (-2) */
- 0x65, 0x11, /* Unit (System: SI Linear, Length: cm) */
- 0x09, 0x30, /* Usage (X) */
- /* FIXME: Physical/logical dimensions should come from trackpad info */
- 0x35, 0x00, /* Physical Minimum (0) */
- 0x26, 0x86, 0x0C, /* Logical Maximum (3206) */
- 0x46, 0xF8, 0x03, /* Physical Maximum (10.16 cm) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
- 0x26, 0xf7, 0x06, /* Logical Maximum (1783) */
- 0x46, 0x36, 0x02, /* Physical Maximum (5.66 cm) */
- 0x09, 0x31, /* Usage (Y) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
+ FINGER_USAGE_X_Y,
0x05, 0x0D, /* Usage Page (Digitizer) */
0x26, 0xFF, 0x00, /* Logical Maximum (255) */
0x75, 0x08, /* Report Size (8) */
@@ -171,20 +166,7 @@ static const uint8_t report_desc[] = {
0x81, 0x02, /* Input (Data,Var,Abs) */
0x09, 0x49, /* Usage (HEIGHT) */
0x81, 0x02, /* Input (Data,Var,Abs) */
- 0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */
- 0x75, 0x0C, /* Report Size (12) */
- 0x55, 0x0E, /* Unit Exponent (-2) */
- 0x65, 0x11, /* Unit (System: SI Linear, Length: cm) */
- 0x09, 0x30, /* Usage (X) */
- /* FIXME: Physical/logical dimensions should come from trackpad info */
- 0x35, 0x00, /* Physical Minimum (0) */
- 0x26, 0x86, 0x0C, /* Logical Maximum (3206) */
- 0x46, 0xF8, 0x03, /* Physical Maximum (10.16 cm) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
- 0x26, 0xf7, 0x06, /* Logical Maximum (1783) */
- 0x46, 0x36, 0x02, /* Physical Maximum (5.66 cm) */
- 0x09, 0x31, /* Usage (Y) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
+ FINGER_USAGE_X_Y,
0x05, 0x0D, /* Usage Page (Digitizer) */
0x26, 0xFF, 0x00, /* Logical Maximum (255) */
0x75, 0x08, /* Report Size (8) */
@@ -213,20 +195,7 @@ static const uint8_t report_desc[] = {
0x81, 0x02, /* Input (Data,Var,Abs) */
0x09, 0x49, /* Usage (HEIGHT) */
0x81, 0x02, /* Input (Data,Var,Abs) */
- 0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */
- 0x75, 0x0C, /* Report Size (12) */
- 0x55, 0x0E, /* Unit Exponent (-2) */
- 0x65, 0x11, /* Unit (System: SI Linear, Length: cm) */
- 0x09, 0x30, /* Usage (X) */
- /* FIXME: Physical/logical dimensions should come from trackpad info */
- 0x35, 0x00, /* Physical Minimum (0) */
- 0x26, 0x86, 0x0C, /* Logical Maximum (3206) */
- 0x46, 0xF8, 0x03, /* Physical Maximum (10.16 cm) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
- 0x26, 0xf7, 0x06, /* Logical Maximum (1783) */
- 0x46, 0x36, 0x02, /* Physical Maximum (5.66 cm) */
- 0x09, 0x31, /* Usage (Y) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
+ FINGER_USAGE_X_Y,
0x05, 0x0D, /* Usage Page (Digitizer) */
0x26, 0xFF, 0x00, /* Logical Maximum (255) */
0x75, 0x08, /* Report Size (8) */
@@ -255,20 +224,7 @@ static const uint8_t report_desc[] = {
0x81, 0x02, /* Input (Data,Var,Abs) */
0x09, 0x49, /* Usage (HEIGHT) */
0x81, 0x02, /* Input (Data,Var,Abs) */
- 0x05, 0x01, /* Usage Page (Generic Desktop Ctrls) */
- 0x75, 0x0C, /* Report Size (12) */
- 0x55, 0x0E, /* Unit Exponent (-2) */
- 0x65, 0x11, /* Unit (System: SI Linear, Length: cm) */
- 0x09, 0x30, /* Usage (X) */
- /* FIXME: Physical/logical dimensions should come from trackpad info */
- 0x35, 0x00, /* Physical Minimum (0) */
- 0x26, 0x86, 0x0C, /* Logical Maximum (3206) */
- 0x46, 0xF8, 0x03, /* Physical Maximum (10.16 cm) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
- 0x26, 0xf7, 0x06, /* Logical Maximum (1783) */
- 0x46, 0x36, 0x02, /* Physical Maximum (5.66 cm) */
- 0x09, 0x31, /* Usage (Y) */
- 0x81, 0x02, /* Input (Data,Var,Abs) */
+ FINGER_USAGE_X_Y,
0x05, 0x0D, /* Usage Page (Digitizer) */
0x26, 0xFF, 0x00, /* Logical Maximum (255) */
0x75, 0x08, /* Report Size (8) */
diff --git a/include/config.h b/include/config.h
index 90f13b3dcc..701d815c6a 100644
--- a/include/config.h
+++ b/include/config.h
@@ -2469,6 +2469,13 @@
/* Support USB HID touchpad interface. */
#undef CONFIG_USB_HID_TOUCHPAD
+/* HID touchpad logical dimensions */
+#undef CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X
+#undef CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y
+/* HID touchpad physical dimensions (tenth of mm) */
+#undef CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X
+#undef CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y
+
/* USB device buffers and descriptors */
#undef CONFIG_USB_RAM_ACCESS_SIZE
#undef CONFIG_USB_RAM_ACCESS_TYPE