2019-06-04 16:11:33 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-08-08 14:26:18 +08:00
|
|
|
/*
|
|
|
|
* Stephen Evanchik <evanchsa@gmail.com>
|
|
|
|
*
|
|
|
|
* Trademarks are the property of their respective owners.
|
|
|
|
*/
|
|
|
|
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-08-08 14:26:18 +08:00
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/serio.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <linux/libps2.h>
|
|
|
|
#include <linux/proc_fs.h>
|
2016-12-25 03:46:01 +08:00
|
|
|
#include <linux/uaccess.h>
|
2005-08-08 14:26:18 +08:00
|
|
|
#include "psmouse.h"
|
|
|
|
#include "trackpoint.h"
|
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
static const char * const trackpoint_variants[] = {
|
2020-09-15 03:19:08 +08:00
|
|
|
[TP_VARIANT_IBM] = "IBM",
|
|
|
|
[TP_VARIANT_ALPS] = "ALPS",
|
|
|
|
[TP_VARIANT_ELAN] = "Elan",
|
|
|
|
[TP_VARIANT_NXP] = "NXP",
|
|
|
|
[TP_VARIANT_JYT_SYNAPTICS] = "JYT_Synaptics",
|
|
|
|
[TP_VARIANT_SYNAPTICS] = "Synaptics",
|
2018-01-06 05:28:47 +08:00
|
|
|
};
|
|
|
|
|
2013-04-16 04:49:34 +08:00
|
|
|
/*
|
|
|
|
* Power-on Reset: Resets all trackpoint parameters, including RAM values,
|
|
|
|
* to defaults.
|
|
|
|
* Returns zero on success, non-zero on failure.
|
|
|
|
*/
|
|
|
|
static int trackpoint_power_on_reset(struct ps2dev *ps2dev)
|
|
|
|
{
|
2018-01-05 14:52:55 +08:00
|
|
|
u8 param[2] = { TP_POR };
|
|
|
|
int err;
|
2013-04-16 04:49:34 +08:00
|
|
|
|
2018-01-05 14:52:55 +08:00
|
|
|
err = ps2_command(ps2dev, param, MAKE_PS2_CMD(1, 2, TP_COMMAND));
|
|
|
|
if (err)
|
|
|
|
return err;
|
2013-04-16 04:49:34 +08:00
|
|
|
|
|
|
|
/* Check for success response -- 0xAA00 */
|
2018-01-05 14:52:55 +08:00
|
|
|
if (param[0] != 0xAA || param[1] != 0x00)
|
2018-01-06 05:28:47 +08:00
|
|
|
return -ENODEV;
|
2013-04-16 04:49:34 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-08-08 14:26:18 +08:00
|
|
|
/*
|
|
|
|
* Device IO: read, write and toggle bit
|
|
|
|
*/
|
2018-01-06 05:28:47 +08:00
|
|
|
static int trackpoint_read(struct ps2dev *ps2dev, u8 loc, u8 *results)
|
2005-08-08 14:26:18 +08:00
|
|
|
{
|
2018-01-05 14:52:55 +08:00
|
|
|
results[0] = loc;
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2018-01-05 14:52:55 +08:00
|
|
|
return ps2_command(ps2dev, results, MAKE_PS2_CMD(1, 1, TP_COMMAND));
|
2005-08-08 14:26:18 +08:00
|
|
|
}
|
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
static int trackpoint_write(struct ps2dev *ps2dev, u8 loc, u8 val)
|
2005-08-08 14:26:18 +08:00
|
|
|
{
|
2018-01-05 14:52:55 +08:00
|
|
|
u8 param[3] = { TP_WRITE_MEM, loc, val };
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2018-01-05 14:52:55 +08:00
|
|
|
return ps2_command(ps2dev, param, MAKE_PS2_CMD(3, 0, TP_COMMAND));
|
2005-08-08 14:26:18 +08:00
|
|
|
}
|
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
static int trackpoint_toggle_bit(struct ps2dev *ps2dev, u8 loc, u8 mask)
|
2005-08-08 14:26:18 +08:00
|
|
|
{
|
2018-01-05 14:52:55 +08:00
|
|
|
u8 param[3] = { TP_TOGGLE, loc, mask };
|
|
|
|
|
2005-08-08 14:26:18 +08:00
|
|
|
/* Bad things will happen if the loc param isn't in this range */
|
|
|
|
if (loc < 0x20 || loc >= 0x2F)
|
2018-01-05 14:52:55 +08:00
|
|
|
return -EINVAL;
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2018-01-05 14:52:55 +08:00
|
|
|
return ps2_command(ps2dev, param, MAKE_PS2_CMD(3, 0, TP_COMMAND));
|
2005-08-08 14:26:18 +08:00
|
|
|
}
|
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
static int trackpoint_update_bit(struct ps2dev *ps2dev,
|
|
|
|
u8 loc, u8 mask, u8 value)
|
2013-04-16 04:49:34 +08:00
|
|
|
{
|
2018-01-05 14:52:55 +08:00
|
|
|
int retval;
|
2018-01-06 05:28:47 +08:00
|
|
|
u8 data;
|
2013-04-16 04:49:34 +08:00
|
|
|
|
2018-01-05 14:52:55 +08:00
|
|
|
retval = trackpoint_read(ps2dev, loc, &data);
|
|
|
|
if (retval)
|
|
|
|
return retval;
|
|
|
|
|
2013-04-16 04:49:34 +08:00
|
|
|
if (((data & mask) == mask) != !!value)
|
|
|
|
retval = trackpoint_toggle_bit(ps2dev, loc, mask);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2005-09-04 14:40:20 +08:00
|
|
|
/*
|
|
|
|
* Trackpoint-specific attributes
|
|
|
|
*/
|
|
|
|
struct trackpoint_attr_data {
|
|
|
|
size_t field_offset;
|
2018-01-06 05:28:47 +08:00
|
|
|
u8 command;
|
|
|
|
u8 mask;
|
|
|
|
bool inverted;
|
|
|
|
u8 power_on_default;
|
2005-09-04 14:40:20 +08:00
|
|
|
};
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse,
|
|
|
|
void *data, char *buf)
|
2005-09-04 14:40:20 +08:00
|
|
|
{
|
|
|
|
struct trackpoint_data *tp = psmouse->private;
|
|
|
|
struct trackpoint_attr_data *attr = data;
|
2018-01-06 05:28:47 +08:00
|
|
|
u8 value = *(u8 *)((void *)tp + attr->field_offset);
|
2006-02-15 13:49:09 +08:00
|
|
|
|
|
|
|
if (attr->inverted)
|
|
|
|
value = !value;
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2006-02-15 13:49:09 +08:00
|
|
|
return sprintf(buf, "%u\n", value);
|
2005-09-04 14:40:20 +08:00
|
|
|
}
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2005-09-04 14:40:20 +08:00
|
|
|
static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct trackpoint_data *tp = psmouse->private;
|
|
|
|
struct trackpoint_attr_data *attr = data;
|
2018-01-06 05:28:47 +08:00
|
|
|
u8 *field = (void *)tp + attr->field_offset;
|
|
|
|
u8 value;
|
2011-11-10 02:20:14 +08:00
|
|
|
int err;
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2011-11-10 02:20:14 +08:00
|
|
|
err = kstrtou8(buf, 10, &value);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2005-09-04 14:40:20 +08:00
|
|
|
*field = value;
|
2018-01-05 14:52:55 +08:00
|
|
|
err = trackpoint_write(&psmouse->ps2dev, attr->command, value);
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2018-01-05 14:52:55 +08:00
|
|
|
return err ?: count;
|
2005-09-04 14:40:20 +08:00
|
|
|
}
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2013-04-16 04:49:34 +08:00
|
|
|
#define TRACKPOINT_INT_ATTR(_name, _command, _default) \
|
2005-09-04 14:40:20 +08:00
|
|
|
static struct trackpoint_attr_data trackpoint_attr_##_name = { \
|
|
|
|
.field_offset = offsetof(struct trackpoint_data, _name), \
|
|
|
|
.command = _command, \
|
2013-04-16 04:49:34 +08:00
|
|
|
.power_on_default = _default, \
|
2005-09-04 14:40:20 +08:00
|
|
|
}; \
|
|
|
|
PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \
|
|
|
|
&trackpoint_attr_##_name, \
|
|
|
|
trackpoint_show_int_attr, trackpoint_set_int_attr)
|
|
|
|
|
|
|
|
static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct trackpoint_data *tp = psmouse->private;
|
|
|
|
struct trackpoint_attr_data *attr = data;
|
2018-01-06 05:28:47 +08:00
|
|
|
bool *field = (void *)tp + attr->field_offset;
|
|
|
|
bool value;
|
2011-11-10 02:20:14 +08:00
|
|
|
int err;
|
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
err = kstrtobool(buf, &value);
|
2011-11-10 02:20:14 +08:00
|
|
|
if (err)
|
|
|
|
return err;
|
2005-09-04 14:40:20 +08:00
|
|
|
|
2006-02-15 13:49:09 +08:00
|
|
|
if (attr->inverted)
|
|
|
|
value = !value;
|
|
|
|
|
2005-09-04 14:40:20 +08:00
|
|
|
if (*field != value) {
|
|
|
|
*field = value;
|
2018-01-05 14:52:55 +08:00
|
|
|
err = trackpoint_toggle_bit(&psmouse->ps2dev,
|
|
|
|
attr->command, attr->mask);
|
2005-09-04 14:40:20 +08:00
|
|
|
}
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2018-01-05 14:52:55 +08:00
|
|
|
return err ?: count;
|
2005-09-04 14:40:20 +08:00
|
|
|
}
|
2005-08-08 14:26:18 +08:00
|
|
|
|
|
|
|
|
2013-04-16 04:49:34 +08:00
|
|
|
#define TRACKPOINT_BIT_ATTR(_name, _command, _mask, _inv, _default) \
|
|
|
|
static struct trackpoint_attr_data trackpoint_attr_##_name = { \
|
|
|
|
.field_offset = offsetof(struct trackpoint_data, \
|
|
|
|
_name), \
|
|
|
|
.command = _command, \
|
|
|
|
.mask = _mask, \
|
|
|
|
.inverted = _inv, \
|
|
|
|
.power_on_default = _default, \
|
|
|
|
}; \
|
|
|
|
PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \
|
|
|
|
&trackpoint_attr_##_name, \
|
|
|
|
trackpoint_show_int_attr, trackpoint_set_bit_attr)
|
|
|
|
|
|
|
|
TRACKPOINT_INT_ATTR(sensitivity, TP_SENS, TP_DEF_SENS);
|
|
|
|
TRACKPOINT_INT_ATTR(speed, TP_SPEED, TP_DEF_SPEED);
|
|
|
|
TRACKPOINT_INT_ATTR(inertia, TP_INERTIA, TP_DEF_INERTIA);
|
|
|
|
TRACKPOINT_INT_ATTR(reach, TP_REACH, TP_DEF_REACH);
|
|
|
|
TRACKPOINT_INT_ATTR(draghys, TP_DRAGHYS, TP_DEF_DRAGHYS);
|
|
|
|
TRACKPOINT_INT_ATTR(mindrag, TP_MINDRAG, TP_DEF_MINDRAG);
|
|
|
|
TRACKPOINT_INT_ATTR(thresh, TP_THRESH, TP_DEF_THRESH);
|
|
|
|
TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH, TP_DEF_UP_THRESH);
|
|
|
|
TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME, TP_DEF_Z_TIME);
|
|
|
|
TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV, TP_DEF_JENKS_CURV);
|
2014-12-18 07:22:08 +08:00
|
|
|
TRACKPOINT_INT_ATTR(drift_time, TP_DRIFT_TIME, TP_DEF_DRIFT_TIME);
|
2013-04-16 04:49:34 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, false,
|
2013-04-16 04:49:34 +08:00
|
|
|
TP_DEF_PTSON);
|
2018-01-06 05:28:47 +08:00
|
|
|
TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK, false,
|
2013-04-16 04:49:34 +08:00
|
|
|
TP_DEF_SKIPBACK);
|
2018-01-06 05:28:47 +08:00
|
|
|
TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV, true,
|
2013-04-16 04:49:34 +08:00
|
|
|
TP_DEF_EXT_DEV);
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
static bool trackpoint_is_attr_available(struct psmouse *psmouse,
|
|
|
|
struct attribute *attr)
|
|
|
|
{
|
|
|
|
struct trackpoint_data *tp = psmouse->private;
|
|
|
|
|
|
|
|
return tp->variant_id == TP_VARIANT_IBM ||
|
|
|
|
attr == &psmouse_attr_sensitivity.dattr.attr ||
|
|
|
|
attr == &psmouse_attr_press_to_select.dattr.attr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static umode_t trackpoint_is_attr_visible(struct kobject *kobj,
|
|
|
|
struct attribute *attr, int n)
|
|
|
|
{
|
|
|
|
struct device *dev = container_of(kobj, struct device, kobj);
|
|
|
|
struct serio *serio = to_serio_port(dev);
|
|
|
|
struct psmouse *psmouse = serio_get_drvdata(serio);
|
|
|
|
|
|
|
|
return trackpoint_is_attr_available(psmouse, attr) ? attr->mode : 0;
|
|
|
|
}
|
|
|
|
|
2005-08-08 14:26:18 +08:00
|
|
|
static struct attribute *trackpoint_attrs[] = {
|
2005-09-04 14:40:20 +08:00
|
|
|
&psmouse_attr_sensitivity.dattr.attr,
|
|
|
|
&psmouse_attr_speed.dattr.attr,
|
|
|
|
&psmouse_attr_inertia.dattr.attr,
|
|
|
|
&psmouse_attr_reach.dattr.attr,
|
|
|
|
&psmouse_attr_draghys.dattr.attr,
|
|
|
|
&psmouse_attr_mindrag.dattr.attr,
|
|
|
|
&psmouse_attr_thresh.dattr.attr,
|
|
|
|
&psmouse_attr_upthresh.dattr.attr,
|
|
|
|
&psmouse_attr_ztime.dattr.attr,
|
|
|
|
&psmouse_attr_jenks.dattr.attr,
|
2014-12-18 07:22:08 +08:00
|
|
|
&psmouse_attr_drift_time.dattr.attr,
|
2005-09-04 14:40:20 +08:00
|
|
|
&psmouse_attr_press_to_select.dattr.attr,
|
|
|
|
&psmouse_attr_skipback.dattr.attr,
|
|
|
|
&psmouse_attr_ext_dev.dattr.attr,
|
2005-08-08 14:26:18 +08:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group trackpoint_attr_group = {
|
2018-01-06 05:28:47 +08:00
|
|
|
.is_visible = trackpoint_is_attr_visible,
|
|
|
|
.attrs = trackpoint_attrs,
|
2005-08-08 14:26:18 +08:00
|
|
|
};
|
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
#define TRACKPOINT_UPDATE(_power_on, _psmouse, _tp, _name) \
|
|
|
|
do { \
|
|
|
|
struct trackpoint_attr_data *_attr = &trackpoint_attr_##_name; \
|
|
|
|
\
|
|
|
|
if ((!_power_on || _tp->_name != _attr->power_on_default) && \
|
|
|
|
trackpoint_is_attr_available(_psmouse, \
|
|
|
|
&psmouse_attr_##_name.dattr.attr)) { \
|
|
|
|
if (!_attr->mask) \
|
|
|
|
trackpoint_write(&_psmouse->ps2dev, \
|
|
|
|
_attr->command, _tp->_name); \
|
|
|
|
else \
|
|
|
|
trackpoint_update_bit(&_psmouse->ps2dev, \
|
|
|
|
_attr->command, _attr->mask, \
|
|
|
|
_tp->_name); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
#define TRACKPOINT_SET_POWER_ON_DEFAULT(_tp, _name) \
|
|
|
|
do { \
|
|
|
|
_tp->_name = trackpoint_attr_##_name.power_on_default; \
|
|
|
|
} while (0)
|
2006-08-05 10:52:26 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
static int trackpoint_start_protocol(struct psmouse *psmouse,
|
|
|
|
u8 *variant_id, u8 *firmware_id)
|
|
|
|
{
|
|
|
|
u8 param[2] = { 0 };
|
|
|
|
int error;
|
2006-08-05 10:52:26 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
error = ps2_command(&psmouse->ps2dev,
|
|
|
|
param, MAKE_PS2_CMD(0, 2, TP_READ_ID));
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
switch (param[0]) {
|
|
|
|
case TP_VARIANT_IBM:
|
|
|
|
case TP_VARIANT_ALPS:
|
|
|
|
case TP_VARIANT_ELAN:
|
|
|
|
case TP_VARIANT_NXP:
|
|
|
|
if (variant_id)
|
|
|
|
*variant_id = param[0];
|
|
|
|
if (firmware_id)
|
|
|
|
*firmware_id = param[1];
|
|
|
|
return 0;
|
|
|
|
}
|
2006-08-05 10:52:26 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
return -ENODEV;
|
2005-08-08 14:26:18 +08:00
|
|
|
}
|
|
|
|
|
2013-04-16 04:49:34 +08:00
|
|
|
/*
|
|
|
|
* Write parameters to trackpad.
|
|
|
|
* in_power_on_state: Set to true if TP is in default / power-on state (ex. if
|
|
|
|
* power-on reset was run). If so, values will only be
|
|
|
|
* written to TP if they differ from power-on default.
|
|
|
|
*/
|
|
|
|
static int trackpoint_sync(struct psmouse *psmouse, bool in_power_on_state)
|
2005-08-08 14:26:18 +08:00
|
|
|
{
|
|
|
|
struct trackpoint_data *tp = psmouse->private;
|
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
if (!in_power_on_state && tp->variant_id == TP_VARIANT_IBM) {
|
2013-04-16 04:49:34 +08:00
|
|
|
/*
|
|
|
|
* Disable features that may make device unusable
|
|
|
|
* with this driver.
|
|
|
|
*/
|
|
|
|
trackpoint_update_bit(&psmouse->ps2dev, TP_TOGGLE_TWOHAND,
|
|
|
|
TP_MASK_TWOHAND, TP_DEF_TWOHAND);
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2013-04-16 04:49:34 +08:00
|
|
|
trackpoint_update_bit(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG,
|
|
|
|
TP_MASK_SOURCE_TAG, TP_DEF_SOURCE_TAG);
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2013-04-16 04:49:34 +08:00
|
|
|
trackpoint_update_bit(&psmouse->ps2dev, TP_TOGGLE_MB,
|
|
|
|
TP_MASK_MB, TP_DEF_MB);
|
|
|
|
}
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2013-04-16 04:49:34 +08:00
|
|
|
/*
|
|
|
|
* These properties can be changed in this driver. Only
|
|
|
|
* configure them if the values are non-default or if the TP is in
|
|
|
|
* an unknown state.
|
|
|
|
*/
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, sensitivity);
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, inertia);
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, speed);
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, reach);
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, draghys);
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, mindrag);
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, thresh);
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, upthresh);
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, ztime);
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, jenks);
|
2014-12-18 07:22:08 +08:00
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, drift_time);
|
2013-04-16 04:49:34 +08:00
|
|
|
|
|
|
|
/* toggles */
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, press_to_select);
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, skipback);
|
|
|
|
TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, ext_dev);
|
2005-08-08 14:26:18 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void trackpoint_defaults(struct trackpoint_data *tp)
|
|
|
|
{
|
2013-04-16 04:49:34 +08:00
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, sensitivity);
|
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, speed);
|
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, reach);
|
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, draghys);
|
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, mindrag);
|
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, thresh);
|
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, upthresh);
|
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, ztime);
|
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, jenks);
|
2014-12-18 07:22:08 +08:00
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, drift_time);
|
2013-04-16 04:49:34 +08:00
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, inertia);
|
|
|
|
|
|
|
|
/* toggles */
|
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, press_to_select);
|
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, skipback);
|
|
|
|
TRACKPOINT_SET_POWER_ON_DEFAULT(tp, ext_dev);
|
2005-08-08 14:26:18 +08:00
|
|
|
}
|
|
|
|
|
2006-08-05 10:52:26 +08:00
|
|
|
static void trackpoint_disconnect(struct psmouse *psmouse)
|
|
|
|
{
|
2018-01-06 05:28:47 +08:00
|
|
|
device_remove_group(&psmouse->ps2dev.serio->dev,
|
|
|
|
&trackpoint_attr_group);
|
2006-08-05 10:52:26 +08:00
|
|
|
|
|
|
|
kfree(psmouse->private);
|
|
|
|
psmouse->private = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int trackpoint_reconnect(struct psmouse *psmouse)
|
|
|
|
{
|
2018-01-06 05:28:47 +08:00
|
|
|
struct trackpoint_data *tp = psmouse->private;
|
|
|
|
int error;
|
|
|
|
bool was_reset;
|
2013-04-16 04:49:34 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
error = trackpoint_start_protocol(psmouse, NULL, NULL);
|
|
|
|
if (error)
|
|
|
|
return error;
|
2006-08-05 10:52:26 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
was_reset = tp->variant_id == TP_VARIANT_IBM &&
|
|
|
|
trackpoint_power_on_reset(&psmouse->ps2dev) == 0;
|
|
|
|
|
|
|
|
error = trackpoint_sync(psmouse, was_reset);
|
|
|
|
if (error)
|
|
|
|
return error;
|
2006-08-05 10:52:26 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-10 10:13:20 +08:00
|
|
|
int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
|
2005-08-08 14:26:18 +08:00
|
|
|
{
|
|
|
|
struct ps2dev *ps2dev = &psmouse->ps2dev;
|
2018-01-06 05:28:47 +08:00
|
|
|
struct trackpoint_data *tp;
|
|
|
|
u8 variant_id;
|
|
|
|
u8 firmware_id;
|
|
|
|
u8 button_info;
|
2006-11-03 12:59:30 +08:00
|
|
|
int error;
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
error = trackpoint_start_protocol(psmouse, &variant_id, &firmware_id);
|
|
|
|
if (error)
|
|
|
|
return error;
|
2005-08-08 14:26:18 +08:00
|
|
|
|
|
|
|
if (!set_properties)
|
|
|
|
return 0;
|
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
tp = kzalloc(sizeof(*tp), GFP_KERNEL);
|
|
|
|
if (!tp)
|
2010-09-30 09:53:35 +08:00
|
|
|
return -ENOMEM;
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
trackpoint_defaults(tp);
|
|
|
|
tp->variant_id = variant_id;
|
|
|
|
tp->firmware_id = firmware_id;
|
|
|
|
|
|
|
|
psmouse->private = tp;
|
|
|
|
|
|
|
|
psmouse->vendor = trackpoint_variants[variant_id];
|
2005-08-08 14:26:18 +08:00
|
|
|
psmouse->name = "TrackPoint";
|
|
|
|
|
2006-08-05 10:52:26 +08:00
|
|
|
psmouse->reconnect = trackpoint_reconnect;
|
2005-08-08 14:26:18 +08:00
|
|
|
psmouse->disconnect = trackpoint_disconnect;
|
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
if (variant_id != TP_VARIANT_IBM) {
|
|
|
|
/* Newer variants do not support extended button query. */
|
|
|
|
button_info = 0x33;
|
|
|
|
} else {
|
|
|
|
error = trackpoint_read(ps2dev, TP_EXT_BTN, &button_info);
|
|
|
|
if (error) {
|
|
|
|
psmouse_warn(psmouse,
|
|
|
|
"failed to get extended button data, assuming 3 buttons\n");
|
|
|
|
button_info = 0x33;
|
|
|
|
} else if (!button_info) {
|
|
|
|
psmouse_warn(psmouse,
|
|
|
|
"got 0 in extended button data, assuming 3 buttons\n");
|
|
|
|
button_info = 0x33;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-17 14:12:21 +08:00
|
|
|
if ((button_info & 0x0f) >= 3)
|
2018-01-06 05:28:47 +08:00
|
|
|
input_set_capability(psmouse->dev, EV_KEY, BTN_MIDDLE);
|
2009-11-17 14:12:21 +08:00
|
|
|
|
2014-09-09 05:44:05 +08:00
|
|
|
__set_bit(INPUT_PROP_POINTER, psmouse->dev->propbit);
|
2014-09-09 05:42:12 +08:00
|
|
|
__set_bit(INPUT_PROP_POINTING_STICK, psmouse->dev->propbit);
|
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
if (variant_id != TP_VARIANT_IBM ||
|
|
|
|
trackpoint_power_on_reset(ps2dev) != 0) {
|
|
|
|
/*
|
|
|
|
* Write defaults to TP if we did not reset the trackpoint.
|
|
|
|
*/
|
2013-04-16 04:49:34 +08:00
|
|
|
trackpoint_sync(psmouse, false);
|
2018-01-06 05:28:47 +08:00
|
|
|
}
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2018-01-06 05:28:47 +08:00
|
|
|
error = device_add_group(&ps2dev->serio->dev, &trackpoint_attr_group);
|
2006-11-03 12:59:30 +08:00
|
|
|
if (error) {
|
2012-04-10 15:25:01 +08:00
|
|
|
psmouse_err(psmouse,
|
|
|
|
"failed to create sysfs attributes, error: %d\n",
|
|
|
|
error);
|
2009-11-17 14:12:21 +08:00
|
|
|
kfree(psmouse->private);
|
|
|
|
psmouse->private = NULL;
|
2006-11-03 12:59:30 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2005-08-08 14:26:18 +08:00
|
|
|
|
2012-04-10 15:25:01 +08:00
|
|
|
psmouse_info(psmouse,
|
2018-01-06 05:28:47 +08:00
|
|
|
"%s TrackPoint firmware: 0x%02x, buttons: %d/%d\n",
|
|
|
|
psmouse->vendor, firmware_id,
|
2012-04-10 15:25:01 +08:00
|
|
|
(button_info & 0xf0) >> 4, button_info & 0x0f);
|
2005-08-08 14:26:18 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|