Namespaces
Enumerations
enum Error
| Name | Value |
|---|---|
| INVALID_ARGS | 0 |
| IO | 1 |
| DEPENDENCY_NOT_FOUND | 2 |
| TOKEN_SERVICE_CAPABILITY_NOT_FOUND | 3 |
| READ_INSTANCES | 4 |
| NO_TOKEN_SERVICE_INSTANCES | 5 |
| TOKEN_REQUEST | 6 |
| ACTIVITY_GOVERNOR_UNAVAILABLE | 7 |
| ACTIVITY_GOVERNOR_REQUEST | 8 |
| TOPOLOGY_UNAVAILABLE | 9 |
| CONFIGURATION_UNAVAILABLE | 10 |
| CPU_ELEMENT_MANAGER_UNAVAILABLE | 11 |
| CPU_ELEMENT_MANAGER_REQUEST | 12 |
Defined at line 32 of file ../../sdk/lib/driver/power/cpp/power-support.h
enum SagElement
| Name | Value |
|---|---|
| kExecutionState | 1 |
| kApplicationActivity | 4 |
NOTE: This is _not_ a complete list of SAG elements. This enum only lists the elements supported
by the power support library.
Defined at line 68 of file ../../sdk/lib/driver/power/cpp/types.h
enum CpuElement
| Name | Value |
|---|---|
| kCpu | 1 |
Defined at line 73 of file ../../sdk/lib/driver/power/cpp/types.h
Records
-
class BasicElementRunner -
class Completer -
class ElementDesc -
class ElementDescBuilder -
class LeaseDependency -
class LeaseHelper -
class LevelTuple -
class ManualWakeLease -
class ParentElement -
class PowerDependency -
class PowerElement -
class PowerElementConfiguration -
class PowerLevel -
class ResumeCompleter -
class SuspendCompleter -
class Suspendable -
class TimeoutWakeLease -
class Transition -
class WakeLease -
class WakeLeaseProvider
Functions
-
fit::result<zx_status_t, uint8_t> default_level_changer (uint8_t level)Defined at line 78 of file ../../sdk/lib/driver/power/cpp/power-support.h
-
zx::error<zx_status_t> ErrorToZxError (Error e)Convenience methods that provide an approximate mapping to Zircon error values.
Defined at line 257 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
zx::error<zx_status_t> LeaseErrorToZxError (fuchsia_power_broker::LeaseError e)Defined at line 313 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
zx::error<zx_status_t> AddElementErrorToZxError (fuchsia_power_broker::AddElementError e)Defined at line 326 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
const char * ErrorToString (Error e)Convenience methods for printing errors.
Defined at line 281 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
const char * LeaseErrorToString (fuchsia_power_broker::LeaseError e)Defined at line 337 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
const char * AddElementErrorToString (fuchsia_power_broker::AddElementError e)Defined at line 350 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
fit::result<Error, std::vector<ElementDesc>> ApplyPowerConfiguration (const fdf::Namespace & ns, cpp20::span<PowerElementConfiguration> power_configs, bool use_element_runner)Uses the provided namespace to add the power elements described in
|power_configs| to the power topology and returns corresponding
`ElementDesc` instances.
This function:
* Retrieves the tokens of any dependencies via
`fuchsia.hardware.power/PowerTokenProvider` instances
* Adds the power element via `fuchsia.power.broker/Topology`
In effect, this function converts the provided |power_configs| into their
corresponding `ElementDesc` objects and returns them.
Defined at line 679 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
fit::result<std::tuple<fidl::Status, std::optional<fuchsia_power_broker::AddElementError>>, std::unique_ptr<LeaseHelper>> CreateLeaseHelper (const fidl::ClientEnd<fuchsia_power_broker::Topology> & topology, std::vector<LeaseDependency> dependencies, std::string lease_name, async_dispatcher_t * dispatcher, fit::function<void ()> error_callback, inspect::Node * parent)Create a lease based on the set of dependencies represented by
|dependencies|. When the lease is fulfilled those dependencies will be at
the level specified. The lease is **not** active when this function returns,
use |LeaseHelper::AcquireLease| to trigger lease activation.
The |dispatcher| passed in is used to run a power element, so blocking
the dispatcher while acquiring a lease with |LeaseHelper::AcquireLease|
will result in a deadlock.
|error_callback| is **not** invoked if |LeaseHelper| creation fails,
instead it is called if the running the internal power element encounters
an error. If this error occurs, future lease acquisitions will likely fail
and the |LeaseHelper| should be replaced with a new instance.
RETURN VALUES
On error returns a tuple representing whether it was a FIDL error or a
protocol error. If the |fidl::Status| is not ZX_OK, this was a FIDL error,
and the second member of the tuple will be `nullopt`. Otherwise, this is a
protocol error from adding the power element that the direct lease wraps
and will be an error value from `fuchsia.power.broker/Topology.AddElement`.
On success returns a |LeaseHelper|.
Defined at line 623 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
fit::result<Error, ElementDependencyMap> LevelDependencyFromConfig (const PowerElementConfiguration & element_config)Given a `PowerElementConfiguration` from driver framework, convert this
into a set of Power Broker's `LevelDependency` objects. The map is keyed
by the name of the parent/dependency.
If the `PowerElementConfiguration` expresses no dependencies, we return an
empty map.
NOTE: The `requires_token` of each of the `LevelDependency` objects is
**not** populated and must be filled in before providing this map to
`AddElement`.
Error returns:
- Error::INVALID_ARGS if `element_config` is missing fields, for example
if a level dependency doesn't have a parent level.
Defined at line 369 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
std::vector<fuchsia_power_broker::PowerLevel> PowerLevelsFromConfig (PowerElementConfiguration element_config)Given a `PowerElementConfiguration` from driver framework, convert this
into a set of Power Broker's `PowerLevel` objects.
If the `PowerElementConfiguration` expresses no levels, we return an
empty vector.
Defined at line 397 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
fit::result<Error, TokenMap> GetDependencyTokens (const fdf::Namespace & ns, const PowerElementConfiguration & element_config)For the Power Element represented by `element_config`, get the tokens for
the element's dependencies (ie. "parents") from
`fuchsia.hardware.power/PowerTokenProvider` instances in `ns`.
If the power element represented by `element_config` has no dependencies,
this function returns an empty set. If any dependency's token can not be
be retrieved we return an error.
Error returns:
- `Error::INVALID_ARGS` if the element_config appears invalid
- `Error::IO` if there is a communication failure when talking to a
service or a protocol required to get a token.
- `Error::DEPENDENCY_NOT_FOUND` if a token for a required dependency is
not available.
Defined at line 408 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
fit::result<Error, TokenMap> GetDependencyTokens (const PowerElementConfiguration & element_config, fidl::ClientEnd<fuchsia_io::Directory> svcs_dir)For the Power Element represented by `element_config`, get the tokens for
the
element's dependencies (ie. "parents") from
`fuchsia.hardware.power/PowerTokenProvider` instances in `svcs_dir`.
`svcs_dir` should contain an entry for
`fuchsia.hardware.power/PowerTokenService`.
Returns a set of tokens from services instances found in `svcs_dir`. If
the power element represented by `element_config` has no dependencies, this
function returns an empty set. If any dependency's token can not be
be retrieved we return an error.
Error returns:
- `Error::INVALID_ARGS` if the element_config appears invalid
- `Error::IO` if there is a communication failure when talking to a
service or a protocol required to get a token.
- `Error::DEPENDENCY_NOT_FOUND` if a token for a required dependency is
not available.
Defined at line 421 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
fit::result<Error> AddElement (const fidl::ClientEnd<fuchsia_power_broker::Topology> & power_broker, const PowerElementConfiguration & config, TokenMap tokens, const zx::unowned_event & assertive_token, std::optional<fidl::ServerEnd<fuchsia_power_broker::Lessor>> lessor, std::optional<fidl::ServerEnd<fuchsia_power_broker::ElementControl>> element_control, std::optional<fidl::UnownedClientEnd<fuchsia_power_broker::ElementControl>> element_control_client, std::optional<fidl::ClientEnd<fuchsia_power_broker::ElementRunner>> element_runner)Call `AddElement` on the `power_broker` channel passed in.
This function uses the `config` and `tokens` arguments to properly construct
the call to `fuchsia.power.broker/Topology.AddElement`. Optionally callers
can pass in tokens to be registered for granting assertive
dependency access on the created element.
Error
- Error::DEPENDENCY_NOT_FOUND if there is a dependency specified by
`config` which is to found in `tokens`.
- Error::INVALID_ARGS if `config` appears to be invalid, we fail to
duplicate a token and therefore assume it must have been invalid, or
the call to power broker fails for any reason *other* than a closed
channel.
Defined at line 499 of file ../../sdk/lib/driver/power/cpp/power-support.cc
-
fit::result<Error> AddElement (fidl::ClientEnd<fuchsia_power_broker::Topology> & power_brokerElementDesc & description)Call `AddElement` on the `power_broker` channel passed in.
This function uses `ElementDescription` passed in to make the proper call
to `fuchsia.power.broker/Topology.AddElement`. See `ElementDescription` for
more information about what fields are inputs to `AddElement`.
Error
- Error::DEPENDENCY_NOT_FOUND if there is a dependency specified by
`config` which is to found in `tokens`.
- Error::INVALID_ARGS if `config` appears to be invalid, we fail to
duplicate a token and therefore assume it must have been invalid, or
the call to power broker fails for any reason *other* than a closed
channel.
Defined at line 600 of file ../../sdk/lib/driver/power/cpp/power-support.cc