标签:
转载:http://blog.chinaunix.net/uid-9688646-id-1998294.html
控制台VT有一个定时器,默认为10分钟,只要时间一到就会blank screen,会导致fb黑屏,会导致给人“电源管理的假象”
函数再现:
static void blank_screen_t(unsigned long dummy)
{
if (unlikely(!keventd_up())) {
mod_timer(&console_timer, jiffies + (blankinterval * HZ));
return;
}
blank_timer_expired = 1;
schedule_work(&console_work);
}
如果产品需要去掉光标,只需要修改VT代码,将VT的vc->vc_cursor_type = CUR_DEFAULT修改为vc->vc_cursor_type=CUR_NONE即可,
默认的光标即为不显示状态。
现象的本质与内核电源管理编译选项无关,总的解决方法:在用户空间代码里添加
/* disable console. avoid console blank automatically */
system("echo -e \"\033[9;0]\" > /dev/tty1");
解释:
该系统调用相当于setterm -blank 0,详见setterm命令的源码,其中
/* -blank [0-60]. */
if (opt_blank && vcterm)
printf("\033[9;%d]", opt_bl_min);
也可以见Vt.c (drivers\char): case ‘]‘: /* setterm functions */
9月13日
static int __init con_init(void)
{
const char *display_desc = NULL;
struct vc_data *vc;
unsigned int currcons = 0;
acquire_console_sem();
if (conswitchp)
display_desc = conswitchp->con_startup();
if (!display_desc) {
fg_console = 0;
release_console_sem();
return 0;
}
init_timer(&console_timer); console_timer.function = blank_screen_t;
if (blankinterval) {
blank_state = blank_normal_wait; mod_timer(&console_timer, jiffies + blankinterval);
}
// 这是对控制台定时器的初始化,定时器事件函数被连接到了blank_screen_t()
/*
* kmalloc is not running yet - we use the bootmem allocator.
*/
for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
vc_cons[currcons].d = vc = alloc_bootmem(sizeof(struct vc_data));
visual_init(vc, currcons, 1);
vc->vc_screenbuf = (unsigned short *)alloc_bootmem(vc->vc_screenbuf_size);
vc->vc_kmalloced = 0;
vc_init(vc, vc->vc_rows, vc->vc_cols, currcons || !vc->vc_sw->con_save_screen);
}
currcons = fg_console = 0;
master_display_fg = vc = vc_cons[currcons].d;
set_origin(vc);
save_screen(vc);
gotoxy(vc, vc->vc_x, vc->vc_y);
csi_J(vc, 0);
update_screen(vc);
printk("Console: %s %s %dx%d",
vc->vc_can_do_color ? "colour" : "mono", display_desc, vc->vc_cols, vc->vc_rows);
printable = 1;
printk("\n");
release_console_sem();
#ifdef CONFIG_VT_CONSOLE
register_console(&vt_console_driver);
#endif
return 0;
}
static void blank_screen_t(unsigned long dummy)
{
blank_timer_expired = 1;
schedule_work(&console_work);
}
static void console_callback(void *ignored)
{
acquire_console_sem();
if (want_console >= 0) {
if (want_console != fg_console &&
vc_cons_allocated(want_console)) {
hide_cursor(vc_cons[fg_console].d);
change_console(vc_cons[want_console].d);
/* we only changed when the console had already
been allocated - a new console is not created
in an interrupt routine */
}
want_console = -1;
}
if (do_poke_blanked_console) { /* do not unblank for a LED change */
do_poke_blanked_console = 0;
poke_blanked_console();
}
if (scrollback_delta) {
struct vc_data *vc = vc_cons[fg_console].d;
clear_selection();
if (vc->vc_mode == KD_TEXT)
vc->vc_sw->con_scrolldelta(vc, scrollback_delta);
scrollback_delta = 0;
}
if (blank_timer_expired) { do_blank_screen(0); blank_timer_expired = 0; }
release_console_sem();
}
static struct tty_operations con_ops = {
.open = con_open,
.close = con_close,
.write = con_write,
.write_room = con_write_room,
.put_char = con_put_char,
.flush_chars = con_flush_chars,
.chars_in_buffer = con_chars_in_buffer,
.ioctl = vt_ioctl,
.stop = con_stop,
.start = con_start,
.throttle = con_throttle,
.unthrottle = con_unthrottle,
};
/* -blank [0-60]. */
if (opt_blank && vcterm)
printf("\033[9;%d]", opt_bl_min);
#include
#include
#include
void some_function()
{
int f;
f = open("/dev/tty0", O_RDWR);
write(f, "\033[9;0]", 8);
close(f);
}
如何解决 FrameBuffer console (vc)自动关闭显示
标签:
原文地址:http://www.cnblogs.com/pengdonglin137/p/4613955.html