Skip to contentSkip to conversation

IBM Trackpoint support

PATCH Applied Stephen Evanchik 8 participants 24 messages Feb 3, 2005 – Feb 13, 2005 Input drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IBM Trackpoint support

Vojtech,

Here is a patch that exposes the IBM TrackPoint's extended properties as well as scroll wheel emulation.

I would appreciate comments and suggestions to make this more acceptable.

Stephen

drivers/input/mouse/Makefile +1 -1
diff -uNr a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
@@ -14,4 +14,4 @@
 obj-$(CONFIG_MOUSE_SERIAL)	+= sermouse.o
 obj-$(CONFIG_MOUSE_VSXXXAA)	+= vsxxxaa.o
 
-psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o
+psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o trackpoint.o

diff -uNr a/drivers/input/mouse/psmouse-base.c
b/drivers/input/mouse/psmouse-base.c

drivers/input/mouse/psmouse-base.c +18 -0
@@ -23,6 +23,7 @@
 #include "psmouse.h"
 #include "synaptics.h"
 #include "logips2pp.h"
+#include "trackpoint.h"
 #include "alps.h"
 
 #define DRIVER_DESC	"PS/2 mouse driver"
@@ -119,6 +120,13 @@
 	}
 
 /*
+ * TrackPoint scroll simulation handler if the BTN_MIDDLE is down
+ */
+
+	if(psmouse->model == PSMOUSE_TRACKPOINT)
+		trackpoint_sim_scroll(psmouse);
+
+/*
  * Generic PS/2 Mouse
  */
 
@@ -482,6 +490,16 @@
 		return PSMOUSE_IMPS;
 
 /*
+ * Try to initialize the IBM TrackPoint
+ */
+	if (max_proto > PSMOUSE_PS2 && trackpoint_init(psmouse) == 0) {
+		psmouse->vendor = "IBM";
+		psmouse->name = "TrackPoint";
+ 
+		return PSMOUSE_PS2;
+	}
+
+/*
  * Okay, all failed, we have a standard mouse here. The number of the buttons
  * is still a question, though. We assume 3.
  */
drivers/input/mouse/trackpoint.c +94 -0

94 lines not on this page · raw message

