]>
Commit | Line | Data |
---|---|---|
fb0b259e | 1 | /** @file\r |
9937b365 | 2 | Support for Graphics output spliter.\r |
d1102dba LG |
3 | \r |
4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
95276127 | 6 | \r |
a4d608d1 | 7 | \r |
fb0b259e | 8 | **/\r |
95276127 | 9 | \r |
95276127 | 10 | #include "ConSplitter.h"\r |
11 | \r | |
1436aea4 | 12 | CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };\r |
a4d608d1 | 13 | \r |
a4d608d1 | 14 | /**\r |
2da292f6 | 15 | Returns information for an available graphics mode that the graphics device\r |
16 | and the set of active video output devices supports.\r | |
a4d608d1 | 17 | \r |
2da292f6 | 18 | @param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.\r |
19 | @param ModeNumber The mode number to return information on.\r | |
20 | @param SizeOfInfo A pointer to the size, in bytes, of the Info buffer.\r | |
21 | @param Info A pointer to callee allocated buffer that returns information about ModeNumber.\r | |
a4d608d1 | 22 | \r |
2da292f6 | 23 | @retval EFI_SUCCESS Mode information returned.\r |
24 | @retval EFI_BUFFER_TOO_SMALL The Info buffer was too small.\r | |
25 | @retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the video mode.\r | |
2da292f6 | 26 | @retval EFI_INVALID_PARAMETER One of the input args was NULL.\r |
27 | @retval EFI_OUT_OF_RESOURCES No resource available.\r | |
a4d608d1 | 28 | \r |
29 | **/\r | |
95276127 | 30 | EFI_STATUS\r |
31 | EFIAPI\r | |
d6e11f22 | 32 | ConSplitterGraphicsOutputQueryMode (\r |
95276127 | 33 | IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r |
34 | IN UINT32 ModeNumber,\r | |
35 | OUT UINTN *SizeOfInfo,\r | |
36 | OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info\r | |
37 | )\r | |
95276127 | 38 | {\r |
39 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
2fa996f9 | 40 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r |
41 | EFI_STATUS Status;\r | |
42 | UINTN Index;\r | |
95276127 | 43 | \r |
1436aea4 | 44 | if ((This == NULL) || (Info == NULL) || (SizeOfInfo == NULL) || (ModeNumber >= This->Mode->MaxMode)) {\r |
95276127 | 45 | return EFI_INVALID_PARAMETER;\r |
46 | }\r | |
47 | \r | |
48 | //\r | |
49 | // retrieve private data\r | |
50 | //\r | |
51 | Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
52 | \r | |
2fa996f9 | 53 | GraphicsOutput = NULL;\r |
d1102dba | 54 | \r |
2fa996f9 | 55 | if (Private->CurrentNumberOfGraphicsOutput == 1) {\r |
56 | //\r | |
57 | // Find the only one GraphicsOutput.\r | |
58 | //\r | |
59 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
60 | GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;\r | |
61 | if (GraphicsOutput != NULL) {\r | |
62 | break;\r | |
63 | }\r | |
64 | }\r | |
65 | }\r | |
d1102dba | 66 | \r |
2fa996f9 | 67 | if (GraphicsOutput != NULL) {\r |
68 | //\r | |
69 | // If only one physical GOP device exist, return its information.\r | |
70 | //\r | |
1436aea4 | 71 | Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32)ModeNumber, SizeOfInfo, Info);\r |
2fa996f9 | 72 | return Status;\r |
73 | } else {\r | |
74 | //\r | |
d1102dba | 75 | // If 2 more phyiscal GOP device exist or GOP protocol does not exist,\r |
2fa996f9 | 76 | // return GOP information (PixelFormat is PixelBltOnly) created in ConSplitterAddGraphicsOutputMode ().\r |
77 | //\r | |
78 | *Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
79 | if (*Info == NULL) {\r | |
80 | return EFI_OUT_OF_RESOURCES;\r | |
81 | }\r | |
1436aea4 | 82 | \r |
2fa996f9 | 83 | *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r |
84 | CopyMem (*Info, &Private->GraphicsOutputModeBuffer[ModeNumber], *SizeOfInfo);\r | |
95276127 | 85 | }\r |
95276127 | 86 | \r |
87 | return EFI_SUCCESS;\r | |
88 | }\r | |
89 | \r | |
a4d608d1 | 90 | /**\r |
ed055f1b | 91 | Set the video device into the specified mode and clears the visible portions of\r |
2da292f6 | 92 | the output display to black.\r |
a4d608d1 | 93 | \r |
2da292f6 | 94 | @param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.\r |
95 | @param ModeNumber Abstraction that defines the current video mode.\r | |
a4d608d1 | 96 | \r |
2da292f6 | 97 | @retval EFI_SUCCESS The graphics mode specified by ModeNumber was selected.\r |
98 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r | |
99 | @retval EFI_UNSUPPORTED ModeNumber is not supported by this device.\r | |
100 | @retval EFI_OUT_OF_RESOURCES No resource available.\r | |
a4d608d1 | 101 | \r |
102 | **/\r | |
95276127 | 103 | EFI_STATUS\r |
104 | EFIAPI\r | |
d6e11f22 | 105 | ConSplitterGraphicsOutputSetMode (\r |
1436aea4 MK |
106 | IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r |
107 | IN UINT32 ModeNumber\r | |
95276127 | 108 | )\r |
95276127 | 109 | {\r |
1436aea4 MK |
110 | EFI_STATUS Status;\r |
111 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
112 | UINTN Index;\r | |
113 | EFI_STATUS ReturnStatus;\r | |
114 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode;\r | |
115 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
116 | EFI_GRAPHICS_OUTPUT_PROTOCOL *PhysicalGraphicsOutput;\r | |
117 | UINTN NumberIndex;\r | |
118 | UINTN SizeOfInfo;\r | |
119 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r | |
120 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
95276127 | 121 | \r |
122 | if (ModeNumber >= This->Mode->MaxMode) {\r | |
123 | return EFI_UNSUPPORTED;\r | |
124 | }\r | |
125 | \r | |
95276127 | 126 | Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r |
1436aea4 | 127 | Mode = &Private->GraphicsOutputModeBuffer[ModeNumber];\r |
95276127 | 128 | \r |
1436aea4 MK |
129 | ReturnStatus = EFI_SUCCESS;\r |
130 | GraphicsOutput = NULL;\r | |
8d4e1bd9 | 131 | PhysicalGraphicsOutput = NULL;\r |
95276127 | 132 | //\r |
133 | // return the worst status met\r | |
134 | //\r | |
135 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
136 | GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;\r | |
137 | if (GraphicsOutput != NULL) {\r | |
8d4e1bd9 | 138 | PhysicalGraphicsOutput = GraphicsOutput;\r |
95276127 | 139 | //\r |
140 | // Find corresponding ModeNumber of this GraphicsOutput instance\r | |
141 | //\r | |
1436aea4 MK |
142 | for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex++) {\r |
143 | Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32)NumberIndex, &SizeOfInfo, &Info);\r | |
95276127 | 144 | if (EFI_ERROR (Status)) {\r |
145 | return Status;\r | |
146 | }\r | |
1436aea4 | 147 | \r |
95276127 | 148 | if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) {\r |
149 | FreePool (Info);\r | |
150 | break;\r | |
151 | }\r | |
1436aea4 | 152 | \r |
95276127 | 153 | FreePool (Info);\r |
154 | }\r | |
155 | \r | |
1436aea4 | 156 | Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32)NumberIndex);\r |
95276127 | 157 | if (EFI_ERROR (Status)) {\r |
158 | ReturnStatus = Status;\r | |
159 | }\r | |
2da292f6 | 160 | } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r |
d0c64728 | 161 | UgaDraw = Private->TextOutList[Index].UgaDraw;\r |
162 | if (UgaDraw != NULL) {\r | |
163 | Status = UgaDraw->SetMode (\r | |
164 | UgaDraw,\r | |
165 | Mode->HorizontalResolution,\r | |
166 | Mode->VerticalResolution,\r | |
167 | 32,\r | |
168 | 60\r | |
169 | );\r | |
170 | if (EFI_ERROR (Status)) {\r | |
171 | ReturnStatus = Status;\r | |
172 | }\r | |
95276127 | 173 | }\r |
174 | }\r | |
175 | }\r | |
176 | \r | |
177 | This->Mode->Mode = ModeNumber;\r | |
178 | \r | |
8d4e1bd9 | 179 | if ((Private->CurrentNumberOfGraphicsOutput == 1) && (PhysicalGraphicsOutput != NULL)) {\r |
2fa996f9 | 180 | //\r |
181 | // If only one physical GOP device exist, copy physical information to consplitter.\r | |
182 | //\r | |
8d4e1bd9 | 183 | CopyMem (This->Mode->Info, PhysicalGraphicsOutput->Mode->Info, PhysicalGraphicsOutput->Mode->SizeOfInfo);\r |
1436aea4 | 184 | This->Mode->SizeOfInfo = PhysicalGraphicsOutput->Mode->SizeOfInfo;\r |
8d4e1bd9 | 185 | This->Mode->FrameBufferBase = PhysicalGraphicsOutput->Mode->FrameBufferBase;\r |
186 | This->Mode->FrameBufferSize = PhysicalGraphicsOutput->Mode->FrameBufferSize;\r | |
2fa996f9 | 187 | } else {\r |
188 | //\r | |
d1102dba | 189 | // If 2 more phyiscal GOP device exist or GOP protocol does not exist,\r |
2fa996f9 | 190 | // return GOP information (PixelFormat is PixelBltOnly) created in ConSplitterAddGraphicsOutputMode ().\r |
191 | //\r | |
192 | CopyMem (This->Mode->Info, &Private->GraphicsOutputModeBuffer[ModeNumber], This->Mode->SizeOfInfo);\r | |
193 | }\r | |
95276127 | 194 | \r |
95276127 | 195 | return ReturnStatus;\r |
196 | }\r | |
197 | \r | |
a4d608d1 | 198 | /**\r |
199 | The following table defines actions for BltOperations.\r | |
200 | \r | |
201 | EfiBltVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY)\r | |
202 | directly to every pixel of the video display rectangle\r | |
203 | (DestinationX, DestinationY)\r | |
204 | (DestinationX + Width, DestinationY + Height).\r | |
205 | Only one pixel will be used from the BltBuffer. Delta is NOT used.\r | |
206 | EfiBltVideoToBltBuffer - Read data from the video display rectangle\r | |
207 | (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in\r | |
208 | the BltBuffer rectangle (DestinationX, DestinationY )\r | |
209 | (DestinationX + Width, DestinationY + Height). If DestinationX or\r | |
210 | DestinationY is not zero then Delta must be set to the length in bytes\r | |
211 | of a row in the BltBuffer.\r | |
212 | EfiBltBufferToVideo - Write data from the BltBuffer rectangle\r | |
213 | (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the\r | |
214 | video display rectangle (DestinationX, DestinationY)\r | |
215 | (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is\r | |
216 | not zero then Delta must be set to the length in bytes of a row in the\r | |
217 | BltBuffer.\r | |
218 | EfiBltVideoToVideo - Copy from the video display rectangle\r | |
219 | (SourceX, SourceY) (SourceX + Width, SourceY + Height) .\r | |
220 | to the video display rectangle (DestinationX, DestinationY)\r | |
221 | (DestinationX + Width, DestinationY + Height).\r | |
222 | The BltBuffer and Delta are not used in this mode.\r | |
223 | \r | |
224 | @param This Protocol instance pointer.\r | |
225 | @param BltBuffer Buffer containing data to blit into video buffer.\r | |
226 | This buffer has a size of\r | |
227 | Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r | |
228 | @param BltOperation Operation to perform on BlitBuffer and video\r | |
229 | memory\r | |
230 | @param SourceX X coordinate of source for the BltBuffer.\r | |
231 | @param SourceY Y coordinate of source for the BltBuffer.\r | |
232 | @param DestinationX X coordinate of destination for the BltBuffer.\r | |
233 | @param DestinationY Y coordinate of destination for the BltBuffer.\r | |
234 | @param Width Width of rectangle in BltBuffer in pixels.\r | |
ed055f1b | 235 | @param Height Hight of rectangle in BltBuffer in pixels.\r |
33019a71 | 236 | @param Delta OPTIONAL.\r |
a4d608d1 | 237 | \r |
238 | @retval EFI_SUCCESS The Blt operation completed.\r | |
239 | @retval EFI_INVALID_PARAMETER BltOperation is not valid.\r | |
d181539b | 240 | @retval EFI_DEVICE_ERROR A hardware error occurred writting to the video\r |
a4d608d1 | 241 | buffer.\r |
242 | \r | |
243 | **/\r | |
95276127 | 244 | EFI_STATUS\r |
245 | EFIAPI\r | |
d6e11f22 | 246 | ConSplitterGraphicsOutputBlt (\r |
1436aea4 MK |
247 | IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r |
248 | IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,\r | |
249 | IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r | |
250 | IN UINTN SourceX,\r | |
251 | IN UINTN SourceY,\r | |
252 | IN UINTN DestinationX,\r | |
253 | IN UINTN DestinationY,\r | |
254 | IN UINTN Width,\r | |
255 | IN UINTN Height,\r | |
256 | IN UINTN Delta OPTIONAL\r | |
95276127 | 257 | )\r |
95276127 | 258 | {\r |
259 | EFI_STATUS Status;\r | |
7389f649 | 260 | EFI_STATUS ReturnStatus;\r |
95276127 | 261 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r |
262 | UINTN Index;\r | |
95276127 | 263 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r |
264 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
265 | \r | |
1436aea4 | 266 | if ((This == NULL) || (((UINTN)BltOperation) >= EfiGraphicsOutputBltOperationMax)) {\r |
97c74782 | 267 | return EFI_INVALID_PARAMETER;\r |
268 | }\r | |
d1102dba | 269 | \r |
95276127 | 270 | Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r |
271 | \r | |
7389f649 | 272 | ReturnStatus = EFI_SUCCESS;\r |
273 | \r | |
95276127 | 274 | //\r |
275 | // return the worst status met\r | |
276 | //\r | |
277 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
278 | GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;\r | |
279 | if (GraphicsOutput != NULL) {\r | |
280 | Status = GraphicsOutput->Blt (\r | |
1436aea4 MK |
281 | GraphicsOutput,\r |
282 | BltBuffer,\r | |
283 | BltOperation,\r | |
284 | SourceX,\r | |
285 | SourceY,\r | |
286 | DestinationX,\r | |
287 | DestinationY,\r | |
288 | Width,\r | |
289 | Height,\r | |
290 | Delta\r | |
291 | );\r | |
95276127 | 292 | if (EFI_ERROR (Status)) {\r |
293 | ReturnStatus = Status;\r | |
294 | } else if (BltOperation == EfiBltVideoToBltBuffer) {\r | |
295 | //\r | |
296 | // Only need to read the data into buffer one time\r | |
297 | //\r | |
298 | return EFI_SUCCESS;\r | |
299 | }\r | |
300 | }\r | |
301 | \r | |
302 | UgaDraw = Private->TextOutList[Index].UgaDraw;\r | |
1436aea4 | 303 | if ((UgaDraw != NULL) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r |
95276127 | 304 | Status = UgaDraw->Blt (\r |
1436aea4 MK |
305 | UgaDraw,\r |
306 | (EFI_UGA_PIXEL *)BltBuffer,\r | |
307 | (EFI_UGA_BLT_OPERATION)BltOperation,\r | |
308 | SourceX,\r | |
309 | SourceY,\r | |
310 | DestinationX,\r | |
311 | DestinationY,\r | |
312 | Width,\r | |
313 | Height,\r | |
314 | Delta\r | |
315 | );\r | |
95276127 | 316 | if (EFI_ERROR (Status)) {\r |
317 | ReturnStatus = Status;\r | |
318 | } else if (BltOperation == EfiBltVideoToBltBuffer) {\r | |
319 | //\r | |
320 | // Only need to read the data into buffer one time\r | |
321 | //\r | |
322 | return EFI_SUCCESS;\r | |
323 | }\r | |
324 | }\r | |
325 | }\r | |
326 | \r | |
327 | return ReturnStatus;\r | |
328 | }\r | |
329 | \r | |
a4d608d1 | 330 | /**\r |
331 | Return the current video mode information.\r | |
332 | \r | |
2da292f6 | 333 | @param This The EFI_UGA_DRAW_PROTOCOL instance.\r |
334 | @param HorizontalResolution The size of video screen in pixels in the X dimension.\r | |
335 | @param VerticalResolution The size of video screen in pixels in the Y dimension.\r | |
336 | @param ColorDepth Number of bits per pixel, currently defined to be 32.\r | |
337 | @param RefreshRate The refresh rate of the monitor in Hertz.\r | |
a4d608d1 | 338 | \r |
2da292f6 | 339 | @retval EFI_SUCCESS Mode information returned.\r |
340 | @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()\r | |
341 | @retval EFI_INVALID_PARAMETER One of the input args was NULL.\r | |
a4d608d1 | 342 | \r |
343 | **/\r | |
d0c64728 | 344 | EFI_STATUS\r |
345 | EFIAPI\r | |
d6e11f22 | 346 | ConSplitterUgaDrawGetMode (\r |
1436aea4 MK |
347 | IN EFI_UGA_DRAW_PROTOCOL *This,\r |
348 | OUT UINT32 *HorizontalResolution,\r | |
349 | OUT UINT32 *VerticalResolution,\r | |
350 | OUT UINT32 *ColorDepth,\r | |
351 | OUT UINT32 *RefreshRate\r | |
d0c64728 | 352 | )\r |
d0c64728 | 353 | {\r |
354 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
355 | \r | |
a4d608d1 | 356 | if ((HorizontalResolution == NULL) ||\r |
2da292f6 | 357 | (VerticalResolution == NULL) ||\r |
358 | (RefreshRate == NULL) ||\r | |
1436aea4 MK |
359 | (ColorDepth == NULL))\r |
360 | {\r | |
d0c64728 | 361 | return EFI_INVALID_PARAMETER;\r |
362 | }\r | |
1436aea4 | 363 | \r |
d0c64728 | 364 | //\r |
365 | // retrieve private data\r | |
366 | //\r | |
1436aea4 | 367 | Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r |
d0c64728 | 368 | \r |
369 | *HorizontalResolution = Private->UgaHorizontalResolution;\r | |
370 | *VerticalResolution = Private->UgaVerticalResolution;\r | |
371 | *ColorDepth = Private->UgaColorDepth;\r | |
372 | *RefreshRate = Private->UgaRefreshRate;\r | |
373 | \r | |
374 | return EFI_SUCCESS;\r | |
375 | }\r | |
376 | \r | |
a4d608d1 | 377 | /**\r |
2da292f6 | 378 | Set the current video mode information.\r |
a4d608d1 | 379 | \r |
2da292f6 | 380 | @param This The EFI_UGA_DRAW_PROTOCOL instance.\r |
381 | @param HorizontalResolution The size of video screen in pixels in the X dimension.\r | |
382 | @param VerticalResolution The size of video screen in pixels in the Y dimension.\r | |
383 | @param ColorDepth Number of bits per pixel, currently defined to be 32.\r | |
384 | @param RefreshRate The refresh rate of the monitor in Hertz.\r | |
a4d608d1 | 385 | \r |
2da292f6 | 386 | @retval EFI_SUCCESS Mode information returned.\r |
387 | @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()\r | |
388 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
a4d608d1 | 389 | \r |
390 | **/\r | |
d0c64728 | 391 | EFI_STATUS\r |
392 | EFIAPI\r | |
d6e11f22 | 393 | ConSplitterUgaDrawSetMode (\r |
1436aea4 MK |
394 | IN EFI_UGA_DRAW_PROTOCOL *This,\r |
395 | IN UINT32 HorizontalResolution,\r | |
396 | IN UINT32 VerticalResolution,\r | |
397 | IN UINT32 ColorDepth,\r | |
398 | IN UINT32 RefreshRate\r | |
d0c64728 | 399 | )\r |
d0c64728 | 400 | {\r |
1436aea4 MK |
401 | EFI_STATUS Status;\r |
402 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
403 | UINTN Index;\r | |
404 | EFI_STATUS ReturnStatus;\r | |
405 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
406 | UINTN NumberIndex;\r | |
407 | UINTN SizeOfInfo;\r | |
408 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r | |
409 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
d0c64728 | 410 | \r |
411 | Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
412 | \r | |
d0c64728 | 413 | ReturnStatus = EFI_SUCCESS;\r |
414 | \r | |
d0c64728 | 415 | //\r |
416 | // Update the Mode data\r | |
417 | //\r | |
1436aea4 MK |
418 | Private->UgaHorizontalResolution = HorizontalResolution;\r |
419 | Private->UgaVerticalResolution = VerticalResolution;\r | |
420 | Private->UgaColorDepth = ColorDepth;\r | |
421 | Private->UgaRefreshRate = RefreshRate;\r | |
d0c64728 | 422 | \r |
d0c64728 | 423 | //\r |
424 | // return the worst status met\r | |
425 | //\r | |
426 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
2da292f6 | 427 | GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;\r |
428 | if (GraphicsOutput != NULL) {\r | |
429 | //\r | |
430 | // Find corresponding ModeNumber of this GraphicsOutput instance\r | |
431 | //\r | |
1436aea4 MK |
432 | for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex++) {\r |
433 | Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32)NumberIndex, &SizeOfInfo, &Info);\r | |
8541adab | 434 | if (EFI_ERROR (Status)) {\r |
2da292f6 | 435 | return Status;\r |
8541adab | 436 | }\r |
1436aea4 | 437 | \r |
2da292f6 | 438 | if ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution == VerticalResolution)) {\r |
d0c64728 | 439 | FreePool (Info);\r |
2da292f6 | 440 | break;\r |
d0c64728 | 441 | }\r |
1436aea4 | 442 | \r |
2da292f6 | 443 | FreePool (Info);\r |
444 | }\r | |
d0c64728 | 445 | \r |
1436aea4 | 446 | Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32)NumberIndex);\r |
2da292f6 | 447 | if (EFI_ERROR (Status)) {\r |
448 | ReturnStatus = Status;\r | |
449 | }\r | |
1436aea4 | 450 | } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r |
2da292f6 | 451 | UgaDraw = Private->TextOutList[Index].UgaDraw;\r |
452 | if (UgaDraw != NULL) {\r | |
453 | Status = UgaDraw->SetMode (\r | |
1436aea4 MK |
454 | UgaDraw,\r |
455 | HorizontalResolution,\r | |
456 | VerticalResolution,\r | |
457 | ColorDepth,\r | |
458 | RefreshRate\r | |
459 | );\r | |
d0c64728 | 460 | if (EFI_ERROR (Status)) {\r |
461 | ReturnStatus = Status;\r | |
462 | }\r | |
463 | }\r | |
ed055f1b | 464 | }\r |
d0c64728 | 465 | }\r |
466 | \r | |
467 | return ReturnStatus;\r | |
468 | }\r | |
469 | \r | |
a4d608d1 | 470 | /**\r |
2da292f6 | 471 | Blt a rectangle of pixels on the graphics screen.\r |
a4d608d1 | 472 | \r |
2da292f6 | 473 | The following table defines actions for BltOperations.\r |
a4d608d1 | 474 | \r |
2da292f6 | 475 | EfiUgaVideoFill:\r |
476 | Write data from the BltBuffer pixel (SourceX, SourceY)\r | |
477 | directly to every pixel of the video display rectangle\r | |
478 | (DestinationX, DestinationY)\r | |
479 | (DestinationX + Width, DestinationY + Height).\r | |
480 | Only one pixel will be used from the BltBuffer. Delta is NOT used.\r | |
ed055f1b | 481 | EfiUgaVideoToBltBuffer:\r |
2da292f6 | 482 | Read data from the video display rectangle\r |
483 | (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in\r | |
484 | the BltBuffer rectangle (DestinationX, DestinationY )\r | |
485 | (DestinationX + Width, DestinationY + Height). If DestinationX or\r | |
486 | DestinationY is not zero then Delta must be set to the length in bytes\r | |
487 | of a row in the BltBuffer.\r | |
488 | EfiUgaBltBufferToVideo:\r | |
489 | Write data from the BltBuffer rectangle\r | |
490 | (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the\r | |
491 | video display rectangle (DestinationX, DestinationY)\r | |
492 | (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is\r | |
493 | not zero then Delta must be set to the length in bytes of a row in the\r | |
494 | BltBuffer.\r | |
495 | EfiUgaVideoToVideo:\r | |
496 | Copy from the video display rectangle\r | |
497 | (SourceX, SourceY) (SourceX + Width, SourceY + Height) .\r | |
498 | to the video display rectangle (DestinationX, DestinationY)\r | |
499 | (DestinationX + Width, DestinationY + Height).\r | |
500 | The BltBuffer and Delta are not used in this mode.\r | |
501 | \r | |
502 | @param This Protocol instance pointer.\r | |
503 | @param BltBuffer Buffer containing data to blit into video buffer. This\r | |
504 | buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)\r | |
505 | @param BltOperation Operation to perform on BlitBuffer and video memory\r | |
506 | @param SourceX X coordinate of source for the BltBuffer.\r | |
507 | @param SourceY Y coordinate of source for the BltBuffer.\r | |
508 | @param DestinationX X coordinate of destination for the BltBuffer.\r | |
509 | @param DestinationY Y coordinate of destination for the BltBuffer.\r | |
510 | @param Width Width of rectangle in BltBuffer in pixels.\r | |
511 | @param Height Hight of rectangle in BltBuffer in pixels.\r | |
512 | @param Delta OPTIONAL\r | |
513 | \r | |
514 | @retval EFI_SUCCESS The Blt operation completed.\r | |
515 | @retval EFI_INVALID_PARAMETER BltOperation is not valid.\r | |
d181539b | 516 | @retval EFI_DEVICE_ERROR A hardware error occurred writting to the video buffer.\r |
a4d608d1 | 517 | \r |
518 | **/\r | |
d0c64728 | 519 | EFI_STATUS\r |
520 | EFIAPI\r | |
d6e11f22 | 521 | ConSplitterUgaDrawBlt (\r |
1436aea4 MK |
522 | IN EFI_UGA_DRAW_PROTOCOL *This,\r |
523 | IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,\r | |
524 | IN EFI_UGA_BLT_OPERATION BltOperation,\r | |
525 | IN UINTN SourceX,\r | |
526 | IN UINTN SourceY,\r | |
527 | IN UINTN DestinationX,\r | |
528 | IN UINTN DestinationY,\r | |
529 | IN UINTN Width,\r | |
530 | IN UINTN Height,\r | |
531 | IN UINTN Delta OPTIONAL\r | |
d0c64728 | 532 | )\r |
d0c64728 | 533 | {\r |
534 | EFI_STATUS Status;\r | |
535 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
536 | UINTN Index;\r | |
537 | EFI_STATUS ReturnStatus;\r | |
538 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
539 | \r | |
540 | Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
541 | \r | |
9937b365 | 542 | ReturnStatus = EFI_SUCCESS;\r |
d0c64728 | 543 | //\r |
544 | // return the worst status met\r | |
545 | //\r | |
546 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
547 | GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;\r | |
548 | if (GraphicsOutput != NULL) {\r | |
549 | Status = GraphicsOutput->Blt (\r | |
1436aea4 MK |
550 | GraphicsOutput,\r |
551 | (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)BltBuffer,\r | |
552 | (EFI_GRAPHICS_OUTPUT_BLT_OPERATION)BltOperation,\r | |
553 | SourceX,\r | |
554 | SourceY,\r | |
555 | DestinationX,\r | |
556 | DestinationY,\r | |
557 | Width,\r | |
558 | Height,\r | |
559 | Delta\r | |
560 | );\r | |
d0c64728 | 561 | if (EFI_ERROR (Status)) {\r |
562 | ReturnStatus = Status;\r | |
815119f3 | 563 | } else if (BltOperation == EfiUgaVideoToBltBuffer) {\r |
d0c64728 | 564 | //\r |
565 | // Only need to read the data into buffer one time\r | |
566 | //\r | |
567 | return EFI_SUCCESS;\r | |
568 | }\r | |
569 | }\r | |
570 | \r | |
1436aea4 | 571 | if ((Private->TextOutList[Index].UgaDraw != NULL) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r |
d0c64728 | 572 | Status = Private->TextOutList[Index].UgaDraw->Blt (\r |
573 | Private->TextOutList[Index].UgaDraw,\r | |
574 | BltBuffer,\r | |
575 | BltOperation,\r | |
576 | SourceX,\r | |
577 | SourceY,\r | |
578 | DestinationX,\r | |
579 | DestinationY,\r | |
580 | Width,\r | |
581 | Height,\r | |
582 | Delta\r | |
583 | );\r | |
584 | if (EFI_ERROR (Status)) {\r | |
585 | ReturnStatus = Status;\r | |
586 | } else if (BltOperation == EfiUgaVideoToBltBuffer) {\r | |
587 | //\r | |
588 | // Only need to read the data into buffer one time\r | |
589 | //\r | |
590 | return EFI_SUCCESS;\r | |
591 | }\r | |
592 | }\r | |
593 | }\r | |
594 | \r | |
595 | return ReturnStatus;\r | |
596 | }\r | |
597 | \r | |
a4d608d1 | 598 | /**\r |
599 | Sets the output device(s) to a specified mode.\r | |
600 | \r | |
2da292f6 | 601 | @param Private Text Out Splitter pointer.\r |
a4d608d1 | 602 | @param ModeNumber The mode number to set.\r |
603 | \r | |
a4d608d1 | 604 | **/\r |
9937b365 | 605 | VOID\r |
606 | TextOutSetMode (\r | |
95276127 | 607 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r |
608 | IN UINTN ModeNumber\r | |
609 | )\r | |
95276127 | 610 | {\r |
611 | //\r | |
612 | // No need to do extra check here as whether (Column, Row) is valid has\r | |
613 | // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should\r | |
614 | // always be supported.\r | |
615 | //\r | |
1436aea4 | 616 | Private->TextOutMode.Mode = (INT32)ModeNumber;\r |
9937b365 | 617 | Private->TextOutMode.CursorColumn = 0;\r |
618 | Private->TextOutMode.CursorRow = 0;\r | |
619 | Private->TextOutMode.CursorVisible = TRUE;\r | |
a4d608d1 | 620 | \r |
9937b365 | 621 | return;\r |
95276127 | 622 | }\r |