ignatenkobrain / rpms / kernel

Forked from rpms/kernel 3 years ago
Clone
b312fc
centosplus patch (bug#10447)
b312fc
support for touchpad and fn key support for MacBookPro 12,1
b312fc
b312fc
https://kernel.googlesource.com/pub/scm/linux/kernel/git/groeck/linux-staging/+/dbe08116b87cdc2217f11a78b5b70e29068b7efd%5E1..dbe08116b87cdc2217f11a78b5b70e29068b7efd/
b312fc
b312fc
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
b312fc
b312fc
Pull input fixes from Dmitry Torokhov:
b312fc
 "The main change is support for keyboards and touchpads found in 2015
b312fc
  editions of Macbooks"
b312fc
b312fc
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
b312fc
  Revert "Input: zforce - don't overwrite the stack"
b312fc
  Input: bcm5974 - add support for the 2015 Macbook Pro
b312fc
  HID: apple: Add support for the 2015 Macbook Pro
b312fc
  Input: bcm5974 - prepare for a new trackpad generation
b312fc
  Input: synaptics - dump ext10 capabilities as well
b312fc
b312fc
Applied-by Akemi Yagi <toracat@centos.org>
b312fc
b312fc
--- a/drivers/hid/hid-apple.c	2016-01-23 00:53:07.000000000 -0800
b312fc
+++ b/drivers/hid/hid-apple.c	2016-03-08 12:41:27.147368677 -0800
b312fc
@@ -552,6 +552,12 @@ static const struct hid_device_id apple_
b312fc
 		.driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
b312fc
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
b312fc
 		.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
b312fc
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
b312fc
+		.driver_data = APPLE_HAS_FN },
b312fc
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
b312fc
+		.driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
b312fc
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
b312fc
+		.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
b312fc
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
b312fc
 		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
b312fc
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
b312fc
--- a/drivers/hid/hid-core.c	2016-01-23 00:53:07.000000000 -0800
b312fc
+++ b/drivers/hid/hid-core.c	2016-03-08 12:45:44.846880469 -0800
b312fc
@@ -1643,6 +1643,9 @@ static const struct hid_device_id hid_ha
b312fc
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI) },
b312fc
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO) },
b312fc
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS) },
b312fc
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) },
b312fc
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
b312fc
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
b312fc
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
b312fc
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
b312fc
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
b312fc
@@ -2284,6 +2287,9 @@ static const struct hid_device_id hid_mo
b312fc
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI) },
b312fc
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO) },
b312fc
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS) },
b312fc
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) },
b312fc
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
b312fc
+	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
b312fc
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
b312fc
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
b312fc
 	{ }
b312fc
--- a/drivers/hid/hid-ids.h	2016-01-23 00:53:07.000000000 -0800
b312fc
+++ b/drivers/hid/hid-ids.h	2016-03-08 12:48:25.532198900 -0800
b312fc
@@ -138,6 +138,9 @@
b312fc
 #define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI	0x0290
b312fc
 #define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO	0x0291
b312fc
 #define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS	0x0292
b312fc
+#define USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI	0x0272
b312fc
+#define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO		0x0273
b312fc
+#define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS		0x0274
b312fc
 #define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY	0x030a
b312fc
 #define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY	0x030b
b312fc
 #define USB_DEVICE_ID_APPLE_IRCONTROL	0x8240
b312fc
--- a/drivers/input/mouse/bcm5974.c	2016-01-23 00:53:07.000000000 -0800
b312fc
+++ b/drivers/input/mouse/bcm5974.c	2016-03-08 13:37:14.906154047 -0800
b312fc
@@ -2,6 +2,7 @@
b312fc
  * Apple USB BCM5974 (Macbook Air and Penryn Macbook Pro) multitouch driver
b312fc
  *
b312fc
  * Copyright (C) 2008	   Henrik Rydberg (rydberg@euromail.se)
b312fc
+ * Copyright (C) 2015      John Horan (knasher@gmail.com)
b312fc
  *
b312fc
  * The USB initialization and package decoding was made by
b312fc
  * Scott Shawcroft as part of the touchd user-space driver project:
