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