CPU : ARM9 s3c2410
LCD : 规格不明(这个很无奈,但是我所知道的只有一个分辨率)
OS : Linux kernel 2.6.30.4
之前搞定了LCD的驱动程序,基本工作正常。但是测试过程中发现有这么一个问题,就是如果几分钟后LCD会自动关闭,此时敲击I2C键盘LCD无法正常点亮。开始认为问题出在“menuconfig”中的“power management”,但经多次尝试,未果。
网上查阅了很多前人的经验,终于搞清楚了原因。找到“drivers/char/vt.c”文件,在这个文件中有一个函数叫做“static int __init con_init(void)”,这个函数做了控制台初始化的工作。在这个过程中Linux设置了一个计时器,这个计时器的值每次的变化量由“blankinterval”这个变量设定。当计时器的值减至0时,“static void blank_screen_t(unsigned long dummy)”函数就会被执行,完成关闭LCD的操作。
那么显而易见,解决问题的方式有这么两种,其一是修改“blankinterval”为0,这样一来计时器的值就不会发生改变;另外也可以把“static void blank_screen_t(unsigned long dummy)”改成空函数,那么即使计时器值减为0,LCD也不会被关闭。我选用了后者。
源码修改:
drivers/char/vt.c
/*
* We defer the timer blanking to work queue so it can take the console mutex
* (console operations can still happen at irq time, but only from printk which
* has the console mutex. Not perfect yet, but better than no locking
*/
#if 1 //modified by B.Zhou
static void blank_screen_t(unsigned long dummy)
{
}
#else
static void blank_screen_t(unsigned long dummy)
{
if (unlikely(!keventd_up())) {
mod_timer(&console_timer, jiffies + blankinterval);
return;
}
blank_timer_expired = 1;
schedule_work(&console_work);
}
#endif
至此,LCD已经不会自动熄灭了,但是最理想的解决方案应该是熄灭后能够相应I2C键盘,等有时间再看看如何实现。