aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Wood <simon@mungewell.org>2015-06-09 23:27:05 -0400
committerJiri Kosina <jkosina@suse.cz>2015-06-12 05:37:41 -0400
commit12e9a6d72b3ac33e542b6001ccd891d7b41fff10 (patch)
treefa5019c1656b90d567e425c3ac3ae56e6ecacbad
parentb3bca326fa813e4770f74f9ceffe97b72e281475 (diff)
HID: sony: Add support PS3 Move Battery via BT
Add support for the battery charge level and state to be read via BT. This is not support via USB as there is no know way to get the device sending 'input' reports over USB. Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-sony.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 28dba6c4c273..d9fa804770fe 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -55,7 +55,8 @@
55 DUALSHOCK4_CONTROLLER_BT) 55 DUALSHOCK4_CONTROLLER_BT)
56#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\ 56#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\
57 DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER) 57 DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER)
58#define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER) 58#define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\
59 MOTION_CONTROLLER_BT)
59#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\ 60#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\
60 MOTION_CONTROLLER) 61 MOTION_CONTROLLER)
61 62
@@ -1041,6 +1042,7 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
1041{ 1042{
1042 static const __u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 }; 1043 static const __u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 };
1043 unsigned long flags; 1044 unsigned long flags;
1045 int offset;
1044 __u8 cable_state, battery_capacity, battery_charging; 1046 __u8 cable_state, battery_capacity, battery_charging;
1045 1047
1046 /* 1048 /*
@@ -1049,12 +1051,14 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
1049 * It does not report the actual level while charging so it 1051 * It does not report the actual level while charging so it
1050 * is set to 100% while charging is in progress. 1052 * is set to 100% while charging is in progress.
1051 */ 1053 */
1052 if (rd[30] >= 0xee) { 1054 offset = (sc->quirks & MOTION_CONTROLLER) ? 12 : 30;
1055
1056 if (rd[offset] >= 0xee) {
1053 battery_capacity = 100; 1057 battery_capacity = 100;
1054 battery_charging = !(rd[30] & 0x01); 1058 battery_charging = !(rd[offset] & 0x01);
1055 cable_state = 1; 1059 cable_state = 1;
1056 } else { 1060 } else {
1057 __u8 index = rd[30] <= 5 ? rd[30] : 5; 1061 __u8 index = rd[offset] <= 5 ? rd[offset] : 5;
1058 battery_capacity = sixaxis_battery_capacity[index]; 1062 battery_capacity = sixaxis_battery_capacity[index];
1059 battery_charging = 0; 1063 battery_charging = 0;
1060 cable_state = 0; 1064 cable_state = 0;
@@ -1155,6 +1159,8 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
1155 swap(rd[47], rd[48]); 1159 swap(rd[47], rd[48]);
1156 1160
1157 sixaxis_parse_report(sc, rd, size); 1161 sixaxis_parse_report(sc, rd, size);
1162 } else if ((sc->quirks & MOTION_CONTROLLER_BT) && rd[0] == 0x01 && size == 49) {
1163 sixaxis_parse_report(sc, rd, size);
1158 } else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 && 1164 } else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 &&
1159 size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) 1165 size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT)
1160 && rd[0] == 0x11 && size == 78)) { 1166 && rd[0] == 0x11 && size == 78)) {
@@ -1976,6 +1982,7 @@ static int sony_check_add(struct sony_sc *sc)
1976 int n, ret; 1982 int n, ret;
1977 1983
1978 if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) || 1984 if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) ||
1985 (sc->quirks & MOTION_CONTROLLER_BT) ||
1979 (sc->quirks & SIXAXIS_CONTROLLER_BT)) { 1986 (sc->quirks & SIXAXIS_CONTROLLER_BT)) {
1980 /* 1987 /*
1981 * sony_get_bt_devaddr() attempts to parse the Bluetooth MAC 1988 * sony_get_bt_devaddr() attempts to parse the Bluetooth MAC