VesaBiosExtensions.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. /** @file
  2. Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #ifndef _VESA_BIOS_EXTENSIONS_H_
  6. #define _VESA_BIOS_EXTENSIONS_H_
  7. //
  8. // Turn on byte packing of data structures
  9. //
  10. #pragma pack(1)
  11. //
  12. // VESA BIOS Extensions status codes
  13. //
  14. #define VESA_BIOS_EXTENSIONS_STATUS_SUCCESS 0x004f
  15. //
  16. // VESA BIOS Extensions Services
  17. //
  18. #define VESA_BIOS_EXTENSIONS_RETURN_CONTROLLER_INFORMATION 0x4f00
  19. /*++
  20. Routine Description:
  21. Function 00 : Return Controller Information
  22. Arguments:
  23. Inputs:
  24. AX = 0x4f00
  25. ES:DI = Pointer to buffer to place VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK structure
  26. Outputs:
  27. AX = Return Status
  28. --*/
  29. #define VESA_BIOS_EXTENSIONS_RETURN_MODE_INFORMATION 0x4f01
  30. /*++
  31. Routine Description:
  32. Function 01 : Return Mode Information
  33. Arguments:
  34. Inputs:
  35. AX = 0x4f01
  36. CX = Mode Number
  37. ES:DI = Pointer to buffer to place VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK structure
  38. Outputs:
  39. AX = Return Status
  40. --*/
  41. #define VESA_BIOS_EXTENSIONS_SET_MODE 0x4f02
  42. /*++
  43. Routine Description:
  44. Function 02 : Set Mode
  45. Arguments:
  46. Inputs:
  47. AX = 0x4f02
  48. BX = Desired mode to set
  49. D0-D8 = Mode Number
  50. D9-D10 = Reserved (must be 0)
  51. D11 = 0 - Use current default refresh rate
  52. = 1 - Use user specfieid CRTC values for refresh rate
  53. D12-D13 = Reserved (must be 0)
  54. D14 = 0 - Use windowed frame buffer model
  55. = 1 - Use linear/flat frame buffer model
  56. D15 = 0 - Clear display memory
  57. = 1 - Don't clear display memory
  58. ES:DI = Pointer to buffer to the VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK structure
  59. Outputs:
  60. AX = Return Status
  61. --*/
  62. #define VESA_BIOS_EXTENSIONS_RETURN_CURRENT_MODE 0x4f03
  63. /*++
  64. Routine Description:
  65. Function 03 : Return Current Mode
  66. Arguments:
  67. Inputs:
  68. AX = 0x4f03
  69. Outputs:
  70. AX = Return Status
  71. BX = Current mode
  72. D0-D13 = Mode Number
  73. D14 = 0 - Windowed frame buffer model
  74. = 1 - Linear/flat frame buffer model
  75. D15 = 0 - Memory cleared at last mode set
  76. = 1 - Memory not cleared at last mode set
  77. --*/
  78. #define VESA_BIOS_EXTENSIONS_SAVE_RESTORE_STATE 0x4f04
  79. /*++
  80. Routine Description:
  81. Function 04 : Save/Restore State
  82. Arguments:
  83. Inputs:
  84. AX = 0x4f03
  85. DL = 0x00 - Return Save/Restore State buffer size
  86. = 0x01 - Save State
  87. = 0x02 - Restore State
  88. CX = Requested Status
  89. D0 = Save/Restore controller hardware state
  90. D1 = Save/Restore BIOS data state
  91. D2 = Save/Restore DAC state
  92. D3 = Save/Restore Regsiter state
  93. ES:BX = Pointer to buffer if DL=1 or DL=2
  94. Outputs:
  95. AX = Return Status
  96. BX = Number of 64 byte blocks to hold the state buffer if DL=0
  97. --*/
  98. #define VESA_BIOS_EXTENSIONS_EDID 0x4f15
  99. /*++
  100. Routine Description:
  101. Function 15 : implement VBE/DDC service
  102. Arguments:
  103. Inputs:
  104. AX = 0x4f15
  105. BL = 0x00 - Report VBE/DDC Capabilities
  106. CX = 0x00 - Controller unit number (00 = primary controller)
  107. ES:DI = Null pointer, must be 0:0 in version 1.0
  108. Outputs:
  109. AX = Return Status
  110. BH = Approx. time in seconds, rounded up, to transfer one EDID block(128 bytes)
  111. BL = DDC level supported
  112. D0 = 0 DDC1 not supported
  113. = 1 DDC1 supported
  114. D1 = 0 DDC2 not supported
  115. = 1 DDC2 supported
  116. D2 = 0 Screen not blanked during data transfer
  117. = 1 Screen blanked during data transfer
  118. Inputs:
  119. AX = 0x4f15
  120. BL = 0x01 - Read EDID
  121. CX = 0x00 - Controller unit number (00 = primary controller)
  122. DX = 0x00 - EDID block number
  123. ES:DI = Pointer to buffer in which the EDID block is returned
  124. Outputs:
  125. AX = Return Status
  126. --*/
  127. //
  128. // Timing data from EDID data block
  129. //
  130. #define VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE 128
  131. #define VESA_BIOS_EXTENSIONS_EDID_ESTABLISHED_TIMING_MAX_NUMBER 17
  132. //
  133. // Established Timings: 24 possible resolutions
  134. // Standard Timings: 8 possible resolutions
  135. // Detailed Timings: 4 possible resolutions
  136. //
  137. #define VESA_BIOS_EXTENSIONS_EDID_TIMING_MAX_NUMBER 36
  138. //
  139. // Timing data size for Established Timings, Standard Timings and Detailed Timings
  140. //
  141. #define VESA_BIOS_EXTENSIONS_ESTABLISHED_TIMING_SIZE 3
  142. #define VESA_BIOS_EXTENSIONS_STANDARD_TIMING_SIZE 16
  143. #define VESA_BIOS_EXTENSIONS_DETAILED_TIMING_EACH_DESCRIPTOR_SIZE 18
  144. #define VESA_BIOS_EXTENSIONS_DETAILED_TIMING_DESCRIPTOR_MAX_SIZE 72
  145. typedef struct {
  146. UINT16 HorizontalResolution;
  147. UINT16 VerticalResolution;
  148. UINT16 RefreshRate;
  149. } VESA_BIOS_EXTENSIONS_EDID_TIMING;
  150. typedef struct {
  151. UINT32 ValidNumber;
  152. UINT32 Key[VESA_BIOS_EXTENSIONS_EDID_TIMING_MAX_NUMBER];
  153. } VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING;
  154. typedef struct {
  155. UINT8 Header[8]; // EDID header "00 FF FF FF FF FF FF 00"
  156. UINT16 ManufactureName; // EISA 3-character ID
  157. UINT16 ProductCode; // Vendor assigned code
  158. UINT32 SerialNumber; // 32-bit serial number
  159. UINT8 WeekOfManufacture; // Week number
  160. UINT8 YearOfManufacture; // Year
  161. UINT8 EdidVersion; // EDID Structure Version
  162. UINT8 EdidRevision; // EDID Structure Revision
  163. UINT8 VideoInputDefinition;
  164. UINT8 MaxHorizontalImageSize; // cm
  165. UINT8 MaxVerticalImageSize; // cm
  166. UINT8 DisplayTransferCharacteristic;
  167. UINT8 FeatureSupport;
  168. UINT8 RedGreenLowBits; // Rx1 Rx0 Ry1 Ry0 Gx1 Gx0 Gy1Gy0
  169. UINT8 BlueWhiteLowBits; // Bx1 Bx0 By1 By0 Wx1 Wx0 Wy1 Wy0
  170. UINT8 RedX; // Red-x Bits 9 - 2
  171. UINT8 RedY; // Red-y Bits 9 - 2
  172. UINT8 GreenX; // Green-x Bits 9 - 2
  173. UINT8 GreenY; // Green-y Bits 9 - 2
  174. UINT8 BlueX; // Blue-x Bits 9 - 2
  175. UINT8 BlueY; // Blue-y Bits 9 - 2
  176. UINT8 WhiteX; // White-x Bits 9 - 2
  177. UINT8 WhiteY; // White-x Bits 9 - 2
  178. UINT8 EstablishedTimings[VESA_BIOS_EXTENSIONS_ESTABLISHED_TIMING_SIZE];
  179. UINT8 StandardTimingIdentification[VESA_BIOS_EXTENSIONS_STANDARD_TIMING_SIZE];
  180. UINT8 DetailedTimingDescriptions[VESA_BIOS_EXTENSIONS_DETAILED_TIMING_DESCRIPTOR_MAX_SIZE];
  181. UINT8 ExtensionFlag; // Number of (optional) 128-byte EDID extension blocks to follow
  182. UINT8 Checksum;
  183. } VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK;
  184. //
  185. // Super VGA Information Block
  186. //
  187. typedef struct {
  188. UINT32 VESASignature; // 'VESA' 4 byte signature
  189. UINT16 VESAVersion; // VBE version number
  190. UINT32 OEMStringPtr; // Pointer to OEM string
  191. UINT32 Capabilities; // Capabilities of video card
  192. UINT32 VideoModePtr; // Pointer to an array of 16-bit supported modes values terminated by 0xFFFF
  193. UINT16 TotalMemory; // Number of 64kb memory blocks
  194. UINT16 OemSoftwareRev; // VBE implementation Software revision
  195. UINT32 OemVendorNamePtr; // VbeFarPtr to Vendor Name String
  196. UINT32 OemProductNamePtr; // VbeFarPtr to Product Name String
  197. UINT32 OemProductRevPtr; // VbeFarPtr to Product Revision String
  198. UINT8 Reserved[222]; // Reserved for VBE implementation scratch area
  199. UINT8 OemData[256]; // Data area for OEM strings. Pad to 512 byte block size
  200. } VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK;
  201. //
  202. // Super VGA Information Block VESASignature values
  203. //
  204. #define VESA_BIOS_EXTENSIONS_VESA_SIGNATURE SIGNATURE_32 ('V', 'E', 'S', 'A')
  205. #define VESA_BIOS_EXTENSIONS_VBE2_SIGNATURE SIGNATURE_32 ('V', 'B', 'E', '2')
  206. //
  207. // Super VGA Information Block VESAVersion values
  208. //
  209. #define VESA_BIOS_EXTENSIONS_VERSION_1_2 0x0102
  210. #define VESA_BIOS_EXTENSIONS_VERSION_2_0 0x0200
  211. #define VESA_BIOS_EXTENSIONS_VERSION_3_0 0x0300
  212. //
  213. // Super VGA Information Block Capabilities field bit definitions
  214. //
  215. #define VESA_BIOS_EXTENSIONS_CAPABILITY_8_BIT_DAC 0x01 // 0: DAC width is fixed at 6 bits/color
  216. // 1: DAC width switchable to 8 bits/color
  217. //
  218. #define VESA_BIOS_EXTENSIONS_CAPABILITY_NOT_VGA 0x02 // 0: Controller is VGA compatible
  219. // 1: Controller is not VGA compatible
  220. //
  221. #define VESA_BIOS_EXTENSIONS_CAPABILITY_NOT_NORMAL_RAMDAC 0x04 // 0: Normal RAMDAC operation
  222. // 1: Use blank bit in function 9 to program RAMDAC
  223. //
  224. #define VESA_BIOS_EXTENSIONS_CAPABILITY_STEREOSCOPIC 0x08 // 0: No hardware stereoscopic signal support
  225. // 1: Hardware stereoscopic signal support
  226. //
  227. #define VESA_BIOS_EXTENSIONS_CAPABILITY_VESA_EVC 0x10 // 0: Stero signaling supported via external VESA stereo connector
  228. // 1: Stero signaling supported via VESA EVC connector
  229. //
  230. // Super VGA mode number bite field definitions
  231. //
  232. #define VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA 0x0100 // 0: Not a VESA defined VBE mode
  233. // 1: A VESA defined VBE mode
  234. //
  235. #define VESA_BIOS_EXTENSIONS_MODE_NUMBER_REFRESH_CONTROL_USER 0x0800 // 0: Use current BIOS default referesh rate
  236. // 1: Use the user specified CRTC values for refresh rate
  237. //
  238. #define VESA_BIOS_EXTENSIONS_MODE_NUMBER_LINEAR_FRAME_BUFFER 0x4000 // 0: Use a banked/windowed frame buffer
  239. // 1: Use a linear/flat frame buffer
  240. //
  241. #define VESA_BIOS_EXTENSIONS_MODE_NUMBER_PRESERVE_MEMORY 0x8000 // 0: Clear display memory
  242. // 1: Preseve display memory
  243. //
  244. // Super VGA Information Block mode list terminator value
  245. //
  246. #define VESA_BIOS_EXTENSIONS_END_OF_MODE_LIST 0xffff
  247. //
  248. // Window Function
  249. //
  250. typedef
  251. VOID
  252. (*VESA_BIOS_EXTENSIONS_WINDOW_FUNCTION) (
  253. VOID
  254. );
  255. //
  256. // Super VGA Mode Information Block
  257. //
  258. typedef struct {
  259. //
  260. // Manadory fields for all VESA Bios Extensions revisions
  261. //
  262. UINT16 ModeAttributes; // Mode attributes
  263. UINT8 WinAAttributes; // Window A attributes
  264. UINT8 WinBAttributes; // Window B attributes
  265. UINT16 WinGranularity; // Window granularity in k
  266. UINT16 WinSize; // Window size in k
  267. UINT16 WinASegment; // Window A segment
  268. UINT16 WinBSegment; // Window B segment
  269. UINT32 WindowFunction; // Pointer to window function
  270. UINT16 BytesPerScanLine; // Bytes per scanline
  271. //
  272. // Manadory fields for VESA Bios Extensions 1.2 and above
  273. //
  274. UINT16 XResolution; // Horizontal resolution
  275. UINT16 YResolution; // Vertical resolution
  276. UINT8 XCharSize; // Character cell width
  277. UINT8 YCharSize; // Character cell height
  278. UINT8 NumberOfPlanes; // Number of memory planes
  279. UINT8 BitsPerPixel; // Bits per pixel
  280. UINT8 NumberOfBanks; // Number of CGA style banks
  281. UINT8 MemoryModel; // Memory model type
  282. UINT8 BankSize; // Size of CGA style banks
  283. UINT8 NumberOfImagePages; // Number of images pages
  284. UINT8 Reserved1; // Reserved
  285. UINT8 RedMaskSize; // Size of direct color red mask
  286. UINT8 RedFieldPosition; // Bit posn of lsb of red mask
  287. UINT8 GreenMaskSize; // Size of direct color green mask
  288. UINT8 GreenFieldPosition; // Bit posn of lsb of green mask
  289. UINT8 BlueMaskSize; // Size of direct color blue mask
  290. UINT8 BlueFieldPosition; // Bit posn of lsb of blue mask
  291. UINT8 RsvdMaskSize; // Size of direct color res mask
  292. UINT8 RsvdFieldPosition; // Bit posn of lsb of res mask
  293. UINT8 DirectColorModeInfo; // Direct color mode attributes
  294. //
  295. // Manadory fields for VESA Bios Extensions 2.0 and above
  296. //
  297. UINT32 PhysBasePtr; // Physical Address for flat memory frame buffer
  298. UINT32 Reserved2; // Reserved
  299. UINT16 Reserved3; // Reserved
  300. //
  301. // Manadory fields for VESA Bios Extensions 3.0 and above
  302. //
  303. UINT16 LinBytesPerScanLine; // Bytes/scan line for linear modes
  304. UINT8 BnkNumberOfImagePages; // Number of images for banked modes
  305. UINT8 LinNumberOfImagePages; // Number of images for linear modes
  306. UINT8 LinRedMaskSize; // Size of direct color red mask (linear mode)
  307. UINT8 LinRedFieldPosition; // Bit posiiton of lsb of red mask (linear modes)
  308. UINT8 LinGreenMaskSize; // Size of direct color green mask (linear mode)
  309. UINT8 LinGreenFieldPosition; // Bit posiiton of lsb of green mask (linear modes)
  310. UINT8 LinBlueMaskSize; // Size of direct color blue mask (linear mode)
  311. UINT8 LinBlueFieldPosition; // Bit posiiton of lsb of blue mask (linear modes)
  312. UINT8 LinRsvdMaskSize; // Size of direct color reserved mask (linear mode)
  313. UINT8 LinRsvdFieldPosition; // Bit posiiton of lsb of reserved mask (linear modes)
  314. UINT32 MaxPixelClock; // Maximum pixel clock (in Hz) for graphics mode
  315. UINT8 Pad[190]; // Pad to 256 byte block size
  316. } VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK;
  317. //
  318. // Super VGA Mode Information Block ModeAttributes field bit definitions
  319. //
  320. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_HARDWARE 0x0001 // 0: Mode not supported in handware
  321. // 1: Mode supported in handware
  322. //
  323. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_TTY 0x0004 // 0: TTY Output functions not supported by BIOS
  324. // 1: TTY Output functions supported by BIOS
  325. //
  326. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_COLOR 0x0008 // 0: Monochrome mode
  327. // 1: Color mode
  328. //
  329. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_GRAPHICS 0x0010 // 0: Text mode
  330. // 1: Graphics mode
  331. //
  332. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NOT_VGA 0x0020 // 0: VGA compatible mode
  333. // 1: Not a VGA compatible mode
  334. //
  335. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NOT_WINDOWED 0x0040 // 0: VGA compatible windowed memory mode
  336. // 1: Not a VGA compatible windowed memory mode
  337. //
  338. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER 0x0080 // 0: No linear fram buffer mode available
  339. // 1: Linear frame buffer mode available
  340. //
  341. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_DOUBLE_SCAN 0x0100 // 0: No double scan mode available
  342. // 1: Double scan mode available
  343. //
  344. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_INTERLACED 0x0200 // 0: No interlaced mode is available
  345. // 1: Interlaced mode is available
  346. //
  347. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NO_TRIPPLE_BUFFER 0x0400 // 0: No hardware triple buffer mode support available
  348. // 1: Hardware triple buffer mode support available
  349. //
  350. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_STEREOSCOPIC 0x0800 // 0: No hardware steroscopic display support
  351. // 1: Hardware steroscopic display support
  352. //
  353. #define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_DUAL_DISPLAY 0x1000 // 0: No dual display start address support
  354. // 1: Dual display start address support
  355. //
  356. // Super VGA Mode Information Block WinAAttribite/WinBAttributes field bit definitions
  357. //
  358. #define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_RELOCATABLE 0x01 // 0: Single non-relocatable window only
  359. // 1: Relocatable window(s) are supported
  360. //
  361. #define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_READABLE 0x02 // 0: Window is not readable
  362. // 1: Window is readable
  363. //
  364. #define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_WRITABLE 0x04 // 0: Window is not writable
  365. // 1: Window is writable
  366. //
  367. // Super VGA Mode Information Block DirectColorMode field bit definitions
  368. //
  369. #define VESA_BIOS_EXTENSIONS_DIRECT_COLOR_MODE_PROG_COLOR_RAMP 0x01 // 0: Color ram is fixed
  370. // 1: Color ramp is programmable
  371. //
  372. #define VESA_BIOS_EXTENSIONS_DIRECT_COLOR_MODE_RSVD_USABLE 0x02 // 0: Bits in Rsvd field are reserved
  373. // 1: Bits in Rsdv field are usable
  374. //
  375. // Super VGA Memory Models
  376. //
  377. typedef enum {
  378. MemPL = 3, // Planar memory model
  379. MemPK = 4, // Packed pixel memory model
  380. MemRGB = 6, // Direct color RGB memory model
  381. MemYUV = 7 // Direct color YUV memory model
  382. } VESA_BIOS_EXTENSIONS_MEMORY_MODELS;
  383. //
  384. // Super VGA CRTC Information Block
  385. //
  386. typedef struct {
  387. UINT16 HorizontalTotal; // Horizontal total in pixels
  388. UINT16 HorizontalSyncStart; // Horizontal sync start in pixels
  389. UINT16 HorizontalSyncEnd; // Horizontal sync end in pixels
  390. UINT16 VericalTotal; // Vertical total in pixels
  391. UINT16 VericalSyncStart; // Vertical sync start in pixels
  392. UINT16 VericalSyncEnd; // Vertical sync end in pixels
  393. UINT8 Flags; // Flags (Interlaced/DoubleScan/etc).
  394. UINT32 PixelClock; // Pixel clock in units of Hz
  395. UINT16 RefreshRate; // Refresh rate in units of 0.01 Hz
  396. UINT8 Reserved[40]; // Pad
  397. } VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK;
  398. #define VESA_BIOS_EXTENSIONS_CRTC_FLAGS_DOUBLE_SCAN 0x01 // 0: Graphics mode is not souble scanned
  399. // 1: Graphics mode is double scanned
  400. //
  401. #define VESA_BIOS_EXTENSIONS_CRTC_FLAGSINTERLACED 0x02 // 0: Graphics mode is not interlaced
  402. // 1: Graphics mode is interlaced
  403. //
  404. #define VESA_BIOS_EXTENSIONS_CRTC_HORIZONTAL_SYNC_NEGATIVE 0x04 // 0: Horizontal sync polarity is positive(+)
  405. // 0: Horizontal sync polarity is negative(-)
  406. //
  407. #define VESA_BIOS_EXTENSIONS_CRTC_VERITICAL_SYNC_NEGATIVE 0x08 // 0: Verical sync polarity is positive(+)
  408. // 0: Verical sync polarity is negative(-)
  409. //
  410. // Turn off byte packing of data structures
  411. //
  412. #pragma pack()
  413. #endif