unsigned char *results)
+{
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND));
+ ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 1, loc));
+}
+
+static void trackpoint_write(struct ps2dev *ps2dev, unsigned char loc, unsigned char val)
+{
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND));
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_WRITE_MEM));
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, loc));
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, val));
+}
+
+static int trackpoint_toggle_bit(struct ps2dev *ps2dev, unsigned char loc, unsigned char mask)
+{
+ /* Bad things will happen if the loc param isn't in this range */
+ if(loc < 0x20 || loc >= 0x2F)
+ return -1;
+
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND));
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_TOGGLE));
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, loc));
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, mask));
+
+ return 0;
+}
+
+
+#ifdef CONFIG_PROC_FS
+
+#define PROC_READ_NAME(name) name##_read_func
+#define PROC_WRITE_NAME(name) name##_write_func
+#define PROC_TOGGLE_NAME(name) name##_toggle_func
+
+#define MAKE_PROC_READ(name, item) \
+ static int name(char* page, char** start, off_t off, int count, int*
eof, void* data) \
+ { \
+ int len; \
+ struct psmouse *psmouse = (struct psmouse *)data; \
+ struct trackpoint_data *tp = (struct trackpoint_data*)psmouse->private; \
+ len = sprintf(page, "%lu\n", (unsigned long)tp->item); \
+ *eof = 1; \
+ return len; \
+ }
+
+#define MAKE_PROC_WRITE(name, item, command) \
+ static int name(struct file *file, const char __user *buffer,
unsigned long count, void *data) \
+ { \
+ int len = count; \
+ unsigned char tmp[5]; \
+ struct psmouse *psmouse = (struct psmouse *)data; \
+ struct trackpoint_data *tp = (struct trackpoint_data*)psmouse->private; \
+ if(count > sizeof(tmp) - 1) \
+ len = sizeof(tmp) - 1; \
+ if(copy_from_user(tmp, buffer, len)) \
+ return -EFAULT; \
+ tmp[len] = '\0'; \
+ tp->item = simple_strtoul(tmp, 0, 10); \
+ trackpoint_write(&psmouse->ps2dev, command, tp->item); \
+ return len; \
+ }
+
+#define MAKE_PROC_TOGGLE(name, item, command, mask) \
+ static int name(struct file *file, const char __user *buffer,
unsigned long count, void *data) \
+ { \
+ int len = count; \
+ unsigned char toggle, tmp[5]; \
+ struct psmouse *psmouse = (struct psmouse *)data; \
+ struct trackpoint_data *tp = (struct trackpoint_data*)psmouse->private; \
+ if(count > sizeof(tmp) - 1) \
+ len = sizeof(tmp) - 1; \
+ if(copy_from_user(tmp, buffer, len)) \
+ return -EFAULT; \
+ tmp[len] = '\0'; \
+ toggle = (tmp[0] == '1') ? 1 : 0; \
+ if( toggle != tp->item) { \
+ tp->item = toggle; \
+ trackpoint_toggle_bit(&psmouse->ps2dev, command, mask); \
+ } \
+ return len; \
+ }
+
+
+MAKE_PROC_WRITE(PROC_WRITE_NAME(sensitivity), sens, TP_SENS); +MAKE_PROC_READ(PROC_READ_NAME(sensitivity), sens);
+
+MAKE_PROC_WRITE(PROC_WRITE_NAME(speed), speed, TP_SPEED); +MAKE_PROC_READ(PROC_READ_NAME(speed), speed);
+
+MAKE_PROC_WRITE(PROC_WRITE_NAME(neg_inertia), inertia, TP_INERTIA); +MAKE_PROC_READ(PROC_READ_NAME(neg_inertia), inertia);
+
+MAKE_PROC_WRITE(PROC_WRITE_NAME(backup), reach, TP_REACH); +MAKE_PROC_READ(PROC_READ_NAME(backup), reach);
+
+MAKE_PROC_WRITE(PROC_WRITE_NAME(drag_hyst), draghys, TP_DRAGHYS); +MAKE_PROC_READ(PROC_READ_NAME(drag_hyst), draghys);
+
+MAKE_PROC_WRITE(PROC_WRITE_NAME(min_drag), mindrag, TP_MINDRAG); +MAKE_PROC_READ(PROC_READ_NAME(min_drag), mindrag);
+
+MAKE_PROC_WRITE(PROC_WRITE_NAME(thresh), thresh, TP_THRESH); +MAKE_PROC_READ(PROC_READ_NAME(thresh), thresh);
+
+MAKE_PROC_WRITE(PROC_WRITE_NAME(up_thresh), up_thresh, TP_UP_THRESH); +MAKE_PROC_READ(PROC_READ_NAME(up_thresh), up_thresh);
+
+MAKE_PROC_WRITE(PROC_WRITE_NAME(z_time), z_time, TP_Z_TIME); +MAKE_PROC_READ(PROC_READ_NAME(z_time), z_time);
+
+MAKE_PROC_WRITE(PROC_WRITE_NAME(jenks_curv), jenks_curv, TP_JENKS_CURV); +MAKE_PROC_READ(PROC_READ_NAME(jenks_curv), jenks_curv);
+
+MAKE_PROC_TOGGLE(PROC_TOGGLE_NAME(ptson), ptson, TP_TOGGLE_PTSON, TP_MASK_PTSON);
+MAKE_PROC_READ(PROC_READ_NAME(ptson), ptson);
+
+MAKE_PROC_TOGGLE(PROC_TOGGLE_NAME(skip_back), skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK); +MAKE_PROC_READ(PROC_READ_NAME(skip_back), skipback);
+
+MAKE_PROC_TOGGLE(PROC_TOGGLE_NAME(mb), mb, TP_TOGGLE_MB, TP_MASK_MB); +MAKE_PROC_READ(PROC_READ_NAME(mb), mb);
+
+MAKE_PROC_TOGGLE(PROC_TOGGLE_NAME(ext_dev), ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV); +MAKE_PROC_READ(PROC_READ_NAME(ext_dev), ext_dev);
+
+/* MAKE_PROC_WRITE( ) for Soft Transparent mode */
+static int transparent_write_func(struct file *file, const char __user *buffer, unsigned long count, void *data)
+{
+ int len = count;
+ unsigned char command;
+ unsigned char tmp[5];
+ struct psmouse *psmouse = (struct psmouse *)data;
+ struct trackpoint_data *tp = (struct trackpoint_data*)psmouse->private;
+ if(count > sizeof(tmp) - 1)
+ len = sizeof(tmp) - 1;
+ if(copy_from_user(tmp, buffer, len))
+ return -EFAULT;
+ tmp[len] = '\0'; \
+ tp->transparent = simple_strtoul(tmp, 0, 10);
+ command = (tp->transparent) ? TP_SET_SOFT_TRANS : TP_CANCEL_SOFT_TRANS;
+
+ trackpoint_command(&psmouse->ps2dev, command);
+ return len;
+}
+
+MAKE_PROC_READ(PROC_READ_NAME(transparent), transparent);
+
+/* MAKE_PROC_WRITE( ) for Middle Button Scroll mode */ +static int scroll_write_func(struct file *file, const char __user *buffer, unsigned long count, void *data)
+{
+ int len = count;
+ unsigned char tmp[5];
+ struct psmouse *psmouse = (struct psmouse *)data;
+ struct trackpoint_data *tp = (struct trackpoint_data*)psmouse->private;
+ if(count > sizeof(tmp) - 1)
+ len = sizeof(tmp) - 1;
+ if(copy_from_user(tmp, buffer, len))
+ return -EFAULT;
+ tmp[len] = '\0'; \
+ tp->mb_scroll = simple_strtoul(tmp, 0, 10);
+
+ return len;
+}
+
+MAKE_PROC_READ(PROC_READ_NAME(scroll), mb_scroll);
+
+/* MAKE_PROC_WRITE( ) for delay before scroll */
+static int scroll_delay_write_func(struct file *file, const char __user *buffer, unsigned long count, void *data)
+{

+        int len = count;
+        unsigned char tmp[5];
+        struct psmouse *psmouse = (struct psmouse *)data;
+        struct trackpoint_data *tp = (struct trackpoint_data*)psmouse->private;
+        if(count > sizeof(tmp) - 1)

+ len = sizeof(tmp) - 1;
+ if(copy_from_user(tmp, buffer, len))
+ return -EFAULT;
+ tmp[len] = '\0'; \
+ tp->scroll_delay = simple_strtoul(tmp, 0, 10);
+
+ return len;
+}
+
+MAKE_PROC_READ(PROC_READ_NAME(scroll_delay), scroll_delay); +
+
+
+#define NEW_PROC_ENTRY(name) \
+ entry = create_proc_entry(#name, 0644, tp_dir); \
+ if(!entry) \
+ goto no_##name; \

+        entry->owner = THIS_MODULE; \
+        entry->data = psmouse; \
+        entry->read_proc = PROC_READ_NAME(name); \
+        entry->write_proc = PROC_WRITE_NAME(name);

+
+
+#define NEW_PROC_TOGGLE_ENTRY(name) \
+ entry = create_proc_entry(#name, 0644, tp_dir); \
+ if(!entry) \
+ goto no_##name; \

+        entry->owner = THIS_MODULE; \
+        entry->data = psmouse; \
+        entry->read_proc = PROC_READ_NAME(name); \
+        entry->write_proc = PROC_TOGGLE_NAME(name);

+
+
+
+static struct proc_dir_entry *tp_dir = NULL;
+
+
+static int trackpoint_proc_init(struct psmouse *psmouse) +{
+ struct proc_dir_entry *entry = NULL;
+
+ tp_dir = proc_mkdir("trackpoint", NULL);
+ if(!tp_dir)
+ return -ENOMEM;
+
+ tp_dir->owner = THIS_MODULE;
+
+ NEW_PROC_ENTRY(sensitivity);
+ NEW_PROC_ENTRY(speed);
+ NEW_PROC_ENTRY(neg_inertia);
+ NEW_PROC_ENTRY(backup);
+ NEW_PROC_ENTRY(drag_hyst);
+ NEW_PROC_ENTRY(min_drag);
+ NEW_PROC_ENTRY(thresh);
+ NEW_PROC_ENTRY(up_thresh);
+ NEW_PROC_ENTRY(z_time);
+ NEW_PROC_ENTRY(jenks_curv);
+
+ NEW_PROC_TOGGLE_ENTRY(ptson);
+ NEW_PROC_TOGGLE_ENTRY(skip_back);
+ NEW_PROC_TOGGLE_ENTRY(mb);
+ NEW_PROC_TOGGLE_ENTRY(ext_dev);
+
+ /* Soft Transparent mode isn't a toggle or a single
+ * command used to read/write the value
+ */
+ entry = create_proc_entry("transparent", 0644, tp_dir);
+ if(!entry)
+ goto no_transparent;

+        entry->owner = THIS_MODULE;
+        entry->data = psmouse;
+        entry->read_proc = transparent_read_func;
+        entry->write_proc = transparent_write_func;

+
+ entry = create_proc_entry("scroll", 0644, tp_dir);
+ if(!entry)
+ goto no_scroll;

+        entry->owner = THIS_MODULE;
+        entry->data = psmouse;
+        entry->read_proc = scroll_read_func;
+        entry->write_proc = scroll_write_func;

+
+ entry = create_proc_entry("scroll_delay", 0644, tp_dir);
+ if(!entry)
+ goto no_scroll_delay;

+        entry->owner = THIS_MODULE;
+        entry->data = psmouse;
+        entry->read_proc = scroll_delay_read_func;
+        entry->write_proc = scroll_delay_write_func;

+
+ return 0;
+
+no_scroll_delay:
+ remove_proc_entry("scroll_delay", tp_dir);
+
+no_scroll:
+ remove_proc_entry("transparent", tp_dir);
+
+no_transparent:
+ remove_proc_entry("ext_dev", tp_dir);
+
+no_ext_dev:
+ remove_proc_entry("mb", tp_dir);
+
+no_mb:
+ remove_proc_entry("skip_back", tp_dir);
+
+no_skip_back:
+ remove_proc_entry("ptson", tp_dir);
+
+no_ptson:
+ remove_proc_entry("jenks_curv", tp_dir);
+
+no_jenks_curv:
+ remove_proc_entry("z_time", tp_dir);
+
+no_z_time:
+ remove_proc_entry("up_thresh", tp_dir);
+
+no_up_thresh:
+ remove_proc_entry("thresh", tp_dir);
+
+no_thresh:
+ remove_proc_entry("min_drag", tp_dir);
+
+no_min_drag:
+ remove_proc_entry("drag_hyst", tp_dir);
+
+no_drag_hyst:
+ remove_proc_entry("backup", tp_dir);
+
+no_backup:
+ remove_proc_entry("neg_inertia", tp_dir);
+
+no_neg_inertia:
+ remove_proc_entry("speed", tp_dir);
+
+no_speed:
+ remove_proc_entry("sensitivity", tp_dir);
+
+no_sensitivity:
+ remove_proc_entry("trackpoint", NULL);
+
+ return -ENOMEM;
+}
+
+static void trackpoint_proc_remove(void)
+{

+        remove_proc_entry("scroll_delay", tp_dir);
+        remove_proc_entry("scroll", tp_dir);
+        remove_proc_entry("transparent", tp_dir);
+        remove_proc_entry("ext_dev", tp_dir);
+        remove_proc_entry("mb", tp_dir);
+        remove_proc_entry("skip_back", tp_dir);
+        remove_proc_entry("ptson", tp_dir);
+        remove_proc_entry("jenks_curv", tp_dir);
+        remove_proc_entry("z_time", tp_dir);
+        remove_proc_entry("up_thresh", tp_dir);
+        remove_proc_entry("thresh", tp_dir);
+        remove_proc_entry("min_drag", tp_dir);
+        remove_proc_entry("drag_hyst", tp_dir);
+        remove_proc_entry("backup", tp_dir);
+        remove_proc_entry("neg_inertia", tp_dir);
+        remove_proc_entry("speed", tp_dir);
+        remove_proc_entry("sensitivity", tp_dir);
+        remove_proc_entry("trackpoint", NULL);

+}
+
+#else
+static int trackpoint_proc_init(struct psmouse *psmouse) { return 0; } +static void trackpoint_proc_remove(void) { }
+#endif
+
+
+/* This is much cleaner now, it probably could be better.
+ * The only thing left here is to make the scroll feature more gradual.
+ */
+
+void trackpoint_sim_scroll(struct psmouse *psmouse)
+{
+ int diff;
+ struct trackpoint_data *tp = psmouse->private;
+ unsigned char *packet = psmouse->packet;
+
+ if(!tp->mb_scroll)
+ return;
+
+ if( ((packet[0] >> 2) & 1) == 0 ) {
+
+ if(tp->mb_was_down &&
+ time_after(tp->last_mb_press +
msecs_to_jiffies(tp->scroll_delay), jiffies)) {
+
+ /* This doesn't seem to get processed until the next
+ * mouse move.
+ */
+ input_report_key(&psmouse->dev, BTN_MIDDLE, 1);
+
+ input_sync(&psmouse->dev);
+ }
+
+ tp->scrolling = 0;
+ tp->mb_was_down = 0;
+ }
+ else if(tp->scrolling) {
+
+ /* Vertical scrolling */
+ diff = (int) ((packet[0] << 3) & 0x100) - (int) packet[2];
+ if( diff < -2 ) {
+ input_report_rel(&psmouse->dev, REL_WHEEL, 1);
+ }
+ else if(diff > 2) {
+ input_report_rel(&psmouse->dev, REL_WHEEL, -1);
+ }
+

+                /* Horizontal scrolling */
+                diff = (int) packet[1] - (int) ((packet[0] << 4) & 0x100);
+                if( diff < -2) {

+ input_report_rel(&psmouse->dev, REL_HWHEEL, 1);
+ }
+ else if( diff > 2) {
+ input_report_rel(&psmouse->dev, REL_HWHEEL, -1);
+ }
+
+ packet[1] &= 0x00;
+ packet[2] &= 0x00;
+ }
+ else {
+ /* Middle button is down, but we aren't scrolling */
+ if( time_after_eq(jiffies, tp->last_mb_press +
msecs_to_jiffies(tp->scroll_delay)) )
+ tp->scrolling = 1;
+
+ tp->last_mb_press = jiffies;
+ tp->mb_was_down = 1;
+ }
+
+ /* Suppress the key event from entering the queue */
+ packet[0] &= 0xFB;
+}
+
+void trackpoint_disconnect(struct psmouse *psmouse) +{
+ trackpoint_proc_remove();
+ kfree(psmouse->private);
+}
+
+int trackpoint_reconnect(struct psmouse *psmouse) +{
+ unsigned char toggle;
+ struct trackpoint_data *tp = psmouse->private;
+
+ /* Push the config to the device */
+
+ trackpoint_write(&psmouse->ps2dev, TP_SENS, tp->sens);
+ trackpoint_write(&psmouse->ps2dev, TP_INERTIA, tp->inertia);
+ trackpoint_write(&psmouse->ps2dev, TP_SPEED, tp->speed);
+
+ trackpoint_write(&psmouse->ps2dev, TP_REACH, tp->reach);
+ trackpoint_write(&psmouse->ps2dev, TP_DRAGHYS, tp->draghys);
+ trackpoint_write(&psmouse->ps2dev, TP_MINDRAG, tp->mindrag);
+
+ trackpoint_write(&psmouse->ps2dev, TP_THRESH, tp->thresh);
+ trackpoint_write(&psmouse->ps2dev, TP_UP_THRESH, tp->up_thresh);
+
+ trackpoint_write(&psmouse->ps2dev, TP_Z_TIME, tp->z_time);
+ trackpoint_write(&psmouse->ps2dev, TP_JENKS_CURV, tp->jenks_curv);
+
+
+ trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_PTSON, &toggle);
+ if(((toggle & TP_MASK_PTSON) == TP_MASK_PTSON)!= tp->ptson)
+ trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_PTSON, TP_MASK_PTSON);
+
+ trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_MB, &toggle);
+ if(((toggle & TP_MASK_MB) == TP_MASK_MB) != tp->mb)
+ trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_MB, TP_MASK_MB);
+
+ trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, &toggle);
+ if(((toggle & TP_MASK_TWOHAND) == TP_MASK_TWOHAND) != tp->twohand)
+ trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, TP_MASK_TWOHAND);
+
+ trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_SKIPBACK, &toggle);
+ if(((toggle & TP_MASK_SKIPBACK) == TP_MASK_SKIPBACK) != tp->skipback)
+ trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_SKIPBACK,
TP_MASK_SKIPBACK);
+
+ trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_MB, &toggle);
+ if(((toggle & TP_MASK_MB) == TP_MASK_MB) != tp->mb)
+ trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_MB, TP_MASK_MB);
+
+ trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG, &toggle);
+ if(((toggle & TP_MASK_SOURCE_TAG) == TP_MASK_SOURCE_TAG) != tp->source_tag)
+ trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG,
TP_MASK_SOURCE_TAG);
+
+ trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_EXT_DEV, &toggle);
+ if(((toggle & TP_MASK_EXT_DEV) == TP_MASK_EXT_DEV) != tp->skipback)
+ trackpoint_toggle_bit(&psmouse->ps2dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV);
+
+ return 0;
+}
+
+static void trackpoint_defaults(struct trackpoint_data *tp) +{
+ tp->ptson = tp_ptson;
+ tp->sens = tp_sens;
+ tp->speed = tp_speed;
+ tp->reach = tp_reach;
+
+ tp->draghys = tp_draghys;
+ tp->mindrag = tp_mindrag;
+
+ tp->thresh = tp_thresh;
+ tp->up_thresh = tp_upthresh;
+
+ tp->z_time = tp_ztime;
+ tp->jenks_curv = tp_jenks;
+
+ tp->mb = tp_mb;
+ tp->mb_scroll = tp_mb_scroll;
+
+ /* The following can't be set via module parameters */
+ tp->inertia = TP_DEF_INERTIA;
+ tp->skipback = TP_DEF_SKIPBACK;
+ tp->ext_dev = TP_DEF_EXT_DEV;
+ tp->scroll_delay = TP_DEF_SCROLL_DELAY;
+
+ tp->scrolling = tp->mb_was_down = 0;
+ tp->xacc = tp->yacc = 0;
+}
+
+
+
+int trackpoint_init(struct psmouse *psmouse)
+{
+ unsigned char param[2];
+ struct trackpoint_data *priv;
+ struct ps2dev *ps2dev = &psmouse->ps2dev;
+
+ param[0] = param[1] = 0;
+
+ /* The real driver disables, queries and
+ then enables so we'll do that too
+ */
+ ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
+
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_DISABLE));
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_DISABLE_EXT));
+
+ ps2_command(ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID));
+
+ if(param[0] != TP_MAGIC_IDENT)
+ return -1;
+
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_ENABLE_EXT));
+ ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_ENABLE));
+
+ psmouse->private = priv = kmalloc(sizeof(struct trackpoint_data), GFP_KERNEL);
+
+ if(!priv)
+ return -1;
+
+ memset(priv, 0, sizeof(struct trackpoint_data));
+
+ priv->firmware_id = param[1];
+ trackpoint_defaults(priv);
+
+ trackpoint_reconnect(psmouse);
+ trackpoint_proc_init(psmouse);
+
+
+ /* Used to simulate wheel scrolling */
+ set_bit(REL_HWHEEL, psmouse->dev.relbit);
+ set_bit(REL_WHEEL, psmouse->dev.relbit);
+
+ psmouse->model = PSMOUSE_TRACKPOINT;
+
+ psmouse->reconnect = trackpoint_reconnect;
+ psmouse->disconnect = trackpoint_disconnect;
+
+ printk("IBM TrackPoint firmware: 0x%02X\n", param[1]);
+
+ return 0;
+}
+

