1 /*
2  * Copyright (c) 2022-2023 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 #include "soc_action_base.h"
17 
18 #ifdef SOC_PERF_ENABLE
19 #include "socperf_client.h"
20 #endif
21 
22 namespace OHOS {
23 namespace PowerMgr {
24 namespace {
25 #ifdef SOC_PERF_ENABLE
26 constexpr int32_t ACTION_TYPE_THERMAL_ID = 2;
27 constexpr int32_t ACTION_TYPE_CPU_ISOLATE_CMDID = 12361;
28 const std::string THERMAL_MSG = "thermal";
29 #endif
30 }
31 
SocLimitRequest(int32_t tag,int64_t value)32 void SocActionBase::SocLimitRequest(int32_t tag, int64_t value)
33 {
34 #ifdef SOC_PERF_ENABLE
35     std::vector<int32_t> tags;
36     std::vector<int64_t> configs;
37     tags.push_back(tag);
38     configs.push_back(value);
39     OHOS::SOCPERF::SocPerfClient::GetInstance().LimitRequest(ACTION_TYPE_THERMAL_ID, tags, configs, "");
40 #endif
41 }
42 
SetSocPerfThermalLevel(uint32_t level)43 void SocActionBase::SetSocPerfThermalLevel(uint32_t level)
44 {
45 #ifdef SOC_PERF_ENABLE
46     OHOS::SOCPERF::SocPerfClient::GetInstance().SetThermalLevel(level);
47 #endif
48 }
49 
SocIsolateRequest(bool enable)50 void SocActionBase::SocIsolateRequest(bool enable)
51 {
52 #ifdef SOC_PERF_ENABLE
53     OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(ACTION_TYPE_CPU_ISOLATE_CMDID, enable, "");
54 #endif
55 }
56 
SetBoostEnable(bool status)57 void SocActionBase::SetBoostEnable(bool status)
58 {
59 #ifdef SOC_PERF_ENABLE
60     OHOS::SOCPERF::SocPerfClient::GetInstance().SetRequestStatus(status, THERMAL_MSG);
61 #endif
62 }
63 } // namespace PowerMgr
64 } // namespace OHOS
65