52 #undef FALLBACK_TO_1BPP
54 #undef DEBUG_STIFB_REGS
57 #include <linux/module.h>
58 #include <linux/kernel.h>
59 #include <linux/errno.h>
60 #include <linux/string.h>
62 #include <linux/slab.h>
69 #include <asm/uaccess.h>
74 #define REGION_BASE(fb_info, index) \
75 F_EXTEND(fb_info->sti->glob_cfg->region_ptrs[index])
77 #define NGLEDEVDEPROM_CRT_REGION 1
79 #define NR_PALETTE 256
119 #define REG_1 0x000118
120 #define REG_2 0x000480
121 #define REG_3 0x0004a0
122 #define REG_4 0x000600
123 #define REG_6 0x000800
124 #define REG_8 0x000820
125 #define REG_9 0x000a04
126 #define REG_10 0x018000
127 #define REG_11 0x018004
128 #define REG_12 0x01800c
129 #define REG_13 0x018018
130 #define REG_14 0x01801c
131 #define REG_15 0x200000
132 #define REG_15b0 0x200000
133 #define REG_16b1 0x200005
134 #define REG_16b3 0x200007
135 #define REG_21 0x200218
136 #define REG_22 0x0005a0
137 #define REG_23 0x0005c0
138 #define REG_26 0x200118
139 #define REG_27 0x200308
140 #define REG_32 0x21003c
141 #define REG_33 0x210040
142 #define REG_34 0x200008
143 #define REG_35 0x018010
144 #define REG_38 0x210020
145 #define REG_39 0x210120
146 #define REG_40 0x210130
147 #define REG_42 0x210028
148 #define REG_43 0x21002c
149 #define REG_44 0x210030
150 #define REG_45 0x210034
152 #define READ_BYTE(fb,reg) gsc_readb((fb)->info.fix.mmio_start + (reg))
153 #define READ_WORD(fb,reg) gsc_readl((fb)->info.fix.mmio_start + (reg))
156 #ifndef DEBUG_STIFB_REGS
159 # define WRITE_BYTE(value,fb,reg) gsc_writeb((value),(fb)->info.fix.mmio_start + (reg))
160 # define WRITE_WORD(value,fb,reg) gsc_writel((value),(fb)->info.fix.mmio_start + (reg))
162 static int debug_on = 1;
163 # define DEBUG_OFF() debug_on=0
164 # define DEBUG_ON() debug_on=1
165 # define WRITE_BYTE(value,fb,reg) do { if (debug_on) \
166 printk(KERN_DEBUG "%30s: WRITE_BYTE(0x%06x) = 0x%02x (old=0x%02x)\n", \
167 __func__, reg, value, READ_BYTE(fb,reg)); \
168 gsc_writeb((value),(fb)->info.fix.mmio_start + (reg)); } while (0)
169 # define WRITE_WORD(value,fb,reg) do { if (debug_on) \
170 printk(KERN_DEBUG "%30s: WRITE_WORD(0x%06x) = 0x%08x (old=0x%08x)\n", \
171 __func__, reg, value, READ_WORD(fb,reg)); \
172 gsc_writel((value),(fb)->info.fix.mmio_start + (reg)); } while (0)
179 #define NGLE_LOCK(fb_info) do { } while (0)
180 #define NGLE_UNLOCK(fb_info) do { } while (0)
198 unsigned int reg10_value = 0;
206 reg10_value = 0x13601000;
209 if (fb->
info.var.bits_per_pixel == 32)
210 reg10_value = 0xBBA0A000;
212 reg10_value = 0x13601000;
215 if (fb->
info.var.bits_per_pixel == 32)
216 reg10_value = 0xBBA0A000;
218 reg10_value = 0x13602000;
222 reg10_value = 0x13602000;
233 START_IMAGE_COLORMAP_ACCESS(
struct stifb_info *fb)
250 FINISH_IMAGE_COLORMAP_ACCESS(
struct stifb_info *fb)
253 if (fb->
info.var.bits_per_pixel == 32) {
307 unsigned int value = enable ? 0x43000000 : 0x03000000;
316 unsigned int value = enable ? 0x10000000 : 0x30000000;
339 #define GET_ROMTABLE_INDEX(fb) \
340 (READ_BYTE(fb, REG_16b3) - 1)
342 #define HYPER_CONFIG_PLANES_24 0x00000100
344 #define IS_24_DEVICE(fb) \
345 (fb->deviceSpecificConfig & HYPER_CONFIG_PLANES_24)
347 #define IS_888_DEVICE(fb) \
348 (!(IS_24_DEVICE(fb)))
350 #define GET_FIFO_SLOTS(fb, cnt, numslots) \
351 { while (cnt < numslots) \
352 cnt = READ_WORD(fb, REG_34); \
360 #define OtsIndirect 6
365 #define BINapp0F8 0xa
368 #define BitmapExtent08 3
369 #define BitmapExtent32 5
370 #define DataDynamic 0
371 #define MaskDynamic 1
374 #define MaskAddrOffset(offset) (offset)
375 #define StaticReg(en) (en)
379 #define BAJustPoint(offset) (offset)
380 #define BAIndexBase(base) (base)
381 #define BA(F,C,S,A,J,B,I) \
382 (((F)<<31)|((C)<<27)|((S)<<24)|((A)<<21)|((J)<<16)|((B)<<12)|(I))
384 #define IBOvals(R,M,X,S,D,L,B,F) \
385 (((R)<<8)|((M)<<16)|((X)<<24)|((S)<<29)|((D)<<28)|((L)<<31)|((B)<<1)|(F))
387 #define NGLE_QUICK_SET_IMAGE_BITMAP_OP(fb, val) \
388 WRITE_WORD(val, fb, REG_14)
390 #define NGLE_QUICK_SET_DST_BM_ACCESS(fb, val) \
391 WRITE_WORD(val, fb, REG_11)
393 #define NGLE_QUICK_SET_CTL_PLN_REG(fb, val) \
394 WRITE_WORD(val, fb, REG_12)
396 #define NGLE_REALLY_SET_IMAGE_PLANEMASK(fb, plnmsk32) \
397 WRITE_WORD(plnmsk32, fb, REG_13)
399 #define NGLE_REALLY_SET_IMAGE_FG_COLOR(fb, fg32) \
400 WRITE_WORD(fg32, fb, REG_35)
402 #define NGLE_SET_TRANSFERDATA(fb, val) \
403 WRITE_WORD(val, fb, REG_8)
405 #define NGLE_SET_DSTXY(fb, val) \
406 WRITE_WORD(val, fb, REG_6)
408 #define NGLE_LONG_FB_ADDRESS(fbaddrbase, x, y) ( \
409 (u32) (fbaddrbase) + \
410 ( (unsigned int) ( (y) << 13 ) | \
411 (unsigned int) ( (x) << 2 ) ) \
414 #define NGLE_BINC_SET_DSTADDR(fb, addr) \
415 WRITE_WORD(addr, fb, REG_3)
417 #define NGLE_BINC_SET_SRCADDR(fb, addr) \
418 WRITE_WORD(addr, fb, REG_2)
420 #define NGLE_BINC_SET_DSTMASK(fb, mask) \
421 WRITE_WORD(mask, fb, REG_22)
423 #define NGLE_BINC_WRITE32(fb, data32) \
424 WRITE_WORD(data32, fb, REG_23)
426 #define START_COLORMAPLOAD(fb, cmapBltCtlData32) \
427 WRITE_WORD((cmapBltCtlData32), fb, REG_38)
429 #define SET_LENXY_START_RECFILL(fb, lenxy) \
430 WRITE_WORD(lenxy, fb, REG_9)
433 HYPER_ENABLE_DISABLE_DISPLAY(
struct stifb_info *fb,
int enable)
438 value =
READ_WORD(fb, DregsHypMiscVideo);
442 value &= ~0x0A000000;
448 #define BUFF0_CMAP0 0x00001e02
449 #define BUFF1_CMAP0 0x02001e02
450 #define BUFF1_CMAP3 0x0c001e02
451 #define ARTIST_CMAP0 0x00000102
452 #define HYPER_CMAP8 0x00000100
453 #define HYPER_CMAP24 0x00000800
456 SETUP_ATTR_ACCESS(
struct stifb_info *fb,
unsigned BufferNumber)
496 ngleSetupAttrPlanes(
struct stifb_info *fb,
int BufferNumber)
498 SETUP_ATTR_ACCESS(fb, BufferNumber);
499 SET_ATTR_SIZE(fb, fb->
info.var.xres, fb->
info.var.yres);
500 FINISH_ATTR_ACCESS(fb);
514 CRX24_SETUP_RAMDAC(fb);
522 for (y = 0; y < fb->
info.var.yres; ++
y)
524 0xff, fb->
info.var.xres * fb->
info.var.bits_per_pixel/8);
526 CRX24_SET_OVLY_MASK(fb);
531 #define HYPER_CMAP_TYPE 0
532 #define NGLE_CMAP_INDEXED0_TYPE 0
533 #define NGLE_CMAP_OVERLAY_TYPE 3
541 unsigned waitBlank : 1;
543 unsigned lutOffset : 10;
544 unsigned lutType : 2;
558 lutBltCtl.
all = 0x80000000;
564 if (fb->var.bits_per_pixel == 8) {
566 lutBltCtl.
fields.lutOffset = 0;
569 lutBltCtl.
fields.lutOffset = 0 * 256;
575 lutBltCtl.
fields.lutOffset = 0 * 256;
580 lutBltCtl.
fields.lutOffset = 0;
585 lutBltCtl.
fields.lutOffset += offsetWithinLut;
597 lutBltCtl.
all = 0x80000000;
603 if (fb->
info.var.bits_per_pixel == 8)
604 lutBltCtl.
fields.lutOffset = 2 * 256;
606 lutBltCtl.
fields.lutOffset = 0 * 256;
609 lutBltCtl.
fields.lutOffset += offsetWithinLut;
615 static void hyperUndoITE(
struct stifb_info *fb)
617 int nFreeFifoSlots = 0;
650 ngleDepth8_ClearImagePlanes(
struct stifb_info *fb)
656 ngleDepth24_ClearImagePlanes(
struct stifb_info *fb)
662 ngleResetAttrPlanes(
struct stifb_info *fb,
unsigned int ctlPlaneReg)
664 int nFreeFifoSlots = 0;
684 packed_len = (fb->
info.var.xres << 16) | fb->
info.var.yres;
699 packed_dst = (1280 << 16);
702 packed_len = (4 << 16) | 1;
716 int nFreeFifoSlots = 0;
734 packed_len = (fb->
info.var.xres << 16) | fb->
info.var.yres;
749 hyperResetPlanes(
struct stifb_info *fb,
int enable)
751 unsigned int controlPlaneReg;
756 if (fb->
info.var.bits_per_pixel == 32)
757 controlPlaneReg = 0x04000F00;
759 controlPlaneReg = 0x00000F00;
761 controlPlaneReg = 0x00000F00;
767 ngleDepth24_ClearImagePlanes(fb);
769 ngleDepth8_ClearImagePlanes(fb);
773 ngleResetAttrPlanes(fb, controlPlaneReg);
776 ngleClearOverlayPlanes(fb, 0xff, 255);
787 ngleDepth24_ClearImagePlanes(fb);
789 ngleDepth8_ClearImagePlanes(fb);
790 ngleResetAttrPlanes(fb, controlPlaneReg);
791 ngleClearOverlayPlanes(fb, 0xff, 0);
796 ngleResetAttrPlanes(fb, controlPlaneReg);
810 int *pBytePerLongDevDepData;
812 NgleDevRomData *pPackedDevRomData;
813 int sizePackedDevRomData =
sizeof(*pPackedDevRomData);
816 char *mapOrigin =
NULL;
824 pPackedDevRomData->cursor_pipeline_delay = 4;
825 pPackedDevRomData->video_interleaves = 4;
835 while (romTableIdx > 0)
837 pCard8 = (Card8 *) pPackedDevRomData;
838 pRomTable = pBytePerLongDevDepData;
840 for (i = 0; i < sizePackedDevRomData; i++)
842 *pCard8++ = (Card8) (*pRomTable++);
845 pBytePerLongDevDepData = (Card32 *)
846 ((Card8 *) pBytePerLongDevDepData +
847 pPackedDevRomData->sizeof_ngle_data);
853 pCard8 = (Card8 *) pPackedDevRomData;
856 for (i = 0; i < sizePackedDevRomData; i++)
858 *pCard8++ = (Card8) (*pBytePerLongDevDepData++);
867 #define HYPERBOWL_MODE_FOR_8_OVER_88_LUT0_NO_TRANSPARENCIES 4
868 #define HYPERBOWL_MODE01_8_24_LUT0_TRANSPARENT_LUT1_OPAQUE 8
869 #define HYPERBOWL_MODE01_8_24_LUT0_OPAQUE_LUT1_OPAQUE 10
870 #define HYPERBOWL_MODE2_8_24 15
877 int nFreeFifoSlots = 0;
886 hyperbowl = (fb->
info.var.bits_per_pixel == 32) ?
933 START_IMAGE_COLORMAP_ACCESS(fb);
937 color = ((red * 77) +
941 color = ((red << 16) |
949 ((
u32 *)fb->
info.pseudo_palette)[regno] =
950 regno << var->
red.offset |
951 regno << var->
green.offset |
952 regno << var->
blue.offset;
955 WRITE_IMAGE_COLOR(fb, regno, color);
960 lutBltCtl = setHyperLutBltCtl(fb,
970 FINISH_IMAGE_COLORMAP_ACCESS(fb);
979 stifb_blank(
int blank_mode,
struct fb_info *info)
986 CRX24_ENABLE_DISABLE_DISPLAY(fb, enable);
990 ARTIST_ENABLE_DISABLE_DISPLAY(fb, enable);
993 HYPER_ENABLE_DISABLE_DISPLAY(fb, enable);
999 ENABLE_DISABLE_DISPLAY(fb, enable);
1027 hyperResetPlanes(fb,
ENABLE);
1030 rattlerSetupPlanes(fb);
1043 if (fb->
info.var.bits_per_pixel == 32)
1049 ngleClearOverlayPlanes(fb, 0xff, 0);
1053 if (fb->
info.var.bits_per_pixel == 32)
1060 stifb_blank(0, (
struct fb_info *)fb);
1067 static struct fb_ops stifb_ops = {
1069 .fb_setcolreg = stifb_setcolreg,
1070 .fb_blank = stifb_blank,
1087 unsigned long sti_rom_address;
1089 int bpp, xres, yres;
1105 fb->
id = fb->
sti->graphics_id[0];
1119 "WARNING: stifb framebuffer driver does not support '%s' in double-buffer mode.\n"
1120 "WARNING: Please disable the double-buffer mode in IPL menu (the PARISC-BIOS).\n",
1142 ngleGetDeviceRomData(fb);
1157 dev_name = fb->
sti->outptr.dev_name;
1158 if (
strstr(dev_name,
"GRAYSCALE") ||
1159 strstr(dev_name,
"Grayscale") ||
1160 strstr(dev_name,
"grayscale"))
1177 if ((fb->
sti->regions_phys[0] & 0xfc000000) ==
1178 (fb->
sti->regions_phys[2] & 0xfc000000))
1179 sti_rom_address =
F_EXTEND(fb->
sti->regions_phys[0]);
1181 sti_rom_address =
F_EXTEND(fb->
sti->regions_phys[1]);
1185 if (bpp_pref == 8 || bpp_pref == 32)
1198 #ifdef FALLBACK_TO_1BPP
1200 "stifb: Unsupported graphics card (id=0x%08x) "
1201 "- now trying 1bpp mode instead\n",
1207 "stifb: Unsupported graphics card (id=0x%08x) "
1217 fix->
smem_len = fb->
sti->regions[1].region_desc.length * 4096;
1233 var->
red.length = var->
green.length = var->
blue.length = 1;
1238 var->
red.length = var->
green.length = var->
blue.length = 8;
1244 var->
blue.offset = 0;
1245 var->
green.offset = 8;
1246 var->
red.offset = 16;
1258 info->
fbops = &stifb_ops;
1267 stifb_init_display(fb);
1270 printk(
KERN_ERR "stifb: cannot reserve fb region 0x%04lx-0x%04lx\n",
1276 printk(
KERN_ERR "stifb: cannot reserve sti mmio region 0x%04lx-0x%04lx\n",
1287 "fb%d: %s %dx%d-%d frame buffer device, %s, id: %04x, mmio: 0x%04lx\n",
1318 static int __init stifb_init(
void)
1331 if (stifb_disabled) {
1332 printk(
KERN_INFO "stifb: disabled by \"stifb=off\" kernel parameter\n");
1342 if (sti == def_sti) {
1343 stifb_init_fb(sti, stifb_bpp_pref[i - 1]);
1355 stifb_init_fb(sti, stifb_bpp_pref[i - 1]);
1393 if (!options || !*options)
1396 if (
strncmp(options,
"off", 3) == 0) {
1401 if (
strncmp(options,
"bpp", 3) == 0) {
1404 if (*options++ !=
':')
1418 MODULE_DESCRIPTION(
"Framebuffer driver for HP's NGLE series graphics cards in HP PARISC machines");