⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 framebuffer.h

📁 ARM&linux 嵌入式系统 开发程序样例
💻 H
字号:
/*
 *	framebuffer.h	---	Primary header file of 
 *						LCD Device Driver with Framebuffer
 *						for MGUI
 *	(C)opyright 2004 Bit 920 Labs
 *
 *	Written by: Ye Nan <bye200009123@163.com>
 *	Created on: Sat. Mar 6 22:03:45 GMT +8:00 2004
 */

#ifndef __GAL_DRIVER_FB_H
#define __GAL_DRIVER_FB_H

#include "../gal.h"
#include "../../include/sysdef.h"
#include <linux/fb.h>

// Define common data types
typedef unsigned char	ByteType;
typedef unsigned short	WordType;
typedef unsigned long	DWordType;

// Define color types
typedef unsigned long	ColorType;

// Define default dash space
#define DEFAULT_DASH	2

// Framebuffer device display information
unsigned int fb_bpp;
unsigned int fb_width;
unsigned int fb_height;
unsigned int fb_pixel_size;
unsigned int fb_line_size;
unsigned int fb_buffer_size;

// Define macro of display information
#define BPP				fb_bpp
#define SCREEN_WIDTH	fb_width
#define SCREEN_HEIGHT	fb_height
#define PIXEL_SIZE		fb_pixel_size
#define LINE_SIZE		fb_line_size
#define BUFFER_SIZE		fb_buffer_size

// Define color convertion macro
#define _RGB2COLOR8(r, g, b)		(((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
#define _RGB2COLOR16(r, g, b)		((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3))

#define _COLOR8_RED(color)			(((color) >> 5) & 0x07)
#define _COLOR8_GREEN(color)		(((color) >> 2) & 0x07)
#define _COLOR8_BLUE(color)			((color) & 0x03)

#define _COLOR16_RED(color)			(((color) >> 11) & 0x1f)
#define _COLOR16_GREEN(color)		(((color) >> 5) & 0x3f)
#define _COLOR16_BLUE(color)		((color) & 0x1f)

#define _COLOR24_RED(color)		    (((color) >> 16) & 0xff)
#define _COLOR24_GREEN(color)		(((color) >> 8) & 0xff)
#define _COLOR24_BLUE(color)		((color) & 0xff)

#define _COLOR24_16(color)			_RGB2COLOR16(_COLOR24_RED(color), _COLOR24_GREEN(color), _COLOR24_BLUE(color))
#define _COLOR24_8(color)			_RGB2COLOR8(_COLOR24_RED(color), _COLOR24_GREEN(color), _COLOR24_BLUE(color))

/* * * * * * * * * * * * * * * * * * * *
 *
 * Framebuffer device display functions
 *
 * * * * * * * * * * * * * * * * * * * */

// Framebuffer initialization.
// Failed return 0, succeed return 1.
int fb_Init(void);

// Framebuffer release
void fb_Release(void);

// Assert device is opened
int fb_AssertDevice(int dev);

// Make up System Palette
void fb_MakePalette(struct fb_cmap *map);

// Save System Palette
int fb_SavePalette(struct fb_cmap * map);

// Update System Palette
int fb_UpdatePalette(struct fb_cmap map);

// Make up a color fits for 8-bit display according to RGB factors specified
ColorType fb_MakeColor_8(ByteType red, ByteType green, ByteType blue);

// Make up a color fits for 16-bit display according to RGB factors specified
ColorType fb_MakeColor_16(ByteType red, ByteType green, ByteType blue);

// Retrieve base address of frame buffer
void * fb_GetFrameAddr();

// Retrieve screen width
unsigned int fb_GetScreenWidth();

// Retrieve screen height
unsigned int fb_GetScreenHeight();

// Retrieve screen bits_per_pixel
unsigned int fb_GetScreenBpp();

// Retrieve screen colors
unsigned int fb_GetScreenColors();

// Clear screen with specified color
void fb_Clear(ColorType color);

// Put a color pixel on the screen
void fb_PutPixel(int x, int y, ColorType color/*, int xorm */);

// Retrieve the color of specified pixel
ColorType fb_GetPixel(int x, int y);

// Draw a horizontal line on the screen
void fb_DrawLine_H(int x1, int x2, int y, ColorType color/*, int xorm */);

// Draw a vertical line on the screen
void fb_DrawLine_V(int x, int y1, int y2, ColorType color/*, int xorm */);

// Draw a common line on the screen
void fb_DrawLine(int x1, int y1, int x2, int y2, ColorType color/*, int xorm */);

// Draw a rectangle frame on the screen
void fb_DrawRect(int x1, int y1, int x2, int y2, ColorType color);
                                                                                                                                                                                                                                                                                                                                                            
// Draw a rectangle frame on the screen
void fb_FillRect(int x1, int y1, int x2, int y2, ColorType color);

// Save screen content of specified range
void fb_SaveRange(int x1, int y1, int x2, int y2, ByteType * buffer, int * sw, int * sh);

// Load saved screen content to specified range
void fb_LoadRange(int x1, int y1, int x2, int y2, ByteType * buffer, int sw, int sh);


// Interface functions
int InitFB(GFX * gfx);
void ReleaseFB(GFX * gfx);

#endif	// __GAL_DRIVER_FB_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -