1 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h,v 1.51 2005/04/16 23:57:26 mvojkovi Exp $ */
3 #ifndef __NV_STRUCT_H__
4 #define __NV_STRUCT_H__
6 #include "colormapst.h"
8 #include "xf86Cursor.h"
12 #define _XF86DRI_SERVER_
17 #include "nouveau_drm.h"
20 #error "This driver requires a DRI-enabled X server"
23 #include "nv50_type.h"
24 #include "nv_pcicompat.h"
26 #include "nouveau_local.h" /* needed for NOUVEAU_EXA_PIXMAPS */
28 #define NV_ARCH_03 0x03
29 #define NV_ARCH_04 0x04
30 #define NV_ARCH_10 0x10
31 #define NV_ARCH_20 0x20
32 #define NV_ARCH_30 0x30
33 #define NV_ARCH_40 0x40
34 #define NV_ARCH_50 0x50
36 #define CHIPSET_NV03 0x0010
37 #define CHIPSET_NV04 0x0020
38 #define CHIPSET_NV10 0x0100
39 #define CHIPSET_NV11 0x0110
40 #define CHIPSET_NV15 0x0150
41 #define CHIPSET_NV17 0x0170
42 #define CHIPSET_NV18 0x0180
43 #define CHIPSET_NFORCE 0x01A0
44 #define CHIPSET_NFORCE2 0x01F0
45 #define CHIPSET_NV20 0x0200
46 #define CHIPSET_NV25 0x0250
47 #define CHIPSET_NV28 0x0280
48 #define CHIPSET_NV30 0x0300
49 #define CHIPSET_NV31 0x0310
50 #define CHIPSET_NV34 0x0320
51 #define CHIPSET_NV35 0x0330
52 #define CHIPSET_NV36 0x0340
53 #define CHIPSET_NV40 0x0040
54 #define CHIPSET_NV41 0x00C0
55 #define CHIPSET_NV43 0x0140
56 #define CHIPSET_NV44 0x0160
57 #define CHIPSET_NV44A 0x0220
58 #define CHIPSET_NV45 0x0210
59 #define CHIPSET_NV50 0x0190
60 #define CHIPSET_NV84 0x0400
61 #define CHIPSET_MISC_BRIDGED 0x00F0
62 #define CHIPSET_G70 0x0090
63 #define CHIPSET_G71 0x0290
64 #define CHIPSET_G72 0x01D0
65 #define CHIPSET_G73 0x0390
66 // integrated GeForces (6100, 6150)
67 #define CHIPSET_C51 0x0240
68 // variant of C51, seems based on a G70 design
69 #define CHIPSET_C512 0x03D0
70 #define CHIPSET_G73_BRIDGED 0x02E0
73 #define BITMASK(t,b) (((unsigned)(1U << (((t)-(b)+1)))-1) << (b))
74 #define MASKEXPAND(mask) BITMASK(1?mask,0?mask)
75 #define SetBF(mask,value) ((value) << (0?mask))
76 #define GetBF(var,mask) (((unsigned)((var) & MASKEXPAND(mask))) >> (0?mask) )
77 #define SetBitField(value,from,to) SetBF(to, GetBF(value,from))
78 #define SetBit(n) (1<<(n))
79 #define Set8Bits(value) ((value)&0xff)
81 #define MAX_NUM_DCB_ENTRIES 16
83 typedef enum /* matches DCB types */
92 typedef struct _nv_crtc_reg
94 unsigned char MiscOutReg; /* */
99 uint8_t Attribute[21];
100 unsigned char DAC[768]; /* Internal Colorlookuptable */
101 uint32_t cursorConfig;
111 /* These are former output regs, but are believed to be crtc related */
119 uint32_t dither_regs[6];
120 uint32_t fp_horiz_regs[7];
121 uint32_t fp_vert_regs[7];
122 uint32_t fp_hvalid_start;
123 uint32_t fp_hvalid_end;
124 uint32_t fp_vvalid_start;
125 uint32_t fp_vvalid_end;
127 uint32_t nv10_cursync;
128 uint32_t fp_control[2];
131 } NVCrtcRegRec, *NVCrtcRegPtr;
133 typedef struct _nv_output_reg
137 } NVOutputRegRec, *NVOutputRegPtr;
139 typedef struct _riva_hw_state
154 uint32_t arbitration0;
155 uint32_t arbitration1;
165 Bool vpll_changed[2];
166 /* These vpll values are only for nv4x hardware */
177 uint32_t cursorConfig;
186 NVCrtcRegRec crtc_reg[2];
187 NVOutputRegRec dac_reg[2];
188 } RIVA_HW_STATE, *NVRegPtr;
190 typedef struct _NVCrtcPrivateRec {
195 Bool skipModeFixup; /* NV50 only */
196 int pclk; /* Pixel clock in kHz */ /* NV50 only */
197 #if NOUVEAU_EXA_PIXMAPS
198 struct nouveau_bo *shadow;
200 ExaOffscreenArea *shadow;
201 #endif /* NOUVEAU_EXA_PIXMAPS */
202 } NVCrtcPrivateRec, *NVCrtcPrivatePtr;
207 } ValidOutputResource;
209 typedef struct _NVOutputPrivateRec {
210 uint8_t preferred_output;
211 uint8_t output_resource;
218 DisplayModePtr native_mode;
219 uint8_t scaling_mode;
220 uint32_t restore_output;
221 } NVOutputPrivateRec, *NVOutputPrivatePtr;
223 typedef struct _MiscStartupInfo {
224 uint8_t crtc_reg_52[2];
225 uint32_t ramdac_0_reg_580;
226 uint32_t ramdac_0_pllsel;
227 uint32_t ramdac_general_control[2];
240 Bool duallink_possible;
243 Bool use_straps_for_mode;
244 Bool use_power_scripts;
249 #define MAX_PLL_TYPES 2
269 uint8_t max_log2p_bias;
279 uint8_t major_version, chip_version;
280 uint8_t feature_byte;
282 uint32_t fmaxvco, fminvco;
286 uint16_t init_script_tbls_ptr;
287 uint16_t extra_init_script_tbl_ptr;
288 uint16_t macro_index_tbl_ptr;
289 uint16_t macro_tbl_ptr;
290 uint16_t condition_tbl_ptr;
291 uint16_t io_condition_tbl_ptr;
292 uint16_t io_flag_condition_tbl_ptr;
293 uint16_t init_function_tbl_ptr;
295 uint16_t pll_limit_tbl_ptr;
296 uint16_t ram_restrict_tbl_ptr;
299 DisplayModePtr native_mode;
301 uint16_t lvdsmanufacturerpointer;
302 uint16_t xlated_entry;
303 bool reset_after_pclk_change;
305 bool link_c_increment;
308 int duallink_transition_clk;
309 /* lower nibble stores PEXTDEV_BOOT_0 strap
310 * upper nibble stores xlated display strap */
315 uint16_t output0_script_ptr;
316 uint16_t output1_script_ptr;
320 uint16_t mem_init_tbl_ptr;
321 uint16_t sdr_seq_tbl_ptr;
322 uint16_t ddr_seq_tbl_ptr;
325 uint8_t crt, tv, panel;
331 /* Order *does* matter here */
342 uint8_t depth; /* mode related */
343 uint8_t bpp; /* pitch related */
350 #define NVOutputPrivate(o) ((NVOutputPrivatePtr (o)->driver_private)
352 typedef struct _NVRec *NVPtr;
353 typedef struct _NVRec {
354 RIVA_HW_STATE SavedReg;
355 RIVA_HW_STATE ModeReg;
356 uint32_t Architecture;
358 #ifndef XSERVER_LIBPCIACCESS
362 struct pci_device *PciInfo;
363 #endif /* XSERVER_LIBPCIACCESS */
369 /* VRAM physical address */
370 unsigned long VRAMPhysical;
371 /* Size of VRAM BAR */
372 unsigned long VRAMPhysicalSize;
373 /* Accesible VRAM size (by the GPU) */
374 unsigned long VRAMSize;
375 /* Accessible AGP size */
376 unsigned long AGPSize;
378 /* Various pinned memory regions */
379 struct nouveau_bo * FB;
380 struct nouveau_bo * Cursor;
381 struct nouveau_bo * Cursor2;
382 struct nouveau_bo * CLUT; /* NV50 only */
383 struct nouveau_bo * GART;
390 unsigned char * ShadowPtr;
392 CARD32 MinVClockFreqKHz;
393 CARD32 MaxVClockFreqKHz;
394 CARD32 CrystalFreqKHz;
395 CARD32 RamAmountKBytes;
397 volatile CARD32 *REGS;
398 volatile CARD32 *NV50_PCRTC;
399 volatile CARD32 *PGRAPH;
400 volatile CARD32 *PRAMIN;
401 volatile CARD32 *CURSOR;
402 volatile CARD8 *PCIO0;
403 volatile CARD8 *PCIO1;
404 volatile CARD8 *PVIO0;
405 volatile CARD8 *PVIO1;
406 volatile CARD8 *PDIO0;
407 volatile CARD8 *PDIO1;
409 unsigned int SaveGeneration;
411 ExaDriverPtr EXADriverPtr;
412 xf86CursorInfoPtr CursorInfoRec;
413 void (*PointerMoved)(int index, int x, int y);
414 ScreenBlockHandlerProcPtr BlockHandler;
415 CloseScreenProcPtr CloseScreen;
419 CARD32 curImage[256];
421 xf86Int10InfoPtr pInt10;
423 void (*VideoTimerCallback)(ScrnInfoPtr, Time);
424 XF86VideoAdaptorPtr overlayAdaptor;
425 XF86VideoAdaptorPtr blitAdaptor;
426 XF86VideoAdaptorPtr textureAdaptor[2];
434 OptionInfoPtr Options;
436 unsigned char DDCBase;
451 Bool WaitVSyncPossible;
452 Bool BlendingPossible;
455 drmVersionPtr pLibDRMVersion;
456 drmVersionPtr pKernelDRMVersion;
461 I2CBusPtr pI2CBus[MAX_NUM_DCB_ENTRIES];
463 uint8_t fp_regs_owner[2];
467 struct dcb_entry entry[MAX_NUM_DCB_ENTRIES];
468 unsigned char i2c_read[MAX_NUM_DCB_ENTRIES];
469 unsigned char i2c_write[MAX_NUM_DCB_ENTRIES];
472 MiscStartupInfo misc_info;
473 NVConsoleMode console_mode[2];
485 struct nouveau_device *dev;
488 struct nouveau_channel *chan;
489 struct nouveau_notifier *notify0;
490 struct nouveau_grobj *NvNull;
491 struct nouveau_grobj *NvContextSurfaces;
492 struct nouveau_grobj *NvContextBeta1;
493 struct nouveau_grobj *NvContextBeta4;
494 struct nouveau_grobj *NvImagePattern;
495 struct nouveau_grobj *NvRop;
496 struct nouveau_grobj *NvRectangle;
497 struct nouveau_grobj *NvImageBlit;
498 struct nouveau_grobj *NvScaledImage;
499 struct nouveau_grobj *NvClipRectangle;
500 struct nouveau_grobj *NvMemFormat;
501 struct nouveau_grobj *NvImageFromCpu;
502 struct nouveau_grobj *Nv2D;
503 struct nouveau_grobj *Nv3D;
515 #define NVCrtcPrivate(c) ((NVCrtcPrivatePtr)(c)->driver_private)
517 #define NVPTR(p) ((NVPtr)((p)->driverPrivate))
519 #define NVShowHideCursor(pScrn, show) do { \
520 NVPtr pNv = NVPTR(pScrn); \
521 nv_crtc_show_hide_cursor(pScrn, pNv->cur_head, show); \
524 #define NVLockUnlock(pScrn, lock) NVLockVgaCrtc(NVPTR(pScrn), NVPTR(pScrn)->cur_head, lock)
526 #define nvReadCurVGA(pNv, reg) NVReadVgaCrtc(pNv, pNv->cur_head, reg)
527 #define nvWriteCurVGA(pNv, reg, val) NVWriteVgaCrtc(pNv, pNv->cur_head, reg, val)
529 #define nvReadCurRAMDAC(pNv, reg) NVReadRAMDAC(pNv, pNv->cur_head, reg)
530 #define nvWriteCurRAMDAC(pNv, reg, val) NVWriteRAMDAC(pNv, pNv->cur_head, reg, val)
532 #define nvReadCurCRTC(pNv, reg) NVReadCRTC(pNv, pNv->cur_head, reg)
533 #define nvWriteCurCRTC(pNv, reg, val) NVWriteCRTC(pNv, pNv->cur_head, reg, val)
535 #define nvReadFB(pNv, reg) DDXMMIOW("nvReadFB: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
536 #define nvWriteFB(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteFB: reg %08x val %08x\n", reg, val))
538 #define nvReadGRAPH(pNv, reg) DDXMMIOW("nvReadGRAPH: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
539 #define nvWriteGRAPH(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteGRAPH: reg %08x val %08x\n", reg, val))
541 #define nvReadMC(pNv, reg) DDXMMIOW("nvReadMC: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
542 #define nvWriteMC(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteMC: reg %08x val %08x\n", reg, val))
544 #define nvReadME(pNv, reg) DDXMMIOW("nvReadME: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
545 #define nvWriteME(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteME: reg %08x val %08x\n", reg, val))
547 #define nvReadEXTDEV(pNv, reg) DDXMMIOW("nvReadEXTDEV: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
548 #define nvWriteEXTDEV(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteEXTDEV: reg %08x val %08x\n", reg, val))
550 #define nvReadTIMER(pNv, reg) DDXMMIOW("nvReadTIMER: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
551 #define nvWriteTIMER(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteTIMER: reg %08x val %08x\n", reg, val))
553 #define nvReadVIDEO(pNv, reg) DDXMMIOW("nvReadVIDEO: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
554 #define nvWriteVIDEO(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteVIDEO: reg %08x val %08x\n", reg, val))
556 typedef struct _NVPortPrivRec {
563 Bool autopaintColorKey;
573 Bool bicubic; /* only for texture adapter */
575 struct nouveau_bo *video_mem;
578 struct nouveau_bo *TT_mem_chunk[2];
579 int currentHostBuffer;
580 struct nouveau_notifier *DMANotifier[2];
581 } NVPortPrivRec, *NVPortPrivPtr;
583 #define GET_OVERLAY_PRIVATE(pNv) \
584 (NVPortPrivPtr)((pNv)->overlayAdaptor->pPortPrivates[0].ptr)
586 #define GET_BLIT_PRIVATE(pNv) \
587 (NVPortPrivPtr)((pNv)->blitAdaptor->pPortPrivates[0].ptr)
589 #define OFF_TIMER 0x01
590 #define FREE_TIMER 0x02
591 #define CLIENT_VIDEO_ON 0x04
592 #define OFF_DELAY 500 /* milliseconds */
593 #define FREE_DELAY 5000
595 #define TIMER_MASK (OFF_TIMER | FREE_TIMER)
597 #endif /* __NV_STRUCT_H__ */