系统休眠时,sleep函数或定时器都会跟随系统频率发生变化。一进休眠就会变慢或感觉被卡住。
这个时候,我们有一种简单的方法就是将系统禁止休眠,当然,也使可以恢复的。
初始化文件路径和定义:
kernel-4.9includelinuxpm_wakeup.h
static inline void wakeup_source_init(struct wakeup_source *ws, const char *name)
停止函数文件路径和定义:
kernel-4.9driversbasepowerwakeup.c
void __pm_stay_awake(struct wakeup_source *ws);
参数路径和定义:
kernel-4.9includelinuxpm_wakeup.h
struct wakeup_source {
const char *name;
struct list_head entry;
spinlock_t lock;
struct wake_irq *wakeirq;
struct timer_list timer;
unsigned long timer_expires;
ktime_t total_time;
ktime_t max_time;
ktime_t last_time;
ktime_t start_prevent_time;
ktime_t prevent_sleep_time;
unsigned long event_count;
unsigned long active_count;
unsigned long relax_count;
unsigned long expire_count;
unsigned long wakeup_count;
bool active:1;
bool autosleep_enabled:1;
};
参考代码示例:代码在MT6765(kernel4.9)上验证OK
#include <linux/suspend.h>struct wakeup_source suspend_lock;
extern void wakeup_source_init(struct wakeup_source *lock, const char *name);
extern void __pm_stay_awake(struct wakeup_source *ws);
......//保持唤醒状态
static void keep_wakeup(void)
{wakeup_source_init(&suspend_lock,"my wakelock");__pm_stay_awake(&suspend_lock);
}
解锁参考代码示例:
//释放解锁__pm_relax(&suspend_lock);
本文发布于:2024-02-02 20:54:41,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170687849546387.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |