2005-03-14 05:05:42

by Stephen Evanchik

[permalink] [raw]
Subject: [PATCH 2.6.11] IBM TrackPoint support

Here's the latest patch for TracKPoint devices. I have changed the
sysfs filenames to be more descriptive for commonly used attributes. I
also implemented the set_properties flag for initialization.

It patches against 2.6.11 and 2.6.11.3 however I have not tested it
with 2.6.11.3 .

Any comments are appreciated.


Stephen


--- a/drivers/input/mouse/trackpoint.c 1969-12-31 19:00:00.000000000 -0500
+++ b/drivers/input/mouse/trackpoint.c 2005-03-13 23:43:14.000000000 -0500
@@ -0,0 +1,352 @@
+/*
+ * Stephen Evanchik <[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.
+ *
+ * Trademarks are the property of their respective owners.
+ *
+ * 13/02/2005 - Removed middle button scroll, see Xorg for
+ * scroll emulation.
+ *
+ * 03/02/2005 - Remove proc and module parameters
+ * Added sysfs attributes
+ *
+ * 29/01/2005 - Fixed UltraNav support
+ * Moved to libps2 interface
+ * Renamed internal property variables to be consistent with reference docs
+ * Fixed negative inertia not being set properly
+ * Added middle button scroll module parameter
+ *
+ */
+
+#include <linux/delay.h>
+#include <linux/serio.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/input.h>
+#include <linux/libps2.h>
+#include <linux/proc_fs.h>
+#include <asm/uaccess.h>
+#include "psmouse.h"
+#include "trackpoint.h"
+
+
+PSMOUSE_DEFINE_ATTR(sensitivity);
+PSMOUSE_DEFINE_ATTR(speed);
+PSMOUSE_DEFINE_ATTR(inertia);
+PSMOUSE_DEFINE_ATTR(reach);
+PSMOUSE_DEFINE_ATTR(draghys);
+PSMOUSE_DEFINE_ATTR(mindrag);
+PSMOUSE_DEFINE_ATTR(thresh);
+PSMOUSE_DEFINE_ATTR(upthresh);
+PSMOUSE_DEFINE_ATTR(ztime);
+PSMOUSE_DEFINE_ATTR(jenks);
+PSMOUSE_DEFINE_ATTR(press_to_select);
+PSMOUSE_DEFINE_ATTR(skipback);
+PSMOUSE_DEFINE_ATTR(middle_btn_disable);
+PSMOUSE_DEFINE_ATTR(ext_dev);
+PSMOUSE_DEFINE_ATTR(transparent);
+
+
+#define MAKE_ATTR_READ(_item) \
+ static ssize_t psmouse_attr_show_##_item(struct psmouse *psmouse, char *buf) \
+ { \
+ struct trackpoint_data *tp = psmouse->private; \
+ return sprintf(buf, "%lu\n", (unsigned long)tp->_item); \
+ }
+
+#define MAKE_ATTR_WRITE(_item, command) \
+ static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse,
const char *buf, size_t count) \
+ { \
+ char *rest; \
+ unsigned long value; \
+ struct trackpoint_data *tp = psmouse->private; \
+ value = simple_strtoul(buf, &rest, 10); \
+ if(*rest) \
+ return -EINVAL; \
+ tp->_item = value; \
+ trackpoint_write(&psmouse->ps2dev, command, tp->_item); \
+ return count; \
+ }
+
+#define MAKE_ATTR_TOGGLE(_item, command, mask) \
+ static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse,
const char *buf, size_t count) \
+ { \
+ unsigned char toggle; \
+ struct trackpoint_data *tp = psmouse->private; \
+ toggle = (buf[0] == '1') ? 1 : 0; \
+ if( toggle != tp->_item) { \
+ tp->_item = toggle; \
+ trackpoint_toggle_bit(&psmouse->ps2dev, command, mask); \
+ } \
+ return count; \
+ }
+
+
+/*
+ * 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));
+}
+
+static void trackpoint_read(struct ps2dev *ps2dev, unsigned char loc,
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;
+}
+
+
+MAKE_ATTR_WRITE(sensitivity, TP_SENS);
+MAKE_ATTR_READ(sensitivity);
+
+MAKE_ATTR_WRITE(speed, TP_SPEED);
+MAKE_ATTR_READ(speed);
+
+MAKE_ATTR_WRITE(inertia, TP_INERTIA);
+MAKE_ATTR_READ(inertia);
+
+MAKE_ATTR_WRITE(reach, TP_REACH);
+MAKE_ATTR_READ(reach);
+
+MAKE_ATTR_WRITE(draghys, TP_DRAGHYS);
+MAKE_ATTR_READ(draghys);
+
+MAKE_ATTR_WRITE(mindrag, TP_MINDRAG);
+MAKE_ATTR_READ(mindrag);
+
+MAKE_ATTR_WRITE(thresh, TP_THRESH);
+MAKE_ATTR_READ(thresh);
+
+MAKE_ATTR_WRITE(upthresh, TP_UP_THRESH);
+MAKE_ATTR_READ(upthresh);
+
+MAKE_ATTR_WRITE(ztime, TP_Z_TIME);
+MAKE_ATTR_READ(ztime);
+
+MAKE_ATTR_WRITE(jenks, TP_JENKS_CURV);
+MAKE_ATTR_READ(jenks);
+
+MAKE_ATTR_TOGGLE(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON);
+MAKE_ATTR_READ(press_to_select);
+
+MAKE_ATTR_TOGGLE(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK);
+MAKE_ATTR_READ(skipback);
+
+MAKE_ATTR_TOGGLE(middle_btn_disable, TP_TOGGLE_MB, TP_MASK_MB);
+MAKE_ATTR_READ(middle_btn_disable);
+
+MAKE_ATTR_TOGGLE(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV);
+MAKE_ATTR_READ(ext_dev);
+
+/* MAKE_ATTR_WRITE( ) for Soft Transparent mode */
+static ssize_t psmouse_attr_set_transparent(struct psmouse *psmouse,
const char *buf, size_t count)
+{
+ unsigned char command;
+
+ struct trackpoint_data *tp = psmouse->private;
+
+ tp->transparent = (buf[0] == '1') ? 1 : 0;
+
+ command = (tp->transparent) ? TP_SET_SOFT_TRANS : TP_CANCEL_SOFT_TRANS;
+
+ trackpoint_command(&psmouse->ps2dev, command);
+
+ return count;
+}
+
+MAKE_ATTR_READ(transparent);
+
+
+static void trackpoint_disconnect(struct psmouse *psmouse)
+{
+ struct serio *serio = psmouse->ps2dev.serio;
+
+ device_remove_file(&serio->dev, &psmouse_attr_sensitivity);
+ device_remove_file(&serio->dev, &psmouse_attr_speed);
+ device_remove_file(&serio->dev, &psmouse_attr_inertia);
+ device_remove_file(&serio->dev, &psmouse_attr_reach);
+ device_remove_file(&serio->dev, &psmouse_attr_draghys);
+ device_remove_file(&serio->dev, &psmouse_attr_mindrag);
+ device_remove_file(&serio->dev, &psmouse_attr_thresh);
+ device_remove_file(&serio->dev, &psmouse_attr_upthresh);
+ device_remove_file(&serio->dev, &psmouse_attr_ztime);
+ device_remove_file(&serio->dev, &psmouse_attr_jenks);
+ device_remove_file(&serio->dev, &psmouse_attr_press_to_select);
+ device_remove_file(&serio->dev, &psmouse_attr_skipback);
+ device_remove_file(&serio->dev, &psmouse_attr_middle_btn_disable);
+ device_remove_file(&serio->dev, &psmouse_attr_ext_dev);
+ device_remove_file(&serio->dev, &psmouse_attr_transparent);
+
+ kfree(psmouse->private);
+
+ psmouse->private = NULL;
+}
+
+static int trackpoint_sync(struct psmouse *psmouse)
+{
+ unsigned char toggle;
+ struct trackpoint_data *tp = psmouse->private;
+
+ if(!tp)
+ return -1;
+
+ /* Push the config to the device */
+
+ trackpoint_write(&psmouse->ps2dev, TP_SENS, tp->sensitivity);
+ 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->upthresh);
+
+ trackpoint_write(&psmouse->ps2dev, TP_Z_TIME, tp->ztime);
+ trackpoint_write(&psmouse->ps2dev, TP_JENKS_CURV, tp->jenks);
+
+
+ trackpoint_read(&psmouse->ps2dev, TP_TOGGLE_PTSON, &toggle);
+ if(((toggle & TP_MASK_PTSON) == TP_MASK_PTSON)!= tp->press_to_select)
+ 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->middle_btn_disable)
+ 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->middle_btn_disable)
+ 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->press_to_select = TP_DEF_PTSON;
+ tp->sensitivity = TP_DEF_SENS;
+ tp->speed = TP_DEF_SPEED;
+ tp->reach = TP_DEF_REACH;
+
+ tp->draghys = TP_DEF_DRAGHYS;
+ tp->mindrag = TP_DEF_MINDRAG;
+
+ tp->thresh = TP_DEF_THRESH;
+ tp->upthresh = TP_DEF_UP_THRESH;
+
+ tp->ztime = TP_DEF_Z_TIME;
+ tp->jenks = TP_DEF_JENKS_CURV;
+
+ tp->middle_btn_disable = TP_DEF_MB;
+
+ tp->inertia = TP_DEF_INERTIA;
+ tp->skipback = TP_DEF_SKIPBACK;
+ tp->ext_dev = TP_DEF_EXT_DEV;
+}
+
+
+
+int trackpoint_init(struct psmouse *psmouse, int set_properties)
+{
+ unsigned char param[2];
+ struct trackpoint_data *priv;
+
+ struct ps2dev *ps2dev = &psmouse->ps2dev;
+ struct serio *serio = ps2dev->serio;
+
+ param[0] = param[1] = 0;
+
+ if(ps2_command(ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID)))
+ return -1;
+
+ if(param[0] != TP_MAGIC_IDENT)
+ return -1;
+
+ if(!set_properties)
+ return 0;
+
+ 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_sync(psmouse);
+
+ psmouse->vendor = "IBM";
+ psmouse->name = "TrackPoint";
+
+ psmouse->reconnect = trackpoint_sync;
+ psmouse->disconnect = trackpoint_disconnect;
+
+ device_create_file(&serio->dev, &psmouse_attr_sensitivity);
+ device_create_file(&serio->dev, &psmouse_attr_speed);
+ device_create_file(&serio->dev, &psmouse_attr_inertia);
+ device_create_file(&serio->dev, &psmouse_attr_reach);
+ device_create_file(&serio->dev, &psmouse_attr_draghys);
+ device_create_file(&serio->dev, &psmouse_attr_mindrag);
+ device_create_file(&serio->dev, &psmouse_attr_thresh);
+ device_create_file(&serio->dev, &psmouse_attr_upthresh);
+ device_create_file(&serio->dev, &psmouse_attr_ztime);
+ device_create_file(&serio->dev, &psmouse_attr_jenks);
+ device_create_file(&serio->dev, &psmouse_attr_press_to_select);
+ device_create_file(&serio->dev, &psmouse_attr_skipback);
+ device_create_file(&serio->dev, &psmouse_attr_middle_btn_disable);
+ device_create_file(&serio->dev, &psmouse_attr_ext_dev);
+ device_create_file(&serio->dev, &psmouse_attr_transparent);
+
+ printk(KERN_INFO "IBM TrackPoint firmware: 0x%02X\n", param[1]);
+
+ return 0;
+}
+
--- a/drivers/input/mouse/trackpoint.h 1969-12-31 19:00:00.000000000 -0500
+++ b/drivers/input/mouse/trackpoint.h 2005-03-02 21:39:27.000000000 -0500
@@ -0,0 +1,157 @@
+/*
+ * IBM TrackPoint PS/2 mouse driver
+ *
+ * Stephen Evanchik <[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 _TRACKPOINT_H
+#define _TRACKPOINT_H
+
+/*
+ * These constants are from the TrackPoint System
+ * Engineering documentation Version 4 from IBM Watson
+ * research:
+ * http://wwwcssrv.almaden.ibm.com/trackpoint/download.html
+ */
+
+#define TP_COMMAND (0xE2) /* Commands start with this */
+
+#define TP_READ_ID (0xE1) /* Sent for device identification */
+#define TP_MAGIC_IDENT (0x01) /* Sent after a TP_READ_ID followed */
+ /* by the firmware ID */
+
+
+/*
+ * Commands
+ */
+#define TP_RECALIB (0x51) /* Recalibrate */
+#define TP_POWER_DOWN (0x44) /* Can only be undone through HW reset */
+#define TP_EXT_DEV (0x21) /* Determines if external device is connected (RO) */
+#define TP_EXT_BTN (0x4B) /* Read extended button status */
+#define TP_POR (0x7F) /* Execute Power on Reset */
+#define TP_POR_RESULTS (0x25) /* Read Power on Self test results */
+#define TP_DISABLE_EXT (0x40) /* Disable external pointing device */
+#define TP_ENABLE_EXT (0x41) /* Enable external pointing device */
+
+/*
+ * Mode manipulation
+ */
+#define TP_SET_SOFT_TRANS (0x4E) /* Set mode */
+#define TP_CANCEL_SOFT_TRANS (0xB9) /* Cancel mode */
+#define TP_SET_HARD_TRANS (0x45) /* Mode can only be set */
+
+
+/*
+ * Register oriented commands/properties
+ */
+#define TP_WRITE_MEM (0x81)
+#define TP_READ_MEM (0x80) /* Not used in this implementation */
+
+/*
+* RAM Locations for properties
+ */
+#define TP_SENS (0x4A) /* Sensitivity */
+#define TP_MB (0x4C) /* Read Middle Button Status (RO) */
+#define TP_INERTIA (0x4D) /* Negative Inertia */
+#define TP_SPEED (0x60) /* Speed of TP Cursor */
+#define TP_REACH (0x57) /* Backup for Z-axis press */
+#define TP_DRAGHYS (0x58) /* Drag Hysteresis */
+ /* (how hard it is to drag */
+ /* with Z-axis pressed) */
+
+#define TP_MINDRAG (0x59) /* Minimum amount of force needed */
+ /* to trigger dragging */
+
+#define TP_THRESH (0x5C) /* Minimum value for a Z-axis press */
+#define TP_UP_THRESH (0x5A) /* Used to generate a 'click' on Z-axis */
+#define TP_Z_TIME (0x5E) /* How sharp of a press */
+#define TP_JENKS_CURV (0x5D) /* Minimum curvature for double click */
+
+/*
+ * Toggling Flag bits
+ */
+#define TP_TOGGLE (0x47) /* Toggle command */
+
+#define TP_TOGGLE_MB (0x23) /* Disable/Enable Middle Button */
+#define TP_TOGGLE_DRIFT (0x23) /* Drift Correction */
+#define TP_TOGGLE_BURST (0x28) /* Burst Mode */
+#define TP_TOGGLE_PTSON (0x2C) /* Press to Select */
+#define TP_TOGGLE_HARD_TRANS (0x2C) /* Alternate method to set Hard
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 MAKE_PS2_CMD(params, results, cmd) ((params<<12) |
(results<<8) | (cmd))
+
+
+
+struct trackpoint_data
+{
+ unsigned char firmware_id;
+
+ unsigned char sensitivity, speed, inertia, reach;
+ unsigned char draghys, mindrag;
+ unsigned char thresh, upthresh;
+ unsigned char ztime, jenks;
+
+ unsigned char press_to_select;
+ unsigned char twohand, skipback;
+ unsigned char middle_btn_disable;
+
+ unsigned char ext_dev;
+ unsigned char transparent;
+ unsigned char source_tag;
+
+};
+
+extern int trackpoint_init (struct psmouse *psmouse, int set_properties);
+
+#endif /* _TRACKPOINT_H */
--- a/drivers/input/mouse/Makefile 2005-03-02 02:37:50.000000000 -0500
+++ b/drivers/input/mouse/Makefile 2005-03-02 21:18:36.000000000 -0500
@@ -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
--- a/drivers/input/mouse/psmouse-base.c 2005-03-02 02:37:50.000000000 -0500
+++ b/drivers/input/mouse/psmouse-base.c 2005-03-02 21:48:25.000000000 -0500
@@ -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"
@@ -62,7 +63,7 @@
__obsolete_setup("psmouse_resetafter=");
__obsolete_setup("psmouse_rate=");

