]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg: Add PCD to select pixel format
authorGirish Pathak <girish.pathak at arm.com>
Tue, 26 Sep 2017 20:15:24 +0000 (21:15 +0100)
committerLeif Lindholm <leif.lindholm@linaro.org>
Mon, 23 Apr 2018 11:01:04 +0000 (12:01 +0100)
Current HDLCD and PL111 platform libraries do not support display modes
with PixelBlueGreenRedReserved8BitPerColor format, i.e. because of
historical confusion, they do not support the UEFI default
PixelBlueGreenRedReserved8BitPerColor format

In LcdPlatformLib for PL111, LcdPlatformQueryMode returns the pixel
format as PixelRedGreenBlueReserved8BitPerColor which is wrong, because
that does not match the display controller's pixel format which is set
to BGR in PL111Lcd LcdHwLib.

Also it is not possible to configure pixel format as RGB/BGR for the
display modes for a platform at build time.

This change adds PcdGopPixelFormat to configure pixel format as
    PixelRedGreenBlueReserved8BitPerColor    or
    PixelBlueGreenRedReserved8BitPerColor    or
    PixelBitMask.
With this change, pixel format can be selected in the platform specific
.dsc file for all supported display modes.

Support for PixelBitMask is not implemented in PL111 or HDLCD LcdHwLib
libraries, hence  HDLCD and PL111 platform libraries will return error
EFI_UNSUPPORTED if PcdGopPixelFormat is set to PixelBitMask.  Indeed,
it is not clear what selecting PixelBitMask might mean, but the option
is allowed as it might suit a custom platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Girish Pathak <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPlatformPkg/ArmPlatformPkg.dec
ArmPlatformPkg/Library/HdLcd/HdLcd.c
ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c

index 8f32a5e2c14dece225748bd16909521d40304b02..99ca4e1822652f3768b1b1ead365671bd2a9ccc1 100644 (file)
@@ -1,6 +1,6 @@
 #/** @file\r
 #\r
-#  Copyright (c) 2011-2017, ARM Limited. All rights reserved.\r
+#  Copyright (c) 2011-2018, ARM Limited. All rights reserved.\r
 #  Copyright (c) 2015, Intel Corporation. All rights reserved.\r
 #\r
 #  This program and the accompanying materials\r
   gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|UINT32|0x00000028\r
   gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UINT32|0x00000029\r
 \r
+  # Graphics Output Pixel format\r
+  # 0 : PixelRedGreenBlueReserved8BitPerColor\r
+  # 1 : PixelBlueGreenRedReserved8BitPerColor\r
+  # 2 : PixelBitMask\r
+  # Default is set to UEFI console font format PixelBlueGreenRedReserved8BitPerColor\r
+  gArmPlatformTokenSpaceGuid.PcdGopPixelFormat|0x00000001|UINT32|0x00000040\r
+\r
 [PcdsFixedAtBuild.common,PcdsDynamic.common]\r
   ## PL031 RealTimeClock\r
   gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0|UINT32|0x00000024\r
index f5886848ce582b475b597ccca015c816707ade0e..96f2bf437fbabd2509f860c67c5442def5b5f03d 100644 (file)
 \r
 #include "HdLcd.h"\r
 \r
