Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5d21704 authored by Dmitry Torokhov's avatar Dmitry Torokhov
Browse files

Input: psmouse - switch to using dev_*() for messages



This will ensure our reporting is consistent with the rest of the system
and we do not refer to obsolete source file names.

Reviewed-by: default avatarWanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: default avatarJJ Ding <dgdunix@gmail.com>
Reviewed-by: default avatarDaniel Kurtz <djkurtz@chromium.org>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent ae927560
Loading
Loading
Loading
Loading
+25 −27
Original line number Original line Diff line number Diff line
@@ -23,13 +23,6 @@
#include "psmouse.h"
#include "psmouse.h"
#include "alps.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_OLDPROTO		0x01	/* old style input */
#define ALPS_DUALPOINT		0x02	/* touchpad has trackstick */
#define ALPS_DUALPOINT		0x02	/* touchpad has trackstick */
#define ALPS_PASS		0x04	/* device has a pass-through port */
#define ALPS_PASS		0x04	/* device has a pass-through port */
@@ -297,8 +290,8 @@ static psmouse_ret_t alps_handle_interleaved_ps2(struct psmouse *psmouse)
		      psmouse->packet[4] |
		      psmouse->packet[4] |
		      psmouse->packet[5]) & 0x80) ||
		      psmouse->packet[5]) & 0x80) ||
		    (!alps_is_valid_first_byte(priv->i, psmouse->packet[6]))) {
		    (!alps_is_valid_first_byte(priv->i, psmouse->packet[6]))) {
			dbg("refusing packet %x %x %x %x "
			psmouse_dbg(psmouse,
			    "(suspected interleaved ps/2)\n",
				    "refusing packet %x %x %x %x (suspected interleaved ps/2)\n",
				    psmouse->packet[3], psmouse->packet[4],
				    psmouse->packet[3], psmouse->packet[4],
				    psmouse->packet[5], psmouse->packet[6]);
				    psmouse->packet[5], psmouse->packet[6]);
			return PSMOUSE_BAD_DATA;
			return PSMOUSE_BAD_DATA;
@@ -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
		 * There is also possibility that we got 6-byte ALPS
		 * packet followed  by 3-byte packet from trackpoint. We
		 * packet followed  by 3-byte packet from trackpoint. We
		 * can not distinguish between these 2 scenarios but
		 * 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
		 * normal operation (user would need to press all
		 * buttons on the pad and start moving trackpoint
		 * buttons on the pad and start moving trackpoint
		 * without touching the pad surface) we assume former.
		 * without touching the pad surface) we assume former.
		 * Even if we are wrong the wost thing that would happen
		 * Even if we are wrong the wost thing that would happen
		 * the cursor would jump but we should not get protocol
		 * the cursor would jump but we should not get protocol
		 * desynchronization.
		 * de-synchronization.
		 */
		 */


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


	if (!alps_is_valid_first_byte(model, psmouse->packet[0])) {
	if (!alps_is_valid_first_byte(model, psmouse->packet[0])) {
		dbg("refusing packet[0] = %x (mask0 = %x, byte0 = %x)\n",
		psmouse_dbg(psmouse,
			    "refusing packet[0] = %x (mask0 = %x, byte0 = %x)\n",
			    psmouse->packet[0], model->mask0, model->byte0);
			    psmouse->packet[0], model->mask0, model->byte0);
		return PSMOUSE_BAD_DATA;
		return PSMOUSE_BAD_DATA;
	}
	}
@@ -404,8 +398,9 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
	/* Bytes 2 - 6 should have 0 in the highest bit */
	/* Bytes 2 - 6 should have 0 in the highest bit */
	if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 6 &&
	if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 6 &&
	    (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
	    (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
		dbg("refusing packet[%i] = %x\n",
		psmouse_dbg(psmouse, "refusing packet[%i] = %x\n",
		    psmouse->pktcnt - 1, psmouse->packet[psmouse->pktcnt - 1]);
			    psmouse->pktcnt - 1,
			    psmouse->packet[psmouse->pktcnt - 1]);
		return PSMOUSE_BAD_DATA;
		return PSMOUSE_BAD_DATA;
	}
	}


