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#ifndef _AST_H_ 24# define _AST_H_ 25 26/* Compiler Options */ 27#define Accel_2D 28/* #define MMIO_2D */ 29#define HWC 30#define AstVideo 31/* #define PATCH_ABI_VERSION */ 32#define Support_ShadowFB 33 34#include <string.h> 35#include <stdlib.h> 36 37#ifdef HAVE_XAA_H 38#include "xaa.h" 39#endif 40 41#include "ast_pcirename.h" 42 43#include "compat-api.h" 44 45#ifdef Support_ShadowFB 46#include "shadow.h" 47#endif 48 49/* Vendor & Device Info */ 50#ifndef PCI_VENDOR_AST 51#define PCI_VENDOR_AST 0x1A03 52#endif 53 54#ifndef PCI_CHIP_AST2000 55#define PCI_CHIP_AST2000 0x2000 56#endif 57 58#ifndef PCI_CHIP_AST2100 59#define PCI_CHIP_AST2100 0x2010 60#endif 61 62#ifndef PCI_CHIP_AST1180 63#define PCI_CHIP_AST1180 0x1180 64#endif 65 66typedef enum _CHIP_ID { 67 VGALegacy, 68 AST2000, 69 AST2100, 70 AST1100, 71 AST2200, 72 AST2150, 73 AST2300, 74 AST2400, 75 AST2500, 76 AST1180 77} CHIP_ID; 78 79typedef enum _TX_CHIPTYPE { 80 Tx_NONE, 81 Tx_Sil164, 82 Tx_Ite66121, 83 Tx_DP501 84} TX_CHIPTYPE; 85 86/* AST REC Info */ 87#define AST_NAME "AST" 88#define AST_DRIVER_NAME "ast" 89#define AST_MAJOR_VERSION PACKAGE_VERSION_MAJOR 90#define AST_MINOR_VERSION PACKAGE_VERSION_MINOR 91#define AST_PATCH_VERSION PACKAGE_VERSION_PATCHLEVEL 92#define AST_VERSION \ 93 ((AST_MAJOR_VERSION << 20) | (AST_MINOR_VERSION << 10) | AST_PATCH_VERSION) 94 95/* Customized Info */ 96#define DEFAULT_VIDEOMEM_SIZE 0x00800000 97#define DEFAULT_MMIO_SIZE 0x00020000 98#define DEFAULT_CMDQ_SIZE 0x00100000 99#define MIN_CMDQ_SIZE 0x00040000 100#define CMD_QUEUE_GUARD_BAND 0x00000020 101#define DEFAULT_HWC_NUM 0x00000002 102 103/* Customized Info. for DVO */ 104#define HDMI_I2C_CHANNEL 1 105#define HDMI_TX_I2C_SLAVE_ADDR 0x98 106 107/* Patch Info */ 108#define ABI_VIDEODRV_VERSION_PATCH SET_ABI_VERSION(0, 5) 109 110/* Data Type Definition */ 111typedef INT32 LONG; 112typedef CARD8 UCHAR; 113typedef CARD16 USHORT; 114typedef CARD32 ULONG; 115 116/* Data Structure Definition */ 117typedef struct _ASTRegRec { 118 119 UCHAR ExtCRTC[0x50]; 120 121 UCHAR MISC; 122 UCHAR SEQ[4]; 123 UCHAR CRTC[25]; 124 UCHAR AR[20]; 125 UCHAR GR[9]; 126 UCHAR DAC[256][3]; 127 128 ULONG GFX[12]; 129 130 UCHAR REGA4; 131 ULONG ENG8044; 132} ASTRegRec, *ASTRegPtr; 133 134typedef struct _VIDEOMODE { 135 136 int ScreenWidth; 137 int ScreenHeight; 138 int bitsPerPixel; 139 int ScreenPitch; 140 141} VIDEOMODE, *PVIDEOMODE; 142 143typedef struct { 144 145 ULONG ulCMDQSize; 146 ULONG ulCMDQType; 147 148 ULONG ulCMDQOffsetAddr; 149 UCHAR *pjCMDQVirtualAddr; 150 151 UCHAR *pjCmdQBasePort; 152 UCHAR *pjWritePort; 153 UCHAR *pjReadPort; 154 UCHAR *pjEngStatePort; 155 156 ULONG ulCMDQMask; 157 ULONG ulCurCMDQueueLen; 158 159 ULONG ulWritePointer; 160 ULONG ulReadPointer; 161 162 ULONG ulReadPointer_OK; /* for Eng_DBGChk */ 163 164} CMDQINFO, *PCMDQINFO; 165 166typedef struct { 167 168 int HWC_NUM; 169 int HWC_NUM_Next; 170 171 ULONG ulHWCOffsetAddr; 172 UCHAR *pjHWCVirtualAddr; 173 174 USHORT cursortype; 175 USHORT width; 176 USHORT height; 177 USHORT offset_x; 178 USHORT offset_y; 179 ULONG fg; 180 ULONG bg; 181 182 UCHAR cursorpattern[1024]; 183 184} HWCINFO, *PHWCINFO; 185 186typedef struct _ASTPortPrivRec{ 187 FBLinearPtr linear; 188 FBAreaPtr fbAreaPtr; 189 int fbSize; 190 CARD32 bufAddr[2]; 191 192 unsigned char currentBuf; 193 194 short drw_x, drw_y, drw_w, drw_h; 195 short src_x, src_y, src_w, src_h; 196 int id; 197 short srcPitch, height; 198 199 INT32 brightness; 200 INT32 contrast; 201 INT32 saturation; 202 INT32 hue; 203 204 INT32 gammaR; 205 INT32 gammaG; 206 INT32 gammaB; 207 208 RegionRec clip; 209 CARD32 colorKey; 210 211 CARD32 videoStatus; 212 Time offTime; 213 Time freeTime; 214 215 CARD32 displayMode; 216 217 int pitch; 218 int offset; 219} ASTPortPrivRec, *ASTPortPrivPtr; 220 221typedef struct _ASTRec { 222 223 EntityInfoPtr pEnt; 224#ifndef XSERVER_LIBPCIACCESS 225 pciVideoPtr PciInfo; 226 PCITAG PciTag; 227#else 228 struct pci_device *PciInfo; 229#endif 230 231 OptionInfoPtr Options; 232 DisplayModePtr ModePtr; 233 FBLinearPtr pCMDQPtr; 234#ifdef HAVE_XAA_H 235 XAAInfoRecPtr AccelInfoPtr; 236#endif 237 xf86CursorInfoPtr HWCInfoPtr; 238 FBLinearPtr pHWCPtr; 239 240 CloseScreenProcPtr CloseScreen; 241 ScreenBlockHandlerProcPtr BlockHandler; 242 243 UCHAR jChipType; 244 UCHAR jDRAMType; 245 ULONG ulDRAMBusWidth ; 246 ULONG ulDRAMSize; 247 ULONG ulVRAMSize; 248 ULONG ulVRAMBase; 249 ULONG ulMCLK; 250 251 Bool noAccel; 252 Bool noHWC; 253 Bool MMIO2D; 254 int ENGCaps; 255 int DBGSelect; 256 Bool VGA2Clone; 257 Bool SupportWideScreen; 258 259 ULONG FBPhysAddr; /* Frame buffer physical address */ 260 ULONG MMIOPhysAddr; /* MMIO region physical address */ 261 ULONG BIOSPhysAddr; /* BIOS physical address */ 262 263 UCHAR *FBVirtualAddr; /* Map of frame buffer */ 264 UCHAR *MMIOVirtualAddr; /* Map of MMIO region */ 265 266 unsigned long FbMapSize; 267 unsigned long MMIOMapSize; 268 269#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12 270 IOADDRESS RelocateIO; 271#else 272 int RelocateIO; 273#endif 274 275 VIDEOMODE VideoModeInfo; 276 ASTRegRec SavedReg; 277 CMDQINFO CMDQInfo; 278 HWCINFO HWCInfo; 279 ULONG ulCMDReg; 280 Bool EnableClip; 281 282 int clip_left; 283 int clip_top; 284 int clip_right; 285 int clip_bottom; 286 287 int mon_h_active; /* Monitor Info. */ 288 int mon_v_active; 289 290 UCHAR jTxChipType; /* 3rd TX */ 291 UCHAR DP501_MaxVCLK; 292 UCHAR *pDP501FWBufferVirtualAddress; 293 294#ifdef AstVideo 295 XF86VideoAdaptorPtr adaptor; 296 Atom xvBrightness, xvContrast, xvColorKey, xvHue, xvSaturation; 297 Atom xvGammaRed, xvGammaGreen, xvGammaBlue; 298#endif 299 300#ifdef Support_ShadowFB 301 Bool shadowFB; 302 Bool shadowFB_validation; 303 void *shadow; 304 ShadowUpdateProc update; 305 ShadowWindowProc window; 306 CreateScreenResourcesProcPtr CreateScreenResources; 307#endif 308 309} ASTRec, *ASTRecPtr, *ASTPtr; 310 311#define ASTPTR(p) ((ASTRecPtr)((p)->driverPrivate)) 312 313/* ast_vgatool.c */ 314extern Bool bASTIsVGAEnabled(ScrnInfoPtr pScrn); 315extern Bool ASTGetVGA2EDID(ScrnInfoPtr pScrn, unsigned char *pEDIDBuffer); 316extern void ASTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags); 317extern void vASTLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual); 318extern void ASTBlankScreen(ScrnInfoPtr pScreen, Bool unblack); 319extern void vAST1000DisplayOn(ScrnInfoPtr pScrn); 320extern void vAST1000DisplayOff(ScrnInfoPtr pScrn); 321extern void vASTSetStartAddressCRT1(ASTRecPtr pAST, ULONG base); 322extern void ASTGetScratchOptions(ScrnInfoPtr pScrn); 323void ASTGetChipType(ScrnInfoPtr pScrn); 324ULONG ASTGetMaxDCLK(ScrnInfoPtr pScrn); 325ULONG ASTGetVRAMInfo(ScrnInfoPtr pScrn); 326void ASTGetDRAMInfo(ScrnInfoPtr pScrn); 327Bool bASTRegInit(ScrnInfoPtr pScrn); 328void vASTOpenKey(ScrnInfoPtr pScrn); 329Bool ASTReadEDID_M68K(ScrnInfoPtr pScrn, BYTE *pEDIDData); 330UCHAR ASTGetLinkMaxCLK(ScrnInfoPtr pScrn); 331Bool ASTGetVGAEDID(ScrnInfoPtr pScrn, unsigned char *pEDIDBuffer); 332Bool bASTInitAST1180(ScrnInfoPtr pScrn); 333void ASTGetAST1180DRAMInfo(ScrnInfoPtr pScrn); 334void vASTEnableVGAMMIO(ScrnInfoPtr pScrn); 335Bool ASTInitVGA(ScrnInfoPtr pScrn, ULONG Flags); 336 337/* ast_2dtool.c */ 338void vASTWaitEngIdle(ScrnInfoPtr pScrn, ASTRecPtr pAST); 339UCHAR *pASTjRequestCMDQ(ASTRecPtr pAST, ULONG ulDataLen); 340Bool bASTEnable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST); 341void vASTDisable2D(ScrnInfoPtr pScrn, ASTRecPtr pAST); 342 343/* ast_cursor.c */ 344#ifdef HWC 345Bool ASTCursorInit(ScreenPtr pScreen); 346Bool bASTInitHWC(ScrnInfoPtr pScrn, ASTRecPtr pAST); 347void ASTDisableHWC(ScrnInfoPtr pScrn); 348#endif 349 350/* ast_mode.c */ 351Bool ASTSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode); 352 353/* ast_accel.c */ 354#ifdef HAVE_XAA_H 355Bool ASTAccelInit(ScreenPtr pScreen); 356#endif 357void ASTDisplayVideo(ScrnInfoPtr pScrn, ASTPortPrivPtr pPriv, RegionPtr clipBoxes, int id); 358 359/* ast_tool.c */ 360Bool ASTMapMem(ScrnInfoPtr pScrn); 361Bool ASTUnmapMem(ScrnInfoPtr pScrn); 362Bool ASTMapMMIO(ScrnInfoPtr pScrn); 363void ASTUnmapMMIO(ScrnInfoPtr pScrn); 364 365#endif /* _AST_H_ */ 366