-static char *psmouse_protocols[] = { "None", "PS/2", "PS2++",
"ThinkPS/2", "GenPS/2", "ImPS/2", "ImExPS/2", "SynPS/2", "AlpsPS/2" };
+static char *psmouse_protocols[] = { "None", "PS/2", "PS2++",
"ThinkPS/2", "GenPS/2", "ImPS/2", "ImExPS/2", "SynPS/2", "AlpsPS/2",
"TrackPoint" };

/*
* psmouse_process_byte() analyzes the PS/2 data stream and reports
@@ -482,6 +483,12 @@
return PSMOUSE_IMPS;

/*
+ * Try to initialize the IBM TrackPoint
+ */
+ if (max_proto > PSMOUSE_PS2 && trackpoint_init(psmouse, set_properties) == 0)
+ return PSMOUSE_TRACKPOINT;
+
+/*
* Okay, all failed, we have a standard mouse here. The number of the buttons
* is still a question, though. We assume 3.
*/


2005-03-14 05:30:53

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 2.6.11] IBM TrackPoint support

On Monday 14 March 2005 00:02, Stephen Evanchik wrote:
> Here's the latest patch for TracKPoint devices. I have changed the
> sysfs filenames to be more descriptive for commonly used attributes. I
> also implemented the set_properties flag for initialization.
>
> It patches against 2.6.11 and 2.6.11.3 however I have not tested it
> with 2.6.11.3 .
>
> Any comments are appreciated.
>

