电源管理
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Android电源管理系统调研报告-(1)
2011-02-17 09:18
转载自carvencao
最终编辑carvencao
如今手持设备中出现的一对不可调和的矛盾就是越来越大的能量消耗与电池容量瓶颈之间的矛盾,就算没有这个瓶颈,相对更持久的续航能力也是众向所归。Android系统一般应用于高端智能设备,能源消耗尤其突出,因此对Android 的电源管理系统的调研有很必要。
Android系统是基于标准Linux内核之上的,在Linux内核在原有的power manager系统之上增加了相应了文件,为Android系统的power manager提供底层服务支持。因此,调研工作在两个层面展开:Linux内核层、Android系统层。
Linux内核层:
针对Android系统而增添的power manager文件有如下五个:
/Linux-2.6.29/kernel/power/
|-consoleearlysuspend.c
|-earlysuspend.c
|-fbearlysuspend.c
|-userwakelock.c
|-wakelock.c
这五个文件配合Linux层的power manager柜架和与功耗相关的设备驱动,向Android层提供了power manager的底层支持。与功耗相关的设备主要包括LCD屏和键盘及其它设备的LED灯。因些,在这类设备的驱动中应该增加相应的power manager功能。
在该调研报告中,仅简单地罗出列出各文件中定义的功能函数以及向上提供的接口,其具体的功能调用及整个power manager柜架地实现在后期的调研报告中阐述。
1)、consoleearlysuspend.c
功能函数:
static void console_early_suspend(struct early_suspend *h);
static void console_late_resume(struct early_suspend *h);
static int __init console_early_suspend_init(void);
static void __exit console_early_suspend_exit(void);
数据结构:
static struct early_suspend console_early_suspend_desc = { .level = EARLY_SUSPEND_LEVEL_STOP_DRAWING,
.suspend = console_early_suspend,
.resume = console_late_resume,
};
2、earlysuspend.c
功能函数:
void register_early_suspend(struct early_suspend *handler);
void unregister_early_suspend(struct early_suspend *handler);
static void early_suspend(struct work_struct *work);
static void late_resume(struct work_struct *work);
void request_suspend_state(suspend_state_t new_state); suspend_state_t get_suspend_state(void);
供驱动使用的函数接口:
EXPORT_SYMBOL(register_early_suspend);
EXPORT_SYMBOL(unregister_early_suspend);
在earlysuspend.h文件中定义了注册接口函数:
#ifdef CONFIG_HAS_EARLYSUSPEND
void register_early_suspend(struct early_suspend *handler);
void unregister_early_suspend(struct early_suspend *handler);
3、fbearlysuspend.c
功能函数:
static void stop_drawing_early_suspend(struct early_suspend *h);
static void start_drawing_late_resume(struct early_suspend *h);
static ssize_t wait_for_fb_sleep_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf);
static ssize_t wait_for_fb_wake_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf);
static int __init android_power_init(void);
static void __exit android_power_exit(void)
主要的数据结构:
static struct early_suspend stop_drawing_early_suspend_desc = {
.level = EARLY_SUSPEND_LEVEL_STOP_DRAWING,
.suspend = stop_drawing_early_suspend,
.resume = start_drawing_late_resume,
};
在以上面的几个函数中,都调用了__wake_up:
在sched.c中定义了这个函数
/**
* __wake_up - wake up threads blocked on a waitqueue.
* @q: the waitqueue
* @mode: which threads
* @nr_exclusive: how many wake-one or wake-many threads to wake up
* @key: is directly passed to the wakeup function
*/
void __wake_up(wait_queue_head_t *q, unsigned int mode,
int nr_exclusive, void *key)
{
unsigned long flags;
spin_lock_irqsave(&q->lock, flags);