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.

241 lines
9.6 KiB

  1. /******************************Module*Header***********************************\
  2. * Module Name: hwmisc.c
  3. *
  4. * Hardware specific support routines and structures.
  5. *
  6. * Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
  7. * Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved.
  8. *
  9. \******************************************************************************/
  10. #include "precomp.h"
  11. #include "gdi.h"
  12. #include "tvp4020.h"
  13. // table to determine which logicops need read dest turned on in FBReadMode
  14. DWORD LogicopReadDest[] = {
  15. 0, /* 00 */
  16. __FB_READ_DESTINATION, /* 01 */
  17. __FB_READ_DESTINATION, /* 02 */
  18. 0, /* 03 */
  19. __FB_READ_DESTINATION, /* 04 */
  20. __FB_READ_DESTINATION, /* 05 */
  21. __FB_READ_DESTINATION, /* 06 */
  22. __FB_READ_DESTINATION, /* 07 */
  23. __FB_READ_DESTINATION, /* 08 */
  24. __FB_READ_DESTINATION, /* 09 */
  25. __FB_READ_DESTINATION, /* 10 */
  26. __FB_READ_DESTINATION, /* 11 */
  27. 0, /* 12 */
  28. __FB_READ_DESTINATION, /* 13 */
  29. __FB_READ_DESTINATION, /* 14 */
  30. 0, /* 15 */
  31. };
  32. // table to determine which logicops need read dest turned on in Config
  33. DWORD ConfigReadDest[] = {
  34. 0, /* 00 */
  35. __PERMEDIA_CONFIG_FBREAD_DST, /* 01 */
  36. __PERMEDIA_CONFIG_FBREAD_DST, /* 02 */
  37. 0, /* 03 */
  38. __PERMEDIA_CONFIG_FBREAD_DST, /* 04 */
  39. __PERMEDIA_CONFIG_FBREAD_DST, /* 05 */
  40. __PERMEDIA_CONFIG_FBREAD_DST, /* 06 */
  41. __PERMEDIA_CONFIG_FBREAD_DST, /* 07 */
  42. __PERMEDIA_CONFIG_FBREAD_DST, /* 08 */
  43. __PERMEDIA_CONFIG_FBREAD_DST, /* 09 */
  44. __PERMEDIA_CONFIG_FBREAD_DST, /* 10 */
  45. __PERMEDIA_CONFIG_FBREAD_DST, /* 11 */
  46. 0, /* 12 */
  47. __PERMEDIA_CONFIG_FBREAD_DST, /* 13 */
  48. __PERMEDIA_CONFIG_FBREAD_DST, /* 14 */
  49. 0, /* 15 */
  50. };
  51. //
  52. // Partial products array for width multiples of 32:
  53. // Use GET_PPCODE macro to access this
  54. //
  55. const PPCODE aPartialProducts[] =
  56. {
  57. 0, (0 << 6) | (0 << 3) | 0,
  58. 32, (0 << 6) | (0 << 3) | 1,
  59. 64, (0 << 6) | (1 << 3) | 1,
  60. 96, (1 << 6) | (1 << 3) | 1,
  61. 128, (1 << 6) | (1 << 3) | 2,
  62. 160, (1 << 6) | (2 << 3) | 2,
  63. 192, (2 << 6) | (2 << 3) | 2,
  64. 224, (1 << 6) | (2 << 3) | 3,
  65. 256, (2 << 6) | (2 << 3) | 3,
  66. 288, (1 << 6) | (3 << 3) | 3,
  67. 320, (2 << 6) | (3 << 3) | 3,
  68. 384, (3 << 6) | (3 << 3) | 3, // 352 = 384
  69. 384, (3 << 6) | (3 << 3) | 3,
  70. 416, (1 << 6) | (3 << 3) | 4,
  71. 448, (2 << 6) | (3 << 3) | 4,
  72. 512, (3 << 6) | (3 << 3) | 4, // 480 = 512
  73. 512, (3 << 6) | (3 << 3) | 4,
  74. 544, (1 << 6) | (4 << 3) | 4,
  75. 576, (2 << 6) | (4 << 3) | 4,
  76. 640, (3 << 6) | (4 << 3) | 4, // 608 = 640
  77. 640, (3 << 6) | (4 << 3) | 4,
  78. 768, (4 << 6) | (4 << 3) | 4, // 672 = 768
  79. 768, (4 << 6) | (4 << 3) | 4, // 704 = 768
  80. 768, (4 << 6) | (4 << 3) | 4, // 736 = 768
  81. 768, (4 << 6) | (4 << 3) | 4,
  82. 800, (1 << 6) | (4 << 3) | 5,
  83. 832, (2 << 6) | (4 << 3) | 5,
  84. 896, (3 << 6) | (4 << 3) | 5, // 864 = 896
  85. 896, (3 << 6) | (4 << 3) | 5,
  86. 1024, (4 << 6) | (4 << 3) | 5, // 928 = 1024
  87. 1024, (4 << 6) | (4 << 3) | 5, // 960 = 1024
  88. 1024, (4 << 6) | (4 << 3) | 5, // 992 = 1024
  89. 1024, (4 << 6) | (4 << 3) | 5,
  90. 1056, (1 << 6) | (5 << 3) | 5,
  91. 1088, (2 << 6) | (5 << 3) | 5,
  92. 1152, (3 << 6) | (5 << 3) | 5, // 1120 = 1152
  93. 1152, (3 << 6) | (5 << 3) | 5,
  94. 1280, (4 << 6) | (5 << 3) | 5, // 1184 = 1280
  95. 1280, (4 << 6) | (5 << 3) | 5, // 1216 = 1280
  96. 1280, (4 << 6) | (5 << 3) | 5, // 1248 = 1280
  97. 1280, (4 << 6) | (5 << 3) | 5,
  98. 1536, (5 << 6) | (5 << 3) | 5, // 1312 = 1536
  99. 1536, (5 << 6) | (5 << 3) | 5, // 1344 = 1536
  100. 1536, (5 << 6) | (5 << 3) | 5, // 1376 = 1536
  101. 1536, (5 << 6) | (5 << 3) | 5, // 1408 = 1536
  102. 1536, (5 << 6) | (5 << 3) | 5, // 1440 = 1536
  103. 1536, (5 << 6) | (5 << 3) | 5, // 1472 = 1536
  104. 1536, (5 << 6) | (5 << 3) | 5, // 1504 = 1536
  105. 1536, (5 << 6) | (5 << 3) | 5,
  106. 2048, (5 << 6) | (5 << 3) | 6, // 1568 = 2048
  107. 2048, (5 << 6) | (5 << 3) | 6, // 1600 = 2048
  108. 2048, (5 << 6) | (5 << 3) | 6, // 1632 = 2048
  109. 2048, (5 << 6) | (5 << 3) | 6, // 1664 = 2048
  110. 2048, (5 << 6) | (5 << 3) | 6, // 1696 = 2048
  111. 2048, (5 << 6) | (5 << 3) | 6, // 1728 = 2048
  112. 2048, (5 << 6) | (5 << 3) | 6, // 1760 = 2048
  113. 2048, (5 << 6) | (5 << 3) | 6, // 1792 = 2048
  114. 2048, (5 << 6) | (5 << 3) | 6, // 1824 = 2048
  115. 2048, (5 << 6) | (5 << 3) | 6, // 1856 = 2048
  116. 2048, (5 << 6) | (5 << 3) | 6, // 1888 = 2048
  117. 2048, (5 << 6) | (5 << 3) | 6, // 1920 = 2048
  118. 2048, (5 << 6) | (5 << 3) | 6, // 1952 = 2048
  119. 2048, (5 << 6) | (5 << 3) | 6, // 1984 = 2048
  120. 2048, (5 << 6) | (5 << 3) | 6, // 2016 = 2048
  121. 2048, (5 << 6) | (5 << 3) | 6, // 2048 = 2048
  122. };
  123. //------------------------------------------------------------------------------
  124. // VOID vCheckDefaultState
  125. //
  126. // Checks that the default state of the hardware is set.
  127. //
  128. //------------------------------------------------------------------------------
  129. VOID vCheckDefaultState(PPDev * ppdev)
  130. {
  131. #if 0
  132. // Make sure we sync before checking
  133. vInputBufferSync(ppdev);
  134. ASSERTDD(READ_FIFO_REG(__Permedia2TagdY) == INTtoFIXED(1),
  135. "vCheckDefaultState: dY is not 1.0");
  136. ASSERTDD(READ_FIFO_REG(__Permedia2TagTextureAddressMode)
  137. == __PERMEDIA_DISABLE,
  138. "vCheckDefaultState: TextureAddressMode is not disabled");
  139. ASSERTDD(READ_FIFO_REG(__Permedia2TagTextureColorMode)
  140. == __PERMEDIA_DISABLE,
  141. "vCheckDefaultState: TextureColorMode is not disabled");
  142. // ASSERTDD(P2_READ_FIFO_REG(__Permedia2TagTextureReadMode)
  143. // == __PERMEDIA_DISABLE,
  144. // "vCheckDefaultState: TextureReadMode is not disabled");
  145. ASSERTDD(READ_FIFO_REG(__Permedia2TagAlphaBlendMode)
  146. == __PERMEDIA_DISABLE,
  147. "vCheckDefaultState: AlphaBlendMode is not disabled");
  148. ASSERTDD(READ_FIFO_REG(__Permedia2TagColorDDAMode)
  149. == __PERMEDIA_DISABLE,
  150. "vCheckDefaultState: ColorDDAMode is not disabled");
  151. ASSERTDD(READ_FIFO_REG(__Permedia2TagDitherMode)
  152. == __PERMEDIA_DISABLE,
  153. "vCheckDefaultState: DitherMode is not disabled");
  154. ASSERTDD(READ_FIFO_REG(__Permedia2TagYUVMode)
  155. == __PERMEDIA_DISABLE,
  156. "vCheckDefaultState: YUVMode is not disabled");
  157. #endif
  158. }
  159. //-----------------------------------------------------------------------------
  160. //
  161. // VOID vCalcPackedPP
  162. //
  163. // Function:
  164. // Calculate the packed partial products for the given width.
  165. // If outPitch is not NULL, then return the pitch in pixels
  166. // for the passed back packed partial product.
  167. //
  168. //-----------------------------------------------------------------------------
  169. VOID
  170. vCalcPackedPP(LONG width,
  171. LONG* outPitch,
  172. ULONG* outPackedPP)
  173. {
  174. LONG pitch = (width + 31) & ~31;
  175. LONG pp[4];
  176. LONG ppn;
  177. LONG j;
  178. do
  179. {
  180. ppn = pp[0] = pp[1] = pp[2] = pp[3] = 0;
  181. if ( pitch >= MAX_PARTIAL_PRODUCT_P2 )
  182. {
  183. ppn = pitch >> (MAX_PARTIAL_PRODUCT_P2);
  184. for ( j = 0; j < ppn; j++ )
  185. {
  186. pp[j] = 1 + MAX_PARTIAL_PRODUCT_P2 - MIN_PARTIAL_PRODUCT_P2;
  187. }
  188. }
  189. for ( j = MIN_PARTIAL_PRODUCT_P2 ; j < MAX_PARTIAL_PRODUCT_P2 ; j++ )
  190. {
  191. if ( pitch & (1 << j) )
  192. {
  193. if ( ppn < 4 )
  194. pp[ppn] = j + 1 - MIN_PARTIAL_PRODUCT_P2;
  195. ppn++;
  196. }
  197. }
  198. pitch += 32; // Add 32 to the pitch just in case we have
  199. // too many pps.
  200. } while ( ppn > 3 ); // We have to loop until we get a pitch
  201. // with < 4 pps
  202. pitch -= 32; // Pitch is now the correct number of words
  203. if (outPitch != NULL)
  204. {
  205. *outPitch = pitch;
  206. }
  207. else
  208. {
  209. // if outPitch is null, then caller expects calculated pitch to be
  210. // the same as the width
  211. ASSERTDD(pitch == width, "vCalcPackedPP: pitch does not equal width");
  212. }
  213. *outPackedPP = pp[0] | (pp[1] << 3) | (pp[2] << 6);
  214. }// vCalcPackedPP()