aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Praznik <frank.praznik@oh.rr.com>2014-08-29 13:11:52 -0400
committerJiri Kosina <jkosina@suse.cz>2014-09-01 05:20:52 -0400
commit9fddd74a238f03c322b373662803bd1ce80338da (patch)
treecea0734b40c126147fcaf39e8ac995743ed19fc2
parentff0c57ac70434bc936cb0110eaf033a0a1a62e52 (diff)
HID: sony: Set the Sixaxis cable state correctly
Bit 3 in byte 31 of the Sixaxis report indicates whether the battery is charging or not charging as opposed to whether or not the cable is plugged in. As a result, when connected via USB and fully charged, the power_supply status is wrongly reported as 'Discharging' instead of 'Full'. Use the battery level value to set the cable state so that the power status is reported correctly as that seems to be the only reliable way to determine the cable status on the Sixaxis. Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-sony.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index c372368e438c..ecc6616ab550 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -935,12 +935,13 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
935 if (rd[30] >= 0xee) { 935 if (rd[30] >= 0xee) {
936 battery_capacity = 100; 936 battery_capacity = 100;
937 battery_charging = !(rd[30] & 0x01); 937 battery_charging = !(rd[30] & 0x01);
938 cable_state = 1;
938 } else { 939 } else {
939 __u8 index = rd[30] <= 5 ? rd[30] : 5; 940 __u8 index = rd[30] <= 5 ? rd[30] : 5;
940 battery_capacity = sixaxis_battery_capacity[index]; 941 battery_capacity = sixaxis_battery_capacity[index];
941 battery_charging = 0; 942 battery_charging = 0;
943 cable_state = 0;
942 } 944 }
943 cable_state = !(rd[31] & 0x04);
944 945
945 spin_lock_irqsave(&sc->lock, flags); 946 spin_lock_irqsave(&sc->lock, flags);
946 sc->cable_state = cable_state; 947 sc->cable_state = cable_state;