Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269499
b: refs/heads/master
c: b5d2170
h: refs/heads/master
i:
  269497: 73114a8
  269495: ad0945f
v: v3
  • Loading branch information
Dmitry Torokhov committed Oct 11, 2011
1 parent 8d5a81f commit ce93644
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 199 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ae927560a7d3055618ccc73a5d057cdd91b63740
refs/heads/master: b5d21704361eefe337a36ebbb57a1d9927132511
52 changes: 25 additions & 27 deletions trunk/drivers/input/mouse/alps.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@
#include "psmouse.h"
#include "alps.h"

#undef DEBUG
#ifdef DEBUG
#define dbg(format, arg...) printk(KERN_INFO "alps.c: " format "\n", ## arg)
#else
#define dbg(format, arg...) do {} while (0)
#endif

#define ALPS_OLDPROTO 0x01 /* old style input */
#define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */
#define ALPS_PASS 0x04 /* device has a pass-through port */
Expand Down Expand Up @@ -297,10 +290,10 @@ static psmouse_ret_t alps_handle_interleaved_ps2(struct psmouse *psmouse)
psmouse->packet[4] |
psmouse->packet[5]) & 0x80) ||
(!alps_is_valid_first_byte(priv->i, psmouse->packet[6]))) {
dbg("refusing packet %x %x %x %x "
"(suspected interleaved ps/2)\n",
psmouse->packet[3], psmouse->packet[4],
psmouse->packet[5], psmouse->packet[6]);
psmouse_dbg(psmouse,
"refusing packet %x %x %x %x (suspected interleaved ps/2)\n",
psmouse->packet[3], psmouse->packet[4],
psmouse->packet[5], psmouse->packet[6]);
return PSMOUSE_BAD_DATA;
}

Expand All @@ -319,13 +312,13 @@ static psmouse_ret_t alps_handle_interleaved_ps2(struct psmouse *psmouse)
* There is also possibility that we got 6-byte ALPS
* packet followed by 3-byte packet from trackpoint. We
* can not distinguish between these 2 scenarios but
* becase the latter is unlikely to happen in course of
* because the latter is unlikely to happen in course of
* normal operation (user would need to press all
* buttons on the pad and start moving trackpoint
* without touching the pad surface) we assume former.
* Even if we are wrong the wost thing that would happen
* the cursor would jump but we should not get protocol
* desynchronization.
* de-synchronization.
*/

alps_report_bare_ps2_packet(psmouse, &psmouse->packet[3],
Expand Down Expand Up @@ -361,10 +354,10 @@ static void alps_flush_packet(unsigned long data)
if ((psmouse->packet[3] |
psmouse->packet[4] |
psmouse->packet[5]) & 0x80) {
dbg("refusing packet %x %x %x "
"(suspected interleaved ps/2)\n",
psmouse->packet[3], psmouse->packet[4],
psmouse->packet[5]);
psmouse_dbg(psmouse,
"refusing packet %x %x %x (suspected interleaved ps/2)\n",
psmouse->packet[3], psmouse->packet[4],
psmouse->packet[5]);
} else {
alps_process_packet(psmouse);
}
Expand Down Expand Up @@ -396,16 +389,18 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
}

if (!alps_is_valid_first_byte(model, psmouse->packet[0])) {
dbg("refusing packet[0] = %x (mask0 = %x, byte0 = %x)\n",
psmouse->packet[0], model->mask0, model->byte0);
psmouse_dbg(psmouse,
"refusing packet[0] = %x (mask0 = %x, byte0 = %x)\n",
psmouse->packet[0], model->mask0, model->byte0);
return PSMOUSE_BAD_DATA;
}

/* Bytes 2 - 6 should have 0 in the highest bit */
if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 6 &&
(psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
dbg("refusing packet[%i] = %x\n",
psmouse->pktcnt - 1, psmouse->packet[psmouse->pktcnt - 1]);
psmouse_dbg(psmouse, "refusing packet[%i] = %x\n",
psmouse->pktcnt - 1,
psmouse->packet[psmouse->pktcnt - 1]);
return PSMOUSE_BAD_DATA;
}

Expand Down Expand Up @@ -439,7 +434,8 @@ static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int
if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
return NULL;

dbg("E6 report: %2.2x %2.2x %2.2x", param[0], param[1], param[2]);
psmouse_dbg(psmouse, "E6 report: %2.2x %2.2x %2.2x",
param[0], param[1], param[2]);

if (param[0] != 0 || param[1] != 0 || (param[2] != 10 && param[2] != 100))
return NULL;
Expand All @@ -459,7 +455,8 @@ static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int
if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
return NULL;

