2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_INCLUDE_HARDWARE_POWER_H
18 #define ANDROID_INCLUDE_HARDWARE_POWER_H
21 #include <sys/cdefs.h>
22 #include <sys/types.h>
24 #include <hardware/hardware.h>
28 #define POWER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1)
29 #define POWER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2)
30 #define POWER_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3)
33 * The id of this module
35 #define POWER_HARDWARE_MODULE_ID "power"
38 * Power hint identifiers passed to (*powerHint)
42 POWER_HINT_VSYNC = 0x00000001,
43 POWER_HINT_INTERACTION = 0x00000002,
44 /* DO NOT USE POWER_HINT_VIDEO_ENCODE/_DECODE! They will be removed in
47 POWER_HINT_VIDEO_ENCODE = 0x00000003,
48 POWER_HINT_VIDEO_DECODE = 0x00000004,
49 POWER_HINT_LOW_POWER = 0x00000005,
50 POWER_HINT_FOREGROUND_LOAD = 0x00000006
54 POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 0x00000001
58 * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
59 * and the fields of this data structure must begin with hw_module_t
60 * followed by module specific information.
62 typedef struct power_module {
63 struct hw_module_t common;
66 * (*init)() performs power management setup actions at runtime
67 * startup, such as to set default cpufreq parameters. This is
68 * called only by the Power HAL instance loaded by
69 * PowerManagerService.
71 void (*init)(struct power_module *module);
74 * (*setInteractive)() performs power management actions upon the
75 * system entering interactive state (that is, the system is awake
76 * and ready for interaction, often with UI devices such as
77 * display and touchscreen enabled) or non-interactive state (the
78 * system appears asleep, display usually turned off). The
79 * non-interactive state is usually entered after a period of
80 * inactivity, in order to conserve battery power during
81 * such inactive periods.
83 * Typical actions are to turn on or off devices and adjust
84 * cpufreq parameters. This function may also call the
85 * appropriate interfaces to allow the kernel to suspend the
86 * system to low-power sleep state when entering non-interactive
87 * state, and to disallow low-power suspend when the system is in
88 * interactive state. When low-power suspend state is allowed, the
89 * kernel may suspend the system whenever no wakelocks are held.
91 * on is non-zero when the system is transitioning to an
92 * interactive / awake state, and zero when transitioning to a
93 * non-interactive / asleep state.
95 * This function is called to enter non-interactive state after
96 * turning off the screen (if present), and called to enter
97 * interactive state prior to turning on the screen.
99 void (*setInteractive)(struct power_module *module, int on);
102 * (*powerHint) is called to pass hints on power requirements, which
103 * may result in adjustment of power/performance parameters of the
104 * cpufreq governor and other controls. The possible hints are:
108 * Foreground app has started or stopped requesting a VSYNC pulse
109 * from SurfaceFlinger. If the app has started requesting VSYNC
110 * then CPU and GPU load is expected soon, and it may be appropriate
111 * to raise speeds of CPU, memory bus, etc. The data parameter is
112 * non-zero to indicate VSYNC pulse is now requested, or zero for
113 * VSYNC pulse no longer requested.
115 * POWER_HINT_INTERACTION
117 * User is interacting with the device, for example, touchscreen
118 * events are incoming. CPU and GPU load may be expected soon,
119 * and it may be appropriate to raise speeds of CPU, memory bus,
120 * etc. The data parameter is the estimated length of the interaction
121 * in milliseconds, or 0 if unknown.
123 * POWER_HINT_LOW_POWER
125 * Low power mode is activated or deactivated. Low power mode
126 * is intended to save battery at the cost of performance. The data
127 * parameter is non-zero when low power mode is activated, and zero
130 * A particular platform may choose to ignore any hint.
132 * availability: version 0.2
135 void (*powerHint)(struct power_module *module, power_hint_t hint,
139 * (*setFeature) is called to turn on or off a particular feature
140 * depending on the state parameter. The possible features are:
142 * FEATURE_DOUBLE_TAP_TO_WAKE
144 * Enabling/Disabling this feature will allow/disallow the system
145 * to wake up by tapping the screen twice.
147 * availability: version 0.3
150 void (*setFeature)(struct power_module *module, feature_t feature, int state);
157 #endif // ANDROID_INCLUDE_HARDWARE_POWER_H