blob: a48918785b0eaa08bcfc91b7814257a1e7bf2e59 [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)
30
Todd Poynorc82792c2012-01-10 00:32:42 -080031/**
32 * The id of this module
33 */
34#define POWER_HARDWARE_MODULE_ID "power"
35
Vijaya Kumar T M7127ce22014-10-16 14:55:43 +053036/**
37* This definition is used by Camera HAL during camcorder recording.
38*
39*/
40#define HAS_MULTIMEDIA_HINTS
41
Todd Poynor2f143fb2012-04-24 13:39:15 -070042/*
43 * Power hint identifiers passed to (*powerHint)
44 */
45
46typedef enum {
Todd Poynor2f143fb2012-04-24 13:39:15 -070047 POWER_HINT_VSYNC = 0x00000001,
Todd Poynorbcdb4cd2012-05-03 14:49:02 -070048 POWER_HINT_INTERACTION = 0x00000002,
Iliyan Malchev1a70c0f2013-06-25 18:50:49 -070049 /* DO NOT USE POWER_HINT_VIDEO_ENCODE/_DECODE! They will be removed in
50 * KLP.
51 */
Mekala Natarajan501fc0f2013-06-19 15:57:22 -070052 POWER_HINT_VIDEO_ENCODE = 0x00000003,
Ruchi Kandoi62f67552014-05-02 13:52:51 -070053 POWER_HINT_VIDEO_DECODE = 0x00000004,
54 POWER_HINT_LOW_POWER = 0x00000005
Todd Poynor2f143fb2012-04-24 13:39:15 -070055} power_hint_t;
56
Todd Poynorc82792c2012-01-10 00:32:42 -080057/**
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.
61 */
62typedef struct power_module {
63 struct hw_module_t common;
64
65 /*
66 * (*init)() performs power management setup actions at runtime
Todd Poynor2f143fb2012-04-24 13:39:15 -070067 * startup, such as to set default cpufreq parameters. This is
68 * called only by the Power HAL instance loaded by
69 * PowerManagerService.
Todd Poynorc82792c2012-01-10 00:32:42 -080070 */
71 void (*init)(struct power_module *module);
72
73 /*
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.
82 *
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.
90 *
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.
94 *
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.
98 */
99 void (*setInteractive)(struct power_module *module, int on);
Todd Poynor2f143fb2012-04-24 13:39:15 -0700100
101 /*
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:
105 *
106 * POWER_HINT_VSYNC
107 *
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.
114 *
Todd Poynorbcdb4cd2012-05-03 14:49:02 -0700115 * POWER_HINT_INTERACTION
116 *
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 unused.
121 *
Ruchi Kandoi62f67552014-05-02 13:52:51 -0700122 * POWER_HINT_LOW_POWER
123 *
124 * Low power mode is activated or deactivated. Low power mode
125 * is intended to save battery at the cost of performance. The data
126 * parameter is non-zero when low power mode is activated, and zero
127 * when deactivated.
128 *
Todd Poynor2f143fb2012-04-24 13:39:15 -0700129 * A particular platform may choose to ignore any hint.
Mathias Agopian5cb1de82012-04-26 19:49:40 -0700130 *
131 * availability: version 0.2
132 *
Todd Poynor2f143fb2012-04-24 13:39:15 -0700133 */
134 void (*powerHint)(struct power_module *module, power_hint_t hint,
135 void *data);
Todd Poynorc82792c2012-01-10 00:32:42 -0800136} power_module_t;
137
138
139__END_DECLS
140
141#endif // ANDROID_INCLUDE_HARDWARE_POWER_H