]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Remove hard code video resolution in C code and use PCD PcdVideoHorizontalResolution...
authorli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 28 Oct 2011 08:23:37 +0000 (08:23 +0000)
committerli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 28 Oct 2011 08:23:37 +0000 (08:23 +0000)
Signed-off-by: li-elvin
Reviewed-by: niruiyu, hhtian
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12595 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf

index d5e3a327534a64c1b8abdf2439612525e10191ef..dc9ec5b9b1ecf7abf538d59a4729382a3260313a 100644 (file)
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxEfiSystemTablePointerAddress|0x0|UINT64|0x30001027\r
   \r
 [PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]\r
-  ## This PCD defines the Console output column and the default value is 25 according to UEFI spec\r
+  ## This PCD defines the Console output column and the default value is 25 according to UEFI spec.\r
+  #  This PCD could be set to 0 then console output could be at max column and max row.\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|25|UINT32|0x40000006\r
 \r
-  ## This PCD defines the Console output row and the default value is 80 according to UEFI spec\r
+  ## This PCD defines the Console output row and the default value is 80 according to UEFI spec.\r
+  #  This PCD could be set to 0 then console output could be at max column and max row.\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|80|UINT32|0x40000007\r
 \r
+  ## This PCD defines the video horizontal resolution.\r
+  #  This PCD could be set to 0 then video resolution could be at highest resolution.\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800|UINT32|0x40000009\r
+\r
+  ## This PCD defines the video vertical resolution.\r
+  #  This PCD could be set to 0 then video resolution could be at highest resolution.\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600|UINT32|0x4000000a\r
+\r
 [PcdsFixedAtBuild, PcdsDynamic, PcdsDynamicEx]\r
   ## Base address of the NV variable range in flash device\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x0|UINT32|0x30000001\r
