• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_PRIVATE_NATIVE_PERFORMANCE_HINT_PRIVATE_H
18 #define ANDROID_PRIVATE_NATIVE_PERFORMANCE_HINT_PRIVATE_H
19 
20 #include <stdint.h>
21 
22 __BEGIN_DECLS
23 
24 /**
25  * For testing only.
26  */
27 void APerformanceHint_setIHintManagerForTesting(void* iManager);
28 
29 /**
30  * Hints for the session used to signal upcoming changes in the mode or workload.
31  */
32 enum SessionHint: int32_t {
33     /**
34      * This hint indicates a sudden increase in CPU workload intensity. It means
35      * that this hint session needs extra CPU resources immediately to meet the
36      * target duration for the current work cycle.
37      */
38     CPU_LOAD_UP = 0,
39     /**
40      * This hint indicates a decrease in CPU workload intensity. It means that
41      * this hint session can reduce CPU resources and still meet the target duration.
42      */
43     CPU_LOAD_DOWN = 1,
44     /*
45      * This hint indicates an upcoming CPU workload that is completely changed and
46      * unknown. It means that the hint session should reset CPU resources to a known
47      * baseline to prepare for an arbitrary load, and must wake up if inactive.
48      */
49     CPU_LOAD_RESET = 2,
50     /*
51      * This hint indicates that the most recent CPU workload is resuming after a
52      * period of inactivity. It means that the hint session should allocate similar
53      * CPU resources to what was used previously, and must wake up if inactive.
54      */
55     CPU_LOAD_RESUME = 3,
56 };
57 
58 /**
59  * Sends performance hints to inform the hint session of changes in the workload.
60  *
61  * @param session The performance hint session instance to update.
62  * @param hint The hint to send to the session.
63  * @return 0 on success
64  *         EPIPE if communication with the system service has failed.
65  */
66 int APerformanceHint_sendHint(void* session, SessionHint hint);
67 
68 /**
69  * Return the list of thread ids, this API should only be used for testing only.
70  */
71 int APerformanceHint_getThreadIds(void* aPerformanceHintSession,
72                                   int32_t* const threadIds, size_t* const size);
73 
74 __END_DECLS
75 
76 #endif // ANDROID_PRIVATE_NATIVE_PERFORMANCE_HINT_PRIVATE_H
77