• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2023 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 #pragma once
18 
19 #include <aidl/android/hardware/power/Boost.h>
20 #include <aidl/android/hardware/power/ChannelConfig.h>
21 #include <aidl/android/hardware/power/ChannelMessage.h>
22 #include <aidl/android/hardware/power/IPower.h>
23 #include <aidl/android/hardware/power/IPowerHintSession.h>
24 #include <aidl/android/hardware/power/Mode.h>
25 #include <aidl/android/hardware/power/SessionConfig.h>
26 #include <aidl/android/hardware/power/SessionTag.h>
27 #include <aidl/android/hardware/power/WorkDuration.h>
28 #include <android-base/thread_annotations.h>
29 #include <fmq/AidlMessageQueue.h>
30 #include <fmq/EventFlag.h>
31 
32 #include <cstdint>
33 
34 namespace aidl::google::hardware::power::impl::pixel {
35 
36 using namespace android::hardware::power;
37 
38 using ::android::AidlMessageQueue;
39 using ::android::hardware::EventFlag;
40 using android::hardware::common::fmq::MQDescriptor;
41 using android::hardware::common::fmq::SynchronizedReadWrite;
42 
43 using ChannelQueueDesc = MQDescriptor<ChannelMessage, SynchronizedReadWrite>;
44 using ChannelQueue = AidlMessageQueue<ChannelMessage, SynchronizedReadWrite>;
45 using FlagQueueDesc = MQDescriptor<int8_t, SynchronizedReadWrite>;
46 using FlagQueue = AidlMessageQueue<int8_t, SynchronizedReadWrite>;
47 
48 enum class AdpfErrorCode : int32_t { ERR_OK = 0, ERR_BAD_STATE = -1, ERR_BAD_ARG = -2 };
49 
50 enum class AdpfVoteType : int32_t {
51     CPU_VOTE_DEFAULT = 0,
52     CPU_LOAD_UP,
53     CPU_LOAD_RESET,
54     CPU_LOAD_RESUME,
55     VOTE_POWER_EFFICIENCY,
56     GPU_LOAD_UP,
57     GPU_LOAD_DOWN,
58     GPU_LOAD_RESET,
59     GPU_CAPACITY,
60     VOTE_TYPE_SIZE
61 };
62 
AdpfVoteTypeToStr(AdpfVoteType voteType)63 constexpr const char *AdpfVoteTypeToStr(AdpfVoteType voteType) {
64     switch (voteType) {
65         case AdpfVoteType::CPU_VOTE_DEFAULT:
66             return "CPU_VOTE_DEFAULT";
67         case AdpfVoteType::CPU_LOAD_UP:
68             return "CPU_LOAD_UP";
69         case AdpfVoteType::CPU_LOAD_RESET:
70             return "CPU_LOAD_RESET";
71         case AdpfVoteType::CPU_LOAD_RESUME:
72             return "CPU_LOAD_RESUME";
73         case AdpfVoteType::VOTE_POWER_EFFICIENCY:
74             return "VOTE_POWER_EFFICIENCY";
75         case AdpfVoteType::GPU_LOAD_UP:
76             return "GPU_LOAD_UP";
77         case AdpfVoteType::GPU_LOAD_DOWN:
78             return "GPU_LOAD_DOWN";
79         case AdpfVoteType::GPU_LOAD_RESET:
80             return "GPU_LOAD_RESET";
81         case AdpfVoteType::GPU_CAPACITY:
82             return "GPU_CAPACITY";
83         default:
84             return "INVALID_VOTE";
85     }
86 }
87 
88 class Immobile {
89   public:
Immobile()90     Immobile() {}
91     Immobile(const Immobile &) = delete;
92     Immobile(Immobile &&) = delete;
93     Immobile &operator=(const Immobile &) = delete;
94     Immobile &operator=(Immobile &) = delete;
95 };
96 
97 constexpr int kUclampMin{0};
98 constexpr int kUclampMax{1024};
99 
100 }  // namespace aidl::google::hardware::power::impl::pixel
101