diff --git a/power/stats/1.0/Android.bp b/power/stats/1.0/Android.bp index 2f16a21336..9a956e4ce1 100644 --- a/power/stats/1.0/Android.bp +++ b/power/stats/1.0/Android.bp @@ -14,9 +14,15 @@ hidl_interface { "android.hidl.base@1.0", ], types: [ - "Status", - "RailInfo", "EnergyData", + "PowerEntityInfo", + "PowerEntityStateInfo", + "PowerEntityStateResidencyData", + "PowerEntityStateResidencyResult", + "PowerEntityStateSpace", + "PowerEntityType", + "RailInfo", + "Status", ], gen_java: false, } diff --git a/power/stats/1.0/IPowerStats.hal b/power/stats/1.0/IPowerStats.hal index b5b3cc9a82..75c6a72fc9 100644 --- a/power/stats/1.0/IPowerStats.hal +++ b/power/stats/1.0/IPowerStats.hal @@ -96,4 +96,67 @@ interface IPowerStats { streamEnergyData(uint32_t timeMs, uint32_t samplingRate) generates(fmq_sync mqDesc, uint32_t numSamples, uint32_t railsPerSample, Status status); + + /** + * PowerEntity information: + * Reports information related to all supported PowerEntity(s) for which + * data is available. A PowerEntity is defined as a platform subsystem, + * peripheral, or power domain that impacts the total device power + * consumption. + * + * @return powerEntityInfos List of information on each PowerEntity + * @return status SUCCESS on success or NOT_SUPPORTED if + * feature is not enabled or FILESYSTEM_ERROR on filesystem nodes + * access error. + */ + getPowerEntityInfo() + generates(vec powerEntityInfos, Status status); + + /** + * PowerEntity state information: + * Reports the set of power states for which the specified + * PowerEntity(s) provide residency data. + * + * @param powerEntityIds collection of IDs of PowerEntity(s) for which + * state information is requested. PowerEntity name to ID mapping may + * be queried from getPowerEntityInfo(). To get state space + * information for all PowerEntity(s) pass an empty vector. + * + * @return powerEntityStateSpaces PowerEntity state space information for + * each specified PowerEntity. + * @return status SUCCESS if powerEntityStateInfos contains state space + * information for at least one PowerEntity, NOT_SUPPORTED if feature + * is not enabled, INVALID_INPUT if no requested PowerEntity(s) + * provide state space information, FILESYSTEM_ERROR if no state space + * information is returned due to filesystem errors. + */ + getPowerEntityStateInfo(vec powerEntityIds) + generates(vec powerEntityStateSpaces, + Status status); + + /** + * PowerEntity residencies for low frequency clients: + * Reports accumulated residency data for each specified PowerEntity. + * Each PowerEntity may reside in one of multiple states. It may also + * transition to another state. Residency data is an accumulation of time + * that a specified PowerEntity resided in each of its possible states, + * the number of times that each state was entered, and a timestamp + * corresponding to the last time that state was entered. Data is + * accumulated starting from the last time the PowerEntity was reset. + * + * @param powerEntityId collection of IDs of PowerEntity(s) for which + * residency data is requested. PowerEntity name to ID mapping may + * be queried from getPowerEntityInfo(). To get state residency + * data for all PowerEntity(s) pass an empty vector. + * @return stateResidencyResults state residency data for the + * specified powerEntity(s) + * @return status SUCCESS if stateResidencyResults contains residency + * data for at least one PowerEntity, NOT_SUPPORTED if + * feature is not enabled, INVALID_INPUT if no requested + * PowerEntity(s) provide state residency data, FILESYSTEM_ERROR + * if no data is returned due to filesystem errors. + */ + getPowerEntityStateResidencyData(vec powerEntityIds) + generates(vec stateResidencyResults, + Status status); }; diff --git a/power/stats/1.0/types.hal b/power/stats/1.0/types.hal index 703e5429e3..986a6bb1af 100644 --- a/power/stats/1.0/types.hal +++ b/power/stats/1.0/types.hal @@ -36,7 +36,7 @@ struct RailInfo { struct EnergyData { /** - * Index corrensponding to the rail. This index matches + * Index corresponding to the rail. This index matches * the index returned in RailInfo */ uint32_t index; @@ -45,3 +45,85 @@ struct EnergyData { /** Accumulated energy since device boot in microwatt-seconds (uWs) */ uint64_t energy; }; + +enum PowerEntityType : uint32_t { + /** + * A subsystem is a self-contained compute unit. Some examples include + * application processor, DSP, GPU. + */ + SUBSYSTEM = 0, + /** + * A peripheral is an auxiliary device that connects to and works with a + * compute unit. Some examples include simple sensors, camera, display. + */ + PERIPHERAL = 1, + /** + * A power domain is a single subsystem or a collection of subsystems + * that is controlled by a single voltage rail. + */ + POWER_DOMAIN = 2, +}; + +/** + * PowerEntityInfo contains information, such as the ID, name, and type of a + * given PowerEntity. + */ +struct PowerEntityInfo { + /** ID corresponding to the PowerEntity */ + uint32_t powerEntityId; + /** + * Name of the PowerEntity. This is unique and opaque to the + * Android framework + */ + string powerEntityName; + /** Type of the PowerEntity */ + PowerEntityType type; +}; + +struct PowerEntityStateInfo { + /** ID corresponding to the state */ + uint32_t powerEntityStateId; + /** Name of the state */ + string powerEntityStateName; +}; + +/** + * PowerEntityStateSpace contains the state space information of a given + * PowerEntity. The state space, is the set of possible states that a given + * PowerEntity provides residency data for. + */ +struct PowerEntityStateSpace { + /** ID of the corresponding PowerEntity */ + uint32_t powerEntityId; + + /** List of states that the PowerEntity may reside in */ + vec states; +}; + +/** Contains residency data for a single state */ +struct PowerEntityStateResidencyData { + /** ID of the corresponding PowerEntityStateInfo */ + uint32_t powerEntityStateId; + /** + * Total time in milliseconds that the corresponding PowerEntity resided + * in this state since the PowerEntity was reset + */ + uint64_t totalTimeInStateMs; + /** + * Total number of times that the state was entered since the corresponding + * PowerEntity was reset + */ + uint64_t totalStateEntryCount; + /** + * Last time this state was entered. Time in milliseconds since the + * corresponding PowerEntity was reset + */ + uint64_t lastEntryTimestampMs; +}; + +struct PowerEntityStateResidencyResult { + /** ID of the corresponding PowerEntity */ + uint32_t powerEntityId; + /** Residency data for each state the PowerEntity's state space */ + vec stateResidencyData; +};