linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: psmouse:  create an 'enabled' sysfs attribute to squelch mouse
@ 2012-02-18  2:06 Andres Salomon
  2012-02-24  8:21 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Andres Salomon @ 2012-02-18  2:06 UTC (permalink / raw)
  To: Alessandro Rubini
  Cc: Dmitry Torokhov, linux-input, linux-kernel, Paul Fox,
	Martin Langhoff


From: Paul Fox <pgf@laptop.org>

on OLPC XO laptops, at least one model of touchpad (sentelic)
emits continuous jittery motion reports when the laptop is
configured in "ebook" mode.  the touchpad is inaccessible in
that configuration, so we simply disable it.

these motion reports will wake the SoC when put to sleep, so simply
ignoring the events is not a possibilty; the device must be disabled.

[dilinger@queued.net: drop psmouse_resync changes, add attribute comment,
 and add psmouse_cleanup workaround]

Signed-off-by: Andres Salomon <dilinger@queued.net>
---
 drivers/input/mouse/psmouse-base.c |   20 ++++++++++++++++++--
 drivers/input/mouse/psmouse.h      |    1 +
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 22fe254..a115534 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -87,6 +87,13 @@ PSMOUSE_DEFINE_ATTR(resetafter, S_IWUSR | S_IRUGO,
 PSMOUSE_DEFINE_ATTR(resync_time, S_IWUSR | S_IRUGO,
 			(void *) offsetof(struct psmouse, resync_time),
 			psmouse_show_int_attr, psmouse_set_int_attr);
+/*
+ * There's no need for a custom handler for the 'enabled' attr;
+ * psmouse_attr_set_helper will take care of disabling and enabling for us.
+ */
+PSMOUSE_DEFINE_ATTR(enabled, S_IWUSR | S_IRUGO,
+			(void *) offsetof(struct psmouse, enabled),
+			psmouse_show_int_attr, psmouse_set_int_attr);
 
 static struct attribute *psmouse_attributes[] = {
 	&psmouse_attr_protocol.dattr.attr,
@@ -94,6 +101,7 @@ static struct attribute *psmouse_attributes[] = {
 	&psmouse_attr_resolution.dattr.attr,
 	&psmouse_attr_resetafter.dattr.attr,
 	&psmouse_attr_resync_time.dattr.attr,
+	&psmouse_attr_enabled.dattr.attr,
 	NULL
 };
 
@@ -1094,6 +1102,9 @@ static void psmouse_initialize(struct psmouse *psmouse)
 
 int psmouse_activate(struct psmouse *psmouse)
 {
+	if (!psmouse->enabled)
+		return 0;
+
 	if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE)) {
 		psmouse_warn(psmouse, "Failed to enable mouse on %s\n",
 			     psmouse->ps2dev.serio->phys);
@@ -1256,7 +1267,8 @@ static void psmouse_cleanup(struct serio *serio)
  * Some boxes, such as HP nx7400, get terribly confused if mouse
  * is not fully enabled before suspending/shutting down.
  */
-	ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);
+	if (psmouse->enabled)
+		ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE);
 
 	if (parent) {
 		if (parent->pt_deactivate)
@@ -1418,6 +1430,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
 	psmouse->resolution = psmouse_resolution;
 	psmouse->resetafter = psmouse_resetafter;
 	psmouse->resync_time = parent ? 0 : psmouse_resync_time;
+	psmouse->enabled = true;
 	psmouse->smartscroll = psmouse_smartscroll;
 
 	psmouse_switch_protocol(psmouse, NULL);
@@ -1516,7 +1529,10 @@ static int psmouse_reconnect(struct serio *serio)
 	if (parent && parent->pt_activate)
 		parent->pt_activate(parent);
 
-	psmouse_activate(psmouse);
+	if (psmouse->enabled)
+		psmouse_activate(psmouse);
+	else
+		psmouse_deactivate(psmouse);
 	rc = 0;
 
 out:
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index fe1df23..aa30321 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -62,6 +62,7 @@ struct psmouse {
 	unsigned int resolution;
 	unsigned int resetafter;
 	unsigned int resync_time;
+	bool enabled;
 	bool smartscroll;	/* Logitech only */
 
 	psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse);
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] input: psmouse:  create an 'enabled' sysfs attribute to squelch mouse
  2012-02-18  2:06 [PATCH] input: psmouse: create an 'enabled' sysfs attribute to squelch mouse Andres Salomon
@ 2012-02-24  8:21 ` Dmitry Torokhov
  2012-02-25 19:19   ` Andres Salomon
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2012-02-24  8:21 UTC (permalink / raw)
  To: Andres Salomon
  Cc: Alessandro Rubini, linux-input, linux-kernel, Paul Fox,
	Martin Langhoff

Hi Andres,

On Fri, Feb 17, 2012 at 06:06:34PM -0800, Andres Salomon wrote:
> 
> From: Paul Fox <pgf@laptop.org>
> 
> on OLPC XO laptops, at least one model of touchpad (sentelic)
> emits continuous jittery motion reports when the laptop is
> configured in "ebook" mode.  the touchpad is inaccessible in
> that configuration, so we simply disable it.
> 
> these motion reports will wake the SoC when put to sleep, so simply
> ignoring the events is not a possibilty; the device must be disabled.

Can you switch the AUX serio port into manual bind mode (viqa sysfs) and
simply connect/disconnect the touchpad as needed (again via sysfs)?

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] input: psmouse:  create an 'enabled' sysfs attribute to squelch mouse
  2012-02-24  8:21 ` Dmitry Torokhov
@ 2012-02-25 19:19   ` Andres Salomon
  0 siblings, 0 replies; 3+ messages in thread
From: Andres Salomon @ 2012-02-25 19:19 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Alessandro Rubini, linux-input, linux-kernel, Paul Fox,
	Martin Langhoff

On Fri, 24 Feb 2012 00:21:58 -0800
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:

> Hi Andres,
> 
> On Fri, Feb 17, 2012 at 06:06:34PM -0800, Andres Salomon wrote:
> > 
> > From: Paul Fox <pgf@laptop.org>
> > 
> > on OLPC XO laptops, at least one model of touchpad (sentelic)
> > emits continuous jittery motion reports when the laptop is
> > configured in "ebook" mode.  the touchpad is inaccessible in
> > that configuration, so we simply disable it.
> > 
> > these motion reports will wake the SoC when put to sleep, so simply
> > ignoring the events is not a possibilty; the device must be
> > disabled.
> 
> Can you switch the AUX serio port into manual bind mode (viqa sysfs)
> and simply connect/disconnect the touchpad as needed (again via
> sysfs)?
> 

Thanks for the suggestion.  We're in the process of testing that; it
does stop the touchpad from transmitting data, but there are some
reinit issues to be investigated.  Quoth pgf, "the added latency
due to the reinit when we enter/exit ebook mode might or might not be
acceptable.  and our touchpad (sentelic) needs some boot time
initialization from user-level -- we're not sure whether we'll need
to redo some or all of that.  (we do seem to lose the current values of
vscroll and hscroll, for instance.)"

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-02-25 19:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-18  2:06 [PATCH] input: psmouse: create an 'enabled' sysfs attribute to squelch mouse Andres Salomon
2012-02-24  8:21 ` Dmitry Torokhov
2012-02-25 19:19   ` Andres Salomon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).