drivers/input/mouse/trackpoint.h +86 -0

86 lines not on this page · raw message

Transparency */
+#define TP_TOGGLE_TWOHAND (0x2D) /* Two handed */
+#define TP_TOGGLE_STICKY_TWO (0x2D) /* Sticky two handed */
+#define TP_TOGGLE_SKIPBACK (0x2D) /* Suppress movement */
+ /* after drag release */
+#define TP_TOGGLE_EXT_DEV (0x23) /* Toggle external device */
+#define TP_TOGGLE_SOURCE_TAG (0x20) /* Bit 3 of the first packet
will be set to
+ to the origin of the packet (external or TP) */
+
+/*
+ * Various makses for registers
+ * XOR'd to current contents for new value
+ */
+#define TP_MASK_PTSON (0x01)
+#define TP_MASK_SKIPBACK (0x08)
+#define TP_MASK_TWOHAND (0x01)
+#define TP_MASK_STICKY_TWO (0x04)
+#define TP_MASK_HARD_TRANS (0x80)
+#define TP_MASK_BURST (0x80)
+#define TP_MASK_MB (0x01)
+#define TP_MASK_DRIFT (0x80)
+#define TP_MASK_EXT_DEV (0x02)
+#define TP_MASK_SOURCE_TAG (0x80)
+
+/* Power on Self Test Results */
+#define TP_POR_SUCCESS (0x3B)
+
+/*
+ * Default power on values
+ */
+#define TP_DEF_SENS (0x80)
+#define TP_DEF_INERTIA (0x06)
+#define TP_DEF_SPEED (0x61)
+#define TP_DEF_REACH (0x0A)
+
+#define TP_DEF_DRAGHYS (0xFF)
+#define TP_DEF_MINDRAG (0x14)
+

+#define TP_DEF_THRESH     (0x08)
+#define TP_DEF_UP_THRESH  (0xFF)
+#define TP_DEF_Z_TIME     (0x26)

+#define TP_DEF_JENKS_CURV (0x87)
+
+/* Toggles */
+#define TP_DEF_MB (0x00)
+#define TP_DEF_PTSON (0x00)
+#define TP_DEF_SKIPBACK (0x00)
+#define TP_DEF_EXT_DEV (0x01)
+#define TP_DEF_MB_SCROLL (0x00)
+#define TP_DEF_SCROLL_DELAY (200)
+
+#define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd))
+
+#define PSMOUSE_TRACKPOINT 42
+#define Z_ACCEL_EXP 1.2
+#define Z_ACCEL_MULT 0.02
+
+
+struct trackpoint_data
+{
+ unsigned char firmware_id;
+
+ unsigned char sens, speed, inertia, reach;
+ unsigned char draghys, mindrag;
+ unsigned char thresh, up_thresh;
+ unsigned char z_time, jenks_curv;
+
+ unsigned char ptson; /* Press to Select */
+ unsigned char twohand, skipback;
+ unsigned char mb;
+
+ unsigned char ext_dev;
+ unsigned char transparent;
+ unsigned char source_tag;
+
+ unsigned char mb_scroll, mb_was_down, scrolling;
+ unsigned long scroll_delay, last_mb_press;
+
+ int xacc, yacc;
+};
+
+extern int trackpoint_init (struct psmouse *psmouse); +extern void trackpoint_sim_scroll(struct psmouse *psmouse); +
+#endif /* _TRACKPOINT_H */

#1 lore raw
Quoted 6 lines · Stephen Evanchik

Vojtech,

Here is a patch that exposes the IBM TrackPoint's extended properties as well as scroll wheel emulation.

Hi,

Very nice although I have a couple of comments.

drivers/input/mouse/psmouse-base.c line 499

Quoted 8 lines

/*
+ * Try to initialize the IBM TrackPoint
+ */