b312fc
@@ -92,6 +93,10 @@
b312fc
 #define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI	0x0290
b312fc
 #define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO	0x0291
b312fc
 #define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS	0x0292
b312fc
+/* MacbookPro12,1 (2015) */
b312fc
+#define USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI	0x0272
b312fc
+#define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO	0x0273
b312fc
+#define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS	0x0274
b312fc
 
b312fc
 #define BCM5974_DEVICE(prod) {					\
b312fc
 	.match_flags = (USB_DEVICE_ID_MATCH_DEVICE |		\
b312fc
@@ -153,6 +158,10 @@ static const struct usb_device_id bcm597
b312fc
 	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI),
b312fc
 	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_ISO),
b312fc
 	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING8_JIS),
b312fc
+	/* MacbookPro12,1 */
b312fc
+	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
b312fc
+	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
b312fc
+	BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
b312fc
 	/* Terminating entry */
b312fc
 	{}
b312fc
 };
b312fc
@@ -181,21 +190,47 @@ struct bt_data {
b312fc
 enum tp_type {
b312fc
 	TYPE1,			/* plain trackpad */
b312fc
 	TYPE2,			/* button integrated in trackpad */
b312fc
-	TYPE3			/* additional header fields since June 2013 */
b312fc
+	TYPE3,			/* additional header fields since June 2013 */
b312fc
+	TYPE4			/* additional header field for pressure data */
b312fc
 };
b312fc
 
b312fc
 /* trackpad finger data offsets, le16-aligned */
b312fc
-#define FINGER_TYPE1		(13 * sizeof(__le16))
b312fc
-#define FINGER_TYPE2		(15 * sizeof(__le16))
b312fc
-#define FINGER_TYPE3		(19 * sizeof(__le16))
b312fc
+#define HEADER_TYPE1		(13 * sizeof(__le16))
b312fc
+#define HEADER_TYPE2		(15 * sizeof(__le16))
b312fc
+#define HEADER_TYPE3		(19 * sizeof(__le16))
b312fc
+#define HEADER_TYPE4		(23 * sizeof(__le16))
b312fc
 
b312fc
 /* trackpad button data offsets */
b312fc
+#define BUTTON_TYPE1		0
b312fc
 #define BUTTON_TYPE2		15
b312fc
 #define BUTTON_TYPE3		23
b312fc
+#define BUTTON_TYPE4		31
b312fc
 
b312fc
 /* list of device capability bits */
b312fc
 #define HAS_INTEGRATED_BUTTON	1
b312fc
 
b312fc
+/* trackpad finger data block size */
b312fc
+#define FSIZE_TYPE1		(14 * sizeof(__le16))
b312fc
+#define FSIZE_TYPE2		(14 * sizeof(__le16))
b312fc
+#define FSIZE_TYPE3		(14 * sizeof(__le16))
b312fc
+#define FSIZE_TYPE4		(15 * sizeof(__le16))
b312fc
+
b312fc
+/* offset from header to finger struct */
b312fc
+#define DELTA_TYPE1		(0 * sizeof(__le16))
b312fc
+#define DELTA_TYPE2		(0 * sizeof(__le16))
b312fc
+#define DELTA_TYPE3		(0 * sizeof(__le16))
b312fc
+#define DELTA_TYPE4		(1 * sizeof(__le16))
b312fc
+
b312fc
+/* usb control message mode switch data */
b312fc
+#define USBMSG_TYPE1		8, 0x300, 0, 0, 0x1, 0x8
b312fc
+#define USBMSG_TYPE2		8, 0x300, 0, 0, 0x1, 0x8
b312fc
+#define USBMSG_TYPE3		8, 0x300, 0, 0, 0x1, 0x8
b312fc
+#define USBMSG_TYPE4		2, 0x302, 2, 1, 0x1, 0x0
b312fc
+
b312fc
+/* Wellspring initialization constants */
b312fc
+#define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID		1
b312fc
+#define BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID	9
b312fc
+
b312fc
 /* trackpad finger structure, le16-aligned */
b312fc
 struct tp_finger {
b312fc
 	__le16 origin;		/* zero when switching track finger */
b312fc
@@ -208,14 +243,13 @@ struct tp_finger {
b312fc
 	__le16 orientation;	/* 16384 when point, else 15 bit angle */
b312fc
 	__le16 touch_major;	/* touch area, major axis */
b312fc
 	__le16 touch_minor;	/* touch area, minor axis */
b312fc
-	__le16 unused[3];	/* zeros */
b312fc
+	__le16 unused[2];	/* zeros */
b312fc
+	__le16 pressure;	/* pressure on forcetouch touchpad */
b312fc
 	__le16 multi;		/* one finger: varies, more fingers: constant */
b312fc
 } __attribute__((packed,aligned(2)));
b312fc
 
b312fc
 /* trackpad finger data size, empirically at least ten fingers */
b312fc
 #define MAX_FINGERS		16
b312fc
-#define SIZEOF_FINGER		sizeof(struct tp_finger)
b312fc
-#define SIZEOF_ALL_FINGERS	(MAX_FINGERS * SIZEOF_FINGER)
b312fc
 #define MAX_FINGER_ORIENTATION	16384
b312fc
 
b312fc
 /* device-specific parameters */
b312fc
@@ -233,8 +267,17 @@ struct bcm5974_config {
b312fc
 	int bt_datalen;		/* data length of the button interface */
b312fc
 	int tp_ep;		/* the endpoint of the trackpad interface */
b312fc
 	enum tp_type tp_type;	/* type of trackpad interface */
b312fc
-	int tp_offset;		/* offset to trackpad finger data */
b312fc
+	int tp_header;		/* bytes in header block */
b312fc
 	int tp_datalen;		/* data length of the trackpad interface */
b312fc
+	int tp_button;		/* offset to button data */
b312fc
+	int tp_fsize;		/* bytes in single finger block */
b312fc
+	int tp_delta;		/* offset from header to finger struct */
b312fc
+	int um_size;		/* usb control message length */
b312fc
+	int um_req_val;		/* usb control message value */
b312fc
+	int um_req_idx;		/* usb control message index */
b312fc
+	int um_switch_idx;	/* usb control message mode switch index */
b312fc
+	int um_switch_on;	/* usb control message mode switch on */
b312fc
+	int um_switch_off;	/* usb control message mode switch off */
b312fc
 	struct bcm5974_param p;	/* finger pressure limits */
b312fc
 	struct bcm5974_param w;	/* finger width limits */
b312fc
 	struct bcm5974_param x;	/* horizontal limits */
b312fc
@@ -260,6 +303,24 @@ struct bcm5974 {
b312fc
 	int slots[MAX_FINGERS];				/* slot assignments */
b312fc
 };
b312fc
 
b312fc
+/* trackpad finger block data, le16-aligned */
b312fc
+static const struct tp_finger *get_tp_finger(const struct bcm5974 *dev, int i)
b312fc
+{
b312fc
+	const struct bcm5974_config *c = &dev->cfg;
b312fc
+	u8 *f_base = dev->tp_data + c->tp_header + c->tp_delta;
b312fc
+
b312fc
+	return (const struct tp_finger *)(f_base + i * c->tp_fsize);
b312fc
+}
b312fc
+
b312fc
+#define DATAFORMAT(type)				\
b312fc
+	type,						\
b312fc
+	HEADER_##type,					\
b312fc
+	HEADER_##type + (MAX_FINGERS) * (FSIZE_##type),	\
b312fc
+	BUTTON_##type,					\
b312fc
+	FSIZE_##type,					\
b312fc
+	DELTA_##type,					\
b312fc
+	USBMSG_##type
b312fc
+
b312fc
 /* logical signal quality */
b312fc
 #define SN_PRESSURE	45		/* pressure signal-to-noise ratio */
b312fc
 #define SN_WIDTH	25		/* width signal-to-noise ratio */
b312fc
@@ -274,7 +335,7 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING_JIS,
b312fc
 		0,
b312fc
 		0x84, sizeof(struct bt_data),
b312fc
-		0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS,
b312fc
+		0x81, DATAFORMAT(TYPE1),
b312fc
 		{ SN_PRESSURE, 0, 256 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4824, 5342 },
b312fc
@@ -287,7 +348,7 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING2_JIS,
b312fc
 		0,
b312fc
 		0x84, sizeof(struct bt_data),
b312fc
-		0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS,
b312fc
+		0x81, DATAFORMAT(TYPE1),
b312fc
 		{ SN_PRESSURE, 0, 256 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4824, 4824 },
b312fc
@@ -300,7 +361,7 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING3_JIS,
b312fc
 		HAS_INTEGRATED_BUTTON,
b312fc
 		0x84, sizeof(struct bt_data),
b312fc
-		0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
b312fc
+		0x81, DATAFORMAT(TYPE2),
b312fc
 		{ SN_PRESSURE, 0, 300 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4460, 5166 },
b312fc
@@ -313,7 +374,7 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING4_JIS,
b312fc
 		HAS_INTEGRATED_BUTTON,
b312fc
 		0x84, sizeof(struct bt_data),
b312fc
-		0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
b312fc
+		0x81, DATAFORMAT(TYPE2),
b312fc
 		{ SN_PRESSURE, 0, 300 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4620, 5140 },
b312fc
@@ -326,7 +387,7 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS,
b312fc
 		HAS_INTEGRATED_BUTTON,
b312fc
 		0x84, sizeof(struct bt_data),
b312fc
-		0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
b312fc
+		0x81, DATAFORMAT(TYPE2),
b312fc
 		{ SN_PRESSURE, 0, 300 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4616, 5112 },
b312fc
@@ -339,7 +400,7 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING5_JIS,
b312fc
 		HAS_INTEGRATED_BUTTON,
b312fc
 		0x84, sizeof(struct bt_data),
b312fc
-		0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
b312fc
+		0x81, DATAFORMAT(TYPE2),
b312fc
 		{ SN_PRESSURE, 0, 300 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4415, 5050 },
b312fc
@@ -352,7 +413,7 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING6_JIS,
b312fc
 		HAS_INTEGRATED_BUTTON,
b312fc
 		0x84, sizeof(struct bt_data),
b312fc
-		0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
b312fc
+		0x81, DATAFORMAT(TYPE2),
b312fc
 		{ SN_PRESSURE, 0, 300 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4620, 5140 },
b312fc
@@ -365,7 +426,7 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS,
b312fc
 		HAS_INTEGRATED_BUTTON,
b312fc
 		0x84, sizeof(struct bt_data),
b312fc
-		0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
b312fc
+		0x81, DATAFORMAT(TYPE2),
b312fc
 		{ SN_PRESSURE, 0, 300 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4750, 5280 },
b312fc
@@ -378,7 +439,7 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS,
b312fc
 		HAS_INTEGRATED_BUTTON,
b312fc
 		0x84, sizeof(struct bt_data),
b312fc
-		0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
b312fc
+		0x81, DATAFORMAT(TYPE2),
b312fc
 		{ SN_PRESSURE, 0, 300 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4620, 5140 },
b312fc
@@ -391,7 +452,7 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING7_JIS,
b312fc
 		HAS_INTEGRATED_BUTTON,
b312fc
 		0x84, sizeof(struct bt_data),
b312fc
-		0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
b312fc
+		0x81, DATAFORMAT(TYPE2),
b312fc
 		{ SN_PRESSURE, 0, 300 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4750, 5280 },
b312fc
@@ -404,7 +465,7 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS,
b312fc
 		HAS_INTEGRATED_BUTTON,
b312fc
 		0x84, sizeof(struct bt_data),
b312fc
-		0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
b312fc
+		0x81, DATAFORMAT(TYPE2),
b312fc
 		{ SN_PRESSURE, 0, 300 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4750, 5280 },
b312fc
@@ -417,13 +478,26 @@ static const struct bcm5974_config bcm59
b312fc
 		USB_DEVICE_ID_APPLE_WELLSPRING8_JIS,
b312fc
 		HAS_INTEGRATED_BUTTON,
b312fc
 		0, sizeof(struct bt_data),
b312fc
-		0x83, TYPE3, FINGER_TYPE3, FINGER_TYPE3 + SIZEOF_ALL_FINGERS,
b312fc
+		0x83, DATAFORMAT(TYPE3),
b312fc
 		{ SN_PRESSURE, 0, 300 },
b312fc
 		{ SN_WIDTH, 0, 2048 },
b312fc
 		{ SN_COORD, -4620, 5140 },
b312fc
 		{ SN_COORD, -150, 6600 },
b312fc
 		{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
b312fc
 	},
b312fc
+	{
b312fc
+		USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI,
b312fc
+		USB_DEVICE_ID_APPLE_WELLSPRING9_ISO,
b312fc
+		USB_DEVICE_ID_APPLE_WELLSPRING9_JIS,
b312fc
+		HAS_INTEGRATED_BUTTON,
b312fc
+		0, sizeof(struct bt_data),
b312fc
+		0x83, DATAFORMAT(TYPE4),
b312fc
+		{ SN_PRESSURE, 0, 300 },
b312fc
+		{ SN_WIDTH, 0, 2048 },
b312fc
+		{ SN_COORD, -4828, 5345 },
b312fc
+		{ SN_COORD, -203, 6803 },
b312fc
+		{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
b312fc
+	},
b312fc
 	{}
b312fc
 };
b312fc
 
b312fc
@@ -550,19 +624,18 @@ static int report_tp_state(struct bcm597
b312fc
 	struct input_dev *input = dev->input;
b312fc
 	int raw_n, i, n = 0;
b312fc
 
b312fc
-	if (size < c->tp_offset || (size - c->tp_offset) % SIZEOF_FINGER != 0)
b312fc
+	if (size < c->tp_header || (size - c->tp_header) % c->tp_fsize != 0)
b312fc
 		return -EIO;
b312fc
 
b312fc
-	/* finger data, le16-aligned */
b312fc
-	f = (const struct tp_finger *)(dev->tp_data + c->tp_offset);
b312fc
-	raw_n = (size - c->tp_offset) / SIZEOF_FINGER;
b312fc
+	raw_n = (size - c->tp_header) / c->tp_fsize;
b312fc
 
b312fc
 	for (i = 0; i < raw_n; i++) {
b312fc
-		if (raw2int(f[i].touch_major) == 0)
b312fc
+		f = get_tp_finger(dev, i);
b312fc
+		if (raw2int(f->touch_major) == 0)
b312fc
 			continue;
b312fc
-		dev->pos[n].x = raw2int(f[i].abs_x);
b312fc
-		dev->pos[n].y = c->y.min + c->y.max - raw2int(f[i].abs_y);
b312fc
-		dev->index[n++] = &f[i];
b312fc
+		dev->pos[n].x = raw2int(f->abs_x);
b312fc
+		dev->pos[n].y = c->y.min + c->y.max - raw2int(f->abs_y);
b312fc
+		dev->index[n++] = f;
b312fc
 	}
b312fc
 
b312fc
 	input_mt_assign_slots(input, dev->slots, dev->pos, n);
b312fc
@@ -573,32 +646,22 @@ static int report_tp_state(struct bcm597
b312fc
 
b312fc
 	input_mt_sync_frame(input);
b312fc
 
b312fc
-	report_synaptics_data(input, c, f, raw_n);
b312fc
+	report_synaptics_data(input, c, get_tp_finger(dev, 0), raw_n);
b312fc
 
b312fc
-	/* type 2 reports button events via ibt only */
b312fc
-	if (c->tp_type == TYPE2) {
b312fc
-		int ibt = raw2int(dev->tp_data[BUTTON_TYPE2]);
b312fc
+	/* later types report button events via integrated button only */
b312fc
+	if (c->caps & HAS_INTEGRATED_BUTTON) {
b312fc
+		int ibt = raw2int(dev->tp_data[c->tp_button]);
b312fc
 		input_report_key(input, BTN_LEFT, ibt);
b312fc
 	}
b312fc
 
b312fc
-	if (c->tp_type == TYPE3)
b312fc
-		input_report_key(input, BTN_LEFT, dev->tp_data[BUTTON_TYPE3]);
b312fc
-
b312fc
 	input_sync(input);
b312fc
 
b312fc
 	return 0;
b312fc
 }
b312fc
 
b312fc
-/* Wellspring initialization constants */
b312fc
-#define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID		1
b312fc
-#define BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID	9
b312fc
-#define BCM5974_WELLSPRING_MODE_REQUEST_VALUE		0x300
b312fc
-#define BCM5974_WELLSPRING_MODE_REQUEST_INDEX		0
b312fc
-#define BCM5974_WELLSPRING_MODE_VENDOR_VALUE		0x01
b312fc
-#define BCM5974_WELLSPRING_MODE_NORMAL_VALUE		0x08
b312fc
-
b312fc
 static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on)
b312fc
 {
b312fc
+	const struct bcm5974_config *c = &dev->cfg;
b312fc
 	int retval = 0, size;
b312fc
 	char *data;
b312fc
 
b312fc
@@ -606,7 +669,7 @@ static int bcm5974_wellspring_mode(struc
b312fc
 	if (dev->cfg.tp_type == TYPE3)
b312fc
 		return 0;
b312fc
 
b312fc
-	data = kmalloc(8, GFP_KERNEL);
b312fc
+	data = kmalloc(c->um_size, GFP_KERNEL);
b312fc
 	if (!data) {
b312fc
 		dev_err(&dev->intf->dev, "out of memory\n");
b312fc
 		retval = -ENOMEM;
b312fc
@@ -617,28 +680,24 @@ static int bcm5974_wellspring_mode(struc
b312fc
 	size = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
b312fc
 			BCM5974_WELLSPRING_MODE_READ_REQUEST_ID,
b312fc
 			USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
b312fc
-			BCM5974_WELLSPRING_MODE_REQUEST_VALUE,
b312fc
-			BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000);
b312fc
+			c->um_req_val, c->um_req_idx, data, c->um_size, 5000);
b312fc
 
b312fc
-	if (size != 8) {
b312fc
+	if (size != c->um_size) {
b312fc
 		dev_err(&dev->intf->dev, "could not read from device\n");
b312fc
 		retval = -EIO;
b312fc
 		goto out;
b312fc
 	}
b312fc
 
b312fc
 	/* apply the mode switch */
b312fc
-	data[0] = on ?
b312fc
-		BCM5974_WELLSPRING_MODE_VENDOR_VALUE :
b312fc
-		BCM5974_WELLSPRING_MODE_NORMAL_VALUE;
b312fc
+	data[c->um_switch_idx] = on ? c->um_switch_on : c->um_switch_off;
b312fc
 
b312fc
 	/* write configuration */
b312fc
 	size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
b312fc
 			BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID,
b312fc
 			USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
b312fc
-			BCM5974_WELLSPRING_MODE_REQUEST_VALUE,
b312fc
-			BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000);
b312fc
+			c->um_req_val, c->um_req_idx, data, c->um_size, 5000);
b312fc
 
b312fc
-	if (size != 8) {
b312fc
+	if (size != c->um_size) {
b312fc
 		dev_err(&dev->intf->dev, "could not write to device\n");
b312fc
 		retval = -EIO;
b312fc
 		goto out;
b312fc
--- a/drivers/input/mouse/synaptics.c	2016-01-23 00:53:07.000000000 -0800
b312fc
+++ b/drivers/input/mouse/synaptics.c	2016-03-08 13:50:00.835861449 -0800
b312fc
@@ -1724,12 +1724,12 @@ static int __synaptics_init(struct psmou
b312fc
 	priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;
b312fc
 
b312fc
 	psmouse_info(psmouse,
b312fc
-		     "Touchpad model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx, board id: %lu, fw id: %lu\n",
b312fc
+		     "Touchpad model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx/%#lx, board id: %lu, fw id: %lu\n",
b312fc
 		     SYN_ID_MODEL(priv->identity),
b312fc
 		     SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity),
b312fc
 		     priv->model_id,
b312fc
 		     priv->capabilities, priv->ext_cap, priv->ext_cap_0c,
b312fc
-		     priv->board_id, priv->firmware_id);
b312fc
+		     priv->ext_cap_10, priv->board_id, priv->firmware_id);
b312fc
 
b312fc
 	set_input_params(psmouse, priv);
b312fc