devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices
@ 2025-06-12 19:41 Kaustabh Chakraborty
  2025-06-12 19:41 ` [PATCH RFC v2 1/5] dt-bindings: input: melfas-mip4: convert to dtschema Kaustabh Chakraborty
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Kaustabh Chakraborty @ 2025-06-12 19:41 UTC (permalink / raw)
  To: Sangwon Jee, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Henrik Rydberg
  Cc: linux-input, devicetree, linux-kernel, Kaustabh Chakraborty

MIP4 is a protocol developed and used by MELFAS in its touchscreen and
touchkey devices. The MIP4 touchscreen driver acknowledges the
touchscreen capabilities, but touchkeys are left unimplemented.

Apart from touchscreen + touchkey devices, the protocol is also used by
devices which are, functionally, touchkey devices. Thus, the driver
should also be compatible with those devices. This series aims to
introduce such required changes.

RFC: How should the compatible string be handled? The string defined in
dtschema is 'melfas,mip4_ts', which implies that it's a MIP4 *touchscreen*
by MELFAS.

Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
---
Changes in v2:
- rewrite MIP4 documentation in dtschema (robh)
- Link to v1: https://lore.kernel.org/r/20250503-mip4-touchkey-v1-0-b483cda29a5b@disroot.org

---
Kaustabh Chakraborty (5):
      dt-bindings: input: melfas-mip4: convert to dtschema
      dt-bindings: input: melfas-mip4: document linux,keycodes property
      Input: melfas-mip4 - add support for touchkey input events
      Input: melfas-mip4 - initialize touch events only if the device is a touchscreen
      Input: melfas-mip4 - add support for event formats 4 and 9

 .../bindings/input/touchscreen/melfas,mip4_ts.yaml | 61 ++++++++++++++
 .../bindings/input/touchscreen/melfas_mip4.txt     | 20 -----
 drivers/input/touchscreen/melfas_mip4.c            | 98 ++++++++++++++++------
 3 files changed, 133 insertions(+), 46 deletions(-)
---
base-commit: 0bb71d301869446810a0b13d3da290bd455d7c78
change-id: 20250501-mip4-touchkey-66a113226bce

Best regards,
-- 
Kaustabh Chakraborty <kauschluss@disroot.org>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH RFC v2 1/5] dt-bindings: input: melfas-mip4: convert to dtschema
  2025-06-12 19:41 [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices Kaustabh Chakraborty
@ 2025-06-12 19:41 ` Kaustabh Chakraborty
  2025-06-13  7:09   ` Krzysztof Kozlowski
  2025-06-12 19:41 ` [PATCH RFC v2 2/5] dt-bindings: input: melfas-mip4: document linux,keycodes property Kaustabh Chakraborty
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Kaustabh Chakraborty @ 2025-06-12 19:41 UTC (permalink / raw)
  To: Sangwon Jee, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Henrik Rydberg
  Cc: linux-input, devicetree, linux-kernel, Kaustabh Chakraborty

