From patchwork Wed Nov 12 00:25:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 40624 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2D88C205DF for ; Wed, 12 Nov 2014 00:29:55 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id e51sf7436984eek.6 for ; Tue, 11 Nov 2014 16:29:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=jg5Z4TJ/S7lXlOGs7Etuh0E/XL2RgGdcp687xbNo4BM=; b=mjrbnBp4CYXl9RkkyVbjuUuo9DLSli2CmUXOjPW2c3pQno6yhiYElfRSzXmxZ2XVAu nH8N3+/ciIh/fuwPJsfbGX7wnNW+ckkbYzOli0o00t6YJp4Zaf9ALJN3qCf2bi4k9lGr Tt0IDY1C/SL96LDe2WJ5HGG8QIs0gqhHoJ3xuNQfqJGcXIL8cvqwnTBvo7L/uUzLQoYv 3nkx48SDH6elwHgJjnOcT0xlh0CpnxY2kaYXzsWNGZKlRvo91tc1hg5bDk4DVQKtzAfN YcdqNC9ShuGl55TqG2u7nC0VgLEhlK88SYFB1p3xczZuX3YyFUjwUdSCbx4unGPEG/r/ SLfw== X-Gm-Message-State: ALoCoQnPvkr/dmo2/yIKNrYQcbJOMDckQuRr5flg/8cfg4yd6wiFG46G2iidzF9qHWc7kyWI2mmD X-Received: by 10.180.89.7 with SMTP id bk7mr115029wib.6.1415752194427; Tue, 11 Nov 2014 16:29:54 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.46 with SMTP id u14ls601343laz.96.gmail; Tue, 11 Nov 2014 16:29:53 -0800 (PST) X-Received: by 10.112.63.133 with SMTP id g5mr37509429lbs.33.1415752193750; Tue, 11 Nov 2014 16:29:53 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id jm10si2667067lbc.89.2014.11.11.16.29.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 16:29:53 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id mc6so10256585lab.40 for ; Tue, 11 Nov 2014 16:29:53 -0800 (PST) X-Received: by 10.112.17.1 with SMTP id k1mr38452137lbd.39.1415752193646; Tue, 11 Nov 2014 16:29:53 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp347273lbc; Tue, 11 Nov 2014 16:29:52 -0800 (PST) X-Received: by 10.140.36.168 with SMTP id p37mr53613607qgp.101.1415752192152; Tue, 11 Nov 2014 16:29:52 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 31si39271556qgz.69.2014.11.11.16.29.51 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 11 Nov 2014 16:29:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:51560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLok-0007DX-UX for patch@linaro.org; Tue, 11 Nov 2014 19:29:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLlX-00024V-3G for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XoLlR-0000Ej-5S for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:31 -0500 Received: from mail-oi0-f48.google.com ([209.85.218.48]:61997) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLlQ-0000Dr-Vg for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:25 -0500 Received: by mail-oi0-f48.google.com with SMTP id x69so7836404oia.35 for ; Tue, 11 Nov 2014 16:26:24 -0800 (PST) X-Received: by 10.202.208.211 with SMTP id h202mr33603706oig.29.1415751984551; Tue, 11 Nov 2014 16:26:24 -0800 (PST) Received: from gbellows-linaro.bellowshome.net (99-179-1-128.lightspeed.austtx.sbcglobal.net. [99.179.1.128]) by mx.google.com with ESMTPSA id d3sm6239765obs.18.2014.11.11.16.26.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 16:26:24 -0800 (PST) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org, christoffer.dall@linaro.org, alex.bennee@linaro.org Date: Tue, 11 Nov 2014 18:25:57 -0600 Message-Id: <1415751963-4081-10-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1415751963-4081-1-git-send-email-greg.bellows@linaro.org> References: <1415751963-4081-1-git-send-email-greg.bellows@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.218.48 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH v1 09/15] android-console: Add GF battery prop print func X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: greg.bellows@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add a function for printing out the Goldfish battery properties to the android console. Signed-off-by: Greg Bellows --- hw/misc/goldfish_battery.c | 54 ++++++++++++++++++++++++++++++++++++++ include/hw/misc/goldfish_battery.h | 2 ++ 2 files changed, 56 insertions(+) -- 1.8.3.2 diff --git a/hw/misc/goldfish_battery.c b/hw/misc/goldfish_battery.c index c956eb2..c7c9d98 100644 --- a/hw/misc/goldfish_battery.c +++ b/hw/misc/goldfish_battery.c @@ -12,6 +12,7 @@ #include "hw/hw.h" #include "hw/sysbus.h" #include "qemu/error-report.h" +#include "monitor/monitor.h" #include "hw/misc/goldfish_battery.h" enum { @@ -74,6 +75,59 @@ static const VMStateDescription goldfish_battery_vmsd = { } }; +void goldfish_battery_display(Monitor *mon) +{ + DeviceState *dev = qdev_find_recursive(sysbus_get_default(), + TYPE_GOLDFISH_BATTERY); + struct goldfish_battery_state *s = GOLDFISH_BATTERY(dev); + const char *value; + + monitor_printf(mon, "AC: %s\n", (s->ac_online) ? "online" : "offline"); + + switch (s->status) { + case POWER_SUPPLY_STATUS_CHARGING: + value = "Charging"; + break; + case POWER_SUPPLY_STATUS_DISCHARGING: + value = "Discharging"; + break; + case POWER_SUPPLY_STATUS_NOT_CHARGING: + value = "Not charging"; + break; + case POWER_SUPPLY_STATUS_FULL: + value = "Full"; + break; + default: + value = "Unknown"; + } + monitor_printf(mon, "status: %s\n", value); + + switch (s->health) { + case POWER_SUPPLY_HEALTH_GOOD: + value = "Good"; + break; + case POWER_SUPPLY_HEALTH_OVERHEAT: + value = "Overhead"; + break; + case POWER_SUPPLY_HEALTH_DEAD: + value = "Dead"; + break; + case POWER_SUPPLY_HEALTH_OVERVOLTAGE: + value = "Overvoltage"; + break; + case POWER_SUPPLY_HEALTH_UNSPEC_FAILURE: + value = "Unspecified failure"; + break; + default: + value = "Unknown"; + } + monitor_printf(mon, "health: %s\n", value); + + monitor_printf(mon, "present: %s\n", (s->present) ? "true" : "false"); + + monitor_printf(mon, "capacity: %d\n", s->capacity); +} + static uint64_t goldfish_battery_read(void *opaque, hwaddr offset, unsigned size) { uint64_t ret; diff --git a/include/hw/misc/goldfish_battery.h b/include/hw/misc/goldfish_battery.h index 85a9f2f..f497538 100644 --- a/include/hw/misc/goldfish_battery.h +++ b/include/hw/misc/goldfish_battery.h @@ -68,4 +68,6 @@ enum power_supply_property { POWER_SUPPLY_PROP_MANUFACTURER, }; +extern void goldfish_battery_display(Monitor *mon); + #endif /* _HW_GOLDFISH_BATTERY_H */