Hi Stephen,

It looks very good now, I have just a couple of comments and I as far as
I concerned it is ready for inclusion.

> +PSMOUSE_DEFINE_ATTR(middle_btn_disable);

Is it possible to change it for positive (something like middle_button
which would show 1 for enabled - default - and 0 for disabled). But this
is my personal preference, others may disagree.

> +#define MAKE_ATTR_WRITE(_item, command) \
> + static ssize_t psmouse_attr_set_##_item(struct psmouse *psmouse,
> const char *buf, size_t count) \

It looks like your mailer has wrapped the patch.

Also the patch has some trailing whitespace. If you are using vim the
foillowing in .vimrc will show all trailing spaces in all their glory:

highlight RedundantWhitespace ctermbg=red guibg=red
match RedundantWhitespace /\s\+$\| \+\ze\t/

--
Dmitry

2005-03-14 08:19:07

by Vojtech Pavlik

[permalink] [raw]
Subject: Re: [PATCH 2.6.11] IBM TrackPoint support

On Mon, Mar 14, 2005 at 12:02:13AM -0500, Stephen Evanchik wrote:

> Here's the latest patch for TracKPoint devices. I have changed the
> sysfs filenames to be more descriptive for commonly used attributes. I
> also implemented the set_properties flag for initialization.
>
> It patches against 2.6.11 and 2.6.11.3 however I have not tested it
> with 2.6.11.3 .
>
> Any comments are appreciated.

