ffb.h revision 89b0bd4c
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 "xf86RamDac.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 srcpitch, srcoff; 210 int xdir, ydir, rop; 211 CARD32 planemask, fbc, wid; 212 213 PixmapPtr pix32, pix8; 214 215 void *I2C; 216 struct ffb_dac_info dac_info; 217 218 OptionInfoPtr Options; 219} FFBRec, *FFBPtr; 220 221/* Acceleration */ 222extern Bool FFBAccelInit(ScreenPtr, FFBPtr); 223extern Bool FFBInitEXA(ScreenPtr); 224extern void CreatorVtChange (ScreenPtr pScreen, int enter); 225 226/* HW cursor support */ 227extern Bool FFBHWCursorInit(ScreenPtr); 228 229/* Exported DAC layer routines. */ 230extern void FFBDacLoadCursorPos(FFBPtr, int, int); 231extern void FFBDacLoadCursorColor(FFBPtr, int, int); 232extern void FFBDacCursorEnableDisable(FFBPtr, int); 233extern void FFBDacCursorLoadBitmap(FFBPtr, int, int, unsigned int *); 234extern void FFBDacLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr); 235extern Bool FFBDacInit(FFBPtr); 236extern void FFBDacFini(FFBPtr); 237extern void FFBDacEnterVT(FFBPtr); 238extern void FFBDacLeaveVT(FFBPtr); 239extern Bool FFBDacSaveScreen(ScreenPtr, int); 240extern void FFBDacDPMSMode(FFBPtr, int, int); 241 242/* Exported WID layer routines. */ 243extern void FFBWidPoolInit(FFBPtr); 244extern unsigned int FFBWidAlloc(FFBPtr, int, int, Bool); 245extern void FFBWidFree(FFBPtr, unsigned int); 246extern unsigned int FFBWidUnshare(FFBPtr, unsigned int); 247extern unsigned int FFBWidReshare(FFBPtr, unsigned int); 248extern void FFBWidChangeBuffer(FFBPtr, unsigned int, int); 249extern void VISmoveImageLR(unsigned char *, unsigned char *, long, long, long, long); 250extern void VISmoveImageRL(unsigned char *, unsigned char *, long, long, long, long); 251 252/* Accelerated double-buffering. */ 253extern Bool FFBDbePreInit(ScreenPtr); 254 255/* The fastfill and pagefill buffer sizes change based upon 256 * the resolution. 257 */ 258struct fastfill_parms { 259 int fastfill_small_area; 260 int pagefill_small_area; 261 262 int fastfill_height; 263 int fastfill_width; 264 int pagefill_height; 265 int pagefill_width; 266}; 267 268extern struct fastfill_parms ffb_fastfill_parms[]; 269 270#define FFB_FFPARMS(__fpriv) (ffb_fastfill_parms[(__fpriv)->ffb_res]) 271 272#define GET_FFB_FROM_SCRN(p) ((FFBPtr)((p)->driverPrivate)) 273 274#undef DEBUG_FFB 275 276#ifdef DEBUG_FFB 277 278extern FILE *FDEBUG_FD; 279 280static __inline__ void FFB_DEBUG_init(void) 281{ 282 FDEBUG_FD = fopen("/tmp/FFB.DEBUG", "a"); 283} 284#define FDEBUG(__x) \ 285do { fprintf __x; \ 286 fflush(FDEBUG_FD); \ 287} while(0) 288#else 289#define FFB_DEBUG_init() do { } while(0) 290#define FDEBUG(__x) do { } while(0) 291#endif 292 293/* Enable this to get very verbose tracing of the driver onto stderr. */ 294#undef TRACE_FFB 295#ifdef TRACE_FFB 296#define FFBLOG(__x) ErrorF __x 297#else 298#define FFBLOG(__x) do { } while(0) 299#endif 300 301#endif /* FFB_H */ 302