Source code of Windows XP (NT5)
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.

291 lines
7.8 KiB

  1. /*++
  2. Copyright (c) 1993 Weitek Corporation
  3. Module Name:
  4. p9000.c
  5. Abstract:
  6. This module contains the code specific to the Weitek P9000.
  7. Environment:
  8. Kernel mode
  9. Revision History may be found at the end of this file.
  10. --*/
  11. #include "p9.h"
  12. #include "p9gbl.h"
  13. #include "p9000.h"
  14. //
  15. // Static data for the P9000 specific support routines.
  16. //
  17. //
  18. // This table is used to compute the qsfselect value for the P9000 Srctl
  19. // register. This value is dependent upon a particular adapter's dot clock
  20. // divisor and its memory configuration. See p. 64 of the P9000 manual for
  21. // details.
  22. //
  23. ULONG qsfSelect[2][5] =
  24. {
  25. {4, 4, 5, 5, 6},
  26. {3, 3, 4, 4, 5},
  27. };
  28. VOID
  29. Init8720(
  30. PHW_DEVICE_EXTENSION HwDeviceExtension
  31. )
  32. /*++
  33. Routine Description:
  34. Initialize the P9000.
  35. Arguments:
  36. HwDeviceExtension - Pointer to the miniport driver's device extension.
  37. Return Value:
  38. None.
  39. --*/
  40. {
  41. P9_WR_REG(0x0000CL, 0x00000080L); //INTERRUPT-EN = disabled
  42. P9_WR_REG(0x00118L, 0x00000000L); //PREHRZC = 0
  43. P9_WR_REG(0x00130L, 0x00000000L); //PREVRTC = 0
  44. //
  45. // Initialize the P9 registers whose values are dependent upon a
  46. // particular OEM implementation.
  47. //
  48. P9_WR_REG(MEMCONF, HwDeviceExtension->AdapterDesc.ulMemConfVal);
  49. P9_WR_REG(SRCTL,
  50. HwDeviceExtension->AdapterDesc.ulSrctlVal |
  51. qsfSelect[(HwDeviceExtension->AdapterDesc.iClkDiv >> 2) - 1]
  52. [HwDeviceExtension->AdapterDesc.ulMemConfVal]);
  53. //
  54. // Initialize non-implementation specific registers.
  55. //
  56. P9_WR_REG(0x00188L, 0x00000186L); //RFPERIOD =
  57. P9_WR_REG(0x00190L, 0x000000FAL); //RLMAX =
  58. P9_WR_REG(0x80208L, 0x000000FFL); //allow writing in all 8 planes
  59. P9_WR_REG(0x8020CL, 0x0000000AL); //drawmode=buffer 0, write inside window
  60. P9_WR_REG(0x80190L, 0x00000000L); //disable any co-ord offset
  61. return;
  62. }
  63. VOID
  64. WriteTiming(
  65. PHW_DEVICE_EXTENSION HwDeviceExtension
  66. )
  67. /*++
  68. Routine Description:
  69. Arguments:
  70. HwDeviceExtension - Pointer to the miniport driver's device extension.
  71. pPal - Pointer to the array of pallete entries.
  72. StartIndex - Specifies the first pallete entry provided in pPal.
  73. Count - Number of palette entries in pPal
  74. Return Value:
  75. None.
  76. --*/
  77. {
  78. int div;
  79. div = (HwDeviceExtension->AdapterDesc.iClkDiv)/(HwDeviceExtension->usBitsPixel / 8);
  80. P9_WR_REG(0x010CL, HwDeviceExtension->VideoData.hsyncp/div - 1 ); // HRZSR
  81. P9_WR_REG(0x0110L, (HwDeviceExtension->VideoData.hsyncp + HwDeviceExtension->VideoData.hbp) / div - 1 ); //HRZBR
  82. P9_WR_REG(0x0114L, (HwDeviceExtension->VideoData.hsyncp + HwDeviceExtension->VideoData.hbp + HwDeviceExtension->VideoData.XSize)/div -1 ); //HRZBF
  83. P9_WR_REG(0x0108L, (HwDeviceExtension->VideoData.hsyncp + HwDeviceExtension->VideoData.hbp + HwDeviceExtension->VideoData.XSize + HwDeviceExtension->VideoData.hfp)/div - 1 ); //HRZT
  84. P9_WR_REG(0x0124L, HwDeviceExtension->VideoData.vsp); //VRTSR
  85. P9_WR_REG(0x0128L, HwDeviceExtension->VideoData.vsp + HwDeviceExtension->VideoData.vbp ); //VRTBR
  86. P9_WR_REG(0x012CL, HwDeviceExtension->VideoData.vsp + HwDeviceExtension->VideoData.vbp + HwDeviceExtension->VideoData.YSize ); //VRTBF
  87. P9_WR_REG(0x0120L, HwDeviceExtension->VideoData.vsp + HwDeviceExtension->VideoData.vbp + HwDeviceExtension->VideoData.YSize+HwDeviceExtension->VideoData.vfp ); //VRTT
  88. return;
  89. }
  90. VOID
  91. SysConf(
  92. PHW_DEVICE_EXTENSION HwDeviceExtension
  93. )
  94. /*++
  95. Routine Description:
  96. Arguments:
  97. HwDeviceExtension - Pointer to the miniport driver's device extension.
  98. Return Value:
  99. None.
  100. --*/
  101. {
  102. int i,j; // loop counters
  103. long sysval = 0x3000L; // swap bytes and words for little endian PC
  104. int xtem = HwDeviceExtension->VideoData.XSize * (HwDeviceExtension->usBitsPixel / 8); //save a copy for clearing bits in
  105. long ClipMax; // clipping register value for NotBusy to restore
  106. if (xtem & 0xf80) // each field in the sysconreg can only set
  107. { // a limited range of bits in the size
  108. j = 7; // each field is 3 bits wide
  109. for (i = 2048; i >= 128;i >>= 1) // look at all the bits field 3 can effect
  110. {
  111. if (i & xtem) // if this bit is on,
  112. {
  113. sysval |= ((long) j) << 20; // use this field to set it
  114. xtem &= ~i; // and remove the bit from the size
  115. break; // each field can only set one bit
  116. }
  117. j -= 1;
  118. }
  119. }
  120. if (xtem & 0x7C0) // do the same thing for field 2
  121. {
  122. j = 6; // each field is 3 bits wide
  123. for (i = 1024; i >= 64; i >>= 1) // look at all the bits field 2 can effect
  124. {
  125. if (i & xtem) // if this bit is on,
  126. {
  127. sysval |= ((long)j)<<17; // use this field to set it
  128. xtem &= ~i; // and remove the bit from the size
  129. break; // each field can only set one bit
  130. }
  131. j -= 1;
  132. }
  133. }
  134. if (xtem & 0x3E0) // do the same thing for field 1
  135. {
  136. j = 5; // each field is 3 bits wide
  137. for (i = 512; i >= 32;i >>= 1) // look at all the bits field 1 can effect
  138. {
  139. if (i & xtem) // if this bit is on,
  140. {
  141. sysval |= ((long) j) << 14; // use this field to set it
  142. xtem &= ~i; // and remove the bit from the size
  143. break; // each field can only set one bit
  144. }
  145. j -= 1;
  146. }
  147. }
  148. if (xtem != 0) // if there are bits left, it is an
  149. return; // illegal x size.
  150. P9_WR_REG(SYSCONFIG, sysval); // send data to the register
  151. P9_WR_REG(WMIN, 0); // minimum clipping register
  152. // calc and set max
  153. ClipMax=((long) HwDeviceExtension->VideoData.XSize - 1) << 16 |
  154. (div32(HwDeviceExtension->FrameLength, (SHORT) HwDeviceExtension->VideoData.XSize) - 1);
  155. // clipping to allow access to all of the extra memory.
  156. P9_WR_REG(WMAX, ClipMax);
  157. return;
  158. }
  159. VOID
  160. P9000SizeMem(
  161. PHW_DEVICE_EXTENSION HwDeviceExtension
  162. )
  163. /*++
  164. Routine Description:
  165. Determines the amount of video memory installed, as well as the P9000
  166. memory configuration, and stores them in the device extension.
  167. Arguments:
  168. HwDeviceExtension - Pointer to the miniport driver's device extension.
  169. Return Value:
  170. None.
  171. --*/
  172. {
  173. PULONG pulFrameBufAddr = (PULONG) HwDeviceExtension->FrameAddress;
  174. ULONG i;
  175. //
  176. // Assume 2 M of VRAM is installed.
  177. //
  178. HwDeviceExtension->AdapterDesc.ulMemConfVal = P90_MEM_CFG_3;
  179. HwDeviceExtension->FrameLength = 0x200000;
  180. //
  181. // Initialize the P9000 to memory configuration 3 (2M), so frame buffer
  182. // memory can be accessed.
  183. //
  184. P9_WR_REG(MEMCONF, P90_MEM_CFG_3);
  185. //
  186. // Write a series of test values to the frame buffer.
  187. //
  188. for (i = 0; i < 32; i++)
  189. {
  190. pulFrameBufAddr[i] = i;
  191. }
  192. //
  193. // Read back the test values. If any errors occur, this is not a valid
  194. // memory configuration.
  195. //
  196. for (i = 0; i < 32; i++)
  197. {
  198. if (pulFrameBufAddr[i] != i)
  199. {
  200. HwDeviceExtension->AdapterDesc.ulMemConfVal = P90_MEM_CFG_1;
  201. HwDeviceExtension->FrameLength = 0x100000;
  202. break;
  203. }
  204. }
  205. return;
  206. }