ast.h revision b534f209
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#include "ast_pcirename.h"
27
28/* Compiler Options */
29#define	Accel_2D
30/* #define MMIO_2D */
31#define HWC
32#define AstVideo
33/* #define PATCH_ABI_VERSION */
34
35/* Vendor & Device Info */
36#ifndef PCI_VENDOR_AST
37#define PCI_VENDOR_AST			0x1A03
38#endif
39
40#ifndef	PCI_CHIP_AST2000
41#define PCI_CHIP_AST2000		0x2000
42#endif
43
44#ifndef	PCI_CHIP_AST2100
45#define PCI_CHIP_AST2100		0x2010
46#endif
47
48#ifndef	PCI_CHIP_AST1180
49#define PCI_CHIP_AST1180		0x1180
50#endif
51
52typedef enum _CHIP_ID {
53    VGALegacy,
54    AST2000,
55    AST2100,
56    AST1100,
57    AST2200,
58    AST2150,
59    AST2300,
60    AST1180
61} CHIP_ID;
62
63/* AST REC Info */
64#define AST_NAME 			"AST"
65#define AST_DRIVER_NAME 		"ast"
66#define AST_MAJOR_VERSION 		PACKAGE_VERSION_MAJOR
67#define AST_MINOR_VERSION 		PACKAGE_VERSION_MINOR
68#define AST_PATCH_VERSION		PACKAGE_VERSION_PATCHLEVEL
69#define AST_VERSION	\
70        ((AST_MAJOR_VERSION << 20) | (AST_MINOR_VERSION << 10) | AST_PATCH_VERSION)
71
72/* Customized Info */
73#define DEFAULT_VIDEOMEM_SIZE		0x00800000
74#define DEFAULT_MMIO_SIZE		0x00020000
75#define DEFAULT_CMDQ_SIZE		0x00100000
76#define MIN_CMDQ_SIZE			0x00040000
77#define CMD_QUEUE_GUARD_BAND    	0x00000020
78#define DEFAULT_HWC_NUM			0x00000002
79
80/* Patch Info */
81#define ABI_VIDEODRV_VERSION_PATCH	SET_ABI_VERSION(0, 5)
82
83/* Data Type Definition */
84typedef INT32  		LONG;
85typedef CARD8   	UCHAR;
86typedef CARD16  	USHORT;
87typedef CARD32  	ULONG;
88
89/* Data Structure Definition */
90typedef struct _ASTRegRec {
91    UCHAR 	ExtCRTC[0x50];
92    ULONG	GFX[12];
93} ASTRegRec, *ASTRegPtr;
94
95typedef struct _VIDEOMODE {
96
97    int			ScreenWidth;
98    int			ScreenHeight;
99    int			bitsPerPixel;
100    int			ScreenPitch;
101
102} VIDEOMODE, *PVIDEOMODE;
103
104typedef struct {
105
106    ULONG		ulCMDQSize;
107    ULONG		ulCMDQType;
108
109    ULONG		ulCMDQOffsetAddr;
110    UCHAR       	*pjCMDQVirtualAddr;
111
112    UCHAR       	*pjCmdQBasePort;
113    UCHAR       	*pjWritePort;
114    UCHAR       	*pjReadPort;
115    UCHAR       	*pjEngStatePort;
116
117    ULONG		ulCMDQMask;
118    ULONG		ulCurCMDQueueLen;
119
120    ULONG		ulWritePointer;
121    ULONG		ulReadPointer;
122
123    ULONG		ulReadPointer_OK;		/* for Eng_DBGChk */
124
125} CMDQINFO, *PCMDQINFO;
126
127typedef struct {
128
129    int			HWC_NUM;
130    int			HWC_NUM_Next;
131
132    ULONG		ulHWCOffsetAddr;
133    UCHAR       	*pjHWCVirtualAddr;
134
135    USHORT		cursortype;
136    USHORT		width;
137    USHORT   		height;
138    USHORT		offset_x;
139    USHORT   		offset_y;
140    ULONG		fg;
141    ULONG		bg;
142
143    UCHAR               cursorpattern[1024];
144
145} HWCINFO, *PHWCINFO;
146
147typedef struct _ASTPortPrivRec{
148    FBLinearPtr     linear;
149    FBAreaPtr       fbAreaPtr;
150    int             fbSize;
151    CARD32          bufAddr[2];
152
153    unsigned char   currentBuf;
154
155    short           drw_x, drw_y, drw_w, drw_h;
156    short           src_x, src_y, src_w, src_h;
157    int             id;
158    short           srcPitch, height;
159
160    INT32           brightness;
161    INT32           contrast;
162    INT32           saturation;
163    INT32           hue;
164
165    INT32           gammaR;
166    INT32           gammaG;
167    INT32           gammaB;
168
169    RegionRec       clip;
170    CARD32          colorKey;
171
172    CARD32          videoStatus;
173    Time            offTime;
174    Time            freeTime;
175
176    CARD32          displayMode;
177
178    int             pitch;
179    int             offset;
180} ASTPortPrivRec, *ASTPortPrivPtr;
181
182typedef struct _ASTRec {
183
184    EntityInfoPtr 	pEnt;
185#ifndef XSERVER_LIBPCIACCESS
186	pciVideoPtr		PciInfo;
187	PCITAG			PciTag;
188#else
189	struct pci_device       *PciInfo;
190#endif
191
192    OptionInfoPtr 	Options;
193    DisplayModePtr      ModePtr;
194    FBLinearPtr 	pCMDQPtr;
195    XAAInfoRecPtr	AccelInfoPtr;
196    xf86CursorInfoPtr   HWCInfoPtr;
197    FBLinearPtr 	pHWCPtr;
198
199    CloseScreenProcPtr CloseScreen;
200    ScreenBlockHandlerProcPtr BlockHandler;
201
202    UCHAR		jChipType;
203    UCHAR		jDRAMType;
204    ULONG		ulDRAMBusWidth  ;
205    ULONG		ulDRAMSize;
206    ULONG		ulVRAMSize;
207    ULONG		ulVRAMBase;
208    ULONG               ulMCLK;
209
210    Bool 		noAccel;
211    Bool 		noHWC;
212    Bool 		MMIO2D;
213    int			ENGCaps;
214    int			DBGSelect;
215    Bool		VGA2Clone;
216
217    ULONG     		FBPhysAddr;		/* Frame buffer physical address     */
218    ULONG     		MMIOPhysAddr;     	/* MMIO region physical address      */
219    ULONG     		BIOSPhysAddr;     	/* BIOS physical address             */
220
221    UCHAR     		*FBVirtualAddr;   	/* Map of frame buffer               */
222    UCHAR     		*MMIOVirtualAddr; 	/* Map of MMIO region                */
223
224    unsigned long	FbMapSize;
225    unsigned long	MMIOMapSize;
226
227    IOADDRESS		IODBase;        	/* Base of PIO memory area */
228    IOADDRESS		PIOOffset;
229    IOADDRESS		RelocateIO;
230
231    VIDEOMODE 		VideoModeInfo;
232    ASTRegRec           SavedReg;
233    CMDQINFO		CMDQInfo;
234    HWCINFO    		HWCInfo;
235    ULONG		ulCMDReg;
236    Bool		EnableClip;
237
238    int			clip_left;
239    int			clip_top;
240    int			clip_right;
241    int			clip_bottom;
242
243    int			mon_h_active;		/* Monitor Info. */
244    int			mon_v_active;
245
246#ifdef AstVideo
247    XF86VideoAdaptorPtr adaptor;
248    Atom        	xvBrightness, xvContrast, xvColorKey, xvHue, xvSaturation;
249    Atom		xvGammaRed, xvGammaGreen, xvGammaBlue;
250#endif
251
252} ASTRec, *ASTRecPtr, *ASTPtr;
253
254#define ASTPTR(p) ((ASTRecPtr)((p)->driverPrivate))
255
256/* Include Files */
257#include "ast_mode.h"
258#include "ast_vgatool.h"
259#include "ast_2dtool.h"
260#include "ast_cursor.h"
261