power.h revision c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14
1c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor/* 2c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * Copyright (C) 2012 The Android Open Source Project 3c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * 4c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * Licensed under the Apache License, Version 2.0 (the "License"); 5c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * you may not use this file except in compliance with the License. 6c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * You may obtain a copy of the License at 7c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * 8c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * http://www.apache.org/licenses/LICENSE-2.0 9c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * 10c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * Unless required by applicable law or agreed to in writing, software 11c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * distributed under the License is distributed on an "AS IS" BASIS, 12c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * See the License for the specific language governing permissions and 14c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * limitations under the License. 15c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor */ 16c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor 17c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor#ifndef ANDROID_INCLUDE_HARDWARE_POWER_H 18c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor#define ANDROID_INCLUDE_HARDWARE_POWER_H 19c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor 20c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor#include <stdint.h> 21c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor#include <sys/cdefs.h> 22c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor#include <sys/types.h> 23c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor 24c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor#include <hardware/hardware.h> 25c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor 26c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor__BEGIN_DECLS 27c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor 28c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor/** 29c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * The id of this module 30c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor */ 31c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor#define POWER_HARDWARE_MODULE_ID "power" 32c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor 33c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor/** 34c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM 35c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * and the fields of this data structure must begin with hw_module_t 36c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * followed by module specific information. 37c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor */ 38c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynortypedef struct power_module { 39c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor struct hw_module_t common; 40c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor 41c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor /* 42c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * (*init)() performs power management setup actions at runtime 43c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * startup, such as to set default cpufreq parameters. 44c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor */ 45c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor void (*init)(struct power_module *module); 46c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor 47c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor /* 48c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * (*setInteractive)() performs power management actions upon the 49c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * system entering interactive state (that is, the system is awake 50c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * and ready for interaction, often with UI devices such as 51c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * display and touchscreen enabled) or non-interactive state (the 52c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * system appears asleep, display usually turned off). The 53c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * non-interactive state is usually entered after a period of 54c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * inactivity, in order to conserve battery power during 55c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * such inactive periods. 56c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * 57c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * Typical actions are to turn on or off devices and adjust 58c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * cpufreq parameters. This function may also call the 59c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * appropriate interfaces to allow the kernel to suspend the 60c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * system to low-power sleep state when entering non-interactive 61c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * state, and to disallow low-power suspend when the system is in 62c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * interactive state. When low-power suspend state is allowed, the 63c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * kernel may suspend the system whenever no wakelocks are held. 64c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * 65c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * on is non-zero when the system is transitioning to an 66c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * interactive / awake state, and zero when transitioning to a 67c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * non-interactive / asleep state. 68c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * 69c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * This function is called to enter non-interactive state after 70c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * turning off the screen (if present), and called to enter 71c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor * interactive state prior to turning on the screen. 72c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor */ 73c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor void (*setInteractive)(struct power_module *module, int on); 74c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor} power_module_t; 75c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor 76c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor 77c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor__END_DECLS 78c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor 79c82792c0a4135c1a5de4e4f0ca47318fa5dd7e14Todd Poynor#endif // ANDROID_INCLUDE_HARDWARE_POWER_H 80