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