dbg("E7 report: %2.2x %2.2x %2.2x", param[0], param[1], param[2]);
psmouse_dbg(psmouse, "E7 report: %2.2x %2.2x %2.2x",
param[0], param[1], param[2]);

if (version) {
for (i = 0; i < ARRAY_SIZE(rates) && param[2] != rates[i]; i++)
Expand Down Expand Up @@ -527,7 +524,8 @@ static int alps_get_status(struct psmouse *psmouse, char *param)
ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
return -1;

dbg("Status: %2.2x %2.2x %2.2x", param[0], param[1], param[2]);
psmouse_dbg(psmouse, "Status: %2.2x %2.2x %2.2x",
param[0], param[1], param[2]);

return 0;
}
Expand Down Expand Up @@ -605,12 +603,12 @@ static int alps_hw_init(struct psmouse *psmouse)
}

if (alps_tap_mode(psmouse, true)) {
printk(KERN_WARNING "alps.c: Failed to enable hardware tapping\n");
psmouse_warn(psmouse, "Failed to enable hardware tapping\n");
return -1;
}

if (alps_absolute_mode(psmouse)) {
printk(KERN_ERR "alps.c: Failed to enable absolute mode\n");
psmouse_err(psmouse, "Failed to enable absolute mode\n");
return -1;
}

Expand All @@ -621,7 +619,7 @@ static int alps_hw_init(struct psmouse *psmouse)

/* ALPS needs stream mode, otherwise it won't report any data */
if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSTREAM)) {
printk(KERN_ERR "alps.c: Failed to enable stream mode\n");
psmouse_err(psmouse, "Failed to enable stream mode\n");
return -1;
}

Expand Down
84 changes: 47 additions & 37 deletions trunk/drivers/input/mouse/elantech.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
* Trademarks are the property of their respective owners.
*/

#define pr_fmt(fmt) KBUILD_BASENAME ": " fmt

#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/module.h>
Expand All @@ -25,7 +23,8 @@
#define elantech_debug(fmt, ...) \
do { \
if (etd->debug) \
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
psmouse_printk(KERN_DEBUG, psmouse, \
fmt, ##__VA_ARGS__); \
} while (0)

/*
Expand All @@ -36,7 +35,7 @@ static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c,
{
if (psmouse_sliced_command(psmouse, c) ||
ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) {
pr_err("synaptics_send_cmd query 0x%02x failed.\n", c);
psmouse_err(psmouse, "%s query 0x%02x failed.\n", __func__, c);
return -1;
}

Expand Down Expand Up @@ -65,7 +64,7 @@ static int elantech_ps2_command(struct psmouse *psmouse,
} while (tries > 0);

if (rc)
pr_err("ps2 command 0x%02x failed.\n", command);
psmouse_err(psmouse, "ps2 command 0x%02x failed.\n", command);

return rc;
}
Expand Down Expand Up @@ -117,7 +116,7 @@ static int elantech_read_reg(struct psmouse *psmouse, unsigned char reg,
}

if (rc)
pr_err("failed to read register 0x%02x.\n", reg);
psmouse_err(psmouse, "failed to read register 0x%02x.\n", reg);
else if (etd->hw_version != 4)
*val = param[0];
else
Expand Down Expand Up @@ -191,22 +190,23 @@ static int elantech_write_reg(struct psmouse *psmouse, unsigned char reg,
}

if (rc)
pr_err("failed to write register 0x%02x with value 0x%02x.\n",
reg, val);
psmouse_err(psmouse,
"failed to write register 0x%02x with value 0x%02x.\n",
reg, val);

return rc;
}

/*
* Dump a complete mouse movement packet to the syslog
*/
static void elantech_packet_dump(unsigned char *packet, int size)
static void elantech_packet_dump(struct psmouse *psmouse)
{
int i;

printk(KERN_DEBUG pr_fmt("PS/2 packet ["));
for (i = 0; i < size; i++)
printk("%s0x%02x ", (i) ? ", " : " ", packet[i]);
psmouse_printk(KERN_DEBUG, psmouse, "PS/2 packet [");
for (i = 0; i < psmouse->pktsize; i++)
printk("%s0x%02x ", i ? ", " : " ", psmouse->packet[i]);
printk("]\n");
}

Expand Down Expand Up @@ -705,7 +705,7 @@ static psmouse_ret_t elantech_process_byte(struct psmouse *psmouse)
return PSMOUSE_GOOD_DATA;

if (etd->debug > 1)
elantech_packet_dump(psmouse->packet, psmouse->pktsize);
elantech_packet_dump(psmouse);

switch (etd->hw_version) {
case 1:
Expand Down Expand Up @@ -801,7 +801,7 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse)
/*
* Read back reg 0x10. For hardware version 1 we must make
* sure the absolute mode bit is set. For hardware version 2
* the touchpad is probably initalising and not ready until
* the touchpad is probably initializing and not ready until
* we read back the value we just wrote.
*/
do {
Expand All @@ -814,17 +814,19 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse)
} while (tries > 0);

