xref: /illumos-gate/usr/src/boot/efi/include/Protocol/UgaDraw.h (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
1 /** @file
2   UGA Draw protocol from the EFI 1.10 specification.
3 
4   Abstraction of a very simple graphics device.
5 
6   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
7   SPDX-License-Identifier: BSD-2-Clause-Patent
8 
9 **/
10 
11 #ifndef __UGA_DRAW_H__
12 #define __UGA_DRAW_H__
13 
14 #define EFI_UGA_DRAW_PROTOCOL_GUID \
15   { \
16     0x982c298b, 0xf4fa, 0x41cb, {0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 } \
17   }
18 
19 typedef struct _EFI_UGA_DRAW_PROTOCOL EFI_UGA_DRAW_PROTOCOL;
20 
21 /**
22   Return the current video mode information.
23 
24   @param  This                  The EFI_UGA_DRAW_PROTOCOL instance.
25   @param  HorizontalResolution  The size of video screen in pixels in the X dimension.
26   @param  VerticalResolution    The size of video screen in pixels in the Y dimension.
27   @param  ColorDepth            Number of bits per pixel, currently defined to be 32.
28   @param  RefreshRate           The refresh rate of the monitor in Hertz.
29 
30   @retval EFI_SUCCESS           Mode information returned.
31   @retval EFI_NOT_STARTED       Video display is not initialized. Call SetMode ()
32   @retval EFI_INVALID_PARAMETER One of the input args was NULL.
33 
34 **/
35 typedef
36 EFI_STATUS
37 (EFIAPI *EFI_UGA_DRAW_PROTOCOL_GET_MODE)(
38   IN  EFI_UGA_DRAW_PROTOCOL *This,
39   OUT UINT32                *HorizontalResolution,
40   OUT UINT32                *VerticalResolution,
41   OUT UINT32                *ColorDepth,
42   OUT UINT32                *RefreshRate
43   );
44 
45 /**
46   Set the current video mode information.
47 
48   @param  This                 The EFI_UGA_DRAW_PROTOCOL instance.
49   @param  HorizontalResolution The size of video screen in pixels in the X dimension.
50   @param  VerticalResolution   The size of video screen in pixels in the Y dimension.
51   @param  ColorDepth           Number of bits per pixel, currently defined to be 32.
52   @param  RefreshRate          The refresh rate of the monitor in Hertz.
53 
54   @retval EFI_SUCCESS          Mode information returned.
55   @retval EFI_NOT_STARTED      Video display is not initialized. Call SetMode ()
56 
57 **/
58 typedef
59 EFI_STATUS
60 (EFIAPI *EFI_UGA_DRAW_PROTOCOL_SET_MODE)(
61   IN  EFI_UGA_DRAW_PROTOCOL *This,
62   IN  UINT32                HorizontalResolution,
63   IN  UINT32                VerticalResolution,
64   IN  UINT32                ColorDepth,
65   IN  UINT32                RefreshRate
66   );
67 
68 typedef struct {
69   UINT8    Blue;
70   UINT8    Green;
71   UINT8    Red;
72   UINT8    Reserved;
73 } EFI_UGA_PIXEL;
74 
75 typedef union {
76   EFI_UGA_PIXEL    Pixel;
77   UINT32           Raw;
78 } EFI_UGA_PIXEL_UNION;
79 
80 ///
81 /// Enumration value for actions of Blt operations.
82 ///
83 typedef enum {
84   EfiUgaVideoFill,          ///< Write data from the  BltBuffer pixel (SourceX, SourceY)
85                             ///< directly to every pixel of the video display rectangle
86                             ///< (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
87                             ///< Only one pixel will be used from the BltBuffer. Delta is NOT used.
88 
89   EfiUgaVideoToBltBuffer,   ///< Read data from the video display rectangle
90                             ///< (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
91                             ///< the BltBuffer rectangle (DestinationX, DestinationY )
92                             ///< (DestinationX + Width, DestinationY + Height). If DestinationX or
93                             ///< DestinationY is not zero then Delta must be set to the length in bytes
94                             ///< of a row in the BltBuffer.
95 
96   EfiUgaBltBufferToVideo,   ///< Write data from the  BltBuffer rectangle
97                             ///< (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
98                             ///< video display rectangle (DestinationX, DestinationY)
99                             ///< (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
100                             ///< not zero then Delta must be set to the length in bytes of a row in the
101                             ///< BltBuffer.
102 
103   EfiUgaVideoToVideo,       ///< Copy from the video display rectangle (SourceX, SourceY)
104                             ///< (SourceX + Width, SourceY + Height) .to the video display rectangle
105                             ///< (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
106                             ///< The BltBuffer and Delta  are not used in this mode.
107 
108   EfiUgaBltMax              ///< Maxmimum value for enumration value of Blt operation. If a Blt operation
109                             ///< larger or equal to this enumration value, it is invalid.
110 } EFI_UGA_BLT_OPERATION;
111 
112 /**
113     Blt a rectangle of pixels on the graphics screen.
114 
115     @param[in] This          - Protocol instance pointer.
116     @param[in] BltBuffer     - Buffer containing data to blit into video buffer. This
117                                buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)
118     @param[in] BltOperation  - Operation to perform on BlitBuffer and video memory
119     @param[in] SourceX       - X coordinate of source for the BltBuffer.
120     @param[in] SourceY       - Y coordinate of source for the BltBuffer.
121     @param[in] DestinationX  - X coordinate of destination for the BltBuffer.
122     @param[in] DestinationY  - Y coordinate of destination for the BltBuffer.
123     @param[in] Width         - Width of rectangle in BltBuffer in pixels.
124     @param[in] Height        - Hight of rectangle in BltBuffer in pixels.
125     @param[in] Delta         - OPTIONAL
126 
127     @retval EFI_SUCCESS           - The Blt operation completed.
128     @retval EFI_INVALID_PARAMETER - BltOperation is not valid.
129     @retval EFI_DEVICE_ERROR      - A hardware error occurred writting to the video buffer.
130 
131 **/
132 typedef
133 EFI_STATUS
134 (EFIAPI *EFI_UGA_DRAW_PROTOCOL_BLT)(
135   IN  EFI_UGA_DRAW_PROTOCOL                   *This,
136   IN  EFI_UGA_PIXEL                           *BltBuffer  OPTIONAL,
137   IN  EFI_UGA_BLT_OPERATION                   BltOperation,
138   IN  UINTN                                   SourceX,
139   IN  UINTN                                   SourceY,
140   IN  UINTN                                   DestinationX,
141   IN  UINTN                                   DestinationY,
142   IN  UINTN                                   Width,
143   IN  UINTN                                   Height,
144   IN  UINTN                                   Delta         OPTIONAL
145   );
146 
147 ///
148 /// This protocol provides a basic abstraction to set video modes and
149 /// copy pixels to and from the graphics controller's frame buffer.
150 ///
151 struct _EFI_UGA_DRAW_PROTOCOL {
152   EFI_UGA_DRAW_PROTOCOL_GET_MODE    GetMode;
153   EFI_UGA_DRAW_PROTOCOL_SET_MODE    SetMode;
154   EFI_UGA_DRAW_PROTOCOL_BLT         Blt;
155 };
156 
157 extern EFI_GUID  gEfiUgaDrawProtocolGuid;
158 
159 #endif
160