diff mbox

[v2,2/3] HID: wacom: Initialize MT slots for generic devices at post_parse_hid

Message ID 1417815453-10618-1-git-send-email-killertofu@gmail.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Gerecke, Jason Dec. 5, 2014, 9:37 p.m. UTC
If a HID descriptor places HID_DG_CONTACTID before HID_DG_X and HID_DG_Y then
the ABS_X and ABS_Y will not be automatically initialized by the call to
input_mt_init_slots. To ensure that this is not a problem, we relocate that
call to occur after HID parsing has been completed and we've initalized all
the multitouch axes.

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
Changes from v1:
 * Patch renamed from "HID: wacom: Manually declare ABS_{X,Y} for pointer emulation"
 * Patch moves call to input_mt_init_slots rather than manually declare ABS_{X,Y}

 drivers/hid/wacom_sys.c | 18 ++++++++++++++++++
 drivers/hid/wacom_wac.c |  3 ---
 2 files changed, 18 insertions(+), 3 deletions(-)

Comments

Benjamin Tissoires Dec. 5, 2014, 10 p.m. UTC | #1
On Fri, Dec 5, 2014 at 4:37 PM, Jason Gerecke <killertofu@gmail.com> wrote:
> If a HID descriptor places HID_DG_CONTACTID before HID_DG_X and HID_DG_Y then
> the ABS_X and ABS_Y will not be automatically initialized by the call to
> input_mt_init_slots. To ensure that this is not a problem, we relocate that
> call to occur after HID parsing has been completed and we've initalized all
> the multitouch axes.
>
> Signed-off-by: Jason Gerecke <killertofu@gmail.com>
> ---

This one is
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Thanks for the v2 Jason!

Cheers,
Benjamin

