1 /* linux/android_power.h 2 ** 3 ** Copyright 2005-2006, The Android Open Source Project 4 ** Author: Arve Hjnnevg 5 ** 6 ** This file is dual licensed. It may be redistributed and/or modified 7 ** under the terms of the Apache 2.0 License OR version 2 of the GNU 8 ** General Public License. 9 */ 10 11 #ifndef _LINUX_ANDROID_POWER_H 12 #define _LINUX_ANDROID_POWER_H 13 14 #include <linux/list.h> 15 16 typedef struct 17 { 18 struct list_head link; 19 int lock_count; 20 int flags; 21 const char *name; 22 int expires; 23 } android_suspend_lock_t; 24 25 #define ANDROID_SUSPEND_LOCK_FLAG_COUNTED (1U << 0) 26 #define ANDROID_SUSPEND_LOCK_FLAG_USER_READABLE (1U << 1) 27 #define ANDROID_SUSPEND_LOCK_FLAG_USER_SET (1U << 2) 28 #define ANDROID_SUSPEND_LOCK_FLAG_USER_CLEAR (1U << 3) 29 #define ANDROID_SUSPEND_LOCK_FLAG_USER_INC (1U << 4) 30 #define ANDROID_SUSPEND_LOCK_FLAG_USER_DEC (1U << 5) 31 #define ANDROID_SUSPEND_LOCK_FLAG_USER_VISIBLE_MASK (0x1fU << 1) 32 #define ANDROID_SUSPEND_LOCK_AUTO_EXPIRE (1U << 6) 33 34 35 typedef struct android_early_suspend android_early_suspend_t; 36 struct android_early_suspend 37 { 38 struct list_head link; 39 int level; 40 void (*suspend)(android_early_suspend_t *h); 41 void (*resume)(android_early_suspend_t *h); 42 }; 43 44 typedef enum { 45 ANDROID_CHARGING_STATE_UNKNOWN, 46 ANDROID_CHARGING_STATE_DISCHARGE, 47 ANDROID_CHARGING_STATE_MAINTAIN, // or trickle 48 ANDROID_CHARGING_STATE_SLOW, 49 ANDROID_CHARGING_STATE_NORMAL, 50 ANDROID_CHARGING_STATE_FAST, 51 ANDROID_CHARGING_STATE_OVERHEAT 52 } android_charging_state_t; 53 54 //android_suspend_lock_t *android_allocate_suspend_lock(const char *debug_name); 55 //void android_free_suspend_lock(android_suspend_lock_t *lock); 56 int android_init_suspend_lock(android_suspend_lock_t *lock); 57 void android_uninit_suspend_lock(android_suspend_lock_t *lock); 58 void android_lock_suspend(android_suspend_lock_t *lock); 59 void android_lock_suspend_auto_expire(android_suspend_lock_t *lock, int timeout); 60 void android_unlock_suspend(android_suspend_lock_t *lock); 61 void android_power_wakeup(int notification); /* notification = 0: normal wakeup, notification = 1: temporary wakeup */ 62 63 int android_power_is_driver_suspended(void); 64 65 void android_register_early_suspend(android_early_suspend_t *handler); 66 void android_unregister_early_suspend(android_early_suspend_t *handler); 67 68 void android_power_set_battery_level(int level); // level 0-100 69 void android_power_set_charging_state(android_charging_state_t state); 70 71 #endif 72 73