2006-12-13 04:50:34

by Andres Salomon

[permalink] [raw]
Subject: [PATCH] psmouse split

Hi,

When Zephaniah Hull sent in a patch for the OLPC touchpad [0], it was
suggested that the psmouse driver be split out into separate components.
What's currently there is way too fat, and people are not happy about
adding even more code to the driver.

I've taken a stab at doing just that. The attached patch splits the
various protocol extensions into their own modules, defines a protocol
registration layer, and allows modules to define their own psmouse
protocols. Psmouse-base now only registers a few extensions, and then
scans the ps/2 ports. Other modules (ie, psmouse-alps) register their
extension, and force a rescan of all serio ports that the psmouse driver
happens to be using. The max_proto stuff has been removed, with the
intention that people should be loading (or unloading) only the modules
they need, rather than playing around w/ module arguments. Rather than
playing games w/ extension detection ordering, I opted to just reset the
port before every scan.

The patch is attached, and I have a git repository here:

git://dev.laptop.org/users/dilinger/psmouse-split

There's also a gitweb interface:

http://dev.laptop.org/git?p=users/dilinger/psmouse-split;a=summary

Comments and feedback are welcome. I intend to do a few further
cleanups (at the very least, there are now stale header files that need
to go away, and further testing is needed).

[0] http://thread.gmane.org/gmane.linux.kernel/441574/


Attachments:
psmouse.patch (28.59 kB)

2006-12-13 06:17:57

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] psmouse split

Hi Andres,

On Tuesday 12 December 2006 23:31, Andres Salomon wrote:
> Hi,
>
> When Zephaniah Hull sent in a patch for the OLPC touchpad [0], it was
> suggested that the psmouse driver be split out into separate components.
> What's currently there is way too fat, and people are not happy about
> adding even more code to the driver.
>
> I've taken a stab at doing just that. The attached patch splits the
> various protocol extensions into their own modules, defines a protocol
> registration layer, and allows modules to define their own psmouse
> protocols. Psmouse-base now only registers a few extensions, and then
> scans the ps/2 ports. Other modules (ie, psmouse-alps) register their
> extension, and force a rescan of all serio ports that the psmouse driver
> happens to be using. The max_proto stuff has been removed, with the
> intention that people should be loading (or unloading) only the modules
> they need, rather than playing around w/ module arguments. Rather than
> playing games w/ extension detection ordering, I opted to just reset the
> port before every scan.
>

Unfortunately I do not think this is going to work well in in default case:

1. PS/2 probing order is important. You need to probe for intellimouse
explorer last otherwise you might miss that mouse supports extended
protocol.

2. Synaptics hardware has to be probed even if synaptics protocol is not
used, otherwise intellimouse probe will case trackpoint on passthrough
port not working.

3. Doing full reset after every protocol probe will cause long delays in
mouse detection.

4. Maxproto is still needed - psmouse base still contains several protocols
and sometimes users need to force "standard" protocols (Intellimouse/
Explorer), for example when using a KVM switch.

Also, splitting psmouse into several modules as opposed to having monolitic
psmouse with an option to exclude some protocols via Kconfig does not really
buy us anything - because protocol autoload is not possible (we do not know
what protocols port uses until we actually do the probe) distributions will
have to compile and load everything anyway. Custom kernel users will just
have to compile protocols they need into psmouse.

And some comments for the patch itself:

