ast.h revision b4d38c65
1/*
2 * Copyright (c) 2005 ASPEED Technology Inc.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the authors not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission.  The authors makes no representations
11 * about the suitability of this software for any purpose.  It is provided
12 * "as is" without express or implied warranty.
13 *
14 * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
21 */
22
23#include <string.h>
24#include <stdlib.h>
25
26#ifdef HAVE_XAA_H
27#include "xaa.h"
28#endif
29
30#include "ast_pcirename.h"
31
32#include "compat-api.h"
33
34/* Compiler Options */
35#define	Accel_2D
36/* #define MMIO_2D */
37#define HWC
38#define AstVideo
39/* #define PATCH_ABI_VERSION */
40
41/* Vendor & Device Info */
42#ifndef PCI_VENDOR_AST
43#define PCI_VENDOR_AST			0x1A03
44#endif
45
46#ifndef	PCI_CHIP_AST2000
47#define PCI_CHIP_AST2000		0x2000
48#endif
49
50#ifndef	PCI_CHIP_AST2100
51#define PCI_CHIP_AST2100		0x2010
52#endif
53
54#ifndef	PCI_CHIP_AST1180
55#define PCI_CHIP_AST1180		0x1180
56#endif
57
58typedef enum _CHIP_ID {
59    VGALegacy,
60    AST2000,
61    AST2100,
62    AST1100,
63    AST2200,
64    AST2150,
65    AST2300,
66    AST1180
67} CHIP_ID;
68
69/* AST REC Info */
70#define AST_NAME 			"AST"
71#define AST_DRIVER_NAME 		"ast"
72#define AST_MAJOR_VERSION 		PACKAGE_VERSION_MAJOR
73#define AST_MINOR_VERSION 		PACKAGE_VERSION_MINOR
74#define AST_PATCH_VERSION		PACKAGE_VERSION_PATCHLEVEL
75#define AST_VERSION	\
76        ((AST_MAJOR_VERSION << 20) | (AST_MINOR_VERSION << 10) | AST_PATCH_VERSION)
77
78/* Customized Info */
79#define DEFAULT_VIDEOMEM_SIZE		0x00800000
80#define DEFAULT_MMIO_SIZE		0x00020000
81#define DEFAULT_CMDQ_SIZE		0x00100000
82#define MIN_CMDQ_SIZE			0x00040000
83#define CMD_QUEUE_GUARD_BAND    	0x00000020
84#define DEFAULT_HWC_NUM			0x00000002
85
86/* Patch Info */
87#define ABI_VIDEODRV_VERSION_PATCH	SET_ABI_VERSION(0, 5)
88
89/* Data Type Definition */
90typedef INT32  		LONG;
91typedef CARD8   	UCHAR;
92typedef CARD16  	USHORT;
93typedef CARD32  	ULONG;
94
95/* Data Structure Definition */
96typedef struct _ASTRegRec {
97
98    UCHAR 	ExtCRTC[0x50];
99
100    UCHAR 	MISC;
101    UCHAR 	SEQ[4];
102    UCHAR 	CRTC[25];
103    UCHAR 	AR[20];
104    UCHAR 	GR[9];
105    UCHAR	DAC[256][3];
106
107    ULONG	GFX[12];
108
109} ASTRegRec, *ASTRegPtr;
110
111typedef struct _VIDEOMODE {
112
113    int			ScreenWidth;
114    int			ScreenHeight;
115    int			bitsPerPixel;
116    int			ScreenPitch;
117
118} VIDEOMODE, *PVIDEOMODE;
119
120typedef struct {
121
122    ULONG		ulCMDQSize;
123    ULONG		ulCMDQType;
124
125    ULONG		ulCMDQOffsetAddr;
126    UCHAR       	*pjCMDQVirtualAddr;
127
128    UCHAR       	*pjCmdQBasePort;
129    UCHAR       	*pjWritePort;
130    UCHAR       	*pjReadPort;
131    UCHAR       	*pjEngStatePort;
132
133    ULONG		ulCMDQMask;
134    ULONG		ulCurCMDQueueLen;
135
136    ULONG		ulWritePointer;
137    ULONG		ulReadPointer;
138
139    ULONG		ulReadPointer_OK;		/* for Eng_DBGChk */
140
141} CMDQINFO, *PCMDQINFO;
142
143typedef struct {
144
145    int			HWC_NUM;
146    int			HWC_NUM_Next;
147
148    ULONG		ulHWCOffsetAddr;
149    UCHAR       	*pjHWCVirtualAddr;
150
151    USHORT		cursortype;
152    USHORT		width;
153    USHORT   		height;
154    USHORT		offset_x;
155    USHORT   		offset_y;
156    ULONG		fg;
157    ULONG		bg;
158
159    UCHAR               cursorpattern[1024];
160
161} HWCINFO, *PHWCINFO;
162
163typedef struct _ASTPortPrivRec{
164    FBLinearPtr     linear;
165    FBAreaPtr       fbAreaPtr;
166    int             fbSize;
167    CARD32          bufAddr[2];
168
169    unsigned char   currentBuf;
170
171    short           drw_x, drw_y, drw_w, drw_h;
172    short           src_x, src_y, src_w, src_h;
173    int             id;
174    short           srcPitch, height;
175
176    INT32           brightness;
177    INT32           contrast;
178    INT32           saturation;
179    INT32           hue;
180
181    INT32           gammaR;
182    INT32           gammaG;
183    INT32           gammaB;
184
185    RegionRec       clip;
186    CARD32          colorKey;
187
188    CARD32          videoStatus;
189    Time            offTime;
190    Time            freeTime;
191
192    CARD32          displayMode;
193
194    int             pitch;
195    int             offset;
196} ASTPortPrivRec, *ASTPortPrivPtr;
197
198typedef struct _ASTRec {
199
200    EntityInfoPtr 	pEnt;
201#ifndef XSERVER_LIBPCIACCESS
202	pciVideoPtr		PciInfo;
203	PCITAG			PciTag;
204#else
205	struct pci_device       *PciInfo;
206#endif
207
208    OptionInfoPtr 	Options;
209    DisplayModePtr      ModePtr;
210    FBLinearPtr 	pCMDQPtr;
211#ifdef HAVE_XAA_H
212    XAAInfoRecPtr	AccelInfoPtr;
213#endif
214    xf86CursorInfoPtr   HWCInfoPtr;
215    FBLinearPtr 	pHWCPtr;
216
217    CloseScreenProcPtr CloseScreen;
218    ScreenBlockHandlerProcPtr BlockHandler;
219
220    UCHAR		jChipType;
221    UCHAR		jDRAMType;
222    ULONG		ulDRAMBusWidth  ;
223    ULONG		ulDRAMSize;
224    ULONG		ulVRAMSize;
225    ULONG		ulVRAMBase;
226    ULONG               ulMCLK;
227
228    Bool 		noAccel;
229    Bool 		noHWC;
230    Bool 		MMIO2D;
231    int			ENGCaps;
232    int			DBGSelect;
233    Bool		VGA2Clone;
234
235    ULONG     		FBPhysAddr;		/* Frame buffer physical address     */
236    ULONG     		MMIOPhysAddr;     	/* MMIO region physical address      */
237    ULONG     		BIOSPhysAddr;     	/* BIOS physical address             */
238
239    UCHAR     		*FBVirtualAddr;   	/* Map of frame buffer               */
240    UCHAR     		*MMIOVirtualAddr; 	/* Map of MMIO region                */
241
242    unsigned long	FbMapSize;
243    unsigned long	MMIOMapSize;
244
245    IOADDRESS		IODBase;        	/* Base of PIO memory area */
246    IOADDRESS		PIOOffset;
247    IOADDRESS		RelocateIO;
248
249    VIDEOMODE 		VideoModeInfo;
250    ASTRegRec           SavedReg;
251    CMDQINFO		CMDQInfo;
252    HWCINFO    		HWCInfo;
253    ULONG		ulCMDReg;
254    Bool		EnableClip;
255
256    int			clip_left;
257    int			clip_top;
258    int			clip_right;
259    int			clip_bottom;
260
261    int			mon_h_active;		/* Monitor Info. */
262    int			mon_v_active;
263
264#ifdef AstVideo
265    XF86VideoAdaptorPtr adaptor;
266    Atom        	xvBrightness, xvContrast, xvColorKey, xvHue, xvSaturation;
267    Atom		xvGammaRed, xvGammaGreen, xvGammaBlue;
268#endif
269
270} ASTRec, *ASTRecPtr, *ASTPtr;
271
272#define ASTPTR(p) ((ASTRecPtr)((p)->driverPrivate))
273
274/* Include Files */
275#include "ast_mode.h"
276#include "ast_vgatool.h"
277#include "ast_2dtool.h"
278#include "ast_cursor.h"
279