drivers/input/mouse/psmouse-base.c +5 -0
+	if (max_proto > PSMOUSE_PS2 && trackpoint_init(psmouse) == 0) {
+		psmouse->vendor = "IBM";
+		psmouse->name = "TrackPoint";
+ 
+		return PSMOUSE_PS2;

Why PSMOUSE_PS2? Reconnect will surely not like it.

Quoted 3 lines
drivers/input/mouse/trackpoint.c +3 -0
+int tp_sens = TP_DEF_SENS;
+module_param_named(sens, tp_sens, uint, 0);
+MODULE_PARM_DESC(sens, "Sensitivity");

....

drivers/input/mouse/trackpoint.c line 78

Quoted 3 lines
drivers/input/mouse/trackpoint.c +3 -0
+int tp_mb_scroll = TP_DEF_MB_SCROLL;
+module_param_named(mb_scroll, tp_mb_scroll, uint, 0);
+MODULE_PARM_DESC(mb_scroll, "Scroll with middle button");

All of this should be handled via sysfs dynamically, we don't need any more pmouse module parameters.

drivers/input/mouse/trackpoint.c line 83

Quoted 3 lines
drivers/input/mouse/trackpoint.c +3 -0
+__obsolete_setup("pts=");
+__obsolete_setup("backup=");
+__obsolete_setup("draghyst=");

What are these? They can't be obsolete as the module has never been part of the vanilla kernel.

drivers/input/mouse/trackpoint.c line 93

Quoted 10 lines
drivers/input/mouse/trackpoint.c +10 -0
+
+/*
+ * Device IO: read, write and toggle bit
+ */
+static void trackpoint_command(struct ps2dev *ps2dev, unsigned char cmd)
+{	
+	ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND));
+	ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, cmd));
+}
+

Error checking would be nice.

Quoted 2 lines
(quoted diff) +2 -0
+
+#ifdef CONFIG_PROC_FS

...

Quoted 10 lines
(quoted diff) +10 -0
+{
+        remove_proc_entry("scroll_delay", tp_dir);
+        remove_proc_entry("scroll", tp_dir);
+        remove_proc_entry("transparent", tp_dir);
+        remove_proc_entry("ext_dev", tp_dir);
+        remove_proc_entry("mb", tp_dir);
+        remove_proc_entry("skip_back", tp_dir);
+        remove_proc_entry("ptson", tp_dir);
+        remove_proc_entry("jenks_curv", tp_dir);
+        remove_proc_entry("z_time", tp_dir);

Review

Quoted 10 lines
(quoted diff) +10 -0
+        remove_proc_entry("up_thresh", tp_dir);
+        remove_proc_entry("thresh", tp_dir);
+        remove_proc_entry("min_drag", tp_dir);
+        remove_proc_entry("drag_hyst", tp_dir);
+        remove_proc_entry("backup", tp_dir);
+        remove_proc_entry("neg_inertia", tp_dir);
+        remove_proc_entry("speed", tp_dir);
+        remove_proc_entry("sensitivity", tp_dir);
+        remove_proc_entry("trackpoint", NULL);
+}

No new proc stuff please (it will be visible from sysfs when you redo the module parameters).

Quoted 17 lines
(quoted diff) +17 -0
+
+		tp->scrolling = 0;
+		tp->mb_was_down = 0;
+	}
+        else if(tp->scrolling) {
+
+		/* Vertical scrolling */
+		diff = (int) ((packet[0] << 3) & 0x100) - (int) packet[2];
+                if( diff < -2 ) {
+			input_report_rel(&psmouse->dev, REL_WHEEL, 1);
+		}
+		else if(diff > 2) {
+			input_report_rel(&psmouse->dev, REL_WHEEL, -1);
+		}
+
+                /* Horizontal scrolling */
+                diff = (int) packet[1] - (int) ((packet[0] << 4) & 0x100);

Review

Quoted 10 lines
(quoted diff) +10 -0
+                if( diff < -2) {
+                        input_report_rel(&psmouse->dev, REL_HWHEEL, 1);
+                }
+                else if( diff > 2) {
+                        input_report_rel(&psmouse->dev, REL_HWHEEL, -1);
+                }
+
+		packet[1] &= 0x00;
+		packet[2] &= 0x00;
+	}

Looks like whitespace damage (tabs vs spaces) plus it should be "} else {" on one line.

Review

