1*38e8c45fSAndroid Build Coastguard Worker /* 2*38e8c45fSAndroid Build Coastguard Worker * Copyright (C) 2024 The Android Open Source Project 3*38e8c45fSAndroid Build Coastguard Worker * 4*38e8c45fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*38e8c45fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*38e8c45fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*38e8c45fSAndroid Build Coastguard Worker * 8*38e8c45fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*38e8c45fSAndroid Build Coastguard Worker * 10*38e8c45fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*38e8c45fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*38e8c45fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*38e8c45fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*38e8c45fSAndroid Build Coastguard Worker * limitations under the License. 15*38e8c45fSAndroid Build Coastguard Worker */ 16*38e8c45fSAndroid Build Coastguard Worker 17*38e8c45fSAndroid Build Coastguard Worker /** 18*38e8c45fSAndroid Build Coastguard Worker * @defgroup SystemHealth 19*38e8c45fSAndroid Build Coastguard Worker * @{ 20*38e8c45fSAndroid Build Coastguard Worker */ 21*38e8c45fSAndroid Build Coastguard Worker 22*38e8c45fSAndroid Build Coastguard Worker /** 23*38e8c45fSAndroid Build Coastguard Worker * @file system_health.h 24*38e8c45fSAndroid Build Coastguard Worker */ 25*38e8c45fSAndroid Build Coastguard Worker 26*38e8c45fSAndroid Build Coastguard Worker #ifndef _ANDROID_SYSTEM_HEALTH_H 27*38e8c45fSAndroid Build Coastguard Worker #define _ANDROID_SYSTEM_HEALTH_H 28*38e8c45fSAndroid Build Coastguard Worker 29*38e8c45fSAndroid Build Coastguard Worker #include <sys/cdefs.h> 30*38e8c45fSAndroid Build Coastguard Worker 31*38e8c45fSAndroid Build Coastguard Worker /****************************************************************** 32*38e8c45fSAndroid Build Coastguard Worker * 33*38e8c45fSAndroid Build Coastguard Worker * IMPORTANT NOTICE: 34*38e8c45fSAndroid Build Coastguard Worker * 35*38e8c45fSAndroid Build Coastguard Worker * This file is part of Android's set of stable system headers 36*38e8c45fSAndroid Build Coastguard Worker * exposed by the Android NDK (Native Development Kit). 37*38e8c45fSAndroid Build Coastguard Worker * 38*38e8c45fSAndroid Build Coastguard Worker * Third-party source AND binary code relies on the definitions 39*38e8c45fSAndroid Build Coastguard Worker * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. 40*38e8c45fSAndroid Build Coastguard Worker * 41*38e8c45fSAndroid Build Coastguard Worker * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) 42*38e8c45fSAndroid Build Coastguard Worker * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS 43*38e8c45fSAndroid Build Coastguard Worker * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY 44*38e8c45fSAndroid Build Coastguard Worker * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES 45*38e8c45fSAndroid Build Coastguard Worker */ 46*38e8c45fSAndroid Build Coastguard Worker 47*38e8c45fSAndroid Build Coastguard Worker 48*38e8c45fSAndroid Build Coastguard Worker #include <stdint.h> 49*38e8c45fSAndroid Build Coastguard Worker #include <sys/types.h> 50*38e8c45fSAndroid Build Coastguard Worker 51*38e8c45fSAndroid Build Coastguard Worker #if !defined(__INTRODUCED_IN) 52*38e8c45fSAndroid Build Coastguard Worker #define __INTRODUCED_IN(__api_level) /* nothing */ 53*38e8c45fSAndroid Build Coastguard Worker #endif 54*38e8c45fSAndroid Build Coastguard Worker 55*38e8c45fSAndroid Build Coastguard Worker #ifdef __cplusplus 56*38e8c45fSAndroid Build Coastguard Worker extern "C" { 57*38e8c45fSAndroid Build Coastguard Worker #endif 58*38e8c45fSAndroid Build Coastguard Worker 59*38e8c45fSAndroid Build Coastguard Worker /** 60*38e8c45fSAndroid Build Coastguard Worker * Params used to customize the calculation of CPU headroom. 61*38e8c45fSAndroid Build Coastguard Worker * 62*38e8c45fSAndroid Build Coastguard Worker * Also see {@link ASystemHealth_getCpuHeadroom}. 63*38e8c45fSAndroid Build Coastguard Worker */ 64*38e8c45fSAndroid Build Coastguard Worker typedef struct ACpuHeadroomParams ACpuHeadroomParams; 65*38e8c45fSAndroid Build Coastguard Worker 66*38e8c45fSAndroid Build Coastguard Worker /** 67*38e8c45fSAndroid Build Coastguard Worker * Params used to customize the calculation of GPU headroom. 68*38e8c45fSAndroid Build Coastguard Worker * 69*38e8c45fSAndroid Build Coastguard Worker * Also see {@link ASystemHealth_getGpuHeadroom}. 70*38e8c45fSAndroid Build Coastguard Worker */ 71*38e8c45fSAndroid Build Coastguard Worker typedef struct AGpuHeadroomParams AGpuHeadroomParams; 72*38e8c45fSAndroid Build Coastguard Worker 73*38e8c45fSAndroid Build Coastguard Worker /** 74*38e8c45fSAndroid Build Coastguard Worker * Creates a new instance of ACpuHeadroomParams. 75*38e8c45fSAndroid Build Coastguard Worker * 76*38e8c45fSAndroid Build Coastguard Worker * When the client finishes using {@link ACpuHeadroomParams}, 77*38e8c45fSAndroid Build Coastguard Worker * {@link ACpuHeadroomParams_destroy()} must be called to destroy 78*38e8c45fSAndroid Build Coastguard Worker * and free up the resources associated with {@link ACpuHeadroomParams}. 79*38e8c45fSAndroid Build Coastguard Worker * 80*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 81*38e8c45fSAndroid Build Coastguard Worker * 82*38e8c45fSAndroid Build Coastguard Worker * @return A new instance of ACpuHeadroomParams. 83*38e8c45fSAndroid Build Coastguard Worker */ 84*38e8c45fSAndroid Build Coastguard Worker ACpuHeadroomParams *_Nonnull ACpuHeadroomParams_create() 85*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 86*38e8c45fSAndroid Build Coastguard Worker 87*38e8c45fSAndroid Build Coastguard Worker enum ACpuHeadroomCalculationType { 88*38e8c45fSAndroid Build Coastguard Worker /** 89*38e8c45fSAndroid Build Coastguard Worker * Use the minimum headroom value within the calculation window. 90*38e8c45fSAndroid Build Coastguard Worker * Introduced in API level 36. 91*38e8c45fSAndroid Build Coastguard Worker */ 92*38e8c45fSAndroid Build Coastguard Worker ACPU_HEADROOM_CALCULATION_TYPE_MIN = 0, 93*38e8c45fSAndroid Build Coastguard Worker /** 94*38e8c45fSAndroid Build Coastguard Worker * Use the average headroom value within the calculation window. 95*38e8c45fSAndroid Build Coastguard Worker * Introduced in API level 36. 96*38e8c45fSAndroid Build Coastguard Worker */ 97*38e8c45fSAndroid Build Coastguard Worker ACPU_HEADROOM_CALCULATION_TYPE_AVERAGE = 1, 98*38e8c45fSAndroid Build Coastguard Worker }; 99*38e8c45fSAndroid Build Coastguard Worker typedef enum ACpuHeadroomCalculationType ACpuHeadroomCalculationType; 100*38e8c45fSAndroid Build Coastguard Worker 101*38e8c45fSAndroid Build Coastguard Worker enum AGpuHeadroomCalculationType { 102*38e8c45fSAndroid Build Coastguard Worker /** 103*38e8c45fSAndroid Build Coastguard Worker * Use the minimum headroom value within the calculation window. 104*38e8c45fSAndroid Build Coastguard Worker * Introduced in API level 36. 105*38e8c45fSAndroid Build Coastguard Worker */ 106*38e8c45fSAndroid Build Coastguard Worker AGPU_HEADROOM_CALCULATION_TYPE_MIN = 0, 107*38e8c45fSAndroid Build Coastguard Worker /** 108*38e8c45fSAndroid Build Coastguard Worker * Use the average headroom value within the calculation window. 109*38e8c45fSAndroid Build Coastguard Worker * Introduced in API level 36. 110*38e8c45fSAndroid Build Coastguard Worker */ 111*38e8c45fSAndroid Build Coastguard Worker AGPU_HEADROOM_CALCULATION_TYPE_AVERAGE = 1, 112*38e8c45fSAndroid Build Coastguard Worker }; 113*38e8c45fSAndroid Build Coastguard Worker typedef enum AGpuHeadroomCalculationType AGpuHeadroomCalculationType; 114*38e8c45fSAndroid Build Coastguard Worker 115*38e8c45fSAndroid Build Coastguard Worker /** 116*38e8c45fSAndroid Build Coastguard Worker * Sets the headroom calculation window size in ACpuHeadroomParams. 117*38e8c45fSAndroid Build Coastguard Worker * 118*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 119*38e8c45fSAndroid Build Coastguard Worker * 120*38e8c45fSAndroid Build Coastguard Worker * @param params The params to be set. 121*38e8c45fSAndroid Build Coastguard Worker * @param windowMillis The window size in milliseconds ranged from [50, 10000]. The smaller the 122*38e8c45fSAndroid Build Coastguard Worker * window size, the larger fluctuation in the headroom value should be expected. 123*38e8c45fSAndroid Build Coastguard Worker * The default value can be retrieved from the 124*38e8c45fSAndroid Build Coastguard Worker * {@link #ACpuHeadroomParams_getCalculationWindowMillis} if not set. The device 125*38e8c45fSAndroid Build Coastguard Worker * will try to use the closest feasible window size to this param. 126*38e8c45fSAndroid Build Coastguard Worker */ 127*38e8c45fSAndroid Build Coastguard Worker void ACpuHeadroomParams_setCalculationWindowMillis(ACpuHeadroomParams *_Nonnull params, 128*38e8c45fSAndroid Build Coastguard Worker int windowMillis) 129*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 130*38e8c45fSAndroid Build Coastguard Worker 131*38e8c45fSAndroid Build Coastguard Worker /** 132*38e8c45fSAndroid Build Coastguard Worker * Gets the headroom calculation window size in ACpuHeadroomParams. 133*38e8c45fSAndroid Build Coastguard Worker * 134*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 135*38e8c45fSAndroid Build Coastguard Worker * 136*38e8c45fSAndroid Build Coastguard Worker * @param params The params to be set. 137*38e8c45fSAndroid Build Coastguard Worker * @return This will return the default value chosen by the device if the params is not set. 138*38e8c45fSAndroid Build Coastguard Worker */ 139*38e8c45fSAndroid Build Coastguard Worker int ACpuHeadroomParams_getCalculationWindowMillis(ACpuHeadroomParams *_Nonnull params) 140*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 141*38e8c45fSAndroid Build Coastguard Worker 142*38e8c45fSAndroid Build Coastguard Worker /** 143*38e8c45fSAndroid Build Coastguard Worker * Sets the headroom calculation window size in AGpuHeadroomParams. 144*38e8c45fSAndroid Build Coastguard Worker * 145*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 146*38e8c45fSAndroid Build Coastguard Worker * 147*38e8c45fSAndroid Build Coastguard Worker * @param params The params to be set. 148*38e8c45fSAndroid Build Coastguard Worker * @param windowMillis The window size in milliseconds ranged from [50, 10000]. The smaller the 149*38e8c45fSAndroid Build Coastguard Worker * window size, the larger fluctuation in the headroom value should be expected. 150*38e8c45fSAndroid Build Coastguard Worker * The default value can be retrieved from the 151*38e8c45fSAndroid Build Coastguard Worker * {@link #AGpuHeadroomParams_getCalculationWindowMillis} if not set. The device 152*38e8c45fSAndroid Build Coastguard Worker * will try to use the closest feasible window size to this param. 153*38e8c45fSAndroid Build Coastguard Worker */ 154*38e8c45fSAndroid Build Coastguard Worker void AGpuHeadroomParams_setCalculationWindowMillis(AGpuHeadroomParams *_Nonnull params, 155*38e8c45fSAndroid Build Coastguard Worker int windowMillis) 156*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 157*38e8c45fSAndroid Build Coastguard Worker 158*38e8c45fSAndroid Build Coastguard Worker /** 159*38e8c45fSAndroid Build Coastguard Worker * Gets the headroom calculation window size in AGpuHeadroomParams. 160*38e8c45fSAndroid Build Coastguard Worker * 161*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 162*38e8c45fSAndroid Build Coastguard Worker * 163*38e8c45fSAndroid Build Coastguard Worker * @param params The params to be set. 164*38e8c45fSAndroid Build Coastguard Worker * @return This will return the default value chosen by the device if the params is not set. 165*38e8c45fSAndroid Build Coastguard Worker */ 166*38e8c45fSAndroid Build Coastguard Worker int AGpuHeadroomParams_getCalculationWindowMillis(AGpuHeadroomParams *_Nonnull params) 167*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 168*38e8c45fSAndroid Build Coastguard Worker 169*38e8c45fSAndroid Build Coastguard Worker /** 170*38e8c45fSAndroid Build Coastguard Worker * Sets the headroom calculation type in ACpuHeadroomParams. 171*38e8c45fSAndroid Build Coastguard Worker * 172*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 173*38e8c45fSAndroid Build Coastguard Worker * 174*38e8c45fSAndroid Build Coastguard Worker * @param params The params to be set. 175*38e8c45fSAndroid Build Coastguard Worker * @param calculationType The headroom calculation type. 176*38e8c45fSAndroid Build Coastguard Worker */ 177*38e8c45fSAndroid Build Coastguard Worker void ACpuHeadroomParams_setCalculationType(ACpuHeadroomParams *_Nonnull params, 178*38e8c45fSAndroid Build Coastguard Worker ACpuHeadroomCalculationType calculationType) 179*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 180*38e8c45fSAndroid Build Coastguard Worker 181*38e8c45fSAndroid Build Coastguard Worker /** 182*38e8c45fSAndroid Build Coastguard Worker * Gets the headroom calculation type in ACpuHeadroomParams. 183*38e8c45fSAndroid Build Coastguard Worker * 184*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 185*38e8c45fSAndroid Build Coastguard Worker * 186*38e8c45fSAndroid Build Coastguard Worker * @param params The params to be set. 187*38e8c45fSAndroid Build Coastguard Worker * @return The headroom calculation type. 188*38e8c45fSAndroid Build Coastguard Worker */ 189*38e8c45fSAndroid Build Coastguard Worker ACpuHeadroomCalculationType 190*38e8c45fSAndroid Build Coastguard Worker ACpuHeadroomParams_getCalculationType(ACpuHeadroomParams *_Nonnull params) 191*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 192*38e8c45fSAndroid Build Coastguard Worker 193*38e8c45fSAndroid Build Coastguard Worker /** 194*38e8c45fSAndroid Build Coastguard Worker * Sets the headroom calculation type in AGpuHeadroomParams. 195*38e8c45fSAndroid Build Coastguard Worker * 196*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 197*38e8c45fSAndroid Build Coastguard Worker * 198*38e8c45fSAndroid Build Coastguard Worker * @param params The params to be set. 199*38e8c45fSAndroid Build Coastguard Worker * @param calculationType The headroom calculation type. 200*38e8c45fSAndroid Build Coastguard Worker */ 201*38e8c45fSAndroid Build Coastguard Worker void AGpuHeadroomParams_setCalculationType(AGpuHeadroomParams *_Nonnull params, 202*38e8c45fSAndroid Build Coastguard Worker AGpuHeadroomCalculationType calculationType) 203*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 204*38e8c45fSAndroid Build Coastguard Worker 205*38e8c45fSAndroid Build Coastguard Worker /** 206*38e8c45fSAndroid Build Coastguard Worker * Gets the headroom calculation type in AGpuHeadroomParams. 207*38e8c45fSAndroid Build Coastguard Worker * 208*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 209*38e8c45fSAndroid Build Coastguard Worker * 210*38e8c45fSAndroid Build Coastguard Worker * @param params The params to be set. 211*38e8c45fSAndroid Build Coastguard Worker * @return The headroom calculation type. 212*38e8c45fSAndroid Build Coastguard Worker */ 213*38e8c45fSAndroid Build Coastguard Worker AGpuHeadroomCalculationType 214*38e8c45fSAndroid Build Coastguard Worker AGpuHeadroomParams_getCalculationType(AGpuHeadroomParams *_Nonnull params) 215*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 216*38e8c45fSAndroid Build Coastguard Worker 217*38e8c45fSAndroid Build Coastguard Worker /** 218*38e8c45fSAndroid Build Coastguard Worker * Sets the thread TIDs to track in ACpuHeadroomParams. 219*38e8c45fSAndroid Build Coastguard Worker * 220*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 221*38e8c45fSAndroid Build Coastguard Worker * 222*38e8c45fSAndroid Build Coastguard Worker * @param params The params to be set. 223*38e8c45fSAndroid Build Coastguard Worker * @param tids Non-null array of TIDs, maximum 5. 224*38e8c45fSAndroid Build Coastguard Worker * @param tidsSize The size of the tids array. 225*38e8c45fSAndroid Build Coastguard Worker */ 226*38e8c45fSAndroid Build Coastguard Worker void ACpuHeadroomParams_setTids(ACpuHeadroomParams *_Nonnull params, const int *_Nonnull tids, 227*38e8c45fSAndroid Build Coastguard Worker int tidsSize) 228*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 229*38e8c45fSAndroid Build Coastguard Worker 230*38e8c45fSAndroid Build Coastguard Worker /** 231*38e8c45fSAndroid Build Coastguard Worker * Creates a new instance of AGpuHeadroomParams. 232*38e8c45fSAndroid Build Coastguard Worker * 233*38e8c45fSAndroid Build Coastguard Worker * When the client finishes using {@link AGpuHeadroomParams}, 234*38e8c45fSAndroid Build Coastguard Worker * {@link AGpuHeadroomParams_destroy()} must be called to destroy 235*38e8c45fSAndroid Build Coastguard Worker * and free up the resources associated with {@link AGpuHeadroomParams}. 236*38e8c45fSAndroid Build Coastguard Worker * 237*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 238*38e8c45fSAndroid Build Coastguard Worker * 239*38e8c45fSAndroid Build Coastguard Worker * @return A new instance of AGpuHeadroomParams. 240*38e8c45fSAndroid Build Coastguard Worker */ 241*38e8c45fSAndroid Build Coastguard Worker AGpuHeadroomParams *_Nonnull AGpuHeadroomParams_create() 242*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 243*38e8c45fSAndroid Build Coastguard Worker 244*38e8c45fSAndroid Build Coastguard Worker /** 245*38e8c45fSAndroid Build Coastguard Worker * Deletes the ACpuHeadroomParams instance. 246*38e8c45fSAndroid Build Coastguard Worker * 247*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 248*38e8c45fSAndroid Build Coastguard Worker * 249*38e8c45fSAndroid Build Coastguard Worker * @param params The params to be deleted. 250*38e8c45fSAndroid Build Coastguard Worker */ 251*38e8c45fSAndroid Build Coastguard Worker void ACpuHeadroomParams_destroy(ACpuHeadroomParams *_Nonnull params) 252*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 253*38e8c45fSAndroid Build Coastguard Worker 254*38e8c45fSAndroid Build Coastguard Worker /** 255*38e8c45fSAndroid Build Coastguard Worker * Deletes the AGpuHeadroomParams instance. 256*38e8c45fSAndroid Build Coastguard Worker * 257*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 258*38e8c45fSAndroid Build Coastguard Worker * 259*38e8c45fSAndroid Build Coastguard Worker * @param params The params to be deleted. 260*38e8c45fSAndroid Build Coastguard Worker */ 261*38e8c45fSAndroid Build Coastguard Worker void AGpuHeadroomParams_destroy(AGpuHeadroomParams *_Nonnull params) 262*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 263*38e8c45fSAndroid Build Coastguard Worker 264*38e8c45fSAndroid Build Coastguard Worker /** 265*38e8c45fSAndroid Build Coastguard Worker * Provides an estimate of available CPU capacity headroom of the device. 266*38e8c45fSAndroid Build Coastguard Worker * 267*38e8c45fSAndroid Build Coastguard Worker * The value can be used by the calling application to determine if the workload was CPU bound and 268*38e8c45fSAndroid Build Coastguard Worker * then take action accordingly to ensure that the workload can be completed smoothly. It can also 269*38e8c45fSAndroid Build Coastguard Worker * be used with the thermal status and headroom to determine if reducing the CPU bound workload can 270*38e8c45fSAndroid Build Coastguard Worker * help reduce the device temperature to avoid thermal throttling. 271*38e8c45fSAndroid Build Coastguard Worker * 272*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 273*38e8c45fSAndroid Build Coastguard Worker * 274*38e8c45fSAndroid Build Coastguard Worker * @param params The params to customize the CPU headroom calculation, or nullptr to use the default 275*38e8c45fSAndroid Build Coastguard Worker * @param outHeadroom Non-null output pointer to a single float, which will be set to the CPU 276*38e8c45fSAndroid Build Coastguard Worker * headroom value. The value will be a single value or `Float.NaN` if it's 277*38e8c45fSAndroid Build Coastguard Worker * temporarily unavailable. 278*38e8c45fSAndroid Build Coastguard Worker * Each valid value ranges from [0, 100], where 0 indicates no more cpu resources 279*38e8c45fSAndroid Build Coastguard Worker * can be granted. 280*38e8c45fSAndroid Build Coastguard Worker * @return 0 on success 281*38e8c45fSAndroid Build Coastguard Worker * EPIPE if failed to get the CPU headroom. 282*38e8c45fSAndroid Build Coastguard Worker * EPERM if the TIDs do not belong to the same process. 283*38e8c45fSAndroid Build Coastguard Worker * ENOTSUP if API or requested params is unsupported. 284*38e8c45fSAndroid Build Coastguard Worker */ 285*38e8c45fSAndroid Build Coastguard Worker int ASystemHealth_getCpuHeadroom(const ACpuHeadroomParams *_Nullable params, 286*38e8c45fSAndroid Build Coastguard Worker float *_Nonnull outHeadroom) 287*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 288*38e8c45fSAndroid Build Coastguard Worker 289*38e8c45fSAndroid Build Coastguard Worker /** 290*38e8c45fSAndroid Build Coastguard Worker * Provides an estimate of available GPU capacity headroom of the device. 291*38e8c45fSAndroid Build Coastguard Worker * 292*38e8c45fSAndroid Build Coastguard Worker * The value can be used by the calling application to determine if the workload was GPU bound and 293*38e8c45fSAndroid Build Coastguard Worker * then take action accordingly to ensure that the workload can be completed smoothly. It can also 294*38e8c45fSAndroid Build Coastguard Worker * be used with the thermal status and headroom to determine if reducing the GPU bound workload can 295*38e8c45fSAndroid Build Coastguard Worker * help reduce the device temperature to avoid thermal throttling. 296*38e8c45fSAndroid Build Coastguard Worker * 297*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36 298*38e8c45fSAndroid Build Coastguard Worker * 299*38e8c45fSAndroid Build Coastguard Worker * @param params The params to customize the GPU headroom calculation, or nullptr to use the default 300*38e8c45fSAndroid Build Coastguard Worker * @param outHeadroom Non-null output pointer to a single float, which will be set to the GPU 301*38e8c45fSAndroid Build Coastguard Worker * headroom value. The value will be a single value or `Float.NaN` if it's 302*38e8c45fSAndroid Build Coastguard Worker * temporarily unavailable. 303*38e8c45fSAndroid Build Coastguard Worker * Each valid value ranges from [0, 100], where 0 indicates no more gpu resources 304*38e8c45fSAndroid Build Coastguard Worker * can be granted. 305*38e8c45fSAndroid Build Coastguard Worker * @return 0 on success 306*38e8c45fSAndroid Build Coastguard Worker * EPIPE if failed to get the GPU headroom. 307*38e8c45fSAndroid Build Coastguard Worker * ENOTSUP if API or requested params is unsupported. 308*38e8c45fSAndroid Build Coastguard Worker */ 309*38e8c45fSAndroid Build Coastguard Worker int ASystemHealth_getGpuHeadroom(const AGpuHeadroomParams *_Nullable params, 310*38e8c45fSAndroid Build Coastguard Worker float *_Nonnull outHeadroom) 311*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 312*38e8c45fSAndroid Build Coastguard Worker 313*38e8c45fSAndroid Build Coastguard Worker /** 314*38e8c45fSAndroid Build Coastguard Worker * Gets minimum polling interval for calling {@link ASystemHealth_getCpuHeadroom} in milliseconds. 315*38e8c45fSAndroid Build Coastguard Worker * 316*38e8c45fSAndroid Build Coastguard Worker * The getCpuHeadroom API may return cached result if called more frequently than the interval. 317*38e8c45fSAndroid Build Coastguard Worker * 318*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 319*38e8c45fSAndroid Build Coastguard Worker * 320*38e8c45fSAndroid Build Coastguard Worker * @param outMinIntervalMillis Non-null output pointer to a int64_t, which 321*38e8c45fSAndroid Build Coastguard Worker * will be set to the minimum polling interval in milliseconds. 322*38e8c45fSAndroid Build Coastguard Worker * @return 0 on success 323*38e8c45fSAndroid Build Coastguard Worker * EPIPE if failed to get the minimum polling interval. 324*38e8c45fSAndroid Build Coastguard Worker * ENOTSUP if API is unsupported. 325*38e8c45fSAndroid Build Coastguard Worker */ 326*38e8c45fSAndroid Build Coastguard Worker int ASystemHealth_getCpuHeadroomMinIntervalMillis(int64_t *_Nonnull outMinIntervalMillis) 327*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 328*38e8c45fSAndroid Build Coastguard Worker 329*38e8c45fSAndroid Build Coastguard Worker /** 330*38e8c45fSAndroid Build Coastguard Worker * Gets minimum polling interval for calling {@link ASystemHealth_getGpuHeadroom} in milliseconds. 331*38e8c45fSAndroid Build Coastguard Worker * 332*38e8c45fSAndroid Build Coastguard Worker * The getGpuHeadroom API may return cached result if called more frequent than the interval. 333*38e8c45fSAndroid Build Coastguard Worker * 334*38e8c45fSAndroid Build Coastguard Worker * Available since API level 36. 335*38e8c45fSAndroid Build Coastguard Worker * 336*38e8c45fSAndroid Build Coastguard Worker * @param outMinIntervalMillis Non-null output pointer to a int64_t, which 337*38e8c45fSAndroid Build Coastguard Worker * will be set to the minimum polling interval in milliseconds. 338*38e8c45fSAndroid Build Coastguard Worker * @return 0 on success 339*38e8c45fSAndroid Build Coastguard Worker * EPIPE if failed to get the minimum polling interval. 340*38e8c45fSAndroid Build Coastguard Worker * ENOTSUP if API is unsupported. 341*38e8c45fSAndroid Build Coastguard Worker */ 342*38e8c45fSAndroid Build Coastguard Worker int ASystemHealth_getGpuHeadroomMinIntervalMillis(int64_t *_Nonnull outMinIntervalMillis) 343*38e8c45fSAndroid Build Coastguard Worker __INTRODUCED_IN(36); 344*38e8c45fSAndroid Build Coastguard Worker 345*38e8c45fSAndroid Build Coastguard Worker #ifdef __cplusplus 346*38e8c45fSAndroid Build Coastguard Worker } 347*38e8c45fSAndroid Build Coastguard Worker #endif 348*38e8c45fSAndroid Build Coastguard Worker 349*38e8c45fSAndroid Build Coastguard Worker #endif // _ANDROID_SYSTEM_HEALTH_H 350*38e8c45fSAndroid Build Coastguard Worker 351*38e8c45fSAndroid Build Coastguard Worker /** @} */ 352