1 /** @file
2   Graphics Output Protocol from the UEFI 2.0 specification.
3 
4   Abstraction of a very simple graphics device.
5 
6   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
7 
8   SPDX-License-Identifier: BSD-2-Clause-Patent
9 
10 **/
11 
12 #ifndef __GRAPHICS_OUTPUT_H__
13 #define __GRAPHICS_OUTPUT_H__
14 
15 #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
16   { \
17     0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a } \
18   }
19 
20 typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL EFI_GRAPHICS_OUTPUT_PROTOCOL;
21 
22 typedef struct {
23   UINT32            RedMask;
24   UINT32            GreenMask;
25   UINT32            BlueMask;
26   UINT32            ReservedMask;
27 } EFI_PIXEL_BITMASK;
28 
29 typedef enum {
30   PixelRedGreenBlueReserved8BitPerColor,
31   PixelBlueGreenRedReserved8BitPerColor,
32   PixelBitMask,
33   PixelBltOnly,
34   PixelFormatMax
35 } EFI_GRAPHICS_PIXEL_FORMAT;
36 
37 typedef struct {
38   UINT32                     Version;
39   UINT32                     HorizontalResolution;
40   UINT32                     VerticalResolution;
41   EFI_GRAPHICS_PIXEL_FORMAT  PixelFormat;
42   EFI_PIXEL_BITMASK          PixelInformation;
43   UINT32                     PixelsPerScanLine;
44 } EFI_GRAPHICS_OUTPUT_MODE_INFORMATION;
45 
46 /**
47   Return the current video mode information.
48 
49   @param  This       Protocol instance pointer.
50   @param  ModeNumber The mode number to return information on.
51   @param  SizeOfInfo A pointer to the size, in bytes, of the Info buffer.
52   @param  Info       A pointer to callee allocated buffer that returns information about ModeNumber.
53 
54   @retval EFI_SUCCESS           Mode information returned.
55   @retval EFI_BUFFER_TOO_SMALL  The Info buffer was too small.
56   @retval EFI_DEVICE_ERROR      A hardware error occurred trying to retrieve the video mode.
57   @retval EFI_NOT_STARTED       Video display is not initialized. Call SetMode ()
58   @retval EFI_INVALID_PARAMETER One of the input args was NULL.
59 
60 **/
61 typedef
62 EFI_STATUS
63 (EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE) (
64   IN  EFI_GRAPHICS_OUTPUT_PROTOCOL          *This,
65   IN  UINT32                                ModeNumber,
66   OUT UINTN                                 *SizeOfInfo,
67   OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info
68   )
69 ;
70 
71 /**
72   Return the current video mode information.
73 
74   @param  This              Protocol instance pointer.
75   @param  ModeNumber        The mode number to be set.
76 
77   @retval EFI_SUCCESS       Graphics mode was changed.
78   @retval EFI_DEVICE_ERROR  The device had an error and could not complete the request.
79   @retval EFI_UNSUPPORTED   ModeNumber is not supported by this device.
80 
81 **/
82 typedef
83 EFI_STATUS
84 (EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE) (
85   IN  EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
86   IN  UINT32                       ModeNumber
87   )
88 ;
89 
90 typedef struct {
91   UINT8 Blue;
92   UINT8 Green;
93   UINT8 Red;
94   UINT8 Reserved;
95 } EFI_GRAPHICS_OUTPUT_BLT_PIXEL;
96 
97 typedef union {
98   EFI_GRAPHICS_OUTPUT_BLT_PIXEL Pixel;
99   UINT32                        Raw;
100 } EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION;
101 
102 typedef enum {
103   EfiBltVideoFill,
104   EfiBltVideoToBltBuffer,
105   EfiBltBufferToVideo,
106   EfiBltVideoToVideo,
107   EfiGraphicsOutputBltOperationMax
108 } EFI_GRAPHICS_OUTPUT_BLT_OPERATION;
109 
110 /**
111   The following table defines actions for BltOperations:
112 
113   <B>EfiBltVideoFill</B> - Write data from the  BltBuffer pixel (SourceX, SourceY)
114   directly to every pixel of the video display rectangle
115   (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
116   Only one pixel will be used from the BltBuffer. Delta is NOT used.
117 
118   <B>EfiBltVideoToBltBuffer</B> - Read data from the video display rectangle
119   (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
120   the BltBuffer rectangle (DestinationX, DestinationY )
121   (DestinationX + Width, DestinationY + Height). If DestinationX or
122   DestinationY is not zero then Delta must be set to the length in bytes
123   of a row in the BltBuffer.
124 
125   <B>EfiBltBufferToVideo</B> - Write data from the  BltBuffer rectangle
126   (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
127   video display rectangle (DestinationX, DestinationY)
128   (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
129   not zero then Delta must be set to the length in bytes of a row in the
130   BltBuffer.
131 
132   <B>EfiBltVideoToVideo</B> - Copy from the video display rectangle (SourceX, SourceY)
133   (SourceX + Width, SourceY + Height) .to the video display rectangle
134   (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
135   The BltBuffer and Delta  are not used in this mode.
136 
137   @param  This         Protocol instance pointer.
138   @param  BltBuffer    Buffer containing data to blit into video buffer. This
139                        buffer has a size of Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
140   @param  BltOperation Operation to perform on BlitBuffer and video memory
141   @param  SourceX      X coordinate of source for the BltBuffer.
142   @param  SourceY      Y coordinate of source for the BltBuffer.
143   @param  DestinationX X coordinate of destination for the BltBuffer.
144   @param  DestinationY Y coordinate of destination for the BltBuffer.
145   @param  Width        Width of rectangle in BltBuffer in pixels.
146   @param  Height       Height of rectangle in BltBuffer in pixels.
147   @param  Delta        OPTIONAL
148 
149   @retval EFI_SUCCESS           The Blt operation completed.
150   @retval EFI_INVALID_PARAMETER BltOperation is not valid.
151   @retval EFI_DEVICE_ERROR      A hardware error occurred writing to the video buffer.
152 
153 **/
154 typedef
155 EFI_STATUS
156 (EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT) (
157   IN  EFI_GRAPHICS_OUTPUT_PROTOCOL            *This,
158   IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL           *BltBuffer,   OPTIONAL
159   IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION       BltOperation,
160   IN  UINTN                                   SourceX,
161   IN  UINTN                                   SourceY,
162   IN  UINTN                                   DestinationX,
163   IN  UINTN                                   DestinationY,
164   IN  UINTN                                   Width,
165   IN  UINTN                                   Height,
166   IN  UINTN                                   Delta         OPTIONAL
167   );
168 
169 typedef struct {
170   UINT32                                 MaxMode;
171   UINT32                                 Mode;
172   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION   *Info;
173   UINTN                                  SizeOfInfo;
174   EFI_PHYSICAL_ADDRESS                   FrameBufferBase;
175   UINTN                                  FrameBufferSize;
176 } EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE;
177 
178 struct _EFI_GRAPHICS_OUTPUT_PROTOCOL {
179   EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE  QueryMode;
180   EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE    SetMode;
181   EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT         Blt;
182   EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE        *Mode;
183 };
184 
185 extern EFI_GUID gEfiGraphicsOutputProtocolGuid;
186 
187 #endif
188