Skip to contentSkip to conversation

OLPC tablet input driver.

RPC In review Zephaniah E. Hull 7 participants 22 messages Aug 29, 2006 – Nov 8, 2006 Input drivers

lore
Share & tools
lore
#0 lore raw

The OLPC will ship with a somewhat unique input device made by ALPS, connected via PS/2 and speaking a protocol only loosely based on that spoken by other ALPS devices.

This is required by the noticeable different between this device and others made by alps, specificly that it is very wide, with the center 1/3rd usable with the GS sensor, and the entire area usable with the PT sensor, with support for using both at once.

The protocol differs enough that I split the driver for this off from the ALPS driver.

The patch is below, but there are a few things of note.

1: Cosmetic: Some line lengths, and outputs with debugging enabled, are over 80 columns wide. Will be fixed in the next version of this patch.

2: Cosmetic: Input device IDs need to be decided on, some feedback on the best values to use here would be appreciated.

3: Patch stuff: Because the protocol uses 9 byte packets I had to increase the size of the buffer in struct psmouse. Should this be split off into a separate patch?

4: Technical/policy: Buttons are currently sent to both of the input devices we generate, I don't see any way to avoid this that is not a policy decision on which buttons belong to which device, but I'm open to suggestions.

5: Technical: Min/max on absolute values are currently reported as the protocol limits (10 bits on GS X, GS Y, and PT Y. 11 bits on PT X. 7 bits on GS pressure). Until we get samples based on the newer design and do some testing to see how big the variations are, we just don't have any numbers to put here.

6: Technical, maybe: The early samples I have that speak this protocol are doing some odd things with this driver. Mostly in the realm of sample rate and pressure reporting. I'm fairly sure that this is hardware related, but it's worth mentioning.

That said, here the patch is for comments.
(And possibly for the OLPC kernel tree for others with samples to play with.)

drivers/input/mouse/Makefile +1 -1
index 21a1de6..6218e5a 100644
@@ -14,4 +14,4 @@ obj-$(CONFIG_MOUSE_SERIAL)	+= sermouse.o
 obj-$(CONFIG_MOUSE_HIL)		+= hil_ptr.o
 obj-$(CONFIG_MOUSE_VSXXXAA)	+= vsxxxaa.o
 
-psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o
+psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o olpc.o
drivers/input/mouse/olpc.c new file +327 -0

327 lines not on this page · raw message

drivers/input/mouse/olpc.h new file +37 -0
new file mode 100644
index 0000000..49f4e3e
@@ -0,0 +1,37 @@
+/*
+ * OLPC touchpad PS/2 mouse driver
+ *
+ * Copyright (c) 2006 One Laptop Per Child, inc.
+ *
+ * This driver is partly based on the ALPS driver.
+ * Copyright (c) 2003 Peter Osterlund <[email protected]>
+ * Copyright (c) 2005 Vojtech Pavlik <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#ifndef _OLPC_H
+#define _OLPC_H
+
+int olpc_detect(struct psmouse *psmouse, int set_properties);
+int olpc_init(struct psmouse *psmouse);
+
+struct olpc_model_info {
+        unsigned char signature[3];
+        unsigned char byte0, mask0;
+        unsigned char flags;
+};
+
+struct olpc_data {
+	struct input_dev *dev2;		/* Relative device */
+	char name[32];			/* Name */
+	char phys[32];			/* Phys */
+	struct olpc_model_info *i; 	/* Info */
+	int prev_fin_pt;		/* Finger bit from previous packet */
+	int prev_fin_gs;		/* Finger bit from previous packet */
+};
+
+
+#endif
drivers/input/mouse/psmouse-base.c +17 -0
index 8bc9f51..20060b0 100644
@@ -26,6 +26,7 @@
 #include "synaptics.h"
 #include "logips2pp.h"
 #include "alps.h"
+#include "olpc.h"
 #include "lifebook.h"
 #include "trackpoint.h"
 
@@ -616,6 +617,15 @@ static int psmouse_extensions(struct psm
  */
 			max_proto = PSMOUSE_IMEX;
 		}
+		ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
+		if (olpc_detect(psmouse, set_properties) == 0) {
+			if (!set_properties || olpc_init(psmouse) == 0)
+				return PSMOUSE_OLPC;
+/*
+ * Init failed, try basic relative protocols
+ */
+			max_proto = PSMOUSE_IMEX;
+		}
 	}
 
 	if (max_proto > PSMOUSE_IMEX && genius_detect(psmouse, set_properties) == 0)
