GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / video / g364fb.c
blob945c162fad5441c3ab6e0f9f3e9a506731bca739
1 /* $Id: g364fb.c,v 1.3 1998/08/28 22:43:00 Exp $
3 * linux/drivers/video/g364fb.c -- Mips Magnum frame buffer device
5 * (C) 1998 Thomas Bogendoerfer
7 * This driver is based on tgafb.c
9 * Copyright (C) 1997 Geert Uytterhoeven
10 * Copyright (C) 1995 Jay Estabrook
12 * This file is subject to the terms and conditions of the GNU General Public
13 * License. See the file COPYING in the main directory of this archive for
14 * more details.
17 #include <linux/module.h>
18 #include <linux/console.h>
19 #include <linux/kernel.h>
20 #include <linux/errno.h>
21 #include <linux/string.h>
22 #include <linux/mm.h>
23 #include <linux/vmalloc.h>
24 #include <linux/delay.h>
25 #include <linux/interrupt.h>
26 #include <linux/fb.h>
27 #include <linux/init.h>
28 #include <asm/io.h>
29 #include <asm/jazz.h>
31 /*
32 * Various defines for the G364
34 #define G364_MEM_BASE 0xe4400000
35 #define G364_PORT_BASE 0xe4000000
36 #define ID_REG 0xe4000000 /* Read only */
37 #define BOOT_REG 0xe4080000
38 #define TIMING_REG 0xe4080108 /* to 0x080170 - DON'T TOUCH! */
39 #define DISPLAY_REG 0xe4080118
40 #define VDISPLAY_REG 0xe4080150
41 #define MASK_REG 0xe4080200
42 #define CTLA_REG 0xe4080300
43 #define CURS_TOGGLE 0x800000
44 #define BIT_PER_PIX 0x700000 /* bits 22 to 20 of Control A */
45 #define DELAY_SAMPLE 0x080000
46 #define PORT_INTER 0x040000
47 #define PIX_PIPE_DEL 0x030000 /* bits 17 and 16 of Control A */
48 #define PIX_PIPE_DEL2 0x008000 /* same as above - don't ask me why */
49 #define TR_CYCLE_TOG 0x004000
50 #define VRAM_ADR_INC 0x003000 /* bits 13 and 12 of Control A */
51 #define BLANK_OFF 0x000800
52 #define FORCE_BLANK 0x000400
53 #define BLK_FUN_SWTCH 0x000200
54 #define BLANK_IO 0x000100
55 #define BLANK_LEVEL 0x000080
56 #define A_VID_FORM 0x000040
57 #define D_SYNC_FORM 0x000020
58 #define FRAME_FLY_PAT 0x000010
59 #define OP_MODE 0x000008
60 #define INTL_STAND 0x000004
61 #define SCRN_FORM 0x000002
62 #define ENABLE_VTG 0x000001
63 #define TOP_REG 0xe4080400
64 #define CURS_PAL_REG 0xe4080508 /* to 0x080518 */
65 #define CHKSUM_REG 0xe4080600 /* to 0x080610 - unused */
66 #define CURS_POS_REG 0xe4080638
67 #define CLR_PAL_REG 0xe4080800 /* to 0x080ff8 */
68 #define CURS_PAT_REG 0xe4081000 /* to 0x081ff8 */
69 #define MON_ID_REG 0xe4100000 /* unused */
70 #define RESET_REG 0xe4180000 /* Write only */
72 static struct fb_info fb_info;
74 static struct fb_fix_screeninfo fb_fix __initdata = {
75 .id = "G364 8plane",
76 .smem_start = 0x40000000, /* physical address */
77 .type = FB_TYPE_PACKED_PIXELS,
78 .visual = FB_VISUAL_PSEUDOCOLOR,
79 .ypanstep = 1,
80 .accel = FB_ACCEL_NONE,
83 static struct fb_var_screeninfo fb_var __initdata = {
84 .bits_per_pixel = 8,
85 .red = { 0, 8, 0 },
86 .green = { 0, 8, 0 },
87 .blue = { 0, 8, 0 },
88 .activate = FB_ACTIVATE_NOW,
89 .height = -1,
90 .width = -1,
91 .pixclock = 39722,
92 .left_margin = 40,
93 .right_margin = 24,
94 .upper_margin = 32,
95 .lower_margin = 11,
96 .hsync_len = 96,
97 .vsync_len = 2,
98 .vmode = FB_VMODE_NONINTERLACED,
102 * Interface used by the world
104 int g364fb_init(void);
106 static int g364fb_pan_display(struct fb_var_screeninfo *var,
107 struct fb_info *info);
108 static int g364fb_setcolreg(u_int regno, u_int red, u_int green,
109 u_int blue, u_int transp,
110 struct fb_info *info);
111 static int g364fb_cursor(struct fb_info *info, struct fb_cursor *cursor);
112 static int g364fb_blank(int blank, struct fb_info *info);
114 static struct fb_ops g364fb_ops = {
115 .owner = THIS_MODULE,
116 .fb_setcolreg = g364fb_setcolreg,
117 .fb_pan_display = g364fb_pan_display,
118 .fb_blank = g364fb_blank,
119 .fb_fillrect = cfb_fillrect,
120 .fb_copyarea = cfb_copyarea,
121 .fb_imageblit = cfb_imageblit,
122 .fb_cursor = g364fb_cursor,
125 int g364fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
128 switch (cursor->enable) {
129 case CM_ERASE:
130 *(unsigned int *) CTLA_REG |= CURS_TOGGLE;
131 break;
133 case CM_MOVE:
134 case CM_DRAW:
135 *(unsigned int *) CTLA_REG &= ~CURS_TOGGLE;
136 *(unsigned int *) CURS_POS_REG =
137 ((x * fontwidth(p)) << 12) | ((y * fontheight(p)) -
138 info->var.yoffset);
139 break;
141 return 0;
145 * Pan or Wrap the Display
147 * This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag
149 static int g364fb_pan_display(struct fb_var_screeninfo *var,
150 struct fb_info *info)
152 if (var->xoffset || var->yoffset + var->yres > var->yres_virtual)
153 return -EINVAL;
155 *(unsigned int *) TOP_REG = var->yoffset * var->xres;
156 return 0;
160 * Blank the display.
162 static int g364fb_blank(int blank, struct fb_info *info)
164 if (blank)
165 *(unsigned int *) CTLA_REG |= FORCE_BLANK;
166 else
167 *(unsigned int *) CTLA_REG &= ~FORCE_BLANK;
168 return 0;
172 * Set a single color register. Return != 0 for invalid regno.
174 static int g364fb_setcolreg(u_int regno, u_int red, u_int green,
175 u_int blue, u_int transp, struct fb_info *info)
177 volatile unsigned int *ptr = (volatile unsigned int *) CLR_PAL_REG;
179 if (regno > 255)
180 return 1;
182 red >>= 8;
183 green >>= 8;
184 blue >>= 8;
186 ptr[regno << 1] = (red << 16) | (green << 8) | blue;
188 return 0;
192 * Initialisation
194 int __init g364fb_init(void)
196 volatile unsigned int *pal_ptr =
197 (volatile unsigned int *) CLR_PAL_REG;
198 volatile unsigned int *curs_pal_ptr =
199 (volatile unsigned int *) CURS_PAL_REG;
200 int mem, i, j;
202 if (fb_get_options("g364fb", NULL))
203 return -ENODEV;
205 /* TBD: G364 detection */
207 /* get the resolution set by ARC console */
208 *(volatile unsigned int *) CTLA_REG &= ~ENABLE_VTG;
209 fb_var.xres =
210 (*((volatile unsigned int *) DISPLAY_REG) & 0x00ffffff) * 4;
211 fb_var.yres =
212 (*((volatile unsigned int *) VDISPLAY_REG) & 0x00ffffff) / 2;
213 *(volatile unsigned int *) CTLA_REG |= ENABLE_VTG;
215 /* setup cursor */
216 curs_pal_ptr[0] |= 0x00ffffff;
217 curs_pal_ptr[2] |= 0x00ffffff;
218 curs_pal_ptr[4] |= 0x00ffffff;
221 * first set the whole cursor to transparent
223 for (i = 0; i < 512; i++)
224 *(unsigned short *) (CURS_PAT_REG + i * 8) = 0;
227 * switch the last two lines to cursor palette 3
228 * we assume here, that FONTSIZE_X is 8
230 *(unsigned short *) (CURS_PAT_REG + 14 * 64) = 0xffff;
231 *(unsigned short *) (CURS_PAT_REG + 15 * 64) = 0xffff;
232 fb_var.xres_virtual = fbvar.xres;
233 fb_fix.line_length = (xres / 8) * fb_var.bits_per_pixel;
234 fb_fix.smem_start = 0x40000000; /* physical address */
235 /* get size of video memory; this is special for the JAZZ hardware */
236 mem = (r4030_read_reg32(JAZZ_R4030_CONFIG) >> 8) & 3;
237 fb_fix.smem_len = (1 << (mem * 2)) * 512 * 1024;
238 fb_var.yres_virtual = fb_fix.smem_len / fb_var.xres;
240 fb_info.fbops = &g364fb_ops;
241 fb_info.screen_base = (char *) G364_MEM_BASE; /* virtual kernel address */
242 fb_info.var = fb_var;
243 fb_info.fix = fb_fix;
244 fb_info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
246 fb_alloc_cmap(&fb_info.cmap, 255, 0);
248 if (register_framebuffer(&fb_info) < 0)
249 return -EINVAL;
250 return 0;
253 module_init(g364fb_init);
254 MODULE_LICENSE("GPL");