blob: 1cb21341d3f2f43c259a949202ab7a8f13516e13 [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
28/**
29 * The id of this module
30 */
31#define POWER_HARDWARE_MODULE_ID "power"
32
Todd Poynor2f143fb2012-04-24 13:39:15 -070033/*
34 * Power hint identifiers passed to (*powerHint)
35 */
36
37typedef enum {
38 /*
39 * VSYNC pulse request from SurfaceFlinger started or stopped.
40 */
41 POWER_HINT_VSYNC = 0x00000001,
42} power_hint_t;
43
Todd Poynorc82792c2012-01-10 00:32:42 -080044/**
45 * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
46 * and the fields of this data structure must begin with hw_module_t
47 * followed by module specific information.
48 */
49typedef struct power_module {
50 struct hw_module_t common;
51
52 /*
53 * (*init)() performs power management setup actions at runtime
Todd Poynor2f143fb2012-04-24 13:39:15 -070054 * startup, such as to set default cpufreq parameters. This is
55 * called only by the Power HAL instance loaded by
56 * PowerManagerService.
Todd Poynorc82792c2012-01-10 00:32:42 -080057 */
58 void (*init)(struct power_module *module);
59
60 /*
61 * (*setInteractive)() performs power management actions upon the
62 * system entering interactive state (that is, the system is awake
63 * and ready for interaction, often with UI devices such as
64 * display and touchscreen enabled) or non-interactive state (the
65 * system appears asleep, display usually turned off). The
66 * non-interactive state is usually entered after a period of
67 * inactivity, in order to conserve battery power during
68 * such inactive periods.
69 *
70 * Typical actions are to turn on or off devices and adjust
71 * cpufreq parameters. This function may also call the
72 * appropriate interfaces to allow the kernel to suspend the
73 * system to low-power sleep state when entering non-interactive
74 * state, and to disallow low-power suspend when the system is in
75 * interactive state. When low-power suspend state is allowed, the
76 * kernel may suspend the system whenever no wakelocks are held.
77 *
78 * on is non-zero when the system is transitioning to an
79 * interactive / awake state, and zero when transitioning to a
80 * non-interactive / asleep state.
81 *
82 * This function is called to enter non-interactive state after
83 * turning off the screen (if present), and called to enter
84 * interactive state prior to turning on the screen.
85 */
86 void (*setInteractive)(struct power_module *module, int on);
Todd Poynor2f143fb2012-04-24 13:39:15 -070087
88 /*
89 * (*powerHint) is called to pass hints on power requirements, which
90 * may result in adjustment of power/performance parameters of the
91 * cpufreq governor and other controls. The possible hints are:
92 *
93 * POWER_HINT_VSYNC
94 *
95 * Foreground app has started or stopped requesting a VSYNC pulse
96 * from SurfaceFlinger. If the app has started requesting VSYNC
97 * then CPU and GPU load is expected soon, and it may be appropriate
98 * to raise speeds of CPU, memory bus, etc. The data parameter is
99 * non-zero to indicate VSYNC pulse is now requested, or zero for
100 * VSYNC pulse no longer requested.
101 *
102 * A particular platform may choose to ignore any hint.
103 */
104 void (*powerHint)(struct power_module *module, power_hint_t hint,
105 void *data);
Todd Poynorc82792c2012-01-10 00:32:42 -0800106} power_module_t;
107
108
109__END_DECLS
110
111#endif // ANDROID_INCLUDE_HARDWARE_POWER_H