feat: 支持L1 低功耗框架
方案描述:
和L0保持一致,上层通过proc文件系统操作:
power_mode 支持的低功耗模式,通过对该文件进行write操作可以设置低功耗模式
power_count powermanager模块通过对该文件操作,和内核进行交互,简要流程如下:
while (1) {
open // 打开该文件
read // 使powermanager低功耗任务常阻塞,当系统无任何模块持锁时,会唤醒该任务
write // 进行低功耗流程
close // 关闭该文件
}
power_lock write该文件,持锁
power_unlock writw该文件,释放锁
Close #I4JSO
Change-Id: I73fcdeeb5e2039484b3351a81b46a0892b349fe9
Signed-off-by: zhushengle <zhushengle@huawei.com>
This commit is contained in:
@@ -76,22 +76,33 @@ static int PowerModeWrite(struct ProcFile *pf, const char *buf, size_t count, lo
|
||||
(void)count;
|
||||
(void)ppos;
|
||||
|
||||
LOS_SysSleepEnum mode;
|
||||
|
||||
if (buf == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(buf, "normal") != 0) {
|
||||
return LOS_NOK;
|
||||
if (strcmp(buf, "normal") == 0) {
|
||||
mode = LOS_SYS_NORMAL_SLEEP;
|
||||
} else if (strcmp(buf, "light") == 0) {
|
||||
mode = LOS_SYS_LIGHT_SLEEP;
|
||||
} else if (strcmp(buf, "deep") == 0) {
|
||||
mode = LOS_SYS_DEEP_SLEEP;
|
||||
} else if (strcmp(buf, "shutdown") == 0) {
|
||||
mode = LOS_SYS_SHUTDOWN;
|
||||
} else {
|
||||
PRINT_ERR("Unsupported hibernation mode: %s\n", buf);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return -LOS_PmModeSet(mode);
|
||||
}
|
||||
|
||||
static int PowerModeRead(struct SeqBuf *m, void *v)
|
||||
{
|
||||
(void)v;
|
||||
|
||||
LosBufPrintf(m, "normal \n");
|
||||
LosBufPrintf(m, "normal light deep shutdown\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -103,14 +114,30 @@ static const struct ProcFileOperations PowerMode = {
|
||||
static int PowerCountRead(struct SeqBuf *m, void *v)
|
||||
{
|
||||
(void)v;
|
||||
UINT32 count = LOS_PmLockCountGet();
|
||||
UINT32 count = LOS_PmReadLock();
|
||||
|
||||
LosBufPrintf(m, "%u\n", count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int PowerCountWrite(struct ProcFile *pf, const char *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
(void)pf;
|
||||
(void)count;
|
||||
(void)ppos;
|
||||
|
||||
int weakCount;
|
||||
|
||||
if (buf == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
weakCount = atoi(buf);
|
||||
return -LOS_PmSuspend(weakCount);
|
||||
}
|
||||
|
||||
static const struct ProcFileOperations PowerCount = {
|
||||
.write = NULL,
|
||||
.write = PowerCountWrite,
|
||||
.read = PowerCountRead,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user