blob: 6ff5077a2e15ba2d5da0732dca85d259c22d23f3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/drivers/video/pm3fb.c -- 3DLabs Permedia3 frame buffer device
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07003 *
4 * Copyright (C) 2001 Romain Dolbeau <romain@dolbeau.org>.
5 *
6 * Ported to 2.6 kernel on 1 May 2007 by Krzysztof Helt <krzysztof.h1@wp.pl>
7 * based on pm2fb.c
8 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * Based on code written by:
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070010 * Sven Luther, <luther@dpt-info.u-strasbg.fr>
11 * Alan Hourihane, <alanh@fairlite.demon.co.uk>
12 * Russell King, <rmk@arm.linux.org.uk>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 * Based on linux/drivers/video/skeletonfb.c:
14 * Copyright (C) 1997 Geert Uytterhoeven
15 * Based on linux/driver/video/pm2fb.c:
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070016 * Copyright (C) 1998-1999 Ilario Nardinocchi (nardinoc@CS.UniBO.IT)
17 * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 *
19 * This file is subject to the terms and conditions of the GNU General Public
20 * License. See the file COPYING in the main directory of this archive for
21 * more details.
22 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 */
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/errno.h>
28#include <linux/string.h>
29#include <linux/mm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/fb.h>
33#include <linux/init.h>
34#include <linux/pci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <video/pm3fb.h>
37
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070038#if !defined(CONFIG_PCI)
39#error "Only generic PCI cards supported."
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#endif
41
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070042#undef PM3FB_MASTER_DEBUG
43#ifdef PM3FB_MASTER_DEBUG
Krzysztof Helt57bac0f2007-10-16 01:28:51 -070044#define DPRINTK(a, b...) \
Harvey Harrison5ae12172008-04-28 02:15:47 -070045 printk(KERN_DEBUG "pm3fb: %s: " a, __func__ , ## b)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070046#else
Krzysztof Helt57bac0f2007-10-16 01:28:51 -070047#define DPRINTK(a, b...)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070048#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Krzysztof Heltb0a318e2007-10-16 01:28:31 -070050#define PM3_PIXMAP_SIZE (2048 * 4)
51
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070052/*
53 * Driver data
54 */
Krzysztof Helt1d677a62007-10-16 01:28:54 -070055static int hwcursor = 1;
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -080056static char *mode_option;
57static bool noaccel;
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -080058static bool nomtrr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070060/*
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070061 * This structure defines the hardware state of the graphics card. Normally
62 * you place this in a header file in linux/include/video. This file usually
63 * also includes register information. That allows other driver subsystems
64 * and userland applications the ability to use the same header file to
65 * avoid duplicate work and easy porting of software.
66 */
67struct pm3_par {
68 unsigned char __iomem *v_regs;/* virtual address of p_regs */
69 u32 video; /* video flags before blanking */
Krzysztof Helt57bac0f2007-10-16 01:28:51 -070070 u32 base; /* screen base in 128 bits unit */
Krzysztof Helt2686ba82007-05-23 13:57:48 -070071 u32 palette[16];
Luis R. Rodriguez26e25062015-04-21 13:16:34 -070072 int wc_cookie;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073};
74
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070075/*
76 * Here we define the default structs fb_fix_screeninfo and fb_var_screeninfo
77 * if we don't use modedb. If we do use modedb see pm3fb_init how to use it
78 * to get a fb_var_screeninfo. Otherwise define a default var as well.
79 */
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -080080static struct fb_fix_screeninfo pm3fb_fix = {
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070081 .id = "Permedia3",
82 .type = FB_TYPE_PACKED_PIXELS,
83 .visual = FB_VISUAL_PSEUDOCOLOR,
84 .xpanstep = 1,
85 .ypanstep = 1,
86 .ywrapstep = 0,
Krzysztof Helta58d67c2007-07-17 04:05:46 -070087 .accel = FB_ACCEL_3DLABS_PERMEDIA3,
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070088};
89
90/*
91 * Utility functions
92 */
93
94static inline u32 PM3_READ_REG(struct pm3_par *par, s32 off)
Linus Torvalds1da177e2005-04-16 15:20:36 -070095{
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070096 return fb_readl(par->v_regs + off);
Linus Torvalds1da177e2005-04-16 15:20:36 -070097}
98
Krzysztof Heltf23a06f2007-05-10 22:23:25 -070099static inline void PM3_WRITE_REG(struct pm3_par *par, s32 off, u32 v)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700101 fb_writel(v, par->v_regs + off);
102}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700104static inline void PM3_WAIT(struct pm3_par *par, u32 n)
105{
Krzysztof Heltdeea62d2007-10-16 01:29:27 -0700106 while (PM3_READ_REG(par, PM3InFIFOSpace) < n)
107 cpu_relax();
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700108}
109
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700110static inline void PM3_WRITE_DAC_REG(struct pm3_par *par, unsigned r, u8 v)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111{
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700112 PM3_WAIT(par, 3);
113 PM3_WRITE_REG(par, PM3RD_IndexHigh, (r >> 8) & 0xff);
114 PM3_WRITE_REG(par, PM3RD_IndexLow, r & 0xff);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700115 wmb();
116 PM3_WRITE_REG(par, PM3RD_IndexedData, v);
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700117 wmb();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118}
119
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700120static inline void pm3fb_set_color(struct pm3_par *par, unsigned char regno,
121 unsigned char r, unsigned char g, unsigned char b)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122{
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700123 PM3_WAIT(par, 4);
124 PM3_WRITE_REG(par, PM3RD_PaletteWriteAddress, regno);
125 wmb();
126 PM3_WRITE_REG(par, PM3RD_PaletteData, r);
127 wmb();
128 PM3_WRITE_REG(par, PM3RD_PaletteData, g);
129 wmb();
130 PM3_WRITE_REG(par, PM3RD_PaletteData, b);
131 wmb();
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700132}
133
134static void pm3fb_clear_colormap(struct pm3_par *par,
135 unsigned char r, unsigned char g, unsigned char b)
136{
137 int i;
138
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700139 for (i = 0; i < 256 ; i++)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700140 pm3fb_set_color(par, i, r, g, b);
141
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142}
143
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700144/* Calculating various clock parameters */
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700145static void pm3fb_calculate_clock(unsigned long reqclock,
146 unsigned char *prescale,
147 unsigned char *feedback,
148 unsigned char *postscale)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149{
150 int f, pre, post;
151 unsigned long freq;
152 long freqerr = 1000;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700153 long currerr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
155 for (f = 1; f < 256; f++) {
156 for (pre = 1; pre < 256; pre++) {
157 for (post = 0; post < 5; post++) {
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700158 freq = ((2*PM3_REF_CLOCK * f) >> post) / pre;
159 currerr = (reqclock > freq)
160 ? reqclock - freq
161 : freq - reqclock;
162 if (currerr < freqerr) {
163 freqerr = currerr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 *feedback = f;
165 *prescale = pre;
166 *postscale = post;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 }
168 }
169 }
170 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171}
172
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700173static inline int pm3fb_depth(const struct fb_var_screeninfo *var)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174{
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700175 if (var->bits_per_pixel == 16)
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700176 return var->red.length + var->green.length
177 + var->blue.length;
178
179 return var->bits_per_pixel;
180}
181
182static inline int pm3fb_shift_bpp(unsigned bpp, int v)
183{
184 switch (bpp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 case 8:
186 return (v >> 4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 case 16:
188 return (v >> 3);
189 case 32:
190 return (v >> 2);
191 }
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700192 DPRINTK("Unsupported depth %u\n", bpp);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700193 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194}
195
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700196/* acceleration */
197static int pm3fb_sync(struct fb_info *info)
198{
199 struct pm3_par *par = info->par;
200
201 PM3_WAIT(par, 2);
202 PM3_WRITE_REG(par, PM3FilterMode, PM3FilterModeSync);
203 PM3_WRITE_REG(par, PM3Sync, 0);
204 mb();
205 do {
Krzysztof Heltdeea62d2007-10-16 01:29:27 -0700206 while ((PM3_READ_REG(par, PM3OutFIFOWords)) == 0)
207 cpu_relax();
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700208 } while ((PM3_READ_REG(par, PM3OutputFifo)) != PM3Sync_Tag);
209
210 return 0;
211}
212
213static void pm3fb_init_engine(struct fb_info *info)
214{
215 struct pm3_par *par = info->par;
216 const u32 width = (info->var.xres_virtual + 7) & ~7;
217
218 PM3_WAIT(par, 50);
219 PM3_WRITE_REG(par, PM3FilterMode, PM3FilterModeSync);
220 PM3_WRITE_REG(par, PM3StatisticMode, 0x0);
221 PM3_WRITE_REG(par, PM3DeltaMode, 0x0);
222 PM3_WRITE_REG(par, PM3RasterizerMode, 0x0);
223 PM3_WRITE_REG(par, PM3ScissorMode, 0x0);
224 PM3_WRITE_REG(par, PM3LineStippleMode, 0x0);
225 PM3_WRITE_REG(par, PM3AreaStippleMode, 0x0);
226 PM3_WRITE_REG(par, PM3GIDMode, 0x0);
227 PM3_WRITE_REG(par, PM3DepthMode, 0x0);
228 PM3_WRITE_REG(par, PM3StencilMode, 0x0);
229 PM3_WRITE_REG(par, PM3StencilData, 0x0);
230 PM3_WRITE_REG(par, PM3ColorDDAMode, 0x0);
231 PM3_WRITE_REG(par, PM3TextureCoordMode, 0x0);
232 PM3_WRITE_REG(par, PM3TextureIndexMode0, 0x0);
233 PM3_WRITE_REG(par, PM3TextureIndexMode1, 0x0);
234 PM3_WRITE_REG(par, PM3TextureReadMode, 0x0);
235 PM3_WRITE_REG(par, PM3LUTMode, 0x0);
236 PM3_WRITE_REG(par, PM3TextureFilterMode, 0x0);
237 PM3_WRITE_REG(par, PM3TextureCompositeMode, 0x0);
238 PM3_WRITE_REG(par, PM3TextureApplicationMode, 0x0);
239 PM3_WRITE_REG(par, PM3TextureCompositeColorMode1, 0x0);
240 PM3_WRITE_REG(par, PM3TextureCompositeAlphaMode1, 0x0);
241 PM3_WRITE_REG(par, PM3TextureCompositeColorMode0, 0x0);
242 PM3_WRITE_REG(par, PM3TextureCompositeAlphaMode0, 0x0);
243 PM3_WRITE_REG(par, PM3FogMode, 0x0);
244 PM3_WRITE_REG(par, PM3ChromaTestMode, 0x0);
245 PM3_WRITE_REG(par, PM3AlphaTestMode, 0x0);
246 PM3_WRITE_REG(par, PM3AntialiasMode, 0x0);
247 PM3_WRITE_REG(par, PM3YUVMode, 0x0);
248 PM3_WRITE_REG(par, PM3AlphaBlendColorMode, 0x0);
249 PM3_WRITE_REG(par, PM3AlphaBlendAlphaMode, 0x0);
250 PM3_WRITE_REG(par, PM3DitherMode, 0x0);
251 PM3_WRITE_REG(par, PM3LogicalOpMode, 0x0);
252 PM3_WRITE_REG(par, PM3RouterMode, 0x0);
253 PM3_WRITE_REG(par, PM3Window, 0x0);
254
255 PM3_WRITE_REG(par, PM3Config2D, 0x0);
256
257 PM3_WRITE_REG(par, PM3SpanColorMask, 0xffffffff);
258
259 PM3_WRITE_REG(par, PM3XBias, 0x0);
260 PM3_WRITE_REG(par, PM3YBias, 0x0);
261 PM3_WRITE_REG(par, PM3DeltaControl, 0x0);
262
263 PM3_WRITE_REG(par, PM3BitMaskPattern, 0xffffffff);
264
265 PM3_WRITE_REG(par, PM3FBDestReadEnables,
266 PM3FBDestReadEnables_E(0xff) |
267 PM3FBDestReadEnables_R(0xff) |
268 PM3FBDestReadEnables_ReferenceAlpha(0xff));
269 PM3_WRITE_REG(par, PM3FBDestReadBufferAddr0, 0x0);
270 PM3_WRITE_REG(par, PM3FBDestReadBufferOffset0, 0x0);
271 PM3_WRITE_REG(par, PM3FBDestReadBufferWidth0,
272 PM3FBDestReadBufferWidth_Width(width));
273
274 PM3_WRITE_REG(par, PM3FBDestReadMode,
275 PM3FBDestReadMode_ReadEnable |
276 PM3FBDestReadMode_Enable0);
277 PM3_WRITE_REG(par, PM3FBSourceReadBufferAddr, 0x0);
278 PM3_WRITE_REG(par, PM3FBSourceReadBufferOffset, 0x0);
279 PM3_WRITE_REG(par, PM3FBSourceReadBufferWidth,
280 PM3FBSourceReadBufferWidth_Width(width));
281 PM3_WRITE_REG(par, PM3FBSourceReadMode,
282 PM3FBSourceReadMode_Blocking |
283 PM3FBSourceReadMode_ReadEnable);
284
285 PM3_WAIT(par, 2);
286 {
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700287 /* invert bits in bitmask */
288 unsigned long rm = 1 | (3 << 7);
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700289 switch (info->var.bits_per_pixel) {
290 case 8:
291 PM3_WRITE_REG(par, PM3PixelSize,
292 PM3PixelSize_GLOBAL_8BIT);
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700293#ifdef __BIG_ENDIAN
294 rm |= 3 << 15;
295#endif
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700296 break;
297 case 16:
298 PM3_WRITE_REG(par, PM3PixelSize,
299 PM3PixelSize_GLOBAL_16BIT);
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700300#ifdef __BIG_ENDIAN
301 rm |= 2 << 15;
302#endif
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700303 break;
304 case 32:
305 PM3_WRITE_REG(par, PM3PixelSize,
306 PM3PixelSize_GLOBAL_32BIT);
307 break;
308 default:
309 DPRINTK(1, "Unsupported depth %d\n",
310 info->var.bits_per_pixel);
311 break;
312 }
313 PM3_WRITE_REG(par, PM3RasterizerMode, rm);
314 }
315
316 PM3_WAIT(par, 20);
317 PM3_WRITE_REG(par, PM3FBSoftwareWriteMask, 0xffffffff);
318 PM3_WRITE_REG(par, PM3FBHardwareWriteMask, 0xffffffff);
319 PM3_WRITE_REG(par, PM3FBWriteMode,
320 PM3FBWriteMode_WriteEnable |
321 PM3FBWriteMode_OpaqueSpan |
322 PM3FBWriteMode_Enable0);
323 PM3_WRITE_REG(par, PM3FBWriteBufferAddr0, 0x0);
324 PM3_WRITE_REG(par, PM3FBWriteBufferOffset0, 0x0);
325 PM3_WRITE_REG(par, PM3FBWriteBufferWidth0,
326 PM3FBWriteBufferWidth_Width(width));
327
328 PM3_WRITE_REG(par, PM3SizeOfFramebuffer, 0x0);
329 {
330 /* size in lines of FB */
331 unsigned long sofb = info->screen_size /
332 info->fix.line_length;
333 if (sofb > 4095)
334 PM3_WRITE_REG(par, PM3SizeOfFramebuffer, 4095);
335 else
336 PM3_WRITE_REG(par, PM3SizeOfFramebuffer, sofb);
337
338 switch (info->var.bits_per_pixel) {
339 case 8:
340 PM3_WRITE_REG(par, PM3DitherMode,
341 (1 << 10) | (2 << 3));
342 break;
343 case 16:
344 PM3_WRITE_REG(par, PM3DitherMode,
345 (1 << 10) | (1 << 3));
346 break;
347 case 32:
348 PM3_WRITE_REG(par, PM3DitherMode,
349 (1 << 10) | (0 << 3));
350 break;
351 default:
352 DPRINTK(1, "Unsupported depth %d\n",
353 info->current_par->depth);
354 break;
355 }
356 }
357
358 PM3_WRITE_REG(par, PM3dXDom, 0x0);
359 PM3_WRITE_REG(par, PM3dXSub, 0x0);
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700360 PM3_WRITE_REG(par, PM3dY, 1 << 16);
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700361 PM3_WRITE_REG(par, PM3StartXDom, 0x0);
362 PM3_WRITE_REG(par, PM3StartXSub, 0x0);
363 PM3_WRITE_REG(par, PM3StartY, 0x0);
364 PM3_WRITE_REG(par, PM3Count, 0x0);
365
366/* Disable LocalBuffer. better safe than sorry */
367 PM3_WRITE_REG(par, PM3LBDestReadMode, 0x0);
368 PM3_WRITE_REG(par, PM3LBDestReadEnables, 0x0);
369 PM3_WRITE_REG(par, PM3LBSourceReadMode, 0x0);
370 PM3_WRITE_REG(par, PM3LBWriteMode, 0x0);
371
372 pm3fb_sync(info);
373}
374
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700375static void pm3fb_fillrect(struct fb_info *info,
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700376 const struct fb_fillrect *region)
377{
378 struct pm3_par *par = info->par;
379 struct fb_fillrect modded;
380 int vxres, vyres;
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700381 int rop;
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700382 u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ?
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700383 ((u32 *)info->pseudo_palette)[region->color] : region->color;
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700384
385 if (info->state != FBINFO_STATE_RUNNING)
386 return;
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700387 if (info->flags & FBINFO_HWACCEL_DISABLED) {
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700388 cfb_fillrect(info, region);
389 return;
390 }
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700391 if (region->rop == ROP_COPY )
392 rop = PM3Config2D_ForegroundROP(0x3); /* GXcopy */
393 else
394 rop = PM3Config2D_ForegroundROP(0x6) | /* GXxor */
395 PM3Config2D_FBDestReadEnable;
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700396
397 vxres = info->var.xres_virtual;
398 vyres = info->var.yres_virtual;
399
400 memcpy(&modded, region, sizeof(struct fb_fillrect));
401
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700402 if (!modded.width || !modded.height ||
403 modded.dx >= vxres || modded.dy >= vyres)
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700404 return;
405
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700406 if (modded.dx + modded.width > vxres)
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700407 modded.width = vxres - modded.dx;
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700408 if (modded.dy + modded.height > vyres)
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700409 modded.height = vyres - modded.dy;
410
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700411 if (info->var.bits_per_pixel == 8)
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700412 color |= color << 8;
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700413 if (info->var.bits_per_pixel <= 16)
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700414 color |= color << 16;
415
416 PM3_WAIT(par, 4);
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700417 /* ROP Ox3 is GXcopy */
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700418 PM3_WRITE_REG(par, PM3Config2D,
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700419 PM3Config2D_UseConstantSource |
420 PM3Config2D_ForegroundROPEnable |
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700421 rop |
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700422 PM3Config2D_FBWriteEnable);
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700423
424 PM3_WRITE_REG(par, PM3ForegroundColor, color);
425
426 PM3_WRITE_REG(par, PM3RectanglePosition,
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700427 PM3RectanglePosition_XOffset(modded.dx) |
428 PM3RectanglePosition_YOffset(modded.dy));
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700429
430 PM3_WRITE_REG(par, PM3Render2D,
431 PM3Render2D_XPositive |
432 PM3Render2D_YPositive |
433 PM3Render2D_Operation_Normal |
434 PM3Render2D_SpanOperation |
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700435 PM3Render2D_Width(modded.width) |
436 PM3Render2D_Height(modded.height));
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700437}
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700438
439static void pm3fb_copyarea(struct fb_info *info,
440 const struct fb_copyarea *area)
441{
442 struct pm3_par *par = info->par;
443 struct fb_copyarea modded;
444 u32 vxres, vyres;
445 int x_align, o_x, o_y;
446
447 if (info->state != FBINFO_STATE_RUNNING)
448 return;
449 if (info->flags & FBINFO_HWACCEL_DISABLED) {
450 cfb_copyarea(info, area);
451 return;
452 }
453
454 memcpy(&modded, area, sizeof(struct fb_copyarea));
455
456 vxres = info->var.xres_virtual;
457 vyres = info->var.yres_virtual;
458
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700459 if (!modded.width || !modded.height ||
460 modded.sx >= vxres || modded.sy >= vyres ||
461 modded.dx >= vxres || modded.dy >= vyres)
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700462 return;
463
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700464 if (modded.sx + modded.width > vxres)
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700465 modded.width = vxres - modded.sx;
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700466 if (modded.dx + modded.width > vxres)
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700467 modded.width = vxres - modded.dx;
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700468 if (modded.sy + modded.height > vyres)
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700469 modded.height = vyres - modded.sy;
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700470 if (modded.dy + modded.height > vyres)
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700471 modded.height = vyres - modded.dy;
472
473 o_x = modded.sx - modded.dx; /*(sx > dx ) ? (sx - dx) : (dx - sx); */
474 o_y = modded.sy - modded.dy; /*(sy > dy ) ? (sy - dy) : (dy - sy); */
475
476 x_align = (modded.sx & 0x1f);
477
478 PM3_WAIT(par, 6);
479
480 PM3_WRITE_REG(par, PM3Config2D,
481 PM3Config2D_UserScissorEnable |
482 PM3Config2D_ForegroundROPEnable |
483 PM3Config2D_Blocking |
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700484 PM3Config2D_ForegroundROP(0x3) | /* Ox3 is GXcopy */
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700485 PM3Config2D_FBWriteEnable);
486
487 PM3_WRITE_REG(par, PM3ScissorMinXY,
488 ((modded.dy & 0x0fff) << 16) | (modded.dx & 0x0fff));
489 PM3_WRITE_REG(par, PM3ScissorMaxXY,
490 (((modded.dy + modded.height) & 0x0fff) << 16) |
491 ((modded.dx + modded.width) & 0x0fff));
492
493 PM3_WRITE_REG(par, PM3FBSourceReadBufferOffset,
494 PM3FBSourceReadBufferOffset_XOffset(o_x) |
495 PM3FBSourceReadBufferOffset_YOffset(o_y));
496
497 PM3_WRITE_REG(par, PM3RectanglePosition,
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700498 PM3RectanglePosition_XOffset(modded.dx - x_align) |
499 PM3RectanglePosition_YOffset(modded.dy));
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700500
501 PM3_WRITE_REG(par, PM3Render2D,
502 ((modded.sx > modded.dx) ? PM3Render2D_XPositive : 0) |
503 ((modded.sy > modded.dy) ? PM3Render2D_YPositive : 0) |
504 PM3Render2D_Operation_Normal |
505 PM3Render2D_SpanOperation |
506 PM3Render2D_FBSourceReadEnable |
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700507 PM3Render2D_Width(modded.width + x_align) |
508 PM3Render2D_Height(modded.height));
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700509}
510
511static void pm3fb_imageblit(struct fb_info *info, const struct fb_image *image)
512{
513 struct pm3_par *par = info->par;
514 u32 height = image->height;
515 u32 fgx, bgx;
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700516 const u32 *src = (const u32 *)image->data;
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700517
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700518 if (info->state != FBINFO_STATE_RUNNING)
519 return;
520 if (info->flags & FBINFO_HWACCEL_DISABLED) {
521 cfb_imageblit(info, image);
522 return;
523 }
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700524 switch (info->fix.visual) {
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700525 case FB_VISUAL_PSEUDOCOLOR:
526 fgx = image->fg_color;
527 bgx = image->bg_color;
528 break;
529 case FB_VISUAL_TRUECOLOR:
530 default:
531 fgx = par->palette[image->fg_color];
532 bgx = par->palette[image->bg_color];
533 break;
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700534 }
Hannes Eder76545322009-01-06 14:42:33 -0800535 if (image->depth != 1) {
536 cfb_imageblit(info, image);
537 return;
538 }
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700539
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700540 if (info->var.bits_per_pixel == 8) {
541 fgx |= fgx << 8;
542 bgx |= bgx << 8;
543 }
544 if (info->var.bits_per_pixel <= 16) {
545 fgx |= fgx << 16;
546 bgx |= bgx << 16;
547 }
548
Krzysztof Heltb0a318e2007-10-16 01:28:31 -0700549 PM3_WAIT(par, 7);
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700550
551 PM3_WRITE_REG(par, PM3ForegroundColor, fgx);
552 PM3_WRITE_REG(par, PM3BackgroundColor, bgx);
553
554 /* ROP Ox3 is GXcopy */
555 PM3_WRITE_REG(par, PM3Config2D,
Krzysztof Heltb0a318e2007-10-16 01:28:31 -0700556 PM3Config2D_UserScissorEnable |
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700557 PM3Config2D_UseConstantSource |
558 PM3Config2D_ForegroundROPEnable |
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700559 PM3Config2D_ForegroundROP(0x3) |
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700560 PM3Config2D_OpaqueSpan |
561 PM3Config2D_FBWriteEnable);
Krzysztof Heltb0a318e2007-10-16 01:28:31 -0700562 PM3_WRITE_REG(par, PM3ScissorMinXY,
563 ((image->dy & 0x0fff) << 16) | (image->dx & 0x0fff));
564 PM3_WRITE_REG(par, PM3ScissorMaxXY,
565 (((image->dy + image->height) & 0x0fff) << 16) |
566 ((image->dx + image->width) & 0x0fff));
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700567 PM3_WRITE_REG(par, PM3RectanglePosition,
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700568 PM3RectanglePosition_XOffset(image->dx) |
569 PM3RectanglePosition_YOffset(image->dy));
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700570 PM3_WRITE_REG(par, PM3Render2D,
571 PM3Render2D_XPositive |
572 PM3Render2D_YPositive |
573 PM3Render2D_Operation_SyncOnBitMask |
574 PM3Render2D_SpanOperation |
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700575 PM3Render2D_Width(image->width) |
576 PM3Render2D_Height(image->height));
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700577
578
579 while (height--) {
Krzysztof Heltc79ba282007-10-16 01:28:32 -0700580 int width = ((image->width + 7) >> 3)
581 + info->pixmap.scan_align - 1;
Krzysztof Heltb0a318e2007-10-16 01:28:31 -0700582 width >>= 2;
Krzysztof Helte7f76df2007-10-16 01:28:29 -0700583
584 while (width >= PM3_FIFO_SIZE) {
585 int i = PM3_FIFO_SIZE - 1;
586
587 PM3_WAIT(par, PM3_FIFO_SIZE);
588 while (i--) {
589 PM3_WRITE_REG(par, PM3BitMaskPattern, *src);
590 src++;
591 }
592 width -= PM3_FIFO_SIZE - 1;
593 }
594
595 PM3_WAIT(par, width + 1);
596 while (width--) {
597 PM3_WRITE_REG(par, PM3BitMaskPattern, *src);
598 src++;
599 }
600 }
601}
Krzysztof Helta58d67c2007-07-17 04:05:46 -0700602/* end of acceleration functions */
603
Krzysztof Helt1d677a62007-10-16 01:28:54 -0700604/*
605 * Hardware Cursor support.
606 */
607static const u8 cursor_bits_lookup[16] = {
608 0x00, 0x40, 0x10, 0x50, 0x04, 0x44, 0x14, 0x54,
609 0x01, 0x41, 0x11, 0x51, 0x05, 0x45, 0x15, 0x55
610};
611
612static int pm3fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
613{
614 struct pm3_par *par = info->par;
615 u8 mode;
616
617 if (!hwcursor)
618 return -EINVAL; /* just to force soft_cursor() call */
619
620 /* Too large of a cursor or wrong bpp :-( */
621 if (cursor->image.width > 64 ||
622 cursor->image.height > 64 ||
623 cursor->image.depth > 1)
624 return -EINVAL;
625
626 mode = PM3RD_CursorMode_TYPE_X;
627 if (cursor->enable)
628 mode |= PM3RD_CursorMode_CURSOR_ENABLE;
629
630 PM3_WRITE_DAC_REG(par, PM3RD_CursorMode, mode);
631
632 /*
633 * If the cursor is not be changed this means either we want the
634 * current cursor state (if enable is set) or we want to query what
635 * we can do with the cursor (if enable is not set)
636 */
637 if (!cursor->set)
638 return 0;
639
640 if (cursor->set & FB_CUR_SETPOS) {
641 int x = cursor->image.dx - info->var.xoffset;
642 int y = cursor->image.dy - info->var.yoffset;
643
644 PM3_WRITE_DAC_REG(par, PM3RD_CursorXLow, x & 0xff);
645 PM3_WRITE_DAC_REG(par, PM3RD_CursorXHigh, (x >> 8) & 0xf);
646 PM3_WRITE_DAC_REG(par, PM3RD_CursorYLow, y & 0xff);
647 PM3_WRITE_DAC_REG(par, PM3RD_CursorYHigh, (y >> 8) & 0xf);
648 }
649
650 if (cursor->set & FB_CUR_SETHOT) {
651 PM3_WRITE_DAC_REG(par, PM3RD_CursorHotSpotX,
652 cursor->hot.x & 0x3f);
653 PM3_WRITE_DAC_REG(par, PM3RD_CursorHotSpotY,
654 cursor->hot.y & 0x3f);
655 }
656
657 if (cursor->set & FB_CUR_SETCMAP) {
658 u32 fg_idx = cursor->image.fg_color;
659 u32 bg_idx = cursor->image.bg_color;
660 struct fb_cmap cmap = info->cmap;
661
662 /* the X11 driver says one should use these color registers */
663 PM3_WRITE_DAC_REG(par, PM3RD_CursorPalette(39),
664 cmap.red[fg_idx] >> 8 );
665 PM3_WRITE_DAC_REG(par, PM3RD_CursorPalette(40),
666 cmap.green[fg_idx] >> 8 );
667 PM3_WRITE_DAC_REG(par, PM3RD_CursorPalette(41),
668 cmap.blue[fg_idx] >> 8 );
669
670 PM3_WRITE_DAC_REG(par, PM3RD_CursorPalette(42),
671 cmap.red[bg_idx] >> 8 );
672 PM3_WRITE_DAC_REG(par, PM3RD_CursorPalette(43),
673 cmap.green[bg_idx] >> 8 );
674 PM3_WRITE_DAC_REG(par, PM3RD_CursorPalette(44),
675 cmap.blue[bg_idx] >> 8 );
676 }
677
678 if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) {
679 u8 *bitmap = (u8 *)cursor->image.data;
680 u8 *mask = (u8 *)cursor->mask;
681 int i;
682 int pos = PM3RD_CursorPattern(0);
683
684 for (i = 0; i < cursor->image.height; i++) {
685 int j = (cursor->image.width + 7) >> 3;
686 int k = 8 - j;
687
688 for (; j > 0; j--) {
689 u8 data = *bitmap ^ *mask;
690
691 if (cursor->rop == ROP_COPY)
692 data = *mask & *bitmap;
693 /* Upper 4 bits of bitmap data */
694 PM3_WRITE_DAC_REG(par, pos++,
695 cursor_bits_lookup[data >> 4] |
696 (cursor_bits_lookup[*mask >> 4] << 1));
697 /* Lower 4 bits of bitmap */
698 PM3_WRITE_DAC_REG(par, pos++,
699 cursor_bits_lookup[data & 0xf] |
700 (cursor_bits_lookup[*mask & 0xf] << 1));
701 bitmap++;
702 mask++;
703 }
704 for (; k > 0; k--) {
705 PM3_WRITE_DAC_REG(par, pos++, 0);
706 PM3_WRITE_DAC_REG(par, pos++, 0);
707 }
708 }
709 while (pos < PM3RD_CursorPattern(1024))
710 PM3_WRITE_DAC_REG(par, pos++, 0);
711 }
712 return 0;
713}
714
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715/* write the mode to registers */
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700716static void pm3fb_write_mode(struct fb_info *info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717{
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700718 struct pm3_par *par = info->par;
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700719 char tempsync = 0x00;
720 char tempmisc = 0x00;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700721 const u32 hsstart = info->var.right_margin;
722 const u32 hsend = hsstart + info->var.hsync_len;
723 const u32 hbend = hsend + info->var.left_margin;
724 const u32 xres = (info->var.xres + 31) & ~31;
725 const u32 htotal = xres + hbend;
726 const u32 vsstart = info->var.lower_margin;
727 const u32 vsend = vsstart + info->var.vsync_len;
728 const u32 vbend = vsend + info->var.upper_margin;
729 const u32 vtotal = info->var.yres + vbend;
730 const u32 width = (info->var.xres_virtual + 7) & ~7;
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700731 const unsigned bpp = info->var.bits_per_pixel;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700733 PM3_WAIT(par, 20);
734 PM3_WRITE_REG(par, PM3MemBypassWriteMask, 0xffffffff);
735 PM3_WRITE_REG(par, PM3Aperture0, 0x00000000);
736 PM3_WRITE_REG(par, PM3Aperture1, 0x00000000);
737 PM3_WRITE_REG(par, PM3FIFODis, 0x00000007);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700739 PM3_WRITE_REG(par, PM3HTotal,
740 pm3fb_shift_bpp(bpp, htotal - 1));
741 PM3_WRITE_REG(par, PM3HsEnd,
742 pm3fb_shift_bpp(bpp, hsend));
743 PM3_WRITE_REG(par, PM3HsStart,
744 pm3fb_shift_bpp(bpp, hsstart));
745 PM3_WRITE_REG(par, PM3HbEnd,
746 pm3fb_shift_bpp(bpp, hbend));
747 PM3_WRITE_REG(par, PM3HgEnd,
748 pm3fb_shift_bpp(bpp, hbend));
749 PM3_WRITE_REG(par, PM3ScreenStride,
750 pm3fb_shift_bpp(bpp, width));
751 PM3_WRITE_REG(par, PM3VTotal, vtotal - 1);
752 PM3_WRITE_REG(par, PM3VsEnd, vsend - 1);
753 PM3_WRITE_REG(par, PM3VsStart, vsstart - 1);
754 PM3_WRITE_REG(par, PM3VbEnd, vbend);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700756 switch (bpp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 case 8:
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700758 PM3_WRITE_REG(par, PM3ByAperture1Mode,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 PM3ByApertureMode_PIXELSIZE_8BIT);
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700760 PM3_WRITE_REG(par, PM3ByAperture2Mode,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 PM3ByApertureMode_PIXELSIZE_8BIT);
762 break;
763
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 case 16:
765#ifndef __BIG_ENDIAN
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700766 PM3_WRITE_REG(par, PM3ByAperture1Mode,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 PM3ByApertureMode_PIXELSIZE_16BIT);
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700768 PM3_WRITE_REG(par, PM3ByAperture2Mode,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 PM3ByApertureMode_PIXELSIZE_16BIT);
770#else
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700771 PM3_WRITE_REG(par, PM3ByAperture1Mode,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 PM3ByApertureMode_PIXELSIZE_16BIT |
773 PM3ByApertureMode_BYTESWAP_BADC);
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700774 PM3_WRITE_REG(par, PM3ByAperture2Mode,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 PM3ByApertureMode_PIXELSIZE_16BIT |
776 PM3ByApertureMode_BYTESWAP_BADC);
777#endif /* ! __BIG_ENDIAN */
778 break;
779
780 case 32:
781#ifndef __BIG_ENDIAN
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700782 PM3_WRITE_REG(par, PM3ByAperture1Mode,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 PM3ByApertureMode_PIXELSIZE_32BIT);
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700784 PM3_WRITE_REG(par, PM3ByAperture2Mode,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 PM3ByApertureMode_PIXELSIZE_32BIT);
786#else
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700787 PM3_WRITE_REG(par, PM3ByAperture1Mode,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 PM3ByApertureMode_PIXELSIZE_32BIT |
789 PM3ByApertureMode_BYTESWAP_DCBA);
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700790 PM3_WRITE_REG(par, PM3ByAperture2Mode,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 PM3ByApertureMode_PIXELSIZE_32BIT |
792 PM3ByApertureMode_BYTESWAP_DCBA);
793#endif /* ! __BIG_ENDIAN */
794 break;
795
796 default:
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700797 DPRINTK("Unsupported depth %d\n", bpp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 break;
799 }
800
801 /*
802 * Oxygen VX1 - it appears that setting PM3VideoControl and
803 * then PM3RD_SyncControl to the same SYNC settings undoes
804 * any net change - they seem to xor together. Only set the
805 * sync options in PM3RD_SyncControl. --rmk
806 */
807 {
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700808 unsigned int video = par->video;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809
810 video &= ~(PM3VideoControl_HSYNC_MASK |
811 PM3VideoControl_VSYNC_MASK);
812 video |= PM3VideoControl_HSYNC_ACTIVE_HIGH |
813 PM3VideoControl_VSYNC_ACTIVE_HIGH;
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700814 PM3_WRITE_REG(par, PM3VideoControl, video);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 }
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700816 PM3_WRITE_REG(par, PM3VClkCtl,
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700817 (PM3_READ_REG(par, PM3VClkCtl) & 0xFFFFFFFC));
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700818 PM3_WRITE_REG(par, PM3ScreenBase, par->base);
819 PM3_WRITE_REG(par, PM3ChipConfig,
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700820 (PM3_READ_REG(par, PM3ChipConfig) & 0xFFFFFFFD));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700822 wmb();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 {
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700824 unsigned char uninitialized_var(m); /* ClkPreScale */
825 unsigned char uninitialized_var(n); /* ClkFeedBackScale */
826 unsigned char uninitialized_var(p); /* ClkPostScale */
827 unsigned long pixclock = PICOS2KHZ(info->var.pixclock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700829 (void)pm3fb_calculate_clock(pixclock, &m, &n, &p);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700831 DPRINTK("Pixclock: %ld, Pre: %d, Feedback: %d, Post: %d\n",
832 pixclock, (int) m, (int) n, (int) p);
833
834 PM3_WRITE_DAC_REG(par, PM3RD_DClk0PreScale, m);
835 PM3_WRITE_DAC_REG(par, PM3RD_DClk0FeedbackScale, n);
836 PM3_WRITE_DAC_REG(par, PM3RD_DClk0PostScale, p);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 }
838 /*
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700839 PM3_WRITE_DAC_REG(par, PM3RD_IndexControl, 0x00);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 */
841 /*
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700842 PM3_SLOW_WRITE_REG(par, PM3RD_IndexControl, 0x00);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 */
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700844 if ((par->video & PM3VideoControl_HSYNC_MASK) ==
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 PM3VideoControl_HSYNC_ACTIVE_HIGH)
846 tempsync |= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700847 if ((par->video & PM3VideoControl_VSYNC_MASK) ==
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 PM3VideoControl_VSYNC_ACTIVE_HIGH)
849 tempsync |= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700851 PM3_WRITE_DAC_REG(par, PM3RD_SyncControl, tempsync);
852 DPRINTK("PM3RD_SyncControl: %d\n", tempsync);
853
854 PM3_WRITE_DAC_REG(par, PM3RD_DACControl, 0x00);
855
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700856 switch (pm3fb_depth(&info->var)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 case 8:
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700858 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 PM3RD_PixelSize_8_BIT_PIXELS);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700860 PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861 PM3RD_ColorFormat_CI8_COLOR |
862 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW);
863 tempmisc |= PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
864 break;
865 case 12:
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700866 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 PM3RD_PixelSize_16_BIT_PIXELS);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700868 PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 PM3RD_ColorFormat_4444_COLOR |
870 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
871 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
872 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
873 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700874 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 case 15:
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700876 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 PM3RD_PixelSize_16_BIT_PIXELS);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700878 PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879 PM3RD_ColorFormat_5551_FRONT_COLOR |
880 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
881 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
882 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
883 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700884 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 case 16:
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700886 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 PM3RD_PixelSize_16_BIT_PIXELS);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700888 PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 PM3RD_ColorFormat_565_FRONT_COLOR |
890 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
891 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
892 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
893 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
894 break;
895 case 32:
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700896 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 PM3RD_PixelSize_32_BIT_PIXELS);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700898 PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 PM3RD_ColorFormat_8888_COLOR |
900 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW);
901 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
902 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
903 break;
904 }
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700905 PM3_WRITE_DAC_REG(par, PM3RD_MiscControl, tempmisc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906}
907
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700908/*
909 * hardware independent functions
910 */
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700911static int pm3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912{
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700913 u32 lpitch;
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700914 unsigned bpp = var->red.length + var->green.length
915 + var->blue.length + var->transp.length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700917 if (bpp != var->bits_per_pixel) {
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700918 /* set predefined mode for bits_per_pixel settings */
919
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700920 switch (var->bits_per_pixel) {
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700921 case 8:
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700922 var->red.length = 8;
923 var->green.length = 8;
924 var->blue.length = 8;
925 var->red.offset = 0;
926 var->green.offset = 0;
927 var->blue.offset = 0;
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700928 var->transp.offset = 0;
929 var->transp.length = 0;
930 break;
931 case 16:
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700932 var->red.length = 5;
933 var->blue.length = 5;
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700934 var->green.length = 6;
935 var->transp.length = 0;
936 break;
937 case 32:
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700938 var->red.length = 8;
939 var->green.length = 8;
940 var->blue.length = 8;
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700941 var->transp.length = 8;
942 break;
943 default:
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700944 DPRINTK("depth not supported: %u\n",
945 var->bits_per_pixel);
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700946 return -EINVAL;
947 }
948 }
949 /* it is assumed BGRA order */
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700950 if (var->bits_per_pixel > 8 ) {
Krzysztof Helt2686ba82007-05-23 13:57:48 -0700951 var->blue.offset = 0;
952 var->green.offset = var->blue.length;
953 var->red.offset = var->green.offset + var->green.length;
954 var->transp.offset = var->red.offset + var->red.length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 }
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700956 var->height = -1;
957 var->width = -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700959 if (var->xres != var->xres_virtual) {
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700960 DPRINTK("virtual x resolution != "
961 "physical x resolution not supported\n");
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700962 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700965 if (var->yres > var->yres_virtual) {
Krzysztof Helt57bac0f2007-10-16 01:28:51 -0700966 DPRINTK("virtual y resolution < "
967 "physical y resolution not possible\n");
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700968 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 }
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700970
971 if (var->xoffset) {
972 DPRINTK("xoffset not supported\n");
973 return -EINVAL;
974 }
975
976 if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
977 DPRINTK("interlace not supported\n");
978 return -EINVAL;
979 }
980
981 var->xres = (var->xres + 31) & ~31; /* could sometimes be 8 */
Krzysztof Helt0ddf7842007-10-16 01:28:32 -0700982 lpitch = var->xres * ((var->bits_per_pixel + 7) >> 3);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -0700983
984 if (var->xres < 200 || var->xres > 2048) {
985 DPRINTK("width not supported: %u\n", var->xres);
986 return -EINVAL;
987 }
988
989 if (var->yres < 200 || var->yres > 4095) {
990 DPRINTK("height not supported: %u\n", var->yres);
991 return -EINVAL;
992 }
993
994 if (lpitch * var->yres_virtual > info->fix.smem_len) {
995 DPRINTK("no memory for screen (%ux%ux%u)\n",
996 var->xres, var->yres_virtual, var->bits_per_pixel);
997 return -EINVAL;
998 }
999
1000 if (PICOS2KHZ(var->pixclock) > PM3_MAX_PIXCLOCK) {
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001001 DPRINTK("pixclock too high (%ldKHz)\n",
1002 PICOS2KHZ(var->pixclock));
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001003 return -EINVAL;
1004 }
1005
1006 var->accel_flags = 0; /* Can't mmap if this is on */
1007
1008 DPRINTK("Checking graphics mode at %dx%d depth %d\n",
1009 var->xres, var->yres, var->bits_per_pixel);
1010 return 0;
1011}
1012
1013static int pm3fb_set_par(struct fb_info *info)
1014{
1015 struct pm3_par *par = info->par;
1016 const u32 xres = (info->var.xres + 31) & ~31;
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001017 const unsigned bpp = info->var.bits_per_pixel;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001018
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001019 par->base = pm3fb_shift_bpp(bpp, (info->var.yoffset * xres)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001020 + info->var.xoffset);
1021 par->video = 0;
1022
1023 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
1024 par->video |= PM3VideoControl_HSYNC_ACTIVE_HIGH;
1025 else
1026 par->video |= PM3VideoControl_HSYNC_ACTIVE_LOW;
1027
1028 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
1029 par->video |= PM3VideoControl_VSYNC_ACTIVE_HIGH;
1030 else
1031 par->video |= PM3VideoControl_VSYNC_ACTIVE_LOW;
1032
1033 if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
1034 par->video |= PM3VideoControl_LINE_DOUBLE_ON;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001035
Krzysztof Helt0bd327e2007-06-01 00:47:09 -07001036 if ((info->var.activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001037 par->video |= PM3VideoControl_ENABLE;
Krzysztof Helt0ddf7842007-10-16 01:28:32 -07001038 else
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001039 DPRINTK("PM3Video disabled\n");
Krzysztof Helt0ddf7842007-10-16 01:28:32 -07001040
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001041 switch (bpp) {
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001042 case 8:
1043 par->video |= PM3VideoControl_PIXELSIZE_8BIT;
1044 break;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001045 case 16:
1046 par->video |= PM3VideoControl_PIXELSIZE_16BIT;
1047 break;
1048 case 32:
1049 par->video |= PM3VideoControl_PIXELSIZE_32BIT;
1050 break;
1051 default:
1052 DPRINTK("Unsupported depth\n");
1053 break;
1054 }
1055
1056 info->fix.visual =
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001057 (bpp == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
Krzysztof Helt0ddf7842007-10-16 01:28:32 -07001058 info->fix.line_length = ((info->var.xres_virtual + 7) >> 3) * bpp;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001059
1060/* pm3fb_clear_memory(info, 0);*/
1061 pm3fb_clear_colormap(par, 0, 0, 0);
Krzysztof Heltf259ebb2007-10-16 01:28:31 -07001062 PM3_WRITE_DAC_REG(par, PM3RD_CursorMode, 0);
Krzysztof Helta58d67c2007-07-17 04:05:46 -07001063 pm3fb_init_engine(info);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001064 pm3fb_write_mode(info);
1065 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066}
1067
1068static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green,
1069 unsigned blue, unsigned transp,
1070 struct fb_info *info)
1071{
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001072 struct pm3_par *par = info->par;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001074 if (regno >= 256) /* no. of hw registers */
1075 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001076
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001077 /* grayscale works only partially under directcolor */
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001078 /* grayscale = 0.30*R + 0.59*G + 0.11*B */
1079 if (info->var.grayscale)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001080 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001081
1082 /* Directcolor:
1083 * var->{color}.offset contains start of bitfield
1084 * var->{color}.length contains length of bitfield
1085 * {hardwarespecific} contains width of DAC
1086 * pseudo_palette[X] is programmed to (X << red.offset) |
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001087 * (X << green.offset) |
1088 * (X << blue.offset)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001089 * RAMDAC[X] is programmed to (red, green, blue)
1090 * color depth = SUM(var->{color}.length)
1091 *
1092 * Pseudocolor:
1093 * var->{color}.offset is 0
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001094 * var->{color}.length contains width of DAC or the number
1095 * of unique colors available (color depth)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001096 * pseudo_palette is not used
1097 * RAMDAC[X] is programmed to (red, green, blue)
1098 * color depth = var->{color}.length
1099 */
1100
1101 /*
1102 * This is the point where the color is converted to something that
1103 * is acceptable by the hardware.
1104 */
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001105#define CNVT_TOHW(val, width) ((((val) << (width)) + 0x7FFF - (val)) >> 16)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001106 red = CNVT_TOHW(red, info->var.red.length);
1107 green = CNVT_TOHW(green, info->var.green.length);
1108 blue = CNVT_TOHW(blue, info->var.blue.length);
1109 transp = CNVT_TOHW(transp, info->var.transp.length);
1110#undef CNVT_TOHW
1111
1112 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
1113 info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
1114 u32 v;
1115
1116 if (regno >= 16)
1117 return -EINVAL;
1118
1119 v = (red << info->var.red.offset) |
1120 (green << info->var.green.offset) |
1121 (blue << info->var.blue.offset) |
1122 (transp << info->var.transp.offset);
1123
1124 switch (info->var.bits_per_pixel) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 case 8:
1126 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 case 16:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 case 32:
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001129 ((u32 *)(info->pseudo_palette))[regno] = v;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130 break;
1131 }
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001132 return 0;
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001133 } else if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001134 pm3fb_set_color(par, regno, red, green, blue);
1135
1136 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137}
1138
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001139static int pm3fb_pan_display(struct fb_var_screeninfo *var,
1140 struct fb_info *info)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141{
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001142 struct pm3_par *par = info->par;
Laurent Pinchart1fdb5182011-06-14 09:24:56 +00001143 const u32 xres = (info->var.xres + 31) & ~31;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144
Laurent Pinchart1fdb5182011-06-14 09:24:56 +00001145 par->base = pm3fb_shift_bpp(info->var.bits_per_pixel,
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001146 (var->yoffset * xres)
1147 + var->xoffset);
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001148 PM3_WAIT(par, 1);
1149 PM3_WRITE_REG(par, PM3ScreenBase, par->base);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001150 return 0;
1151}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001153static int pm3fb_blank(int blank_mode, struct fb_info *info)
1154{
1155 struct pm3_par *par = info->par;
1156 u32 video = par->video;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157
1158 /*
1159 * Oxygen VX1 - it appears that setting PM3VideoControl and
1160 * then PM3RD_SyncControl to the same SYNC settings undoes
1161 * any net change - they seem to xor together. Only set the
1162 * sync options in PM3RD_SyncControl. --rmk
1163 */
1164 video &= ~(PM3VideoControl_HSYNC_MASK |
1165 PM3VideoControl_VSYNC_MASK);
1166 video |= PM3VideoControl_HSYNC_ACTIVE_HIGH |
1167 PM3VideoControl_VSYNC_ACTIVE_HIGH;
1168
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001169 switch (blank_mode) {
1170 case FB_BLANK_UNBLANK:
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001171 video |= PM3VideoControl_ENABLE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 break;
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001173 case FB_BLANK_NORMAL:
Krzysztof Helt0ddf7842007-10-16 01:28:32 -07001174 video &= ~PM3VideoControl_ENABLE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 break;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001176 case FB_BLANK_HSYNC_SUSPEND:
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001177 video &= ~(PM3VideoControl_HSYNC_MASK |
1178 PM3VideoControl_BLANK_ACTIVE_LOW);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 break;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001180 case FB_BLANK_VSYNC_SUSPEND:
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001181 video &= ~(PM3VideoControl_VSYNC_MASK |
1182 PM3VideoControl_BLANK_ACTIVE_LOW);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 break;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001184 case FB_BLANK_POWERDOWN:
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001185 video &= ~(PM3VideoControl_HSYNC_MASK |
1186 PM3VideoControl_VSYNC_MASK |
1187 PM3VideoControl_BLANK_ACTIVE_LOW);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189 default:
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001190 DPRINTK("Unsupported blanking %d\n", blank_mode);
1191 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 }
1193
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001194 PM3_WAIT(par, 1);
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001195 PM3_WRITE_REG(par, PM3VideoControl, video);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 return 0;
1197}
1198
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001199 /*
1200 * Frame buffer operations
1201 */
1202
1203static struct fb_ops pm3fb_ops = {
1204 .owner = THIS_MODULE,
1205 .fb_check_var = pm3fb_check_var,
1206 .fb_set_par = pm3fb_set_par,
1207 .fb_setcolreg = pm3fb_setcolreg,
1208 .fb_pan_display = pm3fb_pan_display,
Krzysztof Helta58d67c2007-07-17 04:05:46 -07001209 .fb_fillrect = pm3fb_fillrect,
Krzysztof Helte7f76df2007-10-16 01:28:29 -07001210 .fb_copyarea = pm3fb_copyarea,
1211 .fb_imageblit = pm3fb_imageblit,
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001212 .fb_blank = pm3fb_blank,
Krzysztof Helta58d67c2007-07-17 04:05:46 -07001213 .fb_sync = pm3fb_sync,
Krzysztof Helt1d677a62007-10-16 01:28:54 -07001214 .fb_cursor = pm3fb_cursor,
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001215};
1216
1217/* ------------------------------------------------------------------------- */
1218
1219 /*
1220 * Initialization
1221 */
1222
1223/* mmio register are already mapped when this function is called */
1224/* the pm3fb_fix.smem_start is also set */
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -08001225static unsigned long pm3fb_size_memory(struct pm3_par *par)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226{
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001227 unsigned long memsize = 0;
1228 unsigned long tempBypass, i, temp1, temp2;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001229 unsigned char __iomem *screen_mem;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001231 pm3fb_fix.smem_len = 64 * 1024l * 1024; /* request full aperture size */
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001232 /* Linear frame buffer - request region and map it. */
1233 if (!request_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len,
1234 "pm3fb smem")) {
1235 printk(KERN_WARNING "pm3fb: Can't reserve smem.\n");
1236 return 0;
1237 }
1238 screen_mem =
1239 ioremap_nocache(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
1240 if (!screen_mem) {
1241 printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n");
1242 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
1243 return 0;
1244 }
1245
1246 /* TODO: card-specific stuff, *before* accessing *any* FB memory */
1247 /* For Appian Jeronimo 2000 board second head */
1248
1249 tempBypass = PM3_READ_REG(par, PM3MemBypassWriteMask);
1250
1251 DPRINTK("PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass);
1252
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001253 PM3_WAIT(par, 1);
1254 PM3_WRITE_REG(par, PM3MemBypassWriteMask, 0xFFFFFFFF);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001255
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001256 /* pm3 split up memory, replicates, and do a lot of
1257 * nasty stuff IMHO ;-)
1258 */
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001259 for (i = 0; i < 32; i++) {
1260 fb_writel(i * 0x00345678,
1261 (screen_mem + (i * 1048576)));
1262 mb();
1263 temp1 = fb_readl((screen_mem + (i * 1048576)));
1264
1265 /* Let's check for wrapover, write will fail at 16MB boundary */
1266 if (temp1 == (i * 0x00345678))
1267 memsize = i;
1268 else
1269 break;
1270 }
1271
1272 DPRINTK("First detect pass already got %ld MB\n", memsize + 1);
1273
1274 if (memsize + 1 == i) {
1275 for (i = 0; i < 32; i++) {
1276 /* Clear first 32MB ; 0 is 0, no need to byteswap */
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001277 writel(0x0000000, (screen_mem + (i * 1048576)));
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001278 }
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001279 wmb();
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001280
1281 for (i = 32; i < 64; i++) {
1282 fb_writel(i * 0x00345678,
1283 (screen_mem + (i * 1048576)));
1284 mb();
1285 temp1 =
1286 fb_readl((screen_mem + (i * 1048576)));
1287 temp2 =
1288 fb_readl((screen_mem + ((i - 32) * 1048576)));
1289 /* different value, different RAM... */
1290 if ((temp1 == (i * 0x00345678)) && (temp2 == 0))
1291 memsize = i;
1292 else
1293 break;
1294 }
1295 }
1296 DPRINTK("Second detect pass got %ld MB\n", memsize + 1);
1297
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001298 PM3_WAIT(par, 1);
1299 PM3_WRITE_REG(par, PM3MemBypassWriteMask, tempBypass);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001300
1301 iounmap(screen_mem);
1302 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
1303 memsize = 1048576 * (memsize + 1);
1304
1305 DPRINTK("Returning 0x%08lx bytes\n", memsize);
1306
1307 return memsize;
1308}
1309
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -08001310static int pm3fb_probe(struct pci_dev *dev, const struct pci_device_id *ent)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001311{
1312 struct fb_info *info;
1313 struct pm3_par *par;
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001314 struct device *device = &dev->dev; /* for pci drivers */
1315 int err;
1316 int retval = -ENXIO;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001317
1318 err = pci_enable_device(dev);
1319 if (err) {
1320 printk(KERN_WARNING "pm3fb: Can't enable PCI dev: %d\n", err);
1321 return err;
1322 }
1323 /*
1324 * Dynamically allocate info and par
1325 */
1326 info = framebuffer_alloc(sizeof(struct pm3_par), device);
1327
1328 if (!info)
1329 return -ENOMEM;
1330 par = info->par;
1331
1332 /*
1333 * Here we set the screen_base to the virtual memory address
1334 * for the framebuffer.
1335 */
1336 pm3fb_fix.mmio_start = pci_resource_start(dev, 0);
1337 pm3fb_fix.mmio_len = PM3_REGS_SIZE;
Krzysztof Heltc79ba282007-10-16 01:28:32 -07001338#if defined(__BIG_ENDIAN)
1339 pm3fb_fix.mmio_start += PM3_REGS_SIZE;
1340 DPRINTK("Adjusting register base for big-endian.\n");
1341#endif
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001342
1343 /* Registers - request region and map it. */
1344 if (!request_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len,
1345 "pm3fb regbase")) {
1346 printk(KERN_WARNING "pm3fb: Can't reserve regbase.\n");
1347 goto err_exit_neither;
1348 }
1349 par->v_regs =
1350 ioremap_nocache(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len);
1351 if (!par->v_regs) {
1352 printk(KERN_WARNING "pm3fb: Can't remap %s register area.\n",
1353 pm3fb_fix.id);
1354 release_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len);
1355 goto err_exit_neither;
1356 }
1357
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001358 /* Linear frame buffer - request region and map it. */
1359 pm3fb_fix.smem_start = pci_resource_start(dev, 1);
1360 pm3fb_fix.smem_len = pm3fb_size_memory(par);
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001361 if (!pm3fb_fix.smem_len) {
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001362 printk(KERN_WARNING "pm3fb: Can't find memory on board.\n");
1363 goto err_exit_mmio;
1364 }
1365 if (!request_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len,
1366 "pm3fb smem")) {
1367 printk(KERN_WARNING "pm3fb: Can't reserve smem.\n");
1368 goto err_exit_mmio;
1369 }
Luis R. Rodriguez26e25062015-04-21 13:16:34 -07001370 info->screen_base = ioremap_wc(pm3fb_fix.smem_start,
1371 pm3fb_fix.smem_len);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001372 if (!info->screen_base) {
1373 printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n");
1374 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
1375 goto err_exit_mmio;
1376 }
1377 info->screen_size = pm3fb_fix.smem_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001379 if (!nomtrr)
Luis R. Rodriguez26e25062015-04-21 13:16:34 -07001380 par->wc_cookie = arch_phys_wc_add(pm3fb_fix.smem_start,
1381 pm3fb_fix.smem_len);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001382 info->fbops = &pm3fb_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001384 par->video = PM3_READ_REG(par, PM3VideoControl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001386 info->fix = pm3fb_fix;
1387 info->pseudo_palette = par->palette;
Krzysztof Helta58d67c2007-07-17 04:05:46 -07001388 info->flags = FBINFO_DEFAULT |
Krzysztof Heltc79ba282007-10-16 01:28:32 -07001389 FBINFO_HWACCEL_XPAN |
1390 FBINFO_HWACCEL_YPAN |
Krzysztof Helte7f76df2007-10-16 01:28:29 -07001391 FBINFO_HWACCEL_COPYAREA |
1392 FBINFO_HWACCEL_IMAGEBLIT |
1393 FBINFO_HWACCEL_FILLRECT;
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001394
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001395 if (noaccel) {
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001396 printk(KERN_DEBUG "disabling acceleration\n");
1397 info->flags |= FBINFO_HWACCEL_DISABLED;
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001398 }
Krzysztof Heltb0a318e2007-10-16 01:28:31 -07001399 info->pixmap.addr = kmalloc(PM3_PIXMAP_SIZE, GFP_KERNEL);
1400 if (!info->pixmap.addr) {
1401 retval = -ENOMEM;
1402 goto err_exit_pixmap;
1403 }
1404 info->pixmap.size = PM3_PIXMAP_SIZE;
1405 info->pixmap.buf_align = 4;
1406 info->pixmap.scan_align = 4;
1407 info->pixmap.access_align = 32;
1408 info->pixmap.flags = FB_PIXMAP_SYSTEM;
1409
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001410 /*
1411 * This should give a reasonable default video mode. The following is
1412 * done when we can set a video mode.
1413 */
1414 if (!mode_option)
1415 mode_option = "640x480@60";
1416
1417 retval = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8);
1418
1419 if (!retval || retval == 4) {
1420 retval = -EINVAL;
1421 goto err_exit_both;
1422 }
1423
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001424 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
1425 retval = -ENOMEM;
1426 goto err_exit_both;
1427 }
1428
1429 /*
1430 * For drivers that can...
1431 */
1432 pm3fb_check_var(&info->var, info);
1433
1434 if (register_framebuffer(info) < 0) {
1435 retval = -EINVAL;
1436 goto err_exit_all;
1437 }
Joe Perches31b67802013-09-19 18:35:55 -07001438 fb_info(info, "%s frame buffer device\n", info->fix.id);
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001439 pci_set_drvdata(dev, info);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001440 return 0;
1441
1442 err_exit_all:
1443 fb_dealloc_cmap(&info->cmap);
1444 err_exit_both:
Krzysztof Heltb0a318e2007-10-16 01:28:31 -07001445 kfree(info->pixmap.addr);
1446 err_exit_pixmap:
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001447 iounmap(info->screen_base);
1448 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
1449 err_exit_mmio:
1450 iounmap(par->v_regs);
1451 release_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len);
1452 err_exit_neither:
1453 framebuffer_release(info);
1454 return retval;
1455}
1456
1457 /*
1458 * Cleanup
1459 */
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -08001460static void pm3fb_remove(struct pci_dev *dev)
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001461{
1462 struct fb_info *info = pci_get_drvdata(dev);
1463
1464 if (info) {
1465 struct fb_fix_screeninfo *fix = &info->fix;
1466 struct pm3_par *par = info->par;
1467
1468 unregister_framebuffer(info);
1469 fb_dealloc_cmap(&info->cmap);
1470
Luis R. Rodriguez26e25062015-04-21 13:16:34 -07001471 arch_phys_wc_del(par->wc_cookie);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001472 iounmap(info->screen_base);
1473 release_mem_region(fix->smem_start, fix->smem_len);
1474 iounmap(par->v_regs);
1475 release_mem_region(fix->mmio_start, fix->mmio_len);
1476
Krzysztof Heltb0a318e2007-10-16 01:28:31 -07001477 kfree(info->pixmap.addr);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001478 framebuffer_release(info);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 }
1480}
1481
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001482static struct pci_device_id pm3fb_id_table[] = {
1483 { PCI_VENDOR_ID_3DLABS, 0x0a,
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001484 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001485 { 0, }
1486};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001487
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001488/* For PCI drivers */
1489static struct pci_driver pm3fb_driver = {
1490 .name = "pm3fb",
1491 .id_table = pm3fb_id_table,
1492 .probe = pm3fb_probe,
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -08001493 .remove = pm3fb_remove,
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001494};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001496MODULE_DEVICE_TABLE(pci, pm3fb_id_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001498#ifndef MODULE
1499 /*
1500 * Setup
1501 */
1502
1503/*
1504 * Only necessary if your driver takes special options,
1505 * otherwise we fall back on the generic fb_setup().
1506 */
1507static int __init pm3fb_setup(char *options)
1508{
1509 char *this_opt;
1510
Joe Perches75e1b6a2011-06-23 22:35:19 +00001511 /* Parse user specified options (`video=pm3fb:') */
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001512 if (!options || !*options)
1513 return 0;
1514
1515 while ((this_opt = strsep(&options, ",")) != NULL) {
1516 if (!*this_opt)
1517 continue;
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001518 else if (!strncmp(this_opt, "noaccel", 7))
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001519 noaccel = 1;
Krzysztof Helt1d677a62007-10-16 01:28:54 -07001520 else if (!strncmp(this_opt, "hwcursor=", 9))
1521 hwcursor = simple_strtoul(this_opt + 9, NULL, 0);
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001522 else if (!strncmp(this_opt, "nomtrr", 6))
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001523 nomtrr = 1;
Krzysztof Helt57bac0f2007-10-16 01:28:51 -07001524 else
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001525 mode_option = this_opt;
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001526 }
1527 return 0;
1528}
1529#endif /* MODULE */
1530
Adrian Bunkb309c052007-07-17 04:05:46 -07001531static int __init pm3fb_init(void)
Krzysztof Helt2686ba82007-05-23 13:57:48 -07001532{
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001533 /*
1534 * For kernel boot options (in 'video=pm3fb:<options>' format)
1535 */
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001536#ifndef MODULE
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001537 char *option = NULL;
1538
1539 if (fb_get_options("pm3fb", &option))
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001540 return -ENODEV;
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001541 pm3fb_setup(option);
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001542#endif
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001543
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001544 return pci_register_driver(&pm3fb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545}
1546
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001547#ifdef MODULE
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001548static void __exit pm3fb_exit(void)
1549{
1550 pci_unregister_driver(&pm3fb_driver);
1551}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001552
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001553module_exit(pm3fb_exit);
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001554#endif
1555module_init(pm3fb_init);
1556
Krzysztof Helt4e65c612008-04-28 02:15:07 -07001557module_param(mode_option, charp, 0);
1558MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'");
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001559module_param(noaccel, bool, 0);
1560MODULE_PARM_DESC(noaccel, "Disable acceleration");
Krzysztof Helt1d677a62007-10-16 01:28:54 -07001561module_param(hwcursor, int, 0644);
1562MODULE_PARM_DESC(hwcursor, "Enable hardware cursor "
1563 "(1=enable, 0=disable, default=1)");
Krzysztof Heltd5383fc2007-10-16 01:28:33 -07001564module_param(nomtrr, bool, 0);
1565MODULE_PARM_DESC(nomtrr, "Disable MTRR support (0 or 1=disabled) (default=0)");
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001566
Krzysztof Helt0ddf7842007-10-16 01:28:32 -07001567MODULE_DESCRIPTION("Permedia3 framebuffer device driver");
Krzysztof Heltf23a06f2007-05-10 22:23:25 -07001568MODULE_LICENSE("GPL");