Port the documentation file melfas_mip4.txt over to melfas,mip4_ts.yaml.

Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
---
 .../bindings/input/touchscreen/melfas,mip4_ts.yaml | 55 ++++++++++++++++++++++
 .../bindings/input/touchscreen/melfas_mip4.txt     | 20 --------
 2 files changed, 55 insertions(+), 20 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml b/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..5532d46f85a235127e2b3513846259aa7372bda5
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/melfas,mip4_ts.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MELFAS MIP4 touchscreen controller
+
+maintainers:
+  - Sangwon Jee <jeesw@melfas.com>
+
+allOf:
+  - $ref: touchscreen.yaml#
+
+properties:
+  $nodename:
+    pattern: "^touchscreen(@.*)?$"
+
+  compatible:
+    const: melfas,mip4_ts
+
+  reg:
+    enum: [ 0x48, 0x34 ]
+    description: I2C slave address of the chip
+
+  interrupts:
+    maxItems: 1
+
+  ce-gpios:
+    description: GPIO connected to the CE (chip enable) pin of the chip
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      touchscreen@48 {
+        compatible = "melfas,mip4_ts";
+        reg = <0x48>;
+        interrupt-parent = <&gpio>;
+        interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
+        ce-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+      };
+    };
+
+...
diff --git a/Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt b/Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt
deleted file mode 100644
index b2ab5498e51900e887fab4d9b5239cccccec2ea9..0000000000000000000000000000000000000000
--- a/Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-* MELFAS MIP4 Touchscreen
-
-Required properties:
-- compatible: must be "melfas,mip4_ts"
-- reg: I2C slave address of the chip (0x48 or 0x34)
-- interrupts: interrupt to which the chip is connected
-
-Optional properties:
-- ce-gpios: GPIO connected to the CE (chip enable) pin of the chip
-
-Example:
-	i2c@00000000 {
-		touchscreen: melfas_mip4@48 {
-			compatible = "melfas,mip4_ts";
-			reg = <0x48>;
-			interrupt-parent = <&gpio>;
-			interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
-			ce-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
-		};
-	};

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH RFC v2 2/5] dt-bindings: input: melfas-mip4: document linux,keycodes property
  2025-06-12 19:41 [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices Kaustabh Chakraborty
  2025-06-12 19:41 ` [PATCH RFC v2 1/5] dt-bindings: input: melfas-mip4: convert to dtschema Kaustabh Chakraborty
@ 2025-06-12 19:41 ` Kaustabh Chakraborty
  2025-06-12 20:58   ` Rob Herring (Arm)
  2025-06-12 19:41 ` [PATCH RFC v2 3/5] Input: melfas-mip4 - add support for touchkey input events Kaustabh Chakraborty
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Kaustabh Chakraborty @ 2025-06-12 19:41 UTC (permalink / raw)
  To: Sangwon Jee, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Henrik Rydberg
  Cc: linux-input, devicetree, linux-kernel, Kaustabh Chakraborty

Document the linux,keycodes property. The property values are key codes
which are used in input key events generated by the touchkey device.

Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
---
 .../devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml       | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml b/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml
index 5532d46f85a235127e2b3513846259aa7372bda5..6d5e0f4b062f44f83484eccd82353d6f150f9d8f 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml
+++ b/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml
@@ -29,6 +29,11 @@ properties:
   ce-gpios:
     description: GPIO connected to the CE (chip enable) pin of the chip
 
+  linux,keycodes:
+    description: Array of keycodes to be reported by touchkeys
+    minItems: 1
+    maxItems: 4
+
 additionalProperties: false
 
 required:
@@ -49,6 +54,7 @@ examples:
         interrupt-parent = <&gpio>;
         interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
         ce-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+        linux,keycodes = <KEY_MENU>, <KEY_BACK>;
       };
     };
 

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH RFC v2 3/5] Input: melfas-mip4 - add support for touchkey input events
  2025-06-12 19:41 [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices Kaustabh Chakraborty
  2025-06-12 19:41 ` [PATCH RFC v2 1/5] dt-bindings: input: melfas-mip4: convert to dtschema Kaustabh Chakraborty
  2025-06-12 19:41 ` [PATCH RFC v2 2/5] dt-bindings: input: melfas-mip4: document linux,keycodes property Kaustabh Chakraborty
@ 2025-06-12 19:41 ` Kaustabh Chakraborty
  2025-06-29  5:12   ` Dmitry Torokhov
  2025-06-12 19:41 ` [PATCH RFC v2 4/5] Input: melfas-mip4 - initialize touch events only if the device is a touchscreen Kaustabh Chakraborty
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Kaustabh Chakraborty @ 2025-06-12 19:41 UTC (permalink / raw)
  To: Sangwon Jee, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Henrik Rydberg
  Cc: linux-input, devicetree, linux-kernel, Kaustabh Chakraborty

The MIP4 protocol are supposed to support touchscreens, touchkeys, and
combo-devices. The driver handles touchscreen events, but touchkey
events are unimplemented.

Implement them. If compiled with devicetree support, the driver attempts
to retrieve keycodes from a property named "linux,keycodes".

Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
---
 drivers/input/touchscreen/melfas_mip4.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
index a6946e3d8376d7e9b4c26f4194409e0ba78bb075..061ac353bc7a2e28f17581411af81f35c89733a1 100644
--- a/drivers/input/touchscreen/melfas_mip4.c
+++ b/drivers/input/touchscreen/melfas_mip4.c
@@ -169,7 +169,7 @@ struct mip4_ts {
 	unsigned int event_format;
 
 	unsigned int key_num;
-	unsigned short key_code[MIP4_MAX_KEYS];
+	unsigned int key_code[MIP4_MAX_KEYS];
 
 	bool wake_irq_enabled;
 
@@ -337,8 +337,13 @@ static int mip4_query_device(struct mip4_ts *ts)
 			ts->ppm_x, ts->ppm_y);
 
 		/* Key ts */
-		if (ts->node_key > 0)
+		if (ts->node_key > MIP4_MAX_KEYS) {
+			dev_warn(&ts->client->dev,
+				"Too many keys (%u) found\n", ts->node_key);
+			ts->key_num = MIP4_MAX_KEYS;
+		} else {
 			ts->key_num = ts->node_key;
+		}
 	}
 
 	/* Protocol */
@@ -1080,6 +1085,7 @@ static int mip4_flash_fw(struct mip4_ts *ts,
 			 const u8 *fw_data, u32 fw_size, u32 fw_offset)
 {
 	struct i2c_client *client = ts->client;
+	unsigned int i;
 	int offset;
 	u16 buf_addr;
 	int error, error2;
@@ -1149,6 +1155,11 @@ static int mip4_flash_fw(struct mip4_ts *ts,
 	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])
+			input_set_capability(ts->input, EV_KEY, ts->key_code[i]);
+	}
+
 	return error ? error : 0;
 }
 
@@ -1425,6 +1436,7 @@ static int mip4_probe(struct i2c_client *client)
 {
 	struct mip4_ts *ts;
 	struct input_dev *input;
+	unsigned int i;
 	int error;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
@@ -1471,6 +1483,17 @@ static int mip4_probe(struct i2c_client *client)
 
 	input_set_drvdata(input, ts);
 
+#ifdef CONFIG_OF
+	error = of_property_read_u32_array(client->dev.of_node, "linux,keycodes",
+					   ts->key_code, ts->key_num);
+	if (error && ts->key_num) {
+		dev_warn(&client->dev,
+			 "Failed to get codes for %u supported keys", ts->key_num);
+		/* Disable touchkey support */
+		ts->key_num = 0;
+	}
+#endif
+
 	input->keycode = ts->key_code;
 	input->keycodesize = sizeof(*ts->key_code);
 	input->keycodemax = ts->key_num;
@@ -1491,6 +1514,11 @@ static int mip4_probe(struct i2c_client *client)
 	if (error)
 		return error;
 
+	for (i = 0; i < ts->key_num; i++) {
+		if (ts->key_code[i])
+			input_set_capability(input, EV_KEY, ts->key_code[i]);
+	}
+
 	i2c_set_clientdata(client, ts);
 
 	error = devm_request_threaded_irq(&client->dev, client->irq,

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH RFC v2 4/5] Input: melfas-mip4 - initialize touch events only if the device is a touchscreen
  2025-06-12 19:41 [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices Kaustabh Chakraborty
                   ` (2 preceding siblings ...)
  2025-06-12 19:41 ` [PATCH RFC v2 3/5] Input: melfas-mip4 - add support for touchkey input events Kaustabh Chakraborty
@ 2025-06-12 19:41 ` Kaustabh Chakraborty
  2025-06-12 19:41 ` [PATCH RFC v2 5/5] Input: melfas-mip4 - add support for event formats 4 and 9 Kaustabh Chakraborty
  2025-06-13  8:44 ` [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices Kaustabh Chakraborty
  5 siblings, 0 replies; 11+ messages in thread
From: Kaustabh Chakraborty @ 2025-06-12 19:41 UTC (permalink / raw)
  To: Sangwon Jee, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Henrik Rydberg
  Cc: linux-input, devicetree, linux-kernel, Kaustabh Chakraborty

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@disroot.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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH RFC v2 5/5] Input: melfas-mip4 - add support for event formats 4 and 9
  2025-06-12 19:41 [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices Kaustabh Chakraborty
                   ` (3 preceding siblings ...)
  2025-06-12 19:41 ` [PATCH RFC v2 4/5] Input: melfas-mip4 - initialize touch events only if the device is a touchscreen Kaustabh Chakraborty
@ 2025-06-12 19:41 ` Kaustabh Chakraborty
  2025-06-13  8:44 ` [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices Kaustabh Chakraborty
  5 siblings, 0 replies; 11+ messages in thread
From: Kaustabh Chakraborty @ 2025-06-12 19:41 UTC (permalink / raw)
  To: Sangwon Jee, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Henrik Rydberg
  Cc: linux-input, devicetree, linux-kernel, Kaustabh Chakraborty

Valid event formats in this driver is limited to 0, 1, and 3. These are
event formats for MIP4 touchscreen devices. Add support for event
formats 4 and 9, which belong to touchkey devices.

While at it, simplify the logic in function mip4_query_device where
valid event formats are checked. Use a human-readable switch-case block
instead of an if statement with obscure conditions.

Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
---
 drivers/input/touchscreen/melfas_mip4.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
index 57b657694a420220be135c2f78d3ddad3ef6f520..95a78c86873355d0a8e0207b1eb4a8408f55cee4 100644
--- a/drivers/input/touchscreen/melfas_mip4.c
+++ b/drivers/input/touchscreen/melfas_mip4.c
@@ -360,9 +360,19 @@ static int mip4_query_device(struct mip4_ts *ts)
 		dev_dbg(&ts->client->dev, "event_format: %d, event_size: %d\n",
 			ts->event_format, ts->event_size);
 
-		if (ts->event_format == 2 || ts->event_format > 3)
+		switch (ts->event_format) {
+		/* Touchscreens */
+		case 0:
+		case 1:
+		case 3:
+		/* Touchkeys */
+		case 4:
+		case 9:
+			break;
+		default:
 			dev_warn(&ts->client->dev,
 				 "Unknown event format %d\n", ts->event_format);
+		}
 	}
 
 	return 0;
@@ -440,6 +450,8 @@ static void mip4_report_keys(struct mip4_ts *ts, u8 *packet)
 	switch (ts->event_format) {
 	case 0:
 	case 1:
+	case 4:
+	case 9:
 		key = packet[0] & 0x0F;
 		down = packet[0] & 0x80;
 		break;
@@ -552,6 +564,8 @@ static int mip4_handle_packet(struct mip4_ts *ts, u8 *packet)
 	switch (ts->event_format) {
 	case 0:
 	case 1:
+	case 4:
+	case 9:
 		type = (packet[0] & 0x40) >> 6;
 		break;
 

-- 
2.49.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC v2 2/5] dt-bindings: input: melfas-mip4: document linux,keycodes property
  2025-06-12 19:41 ` [PATCH RFC v2 2/5] dt-bindings: input: melfas-mip4: document linux,keycodes property Kaustabh Chakraborty
@ 2025-06-12 20:58   ` Rob Herring (Arm)
  0 siblings, 0 replies; 11+ messages in thread
From: Rob Herring (Arm) @ 2025-06-12 20:58 UTC (permalink / raw)
  To: Kaustabh Chakraborty
  Cc: devicetree, Krzysztof Kozlowski, Dmitry Torokhov, linux-input,
	Henrik Rydberg, linux-kernel, Sangwon Jee, Conor Dooley


On Fri, 13 Jun 2025 01:11:34 +0530, Kaustabh Chakraborty wrote:
> Document the linux,keycodes property. The property values are key codes
> which are used in input key events generated by the touchkey device.
> 
> Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
> ---
>  .../devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml       | 6 ++++++
>  1 file changed, 6 insertions(+)
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.example.dts:35.31-32 syntax error
FATAL ERROR: Unable to parse input tree
make[2]: *** [scripts/Makefile.dtbs:131: Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.example.dtb] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1519: dt_binding_check] Error 2
make: *** [Makefile:248: __sub-make] Error 2

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250613-mip4-touchkey-v2-2-9bbbe14c016d@disroot.org

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC v2 1/5] dt-bindings: input: melfas-mip4: convert to dtschema
  2025-06-12 19:41 ` [PATCH RFC v2 1/5] dt-bindings: input: melfas-mip4: convert to dtschema Kaustabh Chakraborty
@ 2025-06-13  7:09   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2025-06-13  7:09 UTC (permalink / raw)
  To: Kaustabh Chakraborty
  Cc: Sangwon Jee, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Henrik Rydberg, linux-input, devicetree,
	linux-kernel

On Fri, Jun 13, 2025 at 01:11:33AM GMT, Kaustabh Chakraborty wrote:
> Port the documentation file melfas_mip4.txt over to melfas,mip4_ts.yaml.
> 
> Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
> ---
>  .../bindings/input/touchscreen/melfas,mip4_ts.yaml | 55 ++++++++++++++++++++++
>  .../bindings/input/touchscreen/melfas_mip4.txt     | 20 --------
>  2 files changed, 55 insertions(+), 20 deletions(-)

You need to fix MAINTAINERS as well. With that:

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices
  2025-06-12 19:41 [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices Kaustabh Chakraborty
                   ` (4 preceding siblings ...)
  2025-06-12 19:41 ` [PATCH RFC v2 5/5] Input: melfas-mip4 - add support for event formats 4 and 9 Kaustabh Chakraborty
@ 2025-06-13  8:44 ` Kaustabh Chakraborty
  5 siblings, 0 replies; 11+ messages in thread
From: Kaustabh Chakraborty @ 2025-06-13  8:44 UTC (permalink / raw)
  To: Sangwon Jee, Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Henrik Rydberg
  Cc: linux-input, devicetree, linux-kernel

On 2025-06-12 19:41, Kaustabh Chakraborty wrote:
> MIP4 is a protocol developed and used by MELFAS in its touchscreen and
> touchkey devices. The MIP4 touchscreen driver acknowledges the
> touchscreen capabilities, but touchkeys are left unimplemented.
> 
> Apart from touchscreen + touchkey devices, the protocol is also used by
> devices which are, functionally, touchkey devices. Thus, the driver
> should also be compatible with those devices. This series aims to
> introduce such required changes.
> 
> RFC: How should the compatible string be handled? The string defined in
> dtschema is 'melfas,mip4_ts', which implies that it's a MIP4 *touchscreen*
> by MELFAS.

I see that there are 2 dts(i) files which use the compatible
"melfas,mip4_ts", as discovered from a simple grep in arch/. They are:
- arm64/qcom/msm8916-lg-m216.dts
- arm64/mediatek/mt8173-elm-hana.dtsi

Is it possible to change all references of the compatible to something more
generic, such as "melfas,mip4"?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC v2 3/5] Input: melfas-mip4 - add support for touchkey input events
  2025-06-12 19:41 ` [PATCH RFC v2 3/5] Input: melfas-mip4 - add support for touchkey input events Kaustabh Chakraborty
@ 2025-06-29  5:12   ` Dmitry Torokhov
  2025-06-30 18:44     ` Kaustabh Chakraborty
  0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Torokhov @ 2025-06-29  5:12 UTC (permalink / raw)
  To: Kaustabh Chakraborty
  Cc: Sangwon Jee, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Henrik Rydberg, linux-input, devicetree, linux-kernel

Hi Kaustabh,

On Fri, Jun 13, 2025 at 01:11:35AM +0530, Kaustabh Chakraborty wrote:
> The MIP4 protocol are supposed to support touchscreens, touchkeys, and
> combo-devices. The driver handles touchscreen events, but touchkey
> events are unimplemented.

I am confused, because I clearly see the driver parsing and forwarding
key events. It appears that this patch adds the ability to set the
keymap via device tree instead of relying on userspace to load it.

Please adjust the patch description.

> 
> Implement them. If compiled with devicetree support, the driver attempts
> to retrieve keycodes from a property named "linux,keycodes".
> 
> Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
> ---
>  drivers/input/touchscreen/melfas_mip4.c | 32 ++++++++++++++++++++++++++++++--
>  1 file changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
> index a6946e3d8376d7e9b4c26f4194409e0ba78bb075..061ac353bc7a2e28f17581411af81f35c89733a1 100644
> --- a/drivers/input/touchscreen/melfas_mip4.c
> +++ b/drivers/input/touchscreen/melfas_mip4.c
> @@ -169,7 +169,7 @@ struct mip4_ts {
>  	unsigned int event_format;
>  
>  	unsigned int key_num;
> -	unsigned short key_code[MIP4_MAX_KEYS];
> +	unsigned int key_code[MIP4_MAX_KEYS];
>  
>  	bool wake_irq_enabled;
>  
> @@ -337,8 +337,13 @@ static int mip4_query_device(struct mip4_ts *ts)
>  			ts->ppm_x, ts->ppm_y);
>  
>  		/* Key ts */
> -		if (ts->node_key > 0)
> +		if (ts->node_key > MIP4_MAX_KEYS) {
> +			dev_warn(&ts->client->dev,
> +				"Too many keys (%u) found\n", ts->node_key);
> +			ts->key_num = MIP4_MAX_KEYS;
> +		} else {
>  			ts->key_num = ts->node_key;
> +		}

I believe this is a bugfix. Please extract it into a separate patch.

>  	}
>  
>  	/* Protocol */
> @@ -1080,6 +1085,7 @@ static int mip4_flash_fw(struct mip4_ts *ts,
>  			 const u8 *fw_data, u32 fw_size, u32 fw_offset)
>  {
>  	struct i2c_client *client = ts->client;
> +	unsigned int i;
>  	int offset;
>  	u16 buf_addr;
>  	int error, error2;
> @@ -1149,6 +1155,11 @@ static int mip4_flash_fw(struct mip4_ts *ts,
>  	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])
> +			input_set_capability(ts->input, EV_KEY, ts->key_code[i]);
> +	}
> +
>  	return error ? error : 0;
>  }
>  
> @@ -1425,6 +1436,7 @@ static int mip4_probe(struct i2c_client *client)
>  {
>  	struct mip4_ts *ts;
>  	struct input_dev *input;
> +	unsigned int i;
>  	int error;
>  
>  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
> @@ -1471,6 +1483,17 @@ static int mip4_probe(struct i2c_client *client)
>  
>  	input_set_drvdata(input, ts);
>  
> +#ifdef CONFIG_OF
> +	error = of_property_read_u32_array(client->dev.of_node, "linux,keycodes",
> +					   ts->key_code, ts->key_num);
> +	if (error && ts->key_num) {
> +		dev_warn(&client->dev,
> +			 "Failed to get codes for %u supported keys", ts->key_num);
> +		/* Disable touchkey support */
> +		ts->key_num = 0;
> +	}

Please use generic device properties (device_property_read_u32_array())
and drop the dependency on OF.

> +#endif
> +
>  	input->keycode = ts->key_code;
>  	input->keycodesize = sizeof(*ts->key_code);
>  	input->keycodemax = ts->key_num;
> @@ -1491,6 +1514,11 @@ static int mip4_probe(struct i2c_client *client)
>  	if (error)
>  		return error;
>  
> +	for (i = 0; i < ts->key_num; i++) {
> +		if (ts->key_code[i])
> +			input_set_capability(input, EV_KEY, ts->key_code[i]);
> +	}
> +
>  	i2c_set_clientdata(client, ts);
>  
>  	error = devm_request_threaded_irq(&client->dev, client->irq,
> 

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC v2 3/5] Input: melfas-mip4 - add support for touchkey input events
  2025-06-29  5:12   ` Dmitry Torokhov
