Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1464821ybb; Thu, 26 Mar 2020 01:00:40 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtrm84ru+PNo56TTAstrkKaFNUkI03hHfAG97RwL/YzkfkZPLTAbYV5jeoqhE4R5c8iySNW X-Received: by 2002:aca:558c:: with SMTP id j134mr1001096oib.102.1585209640072; Thu, 26 Mar 2020 01:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585209640; cv=none; d=google.com; s=arc-20160816; b=llgkCTjRGPimD4xAyGurXFqDwPPRvFg9iDKX0Mz2+3DC8YXhvylP8EnlcQfznzCc6M DJLkhFHsSCNpVCmR5+F8keOKUoqrBiBZmlO/yxp1J/z6tXz2IjygER84AKB5pOp8Hf/2 Kw4Y2iQa1n87kDPB4w+k3ULkQhep8OJh6HnMAdQagXrAAScJVPXTz9vip6oPHzYL+RjZ BLdvQ6GeZ0FgyYWFjUW6zB7WphszSaRetnvylDQx8EY8/slFL0ZmV2iI2fGLco4UiIQM uNTG3Nic5qSufGtcfyNIn0hcy3UJv8kHlwvXmdgID23dpaB0Q+kNweeHRJW1q3kxiOPE kh5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=kpesQAb1EfvXtxtfV/ThTPpjKNkxOztwAVy2KkYtRQs=; b=YlThZJavE3lYNcPavgtfI/B6GiY72BKkdbCOu1qIuixExLD+TlSM6B8dHWJZwxEkss T2NwaXy5iUP99yupQTOmBg9tJuOt9rSz+gFPjL98jqJOi3woYU1DYcDVHrCuBl8MC3Ea SQBWiPZ7dbkSN74ZHB88piDL4cXM9mikSLW+cJQ9zNU6yWsB7cfcXa6P2LNaThLXGTIX N+IGROo/BJl2Dfi3grmKqfoQerAiQGz6q5NYEr/Nrh27NVyun9UxJGiLpN52KCsjXAJM FMeukWTyvz6CWrSSZw8UTJkshCwtSYSZTeCvTfAOaB+HWtqx/MMWGB+HyM6ibA8IAuSE T+nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jzAIRaqU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r184si684930oie.79.2020.03.26.01.00.27; Thu, 26 Mar 2020 01:00:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jzAIRaqU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727689AbgCZH6x (ORCPT + 99 others); Thu, 26 Mar 2020 03:58:53 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38024 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726279AbgCZH6x (ORCPT ); Thu, 26 Mar 2020 03:58:53 -0400 Received: by mail-pl1-f193.google.com with SMTP id w3so1834487plz.5; Thu, 26 Mar 2020 00:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=kpesQAb1EfvXtxtfV/ThTPpjKNkxOztwAVy2KkYtRQs=; b=jzAIRaqUHbJdHcBmYlTiQwxR7p6qtDzRAZq18vVuoq/WS8xJYMme88GfJsqrf0q9zA GZ98OOXWvIn/4CY3U/VSxm0DgQU1U7v2X1CImXiqUZ4GjcSUkWZS0Uo/alo+Qhy92W01 LkEhlCDUdT59m6UWtRiwiG6BL6+k7NXc4go1GF/fDJLJ4LzFTIPHp2k1JAquhtT7Lkz/ LRmep1QLA/+xOyqiCCW41O27ByxoKpx1d4u/JGrHGn6QVWRZRMMRbD1T+dJws9kxrEC1 QVB9CrLshT97eFW+o8mxQ457lkevhUUY+dBWLephD0e5wiCeWNjWm2wuLZiQcn2sBiRf eJTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kpesQAb1EfvXtxtfV/ThTPpjKNkxOztwAVy2KkYtRQs=; b=t45X+4OfJ7hxemEF+OZgjXZ43JOlCZkhb3HNvs8KR0D2FFvLGmWDX31/zKNYHAKccC beDA8ya77vdNQjD6f6xlqGer8/gyUK7+sp9DO7uFSYtbPzHl+z8gaJ8DkMbX0hwND+UN O9oiggMxya9dCrgJnwY1UovJ6zlb5RI9VPP72Ay2Vkyc8ONEMO4Me+2xpq8FJDrShd3a qGn+wdQ+frdtE+GiHVKsqj/2SEftqx+BPmXHK45DBFm1Moad2DDXSZgqHXfo4bGiWXP5 A0zGOOUvqGv0UxK1lBYVEZjmzjZWSkAKOgVjN6PxGijq0b1fPEIDB1VYFWu3q5gXrTY/ U07A== X-Gm-Message-State: ANhLgQ2YXQvtcJPx5phrNqz0WS7l5l1CqUNrzg6RX4leryhKVkX9aZc6 JTbWrgdCVJA9EdfU9Rq8h34= X-Received: by 2002:a17:90a:37ea:: with SMTP id v97mr1825249pjb.26.1585209531605; Thu, 26 Mar 2020 00:58:51 -0700 (PDT) Received: from localhost.localdomain ([2401:e180:8844:1606:8876:e9fa:cdda:cda2]) by smtp.gmail.com with ESMTPSA id 144sm1011804pgd.29.2020.03.26.00.58.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Mar 2020 00:58:51 -0700 (PDT) From: Johnny Chuang To: Dmitry Torokhov , Benjamin Tissoires , Peter Hutterer , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, Rob Schonberger , Johnny Chuang Cc: James Chen , Jennifer Tsai , Paul Liang , Jeff Chuang Subject: [PATCH] Input: elants_i2c - support palm detection Date: Thu, 26 Mar 2020 15:58:45 +0800 Message-Id: <1585209525-6047-1-git-send-email-johnny.chuang.emc@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johnny Chuang Elan define finger/palm detection on the least significant bit of byte 33. The default value is 1 for all firmwares, which report as MT_TOOL_FINGER. If firmware support palm detection, the bit will change to 0 and report as MT_TOOL_PALM when firmware detecting palm. Signed-off-by: Johnny Chuang --- drivers/input/touchscreen/elants_i2c.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index 14c577c..3b4d9eb3 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -73,6 +73,7 @@ #define FW_POS_STATE 1 #define FW_POS_TOTAL 2 #define FW_POS_XY 3 +#define FW_POS_TOOL_TYPE 33 #define FW_POS_CHECKSUM 34 #define FW_POS_WIDTH 35 #define FW_POS_PRESSURE 45 @@ -842,6 +843,7 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) { struct input_dev *input = ts->input; unsigned int n_fingers; + unsigned int tool_type; u16 finger_state; int i; @@ -852,6 +854,12 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) dev_dbg(&ts->client->dev, "n_fingers: %u, state: %04x\n", n_fingers, finger_state); + /* Note: all fingers have the same tool type */ + if (buf[FW_POS_TOOL_TYPE] & 0x01) + tool_type = MT_TOOL_FINGER; + else + tool_type = MT_TOOL_PALM; + for (i = 0; i < MAX_CONTACT_NUM && n_fingers; i++) { if (finger_state & 1) { unsigned int x, y, p, w; @@ -867,7 +875,7 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) i, x, y, p, w); input_mt_slot(input, i); - input_mt_report_slot_state(input, MT_TOOL_FINGER, true); + input_mt_report_slot_state(input, tool_type, true); input_event(input, EV_ABS, ABS_MT_POSITION_X, x); input_event(input, EV_ABS, ABS_MT_POSITION_Y, y); input_event(input, EV_ABS, ABS_MT_PRESSURE, p); @@ -1307,6 +1315,7 @@ static int elants_i2c_probe(struct i2c_client *client, input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0); input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0); + input_set_abs_params(ts->input, ABS_MT_TOOL_TYPE, 0, MT_TOOL_MAX, 0, 0); input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res); input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res); input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, 1); -- 2.7.4