【驱动】09.LCD驱动

【嵌入式八股】一、语言篇https://www.nowcoder.com/creation/manager/columnDetail/mwQPeM

【嵌入式八股】二、计算机基础篇https://www.nowcoder.com/creation/manager/columnDetail/Mg5Lym

【嵌入式八股】三、硬件篇https://www.nowcoder.com/creation/manager/columnDetail/MRVDlM

【嵌入式八股】四、嵌入式Linux篇(本专栏)https://www.nowcoder.com/creation/manager/columnDetail/MQ2bb0

LCD驱动

硬件原理

alt

alt

MCU常用的8080接口LCD模组(Framebuffer内存+LCD控制器+LCD屏幕都是外面的)

MPU常用的TFT RGB接口(Framebuffer内存+LCD控制器集成在芯片里面)

MIPI标准

对于LCD,MIPI接口可以分为3类:

  • MIPI-DBI (Display Bus Interface)

    • 既然是Bus(总线),就是既能发送数据,也能发送命令,常用的8080接口就属于DBI接口。

    • Type B (i-80 system), 8-/9-/16-/18-/24-bit bus

    • Type C (Serial data transfer interface, 3/4-line SPI)

  • MIPI-DPI (Display Pixel Interface)

    • Pixel(像素),强调的是操作单个像素,在MPU上的LCD控制器就是这种接口

    • Supports 24 bit/pixel (R: 8-bit, G: 8-bit, B: 8-bit)

    • Supports 18 bit/pixel (R: 6-bit, G: 6-bit, B: 6-bit)

    • Supports 16 bit/pixel (R: 5-bit, G: 6-bit, B: 5-bit)

  • MIPI-DSI (Display Serial Interface)

    • Serial,相比于DBI、DPI需要使用很多接口线,DSI需要的接口线大为减少
    • Supports one data lane/maximum speed 500Mbps
    • Supports DSI version 1.01
    • Supports D-PHY version 1.00

应用编程

结合APP分析LCD驱动程序

  1. open
app:  open("/dev/fb0", ...)   主设备号: 29, 次设备号: 0
--------------------------------------------------------------
kernel:
         fb_open   // fbmem.c
         	struct fb_info *info;
         	info = get_fb_info(fbidx);
			
			if (info->fbops->fb_open) {
				res = info->fbops->fb_open(info,1);   // 硬件相关的驱动
				if (res)
					module_put(info->fbops->owner);
			}         	
  1. 获得可变信息(含有分辨率等)
app:  	ioctl(fd, FBIOGET_VSCREENINFO, &fb_info->var);
-------------------------------------------------------------------------
kernel:
         fb_ioctl   // fbmem.c
         	struct fb_info *info = file_fb_info(file);

         	do_fb_ioctl(info, cmd, arg);
         		var = info->var;     // 硬件相关的驱动设置的
         		ret = copy_to_user(argp, &var, sizeof(var)) ? -EFAULT : 0;
  1. 获得固定信息(含有显存信息)
app:  	ioctl(fd, FBIOGET_FSCREENINFO, &fb_info->fix);
-------------------------------------------------------------------------
kernel:
         fb_ioctl   // fbmem.c
         	struct fb_info *info = file_fb_info(file);

         	do_fb_ioctl(info, cmd, arg);
         		fix = info->fix;     // 硬件相关的驱动设置的
         		ret = copy_to_user(argp, &fix, sizeof(fix)) ? -EFAULT : 0;
  1. mmap
app:void *ptr = mmap(0,
			fb_info->var.yres_virtual * fb_info->fix.line_length,
			PROT_WRITE | PROT_READ,
			MAP_SHARED, fd, 0);
-------------------------------------------------------------------------
kernel:
         fb_mmap   // fbmem.c
         	struct fb_info *info = file_fb_info(file);

         	start = info->fix.smem_start;
         	len = info->fix.smem_len;
         	return vm_iomap_memory(vma, s

剩余60%内容,订阅专栏后可继续查看/也可单篇购买

【嵌入式八股】嵌入式Linux 文章被收录于专栏

查阅整理上千份嵌入式面经,将相关资料汇集于此,主要包括: 0.简历面试 1.语言篇 2.计算机基础 3.硬件篇 4.嵌入式Linux【本专栏】 (建议PC端查看)

全部评论

相关推荐

评论
2
8
分享
牛客网
牛客企业服务