From patchwork Mon Dec 9 03:41:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dave.Wang" X-Patchwork-Id: 11278391 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4270A6C1 for ; Mon, 9 Dec 2019 03:42:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20C5C2071A for ; Mon, 9 Dec 2019 03:42:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726748AbfLIDmK (ORCPT ); Sun, 8 Dec 2019 22:42:10 -0500 Received: from emcscan.emc.com.tw ([192.72.220.5]:43216 "EHLO emcscan.emc.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727030AbfLIDmJ (ORCPT ); Sun, 8 Dec 2019 22:42:09 -0500 X-IronPort-AV: E=Sophos;i="5.56,253,1539619200"; d="scan'208";a="33196494" Received: from unknown (HELO webmail.emc.com.tw) ([192.168.10.1]) by emcscan.emc.com.tw with ESMTP; 09 Dec 2019 11:42:06 +0800 Received: from 192.168.10.23 by webmail.emc.com.tw with MailAudit ESMTP Server V5.0(71506:0:AUTH_RELAY) (envelope-from ); Mon, 09 Dec 2019 11:42:07 +0800 (CST) Received: from 42.73.254.157 by webmail.emc.com.tw with Mail2000 ESMTPA Server V7.00(101173:0:AUTH_LOGIN) (envelope-from ); Mon, 09 Dec 2019 11:42:07 +0800 (CST) From: Dave Wang To: Linux-input@vger.kernel.org, Linux-kernel@vger.kernel.org, Dmitry.torokhov@gmail.com Cc: phoenix@emc.com.tw, josh.chen@emc.com.tw, jingle.wu@emc.com.tw, kai.heng.feng@canonical.com, "Dave.Wang" Subject: [PATCH 4/6] Input: elantech - High resolution report for new pattern 2 Date: Sun, 8 Dec 2019 22:41:59 -0500 Message-Id: <20191209034159.30394-1-dave.wang@emc.com.tw> X-Mailer: git-send-email 2.17.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: "Dave.Wang" Due to the higher resolution touchpad is produced, the former resolution bits were not enough. Extend the resolution bits from 12 to 14 bits and also remove the mk value for new pattern 2. Signed-off-by: Dave Wang --- drivers/input/mouse/elantech.c | 66 +++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 322b181d00e9..53d7ff719d76 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -639,15 +639,21 @@ static void process_packet_head_v4(struct psmouse *psmouse) struct elantech_data *etd = psmouse->private; unsigned char *packet = psmouse->packet; int id = ((packet[3] & 0xe0) >> 5) - 1; - int pres, traces; + int pres, traces = 0; if (id < 0) return; - etd->mt[id].x = ((packet[1] & 0x0f) << 8) | packet[2]; - etd->mt[id].y = etd->y_max - (((packet[4] & 0x0f) << 8) | packet[5]); - pres = (packet[1] & 0xf0) | ((packet[4] & 0xf0) >> 4); - traces = (packet[0] & 0xf0) >> 4; + if (etd->info.pattern <= 0x01) { + etd->mt[id].x = ((packet[1] & 0x0f) << 8) | packet[2]; + etd->mt[id].y = etd->y_max - (((packet[4] & 0x0f) << 8) | packet[5]); + pres = (packet[1] & 0xf0) | ((packet[4] & 0xf0) >> 4); + traces = (packet[0] & 0xf0) >> 4; + } else { + etd->mt[id].x = ((packet[1] & 0x3f) << 8) | packet[2]; + etd->mt[id].y = etd->y_max - (((packet[4] & 0x3f) << 8) | packet[5]); + pres = (packet[4] & 0xc0) | ((packet[1] & 0xc0) >> 2) | ((packet[0] & 0xf0) >> 4); + } input_mt_slot(dev, id); input_mt_report_slot_state(dev, MT_TOOL_FINGER, true); @@ -655,9 +661,11 @@ static void process_packet_head_v4(struct psmouse *psmouse) input_report_abs(dev, ABS_MT_POSITION_X, etd->mt[id].x); input_report_abs(dev, ABS_MT_POSITION_Y, etd->mt[id].y); input_report_abs(dev, ABS_MT_PRESSURE, pres); - input_report_abs(dev, ABS_MT_TOUCH_MAJOR, traces * etd->width); - /* report this for backwards compatibility */ - input_report_abs(dev, ABS_TOOL_WIDTH, traces); + if (etd->info.pattern <= 0x01) { + input_report_abs(dev, ABS_MT_TOUCH_MAJOR, traces * etd->width); + /* report this for backwards compatibility */ + input_report_abs(dev, ABS_TOOL_WIDTH, traces); + } elantech_input_sync_v4(psmouse); } @@ -1057,15 +1065,24 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse) } /* - * (value from firmware) * 10 + 790 = dpi + * pattern <= 0x01: + * (value from firmware) * 10 + 790 = dpi + * else + * ((value from firmware) + 3) * 100 = dpi + * * we also have to convert dpi to dots/mm (*10/254 to avoid floating point) */ -static unsigned int elantech_convert_res(unsigned int val) +static unsigned int elantech_convert_res(unsigned int val, + unsigned char pattern) { - return (val * 10 + 790) * 10 / 254; + if (pattern <= 0x01) + return (val * 10 + 790) * 10 / 254; + else + return ((val + 3) * 100) * 10 / 254; } static int elantech_get_resolution_v4(struct psmouse *psmouse, + unsigned char pattern, unsigned int *x_res, unsigned int *y_res, unsigned int *bus) @@ -1075,8 +1092,8 @@ static int elantech_get_resolution_v4(struct psmouse *psmouse, if (elantech_send_cmd(psmouse, ETP_RESOLUTION_QUERY, param)) return -1; - *x_res = elantech_convert_res(param[1] & 0x0f); - *y_res = elantech_convert_res((param[1] & 0xf0) >> 4); + *x_res = elantech_convert_res(param[1] & 0x0f, pattern); + *y_res = elantech_convert_res((param[1] & 0xf0) >> 4, pattern); *bus = param[2]; return 0; @@ -1194,7 +1211,8 @@ static int elantech_set_input_params(struct psmouse *psmouse) */ input_set_abs_params(dev, ABS_PRESSURE, ETP_PMIN_V2, ETP_PMAX_V2, 0, 0); - input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2, + if (etd->info.pattern <= 0x01) + input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2, ETP_WMAX_V2, 0, 0); /* Multitouch capable pad, up to 5 fingers. */ input_mt_init_slots(dev, ETP_MAX_FINGERS, 0); @@ -1206,7 +1224,8 @@ static int elantech_set_input_params(struct psmouse *psmouse) * The firmware reports how many trace lines the finger spans, * convert to surface unit as Protocol-B requires. */ - input_set_abs_params(dev, ABS_MT_TOUCH_MAJOR, 0, + if (etd->info.pattern <= 0x01) + input_set_abs_params(dev, ABS_MT_TOUCH_MAJOR, 0, ETP_WMAX_V2 * width, 0, 0); break; } @@ -1628,6 +1647,7 @@ static int elantech_query_info(struct psmouse *psmouse, { unsigned char param[3]; unsigned char traces; + unsigned char y_max_l; memset(info, 0, sizeof(*info)); @@ -1732,6 +1752,7 @@ static int elantech_query_info(struct psmouse *psmouse, info->y_res = 31; if (info->hw_version == 4) { if (elantech_get_resolution_v4(psmouse, + info->pattern, &info->x_res, &info->y_res, &info->bus)) { @@ -1800,8 +1821,19 @@ static int elantech_query_info(struct psmouse *psmouse, if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) return -EINVAL; - info->x_max = (0x0f & param[0]) << 8 | param[1]; - info->y_max = (0xf0 & param[0]) << 4 | param[2]; + if (info->pattern <= 0x01) { + info->x_max = (0x0f & param[0]) << 8 | param[1]; + info->y_max = (0xf0 & param[0]) << 4 | param[2]; + } else { + info->x_max = (param[0] << 8) | param[1]; + y_max_l = param[2]; + + if (info->send_cmd(psmouse, ETP_SAMPLE_QUERY, param)) + return -1; + + info->y_max = param[2] << 8 | y_max_l; + } + traces = info->capabilities[1]; if ((traces < 2) || (traces > info->x_max)) return -EINVAL; From patchwork Mon Dec 9 03:42:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dave.Wang" X-Patchwork-Id: 11278393 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 69ABF139A for ; Mon, 9 Dec 2019 03:42:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51C742071A for ; Mon, 9 Dec 2019 03:42:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726957AbfLIDms (ORCPT ); Sun, 8 Dec 2019 22:42:48 -0500 Received: from emcscan.emc.com.tw ([192.72.220.5]:46123 "EHLO emcscan.emc.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726894AbfLIDms (ORCPT ); Sun, 8 Dec 2019 22:42:48 -0500 X-IronPort-AV: E=Sophos;i="5.56,253,1539619200"; d="scan'208";a="33196523" Received: from unknown (HELO webmail.emc.com.tw) ([192.168.10.1]) by emcscan.emc.com.tw with ESMTP; 09 Dec 2019 11:42:47 +0800 Received: from 192.168.10.23 by webmail.emc.com.tw with MailAudit ESMTP Server V5.0(71508:0:AUTH_RELAY) (envelope-from ); Mon, 09 Dec 2019 11:42:45 +0800 (CST) Received: from 42.73.254.157 by webmail.emc.com.tw with Mail2000 ESMTPA Server V7.00(101176:0:AUTH_LOGIN) (envelope-from ); Mon, 09 Dec 2019 11:42:45 +0800 (CST) From: Dave Wang To: Linux-input@vger.kernel.org, Linux-kernel@vger.kernel.org, Dmitry.torokhov@gmail.com Cc: phoenix@emc.com.tw, josh.chen@emc.com.tw, jingle.wu@emc.com.tw, kai.heng.feng@canonical.com, "Dave.Wang" Subject: [PATCH 5/6] Input: elantech - Transfer the device information from PS/2 to SMBus Date: Sun, 8 Dec 2019 22:42:40 -0500 Message-Id: <20191209034240.30450-1-dave.wang@emc.com.tw> X-Mailer: git-send-email 2.17.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: "Dave.Wang" Many commands in SMBus interface cannot be triggered. In order to get the correct device information, transfer the device information from PS/2 to SMBus interface for PS/2+SMbus protocol. Signed-off-by: Dave Wang --- drivers/input/mouse/elantech.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 53d7ff719d76..0392b668cd39 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -1889,12 +1889,28 @@ static int elantech_create_smbus(struct psmouse *psmouse, struct elantech_device_info *info, bool leave_breadcrumbs) { - struct property_entry i2c_props[11] = {}; + struct property_entry i2c_props[19] = {}; struct i2c_board_info smbus_board = { I2C_BOARD_INFO("elan_i2c", 0x15), .flags = I2C_CLIENT_HOST_NOTIFY, }; unsigned int idx = 0; + u16 product_id, ic_type; + u8 sm_version, fw_version, iap_version; + + if (info->pattern > 0) { + product_id = get_unaligned_be16(info->samples); + sm_version = info->bus; + ic_type = get_unaligned_be16(info->ic_body); + fw_version = info->ic_body[2]; + iap_version = info->iap_version[2]; + } else { + product_id = info->samples[1]; + sm_version = info->samples[0]; + ic_type = (info->fw_version & 0x0f0000) >> 16; + fw_version = info->fw_version & 0x0000ff; + iap_version = 0x00; + } smbus_board.properties = i2c_props; @@ -1906,6 +1922,22 @@ static int elantech_create_smbus(struct psmouse *psmouse, info->x_min); i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-min-y", info->y_min); + i2c_props[idx++] = PROPERTY_ENTRY_U16("elan,product_id", + product_id); + i2c_props[idx++] = PROPERTY_ENTRY_U8("elan,sm_version", + sm_version); + i2c_props[idx++] = PROPERTY_ENTRY_U16("elan,ic_type", + ic_type); + i2c_props[idx++] = PROPERTY_ENTRY_U8("elan,fw_version", + fw_version); + i2c_props[idx++] = PROPERTY_ENTRY_U16("elan,fw_checksum", + info->fw_checksum[0] << 8 | info->fw_checksum[1]); + i2c_props[idx++] = PROPERTY_ENTRY_U16("elan,iap_checksum", + info->iap_checksum[0] << 8 | info->iap_checksum[1]); + i2c_props[idx++] = PROPERTY_ENTRY_U8("elan,iap_version", + iap_version); + i2c_props[idx++] = PROPERTY_ENTRY_U8("elan,pattern", + info->pattern); if (info->x_res) i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-x-mm", (info->x_max + 1) / info->x_res); From patchwork Mon Dec 9 03:43:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dave.Wang" X-Patchwork-Id: 11278395 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EE87139A for ; Mon, 9 Dec 2019 03:43:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 676442071A for ; Mon, 9 Dec 2019 03:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbfLIDnU (ORCPT ); Sun, 8 Dec 2019 22:43:20 -0500 Received: from emcscan.emc.com.tw ([192.72.220.5]:44940 "EHLO emcscan.emc.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727003AbfLIDnR (ORCPT ); Sun, 8 Dec 2019 22:43:17 -0500 X-IronPort-AV: E=Sophos;i="5.56,253,1539619200"; d="scan'208";a="33196541" Received: from unknown (HELO webmail.emc.com.tw) ([192.168.10.1]) by emcscan.emc.com.tw with ESMTP; 09 Dec 2019 11:43:14 +0800 Received: from 192.168.10.23 by webmail.emc.com.tw with MailAudit ESMTP Server V5.0(71485:0:AUTH_RELAY) (envelope-from ); Mon, 09 Dec 2019 11:43:14 +0800 (CST) Received: from 42.73.254.157 by webmail.emc.com.tw with Mail2000 ESMTPA Server V7.00(101170:0:AUTH_LOGIN) (envelope-from ); Mon, 09 Dec 2019 11:43:12 +0800 (CST) From: Dave Wang To: Linux-input@vger.kernel.org, Linux-kernel@vger.kernel.org, Dmitry.torokhov@gmail.com Cc: phoenix@emc.com.tw, josh.chen@emc.com.tw, jingle.wu@emc.com.tw, kai.heng.feng@canonical.com, "Dave.Wang" Subject: [PATCH 6/6] Input: elantech - Add the flag which will also use host notify Date: Sun, 8 Dec 2019 22:43:07 -0500 Message-Id: <20191209034307.30504-1-dave.wang@emc.com.tw> X-Mailer: git-send-email 2.17.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: "Dave.Wang" Add the flag which will also use host notify technique in SMBus interface. Signed-off-by: Dave Wang --- drivers/input/mouse/elantech.c | 1 + drivers/input/mouse/elantech.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 0392b668cd39..3422710f4100 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -2022,6 +2022,7 @@ static bool elantech_use_host_notify(struct psmouse *psmouse, case ETP_BUS_SMB_HST_NTFY_ONLY: /* fall-through */ case ETP_BUS_PS2_SMB_HST_NTFY: + case ETP_BUS_AMD_SMB_ALERT: return true; default: psmouse_dbg(psmouse, diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h index a633ffa0eb07..3b35ebb56607 100644 --- a/drivers/input/mouse/elantech.h +++ b/drivers/input/mouse/elantech.h @@ -115,6 +115,7 @@ #define ETP_BUS_SMB_HST_NTFY_ONLY 2 #define ETP_BUS_PS2_SMB_ALERT 3 #define ETP_BUS_PS2_SMB_HST_NTFY 4 +#define ETP_BUS_AMD_SMB_ALERT 6 /* * New ICs are either using SMBus Host Notify or just plain PS2.