板子上的LCD是sync mode 24bit TFT LCD,分辨率800*480,
其实Framebuffer驱动已经有了,只要在menuconfig配置下即
可。如果要更改其他LCD,则需要更改相应的时序或驱动。
写了一个刷新LCD的测试程序。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <asm/ioctl.h>
#include <sys/mman.h>
#define LCD_WIDTH 800
#define LCD_HEIGHT 480
#define COLOR_WHITE 0xFFFFFF
#define COLOR_BLUE 0X0000FF
#define COLOR_RED 0XFF0000
unsigned char *pVideoBuffer;
unsigned long uVideoSize;
static int lcd_display_screen(unsigned int color)
{
int i, j;
for(i = 0; i < LCD_HEIGHT; i++)
{
for (j = 0; j < LCD_WIDTH; j++)
{
pVideoBuffer[i*LCD_WIDTH*4+j*4+0] = color & 0xFF;
pVideoBuffer[i*LCD_WIDTH*4+j*4+1] = (color >> 8)&0xFF;
pVideoBuffer[i*LCD_WIDTH*4+j*4+2] = (color >> 16)&0xFF;
}
}
return 0;
}
int main()
{
int fd, ret;
fd = open("/dev/fb0", O_RDWR);
if (fd == -1) {
printf("Cannot open fb0!\n");
return -1;
}
uVideoSize = LCD_WIDTH * LCD_HEIGHT * 4;
pVideoBuffer = mmap(NULL, uVideoSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (pVideoBuffer == MAP_FAILED) {
printf("mmap() failed\n");
exit(0);
}
lcd_display_screen(COLOR_BLUE);
sleep(2);
lcd_display_screen(COLOR_WHITE);
sleep(2);
lcd_display_screen(COLOR_RED);
sleep(2);
return 0;
}