【转】Android驱动开发之earlysuspend睡眠模式编程总结
2016-02-23 14:01
525 查看
原文网址:http://blog.csdn.net/bigapple88/article/details/8669537
(1)添加头文件:
#include <linux/earlysuspend.h>
(2)在特定驱动结构体中添加early_suspend结构:
#ifdef CONFIG_HAS_EARLYSUSPEND
struct early_suspend early_suspend;
#endif
(3)在驱动probe函数中注册相关early_suspend结构体:
#ifdef CONFIG_HAS_EARLYSUSPEND
ftk_ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
ftk_ts->early_suspend.suspend = stm_ts_early_suspend;
ftk_ts->early_suspend.resume =stm_ts_late_resume;
register_early_suspend(&ftk_ts->early_suspend);
#endif
(4)在驱动remove函数取消early_suspend结构体的注册:
#ifdef CONFIG_HAS_EARLYSUSPEND
unregister_early_suspend(&ts->early_suspend);
#endif
(5)定义相关suspend和resume函数:
#ifdef CONFIG_HAS_EARLYSUSPEND
static void stm_ts_early_suspend(struct early_suspend *h)
{
struct ftk_ts *ts;
ts = container_of(h, struct ftk_ts, early_suspend);
stm_ts_suspend(ts->client, PMSG_SUSPEND);
}
static void stm_ts_late_resume(struct early_suspend *h)
{
struct ftk_ts *ts;
ts = container_of(h, struct ftk_ts, early_suspend);
stm_ts_resume(ts->client);
}
#endif
(6)在系统驱动结构体中设置未使用earlysuspend的函数接口:
#ifndef CONFIG_HAS_EARLYSUSPEND
.suspend = stm_ts_suspend,
.resume = stm_ts_resume,
#endif
(1)添加头文件:
#include <linux/earlysuspend.h>
(2)在特定驱动结构体中添加early_suspend结构:
#ifdef CONFIG_HAS_EARLYSUSPEND
struct early_suspend early_suspend;
#endif
(3)在驱动probe函数中注册相关early_suspend结构体:
#ifdef CONFIG_HAS_EARLYSUSPEND
ftk_ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
ftk_ts->early_suspend.suspend = stm_ts_early_suspend;
ftk_ts->early_suspend.resume =stm_ts_late_resume;
register_early_suspend(&ftk_ts->early_suspend);
#endif
(4)在驱动remove函数取消early_suspend结构体的注册:
#ifdef CONFIG_HAS_EARLYSUSPEND
unregister_early_suspend(&ts->early_suspend);
#endif
(5)定义相关suspend和resume函数:
#ifdef CONFIG_HAS_EARLYSUSPEND
static void stm_ts_early_suspend(struct early_suspend *h)
{
struct ftk_ts *ts;
ts = container_of(h, struct ftk_ts, early_suspend);
stm_ts_suspend(ts->client, PMSG_SUSPEND);
}
static void stm_ts_late_resume(struct early_suspend *h)
{
struct ftk_ts *ts;
ts = container_of(h, struct ftk_ts, early_suspend);
stm_ts_resume(ts->client);
}
#endif
(6)在系统驱动结构体中设置未使用earlysuspend的函数接口:
#ifndef CONFIG_HAS_EARLYSUSPEND
.suspend = stm_ts_suspend,
.resume = stm_ts_resume,
#endif
相关文章推荐
- Android Volley完全解析
- Android Studio:can't reload AVD list的解决方法
- Android studio 安装与配置【Android学习入门】
- Android内存优化总结【整理】
- Android Weak Handler:可以避免内存泄漏的Handler库
- Android HandlerThread 完全解析
- Android中自定义控件的步骤
- Android Studio设置记录
- Android仿支付宝首页GridView的网格效果-不能够换位置
- 020自定义BaseAdapter,然后绑定ListView的最简单例子
- Android多线程断点续传下载Demo
- 【Android】12.6 利用Intent实现记事本功能(NotePad)
- Android之PowerManager&BatteryManager
- Android 异步消息处理机制 让你深入理解 Looper、Handler、Message三者关系
- 【Android】12.5 利用Intent读取和更新通讯录
- 如何生成KeyStore
- Android源码分析-深入理解setContentView方法
- Android@id和@+id区别
- android动画详解
- android pendingIntent