2 This file produces the graphics abstration of UGA Draw. It is called by
3 CirrusLogic5430.c file which deals with the EFI 1.1 driver model.
4 This file just does graphics.
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "CirrusLogic5430.h"
20 /// Video Mode structure
30 } CIRRUS_LOGIC_5430_VIDEO_MODES
;
33 /// Generic Attribute Controller Register Settings
35 static UINT8 AttributeController
[21] = {
36 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
37 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
38 0x41, 0x00, 0x0F, 0x00, 0x00
42 /// Generic Graphics Controller Register Settings
44 static UINT8 GraphicsController
[9] = {
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF
49 // 640 x 480 x 256 color @ 60 Hertz
51 static UINT8 Crtc_640_480_256_60
[28] = {
52 0x5d, 0x4f, 0x50, 0x82, 0x53, 0x9f, 0x00, 0x3e,
53 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 0xe1, 0x83, 0xdf, 0x50, 0x00, 0xe7, 0x04, 0xe3,
55 0xff, 0x00, 0x00, 0x22
58 static UINT16 Seq_640_480_256_60
[15] = {
59 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
60 0x5b0c, 0x450d, 0x7e0e, 0x2b1b, 0x2f1c, 0x301d, 0x331e
64 // 800 x 600 x 256 color @ 60 Hertz
66 static UINT8 Crtc_800_600_256_60
[28] = {
67 0x7F, 0x63, 0x64, 0x80, 0x6B, 0x1B, 0x72, 0xF0,
68 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
69 0x58, 0x8C, 0x57, 0x64, 0x00, 0x5F, 0x91, 0xE3,
70 0xFF, 0x00, 0x00, 0x22
73 static UINT16 Seq_800_600_256_60
[15] = {
74 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
75 0x5b0c, 0x450d, 0x510e, 0x2b1b, 0x2f1c, 0x301d, 0x3a1e
79 // 1024 x 768 x 256 color @ 60 Hertz
81 static UINT8 Crtc_1024_768_256_60
[28] = {
82 0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD,
83 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
84 0x02, 0x88, 0xFF, 0x80, 0x00, 0x00, 0x24, 0xE3,
85 0xFF, 0x4A, 0x00, 0x22
88 static UINT16 Seq_1024_768_256_60
[15] = {
89 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
90 0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e
94 /// Table of supported video modes
96 static CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes
[] = {
97 { 640, 480, 8, 60, Crtc_640_480_256_60
, Seq_640_480_256_60
, 0xe3 },
98 { 800, 600, 8, 60, Crtc_800_600_256_60
, Seq_800_600_256_60
, 0xef },
99 { 1024, 768, 8, 60, Crtc_1024_768_256_60
, Seq_1024_768_256_60
, 0xef }
103 // Local Function Prototypes
106 InitializeGraphicsMode (
107 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
108 CIRRUS_LOGIC_5430_VIDEO_MODES
*ModeData
113 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
122 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
128 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
133 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
138 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
145 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
152 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
158 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
163 // UGA Draw Protocol Member Functions
166 TODO: Add function description
168 @param This TODO: add argument description
169 @param HorizontalResolution TODO: add argument description
170 @param VerticalResolution TODO: add argument description
171 @param ColorDepth TODO: add argument description
172 @param RefreshRate TODO: add argument description
174 @retval EFI_NOT_STARTED TODO: Add description for return value
175 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
176 @retval EFI_SUCCESS TODO: Add description for return value
182 CirrusLogic5430UgaDrawGetMode (
183 IN EFI_UGA_DRAW_PROTOCOL
*This
,
184 OUT UINT32
*HorizontalResolution
,
185 OUT UINT32
*VerticalResolution
,
186 OUT UINT32
*ColorDepth
,
187 OUT UINT32
*RefreshRate
190 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
;
192 Private
= CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (This
);
194 if (Private
->HardwareNeedsStarting
) {
195 return EFI_NOT_STARTED
;
198 if ((HorizontalResolution
== NULL
) ||
199 (VerticalResolution
== NULL
) ||
200 (ColorDepth
== NULL
) ||
201 (RefreshRate
== NULL
)) {
202 return EFI_INVALID_PARAMETER
;
205 *HorizontalResolution
= Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
;
206 *VerticalResolution
= Private
->ModeData
[Private
->CurrentMode
].VerticalResolution
;
207 *ColorDepth
= Private
->ModeData
[Private
->CurrentMode
].ColorDepth
;
208 *RefreshRate
= Private
->ModeData
[Private
->CurrentMode
].RefreshRate
;
214 TODO: Add function description
216 @param This TODO: add argument description
217 @param HorizontalResolution TODO: add argument description
218 @param VerticalResolution TODO: add argument description
219 @param ColorDepth TODO: add argument description
220 @param RefreshRate TODO: add argument description
222 @retval EFI_OUT_OF_RESOURCES TODO: Add description for return value
223 @retval EFI_SUCCESS TODO: Add description for return value
224 @retval EFI_NOT_FOUND TODO: Add description for return value
230 CirrusLogic5430UgaDrawSetMode (
231 IN EFI_UGA_DRAW_PROTOCOL
*This
,
232 IN UINT32 HorizontalResolution
,
233 IN UINT32 VerticalResolution
,
234 IN UINT32 ColorDepth
,
235 IN UINT32 RefreshRate
238 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
;
241 Private
= CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (This
);
243 for (Index
= 0; Index
< Private
->MaxMode
; Index
++) {
245 if (HorizontalResolution
!= Private
->ModeData
[Index
].HorizontalResolution
) {
249 if (VerticalResolution
!= Private
->ModeData
[Index
].VerticalResolution
) {
253 if (ColorDepth
!= Private
->ModeData
[Index
].ColorDepth
) {
257 if (RefreshRate
!= Private
->ModeData
[Index
].RefreshRate
) {
261 if (Private
->LineBuffer
) {
262 gBS
->FreePool (Private
->LineBuffer
);
265 Private
->LineBuffer
= NULL
;
266 Private
->LineBuffer
= AllocatePool (HorizontalResolution
);
267 if (Private
->LineBuffer
== NULL
) {
268 return EFI_OUT_OF_RESOURCES
;
271 InitializeGraphicsMode (Private
, &CirrusLogic5430VideoModes
[Index
]);
273 Private
->CurrentMode
= Index
;
275 Private
->HardwareNeedsStarting
= FALSE
;
280 return EFI_NOT_FOUND
;
284 TODO: Add function description
286 @param This TODO: add argument description
287 @param BltBuffer TODO: add argument description
288 @param BltOperation TODO: add argument description
289 @param SourceX TODO: add argument description
290 @param SourceY TODO: add argument description
291 @param DestinationX TODO: add argument description
292 @param DestinationY TODO: add argument description
293 @param Width TODO: add argument description
294 @param Height TODO: add argument description
295 @param Delta TODO: add argument description
297 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
298 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
299 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
300 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
301 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
302 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
303 @retval EFI_SUCCESS TODO: Add description for return value
309 CirrusLogic5430UgaDrawBlt (
310 IN EFI_UGA_DRAW_PROTOCOL
*This
,
311 IN EFI_UGA_PIXEL
*BltBuffer
, OPTIONAL
312 IN EFI_UGA_BLT_OPERATION BltOperation
,
315 IN UINTN DestinationX
,
316 IN UINTN DestinationY
,
322 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
;
334 Private
= CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (This
);
336 if ((BltOperation
< 0) || (BltOperation
>= EfiUgaBltMax
)) {
337 return EFI_INVALID_PARAMETER
;
340 if (Width
== 0 || Height
== 0) {
341 return EFI_INVALID_PARAMETER
;
345 // If Delta is zero, then the entire BltBuffer is being used, so Delta
346 // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
347 // the number of bytes in each row can be computed.
350 Delta
= Width
* sizeof (EFI_UGA_PIXEL
);
354 // We need to fill the Virtual Screen buffer with the blt data.
355 // The virtual screen is upside down, as the first row is the bootom row of
360 // Make sure the SourceX, SourceY, DestinationX, DestinationY, Width, and Height parameters
361 // are valid for the operation and the current screen geometry.
363 if (BltOperation
== EfiUgaVideoToBltBuffer
) {
365 // Video to BltBuffer: Source is Video, destination is BltBuffer
367 if (SourceY
+ Height
> Private
->ModeData
[Private
->CurrentMode
].VerticalResolution
) {
368 return EFI_INVALID_PARAMETER
;
371 if (SourceX
+ Width
> Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) {
372 return EFI_INVALID_PARAMETER
;
376 // BltBuffer to Video: Source is BltBuffer, destination is Video
378 if (DestinationY
+ Height
> Private
->ModeData
[Private
->CurrentMode
].VerticalResolution
) {
379 return EFI_INVALID_PARAMETER
;
382 if (DestinationX
+ Width
> Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) {
383 return EFI_INVALID_PARAMETER
;
387 // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
388 // We would not want a timer based event (Cursor, ...) to come in while we are
389 // doing this operation.
391 OriginalTPL
= gBS
->RaiseTPL (EFI_TPL_NOTIFY
);
393 switch (BltOperation
) {
394 case EfiUgaVideoToBltBuffer
:
396 // Video to BltBuffer: Source is Video, destination is BltBuffer
398 for (SrcY
= SourceY
, DstY
= DestinationY
; DstY
< (Height
+ DestinationY
); SrcY
++, DstY
++) {
400 Offset
= (SrcY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) + SourceX
;
401 if (((Offset
& 0x03) == 0) && ((Width
& 0x03) == 0)) {
402 Private
->PciIo
->Mem
.Read (
411 Private
->PciIo
->Mem
.Read (
421 for (X
= 0; X
< Width
; X
++) {
422 Blt
= (EFI_UGA_PIXEL
*) ((UINT8
*) BltBuffer
+ (DstY
* Delta
) + (DestinationX
+ X
) * sizeof (EFI_UGA_PIXEL
));
424 Blt
->Red
= (UINT8
) (Private
->LineBuffer
[X
] & 0xe0);
425 Blt
->Green
= (UINT8
) ((Private
->LineBuffer
[X
] & 0x1c) << 3);
426 Blt
->Blue
= (UINT8
) ((Private
->LineBuffer
[X
] & 0x03) << 6);
431 case EfiUgaVideoToVideo
:
433 // Perform hardware acceleration for Video to Video operations
435 ScreenWidth
= Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
;
436 SourceOffset
= (SourceY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) + (SourceX
);
437 Offset
= (DestinationY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) + (DestinationX
);
439 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0000);
440 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0010);
441 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0012);
442 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0014);
444 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0001);
445 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0011);
446 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0013);
447 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0015);
449 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) (((Width
<< 8) & 0xff00) | 0x20));
450 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((Width
& 0xff00) | 0x21));
451 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) (((Height
<< 8) & 0xff00) | 0x22));
452 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((Height
& 0xff00) | 0x23));
453 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) (((ScreenWidth
<< 8) & 0xff00) | 0x24));
454 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((ScreenWidth
& 0xff00) | 0x25));
455 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) (((ScreenWidth
<< 8) & 0xff00) | 0x26));
456 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((ScreenWidth
& 0xff00) | 0x27));
457 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((Offset
) << 8) & 0xff00) | 0x28));
458 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((Offset
) >> 0) & 0xff00) | 0x29));
459 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((Offset
) >> 8) & 0xff00) | 0x2a));
460 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((SourceOffset
) << 8) & 0xff00) | 0x2c));
461 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((SourceOffset
) >> 0) & 0xff00) | 0x2d));
462 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((SourceOffset
) >> 8) & 0xff00) | 0x2e));
463 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x002f);
464 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0030);
465 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0d32);
466 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0033);
467 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0034);
468 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0035);
470 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0231);
472 outb (Private
, GRAPH_ADDRESS_REGISTER
, 0x31);
473 while ((inb (Private
, GRAPH_DATA_REGISTER
) & 0x01) == 0x01)
477 case EfiUgaVideoFill
:
479 Pixel
= (UINT8
) ((Blt
->Red
& 0xe0) | ((Blt
->Green
>> 3) & 0x1c) | ((Blt
->Blue
>> 6) & 0x03));
480 WidePixel
= (Pixel
<< 8) | Pixel
;
481 WidePixel
= (WidePixel
<< 16) | WidePixel
;
483 if (DestinationX
== 0 && Width
== Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) {
484 Offset
= DestinationY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
;
485 if (((Offset
& 0x03) == 0) && (((Width
* Height
) & 0x03) == 0)) {
486 Private
->PciIo
->Mem
.Write (
488 EfiPciIoWidthFillUint32
,
491 (Width
* Height
) >> 2,
495 Private
->PciIo
->Mem
.Write (
497 EfiPciIoWidthFillUint8
,
505 for (SrcY
= SourceY
, DstY
= DestinationY
; SrcY
< (Height
+ SourceY
); SrcY
++, DstY
++) {
506 Offset
= (DstY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) + DestinationX
;
507 if (((Offset
& 0x03) == 0) && ((Width
& 0x03) == 0)) {
508 Private
->PciIo
->Mem
.Write (
510 EfiPciIoWidthFillUint32
,
517 Private
->PciIo
->Mem
.Write (
519 EfiPciIoWidthFillUint8
,
530 case EfiUgaBltBufferToVideo
:
531 for (SrcY
= SourceY
, DstY
= DestinationY
; SrcY
< (Height
+ SourceY
); SrcY
++, DstY
++) {
533 for (X
= 0; X
< Width
; X
++) {
534 Blt
= (EFI_UGA_PIXEL
*) ((UINT8
*) BltBuffer
+ (SrcY
* Delta
) + (SourceX
+ X
) * sizeof (EFI_UGA_PIXEL
));
535 Private
->LineBuffer
[X
] = (UINT8
) ((Blt
->Red
& 0xe0) | ((Blt
->Green
>> 3) & 0x1c) | ((Blt
->Blue
>> 6) & 0x03));
538 Offset
= (DstY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) + DestinationX
;
540 if (((Offset
& 0x03) == 0) && ((Width
& 0x03) == 0)) {
541 Private
->PciIo
->Mem
.Write (
550 Private
->PciIo
->Mem
.Write (
566 gBS
->RestoreTPL (OriginalTPL
);
572 // Construction and Destruction functions
576 CirrusLogic5430UgaDrawConstructor
578 TODO: Private - add argument and description to function comment
579 TODO: EFI_SUCCESS - add return value to function comment
582 CirrusLogic5430UgaDrawConstructor (
583 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
586 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
590 // Fill in Private->UgaDraw protocol
592 UgaDraw
= &Private
->UgaDraw
;
594 UgaDraw
->GetMode
= CirrusLogic5430UgaDrawGetMode
;
595 UgaDraw
->SetMode
= CirrusLogic5430UgaDrawSetMode
;
596 UgaDraw
->Blt
= CirrusLogic5430UgaDrawBlt
;
599 // Initialize the private data
601 Private
->MaxMode
= CIRRUS_LOGIC_5430_UGA_DRAW_MODE_COUNT
;
602 Private
->CurrentMode
= 0;
603 for (Index
= 0; Index
< Private
->MaxMode
; Index
++) {
604 Private
->ModeData
[Index
].HorizontalResolution
= CirrusLogic5430VideoModes
[Index
].Width
;
605 Private
->ModeData
[Index
].VerticalResolution
= CirrusLogic5430VideoModes
[Index
].Height
;
606 Private
->ModeData
[Index
].ColorDepth
= 32;
607 Private
->ModeData
[Index
].RefreshRate
= CirrusLogic5430VideoModes
[Index
].RefreshRate
;
610 Private
->HardwareNeedsStarting
= TRUE
;
611 Private
->LineBuffer
= NULL
;
614 // Initialize the hardware
618 Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
,
619 Private
->ModeData
[Private
->CurrentMode
].VerticalResolution
,
620 Private
->ModeData
[Private
->CurrentMode
].ColorDepth
,
621 Private
->ModeData
[Private
->CurrentMode
].RefreshRate
629 CirrusLogic5430UgaDrawDestructor
631 TODO: Private - add argument and description to function comment
632 TODO: EFI_SUCCESS - add return value to function comment
635 CirrusLogic5430UgaDrawDestructor (
636 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
643 TODO: Add function description
645 @param Private TODO: add argument description
646 @param Address TODO: add argument description
647 @param Data TODO: add argument description
649 TODO: add return values
654 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
659 Private
->PciIo
->Io
.Write (
662 EFI_PCI_IO_PASS_THROUGH_BAR
,
670 TODO: Add function description
672 @param Private TODO: add argument description
673 @param Address TODO: add argument description
674 @param Data TODO: add argument description
676 TODO: add return values
681 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
686 Private
->PciIo
->Io
.Write (
689 EFI_PCI_IO_PASS_THROUGH_BAR
,
697 TODO: Add function description
699 @param Private TODO: add argument description
700 @param Address TODO: add argument description
702 TODO: add return values
707 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
713 Private
->PciIo
->Io
.Read (
716 EFI_PCI_IO_PASS_THROUGH_BAR
,
725 TODO: Add function description
727 @param Private TODO: add argument description
728 @param Address TODO: add argument description
730 TODO: add return values
735 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
741 Private
->PciIo
->Io
.Read (
744 EFI_PCI_IO_PASS_THROUGH_BAR
,
753 TODO: Add function description
755 @param Private TODO: add argument description
756 @param Index TODO: add argument description
757 @param Red TODO: add argument description
758 @param Green TODO: add argument description
759 @param Blue TODO: add argument description
761 TODO: add return values
766 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
773 outb (Private
, PALETTE_INDEX_REGISTER
, (UINT8
) Index
);
774 outb (Private
, PALETTE_DATA_REGISTER
, (UINT8
) (Red
>> 2));
775 outb (Private
, PALETTE_DATA_REGISTER
, (UINT8
) (Green
>> 2));
776 outb (Private
, PALETTE_DATA_REGISTER
, (UINT8
) (Blue
>> 2));
780 TODO: Add function description
782 @param Private TODO: add argument description
784 TODO: add return values
789 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
798 for (RedIndex
= 0; RedIndex
< 8; RedIndex
++) {
799 for (GreenIndex
= 0; GreenIndex
< 8; GreenIndex
++) {
800 for (BlueIndex
= 0; BlueIndex
< 4; BlueIndex
++) {
801 SetPaletteColor (Private
, Index
, (UINT8
) (RedIndex
<< 5), (UINT8
) (GreenIndex
<< 5), (UINT8
) (BlueIndex
<< 6));
809 TODO: Add function description
811 @param Private TODO: add argument description
813 TODO: add return values
819 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
825 Private
->PciIo
->Mem
.Write (
827 EfiPciIoWidthFillUint32
,
836 TODO: Add function description
838 @param Private TODO: add argument description
840 TODO: add return values
845 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
855 ScreenWidth
= Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
;
856 ScreenHeight
= Private
->ModeData
[Private
->CurrentMode
].VerticalResolution
;
859 for (Y
= 0; Y
< ScreenHeight
; Y
++) {
860 for (X
= 0; X
< ScreenWidth
; X
++) {
861 Color
= (UINT8
) (256 * (X
+ Y
) / (ScreenWidth
+ ScreenHeight
));
862 Private
->LineBuffer
[X
] = Color
;
865 Private
->PciIo
->Mem
.Write (
869 Offset
+ (Y
* ScreenWidth
),
877 TODO: Add function description
879 @param Private TODO: add argument description
880 @param ModeData TODO: add argument description
882 TODO: add return values
886 InitializeGraphicsMode (
887 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
888 CIRRUS_LOGIC_5430_VIDEO_MODES
*ModeData
894 outw (Private
, SEQ_ADDRESS_REGISTER
, 0x1206);
895 outw (Private
, SEQ_ADDRESS_REGISTER
, 0x0012);
897 for (Index
= 0; Index
< 15; Index
++) {
898 outw (Private
, SEQ_ADDRESS_REGISTER
, ModeData
->SeqSettings
[Index
]);
901 outb (Private
, SEQ_ADDRESS_REGISTER
, 0x0f);
902 Byte
= (UINT8
) ((inb (Private
, SEQ_DATA_REGISTER
) & 0xc7) ^ 0x30);
903 outb (Private
, SEQ_DATA_REGISTER
, Byte
);
905 outb (Private
, MISC_OUTPUT_REGISTER
, ModeData
->MiscSetting
);
906 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0506);
907 outw (Private
, SEQ_ADDRESS_REGISTER
, 0x0300);
908 outw (Private
, CRTC_ADDRESS_REGISTER
, 0x2011);
910 for (Index
= 0; Index
< 28; Index
++) {
911 outw (Private
, CRTC_ADDRESS_REGISTER
, (UINT16
) ((ModeData
->CrtcSettings
[Index
] << 8) | Index
));
914 for (Index
= 0; Index
< 9; Index
++) {
915 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((GraphicsController
[Index
] << 8) | Index
));
918 inb (Private
, INPUT_STATUS_1_REGISTER
);
920 for (Index
= 0; Index
< 21; Index
++) {
921 outb (Private
, ATT_ADDRESS_REGISTER
, (UINT8
) Index
);
922 outb (Private
, ATT_ADDRESS_REGISTER
, AttributeController
[Index
]);
925 outb (Private
, ATT_ADDRESS_REGISTER
, 0x20);
927 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0009);
928 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x000a);
929 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x000b);
930 outb (Private
, DAC_PIXEL_MASK_REGISTER
, 0xff);
932 SetDefaultPalette (Private
);
933 ClearScreen (Private
);