summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chip/stm32/usb_hid_touchpad.c10
-rw-r--r--driver/touchpad_elan.c14
-rw-r--r--include/usb_hid_touchpad.h3
3 files changed, 27 insertions, 0 deletions
diff --git a/chip/stm32/usb_hid_touchpad.c b/chip/stm32/usb_hid_touchpad.c
index ff3ec8d265..a16988f03c 100644
--- a/chip/stm32/usb_hid_touchpad.c
+++ b/chip/stm32/usb_hid_touchpad.c
@@ -139,6 +139,16 @@ static const uint8_t report_desc[] = {
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) */
+ 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 */
};
diff --git a/driver/touchpad_elan.c b/driver/touchpad_elan.c
index 7ba75fa3aa..744ddd6904 100644
--- a/driver/touchpad_elan.c
+++ b/driver/touchpad_elan.c
@@ -7,6 +7,7 @@
#include "console.h"
#include "touchpad_elan.h"
#include "gpio.h"
+#include "hwtimer.h"
#include "i2c.h"
#include "task.h"
#include "timer.h"
@@ -111,6 +112,12 @@ static int elan_tp_write_cmd(uint16_t reg, uint16_t val)
static int finger_status[ETP_MAX_FINGERS] = {0};
+/*
+ * Timestamp of last interrupt (32 bits are enough as we divide the value by 100
+ * and then put it in a 16-bit field).
+ */
+static uint32_t irq_ts;
+
static int elan_tp_read_report(void)
{
int rv;
@@ -120,6 +127,10 @@ static int elan_tp_read_report(void)
uint8_t hover_info;
uint8_t *finger = tp_buf+ETP_FINGER_DATA_OFFSET;
struct usb_hid_touchpad_report report;
+ uint16_t timestamp;
+
+ /* Compute and save timestamp early in case another interrupt comes. */
+ timestamp = irq_ts / USB_HID_TOUCHPAD_TIMESTAMP_UNIT;
i2c_lock(CONFIG_TOUCHPAD_I2C_PORT, 1);
rv = i2c_xfer(CONFIG_TOUCHPAD_I2C_PORT, CONFIG_TOUCHPAD_I2C_ADDR,
@@ -186,6 +197,7 @@ static int elan_tp_read_report(void)
}
report.count = ri;
+ report.timestamp = timestamp;
set_touchpad_report(&report);
@@ -314,6 +326,8 @@ int touchpad_get_info(struct touchpad_info *tp)
void elan_tp_interrupt(enum gpio_signal signal)
{
+ irq_ts = __hw_clock_source_read();
+
task_wake(TASK_ID_TOUCHPAD);
}
diff --git a/include/usb_hid_touchpad.h b/include/usb_hid_touchpad.h
index 16d95b76a1..d7d6dc0363 100644
--- a/include/usb_hid_touchpad.h
+++ b/include/usb_hid_touchpad.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_USB_HID_KEYBOARD_H
#define __CROS_EC_USB_HID_KEYBOARD_H
+#define USB_HID_TOUCHPAD_TIMESTAMP_UNIT 100 /* usec */
+
struct usb_hid_touchpad_report {
uint8_t id; /* 0x01 */
struct {
@@ -22,6 +24,7 @@ struct usb_hid_touchpad_report {
} __packed finger[5];
uint8_t count:7;
uint8_t button:1;
+ uint16_t timestamp;
} __packed;
/* class implementation interfaces */