Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp953907ybm; Tue, 21 May 2019 06:29:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIbsFzsUKJIZz77AxC+K/xFWlDXbuc+qkE0Xqq6tjYOFGjJAYmt3kk6wXuE6Vqz/MF8Fv3 X-Received: by 2002:a17:902:e08b:: with SMTP id cb11mr24091630plb.122.1558445370644; Tue, 21 May 2019 06:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558445370; cv=none; d=google.com; s=arc-20160816; b=crWypAuDtyqpF/O4srMnSQQSRF6hazJfl+UuFUDxNavZQfneiYz3Q8EslE4Bk258R3 Jqy/J86uQENjZggGpxYB9w815hcompjdzY+/CUQy+oIttesUtygw8Rmfi6tg8N8aXqcN D4QU+vRFilnJKj5Qiabl3owiPYMGwEbi5NGh1iV/JnULAv70Y2NmTM/pwyLM73B/+vej bq7Qpuo8RJJgXi/5F0iEo71ZeO92a2zI6w2pDEeGZFQaxRP4Y/4QRGd8y/obTyaYn7kF R3BA9VmwWwOVAwAs1M0CPpV6RexnnsUGNmaYsCbfvPAtaFOgNgZTQ3qpDioAovwo0n7Q EM1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fXp2Y4JCwXEIfwSNY3g/WEtGIyviA1mWkhBVndJ3NGw=; b=VJqeydAd8G4qjvIdogImpDYE8+sqKyVqSUkOeUjp4z8m3vBDga6RfqPaY01/8a/7/A P1h6zWr7j+Updyjho2QS9be/80XndY2dVYCfaeuy0ZIH2tyQczSbWy4YC86N24XuB8yW bm0bBX9XC+7/ZhjV50MzJX2+GEvONWjGTXJEH9zfvLiHi+O8/Djmkolrq97HhhAC7n2w VALPZSxas9zsxzL7BtvL0IhicUqe+IXGo0Qgt1E0ekW7p2266jeDM8DRF4Yojawgi+QB 6bOCQQI/qOz0wrafDcdPwLwFOiJ4j7oCcn2YXmZwwHRPfdrBQYnd2Cc/ZOr074QXISEv g8+A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h40si22879422plb.243.2019.05.21.06.29.15; Tue, 21 May 2019 06:29:30 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728373AbfEUN1x (ORCPT + 99 others); Tue, 21 May 2019 09:27:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40552 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726995AbfEUN1v (ORCPT ); Tue, 21 May 2019 09:27:51 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 68FD681DEE; Tue, 21 May 2019 13:27:51 +0000 (UTC) Received: from plouf.redhat.com (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EF35610A3; Tue, 21 May 2019 13:27:48 +0000 (UTC) From: Benjamin Tissoires To: Dmitry Torokhov , KT Liao , Rob Herring , Aaron Ma , Hans de Goede Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Benjamin Tissoires Subject: [PATCH v2 06/10] Input: elantech/SMBus - export all capabilities from the PS/2 node Date: Tue, 21 May 2019 15:27:08 +0200 Message-Id: <20190521132712.2818-7-benjamin.tissoires@redhat.com> In-Reply-To: <20190521132712.2818-1-benjamin.tissoires@redhat.com> References: <20190521132712.2818-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 21 May 2019 13:27:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The recent touchpads might not have all the information regarding the characteristics through the I2C port. On some Lenovo t480s, this results in the touchpad not being detected as a clickpad, and on the Lenovo P52, this results in a failure while fetching the resolution through I2C. We need to imitate the Windows behavior: fetch the data under PS/2, and limit the querries under I2C. This patch prepares this by exporting the info from PS/2. Signed-off-by: Benjamin Tissoires -- changes in v2: - updated according to the 2 previous patches --- drivers/input/mouse/elantech.c | 47 ++++++++++++++++++++++++++++++---- drivers/input/mouse/elantech.h | 2 ++ 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 057a3cf01eec..ca10fd97d9d5 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -1736,6 +1736,15 @@ static int elantech_query_info(struct psmouse *psmouse, return -EINVAL; info->width = info->x_max / (traces - 1); + + /* column number of traces */ + info->x_traces = traces; + + /* row number of traces */ + traces = info->capabilities[2]; + if ((traces >= 2) && (traces <= info->y_max)) + info->y_traces = traces; + break; } @@ -1781,17 +1790,45 @@ static int elantech_create_smbus(struct psmouse *psmouse, struct elantech_device_info *info, bool leave_breadcrumbs) { - const struct property_entry i2c_properties[] = { - PROPERTY_ENTRY_BOOL("elan,trackpoint"), - { }, - }; + struct property_entry i2c_props[11] = {}; struct i2c_board_info smbus_board = { I2C_BOARD_INFO("elan_i2c", 0x15), .flags = I2C_CLIENT_HOST_NOTIFY, }; + unsigned int idx = 0; + + smbus_board.properties = i2c_props; + + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-size-x", + info->x_max + 1); + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-size-y", + info->y_max + 1); + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-min-x", + info->x_min); + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-min-y", + info->y_min); + if (info->x_res) + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-x-mm", + (info->x_max + 1) / info->x_res); + if (info->y_res) + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-y-mm", + (info->y_max + 1) / info->y_res); if (info->has_trackpoint) - smbus_board.properties = i2c_properties; + i2c_props[idx++] = PROPERTY_ENTRY_BOOL("elan,trackpoint"); + + if (info->has_middle_button) + i2c_props[idx++] = PROPERTY_ENTRY_BOOL("elan,middle-button"); + + if (info->x_traces) + i2c_props[idx++] = PROPERTY_ENTRY_U32("elan,x_traces", + info->x_traces); + if (info->y_traces) + i2c_props[idx++] = PROPERTY_ENTRY_U32("elan,y_traces", + info->y_traces); + + if (elantech_is_buttonpad(info)) + i2c_props[idx++] = PROPERTY_ENTRY_BOOL("elan,clickpad"); return psmouse_smbus_init(psmouse, &smbus_board, NULL, 0, false, leave_breadcrumbs); diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h index 16174b54ffc3..a7eaa62af6a0 100644 --- a/drivers/input/mouse/elantech.h +++ b/drivers/input/mouse/elantech.h @@ -150,6 +150,8 @@ struct elantech_device_info { unsigned int y_max; unsigned int x_res; unsigned int y_res; + unsigned int x_traces; + unsigned int y_traces; unsigned int width; unsigned int bus; bool paritycheck; -- 2.21.0