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

📄 atafb.c

📁 Linux环境下视频显示卡设备的驱动程序源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * linux/drivers/video/atafb.c -- Atari builtin chipset frame buffer device * *  Copyright (C) 1994 Martin Schaller & Roman Hodek * * 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. * * History: *   - 03 Jan 95: Original version by Martin Schaller: The TT driver and *                all the device independent stuff *   - 09 Jan 95: Roman: I've added the hardware abstraction (hw_switch) *                and wrote the Falcon, ST(E), and External drivers *                based on the original TT driver. *   - 07 May 95: Martin: Added colormap operations for the external driver *   - 21 May 95: Martin: Added support for overscan *		  Andreas: some bug fixes for this *   -    Jul 95: Guenther Kelleter <guenther@pool.informatik.rwth-aachen.de>: *                Programmable Falcon video modes *                (thanks to Christian Cartus for documentation *                of VIDEL registers). *   - 27 Dec 95: Guenther: Implemented user definable video modes "user[0-7]" *                on minor 24...31. "user0" may be set on commandline by *                "R<x>;<y>;<depth>". (Makes sense only on Falcon) *                Video mode switch on Falcon now done at next VBL interrupt *                to avoid the annoying right shift of the screen. *   - 23 Sep 97: Juergen: added xres_virtual for cards like ProMST *                The external-part is legacy, therefore hardware-specific *                functions like panning/hardwarescrolling/blanking isn't *				  supported. *   - 29 Sep 97: Juergen: added Romans suggestion for pan_display *				  (var->xoffset was changed even if no set_screen_base avail.) *	 - 05 Oct 97: Juergen: extfb (PACKED_PIXEL) is FB_PSEUDOCOLOR 'cause *				  we know how to set the colors *				  ext_*palette: read from ext_colors (former MV300_colors) *							    write to ext_colors and RAMDAC * * To do: *   - For the Falcon it is not possible to set random video modes on *     SM124 and SC/TV, only the bootup resolution is supported. * */#define ATAFB_TT#define ATAFB_STE#define ATAFB_EXT#define ATAFB_FALCON#include <linux/module.h>#include <linux/kernel.h>#include <linux/errno.h>#include <linux/string.h>#include <linux/mm.h>#include <linux/slab.h>#include <linux/delay.h>#include <linux/init.h>#include <linux/interrupt.h>#include <asm/setup.h>#include <linux/uaccess.h>#include <asm/pgtable.h>#include <asm/irq.h>#include <asm/io.h>#include <asm/atarihw.h>#include <asm/atariints.h>#include <asm/atari_stram.h>#include <linux/fb.h>#include <asm/atarikb.h>#include "c2p.h"#include "atafb.h"#define SWITCH_ACIA 0x01		/* modes for switch on OverScan */#define SWITCH_SND6 0x40#define SWITCH_SND7 0x80#define SWITCH_NONE 0x00#define up(x, r) (((x) + (r) - 1) & ~((r)-1))	/*	 * Interface to the world	 */static int atafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info);static int atafb_set_par(struct fb_info *info);static int atafb_setcolreg(unsigned int regno, unsigned int red, unsigned int green,			   unsigned int blue, unsigned int transp,			   struct fb_info *info);static int atafb_blank(int blank, struct fb_info *info);static int atafb_pan_display(struct fb_var_screeninfo *var,			     struct fb_info *info);static void atafb_fillrect(struct fb_info *info,			   const struct fb_fillrect *rect);static void atafb_copyarea(struct fb_info *info,			   const struct fb_copyarea *region);static void atafb_imageblit(struct fb_info *info, const struct fb_image *image);static int atafb_ioctl(struct fb_info *info, unsigned int cmd,		       unsigned long arg);static int default_par;		/* default resolution (0=none) */static unsigned long default_mem_req;static int hwscroll = -1;static int use_hwscroll = 1;static int sttt_xres = 640, st_yres = 400, tt_yres = 480;static int sttt_xres_virtual = 640, sttt_yres_virtual = 400;static int ovsc_offset, ovsc_addlen;	/*	 * Hardware parameters for current mode	 */static struct atafb_par {	void *screen_base;	int yres_virtual;	u_long next_line;#if defined ATAFB_TT || defined ATAFB_STE	union {		struct {			int mode;			int sync;		} tt, st;#endif#ifdef ATAFB_FALCON		struct falcon_hw {			/* Here are fields for storing a video mode, as direct			 * parameters for the hardware.			 */			short sync;			short line_width;			short line_offset;			short st_shift;			short f_shift;			short vid_control;			short vid_mode;			short xoffset;			short hht, hbb, hbe, hdb, hde, hss;			short vft, vbb, vbe, vdb, vde, vss;			/* auxiliary information */			short mono;			short ste_mode;			short bpp;			u32 pseudo_palette[16];		} falcon;#endif		/* Nothing needed for external mode */	} hw;} current_par;/* Don't calculate an own resolution, and thus don't change the one found when * booting (currently used for the Falcon to keep settings for internal video * hardware extensions (e.g. ScreenBlaster)  */static int DontCalcRes = 0;#ifdef ATAFB_FALCON#define HHT hw.falcon.hht#define HBB hw.falcon.hbb#define HBE hw.falcon.hbe#define HDB hw.falcon.hdb#define HDE hw.falcon.hde#define HSS hw.falcon.hss#define VFT hw.falcon.vft#define VBB hw.falcon.vbb#define VBE hw.falcon.vbe#define VDB hw.falcon.vdb#define VDE hw.falcon.vde#define VSS hw.falcon.vss#define VCO_CLOCK25		0x04#define VCO_CSYPOS		0x10#define VCO_VSYPOS		0x20#define VCO_HSYPOS		0x40#define VCO_SHORTOFFS	0x100#define VMO_DOUBLE		0x01#define VMO_INTER		0x02#define VMO_PREMASK		0x0c#endifstatic struct fb_info fb_info = {	.fix = {		.id	= "Atari ",		.visual	= FB_VISUAL_PSEUDOCOLOR,		.accel	= FB_ACCEL_NONE,	}};static void *screen_base;	/* base address of screen */static void *real_screen_base;	/* (only for Overscan) */static int screen_len;static int current_par_valid;static int mono_moni;#ifdef ATAFB_EXT/* external video handling */static unsigned int external_xres;static unsigned int external_xres_virtual;static unsigned int external_yres;/* * not needed - atafb will never support panning/hardwarescroll with external * static unsigned int external_yres_virtual; */static unsigned int external_depth;static int external_pmode;static void *external_addr;static unsigned long external_len;static unsigned long external_vgaiobase;static unsigned int external_bitspercol = 6;/* * JOE <joe@amber.dinoco.de>: * added card type for external driver, is only needed for * colormap handling. */enum cardtype { IS_VGA, IS_MV300 };static enum cardtype external_card_type = IS_VGA;/* * The MV300 mixes the color registers. So we need an array of munged * indices in order to access the correct reg. */static int MV300_reg_1bit[2] = {	0, 1};static int MV300_reg_4bit[16] = {	0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15};static int MV300_reg_8bit[256] = {	0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240,	8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248,	4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244,	12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252,	2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242,	10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250,	6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246,	14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254,	1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241,	9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249,	5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245,	13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253,	3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243,	11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251,	7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247,	15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255};static int *MV300_reg = MV300_reg_8bit;#endif /* ATAFB_EXT */static int inverse;extern int fontheight_8x8;extern int fontwidth_8x8;extern unsigned char fontdata_8x8[];extern int fontheight_8x16;extern int fontwidth_8x16;extern unsigned char fontdata_8x16[];/* * struct fb_ops { *	* open/release and usage marking *	struct module *owner; *	int (*fb_open)(struct fb_info *info, int user); *	int (*fb_release)(struct fb_info *info, int user); * *	* For framebuffers with strange non linear layouts or that do not *	* work with normal memory mapped access *	ssize_t (*fb_read)(struct file *file, char __user *buf, size_t count, loff_t *ppos); *	ssize_t (*fb_write)(struct file *file, const char __user *buf, size_t count, loff_t *ppos); * *	* checks var and eventually tweaks it to something supported, *	* DOES NOT MODIFY PAR * *	int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info); * *	* set the video mode according to info->var * *	int (*fb_set_par)(struct fb_info *info); * *	* set color register * *	int (*fb_setcolreg)(unsigned int regno, unsigned int red, unsigned int green, *			    unsigned int blue, unsigned int transp, struct fb_info *info); * *	* set color registers in batch * *	int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info); * *	* blank display * *	int (*fb_blank)(int blank, struct fb_info *info); * *	* pan display * *	int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info); * *	*** The meat of the drawing engine *** *	* Draws a rectangle * *	void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect); *	* Copy data from area to another * *	void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region); *	* Draws a image to the display * *	void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image); * *	* Draws cursor * *	int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor); * *	* Rotates the display * *	void (*fb_rotate)(struct fb_info *info, int angle); * *	* wait for blit idle, optional * *	int (*fb_sync)(struct fb_info *info); * *	* perform fb specific ioctl (optional) * *	int (*fb_ioctl)(struct fb_info *info, unsigned int cmd, *			unsigned long arg); * *	* Handle 32bit compat ioctl (optional) * *	int (*fb_compat_ioctl)(struct fb_info *info, unsigned int cmd, *			unsigned long arg); * *	* perform fb specific mmap * *	int (*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma); * *	* save current hardware state * *	void (*fb_save_state)(struct fb_info *info); * *	* restore saved state * *	void (*fb_restore_state)(struct fb_info *info); * } ; *//* ++roman: This structure abstracts from the underlying hardware (ST(e), * TT, or Falcon. * * int (*detect)(void) *   This function should detect the current video mode settings and *   store them in atafb_predefined[0] for later reference by the *   user. Return the index+1 of an equivalent predefined mode or 0 *   if there is no such. * * int (*encode_fix)(struct fb_fix_screeninfo *fix, *                   struct atafb_par *par) *   This function should fill in the 'fix' structure based on the *   values in the 'par' structure. * !!! Obsolete, perhaps !!! * * int (*decode_var)(struct fb_var_screeninfo *var, *                   struct atafb_par *par) *   Get the video params out of 'var'. If a value doesn't fit, round *   it up, if it's too big, return EINVAL. *   Round up in the following order: bits_per_pixel, xres, yres, *   xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, *   horizontal timing, vertical timing. * * int (*encode_var)(struct fb_var_screeninfo *var, *                   struct atafb_par *par); *   Fill the 'var' structure based on the values in 'par' and maybe *   other values read out of the hardware. * * void (*get_par)(struct atafb_par *par) *   Fill the hardware's 'par' structure. *   !!! Used only by detect() !!! * * void (*set_par)(struct atafb_par *par) *   Set the hardware according to 'par'. * * void (*set_screen_base)(void *s_base) *   Set the base address of the displayed frame buffer. Only called *   if yres_virtual > yres or xres_virtual > xres. * * int (*blank)(int blank_mode) *   Blank the screen if blank_mode != 0, else unblank. If blank == NULL then *   the caller blanks by setting the CLUT to all black. Return 0 if blanking *   succeeded, !=0 if un-/blanking failed due to e.g. a video mode which *   doesn't support it. Implements VESA suspend and powerdown modes on *   hardware that supports disabling hsync/vsync: *       blank_mode == 2: suspend vsync, 3:suspend hsync, 4: powerdown. */static struct fb_hwswitch {	int (*detect)(void);	int (*encode_fix)(struct fb_fix_screeninfo *fix,			  struct atafb_par *par);	int (*decode_var)(struct fb_var_screeninfo *var,			  struct atafb_par *par);	int (*encode_var)(struct fb_var_screeninfo *var,			  struct atafb_par *par);	void (*get_par)(struct atafb_par *par);	void (*set_par)(struct atafb_par *par);	void (*set_screen_base)(void *s_base);	int (*blank)(int blank_mode);	int (*pan_display)(struct fb_var_screeninfo *var,			   struct fb_info *info);} *fbhw;static char *autodetect_names[] = { "autodetect", NULL };static char *stlow_names[] = { "stlow", NULL };static char *stmid_names[] = { "stmid", "default5", NULL };static char *sthigh_names[] = { "sthigh", "default4", NULL };static char *ttlow_names[] = { "ttlow", NULL };static char *ttmid_names[] = { "ttmid", "default1", NULL };static char *tthigh_names[] = { "tthigh", "default2", NULL };static char *vga2_names[] = { "vga2", NULL };static char *vga4_names[] = { "vga4", NULL };static char *vga16_names[] = { "vga16", "default3", NULL };static char *vga256_names[] = { "vga256", NULL };static char *falh2_names[] = { "falh2", NULL };static char *falh16_names[] = { "falh16", NULL };static char **fb_var_names[] = {	autodetect_names,	stlow_names,	stmid_names,	sthigh_names,	ttlow_names,	ttmid_names,	tthigh_names,	vga2_names,	vga4_names,	vga16_names,	vga256_names,	falh2_names,	falh16_names,	NULL};static struct fb_var_screeninfo atafb_predefined[] = {	/*	 * yres_virtual == 0 means use hw-scrolling if possible, else yres	 */	{ /* autodetect */	  0, 0, 0, 0, 0, 0, 0, 0,		/* xres-grayscale */	  {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},	/* red green blue tran*/	  0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },	{ /* st low */	  320, 200, 320, 0, 0, 0, 4, 0,	  {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0},	  0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },	{ /* st mid */	  640, 200, 640, 0, 0, 0, 2, 0,	  {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0},	  0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 },	{ /* st high */

⌨️ 快捷键说明

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