aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrzemo Firszt <przemo@firszt.eu>2013-06-29 05:57:13 -0400
committerJiri Kosina <jkosina@suse.cz>2013-07-04 09:04:47 -0400
commit9d157624035214793c6d06b0512c6ab1a7b39e05 (patch)
tree1c697f35a68399d19a473696fe1d47407897775e
parent26e04462c8b78d079d3231396ec72d58a14f114b (diff)
HID: wacom: Intuos4 battery charging changes
Intuos4 WL is separately reporting power supply and battery charging status - now hid-wacom is using that information. Previously hid-wacom was wrongly treating "battery charging" bit as "power supply connected". Now it should report battery charging, battery discharging, battery full and power supply status. Intuos4 WL sends reports when is in use (obvious) and when unplugging power supply. If means that if the device is being charged, but it's not being used it will never report "battery full". The same problem happens after the device has been connected, but it's not in use - the battery/ac status will be incorrect. Currently there is no mechanism to ask the device to send a report containing battery/ac status. Signed-off-by: Przemo Firszt <przemo@firszt.eu> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-wacom.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index a4a8bb0da688..60c75dcbbdb8 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -46,6 +46,7 @@ struct wacom_data {
46 __u8 battery_capacity; 46 __u8 battery_capacity;
47 __u8 power_raw; 47 __u8 power_raw;
48 __u8 ps_connected; 48 __u8 ps_connected;
49 __u8 bat_charging;
49 struct power_supply battery; 50 struct power_supply battery;
50 struct power_supply ac; 51 struct power_supply ac;
51 __u8 led_selector; 52 __u8 led_selector;
@@ -62,6 +63,7 @@ static enum power_supply_property wacom_battery_props[] = {
62 POWER_SUPPLY_PROP_PRESENT, 63 POWER_SUPPLY_PROP_PRESENT,
63 POWER_SUPPLY_PROP_CAPACITY, 64 POWER_SUPPLY_PROP_CAPACITY,
64 POWER_SUPPLY_PROP_SCOPE, 65 POWER_SUPPLY_PROP_SCOPE,
66 POWER_SUPPLY_PROP_STATUS,
65}; 67};
66 68
67static enum power_supply_property wacom_ac_props[] = { 69static enum power_supply_property wacom_ac_props[] = {
@@ -287,6 +289,15 @@ static int wacom_battery_get_property(struct power_supply *psy,
287 case POWER_SUPPLY_PROP_CAPACITY: 289 case POWER_SUPPLY_PROP_CAPACITY:
288 val->intval = wdata->battery_capacity; 290 val->intval = wdata->battery_capacity;
289 break; 291 break;
292 case POWER_SUPPLY_PROP_STATUS:
293 if (wdata->bat_charging)
294 val->intval = POWER_SUPPLY_STATUS_CHARGING;
295 else
296 if (wdata->battery_capacity == 100 && wdata->ps_connected)
297 val->intval = POWER_SUPPLY_STATUS_FULL;
298 else
299 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
300 break;
290 default: 301 default:
291 ret = -EINVAL; 302 ret = -EINVAL;
292 break; 303 break;
@@ -727,7 +738,8 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
727 if (power_raw != wdata->power_raw) { 738 if (power_raw != wdata->power_raw) {
728 wdata->power_raw = power_raw; 739 wdata->power_raw = power_raw;
729 wdata->battery_capacity = batcap_i4[power_raw & 0x07]; 740 wdata->battery_capacity = batcap_i4[power_raw & 0x07];
730 wdata->ps_connected = power_raw & 0x08; 741 wdata->bat_charging = (power_raw & 0x08) ? 1 : 0;
742 wdata->ps_connected = (power_raw & 0x10) ? 1 : 0;
731 } 743 }
732 744
733 break; 745 break;