@@ -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))
	if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
		return NULL;
		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))
	if (param[0] != 0 || param[1] != 0 || (param[2] != 10 && param[2] != 100))
		return NULL;
		return NULL;
@@ -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))
	if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
		return NULL;
		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) {
	if (version) {
		for (i = 0; i < ARRAY_SIZE(rates) && param[2] != rates[i]; i++)
		for (i = 0; i < ARRAY_SIZE(rates) && param[2] != rates[i]; i++)
@@ -527,7 +524,8 @@ static int alps_get_status(struct psmouse *psmouse, char *param)
	    ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
	    ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
		return -1;
		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;
	return 0;
}
}
@@ -605,12 +603,12 @@ static int alps_hw_init(struct psmouse *psmouse)
	}
	}


	if (alps_tap_mode(psmouse, true)) {
	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;
		return -1;
	}
	}


	if (alps_absolute_mode(psmouse)) {
	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;
		return -1;
	}
	}


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


	/* ALPS needs stream mode, otherwise it won't report any data */
	/* ALPS needs stream mode, otherwise it won't report any data */
	if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSTREAM)) {
	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;
		return -1;
	}
	}


+47 −37
Original line number Original line Diff line number Diff line
@@ -10,8 +10,6 @@
 * Trademarks are the property of their respective owners.
 * Trademarks are the property of their respective owners.
 */
 */


#define pr_fmt(fmt) KBUILD_BASENAME ": " fmt

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


/*
/*
@@ -36,7 +35,7 @@ static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c,
{
{
	if (psmouse_sliced_command(psmouse, c) ||
	if (psmouse_sliced_command(psmouse, c) ||
	    ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) {
	    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;
		return -1;
	}
	}


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


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


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


	if (rc)
	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)
	else if (etd->hw_version != 4)
		*val = param[0];
		*val = param[0];
	else
	else
@@ -191,7 +190,8 @@ static int elantech_write_reg(struct psmouse *psmouse, unsigned char reg,
	}
	}


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


	return rc;
	return rc;
@@ -200,13 +200,13 @@ static int elantech_write_reg(struct psmouse *psmouse, unsigned char reg,
/*
/*
 * Dump a complete mouse movement packet to the syslog
 * 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;
	int	i;


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


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


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


	switch (etd->hw_version) {
	switch (etd->hw_version) {
	case 1:
	case 1:
@@ -801,7 +801,7 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse)
		/*
		/*
		 * Read back reg 0x10. For hardware version 1 we must make
		 * Read back reg 0x10. For hardware version 1 we must make
		 * sure the absolute mode bit is set. For hardware version 2
		 * 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.
		 * we read back the value we just wrote.
		 */
		 */
		do {
		do {
@@ -814,17 +814,19 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse)
		} while (tries > 0);
		} while (tries > 0);


		if (rc) {
		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 &&
		} else if (etd->hw_version == 1 &&
			   !(val & ETP_R10_ABSOLUTE_MODE)) {
			   !(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;
			rc = -1;
		}
		}
	}
	}


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


	return rc;
	return rc;
}
}
@@ -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,  NULL, PSMOUSE_CMD_SETSCALE11) ||
	    ps2_command(ps2dev,  NULL, PSMOUSE_CMD_SETSCALE11) ||
	    ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {
	    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;
		return -1;
	}
	}


@@ -1141,7 +1143,8 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties)
	 */
	 */
	if (param[0] != 0x3c || param[1] != 0x03 ||
	if (param[0] != 0x3c || param[1] != 0x03 ||
	    (param[2] != 0xc8 && param[2] != 0x00)) {
	    (param[2] != 0xc8 && param[2] != 0x00)) {
		pr_debug("unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n",
		psmouse_dbg(psmouse,
			    "unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n",
			    param[0], param[1], param[2]);
			    param[0], param[1], param[2]);
		return -1;
		return -1;
	}
	}
