大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
(1)添加头文件:
#include “core.h”
在core.h文件中有:
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
(2)在wifi驱动ath6kl结构体中添加early_suspend结构:
#ifdef CONFIG_HAS_EARLYSUSPEND
struct early_suspend early_suspend;
bool screen_off;
#endif
(3)在wifi驱动的电源管理文件pm.c中填充early_suspend结构体,并将其向android电源管理系统注册:
#ifdef CONFIG_HAS_EARLYSUSPEND
ar->screen_off = false;
ar->early_suspend.suspend = ath6kl_early_suspend;
ar->early_suspend.resume = ath6kl_late_resume;
ar->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN;
register_early_suspend(&ar->early_suspend);
#endif
所有注册到系统中的early_suspend结构都会按level值按顺序加入到全局链表early_suspend_handlers中。
希望执行early suspend的设备,他的设备驱动程序需要向电源管理系统注册,该结构体用于向电源管理系统注册earlysuspend/lateresume,当电源管理系统启动suspend流程时,回调函数suspend会被调用,相反,resume的最后阶段,回调函数resume会被调用,level字段用于调整该结构体在注册链表中的位置,suspend时,level的数值越小,回调函数的被调用的时间越早,resume时则反过来。
Android在earlysuspend.h中预先定义了3个level等级:
enum {
EARLY_SUSPEND_LEVEL_BLANK_SCREEN = 50,
EARLY_SUSPEND_LEVEL_STOP_DRAWING = 100,
EARLY_SUSPEND_LEVEL_DISABLE_FB = 150,
};
具体请见附件kernel/include/linux/earlysuspend.h
(4)在wifi驱动电源管理文件pm.c中取消early_suspend结构体的注册:
#ifdef CONFIG_HAS_EARLYSUSPEND
unregister_early_suspend(&ar->early_suspend);
#endif
(5)定义相关suspend和resume函数:
#ifdef CONFIG_HAS_EARLYSUSPEND
static void ath6kl_early_suspend(struct early_suspend *handler)
{
struct ath6kl *ar = container_of(handler, struct ath6kl, early_suspend);
if (ar)
ar->screen_off = true;
}
static void ath6kl_late_resume(struct early_suspend *handler)
{
struct ath6kl *ar = container_of(handler, struct ath6kl, early_suspend);
if (ar)
ar->screen_off = false;
}
#endif
附:kernel/include/linux/earlysuspend.h
#ifndef _LINUX_EARLYSUSPEND_H
#define _LINUX_EARLYSUSPEND_H
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/list.h>
#endif
/* The early_suspend structure defines suspend and resume hooks to be called
* when the user visible sleep state of the system changes, and a level to
* control the order. They can be used to turn off the screen and input
* devices that are not used for wakeup.
* Suspend handlers are called in low to high level order, resume handlers are
* called in the opposite order. If, when calling register_early_suspend,
* the suspend handlers have already been called without a matching call to the
* Suspend handlers are called in low to high level order, resume handlers are
* called in the opposite order. If, when calling register_early_suspend,
* the suspend handlers have already been called without a matching call to the
* resume handlers, the suspend handler will be called directly from
* register_early_suspend. This direct call can violate the normal level order.
*/
enum {
EARLY_SUSPEND_LEVEL_BLANK_SCREEN = 50,
EARLY_SUSPEND_LEVEL_STOP_DRAWING = 100,
EARLY_SUSPEND_LEVEL_DISABLE_FB = 150,
};
struct early_suspend {
#ifdef CONFIG_HAS_EARLYSUSPEND
struct list_head link;
int level;
void (*suspend)(struct early_suspend *h);
void (*resume)(struct early_suspend *h);
#endif
};
#ifdef CONFIG_HAS_EARLYSUSPEND
void register_early_suspend(struct early_suspend *handler);
void unregister_early_suspend(struct early_suspend *handler);
#else
#define register_early_suspend(handler) do { } while (0)
#define unregister_early_suspend(handler) do { } while (0)
#endif
#endif
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/192266.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...