linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add Clickpad support to synaptics driver
@ 2009-12-14 10:01 Takashi Iwai
  2009-12-14 10:01 ` [PATCH 1/2] input: Enable to report clicks with Clickapd devices Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2009-12-14 10:01 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input

The following small patches are to add the support of new "Clickpad"
devices from Synaptics.  The first patch implements the very basic
change to enable the click reporting while the second one implements
the ClickZone mode support.


[Please add me to Cc as I'm not subscribed to the list.]

thanks,

Takashi

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

* [PATCH 1/2] input: Enable to report clicks with Clickapd devices
  2009-12-14 10:01 [PATCH 0/2] Add Clickpad support to synaptics driver Takashi Iwai
@ 2009-12-14 10:01 ` Takashi Iwai
  2009-12-14 10:01   ` [PATCH 2/2] input: Add ClickZone mode support to Clickpad devices Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2009-12-14 10:01 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, Takashi Iwai

The new Synaptics "Clickpad" devices seem to report the click as a
middle button.  But the synaptics driver doesn't expose because the
device doesn't set the necessary capability bits.

This patch adds a check of the product id bits and forces to enable the
middle-button reporting on Clickpad devices.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/input/mouse/synaptics.c |    5 +++++
 drivers/input/mouse/synaptics.h |    2 ++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 05689e7..8d8365e 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -701,6 +701,11 @@ int synaptics_init(struct psmouse *psmouse)
 		SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity),
 		priv->model_id, priv->capabilities, priv->ext_cap);
 
+	if (SYN_CAP_CLICKPAD(priv->ext_cap)) {
+		/* force to enable the middle button */
+		priv->capabilities |= (1 << 18);
+	}
+
 	set_input_params(psmouse->dev, priv);
 
 	/*
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 838e7f2..35360a6 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -48,6 +48,8 @@
 #define SYN_CAP_VALID(c)		((((c) & 0x00ff00) >> 8) == 0x47)
 #define SYN_EXT_CAP_REQUESTS(c)		(((c) & 0x700000) >> 20)
 #define SYN_CAP_MULTI_BUTTON_NO(ec)	(((ec) & 0x00f000) >> 12)
+#define SYN_CAP_PRODUCT_ID(ec)		(((ec) & 0xff0000) >> 16)
+#define SYN_CAP_CLICKPAD(ec)		(SYN_CAP_PRODUCT_ID(ec) == 0xe4)
 
 /* synaptics modes query bits */
 #define SYN_MODE_ABSOLUTE(m)		((m) & (1 << 7))
-- 
1.6.5.5


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

* [PATCH 2/2] input: Add ClickZone mode support to Clickpad devices
  2009-12-14 10:01 ` [PATCH 1/2] input: Enable to report clicks with Clickapd devices Takashi Iwai
@ 2009-12-14 10:01   ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2009-12-14 10:01 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, Takashi Iwai

The Clickpad devices supports only a single button click, the driver
needs to check the left or the right position with some hints.
In "ClickZone" mode, this is decided by the touch position at clicking.

This patch adds the check of the left/right button (also the middle
button) in the synaptics driver side so that the existing user-space
works as is.  This could be implemented in the user-space side, too, but
unfortunately it can't be done automatically because the h/w capability
bits needed to identify the device model aren't exposed.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 drivers/input/mouse/synaptics.c |   43 +++++++++++++++++++++++++++++++++++++++
 drivers/input/mouse/synaptics.h |    1 +
 2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 8d8365e..b2db417 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -327,6 +327,45 @@ static void synaptics_pt_create(struct psmouse *psmouse)
  *	Functions to interpret the absolute mode packets
  ****************************************************************************/
 
+/* left and right clickpad button ranges;
+ * the gap between them is interpreted as a middle-button click
+ */
+#define CLICKPAD_LEFT_BTN_X \
+	((XMAX_NOMINAL - XMIN_NOMINAL) * 2 / 5 + XMIN_NOMINAL)
+#define CLICKPAD_RIGHT_BTN_X \
+	((XMAX_NOMINAL - XMIN_NOMINAL) * 3 / 5 + XMIN_NOMINAL)
+
+/* handle clickpad events */
+static void clickpad_process_packet(struct synaptics_data *priv,
+				    struct synaptics_hw_state *hw)
+{
+	/* clickpad mode reports Y range from 0 to YMAX_NOMINAL,
+	 * where the area Y < YMIN_NOMINAL is used as click buttons
+	 */
+	if (hw->y < YMIN_NOMINAL) {
+		/* button area */
+		hw->z = 0; /* don't move pointer */
+		/* clickpad reports only the middle button, and we need
+		 * to fake left/right buttons depending on the touch position
+		 */
+		if (hw->middle) { /* clicked? */
+			hw->middle = 0;
+			if (hw->x < CLICKPAD_LEFT_BTN_X)
+				hw->left = 1;
+			else if (hw->x > CLICKPAD_RIGHT_BTN_X)
+				hw->right = 1;
+			else
+				hw->middle = 1;
+		}
+	} else if (hw->middle) {
+		/* dragging */
+		hw->left = priv->prev_hw.left;
+		hw->right = priv->prev_hw.right;
+		hw->middle = priv->prev_hw.middle;
+	}
+	priv->prev_hw = *hw;
+}
+
 static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data *priv, struct synaptics_hw_state *hw)
 {
 	memset(hw, 0, sizeof(struct synaptics_hw_state));
@@ -407,6 +446,9 @@ static void synaptics_process_packet(struct psmouse *psmouse)
 
 	synaptics_parse_hw_state(psmouse->packet, priv, &hw);
 
+	if (SYN_CAP_CLICKPAD(priv->ext_cap))
+		clickpad_process_packet(priv, &hw);
+
 	if (hw.scroll) {
 		priv->scroll += hw.scroll;
 
@@ -702,6 +744,7 @@ int synaptics_init(struct psmouse *psmouse)
 		priv->model_id, priv->capabilities, priv->ext_cap);
 
 	if (SYN_CAP_CLICKPAD(priv->ext_cap)) {
+		printk(KERN_INFO "Synaptics: Clickpad mode enabled\n");
 		/* force to enable the middle button */
 		priv->capabilities |= (1 << 18);
 	}
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 35360a6..76df393 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -105,6 +105,7 @@ struct synaptics_data {
 	unsigned char pkt_type;			/* packet type - old, new, etc */
 	unsigned char mode;			/* current mode byte */
 	int scroll;
+	struct synaptics_hw_state prev_hw;
 };
 
 void synaptics_module_init(void);
-- 
1.6.5.5


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

end of thread, other threads:[~2009-12-14 10:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-14 10:01 [PATCH 0/2] Add Clickpad support to synaptics driver Takashi Iwai
2009-12-14 10:01 ` [PATCH 1/2] input: Enable to report clicks with Clickapd devices Takashi Iwai
2009-12-14 10:01   ` [PATCH 2/2] input: Add ClickZone mode support to Clickpad devices Takashi Iwai

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