.probe = s3c2410fb_probe,
.remove = s3c2410fb_remove,
.suspend = s3c2410fb_suspend,
.resume = s3c2410fb_resume,
.driver = {
.name = 's3c2410-lcd',
.owner = THIS_MODULE,
},
};
3.3.2 lcd驱动注册时的匹配
platform_driver_register->
driver_register->
bus_add_driver->
driver_attach->
bus_for_each_dev-> // 从平台总线的的设备链表中,取出每一项设备进行匹配
__driver_attach->
driver_probe_device->
if (drv->bus->match && !drv->bus->match(dev, drv)) // 此总线类型为平台总线,其存在match函数,即调用platform_match进行匹配
// 之后的执行和上一小节分析的一样
3.3.3 匹配成功后 driver_probe_device 调用驱动层的probe
driver_probe_device-> // 在此函数中匹配成功的话,就会去调用驱动的probe函数
really_probe->
drv->probe(dev)
四,probe函数分析(s3c2410fb_probe)
4.1 注册framebuffer
4.1.1 申请struct fb_info
struct fb_info *fbinfo;
...
fbinfo = framebuffer_alloc(sizeof(struct s3c2410fb_info), &pdev->dev);
if (!fbinfo) {
return -ENOMEM;
}
...
4.1.2 参数设置
见4.2 LCD参数设置
4.1.3 注册
...
ret = register_framebuffer(fbinfo);
if (ret < 0) {
printk(KERN_ERR 'Failed to register framebuffer device: %dn', ret);
goto free_video_memory;
}
...
4.2 LCD 参数设置
获取平台设备数据,即smdk2440_lcd_cfg结构体内数据
// 获取平台数据即 linux-2.6.22.6/arch/arm/mach-s3c2440/mach-smdk2440.c中配置的smdk2440_lcd_cfg
mach_info = pdev->dev.platform_data;
if (mach_info == NULL) {
dev_err(&pdev->dev,'no platform data for lcd, cannot attachn');
return -EINVAL;
}
4.2.1 固定参数设置
struct fb_fix_screeninfo {
char id[16]; /* identification string eg 'TT Builtin' */
unsigned long smem_start; /* Start of frame buffer mem */
/* (physical address) */
__u32 smem_len; /* Length of frame buffer mem */
__u32 type; /* see FB_TYPE_* */
__u32 type_aux; /* Interleave for interleaved Planes */
__u32 visual; /* see FB_VISUAL_* */
__u16 xpanstep; /* zero if no hardware panning */
__u16 ypanstep; /* zero if no hardware panning */
__u16 ywrapstep; /* zero if no hardware ywrap */
__u32 line_length; /* length of a line in bytes */
unsigned long mmio_start; /* Start of Memory Mapped I/O */
/* (physical address) */
__u32 mmio_len; /* Length of Memory Mapped I/O */
__u32 accel; /* Indicate to driver which */
/* specific chip/card we have */
__u16 reserved[3]; /* Reserved for future compatibility */
};
...
id:driver 标识
strcpy(fbinfo->fix.id, driver_name);
smem_start:frame buffer 的起始地址
fbi->map_cpu = dma_alloc_writecombine(fbi->dev, fbi->map_size,
&fbi->map_dma, GFP_KERNEL);
...
fbi->screen_dma = fbi->map_dma;
fbi->fb->fix.smem_start = fbi->screen_dma;
...
smem_len:frame buffer 的长度字节为单位 = 480*272*16/8 屏宽*屏高*一个像素的数据位数/一个字节的位数
fbinfo->fix.smem_len = mach_info->xres.max *
mach_info->yres.max *
mach_info->bpp.max / 8;
type、type_aux:fb数据类型为像素类型,还有平面模式等
fbinfo->fix.type = FB_TYPE_PACKED_PIXELS;
fbinfo->fix.type_aux = 0;
visual:设置为真彩色,还有单色模式,黑/白
fbi->fb->fix.visual = FB_VISUAL_TRUECOLOR;
默认设置为0,简单理解为边框宽度
fbinfo->fix.xpanstep = 0;
fbinfo->fix.ypanstep = 0;
fbinfo->fix.ywrapstep = 0;
line_length:一行fb数据的字节数 480*16/8
fbi->fb->fix.line_length = (var->width*var->bits_per_pixel)/8;
4.2.2 可变参数设置
struct fb_var_screeninfo {
__u32 xres; /* visible resolution */
__u32 yres;
__u32 xres_virtual; /* virtual resolution */
__u32 yres_virtual;
__u32 xoffset; /* offset from virtual to visible */
__u32 yoffset; /* resolution */
__u32 bits_per_pixel; /* guess what */
__u32 grayscale; /* != 0 Graylevels instead of colors */
struct fb_bitfield red; /* bitfield in fb mem if true color, */
struct fb_bitfield green; /* else only length is significant */
struct fb_bitfield blue;
struct fb_bitfield transp; /* transparency */
__u32 nonstd; /* != 0 Non standard pixel format */
__u32 activate; /* see FB_ACTIVATE_* */
__u32 height; /* height of picture in mm */
__u32 width; /* width of picture in mm */
__u32 accel_flags; /* (OBSOLETE) see fb_info.flags */
/* Timing: All values in pixclocks, except pixclock (of course) */
__u32 pixclock; /* pixel clock in ps (pico seconds) */
__u32 left_margin; /* time from sync to picture */
__u32 right_margin; /* time from picture to sync */
__u32 upper_margin; /* time from sync to picture */
__u32 lower_margin;
__u32 hsync_len; /* length of horizontal sync */
__u32 vsync_len; /* length of vertical sync */
__u32 sync; /* see FB_SYNC_* */
__u32 vmode; /* see FB_VMODE_* */
__u32 rotate; /* angle we rotate counter clockwise */
__u32 reserved[5]; /* Reserved for future compatibility */
};
屏幕分辨率和单个像素点的数据位数
fbinfo->var.xres = mach_info->xres.defval; 480
fbinfo->var.xres_virtual = mach_info->xres.defval; 480
fbinfo->var.yres = mach_info->yres.defval; 272
fbinfo->var.yres_virtual = mach_info->yres.defval; 272
fbinfo->var.bits_per_pixel = mach_info->bpp.defval; 16
设置一个像素点的位数分配,rgb+透明度 rrrrrggggggbbbbb 位数从左边为第0位算
fbinfo->var.red.offset = 11;
fbinfo->var.green.offset = 5;
fbinfo->var.blue.offset = 0;
fbinfo->var.transp.offset = 0;
fbinfo->var.red.length = 5;
fbinfo->var.green.length = 6;
fbinfo->var.blue.length = 5;
fbinfo->var.transp.length = 0;
fbinfo->var.nonstd = 0; // 标准像素格式
fbinfo->var.activate = FB_ACTIVATE_NOW;
// 真实分辨率,设置480*272就行了,影响不大
fbinfo->var.height = mach_info->height;
fbinfo->var.width = mach_info->width;
fbinfo->var.accel_flags = 0;
fbinfo->var.vmode = FB_VMODE_NONINTERLACED;
// VBPD:一个VSYNC信号到来之后,多才时间才开始输出数据(显示图像)。会造成上边黑框
// VFPD:一帧(场)数据结束后多长时间,才来一个VSYNC信号。会造成下边黑框
// VSPW: 一个VSYNC信号的时间宽度
fbinfo->var.upper_margin = S3C2410_LCDCON2_GET_VBPD(mregs->lcdcon2) + 1;
fbinfo->var.lower_margin = S3C2410_LCDCON2_GET_VFPD(mregs->lcdcon2) + 1;
fbinfo->var.vsync_len = S3C2410_LCDCON2_GET_VSPW(mregs->lcdcon2) + 1;
// HFPD:一行数据结束多长时间才来一个HSYNC信号。会造成左边黑框
// HBPD:一个HSYNC信号到来之后,多长时间才开始输出数据(显示图像)。会造成右边黑框
上一篇:s3c2440裸机-时钟编程-1-2440时钟体系介绍
下一篇:《Linux驱动:s3c2440 lcd 驱动分析》
推荐阅读最新更新时间:2026-03-20 09:36
- 使用 ON Semiconductor 的 FAN2518S 的参考设计
- LTC1530S8、3.3V/3A 稳压器
- 使用 ON Semiconductor 的 ADP3167 的参考设计
- 使用 Analog Devices 的 LT3420EDD 的参考设计
- 基于Kinetis® M的低成本单相电表参考设计
- LTC3708、具有上升/下降轨跟踪功能的 2.5V/15A 和 1.2V/15A 稳压器
- NXQ1TXH5插件板
- 应变仪仪表放大器
- WRL-13287,基于 ESP8266 802.11 无线局域网的 SparkFun Wi-Fi Shield
- 4.1W、3-LED 通用 LED 照明驱动器



stm32驱动屏IC rm68042
电机驱动教程
非常经典的关于LLC的杨波博士论文
VI-27WIU






京公网安备 11010802033920号