• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2024 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/BnPowerHintSession.h>
20 #include <aidl/android/hardware/power/SessionTag.h>
21 
22 #include <chrono>
23 
24 namespace aidl::google::hardware::power::impl::pixel {
25 
26 // The App Hint Descriptor struct manages information necessary
27 // to calculate the next uclamp min value from the PID function
28 // and is separate so that it can be used as a pointer for
29 // easily passing to the pid function
30 struct AppHintDesc {
AppHintDescAppHintDesc31     AppHintDesc(int64_t sessionId, int32_t tgid, int32_t uid, const std::vector<int32_t> &threadIds,
32                 android::hardware::power::SessionTag tag, std::chrono::nanoseconds pTargetNs)
33         : sessionId(sessionId),
34           tgid(tgid),
35           uid(uid),
36           targetNs(pTargetNs),
37           thread_ids(threadIds),
38           tag(tag),
39           pidControlVariable(0),
40           is_active(true),
41           update_count(0),
42           integral_error(0),
43           previous_error(0) {}
44 
45     std::string toString() const;
46     int64_t sessionId{0};
47     const int32_t tgid;
48     const int32_t uid;
49     std::chrono::nanoseconds targetNs;
50     std::vector<int32_t> thread_ids;
51     android::hardware::power::SessionTag tag;
52     int pidControlVariable;
53     // status
54     std::atomic<bool> is_active;
55     // pid
56     uint64_t update_count = 0;
57     int64_t integral_error = 0;
58     int64_t previous_error = 0;
59 };
60 
61 }  // namespace aidl::google::hardware::power::impl::pixel
62