另一个问题是:在唤醒之后LCD无显示,跟踪了一下,发现在进入LCD的suspend之前,framebuffer的数据已经被清零了,这个问题困扰了我很长时间,后来在论坛上看到帖子有人提供了思路说是在进入睡眠之前系统会切换控制台,所以framebuffer的数据会被清零,根据此思路,修改kernel/power/console.c文件中的pm_prepare_console()
修改如下:
int pm_prepare_console(void)
{
acquire_console_sem();
orig_fgconsole = fg_console;
#if 0
if (vc_allocate(SUSPEND_CONSOLE)) {
/* we can't have a free VC for now. Too bad,
* we don't want to mess the screen for now. */
release_console_sem();
return 1;
}
if (set_console(SUSPEND_CONSOLE)) {
/*
* We're unable to switch to the SUSPEND_CONSOLE.
* Let the calling function know so it can decide
* what to do.
*/
release_console_sem();
return 1;
}
#endif
release_console_sem();
/*
if (vt_waitactive(SUSPEND_CONSOLE)) {
pr_debug("Suspend: Can't switch VCs.");
return 1;
}
*/
orig_kmsg = kmsg_redirect;
kmsg_redirect = SUSPEND_CONSOLE;
return 0;
}
如上修改即可实现唤醒后,LCD上显示原来的图像。
另,可以用应用程序使得系统进入睡眠
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/ioctl.h>
#define APM_IOC_STANDBY _IO('A', 1)
#define APM_IOC_SUSPEND _IO('A', 2)
int main (void)
{
int fd;
//char buf[32];
fd = open ("/dev/apm_bios",O_RDWR);
if (fd < 0) {
printf ("fd open failed\n");
exit(0);
}
if (ioctl (fd, APM_IOC_SUSPEND)<0) {
printf("\nset suspend err\n");
}
close (fd);
return 0;
}