linux lcd测试程序,Linxu S3C2440 LCD驱动 测试程序

主机:VM - RedHat 9.0

开发板:FL2440,linux-2.6.12

arm-linux-gcc:3.4.1

#include 

#include 

#include 

#include 

#include 

#define RED_COLOR565    0x0F100

#define GREEN_COLOR565  0x007E0

#define BLUE_COLOR565   0x0001F

intmain(void)

{

intfd_fb = 0;

structfb_var_screeninfo vinfo;

structfb_fix_screeninfo finfo;

longintscreen_size = 0;

short*fbp565 = NULL;

intx = 0, y = 0;

fd_fb = open("/dev/fb0", O_RDWR);

if(!fd_fb)

{

printf("Error: cannot open framebuffer device.\n");

exit(1);

}

// Get fixed screen info

if(ioctl(fd_fb, FBIOGET_FSCREENINFO, &finfo))

{

printf("Error reading fixed information.\n");

exit(2);

}

// Get variable screen info

if(ioctl(fd_fb, FBIOGET_VSCREENINFO, &vinfo))

{

printf("Error reading variable information.\n");

exit(3);

}

// the size of the screen in bytes

screen_size = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

printf("%dx%d, %dbpp, screen_size = %d\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel, screen_size );

// map framebuffer to user memory

fbp565 = (short*)mmap(0, screen_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_fb, 0);

if((int)fbp565 == -1)

{

printf("Error: failed to map framebuffer device to memory.\n");

exit(4);

}

if(vinfo.bits_per_pixel == 16)

{

printf("16 bpp framebuffer\n");

// Red Screen

printf("Red Screen\n");

for(y = 0; y 

{

for(x = 0; x 

{

*(fbp565 + y * vinfo.xres + x) = RED_COLOR565;

}

}

// Green Screen

printf("Green Screen\n");

for(y = vinfo.yres/3; y 

{

for(x = 0; x 

{

*(fbp565 + y * vinfo.xres + x) =GREEN_COLOR565;

}

}

// Blue Screen

printf("Blue Screen\n");

for(y = (vinfo.yres*2)/3; y 

{

for(x = 0; x 

{

*(fbp565 + y * vinfo.xres + x) = BLUE_COLOR565;

}

}

}

else

{

printf("warnning: bpp is not 16\n");

}

munmap(fbp565, screen_size);

close(fd_fb);

return0;

}#include

#include

#include

#include

#include

#define RED_COLOR565 0x0F100

#define GREEN_COLOR565 0x007E0

#define BLUE_COLOR565 0x0001F

int main(void)

{

int fd_fb = 0;

struct fb_var_screeninfo vinfo;

struct fb_fix_screeninfo finfo;

long int screen_size = 0;

short *fbp565 = NULL;

int x = 0, y = 0;

fd_fb = open("/dev/fb0", O_RDWR);

if (!fd_fb)

{

printf("Error: cannot open framebuffer device.\n");

exit(1);

}

// Get fixed screen info

if (ioctl(fd_fb, FBIOGET_FSCREENINFO, &finfo))

{

printf("Error reading fixed information.\n");

exit(2);

}

// Get variable screen info

if (ioctl(fd_fb, FBIOGET_VSCREENINFO, &vinfo))

{

printf("Error reading variable information.\n");

exit(3);

}

// the size of the screen in bytes

screen_size = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

printf("%dx%d, %dbpp, screen_size = %d\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel, screen_size );

// map framebuffer to user memory

fbp565 = (short *)mmap(0, screen_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_fb, 0);

if ((int)fbp565 == -1)

{

printf("Error: failed to map framebuffer device to memory.\n");

exit(4);

}

if(vinfo.bits_per_pixel == 16)

{

printf("16 bpp framebuffer\n");

// Red Screen

printf("Red Screen\n");

for(y = 0; y < vinfo.yres/3; y++)

{

for(x = 0; x < vinfo.xres ; x++)

{

*(fbp565 + y * vinfo.xres + x) = RED_COLOR565;

}

}

// Green Screen

printf("Green Screen\n");

for(y = vinfo.yres/3; y < (vinfo.yres*2)/3; y++)

{

for(x = 0; x < vinfo.xres; x++)

{

*(fbp565 + y * vinfo.xres + x) =GREEN_COLOR565;

}

}

// Blue Screen

printf("Blue Screen\n");

for(y = (vinfo.yres*2)/3; y < vinfo.yres; y++)

{

for(x = 0; x < vinfo.xres; x++)

{

*(fbp565 + y * vinfo.xres + x) = BLUE_COLOR565;

}

}

}

else

{

printf("warnning: bpp is not 16\n");

}

munmap(fbp565, screen_size);

close(fd_fb);

return 0;

}

测试结果,由上往下颜色分别为红、绿、蓝,图像有色差。

9bea3e4fe5bee8d2fec6ac3b7cbf2837.gif0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值