Quoted 7 lines
(quoted diff) +7 -0
+int trackpoint_reconnect(struct psmouse *psmouse)
+{
+	unsigned char toggle;
+	struct trackpoint_data *tp = psmouse->private;
+
+	/* Push the config to the device */
+	

I'd like to verify that it still recognized as trackpoint - suspends often play tricks on PS/2 devices.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	printk("IBM TrackPoint firmware: 0x%02X\n", param[1]);

KERN_INFO?

Signature · 1 line
Dmitry
#2 lore raw
Quoted 12 lines · Dmitry Torokhov
Quoted 6 lines · Stephen Evanchik

Vojtech,

Here is a patch that exposes the IBM TrackPoint's extended properties as well as scroll wheel emulation.

Hi,

Very nice although I have a couple of comments.

Quoted 11 lines

drivers/input/mouse/psmouse-base.c line 499

Quoted 8 lines

/*
+ * Try to initialize the IBM TrackPoint
+ */

drivers/input/mouse/psmouse-base.c +5 -0
+	if (max_proto > PSMOUSE_PS2 && trackpoint_init(psmouse) == 0) {
+		psmouse->vendor = "IBM";
+		psmouse->name = "TrackPoint";
+ 
+		return PSMOUSE_PS2;

Why PSMOUSE_PS2? Reconnect will surely not like it.

OK, I have read the code once again, and saw that you have special handling within PS/2 protocol based on model constant. Please set psmouse type to PSMOUSE_TRACKPOINT instead of model and provide full protocol handler, like ALPS, Synaptics and Logitech do. Trackpoint is different and complex enough to warrant it.

Signature · 1 line
Dmitry
#3 lore raw
Quoted 5 lines · Dmitry Torokhov

OK, I have read the code once again, and saw that you have special handling within PS/2 protocol based on model constant. Please set psmouse type to PSMOUSE_TRACKPOINT instead of model and provide full protocol handler, like ALPS, Synaptics and Logitech do. Trackpoint is different and complex enough to warrant it.

Thanks, I've made all the changes suggested and I'll incorporate this too. I'll send a new patch at the end of the weekend when I get back.

Stephen

#4 lore raw
In reply to Dmitry Torokhov
Quoted 5 lines · Dmitry Torokhov

OK, I have read the code once again, and saw that you have special handling within PS/2 protocol based on model constant. Please set psmouse type to PSMOUSE_TRACKPOINT instead of model and provide full protocol handler, like ALPS, Synaptics and Logitech do. Trackpoint is different and complex enough to warrant it.

I'm not sure that I think a protocol handler is necessary unless I am misunderstanding what you mean. The TrackPoint is nothing more than a PS/2 mouse with 2 or 3 buttons that responds to an additional set of commands. The extra handling has to do with middle-to-scroll which could be done in userspace.

Aside from that the only time TracKPoint specific processing occurs is when some property is being manipulated.

Do you still think a custom handler is necessary?

Stephen

#5 lore raw
Quoted 14 lines · Stephen Evanchik
Quoted 5 lines · Dmitry Torokhov

OK, I have read the code once again, and saw that you have special handling within PS/2 protocol based on model constant. Please set psmouse type to PSMOUSE_TRACKPOINT instead of model and provide full protocol handler, like ALPS, Synaptics and Logitech do. Trackpoint is different and complex enough to warrant it.

I'm not sure that I think a protocol handler is necessary unless I am misunderstanding what you mean. The TrackPoint is nothing more than a PS/2 mouse with 2 or 3 buttons that responds to an additional set of commands. The extra handling has to do with middle-to-scroll which could be done in userspace.

Quoted 4 lines

Aside from that the only time TracKPoint specific processing occurs is when some property is being manipulated.

Do you still think a custom handler is necessary?

You're right. The IBM trackpoints unfortunately don't have a 'native' mode, they always do full processing and send classic PS/2 packets.

I think we shouldn't need a handler, since we can use the PS/2 protocol one. We'll need some options to set the trackpoint tap behavior (as far as I know it can only be mapped to a button), and we'll need a safe detection, but that's all.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#6 lore raw
Quoted 8 lines · Vojtech Pavlik

You're right. The IBM trackpoints unfortunately don't have a 'native' mode, they always do full processing and send classic PS/2 packets.

I think we shouldn't need a handler, since we can use the PS/2 protocol one. We'll need some options to set the trackpoint tap behavior (as far as I know it can only be mapped to a button), and we'll need a safe detection, but that's all.

The tap only sends a button one event. As far as the Press to Select qualities are concerned, the necessary options are exposed by the driver in the sysfs filesystem now. Understanding their effects on how a press, drag, double press is detected is another matter.

I'll send a 2.6.11-rc4 based patch later today for consideration.

Stephen

#7 lore raw
In reply to Stephen Evanchik
Quoted 8 lines · Stephen Evanchik
Quoted 5 lines · Dmitry Torokhov

OK, I have read the code once again, and saw that you have special handling within PS/2 protocol based on model constant. Please set psmouse type to PSMOUSE_TRACKPOINT instead of model and provide full protocol handler, like ALPS, Synaptics and Logitech do. Trackpoint is different and complex enough to warrant it.

Quoted 6 lines

I'm not sure that I think a protocol handler is necessary unless I am misunderstanding what you mean. The TrackPoint is nothing more than a PS/2 mouse with 2 or 3 buttons that responds to an additional set of commands. The extra handling has to do with middle-to-scroll which could be done in userspace.

If middle-to-scroll is movd to userspace and there is no trackpoint- specific handling added to the "normal" psmouse handler then we don't need a new handler of course.

Signature · 1 line
Dmitry
#8 lore raw
In reply to Dmitry Torokhov
Quoted 12 lines · Dmitry Torokhov
Quoted 6 lines · Stephen Evanchik

Vojtech,

Here is a patch that exposes the IBM TrackPoint's extended properties as well as scroll wheel emulation.

Hi,

Very nice although I have a couple of comments.

Quoted 10 lines

drivers/input/mouse/psmouse-base.c line 499

Quoted 8 lines

/*
+ * Try to initialize the IBM TrackPoint
+ */

drivers/input/mouse/psmouse-base.c +5 -0
+	if (max_proto > PSMOUSE_PS2 && trackpoint_init(psmouse) == 0) {
+		psmouse->vendor = "IBM";
+		psmouse->name = "TrackPoint";
+ 
+		return PSMOUSE_PS2;

Why PSMOUSE_PS2? Reconnect will surely not like it.

Indeed. IIRC this patch killed wheel mouse detection in ubuntu.

Quoted 11 lines
Quoted 4 lines
drivers/input/mouse/trackpoint.c +3 -0
+int tp_sens = TP_DEF_SENS;
+module_param_named(sens, tp_sens, uint, 0);
+MODULE_PARM_DESC(sens, "Sensitivity");

....

drivers/input/mouse/trackpoint.c line 78

Quoted 3 lines
drivers/input/mouse/trackpoint.c +3 -0
+int tp_mb_scroll = TP_DEF_MB_SCROLL;
+module_param_named(mb_scroll, tp_mb_scroll, uint, 0);
+MODULE_PARM_DESC(mb_scroll, "Scroll with middle button");

All of this should be handled via sysfs dynamically, we don't need any more pmouse module parameters.

Exactly.

Quoted 8 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+        remove_proc_entry("neg_inertia", tp_dir);
+        remove_proc_entry("speed", tp_dir);
+        remove_proc_entry("sensitivity", tp_dir);
+        remove_proc_entry("trackpoint", NULL);
+}

No new proc stuff please (it will be visible from sysfs when you redo the module parameters).

... automatically, even ...

Quoted 22 lines
Quoted 22 lines
(quoted diff) +22 -0
+
+		tp->scrolling = 0;
+		tp->mb_was_down = 0;
+	}
+        else if(tp->scrolling) {
+
+		/* Vertical scrolling */
+		diff = (int) ((packet[0] << 3) & 0x100) - (int) packet[2];
+                if( diff < -2 ) {
+			input_report_rel(&psmouse->dev, REL_WHEEL, 1);
+		}
+		else if(diff > 2) {
+			input_report_rel(&psmouse->dev, REL_WHEEL, -1);
+		}
+
+                /* Horizontal scrolling */
+                diff = (int) packet[1] - (int) ((packet[0] << 4) & 0x100);
+                if( diff < -2) {
+                        input_report_rel(&psmouse->dev, REL_HWHEEL, 1);
+                }
+                else if( diff > 2) {
+                        input_report_rel(&psmouse->dev, REL_HWHEEL, -1);
Quoted 8 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+                }
+
+		packet[1] &= 0x00;
+		packet[2] &= 0x00;
+	}

Looks like whitespace damage (tabs vs spaces) plus it should be "} else {" on one line.

What a shame that this thing doesn't have a raw mode where it'd report the pressure ...

Quoted 15 lines

Review

Quoted 7 lines
(quoted diff) +7 -0
+int trackpoint_reconnect(struct psmouse *psmouse)
+{
+	unsigned char toggle;
+	struct trackpoint_data *tp = psmouse->private;
+
+	/* Push the config to the device */
+	

I'd like to verify that it still recognized as trackpoint - suspends often play tricks on PS/2 devices.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	printk("IBM TrackPoint firmware: 0x%02X\n", param[1]);

KERN_INFO?

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#9 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vojtech Pavlik wrote:

| On Thu, Feb 03, 2005 at 07:34:16PM -0500, Dmitry Torokhov wrote:
|
|>On Thursday 03 February 2005 17:43, Stephen Evanchik wrote:
|>
|>>Vojtech,
|>>
|>>Here is a patch that exposes the IBM TrackPoint's extended properties
|>>as well as scroll wheel emulation.
|>>
|>>
|>
|>Hi,
|>
|>Very nice although I have a couple of comments.
|>
|>
|>> /*
|>>+ * Try to initialize the IBM TrackPoint
|>>+ */
|>>+	if (max_proto > PSMOUSE_PS2 && trackpoint_init(psmouse) == 0) {
|>>+		psmouse->vendor = "IBM";
|>>+		psmouse->name = "TrackPoint";
|>>+
|>>+		return PSMOUSE_PS2;
|>
|>Why PSMOUSE_PS2? Reconnect will surely not like it.
|
|
| Indeed. IIRC this patch killed wheel mouse detection in ubuntu.
|

That's correct. I had to revert it unfortunatly and i am dealing to give it another shot if you want to get it tested again before inclusion in the main tree, but it has to happen no later than next week since we are very close to feature freeze for the next release.

Regards,
Fabio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iQIVAwUBQgMaXlA6oBJjVJ+OAQKn7A//ULwd9zWcnqgmY0+uacKYT9LYa2hcIBuu P9i08D/GpTGSglJ0iLBKM6eHw1eKLMwC1snVQ99TyCVMIicEBnNgcF31McEui/Q7 ZJug1Twndb0pUAc/erKUzdqLmQTIPax1eJLLCEmw81UWA0sW2PW52DZ26/4jqSFz qpNYpvkT8h4X5Gc4l8j/erMYasN4jglcdjDKzfj6NMsVqWC5VJN5W863KPyM2dmf BN9Mx8jDSzO6PgfquhKJa/6pUV7OODko6PwnJFkWC3SR03x8SjX7EKKDpkYW8OnX RZGq2Tkmv5B2lme4v9e+O5+UPRzBuahxyknZw9WOcRBUeMpzAAXrIL6cDsWb9ZAd ZCbIp3MS2be+hIY3hElbHiMN6+XLmr41u5PHGoxBOg8t4UPPTij7/ym3w4iB9Fbu JIjEDsUfSVjzMZ0+tLGFl+2CtwrrBtmvGnuzLEzJxbwRWlzirIBj5VxAyLUVfXUB TT0tAeDcopHqki3kFifiXUJ9XKPocwgznosZpISfNdJLB4+kw6S0/XamsbzZBJzr K1Me547OABE8d/vc4dR7nDKqw4quZk6qThK7wqziiz6mGlBC28gLkfyxfGvVj/Uv 6uaE7RNOvRQYQNUFMMt6BH7vogCp7GsqrMfiiNc72SaxN8Gp4g2cH8v7xpUXcrJ0 mc6TtaGNagQ=
=AVn/
-----END PGP SIGNATURE-----

#10 lore raw
In reply to Vojtech Pavlik
Quoted 24 lines · Vojtech Pavlik
Quoted 12 lines · Dmitry Torokhov
Quoted 6 lines · Stephen Evanchik

Vojtech,

Here is a patch that exposes the IBM TrackPoint's extended properties as well as scroll wheel emulation.

Hi,

Very nice although I have a couple of comments.

Quoted 10 lines

drivers/input/mouse/psmouse-base.c line 499

Quoted 8 lines

/*
+ * Try to initialize the IBM TrackPoint
+ */

drivers/input/mouse/psmouse-base.c +5 -0
+	if (max_proto > PSMOUSE_PS2 && trackpoint_init(psmouse) == 0) {
+		psmouse->vendor = "IBM";
+		psmouse->name = "TrackPoint";
+ 
+		return PSMOUSE_PS2;

Why PSMOUSE_PS2? Reconnect will surely not like it.

Quoted 2 lines

Indeed. IIRC this patch killed wheel mouse detection in ubuntu.

We may need yet another psmouse_reset after unsuccessful test.

Signature · 1 line
Dmitry
#11 lore raw
Quoted 25 lines · Dmitry Torokhov
Quoted 24 lines · Vojtech Pavlik
Quoted 22 lines · Dmitry Torokhov
Quoted 6 lines · Stephen Evanchik

Vojtech,

Here is a patch that exposes the IBM TrackPoint's extended properties as well as scroll wheel emulation.

Hi,

Very nice although I have a couple of comments.

drivers/input/mouse/psmouse-base.c line 499

Quoted 8 lines

/*
+ * Try to initialize the IBM TrackPoint
+ */

drivers/input/mouse/psmouse-base.c +5 -0
+	if (max_proto > PSMOUSE_PS2 && trackpoint_init(psmouse) == 0) {
+		psmouse->vendor = "IBM";
+		psmouse->name = "TrackPoint";
+ 
+		return PSMOUSE_PS2;

Why PSMOUSE_PS2? Reconnect will surely not like it.

Quoted 4 lines
Quoted 2 lines

Indeed. IIRC this patch killed wheel mouse detection in ubuntu.

We may need yet another psmouse_reset after unsuccessful test.

We probably should do one after every test for isolation. It's not that big a problem now that we do the probing from a thread.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
maintainer
#12 lore raw
Quoted 26 lines · Vojtech Pavlik
Quoted 25 lines · Dmitry Torokhov
Quoted 24 lines · Vojtech Pavlik
Quoted 22 lines · Dmitry Torokhov
Quoted 6 lines · Stephen Evanchik

Vojtech,

Here is a patch that exposes the IBM TrackPoint's extended properties as well as scroll wheel emulation.

Hi,

Very nice although I have a couple of comments.

drivers/input/mouse/psmouse-base.c line 499

Quoted 8 lines

/*
+ * Try to initialize the IBM TrackPoint
+ */

drivers/input/mouse/psmouse-base.c +5 -0
+       if (max_proto > PSMOUSE_PS2 && trackpoint_init(psmouse) == 0) {
+               psmouse->vendor = "IBM";
+               psmouse->name = "TrackPoint";
+
+               return PSMOUSE_PS2;

Why PSMOUSE_PS2? Reconnect will surely not like it.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Indeed. IIRC this patch killed wheel mouse detection in ubuntu.

We may need yet another psmouse_reset after unsuccessful test.

We probably should do one after every test for isolation. It's not that big a problem now that we do the probing from a thread.

It is still a problem if driver is registered after the port has been detected wich quite often is the case as many people have psmouse as a module.

I wonder if we should make driver registration asynchronous too. I don't forsee any issues providing that I bump up module's reference count while driver structure is "in flight", do you?

Signature · 1 line
Dmitry
#13 lore raw
Quoted 5 lines · Dmitry Torokhov

It is still a problem if driver is registered after the port has been detected wich quite often is the case as many people have psmouse as a module.

I wonder if we should make driver registration asynchronous too.

Probably yes.

Quoted 3 lines

I
don't forsee any issues providing that I bump up module's reference count while driver structure is "in flight", do you?

No, looks OK to me, too.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#14 lore raw
Quoted 8 lines · Vojtech Pavlik
Quoted 5 lines · Dmitry Torokhov

It is still a problem if driver is registered after the port has been detected wich quite often is the case as many people have psmouse as a module.

I wonder if we should make driver registration asynchronous too.

Quoted 8 lines

Probably yes.

Quoted 3 lines

I
don't forsee any issues providing that I bump up module's reference count while driver structure is "in flight", do you?

No, looks OK to me, too.

Ok, what about the following patch then?

Signature · 280 lines
Dmitry


===================================================================


[email protected], 2005-02-05 01:48:45-05:00, [email protected]
  Input: make serio drivers register asynchronously. This should
         speed up boot process as some drivers take a long time
         probing for supported devices.
  
         Also change __inline__ to inline in serio.h
  
  Signed-off-by: Dmitry Torokhov <[email protected]>


 drivers/input/serio/serio.c |   65 ++++++++++++++++++++++++--------------------
 include/linux/serio.h       |   25 ++++++++++------
 2 files changed, 51 insertions(+), 39 deletions(-)


===================================================================



diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c	2005-02-05 01:53:56 -05:00
+++ b/drivers/input/serio/serio.c	2005-02-05 01:53:56 -05:00
@@ -44,7 +44,7 @@
 EXPORT_SYMBOL(__serio_register_port);
 EXPORT_SYMBOL(serio_unregister_port);
 EXPORT_SYMBOL(__serio_unregister_port_delayed);
-EXPORT_SYMBOL(serio_register_driver);
+EXPORT_SYMBOL(__serio_register_driver);
 EXPORT_SYMBOL(serio_unregister_driver);
 EXPORT_SYMBOL(serio_open);
 EXPORT_SYMBOL(serio_close);
@@ -120,18 +120,19 @@
  * Serio event processing.
  */
 
-struct serio_event {
-	int type;
-	struct serio *serio;
-	struct module *owner;
-	struct list_head node;
-};
-
 enum serio_event_type {
 	SERIO_RESCAN,
 	SERIO_RECONNECT,
 	SERIO_REGISTER_PORT,
 	SERIO_UNREGISTER_PORT,
+	SERIO_REGISTER_DRIVER,
+};
+
+struct serio_event {
+	enum serio_event_type type;
+	void *object;
+	struct module *owner;
+	struct list_head node;
 };
 
 static DEFINE_SPINLOCK(serio_event_lock);	/* protects serio_event_list */
@@ -140,7 +141,7 @@
 static DECLARE_COMPLETION(serio_exited);
 static int serio_pid;
 
-static void serio_queue_event(struct serio *serio, struct module *owner,
+static void serio_queue_event(void *object, struct module *owner,
 			      enum serio_event_type event_type)
 {
 	unsigned long flags;
@@ -156,7 +157,7 @@
 	 * we need to preseve sequence of distinct events.
  	 */
 	list_for_each_entry_reverse(event, &serio_event_list, node) {
-		if (event->serio == serio) {
+		if (event->object == object) {
 			if (event->type == event_type)
 				goto out;
 			break;
@@ -170,7 +171,7 @@
 		}
 
 		event->type = event_type;
-		event->serio = serio;
+		event->object = object;
 		event->owner = owner;
 
 		list_add_tail(&event->node, &serio_event_list);
@@ -198,7 +199,7 @@
 
 	list_for_each_safe(node, next, &serio_event_list) {
 		e = list_entry(node, struct serio_event, node);
-		if (event->serio == e->serio) {
+		if (event->object == e->object) {
 			/*
 			 * If this event is of different type we should not
 			 * look further - we only suppress duplicate events
@@ -241,6 +242,7 @@
 static void serio_handle_events(void)
 {
 	struct serio_event *event;
+	struct serio_driver *serio_drv;
 
 	down(&serio_sem);
 
@@ -248,21 +250,26 @@
 
 		switch (event->type) {
 			case SERIO_REGISTER_PORT:
-				serio_add_port(event->serio);
+				serio_add_port(event->object);
 				break;
 
 			case SERIO_UNREGISTER_PORT:
-				serio_disconnect_port(event->serio);
-				serio_destroy_port(event->serio);
+				serio_disconnect_port(event->object);
+				serio_destroy_port(event->object);
 				break;
 
 			case SERIO_RECONNECT:
-				serio_reconnect_port(event->serio);
+				serio_reconnect_port(event->object);
 				break;
 
 			case SERIO_RESCAN:
-				serio_disconnect_port(event->serio);
-				serio_find_driver(event->serio);
+				serio_disconnect_port(event->object);
+				serio_find_driver(event->object);
+				break;
+
+			case SERIO_REGISTER_DRIVER:
+				serio_drv = event->object;
+				driver_register(&serio_drv->driver);
 				break;
 
 			default:
@@ -289,7 +296,7 @@
 
 	list_for_each_safe(node, next, &serio_event_list) {
 		event = list_entry(node, struct serio_event, node);
-		if (event->serio == serio) {
+		if (event->object == serio) {
 			list_del_init(node);
 			serio_free_event(event);
 		}
@@ -309,20 +316,23 @@
 static struct serio *serio_get_pending_child(struct serio *parent)
 {
 	struct serio_event *event;
-	struct serio *serio = NULL;
+	struct serio *serio, *child = NULL;
 	unsigned long flags;
 
 	spin_lock_irqsave(&serio_event_lock, flags);
 
 	list_for_each_entry(event, &serio_event_list, node) {
-		if (event->type == SERIO_REGISTER_PORT && event->serio->parent == parent) {
-			serio = event->serio;
-			break;
+		if (event->type == SERIO_REGISTER_PORT) {
+			serio = event->object;
+			if (serio->parent == parent) {
+				child = serio;
+				break;
+			}
 		}
 	}
 
 	spin_unlock_irqrestore(&serio_event_lock, flags);
-	return serio;
+	return child;
 }
 
 static int serio_thread(void *nothing)
@@ -672,16 +682,13 @@
 	return 0;
 }
 
-void serio_register_driver(struct serio_driver *drv)
+void __serio_register_driver(struct serio_driver *drv, struct module *owner)
 {
-	down(&serio_sem);
-
 	drv->driver.bus = &serio_bus;
 	drv->driver.probe = serio_driver_probe;
 	drv->driver.remove = serio_driver_remove;
-	driver_register(&drv->driver);
 
-	up(&serio_sem);
+	serio_queue_event(drv, owner, SERIO_REGISTER_DRIVER);
 }
 
 void serio_unregister_driver(struct serio_driver *drv)
diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h	2005-02-05 01:53:56 -05:00
+++ b/include/linux/serio.h	2005-02-05 01:53:56 -05:00
@@ -95,10 +95,15 @@
 	__serio_unregister_port_delayed(serio, THIS_MODULE);
 }
 
-void serio_register_driver(struct serio_driver *drv);
+void __serio_register_driver(struct serio_driver *drv, struct module *owner);
+static inline void serio_register_driver(struct serio_driver *drv)
+{
+	__serio_register_driver(drv, THIS_MODULE);
+}
+
 void serio_unregister_driver(struct serio_driver *drv);
 
-static __inline__ int serio_write(struct serio *serio, unsigned char data)
+static inline int serio_write(struct serio *serio, unsigned char data)
 {
 	if (serio->write)
 		return serio->write(serio, data);
@@ -106,13 +111,13 @@
 		return -1;
 }
 
-static __inline__ void serio_drv_write_wakeup(struct serio *serio)
+static inline void serio_drv_write_wakeup(struct serio *serio)
 {
 	if (serio->drv && serio->drv->write_wakeup)
 		serio->drv->write_wakeup(serio);
 }
 
-static __inline__ void serio_cleanup(struct serio *serio)
+static inline void serio_cleanup(struct serio *serio)
 {
 	if (serio->drv && serio->drv->cleanup)
 		serio->drv->cleanup(serio);
@@ -122,12 +127,12 @@
  * Use the following fucntions to manipulate serio's per-port
  * driver-specific data.
  */
-static __inline__ void *serio_get_drvdata(struct serio *serio)
+static inline void *serio_get_drvdata(struct serio *serio)
 {
 	return dev_get_drvdata(&serio->dev);
 }
 
-static __inline__ void serio_set_drvdata(struct serio *serio, void *data)
+static inline void serio_set_drvdata(struct serio *serio, void *data)
 {
 	dev_set_drvdata(&serio->dev, data);
 }
@@ -136,12 +141,12 @@
  * Use the following fucntions to protect critical sections in
  * driver code from port's interrupt handler
  */
-static __inline__ void serio_pause_rx(struct serio *serio)
+static inline void serio_pause_rx(struct serio *serio)
 {
 	spin_lock_irq(&serio->lock);
 }
 
-static __inline__ void serio_continue_rx(struct serio *serio)
+static inline void serio_continue_rx(struct serio *serio)
 {
 	spin_unlock_irq(&serio->lock);
 }
@@ -149,12 +154,12 @@
 /*
  * Use the following fucntions to pin serio's driver in process context
  */
-static __inline__ int serio_pin_driver(struct serio *serio)
+static inline int serio_pin_driver(struct serio *serio)
 {
 	return down_interruptible(&serio->drv_sem);
 }
 
-static __inline__ void serio_unpin_driver(struct serio *serio)
+static inline void serio_unpin_driver(struct serio *serio)
 {
 	up(&serio->drv_sem);
 }
#15 lore raw
Quoted 11 lines · Dmitry Torokhov
Quoted 10 lines · Vojtech Pavlik
Quoted 5 lines · Dmitry Torokhov

It is still a problem if driver is registered after the port has been detected wich quite often is the case as many people have psmouse as a module.

I wonder if we should make driver registration asynchronous too.

Probably yes.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I
don't forsee any issues providing that I bump up module's reference count while driver structure is "in flight", do you?

No, looks OK to me, too.

Ok, what about the following patch then?

Applied. ;)

Quoted 283 lines
Signature · 27 lines
-- 
Dmitry


===================================================================


[email protected], 2005-02-05 01:48:45-05:00, [email protected]
  Input: make serio drivers register asynchronously. This should
         speed up boot process as some drivers take a long time
         probing for supported devices.
  
         Also change __inline__ to inline in serio.h
  
  Signed-off-by: Dmitry Torokhov <[email protected]>


 drivers/input/serio/serio.c |   65 ++++++++++++++++++++++++--------------------
 include/linux/serio.h       |   25 ++++++++++------
 2 files changed, 51 insertions(+), 39 deletions(-)


===================================================================



diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
drivers/input/serio/serio.c +36 -29
@@ -44,7 +44,7 @@
 EXPORT_SYMBOL(__serio_register_port);
 EXPORT_SYMBOL(serio_unregister_port);
 EXPORT_SYMBOL(__serio_unregister_port_delayed);
-EXPORT_SYMBOL(serio_register_driver);
+EXPORT_SYMBOL(__serio_register_driver);
 EXPORT_SYMBOL(serio_unregister_driver);
 EXPORT_SYMBOL(serio_open);
 EXPORT_SYMBOL(serio_close);
@@ -120,18 +120,19 @@
  * Serio event processing.
  */
 
-struct serio_event {
-	int type;
-	struct serio *serio;
-	struct module *owner;
-	struct list_head node;
-};
-
 enum serio_event_type {
 	SERIO_RESCAN,
 	SERIO_RECONNECT,
 	SERIO_REGISTER_PORT,
 	SERIO_UNREGISTER_PORT,
+	SERIO_REGISTER_DRIVER,
+};
+
+struct serio_event {
+	enum serio_event_type type;
+	void *object;
+	struct module *owner;
+	struct list_head node;
 };
 
 static DEFINE_SPINLOCK(serio_event_lock);	/* protects serio_event_list */
@@ -140,7 +141,7 @@
 static DECLARE_COMPLETION(serio_exited);
 static int serio_pid;
 
-static void serio_queue_event(struct serio *serio, struct module *owner,
+static void serio_queue_event(void *object, struct module *owner,
 			      enum serio_event_type event_type)
 {
 	unsigned long flags;
@@ -156,7 +157,7 @@
 	 * we need to preseve sequence of distinct events.
  	 */
 	list_for_each_entry_reverse(event, &serio_event_list, node) {
-		if (event->serio == serio) {
+		if (event->object == object) {
 			if (event->type == event_type)
 				goto out;
 			break;
@@ -170,7 +171,7 @@
 		}
 
 		event->type = event_type;
-		event->serio = serio;
+		event->object = object;
 		event->owner = owner;
 
 		list_add_tail(&event->node, &serio_event_list);
@@ -198,7 +199,7 @@
 
 	list_for_each_safe(node, next, &serio_event_list) {
 		e = list_entry(node, struct serio_event, node);
-		if (event->serio == e->serio) {
+		if (event->object == e->object) {
 			/*
 			 * If this event is of different type we should not
 			 * look further - we only suppress duplicate events
@@ -241,6 +242,7 @@
 static void serio_handle_events(void)
 {
 	struct serio_event *event;
+	struct serio_driver *serio_drv;
 
 	down(&serio_sem);
 
@@ -248,21 +250,26 @@
 
 		switch (event->type) {
 			case SERIO_REGISTER_PORT:
-				serio_add_port(event->serio);
+				serio_add_port(event->object);
 				break;
 
 			case SERIO_UNREGISTER_PORT:
-				serio_disconnect_port(event->serio);
-				serio_destroy_port(event->serio);
+				serio_disconnect_port(event->object);
+				serio_destroy_port(event->object);
 				break;
 
 			case SERIO_RECONNECT:
-				serio_reconnect_port(event->serio);
+				serio_reconnect_port(event->object);
 				break;
 
 			case SERIO_RESCAN:
-				serio_disconnect_port(event->serio);
-				serio_find_driver(event->serio);
+				serio_disconnect_port(event->object);
+				serio_find_driver(event->object);
+				break;
+
+			case SERIO_REGISTER_DRIVER:
+				serio_drv = event->object;
+				driver_register(&serio_drv->driver);
 				break;
 
 			default:
@@ -289,7 +296,7 @@
 
 	list_for_each_safe(node, next, &serio_event_list) {
 		event = list_entry(node, struct serio_event, node);
-		if (event->serio == serio) {
+		if (event->object == serio) {
 			list_del_init(node);
 			serio_free_event(event);
 		}
@@ -309,20 +316,23 @@
 static struct serio *serio_get_pending_child(struct serio *parent)
 {
 	struct serio_event *event;
-	struct serio *serio = NULL;
+	struct serio *serio, *child = NULL;
 	unsigned long flags;
 
 	spin_lock_irqsave(&serio_event_lock, flags);
 
 	list_for_each_entry(event, &serio_event_list, node) {
-		if (event->type == SERIO_REGISTER_PORT && event->serio->parent == parent) {
-			serio = event->serio;
-			break;
+		if (event->type == SERIO_REGISTER_PORT) {
+			serio = event->object;
+			if (serio->parent == parent) {
+				child = serio;
+				break;
+			}
 		}
 	}
 
 	spin_unlock_irqrestore(&serio_event_lock, flags);
-	return serio;
+	return child;
 }
 
 static int serio_thread(void *nothing)
@@ -672,16 +682,13 @@
 	return 0;
 }
 
-void serio_register_driver(struct serio_driver *drv)
+void __serio_register_driver(struct serio_driver *drv, struct module *owner)
 {
-	down(&serio_sem);
-
 	drv->driver.bus = &serio_bus;
 	drv->driver.probe = serio_driver_probe;
 	drv->driver.remove = serio_driver_remove;
-	driver_register(&drv->driver);
 
-	up(&serio_sem);
+	serio_queue_event(drv, owner, SERIO_REGISTER_DRIVER);
 }
 
 void serio_unregister_driver(struct serio_driver *drv)

diff -Nru a/include/linux/serio.h b/include/linux/serio.h

include/linux/serio.h +15 -10
@@ -95,10 +95,15 @@
 	__serio_unregister_port_delayed(serio, THIS_MODULE);
 }
 
-void serio_register_driver(struct serio_driver *drv);
+void __serio_register_driver(struct serio_driver *drv, struct module *owner);
+static inline void serio_register_driver(struct serio_driver *drv)
+{
+	__serio_register_driver(drv, THIS_MODULE);
+}
+
 void serio_unregister_driver(struct serio_driver *drv);
 
-static __inline__ int serio_write(struct serio *serio, unsigned char data)
+static inline int serio_write(struct serio *serio, unsigned char data)
 {
 	if (serio->write)
 		return serio->write(serio, data);
@@ -106,13 +111,13 @@
 		return -1;
 }
 
-static __inline__ void serio_drv_write_wakeup(struct serio *serio)
+static inline void serio_drv_write_wakeup(struct serio *serio)
 {
 	if (serio->drv && serio->drv->write_wakeup)
 		serio->drv->write_wakeup(serio);
 }
 
-static __inline__ void serio_cleanup(struct serio *serio)
+static inline void serio_cleanup(struct serio *serio)
 {
 	if (serio->drv && serio->drv->cleanup)
 		serio->drv->cleanup(serio);
@@ -122,12 +127,12 @@
  * Use the following fucntions to manipulate serio's per-port
  * driver-specific data.
  */
-static __inline__ void *serio_get_drvdata(struct serio *serio)
+static inline void *serio_get_drvdata(struct serio *serio)
 {
 	return dev_get_drvdata(&serio->dev);
 }
 
-static __inline__ void serio_set_drvdata(struct serio *serio, void *data)
+static inline void serio_set_drvdata(struct serio *serio, void *data)
 {
 	dev_set_drvdata(&serio->dev, data);
 }
@@ -136,12 +141,12 @@
  * Use the following fucntions to protect critical sections in
  * driver code from port's interrupt handler
  */
-static __inline__ void serio_pause_rx(struct serio *serio)
+static inline void serio_pause_rx(struct serio *serio)
 {
 	spin_lock_irq(&serio->lock);
 }
 
-static __inline__ void serio_continue_rx(struct serio *serio)
+static inline void serio_continue_rx(struct serio *serio)
 {
 	spin_unlock_irq(&serio->lock);
 }
@@ -149,12 +154,12 @@
 /*
  * Use the following fucntions to pin serio's driver in process context
  */
-static __inline__ int serio_pin_driver(struct serio *serio)
+static inline int serio_pin_driver(struct serio *serio)
 {
 	return down_interruptible(&serio->drv_sem);
 }
 
-static __inline__ void serio_unpin_driver(struct serio *serio)
+static inline void serio_unpin_driver(struct serio *serio)
 {
 	up(&serio->drv_sem);
 }
Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#16 lore raw
In reply to Vojtech Pavlik
Quoted 9 lines · Vojtech Pavlik
Quoted 9 lines
Quoted 8 lines

/*
+ * Try to initialize the IBM TrackPoint
+ */

drivers/input/mouse/psmouse-base.c +5 -0
+   if (max_proto > PSMOUSE_PS2 && trackpoint_init(psmouse) == 0) {
+           psmouse->vendor = "IBM";
+           psmouse->name = "TrackPoint";
+
+           return PSMOUSE_PS2;
Quoted 3 lines
Quoted 1 line

Why PSMOUSE_PS2? Reconnect will surely not like it.

Indeed. IIRC this patch killed wheel mouse detection in ubuntu.

Earlier versions of the patch didn't disable the device while probing so events could be interpreted as the magic ID of a TrackPoint. It now resets and disables the PS/2 device before detection but not after a detect failure.

I'll clean that up so its more sensible.

Stephen

#17 lore raw
Quoted 10 lines · Stephen Evanchik
Quoted 9 lines · Vojtech Pavlik
Quoted 9 lines
Quoted 8 lines

/*
+ * Try to initialize the IBM TrackPoint
+ */

drivers/input/mouse/psmouse-base.c +5 -0
+   if (max_proto > PSMOUSE_PS2 && trackpoint_init(psmouse) == 0) {
+           psmouse->vendor = "IBM";
+           psmouse->name = "TrackPoint";
+
+           return PSMOUSE_PS2;
Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Why PSMOUSE_PS2? Reconnect will surely not like it.

Indeed. IIRC this patch killed wheel mouse detection in ubuntu.

Earlier versions of the patch didn't disable the device while probing so events could be interpreted as the magic ID of a TrackPoint. It now resets and disables the PS/2 device before detection but not after a detect failure.

Since we fixed libps2, this shouldn't happen anymore, as long as the BIOS doesn't inject an endless stream of data from an USB mouse.

Quoted 1 line

I'll clean that up so its more sensible.

Thanks.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
maintainer
#18 lore raw
Quoted 4 lines · Vojtech Pavlik
Quoted 3 lines · Stephen Evanchik
Quoted 1 line · Vojtech Pavlik

Indeed. IIRC this patch killed wheel mouse detection in ubuntu.

Quoted 8 lines
Quoted 4 lines

Earlier versions of the patch didn't disable the device while probing so events could be interpreted as the magic ID of a TrackPoint. It now resets and disables the PS/2 device before detection but not after a detect failure.

Since we fixed libps2, this shouldn't happen anymore, as long as the BIOS doesn't inject an endless stream of data from an USB mouse.

I don't think changes in libps2 affect this problem in any way - psmouse does PSMOUSE_CMD_RESET_DIS before trying to do any protocol probing so there should be no events from the mouse during detection phase.

Signature · 1 line
Dmitry
#19 lore raw
In reply to Stephen Evanchik

Hi!

Quoted 35 lines

Here is a patch that exposes the IBM TrackPoint's extended properties as well as scroll wheel emulation.

I would appreciate comments and suggestions to make this more acceptable.

Stephen

diff -uNr a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile

drivers/input/mouse/Makefile +1 -1
@@ -14,4 +14,4 @@
 obj-$(CONFIG_MOUSE_SERIAL)	+= sermouse.o
 obj-$(CONFIG_MOUSE_VSXXXAA)	+= vsxxxaa.o
 
-psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o
+psmouse-objs  := psmouse-base.o alps.o logips2pp.o synaptics.o trackpoint.o

diff -uNr a/drivers/input/mouse/psmouse-base.c
b/drivers/input/mouse/psmouse-base.c

drivers/input/mouse/psmouse-base.c +1 -0
@@ -23,6 +23,7 @@
 #include "psmouse.h"
 #include "synaptics.h"
 #include "logips2pp.h"
+#include "trackpoint.h"
 #include "alps.h"
 
 #define DRIVER_DESC	"PS/2 mouse driver"
@@ -119,6 +120,13 @@
 	}
 
 /*

drivers/input/mouse/psmouse-base.c line 132

Quoted 10 lines
drivers/input/mouse/psmouse-base.c +7 -0
+ * TrackPoint scroll simulation handler if the BTN_MIDDLE is down
+ */
+
+	if(psmouse->model == PSMOUSE_TRACKPOINT)
+		trackpoint_sim_scroll(psmouse);
+
+/*
  * Generic PS/2 Mouse
  */
 

Perhaps this should be done in userspace? It is probably usable on non-trackpoint devices, too...
Pavel

Signature · 2 lines
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
#20 lore raw
Quoted 9 lines · Pavel Machek
Quoted 6 lines

Here is a patch that exposes the IBM TrackPoint's extended properties as well as scroll wheel emulation.

I would appreciate comments and suggestions to make this more acceptable.

Perhaps this should be done in userspace? It is probably usable on non-trackpoint devices, too...

For a big part it's not possible to do in userspace, because the touchpoint doesn't give the pressure information, it only can be mapped to a button click.

But middle-button-to-scroll would be doable in userspace, yes.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#21 lore raw
Quoted 9 lines · Vojtech Pavlik
Quoted 2 lines

Perhaps this should be done in userspace? It is probably usable on non-trackpoint devices, too...

For a big part it's not possible to do in userspace, because the touchpoint doesn't give the pressure information, it only can be mapped to a button click.

But middle-button-to-scroll would be doable in userspace, yes.

Middle-to-scroll in the newer Xorg releases. I received a number of requests from users to include this feature, I'm not sure why the Xorg option is inadequate. It can be removed if necessary.

Stephen

#22 lore raw
Quoted 7 lines · Stephen Evanchik
Quoted 7 lines
Quoted 2 lines

Perhaps this should be done in userspace? It is probably usable on non-trackpoint devices, too...

For a big part it's not possible to do in userspace, because the touchpoint doesn't give the pressure information, it only can be mapped to a button click.

Quoted 5 lines
Quoted 1 line

But middle-button-to-scroll would be doable in userspace, yes.

Middle-to-scroll in the newer Xorg releases. I received a number of requests from users to include this feature, I'm not sure why the Xorg option is inadequate. It can be removed if necessary.

I'm glad it's in the Xorg X server. It's the right place for it to be.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#23 lore raw
In reply to Stephen Evanchik

I'm a bit late, sorry. Haven't seen these mentioned in replies:

drivers/input/mouse/trackpoint.c line 32

Quoted 3 lines · Stephen Evanchik
drivers/input/mouse/trackpoint.c +3 -0
+int tp_sens = TP_DEF_SENS;
+module_param_named(sens, tp_sens, uint, 0);
+MODULE_PARM_DESC(sens, "Sensitivity");

I don't see out-of-file usages... these could be static.

...

Review

Quoted 6 lines
(quoted diff) +1 -0
+	static int name(char* page, char** start, off_t off, int count, int*

eof, void* data) \

(quoted diff) +4 -0
+	{ \
+		int len; \
+		struct psmouse *psmouse = (struct psmouse *)data; \
+		struct trackpoint_data *tp = (struct trackpoint_data*)psmouse->private; \

No need to cast (void *).

...

Review

Quoted 9 lines

+static int scroll_write_func(struct file *file, const char __user *buffer, unsigned long count, void *data)

(quoted diff) +7 -0
+{
+	int len = count;
+	unsigned char tmp[5];
+	struct psmouse *psmouse = (struct psmouse *)data;
+	struct trackpoint_data *tp = (struct trackpoint_data*)psmouse->private;
+	if(count > sizeof(tmp) - 1)
+		len = sizeof(tmp) - 1;

How about: len = min(count, sizeof(tmp) - 1);?

...

Quoted 1 line

+no_ext_dev:

Nitpick:
Some like ' ' before label (makes diff -pu patches more readable)

Domen