All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: kt.liao@emc.com.tw, Oliver Haessler <oliver@redhat.com>,
	Benjamin Berg <bberg@redhat.com>,
	Rob Herring <robh+dt@kernel.org>,
	devicetree@vger.kernel.org, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Subject: [PATCH v2 6/9] Input: elantech - query the resolution in query_info
Date: Mon,  9 Apr 2018 11:10:48 +0200	[thread overview]
Message-ID: <20180409091051.2944-7-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <20180409091051.2944-1-benjamin.tissoires@redhat.com>

The command ETP_RESOLUTION_QUERY also contains the bus information.
It is better to fetch it once, while we are querying for device
information.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
no changes in v2

 drivers/input/mouse/elantech.c | 27 +++++++++++++++------------
 drivers/input/mouse/elantech.h |  2 ++
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 980dfd7e861e..a2a14a31edb5 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -1179,7 +1179,6 @@ static int elantech_set_input_params(struct psmouse *psmouse)
 	struct elantech_data *etd = psmouse->private;
 	struct elantech_device_info *info = &etd->info;
 	unsigned int x_min = 0, y_min = 0, x_max = 0, y_max = 0, width = 0;
-	unsigned int x_res = 31, y_res = 31;
 
 	if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width))
 		return -1;
@@ -1232,13 +1231,6 @@ static int elantech_set_input_params(struct psmouse *psmouse)
 		break;
 
 	case 4:
-		if (elantech_get_resolution_v4(psmouse, &x_res, &y_res)) {
-			/*
-			 * if query failed, print a warning and leave the values
-			 * zero to resemble synaptics.c behavior.
-			 */
-			psmouse_warn(psmouse, "couldn't query resolution data.\n");
-		}
 		elantech_set_buttonpad_prop(psmouse);
 		__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
 		/* For X to recognize me as touchpad. */
@@ -1267,11 +1259,11 @@ static int elantech_set_input_params(struct psmouse *psmouse)
 		break;
 	}
 
-	input_abs_set_res(dev, ABS_X, x_res);
-	input_abs_set_res(dev, ABS_Y, y_res);
+	input_abs_set_res(dev, ABS_X, info->x_res);
+	input_abs_set_res(dev, ABS_Y, info->y_res);
 	if (info->hw_version > 1) {
-		input_abs_set_res(dev, ABS_MT_POSITION_X, x_res);
-		input_abs_set_res(dev, ABS_MT_POSITION_Y, y_res);
+		input_abs_set_res(dev, ABS_MT_POSITION_X, info->x_res);
+		input_abs_set_res(dev, ABS_MT_POSITION_Y, info->y_res);
 	}
 
 	etd->y_max = y_max;
@@ -1720,6 +1712,17 @@ static int elantech_query_info(struct psmouse *psmouse,
 	/* The MSB indicates the presence of the trackpoint */
 	info->has_trackpoint = (info->capabilities[0] & 0x80) == 0x80;
 
+	info->x_res = 31;
+	info->y_res = 31;
+	if (info->hw_version == 4) {
+		if (elantech_get_resolution_v4(psmouse,
+					       &info->x_res,
+					       &info->y_res)) {
+			psmouse_warn(psmouse,
+				     "failed to query resolution data.\n");
+		}
+	}
+
 	return 0;
 }
 
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index d8ac27fe4597..851df4ce6232 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -120,6 +120,8 @@ struct elantech_device_info {
 	unsigned char debug;
 	unsigned char hw_version;
 	unsigned int fw_version;
+	unsigned int x_res;
+	unsigned int y_res;
 	bool paritycheck;
 	bool jumpy_cursor;
 	bool reports_pressure;
-- 
2.14.3

  parent reply	other threads:[~2018-04-09  9:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-09  9:10 [PATCH v2 0/9] Input: support for latest Lenovo thinkpads (series 80) Benjamin Tissoires
2018-04-09  9:10 ` [PATCH v2 1/9] Input: synaptics - add Lenovo 80 series ids to SMBus Benjamin Tissoires
2018-04-09  9:10 ` [PATCH v2 2/9] input: elan_i2c_smbus - fix corrupted stack Benjamin Tissoires
2018-04-09  9:10 ` [PATCH v2 3/9] Input: elan_i2c - add trackstick report Benjamin Tissoires
2018-04-13 17:36   ` Rob Herring
2018-04-09  9:10 ` [PATCH v2 4/9] Input: elantech - split device info into a separate structure Benjamin Tissoires
2018-04-09  9:10 ` [PATCH v2 5/9] Input: elantech_query_info() can be static Benjamin Tissoires
2018-04-09  9:10 ` Benjamin Tissoires [this message]
2018-04-09  9:10 ` [PATCH v2 7/9] Input: elantech - add support for SMBus devices Benjamin Tissoires
2018-04-09  9:10 ` [PATCH v2 8/9] Input: elantech - detect new ICs and setup Host Notify for them Benjamin Tissoires
2018-04-09  9:10 ` [PATCH v2 9/9] input: psmouse-smbus: allow to control psmouse_deactivate Benjamin Tissoires
2018-04-17  8:34 ` [PATCH v2 0/9] Input: support for latest Lenovo thinkpads (series 80) Benjamin Tissoires
2018-04-17  8:40   ` 廖崇榮
2018-04-17  8:40     ` 廖崇榮
2018-04-17 11:42     ` Aaron Ma
2018-05-14  8:19       ` Benjamin Tissoires
2018-05-16  7:09       ` Teika Kazura
2018-05-16  8:48         ` Aaron Ma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180409091051.2944-7-benjamin.tissoires@redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=bberg@redhat.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kt.liao@emc.com.tw \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver@redhat.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.