@@ -1152,15 +1155,17 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties)
	 * to Elantech magic knock and there might be more.
	 * to Elantech magic knock and there might be more.
	 */
	 */
	if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) {
	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;
		return -1;
	}
	}


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


	if (!elantech_is_signature_valid(param)) {
	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;
		return -1;
	}
	}


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


	if (elantech_set_absolute_mode(psmouse)) {
	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;
		return -1;
	}
	}


@@ -1262,42 +1268,46 @@ int elantech_init(struct psmouse *psmouse)
	 * Do the version query again so we can store the result
	 * Do the version query again so we can store the result
	 */
	 */
	if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) {
	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;
		goto init_fail;
	}
	}
	etd->fw_version = (param[0] << 16) | (param[1] << 8) | param[2];
	etd->fw_version = (param[0] << 16) | (param[1] << 8) | param[2];


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


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


	if (elantech_set_absolute_mode(psmouse)) {
	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;
		goto init_fail;
	}
	}


	if (elantech_set_input_params(psmouse)) {
	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;
		goto init_fail;
	}
	}


	error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj,
	error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj,
				   &elantech_attr_group);
				   &elantech_attr_group);
	if (error) {
	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;
		goto init_fail;
	}
	}


+43 −41
Original line number Original line Diff line number Diff line
@@ -136,10 +136,10 @@ static int hgpk_discard_decay_hack(struct psmouse *psmouse, int x, int y)
	/* discard if too big, or half that but > 4 times the prev delta */
	/* discard if too big, or half that but > 4 times the prev delta */
	if (avx > recalib_delta ||
	if (avx > recalib_delta ||
		(avx > recalib_delta / 2 && ((avx / 4) > priv->xlast))) {
		(avx > recalib_delta / 2 && ((avx / 4) > priv->xlast))) {
		hgpk_err(psmouse, "detected %dpx jump in x\n", x);
		psmouse_warn(psmouse, "detected %dpx jump in x\n", x);
		priv->xbigj = avx;
		priv->xbigj = avx;
	} else if (approx_half(avx, priv->xbigj)) {
	} else if (approx_half(avx, priv->xbigj)) {
		hgpk_err(psmouse, "detected secondary %dpx jump in x\n", x);
		psmouse_warn(psmouse, "detected secondary %dpx jump in x\n", x);
		priv->xbigj = avx;
		priv->xbigj = avx;
		priv->xsaw_secondary++;
		priv->xsaw_secondary++;
	} else {
	} else {
@@ -151,10 +151,10 @@ static int hgpk_discard_decay_hack(struct psmouse *psmouse, int x, int y)


	if (avy > recalib_delta ||
	if (avy > recalib_delta ||
		(avy > recalib_delta / 2 && ((avy / 4) > priv->ylast))) {
		(avy > recalib_delta / 2 && ((avy / 4) > priv->ylast))) {
		hgpk_err(psmouse, "detected %dpx jump in y\n", y);
		psmouse_warn(psmouse, "detected %dpx jump in y\n", y);
		priv->ybigj = avy;
		priv->ybigj = avy;
	} else if (approx_half(avy, priv->ybigj)) {
	} else if (approx_half(avy, priv->ybigj)) {
		hgpk_err(psmouse, "detected secondary %dpx jump in y\n", y);
		psmouse_warn(psmouse, "detected secondary %dpx jump in y\n", y);
		priv->ybigj = avy;
		priv->ybigj = avy;
		priv->ysaw_secondary++;
		priv->ysaw_secondary++;
	} else {
	} else {
@@ -168,7 +168,7 @@ static int hgpk_discard_decay_hack(struct psmouse *psmouse, int x, int y)
	priv->ylast = avy;
	priv->ylast = avy;


	if (do_recal && jumpy_delay) {
	if (do_recal && jumpy_delay) {
		hgpk_err(psmouse, "scheduling recalibration\n");
		psmouse_warn(psmouse, "scheduling recalibration\n");
		psmouse_queue_work(psmouse, &priv->recalib_wq,
		psmouse_queue_work(psmouse, &priv->recalib_wq,
				msecs_to_jiffies(jumpy_delay));
				msecs_to_jiffies(jumpy_delay));
	}
	}
@@ -260,7 +260,7 @@ static void hgpk_spewing_hack(struct psmouse *psmouse,
		 * movement, it is probably a case of the user moving the
		 * movement, it is probably a case of the user moving the
		 * cursor very slowly across the screen. */
		 * cursor very slowly across the screen. */
		if (abs(priv->x_tally) < 3 && abs(priv->y_tally) < 3) {
		if (abs(priv->x_tally) < 3 && abs(priv->y_tally) < 3) {
			hgpk_err(psmouse, "packet spew detected (%d,%d)\n",
			psmouse_warn(psmouse, "packet spew detected (%d,%d)\n",
				     priv->x_tally, priv->y_tally);
				     priv->x_tally, priv->y_tally);
			priv->spew_flag = RECALIBRATING;
			priv->spew_flag = RECALIBRATING;
			psmouse_queue_work(psmouse, &priv->recalib_wq,
			psmouse_queue_work(psmouse, &priv->recalib_wq,
@@ -333,7 +333,7 @@ static bool hgpk_is_byte_valid(struct psmouse *psmouse, unsigned char *packet)
	}
	}


	if (!valid)
	if (!valid)
		hgpk_dbg(psmouse,
		psmouse_dbg(psmouse,
			    "bad data, mode %d (%d) %02x %02x %02x %02x %02x %02x\n",
			    "bad data, mode %d (%d) %02x %02x %02x %02x %02x %02x\n",
			    priv->mode, pktcnt,
			    priv->mode, pktcnt,
			    psmouse->packet[0], psmouse->packet[1],
			    psmouse->packet[0], psmouse->packet[1],
@@ -361,7 +361,7 @@ static void hgpk_process_advanced_packet(struct psmouse *psmouse)


		input_report_abs(idev, ABS_PRESSURE, z);
		input_report_abs(idev, ABS_PRESSURE, z);
		if (tpdebug)
		if (tpdebug)
			hgpk_dbg(psmouse, "pd=%d fd=%d z=%d",
			psmouse_dbg(psmouse, "pd=%d fd=%d z=%d",
				    pt_down, finger_down, z);
				    pt_down, finger_down, z);
	} else {
	} else {
		/*
		/*
@@ -369,11 +369,12 @@ static void hgpk_process_advanced_packet(struct psmouse *psmouse)
		 * report it here
		 * report it here
		 */
		 */
		if (tpdebug)
		if (tpdebug)
			hgpk_dbg(psmouse, "pd=%d ", down);
			psmouse_dbg(psmouse, "pd=%d ", down);
	}
	}


	if (tpdebug)
	if (tpdebug)
		hgpk_dbg(psmouse, "l=%d r=%d x=%d y=%d\n", left, right, x, y);
		psmouse_dbg(psmouse, "l=%d r=%d x=%d y=%d\n",
			    left, right, x, y);


	input_report_key(idev, BTN_TOUCH, down);
	input_report_key(idev, BTN_TOUCH, down);
	input_report_key(idev, BTN_LEFT, left);
	input_report_key(idev, BTN_LEFT, left);
@@ -395,7 +396,7 @@ static void hgpk_process_advanced_packet(struct psmouse *psmouse)
	if (x == priv->abs_x && y == priv->abs_y) {
	if (x == priv->abs_x && y == priv->abs_y) {
		if (++priv->dupe_count > SPEW_WATCH_COUNT) {
		if (++priv->dupe_count > SPEW_WATCH_COUNT) {
			if (tpdebug)
			if (tpdebug)
				hgpk_dbg(psmouse, "hard spew detected\n");
				psmouse_dbg(psmouse, "hard spew detected\n");
			priv->spew_flag = RECALIBRATING;
			priv->spew_flag = RECALIBRATING;
			psmouse_queue_work(psmouse, &priv->recalib_wq,
			psmouse_queue_work(psmouse, &priv->recalib_wq,
					   msecs_to_jiffies(spew_delay));
					   msecs_to_jiffies(spew_delay));
@@ -412,7 +413,7 @@ static void hgpk_process_advanced_packet(struct psmouse *psmouse)
		int y_diff = priv->abs_y - y;
		int y_diff = priv->abs_y - y;
		if (hgpk_discard_decay_hack(psmouse, x_diff, y_diff)) {
		if (hgpk_discard_decay_hack(psmouse, x_diff, y_diff)) {
			if (tpdebug)
			if (tpdebug)
				hgpk_dbg(psmouse, "discarding\n");
				psmouse_dbg(psmouse, "discarding\n");
			goto done;
			goto done;
		}
		}
		hgpk_spewing_hack(psmouse, left, right, x_diff, y_diff);
		hgpk_spewing_hack(psmouse, left, right, x_diff, y_diff);
@@ -437,20 +438,21 @@ static void hgpk_process_simple_packet(struct psmouse *psmouse)
	int y = ((packet[0] << 3) & 0x100) - packet[2];
	int y = ((packet[0] << 3) & 0x100) - packet[2];


	if (packet[0] & 0xc0)
	if (packet[0] & 0xc0)
		hgpk_dbg(psmouse,
		psmouse_dbg(psmouse,
			    "overflow -- 0x%02x 0x%02x 0x%02x\n",
			    "overflow -- 0x%02x 0x%02x 0x%02x\n",
			    packet[0], packet[1], packet[2]);
			    packet[0], packet[1], packet[2]);


	if (hgpk_discard_decay_hack(psmouse, x, y)) {
	if (hgpk_discard_decay_hack(psmouse, x, y)) {
		if (tpdebug)
		if (tpdebug)
			hgpk_dbg(psmouse, "discarding\n");
			psmouse_dbg(psmouse, "discarding\n");
		return;
		return;
	}
	}


	hgpk_spewing_hack(psmouse, left, right, x, y);
	hgpk_spewing_hack(psmouse, left, right, x, y);


	if (tpdebug)
	if (tpdebug)
		hgpk_dbg(psmouse, "l=%d r=%d x=%d y=%d\n", left, right, x, y);
		psmouse_dbg(psmouse, "l=%d r=%d x=%d y=%d\n",
			    left, right, x, y);


	input_report_key(dev, BTN_LEFT, left);
	input_report_key(dev, BTN_LEFT, left);
	input_report_key(dev, BTN_RIGHT, right);
	input_report_key(dev, BTN_RIGHT, right);
@@ -482,9 +484,8 @@ static psmouse_ret_t hgpk_process_byte(struct psmouse *psmouse)
			 * ugh, got a packet inside our recalibration
			 * ugh, got a packet inside our recalibration
			 * window, schedule another recalibration.
			 * window, schedule another recalibration.
			 */
			 */
			hgpk_dbg(psmouse,
			psmouse_dbg(psmouse,
				 "packet inside calibration window, "
				    "packet inside calibration window, queueing another recalibration\n");
				 "queueing another recalibration\n");
			psmouse_queue_work(psmouse, &priv->recalib_wq,
			psmouse_queue_work(psmouse, &priv->recalib_wq,
					msecs_to_jiffies(post_interrupt_delay));
					msecs_to_jiffies(post_interrupt_delay));
		}
		}
@@ -628,7 +629,7 @@ static int hgpk_reset_device(struct psmouse *psmouse, bool recalibrate)


	err = hgpk_select_mode(psmouse);
	err = hgpk_select_mode(psmouse);
	if (err) {
	if (err) {
		hgpk_err(psmouse, "failed to select mode\n");
		psmouse_err(psmouse, "failed to select mode\n");
		return err;
		return err;
	}
	}


@@ -648,11 +649,11 @@ static int hgpk_force_recalibrate(struct psmouse *psmouse)
		return 0;
		return 0;


	if (!autorecal) {
	if (!autorecal) {
		hgpk_dbg(psmouse, "recalibrations disabled, ignoring\n");
		psmouse_dbg(psmouse, "recalibration disabled, ignoring\n");
		return 0;
		return 0;
	}
	}


	hgpk_dbg(psmouse, "recalibrating touchpad..\n");
	psmouse_dbg(psmouse, "recalibrating touchpad..\n");


	/* we don't want to race with the irq handler, nor with resyncs */
	/* we don't want to race with the irq handler, nor with resyncs */
	psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
	psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
@@ -675,7 +676,7 @@ static int hgpk_force_recalibrate(struct psmouse *psmouse)
	psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
	psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);


	if (tpdebug)
	if (tpdebug)
		hgpk_dbg(psmouse, "touchpad reactivated\n");
		psmouse_dbg(psmouse, "touchpad reactivated\n");


	/*
	/*
	 * If we get packets right away after recalibrating, it's likely
	 * If we get packets right away after recalibrating, it's likely
@@ -727,16 +728,16 @@ static int hgpk_toggle_powersave(struct psmouse *psmouse, int enable)


		err = hgpk_reset_device(psmouse, false);
		err = hgpk_reset_device(psmouse, false);
		if (err) {
		if (err) {
			hgpk_err(psmouse, "Failed to reset device!\n");
			psmouse_err(psmouse, "Failed to reset device!\n");
			return err;
			return err;
		}
		}


		/* should be all set, enable the touchpad */
		/* should be all set, enable the touchpad */
		ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);
		ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);
		psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
		psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
		hgpk_dbg(psmouse, "Touchpad powered up.\n");
		psmouse_dbg(psmouse, "Touchpad powered up.\n");
	} else {
	} else {
		hgpk_dbg(psmouse, "Powering off touchpad.\n");
		psmouse_dbg(psmouse, "Powering off touchpad.\n");


		if (ps2_command(ps2dev, NULL, 0xec) ||
		if (ps2_command(ps2dev, NULL, 0xec) ||
		    ps2_command(ps2dev, NULL, 0xec) ||
		    ps2_command(ps2dev, NULL, 0xec) ||
@@ -923,7 +924,7 @@ static void hgpk_recalib_work(struct work_struct *work)
	struct psmouse *psmouse = priv->psmouse;
	struct psmouse *psmouse = priv->psmouse;


	if (hgpk_force_recalibrate(psmouse))
	if (hgpk_force_recalibrate(psmouse))
		hgpk_err(psmouse, "recalibration failed!\n");
		psmouse_err(psmouse, "recalibration failed!\n");
}
}


static int hgpk_register(struct psmouse *psmouse)
static int hgpk_register(struct psmouse *psmouse)
@@ -947,14 +948,15 @@ static int hgpk_register(struct psmouse *psmouse)
	err = device_create_file(&psmouse->ps2dev.serio->dev,
	err = device_create_file(&psmouse->ps2dev.serio->dev,
				 &psmouse_attr_powered.dattr);
				 &psmouse_attr_powered.dattr);
	if (err) {
	if (err) {
		hgpk_err(psmouse, "Failed creating 'powered' sysfs node\n");
		psmouse_err(psmouse, "Failed creating 'powered' sysfs node\n");
		return err;
		return err;
	}
	}


	err = device_create_file(&psmouse->ps2dev.serio->dev,
	err = device_create_file(&psmouse->ps2dev.serio->dev,
				 &psmouse_attr_hgpk_mode.dattr);
				 &psmouse_attr_hgpk_mode.dattr);
	if (err) {
	if (err) {
		hgpk_err(psmouse, "Failed creating 'hgpk_mode' sysfs node\n");
		psmouse_err(psmouse,
			    "Failed creating 'hgpk_mode' sysfs node\n");
		goto err_remove_powered;
		goto err_remove_powered;
	}
	}


@@ -963,7 +965,7 @@ static int hgpk_register(struct psmouse *psmouse)
		err = device_create_file(&psmouse->ps2dev.serio->dev,
		err = device_create_file(&psmouse->ps2dev.serio->dev,
					 &psmouse_attr_recalibrate.dattr);
					 &psmouse_attr_recalibrate.dattr);
		if (err) {
		if (err) {
			hgpk_err(psmouse,
			psmouse_err(psmouse,
				    "Failed creating 'recalibrate' sysfs node\n");
				    "Failed creating 'recalibrate' sysfs node\n");
			goto err_remove_mode;
			goto err_remove_mode;
		}
		}
@@ -1027,13 +1029,13 @@ static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse)
		return -EIO;
		return -EIO;
	}
	}


	hgpk_dbg(psmouse, "ID: %02x %02x %02x\n", param[0], param[1], param[2]);
	psmouse_dbg(psmouse, "ID: %02x %02x %02x\n", param[0], param[1], param[2]);


	/* HGPK signature: 0x67, 0x00, 0x<model> */
	/* HGPK signature: 0x67, 0x00, 0x<model> */
	if (param[0] != 0x67 || param[1] != 0x00)
	if (param[0] != 0x67 || param[1] != 0x00)
		return -ENODEV;
		return -ENODEV;


	hgpk_info(psmouse, "OLPC touchpad revision 0x%x\n", param[2]);
	psmouse_info(psmouse, "OLPC touchpad revision 0x%x\n", param[2]);


	return param[2];
	return param[2];
}
}
+0 −11
Original line number Original line Diff line number Diff line
@@ -46,17 +46,6 @@ struct hgpk_data {
	int xsaw_secondary, ysaw_secondary; /* jumpiness detection */
	int xsaw_secondary, ysaw_secondary; /* jumpiness detection */
};
};


