1 /** @file
2   UGA Draw protocol from the EFI 1.1 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 __UGA_DRAW_H__
13 #define __UGA_DRAW_H__
14 
15 #define EFI_UGA_DRAW_PROTOCOL_GUID \
16   { \
17     0x982c298b, 0xf4fa, 0x41cb, {0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 } \
18   }
19 
20 typedef struct _EFI_UGA_DRAW_PROTOCOL EFI_UGA_DRAW_PROTOCOL;
21 
22 /**
23   Return the current video mode information.
24 
25   @param  This                  Protocol instance pointer.
26   @param  HorizontalResolution  Current video horizontal resolution in pixels
27   @param  VerticalResolution    Current video vertical resolution in pixels
28   @param  ColorDepth            Current video color depth in bits per pixel
29   @param  RefreshRate           Current video refresh rate in Hz.
30 
31   @retval EFI_SUCCESS           Mode information returned.
32   @retval EFI_NOT_STARTED       Video display is not initialized. Call SetMode ()
33   @retval EFI_INVALID_PARAMETER One of the input args was NULL.
34 
35 **/
36 typedef
37 EFI_STATUS
_map(LV2_URID_Map_Handle instance,const char * uri)38 (EFIAPI *EFI_UGA_DRAW_PROTOCOL_GET_MODE) (
39   IN  EFI_UGA_DRAW_PROTOCOL *This,
40   OUT UINT32                *HorizontalResolution,
41   OUT UINT32                *VerticalResolution,
42   OUT UINT32                *ColorDepth,
43   OUT UINT32                *RefreshRate
44   )
45 ;
46 
47 /**
48   Return the current video mode information.
49 
50   @param  This                 Protocol instance pointer.
51   @param  HorizontalResolution Current video horizontal resolution in pixels
52   @param  VerticalResolution   Current video vertical resolution in pixels
53   @param  ColorDepth           Current video color depth in bits per pixel
54   @param  RefreshRate          Current video refresh rate in Hz.
55 
56   @retval EFI_SUCCESS          Mode information returned.
57   @retval EFI_NOT_STARTED      Video display is not initialized. Call SetMode ()
58 
_unmap(LV2_URID_Unmap_Handle instance,LV2_URID urid)59 **/
60 typedef
61 EFI_STATUS
62 (EFIAPI *EFI_UGA_DRAW_PROTOCOL_SET_MODE) (
63   IN  EFI_UGA_DRAW_PROTOCOL *This,
64   IN  UINT32                HorizontalResolution,
65   IN  UINT32                VerticalResolution,
66   IN  UINT32                ColorDepth,
67   IN  UINT32                RefreshRate
68   )
69 ;
70 
71 typedef struct {
72   UINT8 Blue;
73   UINT8 Green;
_freemap(handle_t * handle)74   UINT8 Red;
75   UINT8 Reserved;
76 } EFI_UGA_PIXEL;
77 
78 typedef union {
79   EFI_UGA_PIXEL Pixel;
80   UINT32        Raw;
_netatom_test(LV2_URID_Map * map,LV2_URID_Unmap * unmap,bool swap,const LV2_Atom * atom,unsigned iterations)81 } EFI_UGA_PIXEL_UNION;
82 
83 typedef enum {
84   EfiUgaVideoFill,
85   EfiUgaVideoToBltBuffer,
86   EfiUgaBltBufferToVideo,
87   EfiUgaVideoToVideo,
88   EfiUgaBltMax
89 } EFI_UGA_BLT_OPERATION;
90 
91 /**
92   Type specifying a pointer to a function to perform an UGA Blt operation.
93 
94     The following table defines actions for BltOperations:
95 
96     <B>EfiUgaVideoFill</B> - Write data from the  BltBuffer pixel (SourceX, SourceY)
97       directly to every pixel of the video display rectangle
98       (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
99       Only one pixel will be used from the BltBuffer. Delta is NOT used.
100 
101     <B>EfiUgaVideoToBltBuffer</B> - Read data from the video display rectangle
102       (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
103       the BltBuffer rectangle (DestinationX, DestinationY )
104       (DestinationX + Width, DestinationY + Height). If DestinationX or
105       DestinationY is not zero then Delta must be set to the length in bytes
106       of a row in the BltBuffer.
107 
108     <B>EfiUgaBltBufferToVideo</B> - Write data from the  BltBuffer rectangle
109       (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
110       video display rectangle (DestinationX, DestinationY)
111       (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
_sratom_test(LV2_URID_Map * map,LV2_URID_Unmap * unmap,bool pretty,const LV2_Atom * atom,unsigned iterations)112       not zero then Delta must be set to the length in bytes of a row in the
113       BltBuffer.
114 
115     <B>EfiUgaVideoToVideo</B> - Copy from the video display rectangle (SourceX, SourceY)
116      (SourceX + Width, SourceY + Height) .to the video display rectangle
117      (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
118      The BltBuffer and Delta  are not used in this mode.
119 
120 
121     @param[in] This          - Protocol instance pointer.
122     @param[in] BltBuffer     - Buffer containing data to blit into video buffer. This
123                                buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)
124     @param[in] BltOperation  - Operation to perform on BlitBuffer and video memory
125     @param[in] SourceX       - X coordinate of source for the BltBuffer.
126     @param[in] SourceY       - Y coordinate of source for the BltBuffer.
127     @param[in] DestinationX  - X coordinate of destination for the BltBuffer.
128     @param[in] DestinationY  - Y coordinate of destination for the BltBuffer.
129     @param[in] Width         - Width of rectangle in BltBuffer in pixels.
130     @param[in] Height        - Height of rectangle in BltBuffer in pixels.
131     @param[in] Delta         - OPTIONAL
132 
133     @retval EFI_SUCCESS           - The Blt operation completed.
134     @retval EFI_INVALID_PARAMETER - BltOperation is not valid.
135     @retval EFI_DEVICE_ERROR      - A hardware error occurred writing to the video buffer.
136 
137 --*/
138 typedef
139 EFI_STATUS
140 (EFIAPI *EFI_UGA_DRAW_PROTOCOL_BLT) (
141   IN  EFI_UGA_DRAW_PROTOCOL                   * This,
142   IN  EFI_UGA_PIXEL                           * BltBuffer, OPTIONAL
143   IN  EFI_UGA_BLT_OPERATION                   BltOperation,
144   IN  UINTN                                   SourceX,
145   IN  UINTN                                   SourceY,
146   IN  UINTN                                   DestinationX,
147   IN  UINTN                                   DestinationY,
148   IN  UINTN                                   Width,
149   IN  UINTN                                   Height,
150   IN  UINTN                                   Delta         OPTIONAL
151   );
152 
153 struct _EFI_UGA_DRAW_PROTOCOL {
154   EFI_UGA_DRAW_PROTOCOL_GET_MODE  GetMode;
155   EFI_UGA_DRAW_PROTOCOL_SET_MODE  SetMode;
156   EFI_UGA_DRAW_PROTOCOL_BLT       Blt;
157 };
158 
159 extern EFI_GUID gEfiUgaDrawProtocolGuid;
160 
161 #endif
162