> +/*
> + * Mode manipulation
> + */
> +#define TP_SET_SOFT_TRANS (0x4E) /* Set mode */
> +#define TP_CANCEL_SOFT_TRANS (0xB9) /* Cancel mode */
> +#define TP_SET_HARD_TRANS (0x45) /* Mode can only be set */

What exactly is transparent mode?

--
Vojtech Pavlik
SuSE Labs, SuSE CR

2005-03-14 12:01:27

by Stephen Evanchik

[permalink] [raw]
Subject: Re: [PATCH 2.6.11] IBM TrackPoint support

On Mon, 14 Mar 2005 09:19:49 +0100, Vojtech Pavlik <[email protected]> wrote:
> > +/*
> > + * Mode manipulation
> > + */
> > +#define TP_SET_SOFT_TRANS (0x4E) /* Set mode */
> > +#define TP_CANCEL_SOFT_TRANS (0xB9) /* Cancel mode */
> > +#define TP_SET_HARD_TRANS (0x45) /* Mode can only be set */
>
> What exactly is transparent mode?

Transparency mode, when enabled, turns off the TrackPoint controller's
interpretation of the byte stream going to and coming from the
external PS/2 port if present.

Soft transparency mode can be cancelled, while hard transparency mode
requires a reset of the device and possibly the machine.