@@ -726,6 +736,13 @@ static struct psmouse_protocol psmouse_p
 		.detect		= trackpoint_detect,
 	},
 	{
+		.type		= PSMOUSE_OLPC,
+		.name		= "OLPC",
+		.alias		= "olpc",
+		.maxproto	= 1,
+		.detect		= olpc_detect,
+	},
+	{
 		.type		= PSMOUSE_AUTO,
 		.name		= "auto",
 		.alias		= "any",
drivers/input/mouse/psmouse.h +2 -1
index 4d9107f..f3d7199 100644
@@ -42,7 +42,7 @@ struct psmouse {
 	struct work_struct resync_work;
 	char *vendor;
 	char *name;
-	unsigned char packet[8];
+	unsigned char packet[9];
 	unsigned char badbyte;
 	unsigned char pktcnt;
 	unsigned char pktsize;
@@ -86,6 +86,7 @@ enum psmouse_type {
 	PSMOUSE_ALPS,
 	PSMOUSE_LIFEBOOK,
 	PSMOUSE_TRACKPOINT,
+	PSMOUSE_OLPC,
 	PSMOUSE_AUTO		/* This one should always be last */
 };
 
Signature · 3 lines
	  1024D/E65A7801 Zephaniah E. Hull <[email protected]>
	   92ED 94E4 B1E6 3624 226D  5727 4453 008B E65A 7801
	    CCs of replies from mailing lists are requested.
#1 lore raw

drivers/input/mouse/olpc.c line 45

Quoted 6 lines
drivers/input/mouse/olpc.c new file +6 -0
+#undef DEBUG
+#ifdef DEBUG
+#define dbg(format, arg...) printk(KERN_INFO "olpc.c(%d): " format "\n", __LINE__, ## arg)
+#else
+#define dbg(format, arg...) do {} while (0)
+#endif

why not use pr_debug or even dev_debug() ?
Those already have this ifdef included

drivers/input/mouse/olpc.c line 53

Quoted 4 lines
drivers/input/mouse/olpc.c new file +4 -0
+
+static struct olpc_model_info olpc_model_data[] = {
+	{ { 0x67, 0x00, 0x0a }, 0xeb, 0xff, OLPC_PTGS },	/* OLPC in PT+GS mode. */
+};

const?

also.. there's no locking visible anywhere in the driver... is this right?

Greetings,
Arjan van de Ven

#2 lore raw
Quoted 9 lines · Arjan van de Ven

drivers/input/mouse/olpc.c line 45

Quoted 6 lines
drivers/input/mouse/olpc.c new file +6 -0
+#undef DEBUG
+#ifdef DEBUG
+#define dbg(format, arg...) printk(KERN_INFO "olpc.c(%d): " format "\n", __LINE__, ## arg)
+#else
+#define dbg(format, arg...) do {} while (0)
+#endif

why not use pr_debug or even dev_debug() ?
Those already have this ifdef included

I was not thinking of them at the time, however dev_dbg is not an option because we do not have a struct device at hand when we want to print some debugging lines.

pr_debug might work, but I would rather have file and line already there.

Though, admittedly, that would be a better argument if it used __FILE__ there instead of hard coding it.

In any case, I don't think any of the debug prints will have to stick around that much longer.

Quoted 7 lines

drivers/input/mouse/olpc.c line 53

Quoted 5 lines
drivers/input/mouse/olpc.c new file +4 -0
+
+static struct olpc_model_info olpc_model_data[] = {
+	{ { 0x67, 0x00, 0x0a }, 0xeb, 0xff, OLPC_PTGS },	/* OLPC in PT+GS mode. */
+};

const?

Added.
(Along with associated changes so that it's kept const everywhere.)

Quoted 3 lines

also.. there's no locking visible anywhere in the driver... is this right?

It looks like psmouse handles it with a mutex lock around freeing stuff and calling the callback function pointers we set on init, so we _should_ be safe unless I've missed something.

Add to it that none of the other psmouse drivers are doing locking on their own, and I'm fairly sure that this is correct. (But if someone knows better, please correct me.)

Thank you.

Zephaniah E. Hull.

Signature · 5 lines
	  1024D/E65A7801 Zephaniah E. Hull <[email protected]>
	   92ED 94E4 B1E6 3624 226D  5727 4453 008B E65A 7801
	    CCs of replies from mailing lists are requested.

Mike Sphar (Scary Devil Monastery):
Quoted 10 lines

I am hired because I know what I am doing, not because I will do whatever I am told is a good idea. This might cost me bonuses, raises, promotions, and may even label me as "undesirable" by places I don't want to work at anyway, but I don't care. I will not compromise my own principles and judgement without putting up a fight. Of course, I won't always win, and I will sometimes be forced to do things I don't agree with, but if I am my objections will be known, and if I am shown to be right and problems later develop, I will shout "I told you so!" repeatedly, laugh hysterically, and do a small dance or jig as appropriate to my heritage.

#3 lore raw
Quoted 4 lines · Zephaniah E. Hull
Quoted 3 lines

also.. there's no locking visible anywhere in the driver... is this right?

Quoted 8 lines

It looks like psmouse handles it with a mutex lock around freeing stuff and calling the callback function pointers we set on init, so we _should_ be safe unless I've missed something.

Add to it that none of the other psmouse drivers are doing locking on their own, and I'm fairly sure that this is correct. (But if someone knows better, please correct me.)

Serio and psmouse cores should handle all necessary locking, no worries here.

Signature · 1 line
Dmitry
#4 lore raw
In reply to Zephaniah E. Hull
Quoted 11 lines · Zephaniah E. Hull
Quoted 9 lines · Arjan van de Ven

drivers/input/mouse/olpc.c line 45

Quoted 6 lines
drivers/input/mouse/olpc.c new file +6 -0
+#undef DEBUG
+#ifdef DEBUG
+#define dbg(format, arg...) printk(KERN_INFO "olpc.c(%d): " format "\n", __LINE__, ## arg)
+#else
+#define dbg(format, arg...) do {} while (0)
+#endif

why not use pr_debug or even dev_debug() ?
Those already have this ifdef included

Quoted 3 lines

I was not thinking of them at the time, however dev_dbg is not an option because we do not have a struct device at hand when we want to print some debugging lines.

Then use it for the majority of the places where you do have it, and do pr_debug() when you do not.

Quoted 5 lines

pr_debug might work, but I would rather have file and line already there.

Though, admittedly, that would be a better argument if it used __FILE__ there instead of hard coding it.

__FILE__ will return you a full path, which is what I do not think you want...

thanks,

greg k-h

#5 lore raw
In reply to Zephaniah E. Hull
Quoted 20 lines · --- "Zephaniah E. Hull

That said, here the patch is for comments.
(And possibly for the OLPC kernel tree for others with samples to play
with.)

drivers/input/mouse/Makefile +0 -1
index 21a1de6..6218e5a 100644
@@ -14,4 +14,4 @@ obj-$(CONFIG_MOUSE_SERIAL)	+= sermouse.o
 obj-$(CONFIG_MOUSE_HIL)		+= hil_ptr.o
 obj-$(CONFIG_MOUSE_VSXXXAA)	+= vsxxxaa.o
 
-psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o
Quoted 3 lines

lifebook.o trackpoint.o
+psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o olpc.o

Where is KConfigurable entry ?

Quoted 18 lines
drivers/input/mouse/olpc.c new file +10 -0
new file mode 100644
index 0000000..245f29e
@@ -0,0 +1,327 @@
 
 
+/*
+ * OLPC touchpad PS/2 mouse driver
+ *
+int olpc_init(struct psmouse *psmouse)
+{
+	struct olpc_data *priv;
+	struct input_dev *dev = psmouse->dev;
+	struct input_dev *dev2;
+
+	psmouse->private = priv = kzalloc(sizeof(struct olpc_data),
Quoted 1 line

GFP_KERNEL);

I think you should assign priv to private only if !NULL.

Quoted 32 lines
drivers/input/mouse/olpc.c new file +24 -0
+	dev2 = input_allocate_device();
+	if (!priv || !dev2)
+		goto init_fail;
+
+	priv->dev2 = dev2;
+
+	if (!(priv->i = olpc_get_model(psmouse)))
+		goto init_fail;
+
+	if (olpc_absolute_mode(psmouse)) {
+		printk(KERN_ERR "olpc.c: Failed to enable absolute mode\n");
+		goto init_fail;
+	}
+
+	dev->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
+	dev->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+	dev->keybit[LONG(BTN_TOOL_PEN)] |= BIT(BTN_TOOL_PEN);
+	dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT);
+
+	dev->evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
+	input_set_abs_params(dev, ABS_X, 0, 1023, 0, 0);
+	input_set_abs_params(dev, ABS_Y, 0, 1023, 0, 0);
+
+	snprintf(priv->phys, sizeof(priv->phys), "%s/input1",

psmouse->ps2dev.serio->phys);

drivers/input/mouse/olpc.c new file +7 -0
+	dev2->phys = priv->phys;
+	dev2->name = "OLPC OLPC GlideSensor";
+	dev2->id.bustype = BUS_I8042;
+	dev2->id.vendor  = 0x0002;
+	dev2->id.product = PSMOUSE_OLPC;
+	dev2->id.version = 0x0000;
+

drivers/input/mouse/olpc.c line 293

Quoted 10 lines
drivers/input/mouse/olpc.c new file +10 -0
+	dev2->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
+	dev2->evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
+	input_set_abs_params(dev2, ABS_X, 0, 2047, 0, 0);
+	input_set_abs_params(dev2, ABS_Y, 0, 1023, 0, 0);
+	input_set_abs_params(dev2, ABS_PRESSURE, 0, 63, 0, 0);
+	dev2->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+	dev2->keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER);
+	dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT);
+
+	input_register_device(priv->dev2);

Please check the return value of input_register_device and its friends.

Quoted 10 lines
drivers/input/mouse/olpc.c new file +9 -0
+
+
+	psmouse->protocol_handler = olpc_process_byte;
+	psmouse->poll = olpc_poll;
+	psmouse->disconnect = olpc_disconnect;
+	psmouse->reconnect = olpc_reconnect;
+	psmouse->pktsize = 9;
+
+	/* We are having trouble resyncing OLPC touchpads so disable it for

now */

drivers/input/mouse/olpc.c line 312

Quoted 10 lines
drivers/input/mouse/olpc.c new file +10 -0
+	psmouse->resync_time = 0;
+
+	return 0;
+
+init_fail:
+	input_free_device(dev2);
+	kfree(priv);
+	return -1;
+}
+

---Komal Shah
http://komalshah.blogspot.com/

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#6 lore raw
Quoted 21 lines · Komal Shah
Quoted 19 lines · --- "Zephaniah E. Hull

That said, here the patch is for comments.
(And possibly for the OLPC kernel tree for others with samples to play
with.)

drivers/input/mouse/Makefile +0 -0
index 21a1de6..6218e5a 100644
@@ -14,4 +14,4 @@ obj-$(CONFIG_MOUSE_SERIAL)	+= sermouse.o
 obj-$(CONFIG_MOUSE_HIL)		+= hil_ptr.o
 obj-$(CONFIG_MOUSE_VSXXXAA)	+= vsxxxaa.o
 
Quoted 6 lines
Quoted 4 lines
drivers/input/mouse/Makefile +0 -1
-psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o

lifebook.o trackpoint.o
+psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o olpc.o

Where is KConfigurable entry ?

It is a component of psmouse.o, which is a few lines up.

Breaking out the components of psmouse.o into separate configuration items might be interesting, but it is quite a bit beyond the scope of this patch.

Quoted 9 lines
Quoted 7 lines
drivers/input/mouse/olpc.c new file +0 -0
new file mode 100644
index 0000000..245f29e
@@ -0,0 +1,327 @@
Quoted 13 lines
Quoted 11 lines
drivers/input/mouse/olpc.c new file +10 -0
+/*
+ * OLPC touchpad PS/2 mouse driver
+ *
+int olpc_init(struct psmouse *psmouse)
+{
+	struct olpc_data *priv;
+	struct input_dev *dev = psmouse->dev;
+	struct input_dev *dev2;
+
+	psmouse->private = priv = kzalloc(sizeof(struct olpc_data),

GFP_KERNEL);

I think you should assign priv to private only if !NULL.

Fixed.

It should not actually matter, as a failure to get a !NULL value causes us to return false, which will fall over to other psmouse drivers which will either set it themselves, or not use it at all, however.

It should be noted that alps.c contains the same issue.

Quoted 3 lines

drivers/input/mouse/olpc.c line 293

Quoted 1 line
drivers/input/mouse/olpc.c new file +1 -0
+	input_register_device(priv->dev2);

Please check the return value of input_register_device and its friends.

Alright, added to my todo, should have it done by the next patch revision.

Thank you very much.
Zephaniah E. Hull.

Signature · 6 lines
	  1024D/E65A7801 Zephaniah E. Hull <[email protected]>
	   92ED 94E4 B1E6 3624 226D  5727 4453 008B E65A 7801
	    CCs of replies from mailing lists are requested.

"And now, little kittens, we're going to run across red-hot
motherboards, with our bare feet." -- Buzh.
maintainer
#7 lore raw
Quoted 10 lines · Zephaniah E. Hull
Quoted 8 lines · Komal Shah
Quoted 5 lines · --- "Zephaniah E. Hull

-psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o
+psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o olpc.o

Where is KConfigurable entry ?

Quoted 5 lines

It is a component of psmouse.o, which is a few lines up.

Breaking out the components of psmouse.o into separate configuration items might be interesting, but it is quite a bit beyond the scope of this patch.

Is there a chance that this device will be used on generally-available hardware? If not then having Kconfig sub-option would be nice.

Quoted 23 lines
Quoted 9 lines
Quoted 7 lines
drivers/input/mouse/olpc.c new file +0 -0
new file mode 100644
index 0000000..245f29e
@@ -0,0 +1,327 @@
Quoted 13 lines
Quoted 11 lines
drivers/input/mouse/olpc.c new file +10 -0
+/*
+ * OLPC touchpad PS/2 mouse driver
+ *
+int olpc_init(struct psmouse *psmouse)
+{
+   struct olpc_data *priv;
+   struct input_dev *dev = psmouse->dev;
+   struct input_dev *dev2;
+
+   psmouse->private = priv = kzalloc(sizeof(struct olpc_data),

GFP_KERNEL);

I think you should assign priv to private only if !NULL.

Quoted 8 lines

Fixed.

It should not actually matter, as a failure to get a !NULL value causes us to return false, which will fall over to other psmouse drivers which will either set it themselves, or not use it at all, however.

It should be noted that alps.c contains the same issue.

I do not consider this is an issue. priv is just a shortcut or alias for psmouse->private that saves some typing and allows the compiled to generate better code.

Signature · 1 line
Dmitry
#8 lore raw
In reply to Zephaniah E. Hull
Quoted 20 lines · --- "Zephaniah E. Hull

That said, here the patch is for comments.
(And possibly for the OLPC kernel tree for others with samples to play
with.)

drivers/input/mouse/Makefile +0 -1
index 21a1de6..6218e5a 100644
@@ -14,4 +14,4 @@ obj-$(CONFIG_MOUSE_SERIAL)	+= sermouse.o
 obj-$(CONFIG_MOUSE_HIL)		+= hil_ptr.o
 obj-$(CONFIG_MOUSE_VSXXXAA)	+= vsxxxaa.o
 
-psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o
Quoted 3 lines

lifebook.o trackpoint.o
+psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o olpc.o

Where is KConfigurable entry ?

Quoted 18 lines
drivers/input/mouse/olpc.c new file +10 -0
new file mode 100644
index 0000000..245f29e
@@ -0,0 +1,327 @@
 
 
+/*
+ * OLPC touchpad PS/2 mouse driver
+ *
+int olpc_init(struct psmouse *psmouse)
+{
+	struct olpc_data *priv;
+	struct input_dev *dev = psmouse->dev;
+	struct input_dev *dev2;
+
+	psmouse->private = priv = kzalloc(sizeof(struct olpc_data),
Quoted 1 line

GFP_KERNEL);

I think you should assign priv to private only if !NULL.

Quoted 32 lines
drivers/input/mouse/olpc.c new file +24 -0
+	dev2 = input_allocate_device();
+	if (!priv || !dev2)
+		goto init_fail;
+
+	priv->dev2 = dev2;
+
+	if (!(priv->i = olpc_get_model(psmouse)))
+		goto init_fail;
+
+	if (olpc_absolute_mode(psmouse)) {
+		printk(KERN_ERR "olpc.c: Failed to enable absolute mode\n");
+		goto init_fail;
+	}
+
+	dev->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
+	dev->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+	dev->keybit[LONG(BTN_TOOL_PEN)] |= BIT(BTN_TOOL_PEN);
+	dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT);
+
+	dev->evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
+	input_set_abs_params(dev, ABS_X, 0, 1023, 0, 0);
+	input_set_abs_params(dev, ABS_Y, 0, 1023, 0, 0);
+
+	snprintf(priv->phys, sizeof(priv->phys), "%s/input1",

psmouse->ps2dev.serio->phys);

drivers/input/mouse/olpc.c new file +7 -0
+	dev2->phys = priv->phys;
+	dev2->name = "OLPC OLPC GlideSensor";
+	dev2->id.bustype = BUS_I8042;
+	dev2->id.vendor  = 0x0002;
+	dev2->id.product = PSMOUSE_OLPC;
+	dev2->id.version = 0x0000;
+

drivers/input/mouse/olpc.c line 293

Quoted 10 lines
drivers/input/mouse/olpc.c new file +10 -0
+	dev2->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
+	dev2->evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
+	input_set_abs_params(dev2, ABS_X, 0, 2047, 0, 0);
+	input_set_abs_params(dev2, ABS_Y, 0, 1023, 0, 0);
+	input_set_abs_params(dev2, ABS_PRESSURE, 0, 63, 0, 0);
+	dev2->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+	dev2->keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER);
+	dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT);
+
+	input_register_device(priv->dev2);

Please check the return value of input_register_device and its friends.

Quoted 10 lines
drivers/input/mouse/olpc.c new file +9 -0
+
+
+	psmouse->protocol_handler = olpc_process_byte;
+	psmouse->poll = olpc_poll;
+	psmouse->disconnect = olpc_disconnect;
+	psmouse->reconnect = olpc_reconnect;
+	psmouse->pktsize = 9;
+
+	/* We are having trouble resyncing OLPC touchpads so disable it for

now */

drivers/input/mouse/olpc.c line 312

Quoted 10 lines
drivers/input/mouse/olpc.c new file +10 -0
+	psmouse->resync_time = 0;
+
+	return 0;
+
+init_fail:
+	input_free_device(dev2);
+	kfree(priv);
+	return -1;
+}
+

---Komal Shah
http://komalshah.blogspot.com/

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#9 lore raw
In reply to Zephaniah E. Hull

Hi,

Quoted 4 lines · Zephaniah E. Hull

The OLPC will ship with a somewhat unique input device made by ALPS, connected via PS/2 and speaking a protocol only loosely based on that spoken by other ALPS devices.

Do you have a formal programming spec for it?

Quoted 5 lines

This is required by the noticeable different between this device and others made by alps, specificly that it is very wide, with the center 1/3rd usable with the GS sensor, and the entire area usable with the PT sensor, with support for using both at once.

Coudl youp please tell me what GS and PT stand for?

Quoted 8 lines

The protocol differs enough that I split the driver for this off from the ALPS driver.

The patch is below, but there are a few things of note.

1: Cosmetic: Some line lengths, and outputs with debugging enabled, are over 80 columns wide. Will be fixed in the next version of this patch.

If going to 80 colums will require monstrocities like this:

... do_bla(struct_b->

              array_g[
              index_i].
              submember);

(and I seen quite a few such attempts to "improve" code) then please don't ;)

Quoted 2 lines

2: Cosmetic: Input device IDs need to be decided on, some feedback on the best values to use here would be appreciated.

I think what you've done is fine.

Quoted 5 lines

3: Patch stuff: Because the protocol uses 9 byte packets I had to increase the size of the buffer in struct psmouse. Should this be split off into a separate patch?

No.

Quoted 5 lines

4: Technical/policy: Buttons are currently sent to both of the input devices we generate, I don't see any way to avoid this that is not a policy decision on which buttons belong to which device, but I'm open to suggestions.

Is it not known how actual hardware wired?

Quoted 6 lines

5: Technical: Min/max on absolute values are currently reported as the protocol limits (10 bits on GS X, GS Y, and PT Y. 11 bits on PT X. 7 bits on GS pressure). Until we get samples based on the newer design and do some testing to see how big the variations are, we just don't have any numbers to put here.

Using protocol limits is fine, I don't think anyone actually uses it. Synaptics X driver allows users to tweak it to their preference.

Quoted 69 lines

6: Technical, maybe: The early samples I have that speak this protocol are doing some odd things with this driver. Mostly in the realm of sample rate and pressure reporting. I'm fairly sure that this is hardware related, but it's worth mentioning.

That said, here the patch is for comments.
(And possibly for the OLPC kernel tree for others with samples to play with.)

drivers/input/mouse/Makefile +1 -1
index 21a1de6..6218e5a 100644
@@ -14,4 +14,4 @@ obj-$(CONFIG_MOUSE_SERIAL)    += sermouse.o
 obj-$(CONFIG_MOUSE_HIL)                += hil_ptr.o
 obj-$(CONFIG_MOUSE_VSXXXAA)    += vsxxxaa.o
 
-psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o
+psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o olpc.o
drivers/input/mouse/olpc.c new file +40 -0
new file mode 100644
index 0000000..245f29e
@@ -0,0 +1,327 @@
+/*
+ * OLPC touchpad PS/2 mouse driver
+ *
+ * Copyright (c) 2006 One Laptop Per Child, inc.
+ * Author Zephaniah E. Hull.
+ *
+ * This driver is partly based on the ALPS driver, which is:
+ *
+ * Copyright (c) 2003 Neil Brown <[email protected]>
+ * Copyright (c) 2003-2005 Peter Osterlund <[email protected]>
+ * Copyright (c) 2004 Dmitry Torokhov <[email protected]>
+ * Copyright (c) 2005 Vojtech Pavlik <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * The touchpad on the OLPC is fairly wide, with the entire area usable
+ * as a tablet, and the center 1/3rd also usable as a touchpad.
+ *
+ * The device has simultanious reporting, so that both can be used at once.
+ *
+ * The PT+GS protocol is similar to the base ALPS protocol, in that the
+ * GS data is where the ALPS parser would expect to find it, however
+ * there are several additional bytes, the button bits are in a
+ * different byte, and the bits used for finger and gesture indication
+ * are replaced by two bits which indicate if it is reporting PT or GS
+ * coordinate data in that packet.
+ */
+
+#include <linux/input.h>
+#include <linux/serio.h>
+#include <linux/libps2.h>
+
+#include "psmouse.h"
+#include "olpc.h"
+
+#undef DEBUG

drivers/input/mouse/olpc.c line 50

Quoted 10 lines
drivers/input/mouse/olpc.c new file +10 -0
+#ifdef DEBUG
+#define dbg(format, arg...) printk(KERN_INFO "olpc.c(%d): " format "\n", __LINE__, ## arg)
+#else
+#define dbg(format, arg...) do {} while (0)
+#endif
+
+#define OLPC_PT                0x01
+#define OLPC_GS                0x02
+#define OLPC_PTGS      0x04
+

Do you need a separate #define? I'd expect it to be OLPC_PT | OLPC_GS?

Quoted 158 lines
drivers/input/mouse/olpc.c new file +158 -0
+static struct olpc_model_info olpc_model_data[] = {
+       { { 0x67, 0x00, 0x0a }, 0xeb, 0xff, OLPC_PTGS },        /* OLPC in PT+GS mode. */
+};
+
+/*
+ * OLPC absolute Mode - new format
+ *
+ * byte 0:  1    ?    ?    ?    1    ?    ?    ?
+ * byte 1:  0   x6   x5   x4   x3   x2   x1   x0
+ * byte 2:  0   x10  x9   x8   x7    ?  fin  ges
+ * byte 3:  0   y9   y8   y7    1    0    R    L
+ * byte 4:  0   y6   y5   y4   y3   y2   y1   y0
+ * byte 5:  0   z6   z5   z4   z3   z2   z1   z0
+ *
+ * ?'s can have different meanings on different models,
+ * such as wheel rotation, extra buttons, stick buttons
+ * on a dualpoint, etc.
+ */
+
+static void olpc_process_packet(struct psmouse *psmouse, struct pt_regs *regs)
+{
+       struct olpc_data *priv = psmouse->private;
+       unsigned char *packet = psmouse->packet;
+       struct input_dev *dev = psmouse->dev;
+       struct input_dev *dev2 = priv->dev2;
+       int px, py, gx, gy, gz, gs_down, pt_down, left, right;
+
+       input_regs(dev, regs);
+
+       left = packet[6] & 1;
+       right = packet[6] & 2;
+       gx = packet[1] | ((packet[2] & 0x78) << (7 - 3));
+       gy = packet[4] | ((packet[3] & 0x70) << (7 - 4));
+       gz = packet[5];
+       px = packet[8] | ((packet[2] & 0x7) << 7);
+       py = packet[7] | ((packet[6] & 0x70) << (7 - 4));
+
+       pt_down = packet[3] & 1;
+       gs_down = packet[3] & 2;
+
+       input_report_key(dev, BTN_LEFT, left);
+       input_report_key(dev2, BTN_LEFT, left);
+       input_report_key(dev, BTN_RIGHT, right);
+       input_report_key(dev2, BTN_RIGHT, right);
+
+       input_report_key(dev, BTN_TOUCH, pt_down);
+       input_report_key(dev, BTN_TOOL_PEN, pt_down);
+       input_report_key(dev2, BTN_TOUCH, gs_down);
+       input_report_key(dev2, BTN_TOOL_FINGER, gs_down);
+
+       if (gs_down) {
+               input_report_abs(dev2, ABS_X, gx);
+               input_report_abs(dev2, ABS_Y, gy);
+       }
+       input_report_abs(dev2, ABS_PRESSURE, gz);
+
+       if (pt_down) {
+               input_report_abs(dev, ABS_X, px);
+               input_report_abs(dev, ABS_Y, py);
+       }
+
+       input_sync(dev);
+}
+
+static psmouse_ret_t olpc_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
+{
+       struct olpc_data *priv = psmouse->private;
+       psmouse_ret_t ret = PSMOUSE_BAD_DATA;
+
+       if ((psmouse->packet[0] & priv->i->mask0) != priv->i->byte0) {
+               ret = PSMOUSE_BAD_DATA;
+               goto out;
+       }
+
+       /* Bytes 2 - 6 should have 0 in the highest bit */
+       if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 9 &&
+               (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
+           ret = PSMOUSE_BAD_DATA;
+           goto out;
+       }
+
+       if ((psmouse->pktcnt == 4 || psmouse->pktcnt == 7) &&
+               ((psmouse->packet[psmouse->pktcnt - 1] & 0x88) != 8)) {
+           ret = PSMOUSE_BAD_DATA;
+           goto out;
+       }
+
+       if (psmouse->pktcnt == 9) {
+           olpc_process_packet(psmouse, regs);
+
+           ret = PSMOUSE_FULL_PACKET;
+           goto out;
+       }
+
+       ret = PSMOUSE_GOOD_DATA;
+out:
+       if (ret != PSMOUSE_GOOD_DATA)
+               dbg("ret: %d, len: %u, data: %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x", ret, psmouse->pktcnt,
+                       psmouse->packet[0], psmouse->packet[1], psmouse->packet[2],
+                       psmouse->packet[3], psmouse->packet[4], psmouse->packet[5],
+                       psmouse->packet[6], psmouse->packet[7], psmouse->packet[8]);
+       return ret;
+}
+
+static struct olpc_model_info *olpc_get_model(struct psmouse *psmouse)
+{
+       struct ps2dev *ps2dev = &psmouse->ps2dev;
+       unsigned char param[4];
+       int i;
+
+       /*
+        * Now try "E7 report". Allowed responses are in
+        * olpc_model_data[].signature
+        */
+       if (ps2_command(ps2dev,  NULL, PSMOUSE_CMD_SETSCALE21) ||
+           ps2_command(ps2dev,  NULL, PSMOUSE_CMD_SETSCALE21) ||
+           ps2_command(ps2dev,  NULL, PSMOUSE_CMD_SETSCALE21))
+               return NULL;
+
+       param[0] = param[1] = param[2] = 0xff;
+       if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
+               return NULL;
+
+       dbg("E7 report: %2.2x %2.2x %2.2x", param[0], param[1], param[2]);
+
+       for (i = 0; i < ARRAY_SIZE(olpc_model_data); i++)
+               if (!memcmp(param, olpc_model_data[i].signature, sizeof(olpc_model_data[i].signature)))
+                       return olpc_model_data + i;
+
+       return NULL;
+}
+
+static int olpc_absolute_mode(struct psmouse *psmouse)
+{
+       struct ps2dev *ps2dev = &psmouse->ps2dev;
+       unsigned char param;
+
+       /* Switch to 'Advanced mode.', four disables in a row. */
+       if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
+           ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
+           ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
+           ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE))
+               return -1;
+
+       /*
+        * Switch to simultanious mode, F2 (GETID) three times with no
+        * arguments or reply, followed by SETRES with an argument of 2.
+        */
+       ps2_command(ps2dev, NULL, 0xF2);
+       ps2_command(ps2dev, NULL, 0xF2);
+       ps2_command(ps2dev, NULL, 0xF2);
+       param = 0x02;
+       ps2_command(ps2dev, &param, PSMOUSE_CMD_SETRES);
+
+       return 0;
+}
+
+/*

drivers/input/mouse/olpc.c line 218

Quoted 10 lines
drivers/input/mouse/olpc.c new file +10 -0
+ * olpc_poll() - poll the touchpad for current motion packet.
+ * Used in resync.
+ */
+static int olpc_poll(struct psmouse *psmouse)
+{
+       /*
+        * FIXME: We can't poll, find a way to make resync work better.
+        */
+       return 0;
+}

