geode.h revision f29dbc25
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 /* Framebuffer memory */ 214 215 unsigned char *FBBase; 216 unsigned int FBAvail; 217 218 /* EXA structures */ 219 220 ExaDriverPtr pExa; 221 unsigned int exaBfrOffset; 222 unsigned int exaBfrSz; 223 224 /* Other structures */ 225 226 EntityInfoPtr pEnt; 227 ScreenBlockHandlerProcPtr BlockHandler; /* needed for video */ 228 XF86VideoAdaptorPtr adaptor; 229 230 /* State save structures */ 231 unsigned long FBDisplayOffset; 232 unsigned long PrevDisplayOffset; 233 234 VESARec *vesa; 235 236 int FBCompressionEnable; 237 238 VG_CURSOR_DATA FBCursor; 239 240 /* Save the Cursor offset of the FB */ 241 unsigned long FBCursorOffset; 242 unsigned char FBBIOSMode; 243 244 /* Hooks */ 245 246 void (*PointerMoved) (int index, int x, int y); 247 CloseScreenProcPtr CloseScreen; 248 Bool(*CreateScreenResources) (ScreenPtr); 249 250 /* ===== LX specific items ===== */ 251 252 /* Flags */ 253 Bool Scale; 254 255 DisplayModePtr panelMode; /* The mode for the panel (if attached) */ 256 257 /* Command buffer information */ 258 unsigned long CmdBfrOffset; 259 unsigned long CmdBfrSize; 260 261 /* Memory Management */ 262 GeodeMemPtr offscreenList; 263 unsigned int offscreenStart; 264 unsigned int offscreenSize; 265 266 /* Save state */ 267 VG_COMPRESSION_DATA CBData; 268 VG_COMPRESSION_DATA FBCBData; 269 CIM_DISPLAYTIMING FBcimdisplaytiming; 270 271 /* ===== GX specific items ===== */ 272 273 /* Flags */ 274 Bool Panel; 275 276 int PanelX; 277 int PanelY; 278 279 int displayPitch; /* The pitch ofthe visible area */ 280 int displayOffset; /* The offset of the visible area */ 281 282 DisplayModePtr curMode; 283 284 unsigned int shadowSize; 285 unsigned int shadowOffset; 286 287 int FBVGAActive; 288 289 xf86CursorInfoPtr CursorInfo; 290 291 /* XAA structures */ 292 293 unsigned int cpySrcOffset; 294 int cpySrcPitch, cpySrcBpp; 295 int cpyDx, cpyDy; 296 unsigned int cmpSrcOffset; 297 int cmpSrcPitch, cmpSrcBpp; 298 unsigned int cmpSrcFmt, cmpDstFmt; 299 int cmpOp; 300 301 unsigned char **AccelImageWriteBuffers; 302 int NoOfImgBuffers; 303 unsigned char **AccelColorExpandBuffers; 304 int NoOfColorExpandLines; 305 XAAInfoRecPtr AccelInfoRec; 306 307 /* Save state */ 308 unsigned long FBCompressionOffset; 309 unsigned short FBCompressionPitch; 310 unsigned short FBCompressionSize; 311 GFX_DISPLAYTIMING FBgfxdisplaytiming; 312 313 /* Hooks */ 314 void (*WritePixmap) (ScrnInfoPtr pScrni, int x, int y, int w, int h, 315 unsigned char *src, int srcwidth, int rop, 316 unsigned int planemask, int trans, int bpp, int depth); 317 318 /* Video information */ 319 int video_x; 320 int video_y; 321 short video_w; 322 short video_h; 323 short video_srcw; 324 short video_srch; 325 short video_dstw; 326 short video_dsth; 327 int video_id; 328 int video_offset; 329 ScrnInfoPtr video_scrnptr; 330 BOOL OverlayON; 331} 332GeodeRec, *GeodePtr; 333 334/* option flags are self-explanatory */ 335#ifdef HAVE_LX 336enum 337{ 338 LX_OPTION_SW_CURSOR, 339 LX_OPTION_HW_CURSOR, 340 LX_OPTION_NOCOMPRESSION, 341 LX_OPTION_NOACCEL, 342 LX_OPTION_EXA_SCRATCH_BFRSZ, 343 LX_OPTION_TV_SUPPORT, 344 LX_OPTION_TV_OUTPUT, 345 LX_OPTION_TV_OVERSCAN, 346 LX_OPTION_ROTATE, 347 LX_OPTION_NOPANEL, 348 LX_OPTION_FBSIZE, 349 LX_OPTION_PANEL_MODE, 350 LX_OPTION_DONT_PROGRAM 351} 352LX_GeodeOpts; 353#endif 354 355#ifdef HAVE_GX 356enum 357{ 358 GX_OPTION_SW_CURSOR, 359 GX_OPTION_HW_CURSOR, 360 GX_OPTION_NOCOMPRESSION, 361 GX_OPTION_NOACCEL, 362 GX_OPTION_ACCEL_METHOD, 363 GX_OPTION_EXA_SCRATCH_BFRSZ, 364 GX_OPTION_TV_SUPPORT, 365 GX_OPTION_TV_OUTPUT, 366 GX_OPTION_TV_OVERSCAN, 367 GX_OPTION_ROTATE, 368 GX_OPTION_NOPANEL, 369 GX_OPTION_OSM_IMG_BUFS, 370 GX_OPTION_OSM_CLR_BUFS, 371 GX_OPTION_FBSIZE, 372 GX_OPTION_PANEL_GEOMETRY, 373 GX_OPTION_DONT_PROGRAM 374} 375GX_GeodeOpts; 376#endif 377 378/* geode_dcon.c */ 379extern Bool dcon_init(ScrnInfoPtr pScrni); 380extern int DCONDPMSSet(ScrnInfoPtr pScrni, int mode); 381 382/* geode_common.c */ 383 384void geode_memory_to_screen_blt(unsigned long, unsigned long, 385 unsigned long, unsigned long, long, long, int); 386int GeodeGetRefreshRate(DisplayModePtr); 387void GeodeCopyGreyscale(unsigned char *, unsigned char *, int, int, int, int); 388int GeodeGetSizeFromFB(unsigned int *); 389 390/* gx_video.c */ 391 392int 393GeodeQueryImageAttributes(ScrnInfoPtr, int id, unsigned short *w, 394 unsigned short *h, int *pitches, int *offsets); 395 396Bool RegionsEqual(RegionPtr A, RegionPtr B); 397 398/* gx_driver.c */ 399 400void GeodeProbeDDC(ScrnInfoPtr pScrni, int index); 401xf86MonPtr GeodeDoDDC(ScrnInfoPtr pScrni, int index); 402Bool GeodeI2CInit(ScrnInfoPtr pScrni, I2CBusPtr * ptr, char *name); 403 404int GeodeGetFPGeometry(const char *str, int *width, int *height); 405void GeodePointerMoved(int index, int x, int y); 406void GeodeFreeScreen(int scrnIndex, int flags); 407int GeodeCalculatePitchBytes(unsigned int width, unsigned int bpp); 408void GXSetupChipsetFPtr(ScrnInfoPtr pScrn); 409 410/* geode_msr.c */ 411int GeodeReadMSR(unsigned long addr, unsigned long *lo, unsigned long *hi); 412int GeodeWriteMSR(unsigned long addr, unsigned long lo, unsigned long hi); 413 414/* gx_cursor.c */ 415Bool GXHWCursorInit(ScreenPtr pScrn); 416void GXLoadCursorImage(ScrnInfoPtr pScrni, unsigned char *src); 417void GXHideCursor(ScrnInfoPtr pScrni); 418void GXShowCursor(ScrnInfoPtr pScrni); 419 420/* gx_randr.c */ 421Rotation GXGetRotation(ScreenPtr pScreen); 422Bool GXRandRInit(ScreenPtr pScreen, int rotation); 423extern _X_EXPORT Bool GXRandRSetConfig(ScreenPtr pScreen, Rotation rotation, 424 int rate, RRScreenSizePtr pSize); 425 426/* gx_rotate.c */ 427Bool GXRotate(ScrnInfoPtr pScrni, DisplayModePtr mode); 428 429/* gx_accel.c */ 430Bool GXAccelInit(ScreenPtr pScrn); 431void GXAccelSync(ScrnInfoPtr pScrni); 432 433/* gx_video.c */ 434void GXInitVideo(ScreenPtr pScrn); 435 436/* lx_driver.c */ 437void LXSetupChipsetFPtr(ScrnInfoPtr pScrn); 438 439/* lx_cursor.c */ 440Bool LXHWCursorInit(ScreenPtr pScrn); 441void LXLoadARGBCursorImage(ScrnInfoPtr pScrni, unsigned char *src); 442void LXHideCursor(ScrnInfoPtr pScrni); 443void LXShowCursor(ScrnInfoPtr pScrni); 444 445/* lx_exa.c */ 446Bool LXExaInit(ScreenPtr pScreen); 447 448/* lx_video.c */ 449void LXInitVideo(ScreenPtr pScrn); 450 451/* lx_output.c */ 452void LXSetupOutput(ScrnInfoPtr); 453 454/* lx_panel.c */ 455DisplayModePtr LXGetLegacyPanelMode(void); 456DisplayModePtr LXGetManualPanelMode(char *modestr); 457 458void LXAdjustFrame(int scrnIndex, int x, int y, int flags); 459 460/* lx_display.c */ 461void LXSetupCrtc(ScrnInfoPtr pScrni); 462 463/* lx_memory.c */ 464GeodeMemPtr GeodeAllocOffscreen(GeodeRec * pGeode, int size, int align); 465void GeodeFreeOffscreen(GeodeRec * pGeode, GeodeMemPtr ptr); 466void LXInitOffscreen(ScrnInfoPtr pScrni); 467void GeodeCloseOffscreen(ScrnInfoPtr pScrni); 468unsigned int GeodeOffscreenFreeSize(GeodeRec * pGeode); 469 470/* lx_cursor.c */ 471Bool LXCursorInit(ScreenPtr pScrn); 472 473#endif 474