2 GopBltLib - Library to perform blt using the UEFI Graphics Output Protocol.
4 Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Protocol/GraphicsOutput.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/BltLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/MemoryAllocationLib.h>
24 #include <Library/UefiBootServicesTableLib.h>
26 EFI_GRAPHICS_OUTPUT_PROTOCOL
*mGop
= NULL
;
30 Configure the FrameBufferLib instance
32 @param[in] FrameBuffer Pointer to the start of the frame buffer
33 @param[in] FrameBufferInfo Describes the frame buffer characteristics
35 @retval EFI_INVALID_PARAMETER - Invalid parameter
36 @retval EFI_UNSUPPORTED - The BltLib does not support this configuration
37 @retval EFI_SUCCESS - Blt operation success
44 IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*FrameBufferInfo
48 EFI_HANDLE
*HandleBuffer
;
51 EFI_GRAPHICS_OUTPUT_PROTOCOL
*Gop
;
53 Status
= gBS
->LocateHandleBuffer (
55 &gEfiGraphicsOutputProtocolGuid
,
60 if (!EFI_ERROR (Status
)) {
61 for (Index
= 0; Index
< HandleCount
; Index
++) {
62 Status
= gBS
->HandleProtocol (
64 &gEfiGraphicsOutputProtocolGuid
,
67 if (!EFI_ERROR (Status
) &&
68 (FrameBuffer
== (VOID
*)(UINTN
) Gop
->Mode
->FrameBufferBase
)) {
70 FreePool (HandleBuffer
);
75 FreePool (HandleBuffer
);
78 return EFI_UNSUPPORTED
;
83 Performs a UEFI Graphics Output Protocol Blt operation.
85 @param[in,out] BltBuffer - The data to transfer to screen
86 @param[in] BltOperation - The operation to perform
87 @param[in] SourceX - The X coordinate of the source for BltOperation
88 @param[in] SourceY - The Y coordinate of the source for BltOperation
89 @param[in] DestinationX - The X coordinate of the destination for BltOperation
90 @param[in] DestinationY - The Y coordinate of the destination for BltOperation
91 @param[in] Width - The width of a rectangle in the blt rectangle in pixels
92 @param[in] Height - The height of a rectangle in the blt rectangle in pixels
93 @param[in] Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.
94 If a Delta of 0 is used, the entire BltBuffer will be operated on.
95 If a subrectangle of the BltBuffer is used, then Delta represents
96 the number of bytes in a row of the BltBuffer.
98 @retval EFI_DEVICE_ERROR - A hardware error occured
99 @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
100 @retval EFI_SUCCESS - Blt operation success
104 InternalGopBltCommon (
105 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
, OPTIONAL
106 IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation
,
109 IN UINTN DestinationX
,
110 IN UINTN DestinationY
,
117 return EFI_DEVICE_ERROR
;
136 Performs a UEFI Graphics Output Protocol Blt operation.
138 @param[in,out] BltBuffer - The data to transfer to screen
139 @param[in] BltOperation - The operation to perform
140 @param[in] SourceX - The X coordinate of the source for BltOperation
141 @param[in] SourceY - The Y coordinate of the source for BltOperation
142 @param[in] DestinationX - The X coordinate of the destination for BltOperation
143 @param[in] DestinationY - The Y coordinate of the destination for BltOperation
144 @param[in] Width - The width of a rectangle in the blt rectangle in pixels
145 @param[in] Height - The height of a rectangle in the blt rectangle in pixels
146 @param[in] Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.
147 If a Delta of 0 is used, the entire BltBuffer will be operated on.
148 If a subrectangle of the BltBuffer is used, then Delta represents
149 the number of bytes in a row of the BltBuffer.
151 @retval EFI_DEVICE_ERROR - A hardware error occured
152 @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
153 @retval EFI_SUCCESS - Blt operation success
159 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
, OPTIONAL
160 IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation
,
163 IN UINTN DestinationX
,
164 IN UINTN DestinationY
,
170 return InternalGopBltCommon (
185 Performs a UEFI Graphics Output Protocol Blt Video Fill.
187 @param[in] Color Color to fill the region with
188 @param[in] DestinationX X location to start fill operation
189 @param[in] DestinationY Y location to start fill operation
190 @param[in] Width Width (in pixels) to fill
191 @param[in] Height Height to fill
193 @retval EFI_DEVICE_ERROR - A hardware error occured
194 @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
195 @retval EFI_SUCCESS - The sizes were returned
201 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*Color
,
202 IN UINTN DestinationX
,
203 IN UINTN DestinationY
,
208 return InternalGopBltCommon (
223 Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation.
225 @param[out] BltBuffer Output buffer for pixel color data
226 @param[in] SourceX X location within video
227 @param[in] SourceY Y location within video
228 @param[in] Width Width (in pixels)
229 @param[in] Height Height
231 @retval EFI_DEVICE_ERROR - A hardware error occured
232 @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
233 @retval EFI_SUCCESS - The sizes were returned
238 BltLibVideoToBltBuffer (
239 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
,
246 return InternalGopBltCommon (
248 EfiBltVideoToBltBuffer
,
261 Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation
262 with extended parameters.
264 @param[out] BltBuffer Output buffer for pixel color data
265 @param[in] SourceX X location within video
266 @param[in] SourceY Y location within video
267 @param[in] DestinationX X location within BltBuffer
268 @param[in] DestinationY Y location within BltBuffer
269 @param[in] Width Width (in pixels)
270 @param[in] Height Height
271 @param[in] Delta Number of bytes in a row of BltBuffer
273 @retval EFI_DEVICE_ERROR - A hardware error occured
274 @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
275 @retval EFI_SUCCESS - The sizes were returned
280 BltLibVideoToBltBufferEx (
281 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
,
284 IN UINTN DestinationX
,
285 IN UINTN DestinationY
,
291 return InternalGopBltCommon (
293 EfiBltVideoToBltBuffer
,
306 Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation.
308 @param[in] BltBuffer Output buffer for pixel color data
309 @param[in] DestinationX X location within video
310 @param[in] DestinationY Y location within video
311 @param[in] Width Width (in pixels)
312 @param[in] Height Height
314 @retval EFI_DEVICE_ERROR - A hardware error occured
315 @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
316 @retval EFI_SUCCESS - The sizes were returned
321 BltLibBufferToVideo (
322 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
,
323 IN UINTN DestinationX
,
324 IN UINTN DestinationY
,
329 return InternalGopBltCommon (
344 Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation
345 with extended parameters.
347 @param[in] BltBuffer Output buffer for pixel color data
348 @param[in] SourceX X location within BltBuffer
349 @param[in] SourceY Y location within BltBuffer
350 @param[in] DestinationX X location within video
351 @param[in] DestinationY Y location within video
352 @param[in] Width Width (in pixels)
353 @param[in] Height Height
354 @param[in] Delta Number of bytes in a row of BltBuffer
356 @retval EFI_DEVICE_ERROR - A hardware error occured
357 @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
358 @retval EFI_SUCCESS - The sizes were returned
363 BltLibBufferToVideoEx (
364 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*BltBuffer
,
367 IN UINTN DestinationX
,
368 IN UINTN DestinationY
,
374 return InternalGopBltCommon (
389 Performs a UEFI Graphics Output Protocol Blt Video to Video operation
391 @param[in] SourceX X location within video
392 @param[in] SourceY Y location within video
393 @param[in] DestinationX X location within video
394 @param[in] DestinationY Y location within video
395 @param[in] Width Width (in pixels)
396 @param[in] Height Height
398 @retval EFI_DEVICE_ERROR - A hardware error occured
399 @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
400 @retval EFI_SUCCESS - The sizes were returned
408 IN UINTN DestinationX
,
409 IN UINTN DestinationY
,
414 return InternalGopBltCommon (
428 Returns the sizes related to the video device
430 @param[out] Width Width (in pixels)
431 @param[out] Height Height (in pixels)
433 @retval EFI_INVALID_PARAMETER - Invalid parameter passed in
434 @retval EFI_SUCCESS - The sizes were returned
440 OUT UINTN
*Width
, OPTIONAL
441 OUT UINTN
*Height OPTIONAL
444 ASSERT (mGop
!= NULL
);
447 *Width
= mGop
->Mode
->Info
->HorizontalResolution
;
449 if (Height
!= NULL
) {
450 *Height
= mGop
->Mode
->Info
->VerticalResolution
;