bcm5974.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  1. /*
  2. * Apple USB BCM5974 (Macbook Air and Penryn Macbook Pro) multitouch driver
  3. *
  4. * Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se)
  5. *
  6. * The USB initialization and package decoding was made by
  7. * Scott Shawcroft as part of the touchd user-space driver project:
  8. * Copyright (C) 2008 Scott Shawcroft (scott.shawcroft@gmail.com)
  9. *
  10. * The BCM5974 driver is based on the appletouch driver:
  11. * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
  12. * Copyright (C) 2005 Johannes Berg (johannes@sipsolutions.net)
  13. * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
  14. * Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de)
  15. * Copyright (C) 2005 Peter Osterlund (petero2@telia.com)
  16. * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch)
  17. * Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch)
  18. *
  19. * This program is free software; you can redistribute it and/or modify
  20. * it under the terms of the GNU General Public License as published by
  21. * the Free Software Foundation; either version 2 of the License, or
  22. * (at your option) any later version.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with this program; if not, write to the Free Software
  31. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  32. *
  33. */
  34. #include <linux/kernel.h>
  35. #include <linux/errno.h>
  36. #include <linux/init.h>
  37. #include <linux/slab.h>
  38. #include <linux/module.h>
  39. #include <linux/usb/input.h>
  40. #include <linux/hid.h>
  41. #include <linux/mutex.h>
  42. #define USB_VENDOR_ID_APPLE 0x05ac
  43. /* MacbookAir, aka wellspring */
  44. #define USB_DEVICE_ID_APPLE_WELLSPRING_ANSI 0x0223
  45. #define USB_DEVICE_ID_APPLE_WELLSPRING_ISO 0x0224
  46. #define USB_DEVICE_ID_APPLE_WELLSPRING_JIS 0x0225
  47. /* MacbookProPenryn, aka wellspring2 */
  48. #define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230
  49. #define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231
  50. #define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232
  51. /* Macbook5,1 (unibody), aka wellspring3 */
  52. #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236
  53. #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237
  54. #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238
  55. /* MacbookAir3,2 (unibody), aka wellspring5 */
  56. #define USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI 0x023f
  57. #define USB_DEVICE_ID_APPLE_WELLSPRING4_ISO 0x0240
  58. #define USB_DEVICE_ID_APPLE_WELLSPRING4_JIS 0x0241
  59. /* MacbookAir3,1 (unibody), aka wellspring4 */
  60. #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242
  61. #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243
  62. #define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244
  63. /* Macbook8 (unibody, March 2011) */
  64. #define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245
  65. #define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246
  66. #define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247
  67. /* MacbookAir4,1 (unibody, July 2011) */
  68. #define USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI 0x0249
  69. #define USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO 0x024a
  70. #define USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS 0x024b
  71. /* MacbookAir4,2 (unibody, July 2011) */
  72. #define USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI 0x024c
  73. #define USB_DEVICE_ID_APPLE_WELLSPRING6_ISO 0x024d
  74. #define USB_DEVICE_ID_APPLE_WELLSPRING6_JIS 0x024e
  75. /* Macbook8,2 (unibody) */
  76. #define USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI 0x0252
  77. #define USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO 0x0253
  78. #define USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS 0x0254
  79. /* MacbookPro10,1 (unibody, June 2012) */
  80. #define USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI 0x0262
  81. #define USB_DEVICE_ID_APPLE_WELLSPRING7_ISO 0x0263
  82. #define USB_DEVICE_ID_APPLE_WELLSPRING7_JIS 0x0264
  83. #define BCM5974_DEVICE(prod) { \
  84. .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
  85. USB_DEVICE_ID_MATCH_INT_CLASS | \
  86. USB_DEVICE_ID_MATCH_INT_PROTOCOL), \
  87. .idVendor = USB_VENDOR_ID_APPLE, \
  88. .idProduct = (prod), \
  89. .bInterfaceClass = USB_INTERFACE_CLASS_HID, \
  90. .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE \
  91. }
  92. /* table of devices that work with this driver */
  93. static const struct usb_device_id bcm5974_table[] = {
  94. /* MacbookAir1.1 */
  95. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
  96. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
  97. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
  98. /* MacbookProPenryn */
  99. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
  100. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
  101. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
  102. /* Macbook5,1 */
  103. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
  104. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
  105. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
  106. /* MacbookAir3,2 */
  107. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI),
  108. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ISO),
  109. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_JIS),
  110. /* MacbookAir3,1 */
  111. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
  112. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
  113. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
  114. /* MacbookPro8 */
  115. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
  116. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
  117. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
  118. /* MacbookAir4,1 */
  119. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
  120. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
  121. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
  122. /* MacbookAir4,2 */
  123. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
  124. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
  125. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
  126. /* MacbookPro8,2 */
  127. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
  128. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
  129. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
  130. /* MacbookPro10,1 */
  131. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
  132. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
  133. BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
  134. /* Terminating entry */
  135. {}
  136. };
  137. MODULE_DEVICE_TABLE(usb, bcm5974_table);
  138. MODULE_AUTHOR("Henrik Rydberg");
  139. MODULE_DESCRIPTION("Apple USB BCM5974 multitouch driver");
  140. MODULE_LICENSE("GPL");
  141. #define dprintk(level, format, a...)\
  142. { if (debug >= level) printk(KERN_DEBUG format, ##a); }
  143. static int debug = 1;
  144. module_param(debug, int, 0644);
  145. MODULE_PARM_DESC(debug, "Activate debugging output");
  146. /* button data structure */
  147. struct bt_data {
  148. u8 unknown1; /* constant */
  149. u8 button; /* left button */
  150. u8 rel_x; /* relative x coordinate */
  151. u8 rel_y; /* relative y coordinate */
  152. };
  153. /* trackpad header types */
  154. enum tp_type {
  155. TYPE1, /* plain trackpad */
  156. TYPE2 /* button integrated in trackpad */
  157. };
  158. /* trackpad finger data offsets, le16-aligned */
  159. #define FINGER_TYPE1 (13 * sizeof(__le16))
  160. #define FINGER_TYPE2 (15 * sizeof(__le16))
  161. /* trackpad button data offsets */
  162. #define BUTTON_TYPE2 15
  163. /* list of device capability bits */
  164. #define HAS_INTEGRATED_BUTTON 1
  165. /* trackpad finger structure, le16-aligned */
  166. struct tp_finger {
  167. __le16 origin; /* zero when switching track finger */
  168. __le16 abs_x; /* absolute x coodinate */
  169. __le16 abs_y; /* absolute y coodinate */
  170. __le16 rel_x; /* relative x coodinate */
  171. __le16 rel_y; /* relative y coodinate */
  172. __le16 tool_major; /* tool area, major axis */
  173. __le16 tool_minor; /* tool area, minor axis */
  174. __le16 orientation; /* 16384 when point, else 15 bit angle */
  175. __le16 touch_major; /* touch area, major axis */
  176. __le16 touch_minor; /* touch area, minor axis */
  177. __le16 unused[3]; /* zeros */
  178. __le16 multi; /* one finger: varies, more fingers: constant */
  179. } __attribute__((packed,aligned(2)));
  180. /* trackpad finger data size, empirically at least ten fingers */
  181. #define MAX_FINGERS 16
  182. #define SIZEOF_FINGER sizeof(struct tp_finger)
  183. #define SIZEOF_ALL_FINGERS (MAX_FINGERS * SIZEOF_FINGER)
  184. #define MAX_FINGER_ORIENTATION 16384
  185. /* device-specific parameters */
  186. struct bcm5974_param {
  187. int dim; /* logical dimension */
  188. int fuzz; /* logical noise value */
  189. int devmin; /* device minimum reading */
  190. int devmax; /* device maximum reading */
  191. };
  192. /* device-specific configuration */
  193. struct bcm5974_config {
  194. int ansi, iso, jis; /* the product id of this device */
  195. int caps; /* device capability bitmask */
  196. int bt_ep; /* the endpoint of the button interface */
  197. int bt_datalen; /* data length of the button interface */
  198. int tp_ep; /* the endpoint of the trackpad interface */
  199. enum tp_type tp_type; /* type of trackpad interface */
  200. int tp_offset; /* offset to trackpad finger data */
  201. int tp_datalen; /* data length of the trackpad interface */
  202. struct bcm5974_param p; /* finger pressure limits */
  203. struct bcm5974_param w; /* finger width limits */
  204. struct bcm5974_param x; /* horizontal limits */
  205. struct bcm5974_param y; /* vertical limits */
  206. };
  207. /* logical device structure */
  208. struct bcm5974 {
  209. char phys[64];
  210. struct usb_device *udev; /* usb device */
  211. struct usb_interface *intf; /* our interface */
  212. struct input_dev *input; /* input dev */
  213. struct bcm5974_config cfg; /* device configuration */
  214. struct mutex pm_mutex; /* serialize access to open/suspend */
  215. int opened; /* 1: opened, 0: closed */
  216. struct urb *bt_urb; /* button usb request block */
  217. struct bt_data *bt_data; /* button transferred data */
  218. struct urb *tp_urb; /* trackpad usb request block */
  219. u8 *tp_data; /* trackpad transferred data */
  220. int fingers; /* number of fingers on trackpad */
  221. };
  222. /* logical dimensions */
  223. #define DIM_PRESSURE 256 /* maximum finger pressure */
  224. #define DIM_WIDTH 16 /* maximum finger width */
  225. #define DIM_X 1280 /* maximum trackpad x value */
  226. #define DIM_Y 800 /* maximum trackpad y value */
  227. /* logical signal quality */
  228. #define SN_PRESSURE 45 /* pressure signal-to-noise ratio */
  229. #define SN_WIDTH 100 /* width signal-to-noise ratio */
  230. #define SN_COORD 250 /* coordinate signal-to-noise ratio */
  231. /* pressure thresholds */
  232. #define PRESSURE_LOW (2 * DIM_PRESSURE / SN_PRESSURE)
  233. #define PRESSURE_HIGH (3 * PRESSURE_LOW)
  234. /* device constants */
  235. static const struct bcm5974_config bcm5974_config_table[] = {
  236. {
  237. USB_DEVICE_ID_APPLE_WELLSPRING_ANSI,
  238. USB_DEVICE_ID_APPLE_WELLSPRING_ISO,
  239. USB_DEVICE_ID_APPLE_WELLSPRING_JIS,
  240. 0,
  241. 0x84, sizeof(struct bt_data),
  242. 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS,
  243. { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 },
  244. { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
  245. { DIM_X, DIM_X / SN_COORD, -4824, 5342 },
  246. { DIM_Y, DIM_Y / SN_COORD, -172, 5820 }
  247. },
  248. {
  249. USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI,
  250. USB_DEVICE_ID_APPLE_WELLSPRING2_ISO,
  251. USB_DEVICE_ID_APPLE_WELLSPRING2_JIS,
  252. 0,
  253. 0x84, sizeof(struct bt_data),
  254. 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS,
  255. { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 },
  256. { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
  257. { DIM_X, DIM_X / SN_COORD, -4824, 4824 },
  258. { DIM_Y, DIM_Y / SN_COORD, -172, 4290 }
  259. },
  260. {
  261. USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI,
  262. USB_DEVICE_ID_APPLE_WELLSPRING3_ISO,
  263. USB_DEVICE_ID_APPLE_WELLSPRING3_JIS,
  264. HAS_INTEGRATED_BUTTON,
  265. 0x84, sizeof(struct bt_data),
  266. 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
  267. { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
  268. { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
  269. { DIM_X, DIM_X / SN_COORD, -4460, 5166 },
  270. { DIM_Y, DIM_Y / SN_COORD, -75, 6700 }
  271. },
  272. {
  273. USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI,
  274. USB_DEVICE_ID_APPLE_WELLSPRING4_ISO,
  275. USB_DEVICE_ID_APPLE_WELLSPRING4_JIS,
  276. HAS_INTEGRATED_BUTTON,
  277. 0x84, sizeof(struct bt_data),
  278. 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
  279. { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
  280. { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
  281. { DIM_X, DIM_X / SN_COORD, -4620, 5140 },
  282. { DIM_Y, DIM_Y / SN_COORD, -150, 6600 }
  283. },
  284. {
  285. USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI,
  286. USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO,
  287. USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS,
  288. HAS_INTEGRATED_BUTTON,
  289. 0x84, sizeof(struct bt_data),
  290. 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
  291. { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
  292. { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
  293. { DIM_X, DIM_X / SN_COORD, -4616, 5112 },
  294. { DIM_Y, DIM_Y / SN_COORD, -142, 5234 }
  295. },
  296. {
  297. USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI,
  298. USB_DEVICE_ID_APPLE_WELLSPRING5_ISO,
  299. USB_DEVICE_ID_APPLE_WELLSPRING5_JIS,
  300. HAS_INTEGRATED_BUTTON,
  301. 0x84, sizeof(struct bt_data),
  302. 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
  303. { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
  304. { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
  305. { DIM_X, DIM_X / SN_COORD, -4415, 5050 },
  306. { DIM_Y, DIM_Y / SN_COORD, -55, 6680 }
  307. },
  308. {
  309. USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI,
  310. USB_DEVICE_ID_APPLE_WELLSPRING6_ISO,
  311. USB_DEVICE_ID_APPLE_WELLSPRING6_JIS,
  312. HAS_INTEGRATED_BUTTON,
  313. 0x84, sizeof(struct bt_data),
  314. 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
  315. { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
  316. { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
  317. { DIM_X, DIM_X / SN_COORD, -4620, 5140 },
  318. { DIM_Y, DIM_Y / SN_COORD, -150, 6600 }
  319. },
  320. {
  321. USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI,
  322. USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO,
  323. USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS,
  324. HAS_INTEGRATED_BUTTON,
  325. 0x84, sizeof(struct bt_data),
  326. 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
  327. { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
  328. { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
  329. { DIM_X, DIM_X / SN_COORD, -4750, 5280 },
  330. { DIM_Y, DIM_Y / SN_COORD, -150, 6730 }
  331. },
  332. {
  333. USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI,
  334. USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO,
  335. USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS,
  336. HAS_INTEGRATED_BUTTON,
  337. 0x84, sizeof(struct bt_data),
  338. 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
  339. { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
  340. { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
  341. { DIM_X, DIM_X / SN_COORD, -4620, 5140 },
  342. { DIM_Y, DIM_Y / SN_COORD, -150, 6600 }
  343. },
  344. {
  345. USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI,
  346. USB_DEVICE_ID_APPLE_WELLSPRING7_ISO,
  347. USB_DEVICE_ID_APPLE_WELLSPRING7_JIS,
  348. HAS_INTEGRATED_BUTTON,
  349. 0x84, sizeof(struct bt_data),
  350. 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
  351. { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 },
  352. { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
  353. { DIM_X, DIM_X / SN_COORD, -4750, 5280 },
  354. { DIM_Y, DIM_Y / SN_COORD, -150, 6730 }
  355. },
  356. {}
  357. };
  358. /* return the device-specific configuration by device */
  359. static const struct bcm5974_config *bcm5974_get_config(struct usb_device *udev)
  360. {
  361. u16 id = le16_to_cpu(udev->descriptor.idProduct);
  362. const struct bcm5974_config *cfg;
  363. for (cfg = bcm5974_config_table; cfg->ansi; ++cfg)
  364. if (cfg->ansi == id || cfg->iso == id || cfg->jis == id)
  365. return cfg;
  366. return bcm5974_config_table;
  367. }
  368. /* convert 16-bit little endian to signed integer */
  369. static inline int raw2int(__le16 x)
  370. {
  371. return (signed short)le16_to_cpu(x);
  372. }
  373. /* scale device data to logical dimensions (asserts devmin < devmax) */
  374. static inline int int2scale(const struct bcm5974_param *p, int x)
  375. {
  376. return x * p->dim / (p->devmax - p->devmin);
  377. }
  378. /* all logical value ranges are [0,dim). */
  379. static inline int int2bound(const struct bcm5974_param *p, int x)
  380. {
  381. int s = int2scale(p, x);
  382. return clamp_val(s, 0, p->dim - 1);
  383. }
  384. /* setup which logical events to report */
  385. static void setup_events_to_report(struct input_dev *input_dev,
  386. const struct bcm5974_config *cfg)
  387. {
  388. __set_bit(EV_ABS, input_dev->evbit);
  389. input_set_abs_params(input_dev, ABS_PRESSURE,
  390. 0, cfg->p.dim, cfg->p.fuzz, 0);
  391. input_set_abs_params(input_dev, ABS_TOOL_WIDTH,
  392. 0, cfg->w.dim, cfg->w.fuzz, 0);
  393. input_set_abs_params(input_dev, ABS_X,
  394. 0, cfg->x.dim, cfg->x.fuzz, 0);
  395. input_set_abs_params(input_dev, ABS_Y,
  396. 0, cfg->y.dim, cfg->y.fuzz, 0);
  397. /* finger touch area */
  398. input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
  399. cfg->w.devmin, cfg->w.devmax, 0, 0);
  400. input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
  401. cfg->w.devmin, cfg->w.devmax, 0, 0);
  402. /* finger approach area */
  403. input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR,
  404. cfg->w.devmin, cfg->w.devmax, 0, 0);
  405. input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR,
  406. cfg->w.devmin, cfg->w.devmax, 0, 0);
  407. /* finger orientation */
  408. input_set_abs_params(input_dev, ABS_MT_ORIENTATION,
  409. -MAX_FINGER_ORIENTATION,
  410. MAX_FINGER_ORIENTATION, 0, 0);
  411. /* finger position */
  412. input_set_abs_params(input_dev, ABS_MT_POSITION_X,
  413. cfg->x.devmin, cfg->x.devmax, 0, 0);
  414. input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
  415. cfg->y.devmin, cfg->y.devmax, 0, 0);
  416. __set_bit(EV_KEY, input_dev->evbit);
  417. __set_bit(BTN_TOUCH, input_dev->keybit);
  418. __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
  419. __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
  420. __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
  421. __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit);
  422. __set_bit(BTN_LEFT, input_dev->keybit);
  423. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  424. if (cfg->caps & HAS_INTEGRATED_BUTTON)
  425. __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
  426. input_set_events_per_packet(input_dev, 60);
  427. }
  428. /* report button data as logical button state */
  429. static int report_bt_state(struct bcm5974 *dev, int size)
  430. {
  431. if (size != sizeof(struct bt_data))
  432. return -EIO;
  433. dprintk(7,
  434. "bcm5974: button data: %x %x %x %x\n",
  435. dev->bt_data->unknown1, dev->bt_data->button,
  436. dev->bt_data->rel_x, dev->bt_data->rel_y);
  437. input_report_key(dev->input, BTN_LEFT, dev->bt_data->button);
  438. input_sync(dev->input);
  439. return 0;
  440. }
  441. static void report_finger_data(struct input_dev *input,
  442. const struct bcm5974_config *cfg,
  443. const struct tp_finger *f)
  444. {
  445. input_report_abs(input, ABS_MT_TOUCH_MAJOR,
  446. raw2int(f->touch_major) << 1);
  447. input_report_abs(input, ABS_MT_TOUCH_MINOR,
  448. raw2int(f->touch_minor) << 1);
  449. input_report_abs(input, ABS_MT_WIDTH_MAJOR,
  450. raw2int(f->tool_major) << 1);
  451. input_report_abs(input, ABS_MT_WIDTH_MINOR,
  452. raw2int(f->tool_minor) << 1);
  453. input_report_abs(input, ABS_MT_ORIENTATION,
  454. MAX_FINGER_ORIENTATION - raw2int(f->orientation));
  455. input_report_abs(input, ABS_MT_POSITION_X, raw2int(f->abs_x));
  456. input_report_abs(input, ABS_MT_POSITION_Y,
  457. cfg->y.devmin + cfg->y.devmax - raw2int(f->abs_y));
  458. input_mt_sync(input);
  459. }
  460. /* report trackpad data as logical trackpad state */
  461. static int report_tp_state(struct bcm5974 *dev, int size)
  462. {
  463. const struct bcm5974_config *c = &dev->cfg;
  464. const struct tp_finger *f;
  465. struct input_dev *input = dev->input;
  466. int raw_p, raw_w, raw_x, raw_y, raw_n, i;
  467. int ptest, origin, ibt = 0, nmin = 0, nmax = 0;
  468. int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0;
  469. if (size < c->tp_offset || (size - c->tp_offset) % SIZEOF_FINGER != 0)
  470. return -EIO;
  471. /* finger data, le16-aligned */
  472. f = (const struct tp_finger *)(dev->tp_data + c->tp_offset);
  473. raw_n = (size - c->tp_offset) / SIZEOF_FINGER;
  474. /* always track the first finger; when detached, start over */
  475. if (raw_n) {
  476. /* report raw trackpad data */
  477. for (i = 0; i < raw_n; i++)
  478. report_finger_data(input, c, &f[i]);
  479. raw_p = raw2int(f->touch_major);
  480. raw_w = raw2int(f->tool_major);
  481. raw_x = raw2int(f->abs_x);
  482. raw_y = raw2int(f->abs_y);
  483. dprintk(9,
  484. "bcm5974: "
  485. "raw: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n",
  486. raw_p, raw_w, raw_x, raw_y, raw_n);
  487. ptest = int2bound(&c->p, raw_p);
  488. origin = raw2int(f->origin);
  489. /* while tracking finger still valid, count all fingers */
  490. if (ptest > PRESSURE_LOW && origin) {
  491. abs_p = ptest;
  492. abs_w = int2bound(&c->w, raw_w);
  493. abs_x = int2bound(&c->x, raw_x - c->x.devmin);
  494. abs_y = int2bound(&c->y, c->y.devmax - raw_y);
  495. while (raw_n--) {
  496. ptest = int2bound(&c->p,
  497. raw2int(f->touch_major));
  498. if (ptest > PRESSURE_LOW)
  499. nmax++;
  500. if (ptest > PRESSURE_HIGH)
  501. nmin++;
  502. f++;
  503. }
  504. }
  505. }
  506. /* set the integrated button if applicable */
  507. if (c->tp_type == TYPE2)
  508. ibt = raw2int(dev->tp_data[BUTTON_TYPE2]);
  509. if (dev->fingers < nmin)
  510. dev->fingers = nmin;
  511. if (dev->fingers > nmax)
  512. dev->fingers = nmax;
  513. input_report_key(input, BTN_TOUCH, dev->fingers > 0);
  514. input_report_key(input, BTN_TOOL_FINGER, dev->fingers == 1);
  515. input_report_key(input, BTN_TOOL_DOUBLETAP, dev->fingers == 2);
  516. input_report_key(input, BTN_TOOL_TRIPLETAP, dev->fingers == 3);
  517. input_report_key(input, BTN_TOOL_QUADTAP, dev->fingers > 3);
  518. input_report_abs(input, ABS_PRESSURE, abs_p);
  519. input_report_abs(input, ABS_TOOL_WIDTH, abs_w);
  520. if (abs_p) {
  521. input_report_abs(input, ABS_X, abs_x);
  522. input_report_abs(input, ABS_Y, abs_y);
  523. dprintk(8,
  524. "bcm5974: abs: p: %+05d w: %+05d x: %+05d y: %+05d "
  525. "nmin: %d nmax: %d n: %d ibt: %d\n", abs_p, abs_w,
  526. abs_x, abs_y, nmin, nmax, dev->fingers, ibt);
  527. }
  528. /* type 2 reports button events via ibt only */
  529. if (c->tp_type == TYPE2)
  530. input_report_key(input, BTN_LEFT, ibt);
  531. input_sync(input);
  532. return 0;
  533. }
  534. /* Wellspring initialization constants */
  535. #define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID 1
  536. #define BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID 9
  537. #define BCM5974_WELLSPRING_MODE_REQUEST_VALUE 0x300
  538. #define BCM5974_WELLSPRING_MODE_REQUEST_INDEX 0
  539. #define BCM5974_WELLSPRING_MODE_VENDOR_VALUE 0x01
  540. #define BCM5974_WELLSPRING_MODE_NORMAL_VALUE 0x08
  541. static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on)
  542. {
  543. char *data = kmalloc(8, GFP_KERNEL);
  544. int retval = 0, size;
  545. if (!data) {
  546. dev_err(&dev->intf->dev, "out of memory\n");
  547. retval = -ENOMEM;
  548. goto out;
  549. }
  550. /* read configuration */
  551. size = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
  552. BCM5974_WELLSPRING_MODE_READ_REQUEST_ID,
  553. USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
  554. BCM5974_WELLSPRING_MODE_REQUEST_VALUE,
  555. BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000);
  556. if (size != 8) {
  557. dev_err(&dev->intf->dev, "could not read from device\n");
  558. retval = -EIO;
  559. goto out;
  560. }
  561. /* apply the mode switch */
  562. data[0] = on ?
  563. BCM5974_WELLSPRING_MODE_VENDOR_VALUE :
  564. BCM5974_WELLSPRING_MODE_NORMAL_VALUE;
  565. /* write configuration */
  566. size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
  567. BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID,
  568. USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
  569. BCM5974_WELLSPRING_MODE_REQUEST_VALUE,
  570. BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000);
  571. if (size != 8) {
  572. dev_err(&dev->intf->dev, "could not write to device\n");
  573. retval = -EIO;
  574. goto out;
  575. }
  576. dprintk(2, "bcm5974: switched to %s mode.\n",
  577. on ? "wellspring" : "normal");
  578. out:
  579. kfree(data);
  580. return retval;
  581. }
  582. static void bcm5974_irq_button(struct urb *urb)
  583. {
  584. struct bcm5974 *dev = urb->context;
  585. struct usb_interface *intf = dev->intf;
  586. int error;
  587. switch (urb->status) {
  588. case 0:
  589. break;
  590. case -EOVERFLOW:
  591. case -ECONNRESET:
  592. case -ENOENT:
  593. case -ESHUTDOWN:
  594. dev_dbg(&intf->dev, "button urb shutting down: %d\n",
  595. urb->status);
  596. return;
  597. default:
  598. dev_dbg(&intf->dev, "button urb status: %d\n", urb->status);
  599. goto exit;
  600. }
  601. if (report_bt_state(dev, dev->bt_urb->actual_length))
  602. dprintk(1, "bcm5974: bad button package, length: %d\n",
  603. dev->bt_urb->actual_length);
  604. exit:
  605. error = usb_submit_urb(dev->bt_urb, GFP_ATOMIC);
  606. if (error)
  607. dev_err(&intf->dev, "button urb failed: %d\n", error);
  608. }
  609. static void bcm5974_irq_trackpad(struct urb *urb)
  610. {
  611. struct bcm5974 *dev = urb->context;
  612. struct usb_interface *intf = dev->intf;
  613. int error;
  614. switch (urb->status) {
  615. case 0:
  616. break;
  617. case -EOVERFLOW:
  618. case -ECONNRESET:
  619. case -ENOENT:
  620. case -ESHUTDOWN:
  621. dev_dbg(&intf->dev, "trackpad urb shutting down: %d\n",
  622. urb->status);
  623. return;
  624. default:
  625. dev_dbg(&intf->dev, "trackpad urb status: %d\n", urb->status);
  626. goto exit;
  627. }
  628. /* control response ignored */
  629. if (dev->tp_urb->actual_length == 2)
  630. goto exit;
  631. if (report_tp_state(dev, dev->tp_urb->actual_length))
  632. dprintk(1, "bcm5974: bad trackpad package, length: %d\n",
  633. dev->tp_urb->actual_length);
  634. exit:
  635. error = usb_submit_urb(dev->tp_urb, GFP_ATOMIC);
  636. if (error)
  637. dev_err(&intf->dev, "trackpad urb failed: %d\n", error);
  638. }
  639. /*
  640. * The Wellspring trackpad, like many recent Apple trackpads, share
  641. * the usb device with the keyboard. Since keyboards are usually
  642. * handled by the HID system, the device ends up being handled by two
  643. * modules. Setting up the device therefore becomes slightly
  644. * complicated. To enable multitouch features, a mode switch is
  645. * required, which is usually applied via the control interface of the
  646. * device. It can be argued where this switch should take place. In
  647. * some drivers, like appletouch, the switch is made during
  648. * probe. However, the hid module may also alter the state of the
  649. * device, resulting in trackpad malfunction under certain
  650. * circumstances. To get around this problem, there is at least one
  651. * example that utilizes the USB_QUIRK_RESET_RESUME quirk in order to
  652. * receive a reset_resume request rather than the normal resume.
  653. * Since the implementation of reset_resume is equal to mode switch
  654. * plus start_traffic, it seems easier to always do the switch when
  655. * starting traffic on the device.
  656. */
  657. static int bcm5974_start_traffic(struct bcm5974 *dev)
  658. {
  659. int error;
  660. error = bcm5974_wellspring_mode(dev, true);
  661. if (error) {
  662. dprintk(1, "bcm5974: mode switch failed\n");
  663. goto err_out;
  664. }
  665. if (dev->bt_urb) {
  666. error = usb_submit_urb(dev->bt_urb, GFP_KERNEL);
  667. if (error)
  668. goto err_reset_mode;
  669. }
  670. error = usb_submit_urb(dev->tp_urb, GFP_KERNEL);
  671. if (error)
  672. goto err_kill_bt;
  673. return 0;
  674. err_kill_bt:
  675. usb_kill_urb(dev->bt_urb);
  676. err_reset_mode:
  677. bcm5974_wellspring_mode(dev, false);
  678. err_out:
  679. return error;
  680. }
  681. static void bcm5974_pause_traffic(struct bcm5974 *dev)
  682. {
  683. usb_kill_urb(dev->tp_urb);
  684. usb_kill_urb(dev->bt_urb);
  685. bcm5974_wellspring_mode(dev, false);
  686. }
  687. /*
  688. * The code below implements open/close and manual suspend/resume.
  689. * All functions may be called in random order.
  690. *
  691. * Opening a suspended device fails with EACCES - permission denied.
  692. *
  693. * Failing a resume leaves the device resumed but closed.
  694. */
  695. static int bcm5974_open(struct input_dev *input)
  696. {
  697. struct bcm5974 *dev = input_get_drvdata(input);
  698. int error;
  699. error = usb_autopm_get_interface(dev->intf);
  700. if (error)
  701. return error;
  702. mutex_lock(&dev->pm_mutex);
  703. error = bcm5974_start_traffic(dev);
  704. if (!error)
  705. dev->opened = 1;
  706. mutex_unlock(&dev->pm_mutex);
  707. if (error)
  708. usb_autopm_put_interface(dev->intf);
  709. return error;
  710. }
  711. static void bcm5974_close(struct input_dev *input)
  712. {
  713. struct bcm5974 *dev = input_get_drvdata(input);
  714. mutex_lock(&dev->pm_mutex);
  715. bcm5974_pause_traffic(dev);
  716. dev->opened = 0;
  717. mutex_unlock(&dev->pm_mutex);
  718. usb_autopm_put_interface(dev->intf);
  719. }
  720. static int bcm5974_suspend(struct usb_interface *iface, pm_message_t message)
  721. {
  722. struct bcm5974 *dev = usb_get_intfdata(iface);
  723. mutex_lock(&dev->pm_mutex);
  724. if (dev->opened)
  725. bcm5974_pause_traffic(dev);
  726. mutex_unlock(&dev->pm_mutex);
  727. return 0;
  728. }
  729. static int bcm5974_resume(struct usb_interface *iface)
  730. {
  731. struct bcm5974 *dev = usb_get_intfdata(iface);
  732. int error = 0;
  733. mutex_lock(&dev->pm_mutex);
  734. if (dev->opened)
  735. error = bcm5974_start_traffic(dev);
  736. mutex_unlock(&dev->pm_mutex);
  737. return error;
  738. }
  739. static int bcm5974_probe(struct usb_interface *iface,
  740. const struct usb_device_id *id)
  741. {
  742. struct usb_device *udev = interface_to_usbdev(iface);
  743. const struct bcm5974_config *cfg;
  744. struct bcm5974 *dev;
  745. struct input_dev *input_dev;
  746. int error = -ENOMEM;
  747. /* find the product index */
  748. cfg = bcm5974_get_config(udev);
  749. /* allocate memory for our device state and initialize it */
  750. dev = kzalloc(sizeof(struct bcm5974), GFP_KERNEL);
  751. input_dev = input_allocate_device();
  752. if (!dev || !input_dev) {
  753. dev_err(&iface->dev, "out of memory\n");
  754. goto err_free_devs;
  755. }
  756. dev->udev = udev;
  757. dev->intf = iface;
  758. dev->input = input_dev;
  759. dev->cfg = *cfg;
  760. mutex_init(&dev->pm_mutex);
  761. /* setup urbs */
  762. if (cfg->tp_type == TYPE1) {
  763. dev->bt_urb = usb_alloc_urb(0, GFP_KERNEL);
  764. if (!dev->bt_urb)
  765. goto err_free_devs;
  766. }
  767. dev->tp_urb = usb_alloc_urb(0, GFP_KERNEL);
  768. if (!dev->tp_urb)
  769. goto err_free_bt_urb;
  770. if (dev->bt_urb) {
  771. dev->bt_data = usb_alloc_coherent(dev->udev,
  772. dev->cfg.bt_datalen, GFP_KERNEL,
  773. &dev->bt_urb->transfer_dma);
  774. if (!dev->bt_data)
  775. goto err_free_urb;
  776. }
  777. dev->tp_data = usb_alloc_coherent(dev->udev,
  778. dev->cfg.tp_datalen, GFP_KERNEL,
  779. &dev->tp_urb->transfer_dma);
  780. if (!dev->tp_data)
  781. goto err_free_bt_buffer;
  782. if (dev->bt_urb)
  783. usb_fill_int_urb(dev->bt_urb, udev,
  784. usb_rcvintpipe(udev, cfg->bt_ep),
  785. dev->bt_data, dev->cfg.bt_datalen,
  786. bcm5974_irq_button, dev, 1);
  787. usb_fill_int_urb(dev->tp_urb, udev,
  788. usb_rcvintpipe(udev, cfg->tp_ep),
  789. dev->tp_data, dev->cfg.tp_datalen,
  790. bcm5974_irq_trackpad, dev, 1);
  791. /* create bcm5974 device */
  792. usb_make_path(udev, dev->phys, sizeof(dev->phys));
  793. strlcat(dev->phys, "/input0", sizeof(dev->phys));
  794. input_dev->name = "bcm5974";
  795. input_dev->phys = dev->phys;
  796. usb_to_input_id(dev->udev, &input_dev->id);
  797. /* report driver capabilities via the version field */
  798. input_dev->id.version = cfg->caps;
  799. input_dev->dev.parent = &iface->dev;
  800. input_set_drvdata(input_dev, dev);
  801. input_dev->open = bcm5974_open;
  802. input_dev->close = bcm5974_close;
  803. setup_events_to_report(input_dev, cfg);
  804. error = input_register_device(dev->input);
  805. if (error)
  806. goto err_free_buffer;
  807. /* save our data pointer in this interface device */
  808. usb_set_intfdata(iface, dev);
  809. return 0;
  810. err_free_buffer:
  811. usb_free_coherent(dev->udev, dev->cfg.tp_datalen,
  812. dev->tp_data, dev->tp_urb->transfer_dma);
  813. err_free_bt_buffer:
  814. if (dev->bt_urb)
  815. usb_free_coherent(dev->udev, dev->cfg.bt_datalen,
  816. dev->bt_data, dev->bt_urb->transfer_dma);
  817. err_free_urb:
  818. usb_free_urb(dev->tp_urb);
  819. err_free_bt_urb:
  820. usb_free_urb(dev->bt_urb);
  821. err_free_devs:
  822. usb_set_intfdata(iface, NULL);
  823. input_free_device(input_dev);
  824. kfree(dev);
  825. return error;
  826. }
  827. static void bcm5974_disconnect(struct usb_interface *iface)
  828. {
  829. struct bcm5974 *dev = usb_get_intfdata(iface);
  830. usb_set_intfdata(iface, NULL);
  831. input_unregister_device(dev->input);
  832. usb_free_coherent(dev->udev, dev->cfg.tp_datalen,
  833. dev->tp_data, dev->tp_urb->transfer_dma);
  834. if (dev->bt_urb)
  835. usb_free_coherent(dev->udev, dev->cfg.bt_datalen,
  836. dev->bt_data, dev->bt_urb->transfer_dma);
  837. usb_free_urb(dev->tp_urb);
  838. usb_free_urb(dev->bt_urb);
  839. kfree(dev);
  840. }
  841. static struct usb_driver bcm5974_driver = {
  842. .name = "bcm5974",
  843. .probe = bcm5974_probe,
  844. .disconnect = bcm5974_disconnect,
  845. .suspend = bcm5974_suspend,
  846. .resume = bcm5974_resume,
  847. .id_table = bcm5974_table,
  848. .supports_autosuspend = 1,
  849. };
  850. module_usb_driver(bcm5974_driver);