Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp953908ybm; Tue, 21 May 2019 06:29:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0YmR3SnIuOerlIiSR2d3IMnQp0RYezjjyG5kBu50TKRRmaUiCGQM3HbD8ehHI+yHVpIqB X-Received: by 2002:a63:6f8e:: with SMTP id k136mr82875887pgc.104.1558445370687; 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=VUjqF4w6faNGtafJ8tfIJ4u/sgPHn1rBpCfFoBclGUbMo1G2O/ArgAXtjiFii/O54v gwqI+qsbeMbMxia0H292KkaY+47i2kLTs7kqHt5CksPuiDeZWIuuQZTAzHoMOAzBI3bl z6Xm3zb2askGfMlLOG2r2yI1Iu+pfAdoWeSLo5JgGNHHYIxyI44xSnvRlvSGcLecqz7P Mlvy625M6TtjUalG+UgZfCzb0fFQoZVaP2VAGP+CxrkUohni8iy8l0EfdmLT6jocy9Bt 2zzbtTHZdfDK9teOlBN45bBep5I5hKTdn4b7MZ9JSwPQWzArdN9I0GimURVg2cCBccOr zzzw== 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=HyxzQbIrPgif1jaFIgBrp0/An784NvQb/AwoTsp+quE=; b=bC4Su6PCe8HLst97pL0ee1wxpMzmZEmrANrVmwedlrE+LbA+V86LiFM1GkN1pnx8XU XBZ3tFZlaI7Xm3M6FLTRQ+Q3RNJjLt3osKCsNFCRjsHQ+RQMk7orCjOvG2hJXBKsh/0E L+D5YhnH6IxRWB1NWwn+dzizlQolLxLSAvCQNEQUapV1qCsCz57kmfzXaYk3r+fb2yEn GXOa5BSbFyBM7FIO1vqeu0ZSL3YhWjahGZ126Fhsbq9cOKrzemQtXly4UB3OeyO5ibkN 2xIa3ShMnWuSFpj/8gJwtlWQyqwJ+69rDA0rp8SRfYNSDKX5lmubj8wnzL0DNIEb2/dE AyLg== 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 g67si9201503pgc.344.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 S1728357AbfEUN1u (ORCPT + 99 others); Tue, 21 May 2019 09:27:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34898 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728334AbfEUN1s (ORCPT ); Tue, 21 May 2019 09:27:48 -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 D1F868831E; Tue, 21 May 2019 13:27:47 +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 CD9CC60F8D; Tue, 21 May 2019 13:27:45 +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 05/10] Input: elan_i2c - do not query the info if they are provided Date: Tue, 21 May 2019 15:27:07 +0200 Message-Id: <20190521132712.2818-6-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.28]); Tue, 21 May 2019 13:27:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org See the previous patch for a long explanation. TL;DR: the P52 and the t480s from Lenovo can't rely on I2C to fetch the information, so we need it from PS/2. Signed-off-by: Benjamin Tissoires -- changes in v2: - updated accroding to previous patch --- drivers/input/mouse/elan_i2c_core.c | 56 ++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index f9525d6f0bfe..53cac610ba33 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -366,27 +366,59 @@ static unsigned int elan_convert_resolution(u8 val) static int elan_query_device_parameters(struct elan_tp_data *data) { + struct i2c_client *client = data->client; unsigned int x_traces, y_traces; + u32 x_mm, y_mm; u8 hw_x_res, hw_y_res; int error; - error = data->ops->get_max(data->client, &data->max_x, &data->max_y); - if (error) - return error; - - error = data->ops->get_num_traces(data->client, &x_traces, &y_traces); - if (error) - return error; + if (device_property_read_u32(&client->dev, + "touchscreen-size-x", &data->max_x) || + device_property_read_u32(&client->dev, + "touchscreen-size-y", &data->max_y)) { + error = data->ops->get_max(data->client, + &data->max_x, + &data->max_y); + if (error) + return error; + } else { + /* size is the maximum + 1 */ + --data->max_x; + --data->max_y; + } + if (device_property_read_u32(&client->dev, + "elan,x_traces", + &x_traces) || + device_property_read_u32(&client->dev, + "elan,y_traces", + &y_traces)) { + error = data->ops->get_num_traces(data->client, + &x_traces, &y_traces); + if (error) + return error; + } data->width_x = data->max_x / x_traces; data->width_y = data->max_y / y_traces; - error = data->ops->get_resolution(data->client, &hw_x_res, &hw_y_res); - if (error) - return error; + if (device_property_read_u32(&client->dev, + "touchscreen-x-mm", &x_mm) || + device_property_read_u32(&client->dev, + "touchscreen-y-mm", &y_mm)) { + error = data->ops->get_resolution(data->client, + &hw_x_res, &hw_y_res); + if (error) + return error; + + data->x_res = elan_convert_resolution(hw_x_res); + data->y_res = elan_convert_resolution(hw_y_res); + } else { + data->x_res = (data->max_x + 1) / x_mm; + data->y_res = (data->max_y + 1) / y_mm; + } - data->x_res = elan_convert_resolution(hw_x_res); - data->y_res = elan_convert_resolution(hw_y_res); + if (device_property_read_bool(&client->dev, "elan,clickpad")) + data->clickpad = 1; return 0; } -- 2.21.0