I'd expect it to return -1. It's OK that it can't poll, it looks like it should resync fairly well on its own.

Quoted 50 lines
drivers/input/mouse/olpc.c new file +50 -0
+
+static int olpc_reconnect(struct psmouse *psmouse)
+{
+       struct olpc_data *priv = psmouse->private;
+
+       psmouse_reset(psmouse);
+
+       if (!(priv->i = olpc_get_model(psmouse)))
+               return -1;
+
+       if (olpc_absolute_mode(psmouse)) {
+               printk(KERN_ERR "olpc.c: Failed to reenable absolute mode\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static void olpc_disconnect(struct psmouse *psmouse)
+{
+       struct olpc_data *priv = psmouse->private;
+
+       psmouse_reset(psmouse);
+       input_unregister_device(priv->dev2);
+       kfree(priv);
+}
+
+int olpc_init(struct psmouse *psmouse)
+{
+       struct olpc_data *priv;
+       struct input_dev *dev = psmouse->dev;
+       struct input_dev *dev2;
+
+       psmouse->private = priv = kzalloc(sizeof(struct olpc_data), GFP_KERNEL);
+       dev2 = input_allocate_device();
+       if (!priv || !dev2)
+               goto init_fail;
+
+       priv->dev2 = dev2;
+
+       if (!(priv->i = olpc_get_model(psmouse)))
+               goto init_fail;
+
+       if (olpc_absolute_mode(psmouse)) {
+               printk(KERN_ERR "olpc.c: Failed to enable absolute mode\n");
+               goto init_fail;
+       }
+
+       dev->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
+       dev->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);

drivers/input/mouse/olpc.c line 278

Quoted 10 lines
drivers/input/mouse/olpc.c new file +10 -0
+       dev->keybit[LONG(BTN_TOOL_PEN)] |= BIT(BTN_TOOL_PEN);
+       dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT);
+
+       dev->evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
+       input_set_abs_params(dev, ABS_X, 0, 1023, 0, 0);
+       input_set_abs_params(dev, ABS_Y, 0, 1023, 0, 0);
+
+       snprintf(priv->phys, sizeof(priv->phys), "%s/input1", psmouse->ps2dev.serio->phys);
+       dev2->phys = priv->phys;
+       dev2->name = "OLPC OLPC GlideSensor";

"OLPC OLPC"?

Quoted 78 lines
drivers/input/mouse/olpc.c new file +49 -0
+       dev2->id.bustype = BUS_I8042;
+       dev2->id.vendor  = 0x0002;
+       dev2->id.product = PSMOUSE_OLPC;
+       dev2->id.version = 0x0000;
+
+       dev2->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
+       dev2->evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
+       input_set_abs_params(dev2, ABS_X, 0, 2047, 0, 0);
+       input_set_abs_params(dev2, ABS_Y, 0, 1023, 0, 0);
+       input_set_abs_params(dev2, ABS_PRESSURE, 0, 63, 0, 0);
+       dev2->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+       dev2->keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER);
+       dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT);
+
+       input_register_device(priv->dev2);
+
+
+       psmouse->protocol_handler = olpc_process_byte;
+       psmouse->poll = olpc_poll;
+       psmouse->disconnect = olpc_disconnect;
+       psmouse->reconnect = olpc_reconnect;
+       psmouse->pktsize = 9;
+
+       /* We are having trouble resyncing OLPC touchpads so disable it for now */
+       psmouse->resync_time = 0;
+
+       return 0;
+
+init_fail:
+       input_free_device(dev2);
+       kfree(priv);
+       return -1;
+}
+
+int olpc_detect(struct psmouse *psmouse, int set_properties)
+{
+       struct olpc_model_info *model;
+
+       if (!(model = olpc_get_model(psmouse)))
+               return -1;
+
+       if (set_properties) {
+               psmouse->vendor = "OLPC";
+               psmouse->name = "PenTablet";
+               psmouse->model = 0;
+       }
+       return 0;
+}
+
drivers/input/mouse/olpc.h new file +23 -0
new file mode 100644
index 0000000..49f4e3e
@@ -0,0 +1,37 @@
+/*
+ * OLPC touchpad PS/2 mouse driver
+ *
+ * Copyright (c) 2006 One Laptop Per Child, inc.
+ *
+ * This driver is partly based on the ALPS driver.
+ * Copyright (c) 2003 Peter Osterlund <[email protected]>
+ * Copyright (c) 2005 Vojtech Pavlik <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#ifndef _OLPC_H
+#define _OLPC_H
+
+int olpc_detect(struct psmouse *psmouse, int set_properties);
+int olpc_init(struct psmouse *psmouse);
+
+struct olpc_model_info {
+        unsigned char signature[3];
+        unsigned char byte0, mask0;

drivers/input/mouse/olpc.h line 33

Quoted 10 lines
drivers/input/mouse/olpc.h new file +10 -0
+        unsigned char flags;
+};
+
+struct olpc_data {
+       struct input_dev *dev2;         /* Relative device */
+       char name[32];                  /* Name */
+       char phys[32];                  /* Phys */
+       struct olpc_model_info *i;      /* Info */
+       int prev_fin_pt;                /* Finger bit from previous packet */
+       int prev_fin_gs;                /* Finger bit from previous packet */

