public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Girish Pathak <girish.pathak@arm.com>
To: edk2-devel@lists.01.org
Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org,
	Matteo.Carlini@arm.com, Stephanie.Hughes-Fitt@arm.com,
	nd@arm.com
Subject: [PATCH v3 10/16] ArmPlatformPkg: Add PCD to select pixel format
Date: Tue, 20 Mar 2018 16:12:06 +0000	[thread overview]
Message-ID: <20180320161212.79120-11-girish.pathak@arm.com> (raw)
In-Reply-To: <20180320161212.79120-1-girish.pathak@arm.com>

From: Girish Pathak <girish.pathak at arm.com>

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>
---
 ArmPlatformPkg/ArmPlatformPkg.dec          |  9 +++-
 ArmPlatformPkg/Library/HdLcd/HdLcd.c       | 54 +++++++-------------
 ArmPlatformPkg/Library/PL111Lcd/PL111Lcd.c | 15 +++++-
 3 files changed, 40 insertions(+), 38 deletions(-)

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




  parent reply	other threads:[~2018-03-20 16:05 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-20 16:11 [PATCH v3 00/16] Update GOP Girish Pathak
2018-03-20 16:11 ` [PATCH v3 01/16] ArmPlatformPkg: Rectify line endings of LcdHwNullLib Girish Pathak
2018-03-21 12:53   ` Evan Lloyd
2018-03-20 16:11 ` [PATCH v3 02/16] ArmPlatformPkg: Rectify line endings of LcdPlatformNullLib Girish Pathak
2018-03-21 12:53   ` Evan Lloyd
2018-03-20 16:11 ` [PATCH v3 03/16] ArmPlatformPkg: Tidy Lcd code: Coding standard Girish Pathak
2018-03-21 12:53   ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 04/16] ArmPlatformPkg: Tidy Lcd code: Updated comments Girish Pathak
2018-03-21 12:53   ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 05/16] ArmPlatformPkg: HDLCD and PL111: Update debug ASSERTS Girish Pathak
2018-03-21 12:53   ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 06/16] ArmPlatformPkg: PL111Lcd: Replace magic number with macro Girish Pathak
2018-03-21 12:26   ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 07/16] ArmPlatformPkg: PL111Lcd: Combine two writes to LCDControl Girish Pathak
2018-03-21 12:26   ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 08/16] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP Girish Pathak
2018-03-21 12:26   ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 09/16] ArmPlatformPkg: Redefine LcdPlatformGetTimings function Girish Pathak
2018-03-21 12:53   ` Evan Lloyd
2018-03-20 16:12 ` Girish Pathak [this message]
2018-03-21 12:53   ` [PATCH v3 10/16] ArmPlatformPkg: Add PCD to select pixel format Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 11/16] ArmPlatformPkg: PCD to swap red/blue format for HDLCD Girish Pathak
2018-03-21 12:53   ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 12/16] ArmPlatformPkg: Additional display modes Girish Pathak
2018-03-21 12:54   ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 13/16] ArmPlatformPkg: Reserving framebuffer at build Girish Pathak
2018-03-21 12:54   ` Evan Lloyd
2018-03-20 16:12 ` [PATCH v3 14/16] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver Girish Pathak
2018-03-21 12:54   ` Evan Lloyd
2018-04-23 11:07   ` Leif Lindholm
2018-03-20 16:12 ` [PATCH v3 15/16] ArmPkg: MTL Library interface and Null library implementation Girish Pathak
2018-03-21 12:54   ` Evan Lloyd
2018-04-23 11:11   ` Leif Lindholm
2018-03-20 16:12 ` [PATCH v3 16/16] ArmPkg: Introduce SCMI protocol Girish Pathak
2018-03-21 12:54   ` Evan Lloyd
2018-04-23 11:31   ` Leif Lindholm
2018-04-23 16:06     ` Girish Pathak
2018-04-23 16:22       ` Leif Lindholm
2018-04-23 16:49         ` Girish Pathak
2018-04-23 17:11 ` [PATCH v3 00/16] Update GOP Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180320161212.79120-11-girish.pathak@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox