12 #include <linux/module.h>
13 #include <linux/kernel.h>
15 #include <linux/errno.h>
26 #define INCLUDE_TIMING_TABLE_DATA
27 #define DBE_REG_BASE par->regs
36 #define FLATPANEL_SGI_1600SW 5
48 static int flatpanel_id = -1;
51 .id =
"SGI Vis WS FB",
117 static struct fb_ops sgivwfb_ops = {
119 .fb_check_var = sgivwfb_check_var,
120 .fb_set_par = sgivwfb_set_par,
121 .fb_setcolreg = sgivwfb_setcolreg,
125 .fb_mmap = sgivwfb_mmap,
131 static unsigned long bytes_per_pixel(
int bpp)
146 static unsigned long get_line_length(
int xres_virtual,
int bpp)
148 return (xres_virtual * bytes_per_pixel(bpp));
159 static void dbe_TurnOffDma(
struct sgivw_par *par)
161 unsigned int readVal;
198 for (i = 0; i < 10000; i++) {
206 (OVR_INHWCTRL, OVR_DMA_ENABLE, readVal) == 0)
211 (DID_INHWCTRL, DID_DMA_ENABLE,
263 for (min_mode = 0; min_mode <
ARRAY_SIZE(dbeVTimings); min_mode++) {
264 if (dbeVTimings[min_mode].
width >= var->
xres &&
265 dbeVTimings[min_mode].height >= var->
yres)
277 test_mode = min_mode;
278 while (dbeVTimings[min_mode].
width == dbeVTimings[test_mode].
width) {
279 if (dbeVTimings[test_mode].cfreq + 3000 > req_dot)
283 if (dbeVTimings[min_mode].width != dbeVTimings[test_mode].width)
285 min_mode = test_mode;
286 timing = &dbeVTimings[min_mode];
302 info->
fix.line_length = line_length;
308 var->
green.offset = 0;
309 var->
green.length = 8;
310 var->
blue.offset = 0;
311 var->
blue.length = 8;
316 var->
red.offset = 11;
318 var->
green.offset = 6;
319 var->
green.length = 5;
320 var->
blue.offset = 1;
321 var->
blue.length = 5;
328 var->
green.offset = 8;
329 var->
green.length = 8;
330 var->
blue.offset = 16;
331 var->
blue.length = 8;
336 var->
red.msb_right = 0;
337 var->
green.msb_right = 0;
338 var->
blue.msb_right = 0;
339 var->
transp.msb_right = 0;
366 int fp_wid, fp_hgt, fp_vbs, fp_vbe;
376 switch (flatpanel_id) {
382 currentTiming->
pll_m = 4;
383 currentTiming->
pll_n = 1;
384 currentTiming->
pll_p = 0;
387 fp_wid = fp_hgt = fp_vbs = fp_vbe = 0xfff;
406 static int sgivwfb_set_par(
struct fb_info *info)
410 u32 readVal, outputVal;
411 int wholeTilesX, maxPixelsPerTileX;
412 int frmWrite1, frmWrite2, frmWrite3b;
417 currentTiming = &dbeVTimings[par->
timing_num];
418 bytesPerPixel = bytes_per_pixel(info->
var.bits_per_pixel);
419 xpmax = currentTiming->
width;
420 ypmax = currentTiming->
height;
429 maxPixelsPerTileX = 512 / bytesPerPixel;
430 wholeTilesX = xpmax / maxPixelsPerTileX;
431 if (wholeTilesX * maxPixelsPerTileX < xpmax)
435 maxPixelsPerTileX, wholeTilesX);
440 for (i = 0; i < 256; i++) {
453 for (i = 0; i < 256; i++) {
454 for (j = 0; j < 100; j++) {
456 if (readVal != 0x00000000)
463 DBE_ISETREG(cmap, i, (i << 8) | (i << 16) | (i << 24));
472 switch (bytesPerPixel) {
488 SET_DBE_FIELD(FRM_SIZE_PIXEL, FB_HEIGHT_PIX, frmWrite2, ypmax);
501 switch (bytesPerPixel) {
514 for (i = 0; i < 32; i++) {
563 if (flatpanel_id != -1)
564 sgivwfb_setup_flatpanel(par, currentTiming);
577 currentTiming->
htotal - (20 -
621 outputVal = frmWrite1;
635 for (i = 0; i < 100000; i++) {
646 "sgivwfb: timeout waiting for frame DMA enable.\n");
651 htmp += currentTiming->
htotal;
654 ((htmp + currentTiming->
width -
655 2) % currentTiming->
htotal));
666 par->
regs->crs_ctl = 0;
670 readVal &= 0x02000000;
700 par->
regs->cmap[regno] = (red << 24) | (green << 16) | (blue << 8);
705 static int sgivwfb_mmap(
struct fb_info *info,
731 if (!options || !*options)
734 while ((this_opt =
strsep(&options,
",")) !=
NULL) {
735 if (!
strncmp(this_opt,
"monitor:", 8)) {
736 if (!
strncmp(this_opt + 8,
"crt", 3))
738 else if (!
strncmp(this_opt + 8,
"1600sw", 6))
768 goto fail_ioremap_regs;
775 sgivwfb_fix.ywrapstep = ywrap;
776 sgivwfb_fix.ypanstep = ypan;
778 info->
fix = sgivwfb_fix;
780 switch (flatpanel_id) {
782 info->
var = sgivwfb_var1600sw;
783 monitor =
"SGI 1600SW flatpanel";
786 info->
var = sgivwfb_var;
792 info->
fbops = &sgivwfb_ops;
799 goto fail_ioremap_fbmem;
807 goto fail_register_framebuffer;
810 platform_set_drvdata(dev, info);
812 printk(
KERN_INFO "fb%d: SGI DBE frame buffer device, using %ldK of video memory at %#lx\n",
816 fail_register_framebuffer:
830 struct fb_info *info = platform_get_drvdata(dev);
847 .probe = sgivwfb_probe,
870 if (sgivwfb_device) {
887 static void __exit sgivwfb_exit(
void)