1/* 2 * Acceleration for the Creator and Creator3D framebuffer - defines. 3 * 4 * Copyright (C) 1998,1999,2000 Jakub Jelinek (jakub@redhat.com) 5 * Copyright (C) 1998 Michal Rehacek (majkl@iname.com) 6 * Copyright (C) 1999 David S. Miller (davem@redhat.com) 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy 9 * of this software and associated documentation files (the "Software"), to deal 10 * in the Software without restriction, including without limitation the rights 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 * copies of the Software, and to permit persons to whom the Software is 13 * furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included in 16 * all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 * JAKUB JELINEK, MICHAL REHACEK, OR DAVID MILLER BE LIABLE FOR ANY CLAIM, 22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 24 * USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 */ 27 28#ifndef FFB_H 29#define FFB_H 30 31#include "xf86.h" 32#include "xf86_OSproc.h" 33#include "xf86Cursor.h" 34#ifdef HAVE_XAA_H 35#include "xaa.h" 36#endif 37#include "exa.h" 38 39#include <X11/Xmd.h> 40#include "gcstruct.h" 41#include "windowstr.h" 42#include "ffb_regs.h" 43#include "xf86sbusBus.h" 44#include "ffb_dac.h" 45#ifdef HAVE_XEXTPROTO_71 46#include <X11/extensions/dpmsconst.h> 47#else 48#ifndef DPMS_SERVER 49#define DPMS_SERVER 50#endif /* DPMS_SERVER */ 51#include <X11/extensions/dpms.h> 52#endif 53 54#include "compat-api.h" 55/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */ 56/* Note: do not mmap FFB_DFB8R_VOFF and following mappings using one mmap together 57 with any previous SFB mapping, otherwise the OS won't be able to use 4M pages 58 for the DFB mappings. -jj */ 59#define FFB_SFB8R_VOFF 0x00000000 60#define FFB_SFB8G_VOFF 0x00400000 61#define FFB_SFB8B_VOFF 0x00800000 62#define FFB_SFB8X_VOFF 0x00c00000 63#define FFB_SFB32_VOFF 0x01000000 64#define FFB_SFB64_VOFF 0x02000000 65#define FFB_FBC_REGS_VOFF 0x04000000 66#define FFB_BM_FBC_REGS_VOFF 0x04002000 67#define FFB_DFB8R_VOFF 0x04004000 68#define FFB_DFB8G_VOFF 0x04404000 69#define FFB_DFB8B_VOFF 0x04804000 70#define FFB_DFB8X_VOFF 0x04c04000 71#define FFB_DFB24_VOFF 0x05004000 72#define FFB_DFB32_VOFF 0x06004000 73#define FFB_DFB422A_VOFF 0x07004000 /* DFB 422 mode write to A */ 74#define FFB_DFB422AD_VOFF 0x07804000 /* DFB 422 mode with line doubling */ 75#define FFB_DFB24B_VOFF 0x08004000 /* DFB 24bit mode write to B */ 76#define FFB_DFB422B_VOFF 0x09004000 /* DFB 422 mode write to B */ 77#define FFB_DFB422BD_VOFF 0x09804000 /* DFB 422 mode with line doubling */ 78#define FFB_SFB16Z_VOFF 0x0a004000 /* 16bit mode Z planes */ 79#define FFB_SFB8Z_VOFF 0x0a404000 /* 8bit mode Z planes */ 80#define FFB_SFB422_VOFF 0x0ac04000 /* SFB 422 mode write to A/B */ 81#define FFB_SFB422D_VOFF 0x0b404000 /* SFB 422 mode with line doubling */ 82#define FFB_FBC_KREGS_VOFF 0x0bc04000 83#define FFB_DAC_VOFF 0x0bc06000 84#define FFB_PROM_VOFF 0x0bc08000 85#define FFB_EXP_VOFF 0x0bc18000 86 87#if defined(__GNUC__) && defined(USE_VIS) 88#define FFB_ALIGN64 __attribute__((aligned(8))) 89#else 90#define FFB_ALIGN64 91#endif 92 93typedef struct { 94 unsigned int fg FFB_ALIGN64, bg; /* FG/BG colors for stipple */ 95 unsigned int patalign; /* X/Y alignment of bits */ 96 unsigned char alu; /* ALU operation */ 97 unsigned char inhw; /* Cached in FFB */ 98 unsigned char pagable; /* Can be used in a pagefill */ 99 unsigned char ph; /* Page buffer height */ 100 unsigned int bits[32]; /* The stipple bits themselves */ 101} CreatorStippleRec, *CreatorStipplePtr; 102 103/* WID and framebuffer controls are a property of the 104 * window. 105 */ 106typedef struct { 107 CreatorStipplePtr Stipple; 108 unsigned int fbc_base; 109 unsigned int wid; 110} CreatorPrivWinRec, *CreatorPrivWinPtr; 111 112enum ffb_resolution { 113 ffb_res_standard = 0, /* 1280 x 1024 */ 114 ffb_res_high, /* 1920 x 1360 */ 115 ffb_res_stereo, /* 960 x 580 */ 116 ffb_res_portrait /* 1280 x 2048 */ 117}; 118 119enum ffb_chip_type { 120 ffb1_prototype = 0, /* Early pre-FCS FFB */ 121 ffb1_standard, /* First FCS FFB, 100Mhz UPA, 66MHz gclk */ 122 ffb1_speedsort, /* Second FCS FFB, 100Mhz UPA, 75MHz gclk */ 123 ffb2_prototype, /* Early pre-FCS vertical FFB2 */ 124 ffb2_vertical, /* First FCS FFB2/vertical, 100Mhz UPA, 100MHZ gclk, 125 75(SingleBuffer)/83(DoubleBuffer) MHz fclk */ 126 ffb2_vertical_plus, /* Second FCS FFB2/vertical, same timings */ 127 ffb2_horizontal, /* First FCS FFB2/horizontal, same timings as FFB2/vert */ 128 ffb2_horizontal_plus, /* Second FCS FFB2/horizontal, same timings */ 129 afb_m3, /* FCS Elite3D, 3 float chips */ 130 afb_m6 /* FCS Elite3D, 6 float chips */ 131}; 132 133typedef struct { 134 unsigned short fifo_cache; 135 unsigned short rp_active; 136 ffb_fbcPtr regs; 137 unsigned int ppc_cache; 138 unsigned int pmask_cache; 139 unsigned int rop_cache; 140 unsigned int drawop_cache; 141 unsigned int fg_cache; 142 unsigned int bg_cache; 143 unsigned int fontw_cache; 144 unsigned int fontinc_cache; 145 unsigned int fbc_cache; 146 unsigned int wid_cache; 147 enum ffb_chip_type ffb_type; 148 CreatorStipplePtr laststipple; 149 unsigned *fb; 150 unsigned *sfb32; 151 unsigned *sfb8r; 152 unsigned *sfb8x; 153 unsigned *dfb24; 154 unsigned *dfb8r; 155 unsigned *dfb8x; 156 157 /* Slot offset 0x0200000, used to probe board type. */ 158 volatile unsigned int *strapping_bits; 159 160 /* Needed for some 3DRAM revisions and ffb1 in hires */ 161 unsigned char disable_pagefill; 162 163 /* Needed for FFB2/AFB when in stereo or hires */ 164 unsigned char disable_fastfill_ap; 165 166 /* Needed for FFB1 in highres mode */ 167 unsigned char disable_vscroll; 168 169 /* Needed on all FFB1 boards. */ 170 unsigned char has_brline_bug; 171 172 /* Available on FFB2 and AFB */ 173 unsigned char use_blkread_prefetch; 174 175 /* Framebuffer configuration */ 176 unsigned char has_double_res; 177 unsigned char has_z_buffer; 178 unsigned char has_double_buffer; 179 180 /* XAA related info */ 181#ifdef HAVE_XAA_H 182 XAAInfoRecPtr pXAAInfo; 183#endif 184 unsigned int xaa_linepat; 185 int xaa_xdir, xaa_ydir, xaa_rop; 186 unsigned char *xaa_scanline_buffers[2]; 187 int xaa_scanline_x, xaa_scanline_y, xaa_scanline_w; 188 unsigned char *xaa_tex; 189 int xaa_tex_pitch, xaa_tex_width, xaa_tex_height; 190 unsigned int xaa_tex_color; 191 192 enum ffb_resolution ffb_res; 193 BoxRec ClippedBoxBuf[64]; 194 xRectangle Pf_Fixups[4]; 195 short Pf_AlignTab[0x800]; 196 197 ffb_dacPtr dac; 198 sbusDevicePtr psdp; 199 Bool HWCursor; 200 Bool NoAccel; 201 Bool vtSema; 202 CloseScreenProcPtr CloseScreen; 203 xf86CursorInfoPtr CursorInfoRec; 204 unsigned char CursorShiftX, CursorShiftY; 205 unsigned char *CursorData; 206 207 /* EXA stuff */ 208 ExaDriverPtr pExa; 209 int xdir, ydir, rop; 210 CARD32 planemask, fbc, wid, fillcolour; 211 Bool no_source_pixmap, source_is_solid; 212 int srcoff, srcpitch, mskoff, mskpitch; 213 CARD32 srcformat, dstformat, mskformat; 214 int op; 215 216 217 PixmapPtr pix32, pix8; 218 219 void *I2C; 220 struct ffb_dac_info dac_info; 221 222 OptionInfoPtr Options; 223} FFBRec, *FFBPtr; 224 225/* Acceleration */ 226extern Bool FFBAccelInit(ScreenPtr, FFBPtr); 227extern Bool FFBInitEXA(ScreenPtr); 228extern void CreatorVtChange (ScreenPtr pScreen, int enter); 229 230/* HW cursor support */ 231extern Bool FFBHWCursorInit(ScreenPtr); 232 233/* Exported DAC layer routines. */ 234extern void FFBDacLoadCursorPos(FFBPtr, int, int); 235extern void FFBDacLoadCursorColor(FFBPtr, int, int); 236extern void FFBDacCursorEnableDisable(FFBPtr, int); 237extern void FFBDacCursorLoadBitmap(FFBPtr, int, int, unsigned int *); 238extern void FFBDacLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr); 239extern Bool FFBDacInit(FFBPtr); 240extern void FFBDacFini(FFBPtr); 241extern void FFBDacEnterVT(FFBPtr); 242extern void FFBDacLeaveVT(FFBPtr); 243extern Bool FFBDacSaveScreen(ScreenPtr, int); 244extern void FFBDacDPMSMode(FFBPtr, int, int); 245 246/* Exported WID layer routines. */ 247extern void FFBWidPoolInit(FFBPtr); 248extern unsigned int FFBWidAlloc(FFBPtr, int, int, Bool); 249extern void FFBWidFree(FFBPtr, unsigned int); 250extern unsigned int FFBWidUnshare(FFBPtr, unsigned int); 251extern unsigned int FFBWidReshare(FFBPtr, unsigned int); 252extern void FFBWidChangeBuffer(FFBPtr, unsigned int, int); 253extern void VISmoveImageLR(unsigned char *, unsigned char *, long, long, long, long); 254extern void VISmoveImageRL(unsigned char *, unsigned char *, long, long, long, long); 255 256/* Accelerated double-buffering. */ 257extern Bool FFBDbePreInit(ScreenPtr); 258 259/* The fastfill and pagefill buffer sizes change based upon 260 * the resolution. 261 */ 262struct fastfill_parms { 263 int fastfill_small_area; 264 int pagefill_small_area; 265 266 int fastfill_height; 267 int fastfill_width; 268 int pagefill_height; 269 int pagefill_width; 270}; 271 272extern struct fastfill_parms ffb_fastfill_parms[]; 273 274#define FFB_FFPARMS(__fpriv) (ffb_fastfill_parms[(__fpriv)->ffb_res]) 275 276#define GET_FFB_FROM_SCRN(p) ((FFBPtr)((p)->driverPrivate)) 277 278#undef DEBUG_FFB 279 280#ifdef DEBUG_FFB 281 282extern FILE *FDEBUG_FD; 283 284static __inline__ void FFB_DEBUG_init(void) 285{ 286 FDEBUG_FD = fopen("/tmp/FFB.DEBUG", "a"); 287} 288#define FDEBUG(__x) \ 289do { fprintf __x; \ 290 fflush(FDEBUG_FD); \ 291} while(0) 292#else 293#define FFB_DEBUG_init() do { } while(0) 294#define FDEBUG(__x) do { } while(0) 295#endif 296 297/* Enable this to get very verbose tracing of the driver onto stderr. */ 298#undef TRACE_FFB 299#ifdef TRACE_FFB 300#define FFBLOG(__x) ErrorF __x 301#else 302#define FFBLOG(__x) do { } while(0) 303#endif 304 305/* common acceleration routines */ 306void FFB_SetupTextureAttrs(FFBPtr); 307void FFB_HardwareSetup(FFBPtr); 308void CreatorAlignTabInit(FFBPtr); 309 310#endif /* FFB_H */ 311