Stephen

2005-03-14 12:19:25

by Vojtech Pavlik

[permalink] [raw]
Subject: Re: [PATCH 2.6.11] IBM TrackPoint support

On Mon, Mar 14, 2005 at 07:01:23AM -0500, Stephen Evanchik wrote:
> On Mon, 14 Mar 2005 09:19:49 +0100, Vojtech Pavlik <[email protected]> wrote:
> > > +/*
> > > + * Mode manipulation
> > > + */
> > > +#define TP_SET_SOFT_TRANS (0x4E) /* Set mode */
> > > +#define TP_CANCEL_SOFT_TRANS (0xB9) /* Cancel mode */
> > > +#define TP_SET_HARD_TRANS (0x45) /* Mode can only be set */
> >
> > What exactly is transparent mode?
>
> Transparency mode, when enabled, turns off the TrackPoint controller's
> interpretation of the byte stream going to and coming from the
> external PS/2 port if present.
>
> Soft transparency mode can be cancelled, while hard transparency mode
> requires a reset of the device and possibly the machine.

How much does it interpret the stream in non-transparent mode? Are
commands also passed through in soft transparent mode?

I'm asking because we might want to implement a passthrough port
similarly to what the Synaptics driver does and allow extended protocol
mice to be connected to the external mouse port.

