From: Przemo Firszt <przemo@firszt.eu>
To: jkosina@suse.cz
Cc: pinglinux@gmail.com, chris@cnpbagwell.com,
linuxwacom-devel@lists.sourceforge.net,
linux-input@vger.kernel.org, Przemo Firszt <przemo@firszt.eu>
Subject: [PATCH 4/4] HID: wacom: Add battery/ac reporting for Intuos4 WL
Date: Thu, 22 Mar 2012 18:54:08 +0000 [thread overview]
Message-ID: <1332442448-10473-4-git-send-email-przemo@firszt.eu> (raw)
In-Reply-To: <1332442448-10473-1-git-send-email-przemo@firszt.eu>
This patch adds battery/ac reporting for Intuos4 WL. It uses existing
sysfs code, but the device reports battery capacity in more fine-grained way,
so there has to be a separate lookup table (called batcap_i4).
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
---
drivers/hid/hid-wacom.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index dafd240..fb0fe16 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -49,6 +49,8 @@ struct wacom_data {
/*percent of battery capacity for Graphire
8th value means AC online and show 100% capacity */
static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
+/*percent of battery capacity for Intuos4 WL, AC has a separate bit*/
+static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
static enum power_supply_property wacom_battery_props[] = {
POWER_SUPPLY_PROP_PRESENT,
@@ -447,6 +449,7 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
struct input_dev *input;
unsigned char *data = (unsigned char *) raw_data;
int i;
+ __u8 power_raw;
if (!(hdev->claimed & HID_CLAIMED_INPUT))
return 0;
@@ -474,6 +477,13 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
wacom_i4_parse_report(hdev, wdata, input, data + i);
i += 10;
wacom_i4_parse_report(hdev, wdata, input, data + i);
+ power_raw = data[i+10];
+ if (power_raw != wdata->power_raw) {
+ wdata->power_raw = power_raw;
+ wdata->battery_capacity = batcap_i4[power_raw & 0x07];
+ wdata->ps_connected = power_raw & 0x08;
+ }
+
break;
default:
hid_err(hdev, "Unknown report: %d,%d size:%d\n",
--
1.7.6.4
prev parent reply other threads:[~2012-03-22 18:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-22 18:54 [PATCH 1/4] HID: wacom: Remove CONFIG_HID_WACOM_POWER_SUPPLY option Przemo Firszt
2012-03-22 18:54 ` [PATCH 2/4] HID: wacom: Change HID_WACOM option description Przemo Firszt
2012-03-22 18:54 ` [PATCH 3/4] HID: wacom: Refactor battery/ac reporting for Graphire Przemo Firszt
2012-03-22 18:54 ` Przemo Firszt [this message]
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=1332442448-10473-4-git-send-email-przemo@firszt.eu \
--to=przemo@firszt.eu \
--cc=chris@cnpbagwell.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linuxwacom-devel@lists.sourceforge.net \
--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).