[PATCH 3/5] Input: imagis - replace the protocol_b flag with a protocol enum

From
Markuss Broks via B4 Relay <devnull+markuss.broks.gmail.com@kernel.org>
Date
2026-08-21 21:30:45
Also in
b4-sent, linux-input, lkml
Reply to
Markuss Broks via B4 Relay, 2026-08-21
From: Markuss Broks <markuss.broks@gmail.com>

The driver tells the two supported touch reporting formats apart with
the protocol_b flag. The naming is unfortunate: "protocol B" is the
format of the IST30XXC series, while the B-suffixed chips use the
unnamed other format. Adding support for the IST40xx family is about to
introduce a third format, at which point a collection of booleans gets
easy to misuse.

Replace the flag with an enum which describes each reporting format:
IMAGIS_PROTOCOL_SHARED_REGISTER for the single coordinate register
shared by all contacts (IST3038, IST3038B and IST3038H), and
IMAGIS_PROTOCOL_PER_CONTACT_REGISTERS for one coordinate register per
contact (IST3032C and IST3038C).

No functional change intended.

Signed-off-by: Markuss Broks <markuss.broks@gmail.com>
---
 drivers/input/touchscreen/imagis.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c
index 7cc91f97c06e..6552d97efe32 100644
--- a/drivers/input/touchscreen/imagis.c
+++ b/drivers/input/touchscreen/imagis.c
@@ -44,12 +44,19 @@
 #define IST3038C_FINGER_STATUS_MASK	GENMASK(9, 0)
 #define IST3032C_KEY_STATUS_MASK	GENMASK(20, 16)
 
+enum imagis_protocol {
+	/* one coordinate register shared by all contacts */
+	IMAGIS_PROTOCOL_SHARED_REGISTER,
+	/* one coordinate register per contact */
+	IMAGIS_PROTOCOL_PER_CONTACT_REGISTERS,
+};
+
 struct imagis_properties {
 	unsigned int interrupt_msg_cmd;
 	unsigned int touch_coord_cmd;
 	unsigned int whoami_cmd;
 	unsigned int whoami_val;
-	bool protocol_b;
+	enum imagis_protocol protocol;
 	bool touch_keys_supported;
 };
 
@@ -129,7 +136,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id)
 	for (i = 0; i < finger_count; i++) {
 		bool pressed;
 
-		if (ts->tdata->protocol_b)
+		if (ts->tdata->protocol == IMAGIS_PROTOCOL_PER_CONTACT_REGISTERS)
 			error = imagis_i2c_read_reg(ts,
 						    ts->tdata->touch_coord_cmd + (i * 4),
 						    &finger_status);
@@ -410,8 +417,8 @@ static const struct imagis_properties imagis_3032c_data = {
 	.touch_coord_cmd = IST3038C_REG_TOUCH_COORD,
 	.whoami_cmd = IST3038C_REG_CHIPID,
 	.whoami_val = IST3032C_WHOAMI,
+	.protocol = IMAGIS_PROTOCOL_PER_CONTACT_REGISTERS,
 	.touch_keys_supported = true,
-	.protocol_b = true,
 };
 
 static const struct imagis_properties imagis_3038_data = {
@@ -419,6 +426,7 @@ static const struct imagis_properties imagis_3038_data = {
 	.touch_coord_cmd = IST30XX_REG_STATUS,
 	.whoami_cmd = IST30XX_REG_CHIPID,
 	.whoami_val = IST3038_WHOAMI,
+	.protocol = IMAGIS_PROTOCOL_SHARED_REGISTER,
 	.touch_keys_supported = true,
 };
 
@@ -427,6 +435,7 @@ static const struct imagis_properties imagis_3038b_data = {
 	.touch_coord_cmd = IST30XX_REG_STATUS,
 	.whoami_cmd = IST3038B_REG_CHIPID,
 	.whoami_val = IST3038B_WHOAMI,
+	.protocol = IMAGIS_PROTOCOL_SHARED_REGISTER,
 };
 
 static const struct imagis_properties imagis_3038c_data = {
@@ -434,7 +443,7 @@ static const struct imagis_properties imagis_3038c_data = {
 	.touch_coord_cmd = IST3038C_REG_TOUCH_COORD,
 	.whoami_cmd = IST3038C_REG_CHIPID,
 	.whoami_val = IST3038C_WHOAMI,
-	.protocol_b = true,
+	.protocol = IMAGIS_PROTOCOL_PER_CONTACT_REGISTERS,
 };
 
 static const struct imagis_properties imagis_3038h_data = {
@@ -442,6 +451,7 @@ static const struct imagis_properties imagis_3038h_data = {
 	.touch_coord_cmd = IST3038C_REG_TOUCH_COORD,
 	.whoami_cmd = IST3038C_REG_CHIPID,
 	.whoami_val = IST3038H_WHOAMI,
+	.protocol = IMAGIS_PROTOCOL_SHARED_REGISTER,
 };
 
 static const struct of_device_id imagis_of_match[] = {
-- 
2.55.0

Thread (11 messages) 11 messages, 3 authors, last reply 2026-08-24
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help