if (rc) {
pr_err("failed to read back register 0x10.\n");
psmouse_err(psmouse,
"failed to read back register 0x10.\n");
} else if (etd->hw_version == 1 &&
!(val & ETP_R10_ABSOLUTE_MODE)) {
pr_err("touchpad refuses to switch to absolute mode.\n");
psmouse_err(psmouse,
"touchpad refuses to switch to absolute mode.\n");
rc = -1;
}
}

skip_readback_reg_10:
if (rc)
pr_err("failed to initialise registers.\n");
psmouse_err(psmouse, "failed to initialise registers.\n");

return rc;
}
Expand Down Expand Up @@ -1131,7 +1133,7 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties)
ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {
pr_debug("sending Elantech magic knock failed.\n");
psmouse_dbg(psmouse, "sending Elantech magic knock failed.\n");
return -1;
}

Expand All @@ -1141,8 +1143,9 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties)
*/
if (param[0] != 0x3c || param[1] != 0x03 ||
(param[2] != 0xc8 && param[2] != 0x00)) {
pr_debug("unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n",
param[0], param[1], param[2]);
psmouse_dbg(psmouse,
"unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n",
param[0], param[1], param[2]);
return -1;
}

Expand All @@ -1152,15 +1155,17 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties)
* to Elantech magic knock and there might be more.
*/
if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) {
pr_debug("failed to query firmware version.\n");
psmouse_dbg(psmouse, "failed to query firmware version.\n");
return -1;
}

pr_debug("Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n",
param[0], param[1], param[2]);
psmouse_dbg(psmouse,
"Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n",
param[0], param[1], param[2]);

if (!elantech_is_signature_valid(param)) {
pr_debug("Probably not a real Elantech touchpad. Aborting.\n");
psmouse_dbg(psmouse,
"Probably not a real Elantech touchpad. Aborting.\n");
return -1;
}

Expand Down Expand Up @@ -1192,7 +1197,8 @@ static int elantech_reconnect(struct psmouse *psmouse)
return -1;

if (elantech_set_absolute_mode(psmouse)) {
pr_err("failed to put touchpad back into absolute mode.\n");
psmouse_err(psmouse,
"failed to put touchpad back into absolute mode.\n");
return -1;
}

Expand Down Expand Up @@ -1262,42 +1268,46 @@ int elantech_init(struct psmouse *psmouse)
* Do the version query again so we can store the result
*/
if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) {
pr_err("failed to query firmware version.\n");
psmouse_err(psmouse, "failed to query firmware version.\n");
goto init_fail;
}
etd->fw_version = (param[0] << 16) | (param[1] << 8) | param[2];

if (elantech_set_properties(etd)) {
pr_err("unknown hardware version, aborting...\n");
psmouse_err(psmouse, "unknown hardware version, aborting...\n");
goto init_fail;
}
pr_info("assuming hardware version %d "
"(with firmware version 0x%02x%02x%02x)\n",
etd->hw_version, param[0], param[1], param[2]);
psmouse_info(psmouse,
"assuming hardware version %d (with firmware version 0x%02x%02x%02x)\n",
etd->hw_version, param[0], param[1], param[2]);

if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY,
etd->capabilities)) {
pr_err("failed to query capabilities.\n");
psmouse_err(psmouse, "failed to query capabilities.\n");
goto init_fail;
}
pr_info("Synaptics capabilities query result 0x%02x, 0x%02x, 0x%02x.\n",
etd->capabilities[0], etd->capabilities[1],
etd->capabilities[2]);
psmouse_info(psmouse,
"Synaptics capabilities query result 0x%02x, 0x%02x, 0x%02x.\n",
etd->capabilities[0], etd->capabilities[1],
etd->capabilities[2]);

if (elantech_set_absolute_mode(psmouse)) {
pr_err("failed to put touchpad into absolute mode.\n");
psmouse_err(psmouse,
"failed to put touchpad into absolute mode.\n");
goto init_fail;
}

if (elantech_set_input_params(psmouse)) {
pr_err("failed to query touchpad range.\n");
psmouse_err(psmouse, "failed to query touchpad range.\n");
goto init_fail;
}

error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj,
&elantech_attr_group);
if (error) {
pr_err("failed to create sysfs attributes, error: %d.\n", error);
psmouse_err(psmouse,
"failed to create sysfs attributes, error: %d.\n",
error);
goto init_fail;
}

Expand Down
Loading

0 comments on commit ce93644

Please sign in to comment.