diff options
author | Jason Gerecke <killertofu@gmail.com> | 2015-03-06 14:47:41 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2015-03-11 11:46:12 -0400 |
commit | 8f93b0b2b0a336746adc8730921b219f0ba40c29 (patch) | |
tree | 290aaf611dce08c323e74da32e61770ba2465625 /drivers/hid/wacom_wac.c | |
parent | fce9957d8f618346b76c63066e146fc76ed975ce (diff) |
HID: wacom: Provide battery charge state to system over USB if available
If a wireless adapter (which contains the charging circuitry) is
detected as being attached to the tablet then create a new battery
interface and update its status as data is reported. Also destroy the
battery if the adapter goes away.
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 | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 5d57fec177a8..f1e53f15abb5 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c | |||
@@ -1952,6 +1952,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len) | |||
1952 | 1952 | ||
1953 | static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len) | 1953 | static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len) |
1954 | { | 1954 | { |
1955 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); | ||
1955 | struct wacom_features *features = &wacom_wac->features; | 1956 | struct wacom_features *features = &wacom_wac->features; |
1956 | unsigned char *data = wacom_wac->data; | 1957 | unsigned char *data = wacom_wac->data; |
1957 | 1958 | ||
@@ -1965,6 +1966,30 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len) | |||
1965 | SW_MUTE_DEVICE, data[8] & 0x40); | 1966 | SW_MUTE_DEVICE, data[8] & 0x40); |
1966 | input_sync(wacom_wac->shared->touch_input); | 1967 | input_sync(wacom_wac->shared->touch_input); |
1967 | } | 1968 | } |
1969 | |||
1970 | if (data[9] & 0x02) { /* wireless module is attached */ | ||
1971 | int battery = (data[8] & 0x3f) * 100 / 31; | ||
1972 | bool ps_connected = !!(data[8] & 0x80); | ||
1973 | bool charging = ps_connected && | ||
1974 | wacom_wac->battery_capacity < 100; | ||
1975 | |||
1976 | wacom_notify_battery(wacom_wac, battery, charging, | ||
1977 | ps_connected); | ||
1978 | |||
1979 | if (!wacom->battery.dev && | ||
1980 | !(features->quirks & WACOM_QUIRK_BATTERY)) { | ||
1981 | features->quirks |= WACOM_QUIRK_BATTERY; | ||
1982 | INIT_WORK(&wacom->work, wacom_battery_work); | ||
1983 | wacom_schedule_work(wacom_wac); | ||
1984 | } | ||
1985 | } | ||
1986 | else if ((features->quirks & WACOM_QUIRK_BATTERY) && | ||
1987 | wacom->battery.dev) { | ||
1988 | features->quirks &= ~WACOM_QUIRK_BATTERY; | ||
1989 | INIT_WORK(&wacom->work, wacom_battery_work); | ||
1990 | wacom_schedule_work(wacom_wac); | ||
1991 | wacom_notify_battery(wacom_wac, 0, 0, 0); | ||
1992 | } | ||
1968 | return 0; | 1993 | return 0; |
1969 | } | 1994 | } |
1970 | 1995 | ||