[PATCH synaptics 13/17] Don't autoprobe for devices when Option Device is set.
Chris Bagwell
chris at cnpbagwell.com
Sat Apr 2 18:44:10 PDT 2011
On Sun, Mar 20, 2011 at 9:08 PM, Peter Hutterer
<peter.hutterer at who-t.net> wrote:
> If only Option Device is set but no protocol, the code calls into
> AutoDevProbe. eventcomm (the only backend with an AutoDevProbe) then runs
> through all /dev/input/event devices and takes the first one it can find.
>
> If two touchpads are connected on a system, this may cause the same touchpad
> to be added twice and the other one not at all - even though the device path
> is specified. (This can only happen when the event device is not grabbed,
> otherwise the grabcheck prevents the touchpad from being added twice)
>
> Pass the device option into AutoDevProbe and check that device first. If it
> is a touchpad, finish with success. If it isn't, fail AutoDevProbe.
I think I've stared at this enough to understand most of it. If
double adds were happening before I think its important not just that
its a touchpad but that its a touchpad that hasn't been previously
grabbed (for 2 touchpad case). If so, that might be nice to add in
comment somewhere.
Reviewed-by: Chris Bagwell <chris at cnpbagwell.com>
>
> Introduced in dce6006f6a851be4147e16731caa453dd0d1ec1c.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> CC: Alexandr Shadchin <alexandr.shadchin at gmail.com>
> ---
> src/eventcomm.c | 17 ++++++++++++++++-
> src/synaptics.c | 2 +-
> src/synproto.h | 2 +-
> 3 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/src/eventcomm.c b/src/eventcomm.c
> index 41dd669..d59efdc 100644
> --- a/src/eventcomm.c
> +++ b/src/eventcomm.c
> @@ -504,7 +504,7 @@ EventReadDevDimensions(InputInfoPtr pInfo)
> }
>
> static Bool
> -EventAutoDevProbe(InputInfoPtr pInfo)
> +EventAutoDevProbe(InputInfoPtr pInfo, const char *device)
> {
> /* We are trying to find the right eventX device or fall back to
> the psaux protocol and the given device from XF86Config */
> @@ -512,6 +512,21 @@ EventAutoDevProbe(InputInfoPtr pInfo)
> Bool touchpad_found = FALSE;
> struct dirent **namelist;
>
> + if (device) {
> + int fd = -1;
> + SYSCALL(fd = open(device, O_RDONLY));
> + if (fd >= 0)
> + {
> + touchpad_found = event_query_is_touchpad(fd, TRUE);
> +
> + SYSCALL(close(fd));
> + /* if a device is set and not a touchpad, we must return FALSE.
> + * Otherwise, we'll add a device that wasn't requested for and
> + * repeat f5687a6741a19ef3081e7fd83ac55f6df8bcd5c2. */
> + return touchpad_found;
> + }
> + }
> +
> i = scandir(DEV_INPUT_EVENT, &namelist, EventDevOnly, alphasort);
> if (i < 0) {
> xf86Msg(X_ERROR, "Couldn't open %s\n", DEV_INPUT_EVENT);
> diff --git a/src/synaptics.c b/src/synaptics.c
> index 1233917..102a701 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -261,7 +261,7 @@ SetDeviceAndProtocol(InputInfoPtr pInfo)
> for (i = 0; protocols[i].name; i++) {
> if ((!device || !proto) &&
> protocols[i].proto_ops->AutoDevProbe &&
> - protocols[i].proto_ops->AutoDevProbe(pInfo))
> + protocols[i].proto_ops->AutoDevProbe(pInfo, device))
> break;
> else if (proto && !strcmp(proto, protocols[i].name))
> break;
> diff --git a/src/synproto.h b/src/synproto.h
> index 251dc84..75f90e4 100644
> --- a/src/synproto.h
> +++ b/src/synproto.h
> @@ -75,7 +75,7 @@ struct SynapticsProtocolOperations {
> Bool (*QueryHardware)(InputInfoPtr pInfo);
> Bool (*ReadHwState)(InputInfoPtr pInfo,
> struct CommData *comm, struct SynapticsHwState *hwRet);
> - Bool (*AutoDevProbe)(InputInfoPtr pInfo);
> + Bool (*AutoDevProbe)(InputInfoPtr pInfo, const char *device);
> void (*ReadDevDimensions)(InputInfoPtr pInfo);
> };
>
> --
> 1.7.4
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list