From patchwork Fri Mar 6 19:47:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 5957681 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 689D6BF440 for ; Fri, 6 Mar 2015 19:48:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EAAC52034E for ; Fri, 6 Mar 2015 19:48:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6995820263 for ; Fri, 6 Mar 2015 19:48:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755916AbbCFTsS (ORCPT ); Fri, 6 Mar 2015 14:48:18 -0500 Received: from mail-pd0-f170.google.com ([209.85.192.170]:38068 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756104AbbCFTsR (ORCPT ); Fri, 6 Mar 2015 14:48:17 -0500 Received: by pdbfl12 with SMTP id fl12so46297246pdb.5 for ; Fri, 06 Mar 2015 11:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+W9Cc5F7BMz4N4oBAEGQgNlwlqRHGnd3OVgWn/SGwqg=; b=wMNq1wtaRS9/IH7ZChuPLe5w777efC0FleBisAJX3ARP4KUSgXGd6LfoV4vq5mqFUH sfp/WvK8CujWqgf1YFRINxYJOojX9aYCDK6IhtIidaPlrW+OqMyH5oxGtuNvwnoIibKB tL4BVUJU8fna+g/wL5Dc4Lsv+5Qe1Cke3faTzTaG3AdaJPIbmrPQxRzAGxX0DwQaB47G pWbhYksZux08VgqWSprr5mW76XdWdwwZcTR3XrYsbkaYi96pxmulz0Btu50JmxF37tHs Fi13eC6EG4S12JVBB53Y95/JHA3i4FQqfChVTzIY8HUVEQAkxJnHT0Z9owLAHZVbMtl2 zlDA== X-Received: by 10.68.244.2 with SMTP id xc2mr28148974pbc.45.1425671296981; Fri, 06 Mar 2015 11:48:16 -0800 (PST) Received: from wacom-arch2.localdomain ([67.51.163.2]) by mx.google.com with ESMTPSA id gf2sm2367452pbc.60.2015.03.06.11.48.13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Mar 2015 11:48:14 -0800 (PST) From: Jason Gerecke To: jkosina@suse.cz, linux-input@vger.kernel.org Cc: pinglinux@gmail.com, benjamin.tissoires@redhat.com, Jason Gerecke Subject: [PATCH 6/7] HID: wacom: Status packet provides 'charging', not 'powered' bit Date: Fri, 6 Mar 2015 11:47:43 -0800 Message-Id: <1425671264-4944-13-git-send-email-killertofu@gmail.com> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1425671264-4944-1-git-send-email-killertofu@gmail.com> References: <1425671264-4944-1-git-send-email-killertofu@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/hid/wacom_sys.c | 2 ++ drivers/hid/wacom_wac.c | 14 +++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index dfa4be7..955ce7c 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -977,6 +977,8 @@ static int wacom_battery_get_property(struct power_supply *psy, else if (wacom->wacom_wac.battery_capacity == 100 && wacom->wacom_wac.ps_connected) val->intval = POWER_SUPPLY_STATUS_FULL; + else if (wacom->wacom_wac.ps_connected) + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; else val->intval = POWER_SUPPLY_STATUS_DISCHARGING; break; diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 726fedb..57faf5b 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) connected = data[1] & 0x01; if (connected) { - int pid, battery, ps_connected, charging; + int pid, battery, charging; if ((wacom->shared->type == INTUOSHT) && 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]); battery = (data[5] & 0x3f) * 100 / 31; - ps_connected = !!(data[5] & 0x80); - charging = ps_connected && wacom->battery_capacity < 100; + charging = !!(data[5] & 0x80); if (wacom->pid != pid) { wacom->pid = pid; wacom_schedule_work(wacom); } if (wacom->shared->type) - wacom_notify_battery(wacom, battery, charging, - ps_connected); + wacom_notify_battery(wacom, battery, charging, 0); } else if (wacom->pid != 0) { /* 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 */ int battery = (data[8] & 0x3f) * 100 / 31; - bool ps_connected = !!(data[8] & 0x80); - bool charging = ps_connected && - wacom_wac->battery_capacity < 100; + bool charging = !!(data[8] & 0x80); wacom_notify_battery(wacom_wac, battery, charging, - ps_connected); + 1); if (!wacom->battery.dev && !(features->quirks & WACOM_QUIRK_BATTERY)) {