linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/RFT] Synaptics -
@ 2010-04-21  6:11 Dmitry Torokhov
  2010-04-21 13:45 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2010-04-21  6:11 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Christopher Heiny, linux-input

Newer Synaptics firmware allows to quesry maximim dimensions reported by
device, let's use this data.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

Takashi,

I would appreciate if you could give this patch a try.


Christofer,

Does this look about right?

Thank you!

 drivers/input/mouse/synaptics.c |   28 ++++++++++++++++++++--------
 drivers/input/mouse/synaptics.h |    3 +++
 2 files changed, 23 insertions(+), 8 deletions(-)


diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index ebd7a99..df608c5 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -201,16 +201,26 @@ static int synaptics_resolution(struct psmouse *psmouse)
 {
 	struct synaptics_data *priv = psmouse->private;
 	unsigned char res[3];
+	unsigned char max[3];
 
 	if (SYN_ID_MAJOR(priv->identity) < 4)
-		return 0;
 
-	if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, res))
-		return 0;
+	if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, res) == 0) {
+		if (res[0] != 0 && (res[1] & 0x80) && res[2] != 0) {
+			priv->x_res = res[0]; /* x resolution in units/mm */
+			priv->y_res = res[2]; /* y resolution in units/mm */
+		}
+	}
 
-	if ((res[0] != 0) && (res[1] & 0x80) && (res[2] != 0)) {
-		priv->x_res = res[0]; /* x resolution in units/mm */
-		priv->y_res = res[2]; /* y resolution in units/mm */
+	if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 5 &&
+	    SYN_CAP_MAX_DIMENSIONS(priv->ext_cap_0c)) {
+		if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_DIMENSIONS, max)) {
+			printk(KERN_ERR "Synaptics claims to have dimensions query,"
+			       " but I'm not able to read it.\n");
+		} else {
+			priv->max_x = (max[0] << 5) | ((max[1] & 0x0f) << 1);
+			priv->max_y = (max[2] << 5) | ((max[1] & 0xf0) >> 3);
+		}
 	}
 
 	return 0;
@@ -578,8 +588,10 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
 	int i;
 
 	__set_bit(EV_ABS, dev->evbit);
-	input_set_abs_params(dev, ABS_X, XMIN_NOMINAL, XMAX_NOMINAL, 0, 0);
-	input_set_abs_params(dev, ABS_Y, YMIN_NOMINAL, YMAX_NOMINAL, 0, 0);
+	input_set_abs_params(dev, ABS_X,
+			     XMIN_NOMINAL, priv->max_x ?: XMAX_NOMINAL, 0, 0);
+	input_set_abs_params(dev, ABS_Y,
+			     YMIN_NOMINAL, priv->max_y ?: YMAX_NOMINAL, 0, 0);
 	input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
 	__set_bit(ABS_TOOL_WIDTH, dev->absbit);
 
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index ae37c5d..6705c43 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -19,6 +19,7 @@
 #define SYN_QUE_RESOLUTION		0x08
 #define SYN_QUE_EXT_CAPAB		0x09
 #define SYN_QUE_EXT_CAPAB_0C		0x0c
+#define SYN_QUE_EXT_DIMENSIONS		0x0d
 
 /* synatics modes */
 #define SYN_BIT_ABSOLUTE_MODE		(1 << 7)
@@ -51,6 +52,7 @@
 #define SYN_CAP_MULTI_BUTTON_NO(ec)	(((ec) & 0x00f000) >> 12)
 #define SYN_CAP_PRODUCT_ID(ec)		(((ec) & 0xff0000) >> 16)
 #define SYN_CAP_CLICKPAD(ex0c)		((ex0c) & 0x100100)
+#define SYN_CAP_MAX_DIMENSIONS(ex0c)	((ex0c) & 0x02)
 
 /* synaptics modes query bits */
 #define SYN_MODE_ABSOLUTE(m)		((m) & (1 << 7))
@@ -100,6 +102,7 @@ struct synaptics_data {
 	unsigned long int capabilities;		/* Capabilities */
 	unsigned long int ext_cap;		/* Extended Capabilities */
 	unsigned long int ext_cap_0c;		/* Ext Caps from 0x0c query */
+	unsigned int max_x, max_y;		/* Max dimensions (from FW) */
 	unsigned long int identity;		/* Identification */
 	int x_res;				/* X resolution in units/mm */
 	int y_res;				/* Y resolution in units/mm */
-- 
Dmitry

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

* Re: [RFC/RFT] Synaptics -
  2010-04-21  6:11 [RFC/RFT] Synaptics - Dmitry Torokhov
@ 2010-04-21 13:45 ` Takashi Iwai
  2010-04-21 17:24   ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2010-04-21 13:45 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Christopher Heiny, linux-input

At Tue, 20 Apr 2010 23:11:17 -0700,
Dmitry Torokhov wrote:
> 
> Newer Synaptics firmware allows to quesry maximim dimensions reported by
> device, let's use this data.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> ---
> 
> Takashi,
> 
> I would appreciate if you could give this patch a try.

The bit definition seems wrong:

> @@ -51,6 +52,7 @@
>  #define SYN_CAP_MULTI_BUTTON_NO(ec)	(((ec) & 0x00f000) >> 12)
>  #define SYN_CAP_PRODUCT_ID(ec)		(((ec) & 0xff0000) >> 16)
>  #define SYN_CAP_CLICKPAD(ex0c)		((ex0c) & 0x100100)
> +#define SYN_CAP_MAX_DIMENSIONS(ex0c)	((ex0c) & 0x02)

This should be

	#define SYN_CAP_MAX_DIMENSIONS(ex0c)	((ex0c) & 0x020000)

After changing this, it seems working fine.
The area is detected as 5584 x 4618.


thanks,

Takashi

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

* Re: [RFC/RFT] Synaptics -
  2010-04-21 13:45 ` Takashi Iwai
@ 2010-04-21 17:24   ` Dmitry Torokhov
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2010-04-21 17:24 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Christopher Heiny, linux-input

On Wed, Apr 21, 2010 at 03:45:40PM +0200, Takashi Iwai wrote:
> At Tue, 20 Apr 2010 23:11:17 -0700,
> Dmitry Torokhov wrote:
> > 
> > Newer Synaptics firmware allows to quesry maximim dimensions reported by
> > device, let's use this data.
> > 
> > Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> > ---
> > 
> > Takashi,
> > 
> > I would appreciate if you could give this patch a try.
> 
> The bit definition seems wrong:
> 
> > @@ -51,6 +52,7 @@
> >  #define SYN_CAP_MULTI_BUTTON_NO(ec)	(((ec) & 0x00f000) >> 12)
> >  #define SYN_CAP_PRODUCT_ID(ec)		(((ec) & 0xff0000) >> 16)
> >  #define SYN_CAP_CLICKPAD(ex0c)		((ex0c) & 0x100100)
> > +#define SYN_CAP_MAX_DIMENSIONS(ex0c)	((ex0c) & 0x02)
> 
> This should be
> 
> 	#define SYN_CAP_MAX_DIMENSIONS(ex0c)	((ex0c) & 0x020000)
> 

You are right. I forgot we shift the bytes around...

> After changing this, it seems working fine.
> The area is detected as 5584 x 4618.
> 

Great! Thank you.

-- 
Dmitry

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

end of thread, other threads:[~2010-04-21 17:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-21  6:11 [RFC/RFT] Synaptics - Dmitry Torokhov
2010-04-21 13:45 ` Takashi Iwai
2010-04-21 17:24   ` 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).