index 8b9b2e77fde377e7651f30d778cc78db7bcec000..6425beac8b8ec5b9e8d1df64e223d895de884b4d 100644 (file)
@@ -2901,6 +2901,7 @@ ConsplitterSetConsoleOutMode (
   UINTN                            MaxMode;\r
   EFI_STATUS                       Status;\r
   CONSOLE_OUT_MODE                 ModeInfo;\r
+  CONSOLE_OUT_MODE                 MaxModeInfo;\r
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *TextOut;\r
 \r
   PreferMode   = 0xFF;\r
@@ -2908,8 +2909,10 @@ ConsplitterSetConsoleOutMode (
   TextOut      = &Private->TextOut;\r
   MaxMode      = (UINTN) (TextOut->Mode->MaxMode);\r
 \r
-  ModeInfo.Column = PcdGet32 (PcdConOutColumn);\r
-  ModeInfo.Row    = PcdGet32 (PcdConOutRow);\r
+  MaxModeInfo.Column = 0;\r
+  MaxModeInfo.Row    = 0; \r
+  ModeInfo.Column    = PcdGet32 (PcdConOutColumn);\r
+  ModeInfo.Row       = PcdGet32 (PcdConOutRow);\r
 \r
   //\r
   // To find the prefer mode and basic mode from Text Out mode list\r
@@ -2917,8 +2920,23 @@ ConsplitterSetConsoleOutMode (
   for (Mode = 0; Mode < MaxMode; Mode++) {\r
     Status = TextOut->QueryMode (TextOut, Mode, &Col, &Row);\r
     if (!EFI_ERROR(Status)) {\r
-      if (Col == ModeInfo.Column && Row == ModeInfo.Row) {\r
-        PreferMode = Mode;\r
+      if ((ModeInfo.Column != 0) && (ModeInfo.Row != 0)) {\r
+        //\r
+        // Use user defined column and row\r
+        //\r
+        if (Col == ModeInfo.Column && Row == ModeInfo.Row) {\r
+          PreferMode = Mode;\r
+        }\r
+      } else {\r
+        //\r
+        // If user sets PcdConOutColumn or PcdConOutRow to 0,\r
+        // find and set the highest text mode.\r
+        //\r
+        if ((Col >= MaxModeInfo.Column) && (Row >= MaxModeInfo.Row)) {\r
+          MaxModeInfo.Column  = Col;\r
+          MaxModeInfo.Row     = Row;\r
+          PreferMode          = Mode;\r
+        }\r
       }\r
       if (Col == 80 && Row == 25) {\r
         BaseMode = Mode;\r
index bb279f985027e1cdc5c37b485b11ea604cce86da..553a8146346076d50480e5e9bd351664c64242bd 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This is the main routine for initializing the Graphics Console support routines.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -239,13 +239,17 @@ GraphicsConsoleControllerDriverStart (
   UINT32                               VerticalResolution;\r
   UINT32                               ColorDepth;\r
   UINT32                               RefreshRate;\r
-  UINT                               ModeIndex;\r
+  UINT32                               ModeIndex;\r
   UINTN                                MaxMode;\r
-  UINTN                                Columns;\r
-  UINTN                                Rows;\r
+  UINTN                                MaxColumns;\r
+  UINTN                                MaxRows;\r
   UINT32                               ModeNumber;\r
   EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE    *Mode;\r
   GRAPHICS_CONSOLE_MODE_DATA           *ModeData;\r
+  UINTN                                SizeOfInfo;  \r
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r
+  BOOLEAN                              TextModeFound;\r
+  \r
   ModeNumber = 0;\r
 \r
   //\r
@@ -285,12 +289,8 @@ GraphicsConsoleControllerDriverStart (
     goto Error;\r
   }\r
 \r
-  //\r
-  // If the current mode information can not be retrieved, then attempt to set the default mode\r
-  // of 800x600, 32 bit color, 60 Hz refresh.\r
-  //\r
-  HorizontalResolution  = 800;\r
-  VerticalResolution    = 600;\r
+  HorizontalResolution  = PcdGet32 (PcdVideoHorizontalResolution);\r
+  VerticalResolution    = PcdGet32 (PcdVideoVerticalResolution);\r
 \r
   if (Private->GraphicsOutput != NULL) {\r
     //\r
@@ -298,39 +298,63 @@ GraphicsConsoleControllerDriverStart (
     // for the user-defined mode; if there are multiple video devices,\r
     // graphic console driver will set all the video devices to the same mode.\r
     //\r
-    Status = CheckModeSupported (\r
-                 Private->GraphicsOutput,\r
-                 CURRENT_HORIZONTAL_RESOLUTION,\r
-                 CURRENT_VERTICAL_RESOLUTION,\r
-                 &ModeNumber\r
-                 );\r
-    if (!EFI_ERROR(Status)) {\r
-      //\r
-      // Update default mode to current mode\r
+    if ((HorizontalResolution == 0x0) || (VerticalResolution == 0x0)) {\r
       //\r
-      HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION;\r
-      VerticalResolution   = CURRENT_VERTICAL_RESOLUTION;\r
+      // Find the highest resolution which GOP supports.\r
+      //    \r
+      MaxMode = Private->GraphicsOutput->Mode->MaxMode;\r
+      \r
+      for (ModeIndex = 0; ModeIndex < MaxMode; ModeIndex++) {\r
+        Status = Private->GraphicsOutput->QueryMode (\r
+                           Private->GraphicsOutput,\r
+                           ModeIndex,\r
+                           &SizeOfInfo,\r
+                           &Info\r
+                           );\r
+        if (!EFI_ERROR (Status)) {\r
+          if ((Info->HorizontalResolution >= HorizontalResolution) &&\r
+              (Info->VerticalResolution >= VerticalResolution)) {\r
+            HorizontalResolution = Info->HorizontalResolution;\r
+            VerticalResolution   = Info->VerticalResolution;\r
+            ModeNumber           = ModeIndex;\r
+          }\r
+          FreePool (Info);\r
+        }\r
+      }\r
+      if ((HorizontalResolution == 0x0) || (VerticalResolution == 0x0)) {\r
+        Status = EFI_UNSUPPORTED;\r
+        goto Error;\r
+      }\r
     } else {\r
       //\r
-      // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec\r
+      // Use user-defined resolution\r
       //\r
       Status = CheckModeSupported (\r
                    Private->GraphicsOutput,\r
-                   800,\r
-                   600,\r
+                   HorizontalResolution,\r
+                   VerticalResolution,\r
                    &ModeNumber\r
                    );\r
-    }\r
-\r
-    Mode = Private->GraphicsOutput->Mode;\r
-\r
-    if (EFI_ERROR (Status) || (Mode->MaxMode != 0)) {\r
-      //\r
-      // Set default mode failed or device don't support default mode, then get the current mode information\r
-      //\r
-      HorizontalResolution = Mode->Info->HorizontalResolution;\r
-      VerticalResolution = Mode->Info->VerticalResolution;\r
-      ModeNumber = Mode->Mode;\r
+      if (EFI_ERROR (Status)) {\r
+        //\r
+        // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec\r
+        //\r
+        Status = CheckModeSupported (\r
+                     Private->GraphicsOutput,\r
+                     800,\r
+                     600,\r
+                     &ModeNumber\r
+                     );\r
+        Mode = Private->GraphicsOutput->Mode;\r
+        if (EFI_ERROR (Status) && Mode->MaxMode != 0) {\r
+          //\r
+          // Set default mode failed or device don't support default mode, then get the current mode information\r
+          //\r
+          HorizontalResolution = Mode->Info->HorizontalResolution;\r
+          VerticalResolution = Mode->Info->VerticalResolution;\r
+          ModeNumber = Mode->Mode;\r
+        }\r
+      }\r
     }\r
   } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
     //\r
@@ -340,22 +364,19 @@ GraphicsConsoleControllerDriverStart (
     RefreshRate           = 60;\r
     Status = Private->UgaDraw->SetMode (\r
                                 Private->UgaDraw,\r
-                                CURRENT_HORIZONTAL_RESOLUTION,\r
-                                CURRENT_VERTICAL_RESOLUTION,\r
+                                HorizontalResolution,\r
+                                VerticalResolution,\r
                                 ColorDepth,\r
                                 RefreshRate\r
                                 );\r
-    if (!EFI_ERROR (Status)) {\r
-      HorizontalResolution = CURRENT_HORIZONTAL_RESOLUTION;\r
-      VerticalResolution   = CURRENT_VERTICAL_RESOLUTION;\r
-    } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {\r
+    if (EFI_ERROR (Status)) {\r
       //\r
       // Try to set 800*600 which is required by UEFI/EFI spec\r
       //\r
       Status = Private->UgaDraw->SetMode (\r
                                   Private->UgaDraw,\r
-                                  HorizontalResolution,\r
-                                  VerticalResolution,\r
+                                  800,\r
+                                  600,\r
                                   ColorDepth,\r
                                   RefreshRate\r
                                   );\r
@@ -378,50 +399,67 @@ GraphicsConsoleControllerDriverStart (
   }\r
 \r
   //\r
-  // Add Mode #3 that uses the entire display for user-defined mode\r
+  // Include the existing pre-defined 80x25, 80x50 and 100x31 \r
+  // in mGraphicsConsoleDevTemplate.\r
   //\r
-  Private->ModeData[3].Columns = HorizontalResolution / EFI_GLYPH_WIDTH;\r
-  Private->ModeData[3].Rows    = VerticalResolution / EFI_GLYPH_HEIGHT;\r
+  MaxMode = 3;\r
 \r
   //\r
-  // Add Mode #4 that uses the PCD values\r
+  // Compute the maximum number of text Rows and Columns that this current graphics mode can support\r
   //\r
-  Private->ModeData[4].Columns = (UINTN) PcdGet32 (PcdConOutColumn);\r
-  Private->ModeData[4].Rows    = (UINTN) PcdGet32 (PcdConOutRow);\r
+  MaxColumns = HorizontalResolution / EFI_GLYPH_WIDTH;\r
+  MaxRows    = VerticalResolution / EFI_GLYPH_HEIGHT;\r
 \r
   //\r
-  // Compute the maximum number of text Rows and Columns that this current graphics mode can support\r
+  // Add Mode #3 that uses the entire display for user-defined mode\r
+  //\r
+  Private->ModeData[MaxMode].Columns = MaxColumns;\r
+  Private->ModeData[MaxMode].Rows    = MaxRows;\r
+  MaxMode++;\r
+\r
+  //\r
+  // Add Mode #4 that uses the PCD values\r
   //\r
-  Columns = HorizontalResolution / EFI_GLYPH_WIDTH;\r
-  Rows    = VerticalResolution / EFI_GLYPH_HEIGHT;\r
+  Private->ModeData[MaxMode].Columns = (UINTN) PcdGet32 (PcdConOutColumn);\r
+  Private->ModeData[MaxMode].Rows    = (UINTN) PcdGet32 (PcdConOutRow);  \r
+  if ((Private->ModeData[MaxMode].Columns != 0) && (Private->ModeData[MaxMode].Rows != 0)) {\r
+    MaxMode++;\r
+  }\r
 \r
   //\r
   // Here we make sure that mode 0 is valid\r
   //\r
-  if (Columns < Private->ModeData[0].Columns ||\r
-      Rows < Private->ModeData[0].Rows) {\r
+  if (MaxColumns < Private->ModeData[0].Columns ||\r
+      MaxRows < Private->ModeData[0].Rows) {\r
     //\r
     // 80x25 cannot be supported.\r
     //\r
-    // Fallback to using the PcdConOutColumn and PcdConOutRow\r
-    // for mode 0.  If the PCDs are also to large, then mode 0\r
-    // will be shrunk to fit as needed.\r
+    if ((Private->ModeData[4].Columns != 0) && (Private->ModeData[4].Rows != 0)) {\r
+    //\r
+    // Fallback to using the Mode 4 for mode 0 if PcdConOutColumn and PcdConOutRow\r
+    // are not 0. If the PCDs are also too large, then mode 0\r
+    // will be shrunk to fit as needed. If the PCDs are all 0,\r
+    // then mode 0 will be the entire display.\r
     //\r
-    Private->ModeData[0].Columns = MIN (Private->ModeData[4].Columns, Columns);\r
-    Private->ModeData[0].Rows    = MIN (Private->ModeData[4].Rows, Rows);\r
+      Private->ModeData[0].Columns = MIN (Private->ModeData[4].Columns, MaxColumns);\r
+      Private->ModeData[0].Rows    = MIN (Private->ModeData[4].Rows, MaxRows);\r
+    } else {\r
+      Private->ModeData[0].Columns = MaxColumns;\r
+      Private->ModeData[0].Rows    = MaxRows;\r
+    }\r
   }\r
-\r
-  MaxMode = 0;\r
+  \r
+  TextModeFound = FALSE;\r
   for (ModeIndex = 0; ModeIndex < GRAPHICS_MAX_MODE; ModeIndex++) {\r
     ModeData = &Private->ModeData[ModeIndex];\r
     ModeData->GopWidth      = HorizontalResolution;\r
     ModeData->GopHeight     = VerticalResolution;\r
     ModeData->GopModeNumber = ModeNumber;\r
-    if (Columns >= ModeData->Columns &&\r
-        Rows >= ModeData->Rows) {\r
+    if ((ModeData->Columns != 0) && (ModeData->Rows != 0) &&\r
+        (MaxColumns >= ModeData->Columns) && (MaxRows >= ModeData->Rows)) {\r
       ModeData->DeltaX        = (HorizontalResolution - (ModeData->Columns * EFI_GLYPH_WIDTH)) >> 1;\r
       ModeData->DeltaY        = (VerticalResolution - (ModeData->Rows * EFI_GLYPH_HEIGHT)) >> 1;\r
-      MaxMode = ModeIndex + 1;\r
+      TextModeFound = TRUE;\r
     } else {\r
       ModeData->Columns       = 0;\r
       ModeData->Rows          = 0;\r
@@ -433,7 +471,8 @@ GraphicsConsoleControllerDriverStart (
   //\r
   // See if the resolution was too small to support any text modes\r
   //\r
-  if (MaxMode == 0) {\r
+  if (!TextModeFound) {\r
+    Status = EFI_UNSUPPORTED;\r
     goto Error;\r
   }\r
 \r
index 824de4578a42557fbd11e8dd10233de9d4f044cb..338b7aad29cde3eeef56c04b71925f475884c28a 100644 (file)
@@ -42,12 +42,6 @@ extern EFI_DRIVER_BINDING_PROTOCOL   gGraphicsConsoleDriverBinding;
 extern EFI_NARROW_GLYPH              gUsStdNarrowGlyphData[];\r
 \r
 extern UINT32 mNarrowFontSize;\r
-//\r
-// User can define valid graphic resolution here\r
-// e.g. 640x480, 800x600, 1024x768...\r
-//\r
-#define CURRENT_HORIZONTAL_RESOLUTION  800\r
-#define CURRENT_VERTICAL_RESOLUTION    600\r
 \r
 typedef union {\r
   EFI_NARROW_GLYPH  NarrowGlyph;\r
index 169e15a46fa8b59bf17b3da98ebcb6c2aa147edd..abdda5949aa521679d5ce13d255afcb8e33df448 100644 (file)
@@ -4,7 +4,7 @@
 #\r
 #  This is the main routine for initializing the Graphics Console support routines.\r
 #  \r
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution. The full text of the license may be found at\r
@@ -67,4 +67,6 @@
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution\r
 \r