首页 技术 正文
技术 2022年11月10日
0 收藏 335 点赞 2,792 浏览 1805 个字

转自:http://blog.csdn.net/changliang7731/article/details/53074616

上一章我们简单介绍了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到
显存中的相应位置上就可以了


这边就先不多讲了,因为时间太晚,太累。我们画一个这样的图片:
linux驱动开发:用户空间操作LCD显示简单的图片【转】

用户空间代码:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>#define _COLOR_RED 0x00ff0000
#define _COLOR_GREEN 0x0000ff00
#define _COLOR_BLUE 0x000000ffstatic 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;
}

实验效果:
linux驱动开发:用户空间操作LCD显示简单的图片【转】

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

版权声明:学习记录,积少成多

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,494
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295