blob: d033ad6fd872d036a1f27378eefbe3bef6960249 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.hardware.power;
using zx;
type PowerType = strict enum : uint8 {
AC = 0;
BATTERY = 1;
};
const POWER_STATE_ONLINE uint8 = 0x1;
const POWER_STATE_DISCHARGING uint8 = 0x2;
const POWER_STATE_CHARGING uint8 = 0x4;
const POWER_STATE_CRITICAL uint8 = 0x8;
type SourceInfo = struct {
type PowerType;
state uint8;
};
type BatteryUnit = strict enum {
/// Milliwatts
MW = 0;
/// Milliamps
MA = 1;
};
type BatteryInfo = struct {
/// capacity unit. all voltage fields are in millivolts
unit BatteryUnit;
/// nominal capacity of a new battery
design_capacity uint32;
/// predicted battery capacity when fully charged
last_full_capacity uint32;
/// nominal voltage of a new battery
design_voltage uint32;
/// capacity when the device will generate a warning notification
capacity_warning uint32;
/// capacity when the device will generate a low battery notification
capacity_low uint32;
/// the smallest increment the battery is capable of measuring between the
/// low and warning capacities
capacity_granularity_low_warning uint32;
/// the smallest increment the battery is capable of measuring between the low
/// and warning capacities
capacity_granularity_warning_full uint32;
/// below fields are in units specified the `unit` field.
/// charging/discharging rate in the capacity unit. positive is charging,
/// negative is discharging
present_rate int32;
remaining_capacity uint32;
present_voltage uint32;
};
protocol Source {
/// Get device info.
GetPowerInfo() -> (struct {
status zx.status;
info SourceInfo;
});
/// Get an event to receive state change notifications on. ZX_USER_SIGNAL_0 is
/// asserted when power_info_t.state is changed. It is deasserted when the
/// state is read via `GetPowerInfo`.
GetStateChangeEvent() -> (resource struct {
status zx.status;
handle zx.handle:<EVENT, zx.rights.WAIT>;
});
/// Get battery info. Only supported if type == PowerType::BATTERY.
GetBatteryInfo() -> (struct {
status zx.status;
info BatteryInfo;
});
};