TianoCore EDK2 master
Loading...
Searching...
No Matches
ConSplitterGraphics.c
Go to the documentation of this file.
1
10#include "ConSplitter.h"
11
12CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };
13
31EFIAPI
34 IN UINT32 ModeNumber,
35 OUT UINTN *SizeOfInfo,
37 )
38{
40 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
41 EFI_STATUS Status;
42 UINTN Index;
43
44 if ((This == NULL) || (Info == NULL) || (SizeOfInfo == NULL) || (ModeNumber >= This->Mode->MaxMode)) {
45 return EFI_INVALID_PARAMETER;
46 }
47
48 //
49 // retrieve private data
50 //
51 Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
52
53 GraphicsOutput = NULL;
54
55 if (Private->CurrentNumberOfGraphicsOutput == 1) {
56 //
57 // Find the only one GraphicsOutput.
58 //
59 for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
60 GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
61 if (GraphicsOutput != NULL) {
62 break;
63 }
64 }
65 }
66
67 if (GraphicsOutput != NULL) {
68 //
69 // If only one physical GOP device exist, return its information.
70 //
71 Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32)ModeNumber, SizeOfInfo, Info);
72 return Status;
73 } else {
74 //
75 // If 2 more phyiscal GOP device exist or GOP protocol does not exist,
76 // return GOP information (PixelFormat is PixelBltOnly) created in ConSplitterAddGraphicsOutputMode ().
77 //
79 if (*Info == NULL) {
80 return EFI_OUT_OF_RESOURCES;
81 }
82
83 *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
84 CopyMem (*Info, &Private->GraphicsOutputModeBuffer[ModeNumber], *SizeOfInfo);
85 }
86
87 return EFI_SUCCESS;
88}
89
104EFIAPI
107 IN UINT32 ModeNumber
108 )
109{
110 EFI_STATUS Status;
112 UINTN Index;
113 EFI_STATUS ReturnStatus;
115 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
116 EFI_GRAPHICS_OUTPUT_PROTOCOL *PhysicalGraphicsOutput;
117 UINTN NumberIndex;
118 UINTN SizeOfInfo;
120 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
121
122 if (ModeNumber >= This->Mode->MaxMode) {
123 return EFI_UNSUPPORTED;
124 }
125
126 Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
127 Mode = &Private->GraphicsOutputModeBuffer[ModeNumber];
128
129 ReturnStatus = EFI_SUCCESS;
130 GraphicsOutput = NULL;
131 PhysicalGraphicsOutput = NULL;
132 //
133 // return the worst status met
134 //
135 for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
136 GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
137 if (GraphicsOutput != NULL) {
138 PhysicalGraphicsOutput = GraphicsOutput;
139 //
140 // Find corresponding ModeNumber of this GraphicsOutput instance
141 //
142 for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex++) {
143 Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32)NumberIndex, &SizeOfInfo, &Info);
144 if (EFI_ERROR (Status)) {
145 return Status;
146 }
147
148 if ((Info->HorizontalResolution == Mode->HorizontalResolution) && (Info->VerticalResolution == Mode->VerticalResolution)) {
149 FreePool (Info);
150 break;
151 }
152
153 FreePool (Info);
154 }
155
156 Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32)NumberIndex);
157 if (EFI_ERROR (Status)) {
158 ReturnStatus = Status;
159 }
160 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
161 UgaDraw = Private->TextOutList[Index].UgaDraw;
162 if (UgaDraw != NULL) {
163 Status = UgaDraw->SetMode (
164 UgaDraw,
166 Mode->VerticalResolution,
167 32,
168 60
169 );
170 if (EFI_ERROR (Status)) {
171 ReturnStatus = Status;
172 }
173 }
174 }
175 }
176
177 This->Mode->Mode = ModeNumber;
178
179 if ((Private->CurrentNumberOfGraphicsOutput == 1) && (PhysicalGraphicsOutput != NULL)) {
180 //
181 // If only one physical GOP device exist, copy physical information to consplitter.
182 //
183 CopyMem (This->Mode->Info, PhysicalGraphicsOutput->Mode->Info, PhysicalGraphicsOutput->Mode->SizeOfInfo);
184 This->Mode->SizeOfInfo = PhysicalGraphicsOutput->Mode->SizeOfInfo;
185 This->Mode->FrameBufferBase = PhysicalGraphicsOutput->Mode->FrameBufferBase;
186 This->Mode->FrameBufferSize = PhysicalGraphicsOutput->Mode->FrameBufferSize;
187 } else {
188 //
189 // If 2 more phyiscal GOP device exist or GOP protocol does not exist,
190 // return GOP information (PixelFormat is PixelBltOnly) created in ConSplitterAddGraphicsOutputMode ().
191 //
192 CopyMem (This->Mode->Info, &Private->GraphicsOutputModeBuffer[ModeNumber], This->Mode->SizeOfInfo);
193 }
194
195 return ReturnStatus;
196}
197
245EFIAPI
248 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
250 IN UINTN SourceX,
251 IN UINTN SourceY,
252 IN UINTN DestinationX,
253 IN UINTN DestinationY,
254 IN UINTN Width,
255 IN UINTN Height,
256 IN UINTN Delta OPTIONAL
257 )
258{
259 EFI_STATUS Status;
260 EFI_STATUS ReturnStatus;
262 UINTN Index;
263 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
264 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
265
266 if ((This == NULL) || (((UINTN)BltOperation) >= EfiGraphicsOutputBltOperationMax)) {
267 return EFI_INVALID_PARAMETER;
268 }
269
270 Private = GRAPHICS_OUTPUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
271
272 ReturnStatus = EFI_SUCCESS;
273
274 //
275 // return the worst status met
276 //
277 for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
278 GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
279 if (GraphicsOutput != NULL) {
280 Status = GraphicsOutput->Blt (
281 GraphicsOutput,
282 BltBuffer,
283 BltOperation,
284 SourceX,
285 SourceY,
286 DestinationX,
287 DestinationY,
288 Width,
289 Height,
290 Delta
291 );
292 if (EFI_ERROR (Status)) {
293 ReturnStatus = Status;
294 } else if (BltOperation == EfiBltVideoToBltBuffer) {
295 //
296 // Only need to read the data into buffer one time
297 //
298 return EFI_SUCCESS;
299 }
300 }
301
302 UgaDraw = Private->TextOutList[Index].UgaDraw;
303 if ((UgaDraw != NULL) && FeaturePcdGet (PcdUgaConsumeSupport)) {
304 Status = UgaDraw->Blt (
305 UgaDraw,
306 (EFI_UGA_PIXEL *)BltBuffer,
307 (EFI_UGA_BLT_OPERATION)BltOperation,
308 SourceX,
309 SourceY,
310 DestinationX,
311 DestinationY,
312 Width,
313 Height,
314 Delta
315 );
316 if (EFI_ERROR (Status)) {
317 ReturnStatus = Status;
318 } else if (BltOperation == EfiBltVideoToBltBuffer) {
319 //
320 // Only need to read the data into buffer one time
321 //
322 return EFI_SUCCESS;
323 }
324 }
325 }
326
327 return ReturnStatus;
328}
329
345EFIAPI
348 OUT UINT32 *HorizontalResolution,
349 OUT UINT32 *VerticalResolution,
350 OUT UINT32 *ColorDepth,
351 OUT UINT32 *RefreshRate
352 )
353{
355
356 if ((HorizontalResolution == NULL) ||
357 (VerticalResolution == NULL) ||
358 (RefreshRate == NULL) ||
359 (ColorDepth == NULL))
360 {
361 return EFI_INVALID_PARAMETER;
362 }
363
364 //
365 // retrieve private data
366 //
367 Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
368
369 *HorizontalResolution = Private->UgaHorizontalResolution;
370 *VerticalResolution = Private->UgaVerticalResolution;
371 *ColorDepth = Private->UgaColorDepth;
372 *RefreshRate = Private->UgaRefreshRate;
373
374 return EFI_SUCCESS;
375}
376
392EFIAPI
395 IN UINT32 HorizontalResolution,
396 IN UINT32 VerticalResolution,
397 IN UINT32 ColorDepth,
398 IN UINT32 RefreshRate
399 )
400{
401 EFI_STATUS Status;
403 UINTN Index;
404 EFI_STATUS ReturnStatus;
405 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
406 UINTN NumberIndex;
407 UINTN SizeOfInfo;
409 EFI_UGA_DRAW_PROTOCOL *UgaDraw;
410
411 Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
412
413 ReturnStatus = EFI_SUCCESS;
414
415 //
416 // Update the Mode data
417 //
418 Private->UgaHorizontalResolution = HorizontalResolution;
419 Private->UgaVerticalResolution = VerticalResolution;
420 Private->UgaColorDepth = ColorDepth;
421 Private->UgaRefreshRate = RefreshRate;
422
423 //
424 // return the worst status met
425 //
426 for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
427 GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
428 if (GraphicsOutput != NULL) {
429 //
430 // Find corresponding ModeNumber of this GraphicsOutput instance
431 //
432 for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex++) {
433 Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32)NumberIndex, &SizeOfInfo, &Info);
434 if (EFI_ERROR (Status)) {
435 return Status;
436 }
437
438 if ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution == VerticalResolution)) {
439 FreePool (Info);
440 break;
441 }
442
443 FreePool (Info);
444 }
445
446 Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32)NumberIndex);
447 if (EFI_ERROR (Status)) {
448 ReturnStatus = Status;
449 }
450 } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
451 UgaDraw = Private->TextOutList[Index].UgaDraw;
452 if (UgaDraw != NULL) {
453 Status = UgaDraw->SetMode (
454 UgaDraw,
455 HorizontalResolution,
456 VerticalResolution,
457 ColorDepth,
458 RefreshRate
459 );
460 if (EFI_ERROR (Status)) {
461 ReturnStatus = Status;
462 }
463 }
464 }
465 }
466
467 return ReturnStatus;
468}
469
520EFIAPI
523 IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
524 IN EFI_UGA_BLT_OPERATION BltOperation,
525 IN UINTN SourceX,
526 IN UINTN SourceY,
527 IN UINTN DestinationX,
528 IN UINTN DestinationY,
529 IN UINTN Width,
530 IN UINTN Height,
531 IN UINTN Delta OPTIONAL
532 )
533{
534 EFI_STATUS Status;
536 UINTN Index;
537 EFI_STATUS ReturnStatus;
538 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
539
540 Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
541
542 ReturnStatus = EFI_SUCCESS;
543 //
544 // return the worst status met
545 //
546 for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
547 GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
548 if (GraphicsOutput != NULL) {
549 Status = GraphicsOutput->Blt (
550 GraphicsOutput,
553 SourceX,
554 SourceY,
555 DestinationX,
556 DestinationY,
557 Width,
558 Height,
559 Delta
560 );
561 if (EFI_ERROR (Status)) {
562 ReturnStatus = Status;
563 } else if (BltOperation == EfiUgaVideoToBltBuffer) {
564 //
565 // Only need to read the data into buffer one time
566 //
567 return EFI_SUCCESS;
568 }
569 }
570
571 if ((Private->TextOutList[Index].UgaDraw != NULL) && FeaturePcdGet (PcdUgaConsumeSupport)) {
572 Status = Private->TextOutList[Index].UgaDraw->Blt (
573 Private->TextOutList[Index].UgaDraw,
574 BltBuffer,
575 BltOperation,
576 SourceX,
577 SourceY,
578 DestinationX,
579 DestinationY,
580 Width,
581 Height,
582 Delta
583 );
584 if (EFI_ERROR (Status)) {
585 ReturnStatus = Status;
586 } else if (BltOperation == EfiUgaVideoToBltBuffer) {
587 //
588 // Only need to read the data into buffer one time
589 //
590 return EFI_SUCCESS;
591 }
592 }
593 }
594
595 return ReturnStatus;
596}
597
605VOID
608 IN UINTN ModeNumber
609 )
610{
611 //
612 // No need to do extra check here as whether (Column, Row) is valid has
613 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
614 // always be supported.
615 //
616 Private->TextOutMode.Mode = (INT32)ModeNumber;
617 Private->TextOutMode.CursorColumn = 0;
618 Private->TextOutMode.CursorRow = 0;
619 Private->TextOutMode.CursorVisible = TRUE;
620
621 return;
622}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS EFIAPI ConSplitterUgaDrawGetMode(IN EFI_UGA_DRAW_PROTOCOL *This, OUT UINT32 *HorizontalResolution, OUT UINT32 *VerticalResolution, OUT UINT32 *ColorDepth, OUT UINT32 *RefreshRate)
EFI_STATUS EFIAPI ConSplitterGraphicsOutputBlt(IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL, IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN Delta OPTIONAL)
VOID TextOutSetMode(IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private, IN UINTN ModeNumber)
EFI_STATUS EFIAPI ConSplitterGraphicsOutputSetMode(IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, IN UINT32 ModeNumber)
EFI_STATUS EFIAPI ConSplitterGraphicsOutputQueryMode(IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, IN UINT32 ModeNumber, OUT UINTN *SizeOfInfo, OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info)
EFI_STATUS EFIAPI ConSplitterUgaDrawBlt(IN EFI_UGA_DRAW_PROTOCOL *This, IN EFI_UGA_PIXEL *BltBuffer OPTIONAL, IN EFI_UGA_BLT_OPERATION BltOperation, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN Delta OPTIONAL)
EFI_STATUS EFIAPI ConSplitterUgaDrawSetMode(IN EFI_UGA_DRAW_PROTOCOL *This, IN UINT32 HorizontalResolution, IN UINT32 VerticalResolution, IN UINT32 ColorDepth, IN UINT32 RefreshRate)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_GRAPHICS_OUTPUT_BLT_OPERATION
@ EfiBltVideoToBltBuffer
#define FeaturePcdGet(TokenName)
Definition: PcdLib.h:50
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_UGA_BLT_OPERATION
Definition: UgaDraw.h:83
@ EfiUgaVideoToBltBuffer
Definition: UgaDraw.h:89
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE * Mode
EFI_PHYSICAL_ADDRESS FrameBufferBase
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * Info