linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: mms114 - Support MMS136
@ 2021-04-04 23:26 Linus Walleij
  2021-04-10  6:05 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2021-04-04 23:26 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input
  Cc: Linus Walleij, Stephan Gerhold, Simon Shields, Tomasz Figa

The Melfas MMS136 is similar to the other MMS variants but
has event packages of 6 bytes rather than 8 as the others.

The define is named FINGER_EVENT_SZ in the vendor drivers
so I renamed it from MMS*_PACKET_SZ to MMS*_EVENT_SZ.

After this patch, the touchscreen on the Samsung GT-I8530
works fine with PostmarketOS.

Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Simon Shields <simon@lineageos.org>
Cc: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
This uses the new compatible string from the YAML
conversion patch that was sent separately.
---
 drivers/input/touchscreen/mms114.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index 16557f51b09d..131c1136d01c 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-// Melfas MMS114/MMS152 touchscreen device driver
+// Melfas MMS114/MMS136/MMS152 touchscreen device driver
 //
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 // Author: Joonyoung Shim <jy0922.shim@samsung.com>
@@ -44,7 +44,8 @@
 #define MMS114_MAX_AREA			0xff
 
 #define MMS114_MAX_TOUCH		10
-#define MMS114_PACKET_NUM		8
+#define MMS114_EVENT_SIZE		8
+#define MMS136_EVENT_SIZE		6
 
 /* Touch type */
 #define MMS114_TYPE_NONE		0
@@ -53,6 +54,7 @@
 
 enum mms_type {
 	TYPE_MMS114	= 114,
+	TYPE_MMS136	= 136,
 	TYPE_MMS152	= 152,
 	TYPE_MMS345L	= 345,
 };
@@ -209,7 +211,11 @@ static irqreturn_t mms114_interrupt(int irq, void *dev_id)
 	if (packet_size <= 0)
 		goto out;
 
-	touch_size = packet_size / MMS114_PACKET_NUM;
+	/* MMS136 has slightly different event size */
+	if (data->type == TYPE_MMS136)
+		touch_size = packet_size / MMS136_EVENT_SIZE;
+	else
+		touch_size = packet_size / MMS114_EVENT_SIZE;
 
 	error = __mms114_read_reg(data, MMS114_INFORMATION, packet_size,
 			(u8 *)touch);
@@ -275,6 +281,7 @@ static int mms114_get_version(struct mms114_data *data)
 		break;
 
 	case TYPE_MMS114:
+	case TYPE_MMS136:
 		error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf);
 		if (error)
 			return error;
@@ -297,8 +304,9 @@ static int mms114_setup_regs(struct mms114_data *data)
 	if (error < 0)
 		return error;
 
-	/* Only MMS114 has configuration and power on registers */
-	if (data->type != TYPE_MMS114)
+	/* Only MMS114 and MMS136 have configuration and power on registers */
+	if (data->type != TYPE_MMS114 &&
+	    data->type != TYPE_MMS136)
 		return 0;
 
 	error = mms114_set_active(data, true);
@@ -480,7 +488,8 @@ static int mms114_probe(struct i2c_client *client,
 				     0, data->props.max_y, 0, 0);
 	}
 
-	if (data->type == TYPE_MMS114) {
+	if ((data->type == TYPE_MMS114) ||
+	    (data->type == TYPE_MMS136)) {
 		/*
 		 * The firmware handles movement and pressure fuzz, so
 		 * don't duplicate that in software.
@@ -604,6 +613,9 @@ static const struct of_device_id mms114_dt_match[] = {
 	{
 		.compatible = "melfas,mms114",
 		.data = (void *)TYPE_MMS114,
+	}, {
+		.compatible = "melfas,mms136",
+		.data = (void *)TYPE_MMS136,
 	}, {
 		.compatible = "melfas,mms152",
 		.data = (void *)TYPE_MMS152,
-- 
2.29.2


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

* Re: [PATCH] Input: mms114 - Support MMS136
  2021-04-04 23:26 [PATCH] Input: mms114 - Support MMS136 Linus Walleij
@ 2021-04-10  6:05 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2021-04-10  6:05 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-input, Stephan Gerhold, Simon Shields, Tomasz Figa

On Mon, Apr 05, 2021 at 01:26:19AM +0200, Linus Walleij wrote:
> The Melfas MMS136 is similar to the other MMS variants but
> has event packages of 6 bytes rather than 8 as the others.
> 
> The define is named FINGER_EVENT_SZ in the vendor drivers
> so I renamed it from MMS*_PACKET_SZ to MMS*_EVENT_SZ.
> 
> After this patch, the touchscreen on the Samsung GT-I8530
> works fine with PostmarketOS.
> 
> Cc: Stephan Gerhold <stephan@gerhold.net>
> Cc: Simon Shields <simon@lineageos.org>
> Cc: Tomasz Figa <tfiga@chromium.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Applied, thank you.

-- 
Dmitry

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

end of thread, other threads:[~2021-04-10  6:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-04 23:26 [PATCH] Input: mms114 - Support MMS136 Linus Walleij
2021-04-10  6:05 ` Dmitry Torokhov

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).