Wei Wang | 61c2a33 | 2020-01-08 16:51:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 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 | package android.hardware.power; |
| 18 | |
| 19 | import android.hardware.power.Boost; |
Wei Wang | 0500341 | 2021-04-01 10:44:29 -0700 | [diff] [blame] | 20 | import android.hardware.power.IPowerHintSession; |
Wei Wang | 61c2a33 | 2020-01-08 16:51:47 -0800 | [diff] [blame] | 21 | import android.hardware.power.Mode; |
| 22 | |
| 23 | @VintfStability |
| 24 | interface IPower { |
| 25 | /** |
| 26 | * setMode() is called to enable/disable specific hint mode, which |
| 27 | * may result in adjustment of power/performance parameters of the |
| 28 | * cpufreq governor and other controls on device side. |
| 29 | * |
| 30 | * A particular platform may choose to ignore any mode hint. |
| 31 | * |
| 32 | * @param type Mode which is to be enable/disable. |
| 33 | * @param enabled true to enable, false to disable the mode. |
| 34 | */ |
| 35 | oneway void setMode(in Mode type, in boolean enabled); |
| 36 | |
| 37 | /** |
| 38 | * isModeSupported() is called to query if the given mode hint is |
| 39 | * supported by vendor. |
| 40 | * |
| 41 | * @return true if the hint passed is supported on this platform. |
| 42 | * If false, setting the mode will have no effect. |
| 43 | * @param type Mode to be queried |
| 44 | */ |
| 45 | boolean isModeSupported(in Mode type); |
| 46 | |
Dan Stoza | cca8027 | 2020-01-13 13:06:13 -0800 | [diff] [blame] | 47 | /** |
Wei Wang | 61c2a33 | 2020-01-08 16:51:47 -0800 | [diff] [blame] | 48 | * setBoost() indicates the device may need to boost some resources, as the |
| 49 | * the load is likely to increase before the kernel governors can react. |
| 50 | * Depending on the boost, it may be appropriate to raise the frequencies of |
| 51 | * CPU, GPU, memory subsystem, or stop CPU from going into deep sleep state. |
| 52 | * A particular platform may choose to ignore this hint. |
| 53 | * |
| 54 | * @param type Boost type which is to be set with a timeout. |
| 55 | * @param durationMs The expected duration of the user's interaction, if |
| 56 | * known, or 0 if the expected duration is unknown. |
| 57 | * a negative value indicates canceling previous boost. |
| 58 | * A given platform can choose to boost some time based on durationMs, |
| 59 | * and may also pick an appropriate timeout for 0 case. |
| 60 | */ |
| 61 | oneway void setBoost(in Boost type, in int durationMs); |
| 62 | |
| 63 | /** |
| 64 | * isBoostSupported() is called to query if the given boost hint is |
| 65 | * supported by vendor. When returns false, set the boost will have |
| 66 | * no effect on the platform. |
| 67 | * |
| 68 | * @return true if the hint passed is supported on this platform. |
| 69 | * If false, setting the boost will have no effect. |
| 70 | * @param type Boost to be queried |
| 71 | */ |
| 72 | boolean isBoostSupported(in Boost type); |
Wei Wang | 0500341 | 2021-04-01 10:44:29 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * A Session represents a group of threads with an inter-related workload such that hints for |
| 76 | * their performance should be considered as a unit. The threads in a given session should be |
| 77 | * long-life and not created or destroyed dynamically. |
| 78 | * |
| 79 | * Each session is expected to have a periodic workload with a target duration for each |
| 80 | * cycle. The cycle duration is likely greater than the target work duration to allow other |
| 81 | * parts of the pipeline to run within the available budget. For example, a renderer thread may |
| 82 | * work at 60hz in order to produce frames at the display's frame but have a target work |
| 83 | * duration of only 6ms. |
| 84 | * |
| 85 | * Creates a session for the given set of threads and sets their initial target work |
| 86 | * duration. |
| 87 | * |
| 88 | * @return the new session if it is supported on this device, otherwise return with |
| 89 | * EX_UNSUPPORTED_OPERATION error if hint session is not supported on this device. |
| 90 | * @param tgid The TGID to be associated with this session. |
| 91 | * @param uid The UID to be associated with this session. |
| 92 | * @param threadIds The list of threads to be associated with this session. |
| 93 | * @param durationNanos The desired duration in nanoseconds for this session. |
| 94 | */ |
| 95 | IPowerHintSession createHintSession( |
| 96 | in int tgid, in int uid, in int[] threadIds, in long durationNanos); |
| 97 | |
| 98 | /** |
| 99 | * Get preferred update rate (interval) information for this device. Framework must communicate |
| 100 | * this rate to Apps, and also ensure the session hint sent no faster than the update rate. |
| 101 | * |
| 102 | * @return the preferred update rate in nanoseconds supported by device software. Return with |
| 103 | * EX_UNSUPPORTED_OPERATION if hint session is not supported. |
| 104 | */ |
| 105 | long getHintSessionPreferredRate(); |
Wei Wang | 61c2a33 | 2020-01-08 16:51:47 -0800 | [diff] [blame] | 106 | } |