Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input fixes from Dmitry Torokhov: "The main item is that we try to better handle the newer trackpoints on Lenovo devices that are now being produced by Elan/ALPS/NXP and only implement a small subset of the original IBM trackpoint controls" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: Revert "Input: synaptics_rmi4 - use devm_device_add_group() for attributes in F01" Input: trackpoint - only expose supported controls for Elan, ALPS and NXP Input: trackpoint - force 3 buttons if 0 button is reported Input: xpad - add support for PDP Xbox One controllers Input: stmfts,s6sy671 - add SPDX identifier
This commit is contained in:
commit
993ca2068b
|
@ -229,6 +229,7 @@ static const struct xpad_device {
|
||||||
{ 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
|
{ 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
|
||||||
{ 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
|
{ 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
|
||||||
{ 0x0e6f, 0x0246, "Rock Candy Gamepad for Xbox One 2015", 0, XTYPE_XBOXONE },
|
{ 0x0e6f, 0x0246, "Rock Candy Gamepad for Xbox One 2015", 0, XTYPE_XBOXONE },
|
||||||
|
{ 0x0e6f, 0x02ab, "PDP Controller for Xbox One", 0, XTYPE_XBOXONE },
|
||||||
{ 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
|
{ 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
|
||||||
{ 0x0e6f, 0x0346, "Rock Candy Gamepad for Xbox One 2016", 0, XTYPE_XBOXONE },
|
{ 0x0e6f, 0x0346, "Rock Candy Gamepad for Xbox One 2016", 0, XTYPE_XBOXONE },
|
||||||
{ 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
|
{ 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
|
||||||
|
@ -475,6 +476,22 @@ static const u8 xboxone_hori_init[] = {
|
||||||
0x00, 0x00, 0x00, 0x80, 0x00
|
0x00, 0x00, 0x00, 0x80, 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This packet is required for some of the PDP pads to start
|
||||||
|
* sending input reports. One of those pads is (0x0e6f:0x02ab).
|
||||||
|
*/
|
||||||
|
static const u8 xboxone_pdp_init1[] = {
|
||||||
|
0x0a, 0x20, 0x00, 0x03, 0x00, 0x01, 0x14
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This packet is required for some of the PDP pads to start
|
||||||
|
* sending input reports. One of those pads is (0x0e6f:0x02ab).
|
||||||
|
*/
|
||||||
|
static const u8 xboxone_pdp_init2[] = {
|
||||||
|
0x06, 0x20, 0x00, 0x02, 0x01, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A specific rumble packet is required for some PowerA pads to start
|
* A specific rumble packet is required for some PowerA pads to start
|
||||||
* sending input reports. One of those pads is (0x24c6:0x543a).
|
* sending input reports. One of those pads is (0x24c6:0x543a).
|
||||||
|
@ -505,6 +522,8 @@ static const struct xboxone_init_packet xboxone_init_packets[] = {
|
||||||
XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_init),
|
XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_init),
|
||||||
XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_init),
|
XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_init),
|
||||||
XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init),
|
XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init),
|
||||||
|
XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init1),
|
||||||
|
XBOXONE_INIT_PKT(0x0e6f, 0x02ab, xboxone_pdp_init2),
|
||||||
XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init),
|
XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init),
|
||||||
XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init),
|
XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init),
|
||||||
XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init),
|
XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init),
|
||||||
|
|
|
@ -19,6 +19,13 @@
|
||||||
#include "psmouse.h"
|
#include "psmouse.h"
|
||||||
#include "trackpoint.h"
|
#include "trackpoint.h"
|
||||||
|
|
||||||
|
static const char * const trackpoint_variants[] = {
|
||||||
|
[TP_VARIANT_IBM] = "IBM",
|
||||||
|
[TP_VARIANT_ALPS] = "ALPS",
|
||||||
|
[TP_VARIANT_ELAN] = "Elan",
|
||||||
|
[TP_VARIANT_NXP] = "NXP",
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Power-on Reset: Resets all trackpoint parameters, including RAM values,
|
* Power-on Reset: Resets all trackpoint parameters, including RAM values,
|
||||||
* to defaults.
|
* to defaults.
|
||||||
|
@ -26,7 +33,7 @@
|
||||||
*/
|
*/
|
||||||
static int trackpoint_power_on_reset(struct ps2dev *ps2dev)
|
static int trackpoint_power_on_reset(struct ps2dev *ps2dev)
|
||||||
{
|
{
|
||||||
unsigned char results[2];
|
u8 results[2];
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
|
|
||||||
/* Issue POR command, and repeat up to once if 0xFC00 received */
|
/* Issue POR command, and repeat up to once if 0xFC00 received */
|
||||||
|
@ -38,7 +45,7 @@ static int trackpoint_power_on_reset(struct ps2dev *ps2dev)
|
||||||
|
|
||||||
/* Check for success response -- 0xAA00 */
|
/* Check for success response -- 0xAA00 */
|
||||||
if (results[0] != 0xAA || results[1] != 0x00)
|
if (results[0] != 0xAA || results[1] != 0x00)
|
||||||
return -1;
|
return -ENODEV;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -46,8 +53,7 @@ static int trackpoint_power_on_reset(struct ps2dev *ps2dev)
|
||||||
/*
|
/*
|
||||||
* Device IO: read, write and toggle bit
|
* Device IO: read, write and toggle bit
|
||||||
*/
|
*/
|
||||||
static int trackpoint_read(struct ps2dev *ps2dev,
|
static int trackpoint_read(struct ps2dev *ps2dev, u8 loc, u8 *results)
|
||||||
unsigned char loc, unsigned char *results)
|
|
||||||
{
|
{
|
||||||
if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) ||
|
if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) ||
|
||||||
ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 1, loc))) {
|
ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 1, loc))) {
|
||||||
|
@ -57,8 +63,7 @@ static int trackpoint_read(struct ps2dev *ps2dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int trackpoint_write(struct ps2dev *ps2dev,
|
static int trackpoint_write(struct ps2dev *ps2dev, u8 loc, u8 val)
|
||||||
unsigned char loc, unsigned char val)
|
|
||||||
{
|
{
|
||||||
if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) ||
|
if (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, TP_WRITE_MEM)) ||
|
||||||
|
@ -70,8 +75,7 @@ static int trackpoint_write(struct ps2dev *ps2dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int trackpoint_toggle_bit(struct ps2dev *ps2dev,
|
static int trackpoint_toggle_bit(struct ps2dev *ps2dev, u8 loc, u8 mask)
|
||||||
unsigned char loc, unsigned char mask)
|
|
||||||
{
|
{
|
||||||
/* Bad things will happen if the loc param isn't in this range */
|
/* Bad things will happen if the loc param isn't in this range */
|
||||||
if (loc < 0x20 || loc >= 0x2F)
|
if (loc < 0x20 || loc >= 0x2F)
|
||||||
|
@ -87,11 +91,11 @@ static int trackpoint_toggle_bit(struct ps2dev *ps2dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int trackpoint_update_bit(struct ps2dev *ps2dev, unsigned char loc,
|
static int trackpoint_update_bit(struct ps2dev *ps2dev,
|
||||||
unsigned char mask, unsigned char value)
|
u8 loc, u8 mask, u8 value)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
unsigned char data;
|
u8 data;
|
||||||
|
|
||||||
trackpoint_read(ps2dev, loc, &data);
|
trackpoint_read(ps2dev, loc, &data);
|
||||||
if (((data & mask) == mask) != !!value)
|
if (((data & mask) == mask) != !!value)
|
||||||
|
@ -105,17 +109,18 @@ static int trackpoint_update_bit(struct ps2dev *ps2dev, unsigned char loc,
|
||||||
*/
|
*/
|
||||||
struct trackpoint_attr_data {
|
struct trackpoint_attr_data {
|
||||||
size_t field_offset;
|
size_t field_offset;
|
||||||
unsigned char command;
|
u8 command;
|
||||||
unsigned char mask;
|
u8 mask;
|
||||||
unsigned char inverted;
|
bool inverted;
|
||||||
unsigned char power_on_default;
|
u8 power_on_default;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, void *data, char *buf)
|
static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse,
|
||||||
|
void *data, char *buf)
|
||||||
{
|
{
|
||||||
struct trackpoint_data *tp = psmouse->private;
|
struct trackpoint_data *tp = psmouse->private;
|
||||||
struct trackpoint_attr_data *attr = data;
|
struct trackpoint_attr_data *attr = data;
|
||||||
unsigned char value = *(unsigned char *)((char *)tp + attr->field_offset);
|
u8 value = *(u8 *)((void *)tp + attr->field_offset);
|
||||||
|
|
||||||
if (attr->inverted)
|
if (attr->inverted)
|
||||||
value = !value;
|
value = !value;
|
||||||
|
@ -128,8 +133,8 @@ static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data,
|
||||||
{
|
{
|
||||||
struct trackpoint_data *tp = psmouse->private;
|
struct trackpoint_data *tp = psmouse->private;
|
||||||
struct trackpoint_attr_data *attr = data;
|
struct trackpoint_attr_data *attr = data;
|
||||||
unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
|
u8 *field = (void *)tp + attr->field_offset;
|
||||||
unsigned char value;
|
u8 value;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = kstrtou8(buf, 10, &value);
|
err = kstrtou8(buf, 10, &value);
|
||||||
|
@ -157,17 +162,14 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data,
|
||||||
{
|
{
|
||||||
struct trackpoint_data *tp = psmouse->private;
|
struct trackpoint_data *tp = psmouse->private;
|
||||||
struct trackpoint_attr_data *attr = data;
|
struct trackpoint_attr_data *attr = data;
|
||||||
unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
|
bool *field = (void *)tp + attr->field_offset;
|
||||||
unsigned int value;
|
bool value;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = kstrtouint(buf, 10, &value);
|
err = kstrtobool(buf, &value);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (value > 1)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (attr->inverted)
|
if (attr->inverted)
|
||||||
value = !value;
|
value = !value;
|
||||||
|
|
||||||
|
@ -193,30 +195,6 @@ PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \
|
||||||
&trackpoint_attr_##_name, \
|
&trackpoint_attr_##_name, \
|
||||||
trackpoint_show_int_attr, trackpoint_set_bit_attr)
|
trackpoint_show_int_attr, trackpoint_set_bit_attr)
|
||||||
|
|
||||||
#define TRACKPOINT_UPDATE_BIT(_psmouse, _tp, _name) \
|
|
||||||
do { \
|
|
||||||
struct trackpoint_attr_data *_attr = &trackpoint_attr_##_name; \
|
|
||||||
\
|
|
||||||
trackpoint_update_bit(&_psmouse->ps2dev, \
|
|
||||||
_attr->command, _attr->mask, _tp->_name); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define TRACKPOINT_UPDATE(_power_on, _psmouse, _tp, _name) \
|
|
||||||
do { \
|
|
||||||
if (!_power_on || \
|
|
||||||
_tp->_name != trackpoint_attr_##_name.power_on_default) { \
|
|
||||||
if (!trackpoint_attr_##_name.mask) \
|
|
||||||
trackpoint_write(&_psmouse->ps2dev, \
|
|
||||||
trackpoint_attr_##_name.command, \
|
|
||||||
_tp->_name); \
|
|
||||||
else \
|
|
||||||
TRACKPOINT_UPDATE_BIT(_psmouse, _tp, _name); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define TRACKPOINT_SET_POWER_ON_DEFAULT(_tp, _name) \
|
|
||||||
(_tp->_name = trackpoint_attr_##_name.power_on_default)
|
|
||||||
|
|
||||||
TRACKPOINT_INT_ATTR(sensitivity, TP_SENS, TP_DEF_SENS);
|
TRACKPOINT_INT_ATTR(sensitivity, TP_SENS, TP_DEF_SENS);
|
||||||
TRACKPOINT_INT_ATTR(speed, TP_SPEED, TP_DEF_SPEED);
|
TRACKPOINT_INT_ATTR(speed, TP_SPEED, TP_DEF_SPEED);
|
||||||
TRACKPOINT_INT_ATTR(inertia, TP_INERTIA, TP_DEF_INERTIA);
|
TRACKPOINT_INT_ATTR(inertia, TP_INERTIA, TP_DEF_INERTIA);
|
||||||
|
@ -229,13 +207,33 @@ TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME, TP_DEF_Z_TIME);
|
||||||
TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV, TP_DEF_JENKS_CURV);
|
TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV, TP_DEF_JENKS_CURV);
|
||||||
TRACKPOINT_INT_ATTR(drift_time, TP_DRIFT_TIME, TP_DEF_DRIFT_TIME);
|
TRACKPOINT_INT_ATTR(drift_time, TP_DRIFT_TIME, TP_DEF_DRIFT_TIME);
|
||||||
|
|
||||||
TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, 0,
|
TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, false,
|
||||||
TP_DEF_PTSON);
|
TP_DEF_PTSON);
|
||||||
TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK, 0,
|
TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK, false,
|
||||||
TP_DEF_SKIPBACK);
|
TP_DEF_SKIPBACK);
|
||||||
TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV, 1,
|
TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV, true,
|
||||||
TP_DEF_EXT_DEV);
|
TP_DEF_EXT_DEV);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
static struct attribute *trackpoint_attrs[] = {
|
static struct attribute *trackpoint_attrs[] = {
|
||||||
&psmouse_attr_sensitivity.dattr.attr,
|
&psmouse_attr_sensitivity.dattr.attr,
|
||||||
&psmouse_attr_speed.dattr.attr,
|
&psmouse_attr_speed.dattr.attr,
|
||||||
|
@ -255,24 +253,56 @@ static struct attribute *trackpoint_attrs[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct attribute_group trackpoint_attr_group = {
|
static struct attribute_group trackpoint_attr_group = {
|
||||||
.attrs = trackpoint_attrs,
|
.is_visible = trackpoint_is_attr_visible,
|
||||||
|
.attrs = trackpoint_attrs,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int trackpoint_start_protocol(struct psmouse *psmouse, unsigned char *firmware_id)
|
#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)
|
||||||
|
|
||||||
|
#define TRACKPOINT_SET_POWER_ON_DEFAULT(_tp, _name) \
|
||||||
|
do { \
|
||||||
|
_tp->_name = trackpoint_attr_##_name.power_on_default; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
static int trackpoint_start_protocol(struct psmouse *psmouse,
|
||||||
|
u8 *variant_id, u8 *firmware_id)
|
||||||
{
|
{
|
||||||
unsigned char param[2] = { 0 };
|
u8 param[2] = { 0 };
|
||||||
|
int error;
|
||||||
|
|
||||||
if (ps2_command(&psmouse->ps2dev, param, MAKE_PS2_CMD(0, 2, TP_READ_ID)))
|
error = ps2_command(&psmouse->ps2dev,
|
||||||
return -1;
|
param, MAKE_PS2_CMD(0, 2, TP_READ_ID));
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
/* add new TP ID. */
|
switch (param[0]) {
|
||||||
if (!(param[0] & TP_MAGIC_IDENT))
|
case TP_VARIANT_IBM:
|
||||||
return -1;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
if (firmware_id)
|
return -ENODEV;
|
||||||
*firmware_id = param[1];
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -285,7 +315,7 @@ static int trackpoint_sync(struct psmouse *psmouse, bool in_power_on_state)
|
||||||
{
|
{
|
||||||
struct trackpoint_data *tp = psmouse->private;
|
struct trackpoint_data *tp = psmouse->private;
|
||||||
|
|
||||||
if (!in_power_on_state) {
|
if (!in_power_on_state && tp->variant_id == TP_VARIANT_IBM) {
|
||||||
/*
|
/*
|
||||||
* Disable features that may make device unusable
|
* Disable features that may make device unusable
|
||||||
* with this driver.
|
* with this driver.
|
||||||
|
@ -347,7 +377,8 @@ static void trackpoint_defaults(struct trackpoint_data *tp)
|
||||||
|
|
||||||
static void trackpoint_disconnect(struct psmouse *psmouse)
|
static void trackpoint_disconnect(struct psmouse *psmouse)
|
||||||
{
|
{
|
||||||
sysfs_remove_group(&psmouse->ps2dev.serio->dev.kobj, &trackpoint_attr_group);
|
device_remove_group(&psmouse->ps2dev.serio->dev,
|
||||||
|
&trackpoint_attr_group);
|
||||||
|
|
||||||
kfree(psmouse->private);
|
kfree(psmouse->private);
|
||||||
psmouse->private = NULL;
|
psmouse->private = NULL;
|
||||||
|
@ -355,14 +386,20 @@ static void trackpoint_disconnect(struct psmouse *psmouse)
|
||||||
|
|
||||||
static int trackpoint_reconnect(struct psmouse *psmouse)
|
static int trackpoint_reconnect(struct psmouse *psmouse)
|
||||||
{
|
{
|
||||||
int reset_fail;
|
struct trackpoint_data *tp = psmouse->private;
|
||||||
|
int error;
|
||||||
|
bool was_reset;
|
||||||
|
|
||||||
if (trackpoint_start_protocol(psmouse, NULL))
|
error = trackpoint_start_protocol(psmouse, NULL, NULL);
|
||||||
return -1;
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
reset_fail = trackpoint_power_on_reset(&psmouse->ps2dev);
|
was_reset = tp->variant_id == TP_VARIANT_IBM &&
|
||||||
if (trackpoint_sync(psmouse, !reset_fail))
|
trackpoint_power_on_reset(&psmouse->ps2dev) == 0;
|
||||||
return -1;
|
|
||||||
|
error = trackpoint_sync(psmouse, was_reset);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -370,46 +407,66 @@ static int trackpoint_reconnect(struct psmouse *psmouse)
|
||||||
int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
|
int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
|
||||||
{
|
{
|
||||||
struct ps2dev *ps2dev = &psmouse->ps2dev;
|
struct ps2dev *ps2dev = &psmouse->ps2dev;
|
||||||
unsigned char firmware_id;
|
struct trackpoint_data *tp;
|
||||||
unsigned char button_info;
|
u8 variant_id;
|
||||||
|
u8 firmware_id;
|
||||||
|
u8 button_info;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (trackpoint_start_protocol(psmouse, &firmware_id))
|
error = trackpoint_start_protocol(psmouse, &variant_id, &firmware_id);
|
||||||
return -1;
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
if (!set_properties)
|
if (!set_properties)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (trackpoint_read(ps2dev, TP_EXT_BTN, &button_info)) {
|
tp = kzalloc(sizeof(*tp), GFP_KERNEL);
|
||||||
psmouse_warn(psmouse, "failed to get extended button data, assuming 3 buttons\n");
|
if (!tp)
|
||||||
button_info = 0x33;
|
|
||||||
}
|
|
||||||
|
|
||||||
psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL);
|
|
||||||
if (!psmouse->private)
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
psmouse->vendor = "IBM";
|
trackpoint_defaults(tp);
|
||||||
|
tp->variant_id = variant_id;
|
||||||
|
tp->firmware_id = firmware_id;
|
||||||
|
|
||||||
|
psmouse->private = tp;
|
||||||
|
|
||||||
|
psmouse->vendor = trackpoint_variants[variant_id];
|
||||||
psmouse->name = "TrackPoint";
|
psmouse->name = "TrackPoint";
|
||||||
|
|
||||||
psmouse->reconnect = trackpoint_reconnect;
|
psmouse->reconnect = trackpoint_reconnect;
|
||||||
psmouse->disconnect = trackpoint_disconnect;
|
psmouse->disconnect = trackpoint_disconnect;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((button_info & 0x0f) >= 3)
|
if ((button_info & 0x0f) >= 3)
|
||||||
__set_bit(BTN_MIDDLE, psmouse->dev->keybit);
|
input_set_capability(psmouse->dev, EV_KEY, BTN_MIDDLE);
|
||||||
|
|
||||||
__set_bit(INPUT_PROP_POINTER, psmouse->dev->propbit);
|
__set_bit(INPUT_PROP_POINTER, psmouse->dev->propbit);
|
||||||
__set_bit(INPUT_PROP_POINTING_STICK, psmouse->dev->propbit);
|
__set_bit(INPUT_PROP_POINTING_STICK, psmouse->dev->propbit);
|
||||||
|
|
||||||
trackpoint_defaults(psmouse->private);
|
if (variant_id != TP_VARIANT_IBM ||
|
||||||
|
trackpoint_power_on_reset(ps2dev) != 0) {
|
||||||
error = trackpoint_power_on_reset(ps2dev);
|
/*
|
||||||
|
* Write defaults to TP if we did not reset the trackpoint.
|
||||||
/* Write defaults to TP only if reset fails. */
|
*/
|
||||||
if (error)
|
|
||||||
trackpoint_sync(psmouse, false);
|
trackpoint_sync(psmouse, false);
|
||||||
|
}
|
||||||
|
|
||||||
error = sysfs_create_group(&ps2dev->serio->dev.kobj, &trackpoint_attr_group);
|
error = device_add_group(&ps2dev->serio->dev, &trackpoint_attr_group);
|
||||||
if (error) {
|
if (error) {
|
||||||
psmouse_err(psmouse,
|
psmouse_err(psmouse,
|
||||||
"failed to create sysfs attributes, error: %d\n",
|
"failed to create sysfs attributes, error: %d\n",
|
||||||
|
@ -420,8 +477,8 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
psmouse_info(psmouse,
|
psmouse_info(psmouse,
|
||||||
"IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n",
|
"%s TrackPoint firmware: 0x%02x, buttons: %d/%d\n",
|
||||||
firmware_id,
|
psmouse->vendor, firmware_id,
|
||||||
(button_info & 0xf0) >> 4, button_info & 0x0f);
|
(button_info & 0xf0) >> 4, button_info & 0x0f);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -21,10 +21,16 @@
|
||||||
#define TP_COMMAND 0xE2 /* Commands start with this */
|
#define TP_COMMAND 0xE2 /* Commands start with this */
|
||||||
|
|
||||||
#define TP_READ_ID 0xE1 /* Sent for device identification */
|
#define TP_READ_ID 0xE1 /* Sent for device identification */
|
||||||
#define TP_MAGIC_IDENT 0x03 /* Sent after a TP_READ_ID followed */
|
|
||||||
/* by the firmware ID */
|
|
||||||
/* Firmware ID includes 0x1, 0x2, 0x3 */
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Valid first byte responses to the "Read Secondary ID" (0xE1) command.
|
||||||
|
* 0x01 was the original IBM trackpoint, others implement very limited
|
||||||
|
* subset of trackpoint features.
|
||||||
|
*/
|
||||||
|
#define TP_VARIANT_IBM 0x01
|
||||||
|
#define TP_VARIANT_ALPS 0x02
|
||||||
|
#define TP_VARIANT_ELAN 0x03
|
||||||
|
#define TP_VARIANT_NXP 0x04
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Commands
|
* Commands
|
||||||
|
@ -136,18 +142,20 @@
|
||||||
|
|
||||||
#define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd))
|
#define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd))
|
||||||
|
|
||||||
struct trackpoint_data
|
struct trackpoint_data {
|
||||||
{
|
u8 variant_id;
|
||||||
unsigned char sensitivity, speed, inertia, reach;
|
u8 firmware_id;
|
||||||
unsigned char draghys, mindrag;
|
|
||||||
unsigned char thresh, upthresh;
|
u8 sensitivity, speed, inertia, reach;
|
||||||
unsigned char ztime, jenks;
|
u8 draghys, mindrag;
|
||||||
unsigned char drift_time;
|
u8 thresh, upthresh;
|
||||||
|
u8 ztime, jenks;
|
||||||
|
u8 drift_time;
|
||||||
|
|
||||||
/* toggles */
|
/* toggles */
|
||||||
unsigned char press_to_select;
|
bool press_to_select;
|
||||||
unsigned char skipback;
|
bool skipback;
|
||||||
unsigned char ext_dev;
|
bool ext_dev;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_MOUSE_PS2_TRACKPOINT
|
#ifdef CONFIG_MOUSE_PS2_TRACKPOINT
|
||||||
|
|
|
@ -570,14 +570,19 @@ static int rmi_f01_probe(struct rmi_function *fn)
|
||||||
|
|
||||||
dev_set_drvdata(&fn->dev, f01);
|
dev_set_drvdata(&fn->dev, f01);
|
||||||
|
|
||||||
error = devm_device_add_group(&fn->rmi_dev->dev, &rmi_f01_attr_group);
|
error = sysfs_create_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group);
|
||||||
if (error)
|
if (error)
|
||||||
dev_warn(&fn->dev,
|
dev_warn(&fn->dev, "Failed to create sysfs group: %d\n", error);
|
||||||
"Failed to create attribute group: %d\n", error);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rmi_f01_remove(struct rmi_function *fn)
|
||||||
|
{
|
||||||
|
/* Note that the bus device is used, not the F01 device */
|
||||||
|
sysfs_remove_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group);
|
||||||
|
}
|
||||||
|
|
||||||
static int rmi_f01_config(struct rmi_function *fn)
|
static int rmi_f01_config(struct rmi_function *fn)
|
||||||
{
|
{
|
||||||
struct f01_data *f01 = dev_get_drvdata(&fn->dev);
|
struct f01_data *f01 = dev_get_drvdata(&fn->dev);
|
||||||
|
@ -717,6 +722,7 @@ struct rmi_function_handler rmi_f01_handler = {
|
||||||
},
|
},
|
||||||
.func = 0x01,
|
.func = 0x01,
|
||||||
.probe = rmi_f01_probe,
|
.probe = rmi_f01_probe,
|
||||||
|
.remove = rmi_f01_remove,
|
||||||
.config = rmi_f01_config,
|
.config = rmi_f01_config,
|
||||||
.attention = rmi_f01_attention,
|
.attention = rmi_f01_attention,
|
||||||
.suspend = rmi_f01_suspend,
|
.suspend = rmi_f01_suspend,
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
/*
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
* Copyright (c) 2017 Samsung Electronics Co., Ltd.
|
// Samsung S6SY761 Touchscreen device driver
|
||||||
* Author: Andi Shyti <andi.shyti@samsung.com>
|
//
|
||||||
*
|
// Copyright (c) 2017 Samsung Electronics Co., Ltd.
|
||||||
* This program is free software; you can redistribute it and/or modify
|
// Copyright (c) 2017 Andi Shyti <andi.shyti@samsung.com>
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* Samsung S6SY761 Touchscreen device driver
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <asm/unaligned.h>
|
#include <asm/unaligned.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
/*
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
* Copyright (c) 2017 Samsung Electronics Co., Ltd.
|
// STMicroelectronics FTS Touchscreen device driver
|
||||||
* Author: Andi Shyti <andi.shyti@samsung.com>
|
//
|
||||||
*
|
// Copyright (c) 2017 Samsung Electronics Co., Ltd.
|
||||||
* This program is free software; you can redistribute it and/or modify
|
// Copyright (c) 2017 Andi Shyti <andi.shyti@samsung.com>
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* STMicroelectronics FTS Touchscreen device driver
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
|
|
Loading…
Reference in New Issue