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.

272 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. vesa.h
  5. Abstract:
  6. This module implements VESA support.
  7. Author:
  8. Erick Smith (ericks) Sep. 2000
  9. Environment:
  10. kernel mode only
  11. Revision History:
  12. --*/
  13. #define VBE_GET_CONTROLLER_INFO 0x4F00
  14. #define VBE_GET_MODE_INFO 0x4F01
  15. #define VBE_SET_MODE 0x4F02
  16. #define VBE_GET_MODE 0x4F03
  17. #define VBE_SAVE_RESTORE_STATE 0x4F04
  18. #define VBE_WINDOW_CONTROL 0x4F05
  19. #define VBE_SCANLINE 0x4F06
  20. #define VBE_DISPLAY_START 0x4F07
  21. #define VBE_PALLET_FORMAT 0x4F08
  22. #define VBE_PALLET_DATA 0x4F09
  23. #define VBE_PROTECTED_MODE 0x4F0A
  24. #define VBE_PIXEL_CLOCK 0x4F0B
  25. #define VESA_STATUS_SUCCESS 0x004F
  26. //
  27. // VESA SuperVGA structures
  28. //
  29. #pragma pack(1)
  30. typedef struct _VGA_INFO_BLOCK
  31. {
  32. ULONG VesaSignature;
  33. USHORT VbeVersion;
  34. ULONG OemStringPtr;
  35. ULONG Capabilities;
  36. ULONG VideoModePtr;
  37. USHORT TotalMemory;
  38. //
  39. // VBE 2.0
  40. //
  41. USHORT OemSoftwareRev;
  42. ULONG OemVendorNamePtr;
  43. ULONG OemProductNamePtr;
  44. ULONG OemProductRevPtr;
  45. UCHAR Reserved[222];
  46. UCHAR OemData[256];
  47. } VGA_INFO_BLOCK, *PVGA_INFO_BLOCK;
  48. typedef struct _MODE_INFO_BLOCK
  49. {
  50. USHORT ModeAttributes;
  51. UCHAR WinAAttributes;
  52. UCHAR WinBAttributes;
  53. USHORT WinGranularity;
  54. USHORT WinSize;
  55. USHORT WinASegment;
  56. USHORT WinBSegment;
  57. ULONG WinFuncPtr;
  58. USHORT BytesPerScanLine;
  59. USHORT XResolution;
  60. USHORT YResolution;
  61. UCHAR XCharSize;
  62. UCHAR YCharSize;
  63. UCHAR NumberOfPlanes;
  64. UCHAR BitsPerPixel;
  65. UCHAR NumberOfBanks;
  66. UCHAR MemoryModel;
  67. UCHAR BankSize;
  68. UCHAR NumberOfImagePages;
  69. UCHAR Reserved1;
  70. UCHAR RedMaskSize;
  71. UCHAR RedFieldPosition;
  72. UCHAR GreenMaskSize;
  73. UCHAR GreenFieldPosition;
  74. UCHAR BlueMaskSize;
  75. UCHAR BlueFieldPosition;
  76. UCHAR RsvdMaskSize;
  77. UCHAR RsvdFieldPosition;
  78. UCHAR DirectColorModeInfo;
  79. //
  80. // VBE 2.0
  81. //
  82. ULONG PhysBasePtr;
  83. ULONG Reserved2;
  84. USHORT Reserved3;
  85. //
  86. // VBE 3.0
  87. //
  88. USHORT LinBytesPerScanLine;
  89. UCHAR BnkNumberOfImagePages;
  90. UCHAR LinNumberOfImagePages;
  91. UCHAR LinRedMaskSize;
  92. UCHAR LinRedFieldPosition;
  93. UCHAR LinGreenMaskSize;
  94. UCHAR LinGreenFieldPosition;
  95. UCHAR LinBlueMaskSize;
  96. UCHAR LinBlueFieldPosition;
  97. UCHAR LinRsvdMaskSize;
  98. UCHAR LinRsvdFieldPosition;
  99. ULONG MaxPixelClock;
  100. UCHAR Reserved4[190];
  101. } MODE_INFO_BLOCK, *PMODE_INFO_BLOCK;
  102. typedef struct _PALETTE_ENTRY
  103. {
  104. UCHAR Blue;
  105. UCHAR Green;
  106. UCHAR Red;
  107. UCHAR Alignment;
  108. } PALETTE_ENTRY, *PPALETTE_ENTRY;
  109. #pragma pack()
  110. typedef struct _VESA_INFO
  111. {
  112. USHORT ModeNumber;
  113. ULONG FrameBufferSize;
  114. MODE_INFO_BLOCK ModeInfoBlock;
  115. ULONG HardwareStateSize;
  116. UCHAR HardwareState[];
  117. } VESA_INFO, *PVESA_INFO;
  118. #define VDM_TRANSFER_SEGMENT 0x2000
  119. #define VDM_TRANSFER_OFFSET 0x0000
  120. #define VBE_CAP_DAC_WIDTH_8BPP 0x01
  121. #define VBE_CAP_NOT_VGA 0x02
  122. #define VBE_CAP_VSYNC_ON_PALETTE_UPDATE 0x04
  123. #define VBE_CAP_STEREO_SIGNAL 0x08
  124. #define VBE_CAP_STEREO_EVC_CONNECTOR 0x10
  125. #define SEG(x) ((x) >> 16)
  126. #define OFF(x) ((x) & 0xffff)
  127. #define TRANSFER_ADDRESS ((VDM_TRANSFER_SEGMENT << 4) + VDM_TRANSFER_OFFSET)
  128. #define INFOBLOCK_OFFSET(x) ((SEG((x)) << 4) + OFF((x)) - TRANSFER_ADDRESS)
  129. #define IS_LINEAR_MODE(x) ((x)->bitsPerPlane >= 8)
  130. VOID
  131. InitializeModeTable(
  132. PVOID HwDeviceExtension
  133. );
  134. BOOLEAN
  135. ValidateVbeInfo(
  136. PHW_DEVICE_EXTENSION hwDeviceExtension,
  137. PVGA_INFO_BLOCK InfoBlock
  138. );
  139. VOID
  140. UpdateRegistry(
  141. PHW_DEVICE_EXTENSION hwDeviceExtension,
  142. PWSTR ValueName,
  143. PUCHAR Value
  144. );
  145. ULONG
  146. GetVideoMemoryBaseAddress(
  147. PHW_DEVICE_EXTENSION hwDeviceExtension,
  148. PVIDEOMODE pRequestedMode
  149. );
  150. VP_STATUS
  151. VBESetMode(
  152. PHW_DEVICE_EXTENSION HwDeviceExtension,
  153. USHORT VesaModeNumber
  154. );
  155. USHORT
  156. VBEGetMode(
  157. PHW_DEVICE_EXTENSION HwDeviceExtension
  158. );
  159. VP_STATUS
  160. VBEGetModeInfo(
  161. PHW_DEVICE_EXTENSION hwDeviceExtension,
  162. USHORT ModeNumber,
  163. PMODE_INFO_BLOCK ModeInfoBlock
  164. );
  165. ULONG
  166. VBESaveState(
  167. PHW_DEVICE_EXTENSION HwDeviceExtension,
  168. PCHAR StateBuffer
  169. );
  170. VP_STATUS
  171. VBERestoreState(
  172. PHW_DEVICE_EXTENSION HwDeviceExtension,
  173. PCHAR StateBuffer,
  174. ULONG Size
  175. );
  176. VP_STATUS
  177. VBESetDisplayWindow(
  178. PHW_DEVICE_EXTENSION hwDeviceExtension,
  179. UCHAR WindowSelect,
  180. USHORT WindowNumber
  181. );
  182. USHORT
  183. VBEGetDisplayWindow(
  184. PHW_DEVICE_EXTENSION hwDeviceExtension,
  185. UCHAR WindowSelect
  186. );
  187. USHORT
  188. VBEGetScanLineLength(
  189. PHW_DEVICE_EXTENSION HwDeviceExtension
  190. );
  191. VP_STATUS
  192. VesaSaveHardwareState(
  193. PHW_DEVICE_EXTENSION HwDeviceExtension,
  194. PVIDEO_HARDWARE_STATE HardwareState,
  195. ULONG HardwareStateSize,
  196. USHORT ModeNumber
  197. );
  198. PCHAR
  199. SaveFrameBuffer(
  200. PHW_DEVICE_EXTENSION hwDeviceExtension,
  201. PVESA_INFO pVesaInfo
  202. );
  203. BOOLEAN
  204. IsSavedModeVesa(
  205. PVIDEO_HARDWARE_STATE HardwareState
  206. );
  207. VP_STATUS
  208. VesaRestoreHardwareState(
  209. PHW_DEVICE_EXTENSION HwDeviceExtension,
  210. PVIDEO_HARDWARE_STATE HardwareState,
  211. ULONG HardwareStateSize
  212. );
  213. ULONG
  214. RestoreFrameBuffer(
  215. PHW_DEVICE_EXTENSION hwDeviceExtension,
  216. PVESA_INFO pVesaInfo,
  217. PCHAR FrameBufferData
  218. );