LcdPlatformLib.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. /** @file
  2. Copyright (c) 2011-2018, ARM Ltd. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #ifndef LCD_PLATFORM_LIB_H_
  6. #define LCD_PLATFORM_LIB_H_
  7. #include <Protocol/GraphicsOutput.h>
  8. #define LCD_VRAM_SIZE SIZE_8MB
  9. // Modes definitions
  10. #define VGA 0
  11. #define SVGA 1
  12. #define XGA 2
  13. #define SXGA 3
  14. #define WSXGA 4
  15. #define UXGA 5
  16. #define HD 6
  17. #define WVGA 7
  18. #define QHD 8
  19. #define WSVGA 9
  20. #define HD720 10
  21. #define WXGA 11
  22. // VGA Mode: 640 x 480
  23. #define VGA_H_RES_PIXELS 640
  24. #define VGA_V_RES_PIXELS 480
  25. #define VGA_OSC_FREQUENCY 23750000 /* 0x016A6570 */
  26. #define VGA_H_SYNC ( 80 - 1)
  27. #define VGA_H_FRONT_PORCH ( 16 - 1)
  28. #define VGA_H_BACK_PORCH ( 64 - 1)
  29. #define VGA_V_SYNC ( 4 - 1)
  30. #define VGA_V_FRONT_PORCH ( 3 - 1)
  31. #define VGA_V_BACK_PORCH ( 13 - 1)
  32. // SVGA Mode: 800 x 600
  33. #define SVGA_H_RES_PIXELS 800
  34. #define SVGA_V_RES_PIXELS 600
  35. #define SVGA_OSC_FREQUENCY 38250000 /* 0x0247A610 */
  36. #define SVGA_H_SYNC ( 80 - 1)
  37. #define SVGA_H_FRONT_PORCH ( 32 - 1)
  38. #define SVGA_H_BACK_PORCH (112 - 1)
  39. #define SVGA_V_SYNC ( 4 - 1)
  40. #define SVGA_V_FRONT_PORCH ( 3 - 1)
  41. #define SVGA_V_BACK_PORCH ( 17 - 1)
  42. // XGA Mode: 1024 x 768
  43. #define XGA_H_RES_PIXELS 1024
  44. #define XGA_V_RES_PIXELS 768
  45. #define XGA_OSC_FREQUENCY 63500000 /* 0x03C8EEE0 */
  46. #define XGA_H_SYNC (104 - 1)
  47. #define XGA_H_FRONT_PORCH ( 48 - 1)
  48. #define XGA_H_BACK_PORCH (152 - 1)
  49. #define XGA_V_SYNC ( 4 - 1)
  50. #define XGA_V_FRONT_PORCH ( 3 - 1)
  51. #define XGA_V_BACK_PORCH ( 23 - 1)
  52. // SXGA Mode: 1280 x 1024
  53. #define SXGA_H_RES_PIXELS 1280
  54. #define SXGA_V_RES_PIXELS 1024
  55. #define SXGA_OSC_FREQUENCY 109000000 /* 0x067F3540 */
  56. #define SXGA_H_SYNC (136 - 1)
  57. #define SXGA_H_FRONT_PORCH ( 80 - 1)
  58. #define SXGA_H_BACK_PORCH (216 - 1)
  59. #define SXGA_V_SYNC ( 7 - 1)
  60. #define SXGA_V_FRONT_PORCH ( 3 - 1)
  61. #define SXGA_V_BACK_PORCH ( 29 - 1)
  62. // WSXGA+ Mode: 1680 x 1050
  63. #define WSXGA_H_RES_PIXELS 1680
  64. #define WSXGA_V_RES_PIXELS 1050
  65. #define WSXGA_OSC_FREQUENCY 147000000 /* 0x08C30AC0 */
  66. #define WSXGA_H_SYNC (170 - 1)
  67. #define WSXGA_H_FRONT_PORCH (104 - 1)
  68. #define WSXGA_H_BACK_PORCH (274 - 1)
  69. #define WSXGA_V_SYNC ( 5 - 1)
  70. #define WSXGA_V_FRONT_PORCH ( 4 - 1)
  71. #define WSXGA_V_BACK_PORCH ( 41 - 1)
  72. // UXGA Mode: 1600 x 1200
  73. #define UXGA_H_RES_PIXELS 1600
  74. #define UXGA_V_RES_PIXELS 1200
  75. #define UXGA_OSC_FREQUENCY 161000000 /* 0x0998AA40 */
  76. #define UXGA_H_SYNC (168 - 1)
  77. #define UXGA_H_FRONT_PORCH (112 - 1)
  78. #define UXGA_H_BACK_PORCH (280 - 1)
  79. #define UXGA_V_SYNC ( 4 - 1)
  80. #define UXGA_V_FRONT_PORCH ( 3 - 1)
  81. #define UXGA_V_BACK_PORCH ( 38 - 1)
  82. // HD Mode: 1920 x 1080
  83. #define HD_H_RES_PIXELS 1920
  84. #define HD_V_RES_PIXELS 1080
  85. #define HD_OSC_FREQUENCY 165000000 /* 0x09D5B340 */
  86. #define HD_H_SYNC ( 79 - 1)
  87. #define HD_H_FRONT_PORCH (128 - 1)
  88. #define HD_H_BACK_PORCH (328 - 1)
  89. #define HD_V_SYNC ( 5 - 1)
  90. #define HD_V_FRONT_PORCH ( 3 - 1)
  91. #define HD_V_BACK_PORCH ( 32 - 1)
  92. // WVGA Mode: 800 x 480
  93. #define WVGA_H_RES_PIXELS 800
  94. #define WVGA_V_RES_PIXELS 480
  95. #define WVGA_OSC_FREQUENCY 29500000 /* 0x01C22260 */
  96. #define WVGA_H_SYNC ( 72 - 1)
  97. #define WVGA_H_FRONT_PORCH ( 24 - 1)
  98. #define WVGA_H_BACK_PORCH ( 96 - 1)
  99. #define WVGA_V_SYNC ( 7 - 1)
  100. #define WVGA_V_FRONT_PORCH ( 3 - 1)
  101. #define WVGA_V_BACK_PORCH ( 10 - 1)
  102. // QHD Mode: 960 x 540
  103. #define QHD_H_RES_PIXELS 960
  104. #define QHD_V_RES_PIXELS 540
  105. #define QHD_OSC_FREQUENCY 40750000 /* 0x026DCBB0 */
  106. #define QHD_H_SYNC ( 96 - 1)
  107. #define QHD_H_FRONT_PORCH ( 32 - 1)
  108. #define QHD_H_BACK_PORCH (128 - 1)
  109. #define QHD_V_SYNC ( 5 - 1)
  110. #define QHD_V_FRONT_PORCH ( 3 - 1)
  111. #define QHD_V_BACK_PORCH ( 14 - 1)
  112. // WSVGA Mode: 1024 x 600
  113. #define WSVGA_H_RES_PIXELS 1024
  114. #define WSVGA_V_RES_PIXELS 600
  115. #define WSVGA_OSC_FREQUENCY 49000000 /* 0x02EBAE40 */
  116. #define WSVGA_H_SYNC (104 - 1)
  117. #define WSVGA_H_FRONT_PORCH ( 40 - 1)
  118. #define WSVGA_H_BACK_PORCH (144 - 1)
  119. #define WSVGA_V_SYNC ( 10 - 1)
  120. #define WSVGA_V_FRONT_PORCH ( 3 - 1)
  121. #define WSVGA_V_BACK_PORCH ( 11 - 1)
  122. // HD720 Mode: 1280 x 720
  123. #define HD720_H_RES_PIXELS 1280
  124. #define HD720_V_RES_PIXELS 720
  125. #define HD720_OSC_FREQUENCY 74500000 /* 0x0470C7A0 */
  126. #define HD720_H_SYNC (128 - 1)
  127. #define HD720_H_FRONT_PORCH ( 64 - 1)
  128. #define HD720_H_BACK_PORCH (192 - 1)
  129. #define HD720_V_SYNC ( 5 - 1)
  130. #define HD720_V_FRONT_PORCH ( 3 - 1)
  131. #define HD720_V_BACK_PORCH ( 20 - 1)
  132. // WXGA Mode: 1280 x 800
  133. #define WXGA_H_RES_PIXELS 1280
  134. #define WXGA_V_RES_PIXELS 800
  135. #define WXGA_OSC_FREQUENCY 83500000 /* 0x04FA1BE0 */
  136. #define WXGA_H_SYNC (128 - 1)
  137. #define WXGA_H_FRONT_PORCH ( 72 - 1)
  138. #define WXGA_H_BACK_PORCH (200 - 1)
  139. #define WXGA_V_SYNC ( 6 - 1)
  140. #define WXGA_V_FRONT_PORCH ( 3 - 1)
  141. #define WXGA_V_BACK_PORCH ( 22 - 1)
  142. // Colour Masks
  143. #define LCD_24BPP_RED_MASK 0x00FF0000
  144. #define LCD_24BPP_GREEN_MASK 0x0000FF00
  145. #define LCD_24BPP_BLUE_MASK 0x000000FF
  146. #define LCD_24BPP_RESERVED_MASK 0xFF000000
  147. #define LCD_16BPP_555_RED_MASK 0x00007C00
  148. #define LCD_16BPP_555_GREEN_MASK 0x000003E0
  149. #define LCD_16BPP_555_BLUE_MASK 0x0000001F
  150. #define LCD_16BPP_555_RESERVED_MASK 0x00000000
  151. #define LCD_16BPP_565_RED_MASK 0x0000F800
  152. #define LCD_16BPP_565_GREEN_MASK 0x000007E0
  153. #define LCD_16BPP_565_BLUE_MASK 0x0000001F
  154. #define LCD_16BPP_565_RESERVED_MASK 0x00008000
  155. #define LCD_12BPP_444_RED_MASK 0x00000F00
  156. #define LCD_12BPP_444_GREEN_MASK 0x000000F0
  157. #define LCD_12BPP_444_BLUE_MASK 0x0000000F
  158. #define LCD_12BPP_444_RESERVED_MASK 0x0000F000
  159. /** The enumeration maps the PL111 LcdBpp values used in the LCD Control
  160. Register
  161. **/
  162. typedef enum {
  163. LCD_BITS_PER_PIXEL_1 = 0,
  164. LCD_BITS_PER_PIXEL_2,
  165. LCD_BITS_PER_PIXEL_4,
  166. LCD_BITS_PER_PIXEL_8,
  167. LCD_BITS_PER_PIXEL_16_555,
  168. LCD_BITS_PER_PIXEL_24,
  169. LCD_BITS_PER_PIXEL_16_565,
  170. LCD_BITS_PER_PIXEL_12_444
  171. } LCD_BPP;
  172. // Display timing settings.
  173. typedef struct {
  174. UINT32 Resolution;
  175. UINT32 Sync;
  176. UINT32 BackPorch;
  177. UINT32 FrontPorch;
  178. } SCAN_TIMINGS;
  179. /** Platform related initialization function.
  180. @param[in] Handle Handle to the LCD device instance.
  181. @retval EFI_SUCCESS Plaform library initialized successfully.
  182. @retval !(EFI_SUCCESS) Other errors.
  183. **/
  184. EFI_STATUS
  185. LcdPlatformInitializeDisplay (
  186. IN EFI_HANDLE Handle
  187. );
  188. /** Allocate VRAM memory in DRAM for the framebuffer
  189. (unless it is reserved already).
  190. The allocated address can be used to set the framebuffer.
  191. @param[out] VramBaseAddress A pointer to the framebuffer address.
  192. @param[out] VramSize A pointer to the size of the frame
  193. buffer in bytes
  194. @retval EFI_SUCCESS Frame buffer memory allocated successfully.
  195. @retval !(EFI_SUCCESS) Other errors.
  196. **/
  197. EFI_STATUS
  198. LcdPlatformGetVram (
  199. OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
  200. OUT UINTN* VramSize
  201. );
  202. /** Return total number of modes supported.
  203. Note: Valid mode numbers are 0 to MaxMode - 1
  204. See Section 12.9 of the UEFI Specification 2.7
  205. @retval UINT32 Mode Number.
  206. **/
  207. UINT32
  208. LcdPlatformGetMaxMode (
  209. VOID
  210. );
  211. /** Set the requested display mode.
  212. @param[in] ModeNumber Mode Number.
  213. @retval EFI_SUCCESS Mode set successfully.
  214. @retval EFI_INVALID_PARAMETER Requested mode not found.
  215. @retval !(EFI_SUCCESS) Other errors.
  216. **/
  217. EFI_STATUS
  218. LcdPlatformSetMode (
  219. IN UINT32 ModeNumber
  220. );
  221. /** Return information for the requested mode number.
  222. @param[in] ModeNumber Mode Number.
  223. @param[out] Info Pointer for returned mode information
  224. (on success).
  225. @retval EFI_SUCCESS Mode information for the requested mode
  226. returned successfully.
  227. @retval EFI_INVALID_PARAMETER Requested mode not found.
  228. **/
  229. EFI_STATUS
  230. LcdPlatformQueryMode (
  231. IN UINT32 ModeNumber,
  232. OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
  233. );
  234. /** Return display timing information for the requested mode number.
  235. @param[in] ModeNumber Mode Number.
  236. @param[out] Horizontal Pointer to horizontal timing parameters.
  237. (Resolution, Sync, Back porch, Front porch)
  238. @param[out] Vertical Pointer to vertical timing parameters.
  239. (Resolution, Sync, Back porch, Front porch)
  240. @retval EFI_SUCCESS Display timing information for the requested
  241. mode returned successfully.
  242. @retval EFI_INVALID_PARAMETER Requested mode not found.
  243. **/
  244. EFI_STATUS
  245. LcdPlatformGetTimings (
  246. IN UINT32 ModeNumber,
  247. OUT SCAN_TIMINGS **Horizontal,
  248. OUT SCAN_TIMINGS **Vertical
  249. );
  250. /** Return bits per pixel information for a mode number.
  251. @param[in] ModeNumber Mode Number.
  252. @param[out] Bpp Pointer to value bits per pixel information.
  253. @retval EFI_SUCCESS Bit per pixel information for the requested
  254. mode returned successfully.
  255. @retval EFI_INVALID_PARAMETER Requested mode not found.
  256. **/
  257. EFI_STATUS
  258. LcdPlatformGetBpp (
  259. IN UINT32 ModeNumber,
  260. OUT LCD_BPP* Bpp
  261. );
  262. #endif /* LCD_PLATFORM_LIB_H_ */