diff --git a/bdk/input/touch.c b/bdk/input/touch.c index 76562f90..e1c7f974 100644 --- a/bdk/input/touch.c +++ b/bdk/input/touch.c @@ -163,8 +163,9 @@ static int _touch_parse_input_event(touch_event_t *event) int touch_poll(touch_event_t *event) { - int res = i2c_recv_buf_big(event->raw, FTS4_EVENT_SIZE, I2C_3, FTS4_I2C_ADDR, FTS4_CMD_LATEST_EVENT); + u8 cmd = !_touch_info.clone ? FTS4_CMD_LATEST_EVENT : FTS4_CMD_READ_ONE_EVENT; + int res = i2c_recv_buf_big(event->raw, FTS4_EVENT_SIZE, I2C_3, FTS4_I2C_ADDR, cmd); if (!res) res = _touch_parse_input_event(event); @@ -188,6 +189,11 @@ touch_info_t *touch_get_chip_info() _touch_info.config_id = buf[5]; _touch_info.config_ver = buf[6]; + // Validate that device is genuine or proper. + cmd[2] = 2; + _touch_read_reg(cmd, sizeof(cmd), buf, sizeof(buf)); + _touch_info.clone = _touch_info.chip_id != (buf[3] << 8 | buf[4]); + exit: return &_touch_info; } @@ -269,7 +275,7 @@ int touch_panel_ito_test(u8 *err) { // Check that touch IC is supported. touch_info_t *info = touch_get_chip_info(); - if (info->chip_id != FTS4_I2C_CHIP_ID) + if (info->chip_id != FTS4_I2C_CHIP_ID || info->clone) return 1; // Reset touchscreen module. diff --git a/bdk/input/touch.h b/bdk/input/touch.h index b193dfce..48893b95 100644 --- a/bdk/input/touch.h +++ b/bdk/input/touch.h @@ -31,7 +31,7 @@ #define FTS4_CMD_READ_STATUS 0x84 #define FTS4_CMD_READ_ONE_EVENT 0x85 #define FTS4_CMD_READ_ALL_EVENT 0x86 -#define FTS4_CMD_LATEST_EVENT 0x87 +#define FTS4_CMD_LATEST_EVENT 0x87 // Clears event stack. #define FTS4_CMD_SLEEP_IN 0x90 #define FTS4_CMD_SLEEP_OUT 0x91 #define FTS4_CMD_MS_MT_SENSE_OFF 0x92 @@ -156,10 +156,11 @@ typedef struct _touch_panel_info_t } touch_panel_info_t; typedef struct _touch_info_t { - u16 chip_id; - u16 fw_ver; - u16 config_id; - u16 config_ver; + u16 chip_id; + u16 fw_ver; + u16 config_id; + u16 config_ver; + bool clone; } touch_info_t; typedef struct _touch_fw_info_t {