3 Copyright (c) 2011-2020, Arm Limited. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
8 #ifndef LCD_PLATFORM_LIB_H_
9 #define LCD_PLATFORM_LIB_H_
11 #include <Protocol/GraphicsOutput.h>
13 #define LCD_VRAM_SIZE SIZE_8MB
29 // VGA Mode: 640 x 480
30 #define VGA_H_RES_PIXELS 640
31 #define VGA_V_RES_PIXELS 480
32 #define VGA_OSC_FREQUENCY 23750000 /* 0x016A6570 */
34 #define VGA_H_SYNC ( 80 - 1)
35 #define VGA_H_FRONT_PORCH ( 16 - 1)
36 #define VGA_H_BACK_PORCH ( 64 - 1)
38 #define VGA_V_SYNC ( 4 - 1)
39 #define VGA_V_FRONT_PORCH ( 3 - 1)
40 #define VGA_V_BACK_PORCH ( 13 - 1)
42 // SVGA Mode: 800 x 600
43 #define SVGA_H_RES_PIXELS 800
44 #define SVGA_V_RES_PIXELS 600
45 #define SVGA_OSC_FREQUENCY 38250000 /* 0x0247A610 */
47 #define SVGA_H_SYNC ( 80 - 1)
48 #define SVGA_H_FRONT_PORCH ( 32 - 1)
49 #define SVGA_H_BACK_PORCH (112 - 1)
51 #define SVGA_V_SYNC ( 4 - 1)
52 #define SVGA_V_FRONT_PORCH ( 3 - 1)
53 #define SVGA_V_BACK_PORCH ( 17 - 1)
55 // XGA Mode: 1024 x 768
56 #define XGA_H_RES_PIXELS 1024
57 #define XGA_V_RES_PIXELS 768
58 #define XGA_OSC_FREQUENCY 63500000 /* 0x03C8EEE0 */
60 #define XGA_H_SYNC (104 - 1)
61 #define XGA_H_FRONT_PORCH ( 48 - 1)
62 #define XGA_H_BACK_PORCH (152 - 1)
64 #define XGA_V_SYNC ( 4 - 1)
65 #define XGA_V_FRONT_PORCH ( 3 - 1)
66 #define XGA_V_BACK_PORCH ( 23 - 1)
68 // SXGA Mode: 1280 x 1024
69 #define SXGA_H_RES_PIXELS 1280
70 #define SXGA_V_RES_PIXELS 1024
71 #define SXGA_OSC_FREQUENCY 109000000 /* 0x067F3540 */
73 #define SXGA_H_SYNC (136 - 1)
74 #define SXGA_H_FRONT_PORCH ( 80 - 1)
75 #define SXGA_H_BACK_PORCH (216 - 1)
77 #define SXGA_V_SYNC ( 7 - 1)
78 #define SXGA_V_FRONT_PORCH ( 3 - 1)
79 #define SXGA_V_BACK_PORCH ( 29 - 1)
81 // WSXGA+ Mode: 1680 x 1050
82 #define WSXGA_H_RES_PIXELS 1680
83 #define WSXGA_V_RES_PIXELS 1050
84 #define WSXGA_OSC_FREQUENCY 147000000 /* 0x08C30AC0 */
86 #define WSXGA_H_SYNC (170 - 1)
87 #define WSXGA_H_FRONT_PORCH (104 - 1)
88 #define WSXGA_H_BACK_PORCH (274 - 1)
90 #define WSXGA_V_SYNC ( 5 - 1)
91 #define WSXGA_V_FRONT_PORCH ( 4 - 1)
92 #define WSXGA_V_BACK_PORCH ( 41 - 1)
94 // UXGA Mode: 1600 x 1200
95 #define UXGA_H_RES_PIXELS 1600
96 #define UXGA_V_RES_PIXELS 1200
97 #define UXGA_OSC_FREQUENCY 161000000 /* 0x0998AA40 */
99 #define UXGA_H_SYNC (168 - 1)
100 #define UXGA_H_FRONT_PORCH (112 - 1)
101 #define UXGA_H_BACK_PORCH (280 - 1)
103 #define UXGA_V_SYNC ( 4 - 1)
104 #define UXGA_V_FRONT_PORCH ( 3 - 1)
105 #define UXGA_V_BACK_PORCH ( 38 - 1)
107 // HD Mode: 1920 x 1080
108 #define HD_H_RES_PIXELS 1920
109 #define HD_V_RES_PIXELS 1080
110 #define HD_OSC_FREQUENCY 165000000 /* 0x09D5B340 */
112 #define HD_H_SYNC ( 79 - 1)
113 #define HD_H_FRONT_PORCH (128 - 1)
114 #define HD_H_BACK_PORCH (328 - 1)
116 #define HD_V_SYNC ( 5 - 1)
117 #define HD_V_FRONT_PORCH ( 3 - 1)
118 #define HD_V_BACK_PORCH ( 32 - 1)
120 // WVGA Mode: 800 x 480
121 #define WVGA_H_RES_PIXELS 800
122 #define WVGA_V_RES_PIXELS 480
123 #define WVGA_OSC_FREQUENCY 29500000 /* 0x01C22260 */
124 #define WVGA_H_SYNC ( 72 - 1)
125 #define WVGA_H_FRONT_PORCH ( 24 - 1)
126 #define WVGA_H_BACK_PORCH ( 96 - 1)
127 #define WVGA_V_SYNC ( 7 - 1)
128 #define WVGA_V_FRONT_PORCH ( 3 - 1)
129 #define WVGA_V_BACK_PORCH ( 10 - 1)
131 // QHD Mode: 960 x 540
132 #define QHD_H_RES_PIXELS 960
133 #define QHD_V_RES_PIXELS 540
134 #define QHD_OSC_FREQUENCY 40750000 /* 0x026DCBB0 */
135 #define QHD_H_SYNC ( 96 - 1)
136 #define QHD_H_FRONT_PORCH ( 32 - 1)
137 #define QHD_H_BACK_PORCH (128 - 1)
138 #define QHD_V_SYNC ( 5 - 1)
139 #define QHD_V_FRONT_PORCH ( 3 - 1)
140 #define QHD_V_BACK_PORCH ( 14 - 1)
142 // WSVGA Mode: 1024 x 600
143 #define WSVGA_H_RES_PIXELS 1024
144 #define WSVGA_V_RES_PIXELS 600
145 #define WSVGA_OSC_FREQUENCY 49000000 /* 0x02EBAE40 */
146 #define WSVGA_H_SYNC (104 - 1)
147 #define WSVGA_H_FRONT_PORCH ( 40 - 1)
148 #define WSVGA_H_BACK_PORCH (144 - 1)
149 #define WSVGA_V_SYNC ( 10 - 1)
150 #define WSVGA_V_FRONT_PORCH ( 3 - 1)
151 #define WSVGA_V_BACK_PORCH ( 11 - 1)
153 // HD720 Mode: 1280 x 720
154 #define HD720_H_RES_PIXELS 1280
155 #define HD720_V_RES_PIXELS 720
156 #define HD720_OSC_FREQUENCY 74500000 /* 0x0470C7A0 */
157 #define HD720_H_SYNC (128 - 1)
158 #define HD720_H_FRONT_PORCH ( 64 - 1)
159 #define HD720_H_BACK_PORCH (192 - 1)
160 #define HD720_V_SYNC ( 5 - 1)
161 #define HD720_V_FRONT_PORCH ( 3 - 1)
162 #define HD720_V_BACK_PORCH ( 20 - 1)
164 // WXGA Mode: 1280 x 800
165 #define WXGA_H_RES_PIXELS 1280
166 #define WXGA_V_RES_PIXELS 800
167 #define WXGA_OSC_FREQUENCY 83500000 /* 0x04FA1BE0 */
168 #define WXGA_H_SYNC (128 - 1)
169 #define WXGA_H_FRONT_PORCH ( 72 - 1)
170 #define WXGA_H_BACK_PORCH (200 - 1)
171 #define WXGA_V_SYNC ( 6 - 1)
172 #define WXGA_V_FRONT_PORCH ( 3 - 1)
173 #define WXGA_V_BACK_PORCH ( 22 - 1)
176 #define LCD_24BPP_RED_MASK 0x00FF0000
177 #define LCD_24BPP_GREEN_MASK 0x0000FF00
178 #define LCD_24BPP_BLUE_MASK 0x000000FF
179 #define LCD_24BPP_RESERVED_MASK 0xFF000000
181 #define LCD_16BPP_555_RED_MASK 0x00007C00
182 #define LCD_16BPP_555_GREEN_MASK 0x000003E0
183 #define LCD_16BPP_555_BLUE_MASK 0x0000001F
184 #define LCD_16BPP_555_RESERVED_MASK 0x00000000
186 #define LCD_16BPP_565_RED_MASK 0x0000F800
187 #define LCD_16BPP_565_GREEN_MASK 0x000007E0
188 #define LCD_16BPP_565_BLUE_MASK 0x0000001F
189 #define LCD_16BPP_565_RESERVED_MASK 0x00008000
191 #define LCD_12BPP_444_RED_MASK 0x00000F00
192 #define LCD_12BPP_444_GREEN_MASK 0x000000F0
193 #define LCD_12BPP_444_BLUE_MASK 0x0000000F
194 #define LCD_12BPP_444_RESERVED_MASK 0x0000F000
196 /** The enumeration maps the PL111 LcdBpp values used in the LCD Control
200 LcdBitsPerPixel_1
= 0,
204 LcdBitsPerPixel_16_555
,
206 LcdBitsPerPixel_16_565
,
207 LcdBitsPerPixel_12_444
,
211 // Display timing settings.
219 /** Platform related initialization function.
221 @param[in] Handle Handle to the LCD device instance.
223 @retval EFI_SUCCESS Plaform library initialized successfully.
224 @retval !(EFI_SUCCESS) Other errors.
227 LcdPlatformInitializeDisplay (
231 /** Allocate VRAM memory in DRAM for the framebuffer
232 (unless it is reserved already).
234 The allocated address can be used to set the framebuffer.
236 @param[out] VramBaseAddress A pointer to the framebuffer address.
237 @param[out] VramSize A pointer to the size of the frame
240 @retval EFI_SUCCESS Frame buffer memory allocated successfully.
241 @retval !(EFI_SUCCESS) Other errors.
245 OUT EFI_PHYSICAL_ADDRESS
*VramBaseAddress
,
249 /** Return total number of modes supported.
251 Note: Valid mode numbers are 0 to MaxMode - 1
252 See Section 12.9 of the UEFI Specification 2.7
254 @retval UINT32 Mode Number.
257 LcdPlatformGetMaxMode (
261 /** Set the requested display mode.
263 @param[in] ModeNumber Mode Number.
265 @retval EFI_SUCCESS Mode set successfully.
266 @retval EFI_INVALID_PARAMETER Requested mode not found.
267 @retval !(EFI_SUCCESS) Other errors.
274 /** Return information for the requested mode number.
276 @param[in] ModeNumber Mode Number.
277 @param[out] Info Pointer for returned mode information
280 @retval EFI_SUCCESS Mode information for the requested mode
281 returned successfully.
282 @retval EFI_INVALID_PARAMETER Requested mode not found.
285 LcdPlatformQueryMode (
286 IN UINT32 ModeNumber
,
287 OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
290 /** Return display timing information for the requested mode number.
292 @param[in] ModeNumber Mode Number.
294 @param[out] Horizontal Pointer to horizontal timing parameters.
295 (Resolution, Sync, Back porch, Front porch)
296 @param[out] Vertical Pointer to vertical timing parameters.
297 (Resolution, Sync, Back porch, Front porch)
300 @retval EFI_SUCCESS Display timing information for the requested
301 mode returned successfully.
302 @retval EFI_INVALID_PARAMETER Requested mode not found.
305 LcdPlatformGetTimings (
306 IN UINT32 ModeNumber
,
307 OUT SCAN_TIMINGS
**Horizontal
,
308 OUT SCAN_TIMINGS
**Vertical
311 /** Return bits per pixel information for a mode number.
313 @param[in] ModeNumber Mode Number.
315 @param[out] Bpp Pointer to value bits per pixel information.
317 @retval EFI_SUCCESS Bit per pixel information for the requested
318 mode returned successfully.
319 @retval EFI_INVALID_PARAMETER Requested mode not found.
323 IN UINT32 ModeNumber
,
327 #endif /* LCD_PLATFORM_LIB_H_ */