Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 28.32 KB | None | 0 0
  1. diff -Naur linux-2.6.36/drivers/input/tablet//wacom.h linux-2.6.36-rc/drivers/input/tablet//wacom.h
  2. --- linux-2.6.36/drivers/input/tablet//wacom.h  2010-08-02 00:11:14.000000000 +0200
  3. +++ linux-2.6.36-rc/drivers/input/tablet//wacom.h   2010-10-11 00:12:48.000000000 +0200
  4. @@ -11,7 +11,7 @@
  5.   *  Copyright (c) 2000 Daniel Egger        <egger@suse.de>
  6.   *  Copyright (c) 2001 Frederic Lepied     <flepied@mandrakesoft.com>
  7.   *  Copyright (c) 2004 Panagiotis Issaris  <panagiotis.issaris@mech.kuleuven.ac.be>
  8. - *  Copyright (c) 2002-2009 Ping Cheng     <pingc@wacom.com>
  9. + *  Copyright (c) 2002-2010 Ping Cheng     <pingc@wacom.com>
  10.   *
  11.   *  ChangeLog:
  12.   *      v0.1 (vp)  - Initial release
  13. @@ -93,7 +93,7 @@
  14.  /*
  15.   * Version Information
  16.   */
  17. -#define DRIVER_VERSION "v1.52"
  18. +#define DRIVER_VERSION "v1.52-pc-0.3"
  19.  #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
  20.  #define DRIVER_DESC "USB Wacom tablet driver"
  21.  #define DRIVER_LICENSE "GPL"
  22. @@ -104,6 +104,11 @@
  23.  
  24.  #define USB_VENDOR_ID_WACOM    0x056a
  25.  
  26. +/* defines to get/set USB message */
  27. +#define USB_REQ_GET_REPORT 0x01
  28. +#define USB_REQ_SET_REPORT 0x09
  29. +#define WAC_HID_FEATURE_REPORT 0x03
  30. +
  31.  struct wacom {
  32.     dma_addr_t data_dma;
  33.     struct usb_device *usbdev;
  34. @@ -117,6 +122,12 @@
  35.  
  36.  extern const struct usb_device_id wacom_ids[];
  37.  
  38. +int usb_get_report(struct usb_interface *intf, unsigned char type,
  39. +   unsigned char id, void *buf, int size);
  40. +int usb_set_report(struct usb_interface *intf, unsigned char type,
  41. +   unsigned char id, void *buf, int size);
  42. +int wacom_ioctl(struct usb_interface *intf, unsigned int code, void *buf);
  43. +
  44.  void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
  45.  void wacom_setup_input_capabilities(struct input_dev *input_dev,
  46.                     struct wacom_wac *wacom_wac);
  47. diff -Naur linux-2.6.36/drivers/input/tablet//wacom_sys.c linux-2.6.36-rc/drivers/input/tablet//wacom_sys.c
  48. --- linux-2.6.36/drivers/input/tablet//wacom_sys.c  2010-08-02 00:11:14.000000000 +0200
  49. +++ linux-2.6.36-rc/drivers/input/tablet//wacom_sys.c   2010-10-11 00:12:32.000000000 +0200
  50. @@ -45,12 +45,7 @@
  51.     __le16   wDescriptorLength;
  52.  } __attribute__ ((packed));
  53.  
  54. -/* defines to get/set USB message */
  55. -#define USB_REQ_GET_REPORT 0x01
  56. -#define USB_REQ_SET_REPORT 0x09
  57. -#define WAC_HID_FEATURE_REPORT 0x03
  58. -
  59. -static int usb_get_report(struct usb_interface *intf, unsigned char type,
  60. +int usb_get_report(struct usb_interface *intf, unsigned char type,
  61.                 unsigned char id, void *buf, int size)
  62.  {
  63.     return usb_control_msg(interface_to_usbdev(intf),
  64. @@ -60,7 +55,7 @@
  65.         buf, size, 100);
  66.  }
  67.  
  68. -static int usb_set_report(struct usb_interface *intf, unsigned char type,
  69. +int usb_set_report(struct usb_interface *intf, unsigned char type,
  70.                 unsigned char id, void *buf, int size)
  71.  {
  72.     return usb_control_msg(interface_to_usbdev(intf),
  73. @@ -195,17 +190,30 @@
  74.                             features->pktlen = WACOM_PKGLEN_TPC2FG;
  75.                             features->device_type = BTN_TOOL_TRIPLETAP;
  76.                         }
  77. -                       features->x_max =
  78. -                           get_unaligned_le16(&report[i + 3]);
  79. -                       features->x_phy =
  80. -                           get_unaligned_le16(&report[i + 6]);
  81. -                       features->unit = report[i + 9];
  82. -                       features->unitExpo = report[i + 11];
  83. -                       i += 12;
  84. +                       if (features->type == BAMBOO_PT) {
  85. +                           /* need to reset back */
  86. +                           features->pktlen = WACOM_PKGLEN_BBTOUCH;
  87. +                           features->device_type = BTN_TOOL_TRIPLETAP;
  88. +                           features->x_phy =
  89. +                               get_unaligned_le16(&report[i + 5]);
  90. +                           features->x_max =
  91. +                               get_unaligned_le16(&report[i + 8]);
  92. +                           i += 15;
  93. +                       } else {
  94. +                           features->x_max =
  95. +                               get_unaligned_le16(&report[i + 3]);
  96. +                           features->x_phy =
  97. +                               get_unaligned_le16(&report[i + 6]);
  98. +                           features->unit = report[i + 9];
  99. +                           features->unitExpo = report[i + 11];
  100. +                           i += 12;
  101. +                       }
  102.                     } else if (pen) {
  103.                         /* penabled only accepts exact bytes of data */
  104.                         if (features->type == TABLETPC2FG)
  105.                             features->pktlen = WACOM_PKGLEN_GRAPHIRE;
  106. +                       if (features->type == BAMBOO_PT)
  107. +                           features->pktlen = WACOM_PKGLEN_BBFUN;
  108.                         features->device_type = BTN_TOOL_PEN;
  109.                         features->x_max =
  110.                             get_unaligned_le16(&report[i + 3]);
  111. @@ -234,6 +242,15 @@
  112.                             features->y_phy =
  113.                                 get_unaligned_le16(&report[i + 6]);
  114.                             i += 7;
  115. +                       } else if (features->type == BAMBOO_PT) {
  116. +                           /* need to reset back */
  117. +                           features->pktlen = WACOM_PKGLEN_BBTOUCH;
  118. +                           features->device_type = BTN_TOOL_TRIPLETAP;
  119. +                           features->y_phy =
  120. +                               get_unaligned_le16(&report[i + 3]);
  121. +                           features->y_max =
  122. +                               get_unaligned_le16(&report[i + 6]);
  123. +                           i += 12;
  124.                         } else {
  125.                             features->y_max =
  126.                                 features->x_max;
  127. @@ -245,6 +262,8 @@
  128.                         /* penabled only accepts exact bytes of data */
  129.                         if (features->type == TABLETPC2FG)
  130.                             features->pktlen = WACOM_PKGLEN_GRAPHIRE;
  131. +                       if (features->type == BAMBOO_PT)
  132. +                           features->pktlen = WACOM_PKGLEN_BBFUN;
  133.                         features->device_type = BTN_TOOL_PEN;
  134.                         features->y_max =
  135.                             get_unaligned_le16(&report[i + 3]);
  136. @@ -295,8 +314,10 @@
  137.     if (!rep_data)
  138.         return error;
  139.  
  140. -   /* ask to report tablet data if it is 2FGT or not a Tablet PC */
  141. -   if (features->device_type == BTN_TOOL_TRIPLETAP) {
  142. +   /* ask to report tablet data if it is 2FGT Tablet PC
  143. +    * OR not a Tablet PC */
  144. +   if (features->device_type == BTN_TOOL_TRIPLETAP &&
  145. +           (features->type == TABLETPC2FG)) {
  146.         do {
  147.             rep_data[0] = 3;
  148.             rep_data[1] = 4;
  149. @@ -336,8 +357,9 @@
  150.     /* default device to penabled */
  151.     features->device_type = BTN_TOOL_PEN;
  152.  
  153. -   /* only Tablet PCs need to retrieve the info */
  154. -   if ((features->type != TABLETPC) && (features->type != TABLETPC2FG))
  155. +   /* only Tablet PCs and 2FGT devices need to retrieve the info */
  156. +   if ((features->type != TABLETPC) && (features->type != TABLETPC2FG)
  157. +           && (features->type != BAMBOO_PT))
  158.         goto out;
  159.  
  160.     if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {
  161. @@ -495,7 +517,8 @@
  162.  
  163.     strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));
  164.  
  165. -   if (features->type == TABLETPC || features->type == TABLETPC2FG) {
  166. +   if (features->type == TABLETPC || features->type == TABLETPC2FG ||
  167. +            features->type == BAMBOO_PT) {
  168.         /* Append the device type to the name */
  169.         strlcat(wacom_wac->name,
  170.             features->device_type == BTN_TOOL_PEN ?
  171. @@ -577,12 +600,10 @@
  172.  
  173.     /* switch to wacom mode first */
  174.     wacom_query_tablet_data(intf, features);
  175. -
  176.     if (wacom->open)
  177.         rv = usb_submit_urb(wacom->irq, GFP_NOIO);
  178.     else
  179.         rv = 0;
  180. -
  181.     mutex_unlock(&wacom->lock);
  182.  
  183.     return rv;
  184. diff -Naur linux-2.6.36/drivers/input/tablet//wacom_wac.c linux-2.6.36-rc/drivers/input/tablet//wacom_wac.c
  185. --- linux-2.6.36/drivers/input/tablet//wacom_wac.c  2010-10-11 00:50:55.417221949 +0200
  186. +++ linux-2.6.36-rc/drivers/input/tablet//wacom_wac.c   2010-10-11 00:07:39.605526080 +0200
  187. @@ -57,6 +57,40 @@
  188.  
  189.     return 1;
  190.  }
  191. +static int wacom_dtu_irq(struct wacom_wac *wacom)
  192. +{
  193. +   struct wacom_features *features = &wacom->features;
  194. +   char *data = wacom->data;
  195. +   struct input_dev *input = wacom->input;
  196. +   int prox = data[1] & 0x20, pressure;
  197. +
  198. +   dbg("wacom_dtu_irq: received report #%d", data[0]);
  199. +
  200. +   if (prox) {
  201. +       /* Going into proximity select tool */
  202. +       wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  203. +       if (wacom->tool[0] == BTN_TOOL_PEN)
  204. +           wacom->id[0] = STYLUS_DEVICE_ID;
  205. +       else
  206. +           wacom->id[0] = ERASER_DEVICE_ID;
  207. +   }
  208. +   input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  209. +   input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  210. +   pressure = ((data[7] & 0x01) << 8) | data[6];
  211. +   if (pressure < 0)
  212. +       pressure = features->pressure_max + pressure + 1;
  213. +   input_report_abs(input, ABS_PRESSURE, pressure);
  214. +   input_report_key(input, BTN_TOUCH, data[1] & 0x05);
  215. +   if (!prox) /* out-prox */
  216. +       wacom->id[0] = 0;
  217. +   else {
  218. +       input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  219. +       input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  220. +   }
  221. +   input_report_key(input, wacom->tool[0], prox);
  222. +   input_report_abs(input, ABS_MISC, wacom->id[0]);
  223. +   return 1;
  224. +}
  225.  
  226.  static int wacom_pl_irq(struct wacom_wac *wacom)
  227.  {
  228. @@ -158,37 +192,166 @@
  229.     return 1;
  230.  }
  231.  
  232. -static int wacom_dtu_irq(struct wacom_wac *wacom)
  233. +static void wacom_bpt_finger_in(struct wacom_wac *wacom, char *data, int idx)
  234.  {
  235. -   struct wacom_features *features = &wacom->features;
  236. -   char *data = wacom->data;
  237. +   int x = 0, y = 0;
  238. +   int finger = idx + 1;
  239.     struct input_dev *input = wacom->input;
  240. -   int prox = data[1] & 0x20, pressure;
  241.  
  242. -   dbg("wacom_dtu_irq: received report #%d", data[0]);
  243. +   x = get_unaligned_be16(&data[3 + (idx * 9)]) & 0x7ff;
  244. +   y = get_unaligned_be16(&data[5 + (idx * 9)]) & 0x7ff;
  245.  
  246. -   if (prox) {
  247. -       /* Going into proximity select tool */
  248. -       wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  249. -       if (wacom->tool[0] == BTN_TOOL_PEN)
  250. -           wacom->id[0] = STYLUS_DEVICE_ID;
  251. -       else
  252. -           wacom->id[0] = ERASER_DEVICE_ID;
  253. +   if (wacom->last_finger != finger) {
  254. +       if (x == input_abs_get_val(input, ABS_X))
  255. +           x++;
  256. +
  257. +       if (y == input_abs_get_val(input, ABS_Y))
  258. +           y++;
  259.     }
  260. -   input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  261. -   input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  262. -   input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  263. -   input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  264. -   pressure = ((data[7] & 0x01) << 8) | data[6];
  265. -   if (pressure < 0)
  266. -       pressure = features->pressure_max + pressure + 1;
  267. -   input_report_abs(input, ABS_PRESSURE, pressure);
  268. -   input_report_key(input, BTN_TOUCH, data[1] & 0x05);
  269. -   if (!prox) /* out-prox */
  270. -       wacom->id[0] = 0;
  271. -   input_report_key(input, wacom->tool[0], prox);
  272. +
  273. +   input_report_abs(input, ABS_X, x);
  274. +   input_report_abs(input, ABS_Y, y);
  275.     input_report_abs(input, ABS_MISC, wacom->id[0]);
  276. -   return 1;
  277. +   input_report_key(input, wacom->tool[finger], 1);
  278. +
  279. +   if (!idx)
  280. +       input_report_key(input, BTN_TOUCH, 1);
  281. +   input_event(input, EV_MSC, MSC_SERIAL, finger);
  282. +   input_sync(input);
  283. +
  284. +   wacom->last_finger = finger;
  285. +}
  286. +
  287. +static void wacom_bpt_touch_out(struct wacom_wac *wacom, int idx)
  288. +{
  289. +   int finger = idx + 1;
  290. +   struct input_dev *input = wacom->input;
  291. +
  292. +   input_report_abs(input, ABS_PRESSURE, 0);
  293. +   input_report_abs(input, ABS_MISC, 0);
  294. +   input_report_key(input, wacom->tool[finger], 0);
  295. +
  296. +   if (!idx)
  297. +       input_report_key(input, BTN_TOUCH, 0);
  298. +   input_event(input, EV_MSC, MSC_SERIAL, finger);
  299. +   input_sync(input);
  300. +}
  301. +
  302. +static void wacom_bpt_touch_in(struct wacom_wac *wacom)
  303. +{
  304. +   char *data = wacom->data;
  305. +
  306. +   /* First finger down */
  307. +   if (data[3] & 0x80) {
  308. +       wacom->tool[1] = BTN_TOOL_DOUBLETAP;
  309. +       wacom->id[0] = TOUCH_DEVICE_ID;
  310. +       wacom_bpt_finger_in(wacom, data, 0);
  311. +   } else if (wacom->id[2] & 0x01)
  312. +       wacom_bpt_touch_out(wacom, 0);
  313. +
  314. +   /* Second finger down */
  315. +   if (data[12] & 0x80) {
  316. +       wacom->tool[2] = BTN_TOOL_TRIPLETAP;
  317. +       wacom_bpt_finger_in(wacom, data, 1);
  318. +   } else if (wacom->id[2] & 0x02)
  319. +       wacom_bpt_touch_out(wacom, 1);
  320. +}
  321. +
  322. +static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
  323. +{
  324. +   char *data = wacom->data;
  325. +   int prox = 0, retval = 0;
  326. +   struct input_dev *input = wacom->input;
  327. +
  328. +   if (data[0] != WACOM_REPORT_PENABLED) {
  329. +       dbg("wacom_bpt_irq: received unknown report #%d", data[0]);
  330. +       goto exit;
  331. +   }
  332. +
  333. +   /* Touch packet */
  334. +   if (len == WACOM_PKGLEN_BBTOUCH) {
  335. +
  336. +       /* Send pad data if there are any
  337. +        * don't repeat all zeros
  338. +        */
  339. +       prox = data[1] & 0x0f;
  340. +       if (prox || wacom->id[1]) {
  341. +           if (!wacom->id[1]) /* in-prox */
  342. +               wacom->id[1] = PAD_DEVICE_ID;
  343. +
  344. +           if (!prox) /* out-prox */
  345. +               wacom->id[1] = 0;
  346. +
  347. +           input_report_key(input, BTN_0, data[1] & 0x1);
  348. +           input_report_key(input, BTN_1, data[1] & 0x2);
  349. +           input_report_key(input, BTN_2, data[1] & 0x4);
  350. +           input_report_key(input, BTN_3, data[1] & 0x8);
  351. +           input_report_key(input, BTN_TOOL_FINGER, prox);
  352. +           input_report_abs(input, ABS_MISC, wacom->id[1]);
  353. +           input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
  354. +           input_sync(input);
  355. +       }
  356. +
  357. +       if (wacom->shared->stylus_in_proximity) {
  358. +           if (wacom->id[2] & 0x01)
  359. +               wacom_bpt_touch_out(wacom, 0);
  360. +
  361. +           if (wacom->id[2] & 0x02)
  362. +               wacom_bpt_touch_out(wacom, 1);
  363. +           wacom->id[2] = 0;
  364. +           return 0;
  365. +       }
  366. +
  367. +       prox = (data[17] & 0x30 >> 4);
  368. +       if (prox) {
  369. +           /* initialize last touched finger */
  370. +           if (!wacom->id[1])
  371. +               wacom->last_finger = 1;
  372. +
  373. +           wacom_bpt_touch_in(wacom);
  374. +       } else {
  375. +           if (wacom->id[2] & 0x01)
  376. +               wacom_bpt_touch_out(wacom, 0);
  377. +
  378. +           if (wacom->id[2] & 0x02)
  379. +               wacom_bpt_touch_out(wacom, 1);
  380. +
  381. +           wacom->id[0] = 0;
  382. +       }
  383. +       wacom->id[2] = (((data[3] & 0x80) >> 7) & 0x1) |
  384. +               (((data[12] & 0x80) >> 6) & 0x2);
  385. +
  386. +   } else if (len == WACOM_PKGLEN_BBFUN) { /* Penabled */
  387. +       prox = (data[1] & 0x10) && (data[1] & 0x20);
  388. +
  389. +       if (!wacom->shared->stylus_in_proximity) { /* in-prox */
  390. +           if (data[1] & 0x08) {
  391. +               wacom->tool[0] = BTN_TOOL_RUBBER;
  392. +               wacom->id[0] = ERASER_DEVICE_ID;
  393. +           } else {
  394. +               wacom->tool[0] = BTN_TOOL_PEN;
  395. +               wacom->id[0] = STYLUS_DEVICE_ID;
  396. +           }
  397. +           wacom->shared->stylus_in_proximity = true;
  398. +       }
  399. +       input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
  400. +       input_report_abs(input, ABS_DISTANCE, data[8]);
  401. +       input_report_key(input, BTN_TOUCH, data[1] & 0x01);
  402. +       input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  403. +       input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
  404. +       if (!prox) {
  405. +           wacom->id[0] = 0;
  406. +           wacom->shared->stylus_in_proximity = false;
  407. +       } else {
  408. +           input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  409. +           input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  410. +       }
  411. +       input_report_key(input, wacom->tool[0], prox);
  412. +       input_report_abs(input, ABS_MISC, wacom->id[0]);
  413. +       retval = 1;
  414. +   }
  415. +exit:
  416. +   return retval;
  417.  }
  418.  
  419.  static int wacom_graphire_irq(struct wacom_wac *wacom)
  420. @@ -253,6 +416,10 @@
  421.  
  422.         if (!prox)
  423.             wacom->id[0] = 0;
  424. +       else {
  425. +           input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  426. +           input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  427. +       }
  428.         input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  429.         input_report_key(input, wacom->tool[0], prox);
  430.         input_sync(input); /* sync last event */
  431. @@ -779,7 +946,7 @@
  432.     if (len == WACOM_PKGLEN_TPC1FG ||        /* single touch */
  433.         data[0] == WACOM_REPORT_TPC1FG ||        /* single touch */
  434.         data[0] == WACOM_REPORT_TPC2FG) {        /* 2FG touch */
  435. -
  436. +  
  437.         if (wacom->shared->stylus_in_proximity) {
  438.             if (wacom->id[1] & 0x01)
  439.                 wacom_tpc_touch_out(wacom, 0);
  440. @@ -803,8 +970,10 @@
  441.         }
  442.  
  443.         if (prox) {
  444. +           /* initialize last touched finger */
  445.             if (!wacom->id[1])
  446.                 wacom->last_finger = 1;
  447. +
  448.             wacom_tpc_touch_in(wacom, len);
  449.         } else {
  450.             if (data[0] == WACOM_REPORT_TPC2FG) {
  451. @@ -837,8 +1006,6 @@
  452.         }
  453.         input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  454.         input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  455. -       input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  456. -       input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  457.         pressure = ((data[7] & 0x01) << 8) | data[6];
  458.         if (pressure < 0)
  459.             pressure = features->pressure_max + pressure + 1;
  460. @@ -847,6 +1014,9 @@
  461.         if (!prox) { /* out-prox */
  462.             wacom->id[0] = 0;
  463.             wacom->shared->stylus_in_proximity = false;
  464. +       } else {
  465. +           input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  466. +           input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  467.         }
  468.         input_report_key(input, wacom->tool[0], prox);
  469.         input_report_abs(input, ABS_MISC, wacom->id[0]);
  470. @@ -868,6 +1038,10 @@
  471.         sync = wacom_pl_irq(wacom_wac);
  472.         break;
  473.  
  474. +   case BAMBOO_PT:
  475. +       sync = wacom_bpt_irq(wacom_wac, len);
  476. +       break;
  477. +
  478.     case WACOM_G4:
  479.     case GRAPHIRE:
  480.     case WACOM_MO:
  481. @@ -909,12 +1083,11 @@
  482.         input_sync(wacom_wac->input);
  483.  }
  484.  
  485. -static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
  486. +static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
  487.  {
  488.     struct input_dev *input_dev = wacom_wac->input;
  489.  
  490.     input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  491. -   input_set_capability(input_dev, EV_REL, REL_WHEEL);
  492.  
  493.     __set_bit(BTN_LEFT, input_dev->keybit);
  494.     __set_bit(BTN_RIGHT, input_dev->keybit);
  495. @@ -924,11 +1097,9 @@
  496.  
  497.     __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  498.     __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  499. -   __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  500.     __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
  501.     __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
  502.     __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
  503. -   __set_bit(BTN_TOOL_LENS, input_dev->keybit);
  504.     __set_bit(BTN_STYLUS, input_dev->keybit);
  505.     __set_bit(BTN_STYLUS2, input_dev->keybit);
  506.  
  507. @@ -937,6 +1108,18 @@
  508.     input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
  509.     input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
  510.     input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
  511. +}
  512. +
  513. +static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
  514. +{
  515. +   struct input_dev *input_dev = wacom_wac->input;
  516. +
  517. +   input_set_capability(input_dev, EV_REL, REL_WHEEL);
  518. +
  519. +   wacom_setup_cintiq(wacom_wac);
  520. +
  521. +   __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  522. +   __set_bit(BTN_TOOL_LENS, input_dev->keybit);
  523.     input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
  524.     input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
  525.  }
  526. @@ -958,6 +1141,26 @@
  527.     __set_bit(ABS_MISC, input_dev->absbit);
  528.  
  529.     switch (wacom_wac->features.type) {
  530. +   case BAMBOO_PT:
  531. +       if (features->device_type == BTN_TOOL_TRIPLETAP) {
  532. +           __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
  533. +           __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
  534. +           __set_bit(BTN_0, input_dev->keybit);
  535. +           __set_bit(BTN_1, input_dev->keybit);
  536. +           __set_bit(BTN_2, input_dev->keybit);
  537. +           __set_bit(BTN_3, input_dev->keybit);
  538. +           __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
  539. +           input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  540. +           input_set_abs_params(input_dev, ABS_RX, 0, features->x_phy, 0, 0);
  541. +           input_set_abs_params(input_dev, ABS_RY, 0, features->y_phy, 0, 0);
  542. +       }
  543. +       if (features->device_type == BTN_TOOL_PEN) {
  544. +           __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  545. +           __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  546. +           __set_bit(BTN_STYLUS, input_dev->keybit);
  547. +           __set_bit(BTN_STYLUS2, input_dev->keybit);
  548. +       }
  549. +       break;
  550.     case WACOM_MO:
  551.         __set_bit(BTN_1, input_dev->keybit);
  552.         __set_bit(BTN_5, input_dev->keybit);
  553. @@ -1003,9 +1206,19 @@
  554.         __set_bit(BTN_9, input_dev->keybit);
  555.         /* fall through */
  556.  
  557. +   case CINTIQ:
  558. +       for (i = 0; i < 8; i++)
  559. +           __set_bit(BTN_0 + i, input_dev->keybit);
  560. +       __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
  561. +
  562. +       input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
  563. +       input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
  564. +       input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  565. +       wacom_setup_cintiq(wacom_wac);
  566. +       break;
  567. +
  568.     case INTUOS3:
  569.     case INTUOS3L:
  570. -   case CINTIQ:
  571.         __set_bit(BTN_4, input_dev->keybit);
  572.         __set_bit(BTN_5, input_dev->keybit);
  573.         __set_bit(BTN_6, input_dev->keybit);
  574. @@ -1115,6 +1328,16 @@
  575.     { "Wacom Bamboo",         WACOM_PKGLEN_BBFUN,     14760,  9225,  511, 63, WACOM_MO };
  576.  static const struct wacom_features wacom_features_0x69 =
  577.     { "Wacom Bamboo1",        WACOM_PKGLEN_GRAPHIRE,   5104,  3712,  511, 63, GRAPHIRE };
  578. +static struct wacom_features wacom_features_0xD1 =
  579. +   { "Wacom BambooFun 2FG 4x5", WACOM_PKGLEN_BBFUN,  14720,  9200, 1023, 63, BAMBOO_PT };
  580. +static struct wacom_features wacom_features_0xD4 =
  581. +   { "Wacom Bamboo 4x5",     WACOM_PKGLEN_BBFUN,     14720,  9200, 1023, 63, BAMBOO_PT };
  582. +static struct wacom_features wacom_features_0xD2 =
  583. +   { "Wacom Bamboo Craft",   WACOM_PKGLEN_BBFUN,     14720,  9200, 1023, 63, BAMBOO_PT };
  584. +static struct wacom_features wacom_features_0xD3 =
  585. +   { "Wacom BambooFun 2FG 6x8", WACOM_PKGLEN_BBFUN,  21648, 13530, 1023, 63, BAMBOO_PT };
  586. +static struct wacom_features wacom_features_0xD0 =
  587. +   { "Wacom Bamboo 2FG",     WACOM_PKGLEN_BBFUN,     14720,  9200, 1023, 63, BAMBOO_PT };
  588.  static const struct wacom_features wacom_features_0x20 =
  589.     { "Wacom Intuos 4x5",     WACOM_PKGLEN_INTUOS,    12700, 10600, 1023, 31, INTUOS };
  590.  static const struct wacom_features wacom_features_0x21 =
  591. @@ -1255,6 +1478,11 @@
  592.     { USB_DEVICE_WACOM(0xC0) },
  593.     { USB_DEVICE_WACOM(0xC2) },
  594.     { USB_DEVICE_WACOM(0x03) },
  595. +   { USB_DEVICE_WACOM(0xD1) },
  596. +   { USB_DEVICE_WACOM(0xD4) },
  597. +   { USB_DEVICE_WACOM(0xD2) },
  598. +   { USB_DEVICE_WACOM(0xD3) },
  599. +   { USB_DEVICE_WACOM(0xD0) },
  600.     { USB_DEVICE_WACOM(0x41) },
  601.     { USB_DEVICE_WACOM(0x42) },
  602.     { USB_DEVICE_WACOM(0x43) },
  603. @@ -1289,3 +1517,256 @@
  604.     { }
  605.  };
  606.  MODULE_DEVICE_TABLE(usb, wacom_ids);
  607. +
  608. +#define WAC_LED_RETRIES 10
  609. +#define ICON_TRANSFER_STOP 0
  610. +#define ICON_TRANSFER_START 1
  611. +static int icon_transfer_mode(struct usb_interface *intf, int start)
  612. +{
  613. +   int ret;
  614. +   char buf[2];
  615. +   int c = 0;
  616. +
  617. +   buf[0] = 0x21;
  618. +   buf[1] = start;
  619. +   do {
  620. +       ret = usb_set_report(intf, WAC_HID_FEATURE_REPORT,
  621. +                    0x21, buf, 2);
  622. +       c++;
  623. +   } while ((ret == -ETIMEDOUT || ret == -EPIPE) && c < WAC_LED_RETRIES);
  624. +
  625. +   return 0;
  626. +}
  627. +
  628. +static int set_led_mode(struct usb_interface *intf, int led_sel, int led_llv,
  629. +           int led_hlv, int oled_lum)
  630. +{
  631. +   int ret;
  632. +   char buf[9];
  633. +   int c;
  634. +
  635. +   c = 0;
  636. +   ret = -1;
  637. +
  638. +   /* send LED config data */
  639. +   buf[0] = (char)0x20;
  640. +   buf[1] = (char)(led_sel);
  641. +   buf[2] = (char)(led_llv);
  642. +   buf[3] = (char)(led_hlv);
  643. +   buf[4] = (char)(oled_lum);
  644. +   buf[5] = (char)0;
  645. +   buf[6] = (char)0;
  646. +   buf[7] = (char)0;
  647. +   buf[8] = (char)0;
  648. +   do {
  649. +       ret = usb_set_report(intf, WAC_HID_FEATURE_REPORT,0x20, buf, 9);
  650. +   } while ((ret == -ETIMEDOUT || ret == -EPIPE) && c++ < WAC_LED_RETRIES);
  651. +
  652. +   return ret;
  653. +}
  654. +
  655. +/* Call this when recognizing a button 0 button press to change the ring LED
  656. + */
  657. +int set_scroll_wheel_led(struct usb_interface *intf, int num)
  658. +{
  659. +   return set_led_mode(intf, 0x04+num, 0x7f, 0x7f, 0x00);
  660. +}
  661. +
  662. +static int wacom_set_i4_led(struct usb_interface *intf, char *img, int btn)
  663. +{
  664. +   char *temp_buf;
  665. +   int ret;
  666. +   int i;
  667. +   int c;
  668. +
  669. +   if (icon_transfer_mode(intf, ICON_TRANSFER_START) < 0)
  670. +       return -1;
  671. +
  672. +   /* send img in chunks */
  673. +   temp_buf = kzalloc(259, GFP_KERNEL);
  674. +   if (!temp_buf)
  675. +       return -ENOMEM;
  676. +   temp_buf[0] = 0x23;
  677. +   temp_buf[1] = btn;
  678. +   for (i=0; i<4; ++i) {
  679. +       temp_buf[2] = i;
  680. +       memcpy(&temp_buf[3], &img[256*i], 256);
  681. +       c = 0;
  682. +       do {
  683. +           ret = usb_set_report(intf, WAC_HID_FEATURE_REPORT,
  684. +                        0x23, temp_buf, 259);
  685. +           c++;
  686. +       } while ((ret == -ETIMEDOUT || ret == -EPIPE) &&
  687. +            c < WAC_LED_RETRIES);
  688. +       if (ret < 0) {
  689. +           /* starting and stopping the transfer mode doesn't
  690. +            * seem to have an effect on the successfull transfer
  691. +            * of icon data. If it did, we would want to try to stop
  692. +            * the transfer here after failure.
  693. +            */
  694. +           kfree(temp_buf);
  695. +           return ret;
  696. +       }
  697. +   }
  698. +   kfree(temp_buf);
  699. +
  700. +   if (icon_transfer_mode(intf, ICON_TRANSFER_STOP) < 0)
  701. +       return -1;
  702. +
  703. +   return 0;
  704. +}
  705. +
  706. +static void wacom_led_compress(char *buf, int rows, int cols)
  707. +{
  708. +   int row1, row2;
  709. +   int i,j;
  710. +   char compressed;
  711. +   for (i=0; i<rows/2; ++i) {
  712. +       row1 = i*2;
  713. +       row2 = i*2 + 1;
  714. +       for (j=0; j<cols; ++j) {
  715. +           compressed = buf[row2*cols + j];
  716. +           compressed <<= 4;
  717. +           compressed |= buf[row1*cols + j];
  718. +           buf[i*cols + j] = compressed;
  719. +       }
  720. +   }
  721. +}
  722. +
  723. +static void wacom_led_flip_horizontally(char *buf, int rows, int cols)
  724. +{
  725. +   char temp;
  726. +   int i,j;
  727. +   for (i=0; i<rows; ++i) {
  728. +       for (j=0; j<cols/2; ++j) {
  729. +           temp = buf[i*cols + j];
  730. +           buf[i*cols + j] = buf[((i+1)*cols - 1) - j];
  731. +           buf[((i+1)*cols - 1) - j] = temp;
  732. +       }
  733. +   }
  734. +}
  735. +
  736. +static void wacom_led_flip_vertically(char *buf, int rows, int cols)
  737. +{
  738. +   char temp;
  739. +   int i,j;
  740. +   for (i=0; i<cols; ++i) {
  741. +       for (j=0; j<rows/2; ++j) {
  742. +           temp = buf[j*cols + i];
  743. +           buf[j*cols + i] = buf[(rows-j-1)*cols + i];
  744. +           buf[(rows-j-1)*cols + i] = temp;
  745. +
  746. +           /* also flip the first 4 bits with the last 4 bits */
  747. +           temp = buf[j*cols + i] & 0xf0;
  748. +           buf[j*cols + i] <<= 4;
  749. +           buf[j*cols + i] |= (temp >> 4) & 0x0f;
  750. +
  751. +           temp = buf[(rows-j-1)*cols + i] & 0xf0;
  752. +           buf[(rows-j-1)*cols + i] <<= 4;
  753. +           buf[(rows-j-1)*cols + i] |= (temp >> 4) & 0x0f;
  754. +       }
  755. +   }
  756. +
  757. +}
  758. +
  759. +static int wacom_ioctl_set_led(struct usb_interface *intf, char *img, int btn)
  760. +{
  761. +   int r;
  762. +   struct wacom *wacom = usb_get_intfdata(intf);
  763. +
  764. +   /* check interface for LED support */
  765. +   if (!(wacom->wacom_wac.features.type >= INTUOS4S &&
  766. +         wacom->wacom_wac.features.type <= INTUOS4L)) {
  767. +       r = -1;
  768. +       goto out;
  769. +   }
  770. +   if ((wacom->wacom_wac.features.type == INTUOS4S && btn >= 6) ||
  771. +        btn >= 8) {
  772. +       r = -1;
  773. +       goto out;
  774. +   }
  775. +
  776. +   /* flip image as necessary */
  777. +   switch (wacom->wacom_wac.features.type) {
  778. +   case INTUOS4S:
  779. +       printk(KERN_DEBUG "INTUOS4S: set_led not supported!\n");
  780. +       /* to support this, I need to know the dimensions */
  781. +       r = -1;
  782. +       goto out;
  783. +   case INTUOS4:
  784. +   case INTUOS4L:
  785. +       /* Compress buffer from 32*64 byte buffer into a 16*64
  786. +        * byte buffer.
  787. +        */
  788. +       wacom_led_compress(img, 32, 64);
  789. +       if (wacom->wacom_wac.config & (1<<WACOM_CONFIG_HANDEDNESS)) {
  790. +           /* left handed */
  791. +           wacom_led_flip_vertically(img, 16, 64);
  792. +           btn = 7 - btn;
  793. +       } else {
  794. +           /* right handed */
  795. +           wacom_led_flip_horizontally(img, 16, 64);
  796. +       }
  797. +       break;
  798. +   default:
  799. +       r = -1;
  800. +       goto out;
  801. +   }
  802. +
  803. +   /* set LED img */
  804. +   r = wacom_set_i4_led(intf, img, btn);
  805. +
  806. +out:
  807. +   return r;
  808. +}
  809. +
  810. +static int wacom_ioctl_set_handedness(struct usb_interface *intf, int left_hand)
  811. +{
  812. +   int r;
  813. +   struct wacom *wacom = usb_get_intfdata(intf);
  814. +
  815. +   /* check interface for LED support */
  816. +   if (!(wacom->wacom_wac.features.type >= INTUOS4S &&
  817. +         wacom->wacom_wac.features.type <= INTUOS4L)) {
  818. +       r = -1;
  819. +       goto out;
  820. +   }
  821. +  
  822. +   /* set handedness */
  823. +   r = 0;
  824. +   if (left_hand) {
  825. +       __set_bit(WACOM_CONFIG_HANDEDNESS,
  826. +               (void *)&wacom->wacom_wac.config);
  827. +   } else {
  828. +       __clear_bit(WACOM_CONFIG_HANDEDNESS,
  829. +               (void *)&wacom->wacom_wac.config);
  830. +   }
  831. +
  832. +out:
  833. +   return r;
  834. +}
  835. +
  836. +int wacom_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
  837. +{
  838. +   int ret = 0;
  839. +   struct wacom_led_mode *mode = (struct wacom_led_mode *)buf;
  840. +   switch (code) {
  841. +       case WACOM_SET_LED_IMG:
  842. +           ret = wacom_ioctl_set_led(intf,
  843. +               ((struct wacom_led_img *)buf)->buf,
  844. +               ((struct wacom_led_img *)buf)->btn);
  845. +           break;
  846. +       case WACOM_SET_LEFT_HANDED:
  847. +           ret = wacom_ioctl_set_handedness(intf,
  848. +               ((struct wacom_handedness *)buf)->left_handed);
  849. +           break;
  850. +       case WACOM_SET_LED_MODE:
  851. +           ret = set_led_mode(intf, mode->led_sel, mode->led_llv,
  852. +               mode->led_hlv, mode->oled_lum);
  853. +           break;
  854. +       default:
  855. +           ret = -1;
  856. +   }
  857. +  
  858. +   return ret;
  859. +}
  860. diff -Naur linux-2.6.36/drivers/input/tablet//wacom_wac.h linux-2.6.36-rc/drivers/input/tablet//wacom_wac.h
  861. --- linux-2.6.36/drivers/input/tablet//wacom_wac.h  2010-10-11 00:50:55.417221949 +0200
  862. +++ linux-2.6.36-rc/drivers/input/tablet//wacom_wac.h   2010-10-10 23:25:11.000000000 +0200
  863. @@ -21,6 +21,7 @@
  864.  #define WACOM_PKGLEN_INTUOS    10
  865.  #define WACOM_PKGLEN_TPC1FG     5
  866.  #define WACOM_PKGLEN_TPC2FG    14
  867. +#define WACOM_PKGLEN_BBTOUCH   20
  868.  
  869.  /* device IDs */
  870.  #define STYLUS_DEVICE_ID   0x02
  871. @@ -37,6 +38,11 @@
  872.  #define WACOM_REPORT_TPC1FG        6
  873.  #define WACOM_REPORT_TPC2FG        13
  874.  
  875. +/* wacom_wac->config bits */
  876. +#define WACOM_CONFIG_HANDEDNESS    0
  877. +#define WACOM_CONFIG_SCROLL_LED_L  1
  878. +#define WACOM_CONFIG_SCROLL_LED_H  2
  879. +
  880.  enum {
  881.     PENPARTNER = 0,
  882.     GRAPHIRE,
  883. @@ -44,6 +50,7 @@
  884.     PTU,
  885.     PL,
  886.     DTU,
  887. +   BAMBOO_PT,
  888.     INTUOS,
  889.     INTUOS3S,
  890.     INTUOS3,
  891. @@ -89,6 +96,36 @@
  892.     struct wacom_features features;
  893.     struct wacom_shared *shared;
  894.     struct input_dev *input;
  895. +   __u32 config;
  896. +};
  897. +
  898. +/* Provides common system calls for interacting with wacom tablets via usbfs
  899. + *
  900. + * ioctl data for setting led
  901. + *
  902. + *    The image buffer passed to the wacom device is 64*32 bytes for an Intuos4
  903. + *    Medium and Large. The size for the Smalls is probably the same, but I
  904. + *    haven't verified this yet.  Nick Hirsch <nick.hirsch@gmail.com>
  905. + */
  906. +struct wacom_led_img {
  907. +   char buf[2048];
  908. +   int btn;
  909. +};
  910. +
  911. +struct wacom_handedness {
  912. +   int left_handed;
  913. +};
  914. +
  915. +struct wacom_led_mode {
  916. +   char led_sel;
  917. +   char led_llv;
  918. +   char led_hlv;
  919. +   char oled_lum;
  920.  };
  921.  
  922. +/* consider changing the group to something USB specific */
  923. +#define WACOM_SET_LED_IMG _IOW(0x00, 0x00, struct wacom_led_img)
  924. +#define WACOM_SET_LEFT_HANDED _IOW(0x00, 0x01, struct wacom_handedness)
  925. +#define WACOM_SET_LED_MODE _IOW(0x00, 0x02, struct wacom_led_mode)
  926. +
  927.  #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement