The field name "ModeNumber" in QEMU_VIDEO_MODE_DATA is misleading -- it is
not immediately obvious whether this field carries a client-visible mode
number, in the GOP sense, or an internal, card type specific mode index.
After checking all references, rename the field to "InternalModeIndex".

Also, when filling in the card type independent QEMU_VIDEO_MODE_DATA array
from the card type specific mode array, distinguish the GOP mode number
from the internal mode index in the debug message.

This patch effects no functional changes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
---
 OvmfPkg/QemuVideoDxe/Qemu.h       | 11 +++++++++--
 OvmfPkg/QemuVideoDxe/Gop.c        |  4 ++--
 OvmfPkg/QemuVideoDxe/Initialize.c | 18 ++++++++++--------
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h
index 38d6872..b2643f2 100644
--- a/OvmfPkg/QemuVideoDxe/Qemu.h
+++ b/OvmfPkg/QemuVideoDxe/Qemu.h
@@ -50,7 +50,7 @@
 // QEMU Vide Graphical Mode Data
 //
 typedef struct {
-  UINT32  ModeNumber;
+  UINT32  InternalModeIndex; // points into card-specific mode table
   UINT32  HorizontalResolution;
   UINT32  VerticalResolution;
   UINT32  ColorDepth;
@@ -107,16 +107,23 @@ typedef struct {
   UINT64                                OriginalPciAttributes;
   EFI_GRAPHICS_OUTPUT_PROTOCOL          GraphicsOutput;
   EFI_DEVICE_PATH_PROTOCOL              *GopDevicePath;
+
+  //
+  // The next three fields match the client-visible
+  // EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.Mode and
+  // EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE.MaxMode fields.
+  //
   UINTN                                 CurrentMode;
   UINTN                                 MaxMode;
   QEMU_VIDEO_MODE_DATA                  *ModeData;
+
   UINT8                                 *LineBuffer;
   BOOLEAN                               HardwareNeedsStarting;
   QEMU_VIDEO_VARIANT                    Variant;
 } QEMU_VIDEO_PRIVATE_DATA;
 
 ///
-/// Video Mode structure
+/// Card-specific Video Mode structures
 ///
 typedef struct {
   UINT32  Width;
diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c
index 30aac7f..31ab942 100644
--- a/OvmfPkg/QemuVideoDxe/Gop.c
+++ b/OvmfPkg/QemuVideoDxe/Gop.c
@@ -185,11 +185,11 @@ Routine Description:
   switch (Private->Variant) {
   case QEMU_VIDEO_CIRRUS_5430:
   case QEMU_VIDEO_CIRRUS_5446:
-    InitializeCirrusGraphicsMode (Private, 
&QemuVideoCirrusModes[ModeData->ModeNumber]);
+    InitializeCirrusGraphicsMode (Private, 
&QemuVideoCirrusModes[ModeData->InternalModeIndex]);
     break;
   case QEMU_VIDEO_BOCHS_MMIO:
   case QEMU_VIDEO_BOCHS:
-    InitializeBochsGraphicsMode (Private, 
&QemuVideoBochsModes[ModeData->ModeNumber]);
+    InitializeBochsGraphicsMode (Private, 
&QemuVideoBochsModes[ModeData->InternalModeIndex]);
     break;
   default:
     ASSERT (FALSE);
diff --git a/OvmfPkg/QemuVideoDxe/Initialize.c 
b/OvmfPkg/QemuVideoDxe/Initialize.c
index 305797b..c27ba55 100644
--- a/OvmfPkg/QemuVideoDxe/Initialize.c
+++ b/OvmfPkg/QemuVideoDxe/Initialize.c
@@ -179,14 +179,15 @@ QemuVideoCirrusModeSetup (
   ModeData = Private->ModeData;
   VideoMode = &QemuVideoCirrusModes[0];
   for (Index = 0; Index < QEMU_VIDEO_CIRRUS_MODE_COUNT; Index ++) {
-    ModeData->ModeNumber = Index;
+    ModeData->InternalModeIndex = Index;
     ModeData->HorizontalResolution          = VideoMode->Width;
     ModeData->VerticalResolution            = VideoMode->Height;
     ModeData->ColorDepth                    = VideoMode->ColorDepth;
     ModeData->RefreshRate                   = VideoMode->RefreshRate;
     DEBUG ((EFI_D_INFO,
-      "Adding Cirrus Video Mode %d: %dx%d, %d-bit, %d Hz\n",
-      ModeData->ModeNumber,
+      "Adding Mode %d as Cirrus Internal Mode %d: %dx%d, %d-bit, %d Hz\n",
+      (INT32) (ModeData - Private->ModeData),
+      ModeData->InternalModeIndex,
       ModeData->HorizontalResolution,
       ModeData->VerticalResolution,
       ModeData->ColorDepth,
@@ -196,7 +197,7 @@ QemuVideoCirrusModeSetup (
     ModeData ++ ;
     VideoMode ++;
   }
-  Private->MaxMode = QEMU_VIDEO_CIRRUS_MODE_COUNT;
+  Private->MaxMode = ModeData - Private->ModeData;
 
   return EFI_SUCCESS;
 }
@@ -231,14 +232,15 @@ QemuVideoBochsModeSetup (
   ModeData = Private->ModeData;
   VideoMode = &QemuVideoBochsModes[0];
   for (Index = 0; Index < QEMU_VIDEO_BOCHS_MODE_COUNT; Index ++) {
-    ModeData->ModeNumber = Index;
+    ModeData->InternalModeIndex = Index;
     ModeData->HorizontalResolution          = VideoMode->Width;
     ModeData->VerticalResolution            = VideoMode->Height;
     ModeData->ColorDepth                    = VideoMode->ColorDepth;
     ModeData->RefreshRate                   = 60;
     DEBUG ((EFI_D_INFO,
-      "Adding Bochs Video Mode %d: %dx%d, %d-bit, %d Hz\n",
-      ModeData->ModeNumber,
+      "Adding Mode %d as Bochs Internal Mode %d: %dx%d, %d-bit, %d Hz\n",
+      (INT32) (ModeData - Private->ModeData),
+      ModeData->InternalModeIndex,
       ModeData->HorizontalResolution,
       ModeData->VerticalResolution,
       ModeData->ColorDepth,
@@ -248,7 +250,7 @@ QemuVideoBochsModeSetup (
     ModeData ++ ;
     VideoMode ++;
   }
-  Private->MaxMode = QEMU_VIDEO_BOCHS_MODE_COUNT;
+  Private->MaxMode = ModeData - Private->ModeData;
 
   return EFI_SUCCESS;
 }
-- 
1.8.3.1



------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to