Bad (duplicate) comment?

Quoted 83 lines
drivers/input/mouse/olpc.h new file +4 -0
+};
+
+
+#endif
drivers/input/mouse/psmouse-base.c +17 -0
index 8bc9f51..20060b0 100644
@@ -26,6 +26,7 @@
 #include "synaptics.h"
 #include "logips2pp.h"
 #include "alps.h"
+#include "olpc.h"
 #include "lifebook.h"
 #include "trackpoint.h"
 
@@ -616,6 +617,15 @@ static int psmouse_extensions(struct psm
 */
                       max_proto = PSMOUSE_IMEX;
               }
+               ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
+               if (olpc_detect(psmouse, set_properties) == 0) {
+                       if (!set_properties || olpc_init(psmouse) == 0)
+                               return PSMOUSE_OLPC;
+/*
+ * Init failed, try basic relative protocols
+ */
+                       max_proto = PSMOUSE_IMEX;
+               }
       }
 
       if (max_proto > PSMOUSE_IMEX && genius_detect(psmouse, set_properties) == 0)
@@ -726,6 +736,13 @@ static struct psmouse_protocol psmouse_p
               .detect         = trackpoint_detect,
       },
       {
+               .type           = PSMOUSE_OLPC,
+               .name           = "OLPC",
+               .alias          = "olpc",
+               .maxproto       = 1,
+               .detect         = olpc_detect,
+       },
+       {
               .type           = PSMOUSE_AUTO,
               .name           = "auto",
               .alias          = "any",
drivers/input/mouse/psmouse.h +2 -3
index 4d9107f..f3d7199 100644
@@ -42,7 +42,7 @@ struct psmouse {
       struct work_struct resync_work;
       char *vendor;
       char *name;
-       unsigned char packet[8];
+       unsigned char packet[9];
       unsigned char badbyte;
       unsigned char pktcnt;
       unsigned char pktsize;
@@ -86,6 +86,7 @@ enum psmouse_type {
       PSMOUSE_ALPS,
       PSMOUSE_LIFEBOOK,
       PSMOUSE_TRACKPOINT,
+       PSMOUSE_OLPC,
       PSMOUSE_AUTO            /* This one should always be last */
 };
 
--
         1024D/E65A7801 Zephaniah E. Hull <[email protected]>
          92ED 94E4 B1E6 3624 226D  5727 4453 008B E65A 7801
           CCs of replies from mailing lists are requested.
 
 
-----BEGIN PGP SIGNATURE-----

Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFE8+3TRFMAi+ZaeAERAhiNAJ4t4uF3q9G+bdsGUAYDafNearwMUgCeN0kl se5meohSaoJEMhbRsrxtIOo=
=Vd5o
-----END PGP SIGNATURE-----

Signature · 1 line
Dmitry
#10 lore raw
Quoted 9 lines · Dmitry Torokhov

Hi,

Quoted 4 lines · Zephaniah E. Hull

The OLPC will ship with a somewhat unique input device made by ALPS, connected via PS/2 and speaking a protocol only loosely based on that spoken by other ALPS devices.

Do you have a formal programming spec for it?

Not that I can currently distribute.

Converting to html, trimming out hardware detail, and feeding it through channels for ALPS to say that they are comfortable with the amount of data being released is on my todo list, but behind a few other things.

Quoted 8 lines
Quoted 6 lines

This is required by the noticeable different between this device and others made by alps, specificly that it is very wide, with the center 1/3rd usable with the GS sensor, and the entire area usable with the PT sensor, with support for using both at once.

Coudl youp please tell me what GS and PT stand for?

Glide Sensor, and PenTablet.

Quoted 12 lines
Quoted 9 lines

The protocol differs enough that I split the driver for this off from the ALPS driver.

The patch is below, but there are a few things of note.

1: Cosmetic: Some line lengths, and outputs with debugging enabled, are over 80 columns wide. Will be fixed in the next version of this patch.

If going to 80 colums will require monstrocities like this:

Quoted 7 lines

... do_bla(struct_b->

              array_g[
              index_i].
              submember);

(and I seen quite a few such attempts to "improve" code) then please don't ;)

Understood. :)

Quoted 14 lines
Quoted 3 lines

2: Cosmetic: Input device IDs need to be decided on, some feedback on the best values to use here would be appreciated.

I think what you've done is fine.

Quoted 5 lines

3: Patch stuff: Because the protocol uses 9 byte packets I had to increase the size of the buffer in struct psmouse. Should this be split off into a separate patch?

No.

Quoted 7 lines
Quoted 5 lines

4: Technical/policy: Buttons are currently sent to both of the input devices we generate, I don't see any way to avoid this that is not a policy decision on which buttons belong to which device, but I'm open to suggestions.

Is it not known how actual hardware wired?

Hardware is wired with one device, which is quite wide. The entire width can be accessed via the PT sensor, and the middle 1/3rd with the GS sensor.

I believe that the buttons will be one on each side, though I'm not positive, and the PT data, the GS data, and the button data all arrive in the same packet.

So really there is no 'right' way from the kernel driver's point of view, the buttons belong equally to both.

The kernel driver that this will be matched with will probably leave it as a user configuration setting as to which one it will throw button presses away for.

Quoted 6 lines

drivers/input/mouse/olpc.c line 50

Quoted 4 lines
drivers/input/mouse/olpc.c new file +4 -0
+#define OLPC_PT                0x01
+#define OLPC_GS                0x02
+#define OLPC_PTGS      0x04
+

Do you need a separate #define? I'd expect it to be OLPC_PT | OLPC_GS?

Actually it's going away, as the driver is simply not going to try to handle PT or GS mode separate from PT+GS, after more thought there was little to gain from it.

Quoted 6 lines
Quoted 6 lines
drivers/input/mouse/olpc.c new file +6 -0
+/*
+ * olpc_poll() - poll the touchpad for current motion packet.
+ * Used in resync.
+ */
+static int olpc_poll(struct psmouse *psmouse)
+{
Quoted 8 lines

drivers/input/mouse/olpc.c line 218

Quoted 5 lines
drivers/input/mouse/olpc.c new file +5 -0
+       /*
+        * FIXME: We can't poll, find a way to make resync work better.
+        */
+       return 0;
+}

I'd expect it to return -1. It's OK that it can't poll, it looks like it should resync fairly well on its own.

Alright, I'll give that a try.

Quoted 3 lines
Quoted 1 line

+ dev2->name = "OLPC OLPC GlideSensor";

"OLPC OLPC"?

To match the first one, with a protocol name of OLPC and a vendor of OLPC we end up with 'OLPC OLPC' for the first one, this is, IMHO, rather suboptimal, but I'm not sure what else to do here.

Suggestions are most welcome. :)

