brintos

brintos / linux-shallow public Read only

0
0
Text · 9.0 KiB · 25d2e71 Raw
321 lines · c
1/*2 *  linux/drivers/video/fm2fb.c -- BSC FrameMaster II/Rainbow II frame buffer3 *				   device4 *5 *	Copyright (C) 1998 Steffen A. Mork (linux-dev@morknet.de)6 *	Copyright (C) 1999 Geert Uytterhoeven7 *8 *  Written for 2.0.x by Steffen A. Mork9 *  Ported to 2.1.x by Geert Uytterhoeven10 *  Ported to new api by James Simmons11 *12 *  This file is subject to the terms and conditions of the GNU General Public13 *  License. See the file COPYING in the main directory of this archive for14 *  more details.15 */16 17#include <linux/module.h>18#include <linux/mm.h>19#include <linux/fb.h>20#include <linux/init.h>21#include <linux/zorro.h>22#include <asm/io.h>23 24/*25 *	Some technical notes:26 *27 *	The BSC FrameMaster II (or Rainbow II) is a simple very dumb28 *	frame buffer which allows to display 24 bit true color images.29 *	Each pixel is 32 bit width so it's very easy to maintain the30 *	frame buffer. One long word has the following layout:31 *	AARRGGBB which means: AA the alpha channel byte, RR the red32 *	channel, GG the green channel and BB the blue channel.33 *34 *	The FrameMaster II supports the following video modes.35 *	- PAL/NTSC36 *	- interlaced/non interlaced37 *	- composite sync/sync/sync over green38 *39 *	The resolution is to the following both ones:40 *	- 768x576 (PAL)41 *	- 768x480 (NTSC)42 *43 *	This means that pixel access per line is fixed due to the44 *	fixed line width. In case of maximal resolution the frame45 *	buffer needs an amount of memory of 1.769.472 bytes which46 *	is near to 2 MByte (the allocated address space of Zorro2).47 *	The memory is channel interleaved. That means every channel48 *	owns four VRAMs. Unfortunately most FrameMasters II are49 *	not assembled with memory for the alpha channel. In this50 *	case it could be possible to add the frame buffer into the51 *	normal memory pool.52 *53 *	At relative address 0x1ffff8 of the frame buffers base address54 *	there exists a control register with the number of55 *	four control bits. They have the following meaning:56 *	bit value meaning57 *58 *	 0    1   0=interlaced/1=non interlaced59 *	 1    2   0=video out disabled/1=video out enabled60 *	 2    4   0=normal mode as jumpered via JP8/1=complement mode61 *	 3    8   0=read  onboard ROM/1 normal operation (required)62 *63 *	As mentioned above there are several jumper. I think there64 *	is not very much information about the FrameMaster II in65 *	the world so I add these information for completeness.66 *67 *	JP1  interlace selection (1-2 non interlaced/2-3 interlaced)68 *	JP2  wait state creation (leave as is!)69 *	JP3  wait state creation (leave as is!)70 *	JP4  modulate composite sync on green output (1-2 composite71 *	     sync on green channel/2-3 normal composite sync)72 *	JP5  create test signal, shorting this jumper will create73 *	     a white screen74 *	JP6  sync creation (1-2 composite sync/2-3 H-sync output)75 *	JP8  video mode (1-2 PAL/2-3 NTSC)76 *77 *	With the following jumpering table you can connect the78 *	FrameMaster II to a normal TV via SCART connector:79 *	JP1:  2-380 *	JP4:  2-381 *	JP6:  2-382 *	JP8:  1-2 (means PAL for Europe)83 *84 *	NOTE:85 *	There is no other possibility to change the video timings86 *	except the interlaced/non interlaced, sync control and the87 *	video mode PAL (50 Hz)/NTSC (60 Hz). Inside this88 *	FrameMaster II driver are assumed values to avoid anomalies89 *	to a future X server. Except the pixel clock is really90 *	constant at 30 MHz.91 *92 *	9 pin female video connector:93 *94 *	1  analog red 0.7 Vss95 *	2  analog green 0.7 Vss96 *	3  analog blue 0.7 Vss97 *	4  H-sync TTL98 *	5  V-sync TTL99 *	6  ground100 *	7  ground101 *	8  ground102 *	9  ground103 *104 *	Some performance notes:105 *	The FrameMaster II was not designed to display a console106 *	this driver would do! It was designed to display still true107 *	color images. Imagine: When scroll up a text line there108 *	must copied ca. 1.7 MBytes to another place inside this109 *	frame buffer. This means 1.7 MByte read and 1.7 MByte write110 *	over the slow 16 bit wide Zorro2 bus! A scroll of one111 *	line needs 1 second so do not expect to much from this112 *	driver - he is at the limit!113 *114 */115 116/*117 *	definitions118 */119 120#define FRAMEMASTER_SIZE	0x200000121#define FRAMEMASTER_REG		0x1ffff8122 123#define FRAMEMASTER_NOLACE	1124#define FRAMEMASTER_ENABLE	2125#define FRAMEMASTER_COMPL	4126#define FRAMEMASTER_ROM		8127 128static volatile unsigned char *fm2fb_reg;129 130static struct fb_fix_screeninfo fb_fix = {131	.smem_len =	FRAMEMASTER_REG,132	.type =		FB_TYPE_PACKED_PIXELS,133	.visual =	FB_VISUAL_TRUECOLOR,134	.line_length =	(768 << 2),135	.mmio_len =	(8),136	.accel =	FB_ACCEL_NONE,137};138 139static int fm2fb_mode = -1;140 141#define FM2FB_MODE_PAL	0142#define FM2FB_MODE_NTSC	1143 144static struct fb_var_screeninfo fb_var_modes[] = {145    {146	/* 768 x 576, 32 bpp (PAL) */147	768, 576, 768, 576, 0, 0, 32, 0,148	{ 16, 8, 0 }, { 8, 8, 0 }, { 0, 8, 0 }, { 24, 8, 0 },149	0, FB_ACTIVATE_NOW, -1, -1, FB_ACCEL_NONE,150	33333, 10, 102, 10, 5, 80, 34, FB_SYNC_COMP_HIGH_ACT, 0151    }, {152	/* 768 x 480, 32 bpp (NTSC - not supported yet */153	768, 480, 768, 480, 0, 0, 32, 0,154	{ 16, 8, 0 }, { 8, 8, 0 }, { 0, 8, 0 }, { 24, 8, 0 },155	0, FB_ACTIVATE_NOW, -1, -1, FB_ACCEL_NONE,156	33333, 10, 102, 10, 5, 80, 34, FB_SYNC_COMP_HIGH_ACT, 0157    }158};159 160    /*161     *  Interface used by the world162     */163 164static int fm2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,165                           u_int transp, struct fb_info *info);166static int fm2fb_blank(int blank, struct fb_info *info);167 168static const struct fb_ops fm2fb_ops = {169	.owner		= THIS_MODULE,170	FB_DEFAULT_IOMEM_OPS,171	.fb_setcolreg	= fm2fb_setcolreg,172	.fb_blank	= fm2fb_blank,173};174 175    /*176     *  Blank the display.177     */178static int fm2fb_blank(int blank, struct fb_info *info)179{180	unsigned char t = FRAMEMASTER_ROM;181 182	if (!blank)183		t |= FRAMEMASTER_ENABLE | FRAMEMASTER_NOLACE;184	fm2fb_reg[0] = t;185	return 0;186}187 188    /*189     *  Set a single color register. The values supplied are already190     *  rounded down to the hardware's capabilities (according to the191     *  entries in the var structure). Return != 0 for invalid regno.192     */193static int fm2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,194                         u_int transp, struct fb_info *info)195{196	if (regno < 16) {197		red >>= 8;198		green >>= 8;199		blue >>= 8;200 201		((u32*)(info->pseudo_palette))[regno] = (red << 16) |202			(green << 8) | blue;203	}204 205	return 0;206}207 208    /*209     *  Initialisation210     */211 212static int fm2fb_probe(struct zorro_dev *z, const struct zorro_device_id *id);213 214static const struct zorro_device_id fm2fb_devices[] = {215	{ ZORRO_PROD_BSC_FRAMEMASTER_II },216	{ ZORRO_PROD_HELFRICH_RAINBOW_II },217	{ 0 }218};219MODULE_DEVICE_TABLE(zorro, fm2fb_devices);220 221static struct zorro_driver fm2fb_driver = {222	.name		= "fm2fb",223	.id_table	= fm2fb_devices,224	.probe		= fm2fb_probe,225};226 227static int fm2fb_probe(struct zorro_dev *z, const struct zorro_device_id *id)228{229	struct fb_info *info;230	unsigned long *ptr;231	int is_fm;232	int x, y;233 234	is_fm = z->id == ZORRO_PROD_BSC_FRAMEMASTER_II;235 236	if (!zorro_request_device(z,"fm2fb"))237		return -ENXIO;238 239	info = framebuffer_alloc(16 * sizeof(u32), &z->dev);240	if (!info) {241		zorro_release_device(z);242		return -ENOMEM;243	}244 245	if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {246		framebuffer_release(info);247		zorro_release_device(z);248		return -ENOMEM;249	}250 251	/* assigning memory to kernel space */252	fb_fix.smem_start = zorro_resource_start(z);253	info->screen_base = ioremap(fb_fix.smem_start, FRAMEMASTER_SIZE);254	fb_fix.mmio_start = fb_fix.smem_start + FRAMEMASTER_REG;255	fm2fb_reg  = (unsigned char *)(info->screen_base+FRAMEMASTER_REG);256 257	strcpy(fb_fix.id, is_fm ? "FrameMaster II" : "Rainbow II");258 259	/* make EBU color bars on display */260	ptr = (unsigned long *)fb_fix.smem_start;261	for (y = 0; y < 576; y++) {262		for (x = 0; x < 96; x++) *ptr++ = 0xffffff;/* white */263		for (x = 0; x < 96; x++) *ptr++ = 0xffff00;/* yellow */264		for (x = 0; x < 96; x++) *ptr++ = 0x00ffff;/* cyan */265		for (x = 0; x < 96; x++) *ptr++ = 0x00ff00;/* green */266		for (x = 0; x < 96; x++) *ptr++ = 0xff00ff;/* magenta */267		for (x = 0; x < 96; x++) *ptr++ = 0xff0000;/* red */268		for (x = 0; x < 96; x++) *ptr++ = 0x0000ff;/* blue */269		for (x = 0; x < 96; x++) *ptr++ = 0x000000;/* black */270	}271	fm2fb_blank(0, info);272 273	if (fm2fb_mode == -1)274		fm2fb_mode = FM2FB_MODE_PAL;275 276	info->fbops = &fm2fb_ops;277	info->var = fb_var_modes[fm2fb_mode];278	info->pseudo_palette = info->par;279	info->par = NULL;280	info->fix = fb_fix;281 282	if (register_framebuffer(info) < 0) {283		fb_dealloc_cmap(&info->cmap);284		iounmap(info->screen_base);285		framebuffer_release(info);286		zorro_release_device(z);287		return -EINVAL;288	}289	fb_info(info, "%s frame buffer device\n", fb_fix.id);290	return 0;291}292 293static int __init fm2fb_setup(char *options)294{295	char *this_opt;296 297	if (!options || !*options)298		return 0;299 300	while ((this_opt = strsep(&options, ",")) != NULL) {301		if (!strncmp(this_opt, "pal", 3))302			fm2fb_mode = FM2FB_MODE_PAL;303		else if (!strncmp(this_opt, "ntsc", 4))304			fm2fb_mode = FM2FB_MODE_NTSC;305	}306	return 0;307}308 309static int __init fm2fb_init(void)310{311	char *option = NULL;312 313	if (fb_get_options("fm2fb", &option))314		return -ENODEV;315	fm2fb_setup(option);316	return zorro_register_driver(&fm2fb_driver);317}318 319module_init(fm2fb_init);320MODULE_LICENSE("GPL");321