[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250503-mip4-touchkey-v1-3-b483cda29a5b@disroot.org>
Date: Sat, 03 May 2025 14:38:29 +0530
From: Kaustabh Chakraborty <kauschluss@...root.org>
To: Sangwon Jee <jeesw@...fas.com>,
Dmitry Torokhov <dmitry.torokhov@...il.com>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Henrik Rydberg <rydberg@...math.org>
Cc: linux-input@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, Kaustabh Chakraborty <kauschluss@...root.org>
Subject: [PATCH RFC 3/4] Input: melfas-mip4 - initialize touch events only
if the device is a touchscreen
Certain MIP4 devices report zero values when enquired for its touchscreen
dimensions (MIP4_R1_INFO_RESOLUTION_X and MIP4_R1_INFO_RESOLUTION_Y),
which is indicative of the fact that those devices are not touchscreens.
While registering for touch events for the device, always check - and
proceed - only if the device reports a non-zero resolution.
Signed-off-by: Kaustabh Chakraborty <kauschluss@...root.org>
---
drivers/input/touchscreen/melfas_mip4.c | 50 ++++++++++++++++++---------------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
index 061ac353bc7a2e28f17581411af81f35c89733a1..57b657694a420220be135c2f78d3ddad3ef6f520 100644
--- a/drivers/input/touchscreen/melfas_mip4.c
+++ b/drivers/input/touchscreen/melfas_mip4.c
@@ -1146,14 +1146,16 @@ static int mip4_flash_fw(struct mip4_ts *ts,
mip4_query_device(ts);
/* Refresh device parameters */
- input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0);
- input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0);
- input_set_abs_params(ts->input, ABS_X, 0, ts->max_x, 0, 0);
- input_set_abs_params(ts->input, ABS_Y, 0, ts->max_y, 0, 0);
- input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x);
- input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y);
- input_abs_set_res(ts->input, ABS_X, ts->ppm_x);
- input_abs_set_res(ts->input, ABS_Y, ts->ppm_y);
+ if (ts->max_x && ts->max_y) {
+ input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0);
+ input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0);
+ input_set_abs_params(ts->input, ABS_X, 0, ts->max_x, 0, 0);
+ input_set_abs_params(ts->input, ABS_Y, 0, ts->max_y, 0, 0);
+ input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x);
+ input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y);
+ input_abs_set_res(ts->input, ABS_X, ts->ppm_x);
+ input_abs_set_res(ts->input, ABS_Y, ts->ppm_y);
+ }
for (i = 0; i < ts->key_num; i++) {
if (ts->key_code[i])
@@ -1498,21 +1500,23 @@ static int mip4_probe(struct i2c_client *client)
input->keycodesize = sizeof(*ts->key_code);
input->keycodemax = ts->key_num;
- input_set_abs_params(input, ABS_MT_TOOL_TYPE, 0, MT_TOOL_PALM, 0, 0);
- input_set_abs_params(input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0);
- input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0);
- input_set_abs_params(input, ABS_MT_PRESSURE,
- MIP4_PRESSURE_MIN, MIP4_PRESSURE_MAX, 0, 0);
- input_set_abs_params(input, ABS_MT_TOUCH_MAJOR,
- MIP4_TOUCH_MAJOR_MIN, MIP4_TOUCH_MAJOR_MAX, 0, 0);
- input_set_abs_params(input, ABS_MT_TOUCH_MINOR,
- MIP4_TOUCH_MINOR_MIN, MIP4_TOUCH_MINOR_MAX, 0, 0);
- input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x);
- input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y);
-
- error = input_mt_init_slots(input, MIP4_MAX_FINGERS, INPUT_MT_DIRECT);
- if (error)
- return error;
+ if (ts->max_x && ts->max_y) {
+ input_set_abs_params(input, ABS_MT_TOOL_TYPE, 0, MT_TOOL_PALM, 0, 0);
+ input_set_abs_params(input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0);
+ input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0);
+ input_set_abs_params(input, ABS_MT_PRESSURE,
+ MIP4_PRESSURE_MIN, MIP4_PRESSURE_MAX, 0, 0);
+ input_set_abs_params(input, ABS_MT_TOUCH_MAJOR,
+ MIP4_TOUCH_MAJOR_MIN, MIP4_TOUCH_MAJOR_MAX, 0, 0);
+ input_set_abs_params(input, ABS_MT_TOUCH_MINOR,
+ MIP4_TOUCH_MINOR_MIN, MIP4_TOUCH_MINOR_MAX, 0, 0);
+ input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x);
+ input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y);
+
+ error = input_mt_init_slots(input, MIP4_MAX_FINGERS, INPUT_MT_DIRECT);
+ if (error)
+ return error;
+ }
for (i = 0; i < ts->key_num; i++) {
if (ts->key_code[i])
--
2.49.0
Powered by blists - more mailing lists