Commit 085fa80d authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: psmouse - store pointer to current protocol

Instead of storing only protocol "type" in pmsouse structure, store pointer
to the protocol structure, so that we have access to more data without
having to copy it over to psmouse structure.
Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 0ab3fa57
...@@ -116,17 +116,6 @@ static DEFINE_MUTEX(psmouse_mutex); ...@@ -116,17 +116,6 @@ static DEFINE_MUTEX(psmouse_mutex);
static struct workqueue_struct *kpsmoused_wq; static struct workqueue_struct *kpsmoused_wq;
struct psmouse_protocol {
enum psmouse_type type;
bool maxproto;
bool ignore_parity; /* Protocol should ignore parity errors from KBC */
bool try_passthru; /* Try protocol also on passthrough ports */
const char *name;
const char *alias;
int (*detect)(struct psmouse *, bool);
int (*init)(struct psmouse *);
};
static void psmouse_report_standard_buttons(struct input_dev *dev, u8 buttons) static void psmouse_report_standard_buttons(struct input_dev *dev, u8 buttons)
{ {
input_report_key(dev, BTN_LEFT, buttons & BIT(0)); input_report_key(dev, BTN_LEFT, buttons & BIT(0));
...@@ -148,7 +137,7 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse) ...@@ -148,7 +137,7 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
/* Full packet accumulated, process it */ /* Full packet accumulated, process it */
switch (psmouse->type) { switch (psmouse->protocol->type) {
case PSMOUSE_IMPS: case PSMOUSE_IMPS:
/* IntelliMouse has scroll wheel */ /* IntelliMouse has scroll wheel */
input_report_rel(dev, REL_WHEEL, -(signed char) packet[3]); input_report_rel(dev, REL_WHEEL, -(signed char) packet[3]);
...@@ -325,7 +314,8 @@ static irqreturn_t psmouse_interrupt(struct serio *serio, ...@@ -325,7 +314,8 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
goto out; goto out;
if (unlikely((flags & SERIO_TIMEOUT) || if (unlikely((flags & SERIO_TIMEOUT) ||
((flags & SERIO_PARITY) && !psmouse->ignore_parity))) { ((flags & SERIO_PARITY) &&
!psmouse->protocol->ignore_parity))) {
if (psmouse->state == PSMOUSE_ACTIVATED) if (psmouse->state == PSMOUSE_ACTIVATED)
psmouse_warn(psmouse, psmouse_warn(psmouse,
...@@ -372,7 +362,7 @@ static irqreturn_t psmouse_interrupt(struct serio *serio, ...@@ -372,7 +362,7 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
} }
if (psmouse->packet[1] == PSMOUSE_RET_ID || if (psmouse->packet[1] == PSMOUSE_RET_ID ||
(psmouse->type == PSMOUSE_HGPK && (psmouse->protocol->type == PSMOUSE_HGPK &&
psmouse->packet[1] == PSMOUSE_RET_BAT)) { psmouse->packet[1] == PSMOUSE_RET_BAT)) {
__psmouse_set_state(psmouse, PSMOUSE_IGNORE); __psmouse_set_state(psmouse, PSMOUSE_IGNORE);
serio_reconnect(serio); serio_reconnect(serio);
...@@ -959,6 +949,8 @@ static void psmouse_apply_defaults(struct psmouse *psmouse) ...@@ -959,6 +949,8 @@ static void psmouse_apply_defaults(struct psmouse *psmouse)
__set_bit(INPUT_PROP_POINTER, input_dev->propbit); __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
psmouse->protocol = &psmouse_protocols[0];
psmouse->set_rate = psmouse_set_rate; psmouse->set_rate = psmouse_set_rate;
psmouse->set_resolution = psmouse_set_resolution; psmouse->set_resolution = psmouse_set_resolution;
psmouse->set_scale = psmouse_set_scale; psmouse->set_scale = psmouse_set_scale;
...@@ -1476,6 +1468,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, ...@@ -1476,6 +1468,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse,
{ {
const struct psmouse_protocol *selected_proto; const struct psmouse_protocol *selected_proto;
struct input_dev *input_dev = psmouse->dev; struct input_dev *input_dev = psmouse->dev;
enum psmouse_type type;
input_dev->dev.parent = &psmouse->ps2dev.serio->dev; input_dev->dev.parent = &psmouse->ps2dev.serio->dev;
...@@ -1488,15 +1481,13 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, ...@@ -1488,15 +1481,13 @@ static int psmouse_switch_protocol(struct psmouse *psmouse,
if (proto->init && proto->init(psmouse) < 0) if (proto->init && proto->init(psmouse) < 0)
return -1; return -1;
psmouse->type = proto->type;
selected_proto = proto; selected_proto = proto;
} else { } else {
psmouse->type = psmouse_extensions(psmouse, type = psmouse_extensions(psmouse, psmouse_max_proto, true);
psmouse_max_proto, true); selected_proto = psmouse_protocol_by_type(type);
selected_proto = psmouse_protocol_by_type(psmouse->type);
} }
psmouse->ignore_parity = selected_proto->ignore_parity; psmouse->protocol = selected_proto;
/* /*
* If mouse's packet size is 3 there is no point in polling the * If mouse's packet size is 3 there is no point in polling the
...@@ -1522,7 +1513,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, ...@@ -1522,7 +1513,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse,
input_dev->phys = psmouse->phys; input_dev->phys = psmouse->phys;
input_dev->id.bustype = BUS_I8042; input_dev->id.bustype = BUS_I8042;
input_dev->id.vendor = 0x0002; input_dev->id.vendor = 0x0002;
input_dev->id.product = psmouse->type; input_dev->id.product = psmouse->protocol->type;
input_dev->id.version = psmouse->model; input_dev->id.version = psmouse->model;
return 0; return 0;
...@@ -1634,7 +1625,7 @@ static int __psmouse_reconnect(struct serio *serio, bool fast_reconnect) ...@@ -1634,7 +1625,7 @@ static int __psmouse_reconnect(struct serio *serio, bool fast_reconnect)
struct psmouse *psmouse = serio_get_drvdata(serio); struct psmouse *psmouse = serio_get_drvdata(serio);
struct psmouse *parent = NULL; struct psmouse *parent = NULL;
int (*reconnect_handler)(struct psmouse *); int (*reconnect_handler)(struct psmouse *);
unsigned char type; enum psmouse_type type;
int rc = -1; int rc = -1;
mutex_lock(&psmouse_mutex); mutex_lock(&psmouse_mutex);
...@@ -1666,7 +1657,7 @@ static int __psmouse_reconnect(struct serio *serio, bool fast_reconnect) ...@@ -1666,7 +1657,7 @@ static int __psmouse_reconnect(struct serio *serio, bool fast_reconnect)
goto out; goto out;
type = psmouse_extensions(psmouse, psmouse_max_proto, false); type = psmouse_extensions(psmouse, psmouse_max_proto, false);
if (psmouse->type != type) if (psmouse->protocol->type != type)
goto out; goto out;
} }
...@@ -1816,7 +1807,7 @@ static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const ...@@ -1816,7 +1807,7 @@ static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const
static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, void *data, char *buf) static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, void *data, char *buf)
{ {
return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name); return sprintf(buf, "%s\n", psmouse->protocol->name);
} }
static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, const char *buf, size_t count) static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, const char *buf, size_t count)
...@@ -1832,7 +1823,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co ...@@ -1832,7 +1823,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
if (!proto) if (!proto)
return -EINVAL; return -EINVAL;
if (psmouse->type == proto->type) if (psmouse->protocol == proto)
return count; return count;
new_dev = input_allocate_device(); new_dev = input_allocate_device();
...@@ -1856,7 +1847,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co ...@@ -1856,7 +1847,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
return -ENODEV; return -ENODEV;
} }
if (psmouse->type == proto->type) { if (psmouse->protocol == proto) {
input_free_device(new_dev); input_free_device(new_dev);
return count; /* switched by other thread */ return count; /* switched by other thread */
} }
...@@ -1869,7 +1860,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co ...@@ -1869,7 +1860,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
} }
old_dev = psmouse->dev; old_dev = psmouse->dev;
old_proto = psmouse_protocol_by_type(psmouse->type); old_proto = psmouse->protocol;
if (psmouse->disconnect) if (psmouse->disconnect)
psmouse->disconnect(psmouse); psmouse->disconnect(psmouse);
......
...@@ -44,21 +44,58 @@ enum psmouse_scale { ...@@ -44,21 +44,58 @@ enum psmouse_scale {
PSMOUSE_SCALE21 PSMOUSE_SCALE21
}; };
enum psmouse_type {
PSMOUSE_NONE,
PSMOUSE_PS2,
PSMOUSE_PS2PP,
PSMOUSE_THINKPS,
PSMOUSE_GENPS,
PSMOUSE_IMPS,
PSMOUSE_IMEX,
PSMOUSE_SYNAPTICS,
PSMOUSE_ALPS,
PSMOUSE_LIFEBOOK,
PSMOUSE_TRACKPOINT,
PSMOUSE_TOUCHKIT_PS2,
PSMOUSE_CORTRON,
PSMOUSE_HGPK,
PSMOUSE_ELANTECH,
PSMOUSE_FSP,
PSMOUSE_SYNAPTICS_RELATIVE,
PSMOUSE_CYPRESS,
PSMOUSE_FOCALTECH,
PSMOUSE_VMMOUSE,
PSMOUSE_BYD,
PSMOUSE_AUTO /* This one should always be last */
};
struct psmouse;
struct psmouse_protocol {
enum psmouse_type type;
bool maxproto;
bool ignore_parity; /* Protocol should ignore parity errors from KBC */
bool try_passthru; /* Try protocol also on passthrough ports */
const char *name;
const char *alias;
int (*detect)(struct psmouse *, bool);
int (*init)(struct psmouse *);
};
struct psmouse { struct psmouse {
void *private; void *private;
struct input_dev *dev; struct input_dev *dev;
struct ps2dev ps2dev; struct ps2dev ps2dev;
struct delayed_work resync_work; struct delayed_work resync_work;
char *vendor; const char *vendor;
char *name; const char *name;
const struct psmouse_protocol *protocol;
unsigned char packet[8]; unsigned char packet[8];
unsigned char badbyte; unsigned char badbyte;
unsigned char pktcnt; unsigned char pktcnt;
unsigned char pktsize; unsigned char pktsize;
unsigned char type;
unsigned char oob_data_type; unsigned char oob_data_type;
unsigned char extra_buttons; unsigned char extra_buttons;
bool ignore_parity;
bool acks_disable_command; bool acks_disable_command;
unsigned int model; unsigned int model;
unsigned long last; unsigned long last;
...@@ -89,31 +126,6 @@ struct psmouse { ...@@ -89,31 +126,6 @@ struct psmouse {
void (*pt_deactivate)(struct psmouse *psmouse); void (*pt_deactivate)(struct psmouse *psmouse);
}; };
enum psmouse_type {
PSMOUSE_NONE,
PSMOUSE_PS2,
PSMOUSE_PS2PP,
PSMOUSE_THINKPS,
PSMOUSE_GENPS,
PSMOUSE_IMPS,
PSMOUSE_IMEX,
PSMOUSE_SYNAPTICS,
PSMOUSE_ALPS,
PSMOUSE_LIFEBOOK,
PSMOUSE_TRACKPOINT,
PSMOUSE_TOUCHKIT_PS2,
PSMOUSE_CORTRON,
PSMOUSE_HGPK,
PSMOUSE_ELANTECH,
PSMOUSE_FSP,
PSMOUSE_SYNAPTICS_RELATIVE,
PSMOUSE_CYPRESS,
PSMOUSE_FOCALTECH,
PSMOUSE_VMMOUSE,
PSMOUSE_BYD,
PSMOUSE_AUTO /* This one should always be last */
};
void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work, void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
unsigned long delay); unsigned long delay);
int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment