geode.h revision 7aef237f
1 /* 2 * (c) 2006-2008 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 * DEALINGS IN THE SOFTWARE. 21 * 22 * Neither the name of the Advanced Micro Devices, Inc. nor the names of its 23 * contributors may be used to endorse or promote products derived from this 24 * software without specific prior written permission. 25 */ 26 27#ifndef _GEODE_H_ 28#define _GEODE_H_ 29 30#include "geode_pcirename.h" 31#include "config.h" 32 33#include "xaa.h" 34#include "exa.h" 35#include "xf86Cursor.h" 36 37#include "vgaHW.h" 38#include "xf86int10.h" 39#include <X11/extensions/randr.h> 40#include "randrstr.h" 41 42#include "xf86xv.h" 43 44/* We only support EXA version >=2 */ 45 46#if (EXA_VERSION_MAJOR >= 2) 47#ifndef XF86EXA 48#define XF86EXA 1 49#endif 50#else 51#undef XF86EXA 52#endif 53 54#define CFB 0 55#define INT10_SUPPORT 1 56 57/* Existing Processor Models */ 58#define GX1 0x01 59#define GX 0x10 60#define LX 0x20 61 62#define PCI_VENDOR_ID_CYRIX 0x1078 63#define PCI_VENDOR_ID_NS 0x100b 64#define PCI_VENDOR_ID_AMD 0x1022 65 66#define PCI_CHIP_5530 0x0104 67#define PCI_CHIP_SC1200 0x0504 68#define PCI_CHIP_SC1400 0x0104 69#define PCI_CHIP_GEODEGX 0x0030 70#define PCI_CHIP_GEODELX 0x2081 71 72#define GFX_CPU_GEODELX 4 73 74#ifdef HAVE_GX 75#define GX_FILL_RECT_SUPPORT 1 76#define GX_BRES_LINE_SUPPORT 1 77#define GX_DASH_LINE_SUPPORT 0 /* does not do dashed lines */ 78#define GX_MONO_8X8_PAT_SUPPORT 1 79#define GX_CLREXP_8X8_PAT_SUPPORT 1 80#define GX_SCR2SCREXP_SUPPORT 1 81#define GX_SCR2SCRCPY_SUPPORT 1 82#define GX_CPU2SCREXP_SUPPORT 1 83#define GX_SCANLINE_SUPPORT 1 84#define GX_USE_OFFSCRN_MEM 0 85#define GX_ONE_LINE_AT_A_TIME 1 86#define GX_WRITE_PIXMAP_SUPPORT 1 87 88#define GFX(func) gfx_##func 89#define GFX2(func) gfx2_##func 90#endif 91 92#define GEODEPTR(p) ((GeodeRec *)((p)->driverPrivate)) 93 94#define DEFAULT_EXA_SCRATCH_BFRSZ 0x40000 95 96/* the LX hardware (and Cimarron) require a cursor memory size of 48x64.. */ 97#define LX_CURSOR_HW_WIDTH 48 98#define LX_CURSOR_HW_HEIGHT 64 99 100/* ...but xorg requires the cursor width to be a multiple of 32. This is 101the size of the *actual* cursor. */ 102#define LX_CURSOR_MAX_WIDTH 32 103#define LX_CURSOR_MAX_HEIGHT 32 104 105/* FIXME: Get rid of this from GX */ 106 107#define DEBUGMSG(cond, drv_msg) 108 109#ifdef HAVE_LX 110extern unsigned char cim_inb(unsigned short port); 111extern void cim_outb(unsigned short port, unsigned char data); 112extern unsigned short cim_inw(unsigned short port); 113extern void cim_outw(unsigned short port, unsigned short data); 114extern unsigned long cim_ind(unsigned short port); 115extern void cim_outd(unsigned short port, unsigned long data); 116 117#include "cim_rtns.h" 118 119typedef struct _CIM_DISPLAYTIMING 120{ 121 unsigned short wPitch; 122 unsigned short wBpp; 123 VG_DISPLAY_MODE vgDisplayMode; 124} CIM_DISPLAYTIMING; 125 126#endif 127 128#ifdef HAVE_GX 129extern void gfx_write_reg32(int offset, int data); 130extern void gfx_write_reg16(int offset, short data); 131extern void gfx_write_reg8(int offset, char data); 132extern int gfx_read_reg32(int offset); 133extern short gfx_read_reg16(int offset); 134extern void gfx_write_vid32(int offset, int data); 135extern int gfx_read_vid32(int offset); 136extern unsigned char gfx_inb(unsigned short port); 137extern void gfx_outb(unsigned short port, unsigned char data); 138extern unsigned short gfx_inw(unsigned short port); 139extern void gfx_outw(unsigned short port, unsigned short data); 140extern unsigned long gfx_ind(unsigned short port); 141extern void gfx_outd(unsigned short port, unsigned long data); 142 143#define Q_WORD QQ_WORD 144#include "gfx_rtns.h" 145#undef Q_WORD 146#include "panel.h" 147 148typedef struct tag_GFX_DISPLAYTIMING 149{ 150 unsigned int dwDotClock; 151 unsigned short wPitch; 152 unsigned short wBpp; 153 unsigned short wHTotal; 154 unsigned short wHActive; 155 unsigned short wHSyncStart; 156 unsigned short wHSyncEnd; 157 unsigned short wHBlankStart; 158 unsigned short wHBlankEnd; 159 unsigned short wVTotal; 160 unsigned short wVActive; 161 unsigned short wVSyncStart; 162 unsigned short wVSyncEnd; 163 unsigned short wVBlankStart; 164 unsigned short wVBlankEnd; 165 unsigned short wPolarity; 166} GFX_DISPLAYTIMING; 167 168#endif 169 170typedef struct _VESARec 171{ 172 xf86Int10InfoPtr pInt; 173} VESARec; 174 175typedef struct _GeodeMemRec 176{ 177 struct _GeodeMemRec *next; 178 struct _GeodeMemRec *prev; 179 unsigned int offset; 180 int size; 181} GeodeMemRec, *GeodeMemPtr; 182 183#define OUTPUT_PANEL 0x01 184#define OUTPUT_CRT 0x02 185#define OUTPUT_TV 0x04 186#define OUTPUT_VOP 0x08 187#define OUTPUT_DCON 0x10 188 189typedef struct _geodeRec 190{ 191 /* Common for both GX and LX */ 192 int Output; /* Bitmask indicating the valid output options */ 193 Bool HWCursor; 194 Bool NoAccel; 195 Bool useVGA; 196 Bool VGAActive; /* Flag indicating if LX VGA is active */ 197 Bool Compression; 198 Bool useEXA; 199 200 int rotation; 201 int displayWidth; 202 Bool starting; 203 Bool tryCompression; 204 Bool tryHWCursor; 205 206 int mm_width, mm_height; /* physical display size */ 207 208 unsigned long CursorStartOffset; 209 210 int Pitch; /* display FB pitch */ 211 int displaySize; /* The size of the visibile area */ 212 213 ExaOffscreenArea *shadowArea; 214 215 /* Framebuffer memory */ 216 217 unsigned char *FBBase; 218 unsigned int FBAvail; 219 220 /* EXA structures */ 221 222 ExaDriverPtr pExa; 223 unsigned int exaBfrOffset; 224 unsigned int exaBfrSz; 225 226 /* Other structures */ 227 228 EntityInfoPtr pEnt; 229 ScreenBlockHandlerProcPtr BlockHandler; /* needed for video */ 230 XF86VideoAdaptorPtr adaptor; 231 232 /* State save structures */ 233 unsigned long FBDisplayOffset; 234 unsigned long PrevDisplayOffset; 235 236 VESARec *vesa; 237 238 int FBCompressionEnable; 239 240 VG_CURSOR_DATA FBCursor; 241 242 /* Save the Cursor offset of the FB */ 243 unsigned long FBCursorOffset; 244 unsigned char FBBIOSMode; 245 246 /* Hooks */ 247 248 void (*PointerMoved) (int index, int x, int y); 249 CloseScreenProcPtr CloseScreen; 250 Bool(*CreateScreenResources) (ScreenPtr); 251 252 /* ===== LX specific items ===== */ 253 254 /* Flags */ 255 Bool Scale; 256 257 DisplayModePtr panelMode; /* The mode for the panel (if attached) */ 258 259 /* Command buffer information */ 260 unsigned long CmdBfrOffset; 261 unsigned long CmdBfrSize; 262 263 /* Memory Management */ 264 GeodeMemPtr offscreenList; 265 unsigned int offscreenStart; 266 unsigned int offscreenSize; 267 268 /* Save state */ 269 VG_COMPRESSION_DATA CBData; 270 VG_COMPRESSION_DATA FBCBData; 271 CIM_DISPLAYTIMING FBcimdisplaytiming; 272 273 /* ===== GX specific items ===== */ 274 275 /* Flags */ 276 Bool Panel; 277 278 int PanelX; 279 int PanelY; 280 281 int displayPitch; /* The pitch ofthe visible area */ 282 int displayOffset; /* The offset of the visible area */ 283 284 DisplayModePtr curMode; 285 286 unsigned int shadowSize; 287 unsigned int shadowOffset; 288 289 int FBVGAActive; 290 291 xf86CursorInfoPtr CursorInfo; 292 293 /* XAA structures */ 294 295 unsigned int cpySrcOffset; 296 int cpySrcPitch, cpySrcBpp; 297 int cpyDx, cpyDy; 298 unsigned int cmpSrcOffset; 299 int cmpSrcPitch, cmpSrcBpp; 300 unsigned int cmpSrcFmt, cmpDstFmt; 301 int cmpOp; 302 303 unsigned char **AccelImageWriteBuffers; 304 int NoOfImgBuffers; 305 unsigned char **AccelColorExpandBuffers; 306 int NoOfColorExpandLines; 307 XAAInfoRecPtr AccelInfoRec; 308 309 /* Save state */ 310 unsigned long FBCompressionOffset; 311 unsigned short FBCompressionPitch; 312 unsigned short FBCompressionSize; 313 GFX_DISPLAYTIMING FBgfxdisplaytiming; 314 315 /* Hooks */ 316 void (*WritePixmap) (ScrnInfoPtr pScrni, int x, int y, int w, int h, 317 unsigned char *src, int srcwidth, int rop, 318 unsigned int planemask, int trans, int bpp, int depth); 319 320 /* Video information */ 321 int video_x; 322 int video_y; 323 short video_w; 324 short video_h; 325 short video_srcw; 326 short video_srch; 327 short video_dstw; 328 short video_dsth; 329 int video_id; 330 int video_offset; 331 ScrnInfoPtr video_scrnptr; 332 BOOL OverlayON; 333} 334GeodeRec, *GeodePtr; 335 336/* option flags are self-explanatory */ 337#ifdef HAVE_LX 338enum 339{ 340 LX_OPTION_SW_CURSOR, 341 LX_OPTION_HW_CURSOR, 342 LX_OPTION_NOCOMPRESSION, 343 LX_OPTION_NOACCEL, 344 LX_OPTION_EXA_SCRATCH_BFRSZ, 345 LX_OPTION_TV_SUPPORT, 346 LX_OPTION_TV_OUTPUT, 347 LX_OPTION_TV_OVERSCAN, 348 LX_OPTION_ROTATE, 349 LX_OPTION_NOPANEL, 350 LX_OPTION_FBSIZE, 351 LX_OPTION_PANEL_MODE, 352 LX_OPTION_DONT_PROGRAM 353} 354LX_GeodeOpts; 355#endif 356 357#ifdef HAVE_GX 358enum 359{ 360 GX_OPTION_SW_CURSOR, 361 GX_OPTION_HW_CURSOR, 362 GX_OPTION_NOCOMPRESSION, 363 GX_OPTION_NOACCEL, 364 GX_OPTION_ACCEL_METHOD, 365 GX_OPTION_EXA_SCRATCH_BFRSZ, 366 GX_OPTION_TV_SUPPORT, 367 GX_OPTION_TV_OUTPUT, 368 GX_OPTION_TV_OVERSCAN, 369 GX_OPTION_ROTATE, 370 GX_OPTION_NOPANEL, 371 GX_OPTION_OSM_IMG_BUFS, 372 GX_OPTION_OSM_CLR_BUFS, 373 GX_OPTION_FBSIZE, 374 GX_OPTION_PANEL_GEOMETRY, 375 GX_OPTION_DONT_PROGRAM 376} 377GX_GeodeOpts; 378#endif 379 380/* geode_dcon.c */ 381extern Bool dcon_init(ScrnInfoPtr pScrni); 382extern int DCONDPMSSet(ScrnInfoPtr pScrni, int mode); 383 384/* geode_common.c */ 385 386void geode_memory_to_screen_blt(unsigned long, unsigned long, 387 unsigned long, unsigned long, long, long, int); 388int GeodeGetRefreshRate(DisplayModePtr); 389void GeodeCopyGreyscale(unsigned char *, unsigned char *, int, int, int, int); 390int GeodeGetSizeFromFB(unsigned int *); 391 392/* gx_video.c */ 393 394int 395GeodeQueryImageAttributes(ScrnInfoPtr, int id, unsigned short *w, 396 unsigned short *h, int *pitches, int *offsets); 397 398Bool RegionsEqual(RegionPtr A, RegionPtr B); 399 400/* gx_driver.c */ 401 402void GeodeProbeDDC(ScrnInfoPtr pScrni, int index); 403xf86MonPtr GeodeDoDDC(ScrnInfoPtr pScrni, int index); 404Bool GeodeI2CInit(ScrnInfoPtr pScrni, I2CBusPtr * ptr, char *name); 405 406int GeodeGetFPGeometry(const char *str, int *width, int *height); 407void GeodePointerMoved(int index, int x, int y); 408void GeodeFreeScreen(int scrnIndex, int flags); 409int GeodeCalculatePitchBytes(unsigned int width, unsigned int bpp); 410void GXSetupChipsetFPtr(ScrnInfoPtr pScrn); 411 412/* geode_msr.c */ 413int GeodeReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi); 414int GeodeWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi); 415 416/* gx_cursor.c */ 417Bool GXHWCursorInit(ScreenPtr pScrn); 418void GXLoadCursorImage(ScrnInfoPtr pScrni, unsigned char *src); 419void GXHideCursor(ScrnInfoPtr pScrni); 420void GXShowCursor(ScrnInfoPtr pScrni); 421 422/* gx_randr.c */ 423Rotation GXGetRotation(ScreenPtr pScreen); 424Bool GXRandRInit(ScreenPtr pScreen, int rotation); 425extern _X_EXPORT Bool GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation, 426 int rate, RRScreenSizePtr pSize); 427 428/* gx_rotate.c */ 429Bool GXRotate(ScrnInfoPtr pScrni, DisplayModePtr mode); 430 431/* gx_accel.c */ 432Bool GXAccelInit(ScreenPtr pScrn); 433void GXAccelSync(ScrnInfoPtr pScrni); 434 435/* gx_video.c */ 436void GXInitVideo(ScreenPtr pScrn); 437 438/* lx_driver.c */ 439void LXSetupChipsetFPtr(ScrnInfoPtr pScrn); 440 441/* lx_cursor.c */ 442Bool LXHWCursorInit(ScreenPtr pScrn); 443void LXLoadARGBCursorImage(ScrnInfoPtr pScrni, unsigned char *src); 444void LXHideCursor(ScrnInfoPtr pScrni); 445void LXShowCursor(ScrnInfoPtr pScrni); 446 447/* lx_exa.c */ 448Bool LXExaInit(ScreenPtr pScreen); 449 450/* lx_video.c */ 451void LXInitVideo(ScreenPtr pScrn); 452 453/* lx_output.c */ 454void LXSetupOutput(ScrnInfoPtr); 455 456/* lx_panel.c */ 457DisplayModePtr LXGetLegacyPanelMode(ScrnInfoPtr pScrni); 458DisplayModePtr LXGetManualPanelMode(char *modestr); 459 460void LXAdjustFrame(int scrnIndex, int x, int y, int flags); 461 462/* lx_display.c */ 463void LXSetupCrtc(ScrnInfoPtr pScrni); 464 465/* lx_memory.c */ 466GeodeMemPtr GeodeAllocOffscreen(GeodeRec * pGeode, int size, int align); 467void GeodeFreeOffscreen(GeodeRec * pGeode, GeodeMemPtr ptr); 468void LXInitOffscreen(ScrnInfoPtr pScrni); 469void GeodeCloseOffscreen(ScrnInfoPtr pScrni); 470unsigned int GeodeOffscreenFreeSize(GeodeRec * pGeode); 471 472/* lx_cursor.c */ 473Bool LXCursorInit(ScreenPtr pScrn); 474 475#endif 476