diff options
author | Jason Gerecke <killertofu@gmail.com> | 2015-03-06 14:47:43 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2015-03-11 11:46:13 -0400 |
commit | b0882cb79dbd2bbdfac1416f8474aa6b0adb9334 (patch) | |
tree | 2c1b06e9549ae352a2b4925375383545dfdf7307 /drivers/hid/wacom_wac.c | |
parent | 2d13a43813729850572606a653f06c9e567e4c8d (diff) |
HID: wacom: Status packet provides 'charging', not 'powered' bit
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>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/wacom_wac.c')
-rw-r--r-- | drivers/hid/wacom_wac.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 726fedb87a16..57faf5b68b3d 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) | |||
1917 | 1917 | ||
1918 | connected = data[1] & 0x01; | 1918 | connected = data[1] & 0x01; |
1919 | if (connected) { | 1919 | if (connected) { |
1920 | int pid, battery, ps_connected, charging; | 1920 | int pid, battery, charging; |
1921 | 1921 | ||
1922 | if ((wacom->shared->type == INTUOSHT) && | 1922 | if ((wacom->shared->type == INTUOSHT) && |
1923 | wacom->shared->touch_input && | 1923 | wacom->shared->touch_input && |
@@ -1929,16 +1929,14 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len) | |||
1929 | 1929 | ||
1930 | pid = get_unaligned_be16(&data[6]); | 1930 | pid = get_unaligned_be16(&data[6]); |
1931 | battery = (data[5] & 0x3f) * 100 / 31; | 1931 | battery = (data[5] & 0x3f) * 100 / 31; |
1932 | ps_connected = !!(data[5] & 0x80); | 1932 | charging = !!(data[5] & 0x80); |
1933 | charging = ps_connected && wacom->battery_capacity < 100; | ||
1934 | if (wacom->pid != pid) { | 1933 | if (wacom->pid != pid) { |
1935 | wacom->pid = pid; | 1934 | wacom->pid = pid; |
1936 | wacom_schedule_work(wacom); | 1935 | wacom_schedule_work(wacom); |
1937 | } | 1936 | } |
1938 | 1937 | ||
1939 | if (wacom->shared->type) | 1938 | if (wacom->shared->type) |
1940 | wacom_notify_battery(wacom, battery, charging, | 1939 | wacom_notify_battery(wacom, battery, charging, 0); |
1941 | ps_connected); | ||
1942 | 1940 | ||
1943 | } else if (wacom->pid != 0) { | 1941 | } else if (wacom->pid != 0) { |
1944 | /* disconnected while previously connected */ | 1942 | /* disconnected while previously connected */ |
@@ -1969,12 +1967,10 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len) | |||
1969 | 1967 | ||
1970 | if (data[9] & 0x02) { /* wireless module is attached */ | 1968 | if (data[9] & 0x02) { /* wireless module is attached */ |
1971 | int battery = (data[8] & 0x3f) * 100 / 31; | 1969 | int battery = (data[8] & 0x3f) * 100 / 31; |
1972 | bool ps_connected = !!(data[8] & 0x80); | 1970 | bool charging = !!(data[8] & 0x80); |
1973 | bool charging = ps_connected && | ||
1974 | wacom_wac->battery_capacity < 100; | ||
1975 | 1971 | ||
1976 | wacom_notify_battery(wacom_wac, battery, charging, | 1972 | wacom_notify_battery(wacom_wac, battery, charging, |
1977 | ps_connected); | 1973 | 1); |
1978 | 1974 | ||
1979 | if (!wacom->battery.dev && | 1975 | if (!wacom->battery.dev && |
1980 | !(features->quirks & WACOM_QUIRK_BATTERY)) { | 1976 | !(features->quirks & WACOM_QUIRK_BATTERY)) { |