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

📄 fbmem.c

📁 《linux驱动程序设计从入门到精通》一书中所有的程序代码含驱动和相应的应用程序
💻 C
📖 第 1 页 / 共 3 页
字号:
/* *  linux/drivers/video/fbmem.c * *  Copyright (C) 1994 Martin Schaller * *	2001 - Documented with DocBook *	- Brad Douglas <brad@neruo.com> * * This file is subject to the terms and conditions of the GNU General Public * License.  See the file COPYING in the main directory of this archive * for more details. */#include <linux/config.h>#include <linux/module.h>#include <linux/types.h>#include <linux/errno.h>#include <linux/sched.h>#include <linux/smp_lock.h>#include <linux/kernel.h>#include <linux/major.h>#include <linux/slab.h>#include <linux/mm.h>#include <linux/mman.h>#include <linux/tty.h>#include <linux/init.h>#include <linux/linux_logo.h>#include <linux/proc_fs.h>#include <linux/console.h>#ifdef CONFIG_KMOD#include <linux/kmod.h>#endif#include <linux/devfs_fs_kernel.h>#include <linux/err.h>#include <linux/kernel.h>#include <linux/device.h>#if defined(__mc68000__) || defined(CONFIG_APUS)#include <asm/setup.h>#endif#include <asm/io.h>#include <asm/uaccess.h>#include <asm/page.h>#include <asm/pgtable.h>#include <linux/fb.h>#ifdef CONFIG_FRAMEBUFFER_CONSOLE#include "console/fbcon.h"#endif    /*     *  Frame buffer device initialization and setup routines     */extern int acornfb_init(void);extern int acornfb_setup(char*);extern int amifb_init(void);extern int amifb_setup(char*);extern int atafb_init(void);extern int atafb_setup(char*);extern int macfb_init(void);extern int macfb_setup(char*);extern int cyberfb_init(void);extern int cyberfb_setup(char*);extern int pm2fb_init(void);extern int pm2fb_setup(char*);extern int pm3fb_init(void);extern int pm3fb_setup(char*);extern int clps711xfb_init(void);extern int cyber2000fb_init(void);extern int cyber2000fb_setup(char*);extern int retz3fb_init(void);extern int retz3fb_setup(char*);extern int cirrusfb_init(void);extern int cirrusfb_setup(char*);extern int hitfb_init(void);extern int vfb_init(void);extern int vfb_setup(char*);extern int offb_init(void);extern int atyfb_init(void);extern int atyfb_setup(char*);extern int aty128fb_init(void);extern int aty128fb_setup(char*);extern int neofb_init(void);extern int neofb_setup(char*);extern int igafb_init(void);extern int igafb_setup(char*);extern int imsttfb_init(void);extern int imsttfb_setup(char*);extern int dnfb_init(void);extern int tgafb_init(void);extern int tgafb_setup(char*);extern int virgefb_init(void);extern int virgefb_setup(char*);extern int resolver_video_setup(char*);extern int s3triofb_init(void);extern int vesafb_init(void);extern int vesafb_setup(char*);extern int vga16fb_init(void);extern int vga16fb_setup(char*);extern int hgafb_init(void);extern int hgafb_setup(char*);extern int matroxfb_init(void);extern int matroxfb_setup(char*);extern int hpfb_init(void);extern int platinumfb_init(void);extern int platinumfb_setup(char*);extern int control_init(void);extern int control_setup(char*);extern int valkyriefb_init(void);extern int valkyriefb_setup(char*);extern int chips_init(void);extern int g364fb_init(void);extern int sa1100fb_init(void);extern int pxafb_init(void);extern int pxafb_setup(char*);extern int fm2fb_init(void);extern int fm2fb_setup(char*);extern int q40fb_init(void);extern int sun3fb_init(void);extern int sun3fb_setup(char *);extern int sgivwfb_init(void);extern int sgivwfb_setup(char*);extern int gbefb_init(void);extern int gbefb_setup(char*);extern int rivafb_init(void);extern int rivafb_setup(char*);extern int tdfxfb_init(void);extern int tdfxfb_setup(char*);extern int tridentfb_init(void);extern int tridentfb_setup(char*);extern int sisfb_init(void);extern int sisfb_setup(char*);extern int stifb_init(void);extern int stifb_setup(char*);extern int pmagbafb_init(void);extern int pmagbbfb_init(void);extern int maxinefb_init(void);extern int tx3912fb_init(void);extern int tx3912fb_setup(char*);extern int radeonfb_init(void);extern int radeonfb_setup(char*);extern int radeonfb_old_init(void);extern int radeonfb_old_setup(char*);extern int e1355fb_init(void);extern int e1355fb_setup(char*);extern int pvr2fb_init(void);extern int pvr2fb_setup(char*);extern int sstfb_init(void);extern int sstfb_setup(char*);extern int i810fb_init(void);extern int i810fb_setup(char*);extern int ffb_init(void);extern int ffb_setup(char*);extern int cg6_init(void);extern int cg6_setup(char*);extern int cg3_init(void);extern int cg3_setup(char*);extern int bw2_init(void);extern int bw2_setup(char*);extern int cg14_init(void);extern int cg14_setup(char*);extern int p9100_init(void);extern int p9100_setup(char*);extern int tcx_init(void);extern int tcx_setup(char*);extern int leo_init(void);extern int leo_setup(char*);extern int kyrofb_init(void);extern int kyrofb_setup(char*);extern int mc68x328fb_init(void);extern int mc68x328fb_setup(char *);extern int asiliantfb_init(void);extern int imxfb_init(void);extern int imxfb_setup(char *);extern int s3c2410fb_init(void);extern int s3c2410fb_setup(char *);static struct {	const char *name;	int (*init)(void);	int (*setup)(char*);} fb_drivers[] __initdata = {	/*	 * Chipset specific drivers that use resource management	 */#ifdef CONFIG_FB_RETINAZ3	{ "retz3fb", retz3fb_init, retz3fb_setup },#endif#ifdef CONFIG_FB_AMIGA	{ "amifb", amifb_init, amifb_setup },#endif#ifdef CONFIG_FB_CLPS711X	{ "clps711xfb", clps711xfb_init, NULL },#endif#ifdef CONFIG_FB_CYBER	{ "cyberfb", cyberfb_init, cyberfb_setup },#endif#ifdef CONFIG_FB_CYBER2000	{ "cyber2000fb", cyber2000fb_init, cyber2000fb_setup },#endif#ifdef CONFIG_FB_PM2	{ "pm2fb", pm2fb_init, pm2fb_setup },#endif#ifdef CONFIG_FB_PM3	{ "pm3fb", pm3fb_init, pm3fb_setup },#endif           #ifdef CONFIG_FB_CIRRUS	{ "cirrusfb", cirrusfb_init, cirrusfb_setup },#endif#ifdef CONFIG_FB_ATY	{ "atyfb", atyfb_init, atyfb_setup },#endif#ifdef CONFIG_FB_MATROX	{ "matroxfb", matroxfb_init, matroxfb_setup },#endif#ifdef CONFIG_FB_ATY128	{ "aty128fb", aty128fb_init, aty128fb_setup },#endif#ifdef CONFIG_FB_NEOMAGIC	{ "neofb", neofb_init, neofb_setup },#endif#ifdef CONFIG_FB_VIRGE	{ "virgefb", virgefb_init, virgefb_setup },#endif#ifdef CONFIG_FB_RIVA	{ "rivafb", rivafb_init, rivafb_setup },#endif#ifdef CONFIG_FB_3DFX	{ "tdfxfb", tdfxfb_init, tdfxfb_setup },#endif#ifdef CONFIG_FB_RADEON	{ "radeonfb", radeonfb_init, radeonfb_setup },#endif#ifdef CONFIG_FB_RADEON_OLD	{ "radeonfb_old", radeonfb_old_init, radeonfb_old_setup },#endif#ifdef CONFIG_FB_CONTROL	{ "controlfb", control_init, control_setup },#endif#ifdef CONFIG_FB_PLATINUM	{ "platinumfb", platinumfb_init, platinumfb_setup },#endif#ifdef CONFIG_FB_VALKYRIE	{ "valkyriefb", valkyriefb_init, valkyriefb_setup },#endif#ifdef CONFIG_FB_CT65550	{ "chipsfb", chips_init, NULL },#endif#ifdef CONFIG_FB_IMSTT	{ "imsttfb", imsttfb_init, imsttfb_setup },#endif#ifdef CONFIG_FB_S3TRIO	{ "s3triofb", s3triofb_init, NULL },#endif #ifdef CONFIG_FB_FM2	{ "fm2fb", fm2fb_init, fm2fb_setup },#endif #ifdef CONFIG_FB_SIS	{ "sisfb", sisfb_init, sisfb_setup },#endif#ifdef CONFIG_FB_TRIDENT	{ "tridentfb", tridentfb_init, tridentfb_setup },#endif#ifdef CONFIG_FB_I810	{ "i810fb", i810fb_init, i810fb_setup },#endif	#ifdef CONFIG_FB_STI	{ "stifb", stifb_init, stifb_setup },#endif#ifdef CONFIG_FB_FFB	{ "ffb", ffb_init, ffb_setup },#endif#ifdef CONFIG_FB_CG6	{ "cg6fb", cg6_init, cg6_setup },#endif#ifdef CONFIG_FB_CG3	{ "cg3fb", cg3_init, cg3_setup },#endif#ifdef CONFIG_FB_BW2	{ "bw2fb", bw2_init, bw2_setup },#endif#ifdef CONFIG_FB_CG14	{ "cg14fb", cg14_init, cg14_setup },#endif#ifdef CONFIG_FB_P9100	{ "p9100fb", p9100_init, p9100_setup },#endif#ifdef CONFIG_FB_TCX	{ "tcxfb", tcx_init, tcx_setup },#endif#ifdef CONFIG_FB_LEO	{ "leofb", leo_init, leo_setup },#endif	/*	 * Generic drivers that are used as fallbacks	 * 	 * These depend on resource management and must be initialized	 * _after_ all other frame buffer devices that use resource	 * management!	 */#ifdef CONFIG_FB_OF	{ "offb", offb_init, NULL },#endif#ifdef CONFIG_FB_VESA	{ "vesafb", vesafb_init, vesafb_setup },#endif 	/*	 * Chipset specific drivers that don't use resource management (yet)	 */#ifdef CONFIG_FB_SGIVW	{ "sgivwfb", sgivwfb_init, sgivwfb_setup },#endif#ifdef CONFIG_FB_GBE	{ "gbefb", gbefb_init, gbefb_setup },#endif#ifdef CONFIG_FB_ACORN	{ "acornfb", acornfb_init, acornfb_setup },#endif#ifdef CONFIG_FB_ATARI	{ "atafb", atafb_init, atafb_setup },#endif#ifdef CONFIG_FB_MAC	{ "macfb", macfb_init, macfb_setup },#endif#ifdef CONFIG_FB_HGA	{ "hgafb", hgafb_init, hgafb_setup },#endif #ifdef CONFIG_FB_IGA	{ "igafb", igafb_init, igafb_setup },#endif#ifdef CONFIG_APOLLO	{ "apollofb", dnfb_init, NULL },#endif#ifdef CONFIG_FB_Q40	{ "q40fb", q40fb_init, NULL },#endif#ifdef CONFIG_FB_TGA	{ "tgafb", tgafb_init, tgafb_setup },#endif#ifdef CONFIG_FB_HP300	{ "hpfb", hpfb_init, NULL },#endif #ifdef CONFIG_FB_G364	{ "g364fb", g364fb_init, NULL },#endif#ifdef CONFIG_FB_SA1100	{ "sa1100fb", sa1100fb_init, NULL },#endif#ifdef CONFIG_FB_PXA	{ "pxafb", pxafb_init, pxafb_setup },#endif#ifdef CONFIG_FB_SUN3	{ "sun3fb", sun3fb_init, sun3fb_setup },#endif#ifdef CONFIG_FB_HIT	{ "hitfb", hitfb_init, NULL },#endif#ifdef CONFIG_FB_TX3912	{ "tx3912fb", tx3912fb_init, tx3912fb_setup },#endif#ifdef CONFIG_FB_E1355	{ "e1355fb", e1355fb_init, e1355fb_setup },#endif#ifdef CONFIG_FB_PVR2	{ "pvr2fb", pvr2fb_init, pvr2fb_setup },#endif#ifdef CONFIG_FB_PMAG_BA	{ "pmagbafb", pmagbafb_init, NULL },#endif          #ifdef CONFIG_FB_PMAGB_B	{ "pmagbbfb", pmagbbfb_init, NULL },#endif#ifdef CONFIG_FB_MAXINE	{ "maxinefb", maxinefb_init, NULL },#endif            #ifdef CONFIG_FB_VOODOO1	{ "sstfb", sstfb_init, sstfb_setup },#endif#ifdef CONFIG_FB_KYRO	{ "kyrofb", kyrofb_init, kyrofb_setup },#endif#ifdef CONFIG_FB_68328	{ "68328fb", mc68x328fb_init, mc68x328fb_setup },#endif#ifdef CONFIG_FB_ASILIANT	{ "asiliantfb", asiliantfb_init, NULL },#endif#ifdef CONFIG_FB_IMX	{ "imxfb", imxfb_init, imxfb_setup },#endif#ifdef CONFIG_FB_S3C2410	{ "s3c2410fb", s3c2410fb_init, s3c2410fb_setup },#endif	/*	 * Generic drivers that don't use resource management (yet)	 */#ifdef CONFIG_FB_VGA16	{ "vga16fb", vga16fb_init, vga16fb_setup },#endif #ifdef CONFIG_GSP_RESOLVER	/* Not a real frame buffer device... */	{ "resolverfb", NULL, resolver_video_setup },#endif#ifdef CONFIG_FB_VIRTUAL	/*	 * Vfb must be last to avoid that it becomes your primary display if	 * other display devices are present	 */	{ "vfb", vfb_init, vfb_setup },#endif};#define NUM_FB_DRIVERS	(sizeof(fb_drivers)/sizeof(*fb_drivers))#define FBPIXMAPSIZE	16384extern const char *global_mode_option;static initcall_t pref_init_funcs[FB_MAX];static int num_pref_init_funcs __initdata = 0;static struct notifier_block *fb_notifier_list;struct fb_info *registered_fb[FB_MAX];int num_registered_fb;#ifdef CONFIG_FB_OFstatic int ofonly __initdata = 0;#endif/* * Drawing helpers. */void fb_iomove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf,			   u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,			   u32 height){	int i;	for (i = height; i--; ) {		buf->outbuf(info, dst, src, s_pitch);		src += s_pitch;		dst += d_pitch;	}}void fb_sysmove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf,			    u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,			    u32 height){	int i, j;	for (i = height; i--; ) {		for (j = 0; j < s_pitch; j++)			dst[j] = src[j];		src += s_pitch;		dst += d_pitch;	}}void fb_iomove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,			     u8 *dst, u32 d_pitch, u8 *src, u32 idx,			     u32 height, u32 shift_high, u32 shift_low,			     u32 mod){	u8 mask = (u8) (0xfff << shift_high), tmp;	int i, j;	for (i = height; i--; ) {		for (j = 0; j < idx; j++) {			tmp = buf->inbuf(info, dst+j);			tmp &= mask;			tmp |= *src >> shift_low;			buf->outbuf(info, dst+j, &tmp, 1);			tmp = *src << shift_high;			buf->outbuf(info, dst+j+1, &tmp, 1);			src++;		}		tmp = buf->inbuf(info, dst+idx);		tmp &= mask;		tmp |= *src >> shift_low;		buf->outbuf(info, dst+idx, &tmp, 1);		if (shift_high < mod) {			tmp = *src << shift_high;			buf->outbuf(info, dst+idx+1, &tmp, 1);		}			src++;		dst += d_pitch;	}}void fb_sysmove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,			      u8 *dst, u32 d_pitch, u8 *src, u32 idx,			      u32 height, u32 shift_high, u32 shift_low,			      u32 mod){	u8 mask = (u8) (0xfff << shift_high), tmp;	int i, j;	for (i = height; i--; ) {		for (j = 0; j < idx; j++) {			tmp = dst[j];			tmp &= mask;			tmp |= *src >> shift_low;			dst[j] = tmp;			tmp = *src << shift_high;			dst[j+1] = tmp;			src++;		}		tmp = dst[idx];		tmp &= mask;		tmp |= *src >> shift_low;		dst[idx] = tmp;		if (shift_high < mod) {			tmp = *src << shift_high;			dst[idx+1] = tmp;		}		src++;		dst += d_pitch;	}}/* * we need to lock this section since fb_cursor * may use fb_imageblit() */char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size){	u32 align = buf->buf_align - 1, offset;	char *addr = buf->addr;	/* If IO mapped, we need to sync before access, no sharing of	 * the pixmap is done	 */	if (buf->flags & FB_PIXMAP_IO) {		if (info->fbops->fb_sync && (buf->flags & FB_PIXMAP_SYNC))			info->fbops->fb_sync(info);

⌨️ 快捷键说明

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