> +               if (proto->detect(psmouse, set_properties) == 0) {
> +                       if (proto->type == PSMOUSE_SYNAPTICS)
> +                               synaptics_hardware = 1;
> +                       if (!set_properties) {
> +                               if (proto->init && proto->init(psmouse) != 0)
> +                                       continue;

I think you wanted if (set_properties)...

> +static void psmouse_rescan(struct serio *serio, void *data)
> +{
> +       if (serio->drv->driver.name == "psmouse")
> +               serio_rescan(serio);
> +}

This is going to crash if you encounter unconnected port
(serio->drv == NULL).

> +MODULE_AUTHOR("C. Scott Ananian <[email protected]>");
> +MODULE_DESCRIPTION("Synaptics TouchPad PS/2 mouse driver");
> +MODULE_LICENSE("GPL");

You need to be careful with code attribution - for example Synaptics driver
was written by Peter Osterlund. He took some code from tpconfig utility,
that's why there is C. Scott Ananian copyright notice but _module_ author
is still Peter.

> +       psmouse_protocol_register(&genius_proto, 0);
> +       psmouse_protocol_register(&imps_proto), 0;

Hmm, does this compile?

--
Dmitry

2006-12-13 07:21:43

by Andres Salomon

[permalink] [raw]
Subject: Re: [PATCH] psmouse split

Dmitry Torokhov wrote:
> Hi Andres,
[...]
>
> Unfortunately I do not think this is going to work well in in default case:
>
> 1. PS/2 probing order is important. You need to probe for intellimouse
> explorer last otherwise you might miss that mouse supports extended
> protocol.
>

Sorry, I'm not sure I understand; you're saying that the intellimouse
probe will match other mice?

I originally had kept the probing order, but dropped it here:

http://dev.laptop.org/git?p=users/dilinger/psmouse-split;a=commit;h=14f352333d057c3a7a05fdab484b339b9bac2959

I can readd it if necessary.


> 2. Synaptics hardware has to be probed even if synaptics protocol is not
> used, otherwise intellimouse probe will case trackpoint on passthrough
> port not working.
>


I'm aware of that, and the synaptics_hardware variable remains in the
psmouse_extensions() function as a reminder. I just need to figure out
a clean way to do the probing; I wanted feedback about whether people
liked the broken out modules idea, first.


> 3. Doing full reset after every protocol probe will cause long delays in
> mouse detection.


I'm not convinced this will actually take that long, and it should only
happen during init. With ordered detection and an additional field in
the psmouse_protocol struct, each protocol could specify whether it
should be reset or not. However, if it's not necessary, I'd rather get
rid of it all (sounds like the detection ordering might be necessary,
though).

>
> 4. Maxproto is still needed - psmouse base still contains several protocols
> and sometimes users need to force "standard" protocols (Intellimouse/
> Explorer), for example when using a KVM switch.
>

Yes, I intended to split out the protocols into a separate module, as
mentioned in

http://dev.laptop.org/git?p=users/dilinger/psmouse-split;a=commit;h=2a19dbb884cb05b5e9469bde439ac60ed56bd48d

If a KVM requires a user to force a standard protocol, I would think
that forcing it via psmouse_attr_set_protocol would be a much nicer way
than dealing w/ max_proto. Combine that w/ being able to rmmod specific
protocol modules (ie, rmmod psmouse-synaptics if it turns out that
detection is incorrectly seeing something synaptics-like).


> Also, splitting psmouse into several modules as opposed to having monolitic
> psmouse with an option to exclude some protocols via Kconfig does not really
> buy us anything - because protocol autoload is not possible (we do not know

It does; compiling a custom kernel for users is a pain. However, using
a distribution kernel and being able to control specifically which
modules are loaded makes life a lot easier (users get security updates,
etc).


> what protocols port uses until we actually do the probe) distributions will
> have to compile and load everything anyway. Custom kernel users will just
> have to compile protocols they need into psmouse.
>

Yes, distributions will have to compile and load everything anyways.
However, people who know what hardware they have can then force loading
of a specific module, rather than having a monolithic module or having
to recompile a custom kernel.


> And some comments for the patch itself:
>
>> + if (proto->detect(psmouse, set_properties) == 0) {
>> + if (proto->type == PSMOUSE_SYNAPTICS)
>> + synaptics_hardware = 1;
>> + if (!set_properties) {
>> + if (proto->init && proto->init(psmouse) != 0)
>> + continue;
>
> I think you wanted if (set_properties)...
>
>> +static void psmouse_rescan(struct serio *serio, void *data)
>> +{
>> + if (serio->drv->driver.name == "psmouse")
>> + serio_rescan(serio);
>> +}
>
> This is going to crash if you encounter unconnected port
> (serio->drv == NULL).
>

Thanks!


>> +MODULE_AUTHOR("C. Scott Ananian <[email protected]>");
>> +MODULE_DESCRIPTION("Synaptics TouchPad PS/2 mouse driver");
>> +MODULE_LICENSE("GPL");
>
> You need to be careful with code attribution - for example Synaptics driver
> was written by Peter Osterlund. He took some code from tpconfig utility,
> that's why there is C. Scott Ananian copyright notice but _module_ author
> is still Peter.
>

Indeed, that was among the comments I was looking for. The copyright
attribution in each protocol file wasn't clear. Before actually
considering this done, we'd need to go through each module and make sure
that attribution is correct.



>> + psmouse_protocol_register(&genius_proto, 0);
>> + psmouse_protocol_register(&imps_proto), 0;
>
> Hmm, does this compile?
>

Oops, that was a mispaste between what I was testing and what I'd committed.

Thanks for the feedback!

2006-12-13 14:12:14

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] psmouse split

On 12/13/06, Andres Salomon <[email protected]> wrote:
> Dmitry Torokhov wrote:
> > Hi Andres,
> [...]
> >
> > Unfortunately I do not think this is going to work well in in default case:
> >
> > 1. PS/2 probing order is important. You need to probe for intellimouse
> > explorer last otherwise you might miss that mouse supports extended
> > protocol.
> >
>
> Sorry, I'm not sure I understand; you're saying that the intellimouse
> probe will match other mice?
>

Yes, for example many Logitech mice supporting PS2++ will respond to
intellimouse and explorer probes. Some versions of synaptics firmware
support intellimouse protocol as well. I am pretty sure ALPS does too.

> I originally had kept the probing order, but dropped it here:
>
> http://dev.laptop.org/git?p=users/dilinger/psmouse-split;a=commit;h=14f352333d057c3a7a05fdab484b339b9bac2959
>
> I can readd it if necessary.
>
>
> > 2. Synaptics hardware has to be probed even if synaptics protocol is not
> > used, otherwise intellimouse probe will case trackpoint on passthrough
> > port not working.
> >
>
>
> I'm aware of that, and the synaptics_hardware variable remains in the
> psmouse_extensions() function as a reminder. I just need to figure out
> a clean way to do the probing; I wanted feedback about whether people
> liked the broken out modules idea, first.
>

OK.

>
> > 3. Doing full reset after every protocol probe will cause long delays in
> > mouse detection.
>
>
> I'm not convinced this will actually take that long, and it should only
> happen during init. With ordered detection and an additional field in
> the psmouse_protocol struct, each protocol could specify whether it
> should be reset or not. However, if it's not necessary, I'd rather get
> rid of it all (sounds like the detection ordering might be necessary,
> though).
>

Resets are needed. We used not to have it but that confused some mice.

> >
> > 4. Maxproto is still needed - psmouse base still contains several protocols
> > and sometimes users need to force "standard" protocols (Intellimouse/
> > Explorer), for example when using a KVM switch.
> >
>
> Yes, I intended to split out the protocols into a separate module, as
> mentioned in
>
> http://dev.laptop.org/git?p=users/dilinger/psmouse-split;a=commit;h=2a19dbb884cb05b5e9469bde439ac60ed56bd48d
>
> If a KVM requires a user to force a standard protocol, I would think
> that forcing it via psmouse_attr_set_protocol would be a much nicer way
> than dealing w/ max_proto. Combine that w/ being able to rmmod specific
> protocol modules (ie, rmmod psmouse-synaptics if it turns out that
> detection is incorrectly seeing something synaptics-like).
>

That requires changing your init scripts and such. In many instances
specifying psmouse.max_proto on kernel command line is the easiest
way.

>
> > Also, splitting psmouse into several modules as opposed to having monolitic
> > psmouse with an option to exclude some protocols via Kconfig does not really
> > buy us anything - because protocol autoload is not possible (we do not know
>
> It does; compiling a custom kernel for users is a pain. However, using
> a distribution kernel and being able to control specifically which
> modules are loaded makes life a lot easier (users get security updates,
> etc).
>
>
> > what protocols port uses until we actually do the probe) distributions will
> > have to compile and load everything anyway. Custom kernel users will just
> > have to compile protocols they need into psmouse.
> >
>
> Yes, distributions will have to compile and load everything anyways.
> However, people who know what hardware they have can then force loading
> of a specific module, rather than having a monolithic module or having
> to recompile a custom kernel.
>

I would consider this module juggling way over the head for average
user. I want to have the ability to exclude some protocols from
psmouse module via Kconfig option, but I want it to be hidden under
CONFIG_EMBEDDED for everything except very raretic protocols (like
OLPC).

--
Dmitry

2006-12-13 16:43:08

by Andres Salomon

[permalink] [raw]
Subject: Re: [PATCH] psmouse split

Dmitry Torokhov wrote:
> On 12/13/06, Andres Salomon <[email protected]> wrote:
>> Dmitry Torokhov wrote:
[...]
>>
>> If a KVM requires a user to force a standard protocol, I would think
>> that forcing it via psmouse_attr_set_protocol would be a much nicer way
>> than dealing w/ max_proto. Combine that w/ being able to rmmod specific
>> protocol modules (ie, rmmod psmouse-synaptics if it turns out that
>> detection is incorrectly seeing something synaptics-like).
>>
>
> That requires changing your init scripts and such. In many instances
> specifying psmouse.max_proto on kernel command line is the easiest
> way.
>

Init script changing shouldn't be necessary; we have module blacklist stuff.

For example, on an ubuntu system, we have:

/etc/modprobe.d/blacklist

psmouse-foo causing problems? Just add it in there, and you're good.

I'm not aware of any way to specify values to be set in /sys (similar to
/etc/sysctl.conf), but I'm sure we'll get something sooner or later.

>>
>> > Also, splitting psmouse into several modules as opposed to having
>> monolitic
>> > psmouse with an option to exclude some protocols via Kconfig does
>> not really
>> > buy us anything - because protocol autoload is not possible (we do
>> not know
>>
>> It does; compiling a custom kernel for users is a pain. However, using
>> a distribution kernel and being able to control specifically which
>> modules are loaded makes life a lot easier (users get security updates,
>> etc).
>>
>>
>> > what protocols port uses until we actually do the probe)
>> distributions will
>> > have to compile and load everything anyway. Custom kernel users will
>> just
>> > have to compile protocols they need into psmouse.
>> >
>>
>> Yes, distributions will have to compile and load everything anyways.
>> However, people who know what hardware they have can then force loading
>> of a specific module, rather than having a monolithic module or having
>> to recompile a custom kernel.
>>
>
> I would consider this module juggling way over the head for average
> user. I want to have the ability to exclude some protocols from
> psmouse module via Kconfig option, but I want it to be hidden under
> CONFIG_EMBEDDED for everything except very raretic protocols (like
> OLPC).
>

Alright, I guess we're down to a matter of taste then. I'll change the
patch to still have a monolithic psmouse that allows protocols to be
enabled/disabled via Kconfig.

2006-12-13 17:47:22

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] psmouse split

On 12/13/06, Andres Salomon <[email protected]> wrote:
>
> Alright, I guess we're down to a matter of taste then. I'll change the
> patch to still have a monolithic psmouse that allows protocols to be
> enabled/disabled via Kconfig.
>

That'd be great. Thanks!

--
Dmitry

2007-01-03 07:08:08

by Andres Salomon

[permalink] [raw]
Subject: Re: [PATCH] psmouse split [01/03]

>From 3238fbc61c7879c38d750b710dd009560b815ab4 Mon Sep 17 00:00:00 2001
From: Andres Salomon <[email protected]>
Date: Tue, 26 Dec 2006 16:24:57 -0500
Subject: [PATCH] Create PS/2 protocol options for Kconfig

Initial framework for disabling PS/2 protocol extensions. The current
protocols can only be disabled if CONFIG_EMBEDDED is selected. No source
files are changed w/ this patch, merely build stuff.

Signed-off-by: Andres Salomon <[email protected]>
---
drivers/input/mouse/Kconfig | 50 ++++++++++++++++++++++++++++++++++++++++++
drivers/input/mouse/Makefile | 22 ++++++++++++++++++
2 files changed, 71 insertions(+), 1 deletions(-)

diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index 35d998c..498930d 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -37,6 +37,56 @@ config MOUSE_PS2
To compile this driver as a module, choose M here: the
module will be called psmouse.

+config MOUSE_PS2_ALPS
+ bool "ALPS PS/2 mouse protocol extension" if EMBEDDED
+ default y
+ depends on MOUSE_PS2
+ ---help---
+ Say Y here if you have an ALPS PS/2 touchpad connected to
+ your system.
+
+ If unsure, say Y.
+
+config MOUSE_PS2_LOGIPS2PP
+ bool "Logictech PS/2++ mouse protocol extension" if EMBEDDED
+ default y
+ depends on MOUSE_PS2
+ ---help---
+ Say Y here if you have a Logictech PS/2++ mouse connected to
+ your system.
+
+ If unsure, say Y.
+
+config MOUSE_PS2_SYNAPTICS
+ bool "Synaptics PS/2 mouse protocol extension" if EMBEDDED
+ default y
+ depends on MOUSE_PS2
+ ---help---
+ Say Y here if you have a Synaptics PS/2 TouchPad connected to
+ your system.
+
+ If unsure, say Y.
+
+config MOUSE_PS2_LIFEBOOK
+ bool "Fujitsu Lifebook PS/2 mouse protocol extension" if EMBEDDED
+ default y
+ depends on MOUSE_PS2
+ ---help---
+ Say Y here if you have a Fujitsu B-series Lifebook PS/2
+ TouchScreen connected to your system.
+
+ If unsure, say Y.
+
+config MOUSE_PS2_TRACKPOINT
+ bool "IBM Trackpoint PS/2 mouse protocol extension" if EMBEDDED
+ default y
+ depends on MOUSE_PS2
+ ---help---
+ Say Y here if you have an IBM Trackpoint PS/2 mouse connected
+ to your system.
+
+ If unsure, say Y.
+
config MOUSE_SERIAL
tristate "Serial mouse"
select SERIO
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index 21a1de6..e7c7fbb 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -14,4 +14,24 @@ obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o
obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o
obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o

-psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o
+psmouse-objs := psmouse-base.o
+
+ifeq ($(CONFIG_MOUSE_PS2_ALPS),y)
+psmouse-objs += alps.o
+endif
+
+ifeq ($(CONFIG_MOUSE_PS2_LOGIPS2PP),y)
+psmouse-objs += logips2pp.o
+endif
+
+ifeq ($(CONFIG_MOUSE_PS2_SYNAPTICS),y)
+psmouse-objs += synaptics.o
+endif
+
+ifeq ($(CONFIG_MOUSE_PS2_LIFEBOOK),y)
+psmouse-objs += lifebook.o
+endif
+
+ifeq ($(CONFIG_MOUSE_PS2_TRACKPOINT),y)
+psmouse-objs += trackpoint.o
+endif
--
1.4.1


Attachments:
0001-Create-PS-2-protocol-options-for-Kconfig.txt (3.02 kB)

2007-01-03 07:24:46

by Andres Salomon

[permalink] [raw]
Subject: Re: [PATCH] psmouse split [02/03]

>From 712d339038bb348c354f5e7472f1f156e485bda3 Mon Sep 17 00:00:00 2001
From: Andres Salomon <[email protected]>
Date: Tue, 26 Dec 2006 16:50:47 -0500
Subject: [PATCH] Wrap all protocols except for synaptics w/ ifdefs

This patch allows ALPS, LOGIPS2PP, LIFEBOOK, and TRACKPOINT protocol
extensions to be disabled during compilation. The synaptics stuff is left
alone for now, since it needs special handling for synaptic pass-through
ports.

Signed-off-by: Andres Salomon <[email protected]>
---
drivers/input/mouse/psmouse-base.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index a0e4a03..6b3ac9d 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -555,6 +555,7 @@ static int psmouse_extensions(struct psm
{
int synaptics_hardware = 0;

+#ifdef CONFIG_MOUSE_PS2_LIFEBOOK
/*
* We always check for lifebook because it does not disturb mouse
* (it only checks DMI information).
@@ -565,6 +566,7 @@ static int psmouse_extensions(struct psm
return PSMOUSE_LIFEBOOK;
}
}
+#endif

/*
* Try Kensington ThinkingMouse (we try first, because synaptics probe
@@ -596,6 +598,7 @@ static int psmouse_extensions(struct psm
synaptics_reset(psmouse);
}

+#ifdef CONFIG_MOUSE_PS2_ALPS
/*
* Try ALPS TouchPad
*/
@@ -610,15 +613,20 @@ static int psmouse_extensions(struct psm
max_proto = PSMOUSE_IMEX;
}
}
+#endif

if (max_proto > PSMOUSE_IMEX && genius_detect(psmouse, set_properties) == 0)
return PSMOUSE_GENPS;

+#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
if (max_proto > PSMOUSE_IMEX && ps2pp_init(psmouse, set_properties) == 0)
return PSMOUSE_PS2PP;
+#endif

+#ifdef CONFIG_MOUSE_PS2_TRACKPOINT
if (max_proto > PSMOUSE_IMEX && trackpoint_detect(psmouse, set_properties) == 0)
return PSMOUSE_TRACKPOINT;
+#endif

/*
* Reset to defaults in case the device got confused by extended
@@ -660,12 +668,14 @@ static const struct psmouse_protocol psm
.maxproto = 1,
.detect = ps2bare_detect,
},
+#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
{
.type = PSMOUSE_PS2PP,
.name = "PS2++",
.alias = "logitech",
.detect = ps2pp_init,
},
+#endif
{
.type = PSMOUSE_THINKPS,
.name = "ThinkPS/2",
@@ -699,6 +709,7 @@ static const struct psmouse_protocol psm
.detect = synaptics_detect,
.init = synaptics_init,
},
+#ifdef CONFIG_MOUSE_PS2_ALPS
{
.type = PSMOUSE_ALPS,
.name = "AlpsPS/2",
@@ -706,18 +717,23 @@ static const struct psmouse_protocol psm
.detect = alps_detect,
.init = alps_init,
},
+#endif
+#ifdef CONFIG_MOUSE_PS2_LIFEBOOK
{
.type = PSMOUSE_LIFEBOOK,
.name = "LBPS/2",
.alias = "lifebook",
.init = lifebook_init,
},
+#endif
+#ifdef CONFIG_MOUSE_PS2_TRACKPOINT
{
.type = PSMOUSE_TRACKPOINT,
.name = "TPPS/2",
.alias = "trackpoint",
.detect = trackpoint_detect,
},
+#endif
{
.type = PSMOUSE_AUTO,
.name = "auto",
--
1.4.1


Attachments:
0002-Wrap-all-protocols-except-for-synaptics-w-ifdefs.txt (2.96 kB)

2007-01-03 07:24:46

by Andres Salomon

[permalink] [raw]
Subject: Re: [PATCH] psmouse split [03/03]

>From ba82c3e427cd9e319e5d8898c2f730589da698a6 Mon Sep 17 00:00:00 2001
From: Andres Salomon <[email protected]>
Date: Tue, 26 Dec 2006 17:13:42 -0500
Subject: [PATCH] Allow disabling of synaptic protocol extension

This allows disabling of synaptic; basically, it leaves synaptic_detect()
and synaptic_reset() (for synaptic hardware emulating other protocols), but
gets rid of synaptic_init.

Signed-off-by: Andres Salomon <[email protected]>
---
drivers/input/mouse/Makefile | 6 +-----
drivers/input/mouse/psmouse-base.c | 5 +++++
drivers/input/mouse/synaptics.c | 34 ++++++++++++++++++++++------------
3 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index e7c7fbb..76722ec 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -14,7 +14,7 @@ obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o
obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o
obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o

-psmouse-objs := psmouse-base.o
+psmouse-objs := psmouse-base.o synaptics.o

ifeq ($(CONFIG_MOUSE_PS2_ALPS),y)
psmouse-objs += alps.o
@@ -24,10 +24,6 @@ ifeq ($(CONFIG_MOUSE_PS2_LOGIPS2PP),y)
psmouse-objs += logips2pp.o
endif

-ifeq ($(CONFIG_MOUSE_PS2_SYNAPTICS),y)
-psmouse-objs += synaptics.o
-endif
-
ifeq ($(CONFIG_MOUSE_PS2_LIFEBOOK),y)
psmouse-objs += lifebook.o
endif
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 6b3ac9d..bfb47e1 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -583,8 +583,11 @@ #endif
synaptics_hardware = 1;

if (max_proto > PSMOUSE_IMEX) {
+#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
if (!set_properties || synaptics_init(psmouse) == 0)
return PSMOUSE_SYNAPTICS;
+#endif
+
/*
* Some Synaptics touchpads can emulate extended protocols (like IMPS/2).
* Unfortunately Logitech/Genius probes confuse some firmware versions so
@@ -702,6 +705,7 @@ #endif
.maxproto = 1,
.detect = im_explorer_detect,
},
+#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
{
.type = PSMOUSE_SYNAPTICS,
.name = "SynPS/2",
@@ -709,6 +713,7 @@ #endif
.detect = synaptics_detect,
.init = synaptics_init,
},
+#endif
#ifdef CONFIG_MOUSE_PS2_ALPS
{
.type = PSMOUSE_ALPS,
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 49ac696..5d69f52 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -45,28 +45,30 @@ #define YMAX_NOMINAL 4448
****************************************************************************/

/*
- * Send a command to the synpatics touchpad by special commands
+ * Set the synaptics touchpad mode byte by special commands
*/
-static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, unsigned char *param)
+static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode)
{
- if (psmouse_sliced_command(psmouse, c))
+ unsigned char param[1];
+
+ if (psmouse_sliced_command(psmouse, mode))
return -1;
- if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO))
+ param[0] = SYN_PS_SET_MODE2;
+ if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE))
return -1;
return 0;
}