Thanks a ton for the review.
Zephaniah E. Hull.

Signature · 11 lines
	  1024D/E65A7801 Zephaniah E. Hull <[email protected]>
	   92ED 94E4 B1E6 3624 226D  5727 4453 008B E65A 7801
	    CCs of replies from mailing lists are requested.

I could imagine that there might be some GPL project out there that
_deserves_ getting sued(*) and it has nothing to do with Linux.

                Linus

(*) "GNU Emacs, the defendent, did inefariously conspire to play
towers-of-hanoy, while under the guise of a harmless editor".
maintainer
#11 lore raw
Quoted 9 lines · Zephaniah E. Hull
Quoted 8 lines · Dmitry Torokhov

Hi,

Quoted 4 lines · Zephaniah E. Hull

The OLPC will ship with a somewhat unique input device made by ALPS, connected via PS/2 and speaking a protocol only loosely based on that spoken by other ALPS devices.

Quoted 7 lines
Quoted 1 line

Do you have a formal programming spec for it?

Not that I can currently distribute.

Converting to html, trimming out hardware detail, and feeding it through channels for ALPS to say that they are comfortable with the amount of data being released is on my todo list, but behind a few other things.

I see. Well, if you have a decent contacts in ALPS could you ask them if they could release any information on their other hardware?

Quoted 17 lines
Quoted 8 lines
Quoted 6 lines

4: Technical/policy: Buttons are currently sent to both of the input devices we generate, I don't see any way to avoid this that is not a policy decision on which buttons belong to which device, but I'm open to suggestions.

Is it not known how actual hardware wired?

Hardware is wired with one device, which is quite wide. The entire width can be accessed via the PT sensor, and the middle 1/3rd with the GS sensor.

I believe that the buttons will be one on each side, though I'm not positive, and the PT data, the GS data, and the button data all arrive in the same packet.

Quoted 6 lines

So really there is no 'right' way from the kernel driver's point of view, the buttons belong equally to both.

The kernel driver that this will be matched with will probably leave it as a user configuration setting as to which one it will throw button presses away for.

OK.

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

+ dev2->name = "OLPC OLPC GlideSensor";

"OLPC OLPC"?

To match the first one, with a protocol name of OLPC and a vendor of OLPC we end up with 'OLPC OLPC' for the first one, this is, IMHO, rather suboptimal, but I'm not sure what else to do here.

Should not vendor be still ALPS?

Signature · 1 line
Dmitry
#12 lore raw

RFC 1/1 OLPC tablet input driver, take two.

In reply to Zephaniah E. Hull

Take two, with most of the items people commented about addressed.

The OLPC will ship with a somewhat unique input device made by ALPS, connected via PS/2 and speaking a protocol only loosely based on that spoken by other ALPS devices.

This is required by the noticeable different between this device and others made by alps, specificly that it is very wide, with the center 1/3rd usable with the GS sensor, and the entire area usable with the PT sensor, with support for using both at once.

