linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] HID: rmi: Add functions for writing to registers
@ 2015-02-25  1:36 Andrew Duggan
  2015-02-25  1:36 ` [PATCH 2/3] HID: rmi: disable dribble packets on Synaptics touchpads Andrew Duggan
  2015-02-25  1:36 ` [PATCH 3/3] HID: rmi: disable palm detect gesture when present Andrew Duggan
  0 siblings, 2 replies; 5+ messages in thread
From: Andrew Duggan @ 2015-02-25  1:36 UTC (permalink / raw)
  To: linux-input, linux-kernel
  Cc: Andrew Duggan, Jiri Kosina, Benjamin Tissoires, Gabriele Mazzotta

Writing to registers is needed for setting configuration parameters.

Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
---
 drivers/hid/hid-rmi.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 28579d7..e2a43a1 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -274,6 +274,46 @@ static inline int rmi_read(struct hid_device *hdev, u16 addr, void *buf)
 	return rmi_read_block(hdev, addr, buf, 1);
 }
 
+static int rmi_write_block(struct hid_device *hdev, u16 addr, void *buf,
+		const int len)
+{
+	struct rmi_data *data = hid_get_drvdata(hdev);
+	int ret;
+
+	mutex_lock(&data->page_mutex);
+
+	if (RMI_PAGE(addr) != data->page) {
+		ret = rmi_set_page(hdev, RMI_PAGE(addr));
+		if (ret < 0)
+			goto exit;
+	}
+
+	data->writeReport[0] = RMI_WRITE_REPORT_ID;
+	data->writeReport[1] = len;
+	data->writeReport[2] = addr & 0xFF;
+	data->writeReport[3] = (addr >> 8) & 0xFF;
+	memcpy(&data->writeReport[4], buf, len);
+
+	ret = rmi_write_report(hdev, data->writeReport,
+					data->output_report_size);
+	if (ret < 0) {
+		dev_err(&hdev->dev,
+			"failed to write request output report (%d)\n",
+			ret);
+		goto exit;
+	}
+	ret = 0;
+
+exit:
+	mutex_unlock(&data->page_mutex);
+	return ret;
+}
+
+static inline int rmi_write(struct hid_device *hdev, u16 addr, void *buf)
+{
+	return rmi_write_block(hdev, addr, buf, 1);
+}
+
 static void rmi_f11_process_touch(struct rmi_data *hdata, int slot,
 		u8 finger_state, u8 *touch_data)
 {
-- 
2.1.0


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

* [PATCH 2/3] HID: rmi: disable dribble packets on Synaptics touchpads
  2015-02-25  1:36 [PATCH 1/3] HID: rmi: Add functions for writing to registers Andrew Duggan
@ 2015-02-25  1:36 ` Andrew Duggan
  2015-02-25  1:36 ` [PATCH 3/3] HID: rmi: disable palm detect gesture when present Andrew Duggan
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Duggan @ 2015-02-25  1:36 UTC (permalink / raw)
  To: linux-input, linux-kernel
  Cc: Andrew Duggan, Jiri Kosina, Benjamin Tissoires, Gabriele Mazzotta

When a finger is lifted from a Synaptics touchpad the firmware will continue
to interrupts for up to a second. These additional interrupts are know and
dribble interrupts. Since the data read from the touchpad does not change
the input subsystem only reports a single event. This makes the servicing of
dribble interrupts on Linux unnecessary. This patch simply disables dribble
interupts when configuring the touchpad.

Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
---
 drivers/hid/hid-rmi.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index e2a43a1..6e74eae 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -751,6 +751,7 @@ static int rmi_populate_f11(struct hid_device *hdev)
 	bool has_gestures;
 	bool has_rel;
 	bool has_data40 = false;
+	bool has_dribble = false;
 	unsigned x_size, y_size;
 	u16 query_offset;
 
@@ -792,6 +793,14 @@ static int rmi_populate_f11(struct hid_device *hdev)
 	has_rel = !!(buf[0] & BIT(3));
 	has_gestures = !!(buf[0] & BIT(5));
 
+	ret = rmi_read(hdev, data->f11.query_base_addr + 5, buf);
+	if (ret) {
+		hid_err(hdev, "can not get absolute data sources: %d.\n", ret);
+		return ret;
+	}
+
+	has_dribble = !!(buf[0] & BIT(4));
+
 	/*
 	 * At least 4 queries are guaranteed to be present in F11
 	 * +1 for query 5 which is present since absolute events are
@@ -908,6 +917,16 @@ static int rmi_populate_f11(struct hid_device *hdev)
 	data->max_x = buf[6] | (buf[7] << 8);
 	data->max_y = buf[8] | (buf[9] << 8);
 
+	if (has_dribble) {
+		buf[0] = buf[0] & ~BIT(6);
+		ret = rmi_write(hdev, data->f11.control_base_addr, buf);
+		if (ret) {
+			hid_err(hdev, "can not write to control reg 0: %d.\n",
+				ret);
+			return ret;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.1.0

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

* [PATCH 3/3] HID: rmi: disable palm detect gesture when present
  2015-02-25  1:36 [PATCH 1/3] HID: rmi: Add functions for writing to registers Andrew Duggan
  2015-02-25  1:36 ` [PATCH 2/3] HID: rmi: disable dribble packets on Synaptics touchpads Andrew Duggan
@ 2015-02-25  1:36 ` Andrew Duggan
  2015-02-25  9:09   ` Gabriele Mazzotta
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Duggan @ 2015-02-25  1:36 UTC (permalink / raw)
  To: linux-input, linux-kernel
  Cc: Andrew Duggan, Jiri Kosina, Benjamin Tissoires, Gabriele Mazzotta

A touchpad may have firmware based palm detection code enabled which
suppresses 2D data from being reported when the firmware believes a palm is
on the touchpad. This functionality is meant to be used in mouse mode without
a driver. When a driver is present, the driver can do a better job of
determining if a contact is a palm. If this gesture is enabled on a touchpad
operating in rmi mode then the firmware will not properly clear the palm detect
interrupt, causing the touchpad to interrupt indefinately. This patch disables
the palm detect gesture when the touchpad is operating in rmi mode.

Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
---
Hi Gabriele,

Can you test this patch on your system to confirm that it fixes your issue?
I was able to test the  other two patches so I can confirm that the write
fuction works. But, I don't have a touchpad with the palm detect gesture
enabled so it would be good to double check that I have the right address and
mask.

Andrew


 drivers/hid/hid-rmi.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 6e74eae..368ffdf 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -752,6 +752,7 @@ static int rmi_populate_f11(struct hid_device *hdev)
 	bool has_rel;
 	bool has_data40 = false;
 	bool has_dribble = false;
+	bool has_palm_detect = false;
 	unsigned x_size, y_size;
 	u16 query_offset;
 
@@ -820,6 +821,7 @@ static int rmi_populate_f11(struct hid_device *hdev)
 				ret);
 			return ret;
 		}
+		has_palm_detect = !!(buf[0] & BIT(0));
 		has_query10 = !!(buf[0] & BIT(2));
 
 		query_offset += 2; /* query 7 and 8 are present */
@@ -906,11 +908,11 @@ static int rmi_populate_f11(struct hid_device *hdev)
 	 * retrieve the ctrl registers
 	 * the ctrl register has a size of 20 but a fw bug split it into 16 + 4,
 	 * and there is no way to know if the first 20 bytes are here or not.
-	 * We use only the first 10 bytes, so get only them.
+	 * We use only the first 12 bytes, so get only them.
 	 */
-	ret = rmi_read_block(hdev, data->f11.control_base_addr, buf, 10);
+	ret = rmi_read_block(hdev, data->f11.control_base_addr, buf, 12);
 	if (ret) {
-		hid_err(hdev, "can not read ctrl block of size 10: %d.\n", ret);
+		hid_err(hdev, "can not read ctrl block of size 11: %d.\n", ret);
 		return ret;
 	}
 
@@ -927,6 +929,17 @@ static int rmi_populate_f11(struct hid_device *hdev)
 		}
 	}
 
