linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gerecke <killertofu@gmail.com>
To: jkosina@suse.cz, linux-input@vger.kernel.org
Cc: pinglinux@gmail.com, benjamin.tissoires@redhat.com,
	Jason Gerecke <killertofu@gmail.com>
Subject: [PATCH 6/7] HID: wacom: Status packet provides 'charging', not 'powered' bit
Date: Fri,  6 Mar 2015 11:47:36 -0800	[thread overview]
Message-ID: <1425671264-4944-6-git-send-email-killertofu@gmail.com> (raw)
In-Reply-To: <1425671264-4944-1-git-send-email-killertofu@gmail.com>

The status packet for tablets which can use a wireless module contains a
bit that is set if the battery is charging. This bit will be 0 if either
a battery is not present or if the battery has reached full charge. Note
that the charging circuit may continue to charge the battery for a short
time after reaching "100%".

Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
 drivers/hid/wacom_sys.c |  2 ++
 drivers/hid/wacom_wac.c | 14 +++++---------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index dfa4be7..955ce7c 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -977,6 +977,8 @@ static int wacom_battery_get_property(struct power_supply *psy,
 			else if (wacom->wacom_wac.battery_capacity == 100 &&
 				    wacom->wacom_wac.ps_connected)
 				val->intval = POWER_SUPPLY_STATUS_FULL;
+			else if (wacom->wacom_wac.ps_connected)
+				val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
 			else
 				val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
 			break;
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 726fedb..57faf5b 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -1917,7 +1917,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 
 	connected = data[1] & 0x01;
 	if (connected) {
-		int pid, battery, ps_connected, charging;
+		int pid, battery, charging;
 
 		if ((wacom->shared->type == INTUOSHT) &&
 		    wacom->shared->touch_input &&
@@ -1929,16 +1929,14 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 
 		pid = get_unaligned_be16(&data[6]);
 		battery = (data[5] & 0x3f) * 100 / 31;
-		ps_connected = !!(data[5] & 0x80);
-		charging = ps_connected && wacom->battery_capacity < 100;
+		charging = !!(data[5] & 0x80);
 		if (wacom->pid != pid) {
 			wacom->pid = pid;
 			wacom_schedule_work(wacom);
 		}
 
 		if (wacom->shared->type)
-			wacom_notify_battery(wacom, battery, charging,
-					     ps_connected);
+			wacom_notify_battery(wacom, battery, charging, 0);
 
 	} else if (wacom->pid != 0) {
 		/* disconnected while previously connected */
@@ -1969,12 +1967,10 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 
 	if (data[9] & 0x02) { /* wireless module is attached */
 		int battery = (data[8] & 0x3f) * 100 / 31;
-		bool ps_connected = !!(data[8] & 0x80);
-		bool charging = ps_connected &&
-				wacom_wac->battery_capacity < 100;
+		bool charging = !!(data[8] & 0x80);
 
 		wacom_notify_battery(wacom_wac, battery, charging,
-				     ps_connected);
+				     1);
 
 		if (!wacom->battery.dev &&
 		    !(features->quirks & WACOM_QUIRK_BATTERY)) {
-- 
2.3.0


  parent reply	other threads:[~2015-03-06 19:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
2015-03-06 19:47 ` [PATCH 2/7] HID: wacom: Centralize updating of wacom_wac battery status Jason Gerecke
2015-03-06 19:47 ` [PATCH 3/7] HID: wacom: Allow dynamic battery creation/destruction Jason Gerecke
2015-03-06 19:47 ` [PATCH 4/7] HID: wacom: Provide battery charge state to system over USB if available Jason Gerecke
2015-03-06 19:47 ` [PATCH 5/7] HID: wacom: Report battery status for Intuos Pro and Intuos5 Jason Gerecke
2015-03-06 19:47 ` Jason Gerecke [this message]
2015-03-06 19:47 ` [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets Jason Gerecke
2015-03-06 19:47 ` [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
2015-03-06 19:47 ` [PATCH 2/7] HID: wacom: Centralize updating of wacom_wac battery status Jason Gerecke
2015-03-06 19:47 ` [PATCH 3/7] HID: wacom: Allow dynamic battery creation/destruction Jason Gerecke
2015-03-06 19:47 ` [PATCH 4/7] HID: wacom: Provide battery charge state to system over USB if available Jason Gerecke
2015-03-06 19:47 ` [PATCH 5/7] HID: wacom: Report battery status for Intuos Pro and Intuos5 Jason Gerecke
2015-03-06 19:47 ` [PATCH 6/7] HID: wacom: Status packet provides 'charging', not 'powered' bit Jason Gerecke
2015-03-06 19:47 ` [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets Jason Gerecke
2015-03-11 15:50   ` Jiri Kosina
2015-03-11 17:25   ` [PATCH v2 " Jason Gerecke
2015-03-11 17:53     ` Jiri Kosina
2015-03-10  1:31 ` [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Ping Cheng
2015-03-10 16:22   ` Jason Gerecke
2015-03-11 15:49     ` Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425671264-4944-6-git-send-email-killertofu@gmail.com \
    --to=killertofu@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=pinglinux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).