It uses a 9 byte protocol that differs enough that I split the driver for this off from the ALPS driver.

The patch is below, but there are a few things of note.

1: Cosmetic: Some line lengths, and outputs with debugging enabled, are over 80 columns wide. I've fixed most of them, but it would just get into ugly stuff to fix the last few remaining. Suggestions are always welcome though.

2: Technical, maybe: We're seeing a very low sample rate, however we're fairly sure that this is due to the clock on our hardware, should be verified sometime tomorrow. It is doubtful that any changes to this driver will be necessary.

3: Technical: At least the pressure range is a lot smaller then we are reporting, leaving as is until others weigh in on if we need ALPS to give a larger range.

4: Technical: I've not implemented the KCONFIG option for this driver yet, it's on my todo list, but for after we get the sample rate stuff figured out.

That said, here the patch is for comments.
(And possibly for the OLPC kernel tree for others with samples to play with.)

Zephaniah E. Hull.

drivers/input/mouse/Makefile +1 -1
index 21a1de6..6218e5a 100644
@@ -14,4 +14,4 @@ obj-$(CONFIG_MOUSE_SERIAL)	+= sermouse.o
 obj-$(CONFIG_MOUSE_HIL)		+= hil_ptr.o
 obj-$(CONFIG_MOUSE_VSXXXAA)	+= vsxxxaa.o
 
-psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o
+psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o olpc.o
drivers/input/mouse/olpc.c new file +344 -0

344 lines not on this page · raw message

drivers/input/mouse/olpc.h new file +35 -0
new file mode 100644
index 0000000..8ed2e96
@@ -0,0 +1,35 @@
+/*
+ * OLPC touchpad PS/2 mouse driver
+ *
+ * Copyright (c) 2006 One Laptop Per Child, inc.
+ *
+ * This driver is partly based on the ALPS driver.
+ * Copyright (c) 2003 Peter Osterlund <[email protected]>
+ * Copyright (c) 2005 Vojtech Pavlik <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#ifndef _OLPC_H
+#define _OLPC_H
+
+int olpc_detect(struct psmouse *psmouse, int set_properties);
+int olpc_init(struct psmouse *psmouse);
+
+struct olpc_model_info {
+        unsigned char signature[3];
+        unsigned char byte0, mask0;
+        unsigned char flags;
+};
+
+struct olpc_data {
+	struct input_dev *dev2;		/* Relative device */
+	char name[32];			/* Name */
+	char phys[32];			/* Phys */
+	const struct olpc_model_info *i;/* Info */
+};
+
+
+#endif
drivers/input/mouse/psmouse-base.c +17 -0
index 8bc9f51..20060b0 100644
@@ -26,6 +26,7 @@
 #include "synaptics.h"
 #include "logips2pp.h"
 #include "alps.h"
+#include "olpc.h"
 #include "lifebook.h"
 #include "trackpoint.h"
 
@@ -616,6 +617,15 @@ static int psmouse_extensions(struct psm
  */
 			max_proto = PSMOUSE_IMEX;
 		}
+		ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
+		if (olpc_detect(psmouse, set_properties) == 0) {
+			if (!set_properties || olpc_init(psmouse) == 0)
+				return PSMOUSE_OLPC;
+/*
+ * Init failed, try basic relative protocols
+ */
+			max_proto = PSMOUSE_IMEX;
+		}
 	}
 
 	if (max_proto > PSMOUSE_IMEX && genius_detect(psmouse, set_properties) == 0)
@@ -726,6 +736,13 @@ static struct psmouse_protocol psmouse_p
 		.detect		= trackpoint_detect,
 	},
 	{
+		.type		= PSMOUSE_OLPC,
+		.name		= "OLPC",
+		.alias		= "olpc",
+		.maxproto	= 1,
+		.detect		= olpc_detect,
+	},
+	{
 		.type		= PSMOUSE_AUTO,
 		.name		= "auto",
 		.alias		= "any",
drivers/input/mouse/psmouse.h +2 -1
index 4d9107f..f3d7199 100644
@@ -42,7 +42,7 @@ struct psmouse {
 	struct work_struct resync_work;
 	char *vendor;
 	char *name;
-	unsigned char packet[8];
+	unsigned char packet[9];
 	unsigned char badbyte;
 	unsigned char pktcnt;
 	unsigned char pktsize;
@@ -86,6 +86,7 @@ enum psmouse_type {
 	PSMOUSE_ALPS,
 	PSMOUSE_LIFEBOOK,
 	PSMOUSE_TRACKPOINT,
+	PSMOUSE_OLPC,
 	PSMOUSE_AUTO		/* This one should always be last */
 };
 
Signature · 10 lines
	  1024D/E65A7801 Zephaniah E. Hull <[email protected]>
	   92ED 94E4 B1E6 3624 226D  5727 4453 008B E65A 7801
	    CCs of replies from mailing lists are requested.

     "First they came for the Jews, and I didn't speak out - because I
was not a jew. Then they came for the Communists, and I did not speak
out - because I was not a Communist. Then they came for the trade
unionists, and I did not speak out - because I was not a trade unionist.
Then they came for me and there was no one left to speak for me!"
  - Pastor Niemoeller - victim of Hitler's Nazis
#13 lore raw

Re: [RFC] OLPC tablet input driver, take two.

Quoted 2 lines · Zephaniah E. Hull

Take two, with most of the items people commented about addressed.

Hi Zephaniah,

I have couple more comments/requests:

Quoted 4 lines
drivers/input/mouse/olpc.c new file +3 -0
+
+	if (gs_down) {
+		input_report_abs(dev2, ABS_X, gx);

drivers/input/mouse/olpc.c line 110

Quoted 10 lines
drivers/input/mouse/olpc.c new file +10 -0
+		input_report_abs(dev2, ABS_Y, gy);
+	}
+	input_report_abs(dev2, ABS_PRESSURE, gz);
+
+	if (pt_down) {
+		input_report_abs(dev, ABS_X, px);
+		input_report_abs(dev, ABS_Y, py);
+	}
+
+	input_sync(dev);

Please add input_sync(dev2);

drivers/input/mouse/olpc.c line 119

Quoted 9 lines
drivers/input/mouse/olpc.c new file +9 -0
+}
+
+static psmouse_ret_t olpc_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
+{
+	struct olpc_data *priv = psmouse->private;
+	psmouse_ret_t ret = PSMOUSE_BAD_DATA;
+
+	if ((psmouse->packet[0] & priv->i->mask0) != priv->i->byte0) {
+		ret = PSMOUSE_BAD_DATA;

It looks like you can kill "ret = PSMOUSE_BAD_DATA" assignments since you initialize ret with it.

drivers/input/mouse/olpc.c line 128

Quoted 9 lines
drivers/input/mouse/olpc.c new file +9 -0
+		goto out;
+	}
+
+	/* Bytes 2 - 9 should have 0 in the highest bit */
+	if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 9 &&
+		(psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
+	    ret = PSMOUSE_BAD_DATA;
+	    goto out;
+	}

I'd like to have standard identation throughout the driver (and input sybsystem in general).

drivers/input/mouse/olpc.h line 25

Quoted 12 lines
drivers/input/mouse/olpc.h new file +12 -0
+
+#ifndef _OLPC_H
+#define _OLPC_H
+
+int olpc_detect(struct psmouse *psmouse, int set_properties);
+int olpc_init(struct psmouse *psmouse);
+
+struct olpc_model_info {
+        unsigned char signature[3];
+        unsigned char byte0, mask0;
+        unsigned char flags;
+};

Hard TABs for identation please.

Quoted 23 lines
drivers/input/mouse/olpc.h new file +10 -0
+
+struct olpc_data {
+	struct input_dev *dev2;		/* Relative device */
+	char name[32];			/* Name */
+	char phys[32];			/* Phys */
+	const struct olpc_model_info *i;/* Info */
+};
+
+
+#endif
drivers/input/mouse/psmouse-base.c +1 -0
index 8bc9f51..20060b0 100644
@@ -26,6 +26,7 @@
 #include "synaptics.h"
 #include "logips2pp.h"
 #include "alps.h"
+#include "olpc.h"
 #include "lifebook.h"
 #include "trackpoint.h"
 

drivers/input/mouse/psmouse-base.c static int psmouse_extensions(struct psm · line 620

Quoted 4 lines
drivers/input/mouse/psmouse-base.c +1 -0
@@ -616,6 +617,15 @@ static int psmouse_extensions(struct psm
  */
 			max_proto = PSMOUSE_IMEX;
 		}
+		ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);

Do we have to do 2nd reset here? Plus logic seems a bit fuzzy here - if ALPS is detected but initizliztion fails it will start OLPC detection which is probably not what you wanted...

Quoted 12 lines
drivers/input/mouse/psmouse-base.c +8 -0
+		if (olpc_detect(psmouse, set_properties) == 0) {
+			if (!set_properties || olpc_init(psmouse) == 0)
+				return PSMOUSE_OLPC;
+/*
+ * Init failed, try basic relative protocols
+ */
+			max_proto = PSMOUSE_IMEX;
+		}
 	}
 
 	if (max_proto > PSMOUSE_IMEX && genius_detect(psmouse, set_properties) == 0)

drivers/input/mouse/psmouse-base.c static struct psmouse_protocol psmouse_p · line 742

Quoted 7 lines
drivers/input/mouse/psmouse-base.c +4 -0
@@ -726,6 +736,13 @@ static struct psmouse_protocol psmouse_p
 		.detect		= trackpoint_detect,
 	},
 	{
+		.type		= PSMOUSE_OLPC,
+		.name		= "OLPC",
+		.alias		= "olpc",
+		.maxproto	= 1,

Do not set maxproto on speciality protocols. It is meant to limit highest version of standard protocols to be probed/used by a device.

Signature · 1 line
Dmitry
#14 lore raw

Re: [RFC] OLPC tablet input driver, take two.

Quoted 9 lines · Dmitry Torokhov
Quoted 2 lines · Zephaniah E. Hull

Take two, with most of the items people commented about addressed.

Hi Zephaniah,

I have couple more comments/requests:

Quoted 1 line
Quoted 15 lines

drivers/input/mouse/olpc.c line 110

Quoted 13 lines
drivers/input/mouse/olpc.c new file +13 -0
+
+	if (gs_down) {
+		input_report_abs(dev2, ABS_X, gx);
+		input_report_abs(dev2, ABS_Y, gy);
+	}
+	input_report_abs(dev2, ABS_PRESSURE, gz);
+
+	if (pt_down) {
+		input_report_abs(dev, ABS_X, px);
+		input_report_abs(dev, ABS_Y, py);
+	}
+
+	input_sync(dev);

Please add input_sync(dev2);

Whoops, bizarrely it still worked, but fixed.

Quoted 13 lines

drivers/input/mouse/olpc.c line 119

Quoted 10 lines
drivers/input/mouse/olpc.c new file +9 -0
+}
+
+static psmouse_ret_t olpc_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
+{
+	struct olpc_data *priv = psmouse->private;
+	psmouse_ret_t ret = PSMOUSE_BAD_DATA;
+
+	if ((psmouse->packet[0] & priv->i->mask0) != priv->i->byte0) {
+		ret = PSMOUSE_BAD_DATA;

It looks like you can kill "ret = PSMOUSE_BAD_DATA" assignments since you initialize ret with it.

Done.

Quoted 13 lines

drivers/input/mouse/olpc.c line 128

Quoted 10 lines
drivers/input/mouse/olpc.c new file +9 -0
+		goto out;
+	}
+
+	/* Bytes 2 - 9 should have 0 in the highest bit */
+	if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 9 &&
+		(psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
+	    ret = PSMOUSE_BAD_DATA;
+	    goto out;
+	}

I'd like to have standard identation throughout the driver (and input sybsystem in general).

Whoops, fixed.

Quoted 15 lines

drivers/input/mouse/olpc.h line 25

Quoted 13 lines
drivers/input/mouse/olpc.h new file +12 -0
+
+#ifndef _OLPC_H
+#define _OLPC_H
+
+int olpc_detect(struct psmouse *psmouse, int set_properties);
+int olpc_init(struct psmouse *psmouse);
+
+struct olpc_model_info {
+        unsigned char signature[3];
+        unsigned char byte0, mask0;
+        unsigned char flags;
+};

Hard TABs for identation please.

Done.

Quoted 23 lines
Quoted 23 lines
drivers/input/mouse/olpc.h new file +10 -0
+
+struct olpc_data {
+	struct input_dev *dev2;		/* Relative device */
+	char name[32];			/* Name */
+	char phys[32];			/* Phys */
+	const struct olpc_model_info *i;/* Info */
+};
+
+
+#endif
drivers/input/mouse/psmouse-base.c +1 -0
index 8bc9f51..20060b0 100644
@@ -26,6 +26,7 @@
 #include "synaptics.h"
 #include "logips2pp.h"
 #include "alps.h"
+#include "olpc.h"
 #include "lifebook.h"
 #include "trackpoint.h"
 
Quoted 9 lines

drivers/input/mouse/psmouse-base.c static int psmouse_extensions(struct psm · line 620

Quoted 5 lines
drivers/input/mouse/psmouse-base.c +1 -0
@@ -616,6 +617,15 @@ static int psmouse_extensions(struct psm
  */
 			max_proto = PSMOUSE_IMEX;
 		}
+		ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);

Do we have to do 2nd reset here? Plus logic seems a bit fuzzy here - if ALPS is detected but initizliztion fails it will start OLPC detection which is probably not what you wanted...

Reset is _probably_ not necessary, I'll verify.

However the logic is the same as for all the others, if init succeeds, it returns PSMOUSE_ALPS, if it doesn't then it continues on to the next, which happens to be olpc, admittedly it would be more obvious that it's doing the same thing if it was in its own if, but.

Quoted 11 lines
Quoted 11 lines
drivers/input/mouse/psmouse-base.c +8 -0
+		if (olpc_detect(psmouse, set_properties) == 0) {
+			if (!set_properties || olpc_init(psmouse) == 0)
+				return PSMOUSE_OLPC;
+/*
+ * Init failed, try basic relative protocols
+ */
+			max_proto = PSMOUSE_IMEX;
+		}
 	}
 
