Todd Poynor | c82792c | 2012-01-10 00:32:42 -0800 | [diff] [blame^] | 1 | /* |
| 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 | |
| 33 | /** |
| 34 | * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM |
| 35 | * and the fields of this data structure must begin with hw_module_t |
| 36 | * followed by module specific information. |
| 37 | */ |
| 38 | typedef struct power_module { |
| 39 | struct hw_module_t common; |
| 40 | |
| 41 | /* |
| 42 | * (*init)() performs power management setup actions at runtime |
| 43 | * startup, such as to set default cpufreq parameters. |
| 44 | */ |
| 45 | void (*init)(struct power_module *module); |
| 46 | |
| 47 | /* |
| 48 | * (*setInteractive)() performs power management actions upon the |
| 49 | * system entering interactive state (that is, the system is awake |
| 50 | * and ready for interaction, often with UI devices such as |
| 51 | * display and touchscreen enabled) or non-interactive state (the |
| 52 | * system appears asleep, display usually turned off). The |
| 53 | * non-interactive state is usually entered after a period of |
| 54 | * inactivity, in order to conserve battery power during |
| 55 | * such inactive periods. |
| 56 | * |
| 57 | * Typical actions are to turn on or off devices and adjust |
| 58 | * cpufreq parameters. This function may also call the |
| 59 | * appropriate interfaces to allow the kernel to suspend the |
| 60 | * system to low-power sleep state when entering non-interactive |
| 61 | * state, and to disallow low-power suspend when the system is in |
| 62 | * interactive state. When low-power suspend state is allowed, the |
| 63 | * kernel may suspend the system whenever no wakelocks are held. |
| 64 | * |
| 65 | * on is non-zero when the system is transitioning to an |
| 66 | * interactive / awake state, and zero when transitioning to a |
| 67 | * non-interactive / asleep state. |
| 68 | * |
| 69 | * This function is called to enter non-interactive state after |
| 70 | * turning off the screen (if present), and called to enter |
| 71 | * interactive state prior to turning on the screen. |
| 72 | */ |
| 73 | void (*setInteractive)(struct power_module *module, int on); |
| 74 | } power_module_t; |
| 75 | |
| 76 | |
| 77 | __END_DECLS |
| 78 | |
| 79 | #endif // ANDROID_INCLUDE_HARDWARE_POWER_H |