All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] HID: sony: Correct Sixaxis battery reporting
@ 2014-02-15 18:35 Frank Praznik
  2014-02-17 22:18 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Praznik @ 2014-02-15 18:35 UTC (permalink / raw)
  To: linux-input; +Cc: jkosina, 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.

Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
---
 drivers/hid/hid-sony.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 8eac6a6..283b2a3 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -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;
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] HID: sony: Correct Sixaxis battery reporting
  2014-02-15 18:35 [PATCH] HID: sony: Correct Sixaxis battery reporting Frank Praznik
@ 2014-02-17 22:18 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2014-02-17 22:18 UTC (permalink / raw)
  To: Frank Praznik; +Cc: linux-input

On Sat, 15 Feb 2014, Frank Praznik wrote:

> 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>

Applied, thanks Frank.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-17 22:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-15 18:35 [PATCH] HID: sony: Correct Sixaxis battery reporting Frank Praznik
2014-02-17 22:18 ` Jiri Kosina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.