^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Apple USB BCM5974 (Macbook Air and Penryn Macbook Pro) multitouch driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2015 John Horan (knasher@gmail.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * The USB initialization and package decoding was made by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Scott Shawcroft as part of the touchd user-space driver project:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Copyright (C) 2008 Scott Shawcroft (scott.shawcroft@gmail.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * The BCM5974 driver is based on the appletouch driver:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Copyright (C) 2005 Johannes Berg (johannes@sipsolutions.net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Copyright (C) 2005 Peter Osterlund (petero2@telia.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/usb/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/hid.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/input/mt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define USB_VENDOR_ID_APPLE 0x05ac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* MacbookAir, aka wellspring */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define USB_DEVICE_ID_APPLE_WELLSPRING_ANSI 0x0223
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define USB_DEVICE_ID_APPLE_WELLSPRING_ISO 0x0224
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define USB_DEVICE_ID_APPLE_WELLSPRING_JIS 0x0225
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /* MacbookProPenryn, aka wellspring2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* Macbook5,1 (unibody), aka wellspring3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* MacbookAir3,2 (unibody), aka wellspring5 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI 0x023f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define USB_DEVICE_ID_APPLE_WELLSPRING4_ISO 0x0240
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define USB_DEVICE_ID_APPLE_WELLSPRING4_JIS 0x0241
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* MacbookAir3,1 (unibody), aka wellspring4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* Macbook8 (unibody, March 2011) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* MacbookAir4,1 (unibody, July 2011) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI 0x0249
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO 0x024a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS 0x024b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* MacbookAir4,2 (unibody, July 2011) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI 0x024c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define USB_DEVICE_ID_APPLE_WELLSPRING6_ISO 0x024d
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define USB_DEVICE_ID_APPLE_WELLSPRING6_JIS 0x024e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /* Macbook8,2 (unibody) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI 0x0252
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO 0x0253
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS 0x0254
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /* MacbookPro10,1 (unibody, June 2012) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI 0x0262
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define USB_DEVICE_ID_APPLE_WELLSPRING7_ISO 0x0263
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define USB_DEVICE_ID_APPLE_WELLSPRING7_JIS 0x0264
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* MacbookPro10,2 (unibody, October 2012) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI 0x0259
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO 0x025a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS 0x025b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /* MacbookAir6,2 (unibody, June 2013) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* MacbookPro12,1 (2015) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI 0x0272
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO 0x0273
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS 0x0274
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define BCM5974_DEVICE(prod) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) USB_DEVICE_ID_MATCH_INT_CLASS | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) USB_DEVICE_ID_MATCH_INT_PROTOCOL), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .idVendor = USB_VENDOR_ID_APPLE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) .idProduct = (prod), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) .bInterfaceClass = USB_INTERFACE_CLASS_HID, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /* table of devices that work with this driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static const struct usb_device_id bcm5974_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /* MacbookAir1.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /* MacbookProPenryn */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /* Macbook5,1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /* MacbookAir3,2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /* MacbookAir3,1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /* MacbookPro8 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /* MacbookAir4,1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /* MacbookAir4,2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING6_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /* MacbookPro8,2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* MacbookPro10,1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /* MacbookPro10,2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /* MacbookAir6,2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* MacbookPro12,1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /* Terminating entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) MODULE_DEVICE_TABLE(usb, bcm5974_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) MODULE_AUTHOR("Henrik Rydberg");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) MODULE_DESCRIPTION("Apple USB BCM5974 multitouch driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #define dprintk(level, format, a...)\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) { if (debug >= level) printk(KERN_DEBUG format, ##a); }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static int debug = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) module_param(debug, int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) MODULE_PARM_DESC(debug, "Activate debugging output");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /* button data structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct bt_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) u8 unknown1; /* constant */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) u8 button; /* left button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) u8 rel_x; /* relative x coordinate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) u8 rel_y; /* relative y coordinate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* trackpad header types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) enum tp_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) TYPE1, /* plain trackpad */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) TYPE2, /* button integrated in trackpad */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) TYPE3, /* additional header fields since June 2013 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) TYPE4 /* additional header field for pressure data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /* trackpad finger data offsets, le16-aligned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #define HEADER_TYPE1 (13 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #define HEADER_TYPE2 (15 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) #define HEADER_TYPE3 (19 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #define HEADER_TYPE4 (23 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) /* trackpad button data offsets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #define BUTTON_TYPE1 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #define BUTTON_TYPE2 15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #define BUTTON_TYPE3 23
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) #define BUTTON_TYPE4 31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) /* list of device capability bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #define HAS_INTEGRATED_BUTTON 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) /* trackpad finger data block size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #define FSIZE_TYPE1 (14 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #define FSIZE_TYPE2 (14 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define FSIZE_TYPE3 (14 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define FSIZE_TYPE4 (15 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) /* offset from header to finger struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #define DELTA_TYPE1 (0 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) #define DELTA_TYPE2 (0 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) #define DELTA_TYPE3 (0 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) #define DELTA_TYPE4 (1 * sizeof(__le16))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /* usb control message mode switch data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #define USBMSG_TYPE1 8, 0x300, 0, 0, 0x1, 0x8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) #define USBMSG_TYPE2 8, 0x300, 0, 0, 0x1, 0x8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) #define USBMSG_TYPE3 8, 0x300, 0, 0, 0x1, 0x8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #define USBMSG_TYPE4 2, 0x302, 2, 1, 0x1, 0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /* Wellspring initialization constants */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #define BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) /* trackpad finger structure, le16-aligned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) struct tp_finger {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) __le16 origin; /* zero when switching track finger */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) __le16 abs_x; /* absolute x coodinate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) __le16 abs_y; /* absolute y coodinate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) __le16 rel_x; /* relative x coodinate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) __le16 rel_y; /* relative y coodinate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) __le16 tool_major; /* tool area, major axis */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) __le16 tool_minor; /* tool area, minor axis */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) __le16 orientation; /* 16384 when point, else 15 bit angle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) __le16 touch_major; /* touch area, major axis */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) __le16 touch_minor; /* touch area, minor axis */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) __le16 unused[2]; /* zeros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) __le16 pressure; /* pressure on forcetouch touchpad */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) __le16 multi; /* one finger: varies, more fingers: constant */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) } __attribute__((packed,aligned(2)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) /* trackpad finger data size, empirically at least ten fingers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) #define MAX_FINGERS 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) #define MAX_FINGER_ORIENTATION 16384
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) /* device-specific parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) struct bcm5974_param {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) int snratio; /* signal-to-noise ratio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) int min; /* device minimum reading */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) int max; /* device maximum reading */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) /* device-specific configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct bcm5974_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) int ansi, iso, jis; /* the product id of this device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) int caps; /* device capability bitmask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) int bt_ep; /* the endpoint of the button interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) int bt_datalen; /* data length of the button interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) int tp_ep; /* the endpoint of the trackpad interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) enum tp_type tp_type; /* type of trackpad interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) int tp_header; /* bytes in header block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) int tp_datalen; /* data length of the trackpad interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) int tp_button; /* offset to button data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) int tp_fsize; /* bytes in single finger block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) int tp_delta; /* offset from header to finger struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) int um_size; /* usb control message length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) int um_req_val; /* usb control message value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) int um_req_idx; /* usb control message index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) int um_switch_idx; /* usb control message mode switch index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) int um_switch_on; /* usb control message mode switch on */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) int um_switch_off; /* usb control message mode switch off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) struct bcm5974_param p; /* finger pressure limits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) struct bcm5974_param w; /* finger width limits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) struct bcm5974_param x; /* horizontal limits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) struct bcm5974_param y; /* vertical limits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct bcm5974_param o; /* orientation limits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) /* logical device structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) struct bcm5974 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) char phys[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct usb_device *udev; /* usb device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) struct usb_interface *intf; /* our interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) struct input_dev *input; /* input dev */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) struct bcm5974_config cfg; /* device configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) struct mutex pm_mutex; /* serialize access to open/suspend */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) int opened; /* 1: opened, 0: closed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) struct urb *bt_urb; /* button usb request block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) struct bt_data *bt_data; /* button transferred data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) struct urb *tp_urb; /* trackpad usb request block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) u8 *tp_data; /* trackpad transferred data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) const struct tp_finger *index[MAX_FINGERS]; /* finger index data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) struct input_mt_pos pos[MAX_FINGERS]; /* position array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) int slots[MAX_FINGERS]; /* slot assignments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) /* trackpad finger block data, le16-aligned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) static const struct tp_finger *get_tp_finger(const struct bcm5974 *dev, int i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) const struct bcm5974_config *c = &dev->cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) u8 *f_base = dev->tp_data + c->tp_header + c->tp_delta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) return (const struct tp_finger *)(f_base + i * c->tp_fsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) #define DATAFORMAT(type) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) type, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) HEADER_##type, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) HEADER_##type + (MAX_FINGERS) * (FSIZE_##type), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) BUTTON_##type, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) FSIZE_##type, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) DELTA_##type, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) USBMSG_##type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) /* logical signal quality */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) #define SN_PRESSURE 45 /* pressure signal-to-noise ratio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) #define SN_WIDTH 25 /* width signal-to-noise ratio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) #define SN_COORD 250 /* coordinate signal-to-noise ratio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) #define SN_ORIENT 10 /* orientation signal-to-noise ratio */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) /* device constants */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) static const struct bcm5974_config bcm5974_config_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) USB_DEVICE_ID_APPLE_WELLSPRING_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) USB_DEVICE_ID_APPLE_WELLSPRING_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) USB_DEVICE_ID_APPLE_WELLSPRING_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 0x84, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 0x81, DATAFORMAT(TYPE1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) { SN_PRESSURE, 0, 256 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) { SN_COORD, -4824, 5342 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) { SN_COORD, -172, 5820 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) USB_DEVICE_ID_APPLE_WELLSPRING2_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) USB_DEVICE_ID_APPLE_WELLSPRING2_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 0x84, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 0x81, DATAFORMAT(TYPE1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) { SN_PRESSURE, 0, 256 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) { SN_COORD, -4824, 4824 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) { SN_COORD, -172, 4290 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) USB_DEVICE_ID_APPLE_WELLSPRING3_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) USB_DEVICE_ID_APPLE_WELLSPRING3_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) HAS_INTEGRATED_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 0x84, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 0x81, DATAFORMAT(TYPE2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) { SN_PRESSURE, 0, 300 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) { SN_COORD, -4460, 5166 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) { SN_COORD, -75, 6700 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) USB_DEVICE_ID_APPLE_WELLSPRING4_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) USB_DEVICE_ID_APPLE_WELLSPRING4_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) HAS_INTEGRATED_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 0x84, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 0x81, DATAFORMAT(TYPE2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) { SN_PRESSURE, 0, 300 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) { SN_COORD, -4620, 5140 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) { SN_COORD, -150, 6600 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) HAS_INTEGRATED_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 0x84, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 0x81, DATAFORMAT(TYPE2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) { SN_PRESSURE, 0, 300 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) { SN_COORD, -4616, 5112 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) { SN_COORD, -142, 5234 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) USB_DEVICE_ID_APPLE_WELLSPRING5_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) USB_DEVICE_ID_APPLE_WELLSPRING5_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) HAS_INTEGRATED_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 0x84, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 0x81, DATAFORMAT(TYPE2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) { SN_PRESSURE, 0, 300 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) { SN_COORD, -4415, 5050 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) { SN_COORD, -55, 6680 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) USB_DEVICE_ID_APPLE_WELLSPRING6_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) USB_DEVICE_ID_APPLE_WELLSPRING6_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) HAS_INTEGRATED_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 0x84, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 0x81, DATAFORMAT(TYPE2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) { SN_PRESSURE, 0, 300 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) { SN_COORD, -4620, 5140 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) { SN_COORD, -150, 6600 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) HAS_INTEGRATED_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 0x84, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 0x81, DATAFORMAT(TYPE2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) { SN_PRESSURE, 0, 300 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) { SN_COORD, -4750, 5280 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) { SN_COORD, -150, 6730 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) HAS_INTEGRATED_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 0x84, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 0x81, DATAFORMAT(TYPE2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) { SN_PRESSURE, 0, 300 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) { SN_COORD, -4620, 5140 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) { SN_COORD, -150, 6600 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) USB_DEVICE_ID_APPLE_WELLSPRING7_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) USB_DEVICE_ID_APPLE_WELLSPRING7_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) HAS_INTEGRATED_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 0x84, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 0x81, DATAFORMAT(TYPE2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) { SN_PRESSURE, 0, 300 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) { SN_COORD, -4750, 5280 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) { SN_COORD, -150, 6730 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) HAS_INTEGRATED_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 0x84, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 0x81, DATAFORMAT(TYPE2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) { SN_PRESSURE, 0, 300 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) { SN_COORD, -4750, 5280 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) { SN_COORD, -150, 6730 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) USB_DEVICE_ID_APPLE_WELLSPRING8_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) USB_DEVICE_ID_APPLE_WELLSPRING8_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) HAS_INTEGRATED_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 0, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 0x83, DATAFORMAT(TYPE3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) { SN_PRESSURE, 0, 300 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) { SN_COORD, -4620, 5140 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) { SN_COORD, -150, 6600 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) USB_DEVICE_ID_APPLE_WELLSPRING9_ISO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) USB_DEVICE_ID_APPLE_WELLSPRING9_JIS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) HAS_INTEGRATED_BUTTON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 0, sizeof(struct bt_data),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 0x83, DATAFORMAT(TYPE4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) { SN_PRESSURE, 0, 300 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) { SN_WIDTH, 0, 2048 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) { SN_COORD, -4828, 5345 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) { SN_COORD, -203, 6803 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) /* return the device-specific configuration by device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) static const struct bcm5974_config *bcm5974_get_config(struct usb_device *udev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) u16 id = le16_to_cpu(udev->descriptor.idProduct);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) const struct bcm5974_config *cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) for (cfg = bcm5974_config_table; cfg->ansi; ++cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) if (cfg->ansi == id || cfg->iso == id || cfg->jis == id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) return cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) return bcm5974_config_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) /* convert 16-bit little endian to signed integer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) static inline int raw2int(__le16 x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) return (signed short)le16_to_cpu(x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) static void set_abs(struct input_dev *input, unsigned int code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) const struct bcm5974_param *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) int fuzz = p->snratio ? (p->max - p->min) / p->snratio : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) input_set_abs_params(input, code, p->min, p->max, fuzz, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) /* setup which logical events to report */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) static void setup_events_to_report(struct input_dev *input_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) const struct bcm5974_config *cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) __set_bit(EV_ABS, input_dev->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) /* for synaptics only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) input_set_abs_params(input_dev, ABS_PRESSURE, 0, 256, 5, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) input_set_abs_params(input_dev, ABS_TOOL_WIDTH, 0, 16, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) /* finger touch area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) set_abs(input_dev, ABS_MT_TOUCH_MAJOR, &cfg->w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) set_abs(input_dev, ABS_MT_TOUCH_MINOR, &cfg->w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) /* finger approach area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) set_abs(input_dev, ABS_MT_WIDTH_MAJOR, &cfg->w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) set_abs(input_dev, ABS_MT_WIDTH_MINOR, &cfg->w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) /* finger orientation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) set_abs(input_dev, ABS_MT_ORIENTATION, &cfg->o);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) /* finger position */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) set_abs(input_dev, ABS_MT_POSITION_X, &cfg->x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) set_abs(input_dev, ABS_MT_POSITION_Y, &cfg->y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) __set_bit(EV_KEY, input_dev->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) __set_bit(BTN_LEFT, input_dev->keybit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) if (cfg->caps & HAS_INTEGRATED_BUTTON)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) input_mt_init_slots(input_dev, MAX_FINGERS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) INPUT_MT_POINTER | INPUT_MT_DROP_UNUSED | INPUT_MT_TRACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) /* report button data as logical button state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) static int report_bt_state(struct bcm5974 *dev, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) if (size != sizeof(struct bt_data))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) dprintk(7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) "bcm5974: button data: %x %x %x %x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) dev->bt_data->unknown1, dev->bt_data->button,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) dev->bt_data->rel_x, dev->bt_data->rel_y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) input_report_key(dev->input, BTN_LEFT, dev->bt_data->button);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) input_sync(dev->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) static void report_finger_data(struct input_dev *input, int slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) const struct input_mt_pos *pos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) const struct tp_finger *f)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) input_mt_slot(input, slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) input_report_abs(input, ABS_MT_TOUCH_MAJOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) raw2int(f->touch_major) << 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) input_report_abs(input, ABS_MT_TOUCH_MINOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) raw2int(f->touch_minor) << 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) input_report_abs(input, ABS_MT_WIDTH_MAJOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) raw2int(f->tool_major) << 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) input_report_abs(input, ABS_MT_WIDTH_MINOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) raw2int(f->tool_minor) << 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) input_report_abs(input, ABS_MT_ORIENTATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) MAX_FINGER_ORIENTATION - raw2int(f->orientation));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) input_report_abs(input, ABS_MT_POSITION_X, pos->x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) input_report_abs(input, ABS_MT_POSITION_Y, pos->y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) static void report_synaptics_data(struct input_dev *input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) const struct bcm5974_config *cfg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) const struct tp_finger *f, int raw_n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) int abs_p = 0, abs_w = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) if (raw_n) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) int p = raw2int(f->touch_major);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) int w = raw2int(f->tool_major);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) if (p > 0 && raw2int(f->origin)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) abs_p = clamp_val(256 * p / cfg->p.max, 0, 255);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) abs_w = clamp_val(16 * w / cfg->w.max, 0, 15);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) input_report_abs(input, ABS_PRESSURE, abs_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) input_report_abs(input, ABS_TOOL_WIDTH, abs_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) /* report trackpad data as logical trackpad state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) static int report_tp_state(struct bcm5974 *dev, int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) const struct bcm5974_config *c = &dev->cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) const struct tp_finger *f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) struct input_dev *input = dev->input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) int raw_n, i, n = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) if (size < c->tp_header || (size - c->tp_header) % c->tp_fsize != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) raw_n = (size - c->tp_header) / c->tp_fsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) for (i = 0; i < raw_n; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) f = get_tp_finger(dev, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) if (raw2int(f->touch_major) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) dev->pos[n].x = raw2int(f->abs_x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) dev->pos[n].y = c->y.min + c->y.max - raw2int(f->abs_y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) dev->index[n++] = f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) input_mt_assign_slots(input, dev->slots, dev->pos, n, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) for (i = 0; i < n; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) report_finger_data(input, dev->slots[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) &dev->pos[i], dev->index[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) input_mt_sync_frame(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) report_synaptics_data(input, c, get_tp_finger(dev, 0), raw_n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) /* later types report button events via integrated button only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) if (c->caps & HAS_INTEGRATED_BUTTON) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) int ibt = raw2int(dev->tp_data[c->tp_button]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) input_report_key(input, BTN_LEFT, ibt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) input_sync(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) const struct bcm5974_config *c = &dev->cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) int retval = 0, size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) char *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) /* Type 3 does not require a mode switch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) if (c->tp_type == TYPE3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) data = kmalloc(c->um_size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) if (!data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) dev_err(&dev->intf->dev, "out of memory\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) retval = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) /* read configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) size = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) BCM5974_WELLSPRING_MODE_READ_REQUEST_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) c->um_req_val, c->um_req_idx, data, c->um_size, 5000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) if (size != c->um_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) dev_err(&dev->intf->dev, "could not read from device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) /* apply the mode switch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) data[c->um_switch_idx] = on ? c->um_switch_on : c->um_switch_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) /* write configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) c->um_req_val, c->um_req_idx, data, c->um_size, 5000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) if (size != c->um_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) dev_err(&dev->intf->dev, "could not write to device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) retval = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) dprintk(2, "bcm5974: switched to %s mode.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) on ? "wellspring" : "normal");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) kfree(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) static void bcm5974_irq_button(struct urb *urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) struct bcm5974 *dev = urb->context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) struct usb_interface *intf = dev->intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) switch (urb->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) case -EOVERFLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) case -ECONNRESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) case -ENOENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) case -ESHUTDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) dev_dbg(&intf->dev, "button urb shutting down: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) dev_dbg(&intf->dev, "button urb status: %d\n", urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) if (report_bt_state(dev, dev->bt_urb->actual_length))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) dprintk(1, "bcm5974: bad button package, length: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) dev->bt_urb->actual_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) error = usb_submit_urb(dev->bt_urb, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) dev_err(&intf->dev, "button urb failed: %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) static void bcm5974_irq_trackpad(struct urb *urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) struct bcm5974 *dev = urb->context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) struct usb_interface *intf = dev->intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) switch (urb->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) case -EOVERFLOW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) case -ECONNRESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) case -ENOENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) case -ESHUTDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) dev_dbg(&intf->dev, "trackpad urb shutting down: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) dev_dbg(&intf->dev, "trackpad urb status: %d\n", urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) /* control response ignored */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) if (dev->tp_urb->actual_length == 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) if (report_tp_state(dev, dev->tp_urb->actual_length))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) dprintk(1, "bcm5974: bad trackpad package, length: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) dev->tp_urb->actual_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) error = usb_submit_urb(dev->tp_urb, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) dev_err(&intf->dev, "trackpad urb failed: %d\n", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) * The Wellspring trackpad, like many recent Apple trackpads, share
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) * the usb device with the keyboard. Since keyboards are usually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) * handled by the HID system, the device ends up being handled by two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) * modules. Setting up the device therefore becomes slightly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) * complicated. To enable multitouch features, a mode switch is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) * required, which is usually applied via the control interface of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) * device. It can be argued where this switch should take place. In
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) * some drivers, like appletouch, the switch is made during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) * probe. However, the hid module may also alter the state of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) * device, resulting in trackpad malfunction under certain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) * circumstances. To get around this problem, there is at least one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) * example that utilizes the USB_QUIRK_RESET_RESUME quirk in order to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) * receive a reset_resume request rather than the normal resume.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) * Since the implementation of reset_resume is equal to mode switch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) * plus start_traffic, it seems easier to always do the switch when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) * starting traffic on the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) static int bcm5974_start_traffic(struct bcm5974 *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) error = bcm5974_wellspring_mode(dev, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) dprintk(1, "bcm5974: mode switch failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) goto err_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) if (dev->bt_urb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) error = usb_submit_urb(dev->bt_urb, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) goto err_reset_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) error = usb_submit_urb(dev->tp_urb, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) goto err_kill_bt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) err_kill_bt:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) usb_kill_urb(dev->bt_urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) err_reset_mode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) bcm5974_wellspring_mode(dev, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) err_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) static void bcm5974_pause_traffic(struct bcm5974 *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) usb_kill_urb(dev->tp_urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) usb_kill_urb(dev->bt_urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) bcm5974_wellspring_mode(dev, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) * The code below implements open/close and manual suspend/resume.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) * All functions may be called in random order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) * Opening a suspended device fails with EACCES - permission denied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) * Failing a resume leaves the device resumed but closed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) static int bcm5974_open(struct input_dev *input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) struct bcm5974 *dev = input_get_drvdata(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) error = usb_autopm_get_interface(dev->intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) mutex_lock(&dev->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) error = bcm5974_start_traffic(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) dev->opened = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) mutex_unlock(&dev->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) usb_autopm_put_interface(dev->intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) static void bcm5974_close(struct input_dev *input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) struct bcm5974 *dev = input_get_drvdata(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) mutex_lock(&dev->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) bcm5974_pause_traffic(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) dev->opened = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) mutex_unlock(&dev->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) usb_autopm_put_interface(dev->intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) static int bcm5974_suspend(struct usb_interface *iface, pm_message_t message)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) struct bcm5974 *dev = usb_get_intfdata(iface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) mutex_lock(&dev->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) if (dev->opened)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) bcm5974_pause_traffic(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) mutex_unlock(&dev->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) static int bcm5974_resume(struct usb_interface *iface)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) struct bcm5974 *dev = usb_get_intfdata(iface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) int error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) mutex_lock(&dev->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) if (dev->opened)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) error = bcm5974_start_traffic(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) mutex_unlock(&dev->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) static int bcm5974_probe(struct usb_interface *iface,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) const struct usb_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) struct usb_device *udev = interface_to_usbdev(iface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) const struct bcm5974_config *cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) struct bcm5974 *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) int error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) /* find the product index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) cfg = bcm5974_get_config(udev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) /* allocate memory for our device state and initialize it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) dev = kzalloc(sizeof(struct bcm5974), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) input_dev = input_allocate_device();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) if (!dev || !input_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) dev_err(&iface->dev, "out of memory\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) goto err_free_devs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) dev->udev = udev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) dev->intf = iface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) dev->input = input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) dev->cfg = *cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) mutex_init(&dev->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) /* setup urbs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) if (cfg->tp_type == TYPE1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) dev->bt_urb = usb_alloc_urb(0, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) if (!dev->bt_urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) goto err_free_devs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) dev->tp_urb = usb_alloc_urb(0, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) if (!dev->tp_urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) goto err_free_bt_urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) if (dev->bt_urb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) dev->bt_data = usb_alloc_coherent(dev->udev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) dev->cfg.bt_datalen, GFP_KERNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) &dev->bt_urb->transfer_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) if (!dev->bt_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) goto err_free_urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) dev->tp_data = usb_alloc_coherent(dev->udev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) dev->cfg.tp_datalen, GFP_KERNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) &dev->tp_urb->transfer_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) if (!dev->tp_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) goto err_free_bt_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) if (dev->bt_urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) usb_fill_int_urb(dev->bt_urb, udev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) usb_rcvintpipe(udev, cfg->bt_ep),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) dev->bt_data, dev->cfg.bt_datalen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) bcm5974_irq_button, dev, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) usb_fill_int_urb(dev->tp_urb, udev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) usb_rcvintpipe(udev, cfg->tp_ep),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) dev->tp_data, dev->cfg.tp_datalen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) bcm5974_irq_trackpad, dev, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) /* create bcm5974 device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) usb_make_path(udev, dev->phys, sizeof(dev->phys));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) strlcat(dev->phys, "/input0", sizeof(dev->phys));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) input_dev->name = "bcm5974";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) input_dev->phys = dev->phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) usb_to_input_id(dev->udev, &input_dev->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) /* report driver capabilities via the version field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) input_dev->id.version = cfg->caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) input_dev->dev.parent = &iface->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) input_set_drvdata(input_dev, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) input_dev->open = bcm5974_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) input_dev->close = bcm5974_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) setup_events_to_report(input_dev, cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) error = input_register_device(dev->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) goto err_free_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) /* save our data pointer in this interface device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) usb_set_intfdata(iface, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) err_free_buffer:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) usb_free_coherent(dev->udev, dev->cfg.tp_datalen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) dev->tp_data, dev->tp_urb->transfer_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) err_free_bt_buffer:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) if (dev->bt_urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) usb_free_coherent(dev->udev, dev->cfg.bt_datalen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) dev->bt_data, dev->bt_urb->transfer_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) err_free_urb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) usb_free_urb(dev->tp_urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) err_free_bt_urb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) usb_free_urb(dev->bt_urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) err_free_devs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) usb_set_intfdata(iface, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) input_free_device(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) kfree(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) static void bcm5974_disconnect(struct usb_interface *iface)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) struct bcm5974 *dev = usb_get_intfdata(iface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) usb_set_intfdata(iface, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) input_unregister_device(dev->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) usb_free_coherent(dev->udev, dev->cfg.tp_datalen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) dev->tp_data, dev->tp_urb->transfer_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) if (dev->bt_urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) usb_free_coherent(dev->udev, dev->cfg.bt_datalen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) dev->bt_data, dev->bt_urb->transfer_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) usb_free_urb(dev->tp_urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) usb_free_urb(dev->bt_urb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) kfree(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) static struct usb_driver bcm5974_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) .name = "bcm5974",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) .probe = bcm5974_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) .disconnect = bcm5974_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) .suspend = bcm5974_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) .resume = bcm5974_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) .id_table = bcm5974_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) .supports_autosuspend = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) module_usb_driver(bcm5974_driver);