[Thorough understanding linux kernel] -Linux frame buffer device driver

series content
Depth understanding of linux kernel Linux frame buffer device driver

surroundings:

platform Kernel version Android version
RK3399 Linux4.4 Android7.1

1, Linux framebuffer introduction

framebuffer The user interface is a bridge support system and display system hardware part
Here Insert Picture Description

2, Framebuffer critical data structures

Here Insert Picture Description

2.1, fb_info

fb_infoIt is framebufferthe base structure.
File Location:include\linx\fb.h

Important member content
.node In framebufferarchitecture, there is one struct fb_info *registered_fb[32]; it represents the most support
32A framebufferdevice, noderepresents an array of several members of the first array IDfrom the 0start.
.screen_bas Screen starting virtual address, by pre-registering DMAbeen assigned way
.screen_size Buf screen size, in the size, and all the display modes supported by the system,xresyresbpp
.var: Screen variable parameters
.fix Screen fixed parameters
.monspecs Monitor describes the parameters
.pixmap Hardware mapping image
.sprite Mapping the hardware cursor
.cmap Color table
.modelist Display mode list, a fbdrive that supports multiple devices, each device displays the relevant parameters are different, so it is necessary to maintain a list of
.mode The current display mode

Here Insert Picture Description
struct fb_var_screeninfo
Here Insert Picture Description

Important member content
.xres Line the number of points, as xresexpressed
.yres There are a number of points, as yresexpressed
.bits_per_pixel bppEach pixel represents how many bits
.red Offset and length occupied by red
.green Offset and length occupied by green
.blue Offset and length occupied by blue
.nonstd Whether the pixel is a standard format, 0standard formats for representing the non- 0representation is not a standard format
.pixclock Pixel clock, reading (the unit? Bits / byte / word) the time spent
.lef_margin Line switching, the delay between synchronizing to the drawing from
.right_margin Line switching, the delay between drawing from the synchronization
.upper_margin Frame switching, from the synchronization delay between drawing
.lower_margin Frame switching, the delay between the sync from the drawing to
.hsync_len 水平同步长度
.vsync_len 垂直同步长度

struct fb_fix_screeninfo

重要成员 内容
id[16] 字符串形式的标识符
.smem_start fb 缓存开始位置,物理地址
.smem_len fb 缓存的长度
.type type 可取如下值: FB_TYPE_PACKED_PIXELSFB_TYPE_PACKED_PIXELSFB_TYPE_INTERLEAVED_PLANESFB_TYPE_TEXTFB_TYPE_VGA_PLANES
.type_aux 硬件显示点的方式
.visual 色彩模式,很多种
.xpanstep 硬件平移,无硬件平移值为 0
.ypanstep 硬件平移,无硬件平移值为 0
.ywrapstep
.line_length 一行多少个字节
.mmio_start 内存映射I/O开始位置,物理地址
.mmio_len 内存映射I/O 长度
.accel: 特定的芯片

2.2、fb_ops

功能:实现 Framebuffer 操作。
定义:include\linux\fb.h

3、Framebuffer内部函数分析

  • framebuffer_alloc()函数分析:

调用者:platform_driver->probe,例如 vfb_probe()
定义:drivers\video\fbsysfb.c
原型:include\linux\fb.h
extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
参数:

参数名 内容
size 驱动私有数据的大小,可以是 0;
dev 设备结构指针,可以是 NULL

该函数分配 fb_info 结构体和设备私有数据。如果存在设备私有数据,分配空间时,会保证 fb_info 和用户私有数据的起点差距是 4 字节的整数倍——Fb_info+PADDING+设备私有数据。

设备私有数据的指针是 fb_info->par
info->device = dev;
device 结构体定义于include\linux\device.h
kzalloc 是分配空间并把分配的空间都设为零。
GFP_KERNEL 的作用:分配空间的方式是一个在内核空间运行的进程的方式。
当内核可分配的 memory 不足时,内核会使 GFP_KERNEL 的使用者睡眠

  • fb_alloc_cmap() 函数分析
  • register_framebuffer() 函数分析
  • device_create() 函数分析
  • fb_get_options () 函数分析
  • video_setup () 函数分析

4、vfb分析

  • vfb_init() 函数分析
  • vfb_probe() 函数分析
  • vfb_setup() 函数分析
发布了252 篇原创文章 · 获赞 93 · 访问量 12万+

Guess you like

Origin blog.csdn.net/qq_33487044/article/details/104088470