Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2. s3c2410fb.c as an example
Linux 2.6 Driver Model
• Linux Kernel Driver Model
• Generic, centralized driver model
• A unification of all the disparate driver
models that were previously used in the
kernel.
• See
– include/linux/device.h
– driver/base/driver.c
Source: linux/Documentation/driver-model/overview.txt
Ideas and Benefits
• It is intended to augment the bus-specific
drivers for bridges and devices by
consolidating a set of data and operations
into globally accessible data structures.
• Traditional driver models implemented some
sort of tree-like structure (sometimes just a
list) for the devices they control. There
wasn't any uniformity across the different
bus types.
Source: linux/Documentation/driver-model/overview.txt
Platform Driver
• Drivers for platform devices are typically
very simple and unstructured. Either the
device was present at a particular I/O port
and the driver was loaded, or it was not.
• There was no possibility of hotplugging or
alternative discovery besides probing at a
specific I/O address and expecting a
specific response.
Source: linux/Documentation/driver-model/platform.txt
Traditional Device Driver Model
VFS
Driver D
Driver B
Driver A
Driver E
Driver C
New Linux 2.6 Driver Model
kernel
buses devices classes firmware kobject
Driver D
Driver B
Driver A
Driver E
Driver C
Consolusion
• Generic device driver
– 驅動程式開發者的框架( framework )、特定
裝置的驅動程式設計( architecture )或
kernel API
• kobject
– A unification of all the disparate driver models
that were previously used in the kernel.
• Platform driver
– Linux 2.6 的 machine-dependent
driver ( low-level )
TFT-LCD 驅動程式設定
• Device Drivers -> Graphics support
Drivers/video
CONFIG_FB
CONFIG_FB_S3C2410
Files: linux/drivers/video/s3c2410fb.c
Linux FB Subsystem
• linux/drivers/video/dummycon.c
– A dummy console driver
• linux/drivers/video/fbcmap.c
– Colormap handling for frame buffer devices
• linux/drivers/video/fbcon.c
– Low level frame buffer based console driver
• linux/drivers/video/cfbxx.c
– Low level frame buffer operations for xx bpp truecolor packed
pixels
• linux/drivers/video/fbcon-vga.c
– Low level frame buffer operations for VGA characters/attributes
cont...
• linux/drivers/video/fbgen.c
– Generic routines for frame buffer devices
• linux/drivers/video/fbmem.c
– Core of Linux Framebuffer subsystem
• linux/drivers/video/font_*.c
– Fonts
• linux/drivers/video/vesafb.c
– framebuffer driver for VBE 2.0 compliant graphic boards, see
arch/i386/boot/video.S
• linux/drivers/video/vfb.c
– Virtual frame buffer device
• linux/drivers/video/vgacon.c
– Low level VGA based console driver
• linux/drivers/video/s3c2410fb.c
– Low-level framebuffer driver for S3C2410
Porting Your Machine
Platform bus
buses System bus
kobject
s3c2410fb
使用 Platform Driver 觀念
static struct platform_driver s3c2410fb_driver = {
.probe = s3c2410fb_probe,
.remove = s3c2410fb_remove,
.suspend = s3c2410fb_suspend,
.resume = s3c2410fb_resume,
.driver = {
.name = "s3c2410-lcd",
.owner = THIS_MODULE,
},
};
Platform bus
buses System bus
kobject
probe() callback
VFS switch
s3c2410fb
fbmem
Register to…
s3c2410fb_probe()
填寫 struct fb_info 表格,這是 low-level 的 framebuffer 向上層註冊所要
傳入的 fops 資料結構。