@ 2025-06-30 18:44     ` Kaustabh Chakraborty
  0 siblings, 0 replies; 11+ messages in thread
From: Kaustabh Chakraborty @ 2025-06-30 18:44 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Sangwon Jee, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Henrik Rydberg, linux-input, devicetree, linux-kernel

On 2025-06-29 05:12, Dmitry Torokhov wrote:
> Hi Kaustabh,
> 
> On Fri, Jun 13, 2025 at 01:11:35AM +0530, Kaustabh Chakraborty wrote:
>> The MIP4 protocol are supposed to support touchscreens, touchkeys, and
>> combo-devices. The driver handles touchscreen events, but touchkey
>> events are unimplemented.
> 
> I am confused, because I clearly see the driver parsing and forwarding
> key events. It appears that this patch adds the ability to set the
> keymap via device tree instead of relying on userspace to load it.

Yeah, you're correct. Though I'm not sure this is the correct way to do
what I'm trying to do. What I want is a driver which will drive both
touchscreen and pure-touchkey devices.

I feel like a separate driver is how it should be done, although the
protocol is same and it can be done here...

I had tried to get some input (hence the RFC) about this but I couldn't.
Either my wording wasn't clear or I haven't been able to communicate it
properly.

Sorry for bringing this out of the blue in a thread.

> 
> Please adjust the patch description.
> 
>> 
>> Implement them. If compiled with devicetree support, the driver 
>> attempts
>> to retrieve keycodes from a property named "linux,keycodes".
>> 
>> Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
>> ---
>>  drivers/input/touchscreen/melfas_mip4.c | 32 
>> ++++++++++++++++++++++++++++++--
>>  1 file changed, 30 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/input/touchscreen/melfas_mip4.c 
>> b/drivers/input/touchscreen/melfas_mip4.c
>> index 
>> a6946e3d8376d7e9b4c26f4194409e0ba78bb075..061ac353bc7a2e28f17581411af81f35c89733a1 
>> 100644
>> --- a/drivers/input/touchscreen/melfas_mip4.c
>> +++ b/drivers/input/touchscreen/melfas_mip4.c
>> @@ -169,7 +169,7 @@ struct mip4_ts {
>>  	unsigned int event_format;
>> 
>>  	unsigned int key_num;
>> -	unsigned short key_code[MIP4_MAX_KEYS];
>> +	unsigned int key_code[MIP4_MAX_KEYS];
>> 
>>  	bool wake_irq_enabled;
>> 
>> @@ -337,8 +337,13 @@ static int mip4_query_device(struct mip4_ts *ts)
>>  			ts->ppm_x, ts->ppm_y);
>> 
>>  		/* Key ts */
>> -		if (ts->node_key > 0)
>> +		if (ts->node_key > MIP4_MAX_KEYS) {
>> +			dev_warn(&ts->client->dev,
>> +				"Too many keys (%u) found\n", ts->node_key);
>> +			ts->key_num = MIP4_MAX_KEYS;
>> +		} else {
>>  			ts->key_num = ts->node_key;
>> +		}
> 
> I believe this is a bugfix. Please extract it into a separate patch.

Agree, will do so.

> 
>>  	}
>> 
>>  	/* Protocol */
>> @@ -1080,6 +1085,7 @@ static int mip4_flash_fw(struct mip4_ts *ts,
>>  			 const u8 *fw_data, u32 fw_size, u32 fw_offset)
>>  {
>>  	struct i2c_client *client = ts->client;
>> +	unsigned int i;
>>  	int offset;
>>  	u16 buf_addr;
>>  	int error, error2;
>> @@ -1149,6 +1155,11 @@ static int mip4_flash_fw(struct mip4_ts *ts,
>>  	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])
>> +			input_set_capability(ts->input, EV_KEY, ts->key_code[i]);
>> +	}
>> +
>>  	return error ? error : 0;
>>  }
>> 
>> @@ -1425,6 +1436,7 @@ static int mip4_probe(struct i2c_client *client)
>>  {
>>  	struct mip4_ts *ts;
>>  	struct input_dev *input;
>> +	unsigned int i;
>>  	int error;
>> 
>>  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
>> @@ -1471,6 +1483,17 @@ static int mip4_probe(struct i2c_client 
>> *client)
>> 
>>  	input_set_drvdata(input, ts);
>> 
>> +#ifdef CONFIG_OF
>> +	error = of_property_read_u32_array(client->dev.of_node, 
>> "linux,keycodes",
>> +					   ts->key_code, ts->key_num);
>> +	if (error && ts->key_num) {
>> +		dev_warn(&client->dev,
>> +			 "Failed to get codes for %u supported keys", ts->key_num);
>> +		/* Disable touchkey support */
>> +		ts->key_num = 0;
>> +	}
> 
> Please use generic device properties (device_property_read_u32_array())
> and drop the dependency on OF.
> 
>> +#endif
>> +
>>  	input->keycode = ts->key_code;
>>  	input->keycodesize = sizeof(*ts->key_code);
>>  	input->keycodemax = ts->key_num;
>> @@ -1491,6 +1514,11 @@ static int mip4_probe(struct i2c_client 
>> *client)
>>  	if (error)
>>  		return error;
>> 
>> +	for (i = 0; i < ts->key_num; i++) {
>> +		if (ts->key_code[i])
>> +			input_set_capability(input, EV_KEY, ts->key_code[i]);
>> +	}
>> +
>>  	i2c_set_clientdata(client, ts);
>> 
>>  	error = devm_request_threaded_irq(&client->dev, client->irq,
>> 
> 
> Thanks.
> 
> --
> Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-06-30 18:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-12 19:41 [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices Kaustabh Chakraborty
2025-06-12 19:41 ` [PATCH RFC v2 1/5] dt-bindings: input: melfas-mip4: convert to dtschema Kaustabh Chakraborty
2025-06-13  7:09   ` Krzysztof Kozlowski
2025-06-12 19:41 ` [PATCH RFC v2 2/5] dt-bindings: input: melfas-mip4: document linux,keycodes property Kaustabh Chakraborty
2025-06-12 20:58   ` Rob Herring (Arm)
2025-06-12 19:41 ` [PATCH RFC v2 3/5] Input: melfas-mip4 - add support for touchkey input events Kaustabh Chakraborty
2025-06-29  5:12   ` Dmitry Torokhov
2025-06-30 18:44     ` Kaustabh Chakraborty
2025-06-12 19:41 ` [PATCH RFC v2 4/5] Input: melfas-mip4 - initialize touch events only if the device is a touchscreen Kaustabh Chakraborty
2025-06-12 19:41 ` [PATCH RFC v2 5/5] Input: melfas-mip4 - add support for event formats 4 and 9 Kaustabh Chakraborty
2025-06-13  8:44 ` [PATCH RFC v2 0/5] Support for MELFAS MIP4 touchkey devices Kaustabh Chakraborty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).