1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_FRAME_AWARE_SCHED_COMMON_INCLUDE_RTG_INTERFACE_H 17 #define OHOS_FRAME_AWARE_SCHED_COMMON_INCLUDE_RTG_INTERFACE_H 18 19 #include <string> 20 #include <vector> 21 22 namespace OHOS { 23 namespace RME { 24 using namespace std; 25 26 #define MAX_TID_NUM 5 27 #define MAX_SUBPROCESS_NUM 8 28 #define MULTI_FRAME_NUM 5 29 30 struct rtg_enable_data { 31 int enable; 32 int len; 33 char *data; 34 }; 35 36 struct rtg_str_data { 37 int type; 38 int len; 39 char *data; 40 }; 41 42 struct proc_state_data { 43 int grp_id; 44 int state_param; 45 }; 46 47 enum grp_ctrl_cmd { 48 CMD_CREATE_RTG_GRP, 49 CMD_ADD_RTG_THREAD, 50 CMD_REMOVE_RTG_THREAD, 51 CMD_CLEAR_RTG_GRP, 52 CMD_DESTROY_RTG_GRP 53 }; 54 55 struct rtg_grp_data { 56 int rtg_cmd; 57 int grp_id; 58 int prio_type; 59 int rt_cnt; 60 int tid_num; 61 int tids[MAX_TID_NUM]; 62 }; 63 64 struct rtg_info { 65 int rtg_num; 66 int rtgs[MULTI_FRAME_NUM]; 67 }; 68 69 enum rtg_sched_cmdid { 70 SET_ENABLE = 1, 71 SET_RTG, 72 SET_CONFIG, 73 SET_RTG_ATTR, 74 BEGIN_FRAME_FREQ = 5, 75 END_FRAME_FREQ, 76 END_SCENE, 77 SET_MIN_UTIL, 78 SET_MARGIN, 79 LIST_RTG, 80 LIST_RTG_THREAD, 81 SEARCH_RTG, 82 GET_ENABLE, 83 SET_MAX_UTIL, 84 RTG_CTRL_MAX_NR, 85 }; 86 87 bool GetAppExpelAbility(const std::string &appBundleName); 88 89 extern "C" { 90 int EnableRtg(bool flag); 91 int AddThreadToRtg(int tid, int grpId, int prioType = 0, bool isBlue = false); 92 int AddThreadsToRtg(vector<int> tids, int grpId, int prioType = 0, bool isBlue = false); 93 int RemoveRtgThread(int tid, bool isBlue = false); 94 int RemoveRtgThreads(vector<int> tids, bool isBlue = false); 95 int DestroyRtgGrp(int grpId); 96 int SetFrameRateAndPrioType(int rtgId, int rate, int rtgType); 97 int BeginFrameFreq(int stateParam); 98 int EndFrameFreq(int stateParam); 99 int EndScene(int grpId); 100 int SetMinUtil(int stateParam); 101 int SetMaxUtil(int grpId, int stateParam); 102 int SetMargin(int stateParam); 103 int SearchRtgForTid(int tid); 104 int GetRtgEnable(); 105 } 106 } // namespace RME 107 } // namespace OHOS 108 #endif // OHOS_FRAME_AWARE_SCHED_COMMON_INCLUDE_RTG_INTERFACE_H 109