1 #ifndef __NV_STRUCT_H__
2 #define __NV_STRUCT_H__
4 #include "colormapst.h"
6 #include "xf86Cursor.h"
10 #define _XF86DRI_SERVER_
15 #include "nouveau_drm.h"
18 #error "This driver requires a DRI-enabled X server"
21 #include "nv_pcicompat.h"
23 #include "nouveau_local.h" /* needed for NOUVEAU_EXA_PIXMAPS */
25 #include "nouveau_crtc.h"
26 #include "nouveau_connector.h"
27 #include "nouveau_output.h"
29 #include "drmmode_display.h"
31 #define NV_ARCH_03 0x03
32 #define NV_ARCH_04 0x04
33 #define NV_ARCH_10 0x10
34 #define NV_ARCH_20 0x20
35 #define NV_ARCH_30 0x30
36 #define NV_ARCH_40 0x40
37 #define NV_ARCH_50 0x50
39 #define CHIPSET_NV03 0x0010
40 #define CHIPSET_NV04 0x0020
41 #define CHIPSET_NV10 0x0100
42 #define CHIPSET_NV11 0x0110
43 #define CHIPSET_NV15 0x0150
44 #define CHIPSET_NV17 0x0170
45 #define CHIPSET_NV18 0x0180
46 #define CHIPSET_NFORCE 0x01A0
47 #define CHIPSET_NFORCE2 0x01F0
48 #define CHIPSET_NV20 0x0200
49 #define CHIPSET_NV25 0x0250
50 #define CHIPSET_NV28 0x0280
51 #define CHIPSET_NV30 0x0300
52 #define CHIPSET_NV31 0x0310
53 #define CHIPSET_NV34 0x0320
54 #define CHIPSET_NV35 0x0330
55 #define CHIPSET_NV36 0x0340
56 #define CHIPSET_NV40 0x0040
57 #define CHIPSET_NV41 0x00C0
58 #define CHIPSET_NV43 0x0140
59 #define CHIPSET_NV44 0x0160
60 #define CHIPSET_NV44A 0x0220
61 #define CHIPSET_NV45 0x0210
62 #define CHIPSET_NV50 0x0190
63 #define CHIPSET_NV84 0x0400
64 #define CHIPSET_MISC_BRIDGED 0x00F0
65 #define CHIPSET_G70 0x0090
66 #define CHIPSET_G71 0x0290
67 #define CHIPSET_G72 0x01D0
68 #define CHIPSET_G73 0x0390
69 // integrated GeForces (6100, 6150)
70 #define CHIPSET_C51 0x0240
71 // variant of C51, seems based on a G70 design
72 #define CHIPSET_C512 0x03D0
73 #define CHIPSET_G73_BRIDGED 0x02E0
76 #define BITMASK(t,b) (((unsigned)(1U << (((t)-(b)+1)))-1) << (b))
77 #define MASKEXPAND(mask) BITMASK(1?mask,0?mask)
78 #define SetBF(mask,value) ((value) << (0?mask))
79 #define GetBF(var,mask) (((unsigned)((var) & MASKEXPAND(mask))) >> (0?mask) )
80 #define SetBitField(value,from,to) SetBF(to, GetBF(value,from))
81 #define SetBit(n) (1<<(n))
82 #define Set8Bits(value) ((value)&0xff)
84 #define MAX_NUM_DCB_ENTRIES 16
96 bool duallink_possible;
99 bool use_straps_for_mode;
100 bool use_power_scripts;
106 {/* matches DCB types */
137 typedef struct _nv_crtc_reg
139 unsigned char MiscOutReg; /* */
142 uint8_t Sequencer[5];
144 uint8_t Attribute[21];
145 unsigned char DAC[768]; /* Internal Colorlookuptable */
146 uint32_t cursorConfig;
157 /* These are former output regs, but are believed to be crtc related */
165 uint32_t dither_regs[6];
166 uint32_t fp_horiz_regs[7];
167 uint32_t fp_vert_regs[7];
168 uint32_t nv10_cursync;
174 } NVCrtcRegRec, *NVCrtcRegPtr;
176 typedef struct _nv_output_reg
180 } NVOutputRegRec, *NVOutputRegPtr;
182 typedef struct _riva_hw_state
197 uint32_t arbitration0;
198 uint32_t arbitration1;
212 uint32_t cursorConfig;
221 NVCrtcRegRec crtc_reg[2];
222 } RIVA_HW_STATE, *NVRegPtr;
224 typedef struct _NVCrtcPrivateRec {
227 #if NOUVEAU_EXA_PIXMAPS
228 struct nouveau_bo *shadow;
230 ExaOffscreenArea *shadow;
231 #endif /* NOUVEAU_EXA_PIXMAPS */
233 } NVCrtcPrivateRec, *NVCrtcPrivatePtr;
239 } ValidOutputResource;
241 typedef struct _NVOutputPrivateRec {
242 uint8_t last_dpms; /* pre-NV50 */
245 struct dcb_entry *dcb;
248 DisplayModePtr native_mode;
249 uint8_t scaling_mode;
251 NVOutputRegRec restore;
252 } NVOutputPrivateRec, *NVOutputPrivatePtr;
254 /* changing these requires matching changes to reg tables in nv_get_clock */
255 #define MAX_PLL_TYPES 4
277 uint8_t max_log2p_bias;
287 uint8_t major_version, chip_version;
288 uint8_t feature_byte;
290 uint32_t fmaxvco, fminvco;
294 uint16_t init_script_tbls_ptr;
295 uint16_t extra_init_script_tbl_ptr;
296 uint16_t macro_index_tbl_ptr;
297 uint16_t macro_tbl_ptr;
298 uint16_t condition_tbl_ptr;
299 uint16_t io_condition_tbl_ptr;
300 uint16_t io_flag_condition_tbl_ptr;
301 uint16_t init_function_tbl_ptr;
303 uint16_t pll_limit_tbl_ptr;
304 uint16_t ram_restrict_tbl_ptr;
307 DisplayModePtr native_mode;
309 uint16_t lvdsmanufacturerpointer;
310 uint16_t xlated_entry;
311 bool power_off_for_reset;
312 bool reset_after_pclk_change;
314 bool link_c_increment;
317 int duallink_transition_clk;
318 /* lower nibble stores PEXTDEV_BOOT_0 strap
319 * upper nibble stores xlated display strap */
324 uint16_t output0_script_ptr;
325 uint16_t output1_script_ptr;
329 uint16_t mem_init_tbl_ptr;
330 uint16_t sdr_seq_tbl_ptr;
331 uint16_t ddr_seq_tbl_ptr;
334 uint8_t crt, tv, panel;
340 /* Order *does* matter here */
351 uint8_t depth; /* mode related */
352 uint8_t bpp; /* pitch related */
359 typedef struct _NVRec *NVPtr;
360 typedef struct _NVRec {
361 RIVA_HW_STATE SavedReg;
362 RIVA_HW_STATE ModeReg;
363 uint32_t saved_vga_font[4][16384];
364 uint32_t Architecture;
366 #ifndef XSERVER_LIBPCIACCESS
370 struct pci_device *PciInfo;
371 #endif /* XSERVER_LIBPCIACCESS */
377 /* VRAM physical address */
378 unsigned long VRAMPhysical;
379 /* Size of VRAM BAR */
380 unsigned long VRAMPhysicalSize;
381 /* Accesible VRAM size (by the GPU) */
382 unsigned long VRAMSize;
383 /* Accessible AGP size */
384 unsigned long AGPSize;
386 /* Various pinned memory regions */
387 struct nouveau_bo * FB;
389 //struct nouveau_bo * FB_old; /* for KMS */
390 struct nouveau_bo * shadow[2]; /* for easy acces by exa */
391 struct nouveau_bo * Cursor;
392 struct nouveau_bo * Cursor2;
393 struct nouveau_bo * CLUT0; /* NV50 only */
394 struct nouveau_bo * CLUT1; /* NV50 only */
395 struct nouveau_bo * GART;
402 unsigned char * ShadowPtr;
404 CARD32 MinVClockFreqKHz;
405 CARD32 MaxVClockFreqKHz;
406 CARD32 CrystalFreqKHz;
407 CARD32 RamAmountKBytes;
409 volatile CARD32 *REGS;
410 volatile CARD32 *FB_BAR;
411 volatile CARD32 *PGRAPH;
412 volatile CARD32 *PRAMIN;
413 volatile CARD32 *CURSOR;
414 volatile CARD8 *PCIO0;
415 volatile CARD8 *PCIO1;
416 volatile CARD8 *PVIO0;
417 volatile CARD8 *PVIO1;
418 volatile CARD8 *PDIO0;
419 volatile CARD8 *PDIO1;
421 unsigned int SaveGeneration;
423 ExaDriverPtr EXADriverPtr;
424 xf86CursorInfoPtr CursorInfoRec;
425 void (*PointerMoved)(int index, int x, int y);
426 ScreenBlockHandlerProcPtr BlockHandler;
427 CloseScreenProcPtr CloseScreen;
431 CARD32 curImage[256];
433 xf86Int10InfoPtr pInt10;
436 void (*VideoTimerCallback)(ScrnInfoPtr, Time);
437 XF86VideoAdaptorPtr overlayAdaptor;
438 XF86VideoAdaptorPtr blitAdaptor;
439 XF86VideoAdaptorPtr textureAdaptor[2];
447 OptionInfoPtr Options;
449 unsigned char DDCBase;
464 Bool WaitVSyncPossible;
465 Bool BlendingPossible;
468 drmVersionPtr pLibDRMVersion;
469 drmVersionPtr pKernelDRMVersion;
475 I2CBusPtr pI2CBus[MAX_NUM_DCB_ENTRIES];
478 void *drmmode; /* for KMS */
483 struct dcb_entry entry[MAX_NUM_DCB_ENTRIES];
484 unsigned char i2c_read[MAX_NUM_DCB_ENTRIES];
485 unsigned char i2c_write[MAX_NUM_DCB_ENTRIES];
488 NVConsoleMode console_mode[2];
490 nouveauCrtcPtr crtc[2];
491 nouveauOutputPtr output; /* this a linked list. */
492 /* Assume a connector can exist for each i2c bus. */
493 nouveauConnectorPtr connector[MAX_NUM_DCB_ENTRIES];
505 struct nouveau_device *dev;
508 struct nouveau_channel *chan;
509 struct nouveau_notifier *notify0;
510 struct nouveau_grobj *NvNull;
511 struct nouveau_grobj *NvContextSurfaces;
512 struct nouveau_grobj *NvContextBeta1;
513 struct nouveau_grobj *NvContextBeta4;
514 struct nouveau_grobj *NvImagePattern;
515 struct nouveau_grobj *NvRop;
516 struct nouveau_grobj *NvRectangle;
517 struct nouveau_grobj *NvImageBlit;
518 struct nouveau_grobj *NvScaledImage;
519 struct nouveau_grobj *NvClipRectangle;
520 struct nouveau_grobj *NvMemFormat;
521 struct nouveau_grobj *NvImageFromCpu;
522 struct nouveau_grobj *Nv2D;
523 struct nouveau_grobj *Nv3D;
524 struct nouveau_bo *tesla_scratch;
527 #define NVPTR(p) ((NVPtr)((p)->driverPrivate))
529 #define NVShowHideCursor(pScrn, show) do { \
530 NVPtr pNv = NVPTR(pScrn); \
531 nv_crtc_show_hide_cursor(pScrn, pNv->cur_head, show); \
534 #define NVLockUnlock(pScrn, lock) NVLockVgaCrtc(NVPTR(pScrn), NVPTR(pScrn)->cur_head, lock)
536 #define nvReadCurVGA(pNv, reg) NVReadVgaCrtc(pNv, pNv->cur_head, reg)
537 #define nvWriteCurVGA(pNv, reg, val) NVWriteVgaCrtc(pNv, pNv->cur_head, reg, val)
539 #define nvReadCurRAMDAC(pNv, reg) NVReadRAMDAC(pNv, pNv->cur_head, reg)
540 #define nvWriteCurRAMDAC(pNv, reg, val) NVWriteRAMDAC(pNv, pNv->cur_head, reg, val)
542 #define nvReadCurCRTC(pNv, reg) NVReadCRTC(pNv, pNv->cur_head, reg)
543 #define nvWriteCurCRTC(pNv, reg, val) NVWriteCRTC(pNv, pNv->cur_head, reg, val)
545 #define nvReadFB(pNv, reg) DDXMMIOW("nvReadFB: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
546 #define nvWriteFB(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteFB: reg %08x val %08x\n", reg, val))
548 #define nvReadGRAPH(pNv, reg) DDXMMIOW("nvReadGRAPH: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
549 #define nvWriteGRAPH(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteGRAPH: reg %08x val %08x\n", reg, val))
551 #define nvReadMC(pNv, reg) DDXMMIOW("nvReadMC: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
552 #define nvWriteMC(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteMC: reg %08x val %08x\n", reg, val))
554 #define nvReadME(pNv, reg) DDXMMIOW("nvReadME: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
555 #define nvWriteME(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteME: reg %08x val %08x\n", reg, val))
557 #define nvReadEXTDEV(pNv, reg) DDXMMIOW("nvReadEXTDEV: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
558 #define nvWriteEXTDEV(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteEXTDEV: reg %08x val %08x\n", reg, val))
560 #define nvReadTIMER(pNv, reg) DDXMMIOW("nvReadTIMER: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
561 #define nvWriteTIMER(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteTIMER: reg %08x val %08x\n", reg, val))
563 #define nvReadVIDEO(pNv, reg) DDXMMIOW("nvReadVIDEO: reg %08x val %08x\n", reg, (uint32_t)MMIO_IN32(pNv->REGS, reg))
564 #define nvWriteVIDEO(pNv, reg, val) MMIO_OUT32(pNv->REGS, reg, DDXMMIOW("nvWriteVIDEO: reg %08x val %08x\n", reg, val))
566 typedef struct _NVPortPrivRec {
573 Bool autopaintColorKey;
583 Bool bicubic; /* only for texture adapter */
585 struct nouveau_bo *video_mem;
588 struct nouveau_bo *TT_mem_chunk[2];
589 int currentHostBuffer;
590 struct nouveau_notifier *DMANotifier[2];
591 } NVPortPrivRec, *NVPortPrivPtr;
593 #define GET_OVERLAY_PRIVATE(pNv) \
594 (NVPortPrivPtr)((pNv)->overlayAdaptor->pPortPrivates[0].ptr)
596 #define GET_BLIT_PRIVATE(pNv) \
597 (NVPortPrivPtr)((pNv)->blitAdaptor->pPortPrivates[0].ptr)
599 #define OFF_TIMER 0x01
600 #define FREE_TIMER 0x02
601 #define CLIENT_VIDEO_ON 0x04
602 #define OFF_DELAY 500 /* milliseconds */
603 #define FREE_DELAY 5000
605 #define TIMER_MASK (OFF_TIMER | FREE_TIMER)
607 #endif /* __NV_STRUCT_H__ */