Skip to contentSkip to conversation

HID: sony: Correct Sixaxis battery reporting

PATCH Applied Frank Praznik 2 participants 2 messages Feb 15, 2014 – Feb 17, 2014 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: sony: Correct Sixaxis battery reporting

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.

---
 drivers/hid/hid-sony.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/hid-sony.c +2 -2
index 8eac6a6..283b2a3 100644
@@ -850,12 +850,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;
Signature · 1 line
1.8.5.3
Applied
#1 lore raw
Quoted 5 lines · Frank Praznik

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.

Applied, thanks Frank.

Signature · 2 lines
Jiri Kosina
SUSE Labs