diff options
author | Greg Bellows <greg.bellows@linaro.org> | 2014-11-11 14:50:15 -0600 |
---|---|---|
committer | Greg Bellows <greg.bellows@linaro.org> | 2014-11-19 15:27:26 -0600 |
commit | 376194a7a48acfb030d1bbb72988569613fdfb40 (patch) | |
tree | 4a2736bed09c2c0bec644854900070e1d01e8718 /hw | |
parent | 3a4b799cf005f448de63d2cda76b3f33e6a3a8ab (diff) |
android-console: Add GF battery property getter
Add a function for acquiring each of the goldfish battery properties.
Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/misc/goldfish_battery.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/hw/misc/goldfish_battery.c b/hw/misc/goldfish_battery.c index 48da62647..2bc38202d 100644 --- a/hw/misc/goldfish_battery.c +++ b/hw/misc/goldfish_battery.c @@ -128,6 +128,48 @@ void goldfish_battery_display(Monitor *mon) monitor_printf(mon, "capacity: %d\n", s->capacity); } +void goldfish_battery_set_prop(int ac, int property, int value) +{ + DeviceState *dev = qdev_find_recursive(sysbus_get_default(), + TYPE_GOLDFISH_BATTERY); + struct goldfish_battery_state *battery_state = GOLDFISH_BATTERY(dev); + int new_status = (ac ? AC_STATUS_CHANGED : BATTERY_STATUS_CHANGED); + + if (!battery_state || !battery_state->hw_has_battery) { + return; + } + + if (ac) { + switch (property) { + case POWER_SUPPLY_PROP_ONLINE: + battery_state->ac_online = value; + break; + } + } else { + switch (property) { + case POWER_SUPPLY_PROP_STATUS: + battery_state->status = value; + break; + case POWER_SUPPLY_PROP_HEALTH: + battery_state->health = value; + break; + case POWER_SUPPLY_PROP_PRESENT: + battery_state->present = value; + break; + case POWER_SUPPLY_PROP_CAPACITY: + battery_state->capacity = value; + break; + } + } + + if (new_status != battery_state->int_status) { + battery_state->int_status |= new_status; + qemu_set_irq(battery_state->irq, + (battery_state->int_status & + battery_state->int_enable)); + } +} + static uint64_t goldfish_battery_read(void *opaque, hwaddr offset, unsigned size) { uint64_t ret; |