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>
This commit is contained in:
parent
2d13a43813
commit
b0882cb79d
|
@ -977,6 +977,8 @@ static int wacom_battery_get_property(struct power_supply *psy,
|
||||||
else if (wacom->wacom_wac.battery_capacity == 100 &&
|
else if (wacom->wacom_wac.battery_capacity == 100 &&
|
||||||
wacom->wacom_wac.ps_connected)
|
wacom->wacom_wac.ps_connected)
|
||||||
val->intval = POWER_SUPPLY_STATUS_FULL;
|
val->intval = POWER_SUPPLY_STATUS_FULL;
|
||||||
|
else if (wacom->wacom_wac.ps_connected)
|
||||||
|
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
|
||||||
else
|
else
|
||||||
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
|
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1917,7 +1917,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
|
||||||
|
|
||||||
connected = data[1] & 0x01;
|
connected = data[1] & 0x01;
|
||||||
if (connected) {
|
if (connected) {
|
||||||
int pid, battery, ps_connected, charging;
|
int pid, battery, charging;
|
||||||
|
|
||||||
if ((wacom->shared->type == INTUOSHT) &&
|
if ((wacom->shared->type == INTUOSHT) &&
|
||||||
wacom->shared->touch_input &&
|
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]);
|
pid = get_unaligned_be16(&data[6]);
|
||||||
battery = (data[5] & 0x3f) * 100 / 31;
|
battery = (data[5] & 0x3f) * 100 / 31;
|
||||||
ps_connected = !!(data[5] & 0x80);
|
charging = !!(data[5] & 0x80);
|
||||||
charging = ps_connected && wacom->battery_capacity < 100;
|
|
||||||
if (wacom->pid != pid) {
|
if (wacom->pid != pid) {
|
||||||
wacom->pid = pid;
|
wacom->pid = pid;
|
||||||
wacom_schedule_work(wacom);
|
wacom_schedule_work(wacom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wacom->shared->type)
|
if (wacom->shared->type)
|
||||||
wacom_notify_battery(wacom, battery, charging,
|
wacom_notify_battery(wacom, battery, charging, 0);
|
||||||
ps_connected);
|
|
||||||
|
|
||||||
} else if (wacom->pid != 0) {
|
} else if (wacom->pid != 0) {
|
||||||
/* disconnected while previously connected */
|
/* 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 */
|
if (data[9] & 0x02) { /* wireless module is attached */
|
||||||
int battery = (data[8] & 0x3f) * 100 / 31;
|
int battery = (data[8] & 0x3f) * 100 / 31;
|
||||||
bool ps_connected = !!(data[8] & 0x80);
|
bool charging = !!(data[8] & 0x80);
|
||||||
bool charging = ps_connected &&
|
|
||||||
wacom_wac->battery_capacity < 100;
|
|
||||||
|
|
||||||
wacom_notify_battery(wacom_wac, battery, charging,
|
wacom_notify_battery(wacom_wac, battery, charging,
|
||||||
ps_connected);
|
1);
|
||||||
|
|
||||||
if (!wacom->battery.dev &&
|
if (!wacom->battery.dev &&
|
||||||
!(features->quirks & WACOM_QUIRK_BATTERY)) {
|
!(features->quirks & WACOM_QUIRK_BATTERY)) {
|
||||||
|
|
Loading…
Reference in New Issue