diff mbox

HID: magicmouse: ignore 'ivalid report id' while switching modes

Message ID alpine.LNX.2.00.1108231052220.13644@pobox.suse.cz (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Jiri Kosina Aug. 23, 2011, 8:53 a.m. UTC
On Thu, 18 Aug 2011, Jaikumar Ganesh wrote:

> I also tracked down two Apple magic trackpads - both with the same
> Bluetooth version.
> One which needs this patch (as it returns an invalid report id) and
> the other which doesn't need this patch.
> Both use the same device id.

Gotta love hardware vendors indeed.

So how about the patch below?



From: Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH] HID: magicmouse: ignore 'ivalid report id' while switching modes, v2

This is basically a more generic respin of 23746a6 ("HID: magicmouse: ignore
'ivalid report id' while switching modes") which got reverted later by
c3a492.

It turns out that on some configurations, this is actually still the case
and we are not able to detect in runtime.

The device reponds with 'invalid report id' when feature report switching it
into multitouch mode is sent to it.

This has been silently ignored before 0825411ade ("HID: bt: Wait for ACK
on Sent Reports"), but since this commit, it propagates -EIO from the _raw
callback .

So let the driver ignore -EIO as response to 0xd7,0x01 report, as that's
how the device reacts in normal mode.

Sad, but following reality.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=35022

Reported-by: Chase Douglas <chase.douglas@canonical.com>
Reported-by: Jaikumar Ganesh <jaikumarg@android.com>
Tested-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
 drivers/hid/hid-magicmouse.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

Comments

Jaikumar Ganesh Aug. 23, 2011, 6:17 p.m. UTC | #1
Hi Jiri,

On Tue, Aug 23, 2011 at 1:53 AM, Jiri Kosina <jkosina@suse.cz> wrote:
> On Thu, 18 Aug 2011, Jaikumar Ganesh wrote:
>
>> I also tracked down two Apple magic trackpads - both with the same
>> Bluetooth version.
>> One which needs this patch (as it returns an invalid report id) and
>> the other which doesn't need this patch.
>> Both use the same device id.
>
> Gotta love hardware vendors indeed.
>
> So how about the patch below?
>
>
>
> From: Jiri Kosina <jkosina@suse.cz>
> Subject: [PATCH] HID: magicmouse: ignore 'ivalid report id' while switching modes, v2
>
> This is basically a more generic respin of 23746a6 ("HID: magicmouse: ignore
> 'ivalid report id' while switching modes") which got reverted later by
> c3a492.
>
> It turns out that on some configurations, this is actually still the case
> and we are not able to detect in runtime.
>
> The device reponds with 'invalid report id' when feature report switching it
> into multitouch mode is sent to it.
>
> This has been silently ignored before 0825411ade ("HID: bt: Wait for ACK
> on Sent Reports"), but since this commit, it propagates -EIO from the _raw
> callback .
>
> So let the driver ignore -EIO as response to 0xd7,0x01 report, as that's
> how the device reacts in normal mode.
>
> Sad, but following reality.
>
> This fixes https://bugzilla.kernel.org/show_bug.cgi?id=35022
>
> Reported-by: Chase Douglas <chase.douglas@canonical.com>
> Reported-by: Jaikumar Ganesh <jaikumarg@android.com>
> Tested-by: Chase Douglas <chase.douglas@canonical.com>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> ---
>  drivers/hid/hid-magicmouse.c |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
> index b5bdab3..f0fbd7b 100644
> --- a/drivers/hid/hid-magicmouse.c
> +++ b/drivers/hid/hid-magicmouse.c
> @@ -537,9 +537,17 @@ static int magicmouse_probe(struct hid_device *hdev,
>        }
>        report->size = 6;
>
> +       /*
> +        * Some devices repond with 'invalid report id' when feature
> +        * report switching it into multitouch mode is sent to it.
> +        *
> +        * This results in -EIO from the _raw low-level transport callback,
> +        * but there seems to be no other way of switching the mode.
> +        * Thus the super-ugly hacky success check below.
> +        */
>        ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature),
>                        HID_FEATURE_REPORT);
> -       if (ret != sizeof(feature)) {
> +       if (ret != -EIO && ret != sizeof(feature)) {
>                hid_err(hdev, "unable to request touch data (%d)\n", ret);
>                goto err_stop_hw;
>        }
> --
> 1.7.3.1
>
>

Tested. Please push.

Thanks
Jaikumar
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chase Douglas Aug. 24, 2011, 3:13 p.m. UTC | #2
On 08/23/2011 01:53 AM, Jiri Kosina wrote:
> On Thu, 18 Aug 2011, Jaikumar Ganesh wrote:
> 
>> I also tracked down two Apple magic trackpads - both with the same
>> Bluetooth version.
>> One which needs this patch (as it returns an invalid report id) and
>> the other which doesn't need this patch.
>> Both use the same device id.
> 
> Gotta love hardware vendors indeed.
> 
> So how about the patch below?
> 
> 
> 
> From: Jiri Kosina <jkosina@suse.cz>
> Subject: [PATCH] HID: magicmouse: ignore 'ivalid report id' while switching modes, v2

                                    spelling: ^

> 
> This is basically a more generic respin of 23746a6 ("HID: magicmouse: ignore
> 'ivalid report id' while switching modes") which got reverted later by
> c3a492.
> 
> It turns out that on some configurations, this is actually still the case
> and we are not able to detect in runtime.
> 
> The device reponds with 'invalid report id' when feature report switching it
> into multitouch mode is sent to it.
> 
> This has been silently ignored before 0825411ade ("HID: bt: Wait for ACK
> on Sent Reports"), but since this commit, it propagates -EIO from the _raw
> callback .
> 
> So let the driver ignore -EIO as response to 0xd7,0x01 report, as that's
> how the device reacts in normal mode.
> 
> Sad, but following reality.
> 
> This fixes https://bugzilla.kernel.org/show_bug.cgi?id=35022
> 
> Reported-by: Chase Douglas <chase.douglas@canonical.com>
> Reported-by: Jaikumar Ganesh <jaikumarg@android.com>
> Tested-by: Chase Douglas <chase.douglas@canonical.com>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Looks good to me. I tested it and it fixed things here.

Thanks!

-- Chase
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jiri Kosina Aug. 25, 2011, 12:22 p.m. UTC | #3
On Tue, 23 Aug 2011, Jaikumar Ganesh wrote:

> > From: Jiri Kosina <jkosina@suse.cz>
> > Subject: [PATCH] HID: magicmouse: ignore 'ivalid report id' while switching modes, v2
> >
> > This is basically a more generic respin of 23746a6 ("HID: magicmouse: ignore
> > 'ivalid report id' while switching modes") which got reverted later by
> > c3a492.
> >
> > It turns out that on some configurations, this is actually still the case
> > and we are not able to detect in runtime.
> >
> > The device reponds with 'invalid report id' when feature report switching it
> > into multitouch mode is sent to it.
> >
> > This has been silently ignored before 0825411ade ("HID: bt: Wait for ACK
> > on Sent Reports"), but since this commit, it propagates -EIO from the _raw
> > callback .
> >
> > So let the driver ignore -EIO as response to 0xd7,0x01 report, as that's
> > how the device reacts in normal mode.
> >
> > Sad, but following reality.
> >
> > This fixes https://bugzilla.kernel.org/show_bug.cgi?id=35022
> >
> > Reported-by: Chase Douglas <chase.douglas@canonical.com>
> > Reported-by: Jaikumar Ganesh <jaikumarg@android.com>
> > Tested-by: Chase Douglas <chase.douglas@canonical.com>
> > Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> > ---
> >  drivers/hid/hid-magicmouse.c |   10 +++++++++-
> >  1 files changed, 9 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
> > index b5bdab3..f0fbd7b 100644
> > --- a/drivers/hid/hid-magicmouse.c
> > +++ b/drivers/hid/hid-magicmouse.c
> > @@ -537,9 +537,17 @@ static int magicmouse_probe(struct hid_device *hdev,
> >        }
> >        report->size = 6;
> >
> > +       /*
> > +        * Some devices repond with 'invalid report id' when feature
> > +        * report switching it into multitouch mode is sent to it.
> > +        *
> > +        * This results in -EIO from the _raw low-level transport callback,
> > +        * but there seems to be no other way of switching the mode.
> > +        * Thus the super-ugly hacky success check below.
> > +        */
> >        ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature),
> >                        HID_FEATURE_REPORT);
> > -       if (ret != sizeof(feature)) {
> > +       if (ret != -EIO && ret != sizeof(feature)) {
> >                hid_err(hdev, "unable to request touch data (%d)\n", ret);
> >                goto err_stop_hw;
> >        }
> > --
> > 1.7.3.1
> 
> Tested. Please push.

Okay, I have queued it with your Tested-by. Thanks,
diff mbox

Patch

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index b5bdab3..f0fbd7b 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -537,9 +537,17 @@  static int magicmouse_probe(struct hid_device *hdev,
 	}
 	report->size = 6;
 
+	/*
+	 * Some devices repond with 'invalid report id' when feature
+	 * report switching it into multitouch mode is sent to it.
+	 *
+	 * This results in -EIO from the _raw low-level transport callback,
+	 * but there seems to be no other way of switching the mode.
+	 * Thus the super-ugly hacky success check below.
+	 */
 	ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature),
 			HID_FEATURE_REPORT);
-	if (ret != sizeof(feature)) {
+	if (ret != -EIO && ret != sizeof(feature)) {
 		hid_err(hdev, "unable to request touch data (%d)\n", ret);
 		goto err_stop_hw;
 	}