+	if (has_palm_detect) {
+		buf[11] = buf[11] & ~BIT(0);
+		ret = rmi_write(hdev, data->f11.control_base_addr + 11,
+				&buf[11]);
+		if (ret) {
+			hid_err(hdev, "can not write to control reg 11: %d.\n",
+				ret);
+			return ret;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.1.0

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

* Re: [PATCH 3/3] HID: rmi: disable palm detect gesture when present
  2015-02-25  1:36 ` [PATCH 3/3] HID: rmi: disable palm detect gesture when present Andrew Duggan
@ 2015-02-25  9:09   ` Gabriele Mazzotta
  2015-02-25 14:35     ` Jiri Kosina
  0 siblings, 1 reply; 5+ messages in thread
From: Gabriele Mazzotta @ 2015-02-25  9:09 UTC (permalink / raw)
  To: Andrew Duggan; +Cc: linux-input, linux-kernel, Jiri Kosina, Benjamin Tissoires

On Tuesday 24 February 2015 17:36:50 Andrew Duggan wrote:
> A touchpad may have firmware based palm detection code enabled which
> suppresses 2D data from being reported when the firmware believes a palm is
> on the touchpad. This functionality is meant to be used in mouse mode without
> a driver. When a driver is present, the driver can do a better job of
> determining if a contact is a palm. If this gesture is enabled on a touchpad
> operating in rmi mode then the firmware will not properly clear the palm detect
> interrupt, causing the touchpad to interrupt indefinately. This patch disables
> the palm detect gesture when the touchpad is operating in rmi mode.
> 
> Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
> ---
> Hi Gabriele,
> 
> Can you test this patch on your system to confirm that it fixes your issue?
> I was able to test the  other two patches so I can confirm that the write
> fuction works. But, I don't have a touchpad with the palm detect gesture
> enabled so it would be good to double check that I have the right address and
> mask.
> 
> Andrew

I tested it and confirm that it's working. Thanks.

Gabriele

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

* Re: [PATCH 3/3] HID: rmi: disable palm detect gesture when present
  2015-02-25  9:09   ` Gabriele Mazzotta
@ 2015-02-25 14:35     ` Jiri Kosina
  0 siblings, 0 replies; 5+ messages in thread
From: Jiri Kosina @ 2015-02-25 14:35 UTC (permalink / raw)
  To: Gabriele Mazzotta
  Cc: Andrew Duggan, linux-input, linux-kernel, Benjamin Tissoires

On Wed, 25 Feb 2015, Gabriele Mazzotta wrote:

> On Tuesday 24 February 2015 17:36:50 Andrew Duggan wrote:
> > A touchpad may have firmware based palm detection code enabled which
> > suppresses 2D data from being reported when the firmware believes a palm is
> > on the touchpad. This functionality is meant to be used in mouse mode without
> > a driver. When a driver is present, the driver can do a better job of
> > determining if a contact is a palm. If this gesture is enabled on a touchpad
> > operating in rmi mode then the firmware will not properly clear the palm detect
> > interrupt, causing the touchpad to interrupt indefinately. This patch disables
> > the palm detect gesture when the touchpad is operating in rmi mode.
> > 
> > Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
> > ---
> > Hi Gabriele,
> > 
> > Can you test this patch on your system to confirm that it fixes your issue?
> > I was able to test the  other two patches so I can confirm that the write
> > fuction works. But, I don't have a touchpad with the palm detect gesture
> > enabled so it would be good to double check that I have the right address and
> > mask.
> > 
> > Andrew
> 
> I tested it and confirm that it's working. Thanks.

Thanks for testing. I have now applied the series to for-4.1/rmi.

-- 
Jiri Kosina
SUSE Labs

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

end of thread, other threads:[~2015-02-25 14:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-25  1:36 [PATCH 1/3] HID: rmi: Add functions for writing to registers Andrew Duggan
2015-02-25  1:36 ` [PATCH 2/3] HID: rmi: disable dribble packets on Synaptics touchpads Andrew Duggan
2015-02-25  1:36 ` [PATCH 3/3] HID: rmi: disable palm detect gesture when present Andrew Duggan
2015-02-25  9:09   ` Gabriele Mazzotta
2015-02-25 14:35     ` Jiri Kosina

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