+#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
+
/*
- * Set the synaptics touchpad mode byte by special commands
+ * Send a command to the synpatics touchpad by special commands
*/
-static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode)
+static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, unsigned char *param)
{
- unsigned char param[1];
-
- if (psmouse_sliced_command(psmouse, mode))
+ if (psmouse_sliced_command(psmouse, c))
return -1;
- param[0] = SYN_PS_SET_MODE2;
- if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE))
+ if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO))
return -1;
return 0;
}
@@ -529,12 +531,16 @@ static void set_input_params(struct inpu
clear_bit(REL_Y, dev->relbit);
}

+#endif /* CONFIG_MOUSE_PS2_SYNAPTICS */
+
void synaptics_reset(struct psmouse *psmouse)
{
/* reset touchpad back to relative mode, gestures enabled */
synaptics_mode_cmd(psmouse, 0);
}

+#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
+
static void synaptics_disconnect(struct psmouse *psmouse)
{
synaptics_reset(psmouse);
@@ -569,6 +575,8 @@ static int synaptics_reconnect(struct ps
return 0;
}

+#endif /* CONFIG_MOUSE_PS2_SYNAPTICS */
+
int synaptics_detect(struct psmouse *psmouse, int set_properties)
{
struct ps2dev *ps2dev = &psmouse->ps2dev;
@@ -593,6 +601,8 @@ int synaptics_detect(struct psmouse *psm
return 0;
}

+#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
+
#if defined(__i386__)
#include <linux/dmi.h>
static struct dmi_system_id toshiba_dmi_table[] = {
@@ -679,4 +689,4 @@ #endif
return -1;
}

-
+#endif /* CONFIG_MOUSE_PS2_SYNAPTICS */
--
1.4.1


Attachments:
0003-Allow-disabling-of-synaptic-protocol-extension.txt (4.76 kB)

2007-01-03 07:36:52

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH] psmouse split [01/03]

Hi Andres.

> diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
> index 21a1de6..e7c7fbb 100644
> --- a/drivers/input/mouse/Makefile
> +++ b/drivers/input/mouse/Makefile
> @@ -14,4 +14,24 @@ obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o
> obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o
> obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o
>
> -psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o
> +psmouse-objs := psmouse-base.o
> +
> +ifeq ($(CONFIG_MOUSE_PS2_ALPS),y)
> +psmouse-objs += alps.o
> +endif
> +
> +ifeq ($(CONFIG_MOUSE_PS2_LOGIPS2PP),y)
> +psmouse-objs += logips2pp.o
> +endif
> +
> +ifeq ($(CONFIG_MOUSE_PS2_SYNAPTICS),y)
> +psmouse-objs += synaptics.o
> +endif
> +
> +ifeq ($(CONFIG_MOUSE_PS2_LIFEBOOK),y)
> +psmouse-objs += lifebook.o
> +endif
> +
> +ifeq ($(CONFIG_MOUSE_PS2_TRACKPOINT),y)
> +psmouse-objs += trackpoint.o
> +endif


The above code should be redone to use list based assignement.
Something like this:

psmouse-y := psmouse-base.o
psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o
psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o
psmouse-$(CONFIG_MOUSE_PS2_SYNAPTICS) += synaptics.o
psmouse-$(CONFIG_MOUSE_PS2_LIFEBOOK) += lifebook.o
psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o

Sam

2007-01-03 07:51:07

by Andres Salomon

[permalink] [raw]
Subject: Re: [PATCH] psmouse split [01/03]

Sam Ravnborg wrote:
> Hi Andres.
>
[...]
>
> The above code should be redone to use list based assignement.
> Something like this:
>
> psmouse-y := psmouse-base.o
> psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o
> psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o
> psmouse-$(CONFIG_MOUSE_PS2_SYNAPTICS) += synaptics.o
> psmouse-$(CONFIG_MOUSE_PS2_LIFEBOOK) += lifebook.o
> psmouse-$(CONFIG_MOUSE_PS2_TRACKPOINT) += trackpoint.o
>
> Sam

Thanks; committed to my git repo.

http://dev.laptop.org/git?p=users/dilinger/psmouse-split;a=shortlog;h=psmouse-static