]> git.karo-electronics.de Git - linux-beck.git/commitdiff
HID: sony: Correct Sixaxis battery reporting
authorFrank Praznik <frank.praznik@oh.rr.com>
Sat, 15 Feb 2014 18:35:42 +0000 (13:35 -0500)
committerJiri Kosina <jkosina@suse.cz>
Mon, 17 Feb 2014 22:17:36 +0000 (23:17 +0100)
The battery_charging and cable_state flags were backwards on the Sixaxis.
The low bit of report byte 30 is 0 when charging and 1 when not.
Bit 5 of byte 31 is 0 when a USB cable is connected and 1 when not.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-sony.c

index 947d2088a70045e0dd322b1975284e78ad68d6ab..0111d3028c4ba41b91503aadd593be2ff4213f04 100644 (file)
@@ -845,12 +845,12 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
         */
        if (rd[30] >= 0xee) {
                battery_capacity = 100;
-               battery_charging = rd[30] & 0x01;
+               battery_charging = !(rd[30] & 0x01);
        } else {
                battery_capacity = sixaxis_battery_capacity[rd[30]];
                battery_charging = 0;
        }
-       cable_state = (rd[31] >> 4) & 0x01;
+       cable_state = !((rd[31] >> 4) & 0x01);
 
        spin_lock_irqsave(&sc->lock, flags);
        sc->cable_state = cable_state;