diff mbox

[2/2] input: synaptics - fix width calculation on image sensors

Message ID 1419679889-6582-3-git-send-email-gabriele.mzt@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gabriele Mazzotta Dec. 27, 2014, 11:31 a.m. UTC
When two or more fingers are on the touchpad, the 'w' slot holds the
finger count rather than the width. Retrieve the correct value encoded
in the lower bits of 'x', 'y' and 'z'.

The minimum width reported is 8 rather than 4 in this case, while the
maximum remains 15.

Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
---
 drivers/input/mouse/synaptics.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Benjamin Tissoires Jan. 5, 2015, 6:25 p.m. UTC | #1
Hi Gabriele,

On Sat, Dec 27, 2014 at 6:31 AM, Gabriele Mazzotta
<gabriele.mzt@gmail.com> wrote:
> When two or more fingers are on the touchpad, the 'w' slot holds the
> finger count rather than the width. Retrieve the correct value encoded
> in the lower bits of 'x', 'y' and 'z'.
>
> The minimum width reported is 8 rather than 4 in this case, while the
> maximum remains 15.
>
> Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
> ---
>  drivers/input/mouse/synaptics.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
> index ea0563e..5ff4c5b 100644
> --- a/drivers/input/mouse/synaptics.c
> +++ b/drivers/input/mouse/synaptics.c
> @@ -593,7 +593,9 @@ static void synaptics_parse_agm(const unsigned char buf[],
>         switch (agm_packet_type) {
>         case 1:
>                 /* Gesture packet: (x, y, z) half resolution */
> -               agm->w = hw->w;
> +               agm->w = ((buf[1] & 0x01) |
> +                         ((buf[2] & 0x01) << 1) |
> +                         ((buf[5] & 0x01) << 2)) + 8;
>                 agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;

For completeness, I think, we should also removes the w bits from x, y
and z (by masking buf[1], buf[2] and buf[5] with 0xfe).

Cheers,
Benjamin

>                 agm->y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1;
>                 agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1;
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
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
Gabriele Mazzotta Jan. 5, 2015, 6:37 p.m. UTC | #2
On Monday 05 January 2015 13:25:38 Benjamin Tissoires wrote:
> Hi Gabriele,
> 
> On Sat, Dec 27, 2014 at 6:31 AM, Gabriele Mazzotta
> <gabriele.mzt@gmail.com> wrote:
> > When two or more fingers are on the touchpad, the 'w' slot holds the
> > finger count rather than the width. Retrieve the correct value encoded
> > in the lower bits of 'x', 'y' and 'z'.
> >
> > The minimum width reported is 8 rather than 4 in this case, while the
> > maximum remains 15.
> >
> > Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
> > ---
> >  drivers/input/mouse/synaptics.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
> > index ea0563e..5ff4c5b 100644
> > --- a/drivers/input/mouse/synaptics.c
> > +++ b/drivers/input/mouse/synaptics.c
> > @@ -593,7 +593,9 @@ static void synaptics_parse_agm(const unsigned char buf[],
> >         switch (agm_packet_type) {
> >         case 1:
> >                 /* Gesture packet: (x, y, z) half resolution */
> > -               agm->w = hw->w;
> > +               agm->w = ((buf[1] & 0x01) |
> > +                         ((buf[2] & 0x01) << 1) |
> > +                         ((buf[5] & 0x01) << 2)) + 8;
> >                 agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
> 
> For completeness, I think, we should also removes the w bits from x, y
> and z (by masking buf[1], buf[2] and buf[5] with 0xfe).

You are right, I forgot about it.

I was going to re-submit these patches anyway since there have been
quite a few changes and these can no longer be applied on next.

> Cheers,
> Benjamin
> 
> >                 agm->y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1;
> >                 agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1;
> > --
> > 2.1.4
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/

--
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
Benjamin Tissoires Jan. 5, 2015, 6:42 p.m. UTC | #3
On Mon, Jan 5, 2015 at 1:37 PM, Gabriele Mazzotta
<gabriele.mzt@gmail.com> wrote:
> On Monday 05 January 2015 13:25:38 Benjamin Tissoires wrote:
>> Hi Gabriele,
>>
>> On Sat, Dec 27, 2014 at 6:31 AM, Gabriele Mazzotta
>> <gabriele.mzt@gmail.com> wrote:
>> > When two or more fingers are on the touchpad, the 'w' slot holds the
>> > finger count rather than the width. Retrieve the correct value encoded
>> > in the lower bits of 'x', 'y' and 'z'.
>> >
>> > The minimum width reported is 8 rather than 4 in this case, while the
>> > maximum remains 15.
>> >
>> > Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
>> > ---
>> >  drivers/input/mouse/synaptics.c | 4 +++-
>> >  1 file changed, 3 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
>> > index ea0563e..5ff4c5b 100644
>> > --- a/drivers/input/mouse/synaptics.c
>> > +++ b/drivers/input/mouse/synaptics.c
>> > @@ -593,7 +593,9 @@ static void synaptics_parse_agm(const unsigned char buf[],
>> >         switch (agm_packet_type) {
>> >         case 1:
>> >                 /* Gesture packet: (x, y, z) half resolution */
>> > -               agm->w = hw->w;
>> > +               agm->w = ((buf[1] & 0x01) |
>> > +                         ((buf[2] & 0x01) << 1) |
>> > +                         ((buf[5] & 0x01) << 2)) + 8;
>> >                 agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
>>
>> For completeness, I think, we should also removes the w bits from x, y
>> and z (by masking buf[1], buf[2] and buf[5] with 0xfe).
>
> You are right, I forgot about it.
>
> I was going to re-submit these patches anyway since there have been
> quite a few changes and these can no longer be applied on next.

OK, I am trying to put together my thoughts for 1/2 right now. If you
could just wait a little before resubmitting, I would be grateful.

Thanks,
Benjamin

>
>> Cheers,
>> Benjamin
>>
>> >                 agm->y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1;
>> >                 agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1;
>> > --
>> > 2.1.4
>> >
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> > the body of a message to majordomo@vger.kernel.org
>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> > Please read the FAQ at  http://www.tux.org/lkml/
>
--
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
Dmitry Torokhov Jan. 5, 2015, 7:04 p.m. UTC | #4
On January 5, 2015 10:42:13 AM PST, Benjamin Tissoires <benjamin.tissoires@gmail.com> wrote:
>On Mon, Jan 5, 2015 at 1:37 PM, Gabriele Mazzotta
><gabriele.mzt@gmail.com> wrote:
>> On Monday 05 January 2015 13:25:38 Benjamin Tissoires wrote:
>>> Hi Gabriele,
>>>
>>> On Sat, Dec 27, 2014 at 6:31 AM, Gabriele Mazzotta
>>> <gabriele.mzt@gmail.com> wrote:
>>> > When two or more fingers are on the touchpad, the 'w' slot holds
>the
>>> > finger count rather than the width. Retrieve the correct value
>encoded
>>> > in the lower bits of 'x', 'y' and 'z'.
>>> >
>>> > The minimum width reported is 8 rather than 4 in this case, while
>the
>>> > maximum remains 15.
>>> >
>>> > Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
>>> > ---
>>> >  drivers/input/mouse/synaptics.c | 4 +++-
>>> >  1 file changed, 3 insertions(+), 1 deletion(-)
>>> >
>>> > diff --git a/drivers/input/mouse/synaptics.c
>b/drivers/input/mouse/synaptics.c
>>> > index ea0563e..5ff4c5b 100644
>>> > --- a/drivers/input/mouse/synaptics.c
>>> > +++ b/drivers/input/mouse/synaptics.c
>>> > @@ -593,7 +593,9 @@ static void synaptics_parse_agm(const unsigned
>char buf[],
>>> >         switch (agm_packet_type) {
>>> >         case 1:
>>> >                 /* Gesture packet: (x, y, z) half resolution */
>>> > -               agm->w = hw->w;
>>> > +               agm->w = ((buf[1] & 0x01) |
>>> > +                         ((buf[2] & 0x01) << 1) |
>>> > +                         ((buf[5] & 0x01) << 2)) + 8;
>>> >                 agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
>>>
>>> For completeness, I think, we should also removes the w bits from x,
>y
>>> and z (by masking buf[1], buf[2] and buf[5] with 0xfe).
>>
>> You are right, I forgot about it.
>>
>> I was going to re-submit these patches anyway since there have been
>> quite a few changes and these can no longer be applied on next.
>
>OK, I am trying to put together my thoughts for 1/2 right now. If you
>could just wait a little before resubmitting, I would be grateful.
>

BTW, do we really get different widths four different contacts?

Thanks.
Benjamin Tissoires Jan. 5, 2015, 7:07 p.m. UTC | #5
On Mon, Jan 5, 2015 at 2:04 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On January 5, 2015 10:42:13 AM PST, Benjamin Tissoires <benjamin.tissoires@gmail.com> wrote:
>>On Mon, Jan 5, 2015 at 1:37 PM, Gabriele Mazzotta
>><gabriele.mzt@gmail.com> wrote:
>>> On Monday 05 January 2015 13:25:38 Benjamin Tissoires wrote:
>>>> Hi Gabriele,
>>>>
>>>> On Sat, Dec 27, 2014 at 6:31 AM, Gabriele Mazzotta
>>>> <gabriele.mzt@gmail.com> wrote:
>>>> > When two or more fingers are on the touchpad, the 'w' slot holds
>>the
>>>> > finger count rather than the width. Retrieve the correct value
>>encoded
>>>> > in the lower bits of 'x', 'y' and 'z'.
>>>> >
>>>> > The minimum width reported is 8 rather than 4 in this case, while
>>the
>>>> > maximum remains 15.
>>>> >
>>>> > Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
>>>> > ---
>>>> >  drivers/input/mouse/synaptics.c | 4 +++-
>>>> >  1 file changed, 3 insertions(+), 1 deletion(-)
>>>> >
>>>> > diff --git a/drivers/input/mouse/synaptics.c
>>b/drivers/input/mouse/synaptics.c
>>>> > index ea0563e..5ff4c5b 100644
>>>> > --- a/drivers/input/mouse/synaptics.c
>>>> > +++ b/drivers/input/mouse/synaptics.c
>>>> > @@ -593,7 +593,9 @@ static void synaptics_parse_agm(const unsigned
>>char buf[],
>>>> >         switch (agm_packet_type) {
>>>> >         case 1:
>>>> >                 /* Gesture packet: (x, y, z) half resolution */
>>>> > -               agm->w = hw->w;
>>>> > +               agm->w = ((buf[1] & 0x01) |
>>>> > +                         ((buf[2] & 0x01) << 1) |
>>>> > +                         ((buf[5] & 0x01) << 2)) + 8;
>>>> >                 agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
>>>>
>>>> For completeness, I think, we should also removes the w bits from x,
>>y
>>>> and z (by masking buf[1], buf[2] and buf[5] with 0xfe).
>>>
>>> You are right, I forgot about it.
>>>
>>> I was going to re-submit these patches anyway since there have been
>>> quite a few changes and these can no longer be applied on next.
>>
>>OK, I am trying to put together my thoughts for 1/2 right now. If you
>>could just wait a little before resubmitting, I would be grateful.
>>
>
> BTW, do we really get different widths four different contacts?
>

I think we should. However, on capacitive sensors, the "width" and the
"pressure" fields are 2 ways of sending the same initial information.
Given that we already have two different pressure info, we should thus
get 2 different widths.

Cheers,
Benjamin
--
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
Gabriele Mazzotta Jan. 5, 2015, 7:15 p.m. UTC | #6
On Monday 05 January 2015 11:04:07 Dmitry Torokhov wrote:
> On January 5, 2015 10:42:13 AM PST, Benjamin Tissoires <benjamin.tissoires@gmail.com> wrote:
> >On Mon, Jan 5, 2015 at 1:37 PM, Gabriele Mazzotta
> ><gabriele.mzt@gmail.com> wrote:
> >> On Monday 05 January 2015 13:25:38 Benjamin Tissoires wrote:
> >>> Hi Gabriele,
> >>>
> >>> On Sat, Dec 27, 2014 at 6:31 AM, Gabriele Mazzotta
> >>> <gabriele.mzt@gmail.com> wrote:
> >>> > When two or more fingers are on the touchpad, the 'w' slot holds
> >the
> >>> > finger count rather than the width. Retrieve the correct value
> >encoded
> >>> > in the lower bits of 'x', 'y' and 'z'.
> >>> >
> >>> > The minimum width reported is 8 rather than 4 in this case, while
> >the
> >>> > maximum remains 15.
> >>> >
> >>> > Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
> >>> > ---
> >>> >  drivers/input/mouse/synaptics.c | 4 +++-
> >>> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >>> >
> >>> > diff --git a/drivers/input/mouse/synaptics.c
> >b/drivers/input/mouse/synaptics.c
> >>> > index ea0563e..5ff4c5b 100644
> >>> > --- a/drivers/input/mouse/synaptics.c
> >>> > +++ b/drivers/input/mouse/synaptics.c
> >>> > @@ -593,7 +593,9 @@ static void synaptics_parse_agm(const unsigned
> >char buf[],
> >>> >         switch (agm_packet_type) {
> >>> >         case 1:
> >>> >                 /* Gesture packet: (x, y, z) half resolution */
> >>> > -               agm->w = hw->w;
> >>> > +               agm->w = ((buf[1] & 0x01) |
> >>> > +                         ((buf[2] & 0x01) << 1) |
> >>> > +                         ((buf[5] & 0x01) << 2)) + 8;
> >>> >                 agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
> >>>
> >>> For completeness, I think, we should also removes the w bits from x,
> >y
> >>> and z (by masking buf[1], buf[2] and buf[5] with 0xfe).
> >>
> >> You are right, I forgot about it.
> >>
> >> I was going to re-submit these patches anyway since there have been
> >> quite a few changes and these can no longer be applied on next.
> >
> >OK, I am trying to put together my thoughts for 1/2 right now. If you
> >could just wait a little before resubmitting, I would be grateful.
> >
> 
> BTW, do we really get different widths four different contacts?
> 
> Thanks.

I think that only the width of the last finger that was laid on the
touchpad is reported.
--
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
Benjamin Tissoires Jan. 5, 2015, 7:26 p.m. UTC | #7
On Mon, Jan 5, 2015 at 2:15 PM, Gabriele Mazzotta
<gabriele.mzt@gmail.com> wrote:
> On Monday 05 January 2015 11:04:07 Dmitry Torokhov wrote:
>> On January 5, 2015 10:42:13 AM PST, Benjamin Tissoires <benjamin.tissoires@gmail.com> wrote:
>> >On Mon, Jan 5, 2015 at 1:37 PM, Gabriele Mazzotta
>> ><gabriele.mzt@gmail.com> wrote:
>> >> On Monday 05 January 2015 13:25:38 Benjamin Tissoires wrote:
>> >>> Hi Gabriele,
>> >>>
>> >>> On Sat, Dec 27, 2014 at 6:31 AM, Gabriele Mazzotta
>> >>> <gabriele.mzt@gmail.com> wrote:
>> >>> > When two or more fingers are on the touchpad, the 'w' slot holds
>> >the
>> >>> > finger count rather than the width. Retrieve the correct value
>> >encoded
>> >>> > in the lower bits of 'x', 'y' and 'z'.
>> >>> >
>> >>> > The minimum width reported is 8 rather than 4 in this case, while
>> >the
>> >>> > maximum remains 15.
>> >>> >
>> >>> > Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
>> >>> > ---
>> >>> >  drivers/input/mouse/synaptics.c | 4 +++-
>> >>> >  1 file changed, 3 insertions(+), 1 deletion(-)
>> >>> >
>> >>> > diff --git a/drivers/input/mouse/synaptics.c
>> >b/drivers/input/mouse/synaptics.c
>> >>> > index ea0563e..5ff4c5b 100644
>> >>> > --- a/drivers/input/mouse/synaptics.c
>> >>> > +++ b/drivers/input/mouse/synaptics.c
>> >>> > @@ -593,7 +593,9 @@ static void synaptics_parse_agm(const unsigned
>> >char buf[],
>> >>> >         switch (agm_packet_type) {
>> >>> >         case 1:
>> >>> >                 /* Gesture packet: (x, y, z) half resolution */
>> >>> > -               agm->w = hw->w;
>> >>> > +               agm->w = ((buf[1] & 0x01) |
>> >>> > +                         ((buf[2] & 0x01) << 1) |
>> >>> > +                         ((buf[5] & 0x01) << 2)) + 8;
>> >>> >                 agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
>> >>>
>> >>> For completeness, I think, we should also removes the w bits from x,
>> >y
>> >>> and z (by masking buf[1], buf[2] and buf[5] with 0xfe).
>> >>
>> >> You are right, I forgot about it.
>> >>
>> >> I was going to re-submit these patches anyway since there have been
>> >> quite a few changes and these can no longer be applied on next.
>> >
>> >OK, I am trying to put together my thoughts for 1/2 right now. If you
>> >could just wait a little before resubmitting, I would be grateful.
>> >
>>
>> BTW, do we really get different widths four different contacts?
>>
>> Thanks.
>
> I think that only the width of the last finger that was laid on the
> touchpad is reported.

According to the Synaptics PS2 Interfacing guide, the width of the
primary finger is also reported. See
http://www.synaptics.com/sites/default/files/511-000275-01_RevB.pdf
section 3.2.10. page 32)

Cheers,
Benjamin
--
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
diff mbox

Patch

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index ea0563e..5ff4c5b 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -593,7 +593,9 @@  static void synaptics_parse_agm(const unsigned char buf[],
 	switch (agm_packet_type) {
 	case 1:
 		/* Gesture packet: (x, y, z) half resolution */
-		agm->w = hw->w;
+		agm->w = ((buf[1] & 0x01) |
+			  ((buf[2] & 0x01) << 1) |
+			  ((buf[5] & 0x01) << 2)) + 8;
 		agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
 		agm->y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1;
 		agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1;