Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
6.1 KiB

  1. /******************************Module*Header*******************************\
  2. *
  3. * Module Name: init.c
  4. * Author: Goran Devic, Mark Einkauf
  5. * Purpose: Initialize Laguna3D 3D engine
  6. *
  7. * Copyright (c) 1997 Cirrus Logic, Inc.
  8. *
  9. \**************************************************************************/
  10. /*********************************************************************
  11. * Include Files
  12. **********************************************************************/
  13. #include "precomp.h"
  14. #include "mcdhw.h"
  15. extern DWORD _InitDisplayList( PDEV *ppdev, DWORD dwListLen );
  16. /*********************************************************************
  17. * Local Macros
  18. **********************************************************************/
  19. // Set the register and the cache in LL_State to a specific value
  20. #define SETREG(Offset,Reg,Value) \
  21. *(ppdev->LL_State.pRegs + (Offset)) = ppdev->LL_State.Reg = (Value); /*inp(0x80); inp(0x80)*/
  22. // setreg, no cache: do not cache state for this register
  23. #define SETREG_NC(reg, value) \
  24. (*(ppdev->LL_State.pRegs + reg) = value); /*inp(0x80); inp(0x80)*/
  25. // Clears the range of registers
  26. #define CLEAR_RANGE( StartReg, EndReg ) \
  27. memset( (void *)(ppdev->LL_State.pRegs + (StartReg)), 0, ((EndReg) - (StartReg)+1)*4 )
  28. /*********************************************************************
  29. * Local Variables
  30. **********************************************************************/
  31. /*********************************************************************
  32. * Local Functions
  33. **********************************************************************/
  34. DWORD LL_InitLib( PDEV *ppdev )
  35. {
  36. int i, j, error_code;
  37. // =========== REGISTER SETTINGS ==============
  38. // Set all 3D registers in the order
  39. CLEAR_RANGE( X_3D, DU_ORTHO_ADD_3D );// Clear 3D interpolators
  40. SETREG_NC( WIDTH1_3D, 0x10000 ); // Init polyengine reg WIDTH1_3D to 1
  41. CLEAR_RANGE( A_3D, DA_ORTHO_3D ); // Clear 3D interpolators
  42. SETREG_NC( CONTROL_MASK_3D, 0 ); // Enable writes
  43. SETREG_NC( CONTROL0_3D, 0 );
  44. CLEAR_RANGE( COLOR_MIN_BOUNDS_3D, COLOR_MAX_BOUNDS_3D );
  45. ppdev->LL_State.rColor_Min_Bounds = 0;
  46. ppdev->LL_State.rColor_Max_Bounds = 0;
  47. SETREG_NC( CONTROL1_3D, 0 );
  48. // Set Base0 address register:
  49. // * Color buffer X offset
  50. // * Color buffer location in RDRAM
  51. // * Z buffer location in RDRAM
  52. // * Textures in RDRAM
  53. // * Pattern offset of 0
  54. //
  55. SETREG_NC( BASE0_ADDR_3D, 0 );
  56. // Set Base1 address register:
  57. // * Color buffer Y offset to 0
  58. // * Z buffer Y offset to 0
  59. //
  60. SETREG_NC( BASE1_ADDR_3D, 0 );
  61. // Set texture control register:
  62. // * Texture U, V masks to 16
  63. // * Texture U, V wraps
  64. // * Texel mode temporarily to 0
  65. // * Texel lookop to no lookup
  66. // * Texture data is lighting source
  67. // * Filtering disabled
  68. // * Texture polarity of type 0
  69. // * Texture masking diasabled
  70. // * Texture mask function to Write mask
  71. // * Address mux to 0
  72. // * CLUT offset to 0
  73. //
  74. SETREG_NC( TX_CTL0_3D, 0 );
  75. SETREG_NC( TX_XYBASE_3D, 0 );
  76. SETREG_NC( TX_CTL1_3D, 0 ); // Set tex color bounds
  77. #if DRIVER_5465
  78. // FUTURE: verify that filter set of mask_thresh=0,step_bilinear=smooth_bilinear=0,frac=0x7 is OK
  79. SETREG_NC( TX_CTL2_3D, (0x7 << 24) ); // Set tex color bounds and filter to true bilinear
  80. #else // DRIVER_5465
  81. SETREG_NC( TX_CTL2_3D, 0); // Set tex color bounds
  82. #endif // DRIVER_5465
  83. SETREG_NC( COLOR0_3D, 0 );
  84. SETREG_NC( COLOR1_3D, 0 );
  85. // Don't write Z_Collide - will cause interrupt...
  86. //SETREG_NC( Z_COLLIDE_3D, 0 );
  87. CLEAR_RANGE( STATUS0_3D, PATTERN_RAM_7_3D );
  88. SETREG_NC( X_CLIP_3D, 0 );
  89. SETREG_NC( Y_CLIP_3D, 0 );
  90. SETREG_NC( TEX_SRAM_CTRL_3D, 0 ); // Set a 2D ctrl reg
  91. // =========== HOST XY UNIT REGISTERS ==============
  92. SETREG_NC( HXY_HOST_CTRL_3D, 0 );
  93. SETREG_NC( HXY_BASE0_ADDRESS_PTR_3D, 0 );
  94. SETREG_NC( HXY_BASE0_START_XY_3D, 0 );
  95. SETREG_NC( HXY_BASE0_EXTENT_XY_3D, 0 );
  96. SETREG_NC( HXY_BASE1_ADDRESS_PTR_3D, 0 );
  97. SETREG_NC( HXY_BASE1_OFFSET0_3D, 0 );
  98. SETREG_NC( HXY_BASE1_LENGTH_3D, 0 );
  99. SETREG_NC( MAILBOX0_3D, 0 );
  100. SETREG_NC( MAILBOX1_3D, 0 );
  101. SETREG_NC( MAILBOX2_3D, 0 );
  102. SETREG_NC( MAILBOX3_3D, 0 );
  103. // =========== PREFETCH UNIT REGISTERS ==============
  104. SETREG_NC( PF_CTRL_3D, 0); // Disable Prefetch
  105. SETREG_NC( PF_BASE_ADDR_3D, 0 ); // Set prefetch base reg
  106. SETREG_NC( PF_INST_3D, IDLE ); // Write IDLE instruction
  107. SETREG_NC( PF_DEST_ADDR_3D, 0 ); // Set prefetch dest address
  108. SETREG_NC( PF_FB_SEG_3D, 0 ); // Set frame segment reg
  109. SETREG_NC( PF_STATUS_3D, 0 ); // Reset Display_List_Switch
  110. // FUTURE - Host Master Control hardcoded to single read/write
  111. #if 0
  112. ppdev->LL_State.fSingleRead = ppdev->LL_State.fSingleWrite = 1;
  113. SETREG_NC( HOST_MASTER_CTRL_3D, // Set host master control
  114. (ppdev->LL_State.fSingleRead << 1) | ppdev->LL_State.fSingleWrite );
  115. #endif
  116. SETREG_NC( PF_CTRL_3D, 0x19); // Fetch on request
  117. // Initialize display list (displist.c)
  118. //
  119. if( (error_code = _InitDisplayList( ppdev, SIZE_TEMP_DL )) != LL_OK )
  120. return( error_code );
  121. // the 4x4 pattern from LL3D - thought to be best for 3 bit dither
  122. ppdev->LL_State.dither_array.pat[0] = 0x04150415;
  123. ppdev->LL_State.dither_array.pat[1] = 0x62736273;
  124. ppdev->LL_State.dither_array.pat[2] = 0x15041504;
  125. ppdev->LL_State.dither_array.pat[3] = 0x73627362;
  126. ppdev->LL_State.dither_array.pat[4] = 0x04150415;
  127. ppdev->LL_State.dither_array.pat[5] = 0x62736273;
  128. ppdev->LL_State.dither_array.pat[6] = 0x15041504;
  129. ppdev->LL_State.dither_array.pat[7] = 0x73627362;
  130. ppdev->LL_State.dither_x_offset = 0;
  131. ppdev->LL_State.dither_y_offset = 0;
  132. ppdev->LL_State.pattern_ram_state = PATTERN_RAM_INVALID;
  133. return( LL_OK );
  134. }