--
Vojtech Pavlik
SuSE Labs, SuSE CR

2005-03-14 13:43:04

by Stephen Evanchik

[permalink] [raw]
Subject: Re: [PATCH 2.6.11] IBM TrackPoint support

On Mon, 14 Mar 2005 13:19:56 +0100, Vojtech Pavlik <[email protected]> wrote:
> How much does it interpret the stream in non-transparent mode? Are
> commands also passed through in soft transparent mode?
>
> I'm asking because we might want to implement a passthrough port
> similarly to what the Synaptics driver does and allow extended protocol
> mice to be connected to the external mouse port.

I originally thought that I could implement something similar to the
Synaptics driver. Unfortunately, while in transparent mode bytes are
relayed unmodified with the TrackPoint controller disabled. In other
words, no simultaneous usage.

That doesn't mean extended protocol mice couldn't be supported in
transparent mode however. I didn't find it particularly useful given
the TrackPoint itself would be disabled.

2005-03-15 00:44:56

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 2.6.11] IBM TrackPoint support

On Mon, 14 Mar 2005 08:40:22 -0500, Stephen Evanchik <[email protected]> wrote:
> On Mon, 14 Mar 2005 13:19:56 +0100, Vojtech Pavlik <[email protected]> wrote:
> > How much does it interpret the stream in non-transparent mode? Are
> > commands also passed through in soft transparent mode?
> >
> > I'm asking because we might want to implement a passthrough port
> > similarly to what the Synaptics driver does and allow extended protocol
> > mice to be connected to the external mouse port.
>
> I originally thought that I could implement something similar to the
> Synaptics driver. Unfortunately, while in transparent mode bytes are
> relayed unmodified with the TrackPoint controller disabled. In other
> words, no simultaneous usage.
>
> That doesn't mean extended protocol mice couldn't be supported in
> transparent mode however. I didn't find it particularly useful given
> the TrackPoint itself would be disabled.
>