Quoted 12 lines

drivers/input/mouse/psmouse-base.c static struct psmouse_protocol psmouse_p · line 742

Quoted 9 lines
drivers/input/mouse/psmouse-base.c +4 -0
 	if (max_proto > PSMOUSE_IMEX && genius_detect(psmouse, set_properties) == 0)
@@ -726,6 +736,13 @@ static struct psmouse_protocol psmouse_p
 		.detect		= trackpoint_detect,
 	},
 	{
+		.type		= PSMOUSE_OLPC,
+		.name		= "OLPC",
+		.alias		= "olpc",
+		.maxproto	= 1,

Do not set maxproto on speciality protocols. It is meant to limit highest version of standard protocols to be probed/used by a device.

Fixed.

Thanks a ton, I have some extra testing to do and then I'll send out a fixed copy.

Zephaniah E. Hull.

Quoted 4 lines
Signature · 2 lines
-- 
Dmitry
Signature · 6 lines
	  1024D/E65A7801 Zephaniah E. Hull <[email protected]>
	   92ED 94E4 B1E6 3624 226D  5727 4453 008B E65A 7801
	    CCs of replies from mailing lists are requested.

"I am ecstatic that some moron re-invented a 1995 windows fuckup."
        -- Alan Cox
#15 lore raw

Re: [RFC] OLPC tablet input driver, take two.

Quoted 12 lines · Zephaniah E. Hull
Quoted 10 lines · Dmitry Torokhov

drivers/input/mouse/psmouse-base.c static int psmouse_extensions(struct psm · line 620

Quoted 6 lines
drivers/input/mouse/psmouse-base.c +1 -0
@@ -616,6 +617,15 @@ static int psmouse_extensions(struct psm
  */
                    max_proto = PSMOUSE_IMEX;
            }
+           ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);

Do we have to do 2nd reset here? Plus logic seems a bit fuzzy here - if ALPS is detected but initizliztion fails it will start OLPC detection which is probably not what you wanted...

Quoted 6 lines

Reset is _probably_ not necessary, I'll verify.

However the logic is the same as for all the others, if init succeeds, it returns PSMOUSE_ALPS, if it doesn't then it continues on to the next, which happens to be olpc, admittedly it would be more obvious that it's doing the same thing if it was in its own if, but.

Not exactly. We have 2 types of protocols - some have only detect, others have both detect and init. For protocols that have both detect and init we expect detect to reliably identify whether the device is of given type or not and once detect succeeds we do not try to probe for other speciality protocols. For example if alps_detect succeeds but alps_init fails we won't try Genius detection (we will only try standard imex, exps and bare) and we should not try OLPC detection either.

Signature · 1 line
Dmitry
#16 lore raw

Re: [RFC] OLPC tablet input driver, take two.

Quoted 20 lines · Dmitry Torokhov
Quoted 12 lines · Zephaniah E. Hull
Quoted 10 lines · Dmitry Torokhov

drivers/input/mouse/psmouse-base.c static int psmouse_extensions(struct psm · line 620

Quoted 6 lines
drivers/input/mouse/psmouse-base.c +1 -0
@@ -616,6 +617,15 @@ static int psmouse_extensions(struct psm
  */
                    max_proto = PSMOUSE_IMEX;
            }
+           ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);

Do we have to do 2nd reset here? Plus logic seems a bit fuzzy here - if ALPS is detected but initizliztion fails it will start OLPC detection which is probably not what you wanted...

Quoted 6 lines

Reset is _probably_ not necessary, I'll verify.

However the logic is the same as for all the others, if init succeeds, it returns PSMOUSE_ALPS, if it doesn't then it continues on to the next, which happens to be olpc, admittedly it would be more obvious that it's doing the same thing if it was in its own if, but.

Quoted 8 lines

Not exactly. We have 2 types of protocols - some have only detect, others have both detect and init. For protocols that have both detect and init we expect detect to reliably identify whether the device is of given type or not and once detect succeeds we do not try to probe for other speciality protocols. For example if alps_detect succeeds but alps_init fails we won't try Genius detection (we will only try standard imex, exps and bare) and we should not try OLPC detection either.

Ah, I had misread the if. Corrected in the patch that just went out.

Thank you.
Zephaniah E. Hull.

Quoted 4 lines
Signature · 2 lines
-- 
Dmitry
Signature · 7 lines
	  1024D/E65A7801 Zephaniah E. Hull <[email protected]>
	   92ED 94E4 B1E6 3624 226D  5727 4453 008B E65A 7801
	    CCs of replies from mailing lists are requested.

"This system operates under martial law. The constitution is suspended. You
 have no rights except as declared by the area commander. Violators will be
  shot. Repeat violators will be repeatedly shot...."       -from "A_W_O_L"
#17 lore raw

RFC 1/1 OLPC tablet input driver, take three.

In reply to Zephaniah E. Hull

Take three, with most of the items people commented about addressed.

The OLPC will ship with a somewhat unique input device made by ALPS, connected via PS/2 and speaking a protocol only loosely based on that spoken by other ALPS devices.

This is required by the noticeable different between this device and others made by alps, specificly that it is very wide, with the center 1/3rd usable with the GS sensor, and the entire area usable with the PT sensor, with support for using both at once.

It uses a 9 byte protocol that differs enough that I split the driver for this off from the ALPS driver.

The patch is below, but there are a few things of note.

1: Cosmetic: Some line lengths, and outputs with debugging enabled, are over 80 columns wide. I've fixed most of them, but it would just get into ugly stuff to fix the last few remaining. Suggestions are always welcome though.

2: Technical, maybe: We're seeing a very low sample rate, however we're fairly sure that this is due to the clock on our hardware, should be verified sometime tomorrow. It is doubtful that any changes to this driver will be necessary.

3: Technical: At least the pressure range is a lot smaller then we are reporting, leaving as is until others weigh in on if we need ALPS to give a larger range.

4: Technical: I've not implemented the KCONFIG option for this driver yet, it's on my todo list, but for after we get the sample rate stuff figured out.

That said, here the patch, it seems to work, and it's time to at least get into the OLPC kernel tree, if not mainline.

Zephaniah E. Hull.

drivers/input/mouse/Makefile +1 -1
index 21a1de6..6218e5a 100644
@@ -14,4 +14,4 @@ obj-$(CONFIG_MOUSE_SERIAL)	+= sermouse.o
 obj-$(CONFIG_MOUSE_HIL)		+= hil_ptr.o
 obj-$(CONFIG_MOUSE_VSXXXAA)	+= vsxxxaa.o
 
-psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o
+psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o olpc.o
drivers/input/mouse/olpc.c new file +339 -0

339 lines not on this page · raw message

drivers/input/mouse/olpc.h new file +35 -0
new file mode 100644
index 0000000..f61bc90
@@ -0,0 +1,35 @@
+/*
+ * OLPC touchpad PS/2 mouse driver
+ *
+ * Copyright (c) 2006 One Laptop Per Child, inc.
+ *
+ * This driver is partly based on the ALPS driver.
+ * Copyright (c) 2003 Peter Osterlund <[email protected]>
+ * Copyright (c) 2005 Vojtech Pavlik <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#ifndef _OLPC_H
+#define _OLPC_H
+
+int olpc_detect(struct psmouse *psmouse, int set_properties);
+int olpc_init(struct psmouse *psmouse);
+
+struct olpc_model_info {
+	unsigned char signature[3];
+	unsigned char byte0, mask0;
+	unsigned char flags;
+};
+
+struct olpc_data {
+	struct input_dev *dev2;		/* Relative device */
+	char name[32];			/* Name */
+	char phys[32];			/* Phys */
+	const struct olpc_model_info *i;/* Info */
+};
+
+
+#endif
drivers/input/mouse/psmouse-base.c +21 -0
index 8bc9f51..30edbe7 100644
@@ -26,6 +26,7 @@
 #include "synaptics.h"
 #include "logips2pp.h"
 #include "alps.h"
