Commit 9f5bbac5 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Linus Torvalds

input: Synaptics code cleanups.

parent b9dbb222
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
* Use the Synaptics extended ps/2 syntax to write a special command byte. * Use the Synaptics extended ps/2 syntax to write a special command byte.
* special command: 0xE8 rr 0xE8 ss 0xE8 tt 0xE8 uu where (rr*64)+(ss*16)+(tt*4)+uu * special command: 0xE8 rr 0xE8 ss 0xE8 tt 0xE8 uu where (rr*64)+(ss*16)+(tt*4)+uu
* is the command. A 0xF3 or 0xE9 must follow (see synaptics_send_cmd * is the command. A 0xF3 or 0xE9 must follow (see synaptics_send_cmd
* and synaptics_set_mode) * and synaptics_mode_cmd)
*/ */
static int synaptics_special_cmd(struct psmouse *psmouse, unsigned char command) static int synaptics_special_cmd(struct psmouse *psmouse, unsigned char command)
{ {
...@@ -69,7 +69,7 @@ static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, unsigned ...@@ -69,7 +69,7 @@ static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, unsigned
/* /*
* Set the synaptics touchpad mode byte by special commands * Set the synaptics touchpad mode byte by special commands
*/ */
static int synaptics_set_mode(struct psmouse *psmouse, unsigned char mode) static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode)
{ {
unsigned char param[1]; unsigned char param[1];
...@@ -96,13 +96,14 @@ static int synaptics_reset(struct psmouse *psmouse) ...@@ -96,13 +96,14 @@ static int synaptics_reset(struct psmouse *psmouse)
* Read the model-id bytes from the touchpad * Read the model-id bytes from the touchpad
* see also SYN_MODEL_* macros * see also SYN_MODEL_* macros
*/ */
static int synaptics_model_id(struct psmouse *psmouse, unsigned long int *model_id) static int synaptics_model_id(struct psmouse *psmouse)
{ {
struct synaptics_data *priv = psmouse->private;
unsigned char mi[3]; unsigned char mi[3];
if (synaptics_send_cmd(psmouse, SYN_QUE_MODEL, mi)) if (synaptics_send_cmd(psmouse, SYN_QUE_MODEL, mi))
return -1; return -1;
*model_id = (mi[0]<<16) | (mi[1]<<8) | mi[2]; priv->model_id = (mi[0]<<16) | (mi[1]<<8) | mi[2];
return 0; return 0;
} }
...@@ -110,23 +111,24 @@ static int synaptics_model_id(struct psmouse *psmouse, unsigned long int *model_ ...@@ -110,23 +111,24 @@ static int synaptics_model_id(struct psmouse *psmouse, unsigned long int *model_
* Read the capability-bits from the touchpad * Read the capability-bits from the touchpad
* see also the SYN_CAP_* macros * see also the SYN_CAP_* macros
*/ */
static int synaptics_capability(struct psmouse *psmouse, unsigned long int *capability, unsigned long int *ext_cap) static int synaptics_capability(struct psmouse *psmouse)
{ {
struct synaptics_data *priv = psmouse->private;
unsigned char cap[3]; unsigned char cap[3];
if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap)) if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap))
return -1; return -1;
*capability = (cap[0]<<16) | (cap[1]<<8) | cap[2]; priv->capabilities = (cap[0]<<16) | (cap[1]<<8) | cap[2];
*ext_cap = 0; priv->ext_cap = 0;
if (!SYN_CAP_VALID(*capability)) if (!SYN_CAP_VALID(priv->capabilities))
return -1; return -1;
if (SYN_EXT_CAP_REQUESTS(*capability)) { if (SYN_EXT_CAP_REQUESTS(priv->capabilities)) {
if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) { if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) {
printk(KERN_ERR "Synaptics claims to have extended capabilities," printk(KERN_ERR "Synaptics claims to have extended capabilities,"
" but I'm not able to read them."); " but I'm not able to read them.");
} else } else
*ext_cap = (cap[0]<<16) | (cap[1]<<8) | cap[2]; priv->ext_cap = (cap[0]<<16) | (cap[1]<<8) | cap[2];
} }
return 0; return 0;
} }
...@@ -135,14 +137,15 @@ static int synaptics_capability(struct psmouse *psmouse, unsigned long int *capa ...@@ -135,14 +137,15 @@ static int synaptics_capability(struct psmouse *psmouse, unsigned long int *capa
* Identify Touchpad * Identify Touchpad
* See also the SYN_ID_* macros * See also the SYN_ID_* macros
*/ */
static int synaptics_identify(struct psmouse *psmouse, unsigned long int *ident) static int synaptics_identify(struct psmouse *psmouse)
{ {
struct synaptics_data *priv = psmouse->private;
unsigned char id[3]; unsigned char id[3];
if (synaptics_send_cmd(psmouse, SYN_QUE_IDENTIFY, id)) if (synaptics_send_cmd(psmouse, SYN_QUE_IDENTIFY, id))
return -1; return -1;
*ident = (id[0]<<16) | (id[1]<<8) | id[2]; priv->identity = (id[0]<<16) | (id[1]<<8) | id[2];
if (SYN_ID_IS_SYNAPTICS(*ident)) if (SYN_ID_IS_SYNAPTICS(priv->identity))
return 0; return 0;
return -1; return -1;
} }
...@@ -179,7 +182,7 @@ static void print_ident(struct synaptics_data *priv) ...@@ -179,7 +182,7 @@ static void print_ident(struct synaptics_data *priv)
} }
} }
static int query_hardware(struct psmouse *psmouse) static int synaptics_query_hardware(struct psmouse *psmouse)
{ {
struct synaptics_data *priv = psmouse->private; struct synaptics_data *priv = psmouse->private;
int retries = 0; int retries = 0;
...@@ -188,11 +191,11 @@ static int query_hardware(struct psmouse *psmouse) ...@@ -188,11 +191,11 @@ static int query_hardware(struct psmouse *psmouse)
while ((retries++ < 3) && synaptics_reset(psmouse)) while ((retries++ < 3) && synaptics_reset(psmouse))
printk(KERN_ERR "synaptics reset failed\n"); printk(KERN_ERR "synaptics reset failed\n");
if (synaptics_identify(psmouse, &priv->identity)) if (synaptics_identify(psmouse))
return -1; return -1;
if (synaptics_model_id(psmouse, &priv->model_id)) if (synaptics_model_id(psmouse))
return -1; return -1;
if (synaptics_capability(psmouse, &priv->capabilities, &priv->ext_cap)) if (synaptics_capability(psmouse))
return -1; return -1;
mode = SYN_BIT_ABSOLUTE_MODE | SYN_BIT_HIGH_RATE; mode = SYN_BIT_ABSOLUTE_MODE | SYN_BIT_HIGH_RATE;
...@@ -200,7 +203,7 @@ static int query_hardware(struct psmouse *psmouse) ...@@ -200,7 +203,7 @@ static int query_hardware(struct psmouse *psmouse)
mode |= SYN_BIT_DISABLE_GESTURE; mode |= SYN_BIT_DISABLE_GESTURE;
if (SYN_CAP_EXTENDED(priv->capabilities)) if (SYN_CAP_EXTENDED(priv->capabilities))
mode |= SYN_BIT_W_MODE; mode |= SYN_BIT_W_MODE;
if (synaptics_set_mode(psmouse, mode)) if (synaptics_mode_cmd(psmouse, mode))
return -1; return -1;
return 0; return 0;
...@@ -286,7 +289,7 @@ int synaptics_pt_init(struct psmouse *psmouse) ...@@ -286,7 +289,7 @@ int synaptics_pt_init(struct psmouse *psmouse)
/* adjust the touchpad to child's choice of protocol */ /* adjust the touchpad to child's choice of protocol */
child = port->private; child = port->private;
if (child && child->type >= PSMOUSE_GENPS) { if (child && child->type >= PSMOUSE_GENPS) {
if (synaptics_set_mode(psmouse, (SYN_BIT_ABSOLUTE_MODE | if (synaptics_mode_cmd(psmouse, (SYN_BIT_ABSOLUTE_MODE |
SYN_BIT_HIGH_RATE | SYN_BIT_HIGH_RATE |
SYN_BIT_DISABLE_GESTURE | SYN_BIT_DISABLE_GESTURE |
SYN_BIT_FOUR_BYTE_CLIENT | SYN_BIT_FOUR_BYTE_CLIENT |
...@@ -311,46 +314,27 @@ static inline void set_abs_params(struct input_dev *dev, int axis, int min, int ...@@ -311,46 +314,27 @@ static inline void set_abs_params(struct input_dev *dev, int axis, int min, int
set_bit(axis, dev->absbit); set_bit(axis, dev->absbit);
} }
int synaptics_init(struct psmouse *psmouse) static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
{ {
struct synaptics_data *priv;
#ifndef CONFIG_MOUSE_PS2_SYNAPTICS
return -1;
#endif
psmouse->private = priv = kmalloc(sizeof(struct synaptics_data), GFP_KERNEL);
if (!priv)
return -1;
memset(priv, 0, sizeof(struct synaptics_data));
priv->out_of_sync = 0;
if (query_hardware(psmouse)) {
printk(KERN_ERR "Unable to query/initialize Synaptics hardware.\n");
goto init_fail;
}
print_ident(priv);
/* /*
* The x/y limits are taken from the Synaptics TouchPad interfacing Guide, * The x/y limits are taken from the Synaptics TouchPad interfacing Guide,
* which says that they should be valid regardless of the actual size of * which says that they should be valid regardless of the actual size of
* the sensor. * the sensor.
*/ */
set_bit(EV_ABS, psmouse->dev.evbit); set_bit(EV_ABS, dev->evbit);
set_abs_params(&psmouse->dev, ABS_X, 1472, 5472, 0, 0); set_abs_params(dev, ABS_X, 1472, 5472, 0, 0);
set_abs_params(&psmouse->dev, ABS_Y, 1408, 4448, 0, 0); set_abs_params(dev, ABS_Y, 1408, 4448, 0, 0);
set_abs_params(&psmouse->dev, ABS_PRESSURE, 0, 255, 0, 0); set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
set_bit(EV_MSC, psmouse->dev.evbit); set_bit(EV_MSC, dev->evbit);
set_bit(MSC_GESTURE, psmouse->dev.mscbit); set_bit(MSC_GESTURE, dev->mscbit);
set_bit(EV_KEY, psmouse->dev.evbit); set_bit(EV_KEY, dev->evbit);
set_bit(BTN_LEFT, psmouse->dev.keybit); set_bit(BTN_LEFT, dev->keybit);
set_bit(BTN_RIGHT, psmouse->dev.keybit); set_bit(BTN_RIGHT, dev->keybit);
set_bit(BTN_FORWARD, psmouse->dev.keybit); set_bit(BTN_FORWARD, dev->keybit);
set_bit(BTN_BACK, psmouse->dev.keybit); set_bit(BTN_BACK, dev->keybit);
if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)) if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)) {
switch (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) & ~0x01) { switch (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) & ~0x01) {
default: default:
/* /*
...@@ -359,22 +343,46 @@ int synaptics_init(struct psmouse *psmouse) ...@@ -359,22 +343,46 @@ int synaptics_init(struct psmouse *psmouse)
*/ */
break; break;
case 8: case 8:
set_bit(BTN_7, psmouse->dev.keybit); set_bit(BTN_7, dev->keybit);
set_bit(BTN_6, psmouse->dev.keybit); set_bit(BTN_6, dev->keybit);
case 6: case 6:
set_bit(BTN_5, psmouse->dev.keybit); set_bit(BTN_5, dev->keybit);
set_bit(BTN_4, psmouse->dev.keybit); set_bit(BTN_4, dev->keybit);
case 4: case 4:
set_bit(BTN_3, psmouse->dev.keybit); set_bit(BTN_3, dev->keybit);
set_bit(BTN_2, psmouse->dev.keybit); set_bit(BTN_2, dev->keybit);
case 2: case 2:
set_bit(BTN_1, psmouse->dev.keybit); set_bit(BTN_1, dev->keybit);
set_bit(BTN_0, psmouse->dev.keybit); set_bit(BTN_0, dev->keybit);
break; break;
} }
clear_bit(EV_REL, psmouse->dev.evbit); }
clear_bit(REL_X, psmouse->dev.relbit);
clear_bit(REL_Y, psmouse->dev.relbit); clear_bit(EV_REL, dev->evbit);
clear_bit(REL_X, dev->relbit);
clear_bit(REL_Y, dev->relbit);
}
int synaptics_init(struct psmouse *psmouse)
{
struct synaptics_data *priv;
#ifndef CONFIG_MOUSE_PS2_SYNAPTICS
return -1;
#endif
psmouse->private = priv = kmalloc(sizeof(struct synaptics_data), GFP_KERNEL);
if (!priv)
return -1;
memset(priv, 0, sizeof(struct synaptics_data));
if (synaptics_query_hardware(psmouse)) {
printk(KERN_ERR "Unable to query/initialize Synaptics hardware.\n");
goto init_fail;
}
print_ident(priv);
set_input_params(&psmouse->dev, priv);
return 0; return 0;
...@@ -388,7 +396,7 @@ void synaptics_disconnect(struct psmouse *psmouse) ...@@ -388,7 +396,7 @@ void synaptics_disconnect(struct psmouse *psmouse)
struct synaptics_data *priv = psmouse->private; struct synaptics_data *priv = psmouse->private;
if (psmouse->type == PSMOUSE_SYNAPTICS && priv) { if (psmouse->type == PSMOUSE_SYNAPTICS && priv) {
synaptics_set_mode(psmouse, 0); synaptics_mode_cmd(psmouse, 0);
if (priv->ptport) { if (priv->ptport) {
serio_unregister_slave_port(priv->ptport); serio_unregister_slave_port(priv->ptport);
kfree(priv->ptport); kfree(priv->ptport);
...@@ -582,7 +590,9 @@ void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs) ...@@ -582,7 +590,9 @@ void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
} }
break; break;
default: default:
if (psmouse->pktcnt >= 6) { /* Full packet received */ if (psmouse->pktcnt < 6)
break; /* Wait for full packet */
if (priv->out_of_sync) { if (priv->out_of_sync) {
priv->out_of_sync = 0; priv->out_of_sync = 0;
printk(KERN_NOTICE "Synaptics driver resynced.\n"); printk(KERN_NOTICE "Synaptics driver resynced.\n");
...@@ -594,7 +604,6 @@ void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs) ...@@ -594,7 +604,6 @@ void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
synaptics_process_packet(psmouse); synaptics_process_packet(psmouse);
psmouse->pktcnt = 0; psmouse->pktcnt = 0;
}
break; break;
} }
return; return;
......
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