Here is my take on it (now that I have skimmed the TrackPint spec) -
transparent mode is to be used only when querying the external device.
This way trackpoint does not interfere with data stream at all and the
kernel gets a chance to know exactly whta is behing the trackpoint -
Logitech, explorer, something more exotic... Once identification is
done transparent mode should be cancelled.

Bit 3 can be used to de-multiplex 2 streams; hopefully trackpoint is
able to rely packets longer than 3 bytes from the external device.

As far as I can see there is no point of exporting transparent mode to
the userspace via sysfs. I also do not think that we need to export
middle_button_disable as it is "..for compatibility with older
software expecting this bit be always 0" and we do not have such an
issue. Also, if we implement pass-through port, then ext_dev is also
not needed since user can either unbind the driver from pass-through
port or just ignore the secondary input device in his/her config.

--
Dmitry

2005-03-15 20:22:14

by Stephen Evanchik

[permalink] [raw]
Subject: Re: [PATCH 2.6.11] IBM TrackPoint support

On Tue, 15 Mar 2005 20:49:25 +0100, Paweł Sikora <[email protected]> wrote:
> On Monday 14 of March 2005 06:02, Stephen Evanchik wrote:
> > Here's the latest patch for TracKPoint devices. I have changed the
> > sysfs filenames to be more descriptive for commonly used attributes. I
> > also implemented the set_properties flag for initialization.
> >
> > It patches against 2.6.11 and 2.6.11.3 however I have not tested it
> > with 2.6.11.3 .
> >
> > Any comments are appreciated.
>
> CC [M] drivers/input/mouse/psmouse-base.o
> drivers/input/mouse/psmouse-base.c: In function 'psmouse_extensions':
> drivers/input/mouse/psmouse-base.c:489: error: 'PSMOUSE_TRACKPOINT' undeclared
>
> ;-)

Thanks, I noticed this last night and have it fixed in the new patch
yet to be submitted ;)


Stephen

2005-03-15 19:54:55

by Paweł Sikora

[permalink] [raw]
Subject: Re: [PATCH 2.6.11] IBM TrackPoint support

On Monday 14 of March 2005 06:02, Stephen Evanchik wrote:
> Here's the latest patch for TracKPoint devices. I have changed the
> sysfs filenames to be more descriptive for commonly used attributes. I
> also implemented the set_properties flag for initialization.
>
> It patches against 2.6.11 and 2.6.11.3 however I have not tested it
> with 2.6.11.3 .
>
> Any comments are appreciated.

CC [M] drivers/input/mouse/psmouse-base.o
drivers/input/mouse/psmouse-base.c: In function 'psmouse_extensions':
drivers/input/mouse/psmouse-base.c:489: error: 'PSMOUSE_TRACKPOINT' undeclared

;-)

--
/* Copyright (C) 2003, SCO, Inc. This is valuable Intellectual Property. */

#define say(x) lie(x)


Attachments:
(No filename) (718.00 B)
1.diff (351.00 B)
Download all attachments