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 constexpr int32_t ACTION_TYPE_CPU_NONVIP_CMDID = 12362;
29 const std::string THERMAL_MSG = "thermal";
30 #endif
31 }
32
33 std::set<std::string> SocActionBase::SocSet;
34
SocLimitRequest(int32_t tag,int64_t value)35 void SocActionBase::SocLimitRequest(int32_t tag, int64_t value)
36 {
37 #ifdef SOC_PERF_ENABLE
38 std::vector<int32_t> tags;
39 std::vector<int64_t> configs;
40 tags.push_back(tag);
41 configs.push_back(value);
42 OHOS::SOCPERF::SocPerfClient::GetInstance().LimitRequest(ACTION_TYPE_THERMAL_ID, tags, configs, "");
43 #endif
44 }
45
SetSocPerfThermalLevel(uint32_t level)46 void SocActionBase::SetSocPerfThermalLevel(uint32_t level)
47 {
48 #ifdef SOC_PERF_ENABLE
49 OHOS::SOCPERF::SocPerfClient::GetInstance().SetThermalLevel(level);
50 #endif
51 }
52
SocIsolateRequest(bool enable)53 void SocActionBase::SocIsolateRequest(bool enable)
54 {
55 #ifdef SOC_PERF_ENABLE
56 OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(ACTION_TYPE_CPU_ISOLATE_CMDID, enable, "");
57 #endif
58 }
59
SetBoostEnable(bool status)60 void SocActionBase::SetBoostEnable(bool status)
61 {
62 #ifdef SOC_PERF_ENABLE
63 OHOS::SOCPERF::SocPerfClient::GetInstance().SetRequestStatus(status, THERMAL_MSG);
64 #endif
65 }
66
SocNonVipRequest(bool enable)67 void SocActionBase::SocNonVipRequest(bool enable)
68 {
69 #ifdef SOC_PERF_ENABLE
70 OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(ACTION_TYPE_CPU_NONVIP_CMDID, enable, "");
71 #endif
72 }
73 } // namespace PowerMgr
74 } // namespace OHOS
75