-STATIC\r
-UINTN\r
-GetBytesPerPixel (\r
-  IN  LCD_BPP       Bpp\r
-  )\r
-{\r
-  switch (Bpp) {\r
-  case LCD_BITS_PER_PIXEL_24:\r
-    return 4;\r
-\r
-  case LCD_BITS_PER_PIXEL_16_565:\r
-  case LCD_BITS_PER_PIXEL_16_555:\r
-  case LCD_BITS_PER_PIXEL_12_444:\r
-    return 2;\r
-\r
-  case LCD_BITS_PER_PIXEL_8:\r
-  case LCD_BITS_PER_PIXEL_4:\r
-  case LCD_BITS_PER_PIXEL_2:\r
-  case LCD_BITS_PER_PIXEL_1:\r
-    return 1;\r
-\r
-  default:\r
-    return 0;\r
-  }\r
-}\r
+#define BYTES_PER_PIXEL 4\r
 \r
 /** Initialize display.\r
 \r
@@ -78,10 +54,6 @@ LcdInitialize (
     HDLCD_LITTLE_ENDIAN | HDLCD_4BYTES_PER_PIXEL\r
     );\r
 \r
-  MmioWrite32 (HDLCD_REG_RED_SELECT,   (0 << 16 | 8 << 8 | 0));\r
-  MmioWrite32 (HDLCD_REG_GREEN_SELECT, (0 << 16 | 8 << 8 | 8));\r
-  MmioWrite32 (HDLCD_REG_BLUE_SELECT,  (0 << 16 | 8 << 8 | 16));\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -100,8 +72,8 @@ LcdSetMode (
   EFI_STATUS        Status;\r
   SCAN_TIMINGS      *Horizontal;\r
   SCAN_TIMINGS      *Vertical;\r
-  UINT32            BytesPerPixel;\r
-  LCD_BPP           LcdBpp;\r
+\r
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  ModeInfo;\r
 \r
   // Set the video mode timings and other relevant information\r
   Status = LcdPlatformGetTimings (\r
@@ -117,13 +89,22 @@ LcdSetMode (
   ASSERT (Horizontal != NULL);\r
   ASSERT (Vertical != NULL);\r
 \r
-  Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);\r
+  // Get the pixel format information.\r
+  Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);\r
   if (EFI_ERROR (Status)) {\r
     ASSERT_EFI_ERROR (Status);\r
     return Status;\r
   }\r
 \r
-  BytesPerPixel = GetBytesPerPixel (LcdBpp);\r
+  if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {\r
+    MmioWrite32 (HDLCD_REG_RED_SELECT,  (8 << 8) | 16);\r
+    MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8) | 0);\r
+  } else {\r
+    MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8) | 16);\r
+    MmioWrite32 (HDLCD_REG_RED_SELECT,  (8 << 8) | 0);\r
+  }\r
+\r
+  MmioWrite32 (HDLCD_REG_GREEN_SELECT, (8 << 8) | 8);\r
 \r
   // Disable the controller\r
   MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);\r
@@ -131,10 +112,13 @@ LcdSetMode (
   // Update the frame buffer information with the new settings\r
   MmioWrite32 (\r
     HDLCD_REG_FB_LINE_LENGTH,\r
-    Horizontal->Resolution * BytesPerPixel\r
+    Horizontal->Resolution * BYTES_PER_PIXEL\r
     );\r
 \r
-  MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, Horizontal->Resolution * BytesPerPixel);\r
+  MmioWrite32 (\r
+    HDLCD_REG_FB_LINE_PITCH,\r
+    Horizontal->Resolution * BYTES_PER_PIXEL\r
+    );\r
 \r
   MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, Vertical->Resolution - 1);\r
 \r
index c9e2736911881fc36b51562b9259b7bccf30747d..0496376fffe514651a70f58a3316894a4b2b319c 100644 (file)
@@ -76,7 +76,6 @@ LcdInitialize (
 \r
   @retval EFI_SUCCESS            Display mode set successfuly.\r
   @retval !(EFI_SUCCESS)         Other errors.\r
-\r
 **/\r
 EFI_STATUS\r
 LcdSetMode (\r
@@ -89,6 +88,8 @@ LcdSetMode (
   UINT32            LcdControl;\r
   LCD_BPP           LcdBpp;\r
 \r
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  ModeInfo;\r
+\r
   // Set the video mode timings and other relevant information\r
   Status = LcdPlatformGetTimings (\r
              ModeNumber,\r
@@ -109,6 +110,13 @@ LcdSetMode (
     return Status;\r
   }\r
 \r
+  // Get the pixel format information\r
+  Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);\r
+  if (EFI_ERROR (Status)) {\r
+    ASSERT_EFI_ERROR (Status);\r
+    return Status;\r
+  }\r
+\r
   // Disable the CLCD_LcdEn bit\r
   MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);\r
 \r
@@ -142,7 +150,10 @@ LcdSetMode (
 \r
   // PL111_REG_LCD_CONTROL\r
   LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp) |\r
-               PL111_CTRL_LCD_TFT | PL111_CTRL_LCD_PWR | PL111_CTRL_BGR;\r
+               PL111_CTRL_LCD_TFT | PL111_CTRL_LCD_PWR;\r
+  if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {\r
+    LcdControl |= PL111_CTRL_BGR;\r
+  }\r
   MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);\r
 \r
   return EFI_SUCCESS;\r