Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 1 | /* |
Dilip Gudlur | 84060b6 | 2016-07-18 10:36:08 -0700 | [diff] [blame] | 2 | * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 3 | * Copyright (C) 2018 The LineageOS Project |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are |
| 7 | * met: |
| 8 | * * * Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * * Redistributions in binary form must reproduce the above |
| 11 | * copyright notice, this list of conditions and the following |
| 12 | * disclaimer in the documentation and/or other materials provided |
| 13 | * with the distribution. |
| 14 | * * Neither the name of The Linux Foundation nor the names of its |
| 15 | * contributors may be used to endorse or promote products derived |
| 16 | * from this software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 22 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 25 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 26 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 27 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 28 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
Michael Bestas | 47636f6 | 2018-05-25 21:30:28 +0300 | [diff] [blame] | 30 | |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 31 | #define LOG_NIDEBUG 0 |
| 32 | |
| 33 | #include <errno.h> |
BeYkeRYkt | bd52e81 | 2018-12-13 06:42:35 +0900 | [diff] [blame] | 34 | #include <time.h> |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 35 | #include <string.h> |
| 36 | #include <sys/types.h> |
| 37 | #include <sys/stat.h> |
| 38 | #include <fcntl.h> |
| 39 | #include <dlfcn.h> |
| 40 | #include <stdlib.h> |
| 41 | |
| 42 | #define LOG_TAG "QCOM PowerHAL" |
Rashed Abdel-Tawab | 9c14c9f | 2017-12-26 23:11:03 +0200 | [diff] [blame] | 43 | #include <log/log.h> |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 44 | #include <hardware/hardware.h> |
| 45 | #include <hardware/power.h> |
| 46 | |
| 47 | #include "utils.h" |
| 48 | #include "metadata-defs.h" |
| 49 | #include "hint-data.h" |
| 50 | #include "performance.h" |
| 51 | #include "power-common.h" |
| 52 | |
Michael Bestas | 47636f6 | 2018-05-25 21:30:28 +0300 | [diff] [blame] | 53 | #define NUM_PERF_MODES 3 |
| 54 | |
tomascus | 8b038b1 | 2019-02-19 17:15:58 +1100 | [diff] [blame] | 55 | const int kMaxLaunchDuration = 5000; /* ms */ |
BeYkeRYkt | bd52e81 | 2018-12-13 06:42:35 +0900 | [diff] [blame] | 56 | const int kMaxInteractiveDuration = 5000; /* ms */ |
| 57 | const int kMinInteractiveDuration = 500; /* ms */ |
BeYkeRYkt | bd52e81 | 2018-12-13 06:42:35 +0900 | [diff] [blame] | 58 | |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 59 | static int current_power_profile = PROFILE_BALANCED; |
| 60 | |
| 61 | static int profile_high_performance[] = { |
| 62 | SCHED_BOOST_ON_V3, 0x1, |
| 63 | ALL_CPUS_PWR_CLPS_DIS_V3, 0x1, |
| 64 | CPUS_ONLINE_MIN_BIG, 0x2, |
| 65 | CPUS_ONLINE_MIN_LITTLE, 0x2, |
| 66 | MIN_FREQ_BIG_CORE_0, 0xFFF, |
| 67 | MIN_FREQ_LITTLE_CORE_0, 0xFFF, |
| 68 | }; |
| 69 | |
| 70 | static int profile_power_save[] = { |
dianlujitao | 5eb472d | 2018-09-06 21:43:14 +0800 | [diff] [blame] | 71 | CPUS_ONLINE_MAX_BIG, 0x1, |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 72 | MAX_FREQ_BIG_CORE_0, 0x3E8, |
| 73 | MAX_FREQ_LITTLE_CORE_0, 0x3E8, |
| 74 | }; |
| 75 | |
| 76 | static int profile_bias_power[] = { |
| 77 | MAX_FREQ_BIG_CORE_0, 0x514, |
| 78 | MAX_FREQ_LITTLE_CORE_0, 0x3E8, |
| 79 | }; |
| 80 | |
| 81 | static int profile_bias_performance[] = { |
dianlujitao | 5eb472d | 2018-09-06 21:43:14 +0800 | [diff] [blame] | 82 | CPUS_ONLINE_MAX_BIG, 0x2, |
| 83 | CPUS_ONLINE_MAX_LITTLE, 0x2, |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 84 | MIN_FREQ_BIG_CORE_0, 0x578, |
| 85 | }; |
| 86 | |
dianlujitao | 4004811 | 2018-03-02 12:40:04 +0800 | [diff] [blame] | 87 | #ifdef INTERACTION_BOOST |
Michael Bestas | 47636f6 | 2018-05-25 21:30:28 +0300 | [diff] [blame] | 88 | int get_number_of_profiles() |
| 89 | { |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 90 | return 5; |
| 91 | } |
dianlujitao | 4004811 | 2018-03-02 12:40:04 +0800 | [diff] [blame] | 92 | #endif |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 93 | |
dianlujitao | 8780cb7 | 2019-02-23 20:24:57 +0800 | [diff] [blame] | 94 | static int set_power_profile(void *data) |
Michael Bestas | 47636f6 | 2018-05-25 21:30:28 +0300 | [diff] [blame] | 95 | { |
dianlujitao | 8780cb7 | 2019-02-23 20:24:57 +0800 | [diff] [blame] | 96 | int profile = data ? *((int*)data) : 0; |
Corinna Vinschen | 8599e3c | 2018-08-26 22:11:49 +0200 | [diff] [blame] | 97 | int ret = -EINVAL; |
| 98 | const char *profile_name = NULL; |
| 99 | |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 100 | if (profile == current_power_profile) |
Corinna Vinschen | 8599e3c | 2018-08-26 22:11:49 +0200 | [diff] [blame] | 101 | return 0; |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 102 | |
| 103 | ALOGV("%s: Profile=%d", __func__, profile); |
| 104 | |
| 105 | if (current_power_profile != PROFILE_BALANCED) { |
| 106 | undo_hint_action(DEFAULT_PROFILE_HINT_ID); |
| 107 | ALOGV("%s: Hint undone", __func__); |
Corinna Vinschen | 8599e3c | 2018-08-26 22:11:49 +0200 | [diff] [blame] | 108 | current_power_profile = PROFILE_BALANCED; |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | if (profile == PROFILE_POWER_SAVE) { |
Corinna Vinschen | 8599e3c | 2018-08-26 22:11:49 +0200 | [diff] [blame] | 112 | ret = perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_power_save, |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 113 | ARRAY_SIZE(profile_power_save)); |
Corinna Vinschen | 8599e3c | 2018-08-26 22:11:49 +0200 | [diff] [blame] | 114 | profile_name = "powersave"; |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 115 | |
| 116 | } else if (profile == PROFILE_HIGH_PERFORMANCE) { |
Corinna Vinschen | 8599e3c | 2018-08-26 22:11:49 +0200 | [diff] [blame] | 117 | ret = perform_hint_action(DEFAULT_PROFILE_HINT_ID, |
| 118 | profile_high_performance, ARRAY_SIZE(profile_high_performance)); |
| 119 | profile_name = "performance"; |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 120 | |
| 121 | } else if (profile == PROFILE_BIAS_POWER) { |
Corinna Vinschen | 8599e3c | 2018-08-26 22:11:49 +0200 | [diff] [blame] | 122 | ret = perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_power, |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 123 | ARRAY_SIZE(profile_bias_power)); |
Corinna Vinschen | 8599e3c | 2018-08-26 22:11:49 +0200 | [diff] [blame] | 124 | profile_name = "bias power"; |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 125 | |
| 126 | } else if (profile == PROFILE_BIAS_PERFORMANCE) { |
Corinna Vinschen | 8599e3c | 2018-08-26 22:11:49 +0200 | [diff] [blame] | 127 | ret = perform_hint_action(DEFAULT_PROFILE_HINT_ID, |
| 128 | profile_bias_performance, ARRAY_SIZE(profile_bias_performance)); |
| 129 | profile_name = "bias perf"; |
| 130 | } else if (profile == PROFILE_BALANCED) { |
| 131 | ret = 0; |
| 132 | profile_name = "balanced"; |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 133 | } |
| 134 | |
Corinna Vinschen | 8599e3c | 2018-08-26 22:11:49 +0200 | [diff] [blame] | 135 | if (ret == 0) { |
| 136 | current_power_profile = profile; |
| 137 | ALOGD("%s: Set %s mode", __func__, profile_name); |
| 138 | } |
| 139 | return ret; |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 140 | } |
| 141 | |
dianlujitao | fed6fde | 2018-01-20 19:00:05 +0800 | [diff] [blame] | 142 | typedef enum { |
| 143 | NORMAL_MODE = 0, |
| 144 | SUSTAINED_MODE = 1, |
| 145 | VR_MODE = 2, |
| 146 | VR_SUSTAINED_MODE = (SUSTAINED_MODE|VR_MODE), |
| 147 | INVALID_MODE = 0xFF |
| 148 | } perf_mode_type_t; |
| 149 | |
| 150 | typedef struct perf_mode { |
| 151 | perf_mode_type_t type; |
| 152 | int perf_hint_id; |
| 153 | } perf_mode_t; |
| 154 | |
| 155 | perf_mode_t perf_modes[NUM_PERF_MODES] = { |
| 156 | { SUSTAINED_MODE, SUSTAINED_PERF_HINT }, |
| 157 | { VR_MODE, VR_MODE_HINT }, |
| 158 | { VR_SUSTAINED_MODE, VR_MODE_SUSTAINED_PERF_HINT } |
| 159 | }; |
| 160 | |
| 161 | static int current_mode = NORMAL_MODE; |
| 162 | |
Michael Bestas | 47636f6 | 2018-05-25 21:30:28 +0300 | [diff] [blame] | 163 | static inline int get_perfd_hint_id(perf_mode_type_t type) { |
dianlujitao | fed6fde | 2018-01-20 19:00:05 +0800 | [diff] [blame] | 164 | int i; |
| 165 | for (i = 0; i < NUM_PERF_MODES; i++) { |
| 166 | if (perf_modes[i].type == type) { |
| 167 | ALOGD("Hint id is 0x%x for mode 0x%x", perf_modes[i].perf_hint_id, type); |
| 168 | return perf_modes[i].perf_hint_id; |
| 169 | } |
| 170 | } |
| 171 | ALOGD("Couldn't find the hint for mode 0x%x", type); |
| 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | static int switch_mode(perf_mode_type_t mode) { |
dianlujitao | fed6fde | 2018-01-20 19:00:05 +0800 | [diff] [blame] | 176 | int hint_id = 0; |
| 177 | static int perfd_mode_handle = -1; |
| 178 | |
| 179 | // release existing mode if any |
| 180 | if (CHECK_HANDLE(perfd_mode_handle)) { |
| 181 | ALOGD("Releasing handle 0x%x", perfd_mode_handle); |
| 182 | release_request(perfd_mode_handle); |
| 183 | perfd_mode_handle = -1; |
| 184 | } |
| 185 | // switch to a perf mode |
| 186 | hint_id = get_perfd_hint_id(mode); |
| 187 | if (hint_id != 0) { |
| 188 | perfd_mode_handle = perf_hint_enable(hint_id, 0); |
| 189 | if (!CHECK_HANDLE(perfd_mode_handle)) { |
| 190 | ALOGE("Failed perf_hint_interaction for mode: 0x%x", mode); |
| 191 | return -1; |
| 192 | } |
| 193 | ALOGD("Acquired handle 0x%x", perfd_mode_handle); |
| 194 | } |
| 195 | return 0; |
| 196 | } |
| 197 | |
| 198 | static int process_perf_hint(void *data, perf_mode_type_t mode) { |
dianlujitao | fed6fde | 2018-01-20 19:00:05 +0800 | [diff] [blame] | 199 | // enable |
dianlujitao | 8780cb7 | 2019-02-23 20:24:57 +0800 | [diff] [blame] | 200 | if (data) { |
dianlujitao | fed6fde | 2018-01-20 19:00:05 +0800 | [diff] [blame] | 201 | ALOGI("Enable request for mode: 0x%x", mode); |
| 202 | // check if mode is current mode |
Michael Bestas | 47636f6 | 2018-05-25 21:30:28 +0300 | [diff] [blame] | 203 | if (current_mode & mode) { |
dianlujitao | fed6fde | 2018-01-20 19:00:05 +0800 | [diff] [blame] | 204 | ALOGD("Mode 0x%x already enabled", mode); |
| 205 | return HINT_HANDLED; |
| 206 | } |
| 207 | // enable requested mode |
Michael Bestas | 47636f6 | 2018-05-25 21:30:28 +0300 | [diff] [blame] | 208 | if (0 != switch_mode(current_mode | mode)) { |
dianlujitao | fed6fde | 2018-01-20 19:00:05 +0800 | [diff] [blame] | 209 | ALOGE("Couldn't enable mode 0x%x", mode); |
| 210 | return HINT_NONE; |
| 211 | } |
| 212 | current_mode |= mode; |
| 213 | ALOGI("Current mode is 0x%x", current_mode); |
| 214 | // disable |
| 215 | } else { |
| 216 | ALOGI("Disable request for mode: 0x%x", mode); |
| 217 | // check if mode is enabled |
Michael Bestas | 47636f6 | 2018-05-25 21:30:28 +0300 | [diff] [blame] | 218 | if (!(current_mode & mode)) { |
dianlujitao | fed6fde | 2018-01-20 19:00:05 +0800 | [diff] [blame] | 219 | ALOGD("Mode 0x%x already disabled", mode); |
| 220 | return HINT_HANDLED; |
| 221 | } |
Michael Bestas | 47636f6 | 2018-05-25 21:30:28 +0300 | [diff] [blame] | 222 | // disable requested mode |
| 223 | if (0 != switch_mode(current_mode & ~mode)) { |
dianlujitao | fed6fde | 2018-01-20 19:00:05 +0800 | [diff] [blame] | 224 | ALOGE("Couldn't disable mode 0x%x", mode); |
| 225 | return HINT_NONE; |
| 226 | } |
| 227 | current_mode &= ~mode; |
| 228 | ALOGI("Current mode is 0x%x", current_mode); |
| 229 | } |
| 230 | |
| 231 | return HINT_HANDLED; |
| 232 | } |
| 233 | |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 234 | static int process_video_encode_hint(void *metadata) |
| 235 | { |
| 236 | char governor[80]; |
| 237 | struct video_encode_metadata_t video_encode_metadata; |
dianlujitao | 281c136 | 2018-01-20 18:54:04 +0800 | [diff] [blame] | 238 | static int video_encode_handle = 0; |
| 239 | |
| 240 | if (!metadata) { |
| 241 | return HINT_NONE; |
| 242 | } |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 243 | |
| 244 | if (get_scaling_governor(governor, sizeof(governor)) == -1) { |
| 245 | ALOGE("Can't obtain scaling governor."); |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 246 | return HINT_NONE; |
| 247 | } |
| 248 | |
| 249 | /* Initialize encode metadata struct fields */ |
| 250 | memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t)); |
| 251 | video_encode_metadata.state = -1; |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 252 | |
dianlujitao | 281c136 | 2018-01-20 18:54:04 +0800 | [diff] [blame] | 253 | if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) == -1) { |
| 254 | ALOGE("Error occurred while parsing metadata."); |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 255 | return HINT_NONE; |
| 256 | } |
| 257 | |
| 258 | if (video_encode_metadata.state == 1) { |
dianlujitao | 281c136 | 2018-01-20 18:54:04 +0800 | [diff] [blame] | 259 | if (is_interactive_governor(governor)) { |
| 260 | video_encode_handle = perf_hint_enable( |
| 261 | VIDEO_ENCODE_HINT, 0); |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 262 | return HINT_HANDLED; |
| 263 | } |
| 264 | } else if (video_encode_metadata.state == 0) { |
dianlujitao | 281c136 | 2018-01-20 18:54:04 +0800 | [diff] [blame] | 265 | if (is_interactive_governor(governor)) { |
| 266 | release_request(video_encode_handle); |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 267 | return HINT_HANDLED; |
| 268 | } |
| 269 | } |
| 270 | return HINT_NONE; |
| 271 | } |
| 272 | |
tomascus | 8b038b1 | 2019-02-19 17:15:58 +1100 | [diff] [blame] | 273 | static int process_activity_launch_hint(void *data) |
BeYkeRYkt | bd52e81 | 2018-12-13 06:42:35 +0900 | [diff] [blame] | 274 | { |
tomascus | 8b038b1 | 2019-02-19 17:15:58 +1100 | [diff] [blame] | 275 | static int launch_handle = -1; |
| 276 | static int launch_mode = 0; |
| 277 | |
| 278 | // release lock early if launch has finished |
| 279 | if (!data) { |
| 280 | if (CHECK_HANDLE(launch_handle)) { |
| 281 | release_request(launch_handle); |
| 282 | launch_handle = -1; |
| 283 | } |
| 284 | launch_mode = 0; |
| 285 | return HINT_HANDLED; |
| 286 | } |
| 287 | |
BeYkeRYkt | bd52e81 | 2018-12-13 06:42:35 +0900 | [diff] [blame] | 288 | if (current_mode != NORMAL_MODE) { |
| 289 | ALOGV("%s: ignoring due to other active perf hints", __func__); |
tomascus | 8b038b1 | 2019-02-19 17:15:58 +1100 | [diff] [blame] | 290 | } else if (!launch_mode) { |
| 291 | launch_handle = perf_hint_enable_with_type(VENDOR_HINT_FIRST_LAUNCH_BOOST, |
| 292 | kMaxLaunchDuration, LAUNCH_BOOST_V1); |
| 293 | if (!CHECK_HANDLE(launch_handle)) { |
| 294 | ALOGE("Failed to perform launch boost"); |
| 295 | return HINT_NONE; |
| 296 | } |
| 297 | launch_mode = 1; |
BeYkeRYkt | bd52e81 | 2018-12-13 06:42:35 +0900 | [diff] [blame] | 298 | } |
| 299 | return HINT_HANDLED; |
| 300 | } |
| 301 | |
| 302 | static int process_interaction_hint(void *data) |
| 303 | { |
| 304 | static struct timespec s_previous_boost_timespec; |
| 305 | static int s_previous_duration = 0; |
| 306 | |
| 307 | struct timespec cur_boost_timespec; |
| 308 | long long elapsed_time; |
| 309 | int duration = kMinInteractiveDuration; |
| 310 | |
| 311 | if (current_mode != NORMAL_MODE) { |
| 312 | ALOGV("%s: ignoring due to other active perf hints", __func__); |
| 313 | return HINT_HANDLED; |
| 314 | } |
| 315 | |
| 316 | if (data) { |
| 317 | int input_duration = *((int*)data); |
| 318 | if (input_duration > duration) { |
| 319 | duration = (input_duration > kMaxInteractiveDuration) ? |
| 320 | kMaxInteractiveDuration : input_duration; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec); |
| 325 | |
| 326 | elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec); |
| 327 | // don't hint if previous hint's duration covers this hint's duration |
| 328 | if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) { |
| 329 | return HINT_HANDLED; |
| 330 | } |
| 331 | s_previous_boost_timespec = cur_boost_timespec; |
| 332 | s_previous_duration = duration; |
| 333 | |
tomascus | 1c38bac | 2019-02-13 14:42:27 +1100 | [diff] [blame] | 334 | perf_hint_enable_with_type(VENDOR_HINT_SCROLL_BOOST, duration, SCROLL_VERTICAL); |
BeYkeRYkt | bd52e81 | 2018-12-13 06:42:35 +0900 | [diff] [blame] | 335 | |
| 336 | return HINT_HANDLED; |
| 337 | } |
| 338 | |
Rashed Abdel-Tawab | 00b2185 | 2017-11-03 12:44:16 -0700 | [diff] [blame] | 339 | int power_hint_override(power_hint_t hint, void *data) |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 340 | { |
| 341 | int ret_val = HINT_NONE; |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 342 | |
| 343 | if (hint == POWER_HINT_SET_PROFILE) { |
dianlujitao | 8780cb7 | 2019-02-23 20:24:57 +0800 | [diff] [blame] | 344 | if (set_power_profile(data) < 0) |
Corinna Vinschen | 8599e3c | 2018-08-26 22:11:49 +0200 | [diff] [blame] | 345 | ALOGE("Setting power profile failed. perf HAL not started?"); |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 346 | return HINT_HANDLED; |
| 347 | } |
| 348 | |
Michael Bestas | 8ff509e | 2018-03-26 05:21:23 +0300 | [diff] [blame] | 349 | // Skip other hints in high/low power modes |
| 350 | if (current_power_profile == PROFILE_POWER_SAVE || |
| 351 | current_power_profile == PROFILE_HIGH_PERFORMANCE) { |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 352 | return HINT_HANDLED; |
Michael Bestas | 8ff509e | 2018-03-26 05:21:23 +0300 | [diff] [blame] | 353 | } |
dianlujitao | c9f97d7 | 2018-01-18 23:34:38 +0800 | [diff] [blame] | 354 | |
Michael Bestas | 8ff509e | 2018-03-26 05:21:23 +0300 | [diff] [blame] | 355 | switch (hint) { |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 356 | case POWER_HINT_VIDEO_ENCODE: |
| 357 | ret_val = process_video_encode_hint(data); |
| 358 | break; |
dianlujitao | fed6fde | 2018-01-20 19:00:05 +0800 | [diff] [blame] | 359 | case POWER_HINT_SUSTAINED_PERFORMANCE: |
| 360 | ret_val = process_perf_hint(data, SUSTAINED_MODE); |
| 361 | break; |
| 362 | case POWER_HINT_VR_MODE: |
| 363 | ret_val = process_perf_hint(data, VR_MODE); |
| 364 | break; |
BeYkeRYkt | bd52e81 | 2018-12-13 06:42:35 +0900 | [diff] [blame] | 365 | case POWER_HINT_INTERACTION: |
| 366 | ret_val = process_interaction_hint(data); |
| 367 | break; |
| 368 | case POWER_HINT_LAUNCH: |
| 369 | ret_val = process_activity_launch_hint(data); |
| 370 | break; |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 371 | default: |
| 372 | break; |
| 373 | } |
| 374 | return ret_val; |
| 375 | } |
| 376 | |
Michael Bestas | 6204c67 | 2018-03-26 03:26:31 +0300 | [diff] [blame] | 377 | int set_interactive_override(int UNUSED(on)) |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 378 | { |
| 379 | return HINT_HANDLED; /* Don't excecute this code path, not in use */ |
Dilip Gudlur | 4edd2c3 | 2015-07-01 14:13:43 -0700 | [diff] [blame] | 380 | } |