Skip to contentSkip to conversation

input - wacom: Support 2FGT in MT format

PATCH New Ping Cheng 1 participant 1 message Feb 22, 2011 HID

lore
Share & tools
lore

Ping Cheng

author
#0 lore raw

PATCH v2 4/4 input - wacom: Support 2FGT in MT format

Quoted 129 lines · Henrik Rydberg

Hi Ping,

Quoted 8 lines · Ping Cheng

---
v2: Removed the touch status check if-statement as suggested by Henrik for code flow clarity.

---
 drivers/input/tablet/wacom_sys.c |   12 ++++----
 drivers/input/tablet/wacom_wac.c |   60

++++++++++++++++++++++++++++++-------

Review

Quoted 3 lines
 2 files changed, 54 insertions(+), 18 deletions(-)
(quoted diff) +0 -0

b/drivers/input/tablet/wacom_sys.c

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface

Quoted 4 lines

index fc38149..b97665f 100644

drivers/input/tablet/wacom_sys.c +0 -0
@@ -193,16 +193,16 @@ static int wacom_parse_hid(struct usb_interface

*intf, struct hid_descriptor *hi

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 196

Quoted 4 lines
drivers/input/tablet/wacom_sys.c +0 -1
                      case HID_USAGE_X:
                              if (usage == WCM_DESKTOP) {
                                      if (finger) {
-                                             features->device_type =

BTN_TOOL_DOUBLETAP;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 196

Quoted 1 line
drivers/input/tablet/wacom_sys.c +1 -0
+                                             features->device_type =

BTN_TOOL_FINGER;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 197

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -0
                                              if (features->type ==

TABLETPC2FG) {

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 198

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -0
                                                      /* need to reset

back */

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 199

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -0
                                                      features->pktlen =

WACOM_PKGLEN_TPC2FG;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 200

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -1
-

features->device_type = BTN_TOOL_TRIPLETAP;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 200

Quoted 1 line
drivers/input/tablet/wacom_sys.c +1 -0
+

features->device_type = BTN_TOOL_DOUBLETAP;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 202

Quoted 2 lines
drivers/input/tablet/wacom_sys.c +0 -0
                                              }
                                              if (features->type ==

BAMBOO_PT) {

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 203

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -0
                                                      /* need to reset

back */

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 204

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -0
                                                      features->pktlen =

WACOM_PKGLEN_BBTOUCH;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 205

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -1
-

features->device_type = BTN_TOOL_TRIPLETAP;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 205

Quoted 1 line
drivers/input/tablet/wacom_sys.c +1 -0
+

features->device_type = BTN_TOOL_DOUBLETAP;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 207

Quoted 2 lines
drivers/input/tablet/wacom_sys.c +0 -0
                                                      features->x_phy =
 

get_unaligned_le16(&report[i + 5]);

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface

Quoted 2 lines
drivers/input/tablet/wacom_sys.c +0 -0
                                                      features->x_max =
@@ -241,11 +241,11 @@ static int wacom_parse_hid(struct usb_interface

*intf, struct hid_descriptor *hi

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 244

Quoted 4 lines
drivers/input/tablet/wacom_sys.c +0 -1
                      case HID_USAGE_Y:
                              if (usage == WCM_DESKTOP) {
                                      if (finger) {
-                                             features->device_type =

BTN_TOOL_DOUBLETAP;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 244

Quoted 1 line
drivers/input/tablet/wacom_sys.c +1 -0
+                                             features->device_type =

BTN_TOOL_FINGER;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 245

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -0
                                              if (features->type ==

TABLETPC2FG) {

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 246

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -0
                                                      /* need to reset

back */

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 247

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -0
                                                      features->pktlen =

WACOM_PKGLEN_TPC2FG;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 248

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -1
-

features->device_type = BTN_TOOL_TRIPLETAP;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 248

Quoted 1 line
drivers/input/tablet/wacom_sys.c +1 -0
+

features->device_type = BTN_TOOL_DOUBLETAP;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 250

Quoted 2 lines
drivers/input/tablet/wacom_sys.c +0 -0
                                                      features->y_max =
 

get_unaligned_le16(&report[i + 3]);

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface

Quoted 2 lines
drivers/input/tablet/wacom_sys.c +0 -0
                                                      features->y_phy =
@@ -254,7 +254,7 @@ static int wacom_parse_hid(struct usb_interface

*intf, struct hid_descriptor *hi

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 254

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -0
                                              } else if (features->type

== BAMBOO_PT) {

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 255

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -0
                                                      /* need to reset

back */

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 256

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -0
                                                      features->pktlen =

WACOM_PKGLEN_BBTOUCH;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 257

Quoted 1 line
drivers/input/tablet/wacom_sys.c +0 -1
-

features->device_type = BTN_TOOL_TRIPLETAP;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 257

Quoted 1 line
drivers/input/tablet/wacom_sys.c +1 -0
+

features->device_type = BTN_TOOL_DOUBLETAP;

drivers/input/tablet/wacom_sys.c static int wacom_parse_hid(struct usb_interface · line 259

Quoted 2 lines
drivers/input/tablet/wacom_sys.c +0 -0
                                                      features->y_phy =
 

get_unaligned_le16(&report[i + 3]);

Review

Quoted 2 lines
drivers/input/tablet/wacom_sys.c +0 -0
                                                      features->y_max =
(quoted diff) +0 -0

b/drivers/input/tablet/wacom_wac.c

Quoted 11 lines

index fc0669d..8a21fcb 100644

drivers/input/tablet/wacom_wac.c +4 -0
@@ -675,6 +675,38 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
      return 1;
 }
 
+static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
+{
+     struct input_dev *input = wacom->input;
+     unsigned char *data = wacom->data;

drivers/input/tablet/wacom_wac.c static int wacom_intuos_irq(struct wacom_wac *wacom) · line 691

Quoted 10 lines
drivers/input/tablet/wacom_wac.c +10 -0
+     int i;
+
+     for (i = 0; i < 2; i++) {
+             int p = data[1] & (1 << i);
+             bool touch = p && !wacom->shared->stylus_in_proximity;
+
+             input_mt_slot(input, i);
+             input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
+             if (touch) {
+                     int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) &

0x7fff;

drivers/input/tablet/wacom_wac.c static int wacom_intuos_irq(struct wacom_wac *wacom) · line 692

Quoted 1 line
drivers/input/tablet/wacom_wac.c +1 -0
+                     int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) &

0x7fff;

drivers/input/tablet/wacom_wac.c static int wacom_intuos_irq(struct wacom_wac *wacom) · line 702

Quoted 10 lines
drivers/input/tablet/wacom_wac.c +10 -0
+
+                     input_report_abs(input, ABS_MT_POSITION_X, x);
+                     input_report_abs(input, ABS_MT_POSITION_Y, y);
+             }
+
+             /* keep touch bit to send proper touch up event */
+             if (i == 0)
+                     wacom->shared->touch_down = touch;
+             else
+                     wacom->shared->touch_down = max(touch,

wacom->shared->touch_down);

Quoted 4 lines

drivers/input/tablet/wacom_wac.c static int wacom_intuos_irq(struct wacom_wac *wacom) · line 703

Quoted 1 line
drivers/input/tablet/wacom_wac.c +1 -0
+     }

How about wacom->shared->touch_down = contact_count > 0 instead?

I can change to that. It doesn't change the logic though.

Ping

Quoted 97 lines

drivers/input/tablet/wacom_wac.c static int wacom_tpc_irq(struct wacom_wac *wacom,

Quoted 11 lines
drivers/input/tablet/wacom_wac.c +6 -0
+
+     input_mt_report_pointer_emulation(input, true);
+
+     return 1;
+}
+
 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
 {
      char *data = wacom->data;
@@ -753,6 +785,8 @@ static int wacom_tpc_irq(struct wacom_wac *wacom,

size_t len)

drivers/input/tablet/wacom_wac.c void wacom_setup_device_quirks(struct wacom_features

Quoted 9 lines
drivers/input/tablet/wacom_wac.c +2 -0
      if (len == WACOM_PKGLEN_TPC1FG || data[0] == WACOM_REPORT_TPC1FG)
              return wacom_tpc_single_touch(wacom, len);
+     else if (data[0] == WACOM_REPORT_TPC2FG)
+             return wacom_tpc_mt_touch(wacom);
      else if (data[0] == WACOM_REPORT_PENABLED)
              return wacom_tpc_pen(wacom);
 
@@ -979,7 +1013,7 @@ void wacom_setup_device_quirks(struct wacom_features

*features)

drivers/input/tablet/wacom_wac.c void wacom_setup_device_quirks(struct wacom_features · line 982

Quoted 4 lines
drivers/input/tablet/wacom_wac.c +0 -1
 {
 
      /* touch device found but size is not defined. use default */
-     if (features->device_type == BTN_TOOL_DOUBLETAP &&

!features->x_max) {

drivers/input/tablet/wacom_wac.c void wacom_setup_device_quirks(struct wacom_features

Quoted 5 lines
drivers/input/tablet/wacom_wac.c +1 -0
+     if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
              features->x_max = 1023;
              features->y_max = 1023;
      }
@@ -991,7 +1025,7 @@ void wacom_setup_device_quirks(struct wacom_features

*features)

drivers/input/tablet/wacom_wac.c void wacom_setup_input_capabilities(struct

Quoted 9 lines
drivers/input/tablet/wacom_wac.c +1 -1
      /* quirks for bamboo touch */
      if (features->type == BAMBOO_PT &&
-         features->device_type == BTN_TOOL_TRIPLETAP) {
+         features->device_type == BTN_TOOL_DOUBLETAP) {
              features->x_max <<= 5;
              features->y_max <<= 5;
              features->x_fuzz <<= 5;
@@ -1127,28 +1161,30 @@ void wacom_setup_input_capabilities(struct

input_dev *input_dev,

drivers/input/tablet/wacom_wac.c void wacom_setup_input_capabilities(struct · line 1132

Quoted 6 lines
drivers/input/tablet/wacom_wac.c +0 -3
              break;
 
      case TABLETPC2FG:
-             if (features->device_type == BTN_TOOL_TRIPLETAP) {
-                     __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
-                     input_set_capability(input_dev, EV_MSC,

MSC_SERIAL);

drivers/input/tablet/wacom_wac.c void wacom_setup_input_capabilities(struct

Quoted 34 lines
drivers/input/tablet/wacom_wac.c +11 -6
+             if (features->device_type == BTN_TOOL_DOUBLETAP) {
+
+                     input_mt_init_slots(input_dev, 2);
+                     input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE,
+                                     0, MT_TOOL_MAX, 0, 0);
+                     input_set_abs_params(input_dev, ABS_MT_POSITION_X,
+                                     0, features->x_max, 0, 0);
+                     input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
+                                     0, features->y_max, 0, 0);
              }
              /* fall through */
 
      case TABLETPC:
              __clear_bit(ABS_MISC, input_dev->absbit);
 
-             if (features->device_type == BTN_TOOL_DOUBLETAP ||
-                 features->device_type == BTN_TOOL_TRIPLETAP) {
+             if (features->device_type != BTN_TOOL_PEN) {
                      input_abs_set_res(input_dev, ABS_X,
                              wacom_calculate_touch_res(features->x_max,
                                                      features->x_phy));
                      input_abs_set_res(input_dev, ABS_Y,
                              wacom_calculate_touch_res(features->y_max,
                                                      features->y_phy));
-             }
-
-             if (features->device_type != BTN_TOOL_PEN)
                      break;  /* no need to process stylus stuff */
-
+             }
              /* fall through */
 
      case PL:
@@ -1166,7 +1202,7 @@ void wacom_setup_input_capabilities(struct

input_dev *input_dev,

drivers/input/tablet/wacom_wac.c void wacom_setup_input_capabilities(struct · line 1208

Quoted 8 lines
drivers/input/tablet/wacom_wac.c +1 -1
      case BAMBOO_PT:
              __clear_bit(ABS_MISC, input_dev->absbit);
 
-             if (features->device_type == BTN_TOOL_TRIPLETAP) {
+             if (features->device_type == BTN_TOOL_DOUBLETAP) {
                      __set_bit(BTN_LEFT, input_dev->keybit);
                      __set_bit(BTN_FORWARD, input_dev->keybit);
                      __set_bit(BTN_BACK, input_dev->keybit);

Thanks,
Henrik