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"
22 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
26 /// Generic Attribute Controller Register Settings
28 static UINT8 AttributeController
[21] = {
29 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
30 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
31 0x41, 0x00, 0x0F, 0x00, 0x00
35 /// Generic Graphics Controller Register Settings
37 static UINT8 GraphicsController
[9] = {
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF
42 // 640 x 480 x 256 color @ 60 Hertz
44 static UINT8 Crtc_640_480_256_60
[28] = {
45 0x5d, 0x4f, 0x50, 0x82, 0x53, 0x9f, 0x00, 0x3e,
46 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47 0xe1, 0x83, 0xdf, 0x50, 0x00, 0xe7, 0x04, 0xe3,
48 0xff, 0x00, 0x00, 0x22
51 static UINT16 Seq_640_480_256_60
[15] = {
52 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
53 0x5b0c, 0x450d, 0x7e0e, 0x2b1b, 0x2f1c, 0x301d, 0x331e
57 // 800 x 600 x 256 color @ 60 Hertz
59 static UINT8 Crtc_800_600_256_60
[28] = {
60 0x7F, 0x63, 0x64, 0x80, 0x6B, 0x1B, 0x72, 0xF0,
61 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
62 0x58, 0x8C, 0x57, 0x64, 0x00, 0x5F, 0x91, 0xE3,
63 0xFF, 0x00, 0x00, 0x22
66 static UINT16 Seq_800_600_256_60
[15] = {
67 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
68 0x5b0c, 0x450d, 0x510e, 0x2b1b, 0x2f1c, 0x301d, 0x3a1e
72 // 1024 x 768 x 256 color @ 60 Hertz
74 static UINT8 Crtc_1024_768_256_60
[28] = {
75 0xA3, 0x7F, 0x80, 0x86, 0x85, 0x96, 0x24, 0xFD,
76 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
77 0x02, 0x88, 0xFF, 0x80, 0x00, 0x00, 0x24, 0xE3,
78 0xFF, 0x4A, 0x00, 0x22
81 static UINT16 Seq_1024_768_256_60
[15] = {
82 0x0100, 0x0101, 0x0f02, 0x0003, 0x0e04, 0x1107, 0x0008, 0x4a0b,
83 0x5b0c, 0x450d, 0x760e, 0x2b1b, 0x2f1c, 0x301d, 0x341e
87 /// Table of supported video modes
89 static CIRRUS_LOGIC_5430_VIDEO_MODES CirrusLogic5430VideoModes
[] = {
90 { 640, 480, 8, 60, Crtc_640_480_256_60
, Seq_640_480_256_60
, 0xe3 },
91 { 800, 600, 8, 60, Crtc_800_600_256_60
, Seq_800_600_256_60
, 0xef },
92 { 1024, 768, 8, 60, Crtc_1024_768_256_60
, Seq_1024_768_256_60
, 0xef }
96 // UGA Draw Protocol Member Functions
99 TODO: Add function description
101 @param This TODO: add argument description
102 @param HorizontalResolution TODO: add argument description
103 @param VerticalResolution TODO: add argument description
104 @param ColorDepth TODO: add argument description
105 @param RefreshRate TODO: add argument description
107 @retval EFI_NOT_STARTED TODO: Add description for return value
108 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
109 @retval EFI_SUCCESS TODO: Add description for return value
115 CirrusLogic5430UgaDrawGetMode (
116 IN EFI_UGA_DRAW_PROTOCOL
*This
,
117 OUT UINT32
*HorizontalResolution
,
118 OUT UINT32
*VerticalResolution
,
119 OUT UINT32
*ColorDepth
,
120 OUT UINT32
*RefreshRate
123 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
;
125 Private
= CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (This
);
127 if (Private
->HardwareNeedsStarting
) {
128 return EFI_NOT_STARTED
;
131 if ((HorizontalResolution
== NULL
) ||
132 (VerticalResolution
== NULL
) ||
133 (ColorDepth
== NULL
) ||
134 (RefreshRate
== NULL
)) {
135 return EFI_INVALID_PARAMETER
;
138 *HorizontalResolution
= Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
;
139 *VerticalResolution
= Private
->ModeData
[Private
->CurrentMode
].VerticalResolution
;
140 *ColorDepth
= Private
->ModeData
[Private
->CurrentMode
].ColorDepth
;
141 *RefreshRate
= Private
->ModeData
[Private
->CurrentMode
].RefreshRate
;
147 TODO: Add function description
149 @param This TODO: add argument description
150 @param HorizontalResolution TODO: add argument description
151 @param VerticalResolution TODO: add argument description
152 @param ColorDepth TODO: add argument description
153 @param RefreshRate TODO: add argument description
155 @retval EFI_OUT_OF_RESOURCES TODO: Add description for return value
156 @retval EFI_SUCCESS TODO: Add description for return value
157 @retval EFI_NOT_FOUND TODO: Add description for return value
163 CirrusLogic5430UgaDrawSetMode (
164 IN EFI_UGA_DRAW_PROTOCOL
*This
,
165 IN UINT32 HorizontalResolution
,
166 IN UINT32 VerticalResolution
,
167 IN UINT32 ColorDepth
,
168 IN UINT32 RefreshRate
171 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
;
174 Private
= CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (This
);
176 for (Index
= 0; Index
< Private
->MaxMode
; Index
++) {
178 if (HorizontalResolution
!= Private
->ModeData
[Index
].HorizontalResolution
) {
182 if (VerticalResolution
!= Private
->ModeData
[Index
].VerticalResolution
) {
186 if (ColorDepth
!= Private
->ModeData
[Index
].ColorDepth
) {
190 if (RefreshRate
!= Private
->ModeData
[Index
].RefreshRate
) {
194 if (Private
->LineBuffer
) {
195 gBS
->FreePool (Private
->LineBuffer
);
198 Private
->LineBuffer
= NULL
;
199 Private
->LineBuffer
= AllocatePool (HorizontalResolution
);
200 if (Private
->LineBuffer
== NULL
) {
201 return EFI_OUT_OF_RESOURCES
;
204 InitializeGraphicsMode (Private
, &CirrusLogic5430VideoModes
[Index
]);
206 Private
->CurrentMode
= Index
;
208 Private
->HardwareNeedsStarting
= FALSE
;
213 return EFI_NOT_FOUND
;
217 TODO: Add function description
219 @param This TODO: add argument description
220 @param BltBuffer TODO: add argument description
221 @param BltOperation TODO: add argument description
222 @param SourceX TODO: add argument description
223 @param SourceY TODO: add argument description
224 @param DestinationX TODO: add argument description
225 @param DestinationY TODO: add argument description
226 @param Width TODO: add argument description
227 @param Height TODO: add argument description
228 @param Delta TODO: add argument description
230 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
231 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
232 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
233 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
234 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
235 @retval EFI_INVALID_PARAMETER TODO: Add description for return value
236 @retval EFI_SUCCESS TODO: Add description for return value
242 CirrusLogic5430UgaDrawBlt (
243 IN EFI_UGA_DRAW_PROTOCOL
*This
,
244 IN EFI_UGA_PIXEL
*BltBuffer
, OPTIONAL
245 IN EFI_UGA_BLT_OPERATION BltOperation
,
248 IN UINTN DestinationX
,
249 IN UINTN DestinationY
,
255 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
;
267 Private
= CIRRUS_LOGIC_5430_PRIVATE_DATA_FROM_UGA_DRAW_THIS (This
);
269 if ((BltOperation
< 0) || (BltOperation
>= EfiUgaBltMax
)) {
270 return EFI_INVALID_PARAMETER
;
273 if (Width
== 0 || Height
== 0) {
274 return EFI_INVALID_PARAMETER
;
278 // If Delta is zero, then the entire BltBuffer is being used, so Delta
279 // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
280 // the number of bytes in each row can be computed.
283 Delta
= Width
* sizeof (EFI_UGA_PIXEL
);
287 // We need to fill the Virtual Screen buffer with the blt data.
288 // The virtual screen is upside down, as the first row is the bootom row of
293 // Make sure the SourceX, SourceY, DestinationX, DestinationY, Width, and Height parameters
294 // are valid for the operation and the current screen geometry.
296 if (BltOperation
== EfiUgaVideoToBltBuffer
) {
298 // Video to BltBuffer: Source is Video, destination is BltBuffer
300 if (SourceY
+ Height
> Private
->ModeData
[Private
->CurrentMode
].VerticalResolution
) {
301 return EFI_INVALID_PARAMETER
;
304 if (SourceX
+ Width
> Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) {
305 return EFI_INVALID_PARAMETER
;
309 // BltBuffer to Video: Source is BltBuffer, destination is Video
311 if (DestinationY
+ Height
> Private
->ModeData
[Private
->CurrentMode
].VerticalResolution
) {
312 return EFI_INVALID_PARAMETER
;
315 if (DestinationX
+ Width
> Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) {
316 return EFI_INVALID_PARAMETER
;
320 // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
321 // We would not want a timer based event (Cursor, ...) to come in while we are
322 // doing this operation.
324 OriginalTPL
= gBS
->RaiseTPL (TPL_NOTIFY
);
326 switch (BltOperation
) {
327 case EfiUgaVideoToBltBuffer
:
329 // Video to BltBuffer: Source is Video, destination is BltBuffer
331 for (SrcY
= SourceY
, DstY
= DestinationY
; DstY
< (Height
+ DestinationY
); SrcY
++, DstY
++) {
333 Offset
= (SrcY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) + SourceX
;
334 if (((Offset
& 0x03) == 0) && ((Width
& 0x03) == 0)) {
335 Private
->PciIo
->Mem
.Read (
344 Private
->PciIo
->Mem
.Read (
354 for (X
= 0; X
< Width
; X
++) {
355 Blt
= (EFI_UGA_PIXEL
*) ((UINT8
*) BltBuffer
+ (DstY
* Delta
) + (DestinationX
+ X
) * sizeof (EFI_UGA_PIXEL
));
357 Blt
->Red
= (UINT8
) (Private
->LineBuffer
[X
] & 0xe0);
358 Blt
->Green
= (UINT8
) ((Private
->LineBuffer
[X
] & 0x1c) << 3);
359 Blt
->Blue
= (UINT8
) ((Private
->LineBuffer
[X
] & 0x03) << 6);
364 case EfiUgaVideoToVideo
:
366 // Perform hardware acceleration for Video to Video operations
368 ScreenWidth
= Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
;
369 SourceOffset
= (SourceY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) + (SourceX
);
370 Offset
= (DestinationY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) + (DestinationX
);
372 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0000);
373 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0010);
374 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0012);
375 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0014);
377 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0001);
378 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0011);
379 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0013);
380 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0015);
382 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) (((Width
<< 8) & 0xff00) | 0x20));
383 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((Width
& 0xff00) | 0x21));
384 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) (((Height
<< 8) & 0xff00) | 0x22));
385 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((Height
& 0xff00) | 0x23));
386 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) (((ScreenWidth
<< 8) & 0xff00) | 0x24));
387 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((ScreenWidth
& 0xff00) | 0x25));
388 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) (((ScreenWidth
<< 8) & 0xff00) | 0x26));
389 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((ScreenWidth
& 0xff00) | 0x27));
390 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((Offset
) << 8) & 0xff00) | 0x28));
391 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((Offset
) >> 0) & 0xff00) | 0x29));
392 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((Offset
) >> 8) & 0xff00) | 0x2a));
393 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((SourceOffset
) << 8) & 0xff00) | 0x2c));
394 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((SourceOffset
) >> 0) & 0xff00) | 0x2d));
395 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((((SourceOffset
) >> 8) & 0xff00) | 0x2e));
396 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x002f);
397 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0030);
398 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0d32);
399 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0033);
400 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0034);
401 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0035);
403 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0231);
405 outb (Private
, GRAPH_ADDRESS_REGISTER
, 0x31);
406 while ((inb (Private
, GRAPH_DATA_REGISTER
) & 0x01) == 0x01)
410 case EfiUgaVideoFill
:
412 Pixel
= (UINT8
) ((Blt
->Red
& 0xe0) | ((Blt
->Green
>> 3) & 0x1c) | ((Blt
->Blue
>> 6) & 0x03));
413 WidePixel
= (Pixel
<< 8) | Pixel
;
414 WidePixel
= (WidePixel
<< 16) | WidePixel
;
416 if (DestinationX
== 0 && Width
== Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) {
417 Offset
= DestinationY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
;
418 if (((Offset
& 0x03) == 0) && (((Width
* Height
) & 0x03) == 0)) {
419 Private
->PciIo
->Mem
.Write (
421 EfiPciIoWidthFillUint32
,
424 (Width
* Height
) >> 2,
428 Private
->PciIo
->Mem
.Write (
430 EfiPciIoWidthFillUint8
,
438 for (SrcY
= SourceY
, DstY
= DestinationY
; SrcY
< (Height
+ SourceY
); SrcY
++, DstY
++) {
439 Offset
= (DstY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) + DestinationX
;
440 if (((Offset
& 0x03) == 0) && ((Width
& 0x03) == 0)) {
441 Private
->PciIo
->Mem
.Write (
443 EfiPciIoWidthFillUint32
,
450 Private
->PciIo
->Mem
.Write (
452 EfiPciIoWidthFillUint8
,
463 case EfiUgaBltBufferToVideo
:
464 for (SrcY
= SourceY
, DstY
= DestinationY
; SrcY
< (Height
+ SourceY
); SrcY
++, DstY
++) {
466 for (X
= 0; X
< Width
; X
++) {
467 Blt
= (EFI_UGA_PIXEL
*) ((UINT8
*) BltBuffer
+ (SrcY
* Delta
) + (SourceX
+ X
) * sizeof (EFI_UGA_PIXEL
));
468 Private
->LineBuffer
[X
] = (UINT8
) ((Blt
->Red
& 0xe0) | ((Blt
->Green
>> 3) & 0x1c) | ((Blt
->Blue
>> 6) & 0x03));
471 Offset
= (DstY
* Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
) + DestinationX
;
473 if (((Offset
& 0x03) == 0) && ((Width
& 0x03) == 0)) {
474 Private
->PciIo
->Mem
.Write (
483 Private
->PciIo
->Mem
.Write (
499 gBS
->RestoreTPL (OriginalTPL
);
505 // Construction and Destruction functions
509 CirrusLogic5430UgaDrawConstructor
511 TODO: Private - add argument and description to function comment
512 TODO: EFI_SUCCESS - add return value to function comment
515 CirrusLogic5430UgaDrawConstructor (
516 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
519 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
523 // Fill in Private->UgaDraw protocol
525 UgaDraw
= &Private
->UgaDraw
;
527 UgaDraw
->GetMode
= CirrusLogic5430UgaDrawGetMode
;
528 UgaDraw
->SetMode
= CirrusLogic5430UgaDrawSetMode
;
529 UgaDraw
->Blt
= CirrusLogic5430UgaDrawBlt
;
532 // Initialize the private data
534 Private
->MaxMode
= CIRRUS_LOGIC_5430_UGA_DRAW_MODE_COUNT
;
535 Private
->CurrentMode
= 0;
536 for (Index
= 0; Index
< Private
->MaxMode
; Index
++) {
537 Private
->ModeData
[Index
].HorizontalResolution
= CirrusLogic5430VideoModes
[Index
].Width
;
538 Private
->ModeData
[Index
].VerticalResolution
= CirrusLogic5430VideoModes
[Index
].Height
;
539 Private
->ModeData
[Index
].ColorDepth
= 32;
540 Private
->ModeData
[Index
].RefreshRate
= CirrusLogic5430VideoModes
[Index
].RefreshRate
;
543 Private
->HardwareNeedsStarting
= TRUE
;
544 Private
->LineBuffer
= NULL
;
547 // Initialize the hardware
551 Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
,
552 Private
->ModeData
[Private
->CurrentMode
].VerticalResolution
,
553 Private
->ModeData
[Private
->CurrentMode
].ColorDepth
,
554 Private
->ModeData
[Private
->CurrentMode
].RefreshRate
562 CirrusLogic5430UgaDrawDestructor
564 TODO: Private - add argument and description to function comment
565 TODO: EFI_SUCCESS - add return value to function comment
568 CirrusLogic5430UgaDrawDestructor (
569 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
576 TODO: Add function description
578 @param Private TODO: add argument description
579 @param Address TODO: add argument description
580 @param Data TODO: add argument description
582 TODO: add return values
587 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
592 Private
->PciIo
->Io
.Write (
595 EFI_PCI_IO_PASS_THROUGH_BAR
,
603 TODO: Add function description
605 @param Private TODO: add argument description
606 @param Address TODO: add argument description
607 @param Data TODO: add argument description
609 TODO: add return values
614 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
619 Private
->PciIo
->Io
.Write (
622 EFI_PCI_IO_PASS_THROUGH_BAR
,
630 TODO: Add function description
632 @param Private TODO: add argument description
633 @param Address TODO: add argument description
635 TODO: add return values
640 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
646 Private
->PciIo
->Io
.Read (
649 EFI_PCI_IO_PASS_THROUGH_BAR
,
658 TODO: Add function description
660 @param Private TODO: add argument description
661 @param Address TODO: add argument description
663 TODO: add return values
668 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
674 Private
->PciIo
->Io
.Read (
677 EFI_PCI_IO_PASS_THROUGH_BAR
,
686 TODO: Add function description
688 @param Private TODO: add argument description
689 @param Index TODO: add argument description
690 @param Red TODO: add argument description
691 @param Green TODO: add argument description
692 @param Blue TODO: add argument description
694 TODO: add return values
699 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
706 outb (Private
, PALETTE_INDEX_REGISTER
, (UINT8
) Index
);
707 outb (Private
, PALETTE_DATA_REGISTER
, (UINT8
) (Red
>> 2));
708 outb (Private
, PALETTE_DATA_REGISTER
, (UINT8
) (Green
>> 2));
709 outb (Private
, PALETTE_DATA_REGISTER
, (UINT8
) (Blue
>> 2));
713 TODO: Add function description
715 @param Private TODO: add argument description
717 TODO: add return values
722 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
731 for (RedIndex
= 0; RedIndex
< 8; RedIndex
++) {
732 for (GreenIndex
= 0; GreenIndex
< 8; GreenIndex
++) {
733 for (BlueIndex
= 0; BlueIndex
< 4; BlueIndex
++) {
734 SetPaletteColor (Private
, Index
, (UINT8
) (RedIndex
<< 5), (UINT8
) (GreenIndex
<< 5), (UINT8
) (BlueIndex
<< 6));
742 TODO: Add function description
744 @param Private TODO: add argument description
746 TODO: add return values
752 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
758 Private
->PciIo
->Mem
.Write (
760 EfiPciIoWidthFillUint32
,
769 TODO: Add function description
771 @param Private TODO: add argument description
773 TODO: add return values
778 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
788 ScreenWidth
= Private
->ModeData
[Private
->CurrentMode
].HorizontalResolution
;
789 ScreenHeight
= Private
->ModeData
[Private
->CurrentMode
].VerticalResolution
;
792 for (Y
= 0; Y
< ScreenHeight
; Y
++) {
793 for (X
= 0; X
< ScreenWidth
; X
++) {
794 Color
= (UINT8
) (256 * (X
+ Y
) / (ScreenWidth
+ ScreenHeight
));
795 Private
->LineBuffer
[X
] = Color
;
798 Private
->PciIo
->Mem
.Write (
802 Offset
+ (Y
* ScreenWidth
),
810 TODO: Add function description
812 @param Private TODO: add argument description
813 @param ModeData TODO: add argument description
815 TODO: add return values
819 InitializeGraphicsMode (
820 CIRRUS_LOGIC_5430_PRIVATE_DATA
*Private
,
821 CIRRUS_LOGIC_5430_VIDEO_MODES
*ModeData
827 outw (Private
, SEQ_ADDRESS_REGISTER
, 0x1206);
828 outw (Private
, SEQ_ADDRESS_REGISTER
, 0x0012);
830 for (Index
= 0; Index
< 15; Index
++) {
831 outw (Private
, SEQ_ADDRESS_REGISTER
, ModeData
->SeqSettings
[Index
]);
834 outb (Private
, SEQ_ADDRESS_REGISTER
, 0x0f);
835 Byte
= (UINT8
) ((inb (Private
, SEQ_DATA_REGISTER
) & 0xc7) ^ 0x30);
836 outb (Private
, SEQ_DATA_REGISTER
, Byte
);
838 outb (Private
, MISC_OUTPUT_REGISTER
, ModeData
->MiscSetting
);
839 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0506);
840 outw (Private
, SEQ_ADDRESS_REGISTER
, 0x0300);
841 outw (Private
, CRTC_ADDRESS_REGISTER
, 0x2011);
843 for (Index
= 0; Index
< 28; Index
++) {
844 outw (Private
, CRTC_ADDRESS_REGISTER
, (UINT16
) ((ModeData
->CrtcSettings
[Index
] << 8) | Index
));
847 for (Index
= 0; Index
< 9; Index
++) {
848 outw (Private
, GRAPH_ADDRESS_REGISTER
, (UINT16
) ((GraphicsController
[Index
] << 8) | Index
));
851 inb (Private
, INPUT_STATUS_1_REGISTER
);
853 for (Index
= 0; Index
< 21; Index
++) {
854 outb (Private
, ATT_ADDRESS_REGISTER
, (UINT8
) Index
);
855 outb (Private
, ATT_ADDRESS_REGISTER
, AttributeController
[Index
]);
858 outb (Private
, ATT_ADDRESS_REGISTER
, 0x20);
860 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x0009);
861 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x000a);
862 outw (Private
, GRAPH_ADDRESS_REGISTER
, 0x000b);
863 outb (Private
, DAC_PIXEL_MASK_REGISTER
, 0xff);
865 SetDefaultPalette (Private
);
866 ClearScreen (Private
);