34.【linux駆動】framebuffer駆動
17385 ワード
1.framebuffer駆動2.spi framebuffer駆動3.spi framebufferドライバ(仮想端末の切り替えと表示)
framebuffer駆動
framebufferの最も基本的なドライバはfb_を記入して登録するだけです.info構造体
パラメータは比較的に多くて、説明しないで、1つの例を見ます
fbメモリバッファは
framebuffer駆動
framebufferの最も基本的なドライバはfb_を記入して登録するだけです.info構造体
struct fb_info {
atomic_t count;
int node;
int flags;
struct mutex lock; /* Lock for open/release/ioctl funcs */
struct mutex mm_lock; /* Lock for fb_mmap and smem_* fields */
struct fb_var_screeninfo var; /* Current var */
struct fb_fix_screeninfo fix; /* Current fix */
struct fb_monspecs monspecs; /* Current Monitor specs */
struct work_struct queue; /* Framebuffer event queue */
struct fb_pixmap pixmap; /* Image hardware mapper */
struct fb_pixmap sprite; /* Cursor hardware mapper */
struct fb_cmap cmap; /* Current cmap */
struct list_head modelist; /* mode list */
struct fb_videomode *mode; /* current mode */
#ifdef CONFIG_FB_BACKLIGHT
/* assigned backlight device */
/* set before framebuffer registration,
remove after unregister */
struct backlight_device *bl_dev;
/* Backlight level curve */
struct mutex bl_curve_mutex;
u8 bl_curve[FB_BACKLIGHT_LEVELS];
#endif
#ifdef CONFIG_FB_DEFERRED_IO
struct delayed_work deferred_work;
struct fb_deferred_io *fbdefio;
#endif
struct fb_ops *fbops;
struct device *device; /* This is the parent */
struct device *dev; /* This is this fb device */
int class_flag; /* private sysfs flags */
#ifdef CONFIG_FB_TILEBLITTING
struct fb_tile_ops *tileops; /* Tile Blitting */
#endif
char __iomem *screen_base; /* Virtual address */
unsigned long screen_size; /* Amount of ioremapped VRAM or 0 */
void *pseudo_palette; /* Fake palette of 16 colors */
#define FBINFO_STATE_RUNNING 0
#define FBINFO_STATE_SUSPENDED 1
u32 state; /* Hardware state i.e suspend */
void *fbcon_par; /* fbcon use-only private area */
/* From here on everything is device dependent */
void *par;
/* we need the PCI or similar aperture base/size not
smem_start/size as smem_start may just be an object
allocated inside the aperture so may not actually overlap */
struct apertures_struct {
unsigned int count;
struct aperture {
resource_size_t base;
resource_size_t size;
} ranges[0];
} *apertures;
};
パラメータは比較的に多くて、説明しないで、1つの例を見ます
#include
#include
#include
#include
#define X 1024
#define Y 768
u32 p_addr; //
u8 *v_addr; // , ,
struct fb_ops fops = { // , fbmem.c
// ,
};
struct fb_info *fbi;
static int __init framebuffer_init(void)
{
v_addr = dma_alloc_coherent(NULL, X*Y*4, &p_addr, GFP_KERNEL); //
// fb_info , 100 ( 100 ==&fbi[1])
fbi = framebuffer_alloc(100, NULL);
fbi->var.xres = X; //
fbi->var.yres = Y;
fbi->var.xres_virtual = X;
fbi->var.yres_virtual = Y;
fbi->var.bits_per_pixel = 32; // 32
fbi->var.red.offset = 16; //
fbi->var.red.length = 8;
fbi->var.green.offset = 8; //
fbi->var.green.length = 8;
fbi->var.blue.offset = 0; //
fbi->var.blue.length = 8;
strcpy(fbi->fix.id, "myfb");
fbi->fix.smem_start = p_addr; //
fbi->fix.smem_len = X*Y*4; //
fbi->fix.type = FB_TYPE_PACKED_PIXELS; //
fbi->fix.visual = FB_VISUAL_TRUECOLOR; //
fbi->fix.line_length = X*4; //
fbi->fbops = &fops;
fbi->screen_base = v_addr; //
fbi->screen_size = X*Y*4;
return register_framebuffer(fbi); // fb
}
static void __exit framebuffer_exit(void)
{
unregister_framebuffer(fbi);
framebuffer_release(fbi);
dma_free_coherent(NULL, X*Y*4, v_addr, p_addr);
}
module_init(framebuffer_init);
module_exit(framebuffer_exit);
MODULE_LICENSE("GPL");
fbメモリバッファは
dma_alloc_coherent
を使用して物理連続大メモリを申請する.register_framebuffer
登録構造体を用いてframebufferデバイスの登録が完了し、/devディレクトリの下に新しいfbデバイスが生成されたことがわかる.