• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 #ifndef CHRE_PLATFORM_POWER_CONTROL_UTIL_H
18 #define CHRE_PLATFORM_POWER_CONTROL_UTIL_H
19 
20 extern "C" {
21 
22 #include "qurt_island.h"
23 
24 }  // extern "C"
25 
26 #include "chre/core/event_loop_manager.h"
27 #include "chre/platform/slpi/uimg_util.h"
28 
29 namespace chre {
30 
31 /**
32  * @return true if we're currently running in micro-image, aka island mode.
33  */
slpiInUImage()34 inline bool slpiInUImage() {
35   return (qurt_island_get_status() == 1);
36 }
37 
38 /**
39  * @return true if the successfully made a micro to big image transition.
40  */
slpiForceBigImage()41 inline bool slpiForceBigImage() {
42   bool success = false;
43   if (isSlpiUimgSupported() && slpiInUImage()) {
44     success = EventLoopManagerSingleton::get()->getEventLoop().
45         getPowerControlManager().voteBigImage(true);
46   }
47 
48   return success;
49 }
50 
51 /**
52  * Removes a big image vote from CHRE. Should only be called when the system is
53  * idle.
54  *
55  * @return true if the vote succeeds.
56  */
slpiRemoveBigImageVote()57 inline bool slpiRemoveBigImageVote() {
58   return EventLoopManagerSingleton::get()->getEventLoop().
59       getPowerControlManager().voteBigImage(false);
60 }
61 
62 } // namespace chre
63 
64 #endif // CHRE_PLATFORM_POWER_CONTROL_UTIL_H
65