#define hgpk_dbg(psmouse, format, arg...)		\
	dev_dbg(&(psmouse)->ps2dev.serio->dev, format, ## arg)
#define hgpk_err(psmouse, format, arg...)		\
	dev_err(&(psmouse)->ps2dev.serio->dev, format, ## arg)
#define hgpk_info(psmouse, format, arg...)		\
	dev_info(&(psmouse)->ps2dev.serio->dev, format, ## arg)
#define hgpk_warn(psmouse, format, arg...)		\
	dev_warn(&(psmouse)->ps2dev.serio->dev, format, ## arg)
#define hgpk_notice(psmouse, format, arg...)		\
	dev_notice(&(psmouse)->ps2dev.serio->dev, format, ## arg)

#ifdef CONFIG_MOUSE_PS2_OLPC
#ifdef CONFIG_MOUSE_PS2_OLPC
void hgpk_module_init(void);
void hgpk_module_init(void);
int hgpk_detect(struct psmouse *psmouse, bool set_properties);
int hgpk_detect(struct psmouse *psmouse, bool set_properties);
+3 −3
Original line number Original line Diff line number Diff line
@@ -169,8 +169,8 @@ static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse)


	if (relative_packet) {
	if (relative_packet) {
		if (!dev2)
		if (!dev2)
			printk(KERN_WARNING "lifebook.c: got relative packet "
			psmouse_warn(psmouse,
				"but no relative device set up\n");
				     "got relative packet but no relative device set up\n");
	} else {
	} else {
		if (lifebook_use_6byte_proto) {
		if (lifebook_use_6byte_proto) {
			input_report_abs(dev1, ABS_X,
			input_report_abs(dev1, ABS_X,
@@ -212,7 +212,7 @@ static int lifebook_absolute_mode(struct psmouse *psmouse)


	/*
	/*
	 * Enable absolute output -- ps2_command fails always but if
	 * Enable absolute output -- ps2_command fails always but if
	 * you leave this call out the touchsreen will never send
	 * you leave this call out the touchscreen will never send
	 * absolute coordinates
	 * absolute coordinates
	 */
	 */
	param = lifebook_use_6byte_proto ? 0x08 : 0x07;
	param = lifebook_use_6byte_proto ? 0x08 : 0x07;
Loading