+#include "olpc.h"
 #include "lifebook.h"
 #include "trackpoint.h"
 
@@ -618,6 +619,20 @@ static int psmouse_extensions(struct psm
 		}
 	}
 
+/*
+ * Try OLPC touchpad.
+ */
+	if (max_proto > PSMOUSE_IMEX) {
+		if (olpc_detect(psmouse, set_properties) == 0) {
+			if (!set_properties || olpc_init(psmouse) == 0)
+				return PSMOUSE_OLPC;
+/*
+ * Init failed, try basic relative protocols
+ */
+			max_proto = PSMOUSE_IMEX;
+		}
+	}
+
 	if (max_proto > PSMOUSE_IMEX && genius_detect(psmouse, set_properties) == 0)
 		return PSMOUSE_GENPS;
 
@@ -726,6 +741,12 @@ static struct psmouse_protocol psmouse_p
 		.detect		= trackpoint_detect,
 	},
 	{
+		.type		= PSMOUSE_OLPC,
+		.name		= "OLPC",
+		.alias		= "olpc",
+		.detect		= olpc_detect,
+	},
+	{
 		.type		= PSMOUSE_AUTO,
 		.name		= "auto",
 		.alias		= "any",
drivers/input/mouse/psmouse.h +2 -1
index 4d9107f..f3d7199 100644
@@ -42,7 +42,7 @@ struct psmouse {
 	struct work_struct resync_work;
 	char *vendor;
 	char *name;
-	unsigned char packet[8];
+	unsigned char packet[9];
 	unsigned char badbyte;
 	unsigned char pktcnt;
 	unsigned char pktsize;
@@ -86,6 +86,7 @@ enum psmouse_type {
 	PSMOUSE_ALPS,
 	PSMOUSE_LIFEBOOK,
 	PSMOUSE_TRACKPOINT,
+	PSMOUSE_OLPC,
 	PSMOUSE_AUTO		/* This one should always be last */
 };
 
Signature · 7 lines
	  1024D/E65A7801 Zephaniah E. Hull <[email protected]>
	   92ED 94E4 B1E6 3624 226D  5727 4453 008B E65A 7801
	    CCs of replies from mailing lists are requested.

<nonlinear> .net is microsofts perverted version of a java networked
             environment uglified for windows-specific crap
	-- nonlinear in #opengl
#18 lore raw

Re: [RFC] OLPC tablet input driver, take three.

Quoted 9 lines · Zephaniah E. Hull

4: Technical: I've not implemented the KCONFIG option for this driver yet, it's on my todo list, but for after we get the sample rate stuff figured out.

That said, here the patch, it seems to work, and it's time to at least get into the OLPC kernel tree, if not mainline.

Zephaniah,

What are the chances that commodity hardware will have OLPC device present? If there are none (or extremely slim) I think we'd better wait for Kconfig option to be implemented before adding this to mainline because psmouse is already too fat.

Otherwise it looks good.

Signature · 1 line
Dmitry
#19 lore raw

Re: [RFC] OLPC tablet input driver, take three.

Quoted 11 lines · Dmitry Torokhov
Quoted 9 lines · Zephaniah E. Hull

4: Technical: I've not implemented the KCONFIG option for this driver yet, it's on my todo list, but for after we get the sample rate stuff figured out.

That said, here the patch, it seems to work, and it's time to at least get into the OLPC kernel tree, if not mainline.

Quoted 6 lines

Zephaniah,

What are the chances that commodity hardware will have OLPC device present? If there are none (or extremely slim) I think we'd better wait for Kconfig option to be implemented before adding this to mainline because psmouse is already too fat.

Extremely slim, the current generation of samples are 3.3V units instead of 5V units.

When I go in and do this, would it make sense to split out most of the external to psmouse-base.c drivers to be options, most tied to being on unless CONFIG_EMBEDDED is enabled?

Zephaniah E. Hull.

Quoted 11 lines

Otherwise it looks good.

Signature · 6 lines
Dmitry
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Signature · 8 lines
	  1024D/E65A7801 Zephaniah E. Hull <[email protected]>
	   92ED 94E4 B1E6 3624 226D  5727 4453 008B E65A 7801
	    CCs of replies from mailing lists are requested.

"I would rather spend 10 hours reading someone else's source code than
10 minutes listening to Musak waiting for technical support which
isn't."
(By Dr. Greg Wettstein, Roger Maris Cancer Center)
#20 lore raw

Re: [RFC] OLPC tablet input driver, take three.

Quoted 19 lines · Zephaniah E. Hull
Quoted 11 lines · Dmitry Torokhov
Quoted 9 lines · Zephaniah E. Hull

4: Technical: I've not implemented the KCONFIG option for this driver yet, it's on my todo list, but for after we get the sample rate stuff figured out.

That said, here the patch, it seems to work, and it's time to at least get into the OLPC kernel tree, if not mainline.

Quoted 6 lines

Zephaniah,

What are the chances that commodity hardware will have OLPC device present? If there are none (or extremely slim) I think we'd better wait for Kconfig option to be implemented before adding this to mainline because psmouse is already too fat.

Quoted 7 lines

Extremely slim, the current generation of samples are 3.3V units instead of 5V units.

When I go in and do this, would it make sense to split out most of the external to psmouse-base.c drivers to be options, most tied to being on unless CONFIG_EMBEDDED is enabled?

Yes, that would be nice. Just keep in mind that we need to detect synaptics touchpads even if driver support is disabled so that we can properly reset them if they don't support imex or exps protocols. Otherwise the trackpoint connected to the pass-through port stops working.

Signature · 1 line
Dmitry
#21 lore raw
In reply to Zephaniah E. Hull
Quoted 4 lines · Zephaniah E. Hull

4: Technical/policy: Buttons are currently sent to both of the input devices we generate, I don't see any way to avoid this that is not a policy decision on which buttons belong to which device, but I'm open to suggestions.

I would put them on the touchpad device. This way you create a regular looking touchpad and a regular looking tablet, and the user experience will probably be best.

If you report them both, the GUI will get doubled click events (either through /dev/input/mice or through the event X drivers), which can result in doubleclicks where there were none when the click event is very short.

So reporting on both is a bad idea.

Quoted 5 lines

5: Technical: Min/max on absolute values are currently reported as the protocol limits (10 bits on GS X, GS Y, and PT Y. 11 bits on PT X. 7 bits on GS pressure). Until we get samples based on the newer design and do some testing to see how big the variations are, we just don't have any numbers to put here.

No big deal, they're informative only. However, they're defined as the expected min/max of what the device will report, so updating them when you get the actual hardware running makes sense.

Quoted 4 lines

6: Technical, maybe: The early samples I have that speak this protocol are doing some odd things with this driver. Mostly in the realm of sample rate and pressure reporting. I'm fairly sure that this is hardware related, but it's worth mentioning.

I would expect the sample rate to be somewhat limited by the fact that the packets are very large and the serial communication will not be able to keep up.

drivers/input/mouse/olpc.c line 278

Quoted 3 lines
drivers/input/mouse/olpc.c new file +3 -0
+	snprintf(priv->phys, sizeof(priv->phys), "%s/input1", psmouse->ps2dev.serio->phys);
+	dev2->phys = priv->phys;
+	dev2->name = "OLPC OLPC GlideSensor";

Why OLPC twice? Weren't you planning to say ALPS OLPC GlideSensor?

Quoted 4 lines
drivers/input/mouse/olpc.c new file +4 -0
+	dev2->id.bustype = BUS_I8042;
+	dev2->id.vendor  = 0x0002;
+	dev2->id.product = PSMOUSE_OLPC;
+	dev2->id.version = 0x0000;
Signature · 2 lines
Vojtech Pavlik
Director SuSE Labs