> Changes from v1:
>  * Patch renamed from "HID: wacom: Manually declare ABS_{X,Y} for pointer emulation"
>  * Patch moves call to input_mt_init_slots rather than manually declare ABS_{X,Y}
>
>  drivers/hid/wacom_sys.c | 18 ++++++++++++++++++
>  drivers/hid/wacom_wac.c |  3 ---
>  2 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> index eb55316..872aa0b 100644
> --- a/drivers/hid/wacom_sys.c
> +++ b/drivers/hid/wacom_sys.c
> @@ -13,6 +13,7 @@
>
>  #include "wacom_wac.h"
>  #include "wacom.h"
> +#include <linux/input/mt.h>
>
>  #define WAC_MSG_RETRIES                5
>
> @@ -236,6 +237,21 @@ static void wacom_usage_mapping(struct hid_device *hdev,
>                 wacom_wac_usage_mapping(hdev, field, usage);
>  }
>
> +static void wacom_post_parse_hid(struct hid_device *hdev,
> +                                struct wacom_features *features)
> +{
> +       struct wacom *wacom = hid_get_drvdata(hdev);
> +       struct wacom_wac *wacom_wac = &wacom->wacom_wac;
> +
> +       if (features->type == HID_GENERIC) {
> +               /* Any last-minute generic device setup */
> +               if (features->touch_max > 1) {
> +                       input_mt_init_slots(wacom_wac->input, wacom_wac->features.touch_max,
> +                                   INPUT_MT_DIRECT);
> +               }
> +       }
> +}
> +
>  static void wacom_parse_hid(struct hid_device *hdev,
>                            struct wacom_features *features)
>  {
> @@ -270,6 +286,8 @@ static void wacom_parse_hid(struct hid_device *hdev,
>                                 wacom_usage_mapping(hdev, hreport->field[i],
>                                                 hreport->field[i]->usage + j);
>         }
> +
> +       wacom_post_parse_hid(hdev, features);
>  }
>
>  static int wacom_hid_set_device_mode(struct hid_device *hdev)
> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> index a8a19a5..c33f889 100644
> --- a/drivers/hid/wacom_wac.c
> +++ b/drivers/hid/wacom_wac.c
> @@ -1381,7 +1381,6 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
>  {
>         struct wacom *wacom = hid_get_drvdata(hdev);
>         struct wacom_wac *wacom_wac = &wacom->wacom_wac;
> -       struct input_dev *input = wacom_wac->input;
>         unsigned touch_max = wacom_wac->features.touch_max;
>
>         switch (usage->hid) {
> @@ -1400,8 +1399,6 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
>                                         ABS_MT_POSITION_Y, 4);
>                 break;
>         case HID_DG_CONTACTID:
> -               input_mt_init_slots(input, wacom_wac->features.touch_max,
> -                       INPUT_MT_DIRECT);
>                 break;
>         case HID_DG_INRANGE:
>                 break;
> --
> 2.1.3
>
--
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 Dec. 9, 2014, 8 a.m. UTC | #2
On Fri, 5 Dec 2014, Benjamin Tissoires wrote:

> > If a HID descriptor places HID_DG_CONTACTID before HID_DG_X and HID_DG_Y then
> > the ABS_X and ABS_Y will not be automatically initialized by the call to
> > input_mt_init_slots. To ensure that this is not a problem, we relocate that
> > call to occur after HID parsing has been completed and we've initalized all
> > the multitouch axes.
> >
> > Signed-off-by: Jason Gerecke <killertofu@gmail.com>
> > ---
> 
> This one is
> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Benjamin, does your Reviewed-by: apply to both 2/3 and 3/3?

Thanks,
Benjamin Tissoires Dec. 9, 2014, 2:29 p.m. UTC | #3
On Tue, Dec 9, 2014 at 3:00 AM, Jiri Kosina <jkosina@suse.cz> wrote:
> On Fri, 5 Dec 2014, Benjamin Tissoires wrote:
>
>> > If a HID descriptor places HID_DG_CONTACTID before HID_DG_X and HID_DG_Y then
>> > the ABS_X and ABS_Y will not be automatically initialized by the call to
>> > input_mt_init_slots. To ensure that this is not a problem, we relocate that
>> > call to occur after HID parsing has been completed and we've initalized all
>> > the multitouch axes.
>> >
>> > Signed-off-by: Jason Gerecke <killertofu@gmail.com>
>> > ---
>>
>> This one is
>> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>
> Benjamin, does your Reviewed-by: apply to both 2/3 and 3/3?
>

Hi Jiri,

Well, I wanted to make some cosmetic changes in 3/3 and double check
that it was generic enough, but I've been sidetracked, and today I
have to keep my sick daughter.
Please apply my rev-by on this one only. Feel free to apply 3/3
however - if you can dedicate a little bit of time to check it -
(without my rev-by then), it's not that it will prevent us to change
it later if we have to.

Cheers,
Benjamin

> Thanks,
>
> --
> Jiri Kosina
> SUSE Labs
--
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 Dec. 10, 2014, 9:49 a.m. UTC | #4
On Tue, 9 Dec 2014, Benjamin Tissoires wrote:

> Well, I wanted to make some cosmetic changes in 3/3 and double check 
> that it was generic enough, but I've been sidetracked, and today I have 
> to keep my sick daughter. Please apply my rev-by on this one only. Feel 
> free to apply 3/3 however - if you can dedicate a little bit of time to 
> check it - (without my rev-by then), it's not that it will prevent us to 
> change it later if we have to.

Alright, thanks. I am now applying 2/3. If I have time to review 3/3 today 
or tomorrow (not guaranteed), I might be applying it for this merge window 
as well.

Otherwise it'll be processed in the next cycle.

Thanks,
diff mbox

Patch

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index eb55316..872aa0b 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -13,6 +13,7 @@ 
 
 #include "wacom_wac.h"
 #include "wacom.h"
+#include <linux/input/mt.h>
 
 #define WAC_MSG_RETRIES		5
 
@@ -236,6 +237,21 @@  static void wacom_usage_mapping(struct hid_device *hdev,
 		wacom_wac_usage_mapping(hdev, field, usage);
 }
 
+static void wacom_post_parse_hid(struct hid_device *hdev,
+				 struct wacom_features *features)
+{
+	struct wacom *wacom = hid_get_drvdata(hdev);
+	struct wacom_wac *wacom_wac = &wacom->wacom_wac;
+
+	if (features->type == HID_GENERIC) {
+		/* Any last-minute generic device setup */
+		if (features->touch_max > 1) {
+			input_mt_init_slots(wacom_wac->input, wacom_wac->features.touch_max,
+				    INPUT_MT_DIRECT);
+		}
+	}
+}
+
 static void wacom_parse_hid(struct hid_device *hdev,
 			   struct wacom_features *features)
 {
@@ -270,6 +286,8 @@  static void wacom_parse_hid(struct hid_device *hdev,
 				wacom_usage_mapping(hdev, hreport->field[i],
 						hreport->field[i]->usage + j);
 	}
+
+	wacom_post_parse_hid(hdev, features);
 }
 
 static int wacom_hid_set_device_mode(struct hid_device *hdev)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index a8a19a5..c33f889 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1381,7 +1381,6 @@  static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
 {
 	struct wacom *wacom = hid_get_drvdata(hdev);
 	struct wacom_wac *wacom_wac = &wacom->wacom_wac;
-	struct input_dev *input = wacom_wac->input;
 	unsigned touch_max = wacom_wac->features.touch_max;
 
 	switch (usage->hid) {
@@ -1400,8 +1399,6 @@  static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
 					ABS_MT_POSITION_Y, 4);
 		break;
 	case HID_DG_CONTACTID:
-		input_mt_init_slots(input, wacom_wac->features.touch_max,
-			INPUT_MT_DIRECT);
 		break;
 	case HID_DG_INRANGE:
 		break;