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_
16 #include "nouveau_drm.h"
19 #error "This driver requires a DRI-enabled X server"
22 #include "nv50_type.h"
23 #include "nv_pcicompat.h"
25 #define NV_ARCH_03 0x03
26 #define NV_ARCH_04 0x04
27 #define NV_ARCH_10 0x10
28 #define NV_ARCH_20 0x20
29 #define NV_ARCH_30 0x30
30 #define NV_ARCH_40 0x40
31 #define NV_ARCH_50 0x50
33 #define CHIPSET_NV03 0x0010
34 #define CHIPSET_NV04 0x0020
35 #define CHIPSET_NV10 0x0100
36 #define CHIPSET_NV11 0x0110
37 #define CHIPSET_NV15 0x0150
38 #define CHIPSET_NV17 0x0170
39 #define CHIPSET_NV18 0x0180
40 #define CHIPSET_NFORCE 0x01A0
41 #define CHIPSET_NFORCE2 0x01F0
42 #define CHIPSET_NV20 0x0200
43 #define CHIPSET_NV25 0x0250
44 #define CHIPSET_NV28 0x0280
45 #define CHIPSET_NV30 0x0300
46 #define CHIPSET_NV31 0x0310
47 #define CHIPSET_NV34 0x0320
48 #define CHIPSET_NV35 0x0330
49 #define CHIPSET_NV36 0x0340
50 #define CHIPSET_NV40 0x0040
51 #define CHIPSET_NV41 0x00C0
52 #define CHIPSET_NV43 0x0140
53 #define CHIPSET_NV44 0x0160
54 #define CHIPSET_NV44A 0x0220
55 #define CHIPSET_NV45 0x0210
56 #define CHIPSET_NV50 0x0190
57 #define CHIPSET_NV84 0x0400
58 #define CHIPSET_MISC_BRIDGED 0x00F0
59 #define CHIPSET_G70 0x0090
60 #define CHIPSET_G71 0x0290
61 #define CHIPSET_G72 0x01D0
62 #define CHIPSET_G73 0x0390
63 // integrated GeForces (6100, 6150)
64 #define CHIPSET_C51 0x0240
65 // variant of C51, seems based on a G70 design
66 #define CHIPSET_C512 0x03D0
67 #define CHIPSET_G73_BRIDGED 0x02E0
70 #define BITMASK(t,b) (((unsigned)(1U << (((t)-(b)+1)))-1) << (b))
71 #define MASKEXPAND(mask) BITMASK(1?mask,0?mask)
72 #define SetBF(mask,value) ((value) << (0?mask))
73 #define GetBF(var,mask) (((unsigned)((var) & MASKEXPAND(mask))) >> (0?mask) )
74 #define SetBitField(value,from,to) SetBF(to, GetBF(value,from))
75 #define SetBit(n) (1<<(n))
76 #define Set8Bits(value) ((value)&0xff)
78 #define MAX_NUM_DCB_ENTRIES 16
80 typedef enum /* matches DCB types */
97 typedef struct _nv_crtc_reg
99 unsigned char MiscOutReg; /* */
105 unsigned char DAC[768]; /* Internal Colorlookuptable */
116 /* These are former output regs, but are believed to be crtc related */
124 CARD32 fp_horiz_regs[7];
125 CARD32 fp_vert_regs[7];
126 CARD32 fp_hvalid_start;
127 CARD32 fp_hvalid_end;
128 CARD32 fp_vvalid_start;
129 CARD32 fp_vvalid_end;
135 } NVCrtcRegRec, *NVCrtcRegPtr;
137 typedef struct _nv_output_reg
146 } NVOutputRegRec, *NVOutputRegPtr;
148 typedef struct _riva_hw_state
175 /* These vpll values are only for nv4x hardware */
196 NVCrtcRegRec crtc_reg[2];
197 NVOutputRegRec dac_reg[2];
198 } RIVA_HW_STATE, *NVRegPtr;
200 typedef struct _nv50_crtc_reg
203 } NV50CrtcRegRec, *NV50CrtcRegPtr;
205 typedef struct _nv50_hw_state
207 NV50CrtcRegRec crtc_reg[2];
208 } NV50_HW_STATE, *NV50RegPtr;
215 typedef struct _NVOutputPrivateRec {
216 uint8_t preferred_output;
224 DisplayModePtr native_mode;
226 uint8_t scaling_mode;
227 } NVOutputPrivateRec, *NVOutputPrivatePtr;
229 typedef struct _MiscStartupInfo {
231 CARD32 ramdac_0_reg_580;
232 CARD32 ramdac_0_pllsel;
238 OUTPUT_0_SLAVED = (1 << 0),
239 OUTPUT_1_SLAVED = (1 << 1),
240 OUTPUT_0_LVDS = (1 << 2),
241 OUTPUT_1_LVDS = (1 << 3),
242 OUTPUT_0_CROSSWIRED_TMDS = (1 << 4),
243 OUTPUT_1_CROSSWIRED_TMDS = (1 << 5)
253 Bool duallink_possible;
256 Bool use_straps_for_mode;
257 Bool use_power_scripts;
267 uint8_t major_version;
269 uint16_t init_script_tbls_ptr;
270 uint16_t macro_index_tbl_ptr;
271 uint16_t macro_tbl_ptr;
272 uint16_t condition_tbl_ptr;
273 uint16_t io_condition_tbl_ptr;
274 uint16_t io_flag_condition_tbl_ptr;
275 uint16_t init_function_tbl_ptr;
277 uint16_t ram_restrict_tbl_ptr;
280 DisplayModePtr native_mode;
281 uint16_t lvdsmanufacturerpointer;
282 uint16_t xlated_entry;
289 uint16_t output0_script_ptr;
290 uint16_t output1_script_ptr;
295 /* Order *does* matter here */
304 #define NVOutputPrivate(o) ((NVOutputPrivatePtr (o)->driver_private)
306 typedef struct _NVRec *NVPtr;
307 typedef struct _NVRec {
308 RIVA_HW_STATE SavedReg;
309 RIVA_HW_STATE ModeReg;
310 RIVA_HW_STATE *CurrentState;
311 NV50_HW_STATE NV50SavedReg;
312 NV50_HW_STATE NV50ModeReg;
315 #ifndef XSERVER_LIBPCIACCESS
319 struct pci_device *PciInfo;
320 #endif /* XSERVER_LIBPCIACCESS */
327 /* VRAM physical address */
328 unsigned long VRAMPhysical;
329 /* Size of VRAM BAR */
330 unsigned long VRAMPhysicalSize;
331 /* Accesible VRAM size (by the GPU) */
332 unsigned long VRAMSize;
333 /* Accessible AGP size */
334 unsigned long AGPSize;
336 /* Various pinned memory regions */
337 struct nouveau_bo * FB;
338 struct nouveau_bo * Cursor;
339 struct nouveau_bo * CLUT; /* NV50 only */
340 struct nouveau_bo * GART;
347 unsigned char * ShadowPtr;
349 CARD32 MinVClockFreqKHz;
350 CARD32 MaxVClockFreqKHz;
351 CARD32 CrystalFreqKHz;
352 CARD32 RamAmountKBytes;
354 volatile CARD32 *REGS;
355 volatile CARD32 *PCRTC0;
356 volatile CARD32 *PCRTC1;
358 volatile CARD32 *NV50_PCRTC;
360 volatile CARD32 *PRAMDAC0;
361 volatile CARD32 *PRAMDAC1;
362 volatile CARD32 *PFB;
363 volatile CARD32 *PFIFO;
364 volatile CARD32 *PGRAPH;
365 volatile CARD32 *PEXTDEV;
366 volatile CARD32 *PTIMER;
367 volatile CARD32 *PVIDEO;
368 volatile CARD32 *PMC;
369 volatile CARD32 *PRAMIN;
370 volatile CARD32 *CURSOR;
371 volatile CARD8 *PCIO0;
372 volatile CARD8 *PCIO1;
373 volatile CARD8 *PVIO0;
374 volatile CARD8 *PVIO1;
375 volatile CARD8 *PDIO0;
376 volatile CARD8 *PDIO1;
377 volatile CARD8 *PROM;
380 volatile CARD32 *RAMHT;
383 unsigned int SaveGeneration;
385 ExaDriverPtr EXADriverPtr;
386 xf86CursorInfoPtr CursorInfoRec;
387 void (*PointerMoved)(int index, int x, int y);
388 ScreenBlockHandlerProcPtr BlockHandler;
389 CloseScreenProcPtr CloseScreen;
391 NVFBLayout CurrentLayout;
394 CARD32 curImage[256];
397 xf86Int10InfoPtr pInt10;
399 void (*VideoTimerCallback)(ScrnInfoPtr, Time);
400 XF86VideoAdaptorPtr overlayAdaptor;
401 XF86VideoAdaptorPtr blitAdaptor;
409 Bool ramdac_active[2];
410 OptionInfoPtr Options;
412 unsigned char DDCBase;
427 Bool WaitVSyncPossible;
428 Bool BlendingPossible;
431 drmVersionPtr pLibDRMVersion;
432 drmVersionPtr pKernelDRMVersion;
435 CreateScreenResourcesProcPtr CreateScreenResources;
437 I2CBusPtr pI2CBus[MAX_NUM_DCB_ENTRIES];
446 struct dcb_entry entry[MAX_NUM_DCB_ENTRIES];
447 unsigned char i2c_read[MAX_NUM_DCB_ENTRIES];
448 unsigned char i2c_write[MAX_NUM_DCB_ENTRIES];
451 uint32_t output_info;
452 MiscStartupInfo misc_info;
464 struct nouveau_device *dev;
467 struct nouveau_channel *chan;
468 struct nouveau_notifier *notify0;
469 struct nouveau_grobj *NvNull;
470 struct nouveau_grobj *NvContextSurfaces;
471 struct nouveau_grobj *NvContextBeta1;
472 struct nouveau_grobj *NvContextBeta4;
473 struct nouveau_grobj *NvImagePattern;
474 struct nouveau_grobj *NvRop;
475 struct nouveau_grobj *NvRectangle;
476 struct nouveau_grobj *NvImageBlit;
477 struct nouveau_grobj *NvScaledImage;
478 struct nouveau_grobj *NvClipRectangle;
479 struct nouveau_grobj *NvMemFormat;
480 struct nouveau_grobj *NvImageFromCpu;
481 struct nouveau_grobj *Nv2D;
482 struct nouveau_grobj *Nv3D;
486 typedef struct _NVCrtcPrivateRec {
491 } NVCrtcPrivateRec, *NVCrtcPrivatePtr;
493 typedef struct _NV50CrtcPrivRec {
495 int pclk; /* Target pixel clock in kHz */
499 } NV50CrtcPrivRec, *NV50CrtcPrivPtr;
501 #define NVCrtcPrivate(c) ((NVCrtcPrivatePtr)(c)->driver_private)
503 #define NVPTR(p) ((NVPtr)((p)->driverPrivate))
505 #define nvReadRAMDAC0(pNv, reg) nvReadRAMDAC(pNv, 0, reg)
506 #define nvWriteRAMDAC0(pNv, reg, val) nvWriteRAMDAC(pNv, 0, reg, val)
508 #define nvReadCurRAMDAC(pNv, reg) nvReadRAMDAC(pNv, pNv->cur_head, reg)
509 #define nvWriteCurRAMDAC(pNv, reg, val) nvWriteRAMDAC(pNv, pNv->cur_head, reg, val)
511 #define nvReadCRTC0(pNv, reg) nvReadCRTC(pNv, 0, reg)
512 #define nvWriteCRTC0(pNv, reg, val) nvWriteCRTC(pNv, 0, reg, val)
514 #define nvReadCurCRTC(pNv, reg) nvReadCRTC(pNv, pNv->cur_head, reg)
515 #define nvWriteCurCRTC(pNv, reg, val) nvWriteCRTC(pNv, pNv->cur_head, reg, val)
517 #define nvReadFB(pNv, fb_reg) MMIO_IN32(pNv->PFB, fb_reg)
518 #define nvWriteFB(pNv, fb_reg, val) MMIO_OUT32(pNv->PFB, fb_reg, val)
520 #define nvReadGRAPH(pNv, reg) MMIO_IN32(pNv->PGRAPH, reg)
521 #define nvWriteGRAPH(pNv, reg, val) MMIO_OUT32(pNv->PGRAPH, reg, val)
523 #define nvReadMC(pNv, reg) MMIO_IN32(pNv->PMC, reg)
524 #define nvWriteMC(pNv, reg, val) MMIO_OUT32(pNv->PMC, reg, val)
526 #define nvReadEXTDEV(pNv, reg) MMIO_IN32(pNv->PEXTDEV, reg)
527 #define nvWriteEXTDEV(pNv, reg, val) MMIO_OUT32(pNv->PEXTDEV, reg, val)
529 #define nvReadTIMER(pNv, reg) MMIO_IN32(pNv->PTIMER, reg)
530 #define nvWriteTIMER(pNv, reg, val) MMIO_OUT32(pNv->PTIMER, reg, val)
532 #define nvReadVIDEO(pNv, reg) MMIO_IN32(pNv->PVIDEO, reg)
533 #define nvWriteVIDEO(pNv, reg, val) MMIO_OUT32(pNv->PVIDEO, reg, val)
535 #endif /* __NV_STRUCT_H__ */