]>
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 | |
95276127 | 12 | \r |
fe1e36e5 | 13 | CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };\r |
a4d608d1 | 14 | \r |
a4d608d1 | 15 | /**\r |
2da292f6 | 16 | Returns information for an available graphics mode that the graphics device\r |
17 | and the set of active video output devices supports.\r | |
a4d608d1 | 18 | \r |
2da292f6 | 19 | @param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.\r |
20 | @param ModeNumber The mode number to return information on.\r | |
21 | @param SizeOfInfo A pointer to the size, in bytes, of the Info buffer.\r | |
22 | @param Info A pointer to callee allocated buffer that returns information about ModeNumber.\r | |
a4d608d1 | 23 | \r |
2da292f6 | 24 | @retval EFI_SUCCESS Mode information returned.\r |
25 | @retval EFI_BUFFER_TOO_SMALL The Info buffer was too small.\r | |
26 | @retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the video mode.\r | |
2da292f6 | 27 | @retval EFI_INVALID_PARAMETER One of the input args was NULL.\r |
28 | @retval EFI_OUT_OF_RESOURCES No resource available.\r | |
a4d608d1 | 29 | \r |
30 | **/\r | |
95276127 | 31 | EFI_STATUS\r |
32 | EFIAPI\r | |
d6e11f22 | 33 | ConSplitterGraphicsOutputQueryMode (\r |
95276127 | 34 | IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r |
35 | IN UINT32 ModeNumber,\r | |
36 | OUT UINTN *SizeOfInfo,\r | |
37 | OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info\r | |
38 | )\r | |
95276127 | 39 | {\r |
40 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
2fa996f9 | 41 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r |
42 | EFI_STATUS Status;\r | |
43 | UINTN Index;\r | |
95276127 | 44 | \r |
45 | if (This == NULL || Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {\r | |
46 | return EFI_INVALID_PARAMETER;\r | |
47 | }\r | |
48 | \r | |
49 | //\r | |
50 | // retrieve private data\r | |
51 | //\r | |
52 | Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
53 | \r | |
2fa996f9 | 54 | GraphicsOutput = NULL;\r |
d1102dba | 55 | \r |
2fa996f9 | 56 | if (Private->CurrentNumberOfGraphicsOutput == 1) {\r |
57 | //\r | |
58 | // Find the only one GraphicsOutput.\r | |
59 | //\r | |
60 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
61 | GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;\r | |
62 | if (GraphicsOutput != NULL) {\r | |
63 | break;\r | |
64 | }\r | |
65 | }\r | |
66 | }\r | |
d1102dba | 67 | \r |
2fa996f9 | 68 | if (GraphicsOutput != NULL) {\r |
69 | //\r | |
70 | // If only one physical GOP device exist, return its information.\r | |
71 | //\r | |
72 | Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) ModeNumber, SizeOfInfo, Info);\r | |
73 | return Status;\r | |
74 | } else {\r | |
75 | //\r | |
d1102dba | 76 | // If 2 more phyiscal GOP device exist or GOP protocol does not exist,\r |
2fa996f9 | 77 | // return GOP information (PixelFormat is PixelBltOnly) created in ConSplitterAddGraphicsOutputMode ().\r |
78 | //\r | |
79 | *Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
80 | if (*Info == NULL) {\r | |
81 | return EFI_OUT_OF_RESOURCES;\r | |
82 | }\r | |
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 |
91 | /**\r | |
ed055f1b | 92 | Set the video device into the specified mode and clears the visible portions of\r |
2da292f6 | 93 | the output display to black.\r |
a4d608d1 | 94 | \r |
2da292f6 | 95 | @param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.\r |
96 | @param ModeNumber Abstraction that defines the current video mode.\r | |
a4d608d1 | 97 | \r |
2da292f6 | 98 | @retval EFI_SUCCESS The graphics mode specified by ModeNumber was selected.\r |
99 | @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.\r | |
100 | @retval EFI_UNSUPPORTED ModeNumber is not supported by this device.\r | |
101 | @retval EFI_OUT_OF_RESOURCES No resource available.\r | |
a4d608d1 | 102 | \r |
103 | **/\r | |
95276127 | 104 | EFI_STATUS\r |
105 | EFIAPI\r | |
d6e11f22 | 106 | ConSplitterGraphicsOutputSetMode (\r |
95276127 | 107 | IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r |
108 | IN UINT32 ModeNumber\r | |
109 | )\r | |
95276127 | 110 | {\r |
111 | EFI_STATUS Status;\r | |
112 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
113 | UINTN Index;\r | |
114 | EFI_STATUS ReturnStatus;\r | |
aec072ad | 115 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode;\r |
95276127 | 116 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r |
8d4e1bd9 | 117 | EFI_GRAPHICS_OUTPUT_PROTOCOL *PhysicalGraphicsOutput;\r |
95276127 | 118 | UINTN NumberIndex;\r |
119 | UINTN SizeOfInfo;\r | |
120 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r | |
121 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
122 | \r | |
123 | if (ModeNumber >= This->Mode->MaxMode) {\r | |
124 | return EFI_UNSUPPORTED;\r | |
125 | }\r | |
126 | \r | |
95276127 | 127 | Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r |
95276127 | 128 | Mode = &Private->GraphicsOutputModeBuffer[ModeNumber];\r |
95276127 | 129 | \r |
9937b365 | 130 | ReturnStatus = EFI_SUCCESS;\r |
2fa996f9 | 131 | GraphicsOutput = NULL;\r |
8d4e1bd9 | 132 | PhysicalGraphicsOutput = NULL;\r |
95276127 | 133 | //\r |
134 | // return the worst status met\r | |
135 | //\r | |
136 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
137 | GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;\r | |
138 | if (GraphicsOutput != NULL) {\r | |
8d4e1bd9 | 139 | PhysicalGraphicsOutput = GraphicsOutput;\r |
95276127 | 140 | //\r |
141 | // Find corresponding ModeNumber of this GraphicsOutput instance\r | |
142 | //\r | |
143 | for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) {\r | |
144 | Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);\r | |
145 | if (EFI_ERROR (Status)) {\r | |
146 | return Status;\r | |
147 | }\r | |
148 | if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) {\r | |
149 | FreePool (Info);\r | |
150 | break;\r | |
151 | }\r | |
152 | FreePool (Info);\r | |
153 | }\r | |
154 | \r | |
155 | Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex);\r | |
156 | if (EFI_ERROR (Status)) {\r | |
157 | ReturnStatus = Status;\r | |
158 | }\r | |
2da292f6 | 159 | } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r |
d0c64728 | 160 | UgaDraw = Private->TextOutList[Index].UgaDraw;\r |
161 | if (UgaDraw != NULL) {\r | |
162 | Status = UgaDraw->SetMode (\r | |
163 | UgaDraw,\r | |
164 | Mode->HorizontalResolution,\r | |
165 | Mode->VerticalResolution,\r | |
166 | 32,\r | |
167 | 60\r | |
168 | );\r | |
169 | if (EFI_ERROR (Status)) {\r | |
170 | ReturnStatus = Status;\r | |
171 | }\r | |
95276127 | 172 | }\r |
173 | }\r | |
174 | }\r | |
175 | \r | |
176 | This->Mode->Mode = ModeNumber;\r | |
177 | \r | |
8d4e1bd9 | 178 | if ((Private->CurrentNumberOfGraphicsOutput == 1) && (PhysicalGraphicsOutput != NULL)) {\r |
2fa996f9 | 179 | //\r |
180 | // If only one physical GOP device exist, copy physical information to consplitter.\r | |
181 | //\r | |
8d4e1bd9 | 182 | CopyMem (This->Mode->Info, PhysicalGraphicsOutput->Mode->Info, PhysicalGraphicsOutput->Mode->SizeOfInfo);\r |
183 | This->Mode->SizeOfInfo = PhysicalGraphicsOutput->Mode->SizeOfInfo;\r | |
184 | This->Mode->FrameBufferBase = PhysicalGraphicsOutput->Mode->FrameBufferBase;\r | |
185 | This->Mode->FrameBufferSize = PhysicalGraphicsOutput->Mode->FrameBufferSize;\r | |
2fa996f9 | 186 | } else {\r |
187 | //\r | |
d1102dba | 188 | // If 2 more phyiscal GOP device exist or GOP protocol does not exist,\r |
2fa996f9 | 189 | // return GOP information (PixelFormat is PixelBltOnly) created in ConSplitterAddGraphicsOutputMode ().\r |
190 | //\r | |
191 | CopyMem (This->Mode->Info, &Private->GraphicsOutputModeBuffer[ModeNumber], This->Mode->SizeOfInfo);\r | |
192 | }\r | |
95276127 | 193 | \r |
95276127 | 194 | return ReturnStatus;\r |
195 | }\r | |
196 | \r | |
95276127 | 197 | \r |
a4d608d1 | 198 | \r |
199 | /**\r | |
200 | The following table defines actions for BltOperations.\r | |
201 | \r | |
202 | EfiBltVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY)\r | |
203 | directly to every pixel of the video display rectangle\r | |
204 | (DestinationX, DestinationY)\r | |
205 | (DestinationX + Width, DestinationY + Height).\r | |
206 | Only one pixel will be used from the BltBuffer. Delta is NOT used.\r | |
207 | EfiBltVideoToBltBuffer - Read data from the video display rectangle\r | |
208 | (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in\r | |
209 | the BltBuffer rectangle (DestinationX, DestinationY )\r | |
210 | (DestinationX + Width, DestinationY + Height). If DestinationX or\r | |
211 | DestinationY is not zero then Delta must be set to the length in bytes\r | |
212 | of a row in the BltBuffer.\r | |
213 | EfiBltBufferToVideo - Write data from the BltBuffer rectangle\r | |
214 | (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the\r | |
215 | video display rectangle (DestinationX, DestinationY)\r | |
216 | (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is\r | |
217 | not zero then Delta must be set to the length in bytes of a row in the\r | |
218 | BltBuffer.\r | |
219 | EfiBltVideoToVideo - Copy from the video display rectangle\r | |
220 | (SourceX, SourceY) (SourceX + Width, SourceY + Height) .\r | |
221 | to the video display rectangle (DestinationX, DestinationY)\r | |
222 | (DestinationX + Width, DestinationY + Height).\r | |
223 | The BltBuffer and Delta are not used in this mode.\r | |
224 | \r | |
225 | @param This Protocol instance pointer.\r | |
226 | @param BltBuffer Buffer containing data to blit into video buffer.\r | |
227 | This buffer has a size of\r | |
228 | Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r | |
229 | @param BltOperation Operation to perform on BlitBuffer and video\r | |
230 | memory\r | |
231 | @param SourceX X coordinate of source for the BltBuffer.\r | |
232 | @param SourceY Y coordinate of source for the BltBuffer.\r | |
233 | @param DestinationX X coordinate of destination for the BltBuffer.\r | |
234 | @param DestinationY Y coordinate of destination for the BltBuffer.\r | |
235 | @param Width Width of rectangle in BltBuffer in pixels.\r | |
ed055f1b | 236 | @param Height Hight of rectangle in BltBuffer in pixels.\r |
33019a71 | 237 | @param Delta OPTIONAL.\r |
a4d608d1 | 238 | \r |
239 | @retval EFI_SUCCESS The Blt operation completed.\r | |
240 | @retval EFI_INVALID_PARAMETER BltOperation is not valid.\r | |
d181539b | 241 | @retval EFI_DEVICE_ERROR A hardware error occurred writting to the video\r |
a4d608d1 | 242 | buffer.\r |
243 | \r | |
244 | **/\r | |
95276127 | 245 | EFI_STATUS\r |
246 | EFIAPI\r | |
d6e11f22 | 247 | ConSplitterGraphicsOutputBlt (\r |
95276127 | 248 | IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r |
e3917e22 | 249 | IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,\r |
95276127 | 250 | IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r |
251 | IN UINTN SourceX,\r | |
252 | IN UINTN SourceY,\r | |
253 | IN UINTN DestinationX,\r | |
254 | IN UINTN DestinationY,\r | |
255 | IN UINTN Width,\r | |
256 | IN UINTN Height,\r | |
257 | IN UINTN Delta OPTIONAL\r | |
258 | )\r | |
95276127 | 259 | {\r |
260 | EFI_STATUS Status;\r | |
7389f649 | 261 | EFI_STATUS ReturnStatus;\r |
95276127 | 262 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r |
263 | UINTN Index;\r | |
95276127 | 264 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r |
265 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
266 | \r | |
97c74782 | 267 | if (This == NULL || ((UINTN) BltOperation) >= EfiGraphicsOutputBltOperationMax) {\r |
268 | return EFI_INVALID_PARAMETER;\r | |
269 | }\r | |
d1102dba | 270 | \r |
95276127 | 271 | Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r |
272 | \r | |
7389f649 | 273 | ReturnStatus = EFI_SUCCESS;\r |
274 | \r | |
95276127 | 275 | //\r |
276 | // return the worst status met\r | |
277 | //\r | |
278 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
279 | GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;\r | |
280 | if (GraphicsOutput != NULL) {\r | |
281 | Status = GraphicsOutput->Blt (\r | |
282 | GraphicsOutput,\r | |
283 | BltBuffer,\r | |
284 | BltOperation,\r | |
285 | SourceX,\r | |
286 | SourceY,\r | |
287 | DestinationX,\r | |
288 | DestinationY,\r | |
289 | Width,\r | |
290 | Height,\r | |
291 | Delta\r | |
292 | );\r | |
293 | if (EFI_ERROR (Status)) {\r | |
294 | ReturnStatus = Status;\r | |
295 | } else if (BltOperation == EfiBltVideoToBltBuffer) {\r | |
296 | //\r | |
297 | // Only need to read the data into buffer one time\r | |
298 | //\r | |
299 | return EFI_SUCCESS;\r | |
300 | }\r | |
301 | }\r | |
302 | \r | |
303 | UgaDraw = Private->TextOutList[Index].UgaDraw;\r | |
8541adab | 304 | if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r |
95276127 | 305 | Status = UgaDraw->Blt (\r |
306 | UgaDraw,\r | |
307 | (EFI_UGA_PIXEL *) BltBuffer,\r | |
308 | (EFI_UGA_BLT_OPERATION) BltOperation,\r | |
309 | SourceX,\r | |
310 | SourceY,\r | |
311 | DestinationX,\r | |
312 | DestinationY,\r | |
313 | Width,\r | |
314 | Height,\r | |
315 | Delta\r | |
316 | );\r | |
317 | if (EFI_ERROR (Status)) {\r | |
318 | ReturnStatus = Status;\r | |
319 | } else if (BltOperation == EfiBltVideoToBltBuffer) {\r | |
320 | //\r | |
321 | // Only need to read the data into buffer one time\r | |
322 | //\r | |
323 | return EFI_SUCCESS;\r | |
324 | }\r | |
325 | }\r | |
326 | }\r | |
327 | \r | |
328 | return ReturnStatus;\r | |
329 | }\r | |
330 | \r | |
a4d608d1 | 331 | /**\r |
332 | Return the current video mode information.\r | |
333 | \r | |
2da292f6 | 334 | @param This The EFI_UGA_DRAW_PROTOCOL instance.\r |
335 | @param HorizontalResolution The size of video screen in pixels in the X dimension.\r | |
336 | @param VerticalResolution The size of video screen in pixels in the Y dimension.\r | |
337 | @param ColorDepth Number of bits per pixel, currently defined to be 32.\r | |
338 | @param RefreshRate The refresh rate of the monitor in Hertz.\r | |
a4d608d1 | 339 | \r |
2da292f6 | 340 | @retval EFI_SUCCESS Mode information returned.\r |
341 | @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()\r | |
342 | @retval EFI_INVALID_PARAMETER One of the input args was NULL.\r | |
a4d608d1 | 343 | \r |
344 | **/\r | |
d0c64728 | 345 | EFI_STATUS\r |
346 | EFIAPI\r | |
d6e11f22 | 347 | ConSplitterUgaDrawGetMode (\r |
d0c64728 | 348 | IN EFI_UGA_DRAW_PROTOCOL *This,\r |
349 | OUT UINT32 *HorizontalResolution,\r | |
350 | OUT UINT32 *VerticalResolution,\r | |
351 | OUT UINT32 *ColorDepth,\r | |
352 | OUT UINT32 *RefreshRate\r | |
353 | )\r | |
d0c64728 | 354 | {\r |
355 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
356 | \r | |
a4d608d1 | 357 | if ((HorizontalResolution == NULL) ||\r |
2da292f6 | 358 | (VerticalResolution == NULL) ||\r |
359 | (RefreshRate == NULL) ||\r | |
360 | (ColorDepth == NULL)) {\r | |
d0c64728 | 361 | return EFI_INVALID_PARAMETER;\r |
362 | }\r | |
363 | //\r | |
364 | // retrieve private data\r | |
365 | //\r | |
366 | Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
367 | \r | |
368 | *HorizontalResolution = Private->UgaHorizontalResolution;\r | |
369 | *VerticalResolution = Private->UgaVerticalResolution;\r | |
370 | *ColorDepth = Private->UgaColorDepth;\r | |
371 | *RefreshRate = Private->UgaRefreshRate;\r | |
372 | \r | |
373 | return EFI_SUCCESS;\r | |
374 | }\r | |
375 | \r | |
a4d608d1 | 376 | \r |
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 |
d0c64728 | 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 | |
399 | )\r | |
d0c64728 | 400 | {\r |
401 | EFI_STATUS Status;\r | |
402 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
403 | UINTN Index;\r | |
404 | EFI_STATUS ReturnStatus;\r | |
d0c64728 | 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 | |
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 | |
418 | Private->UgaHorizontalResolution = HorizontalResolution;\r | |
419 | Private->UgaVerticalResolution = VerticalResolution;\r | |
420 | Private->UgaColorDepth = ColorDepth;\r | |
421 | Private->UgaRefreshRate = RefreshRate;\r | |
422 | \r | |
d0c64728 | 423 | //\r |
424 | // return the worst status met\r | |
425 | //\r | |
426 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
8541adab | 427 | \r |
2da292f6 | 428 | GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;\r |
429 | if (GraphicsOutput != NULL) {\r | |
430 | //\r | |
431 | // Find corresponding ModeNumber of this GraphicsOutput instance\r | |
432 | //\r | |
433 | for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex ++) {\r | |
434 | Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);\r | |
8541adab | 435 | if (EFI_ERROR (Status)) {\r |
2da292f6 | 436 | return Status;\r |
8541adab | 437 | }\r |
2da292f6 | 438 | if ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution == VerticalResolution)) {\r |
d0c64728 | 439 | FreePool (Info);\r |
2da292f6 | 440 | break;\r |
d0c64728 | 441 | }\r |
2da292f6 | 442 | FreePool (Info);\r |
443 | }\r | |
d0c64728 | 444 | \r |
2da292f6 | 445 | Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32) NumberIndex);\r |
446 | if (EFI_ERROR (Status)) {\r | |
447 | ReturnStatus = Status;\r | |
448 | }\r | |
449 | } else if (FeaturePcdGet (PcdUgaConsumeSupport)){\r | |
450 | UgaDraw = Private->TextOutList[Index].UgaDraw;\r | |
451 | if (UgaDraw != NULL) {\r | |
452 | Status = UgaDraw->SetMode (\r | |
453 | UgaDraw,\r | |
454 | HorizontalResolution,\r | |
455 | VerticalResolution,\r | |
456 | ColorDepth,\r | |
457 | RefreshRate\r | |
458 | );\r | |
d0c64728 | 459 | if (EFI_ERROR (Status)) {\r |
460 | ReturnStatus = Status;\r | |
461 | }\r | |
462 | }\r | |
ed055f1b | 463 | }\r |
d0c64728 | 464 | }\r |
465 | \r | |
466 | return ReturnStatus;\r | |
467 | }\r | |
468 | \r | |
d0c64728 | 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 |
d0c64728 | 522 | IN EFI_UGA_DRAW_PROTOCOL *This,\r |
e3917e22 | 523 | IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,\r |
d0c64728 | 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 | |
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 | |
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 | |
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 | |
8541adab | 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 | |
9937b365 | 616 | Private->TextOutMode.Mode = (INT32) ModeNumber;\r |
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 |