blob: bb576256668900fd5310f8a149d6a306821a92c8 [file] [log] [blame]
Todd Poynorc82792c2012-01-10 00:32:42 -08001/*
2 * Copyright (C) 2012 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 ANDROID_INCLUDE_HARDWARE_POWER_H
18#define ANDROID_INCLUDE_HARDWARE_POWER_H
19
20#include <stdint.h>
21#include <sys/cdefs.h>
22#include <sys/types.h>
23
24#include <hardware/hardware.h>
25
26__BEGIN_DECLS
27
Mathias Agopian5cb1de82012-04-26 19:49:40 -070028#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)
Ruchi Kandoid0917132014-10-29 10:43:38 -070030#define POWER_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3)
Mathias Agopian5cb1de82012-04-26 19:49:40 -070031
Todd Poynorc82792c2012-01-10 00:32:42 -080032/**
33 * The id of this module
34 */
35#define POWER_HARDWARE_MODULE_ID "power"
36
Vijaya Kumar T M7127ce22014-10-16 14:55:43 +053037/**
38* This definition is used by Camera HAL during camcorder recording.
39*
40*/
41#define HAS_MULTIMEDIA_HINTS
42
Todd Poynor2f143fb2012-04-24 13:39:15 -070043/*
44 * Power hint identifiers passed to (*powerHint)
45 */
46
47typedef enum {
Todd Poynor2f143fb2012-04-24 13:39:15 -070048 POWER_HINT_VSYNC = 0x00000001,
Todd Poynorbcdb4cd2012-05-03 14:49:02 -070049 POWER_HINT_INTERACTION = 0x00000002,
Iliyan Malchev1a70c0f2013-06-25 18:50:49 -070050 /* DO NOT USE POWER_HINT_VIDEO_ENCODE/_DECODE! They will be removed in
51 * KLP.
52 */
Mekala Natarajan501fc0f2013-06-19 15:57:22 -070053 POWER_HINT_VIDEO_ENCODE = 0x00000003,
Ruchi Kandoi62f67552014-05-02 13:52:51 -070054 POWER_HINT_VIDEO_DECODE = 0x00000004,
55 POWER_HINT_LOW_POWER = 0x00000005
Todd Poynor2f143fb2012-04-24 13:39:15 -070056} power_hint_t;
57
Ruchi Kandoid0917132014-10-29 10:43:38 -070058typedef enum {
59 POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 0x00000001
60} feature_t;
61
Todd Poynorc82792c2012-01-10 00:32:42 -080062/**
63 * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
64 * and the fields of this data structure must begin with hw_module_t
65 * followed by module specific information.
66 */
67typedef struct power_module {
68 struct hw_module_t common;
69
70 /*
71 * (*init)() performs power management setup actions at runtime
Todd Poynor2f143fb2012-04-24 13:39:15 -070072 * startup, such as to set default cpufreq parameters. This is
73 * called only by the Power HAL instance loaded by
74 * PowerManagerService.
Todd Poynorc82792c2012-01-10 00:32:42 -080075 */
76 void (*init)(struct power_module *module);
77
78 /*
79 * (*setInteractive)() performs power management actions upon the
80 * system entering interactive state (that is, the system is awake
81 * and ready for interaction, often with UI devices such as
82 * display and touchscreen enabled) or non-interactive state (the
83 * system appears asleep, display usually turned off). The
84 * non-interactive state is usually entered after a period of
85 * inactivity, in order to conserve battery power during
86 * such inactive periods.
87 *
88 * Typical actions are to turn on or off devices and adjust
89 * cpufreq parameters. This function may also call the
90 * appropriate interfaces to allow the kernel to suspend the
91 * system to low-power sleep state when entering non-interactive
92 * state, and to disallow low-power suspend when the system is in
93 * interactive state. When low-power suspend state is allowed, the
94 * kernel may suspend the system whenever no wakelocks are held.
95 *
96 * on is non-zero when the system is transitioning to an
97 * interactive / awake state, and zero when transitioning to a
98 * non-interactive / asleep state.
99 *
100 * This function is called to enter non-interactive state after
101 * turning off the screen (if present), and called to enter
102 * interactive state prior to turning on the screen.
103 */
104 void (*setInteractive)(struct power_module *module, int on);
Todd Poynor2f143fb2012-04-24 13:39:15 -0700105
106 /*
107 * (*powerHint) is called to pass hints on power requirements, which
108 * may result in adjustment of power/performance parameters of the
109 * cpufreq governor and other controls. The possible hints are:
110 *
111 * POWER_HINT_VSYNC
112 *
113 * Foreground app has started or stopped requesting a VSYNC pulse
114 * from SurfaceFlinger. If the app has started requesting VSYNC
115 * then CPU and GPU load is expected soon, and it may be appropriate
116 * to raise speeds of CPU, memory bus, etc. The data parameter is
117 * non-zero to indicate VSYNC pulse is now requested, or zero for
118 * VSYNC pulse no longer requested.
119 *
Todd Poynorbcdb4cd2012-05-03 14:49:02 -0700120 * POWER_HINT_INTERACTION
121 *
122 * User is interacting with the device, for example, touchscreen
123 * events are incoming. CPU and GPU load may be expected soon,
124 * and it may be appropriate to raise speeds of CPU, memory bus,
125 * etc. The data parameter is unused.
126 *
Ruchi Kandoi62f67552014-05-02 13:52:51 -0700127 * POWER_HINT_LOW_POWER
128 *
129 * Low power mode is activated or deactivated. Low power mode
130 * is intended to save battery at the cost of performance. The data
131 * parameter is non-zero when low power mode is activated, and zero
132 * when deactivated.
133 *
Todd Poynor2f143fb2012-04-24 13:39:15 -0700134 * A particular platform may choose to ignore any hint.
Mathias Agopian5cb1de82012-04-26 19:49:40 -0700135 *
136 * availability: version 0.2
137 *
Todd Poynor2f143fb2012-04-24 13:39:15 -0700138 */
139 void (*powerHint)(struct power_module *module, power_hint_t hint,
140 void *data);
Ruchi Kandoid0917132014-10-29 10:43:38 -0700141
142 /*
143 * (*setFeature) is called to turn on or off a particular feature
144 * depending on the state parameter. The possible features are:
145 *
146 * FEATURE_DOUBLE_TAP_TO_WAKE
147 *
148 * Enabling/Disabling this feature will allow/disallow the system
149 * to wake up by tapping the screen twice.
150 *
151 * availability: version 0.3
152 *
153 */
154 void (*setFeature)(struct power_module *module, feature_t feature, int state);
155
Todd Poynorc82792c2012-01-10 00:32:42 -0800156} power_module_t;
157
158
159__END_DECLS
160
161#endif // ANDROID_INCLUDE_HARDWARE_POWER_H