Linux系统LCD显示图片的原理,linux驱动开发:用户空间操作LCD显示简单的图片【转】...

上一章我们简单介绍了LCD的一些基本原理。当然更深奥的还有,比如gamma,dither,HUE,satuation.OSD等等.

我们知道我们是用framebuffer来实现显示的.

显存:framebuffer.由DDRAM中划去一部分内存供显存使用.

从而操作lcd相当于操作显存.

lcd控制器(s5pv210里面有lcd控制器)会周期的获取framebuffer中的数据。经过处理丢给 显示屏的lcd 驱动器

lcd驱动器分析,解码,将数据显示到lcd上.

lcd驱动开发的工作:

配置lcd 控制器,让lcd 控制器周期性的读取显存中的数据

然后按照一定的时序和格式讲数据发送给lcd驱动器.驱动器会驱动lcd屏进行显示.

1)申请显存

framebuffer:导出lcd物理缓冲区(显存)导入到用户空间(0-3G)

用户空间要显示一幅图片到lcd,在用户空间直接操作显存,将要显示的图片copy到

显存中的相应位置上就可以了

这边就先不多讲了,因为时间太晚,太累。我们画一个这样的图片:

20da5752fd6fa5b1d93e61db77cb7896511.jpg

用户空间代码:

#include

#include

#include

#include

#include #define _COLOR_RED 0x00ff0000 #define _COLOR_GREEN 0x0000ff00 #define _COLOR_BLUE 0x000000ff static struct fb_fix_screeninfo fb_fix ={0}; static struct fb_var_screeninfo fb_var ={0}; long screen_size=0; int *fb32 =NULL; int main() { int fd = -1; int x,y; fd =open("/dev/fb0",O_RDWR); if(fd < 0) { printf("open dev fb0 fail.\n"); return -1; } //get lcd param ioctl(fd,FBIOGET_FSCREENINFO,&fb_fix); ioctl(fd,FBIOGET_VSCREENINFO,&fb_var); screen_size = fb_var.xres*fb_var.yres*(fb_var.bits_per_pixel/8); fb32 =mmap(0,screen_size,PROT_READ |PROT_WRITE,MAP_SHARED,fd,0); if(fb32 == NULL) { printf("mmap framebuffer fail.\n"); return -1; } if(fb_var.bits_per_pixel == 8) { printf("8bpp framebuffer test.\n"); } else if(fb_var.bits_per_pixel == 16) { printf("16bpp framebuffer test.\n"); } else if(fb_var.bits_per_pixel == 24) { printf("24bpp framebuffer test.\n"); } else if(fb_var.bits_per_pixel == 32) { printf("32bpp framebuffer test.\n"); } for(y=0;y< fb_var.yres/3;y++) { for(x=0;x< fb_var.xres;x++) { *(fb32 +y*fb_var.xres + x) = _COLOR_RED; } } for(;y< fb_var.yres*2/3;y++) { for(x=0;x< fb_var.xres;x++) { *(fb32 +y*fb_var.xres + x) = _COLOR_GREEN; } } for(;y< fb_var.yres;y++) { for(x=0;x< fb_var.xres;x++) { *(fb32 +y*fb_var.xres + x) = _COLOR_BLUE; } } munmap(fb32,screen_size); close(fd); return 0; }

实验效果:

b14c576e9cb52816799b1bf0ca3fec8dc80.jpg

可以看到,和我们预期的一样。其中那边有一个小黑框那是光标,我们不管。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值