From patchwork Sat Jun 29 09:57:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UHJ6ZW15c8OF4oCaYXcgRmlyc3p0?= X-Patchwork-Id: 2803361 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2531BBF4A1 for ; Sat, 29 Jun 2013 10:17:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 263E8200FE for ; Sat, 29 Jun 2013 10:17:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E108D200FA for ; Sat, 29 Jun 2013 10:17:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752667Ab3F2KRg (ORCPT ); Sat, 29 Jun 2013 06:17:36 -0400 Received: from wren.arvixe.com ([50.97.138.117]:34950 "EHLO wren.arvixe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751940Ab3F2KRf (ORCPT ); Sat, 29 Jun 2013 06:17:35 -0400 X-Greylist: delayed 1178 seconds by postgrey-1.27 at vger.kernel.org; Sat, 29 Jun 2013 06:17:35 EDT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=firszt.eu; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=p8h7oZDoFlDchHfNNptWp8sD3VW1CFomGEvXZK4a5sg=; b=ONGUlpzPnB7LwYiYxh0LD6ZMRKq0BGc605Q9o+9LYB/Vw2dV5IDB3hGshUHPb7gGlLavOcW7KPQ1PJHXNxVTfJN2vE3d8IZ/xHtw2SLM3nuXYnc8tJuMSWRJZxDPRbI1; Received: from [79.97.117.59] (port=54748 helo=localhost.localdomain) by wren.arvixe.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.80.1) (envelope-from ) id 1Usruk-0002QY-5w; Sat, 29 Jun 2013 02:57:54 -0700 From: Przemo Firszt To: jkosina@suse.cz, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pinglinux@gmail.com, Przemo Firszt Subject: [PATCH] hid: wacom: Intuos4 battery charging changes Date: Sat, 29 Jun 2013 10:57:13 +0100 Message-Id: <1372499833-7814-1-git-send-email-przemo@firszt.eu> X-Mailer: git-send-email 1.8.1.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - wren.arvixe.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - firszt.eu X-Get-Message-Sender-Via: wren.arvixe.com: authenticated_id: przemo@firszt.eu Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 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 --- drivers/hid/hid-wacom.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index a4a8bb0..60c75dc 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c @@ -46,6 +46,7 @@ struct wacom_data { __u8 battery_capacity; __u8 power_raw; __u8 ps_connected; + __u8 bat_charging; struct power_supply battery; struct power_supply ac; __u8 led_selector; @@ -62,6 +63,7 @@ static enum power_supply_property wacom_battery_props[] = { POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_SCOPE, + POWER_SUPPLY_PROP_STATUS, }; static enum power_supply_property wacom_ac_props[] = { @@ -287,6 +289,15 @@ static int wacom_battery_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CAPACITY: val->intval = wdata->battery_capacity; break; + case POWER_SUPPLY_PROP_STATUS: + if (wdata->bat_charging) + val->intval = POWER_SUPPLY_STATUS_CHARGING; + else + if (wdata->battery_capacity == 100 && wdata->ps_connected) + val->intval = POWER_SUPPLY_STATUS_FULL; + else + val->intval = POWER_SUPPLY_STATUS_DISCHARGING; + break; default: ret = -EINVAL; break; @@ -727,7 +738,8 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, if (power_raw != wdata->power_raw) { wdata->power_raw = power_raw; wdata->battery_capacity = batcap_i4[power_raw & 0x07]; - wdata->ps_connected = power_raw & 0x08; + wdata->bat_charging = (power_raw & 0x08) ? 1 : 0; + wdata->ps_connected = (power_raw & 0x10) ? 1 : 0; } break;