* [PATCH 01/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Coding standard
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-12 18:45 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 02/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Added comments evan.lloyd
` (17 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
There is no functional modification in this change
As preparation for further work, the formatting is corrected to meet
the EDKII coding standard.
Of specific note, some invalid include guards were fixed.
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>
---
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf | 9 +-
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf | 6 +-
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf | 4 +-
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf | 4 +-
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h | 11 +-
ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 10 +-
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 103 +++++++-----
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 173 ++++++++++++--------
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 83 ++++++----
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c | 130 ++++++++-------
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 54 ++++--
11 files changed, 350 insertions(+), 237 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
index dff17e86fd3e563b38318f696a94f2c75276b31f..4733bb8e662d64eca0976af21b2abb7036b4424b 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
@@ -1,8 +1,8 @@
-#/** @file
+#/** @file HdLcdArmVExpress.inf
#
-# Component description file for HdLcdArmLib module
+# Component description file for HdLcdArmVExpress module
#
-# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -23,8 +23,7 @@ [Defines]
LIBRARY_CLASS = LcdPlatformLib
[Sources.common]
-
-HdLcdArmVExpress.c
+ HdLcdArmVExpress.c
[Packages]
MdePkg/MdePkg.dec
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
index 658558ab15230d07f1c04d29a8e2bf8d14f1d6a2..3fde707c33dbcbd8adbbf18bbba718b823194abc 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
@@ -1,8 +1,8 @@
-#/** @file
+#/** @file PL111LcdArmVExpressLib.inf
#
-# Component description file for ArmVeGraphicsDxe module
+# Component description file for PL111LcdArmVExpressLib module
#
-# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
index 462d1fa402d7a1939b2876b74a5b76e8edf2e1f6..26e580a594fc328187407ac4c1787f180fbf4b17 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
@@ -1,8 +1,8 @@
-#/** @file
+#/** @file HdLcdGraphicsOutputDxe.inf
#
# Component description file for HDLCD module
#
-# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
index 003cc2ffa912b39d6f1342c92445eefce94b1f8b..ad0348500326c4567f0e1b235c84b694e61306bf 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
@@ -1,8 +1,8 @@
-#/** @file
+#/** @file PL111LcdGraphicsOutputDxe.inf
#
# Component description file for PL111LcdGraphicsOutputDxe module
#
-# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
index 8856b79901b632071ae4c4081b69e5188daa23ed..85e918de66624d61c6d0e05c5a67c516cd7619aa 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
@@ -1,6 +1,6 @@
-/** @file
+/** @file LcdGraphicsOutputDxe.h
- Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -11,8 +11,8 @@
**/
-#ifndef __ARM_VE_GRAPHICS_DXE_H__
-#define __ARM_VE_GRAPHICS_DXE_H__
+#ifndef LCD_GRAPHICS_OUTPUT_DXE_H_
+#define LCD_GRAPHICS_OUTPUT_DXE_H_
#include <Base.h>
@@ -124,5 +124,4 @@ VOID
LcdShutdown (
VOID
);
-
-#endif /* __ARM_VE_GRAPHICS_DXE_H__ */
+#endif /* LCD_GRAPHICS_OUTPUT_DXE_H_ */
diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
index b9bdf471e2d65dba7a0fcb0f7ecc352bd576b46b..72ebcd02ddb321ee0dad51c87ac8ee876d9ca21c 100644
--- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
+++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
@@ -1,6 +1,6 @@
-/** @file
+/** @file LcdPlatformLib.h
- Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -11,8 +11,8 @@
**/
-#ifndef __LCDPLATFORMLIB_H
-#define __LCDPLATFORMLIB_H
+#ifndef LCD_PLATFORM_LIB_H_
+#define LCD_PLATFORM_LIB_H_
#include <Protocol/GraphicsOutput.h>
@@ -218,4 +218,4 @@ LcdPlatformGetBpp (
OUT LCD_BPP* Bpp
);
-#endif
+#endif // LCD_PLATFORM_LIB_H_
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index b1106ee19b98cebac01820924514eac79b97d0d5..2041de5f63c72de6f0ce4047420c282507a1d04a 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -1,6 +1,6 @@
-/**
+/** @file HdLcdArmVExpress.c
- Copyright (c) 2012, ARM Ltd. All rights reserved.
+ Copyright (c) 2012-2017, ARM Ltd. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -47,32 +47,38 @@ typedef struct {
LCD_RESOLUTION mResolutions[] = {
{ // Mode 0 : VGA : 640 x 480 x 24 bpp
- VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, VGA_OSC_FREQUENCY,
+ VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ VGA_OSC_FREQUENCY,
VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
},
{ // Mode 1 : SVGA : 800 x 600 x 24 bpp
- SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, SVGA_OSC_FREQUENCY,
+ SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ SVGA_OSC_FREQUENCY,
SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
},
{ // Mode 2 : XGA : 1024 x 768 x 24 bpp
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, XGA_OSC_FREQUENCY,
+ XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ XGA_OSC_FREQUENCY,
XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
},
{ // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
- SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (SXGA_OSC_FREQUENCY/2),
+ SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ (SXGA_OSC_FREQUENCY/2),
SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
},
{ // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
- UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (UXGA_OSC_FREQUENCY/2),
+ UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ (UXGA_OSC_FREQUENCY/2),
UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
},
{ // Mode 5 : HD : 1920 x 1080 x 24 bpp
- HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (HD_OSC_FREQUENCY/2),
+ HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ (HD_OSC_FREQUENCY/2),
HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
}
@@ -95,19 +101,25 @@ LcdPlatformInitializeDisplay (
{
EFI_STATUS Status;
- // Set the FPGA multiplexer to select the video output from the motherboard or the daughterboard
- Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, ARM_VE_DAUGHTERBOARD_1_SITE);
- if (EFI_ERROR(Status)) {
+ /* Set the FPGA multiplexer to select the video output from the
+ * motherboard or the daughterboard */
+ Status = ArmPlatformSysConfigSet (
+ SYS_CFG_MUXFPGA,
+ ARM_VE_DAUGHTERBOARD_1_SITE
+ );
+ if (EFI_ERROR (Status)) {
return Status;
}
// Install the EDID Protocols
Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gEfiEdidDiscoveredProtocolGuid, &mEdidDiscovered,
- &gEfiEdidActiveProtocolGuid, &mEdidActive,
- NULL
- );
+ &Handle,
+ &gEfiEdidDiscoveredProtocolGuid,
+ &mEdidDiscovered,
+ &gEfiEdidActiveProtocolGuid,
+ &mEdidActive,
+ NULL
+ );
return Status;
}
@@ -132,16 +144,25 @@ LcdPlatformGetVram (
} else {
AllocationType = AllocateAddress;
}
- Status = gBS->AllocatePages (AllocationType, EfiBootServicesData, EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
- if (EFI_ERROR(Status)) {
+ Status = gBS->AllocatePages (
+ AllocationType,
+ EfiBootServicesData,
+ EFI_SIZE_TO_PAGES (((UINTN)LCD_VRAM_SIZE)),
+ VramBaseAddress
+ );
+ if (EFI_ERROR (Status)) {
return Status;
}
- // Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.
- Status = gDS->SetMemorySpaceAttributes (*VramBaseAddress, *VramSize,
- EFI_MEMORY_WC);
- ASSERT_EFI_ERROR(Status);
- if (EFI_ERROR(Status)) {
+ /* Mark the VRAM as write-combining.
+ * The VRAM is inside the DRAM, which is cacheable. */
+ Status = gDS->SetMemorySpaceAttributes (
+ *VramBaseAddress,
+ *VramSize,
+ EFI_MEMORY_WC
+ );
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
return Status;
}
@@ -150,15 +171,11 @@ LcdPlatformGetVram (
}
UINT32
-LcdPlatformGetMaxMode (
- VOID
- )
+LcdPlatformGetMaxMode(VOID)
{
- //
- // The following line will report correctly the total number of graphics modes
- // that could be supported by the graphics driver:
- //
- return (sizeof(mResolutions) / sizeof(LCD_RESOLUTION));
+ /* The following line will report correctly the total number of graphics modes
+ * that could be supported by the graphics driver: */
+ return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
}
EFI_STATUS
@@ -174,25 +191,35 @@ LcdPlatformSetMode (
// Set the video mode oscillator
do {
- Status = ArmPlatformSysConfigSetDevice (SYS_CFG_OSC_SITE1, PcdGet32(PcdHdLcdVideoModeOscId), mResolutions[ModeNumber].OscFreq);
+ Status = ArmPlatformSysConfigSetDevice (
+ SYS_CFG_OSC_SITE1,
+ PcdGet32 (PcdHdLcdVideoModeOscId),
+ mResolutions[ModeNumber].OscFreq
+ );
} while (Status == EFI_TIMEOUT);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
// Set the DVI into the new mode
do {
- Status = ArmPlatformSysConfigSet (SYS_CFG_DVIMODE, mResolutions[ModeNumber].Mode);
+ Status = ArmPlatformSysConfigSet (
+ SYS_CFG_DVIMODE,
+ mResolutions[ModeNumber].Mode
+ );
} while (Status == EFI_TIMEOUT);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
// Set the multiplexer
- Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, ARM_VE_DAUGHTERBOARD_1_SITE);
- if (EFI_ERROR(Status)) {
+ Status = ArmPlatformSysConfigSet (
+ SYS_CFG_MUXFPGA,
+ ARM_VE_DAUGHTERBOARD_1_SITE
+ );
+ if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -233,7 +260,7 @@ LcdPlatformQueryMode (
case LCD_BITS_PER_PIXEL_1:
default:
// These are not supported
- ASSERT(FALSE);
+ ASSERT (FALSE);
break;
}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 3f3ceb3d2fa82f614e0c6dac8455c117745cf3a6..8d046816454f642bced00e29c4e02093b74afd24 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -1,6 +1,6 @@
-/** @file
+/** @file PL111LcdArmVExpress.c
- Copyright (c) 2011-2015, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -43,83 +43,99 @@ typedef struct {
LCD_RESOLUTION mResolutions[] = {
- { // Mode 0 : VGA : 640 x 480 x 24 bpp
- VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, VGA_OSC_FREQUENCY,
+ { // Mode 0 : VGA : 640 x 480 x 24 bpp
+ VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ VGA_OSC_FREQUENCY,
VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
},
- { // Mode 1 : SVGA : 800 x 600 x 24 bpp
- SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, SVGA_OSC_FREQUENCY,
+ { // Mode 1 : SVGA : 800 x 600 x 24 bpp
+ SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ SVGA_OSC_FREQUENCY,
SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
},
- { // Mode 2 : XGA : 1024 x 768 x 24 bpp
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, XGA_OSC_FREQUENCY,
+ { // Mode 2 : XGA : 1024 x 768 x 24 bpp
+ XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ XGA_OSC_FREQUENCY,
XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
},
- { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
- SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (SXGA_OSC_FREQUENCY/2),
+ { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
+ SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ (SXGA_OSC_FREQUENCY/2),
SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
},
- { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
- UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (UXGA_OSC_FREQUENCY/2),
+ { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
+ UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ (UXGA_OSC_FREQUENCY/2),
UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
},
- { // Mode 5 : HD : 1920 x 1080 x 24 bpp
- HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (HD_OSC_FREQUENCY/2),
+ { // Mode 5 : HD : 1920 x 1080 x 24 bpp
+ HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ (HD_OSC_FREQUENCY/2),
HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
},
- { // Mode 6 : VGA : 640 x 480 x 16 bpp (565 Mode)
- VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, VGA_OSC_FREQUENCY,
+ { // Mode 6 : VGA : 640 x 480 x 16 bpp (565 Mode)
+ VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+ VGA_OSC_FREQUENCY,
VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
},
- { // Mode 7 : SVGA : 800 x 600 x 16 bpp (565 Mode)
- SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, SVGA_OSC_FREQUENCY,
+ { // Mode 7 : SVGA : 800 x 600 x 16 bpp (565 Mode)
+ SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+ SVGA_OSC_FREQUENCY,
SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
},
- { // Mode 8 : XGA : 1024 x 768 x 16 bpp (565 Mode)
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, XGA_OSC_FREQUENCY,
+ { // Mode 8 : XGA : 1024 x 768 x 16 bpp (565 Mode)
+ XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+ XGA_OSC_FREQUENCY,
XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
},
- { // Mode 9 : VGA : 640 x 480 x 15 bpp
- VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, VGA_OSC_FREQUENCY,
+ { // Mode 9 : VGA : 640 x 480 x 15 bpp
+ VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+ VGA_OSC_FREQUENCY,
VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
},
- { // Mode 10 : SVGA : 800 x 600 x 15 bpp
- SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, SVGA_OSC_FREQUENCY,
+ { // Mode 10 : SVGA : 800 x 600 x 15 bpp
+ SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+ SVGA_OSC_FREQUENCY,
SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
},
- { // Mode 11 : XGA : 1024 x 768 x 15 bpp
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, XGA_OSC_FREQUENCY,
+ { // Mode 11 : XGA : 1024 x 768 x 15 bpp
+ XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+ XGA_OSC_FREQUENCY,
XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
},
- { // Mode 12 : XGA : 1024 x 768 x 15 bpp - All the timing info is derived from Linux Kernel Driver Settings
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, 63500000,
+ { // Mode 12 : XGA : 1024 x 768 x 15 bpp - All the timing info is derived from Linux Kernel Driver Settings
+ XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+ 63500000,
XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
},
- { // Mode 13 : VGA : 640 x 480 x 12 bpp (444 Mode)
- VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, VGA_OSC_FREQUENCY,
+ { // Mode 13 : VGA : 640 x 480 x 12 bpp (444 Mode)
+ VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+ VGA_OSC_FREQUENCY,
VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
},
- { // Mode 14 : SVGA : 800 x 600 x 12 bpp (444 Mode)
- SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, SVGA_OSC_FREQUENCY,
+ { // Mode 14 : SVGA : 800 x 600 x 12 bpp (444 Mode)
+ SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+ SVGA_OSC_FREQUENCY,
SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
},
- { // Mode 15 : XGA : 1024 x 768 x 12 bpp (444 Mode)
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, XGA_OSC_FREQUENCY,
+ { // Mode 15 : XGA : 1024 x 768 x 12 bpp (444 Mode)
+ XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+ XGA_OSC_FREQUENCY,
XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
}
@@ -145,14 +161,16 @@ LcdPlatformInitializeDisplay (
// Set the FPGA multiplexer to select the video output from the motherboard or the daughterboard
Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, PL111_CLCD_SITE);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
// Install the EDID Protocols
- Status = gBS->InstallMultipleProtocolInterfaces(
- &Handle,
- &gEfiEdidDiscoveredProtocolGuid, &mEdidDiscovered,
- &gEfiEdidActiveProtocolGuid, &mEdidActive,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Handle,
+ &gEfiEdidDiscoveredProtocolGuid,
+ &mEdidDiscovered,
+ &gEfiEdidActiveProtocolGuid,
+ &mEdidActive,
+ NULL
+ );
}
return Status;
@@ -169,29 +187,38 @@ LcdPlatformGetVram (
Status = EFI_SUCCESS;
// Is it on the motherboard or on the daughterboard?
- switch(PL111_CLCD_SITE) {
+ switch (PL111_CLCD_SITE) {
case ARM_VE_MOTHERBOARD_SITE:
- *VramBaseAddress = (EFI_PHYSICAL_ADDRESS) PL111_CLCD_VRAM_MOTHERBOARD_BASE;
+ *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
*VramSize = LCD_VRAM_SIZE;
break;
case ARM_VE_DAUGHTERBOARD_1_SITE:
- *VramBaseAddress = (EFI_PHYSICAL_ADDRESS) LCD_VRAM_CORE_TILE_BASE;
+ *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)LCD_VRAM_CORE_TILE_BASE;
*VramSize = LCD_VRAM_SIZE;
// Allocate the VRAM from the DRAM so that nobody else uses it.
- Status = gBS->AllocatePages( AllocateAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
- if (EFI_ERROR(Status)) {
+ Status = gBS->AllocatePages (
+ AllocateAddress,
+ EfiBootServicesData,
+ EFI_SIZE_TO_PAGES (((UINTN)LCD_VRAM_SIZE)),
+ VramBaseAddress
+ );
+ if (EFI_ERROR (Status)) {
return Status;
}
- // Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.
- Status = gDS->SetMemorySpaceAttributes (*VramBaseAddress, *VramSize,
- EFI_MEMORY_WC);
- ASSERT_EFI_ERROR(Status);
- if (EFI_ERROR(Status)) {
- gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES(*VramSize));
+ // Mark the VRAM as write-combining.
+ // The VRAM is inside the DRAM, which is cacheable.
+ Status = gDS->SetMemorySpaceAttributes (
+ *VramBaseAddress,
+ *VramSize,
+ EFI_MEMORY_WC
+ );
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
return Status;
}
break;
@@ -206,19 +233,20 @@ LcdPlatformGetVram (
}
UINT32
-LcdPlatformGetMaxMode (
- VOID
- )
+LcdPlatformGetMaxMode(VOID)
{
- // The following line will report correctly the total number of graphics modes
- // supported by the PL111CLCD.
- //return (sizeof(mResolutions) / sizeof(CLCD_RESOLUTION)) - 1;
+ /* The following line would correctly reports the total number
+ * of graphics modes supported by the PL111CLCD.
+ * return (sizeof(mResolutions) / sizeof(CLCD_RESOLUTION)) - 1;
+ */
- // However, on some platforms it is desirable to ignore some graphics modes.
- // This could be because the specific implementation of PL111 has certain limitations.
+ /* However, on some platforms it is desirable to ignore some graphics modes.
+ * This could be because the specific implementation of PL111 has
+ * certain limitations.
+ */
// Set the maximum mode allowed
- return (PcdGet32(PcdPL111LcdMaxMode));
+ return (PcdGet32 (PcdPL111LcdMaxMode));
}
EFI_STATUS
@@ -238,22 +266,26 @@ LcdPlatformSetMode (
LcdSite = PL111_CLCD_SITE;
- switch(LcdSite) {
+ switch (LcdSite) {
case ARM_VE_MOTHERBOARD_SITE:
Function = SYS_CFG_OSC;
OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
break;
case ARM_VE_DAUGHTERBOARD_1_SITE:
Function = SYS_CFG_OSC_SITE1;
- OscillatorId = (UINT32)PcdGet32(PcdPL111LcdVideoModeOscId);
+ OscillatorId = (UINT32)PcdGet32 (PcdPL111LcdVideoModeOscId);
break;
default:
return EFI_UNSUPPORTED;
}
// Set the video mode oscillator
- Status = ArmPlatformSysConfigSetDevice (Function, OscillatorId, mResolutions[ModeNumber].OscFreq);
- if (EFI_ERROR(Status)) {
+ Status = ArmPlatformSysConfigSetDevice (
+ Function,
+ OscillatorId,
+ mResolutions[ModeNumber].OscFreq
+ );
+ if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -267,8 +299,11 @@ LcdPlatformSetMode (
SysId &= ~ARM_FVP_SYS_ID_VARIANT_MASK;
if (SysId != ARM_FVP_BASE_BOARD_SYS_ID) {
// Set the DVI into the new mode
- Status = ArmPlatformSysConfigSet (SYS_CFG_DVIMODE, mResolutions[ModeNumber].Mode);
- if (EFI_ERROR(Status)) {
+ Status = ArmPlatformSysConfigSet (
+ SYS_CFG_DVIMODE,
+ mResolutions[ModeNumber].Mode
+ );
+ if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -277,7 +312,7 @@ LcdPlatformSetMode (
// Set the multiplexer
Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, LcdSite);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -318,7 +353,7 @@ LcdPlatformQueryMode (
case LCD_BITS_PER_PIXEL_1:
default:
// These are not supported
- ASSERT(FALSE);
+ ASSERT (FALSE);
break;
}
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
index 2bfe2c0fe2dcd05f4983eea57542cfe3d30bf1ce..eb0b6fb3fbbc1cb605469433f6c6dcb85bac668c 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
@@ -1,6 +1,6 @@
-/** @file Lcd.c
+/** @file HdLcd.c
- Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -35,21 +35,34 @@ LcdInitialize (
)
{
// Disable the controller
- MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE);
+ MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
// Disable all interrupts
- MmioWrite32(HDLCD_REG_INT_MASK, 0);
+ MmioWrite32 (HDLCD_REG_INT_MASK, 0);
// Define start of the VRAM. This never changes for any graphics mode
- MmioWrite32(HDLCD_REG_FB_BASE, (UINT32) VramBaseAddress);
+ MmioWrite32 (HDLCD_REG_FB_BASE, (UINT32)VramBaseAddress);
// Setup various registers that never change
- MmioWrite32(HDLCD_REG_BUS_OPTIONS, (4 << 8) | HDLCD_BURST_8);
- MmioWrite32(HDLCD_REG_POLARITIES, HDLCD_PXCLK_LOW | HDLCD_DATA_HIGH | HDLCD_DATEN_HIGH | HDLCD_HSYNC_LOW | HDLCD_VSYNC_HIGH);
- MmioWrite32(HDLCD_REG_PIXEL_FORMAT, 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));
+ MmioWrite32 (HDLCD_REG_BUS_OPTIONS, (4 << 8) | HDLCD_BURST_8);
+
+ MmioWrite32 (
+ HDLCD_REG_POLARITIES,
+ HDLCD_PXCLK_LOW
+ | HDLCD_DATA_HIGH
+ | HDLCD_DATEN_HIGH
+ | HDLCD_HSYNC_LOW
+ | HDLCD_VSYNC_HIGH
+ );
+
+ MmioWrite32 (
+ HDLCD_REG_PIXEL_FORMAT,
+ 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;
}
@@ -73,44 +86,52 @@ LcdSetMode (
// Set the video mode timings and other relevant information
- Status = LcdPlatformGetTimings (ModeNumber,
- &HRes,&HSync,&HBackPorch,&HFrontPorch,
- &VRes,&VSync,&VBackPorch,&VFrontPorch);
+ Status = LcdPlatformGetTimings (
+ ModeNumber,
+ &HRes,
+ &HSync,
+ &HBackPorch,
+ &HFrontPorch,
+ &VRes,
+ &VSync,
+ &VBackPorch,
+ &VFrontPorch
+ );
ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR( Status )) {
+ if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
- Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);
+ Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR( Status )) {
+ if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
- BytesPerPixel = GetBytesPerPixel(LcdBpp);
+ BytesPerPixel = GetBytesPerPixel (LcdBpp);
// Disable the controller
- MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE);
+ MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
// Update the frame buffer information with the new settings
- MmioWrite32(HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
- MmioWrite32(HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
- MmioWrite32(HDLCD_REG_FB_LINE_COUNT, VRes - 1);
+ MmioWrite32 (HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
+ MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
+ MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, VRes - 1);
// Set the vertical timing information
- MmioWrite32(HDLCD_REG_V_SYNC, VSync);
- MmioWrite32(HDLCD_REG_V_BACK_PORCH, VBackPorch);
- MmioWrite32(HDLCD_REG_V_DATA, VRes - 1);
- MmioWrite32(HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
+ MmioWrite32 (HDLCD_REG_V_SYNC, VSync);
+ MmioWrite32 (HDLCD_REG_V_BACK_PORCH, VBackPorch);
+ MmioWrite32 (HDLCD_REG_V_DATA, VRes - 1);
+ MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
// Set the horizontal timing information
- MmioWrite32(HDLCD_REG_H_SYNC, HSync);
- MmioWrite32(HDLCD_REG_H_BACK_PORCH, HBackPorch);
- MmioWrite32(HDLCD_REG_H_DATA, HRes - 1);
- MmioWrite32(HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
+ MmioWrite32 (HDLCD_REG_H_SYNC, HSync);
+ MmioWrite32 (HDLCD_REG_H_BACK_PORCH, HBackPorch);
+ MmioWrite32 (HDLCD_REG_H_DATA, HRes - 1);
+ MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
// Enable the controller
- MmioWrite32(HDLCD_REG_COMMAND, HDLCD_ENABLE);
+ MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_ENABLE);
return EFI_SUCCESS;
}
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
index b721061fc1df5695092e8c71da97ae0b9af46b3f..2dd8f39873f77b1c211bff407cabe90c1795b121 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
@@ -1,6 +1,6 @@
-/** @file
+/** @file LcdGraphicsOutputDxe.c
- Copyright (c) 2011-2014, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -9,7 +9,7 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
- **/
+**/
#include <PiDxe.h>
#include <Library/BaseMemoryLib.h>
@@ -64,7 +64,9 @@ LCD_INSTANCE mLcdTemplate = {
{
{
HARDWARE_DEVICE_PATH, HW_VENDOR_DP,
- { (UINT8) (sizeof(VENDOR_DEVICE_PATH)), (UINT8) ((sizeof(VENDOR_DEVICE_PATH)) >> 8) },
+ { (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ },
},
// Hardware Device Path for Lcd
EFI_CALLER_ID_GUID // Use the driver's GUID
@@ -73,7 +75,7 @@ LCD_INSTANCE mLcdTemplate = {
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
- { sizeof(EFI_DEVICE_PATH_PROTOCOL), 0 }
+ { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
}
},
(EFI_EVENT) NULL // ExitBootServicesEvent
@@ -86,7 +88,7 @@ LcdInstanceContructor (
{
LCD_INSTANCE* Instance;
- Instance = AllocateCopyPool (sizeof(LCD_INSTANCE), &mLcdTemplate);
+ Instance = AllocateCopyPool (sizeof (LCD_INSTANCE), &mLcdTemplate);
if (Instance == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -113,23 +115,23 @@ InitializeDisplay (
UINTN VramSize;
Status = LcdPlatformGetVram (&VramBaseAddress, &VramSize);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
// Setup the LCD
Status = LcdInitialize (VramBaseAddress);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto EXIT_ERROR_LCD_SHUTDOWN;
}
Status = LcdPlatformInitializeDisplay (Instance->Handle);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto EXIT_ERROR_LCD_SHUTDOWN;
}
// Setup all the relevant mode information
- Instance->Gop.Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
+ Instance->Gop.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
Instance->Gop.Mode->FrameBufferBase = VramBaseAddress;
// Set the flag before changing the mode, to avoid infinite loops
@@ -139,7 +141,8 @@ InitializeDisplay (
goto EXIT;
EXIT_ERROR_LCD_SHUTDOWN:
- DEBUG((DEBUG_ERROR, "InitializeDisplay: ERROR - Can not initialise the display. Exit Status=%r\n", Status));
+ DEBUG ((DEBUG_ERROR, "InitializeDisplay: ERROR - Can not initialise the display. Exit Status=%r\n", Status));
+
LcdShutdown ();
EXIT:
@@ -157,40 +160,44 @@ LcdGraphicsOutputDxeInitialize (
LCD_INSTANCE* Instance;
Status = LcdIdentify ();
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
Status = LcdInstanceContructor (&Instance);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
// Install the Graphics Output Protocol and the Device Path
- Status = gBS->InstallMultipleProtocolInterfaces(
- &Instance->Handle,
- &gEfiGraphicsOutputProtocolGuid, &Instance->Gop,
- &gEfiDevicePathProtocolGuid, &Instance->DevicePath,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Instance->Handle,
+ &gEfiGraphicsOutputProtocolGuid,
+ &Instance->Gop,
+ &gEfiDevicePathProtocolGuid,
+ &Instance->DevicePath,
+ NULL
+ );
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the protocol. Exit Status=%r\n", Status));
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "LcdGraphicsOutputDxeInitialize: Can not install the protocol. Exit Status=%r\n", Status));
goto EXIT;
}
- // Register for an ExitBootServicesEvent
- // When ExitBootServices starts, this function here will make sure that the graphics driver will shut down properly,
- // i.e. it will free up all allocated memory and perform any necessary hardware re-configuration.
+ /* Register for an ExitBootServicesEvent
+ * When ExitBootServices starts, this function will make sure that the
+ * graphics driver shuts down properly, i.e. it will free up all
+ * allocated memory and perform any necessary hardware re-configuration. */
Status = gBS->CreateEvent (
EVT_SIGNAL_EXIT_BOOT_SERVICES,
TPL_NOTIFY,
- LcdGraphicsExitBootServicesEvent, NULL,
+ LcdGraphicsExitBootServicesEvent,
+ NULL,
&Instance->ExitBootServicesEvent
);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the ExitBootServicesEvent handler. Exit Status=%r\n", Status));
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "LcdGraphicsOutputDxeInitialize: Can not install the ExitBootServicesEvent handler. Exit Status=%r\n", Status));
goto EXIT_ERROR_UNINSTALL_PROTOCOL;
}
@@ -204,11 +211,13 @@ EXIT_ERROR_UNINSTALL_PROTOCOL:
* the Status variable, even it fails to uninstall the protocol.
*/
gBS->UninstallMultipleProtocolInterfaces (
- Instance->Handle,
- &gEfiGraphicsOutputProtocolGuid, &Instance->Gop, // Uninstall Graphics Output protocol
- &gEfiDevicePathProtocolGuid, &Instance->DevicePath, // Uninstall device path
- NULL
- );
+ Instance->Handle,
+ &gEfiGraphicsOutputProtocolGuid,
+ &Instance->Gop, // Uninstall Graphics Output protocol
+ &gEfiDevicePathProtocolGuid,
+ &Instance->DevicePath, // Uninstall device path
+ NULL
+ );
EXIT:
return Status;
@@ -227,9 +236,9 @@ LcdGraphicsExitBootServicesEvent (
IN VOID *Context
)
{
- // By default, this PCD is FALSE. But if a platform starts a predefined OS that
- // does not use a framebuffer then we might want to disable the display controller
- // to avoid to display corrupted information on the screen.
+ /* By default, this PCD is FALSE. But if a platform starts a predefined OS
+ * that does not use a framebuffer then we might want to disable the display
+ * controller to avoid to display corrupted information on the screen. */
if (FeaturePcdGet (PcdGopDisableOnExitBootServices)) {
// Turn-off the Display controller
LcdShutdown ();
@@ -252,19 +261,22 @@ LcdGraphicsQueryMode (
EFI_STATUS Status = EFI_SUCCESS;
LCD_INSTANCE *Instance;
- Instance = LCD_INSTANCE_FROM_GOP_THIS(This);
+ Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
// Setup the hardware if not already done
- if( !mDisplayInitialized ) {
- Status = InitializeDisplay(Instance);
- if (EFI_ERROR(Status)) {
+ if (!mDisplayInitialized) {
+ Status = InitializeDisplay (Instance);
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
}
// Error checking
- if ( (This == NULL) || (Info == NULL) || (SizeOfInfo == NULL) || (ModeNumber >= This->Mode->MaxMode) ) {
- DEBUG((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode number %d : Invalid Parameter.\n", ModeNumber ));
+ if ( (This == NULL)
+ || (Info == NULL)
+ || (SizeOfInfo == NULL)
+ || (ModeNumber >= This->Mode->MaxMode)) {
+ DEBUG ((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode number %d : Invalid Parameter.\n", ModeNumber));
Status = EFI_INVALID_PARAMETER;
goto EXIT;
}
@@ -275,11 +287,11 @@ LcdGraphicsQueryMode (
goto EXIT;
}
- *SizeOfInfo = sizeof( EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
+ *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
- Status = LcdPlatformQueryMode (ModeNumber,*Info);
- if (EFI_ERROR(Status)) {
- FreePool(*Info);
+ Status = LcdPlatformQueryMode (ModeNumber, *Info);
+ if (EFI_ERROR (Status)) {
+ FreePool (*Info);
}
EXIT:
@@ -305,47 +317,48 @@ LcdGraphicsSetMode (
Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
// Setup the hardware if not already done
- if(!mDisplayInitialized) {
+ if (!mDisplayInitialized) {
Status = InitializeDisplay (Instance);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
}
// Check if this mode is supported
- if( ModeNumber >= This->Mode->MaxMode ) {
- DEBUG((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Unsupported mode number %d .\n", ModeNumber ));
+ if (ModeNumber >= This->Mode->MaxMode) {
+ DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Unsupported mode number %d .\n", ModeNumber));
Status = EFI_UNSUPPORTED;
goto EXIT;
}
// Set the oscillator frequency to support the new mode
Status = LcdPlatformSetMode (ModeNumber);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
goto EXIT;
}
// Update the UEFI mode information
This->Mode->Mode = ModeNumber;
- LcdPlatformQueryMode (ModeNumber,&Instance->ModeInfo);
- Status = LcdPlatformGetBpp(ModeNumber, &Bpp);
- if (EFI_ERROR(Status)) {
+ LcdPlatformQueryMode (ModeNumber, &Instance->ModeInfo);
+ Status = LcdPlatformGetBpp (ModeNumber, &Bpp);
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Couldn't get bytes per pixel, status: %r\n", Status));
goto EXIT;
}
This->Mode->FrameBufferSize = Instance->ModeInfo.VerticalResolution
* Instance->ModeInfo.PixelsPerScanLine
- * GetBytesPerPixel(Bpp);
+ * GetBytesPerPixel (Bpp);
// Set the hardware to the new mode
Status = LcdSetMode (ModeNumber);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
goto EXIT;
}
- // The UEFI spec requires that we now clear the visible portions of the output display to black.
+ // The UEFI spec requires that we now clear the visible portions of the
+ // output display to black.
// Set the fill colour to black
SetMem (&FillColour, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
@@ -361,7 +374,8 @@ LcdGraphicsSetMode (
0,
This->Mode->Info->HorizontalResolution,
This->Mode->Info->VerticalResolution,
- 0);
+ 0
+ );
EXIT:
return Status;
@@ -372,7 +386,7 @@ GetBytesPerPixel (
IN LCD_BPP Bpp
)
{
- switch(Bpp) {
+ switch (Bpp) {
case LCD_BITS_PER_PIXEL_24:
return 4;
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
index b5e113b844d4e4df2e35ccd880c01344b4b8b9d7..0b0c4204fbc44bc9e90dce3d7b410ce167d9f40c 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
@@ -1,6 +1,6 @@
/** @file PL111Lcd.c
- Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -54,11 +54,11 @@ LcdInitialize (
)
{
// Define start of the VRAM. This never changes for any graphics mode
- MmioWrite32(PL111_REG_LCD_UP_BASE, (UINT32) VramBaseAddress);
- MmioWrite32(PL111_REG_LCD_LP_BASE, 0); // We are not using a double buffer
+ MmioWrite32 (PL111_REG_LCD_UP_BASE, (UINT32)VramBaseAddress);
+ MmioWrite32 (PL111_REG_LCD_LP_BASE, 0); // We are not using a double buffer
// Disable all interrupts from the PL111
- MmioWrite32(PL111_REG_LCD_IMSC, 0);
+ MmioWrite32 (PL111_REG_LCD_IMSC, 0);
return EFI_SUCCESS;
}
@@ -81,37 +81,55 @@ LcdSetMode (
LCD_BPP LcdBpp;
// Set the video mode timings and other relevant information
- Status = LcdPlatformGetTimings (ModeNumber,
- &HRes,&HSync,&HBackPorch,&HFrontPorch,
- &VRes,&VSync,&VBackPorch,&VFrontPorch);
+ Status = LcdPlatformGetTimings (
+ ModeNumber,
+ &HRes,
+ &HSync,
+ &HBackPorch,
+ &HFrontPorch,
+ &VRes,
+ &VSync,
+ &VBackPorch,
+ &VFrontPorch
+ );
ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR( Status )) {
+ if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
- Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);
+ Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR( Status )) {
+ if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
// Disable the CLCD_LcdEn bit
- LcdControl = MmioRead32( PL111_REG_LCD_CONTROL);
- MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl & ~1);
+ LcdControl = MmioRead32 (PL111_REG_LCD_CONTROL);
+ MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl & ~1);
// Set Timings
- MmioWrite32 (PL111_REG_LCD_TIMING_0, HOR_AXIS_PANEL(HBackPorch, HFrontPorch, HSync, HRes));
- MmioWrite32 (PL111_REG_LCD_TIMING_1, VER_AXIS_PANEL(VBackPorch, VFrontPorch, VSync, VRes));
- MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY(HRes));
+ MmioWrite32 (
+ PL111_REG_LCD_TIMING_0,
+ HOR_AXIS_PANEL (HBackPorch, HFrontPorch, HSync, HRes)
+ );
+
+ MmioWrite32 (
+ PL111_REG_LCD_TIMING_1,
+ VER_AXIS_PANEL (VBackPorch, VFrontPorch, VSync, VRes)
+ );
+
+ MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY (HRes));
MmioWrite32 (PL111_REG_LCD_TIMING_3, 0);
// PL111_REG_LCD_CONTROL
- LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP(LcdBpp) | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
- MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);
+ LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp)
+ | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
+
+ MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
// Turn on power to the LCD Panel
LcdControl |= PL111_CTRL_LCD_PWR;
- MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);
+ MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
return EFI_SUCCESS;
}
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 01/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Coding standard
2017-09-26 20:15 ` [PATCH 01/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Coding standard evan.lloyd
@ 2017-10-12 18:45 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-12 18:45 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:11PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> There is no functional modification in this change
> As preparation for further work, the formatting is corrected to meet
> the EDKII coding standard.
> Of specific note, some invalid include guards were fixed.
Subjects says to be cleaning LcdGraphicsOutputDxe, but that is only
one of the modules modified.
> 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>
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf | 9 +-
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf | 6 +-
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf | 4 +-
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf | 4 +-
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h | 11 +-
> ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 10 +-
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 103 +++++++-----
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 173 ++++++++++++--------
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 83 ++++++----
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c | 130 ++++++++-------
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 54 ++++--
> 11 files changed, 350 insertions(+), 237 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> index dff17e86fd3e563b38318f696a94f2c75276b31f..4733bb8e662d64eca0976af21b2abb7036b4424b 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> @@ -1,8 +1,8 @@
> -#/** @file
> +#/** @file HdLcdArmVExpress.inf
> #
> -# Component description file for HdLcdArmLib module
> +# Component description file for HdLcdArmVExpress module
> #
> -# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
> +# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
> #
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD License
> @@ -23,8 +23,7 @@ [Defines]
> LIBRARY_CLASS = LcdPlatformLib
>
> [Sources.common]
> -
> -HdLcdArmVExpress.c
> + HdLcdArmVExpress.c
>
> [Packages]
> MdePkg/MdePkg.dec
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> index 658558ab15230d07f1c04d29a8e2bf8d14f1d6a2..3fde707c33dbcbd8adbbf18bbba718b823194abc 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> @@ -1,8 +1,8 @@
> -#/** @file
> +#/** @file PL111LcdArmVExpressLib.inf
> #
> -# Component description file for ArmVeGraphicsDxe module
> +# Component description file for PL111LcdArmVExpressLib module
> #
> -# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
> +# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
> #
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD License
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
> index 462d1fa402d7a1939b2876b74a5b76e8edf2e1f6..26e580a594fc328187407ac4c1787f180fbf4b17 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
> @@ -1,8 +1,8 @@
> -#/** @file
> +#/** @file HdLcdGraphicsOutputDxe.inf
> #
> # Component description file for HDLCD module
> #
> -# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
> +# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
> #
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD License
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
> index 003cc2ffa912b39d6f1342c92445eefce94b1f8b..ad0348500326c4567f0e1b235c84b694e61306bf 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
> @@ -1,8 +1,8 @@
> -#/** @file
> +#/** @file PL111LcdGraphicsOutputDxe.inf
> #
> # Component description file for PL111LcdGraphicsOutputDxe module
> #
> -# Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
> +# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD License
> # which accompanies this distribution. The full text of the license may be found at
I guess there has been some sort of rebase accident with the above 2
files - they update the copyright only.
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
> index 8856b79901b632071ae4c4081b69e5188daa23ed..85e918de66624d61c6d0e05c5a67c516cd7619aa 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
> @@ -1,6 +1,6 @@
> -/** @file
> +/** @file LcdGraphicsOutputDxe.h
>
> - Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> which accompanies this distribution. The full text of the license may be found at
> @@ -11,8 +11,8 @@
>
> **/
>
> -#ifndef __ARM_VE_GRAPHICS_DXE_H__
> -#define __ARM_VE_GRAPHICS_DXE_H__
> +#ifndef LCD_GRAPHICS_OUTPUT_DXE_H_
> +#define LCD_GRAPHICS_OUTPUT_DXE_H_
>
>
> #include <Base.h>
> @@ -124,5 +124,4 @@ VOID
> LcdShutdown (
> VOID
> );
> -
> -#endif /* __ARM_VE_GRAPHICS_DXE_H__ */
> +#endif /* LCD_GRAPHICS_OUTPUT_DXE_H_ */
> diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> index b9bdf471e2d65dba7a0fcb0f7ecc352bd576b46b..72ebcd02ddb321ee0dad51c87ac8ee876d9ca21c 100644
> --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> @@ -1,6 +1,6 @@
> -/** @file
> +/** @file LcdPlatformLib.h
>
> - Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> which accompanies this distribution. The full text of the license may be found at
> @@ -11,8 +11,8 @@
>
> **/
>
> -#ifndef __LCDPLATFORMLIB_H
> -#define __LCDPLATFORMLIB_H
> +#ifndef LCD_PLATFORM_LIB_H_
> +#define LCD_PLATFORM_LIB_H_
>
> #include <Protocol/GraphicsOutput.h>
>
> @@ -218,4 +218,4 @@ LcdPlatformGetBpp (
> OUT LCD_BPP* Bpp
> );
>
> -#endif
> +#endif // LCD_PLATFORM_LIB_H_
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index b1106ee19b98cebac01820924514eac79b97d0d5..2041de5f63c72de6f0ce4047420c282507a1d04a 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -1,6 +1,6 @@
> -/**
> +/** @file HdLcdArmVExpress.c
>
> - Copyright (c) 2012, ARM Ltd. All rights reserved.
> + Copyright (c) 2012-2017, ARM Ltd. All rights reserved.
>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> @@ -47,32 +47,38 @@ typedef struct {
>
> LCD_RESOLUTION mResolutions[] = {
> { // Mode 0 : VGA : 640 x 480 x 24 bpp
> - VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, VGA_OSC_FREQUENCY,
> + VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + VGA_OSC_FREQUENCY,
> VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> },
> { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> - SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, SVGA_OSC_FREQUENCY,
> + SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + SVGA_OSC_FREQUENCY,
> SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> },
> { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, XGA_OSC_FREQUENCY,
> + XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + XGA_OSC_FREQUENCY,
> XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> },
> { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> - SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (SXGA_OSC_FREQUENCY/2),
> + SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + (SXGA_OSC_FREQUENCY/2),
> SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
> SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
> },
> { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> - UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (UXGA_OSC_FREQUENCY/2),
> + UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + (UXGA_OSC_FREQUENCY/2),
> UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
> UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
> },
> { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> - HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (HD_OSC_FREQUENCY/2),
> + HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + (HD_OSC_FREQUENCY/2),
> HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
> HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
> }
> @@ -95,19 +101,25 @@ LcdPlatformInitializeDisplay (
> {
> EFI_STATUS Status;
>
> - // Set the FPGA multiplexer to select the video output from the motherboard or the daughterboard
> - Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, ARM_VE_DAUGHTERBOARD_1_SITE);
> - if (EFI_ERROR(Status)) {
> + /* Set the FPGA multiplexer to select the video output from the
> + * motherboard or the daughterboard */
> + Status = ArmPlatformSysConfigSet (
> + SYS_CFG_MUXFPGA,
> + ARM_VE_DAUGHTERBOARD_1_SITE
> + );
> + if (EFI_ERROR (Status)) {
> return Status;
> }
>
> // Install the EDID Protocols
> Status = gBS->InstallMultipleProtocolInterfaces (
> - &Handle,
> - &gEfiEdidDiscoveredProtocolGuid, &mEdidDiscovered,
> - &gEfiEdidActiveProtocolGuid, &mEdidActive,
> - NULL
> - );
> + &Handle,
> + &gEfiEdidDiscoveredProtocolGuid,
> + &mEdidDiscovered,
> + &gEfiEdidActiveProtocolGuid,
> + &mEdidActive,
> + NULL
> + );
>
> return Status;
> }
> @@ -132,16 +144,25 @@ LcdPlatformGetVram (
> } else {
> AllocationType = AllocateAddress;
> }
> - Status = gBS->AllocatePages (AllocationType, EfiBootServicesData, EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
> - if (EFI_ERROR(Status)) {
> + Status = gBS->AllocatePages (
> + AllocationType,
> + EfiBootServicesData,
> + EFI_SIZE_TO_PAGES (((UINTN)LCD_VRAM_SIZE)),
> + VramBaseAddress
> + );
> + if (EFI_ERROR (Status)) {
> return Status;
> }
>
> - // Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.
> - Status = gDS->SetMemorySpaceAttributes (*VramBaseAddress, *VramSize,
> - EFI_MEMORY_WC);
> - ASSERT_EFI_ERROR(Status);
> - if (EFI_ERROR(Status)) {
> + /* Mark the VRAM as write-combining.
> + * The VRAM is inside the DRAM, which is cacheable. */
> + Status = gDS->SetMemorySpaceAttributes (
> + *VramBaseAddress,
> + *VramSize,
> + EFI_MEMORY_WC
> + );
> + ASSERT_EFI_ERROR (Status);
> + if (EFI_ERROR (Status)) {
> gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> return Status;
> }
> @@ -150,15 +171,11 @@ LcdPlatformGetVram (
> }
>
> UINT32
> -LcdPlatformGetMaxMode (
> - VOID
> - )
> +LcdPlatformGetMaxMode(VOID)
> {
> - //
> - // The following line will report correctly the total number of graphics modes
> - // that could be supported by the graphics driver:
> - //
> - return (sizeof(mResolutions) / sizeof(LCD_RESOLUTION));
> + /* The following line will report correctly the total number of graphics modes
> + * that could be supported by the graphics driver: */
> + return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
> }
>
> EFI_STATUS
> @@ -174,25 +191,35 @@ LcdPlatformSetMode (
>
> // Set the video mode oscillator
> do {
> - Status = ArmPlatformSysConfigSetDevice (SYS_CFG_OSC_SITE1, PcdGet32(PcdHdLcdVideoModeOscId), mResolutions[ModeNumber].OscFreq);
> + Status = ArmPlatformSysConfigSetDevice (
> + SYS_CFG_OSC_SITE1,
> + PcdGet32 (PcdHdLcdVideoModeOscId),
> + mResolutions[ModeNumber].OscFreq
> + );
> } while (Status == EFI_TIMEOUT);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
>
> // Set the DVI into the new mode
> do {
> - Status = ArmPlatformSysConfigSet (SYS_CFG_DVIMODE, mResolutions[ModeNumber].Mode);
> + Status = ArmPlatformSysConfigSet (
> + SYS_CFG_DVIMODE,
> + mResolutions[ModeNumber].Mode
> + );
> } while (Status == EFI_TIMEOUT);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
>
> // Set the multiplexer
> - Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, ARM_VE_DAUGHTERBOARD_1_SITE);
> - if (EFI_ERROR(Status)) {
> + Status = ArmPlatformSysConfigSet (
> + SYS_CFG_MUXFPGA,
> + ARM_VE_DAUGHTERBOARD_1_SITE
> + );
> + if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
> @@ -233,7 +260,7 @@ LcdPlatformQueryMode (
> case LCD_BITS_PER_PIXEL_1:
> default:
> // These are not supported
> - ASSERT(FALSE);
> + ASSERT (FALSE);
> break;
> }
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 3f3ceb3d2fa82f614e0c6dac8455c117745cf3a6..8d046816454f642bced00e29c4e02093b74afd24 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -1,6 +1,6 @@
> -/** @file
> +/** @file PL111LcdArmVExpress.c
>
> - Copyright (c) 2011-2015, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> which accompanies this distribution. The full text of the license may be found at
> @@ -43,83 +43,99 @@ typedef struct {
>
>
> LCD_RESOLUTION mResolutions[] = {
> - { // Mode 0 : VGA : 640 x 480 x 24 bpp
> - VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, VGA_OSC_FREQUENCY,
> + { // Mode 0 : VGA : 640 x 480 x 24 bpp
Should the changes in this hunk not fix the alignment of the values
below (from 4 to 2) rather than increase indentati on of the comment
(from 2 to 4)?
> + VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + VGA_OSC_FREQUENCY,
> VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> },
> - { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> - SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, SVGA_OSC_FREQUENCY,
> + { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> + SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + SVGA_OSC_FREQUENCY,
> SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> },
> - { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, XGA_OSC_FREQUENCY,
> + { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> + XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + XGA_OSC_FREQUENCY,
> XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> },
> - { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> - SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (SXGA_OSC_FREQUENCY/2),
> + { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> + SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + (SXGA_OSC_FREQUENCY/2),
> SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
> SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
> },
> - { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> - UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (UXGA_OSC_FREQUENCY/2),
> + { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> + UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + (UXGA_OSC_FREQUENCY/2),
> UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
> UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
> },
> - { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> - HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24, (HD_OSC_FREQUENCY/2),
> + { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> + HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + (HD_OSC_FREQUENCY/2),
> HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
> HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
> },
> - { // Mode 6 : VGA : 640 x 480 x 16 bpp (565 Mode)
> - VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, VGA_OSC_FREQUENCY,
> + { // Mode 6 : VGA : 640 x 480 x 16 bpp (565 Mode)
> + VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> + VGA_OSC_FREQUENCY,
> VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> },
> - { // Mode 7 : SVGA : 800 x 600 x 16 bpp (565 Mode)
> - SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, SVGA_OSC_FREQUENCY,
> + { // Mode 7 : SVGA : 800 x 600 x 16 bpp (565 Mode)
> + SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> + SVGA_OSC_FREQUENCY,
> SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> },
> - { // Mode 8 : XGA : 1024 x 768 x 16 bpp (565 Mode)
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565, XGA_OSC_FREQUENCY,
> + { // Mode 8 : XGA : 1024 x 768 x 16 bpp (565 Mode)
> + XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> + XGA_OSC_FREQUENCY,
> XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> },
> - { // Mode 9 : VGA : 640 x 480 x 15 bpp
> - VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, VGA_OSC_FREQUENCY,
> + { // Mode 9 : VGA : 640 x 480 x 15 bpp
> + VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> + VGA_OSC_FREQUENCY,
> VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> },
> - { // Mode 10 : SVGA : 800 x 600 x 15 bpp
> - SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, SVGA_OSC_FREQUENCY,
> + { // Mode 10 : SVGA : 800 x 600 x 15 bpp
> + SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> + SVGA_OSC_FREQUENCY,
> SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> },
> - { // Mode 11 : XGA : 1024 x 768 x 15 bpp
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, XGA_OSC_FREQUENCY,
> + { // Mode 11 : XGA : 1024 x 768 x 15 bpp
> + XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> + XGA_OSC_FREQUENCY,
> XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> },
> - { // Mode 12 : XGA : 1024 x 768 x 15 bpp - All the timing info is derived from Linux Kernel Driver Settings
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555, 63500000,
> + { // Mode 12 : XGA : 1024 x 768 x 15 bpp - All the timing info is derived from Linux Kernel Driver Settings
> + XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> + 63500000,
> XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> },
> - { // Mode 13 : VGA : 640 x 480 x 12 bpp (444 Mode)
> - VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, VGA_OSC_FREQUENCY,
> + { // Mode 13 : VGA : 640 x 480 x 12 bpp (444 Mode)
> + VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> + VGA_OSC_FREQUENCY,
> VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> },
> - { // Mode 14 : SVGA : 800 x 600 x 12 bpp (444 Mode)
> - SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, SVGA_OSC_FREQUENCY,
> + { // Mode 14 : SVGA : 800 x 600 x 12 bpp (444 Mode)
> + SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> + SVGA_OSC_FREQUENCY,
> SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> },
> - { // Mode 15 : XGA : 1024 x 768 x 12 bpp (444 Mode)
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444, XGA_OSC_FREQUENCY,
> + { // Mode 15 : XGA : 1024 x 768 x 12 bpp (444 Mode)
> + XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> + XGA_OSC_FREQUENCY,
> XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> }
> @@ -145,14 +161,16 @@ LcdPlatformInitializeDisplay (
>
> // Set the FPGA multiplexer to select the video output from the motherboard or the daughterboard
> Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, PL111_CLCD_SITE);
> - if (!EFI_ERROR(Status)) {
> + if (!EFI_ERROR (Status)) {
> // Install the EDID Protocols
> - Status = gBS->InstallMultipleProtocolInterfaces(
> - &Handle,
> - &gEfiEdidDiscoveredProtocolGuid, &mEdidDiscovered,
> - &gEfiEdidActiveProtocolGuid, &mEdidActive,
> - NULL
> - );
> + Status = gBS->InstallMultipleProtocolInterfaces (
> + &Handle,
> + &gEfiEdidDiscoveredProtocolGuid,
> + &mEdidDiscovered,
> + &gEfiEdidActiveProtocolGuid,
> + &mEdidActive,
> + NULL
> + );
> }
>
> return Status;
> @@ -169,29 +187,38 @@ LcdPlatformGetVram (
> Status = EFI_SUCCESS;
>
> // Is it on the motherboard or on the daughterboard?
> - switch(PL111_CLCD_SITE) {
> + switch (PL111_CLCD_SITE) {
>
> case ARM_VE_MOTHERBOARD_SITE:
> - *VramBaseAddress = (EFI_PHYSICAL_ADDRESS) PL111_CLCD_VRAM_MOTHERBOARD_BASE;
> + *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
> *VramSize = LCD_VRAM_SIZE;
> break;
>
> case ARM_VE_DAUGHTERBOARD_1_SITE:
> - *VramBaseAddress = (EFI_PHYSICAL_ADDRESS) LCD_VRAM_CORE_TILE_BASE;
> + *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)LCD_VRAM_CORE_TILE_BASE;
> *VramSize = LCD_VRAM_SIZE;
>
> // Allocate the VRAM from the DRAM so that nobody else uses it.
> - Status = gBS->AllocatePages( AllocateAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(((UINTN)LCD_VRAM_SIZE)), VramBaseAddress);
> - if (EFI_ERROR(Status)) {
> + Status = gBS->AllocatePages (
> + AllocateAddress,
> + EfiBootServicesData,
> + EFI_SIZE_TO_PAGES (((UINTN)LCD_VRAM_SIZE)),
> + VramBaseAddress
> + );
> + if (EFI_ERROR (Status)) {
> return Status;
> }
>
> - // Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.
> - Status = gDS->SetMemorySpaceAttributes (*VramBaseAddress, *VramSize,
> - EFI_MEMORY_WC);
> - ASSERT_EFI_ERROR(Status);
> - if (EFI_ERROR(Status)) {
> - gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES(*VramSize));
> + // Mark the VRAM as write-combining.
> + // The VRAM is inside the DRAM, which is cacheable.
> + Status = gDS->SetMemorySpaceAttributes (
> + *VramBaseAddress,
> + *VramSize,
> + EFI_MEMORY_WC
> + );
> + ASSERT_EFI_ERROR (Status);
> + if (EFI_ERROR (Status)) {
> + gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> return Status;
> }
> break;
> @@ -206,19 +233,20 @@ LcdPlatformGetVram (
> }
>
> UINT32
> -LcdPlatformGetMaxMode (
> - VOID
> - )
> +LcdPlatformGetMaxMode(VOID)
> {
> - // The following line will report correctly the total number of graphics modes
> - // supported by the PL111CLCD.
> - //return (sizeof(mResolutions) / sizeof(CLCD_RESOLUTION)) - 1;
> + /* The following line would correctly reports the total number
> + * of graphics modes supported by the PL111CLCD.
> + * return (sizeof(mResolutions) / sizeof(CLCD_RESOLUTION)) - 1;
> + */
>
> - // However, on some platforms it is desirable to ignore some graphics modes.
> - // This could be because the specific implementation of PL111 has certain limitations.
> + /* However, on some platforms it is desirable to ignore some graphics modes.
> + * This could be because the specific implementation of PL111 has
> + * certain limitations.
> + */
>
> // Set the maximum mode allowed
> - return (PcdGet32(PcdPL111LcdMaxMode));
> + return (PcdGet32 (PcdPL111LcdMaxMode));
> }
>
> EFI_STATUS
> @@ -238,22 +266,26 @@ LcdPlatformSetMode (
>
> LcdSite = PL111_CLCD_SITE;
>
> - switch(LcdSite) {
> + switch (LcdSite) {
> case ARM_VE_MOTHERBOARD_SITE:
> Function = SYS_CFG_OSC;
> OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
> break;
> case ARM_VE_DAUGHTERBOARD_1_SITE:
> Function = SYS_CFG_OSC_SITE1;
> - OscillatorId = (UINT32)PcdGet32(PcdPL111LcdVideoModeOscId);
> + OscillatorId = (UINT32)PcdGet32 (PcdPL111LcdVideoModeOscId);
> break;
> default:
> return EFI_UNSUPPORTED;
> }
>
> // Set the video mode oscillator
> - Status = ArmPlatformSysConfigSetDevice (Function, OscillatorId, mResolutions[ModeNumber].OscFreq);
> - if (EFI_ERROR(Status)) {
> + Status = ArmPlatformSysConfigSetDevice (
> + Function,
> + OscillatorId,
> + mResolutions[ModeNumber].OscFreq
> + );
> + if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
> @@ -267,8 +299,11 @@ LcdPlatformSetMode (
> SysId &= ~ARM_FVP_SYS_ID_VARIANT_MASK;
> if (SysId != ARM_FVP_BASE_BOARD_SYS_ID) {
> // Set the DVI into the new mode
> - Status = ArmPlatformSysConfigSet (SYS_CFG_DVIMODE, mResolutions[ModeNumber].Mode);
> - if (EFI_ERROR(Status)) {
> + Status = ArmPlatformSysConfigSet (
> + SYS_CFG_DVIMODE,
> + mResolutions[ModeNumber].Mode
> + );
> + if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
> @@ -277,7 +312,7 @@ LcdPlatformSetMode (
>
> // Set the multiplexer
> Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, LcdSite);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
> @@ -318,7 +353,7 @@ LcdPlatformQueryMode (
> case LCD_BITS_PER_PIXEL_1:
> default:
> // These are not supported
> - ASSERT(FALSE);
> + ASSERT (FALSE);
> break;
> }
>
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> index 2bfe2c0fe2dcd05f4983eea57542cfe3d30bf1ce..eb0b6fb3fbbc1cb605469433f6c6dcb85bac668c 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> @@ -1,6 +1,6 @@
> -/** @file Lcd.c
> +/** @file HdLcd.c
>
> - Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> @@ -35,21 +35,34 @@ LcdInitialize (
> )
> {
> // Disable the controller
> - MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE);
> + MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
>
> // Disable all interrupts
> - MmioWrite32(HDLCD_REG_INT_MASK, 0);
> + MmioWrite32 (HDLCD_REG_INT_MASK, 0);
>
> // Define start of the VRAM. This never changes for any graphics mode
> - MmioWrite32(HDLCD_REG_FB_BASE, (UINT32) VramBaseAddress);
> + MmioWrite32 (HDLCD_REG_FB_BASE, (UINT32)VramBaseAddress);
>
> // Setup various registers that never change
> - MmioWrite32(HDLCD_REG_BUS_OPTIONS, (4 << 8) | HDLCD_BURST_8);
> - MmioWrite32(HDLCD_REG_POLARITIES, HDLCD_PXCLK_LOW | HDLCD_DATA_HIGH | HDLCD_DATEN_HIGH | HDLCD_HSYNC_LOW | HDLCD_VSYNC_HIGH);
> - MmioWrite32(HDLCD_REG_PIXEL_FORMAT, 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));
> + MmioWrite32 (HDLCD_REG_BUS_OPTIONS, (4 << 8) | HDLCD_BURST_8);
> +
> + MmioWrite32 (
> + HDLCD_REG_POLARITIES,
> + HDLCD_PXCLK_LOW
> + | HDLCD_DATA_HIGH
> + | HDLCD_DATEN_HIGH
> + | HDLCD_HSYNC_LOW
> + | HDLCD_VSYNC_HIGH
> + );
Or maybe a #define HDLCD_DEFAULT_POLARITIES?
> +
> + MmioWrite32 (
> + HDLCD_REG_PIXEL_FORMAT,
> + 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;
> }
> @@ -73,44 +86,52 @@ LcdSetMode (
>
>
> // Set the video mode timings and other relevant information
> - Status = LcdPlatformGetTimings (ModeNumber,
> - &HRes,&HSync,&HBackPorch,&HFrontPorch,
> - &VRes,&VSync,&VBackPorch,&VFrontPorch);
> + Status = LcdPlatformGetTimings (
> + ModeNumber,
> + &HRes,
> + &HSync,
> + &HBackPorch,
> + &HFrontPorch,
> + &VRes,
> + &VSync,
> + &VBackPorch,
> + &VFrontPorch
> + );
> ASSERT_EFI_ERROR (Status);
> - if (EFI_ERROR( Status )) {
> + if (EFI_ERROR (Status)) {
> return EFI_DEVICE_ERROR;
> }
>
> - Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);
> + Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> ASSERT_EFI_ERROR (Status);
> - if (EFI_ERROR( Status )) {
> + if (EFI_ERROR (Status)) {
> return EFI_DEVICE_ERROR;
> }
>
> - BytesPerPixel = GetBytesPerPixel(LcdBpp);
> + BytesPerPixel = GetBytesPerPixel (LcdBpp);
>
> // Disable the controller
> - MmioWrite32(HDLCD_REG_COMMAND, HDLCD_DISABLE);
> + MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
>
> // Update the frame buffer information with the new settings
> - MmioWrite32(HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
> - MmioWrite32(HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
> - MmioWrite32(HDLCD_REG_FB_LINE_COUNT, VRes - 1);
> + MmioWrite32 (HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
> + MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
> + MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, VRes - 1);
>
> // Set the vertical timing information
> - MmioWrite32(HDLCD_REG_V_SYNC, VSync);
> - MmioWrite32(HDLCD_REG_V_BACK_PORCH, VBackPorch);
> - MmioWrite32(HDLCD_REG_V_DATA, VRes - 1);
> - MmioWrite32(HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
> + MmioWrite32 (HDLCD_REG_V_SYNC, VSync);
> + MmioWrite32 (HDLCD_REG_V_BACK_PORCH, VBackPorch);
> + MmioWrite32 (HDLCD_REG_V_DATA, VRes - 1);
> + MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
>
> // Set the horizontal timing information
> - MmioWrite32(HDLCD_REG_H_SYNC, HSync);
> - MmioWrite32(HDLCD_REG_H_BACK_PORCH, HBackPorch);
> - MmioWrite32(HDLCD_REG_H_DATA, HRes - 1);
> - MmioWrite32(HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
> + MmioWrite32 (HDLCD_REG_H_SYNC, HSync);
> + MmioWrite32 (HDLCD_REG_H_BACK_PORCH, HBackPorch);
> + MmioWrite32 (HDLCD_REG_H_DATA, HRes - 1);
> + MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
>
> // Enable the controller
> - MmioWrite32(HDLCD_REG_COMMAND, HDLCD_ENABLE);
> + MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_ENABLE);
>
> return EFI_SUCCESS;
> }
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
> index b721061fc1df5695092e8c71da97ae0b9af46b3f..2dd8f39873f77b1c211bff407cabe90c1795b121 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
> @@ -1,6 +1,6 @@
> -/** @file
> +/** @file LcdGraphicsOutputDxe.c
>
> - Copyright (c) 2011-2014, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> which accompanies this distribution. The full text of the license may be found at
> @@ -9,7 +9,7 @@
> THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>
> - **/
> +**/
>
> #include <PiDxe.h>
> #include <Library/BaseMemoryLib.h>
> @@ -64,7 +64,9 @@ LCD_INSTANCE mLcdTemplate = {
> {
> {
> HARDWARE_DEVICE_PATH, HW_VENDOR_DP,
> - { (UINT8) (sizeof(VENDOR_DEVICE_PATH)), (UINT8) ((sizeof(VENDOR_DEVICE_PATH)) >> 8) },
> + { (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
I thought the '{' should always be on its own line?
> + (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
> + },
> },
> // Hardware Device Path for Lcd
> EFI_CALLER_ID_GUID // Use the driver's GUID
> @@ -73,7 +75,7 @@ LCD_INSTANCE mLcdTemplate = {
> {
> END_DEVICE_PATH_TYPE,
> END_ENTIRE_DEVICE_PATH_SUBTYPE,
> - { sizeof(EFI_DEVICE_PATH_PROTOCOL), 0 }
> + { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
And here
{
sizeof ...
}
?
> }
> },
> (EFI_EVENT) NULL // ExitBootServicesEvent
> @@ -86,7 +88,7 @@ LcdInstanceContructor (
> {
> LCD_INSTANCE* Instance;
>
> - Instance = AllocateCopyPool (sizeof(LCD_INSTANCE), &mLcdTemplate);
> + Instance = AllocateCopyPool (sizeof (LCD_INSTANCE), &mLcdTemplate);
> if (Instance == NULL) {
> return EFI_OUT_OF_RESOURCES;
> }
> @@ -113,23 +115,23 @@ InitializeDisplay (
> UINTN VramSize;
>
> Status = LcdPlatformGetVram (&VramBaseAddress, &VramSize);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> return Status;
> }
>
> // Setup the LCD
> Status = LcdInitialize (VramBaseAddress);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> goto EXIT_ERROR_LCD_SHUTDOWN;
> }
>
> Status = LcdPlatformInitializeDisplay (Instance->Handle);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> goto EXIT_ERROR_LCD_SHUTDOWN;
> }
>
> // Setup all the relevant mode information
> - Instance->Gop.Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
> + Instance->Gop.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
> Instance->Gop.Mode->FrameBufferBase = VramBaseAddress;
>
> // Set the flag before changing the mode, to avoid infinite loops
> @@ -139,7 +141,8 @@ InitializeDisplay (
> goto EXIT;
>
> EXIT_ERROR_LCD_SHUTDOWN:
> - DEBUG((DEBUG_ERROR, "InitializeDisplay: ERROR - Can not initialise the display. Exit Status=%r\n", Status));
> + DEBUG ((DEBUG_ERROR, "InitializeDisplay: ERROR - Can not initialise the display. Exit Status=%r\n", Status));
> +
> LcdShutdown ();
>
> EXIT:
> @@ -157,40 +160,44 @@ LcdGraphicsOutputDxeInitialize (
> LCD_INSTANCE* Instance;
>
> Status = LcdIdentify ();
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> goto EXIT;
> }
>
> Status = LcdInstanceContructor (&Instance);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> goto EXIT;
> }
>
> // Install the Graphics Output Protocol and the Device Path
> - Status = gBS->InstallMultipleProtocolInterfaces(
> - &Instance->Handle,
> - &gEfiGraphicsOutputProtocolGuid, &Instance->Gop,
> - &gEfiDevicePathProtocolGuid, &Instance->DevicePath,
> - NULL
> - );
> + Status = gBS->InstallMultipleProtocolInterfaces (
> + &Instance->Handle,
> + &gEfiGraphicsOutputProtocolGuid,
> + &Instance->Gop,
> + &gEfiDevicePathProtocolGuid,
> + &Instance->DevicePath,
> + NULL
> + );
>
> - if (EFI_ERROR(Status)) {
> - DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the protocol. Exit Status=%r\n", Status));
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "LcdGraphicsOutputDxeInitialize: Can not install the protocol. Exit Status=%r\n", Status));
> goto EXIT;
> }
>
> - // Register for an ExitBootServicesEvent
> - // When ExitBootServices starts, this function here will make sure that the graphics driver will shut down properly,
> - // i.e. it will free up all allocated memory and perform any necessary hardware re-configuration.
> + /* Register for an ExitBootServicesEvent
> + * When ExitBootServices starts, this function will make sure that the
> + * graphics driver shuts down properly, i.e. it will free up all
> + * allocated memory and perform any necessary hardware re-configuration. */
> Status = gBS->CreateEvent (
> EVT_SIGNAL_EXIT_BOOT_SERVICES,
> TPL_NOTIFY,
> - LcdGraphicsExitBootServicesEvent, NULL,
> + LcdGraphicsExitBootServicesEvent,
> + NULL,
> &Instance->ExitBootServicesEvent
> );
>
> - if (EFI_ERROR(Status)) {
> - DEBUG((DEBUG_ERROR, "GraphicsOutputDxeInitialize: Can not install the ExitBootServicesEvent handler. Exit Status=%r\n", Status));
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "LcdGraphicsOutputDxeInitialize: Can not install the ExitBootServicesEvent handler. Exit Status=%r\n", Status));
> goto EXIT_ERROR_UNINSTALL_PROTOCOL;
> }
>
> @@ -204,11 +211,13 @@ EXIT_ERROR_UNINSTALL_PROTOCOL:
> * the Status variable, even it fails to uninstall the protocol.
> */
> gBS->UninstallMultipleProtocolInterfaces (
> - Instance->Handle,
> - &gEfiGraphicsOutputProtocolGuid, &Instance->Gop, // Uninstall Graphics Output protocol
> - &gEfiDevicePathProtocolGuid, &Instance->DevicePath, // Uninstall device path
> - NULL
> - );
> + Instance->Handle,
> + &gEfiGraphicsOutputProtocolGuid,
> + &Instance->Gop, // Uninstall Graphics Output protocol
> + &gEfiDevicePathProtocolGuid,
> + &Instance->DevicePath, // Uninstall device path
> + NULL
> + );
>
> EXIT:
> return Status;
> @@ -227,9 +236,9 @@ LcdGraphicsExitBootServicesEvent (
> IN VOID *Context
> )
> {
> - // By default, this PCD is FALSE. But if a platform starts a predefined OS that
> - // does not use a framebuffer then we might want to disable the display controller
> - // to avoid to display corrupted information on the screen.
> + /* By default, this PCD is FALSE. But if a platform starts a predefined OS
> + * that does not use a framebuffer then we might want to disable the display
> + * controller to avoid to display corrupted information on the screen. */
> if (FeaturePcdGet (PcdGopDisableOnExitBootServices)) {
> // Turn-off the Display controller
> LcdShutdown ();
> @@ -252,19 +261,22 @@ LcdGraphicsQueryMode (
> EFI_STATUS Status = EFI_SUCCESS;
> LCD_INSTANCE *Instance;
>
> - Instance = LCD_INSTANCE_FROM_GOP_THIS(This);
> + Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
>
> // Setup the hardware if not already done
> - if( !mDisplayInitialized ) {
> - Status = InitializeDisplay(Instance);
> - if (EFI_ERROR(Status)) {
> + if (!mDisplayInitialized) {
> + Status = InitializeDisplay (Instance);
> + if (EFI_ERROR (Status)) {
> goto EXIT;
> }
> }
>
> // Error checking
> - if ( (This == NULL) || (Info == NULL) || (SizeOfInfo == NULL) || (ModeNumber >= This->Mode->MaxMode) ) {
> - DEBUG((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode number %d : Invalid Parameter.\n", ModeNumber ));
> + if ( (This == NULL)
> + || (Info == NULL)
> + || (SizeOfInfo == NULL)
> + || (ModeNumber >= This->Mode->MaxMode)) {
> + DEBUG ((DEBUG_ERROR, "LcdGraphicsQueryMode: ERROR - For mode number %d : Invalid Parameter.\n", ModeNumber));
> Status = EFI_INVALID_PARAMETER;
> goto EXIT;
> }
> @@ -275,11 +287,11 @@ LcdGraphicsQueryMode (
> goto EXIT;
> }
>
> - *SizeOfInfo = sizeof( EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
> + *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
>
> - Status = LcdPlatformQueryMode (ModeNumber,*Info);
> - if (EFI_ERROR(Status)) {
> - FreePool(*Info);
> + Status = LcdPlatformQueryMode (ModeNumber, *Info);
> + if (EFI_ERROR (Status)) {
> + FreePool (*Info);
> }
>
> EXIT:
> @@ -305,47 +317,48 @@ LcdGraphicsSetMode (
> Instance = LCD_INSTANCE_FROM_GOP_THIS (This);
>
> // Setup the hardware if not already done
> - if(!mDisplayInitialized) {
> + if (!mDisplayInitialized) {
> Status = InitializeDisplay (Instance);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> goto EXIT;
> }
> }
>
> // Check if this mode is supported
> - if( ModeNumber >= This->Mode->MaxMode ) {
> - DEBUG((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Unsupported mode number %d .\n", ModeNumber ));
> + if (ModeNumber >= This->Mode->MaxMode) {
> + DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Unsupported mode number %d .\n", ModeNumber));
> Status = EFI_UNSUPPORTED;
> goto EXIT;
> }
>
> // Set the oscillator frequency to support the new mode
> Status = LcdPlatformSetMode (ModeNumber);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> Status = EFI_DEVICE_ERROR;
> goto EXIT;
> }
>
> // Update the UEFI mode information
> This->Mode->Mode = ModeNumber;
> - LcdPlatformQueryMode (ModeNumber,&Instance->ModeInfo);
> - Status = LcdPlatformGetBpp(ModeNumber, &Bpp);
> - if (EFI_ERROR(Status)) {
> + LcdPlatformQueryMode (ModeNumber, &Instance->ModeInfo);
> + Status = LcdPlatformGetBpp (ModeNumber, &Bpp);
> + if (EFI_ERROR (Status)) {
> DEBUG ((DEBUG_ERROR, "LcdGraphicsSetMode: ERROR - Couldn't get bytes per pixel, status: %r\n", Status));
> goto EXIT;
> }
> This->Mode->FrameBufferSize = Instance->ModeInfo.VerticalResolution
> * Instance->ModeInfo.PixelsPerScanLine
> - * GetBytesPerPixel(Bpp);
> + * GetBytesPerPixel (Bpp);
>
> // Set the hardware to the new mode
> Status = LcdSetMode (ModeNumber);
> - if (EFI_ERROR(Status)) {
> + if (EFI_ERROR (Status)) {
> Status = EFI_DEVICE_ERROR;
> goto EXIT;
> }
>
> - // The UEFI spec requires that we now clear the visible portions of the output display to black.
> + // The UEFI spec requires that we now clear the visible portions of the
> + // output display to black.
>
> // Set the fill colour to black
> SetMem (&FillColour, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
> @@ -361,7 +374,8 @@ LcdGraphicsSetMode (
> 0,
> This->Mode->Info->HorizontalResolution,
> This->Mode->Info->VerticalResolution,
> - 0);
> + 0
> + );
>
> EXIT:
> return Status;
> @@ -372,7 +386,7 @@ GetBytesPerPixel (
> IN LCD_BPP Bpp
> )
> {
> - switch(Bpp) {
> + switch (Bpp) {
> case LCD_BITS_PER_PIXEL_24:
> return 4;
>
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> index b5e113b844d4e4df2e35ccd880c01344b4b8b9d7..0b0c4204fbc44bc9e90dce3d7b410ce167d9f40c 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> @@ -1,6 +1,6 @@
> /** @file PL111Lcd.c
>
> - Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> @@ -54,11 +54,11 @@ LcdInitialize (
> )
> {
> // Define start of the VRAM. This never changes for any graphics mode
> - MmioWrite32(PL111_REG_LCD_UP_BASE, (UINT32) VramBaseAddress);
> - MmioWrite32(PL111_REG_LCD_LP_BASE, 0); // We are not using a double buffer
> + MmioWrite32 (PL111_REG_LCD_UP_BASE, (UINT32)VramBaseAddress);
> + MmioWrite32 (PL111_REG_LCD_LP_BASE, 0); // We are not using a double buffer
>
> // Disable all interrupts from the PL111
> - MmioWrite32(PL111_REG_LCD_IMSC, 0);
> + MmioWrite32 (PL111_REG_LCD_IMSC, 0);
>
> return EFI_SUCCESS;
> }
> @@ -81,37 +81,55 @@ LcdSetMode (
> LCD_BPP LcdBpp;
>
> // Set the video mode timings and other relevant information
> - Status = LcdPlatformGetTimings (ModeNumber,
> - &HRes,&HSync,&HBackPorch,&HFrontPorch,
> - &VRes,&VSync,&VBackPorch,&VFrontPorch);
> + Status = LcdPlatformGetTimings (
> + ModeNumber,
> + &HRes,
> + &HSync,
> + &HBackPorch,
> + &HFrontPorch,
> + &VRes,
> + &VSync,
> + &VBackPorch,
> + &VFrontPorch
> + );
> ASSERT_EFI_ERROR (Status);
> - if (EFI_ERROR( Status )) {
> + if (EFI_ERROR (Status)) {
> return EFI_DEVICE_ERROR;
> }
>
> - Status = LcdPlatformGetBpp (ModeNumber,&LcdBpp);
> + Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> ASSERT_EFI_ERROR (Status);
> - if (EFI_ERROR( Status )) {
> + if (EFI_ERROR (Status)) {
> return EFI_DEVICE_ERROR;
> }
>
> // Disable the CLCD_LcdEn bit
> - LcdControl = MmioRead32( PL111_REG_LCD_CONTROL);
> - MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl & ~1);
> + LcdControl = MmioRead32 (PL111_REG_LCD_CONTROL);
> + MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl & ~1);
>
> // Set Timings
> - MmioWrite32 (PL111_REG_LCD_TIMING_0, HOR_AXIS_PANEL(HBackPorch, HFrontPorch, HSync, HRes));
> - MmioWrite32 (PL111_REG_LCD_TIMING_1, VER_AXIS_PANEL(VBackPorch, VFrontPorch, VSync, VRes));
> - MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY(HRes));
> + MmioWrite32 (
> + PL111_REG_LCD_TIMING_0,
> + HOR_AXIS_PANEL (HBackPorch, HFrontPorch, HSync, HRes)
> + );
> +
> + MmioWrite32 (
> + PL111_REG_LCD_TIMING_1,
> + VER_AXIS_PANEL (VBackPorch, VFrontPorch, VSync, VRes)
> + );
> +
> + MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY (HRes));
> MmioWrite32 (PL111_REG_LCD_TIMING_3, 0);
>
> // PL111_REG_LCD_CONTROL
> - LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP(LcdBpp) | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> - MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);
> + LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp)
> + | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
No additional indentation of continuation line.
> +
And this extra blank line makes this operation (PL111_REG_LCD_CONTROL)
look different than the subsequent (Turn on power to the LCD Panel).
/
Leif
> + MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
>
> // Turn on power to the LCD Panel
> LcdControl |= PL111_CTRL_LCD_PWR;
> - MmioWrite32(PL111_REG_LCD_CONTROL, LcdControl);
> + MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
>
> return EFI_SUCCESS;
> }
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 02/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Added comments
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
2017-09-26 20:15 ` [PATCH 01/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Coding standard evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-12 19:02 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const qualifier evan.lloyd
` (16 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
There is no functional modification in this change
As preparation for a Change (Rejig of LcdGraphicsOutPutDxe), some
comments are modified and a few new comments are added.
This is to prevent mixing formatting changes with functional
changes.
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>
---
ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 80 +++++++++++++++-----
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 63 ++++++++++++++-
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 68 ++++++++++++++++-
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 20 +++++
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c | 4 +-
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 22 +++++-
6 files changed, 231 insertions(+), 26 deletions(-)
diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
index 72ebcd02ddb321ee0dad51c87ac8ee876d9ca21c..48bdd8a51411137df040aa797fcff272785f7a35 100644
--- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
+++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
@@ -18,9 +18,7 @@
#define LCD_VRAM_SIZE SIZE_8MB
-//
// Modes definitions
-//
#define VGA 0
#define SVGA 1
#define XGA 2
@@ -29,9 +27,7 @@
#define UXGA 5
#define HD 6
-//
// VGA Mode: 640 x 480
-//
#define VGA_H_RES_PIXELS 640
#define VGA_V_RES_PIXELS 480
#define VGA_OSC_FREQUENCY 23750000 /* 0x016A6570 */
@@ -44,9 +40,7 @@
#define VGA_V_FRONT_PORCH ( 3 - 1)
#define VGA_V_BACK_PORCH ( 13 - 1)
-//
// SVGA Mode: 800 x 600
-//
#define SVGA_H_RES_PIXELS 800
#define SVGA_V_RES_PIXELS 600
#define SVGA_OSC_FREQUENCY 38250000 /* 0x0247A610 */
@@ -59,9 +53,7 @@
#define SVGA_V_FRONT_PORCH ( 3 - 1)
#define SVGA_V_BACK_PORCH ( 17 - 1)
-//
// XGA Mode: 1024 x 768
-//
#define XGA_H_RES_PIXELS 1024
#define XGA_V_RES_PIXELS 768
#define XGA_OSC_FREQUENCY 63500000 /* 0x03C8EEE0 */
@@ -74,9 +66,7 @@
#define XGA_V_FRONT_PORCH ( 3 - 1)
#define XGA_V_BACK_PORCH ( 23 - 1)
-//
// SXGA Mode: 1280 x 1024
-//
#define SXGA_H_RES_PIXELS 1280
#define SXGA_V_RES_PIXELS 1024
#define SXGA_OSC_FREQUENCY 109000000 /* 0x067F3540 */
@@ -89,9 +79,7 @@
#define SXGA_V_FRONT_PORCH ( 3 - 1)
#define SXGA_V_BACK_PORCH ( 29 - 1)
-//
// WSXGA+ Mode: 1680 x 1050
-//
#define WSXGA_H_RES_PIXELS 1680
#define WSXGA_V_RES_PIXELS 1050
#define WSXGA_OSC_FREQUENCY 147000000 /* 0x08C30AC0 */
@@ -104,9 +92,7 @@
#define WSXGA_V_FRONT_PORCH ( 4 - 1)
#define WSXGA_V_BACK_PORCH ( 41 - 1)
-//
// UXGA Mode: 1600 x 1200
-//
#define UXGA_H_RES_PIXELS 1600
#define UXGA_V_RES_PIXELS 1200
#define UXGA_OSC_FREQUENCY 161000000 /* 0x0998AA40 */
@@ -119,9 +105,7 @@
#define UXGA_V_FRONT_PORCH ( 3 - 1)
#define UXGA_V_BACK_PORCH ( 38 - 1)
-//
// HD Mode: 1920 x 1080
-//
#define HD_H_RES_PIXELS 1920
#define HD_V_RES_PIXELS 1080
#define HD_OSC_FREQUENCY 165000000 /* 0x09D5B340 */
@@ -134,10 +118,7 @@
#define HD_V_FRONT_PORCH ( 3 - 1)
#define HD_V_BACK_PORCH ( 32 - 1)
-//
// Colour Masks
-//
-
#define LCD_24BPP_RED_MASK 0x00FF0000
#define LCD_24BPP_GREEN_MASK 0x0000FF00
#define LCD_24BPP_BLUE_MASK 0x000000FF
@@ -171,34 +152,85 @@ typedef enum {
LCD_BITS_PER_PIXEL_12_444
} LCD_BPP;
-
+/** Platform related initialization function.
+ *
+ * @param IN Handle Handle to the LCD device instance.
+ *
+ * @retval EFI_SUCCESS Platform initialization success.
+ * @retval !(EFI_SUCCESS) Other errors.
+**/
EFI_STATUS
LcdPlatformInitializeDisplay (
IN EFI_HANDLE Handle
);
+/** Reserve VRAM memory in DRAM for the frame buffer
+ * (unless it is reserved already).
+ *
+ * The allocated address can be used to set the frame buffer.
+ * @param OUT VramBaseAddress A pointer to the frame buffer address.
+ * @param OUT VramSize A pointer to the size of the frame
+ * buffer in bytes
+ *
+ * @retval EFI_SUCCESS Frame buffer memory allocation success.
+ * @retval !(EFI_SUCCESS) Other errors.
+**/
EFI_STATUS
LcdPlatformGetVram (
OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
OUT UINTN* VramSize
);
+/** Return total number of modes.
+ *
+ * @retval UINT32 Mode Number.
+**/
UINT32
LcdPlatformGetMaxMode (
VOID
);
+/** Set the requested display mode.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @retval EFI_SUCCESS Set mode success.
+ * @retval EFI_INVALID_PARAMTER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformSetMode (
IN UINT32 ModeNumber
);
+/** Return information for the requested mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT Info Pointer for returned mode information
+ * (on success).
+ *
+ * @retval EFI_SUCCESS Success if the requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformQueryMode (
IN UINT32 ModeNumber,
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
);
+/** Returns the display timing information for the requested mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT HRes Pointer to horizontal resolution.
+ * @param OUT HSync Pointer to horizontal sync width.
+ * @param OUT HBackPorch Pointer to horizontal back porch.
+ * @param OUT HFrontPorch Pointer to horizontal front porch.
+ * @param OUT VRes Pointer to vertical resolution.
+ * @param OUT VSync Pointer to vertical sync width.
+ * @param OUT VBackPorch Pointer to vertical back porch.
+ * @param OUT VFrontPorch Pointer to vertical front porch.
+
+ * @retval EFI_SUCCESS Success if the requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformGetTimings (
IN UINT32 ModeNumber,
@@ -212,6 +244,14 @@ LcdPlatformGetTimings (
OUT UINT32* VFrontPorch
);
+/** Return bits per pixel information for a mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT Bpp Pointer to value Bytes Per Pixel.
+ *
+ * @retval EFI_SUCCESS The requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformGetBpp (
IN UINT32 ModeNumber,
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index 2041de5f63c72de6f0ce4047420c282507a1d04a..cfe3259d3c737de240350e8c3eab867b80c40948 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -44,7 +44,8 @@ typedef struct {
UINT32 VFrontPorch;
} LCD_RESOLUTION;
-
+/** The display modes supported by the platform.
+**/
LCD_RESOLUTION mResolutions[] = {
{ // Mode 0 : VGA : 640 x 480 x 24 bpp
VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
@@ -94,6 +95,11 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
NULL
};
+/** HDLCD Platform specific initialization function.
+ *
+ * @retval EFI_SUCCESS Plaform library initialization success.
+ * @retval !(EFI_SUCCESS) Other errors.
+**/
EFI_STATUS
LcdPlatformInitializeDisplay (
IN EFI_HANDLE Handle
@@ -124,6 +130,18 @@ LcdPlatformInitializeDisplay (
return Status;
}
+/** Reserve VRAM memory in DRAM for the frame buffer
+ * (unless it is reserved already).
+ *
+ * The allocated address can be used to set the frame buffer.
+ *
+ * @param OUT VramBaseAddress A pointer to the frame buffer address.
+ * @param OUT VramSize A pointer to the size of the frame
+ * buffer in bytes
+ *
+ * @retval EFI_SUCCESS Frame buffer memory allocation success.
+ * @retval !(EFI_SUCCESS) Other errors.
+**/
EFI_STATUS
LcdPlatformGetVram (
OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
@@ -170,6 +188,13 @@ LcdPlatformGetVram (
return EFI_SUCCESS;
}
+/** Return total number of modes supported.
+ *
+ * Note: Valid mode numbers are 0 to MaxMode - 1
+ * See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan 2017)
+ *
+ * @retval UINT32 Mode Number.
+**/
UINT32
LcdPlatformGetMaxMode(VOID)
{
@@ -178,6 +203,10 @@ LcdPlatformGetMaxMode(VOID)
return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
}
+/** Set the requested display mode.
+ *
+ * @param IN ModeNumber Mode Number.
+**/
EFI_STATUS
LcdPlatformSetMode (
IN UINT32 ModeNumber
@@ -227,6 +256,15 @@ LcdPlatformSetMode (
return Status;
}
+/** Return information for the requested mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT Info Pointer for returned mode information
+ * (on success).
+ *
+ * @retval EFI_SUCCESS Success if the requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformQueryMode (
IN UINT32 ModeNumber,
@@ -267,6 +305,21 @@ LcdPlatformQueryMode (
return EFI_SUCCESS;
}
+/** Returns the display timing information for the requested mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT HRes Pointer to horizontal resolution.
+ * @param OUT HSync Pointer to horizontal sync width.
+ * @param OUT HBackPorch Pointer to horizontal back porch.
+ * @param OUT HFrontPorch Pointer to horizontal front porch.
+ * @param OUT VRes Pointer to vertical resolution.
+ * @param OUT VSync Pointer to vertical sync width.
+ * @param OUT VBackPorch Pointer to vertical back porch.
+ * @param OUT VFrontPorch Pointer to vertical front porch.
+ *
+ * @retval EFI_SUCCESS Success if the requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformGetTimings (
IN UINT32 ModeNumber,
@@ -296,6 +349,14 @@ LcdPlatformGetTimings (
return EFI_SUCCESS;
}
+/** Return bits per pixel for a mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT Bpp Pointer to value Bits Per Pixel.
+ *
+ * @retval EFI_SUCCESS The requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformGetBpp (
IN UINT32 ModeNumber,
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 8d046816454f642bced00e29c4e02093b74afd24..84880e5fd1dfe6f824b27e53926f9bb32ff6cdf7 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -41,7 +41,8 @@ typedef struct {
UINT32 VFrontPorch;
} LCD_RESOLUTION;
-
+/** The display modes supported by the platform.
+**/
LCD_RESOLUTION mResolutions[] = {
{ // Mode 0 : VGA : 640 x 480 x 24 bpp
VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
@@ -151,7 +152,11 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
NULL
};
-
+/** PL111 Platform specific initialization function.
+ *
+ * @retval EFI_SUCCESS Plaform library initialization success.
+ * @retval !(EFI_SUCCESS) Other errors.
+**/
EFI_STATUS
LcdPlatformInitializeDisplay (
IN EFI_HANDLE Handle
@@ -176,6 +181,18 @@ LcdPlatformInitializeDisplay (
return Status;
}
+/** Reserve VRAM memory in DRAM for the frame buffer
+ * (unless it is reserved already).
+ *
+ * The allocated address can be used to set the frame buffer.
+ *
+ * @param OUT VramBaseAddress A pointer to the frame buffer address.
+ * @param OUT VramSize A pointer to the size of the frame
+ * buffer in bytes
+ *
+ * @retval EFI_SUCCESS Frame buffer memory allocation success.
+ * @retval !(EFI_SUCCESS) Other errors.
+**/
EFI_STATUS
LcdPlatformGetVram (
OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
@@ -232,6 +249,13 @@ LcdPlatformGetVram (
return Status;
}
+/** Return total number of modes supported.
+ *
+ * Note: Valid mode numbers are 0 to MaxMode - 1
+ * See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan 2017)
+ *
+ * @retval UINT32 Mode Number.
+**/
UINT32
LcdPlatformGetMaxMode(VOID)
{
@@ -249,6 +273,14 @@ LcdPlatformGetMaxMode(VOID)
return (PcdGet32 (PcdPL111LcdMaxMode));
}
+/** Set the requested display mode.
+ *
+ * @param IN ModeNumber Mode Number.
+ *
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+ * @retval EFI_UNSUPPORTED PLL111 configuration not supported.
+ * @retval !(EFI_SUCCESS) Other errors.
+**/
EFI_STATUS
LcdPlatformSetMode (
IN UINT32 ModeNumber
@@ -320,6 +352,15 @@ LcdPlatformSetMode (
return Status;
}
+/** Return information for the requested mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT Info Pointer for returned mode information
+ * (on success).
+ *
+ * @retval EFI_SUCCESS Success if the requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformQueryMode (
IN UINT32 ModeNumber,
@@ -360,6 +401,21 @@ LcdPlatformQueryMode (
return EFI_SUCCESS;
}
+/** Returns the display timing information for the requested mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT HRes Pointer to horizontal resolution.
+ * @param OUT HSync Pointer to horizontal sync width.
+ * @param OUT HBackPorch Pointer to horizontal back porch.
+ * @param OUT HFrontPorch Pointer to horizontal front porch.
+ * @param OUT VRes Pointer to vertical resolution.
+ * @param OUT VSync Pointer to vertical sync width.
+ * @param OUT VBackPorch Pointer to vertical back porch.
+ * @param OUT VFrontPorch Pointer to vertical front porch.
+ *
+ * @retval EFI_SUCCESS Success if the requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformGetTimings (
IN UINT32 ModeNumber,
@@ -389,6 +445,14 @@ LcdPlatformGetTimings (
return EFI_SUCCESS;
}
+/** Return bits per pixel for a mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT Bpp Pointer to value Bits Per Pixel.
+ *
+ * @retval EFI_SUCCESS The requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
EFI_STATUS
LcdPlatformGetBpp (
IN UINT32 ModeNumber,
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
index eb0b6fb3fbbc1cb605469433f6c6dcb85bac668c..744dd3d556b5071defc6bcad5a9a30881bcb4b6f 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
@@ -29,6 +29,12 @@
*
**********************************************************************/
+/** Initialize display.
+ *
+ * @param VramBaseAddress Address of the frame buffer.
+ *
+ * @retval EFI_SUCCESS Display initialization success.
+**/
EFI_STATUS
LcdInitialize (
IN EFI_PHYSICAL_ADDRESS VramBaseAddress
@@ -67,6 +73,12 @@ LcdInitialize (
return EFI_SUCCESS;
}
+/** Set requested mode of the display.
+ *
+ * @param ModeNumber Display mode number.
+ * @retval EFI_SUCCESS Display set mode success.
+ * @retval EFI_DEVICE_ERROR If mode not found/supported.
+**/
EFI_STATUS
LcdSetMode (
IN UINT32 ModeNumber
@@ -136,6 +148,8 @@ LcdSetMode (
return EFI_SUCCESS;
}
+/** De-initializes the display.
+**/
VOID
LcdShutdown (
VOID
@@ -145,6 +159,12 @@ LcdShutdown (
MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
}
+/** Check for presence of HDLCD.
+ *
+ * @retval EFI_SUCCESS Platform implements HDLCD.
+ * @retval EFI_NOT_FOUND HDLCD display controller not
+ * found.
+**/
EFI_STATUS
LcdIdentify (
VOID
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
index 2dd8f39873f77b1c211bff407cabe90c1795b121..c40c8e0fa6f4b5f7798aeb3c8bf3f261f14cb67b 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
@@ -357,8 +357,8 @@ LcdGraphicsSetMode (
goto EXIT;
}
- // The UEFI spec requires that we now clear the visible portions of the
- // output display to black.
+ /* The UEFI spec requires that we now clear the visible portions of the
+ * output display to black. */
// Set the fill colour to black
SetMem (&FillColour, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
index 0b0c4204fbc44bc9e90dce3d7b410ce167d9f40c..f8a3c1f8266c0a11f111c3747688defc0d49877c 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
@@ -26,6 +26,12 @@
*
**********************************************************************/
+/** Check for presence of PL111.
+ *
+ * @retval EFI_SUCCESS Platform implements PL111.
+ * @retval EFI_NOT_FOUND PL111 display controller not
+ * found.
+**/
EFI_STATUS
LcdIdentify (
VOID
@@ -48,6 +54,12 @@ LcdIdentify (
return EFI_NOT_FOUND;
}
+/** Initialize display.
+ *
+ * @param VramBaseAddress Address of the frame buffer.
+ *
+ * @retval EFI_SUCCESS Display initialization success.
+**/
EFI_STATUS
LcdInitialize (
IN EFI_PHYSICAL_ADDRESS VramBaseAddress
@@ -63,6 +75,12 @@ LcdInitialize (
return EFI_SUCCESS;
}
+/** Set requested mode of the display.
+ *
+ * @param ModeNumber Display mode number.
+ * @retval EFI_SUCCESS Display set mode success.
+ * @retval EFI_DEVICE_ERROR If mode not found/supported.
+**/
EFI_STATUS
LcdSetMode (
IN UINT32 ModeNumber
@@ -123,7 +141,7 @@ LcdSetMode (
// PL111_REG_LCD_CONTROL
LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp)
- | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
+ | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
@@ -134,6 +152,8 @@ LcdSetMode (
return EFI_SUCCESS;
}
+/** De-initializes the display.
+*/
VOID
LcdShutdown (
VOID
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 02/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Added comments
2017-09-26 20:15 ` [PATCH 02/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Added comments evan.lloyd
@ 2017-10-12 19:02 ` Leif Lindholm
2017-12-05 18:55 ` Evan Lloyd
0 siblings, 1 reply; 69+ messages in thread
From: Leif Lindholm @ 2017-10-12 19:02 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
Given that all changes to the first file _remove_ comments, it may be
better with a subject line saying "updating comments".
On Tue, Sep 26, 2017 at 09:15:12PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> There is no functional modification in this change
> As preparation for a Change (Rejig of LcdGraphicsOutPutDxe), some
> comments are modified and a few new comments are added.
> This is to prevent mixing formatting changes with functional
> changes.
>
> 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>
> ---
> ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 80 +++++++++++++++-----
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 63 ++++++++++++++-
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 68 ++++++++++++++++-
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 20 +++++
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c | 4 +-
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 22 +++++-
> 6 files changed, 231 insertions(+), 26 deletions(-)
>
> diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> index 72ebcd02ddb321ee0dad51c87ac8ee876d9ca21c..48bdd8a51411137df040aa797fcff272785f7a35 100644
> --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> @@ -18,9 +18,7 @@
Is this where one of the stray copyright updates from 1/19 should go?
>
> #define LCD_VRAM_SIZE SIZE_8MB
>
> -//
> // Modes definitions
> -//
> #define VGA 0
> #define SVGA 1
> #define XGA 2
> @@ -29,9 +27,7 @@
> #define UXGA 5
> #define HD 6
>
> -//
> // VGA Mode: 640 x 480
> -//
> #define VGA_H_RES_PIXELS 640
> #define VGA_V_RES_PIXELS 480
> #define VGA_OSC_FREQUENCY 23750000 /* 0x016A6570 */
> @@ -44,9 +40,7 @@
> #define VGA_V_FRONT_PORCH ( 3 - 1)
> #define VGA_V_BACK_PORCH ( 13 - 1)
>
> -//
> // SVGA Mode: 800 x 600
> -//
> #define SVGA_H_RES_PIXELS 800
> #define SVGA_V_RES_PIXELS 600
> #define SVGA_OSC_FREQUENCY 38250000 /* 0x0247A610 */
> @@ -59,9 +53,7 @@
> #define SVGA_V_FRONT_PORCH ( 3 - 1)
> #define SVGA_V_BACK_PORCH ( 17 - 1)
>
> -//
> // XGA Mode: 1024 x 768
> -//
> #define XGA_H_RES_PIXELS 1024
> #define XGA_V_RES_PIXELS 768
> #define XGA_OSC_FREQUENCY 63500000 /* 0x03C8EEE0 */
> @@ -74,9 +66,7 @@
> #define XGA_V_FRONT_PORCH ( 3 - 1)
> #define XGA_V_BACK_PORCH ( 23 - 1)
>
> -//
> // SXGA Mode: 1280 x 1024
> -//
> #define SXGA_H_RES_PIXELS 1280
> #define SXGA_V_RES_PIXELS 1024
> #define SXGA_OSC_FREQUENCY 109000000 /* 0x067F3540 */
> @@ -89,9 +79,7 @@
> #define SXGA_V_FRONT_PORCH ( 3 - 1)
> #define SXGA_V_BACK_PORCH ( 29 - 1)
>
> -//
> // WSXGA+ Mode: 1680 x 1050
> -//
> #define WSXGA_H_RES_PIXELS 1680
> #define WSXGA_V_RES_PIXELS 1050
> #define WSXGA_OSC_FREQUENCY 147000000 /* 0x08C30AC0 */
> @@ -104,9 +92,7 @@
> #define WSXGA_V_FRONT_PORCH ( 4 - 1)
> #define WSXGA_V_BACK_PORCH ( 41 - 1)
>
> -//
> // UXGA Mode: 1600 x 1200
> -//
> #define UXGA_H_RES_PIXELS 1600
> #define UXGA_V_RES_PIXELS 1200
> #define UXGA_OSC_FREQUENCY 161000000 /* 0x0998AA40 */
> @@ -119,9 +105,7 @@
> #define UXGA_V_FRONT_PORCH ( 3 - 1)
> #define UXGA_V_BACK_PORCH ( 38 - 1)
>
> -//
> // HD Mode: 1920 x 1080
> -//
> #define HD_H_RES_PIXELS 1920
> #define HD_V_RES_PIXELS 1080
> #define HD_OSC_FREQUENCY 165000000 /* 0x09D5B340 */
> @@ -134,10 +118,7 @@
> #define HD_V_FRONT_PORCH ( 3 - 1)
> #define HD_V_BACK_PORCH ( 32 - 1)
>
> -//
> // Colour Masks
> -//
> -
> #define LCD_24BPP_RED_MASK 0x00FF0000
> #define LCD_24BPP_GREEN_MASK 0x0000FF00
> #define LCD_24BPP_BLUE_MASK 0x000000FF
> @@ -171,34 +152,85 @@ typedef enum {
> LCD_BITS_PER_PIXEL_12_444
> } LCD_BPP;
>
> -
> +/** Platform related initialization function.
> + *
> + * @param IN Handle Handle to the LCD device instance.
> + *
> + * @retval EFI_SUCCESS Platform initialization success.
> + * @retval !(EFI_SUCCESS) Other errors.
> +**/
So ... 6.8 lists
/**
text
**/
as the
The format
/**
* text
**/
is mentioned as "also legal because doxygen ignores the leading *".
The format
/**
*
**/
is never mentioned, although I guess "also legal" because * ignored.
However, a quick skim in MdePkg suggests the former is the generally
used variant. Can you please update to that format throughout (drop
the leading '*' on lines not starting or ending the comment block)?
No other comments (other than having these prototype documentations
are a great improvement).
/
Leif
> EFI_STATUS
> LcdPlatformInitializeDisplay (
> IN EFI_HANDLE Handle
> );
>
> +/** Reserve VRAM memory in DRAM for the frame buffer
> + * (unless it is reserved already).
> + *
> + * The allocated address can be used to set the frame buffer.
> + * @param OUT VramBaseAddress A pointer to the frame buffer address.
> + * @param OUT VramSize A pointer to the size of the frame
> + * buffer in bytes
> + *
> + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> + * @retval !(EFI_SUCCESS) Other errors.
> +**/
> EFI_STATUS
> LcdPlatformGetVram (
> OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> OUT UINTN* VramSize
> );
>
> +/** Return total number of modes.
> + *
> + * @retval UINT32 Mode Number.
> +**/
> UINT32
> LcdPlatformGetMaxMode (
> VOID
> );
>
> +/** Set the requested display mode.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @retval EFI_SUCCESS Set mode success.
> + * @retval EFI_INVALID_PARAMTER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformSetMode (
> IN UINT32 ModeNumber
> );
>
> +/** Return information for the requested mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Info Pointer for returned mode information
> + * (on success).
> + *
> + * @retval EFI_SUCCESS Success if the requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformQueryMode (
> IN UINT32 ModeNumber,
> OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
> );
>
> +/** Returns the display timing information for the requested mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT HRes Pointer to horizontal resolution.
> + * @param OUT HSync Pointer to horizontal sync width.
> + * @param OUT HBackPorch Pointer to horizontal back porch.
> + * @param OUT HFrontPorch Pointer to horizontal front porch.
> + * @param OUT VRes Pointer to vertical resolution.
> + * @param OUT VSync Pointer to vertical sync width.
> + * @param OUT VBackPorch Pointer to vertical back porch.
> + * @param OUT VFrontPorch Pointer to vertical front porch.
> +
> + * @retval EFI_SUCCESS Success if the requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformGetTimings (
> IN UINT32 ModeNumber,
> @@ -212,6 +244,14 @@ LcdPlatformGetTimings (
> OUT UINT32* VFrontPorch
> );
>
> +/** Return bits per pixel information for a mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Bpp Pointer to value Bytes Per Pixel.
> + *
> + * @retval EFI_SUCCESS The requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformGetBpp (
> IN UINT32 ModeNumber,
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index 2041de5f63c72de6f0ce4047420c282507a1d04a..cfe3259d3c737de240350e8c3eab867b80c40948 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -44,7 +44,8 @@ typedef struct {
> UINT32 VFrontPorch;
> } LCD_RESOLUTION;
>
> -
> +/** The display modes supported by the platform.
> +**/
> LCD_RESOLUTION mResolutions[] = {
> { // Mode 0 : VGA : 640 x 480 x 24 bpp
> VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> @@ -94,6 +95,11 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
> NULL
> };
>
> +/** HDLCD Platform specific initialization function.
> + *
> + * @retval EFI_SUCCESS Plaform library initialization success.
> + * @retval !(EFI_SUCCESS) Other errors.
> +**/
> EFI_STATUS
> LcdPlatformInitializeDisplay (
> IN EFI_HANDLE Handle
> @@ -124,6 +130,18 @@ LcdPlatformInitializeDisplay (
> return Status;
> }
>
> +/** Reserve VRAM memory in DRAM for the frame buffer
> + * (unless it is reserved already).
> + *
> + * The allocated address can be used to set the frame buffer.
> + *
> + * @param OUT VramBaseAddress A pointer to the frame buffer address.
> + * @param OUT VramSize A pointer to the size of the frame
> + * buffer in bytes
> + *
> + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> + * @retval !(EFI_SUCCESS) Other errors.
> +**/
> EFI_STATUS
> LcdPlatformGetVram (
> OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> @@ -170,6 +188,13 @@ LcdPlatformGetVram (
> return EFI_SUCCESS;
> }
>
> +/** Return total number of modes supported.
> + *
> + * Note: Valid mode numbers are 0 to MaxMode - 1
> + * See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan 2017)
> + *
> + * @retval UINT32 Mode Number.
> +**/
> UINT32
> LcdPlatformGetMaxMode(VOID)
> {
> @@ -178,6 +203,10 @@ LcdPlatformGetMaxMode(VOID)
> return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
> }
>
> +/** Set the requested display mode.
> + *
> + * @param IN ModeNumber Mode Number.
> +**/
> EFI_STATUS
> LcdPlatformSetMode (
> IN UINT32 ModeNumber
> @@ -227,6 +256,15 @@ LcdPlatformSetMode (
> return Status;
> }
>
> +/** Return information for the requested mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Info Pointer for returned mode information
> + * (on success).
> + *
> + * @retval EFI_SUCCESS Success if the requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformQueryMode (
> IN UINT32 ModeNumber,
> @@ -267,6 +305,21 @@ LcdPlatformQueryMode (
> return EFI_SUCCESS;
> }
>
> +/** Returns the display timing information for the requested mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT HRes Pointer to horizontal resolution.
> + * @param OUT HSync Pointer to horizontal sync width.
> + * @param OUT HBackPorch Pointer to horizontal back porch.
> + * @param OUT HFrontPorch Pointer to horizontal front porch.
> + * @param OUT VRes Pointer to vertical resolution.
> + * @param OUT VSync Pointer to vertical sync width.
> + * @param OUT VBackPorch Pointer to vertical back porch.
> + * @param OUT VFrontPorch Pointer to vertical front porch.
> + *
> + * @retval EFI_SUCCESS Success if the requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformGetTimings (
> IN UINT32 ModeNumber,
> @@ -296,6 +349,14 @@ LcdPlatformGetTimings (
> return EFI_SUCCESS;
> }
>
> +/** Return bits per pixel for a mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Bpp Pointer to value Bits Per Pixel.
> + *
> + * @retval EFI_SUCCESS The requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformGetBpp (
> IN UINT32 ModeNumber,
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 8d046816454f642bced00e29c4e02093b74afd24..84880e5fd1dfe6f824b27e53926f9bb32ff6cdf7 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -41,7 +41,8 @@ typedef struct {
> UINT32 VFrontPorch;
> } LCD_RESOLUTION;
>
> -
> +/** The display modes supported by the platform.
> +**/
> LCD_RESOLUTION mResolutions[] = {
> { // Mode 0 : VGA : 640 x 480 x 24 bpp
> VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> @@ -151,7 +152,11 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
> NULL
> };
>
> -
> +/** PL111 Platform specific initialization function.
> + *
> + * @retval EFI_SUCCESS Plaform library initialization success.
> + * @retval !(EFI_SUCCESS) Other errors.
> +**/
> EFI_STATUS
> LcdPlatformInitializeDisplay (
> IN EFI_HANDLE Handle
> @@ -176,6 +181,18 @@ LcdPlatformInitializeDisplay (
> return Status;
> }
>
> +/** Reserve VRAM memory in DRAM for the frame buffer
> + * (unless it is reserved already).
> + *
> + * The allocated address can be used to set the frame buffer.
> + *
> + * @param OUT VramBaseAddress A pointer to the frame buffer address.
> + * @param OUT VramSize A pointer to the size of the frame
> + * buffer in bytes
> + *
> + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> + * @retval !(EFI_SUCCESS) Other errors.
> +**/
> EFI_STATUS
> LcdPlatformGetVram (
> OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> @@ -232,6 +249,13 @@ LcdPlatformGetVram (
> return Status;
> }
>
> +/** Return total number of modes supported.
> + *
> + * Note: Valid mode numbers are 0 to MaxMode - 1
> + * See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan 2017)
> + *
> + * @retval UINT32 Mode Number.
> +**/
> UINT32
> LcdPlatformGetMaxMode(VOID)
> {
> @@ -249,6 +273,14 @@ LcdPlatformGetMaxMode(VOID)
> return (PcdGet32 (PcdPL111LcdMaxMode));
> }
>
> +/** Set the requested display mode.
> + *
> + * @param IN ModeNumber Mode Number.
> + *
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_UNSUPPORTED PLL111 configuration not supported.
> + * @retval !(EFI_SUCCESS) Other errors.
> +**/
> EFI_STATUS
> LcdPlatformSetMode (
> IN UINT32 ModeNumber
> @@ -320,6 +352,15 @@ LcdPlatformSetMode (
> return Status;
> }
>
> +/** Return information for the requested mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Info Pointer for returned mode information
> + * (on success).
> + *
> + * @retval EFI_SUCCESS Success if the requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformQueryMode (
> IN UINT32 ModeNumber,
> @@ -360,6 +401,21 @@ LcdPlatformQueryMode (
> return EFI_SUCCESS;
> }
>
> +/** Returns the display timing information for the requested mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT HRes Pointer to horizontal resolution.
> + * @param OUT HSync Pointer to horizontal sync width.
> + * @param OUT HBackPorch Pointer to horizontal back porch.
> + * @param OUT HFrontPorch Pointer to horizontal front porch.
> + * @param OUT VRes Pointer to vertical resolution.
> + * @param OUT VSync Pointer to vertical sync width.
> + * @param OUT VBackPorch Pointer to vertical back porch.
> + * @param OUT VFrontPorch Pointer to vertical front porch.
> + *
> + * @retval EFI_SUCCESS Success if the requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformGetTimings (
> IN UINT32 ModeNumber,
> @@ -389,6 +445,14 @@ LcdPlatformGetTimings (
> return EFI_SUCCESS;
> }
>
> +/** Return bits per pixel for a mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Bpp Pointer to value Bits Per Pixel.
> + *
> + * @retval EFI_SUCCESS The requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> EFI_STATUS
> LcdPlatformGetBpp (
> IN UINT32 ModeNumber,
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> index eb0b6fb3fbbc1cb605469433f6c6dcb85bac668c..744dd3d556b5071defc6bcad5a9a30881bcb4b6f 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> @@ -29,6 +29,12 @@
> *
> **********************************************************************/
>
> +/** Initialize display.
> + *
> + * @param VramBaseAddress Address of the frame buffer.
> + *
> + * @retval EFI_SUCCESS Display initialization success.
> +**/
> EFI_STATUS
> LcdInitialize (
> IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> @@ -67,6 +73,12 @@ LcdInitialize (
> return EFI_SUCCESS;
> }
>
> +/** Set requested mode of the display.
> + *
> + * @param ModeNumber Display mode number.
> + * @retval EFI_SUCCESS Display set mode success.
> + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> +**/
> EFI_STATUS
> LcdSetMode (
> IN UINT32 ModeNumber
> @@ -136,6 +148,8 @@ LcdSetMode (
> return EFI_SUCCESS;
> }
>
> +/** De-initializes the display.
> +**/
> VOID
> LcdShutdown (
> VOID
> @@ -145,6 +159,12 @@ LcdShutdown (
> MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
> }
>
> +/** Check for presence of HDLCD.
> + *
> + * @retval EFI_SUCCESS Platform implements HDLCD.
> + * @retval EFI_NOT_FOUND HDLCD display controller not
> + * found.
> +**/
> EFI_STATUS
> LcdIdentify (
> VOID
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
> index 2dd8f39873f77b1c211bff407cabe90c1795b121..c40c8e0fa6f4b5f7798aeb3c8bf3f261f14cb67b 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
> @@ -357,8 +357,8 @@ LcdGraphicsSetMode (
> goto EXIT;
> }
>
> - // The UEFI spec requires that we now clear the visible portions of the
> - // output display to black.
> + /* The UEFI spec requires that we now clear the visible portions of the
> + * output display to black. */
>
> // Set the fill colour to black
> SetMem (&FillColour, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> index 0b0c4204fbc44bc9e90dce3d7b410ce167d9f40c..f8a3c1f8266c0a11f111c3747688defc0d49877c 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> @@ -26,6 +26,12 @@
> *
> **********************************************************************/
>
> +/** Check for presence of PL111.
> + *
> + * @retval EFI_SUCCESS Platform implements PL111.
> + * @retval EFI_NOT_FOUND PL111 display controller not
> + * found.
> +**/
> EFI_STATUS
> LcdIdentify (
> VOID
> @@ -48,6 +54,12 @@ LcdIdentify (
> return EFI_NOT_FOUND;
> }
>
> +/** Initialize display.
> + *
> + * @param VramBaseAddress Address of the frame buffer.
> + *
> + * @retval EFI_SUCCESS Display initialization success.
> +**/
> EFI_STATUS
> LcdInitialize (
> IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> @@ -63,6 +75,12 @@ LcdInitialize (
> return EFI_SUCCESS;
> }
>
> +/** Set requested mode of the display.
> + *
> + * @param ModeNumber Display mode number.
> + * @retval EFI_SUCCESS Display set mode success.
> + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> +**/
> EFI_STATUS
> LcdSetMode (
> IN UINT32 ModeNumber
> @@ -123,7 +141,7 @@ LcdSetMode (
>
> // PL111_REG_LCD_CONTROL
> LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp)
> - | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> + | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
>
> MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
>
> @@ -134,6 +152,8 @@ LcdSetMode (
> return EFI_SUCCESS;
> }
>
> +/** De-initializes the display.
> +*/
> VOID
> LcdShutdown (
> VOID
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 02/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Added comments
2017-10-12 19:02 ` Leif Lindholm
@ 2017-12-05 18:55 ` Evan Lloyd
2017-12-05 19:58 ` Leif Lindholm
0 siblings, 1 reply; 69+ messages in thread
From: Evan Lloyd @ 2017-12-05 18:55 UTC (permalink / raw)
To: Leif Lindholm; +Cc: edk2-devel@lists.01.org
> -----Original Message-----
> From: Leif Lindholm [mailto:leif.lindholm@linaro.org]
> Sent: 12 October 2017 20:02
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] [PATCH 02/19] ArmPlatformPkg: Tidy
> LcdGraphicsOutputDxe code: Added comments
>
> Given that all changes to the first file _remove_ comments, it may be better
> with a subject line saying "updating comments".
>
> On Tue, Sep 26, 2017 at 09:15:12PM +0100, evan.lloyd@arm.com wrote:
> > From: Girish Pathak <girish.pathak@arm.com>
> >
> > There is no functional modification in this change As preparation for
> > a Change (Rejig of LcdGraphicsOutPutDxe), some comments are modified
> > and a few new comments are added.
> > This is to prevent mixing formatting changes with functional changes.
> >
> > 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>
> > ---
...
> >
> > -
> > +/** Platform related initialization function.
> > + *
> > + * @param IN Handle Handle to the LCD device instance.
> > + *
> > + * @retval EFI_SUCCESS Platform initialization success.
> > + * @retval !(EFI_SUCCESS) Other errors.
> > +**/
>
> So ... 6.8 lists
> /**
> text
> **/
> as the
>
> The format
> /**
> * text
> **/
> is mentioned as "also legal because doxygen ignores the leading *".
>
> The format
> /**
> *
> **/
> is never mentioned, although I guess "also legal" because * ignored.
>
> However, a quick skim in MdePkg suggests the former is the generally used
> variant. Can you please update to that format throughout (drop the leading
> '*' on lines not starting or ending the comment block)?
[[Evan Lloyd]] I'm not sure if Outlook has mangled something, or I'm being obtuse,
but I'm not sure I follow the distinction you are making there.
However, if your objection is to the leading '*' then we can remove it.
By the way - shouldn't it be:
/** Brief description
Details
**/ (see Horor vacuii)
I actually think the CCS is woefully inconsistent in its example comment style, and that although leading '*'s are acceptable to Doxygen, it would be better to stick to one style (that of the file header comment, without leading '*'s) throughout.
>
> No other comments (other than having these prototype documentations
> are a great improvement).
>
> /
> Leif
>
> > EFI_STATUS
> > LcdPlatformInitializeDisplay (
> > IN EFI_HANDLE Handle
> > );
> >
> > +/** Reserve VRAM memory in DRAM for the frame buffer
> > + * (unless it is reserved already).
> > + *
> > + * The allocated address can be used to set the frame buffer.
> > + * @param OUT VramBaseAddress A pointer to the frame buffer
> address.
> > + * @param OUT VramSize A pointer to the size of the frame
> > + * buffer in bytes
> > + *
> > + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> > + * @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > EFI_STATUS
> > LcdPlatformGetVram (
> > OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> > OUT UINTN* VramSize
> > );
> >
> > +/** Return total number of modes.
> > + *
> > + * @retval UINT32 Mode Number.
> > +**/
> > UINT32
> > LcdPlatformGetMaxMode (
> > VOID
> > );
> >
> > +/** Set the requested display mode.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @retval EFI_SUCCESS Set mode success.
> > + * @retval EFI_INVALID_PARAMTER Requested mode not found.
> > +**/
> > EFI_STATUS
> > LcdPlatformSetMode (
> > IN UINT32 ModeNumber
> > );
> >
> > +/** Return information for the requested mode number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT Info Pointer for returned mode information
> > + * (on success).
> > + *
> > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > +**/
> > EFI_STATUS
> > LcdPlatformQueryMode (
> > IN UINT32 ModeNumber,
> > OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
> > );
> >
> > +/** Returns the display timing information for the requested mode
> number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT HRes Pointer to horizontal resolution.
> > + * @param OUT HSync Pointer to horizontal sync width.
> > + * @param OUT HBackPorch Pointer to horizontal back porch.
> > + * @param OUT HFrontPorch Pointer to horizontal front porch.
> > + * @param OUT VRes Pointer to vertical resolution.
> > + * @param OUT VSync Pointer to vertical sync width.
> > + * @param OUT VBackPorch Pointer to vertical back porch.
> > + * @param OUT VFrontPorch Pointer to vertical front porch.
> > +
> > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > +**/
> > EFI_STATUS
> > LcdPlatformGetTimings (
> > IN UINT32 ModeNumber,
> > @@ -212,6 +244,14 @@ LcdPlatformGetTimings (
> > OUT UINT32* VFrontPorch
> > );
> >
> > +/** Return bits per pixel information for a mode number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT Bpp Pointer to value Bytes Per Pixel.
> > + *
> > + * @retval EFI_SUCCESS The requested mode is found.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > +**/
> > EFI_STATUS
> > LcdPlatformGetBpp (
> > IN UINT32 ModeNumber,
> > diff --git
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> ArmVE
> > xpress.c
> >
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> ArmVE
> > xpress.c index
> >
> 2041de5f63c72de6f0ce4047420c282507a1d04a..cfe3259d3c737de240350
> e8c3eab
> > 867b80c40948 100644
> > ---
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> ArmVE
> > xpress.c
> > +++
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> A
> > +++ rmVExpress.c
> > @@ -44,7 +44,8 @@ typedef struct {
> > UINT32 VFrontPorch;
> > } LCD_RESOLUTION;
> >
> > -
> > +/** The display modes supported by the platform.
> > +**/
> > LCD_RESOLUTION mResolutions[] = {
> > { // Mode 0 : VGA : 640 x 480 x 24 bpp
> > VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
> LCD_BITS_PER_PIXEL_24,
> > @@ -94,6 +95,11 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
> > NULL
> > };
> >
> > +/** HDLCD Platform specific initialization function.
> > + *
> > + * @retval EFI_SUCCESS Plaform library initialization success.
> > + * @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > EFI_STATUS
> > LcdPlatformInitializeDisplay (
> > IN EFI_HANDLE Handle
> > @@ -124,6 +130,18 @@ LcdPlatformInitializeDisplay (
> > return Status;
> > }
> >
> > +/** Reserve VRAM memory in DRAM for the frame buffer
> > + * (unless it is reserved already).
> > + *
> > + * The allocated address can be used to set the frame buffer.
> > + *
> > + * @param OUT VramBaseAddress A pointer to the frame buffer
> address.
> > + * @param OUT VramSize A pointer to the size of the frame
> > + * buffer in bytes
> > + *
> > + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> > + * @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > EFI_STATUS
> > LcdPlatformGetVram (
> > OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress, @@ -170,6 +188,13
> @@
> > LcdPlatformGetVram (
> > return EFI_SUCCESS;
> > }
> >
> > +/** Return total number of modes supported.
> > + *
> > + * Note: Valid mode numbers are 0 to MaxMode - 1
> > + * See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan
> > +2017)
> > + *
> > + * @retval UINT32 Mode Number.
> > +**/
> > UINT32
> > LcdPlatformGetMaxMode(VOID)
> > {
> > @@ -178,6 +203,10 @@ LcdPlatformGetMaxMode(VOID)
> > return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION)); }
> >
> > +/** Set the requested display mode.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > +**/
> > EFI_STATUS
> > LcdPlatformSetMode (
> > IN UINT32 ModeNumber
> > @@ -227,6 +256,15 @@ LcdPlatformSetMode (
> > return Status;
> > }
> >
> > +/** Return information for the requested mode number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT Info Pointer for returned mode information
> > + * (on success).
> > + *
> > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > +**/
> > EFI_STATUS
> > LcdPlatformQueryMode (
> > IN UINT32 ModeNumber,
> > @@ -267,6 +305,21 @@ LcdPlatformQueryMode (
> > return EFI_SUCCESS;
> > }
> >
> > +/** Returns the display timing information for the requested mode
> number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT HRes Pointer to horizontal resolution.
> > + * @param OUT HSync Pointer to horizontal sync width.
> > + * @param OUT HBackPorch Pointer to horizontal back porch.
> > + * @param OUT HFrontPorch Pointer to horizontal front porch.
> > + * @param OUT VRes Pointer to vertical resolution.
> > + * @param OUT VSync Pointer to vertical sync width.
> > + * @param OUT VBackPorch Pointer to vertical back porch.
> > + * @param OUT VFrontPorch Pointer to vertical front porch.
> > + *
> > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > +**/
> > EFI_STATUS
> > LcdPlatformGetTimings (
> > IN UINT32 ModeNumber,
> > @@ -296,6 +349,14 @@ LcdPlatformGetTimings (
> > return EFI_SUCCESS;
> > }
> >
> > +/** Return bits per pixel for a mode number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT Bpp Pointer to value Bits Per Pixel.
> > + *
> > + * @retval EFI_SUCCESS The requested mode is found.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > +**/
> > EFI_STATUS
> > LcdPlatformGetBpp (
> > IN UINT32 ModeNumber,
> > diff --git
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> 11Lc
> > dArmVExpress.c
> >
> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> 11Lc
> > dArmVExpress.c index
> >
> 8d046816454f642bced00e29c4e02093b74afd24..84880e5fd1dfe6f824b27
> e53926f
> > 9bb32ff6cdf7 100644
> > ---
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> 11Lc
> > dArmVExpress.c
> > +++
> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> > +++ 11LcdArmVExpress.c
> > @@ -41,7 +41,8 @@ typedef struct {
> > UINT32 VFrontPorch;
> > } LCD_RESOLUTION;
> >
> > -
> > +/** The display modes supported by the platform.
> > +**/
> > LCD_RESOLUTION mResolutions[] = {
> > { // Mode 0 : VGA : 640 x 480 x 24 bpp
> > VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
> LCD_BITS_PER_PIXEL_24,
> > @@ -151,7 +152,11 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
> > NULL
> > };
> >
> > -
> > +/** PL111 Platform specific initialization function.
> > + *
> > + * @retval EFI_SUCCESS Plaform library initialization success.
> > + * @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > EFI_STATUS
> > LcdPlatformInitializeDisplay (
> > IN EFI_HANDLE Handle
> > @@ -176,6 +181,18 @@ LcdPlatformInitializeDisplay (
> > return Status;
> > }
> >
> > +/** Reserve VRAM memory in DRAM for the frame buffer
> > + * (unless it is reserved already).
> > + *
> > + * The allocated address can be used to set the frame buffer.
> > + *
> > + * @param OUT VramBaseAddress A pointer to the frame buffer
> address.
> > + * @param OUT VramSize A pointer to the size of the frame
> > + * buffer in bytes
> > + *
> > + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> > + * @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > EFI_STATUS
> > LcdPlatformGetVram (
> > OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress, @@ -232,6 +249,13
> @@
> > LcdPlatformGetVram (
> > return Status;
> > }
> >
> > +/** Return total number of modes supported.
> > + *
> > + * Note: Valid mode numbers are 0 to MaxMode - 1
> > + * See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan
> > +2017)
> > + *
> > + * @retval UINT32 Mode Number.
> > +**/
> > UINT32
> > LcdPlatformGetMaxMode(VOID)
> > {
> > @@ -249,6 +273,14 @@ LcdPlatformGetMaxMode(VOID)
> > return (PcdGet32 (PcdPL111LcdMaxMode)); }
> >
> > +/** Set the requested display mode.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + *
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > + * @retval EFI_UNSUPPORTED PLL111 configuration not supported.
> > + * @retval !(EFI_SUCCESS) Other errors.
> > +**/
> > EFI_STATUS
> > LcdPlatformSetMode (
> > IN UINT32 ModeNumber
> > @@ -320,6 +352,15 @@ LcdPlatformSetMode (
> > return Status;
> > }
> >
> > +/** Return information for the requested mode number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT Info Pointer for returned mode information
> > + * (on success).
> > + *
> > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > +**/
> > EFI_STATUS
> > LcdPlatformQueryMode (
> > IN UINT32 ModeNumber,
> > @@ -360,6 +401,21 @@ LcdPlatformQueryMode (
> > return EFI_SUCCESS;
> > }
> >
> > +/** Returns the display timing information for the requested mode
> number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT HRes Pointer to horizontal resolution.
> > + * @param OUT HSync Pointer to horizontal sync width.
> > + * @param OUT HBackPorch Pointer to horizontal back porch.
> > + * @param OUT HFrontPorch Pointer to horizontal front porch.
> > + * @param OUT VRes Pointer to vertical resolution.
> > + * @param OUT VSync Pointer to vertical sync width.
> > + * @param OUT VBackPorch Pointer to vertical back porch.
> > + * @param OUT VFrontPorch Pointer to vertical front porch.
> > + *
> > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > +**/
> > EFI_STATUS
> > LcdPlatformGetTimings (
> > IN UINT32 ModeNumber,
> > @@ -389,6 +445,14 @@ LcdPlatformGetTimings (
> > return EFI_SUCCESS;
> > }
> >
> > +/** Return bits per pixel for a mode number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT Bpp Pointer to value Bits Per Pixel.
> > + *
> > + * @retval EFI_SUCCESS The requested mode is found.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > +**/
> > EFI_STATUS
> > LcdPlatformGetBpp (
> > IN UINT32 ModeNumber,
> > diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > index
> >
> eb0b6fb3fbbc1cb605469433f6c6dcb85bac668c..744dd3d556b5071defc6b
> cad5a9a
> > 30881bcb4b6f 100644
> > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > @@ -29,6 +29,12 @@
> > *
> >
> >
> **********************************************************
> ************
> > /
> >
> > +/** Initialize display.
> > + *
> > + * @param VramBaseAddress Address of the frame buffer.
> > + *
> > + * @retval EFI_SUCCESS Display initialization success.
> > +**/
> > EFI_STATUS
> > LcdInitialize (
> > IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> > @@ -67,6 +73,12 @@ LcdInitialize (
> > return EFI_SUCCESS;
> > }
> >
> > +/** Set requested mode of the display.
> > + *
> > + * @param ModeNumber Display mode number.
> > + * @retval EFI_SUCCESS Display set mode success.
> > + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> > +**/
> > EFI_STATUS
> > LcdSetMode (
> > IN UINT32 ModeNumber
> > @@ -136,6 +148,8 @@ LcdSetMode (
> > return EFI_SUCCESS;
> > }
> >
> > +/** De-initializes the display.
> > +**/
> > VOID
> > LcdShutdown (
> > VOID
> > @@ -145,6 +159,12 @@ LcdShutdown (
> > MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE); }
> >
> > +/** Check for presence of HDLCD.
> > + *
> > + * @retval EFI_SUCCESS Platform implements HDLCD.
> > + * @retval EFI_NOT_FOUND HDLCD display controller not
> > + * found.
> > +**/
> > EFI_STATUS
> > LcdIdentify (
> > VOID
> > diff --git
> >
> a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> c
> >
> b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> c
> > index
> >
> 2dd8f39873f77b1c211bff407cabe90c1795b121..c40c8e0fa6f4b5f7798aeb
> 3c8bf3
> > f261f14cb67b 100644
> > ---
> >
> a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> c
> > +++
> b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe
> > +++ .c
> > @@ -357,8 +357,8 @@ LcdGraphicsSetMode (
> > goto EXIT;
> > }
> >
> > - // The UEFI spec requires that we now clear the visible portions of
> > the
> > - // output display to black.
> > + /* The UEFI spec requires that we now clear the visible portions of the
> > + * output display to black. */
> >
> > // Set the fill colour to black
> > SetMem (&FillColour, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
> > diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > index
> >
> 0b0c4204fbc44bc9e90dce3d7b410ce167d9f40c..f8a3c1f8266c0a11f111c3
> 747688
> > defc0d49877c 100644
> > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > @@ -26,6 +26,12 @@
> > *
> >
> >
> **********************************************************
> ************
> > /
> >
> > +/** Check for presence of PL111.
> > + *
> > + * @retval EFI_SUCCESS Platform implements PL111.
> > + * @retval EFI_NOT_FOUND PL111 display controller not
> > + * found.
> > +**/
> > EFI_STATUS
> > LcdIdentify (
> > VOID
> > @@ -48,6 +54,12 @@ LcdIdentify (
> > return EFI_NOT_FOUND;
> > }
> >
> > +/** Initialize display.
> > + *
> > + * @param VramBaseAddress Address of the frame buffer.
> > + *
> > + * @retval EFI_SUCCESS Display initialization success.
> > +**/
> > EFI_STATUS
> > LcdInitialize (
> > IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> > @@ -63,6 +75,12 @@ LcdInitialize (
> > return EFI_SUCCESS;
> > }
> >
> > +/** Set requested mode of the display.
> > + *
> > + * @param ModeNumber Display mode number.
> > + * @retval EFI_SUCCESS Display set mode success.
> > + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> > +**/
> > EFI_STATUS
> > LcdSetMode (
> > IN UINT32 ModeNumber
> > @@ -123,7 +141,7 @@ LcdSetMode (
> >
> > // PL111_REG_LCD_CONTROL
> > LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp)
> > - | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> > + | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> >
> > MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
> >
> > @@ -134,6 +152,8 @@ LcdSetMode (
> > return EFI_SUCCESS;
> > }
> >
> > +/** De-initializes the display.
> > +*/
> > VOID
> > LcdShutdown (
> > VOID
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 02/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Added comments
2017-12-05 18:55 ` Evan Lloyd
@ 2017-12-05 19:58 ` Leif Lindholm
2017-12-05 22:06 ` Evan Lloyd
0 siblings, 1 reply; 69+ messages in thread
From: Leif Lindholm @ 2017-12-05 19:58 UTC (permalink / raw)
To: Evan Lloyd; +Cc: edk2-devel@lists.01.org
On Tue, Dec 05, 2017 at 06:55:25PM +0000, Evan Lloyd wrote:
>
>
> > -----Original Message-----
> > From: Leif Lindholm [mailto:leif.lindholm@linaro.org]
> > Sent: 12 October 2017 20:02
> > To: Evan Lloyd <Evan.Lloyd@arm.com>
> > Cc: edk2-devel@lists.01.org
> > Subject: Re: [edk2] [PATCH 02/19] ArmPlatformPkg: Tidy
> > LcdGraphicsOutputDxe code: Added comments
> >
> > Given that all changes to the first file _remove_ comments, it may be better
> > with a subject line saying "updating comments".
> >
> > On Tue, Sep 26, 2017 at 09:15:12PM +0100, evan.lloyd@arm.com wrote:
> > > From: Girish Pathak <girish.pathak@arm.com>
> > >
> > > There is no functional modification in this change As preparation for
> > > a Change (Rejig of LcdGraphicsOutPutDxe), some comments are modified
> > > and a few new comments are added.
> > > This is to prevent mixing formatting changes with functional changes.
> > >
> > > 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>
> > > ---
> ...
> > >
> > > -
> > > +/** Platform related initialization function.
> > > + *
> > > + * @param IN Handle Handle to the LCD device instance.
> > > + *
> > > + * @retval EFI_SUCCESS Platform initialization success.
> > > + * @retval !(EFI_SUCCESS) Other errors.
> > > +**/
> >
> > So ... 6.8 lists
> > /**
> > text
> > **/
> > as the
> >
> > The format
> > /**
> > * text
> > **/
> > is mentioned as "also legal because doxygen ignores the leading *".
> >
> > The format
> > /**
> > *
> > **/
> > is never mentioned, although I guess "also legal" because * ignored.
> >
> > However, a quick skim in MdePkg suggests the former is the generally used
> > variant. Can you please update to that format throughout (drop the leading
> > '*' on lines not starting or ending the comment block)?
>
> [[Evan Lloyd]] I'm not sure if Outlook has mangled something, or I'm being obtuse,
> but I'm not sure I follow the distinction you are making there.
> However, if your objection is to the leading '*' then we can remove
> it.
The objection is slightly with regards to the leading *, but moreso
over it aligning with the second * of the opening /** rather than the first.
It is entirely possible that some form of email mangling is the cause
(including perhaps you reading my reply in non-fixed width font).
> By the way - shouldn't it be:
> /** Brief description
>
> Details
> **/ (see Horor vacuii)
That would be my preferred version. (I started typing that above, but
seem to have lost my way after "as the".)
It's just that
/**
*
**/
is common enough in the codebase that I wouldn't object to it.
Whereas I haven't seen
/**
*
**/
anywhere else
> I actually think the CCS is woefully inconsistent in its example
> comment style, and that although leading '*'s are acceptable to
> Doxygen, it would be better to stick to one style (that of the file
> header comment, without leading '*'s) throughout.
I won't argue about the consistency, and agree with your view on this.
/
Leif
>
> >
> > No other comments (other than having these prototype documentations
> > are a great improvement).
> >
> > /
> > Leif
> >
> > > EFI_STATUS
> > > LcdPlatformInitializeDisplay (
> > > IN EFI_HANDLE Handle
> > > );
> > >
> > > +/** Reserve VRAM memory in DRAM for the frame buffer
> > > + * (unless it is reserved already).
> > > + *
> > > + * The allocated address can be used to set the frame buffer.
> > > + * @param OUT VramBaseAddress A pointer to the frame buffer
> > address.
> > > + * @param OUT VramSize A pointer to the size of the frame
> > > + * buffer in bytes
> > > + *
> > > + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> > > + * @retval !(EFI_SUCCESS) Other errors.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformGetVram (
> > > OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> > > OUT UINTN* VramSize
> > > );
> > >
> > > +/** Return total number of modes.
> > > + *
> > > + * @retval UINT32 Mode Number.
> > > +**/
> > > UINT32
> > > LcdPlatformGetMaxMode (
> > > VOID
> > > );
> > >
> > > +/** Set the requested display mode.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > + * @retval EFI_SUCCESS Set mode success.
> > > + * @retval EFI_INVALID_PARAMTER Requested mode not found.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformSetMode (
> > > IN UINT32 ModeNumber
> > > );
> > >
> > > +/** Return information for the requested mode number.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > + * @param OUT Info Pointer for returned mode information
> > > + * (on success).
> > > + *
> > > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformQueryMode (
> > > IN UINT32 ModeNumber,
> > > OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
> > > );
> > >
> > > +/** Returns the display timing information for the requested mode
> > number.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > + * @param OUT HRes Pointer to horizontal resolution.
> > > + * @param OUT HSync Pointer to horizontal sync width.
> > > + * @param OUT HBackPorch Pointer to horizontal back porch.
> > > + * @param OUT HFrontPorch Pointer to horizontal front porch.
> > > + * @param OUT VRes Pointer to vertical resolution.
> > > + * @param OUT VSync Pointer to vertical sync width.
> > > + * @param OUT VBackPorch Pointer to vertical back porch.
> > > + * @param OUT VFrontPorch Pointer to vertical front porch.
> > > +
> > > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformGetTimings (
> > > IN UINT32 ModeNumber,
> > > @@ -212,6 +244,14 @@ LcdPlatformGetTimings (
> > > OUT UINT32* VFrontPorch
> > > );
> > >
> > > +/** Return bits per pixel information for a mode number.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > + * @param OUT Bpp Pointer to value Bytes Per Pixel.
> > > + *
> > > + * @retval EFI_SUCCESS The requested mode is found.
> > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformGetBpp (
> > > IN UINT32 ModeNumber,
> > > diff --git
> > >
> > a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> > ArmVE
> > > xpress.c
> > >
> > b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> > ArmVE
> > > xpress.c index
> > >
> > 2041de5f63c72de6f0ce4047420c282507a1d04a..cfe3259d3c737de240350
> > e8c3eab
> > > 867b80c40948 100644
> > > ---
> > >
> > a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> > ArmVE
> > > xpress.c
> > > +++
> > b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> > A
> > > +++ rmVExpress.c
> > > @@ -44,7 +44,8 @@ typedef struct {
> > > UINT32 VFrontPorch;
> > > } LCD_RESOLUTION;
> > >
> > > -
> > > +/** The display modes supported by the platform.
> > > +**/
> > > LCD_RESOLUTION mResolutions[] = {
> > > { // Mode 0 : VGA : 640 x 480 x 24 bpp
> > > VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
> > LCD_BITS_PER_PIXEL_24,
> > > @@ -94,6 +95,11 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
> > > NULL
> > > };
> > >
> > > +/** HDLCD Platform specific initialization function.
> > > + *
> > > + * @retval EFI_SUCCESS Plaform library initialization success.
> > > + * @retval !(EFI_SUCCESS) Other errors.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformInitializeDisplay (
> > > IN EFI_HANDLE Handle
> > > @@ -124,6 +130,18 @@ LcdPlatformInitializeDisplay (
> > > return Status;
> > > }
> > >
> > > +/** Reserve VRAM memory in DRAM for the frame buffer
> > > + * (unless it is reserved already).
> > > + *
> > > + * The allocated address can be used to set the frame buffer.
> > > + *
> > > + * @param OUT VramBaseAddress A pointer to the frame buffer
> > address.
> > > + * @param OUT VramSize A pointer to the size of the frame
> > > + * buffer in bytes
> > > + *
> > > + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> > > + * @retval !(EFI_SUCCESS) Other errors.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformGetVram (
> > > OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress, @@ -170,6 +188,13
> > @@
> > > LcdPlatformGetVram (
> > > return EFI_SUCCESS;
> > > }
> > >
> > > +/** Return total number of modes supported.
> > > + *
> > > + * Note: Valid mode numbers are 0 to MaxMode - 1
> > > + * See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan
> > > +2017)
> > > + *
> > > + * @retval UINT32 Mode Number.
> > > +**/
> > > UINT32
> > > LcdPlatformGetMaxMode(VOID)
> > > {
> > > @@ -178,6 +203,10 @@ LcdPlatformGetMaxMode(VOID)
> > > return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION)); }
> > >
> > > +/** Set the requested display mode.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformSetMode (
> > > IN UINT32 ModeNumber
> > > @@ -227,6 +256,15 @@ LcdPlatformSetMode (
> > > return Status;
> > > }
> > >
> > > +/** Return information for the requested mode number.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > + * @param OUT Info Pointer for returned mode information
> > > + * (on success).
> > > + *
> > > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformQueryMode (
> > > IN UINT32 ModeNumber,
> > > @@ -267,6 +305,21 @@ LcdPlatformQueryMode (
> > > return EFI_SUCCESS;
> > > }
> > >
> > > +/** Returns the display timing information for the requested mode
> > number.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > + * @param OUT HRes Pointer to horizontal resolution.
> > > + * @param OUT HSync Pointer to horizontal sync width.
> > > + * @param OUT HBackPorch Pointer to horizontal back porch.
> > > + * @param OUT HFrontPorch Pointer to horizontal front porch.
> > > + * @param OUT VRes Pointer to vertical resolution.
> > > + * @param OUT VSync Pointer to vertical sync width.
> > > + * @param OUT VBackPorch Pointer to vertical back porch.
> > > + * @param OUT VFrontPorch Pointer to vertical front porch.
> > > + *
> > > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformGetTimings (
> > > IN UINT32 ModeNumber,
> > > @@ -296,6 +349,14 @@ LcdPlatformGetTimings (
> > > return EFI_SUCCESS;
> > > }
> > >
> > > +/** Return bits per pixel for a mode number.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > + * @param OUT Bpp Pointer to value Bits Per Pixel.
> > > + *
> > > + * @retval EFI_SUCCESS The requested mode is found.
> > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformGetBpp (
> > > IN UINT32 ModeNumber,
> > > diff --git
> > >
> > a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> > 11Lc
> > > dArmVExpress.c
> > >
> > b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> > 11Lc
> > > dArmVExpress.c index
> > >
> > 8d046816454f642bced00e29c4e02093b74afd24..84880e5fd1dfe6f824b27
> > e53926f
> > > 9bb32ff6cdf7 100644
> > > ---
> > >
> > a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> > 11Lc
> > > dArmVExpress.c
> > > +++
> > b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> > > +++ 11LcdArmVExpress.c
> > > @@ -41,7 +41,8 @@ typedef struct {
> > > UINT32 VFrontPorch;
> > > } LCD_RESOLUTION;
> > >
> > > -
> > > +/** The display modes supported by the platform.
> > > +**/
> > > LCD_RESOLUTION mResolutions[] = {
> > > { // Mode 0 : VGA : 640 x 480 x 24 bpp
> > > VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
> > LCD_BITS_PER_PIXEL_24,
> > > @@ -151,7 +152,11 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
> > > NULL
> > > };
> > >
> > > -
> > > +/** PL111 Platform specific initialization function.
> > > + *
> > > + * @retval EFI_SUCCESS Plaform library initialization success.
> > > + * @retval !(EFI_SUCCESS) Other errors.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformInitializeDisplay (
> > > IN EFI_HANDLE Handle
> > > @@ -176,6 +181,18 @@ LcdPlatformInitializeDisplay (
> > > return Status;
> > > }
> > >
> > > +/** Reserve VRAM memory in DRAM for the frame buffer
> > > + * (unless it is reserved already).
> > > + *
> > > + * The allocated address can be used to set the frame buffer.
> > > + *
> > > + * @param OUT VramBaseAddress A pointer to the frame buffer
> > address.
> > > + * @param OUT VramSize A pointer to the size of the frame
> > > + * buffer in bytes
> > > + *
> > > + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> > > + * @retval !(EFI_SUCCESS) Other errors.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformGetVram (
> > > OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress, @@ -232,6 +249,13
> > @@
> > > LcdPlatformGetVram (
> > > return Status;
> > > }
> > >
> > > +/** Return total number of modes supported.
> > > + *
> > > + * Note: Valid mode numbers are 0 to MaxMode - 1
> > > + * See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan
> > > +2017)
> > > + *
> > > + * @retval UINT32 Mode Number.
> > > +**/
> > > UINT32
> > > LcdPlatformGetMaxMode(VOID)
> > > {
> > > @@ -249,6 +273,14 @@ LcdPlatformGetMaxMode(VOID)
> > > return (PcdGet32 (PcdPL111LcdMaxMode)); }
> > >
> > > +/** Set the requested display mode.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > + *
> > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > + * @retval EFI_UNSUPPORTED PLL111 configuration not supported.
> > > + * @retval !(EFI_SUCCESS) Other errors.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformSetMode (
> > > IN UINT32 ModeNumber
> > > @@ -320,6 +352,15 @@ LcdPlatformSetMode (
> > > return Status;
> > > }
> > >
> > > +/** Return information for the requested mode number.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > + * @param OUT Info Pointer for returned mode information
> > > + * (on success).
> > > + *
> > > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformQueryMode (
> > > IN UINT32 ModeNumber,
> > > @@ -360,6 +401,21 @@ LcdPlatformQueryMode (
> > > return EFI_SUCCESS;
> > > }
> > >
> > > +/** Returns the display timing information for the requested mode
> > number.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > + * @param OUT HRes Pointer to horizontal resolution.
> > > + * @param OUT HSync Pointer to horizontal sync width.
> > > + * @param OUT HBackPorch Pointer to horizontal back porch.
> > > + * @param OUT HFrontPorch Pointer to horizontal front porch.
> > > + * @param OUT VRes Pointer to vertical resolution.
> > > + * @param OUT VSync Pointer to vertical sync width.
> > > + * @param OUT VBackPorch Pointer to vertical back porch.
> > > + * @param OUT VFrontPorch Pointer to vertical front porch.
> > > + *
> > > + * @retval EFI_SUCCESS Success if the requested mode is found.
> > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformGetTimings (
> > > IN UINT32 ModeNumber,
> > > @@ -389,6 +445,14 @@ LcdPlatformGetTimings (
> > > return EFI_SUCCESS;
> > > }
> > >
> > > +/** Return bits per pixel for a mode number.
> > > + *
> > > + * @param IN ModeNumber Mode Number.
> > > + * @param OUT Bpp Pointer to value Bits Per Pixel.
> > > + *
> > > + * @retval EFI_SUCCESS The requested mode is found.
> > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > +**/
> > > EFI_STATUS
> > > LcdPlatformGetBpp (
> > > IN UINT32 ModeNumber,
> > > diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > > index
> > >
> > eb0b6fb3fbbc1cb605469433f6c6dcb85bac668c..744dd3d556b5071defc6b
> > cad5a9a
> > > 30881bcb4b6f 100644
> > > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > > @@ -29,6 +29,12 @@
> > > *
> > >
> > >
> > **********************************************************
> > ************
> > > /
> > >
> > > +/** Initialize display.
> > > + *
> > > + * @param VramBaseAddress Address of the frame buffer.
> > > + *
> > > + * @retval EFI_SUCCESS Display initialization success.
> > > +**/
> > > EFI_STATUS
> > > LcdInitialize (
> > > IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> > > @@ -67,6 +73,12 @@ LcdInitialize (
> > > return EFI_SUCCESS;
> > > }
> > >
> > > +/** Set requested mode of the display.
> > > + *
> > > + * @param ModeNumber Display mode number.
> > > + * @retval EFI_SUCCESS Display set mode success.
> > > + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> > > +**/
> > > EFI_STATUS
> > > LcdSetMode (
> > > IN UINT32 ModeNumber
> > > @@ -136,6 +148,8 @@ LcdSetMode (
> > > return EFI_SUCCESS;
> > > }
> > >
> > > +/** De-initializes the display.
> > > +**/
> > > VOID
> > > LcdShutdown (
> > > VOID
> > > @@ -145,6 +159,12 @@ LcdShutdown (
> > > MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE); }
> > >
> > > +/** Check for presence of HDLCD.
> > > + *
> > > + * @retval EFI_SUCCESS Platform implements HDLCD.
> > > + * @retval EFI_NOT_FOUND HDLCD display controller not
> > > + * found.
> > > +**/
> > > EFI_STATUS
> > > LcdIdentify (
> > > VOID
> > > diff --git
> > >
> > a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> > c
> > >
> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> > c
> > > index
> > >
> > 2dd8f39873f77b1c211bff407cabe90c1795b121..c40c8e0fa6f4b5f7798aeb
> > 3c8bf3
> > > f261f14cb67b 100644
> > > ---
> > >
> > a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> > c
> > > +++
> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe
> > > +++ .c
> > > @@ -357,8 +357,8 @@ LcdGraphicsSetMode (
> > > goto EXIT;
> > > }
> > >
> > > - // The UEFI spec requires that we now clear the visible portions of
> > > the
> > > - // output display to black.
> > > + /* The UEFI spec requires that we now clear the visible portions of the
> > > + * output display to black. */
> > >
> > > // Set the fill colour to black
> > > SetMem (&FillColour, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
> > > diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > > index
> > >
> > 0b0c4204fbc44bc9e90dce3d7b410ce167d9f40c..f8a3c1f8266c0a11f111c3
> > 747688
> > > defc0d49877c 100644
> > > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > > @@ -26,6 +26,12 @@
> > > *
> > >
> > >
> > **********************************************************
> > ************
> > > /
> > >
> > > +/** Check for presence of PL111.
> > > + *
> > > + * @retval EFI_SUCCESS Platform implements PL111.
> > > + * @retval EFI_NOT_FOUND PL111 display controller not
> > > + * found.
> > > +**/
> > > EFI_STATUS
> > > LcdIdentify (
> > > VOID
> > > @@ -48,6 +54,12 @@ LcdIdentify (
> > > return EFI_NOT_FOUND;
> > > }
> > >
> > > +/** Initialize display.
> > > + *
> > > + * @param VramBaseAddress Address of the frame buffer.
> > > + *
> > > + * @retval EFI_SUCCESS Display initialization success.
> > > +**/
> > > EFI_STATUS
> > > LcdInitialize (
> > > IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> > > @@ -63,6 +75,12 @@ LcdInitialize (
> > > return EFI_SUCCESS;
> > > }
> > >
> > > +/** Set requested mode of the display.
> > > + *
> > > + * @param ModeNumber Display mode number.
> > > + * @retval EFI_SUCCESS Display set mode success.
> > > + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> > > +**/
> > > EFI_STATUS
> > > LcdSetMode (
> > > IN UINT32 ModeNumber
> > > @@ -123,7 +141,7 @@ LcdSetMode (
> > >
> > > // PL111_REG_LCD_CONTROL
> > > LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp)
> > > - | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> > > + | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> > >
> > > MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
> > >
> > > @@ -134,6 +152,8 @@ LcdSetMode (
> > > return EFI_SUCCESS;
> > > }
> > >
> > > +/** De-initializes the display.
> > > +*/
> > > VOID
> > > LcdShutdown (
> > > VOID
> > > --
> > > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> > >
> > > _______________________________________________
> > > edk2-devel mailing list
> > > edk2-devel@lists.01.org
> > > https://lists.01.org/mailman/listinfo/edk2-devel
> IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 02/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Added comments
2017-12-05 19:58 ` Leif Lindholm
@ 2017-12-05 22:06 ` Evan Lloyd
0 siblings, 0 replies; 69+ messages in thread
From: Evan Lloyd @ 2017-12-05 22:06 UTC (permalink / raw)
To: Leif Lindholm; +Cc: edk2-devel@lists.01.org, dp@arm.com
> -----Original Message-----
> From: Leif Lindholm [mailto:leif.lindholm@linaro.org]
> Sent: 05 December 2017 19:59
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org
> Subject: Re: [edk2] [PATCH 02/19] ArmPlatformPkg: Tidy
> LcdGraphicsOutputDxe code: Added comments
>
> On Tue, Dec 05, 2017 at 06:55:25PM +0000, Evan Lloyd wrote:
> >
> >
> > > -----Original Message-----
> > > From: Leif Lindholm [mailto:leif.lindholm@linaro.org]
> > > Sent: 12 October 2017 20:02
> > > To: Evan Lloyd <Evan.Lloyd@arm.com>
> > > Cc: edk2-devel@lists.01.org
> > > Subject: Re: [edk2] [PATCH 02/19] ArmPlatformPkg: Tidy
> > > LcdGraphicsOutputDxe code: Added comments
> > >
> > > Given that all changes to the first file _remove_ comments, it may
> > > be better with a subject line saying "updating comments".
> > >
> > > On Tue, Sep 26, 2017 at 09:15:12PM +0100, evan.lloyd@arm.com
> wrote:
> > > > From: Girish Pathak <girish.pathak@arm.com>
> > > >
> > > > There is no functional modification in this change As preparation
> > > > for a Change (Rejig of LcdGraphicsOutPutDxe), some comments are
> > > > modified and a few new comments are added.
> > > > This is to prevent mixing formatting changes with functional changes.
> > > >
> > > > 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>
> > > > ---
> > ...
> > > >
> > > > -
> > > > +/** Platform related initialization function.
> > > > + *
> > > > + * @param IN Handle Handle to the LCD device instance.
> > > > + *
> > > > + * @retval EFI_SUCCESS Platform initialization success.
> > > > + * @retval !(EFI_SUCCESS) Other errors.
> > > > +**/
> > >
> > > So ... 6.8 lists
> > > /**
> > > text
> > > **/
> > > as the
> > >
> > > The format
> > > /**
> > > * text
> > > **/
> > > is mentioned as "also legal because doxygen ignores the leading *".
> > >
> > > The format
> > > /**
> > > *
> > > **/
> > > is never mentioned, although I guess "also legal" because * ignored.
> > >
> > > However, a quick skim in MdePkg suggests the former is the generally
> > > used variant. Can you please update to that format throughout (drop
> > > the leading '*' on lines not starting or ending the comment block)?
> >
> > [[Evan Lloyd]] I'm not sure if Outlook has mangled something, or I'm
> > being obtuse, but I'm not sure I follow the distinction you are making
> there.
> > However, if your objection is to the leading '*' then we can remove
> > it.
>
> The objection is slightly with regards to the leading *, but moreso over it
> aligning with the second * of the opening /** rather than the first.
[[Evan Lloyd]] Just to be a barrack room lawyer - the CCS clearly states:
" 3.2.1 Formatting: General Rules
...
All indentation (tabs) is two spaces. See "General Rules”."
" 5.1.2 ... All indentation is on two space boundaries. There are no exceptions to this rule!"
Of course you may quibble over this being an indentation, but the leading '*'s are certainly indented relative to the "/**" in either case.
>
> It is entirely possible that some form of email mangling is the cause
> (including perhaps you reading my reply in non-fixed width font).
[[Evan Lloyd]] Almost certainly true.
>
> > By the way - shouldn't it be:
> > /** Brief description
> >
> > Details
> > **/ (see Horor vacuii)
>
> That would be my preferred version. (I started typing that above, but seem
> to have lost my way after "as the".)
>
> It's just that
> /**
> *
> **/
> is common enough in the codebase that I wouldn't object to it.
>
> Whereas I haven't seen
> /**
> *
> **/
> anywhere else
[[Evan Lloyd]] I refer my learned friend to "CCS 5.1.2 ... All indentation is on two space boundaries. There are no exceptions to this rule!"
Also:
"1.1 Abstract
... All changes or additions from this point on shall conform to this specification. Pre-existing code does not need to be updated for the sole purpose of conforming to this specification. As conforming updates are made, the developer may update other content within the modified file to bring it within compliance with this specification."
Being serious: since we all seem to prefer no leading '*'s the above is not really relevant - we'll go with a match of the file header format (and 2 space indents for the body text).
>
> > I actually think the CCS is woefully inconsistent in its example
> > comment style, and that although leading '*'s are acceptable to
> > Doxygen, it would be better to stick to one style (that of the file
> > header comment, without leading '*'s) throughout.
>
> I won't argue about the consistency, and agree with your view on this.
>
> /
> Leif
>
> >
> > >
> > > No other comments (other than having these prototype
> documentations
> > > are a great improvement).
> > >
> > > /
> > > Leif
> > >
> > > > EFI_STATUS
> > > > LcdPlatformInitializeDisplay (
> > > > IN EFI_HANDLE Handle
> > > > );
> > > >
> > > > +/** Reserve VRAM memory in DRAM for the frame buffer
> > > > + * (unless it is reserved already).
> > > > + *
> > > > + * The allocated address can be used to set the frame buffer.
> > > > + * @param OUT VramBaseAddress A pointer to the frame buffer
> > > address.
> > > > + * @param OUT VramSize A pointer to the size of the frame
> > > > + * buffer in bytes
> > > > + *
> > > > + * @retval EFI_SUCCESS Frame buffer memory allocation
> success.
> > > > + * @retval !(EFI_SUCCESS) Other errors.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformGetVram (
> > > > OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> > > > OUT UINTN* VramSize
> > > > );
> > > >
> > > > +/** Return total number of modes.
> > > > + *
> > > > + * @retval UINT32 Mode Number.
> > > > +**/
> > > > UINT32
> > > > LcdPlatformGetMaxMode (
> > > > VOID
> > > > );
> > > >
> > > > +/** Set the requested display mode.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > + * @retval EFI_SUCCESS Set mode success.
> > > > + * @retval EFI_INVALID_PARAMTER Requested mode not found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformSetMode (
> > > > IN UINT32 ModeNumber
> > > > );
> > > >
> > > > +/** Return information for the requested mode number.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > + * @param OUT Info Pointer for returned mode
> information
> > > > + * (on success).
> > > > + *
> > > > + * @retval EFI_SUCCESS Success if the requested mode is
> found.
> > > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformQueryMode (
> > > > IN UINT32 ModeNumber,
> > > > OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
> > > > );
> > > >
> > > > +/** Returns the display timing information for the requested mode
> > > number.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > + * @param OUT HRes Pointer to horizontal resolution.
> > > > + * @param OUT HSync Pointer to horizontal sync width.
> > > > + * @param OUT HBackPorch Pointer to horizontal back porch.
> > > > + * @param OUT HFrontPorch Pointer to horizontal front porch.
> > > > + * @param OUT VRes Pointer to vertical resolution.
> > > > + * @param OUT VSync Pointer to vertical sync width.
> > > > + * @param OUT VBackPorch Pointer to vertical back porch.
> > > > + * @param OUT VFrontPorch Pointer to vertical front porch.
> > > > +
> > > > + * @retval EFI_SUCCESS Success if the requested mode is
> found.
> > > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformGetTimings (
> > > > IN UINT32 ModeNumber,
> > > > @@ -212,6 +244,14 @@ LcdPlatformGetTimings (
> > > > OUT UINT32* VFrontPorch
> > > > );
> > > >
> > > > +/** Return bits per pixel information for a mode number.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > + * @param OUT Bpp Pointer to value Bytes Per Pixel.
> > > > + *
> > > > + * @retval EFI_SUCCESS The requested mode is found.
> > > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformGetBpp (
> > > > IN UINT32 ModeNumber,
> > > > diff --git
> > > >
> > >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> > > ArmVE
> > > > xpress.c
> > > >
> > >
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> > > ArmVE
> > > > xpress.c index
> > > >
> > >
> 2041de5f63c72de6f0ce4047420c282507a1d04a..cfe3259d3c737de240350
> > > e8c3eab
> > > > 867b80c40948 100644
> > > > ---
> > > >
> > >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> > > ArmVE
> > > > xpress.c
> > > > +++
> > >
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> > > A
> > > > +++ rmVExpress.c
> > > > @@ -44,7 +44,8 @@ typedef struct {
> > > > UINT32 VFrontPorch;
> > > > } LCD_RESOLUTION;
> > > >
> > > > -
> > > > +/** The display modes supported by the platform.
> > > > +**/
> > > > LCD_RESOLUTION mResolutions[] = {
> > > > { // Mode 0 : VGA : 640 x 480 x 24 bpp
> > > > VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
> > > LCD_BITS_PER_PIXEL_24,
> > > > @@ -94,6 +95,11 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive =
> {
> > > > NULL
> > > > };
> > > >
> > > > +/** HDLCD Platform specific initialization function.
> > > > + *
> > > > + * @retval EFI_SUCCESS Plaform library initialization success.
> > > > + * @retval !(EFI_SUCCESS) Other errors.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformInitializeDisplay (
> > > > IN EFI_HANDLE Handle
> > > > @@ -124,6 +130,18 @@ LcdPlatformInitializeDisplay (
> > > > return Status;
> > > > }
> > > >
> > > > +/** Reserve VRAM memory in DRAM for the frame buffer
> > > > + * (unless it is reserved already).
> > > > + *
> > > > + * The allocated address can be used to set the frame buffer.
> > > > + *
> > > > + * @param OUT VramBaseAddress A pointer to the frame buffer
> > > address.
> > > > + * @param OUT VramSize A pointer to the size of the frame
> > > > + * buffer in bytes
> > > > + *
> > > > + * @retval EFI_SUCCESS Frame buffer memory allocation
> success.
> > > > + * @retval !(EFI_SUCCESS) Other errors.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformGetVram (
> > > > OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress, @@ -170,6
> +188,13
> > > @@
> > > > LcdPlatformGetVram (
> > > > return EFI_SUCCESS;
> > > > }
> > > >
> > > > +/** Return total number of modes supported.
> > > > + *
> > > > + * Note: Valid mode numbers are 0 to MaxMode - 1
> > > > + * See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan
> > > > +2017)
> > > > + *
> > > > + * @retval UINT32 Mode Number.
> > > > +**/
> > > > UINT32
> > > > LcdPlatformGetMaxMode(VOID)
> > > > {
> > > > @@ -178,6 +203,10 @@ LcdPlatformGetMaxMode(VOID)
> > > > return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION)); }
> > > >
> > > > +/** Set the requested display mode.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformSetMode (
> > > > IN UINT32 ModeNumber
> > > > @@ -227,6 +256,15 @@ LcdPlatformSetMode (
> > > > return Status;
> > > > }
> > > >
> > > > +/** Return information for the requested mode number.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > + * @param OUT Info Pointer for returned mode
> information
> > > > + * (on success).
> > > > + *
> > > > + * @retval EFI_SUCCESS Success if the requested mode is
> found.
> > > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformQueryMode (
> > > > IN UINT32 ModeNumber,
> > > > @@ -267,6 +305,21 @@ LcdPlatformQueryMode (
> > > > return EFI_SUCCESS;
> > > > }
> > > >
> > > > +/** Returns the display timing information for the requested mode
> > > number.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > + * @param OUT HRes Pointer to horizontal resolution.
> > > > + * @param OUT HSync Pointer to horizontal sync width.
> > > > + * @param OUT HBackPorch Pointer to horizontal back porch.
> > > > + * @param OUT HFrontPorch Pointer to horizontal front porch.
> > > > + * @param OUT VRes Pointer to vertical resolution.
> > > > + * @param OUT VSync Pointer to vertical sync width.
> > > > + * @param OUT VBackPorch Pointer to vertical back porch.
> > > > + * @param OUT VFrontPorch Pointer to vertical front porch.
> > > > + *
> > > > + * @retval EFI_SUCCESS Success if the requested mode is
> found.
> > > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformGetTimings (
> > > > IN UINT32 ModeNumber,
> > > > @@ -296,6 +349,14 @@ LcdPlatformGetTimings (
> > > > return EFI_SUCCESS;
> > > > }
> > > >
> > > > +/** Return bits per pixel for a mode number.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > + * @param OUT Bpp Pointer to value Bits Per Pixel.
> > > > + *
> > > > + * @retval EFI_SUCCESS The requested mode is found.
> > > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformGetBpp (
> > > > IN UINT32 ModeNumber,
> > > > diff --git
> > > >
> > >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> > > 11Lc
> > > > dArmVExpress.c
> > > >
> > >
> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> > > 11Lc
> > > > dArmVExpress.c index
> > > >
> > >
> 8d046816454f642bced00e29c4e02093b74afd24..84880e5fd1dfe6f824b27
> > > e53926f
> > > > 9bb32ff6cdf7 100644
> > > > ---
> > > >
> > >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> > > 11Lc
> > > > dArmVExpress.c
> > > > +++
> > >
> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> > > > +++ 11LcdArmVExpress.c
> > > > @@ -41,7 +41,8 @@ typedef struct {
> > > > UINT32 VFrontPorch;
> > > > } LCD_RESOLUTION;
> > > >
> > > > -
> > > > +/** The display modes supported by the platform.
> > > > +**/
> > > > LCD_RESOLUTION mResolutions[] = {
> > > > { // Mode 0 : VGA : 640 x 480 x 24 bpp
> > > > VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
> > > LCD_BITS_PER_PIXEL_24,
> > > > @@ -151,7 +152,11 @@ EFI_EDID_ACTIVE_PROTOCOL
> mEdidActive = {
> > > > NULL
> > > > };
> > > >
> > > > -
> > > > +/** PL111 Platform specific initialization function.
> > > > + *
> > > > + * @retval EFI_SUCCESS Plaform library initialization success.
> > > > + * @retval !(EFI_SUCCESS) Other errors.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformInitializeDisplay (
> > > > IN EFI_HANDLE Handle
> > > > @@ -176,6 +181,18 @@ LcdPlatformInitializeDisplay (
> > > > return Status;
> > > > }
> > > >
> > > > +/** Reserve VRAM memory in DRAM for the frame buffer
> > > > + * (unless it is reserved already).
> > > > + *
> > > > + * The allocated address can be used to set the frame buffer.
> > > > + *
> > > > + * @param OUT VramBaseAddress A pointer to the frame buffer
> > > address.
> > > > + * @param OUT VramSize A pointer to the size of the frame
> > > > + * buffer in bytes
> > > > + *
> > > > + * @retval EFI_SUCCESS Frame buffer memory allocation
> success.
> > > > + * @retval !(EFI_SUCCESS) Other errors.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformGetVram (
> > > > OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress, @@ -232,6
> +249,13
> > > @@
> > > > LcdPlatformGetVram (
> > > > return Status;
> > > > }
> > > >
> > > > +/** Return total number of modes supported.
> > > > + *
> > > > + * Note: Valid mode numbers are 0 to MaxMode - 1
> > > > + * See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan
> > > > +2017)
> > > > + *
> > > > + * @retval UINT32 Mode Number.
> > > > +**/
> > > > UINT32
> > > > LcdPlatformGetMaxMode(VOID)
> > > > {
> > > > @@ -249,6 +273,14 @@ LcdPlatformGetMaxMode(VOID)
> > > > return (PcdGet32 (PcdPL111LcdMaxMode)); }
> > > >
> > > > +/** Set the requested display mode.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > + *
> > > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > > + * @retval EFI_UNSUPPORTED PLL111 configuration not
> supported.
> > > > + * @retval !(EFI_SUCCESS) Other errors.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformSetMode (
> > > > IN UINT32 ModeNumber
> > > > @@ -320,6 +352,15 @@ LcdPlatformSetMode (
> > > > return Status;
> > > > }
> > > >
> > > > +/** Return information for the requested mode number.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > + * @param OUT Info Pointer for returned mode
> information
> > > > + * (on success).
> > > > + *
> > > > + * @retval EFI_SUCCESS Success if the requested mode is
> found.
> > > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformQueryMode (
> > > > IN UINT32 ModeNumber,
> > > > @@ -360,6 +401,21 @@ LcdPlatformQueryMode (
> > > > return EFI_SUCCESS;
> > > > }
> > > >
> > > > +/** Returns the display timing information for the requested mode
> > > number.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > + * @param OUT HRes Pointer to horizontal resolution.
> > > > + * @param OUT HSync Pointer to horizontal sync width.
> > > > + * @param OUT HBackPorch Pointer to horizontal back porch.
> > > > + * @param OUT HFrontPorch Pointer to horizontal front porch.
> > > > + * @param OUT VRes Pointer to vertical resolution.
> > > > + * @param OUT VSync Pointer to vertical sync width.
> > > > + * @param OUT VBackPorch Pointer to vertical back porch.
> > > > + * @param OUT VFrontPorch Pointer to vertical front porch.
> > > > + *
> > > > + * @retval EFI_SUCCESS Success if the requested mode is
> found.
> > > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformGetTimings (
> > > > IN UINT32 ModeNumber,
> > > > @@ -389,6 +445,14 @@ LcdPlatformGetTimings (
> > > > return EFI_SUCCESS;
> > > > }
> > > >
> > > > +/** Return bits per pixel for a mode number.
> > > > + *
> > > > + * @param IN ModeNumber Mode Number.
> > > > + * @param OUT Bpp Pointer to value Bits Per Pixel.
> > > > + *
> > > > + * @retval EFI_SUCCESS The requested mode is found.
> > > > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdPlatformGetBpp (
> > > > IN UINT32 ModeNumber,
> > > > diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > > > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > > > index
> > > >
> > >
> eb0b6fb3fbbc1cb605469433f6c6dcb85bac668c..744dd3d556b5071defc6b
> > > cad5a9a
> > > > 30881bcb4b6f 100644
> > > > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > > > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > > > @@ -29,6 +29,12 @@
> > > > *
> > > >
> > > >
> > >
> **********************************************************
> > > ************
> > > > /
> > > >
> > > > +/** Initialize display.
> > > > + *
> > > > + * @param VramBaseAddress Address of the frame buffer.
> > > > + *
> > > > + * @retval EFI_SUCCESS Display initialization success.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdInitialize (
> > > > IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> > > > @@ -67,6 +73,12 @@ LcdInitialize (
> > > > return EFI_SUCCESS;
> > > > }
> > > >
> > > > +/** Set requested mode of the display.
> > > > + *
> > > > + * @param ModeNumber Display mode number.
> > > > + * @retval EFI_SUCCESS Display set mode success.
> > > > + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdSetMode (
> > > > IN UINT32 ModeNumber
> > > > @@ -136,6 +148,8 @@ LcdSetMode (
> > > > return EFI_SUCCESS;
> > > > }
> > > >
> > > > +/** De-initializes the display.
> > > > +**/
> > > > VOID
> > > > LcdShutdown (
> > > > VOID
> > > > @@ -145,6 +159,12 @@ LcdShutdown (
> > > > MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE); }
> > > >
> > > > +/** Check for presence of HDLCD.
> > > > + *
> > > > + * @retval EFI_SUCCESS Platform implements HDLCD.
> > > > + * @retval EFI_NOT_FOUND HDLCD display controller not
> > > > + * found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdIdentify (
> > > > VOID
> > > > diff --git
> > > >
> > >
> a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> > > c
> > > >
> > >
> b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> > > c
> > > > index
> > > >
> > >
> 2dd8f39873f77b1c211bff407cabe90c1795b121..c40c8e0fa6f4b5f7798aeb
> > > 3c8bf3
> > > > f261f14cb67b 100644
> > > > ---
> > > >
> > >
> a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.
> > > c
> > > > +++
> > >
> b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe
> > > > +++ .c
> > > > @@ -357,8 +357,8 @@ LcdGraphicsSetMode (
> > > > goto EXIT;
> > > > }
> > > >
> > > > - // The UEFI spec requires that we now clear the visible
> > > > portions of the
> > > > - // output display to black.
> > > > + /* The UEFI spec requires that we now clear the visible portions of
> the
> > > > + * output display to black. */
> > > >
> > > > // Set the fill colour to black
> > > > SetMem (&FillColour, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL),
> > > > 0x0); diff --git
> > > > a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > > > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > > > index
> > > >
> > >
> 0b0c4204fbc44bc9e90dce3d7b410ce167d9f40c..f8a3c1f8266c0a11f111c3
> > > 747688
> > > > defc0d49877c 100644
> > > > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > > > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > > > @@ -26,6 +26,12 @@
> > > > *
> > > >
> > > >
> > >
> **********************************************************
> > > ************
> > > > /
> > > >
> > > > +/** Check for presence of PL111.
> > > > + *
> > > > + * @retval EFI_SUCCESS Platform implements PL111.
> > > > + * @retval EFI_NOT_FOUND PL111 display controller not
> > > > + * found.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdIdentify (
> > > > VOID
> > > > @@ -48,6 +54,12 @@ LcdIdentify (
> > > > return EFI_NOT_FOUND;
> > > > }
> > > >
> > > > +/** Initialize display.
> > > > + *
> > > > + * @param VramBaseAddress Address of the frame buffer.
> > > > + *
> > > > + * @retval EFI_SUCCESS Display initialization success.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdInitialize (
> > > > IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> > > > @@ -63,6 +75,12 @@ LcdInitialize (
> > > > return EFI_SUCCESS;
> > > > }
> > > >
> > > > +/** Set requested mode of the display.
> > > > + *
> > > > + * @param ModeNumber Display mode number.
> > > > + * @retval EFI_SUCCESS Display set mode success.
> > > > + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> > > > +**/
> > > > EFI_STATUS
> > > > LcdSetMode (
> > > > IN UINT32 ModeNumber
> > > > @@ -123,7 +141,7 @@ LcdSetMode (
> > > >
> > > > // PL111_REG_LCD_CONTROL
> > > > LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp)
> > > > - | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> > > > + | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> > > >
> > > > MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
> > > >
> > > > @@ -134,6 +152,8 @@ LcdSetMode (
> > > > return EFI_SUCCESS;
> > > > }
> > > >
> > > > +/** De-initializes the display.
> > > > +*/
> > > > VOID
> > > > LcdShutdown (
> > > > VOID
> > > > --
> > > > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> > > >
> > > > _______________________________________________
> > > > edk2-devel mailing list
> > > > edk2-devel@lists.01.org
> > > > https://lists.01.org/mailman/listinfo/edk2-devel
> > IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose the
> contents to any other person, use it for any purpose, or store or copy the
> information in any medium. Thank you.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const qualifier
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
2017-09-26 20:15 ` [PATCH 01/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Coding standard evan.lloyd
2017-09-26 20:15 ` [PATCH 02/19] ArmPlatformPkg: Tidy LcdGraphicsOutputDxe code: Added comments evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-12 19:07 ` Leif Lindholm
2017-10-12 19:47 ` Ard Biesheuvel
2017-09-26 20:15 ` [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts evan.lloyd
` (15 subsequent siblings)
18 siblings, 2 replies; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
This change adds some STATIC and CONST qualifiers (mainly to arguments
of functions) in PL111 and HdLcd modules.
It doesn't add or modify any functionality.
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>
---
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 34 ++++++++++----------
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 34 ++++++++++----------
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 4 +--
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 4 +--
4 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index cfe3259d3c737de240350e8c3eab867b80c40948..b9859a56988f7e5be0adbaa49048a683fe586bfe 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -46,7 +46,7 @@ typedef struct {
/** The display modes supported by the platform.
**/
-LCD_RESOLUTION mResolutions[] = {
+STATIC CONST LCD_RESOLUTION mResolutions[] = {
{ // Mode 0 : VGA : 640 x 480 x 24 bpp
VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
VGA_OSC_FREQUENCY,
@@ -144,8 +144,8 @@ LcdPlatformInitializeDisplay (
**/
EFI_STATUS
LcdPlatformGetVram (
- OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
- OUT UINTN* VramSize
+ OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
+ OUT UINTN * CONST VramSize
)
{
EFI_STATUS Status;
@@ -209,7 +209,7 @@ LcdPlatformGetMaxMode(VOID)
**/
EFI_STATUS
LcdPlatformSetMode (
- IN UINT32 ModeNumber
+ IN CONST UINT32 ModeNumber
)
{
EFI_STATUS Status;
@@ -267,8 +267,8 @@ LcdPlatformSetMode (
**/
EFI_STATUS
LcdPlatformQueryMode (
- IN UINT32 ModeNumber,
- OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
+ IN CONST UINT32 ModeNumber,
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
)
{
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
@@ -322,15 +322,15 @@ LcdPlatformQueryMode (
**/
EFI_STATUS
LcdPlatformGetTimings (
- IN UINT32 ModeNumber,
- OUT UINT32* HRes,
- OUT UINT32* HSync,
- OUT UINT32* HBackPorch,
- OUT UINT32* HFrontPorch,
- OUT UINT32* VRes,
- OUT UINT32* VSync,
- OUT UINT32* VBackPorch,
- OUT UINT32* VFrontPorch
+ IN CONST UINT32 ModeNumber,
+ OUT UINT32 * CONST HRes,
+ OUT UINT32 * CONST HSync,
+ OUT UINT32 * CONST HBackPorch,
+ OUT UINT32 * CONST HFrontPorch,
+ OUT UINT32 * CONST VRes,
+ OUT UINT32 * CONST VSync,
+ OUT UINT32 * CONST VBackPorch,
+ OUT UINT32 * CONST VFrontPorch
)
{
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
@@ -359,8 +359,8 @@ LcdPlatformGetTimings (
**/
EFI_STATUS
LcdPlatformGetBpp (
- IN UINT32 ModeNumber,
- OUT LCD_BPP * Bpp
+ IN CONST UINT32 ModeNumber,
+ OUT LCD_BPP * CONST Bpp
)
{
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 84880e5fd1dfe6f824b27e53926f9bb32ff6cdf7..6ae13f06d8b396ea1c67f0bcd735a9d70f476400 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -43,7 +43,7 @@ typedef struct {
/** The display modes supported by the platform.
**/
-LCD_RESOLUTION mResolutions[] = {
+STATIC CONST LCD_RESOLUTION mResolutions[] = {
{ // Mode 0 : VGA : 640 x 480 x 24 bpp
VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
VGA_OSC_FREQUENCY,
@@ -195,8 +195,8 @@ LcdPlatformInitializeDisplay (
**/
EFI_STATUS
LcdPlatformGetVram (
- OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
- OUT UINTN* VramSize
+ OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
+ OUT UINTN * CONST VramSize
)
{
EFI_STATUS Status;
@@ -283,7 +283,7 @@ LcdPlatformGetMaxMode(VOID)
**/
EFI_STATUS
LcdPlatformSetMode (
- IN UINT32 ModeNumber
+ IN CONST UINT32 ModeNumber
)
{
EFI_STATUS Status;
@@ -363,8 +363,8 @@ LcdPlatformSetMode (
**/
EFI_STATUS
LcdPlatformQueryMode (
- IN UINT32 ModeNumber,
- OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
+ IN CONST UINT32 ModeNumber,
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
)
{
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
@@ -418,15 +418,15 @@ LcdPlatformQueryMode (
**/
EFI_STATUS
LcdPlatformGetTimings (
- IN UINT32 ModeNumber,
- OUT UINT32* HRes,
- OUT UINT32* HSync,
- OUT UINT32* HBackPorch,
- OUT UINT32* HFrontPorch,
- OUT UINT32* VRes,
- OUT UINT32* VSync,
- OUT UINT32* VBackPorch,
- OUT UINT32* VFrontPorch
+ IN CONST UINT32 ModeNumber,
+ OUT UINT32 * CONST HRes,
+ OUT UINT32 * CONST HSync,
+ OUT UINT32 * CONST HBackPorch,
+ OUT UINT32 * CONST HFrontPorch,
+ OUT UINT32 * CONST VRes,
+ OUT UINT32 * CONST VSync,
+ OUT UINT32 * CONST VBackPorch,
+ OUT UINT32 * CONST VFrontPorch
)
{
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
@@ -455,8 +455,8 @@ LcdPlatformGetTimings (
**/
EFI_STATUS
LcdPlatformGetBpp (
- IN UINT32 ModeNumber,
- OUT LCD_BPP * Bpp
+ IN CONST UINT32 ModeNumber,
+ OUT LCD_BPP * CONST Bpp
)
{
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
index 744dd3d556b5071defc6bcad5a9a30881bcb4b6f..5f950579720fb69e0a481f697a5cc4038158b409 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
@@ -37,7 +37,7 @@
**/
EFI_STATUS
LcdInitialize (
- IN EFI_PHYSICAL_ADDRESS VramBaseAddress
+ IN CONST EFI_PHYSICAL_ADDRESS VramBaseAddress
)
{
// Disable the controller
@@ -81,7 +81,7 @@ LcdInitialize (
**/
EFI_STATUS
LcdSetMode (
- IN UINT32 ModeNumber
+ IN CONST UINT32 ModeNumber
)
{
EFI_STATUS Status;
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
index f8a3c1f8266c0a11f111c3747688defc0d49877c..386e6140a69b045f77ee7fa60c4587d8bf4e7d54 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
@@ -62,7 +62,7 @@ LcdIdentify (
**/
EFI_STATUS
LcdInitialize (
- IN EFI_PHYSICAL_ADDRESS VramBaseAddress
+ IN CONST EFI_PHYSICAL_ADDRESS VramBaseAddress
)
{
// Define start of the VRAM. This never changes for any graphics mode
@@ -83,7 +83,7 @@ LcdInitialize (
**/
EFI_STATUS
LcdSetMode (
- IN UINT32 ModeNumber
+ IN CONST UINT32 ModeNumber
)
{
EFI_STATUS Status;
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const qualifier
2017-09-26 20:15 ` [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const qualifier evan.lloyd
@ 2017-10-12 19:07 ` Leif Lindholm
2017-10-12 19:47 ` Ard Biesheuvel
1 sibling, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-12 19:07 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:13PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> This change adds some STATIC and CONST qualifiers (mainly to arguments
> of functions) in PL111 and HdLcd modules.
>
> It doesn't add or modify any functionality.
If you delete the line above:
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
(These changes are highly likely to affect code generation, so I still
consider it a functional change - if not an algorithmic one.)
/
Leif
> 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>
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 34 ++++++++++----------
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 34 ++++++++++----------
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 4 +--
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 4 +--
> 4 files changed, 38 insertions(+), 38 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index cfe3259d3c737de240350e8c3eab867b80c40948..b9859a56988f7e5be0adbaa49048a683fe586bfe 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -46,7 +46,7 @@ typedef struct {
>
> /** The display modes supported by the platform.
> **/
> -LCD_RESOLUTION mResolutions[] = {
> +STATIC CONST LCD_RESOLUTION mResolutions[] = {
> { // Mode 0 : VGA : 640 x 480 x 24 bpp
> VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> VGA_OSC_FREQUENCY,
> @@ -144,8 +144,8 @@ LcdPlatformInitializeDisplay (
> **/
> EFI_STATUS
> LcdPlatformGetVram (
> - OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> - OUT UINTN* VramSize
> + OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> + OUT UINTN * CONST VramSize
> )
> {
> EFI_STATUS Status;
> @@ -209,7 +209,7 @@ LcdPlatformGetMaxMode(VOID)
> **/
> EFI_STATUS
> LcdPlatformSetMode (
> - IN UINT32 ModeNumber
> + IN CONST UINT32 ModeNumber
> )
> {
> EFI_STATUS Status;
> @@ -267,8 +267,8 @@ LcdPlatformSetMode (
> **/
> EFI_STATUS
> LcdPlatformQueryMode (
> - IN UINT32 ModeNumber,
> - OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
> + IN CONST UINT32 ModeNumber,
> + OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -322,15 +322,15 @@ LcdPlatformQueryMode (
> **/
> EFI_STATUS
> LcdPlatformGetTimings (
> - IN UINT32 ModeNumber,
> - OUT UINT32* HRes,
> - OUT UINT32* HSync,
> - OUT UINT32* HBackPorch,
> - OUT UINT32* HFrontPorch,
> - OUT UINT32* VRes,
> - OUT UINT32* VSync,
> - OUT UINT32* VBackPorch,
> - OUT UINT32* VFrontPorch
> + IN CONST UINT32 ModeNumber,
> + OUT UINT32 * CONST HRes,
> + OUT UINT32 * CONST HSync,
> + OUT UINT32 * CONST HBackPorch,
> + OUT UINT32 * CONST HFrontPorch,
> + OUT UINT32 * CONST VRes,
> + OUT UINT32 * CONST VSync,
> + OUT UINT32 * CONST VBackPorch,
> + OUT UINT32 * CONST VFrontPorch
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -359,8 +359,8 @@ LcdPlatformGetTimings (
> **/
> EFI_STATUS
> LcdPlatformGetBpp (
> - IN UINT32 ModeNumber,
> - OUT LCD_BPP * Bpp
> + IN CONST UINT32 ModeNumber,
> + OUT LCD_BPP * CONST Bpp
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 84880e5fd1dfe6f824b27e53926f9bb32ff6cdf7..6ae13f06d8b396ea1c67f0bcd735a9d70f476400 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -43,7 +43,7 @@ typedef struct {
>
> /** The display modes supported by the platform.
> **/
> -LCD_RESOLUTION mResolutions[] = {
> +STATIC CONST LCD_RESOLUTION mResolutions[] = {
> { // Mode 0 : VGA : 640 x 480 x 24 bpp
> VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> VGA_OSC_FREQUENCY,
> @@ -195,8 +195,8 @@ LcdPlatformInitializeDisplay (
> **/
> EFI_STATUS
> LcdPlatformGetVram (
> - OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> - OUT UINTN* VramSize
> + OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> + OUT UINTN * CONST VramSize
> )
> {
> EFI_STATUS Status;
> @@ -283,7 +283,7 @@ LcdPlatformGetMaxMode(VOID)
> **/
> EFI_STATUS
> LcdPlatformSetMode (
> - IN UINT32 ModeNumber
> + IN CONST UINT32 ModeNumber
> )
> {
> EFI_STATUS Status;
> @@ -363,8 +363,8 @@ LcdPlatformSetMode (
> **/
> EFI_STATUS
> LcdPlatformQueryMode (
> - IN UINT32 ModeNumber,
> - OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
> + IN CONST UINT32 ModeNumber,
> + OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -418,15 +418,15 @@ LcdPlatformQueryMode (
> **/
> EFI_STATUS
> LcdPlatformGetTimings (
> - IN UINT32 ModeNumber,
> - OUT UINT32* HRes,
> - OUT UINT32* HSync,
> - OUT UINT32* HBackPorch,
> - OUT UINT32* HFrontPorch,
> - OUT UINT32* VRes,
> - OUT UINT32* VSync,
> - OUT UINT32* VBackPorch,
> - OUT UINT32* VFrontPorch
> + IN CONST UINT32 ModeNumber,
> + OUT UINT32 * CONST HRes,
> + OUT UINT32 * CONST HSync,
> + OUT UINT32 * CONST HBackPorch,
> + OUT UINT32 * CONST HFrontPorch,
> + OUT UINT32 * CONST VRes,
> + OUT UINT32 * CONST VSync,
> + OUT UINT32 * CONST VBackPorch,
> + OUT UINT32 * CONST VFrontPorch
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -455,8 +455,8 @@ LcdPlatformGetTimings (
> **/
> EFI_STATUS
> LcdPlatformGetBpp (
> - IN UINT32 ModeNumber,
> - OUT LCD_BPP * Bpp
> + IN CONST UINT32 ModeNumber,
> + OUT LCD_BPP * CONST Bpp
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> index 744dd3d556b5071defc6bcad5a9a30881bcb4b6f..5f950579720fb69e0a481f697a5cc4038158b409 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> @@ -37,7 +37,7 @@
> **/
> EFI_STATUS
> LcdInitialize (
> - IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> + IN CONST EFI_PHYSICAL_ADDRESS VramBaseAddress
> )
> {
> // Disable the controller
> @@ -81,7 +81,7 @@ LcdInitialize (
> **/
> EFI_STATUS
> LcdSetMode (
> - IN UINT32 ModeNumber
> + IN CONST UINT32 ModeNumber
> )
> {
> EFI_STATUS Status;
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> index f8a3c1f8266c0a11f111c3747688defc0d49877c..386e6140a69b045f77ee7fa60c4587d8bf4e7d54 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> @@ -62,7 +62,7 @@ LcdIdentify (
> **/
> EFI_STATUS
> LcdInitialize (
> - IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> + IN CONST EFI_PHYSICAL_ADDRESS VramBaseAddress
> )
> {
> // Define start of the VRAM. This never changes for any graphics mode
> @@ -83,7 +83,7 @@ LcdInitialize (
> **/
> EFI_STATUS
> LcdSetMode (
> - IN UINT32 ModeNumber
> + IN CONST UINT32 ModeNumber
> )
> {
> EFI_STATUS Status;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const qualifier
2017-09-26 20:15 ` [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const qualifier evan.lloyd
2017-10-12 19:07 ` Leif Lindholm
@ 2017-10-12 19:47 ` Ard Biesheuvel
2017-12-01 16:17 ` Evan Lloyd
1 sibling, 1 reply; 69+ messages in thread
From: Ard Biesheuvel @ 2017-10-12 19:47 UTC (permalink / raw)
To: Evan Lloyd
Cc: edk2-devel@lists.01.org, "ard.biesheuvel, "leif.lindholm,
"Matteo.Carlini, "nd
On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> This change adds some STATIC and CONST qualifiers (mainly to arguments
> of functions) in PL111 and HdLcd modules.
>
> It doesn't add or modify any functionality.
>
> 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>
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 34 ++++++++++----------
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 34 ++++++++++----------
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 4 +--
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 4 +--
> 4 files changed, 38 insertions(+), 38 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index cfe3259d3c737de240350e8c3eab867b80c40948..b9859a56988f7e5be0adbaa49048a683fe586bfe 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -46,7 +46,7 @@ typedef struct {
>
> /** The display modes supported by the platform.
> **/
> -LCD_RESOLUTION mResolutions[] = {
> +STATIC CONST LCD_RESOLUTION mResolutions[] = {
> { // Mode 0 : VGA : 640 x 480 x 24 bpp
> VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> VGA_OSC_FREQUENCY,
> @@ -144,8 +144,8 @@ LcdPlatformInitializeDisplay (
> **/
> EFI_STATUS
> LcdPlatformGetVram (
> - OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> - OUT UINTN* VramSize
> + OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> + OUT UINTN * CONST VramSize
What is the point of this CONST (and all the other occurrences in this patch)
In all cases [AFAICT] the CONST applies to the argument itself, not to
the object it points to, which means the variable is CONST in the
scope of the function, but can still be dereferenced to assign the OUT
value.
This means your change is technically correct, but it is extremely
unidiomatic for EDK2, so an explanation why this driver needs this
would be highly appreciated.
> )
> {
> EFI_STATUS Status;
> @@ -209,7 +209,7 @@ LcdPlatformGetMaxMode(VOID)
> **/
> EFI_STATUS
> LcdPlatformSetMode (
> - IN UINT32 ModeNumber
> + IN CONST UINT32 ModeNumber
> )
> {
> EFI_STATUS Status;
> @@ -267,8 +267,8 @@ LcdPlatformSetMode (
> **/
> EFI_STATUS
> LcdPlatformQueryMode (
> - IN UINT32 ModeNumber,
> - OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
> + IN CONST UINT32 ModeNumber,
> + OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -322,15 +322,15 @@ LcdPlatformQueryMode (
> **/
> EFI_STATUS
> LcdPlatformGetTimings (
> - IN UINT32 ModeNumber,
> - OUT UINT32* HRes,
> - OUT UINT32* HSync,
> - OUT UINT32* HBackPorch,
> - OUT UINT32* HFrontPorch,
> - OUT UINT32* VRes,
> - OUT UINT32* VSync,
> - OUT UINT32* VBackPorch,
> - OUT UINT32* VFrontPorch
> + IN CONST UINT32 ModeNumber,
> + OUT UINT32 * CONST HRes,
> + OUT UINT32 * CONST HSync,
> + OUT UINT32 * CONST HBackPorch,
> + OUT UINT32 * CONST HFrontPorch,
> + OUT UINT32 * CONST VRes,
> + OUT UINT32 * CONST VSync,
> + OUT UINT32 * CONST VBackPorch,
> + OUT UINT32 * CONST VFrontPorch
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -359,8 +359,8 @@ LcdPlatformGetTimings (
> **/
> EFI_STATUS
> LcdPlatformGetBpp (
> - IN UINT32 ModeNumber,
> - OUT LCD_BPP * Bpp
> + IN CONST UINT32 ModeNumber,
> + OUT LCD_BPP * CONST Bpp
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 84880e5fd1dfe6f824b27e53926f9bb32ff6cdf7..6ae13f06d8b396ea1c67f0bcd735a9d70f476400 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -43,7 +43,7 @@ typedef struct {
>
> /** The display modes supported by the platform.
> **/
> -LCD_RESOLUTION mResolutions[] = {
> +STATIC CONST LCD_RESOLUTION mResolutions[] = {
> { // Mode 0 : VGA : 640 x 480 x 24 bpp
> VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> VGA_OSC_FREQUENCY,
> @@ -195,8 +195,8 @@ LcdPlatformInitializeDisplay (
> **/
> EFI_STATUS
> LcdPlatformGetVram (
> - OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> - OUT UINTN* VramSize
> + OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> + OUT UINTN * CONST VramSize
> )
> {
> EFI_STATUS Status;
> @@ -283,7 +283,7 @@ LcdPlatformGetMaxMode(VOID)
> **/
> EFI_STATUS
> LcdPlatformSetMode (
> - IN UINT32 ModeNumber
> + IN CONST UINT32 ModeNumber
> )
> {
> EFI_STATUS Status;
> @@ -363,8 +363,8 @@ LcdPlatformSetMode (
> **/
> EFI_STATUS
> LcdPlatformQueryMode (
> - IN UINT32 ModeNumber,
> - OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
> + IN CONST UINT32 ModeNumber,
> + OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -418,15 +418,15 @@ LcdPlatformQueryMode (
> **/
> EFI_STATUS
> LcdPlatformGetTimings (
> - IN UINT32 ModeNumber,
> - OUT UINT32* HRes,
> - OUT UINT32* HSync,
> - OUT UINT32* HBackPorch,
> - OUT UINT32* HFrontPorch,
> - OUT UINT32* VRes,
> - OUT UINT32* VSync,
> - OUT UINT32* VBackPorch,
> - OUT UINT32* VFrontPorch
> + IN CONST UINT32 ModeNumber,
> + OUT UINT32 * CONST HRes,
> + OUT UINT32 * CONST HSync,
> + OUT UINT32 * CONST HBackPorch,
> + OUT UINT32 * CONST HFrontPorch,
> + OUT UINT32 * CONST VRes,
> + OUT UINT32 * CONST VSync,
> + OUT UINT32 * CONST VBackPorch,
> + OUT UINT32 * CONST VFrontPorch
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -455,8 +455,8 @@ LcdPlatformGetTimings (
> **/
> EFI_STATUS
> LcdPlatformGetBpp (
> - IN UINT32 ModeNumber,
> - OUT LCD_BPP * Bpp
> + IN CONST UINT32 ModeNumber,
> + OUT LCD_BPP * CONST Bpp
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> index 744dd3d556b5071defc6bcad5a9a30881bcb4b6f..5f950579720fb69e0a481f697a5cc4038158b409 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> @@ -37,7 +37,7 @@
> **/
> EFI_STATUS
> LcdInitialize (
> - IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> + IN CONST EFI_PHYSICAL_ADDRESS VramBaseAddress
> )
> {
> // Disable the controller
> @@ -81,7 +81,7 @@ LcdInitialize (
> **/
> EFI_STATUS
> LcdSetMode (
> - IN UINT32 ModeNumber
> + IN CONST UINT32 ModeNumber
> )
> {
> EFI_STATUS Status;
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> index f8a3c1f8266c0a11f111c3747688defc0d49877c..386e6140a69b045f77ee7fa60c4587d8bf4e7d54 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> @@ -62,7 +62,7 @@ LcdIdentify (
> **/
> EFI_STATUS
> LcdInitialize (
> - IN EFI_PHYSICAL_ADDRESS VramBaseAddress
> + IN CONST EFI_PHYSICAL_ADDRESS VramBaseAddress
> )
> {
> // Define start of the VRAM. This never changes for any graphics mode
> @@ -83,7 +83,7 @@ LcdInitialize (
> **/
> EFI_STATUS
> LcdSetMode (
> - IN UINT32 ModeNumber
> + IN CONST UINT32 ModeNumber
> )
> {
> EFI_STATUS Status;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const qualifier
2017-10-12 19:47 ` Ard Biesheuvel
@ 2017-12-01 16:17 ` Evan Lloyd
2017-12-01 17:31 ` Ard Biesheuvel
0 siblings, 1 reply; 69+ messages in thread
From: Evan Lloyd @ 2017-12-01 16:17 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: edk2-devel@lists.01.org,
"ard.biesheuvel@linaro.org"@arm.com,
"leif.lindholm@linaro.org"@arm.com,
"Matteo.Carlini@arm.com"@arm.com,
"nd@arm.com"@arm.com
Hi Ard.
Response inline below
> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 12 October 2017 20:47
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; "ard.biesheuvel@linaro.org"@arm.com;
> "leif.lindholm@linaro.org"@arm.com;
> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
> Subject: Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const
> qualifier
>
> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> > From: Girish Pathak <girish.pathak@arm.com>
> >
> > This change adds some STATIC and CONST qualifiers (mainly to arguments
> > of functions) in PL111 and HdLcd modules.
> >
> > It doesn't add or modify any functionality.
> >
> > 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>
> > ---
> >
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> mVExpress.c | 34 ++++++++++----------
> >
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL11
> 1LcdArmVExpress.c | 34 ++++++++++----------
> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> | 4 +--
> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> | 4 +--
> > 4 files changed, 38 insertions(+), 38 deletions(-)
> >
> > diff --git
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> ArmVE
> > xpress.c
> >
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> ArmVE
> > xpress.c index
> >
> cfe3259d3c737de240350e8c3eab867b80c40948..b9859a56988f7e5be0ad
> baa49048
> > a683fe586bfe 100644
> > ---
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> ArmVE
> > xpress.c
> > +++
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> A
> > +++ rmVExpress.c
> > @@ -46,7 +46,7 @@ typedef struct {
> >
> > /** The display modes supported by the platform.
> > **/
> > -LCD_RESOLUTION mResolutions[] = {
> > +STATIC CONST LCD_RESOLUTION mResolutions[] = {
> > { // Mode 0 : VGA : 640 x 480 x 24 bpp
> > VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
> LCD_BITS_PER_PIXEL_24,
> > VGA_OSC_FREQUENCY,
> > @@ -144,8 +144,8 @@ LcdPlatformInitializeDisplay ( **/ EFI_STATUS
> > LcdPlatformGetVram (
> > - OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> > - OUT UINTN* VramSize
> > + OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> > + OUT UINTN * CONST VramSize
>
> What is the point of this CONST (and all the other occurrences in this patch)
>
> In all cases [AFAICT] the CONST applies to the argument itself, not to the
> object it points to, which means the variable is CONST in the scope of the
> function, but can still be dereferenced to assign the OUT value.
>
> This means your change is technically correct, but it is extremely
> unidiomatic for EDK2, so an explanation why this driver needs this would be
> highly appreciated.
>
[[Evan Lloyd]] The style is explicitly sanctioned by the Edk2 CCS § 5.6.2.4.2
" Constant pointer to variable: UINTN * CONST ConstPointer;
ConstPointer is a constant pointer to a variable UINTN."
The real benefit is that it clearly identifies the pointer as not changed in the function.
In this specific instance that also makes it obvious that the OUT parameters are not array bases, just pointers to individual values.
On a broader note - why would you ever not have a const where something is not modified?
As another view, the "unidiomatic for EDK2" argument implies you have a very high opinion of the existing ArmPlatformPkg code quality.
The "we have always done it that way" argument does not encourage quality improvements.
Regards,
Evan
> > )
...
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const qualifier
2017-12-01 16:17 ` Evan Lloyd
@ 2017-12-01 17:31 ` Ard Biesheuvel
2017-12-05 20:35 ` Evan Lloyd
0 siblings, 1 reply; 69+ messages in thread
From: Ard Biesheuvel @ 2017-12-01 17:31 UTC (permalink / raw)
To: Evan Lloyd
Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org@arm.com,
leif.lindholm@linaro.org@arm.com, Matteo.Carlini@arm.com@arm.com,
nd@arm.com@arm.com
On 1 December 2017 at 16:17, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> Hi Ard.
> Response inline below
>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 12 October 2017 20:47
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: edk2-devel@lists.01.org; "ard.biesheuvel@linaro.org"@arm.com;
>> "leif.lindholm@linaro.org"@arm.com;
>> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
>> Subject: Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const
>> qualifier
>>
>> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
>> > From: Girish Pathak <girish.pathak@arm.com>
>> >
>> > This change adds some STATIC and CONST qualifiers (mainly to arguments
>> > of functions) in PL111 and HdLcd modules.
>> >
>> > It doesn't add or modify any functionality.
>> >
>> > 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>
>> > ---
>> >
>> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
>> mVExpress.c | 34 ++++++++++----------
>> >
>> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL11
>> 1LcdArmVExpress.c | 34 ++++++++++----------
>> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
>> | 4 +--
>> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
>> | 4 +--
>> > 4 files changed, 38 insertions(+), 38 deletions(-)
>> >
>> > diff --git
>> >
>> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> ArmVE
>> > xpress.c
>> >
>> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> ArmVE
>> > xpress.c index
>> >
>> cfe3259d3c737de240350e8c3eab867b80c40948..b9859a56988f7e5be0ad
>> baa49048
>> > a683fe586bfe 100644
>> > ---
>> >
>> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> ArmVE
>> > xpress.c
>> > +++
>> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> A
>> > +++ rmVExpress.c
>> > @@ -46,7 +46,7 @@ typedef struct {
>> >
>> > /** The display modes supported by the platform.
>> > **/
>> > -LCD_RESOLUTION mResolutions[] = {
>> > +STATIC CONST LCD_RESOLUTION mResolutions[] = {
>> > { // Mode 0 : VGA : 640 x 480 x 24 bpp
>> > VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
>> LCD_BITS_PER_PIXEL_24,
>> > VGA_OSC_FREQUENCY,
>> > @@ -144,8 +144,8 @@ LcdPlatformInitializeDisplay ( **/ EFI_STATUS
>> > LcdPlatformGetVram (
>> > - OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
>> > - OUT UINTN* VramSize
>> > + OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
>> > + OUT UINTN * CONST VramSize
>>
>> What is the point of this CONST (and all the other occurrences in this patch)
>>
>> In all cases [AFAICT] the CONST applies to the argument itself, not to the
>> object it points to, which means the variable is CONST in the scope of the
>> function, but can still be dereferenced to assign the OUT value.
>>
>> This means your change is technically correct, but it is extremely
>> unidiomatic for EDK2, so an explanation why this driver needs this would be
>> highly appreciated.
>>
> [[Evan Lloyd]] The style is explicitly sanctioned by the Edk2 CCS § 5.6.2.4.2
> " Constant pointer to variable: UINTN * CONST ConstPointer;
> ConstPointer is a constant pointer to a variable UINTN."
>
That paragraph is not about function prototypes, but about constant
pointers in general.
> The real benefit is that it clearly identifies the pointer as not changed in the function.
> In this specific instance that also makes it obvious that the OUT parameters are not array bases, just pointers to individual values.
>
> On a broader note - why would you ever not have a const where something is not modified?
>
> As another view, the "unidiomatic for EDK2" argument implies you have a very high opinion of the existing ArmPlatformPkg code quality.
> The "we have always done it that way" argument does not encourage quality improvements.
>
This may all be true. But the fact remains that 99% of the EDK2 code
does not constify its function parameters, and I was simply asking why
we should deviate from that in this driver.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const qualifier
2017-12-01 17:31 ` Ard Biesheuvel
@ 2017-12-05 20:35 ` Evan Lloyd
2017-12-05 20:54 ` Ard Biesheuvel
0 siblings, 1 reply; 69+ messages in thread
From: Evan Lloyd @ 2017-12-05 20:35 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org@arm.com,
leif.lindholm@linaro.org@arm.com, Matteo.Carlini@arm.com@arm.com,
nd@arm.com@arm.com
> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 01 December 2017 17:32
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; ard.biesheuvel@linaro.org@arm.com
> <"ard.biesheuvel@linaro.org"@arm.com>;
> leif.lindholm@linaro.org@arm.com <"leif.lindholm@linaro.org"@arm.com>;
> Matteo.Carlini@arm.com@arm.com
> <"Matteo.Carlini@arm.com"@arm.com>; nd@arm.com@arm.com
> <"nd@arm.com"@arm.com>
> Subject: Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const
> qualifier
>
> On 1 December 2017 at 16:17, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> > Hi Ard.
> > Response inline below
> >
> >> -----Original Message-----
> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> >> Sent: 12 October 2017 20:47
> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
> >> Cc: edk2-devel@lists.01.org; "ard.biesheuvel@linaro.org"@arm.com;
> >> "leif.lindholm@linaro.org"@arm.com;
> >> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
> >> Subject: Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add
> const
> >> qualifier
> >>
> >> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> >> > From: Girish Pathak <girish.pathak@arm.com>
> >> >
> >> > This change adds some STATIC and CONST qualifiers (mainly to
> >> > arguments of functions) in PL111 and HdLcd modules.
> >> >
> >> > It doesn't add or modify any functionality.
> >> >
> >> > 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>
> >> > ---
> >> >
> >>
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> >> mVExpress.c | 34 ++++++++++----------
> >> >
> >>
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL11
> >> 1LcdArmVExpress.c | 34 ++++++++++----------
> >> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> | 4 +--
> >> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> | 4 +--
> >> > 4 files changed, 38 insertions(+), 38 deletions(-)
> >> >
> >> > diff --git
> >> >
> >>
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c
> >> >
> >>
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c index
> >> >
> >>
> cfe3259d3c737de240350e8c3eab867b80c40948..b9859a56988f7e5be0ad
> >> baa49048
> >> > a683fe586bfe 100644
> >> > ---
> >> >
> >>
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c
> >> > +++
> >>
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> A
> >> > +++ rmVExpress.c
> >> > @@ -46,7 +46,7 @@ typedef struct {
> >> >
> >> > /** The display modes supported by the platform.
> >> > **/
> >> > -LCD_RESOLUTION mResolutions[] = {
> >> > +STATIC CONST LCD_RESOLUTION mResolutions[] = {
> >> > { // Mode 0 : VGA : 640 x 480 x 24 bpp
> >> > VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
> >> LCD_BITS_PER_PIXEL_24,
> >> > VGA_OSC_FREQUENCY,
> >> > @@ -144,8 +144,8 @@ LcdPlatformInitializeDisplay ( **/ EFI_STATUS
> >> > LcdPlatformGetVram (
> >> > - OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
> >> > - OUT UINTN* VramSize
> >> > + OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> >> > + OUT UINTN * CONST VramSize
> >>
> >> What is the point of this CONST (and all the other occurrences in
> >> this patch)
> >>
> >> In all cases [AFAICT] the CONST applies to the argument itself, not
> >> to the object it points to, which means the variable is CONST in the
> >> scope of the function, but can still be dereferenced to assign the OUT
> value.
> >>
> >> This means your change is technically correct, but it is extremely
> >> unidiomatic for EDK2, so an explanation why this driver needs this
> >> would be highly appreciated.
> >>
> > [[Evan Lloyd]] The style is explicitly sanctioned by the Edk2 CCS §
> > 5.6.2.4.2 " Constant pointer to variable: UINTN * CONST ConstPointer;
> > ConstPointer is a constant pointer to a variable UINTN."
> >
>
> That paragraph is not about function prototypes, but about constant
> pointers in general.
>
> > The real benefit is that it clearly identifies the pointer as not changed in
> the function.
> > In this specific instance that also makes it obvious that the OUT
> parameters are not array bases, just pointers to individual values.
> >
> > On a broader note - why would you ever not have a const where
> something is not modified?
> >
> > As another view, the "unidiomatic for EDK2" argument implies you have a
> very high opinion of the existing ArmPlatformPkg code quality.
> > The "we have always done it that way" argument does not encourage
> quality improvements.
> >
>
> This may all be true. But the fact remains that 99% of the EDK2 code does
> not constify its function parameters, and I was simply asking why we should
> deviate from that in this driver.
[[Evan Lloyd]] And the simple answer is that it is good practice, providing cleaner, clearer, safer code. As support for that viewpoint: the CCS references MISRA-C (strangely without making use of the reference, but ...), and MISRA-C has, for example:
"Rule 8.13: A pointer should point to a const qualified type where possible"
(NOTE: I don't think it realistic to move edk2 to MISRA-C rules, but they do provide a useful guide to safer practice.)
A further point is that it certainly does no harm, and there is negligible benefit and some cost to reducing the quality of tested code.
I am also impelled to ask: if 99% of the code is so superb, why are there so many commits from Ard Biesheuvel? (Please note attempt at ironic humour here.)
Regards,
Evan
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const qualifier
2017-12-05 20:35 ` Evan Lloyd
@ 2017-12-05 20:54 ` Ard Biesheuvel
0 siblings, 0 replies; 69+ messages in thread
From: Ard Biesheuvel @ 2017-12-05 20:54 UTC (permalink / raw)
To: Evan Lloyd; +Cc: edk2-devel@lists.01.org, Leif Lindholm, Matteo Carlini
On 5 December 2017 at 20:35, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>
>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 01 December 2017 17:32
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: edk2-devel@lists.01.org; ard.biesheuvel@linaro.org@arm.com
>> <"ard.biesheuvel@linaro.org"@arm.com>;
>> leif.lindholm@linaro.org@arm.com <"leif.lindholm@linaro.org"@arm.com>;
>> Matteo.Carlini@arm.com@arm.com
>> <"Matteo.Carlini@arm.com"@arm.com>; nd@arm.com@arm.com
>> <"nd@arm.com"@arm.com>
>> Subject: Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const
>> qualifier
>>
>> On 1 December 2017 at 16:17, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>> > Hi Ard.
>> > Response inline below
>> >
>> >> -----Original Message-----
>> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> >> Sent: 12 October 2017 20:47
>> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> >> Cc: edk2-devel@lists.01.org; "ard.biesheuvel@linaro.org"@arm.com;
>> >> "leif.lindholm@linaro.org"@arm.com;
>> >> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
>> >> Subject: Re: [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add
>> const
>> >> qualifier
>> >>
>> >> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
>> >> > From: Girish Pathak <girish.pathak@arm.com>
>> >> >
>> >> > This change adds some STATIC and CONST qualifiers (mainly to
>> >> > arguments of functions) in PL111 and HdLcd modules.
>> >> >
>> >> > It doesn't add or modify any functionality.
>> >> >
>> >> > 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>
>> >> > ---
>> >> >
>> >>
>> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
>> >> mVExpress.c | 34 ++++++++++----------
>> >> >
>> >>
>> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL11
>> >> 1LcdArmVExpress.c | 34 ++++++++++----------
>> >> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
>> >> | 4 +--
>> >> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
>> >> | 4 +--
>> >> > 4 files changed, 38 insertions(+), 38 deletions(-)
>> >> >
>> >> > diff --git
>> >> >
>> >>
>> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> >> ArmVE
>> >> > xpress.c
>> >> >
>> >>
>> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> >> ArmVE
>> >> > xpress.c index
>> >> >
>> >>
>> cfe3259d3c737de240350e8c3eab867b80c40948..b9859a56988f7e5be0ad
>> >> baa49048
>> >> > a683fe586bfe 100644
>> >> > ---
>> >> >
>> >>
>> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> >> ArmVE
>> >> > xpress.c
>> >> > +++
>> >>
>> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> >> A
>> >> > +++ rmVExpress.c
>> >> > @@ -46,7 +46,7 @@ typedef struct {
>> >> >
>> >> > /** The display modes supported by the platform.
>> >> > **/
>> >> > -LCD_RESOLUTION mResolutions[] = {
>> >> > +STATIC CONST LCD_RESOLUTION mResolutions[] = {
>> >> > { // Mode 0 : VGA : 640 x 480 x 24 bpp
>> >> > VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS,
>> >> LCD_BITS_PER_PIXEL_24,
>> >> > VGA_OSC_FREQUENCY,
>> >> > @@ -144,8 +144,8 @@ LcdPlatformInitializeDisplay ( **/ EFI_STATUS
>> >> > LcdPlatformGetVram (
>> >> > - OUT EFI_PHYSICAL_ADDRESS* VramBaseAddress,
>> >> > - OUT UINTN* VramSize
>> >> > + OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
>> >> > + OUT UINTN * CONST VramSize
>> >>
>> >> What is the point of this CONST (and all the other occurrences in
>> >> this patch)
>> >>
>> >> In all cases [AFAICT] the CONST applies to the argument itself, not
>> >> to the object it points to, which means the variable is CONST in the
>> >> scope of the function, but can still be dereferenced to assign the OUT
>> value.
>> >>
>> >> This means your change is technically correct, but it is extremely
>> >> unidiomatic for EDK2, so an explanation why this driver needs this
>> >> would be highly appreciated.
>> >>
>> > [[Evan Lloyd]] The style is explicitly sanctioned by the Edk2 CCS §
>> > 5.6.2.4.2 " Constant pointer to variable: UINTN * CONST ConstPointer;
>> > ConstPointer is a constant pointer to a variable UINTN."
>> >
>>
>> That paragraph is not about function prototypes, but about constant
>> pointers in general.
>>
>> > The real benefit is that it clearly identifies the pointer as not changed in
>> the function.
>> > In this specific instance that also makes it obvious that the OUT
>> parameters are not array bases, just pointers to individual values.
>> >
>> > On a broader note - why would you ever not have a const where
>> something is not modified?
>> >
>> > As another view, the "unidiomatic for EDK2" argument implies you have a
>> very high opinion of the existing ArmPlatformPkg code quality.
>> > The "we have always done it that way" argument does not encourage
>> quality improvements.
>> >
>>
>> This may all be true. But the fact remains that 99% of the EDK2 code does
>> not constify its function parameters, and I was simply asking why we should
>> deviate from that in this driver.
> [[Evan Lloyd]] And the simple answer is that it is good practice, providing cleaner, clearer, safer code. As support for that viewpoint: the CCS references MISRA-C (strangely without making use of the reference, but ...), and MISRA-C has, for example:
> "Rule 8.13: A pointer should point to a const qualified type where possible"
>
Should *point to* which means
UINTN CONST *Var
not
UINTN * CONST Var
as you are proposing, so this reference is completely irrelevant.
> (NOTE: I don't think it realistic to move edk2 to MISRA-C rules, but they do provide a useful guide to safer practice.)
>
Well, for the firmware in my ABS brake system, yes, but for higher
level stuff it is overly restrictive imo.
> A further point is that it certainly does no harm, and there is negligible benefit and some cost to reducing the quality of tested code.
>
I have read that sentence a couple of times, and I don't understand
what you are trying to say here - sorry. Could you rephrase that?
> I am also impelled to ask: if 99% of the code is so superb, why are there so many commits from Ard Biesheuvel? (Please note attempt at ironic humour here.)
>
No amount of drugs or alcohol could ever elicit such a statement from
me. I was merely pointing out that constifying function arguments is
very uncommon, in any project I am involved in. (EDK2, Linux, Qemu)
I agree that it may help catch programming errors, but beyond that, I
think the value is limited. I won't object to new code that does it,
but changing existing code is just churn imo.
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (2 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 03/19] ArmPlatformPkg: PL111 and HDLCD: add const qualifier evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-12 19:32 ` Leif Lindholm
2017-10-13 7:33 ` Ard Biesheuvel
2017-09-26 20:15 ` [PATCH 05/19] ArmPlatformPkg: PL111LcdArmVExpressLib: Minor code cleanup evan.lloyd
` (14 subsequent siblings)
18 siblings, 2 replies; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
This change adds some debug assertions e.g to catch NULL pointer errors
missing in PL11Lcd and HdLcd modules.
This change also improves related error handling code.
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>
---
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 44 ++++++++++++++++++--
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 43 ++++++++++++++++++-
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 8 ++--
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 8 ++--
4 files changed, 90 insertions(+), 13 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index b9859a56988f7e5be0adbaa49048a683fe586bfe..58dd9f0c77e1bc9af559a71d0c7cce72d71c6da5 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -140,6 +140,7 @@ LcdPlatformInitializeDisplay (
* buffer in bytes
*
* @retval EFI_SUCCESS Frame buffer memory allocation success.
+ * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize are NULL.
* @retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
@@ -151,6 +152,13 @@ LcdPlatformGetVram (
EFI_STATUS Status;
EFI_ALLOCATE_TYPE AllocationType;
+ // Check VramBaseAddress and VramSize are not NULL.
+ if (VramBaseAddress == NULL || VramSize == NULL) {
+ ASSERT (VramBaseAddress != NULL);
+ ASSERT (VramSize != NULL);
+ return EFI_INVALID_PARAMETER;
+ }
+
// Set the vram size
*VramSize = LCD_VRAM_SIZE;
@@ -169,6 +177,7 @@ LcdPlatformGetVram (
VramBaseAddress
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -179,8 +188,8 @@ LcdPlatformGetVram (
*VramSize,
EFI_MEMORY_WC
);
- ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
return Status;
}
@@ -215,6 +224,7 @@ LcdPlatformSetMode (
EFI_STATUS Status;
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+ ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
return EFI_INVALID_PARAMETER;
}
@@ -264,6 +274,7 @@ LcdPlatformSetMode (
*
* @retval EFI_SUCCESS Success if the requested mode is found.
* @retval EFI_INVALID_PARAMETER Requested mode not found.
+ * @retval EFI_INVALID_PARAMETER Info is NULL.
**/
EFI_STATUS
LcdPlatformQueryMode (
@@ -271,7 +282,9 @@ LcdPlatformQueryMode (
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
)
{
- if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+ if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
+ ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
+ ASSERT (Info != NULL);
return EFI_INVALID_PARAMETER;
}
@@ -334,6 +347,28 @@ LcdPlatformGetTimings (
)
{
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+ ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (HRes == NULL
+ || HSync == NULL
+ || HBackPorch == NULL
+ || HFrontPorch == NULL
+ || VRes == NULL
+ || VSync == NULL
+ || VBackPorch == NULL
+ || VFrontPorch == NULL)
+ {
+ // One of the pointers is NULL
+ ASSERT (HRes != NULL);
+ ASSERT (HSync != NULL);
+ ASSERT (HBackPorch != NULL);
+ ASSERT (HFrontPorch != NULL);
+ ASSERT (VRes != NULL);
+ ASSERT (VSync != NULL);
+ ASSERT (VBackPorch != NULL);
+ ASSERT (VFrontPorch != NULL);
return EFI_INVALID_PARAMETER;
}
@@ -356,6 +391,7 @@ LcdPlatformGetTimings (
*
* @retval EFI_SUCCESS The requested mode is found.
* @retval EFI_INVALID_PARAMETER Requested mode not found.
+ * @retval EFI_INVALID_PARAMETER Bpp is NULL.
**/
EFI_STATUS
LcdPlatformGetBpp (
@@ -363,7 +399,9 @@ LcdPlatformGetBpp (
OUT LCD_BPP * CONST Bpp
)
{
- if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+ if (ModeNumber >= LcdPlatformGetMaxMode () || Bpp == NULL) {
+ ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
+ ASSERT (Bpp != NULL);
return EFI_INVALID_PARAMETER;
}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 6ae13f06d8b396ea1c67f0bcd735a9d70f476400..5a4abd4c6f9e84d3d690af7233c1cebfe1ad339b 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -191,6 +191,7 @@ LcdPlatformInitializeDisplay (
* buffer in bytes
*
* @retval EFI_SUCCESS Frame buffer memory allocation success.
+ * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize is NULL.
* @retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
@@ -203,6 +204,13 @@ LcdPlatformGetVram (
Status = EFI_SUCCESS;
+ // Check VramBaseAddress and VramSize are not NULL.
+ if (VramBaseAddress == NULL || VramSize == NULL) {
+ ASSERT (VramBaseAddress != NULL);
+ ASSERT (VramSize != NULL);
+ return EFI_INVALID_PARAMETER;
+ }
+
// Is it on the motherboard or on the daughterboard?
switch (PL111_CLCD_SITE) {
@@ -223,6 +231,7 @@ LcdPlatformGetVram (
VramBaseAddress
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -233,8 +242,8 @@ LcdPlatformGetVram (
*VramSize,
EFI_MEMORY_WC
);
- ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
return Status;
}
@@ -293,6 +302,7 @@ LcdPlatformSetMode (
UINT32 SysId;
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+ ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
return EFI_INVALID_PARAMETER;
}
@@ -359,6 +369,7 @@ LcdPlatformSetMode (
* (on success).
*
* @retval EFI_SUCCESS Success if the requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Info is NULL.
* @retval EFI_INVALID_PARAMETER Requested mode not found.
**/
EFI_STATUS
@@ -367,7 +378,9 @@ LcdPlatformQueryMode (
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
)
{
- if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+ if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
+ ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
+ ASSERT (Info != NULL);
return EFI_INVALID_PARAMETER;
}
@@ -415,6 +428,7 @@ LcdPlatformQueryMode (
*
* @retval EFI_SUCCESS Success if the requested mode is found.
* @retval EFI_INVALID_PARAMETER Requested mode not found.
+ * @retval EFI_INVALID_PARAMETER One of the OUT parameters is NULL.
**/
EFI_STATUS
LcdPlatformGetTimings (
@@ -430,6 +444,28 @@ LcdPlatformGetTimings (
)
{
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+ ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (HRes == NULL
+ || HSync == NULL
+ || HBackPorch == NULL
+ || HFrontPorch == NULL
+ || VRes == NULL
+ || VSync == NULL
+ || VBackPorch == NULL
+ || VFrontPorch == NULL)
+ {
+ // One of the pointers is NULL
+ ASSERT (HRes != NULL);
+ ASSERT (HSync != NULL);
+ ASSERT (HBackPorch != NULL);
+ ASSERT (HFrontPorch != NULL);
+ ASSERT (VRes != NULL);
+ ASSERT (VSync != NULL);
+ ASSERT (VBackPorch != NULL);
+ ASSERT (VFrontPorch != NULL);
return EFI_INVALID_PARAMETER;
}
@@ -452,6 +488,7 @@ LcdPlatformGetTimings (
*
* @retval EFI_SUCCESS The requested mode is found.
* @retval EFI_INVALID_PARAMETER Requested mode not found.
+ * @retval EFI_INVALID_PARAMETER Bpp is NULL.
**/
EFI_STATUS
LcdPlatformGetBpp (
@@ -460,6 +497,8 @@ LcdPlatformGetBpp (
)
{
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
+ ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
+ ASSERT (Bpp != NULL);
return EFI_INVALID_PARAMETER;
}
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
index 5f950579720fb69e0a481f697a5cc4038158b409..a266671a26f01d31e8ddb0cf7cbfe59d2f4dc49c 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
@@ -109,15 +109,15 @@ LcdSetMode (
&VBackPorch,
&VFrontPorch
);
- ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
- ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
BytesPerPixel = GetBytesPerPixel (LcdBpp);
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
index 386e6140a69b045f77ee7fa60c4587d8bf4e7d54..f432c8d802614e8a0e4ddab3898f6e0dbf9a1572 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
@@ -110,15 +110,15 @@ LcdSetMode (
&VBackPorch,
&VFrontPorch
);
- ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
- ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Disable the CLCD_LcdEn bit
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
2017-09-26 20:15 ` [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts evan.lloyd
@ 2017-10-12 19:32 ` Leif Lindholm
2017-10-13 7:33 ` Ard Biesheuvel
1 sibling, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-12 19:32 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:14PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> This change adds some debug assertions e.g to catch NULL pointer errors
> missing in PL11Lcd and HdLcd modules.
>
> This change also improves related error handling code.
>
> 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>
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 44 ++++++++++++++++++--
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 43 ++++++++++++++++++-
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 8 ++--
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 8 ++--
> 4 files changed, 90 insertions(+), 13 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index b9859a56988f7e5be0adbaa49048a683fe586bfe..58dd9f0c77e1bc9af559a71d0c7cce72d71c6da5 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -140,6 +140,7 @@ LcdPlatformInitializeDisplay (
> * buffer in bytes
> *
> * @retval EFI_SUCCESS Frame buffer memory allocation success.
> + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize are NULL.
> * @retval !(EFI_SUCCESS) Other errors.
> **/
> EFI_STATUS
> @@ -151,6 +152,13 @@ LcdPlatformGetVram (
> EFI_STATUS Status;
> EFI_ALLOCATE_TYPE AllocationType;
>
> + // Check VramBaseAddress and VramSize are not NULL.
> + if (VramBaseAddress == NULL || VramSize == NULL) {
> + ASSERT (VramBaseAddress != NULL);
> + ASSERT (VramSize != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
The above is not just a debug assertion change, it also changes
behaviour for RELEASE builds.
I have no objection to these changes in the same patch, but it makes
the commit message misleading. Can you update that please, to say
"adds debug assertions and runtime checks"?
> // Set the vram size
> *VramSize = LCD_VRAM_SIZE;
>
> @@ -169,6 +177,7 @@ LcdPlatformGetVram (
> VramBaseAddress
> );
> if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> return Status;
> }
>
> @@ -179,8 +188,8 @@ LcdPlatformGetVram (
> *VramSize,
> EFI_MEMORY_WC
> );
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> return Status;
> }
> @@ -215,6 +224,7 @@ LcdPlatformSetMode (
> EFI_STATUS Status;
>
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
Is this asserting that LcdPlatformGetMaxMode() returns the same thing
if called twice?
If you just always want to assert when reached, use ASSERT (FALSE).
If you explicitly want the message to tell you which operation went
wrong, please use a temporary variable rather than calling a function twice.
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -264,6 +274,7 @@ LcdPlatformSetMode (
> *
> * @retval EFI_SUCCESS Success if the requested mode is found.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER Info is NULL.
> **/
> EFI_STATUS
> LcdPlatformQueryMode (
> @@ -271,7 +282,9 @@ LcdPlatformQueryMode (
> OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> )
> {
> - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> + ASSERT (Info != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -334,6 +347,28 @@ LcdPlatformGetTimings (
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
ASSERT (FALSE)? Or temporary variable.
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (HRes == NULL
> + || HSync == NULL
> + || HBackPorch == NULL
> + || HFrontPorch == NULL
> + || VRes == NULL
> + || VSync == NULL
> + || VBackPorch == NULL
> + || VFrontPorch == NULL)
> + {
> + // One of the pointers is NULL
> + ASSERT (HRes != NULL);
> + ASSERT (HSync != NULL);
> + ASSERT (HBackPorch != NULL);
> + ASSERT (HFrontPorch != NULL);
> + ASSERT (VRes != NULL);
> + ASSERT (VSync != NULL);
> + ASSERT (VBackPorch != NULL);
> + ASSERT (VFrontPorch != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -356,6 +391,7 @@ LcdPlatformGetTimings (
> *
> * @retval EFI_SUCCESS The requested mode is found.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> **/
> EFI_STATUS
> LcdPlatformGetBpp (
> @@ -363,7 +399,9 @@ LcdPlatformGetBpp (
> OUT LCD_BPP * CONST Bpp
> )
> {
> - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + if (ModeNumber >= LcdPlatformGetMaxMode () || Bpp == NULL) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> + ASSERT (Bpp != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 6ae13f06d8b396ea1c67f0bcd735a9d70f476400..5a4abd4c6f9e84d3d690af7233c1cebfe1ad339b 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -191,6 +191,7 @@ LcdPlatformInitializeDisplay (
> * buffer in bytes
> *
> * @retval EFI_SUCCESS Frame buffer memory allocation success.
> + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize is NULL.
> * @retval !(EFI_SUCCESS) Other errors.
> **/
> EFI_STATUS
> @@ -203,6 +204,13 @@ LcdPlatformGetVram (
>
> Status = EFI_SUCCESS;
>
> + // Check VramBaseAddress and VramSize are not NULL.
> + if (VramBaseAddress == NULL || VramSize == NULL) {
> + ASSERT (VramBaseAddress != NULL);
> + ASSERT (VramSize != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
> // Is it on the motherboard or on the daughterboard?
> switch (PL111_CLCD_SITE) {
>
> @@ -223,6 +231,7 @@ LcdPlatformGetVram (
> VramBaseAddress
> );
> if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
ASSERT (FALSE)? (You already know Status is an EFI_ERROR, and a
console message saying ASSERT (Status) is not getting you out of
looking at the source code to find out what happened.)
> return Status;
> }
>
> @@ -233,8 +242,8 @@ LcdPlatformGetVram (
> *VramSize,
> EFI_MEMORY_WC
> );
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
ASSERT (FALSE)?
> gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> return Status;
> }
> @@ -293,6 +302,7 @@ LcdPlatformSetMode (
> UINT32 SysId;
>
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
ASSERT (FALSE)? Or temporary variable?
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -359,6 +369,7 @@ LcdPlatformSetMode (
> * (on success).
> *
> * @retval EFI_SUCCESS Success if the requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Info is NULL.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> **/
> EFI_STATUS
> @@ -367,7 +378,9 @@ LcdPlatformQueryMode (
> OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> )
> {
> - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
Temporary variable?
> + ASSERT (Info != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -415,6 +428,7 @@ LcdPlatformQueryMode (
> *
> * @retval EFI_SUCCESS Success if the requested mode is found.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER One of the OUT parameters is NULL.
> **/
> EFI_STATUS
> LcdPlatformGetTimings (
> @@ -430,6 +444,28 @@ LcdPlatformGetTimings (
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (HRes == NULL
> + || HSync == NULL
> + || HBackPorch == NULL
> + || HFrontPorch == NULL
> + || VRes == NULL
> + || VSync == NULL
> + || VBackPorch == NULL
> + || VFrontPorch == NULL)
> + {
> + // One of the pointers is NULL
> + ASSERT (HRes != NULL);
> + ASSERT (HSync != NULL);
> + ASSERT (HBackPorch != NULL);
> + ASSERT (HFrontPorch != NULL);
> + ASSERT (VRes != NULL);
> + ASSERT (VSync != NULL);
> + ASSERT (VBackPorch != NULL);
> + ASSERT (VFrontPorch != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -452,6 +488,7 @@ LcdPlatformGetTimings (
> *
> * @retval EFI_SUCCESS The requested mode is found.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> **/
> EFI_STATUS
> LcdPlatformGetBpp (
> @@ -460,6 +497,8 @@ LcdPlatformGetBpp (
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> + ASSERT (Bpp != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> index 5f950579720fb69e0a481f697a5cc4038158b409..a266671a26f01d31e8ddb0cf7cbfe59d2f4dc49c 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> @@ -109,15 +109,15 @@ LcdSetMode (
> &VBackPorch,
> &VFrontPorch
> );
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
ASSERT (FALSE).
> + return Status;
This is a change in behaviour, since the function can now potentially
return other values than it has in the past. Again, it may be fine,
but deserves a mention in the commit message.
> }
>
> Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
> + return Status;
Same as above.
> }
>
> BytesPerPixel = GetBytesPerPixel (LcdBpp);
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> index 386e6140a69b045f77ee7fa60c4587d8bf4e7d54..f432c8d802614e8a0e4ddab3898f6e0dbf9a1572 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> @@ -110,15 +110,15 @@ LcdSetMode (
> &VBackPorch,
> &VFrontPorch
> );
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
> + return Status;
Same as above.
> }
>
> Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
> + return Status;
Same as above.
/
Leif
> }
>
> // Disable the CLCD_LcdEn bit
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
2017-09-26 20:15 ` [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts evan.lloyd
2017-10-12 19:32 ` Leif Lindholm
@ 2017-10-13 7:33 ` Ard Biesheuvel
2017-12-01 16:33 ` Evan Lloyd
1 sibling, 1 reply; 69+ messages in thread
From: Ard Biesheuvel @ 2017-10-13 7:33 UTC (permalink / raw)
To: Evan Lloyd
Cc: edk2-devel@lists.01.org, "ard.biesheuvel, "leif.lindholm,
"Matteo.Carlini, "nd
On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> This change adds some debug assertions e.g to catch NULL pointer errors
> missing in PL11Lcd and HdLcd modules.
>
> This change also improves related error handling code.
>
> 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>
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 44 ++++++++++++++++++--
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 43 ++++++++++++++++++-
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 8 ++--
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 8 ++--
> 4 files changed, 90 insertions(+), 13 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index b9859a56988f7e5be0adbaa49048a683fe586bfe..58dd9f0c77e1bc9af559a71d0c7cce72d71c6da5 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -140,6 +140,7 @@ LcdPlatformInitializeDisplay (
> * buffer in bytes
> *
> * @retval EFI_SUCCESS Frame buffer memory allocation success.
> + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize are NULL.
> * @retval !(EFI_SUCCESS) Other errors.
> **/
> EFI_STATUS
> @@ -151,6 +152,13 @@ LcdPlatformGetVram (
> EFI_STATUS Status;
> EFI_ALLOCATE_TYPE AllocationType;
>
> + // Check VramBaseAddress and VramSize are not NULL.
> + if (VramBaseAddress == NULL || VramSize == NULL) {
> + ASSERT (VramBaseAddress != NULL);
> + ASSERT (VramSize != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
> // Set the vram size
> *VramSize = LCD_VRAM_SIZE;
>
> @@ -169,6 +177,7 @@ LcdPlatformGetVram (
> VramBaseAddress
> );
> if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> return Status;
> }
>
> @@ -179,8 +188,8 @@ LcdPlatformGetVram (
> *VramSize,
> EFI_MEMORY_WC
> );
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
What is the point of this change?
> gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> return Status;
> }
> @@ -215,6 +224,7 @@ LcdPlatformSetMode (
> EFI_STATUS Status;
>
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -264,6 +274,7 @@ LcdPlatformSetMode (
> *
> * @retval EFI_SUCCESS Success if the requested mode is found.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER Info is NULL.
> **/
> EFI_STATUS
> LcdPlatformQueryMode (
> @@ -271,7 +282,9 @@ LcdPlatformQueryMode (
> OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> )
> {
> - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
Please don't put anything that may have a side effect inside ASSERT
(), since they are dropped from RELEASE builds. You can just use
ASSERT (FALSE) here, or use a temp variable.
> + ASSERT (Info != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -334,6 +347,28 @@ LcdPlatformGetTimings (
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
same here
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (HRes == NULL
> + || HSync == NULL
> + || HBackPorch == NULL
> + || HFrontPorch == NULL
> + || VRes == NULL
> + || VSync == NULL
> + || VBackPorch == NULL
> + || VFrontPorch == NULL)
> + {
> + // One of the pointers is NULL
> + ASSERT (HRes != NULL);
> + ASSERT (HSync != NULL);
> + ASSERT (HBackPorch != NULL);
> + ASSERT (HFrontPorch != NULL);
> + ASSERT (VRes != NULL);
> + ASSERT (VSync != NULL);
> + ASSERT (VBackPorch != NULL);
> + ASSERT (VFrontPorch != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -356,6 +391,7 @@ LcdPlatformGetTimings (
> *
> * @retval EFI_SUCCESS The requested mode is found.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> **/
> EFI_STATUS
> LcdPlatformGetBpp (
> @@ -363,7 +399,9 @@ LcdPlatformGetBpp (
> OUT LCD_BPP * CONST Bpp
> )
> {
> - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + if (ModeNumber >= LcdPlatformGetMaxMode () || Bpp == NULL) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> + ASSERT (Bpp != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 6ae13f06d8b396ea1c67f0bcd735a9d70f476400..5a4abd4c6f9e84d3d690af7233c1cebfe1ad339b 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -191,6 +191,7 @@ LcdPlatformInitializeDisplay (
> * buffer in bytes
> *
> * @retval EFI_SUCCESS Frame buffer memory allocation success.
> + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize is NULL.
> * @retval !(EFI_SUCCESS) Other errors.
> **/
> EFI_STATUS
> @@ -203,6 +204,13 @@ LcdPlatformGetVram (
>
> Status = EFI_SUCCESS;
>
> + // Check VramBaseAddress and VramSize are not NULL.
> + if (VramBaseAddress == NULL || VramSize == NULL) {
> + ASSERT (VramBaseAddress != NULL);
> + ASSERT (VramSize != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
> // Is it on the motherboard or on the daughterboard?
> switch (PL111_CLCD_SITE) {
>
> @@ -223,6 +231,7 @@ LcdPlatformGetVram (
> VramBaseAddress
> );
> if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> return Status;
> }
>
> @@ -233,8 +242,8 @@ LcdPlatformGetVram (
> *VramSize,
> EFI_MEMORY_WC
> );
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
Please drop this change
> gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> return Status;
> }
> @@ -293,6 +302,7 @@ LcdPlatformSetMode (
> UINT32 SysId;
>
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
No function calls inside ASSERT () please
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -359,6 +369,7 @@ LcdPlatformSetMode (
> * (on success).
> *
> * @retval EFI_SUCCESS Success if the requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Info is NULL.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> **/
> EFI_STATUS
> @@ -367,7 +378,9 @@ LcdPlatformQueryMode (
> OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> )
> {
> - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> + ASSERT (Info != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -415,6 +428,7 @@ LcdPlatformQueryMode (
> *
> * @retval EFI_SUCCESS Success if the requested mode is found.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER One of the OUT parameters is NULL.
> **/
> EFI_STATUS
> LcdPlatformGetTimings (
> @@ -430,6 +444,28 @@ LcdPlatformGetTimings (
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (HRes == NULL
> + || HSync == NULL
> + || HBackPorch == NULL
> + || HFrontPorch == NULL
> + || VRes == NULL
> + || VSync == NULL
> + || VBackPorch == NULL
> + || VFrontPorch == NULL)
> + {
> + // One of the pointers is NULL
> + ASSERT (HRes != NULL);
> + ASSERT (HSync != NULL);
> + ASSERT (HBackPorch != NULL);
> + ASSERT (HFrontPorch != NULL);
> + ASSERT (VRes != NULL);
> + ASSERT (VSync != NULL);
> + ASSERT (VBackPorch != NULL);
> + ASSERT (VFrontPorch != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> @@ -452,6 +488,7 @@ LcdPlatformGetTimings (
> *
> * @retval EFI_SUCCESS The requested mode is found.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> **/
> EFI_STATUS
> LcdPlatformGetBpp (
> @@ -460,6 +497,8 @@ LcdPlatformGetBpp (
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> + ASSERT (Bpp != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> index 5f950579720fb69e0a481f697a5cc4038158b409..a266671a26f01d31e8ddb0cf7cbfe59d2f4dc49c 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> @@ -109,15 +109,15 @@ LcdSetMode (
> &VBackPorch,
> &VFrontPorch
> );
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> }
>
> Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> }
>
> BytesPerPixel = GetBytesPerPixel (LcdBpp);
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> index 386e6140a69b045f77ee7fa60c4587d8bf4e7d54..f432c8d802614e8a0e4ddab3898f6e0dbf9a1572 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> @@ -110,15 +110,15 @@ LcdSetMode (
> &VBackPorch,
> &VFrontPorch
> );
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> }
>
> Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> - ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR (Status)) {
> - return EFI_DEVICE_ERROR;
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> }
>
> // Disable the CLCD_LcdEn bit
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
2017-10-13 7:33 ` Ard Biesheuvel
@ 2017-12-01 16:33 ` Evan Lloyd
2017-12-01 17:34 ` Ard Biesheuvel
0 siblings, 1 reply; 69+ messages in thread
From: Evan Lloyd @ 2017-12-01 16:33 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: edk2-devel@lists.01.org,
"ard.biesheuvel@linaro.org"@arm.com,
"leif.lindholm@linaro.org"@arm.com,
"Matteo.Carlini@arm.com"@arm.com,
"nd@arm.com"@arm.com
Responses inline:
> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 13 October 2017 08:33
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; "ard.biesheuvel@linaro.org"@arm.com;
> "leif.lindholm@linaro.org"@arm.com;
> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
> Subject: Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add
> debug asserts
>
> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> > From: Girish Pathak <girish.pathak@arm.com>
> >
> > This change adds some debug assertions e.g to catch NULL pointer
> > errors missing in PL11Lcd and HdLcd modules.
> >
> > This change also improves related error handling code.
> >
> > 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>
> > ---
> >
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> mVExpress.c | 44 ++++++++++++++++++--
> >
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL11
> 1LcdArmVExpress.c | 43 ++++++++++++++++++-
> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> | 8 ++--
> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> | 8 ++--
> > 4 files changed, 90 insertions(+), 13 deletions(-)
> >
> > diff --git
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> ArmVE
> > xpress.c
> >
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> ArmVE
> > xpress.c index
> >
> b9859a56988f7e5be0adbaa49048a683fe586bfe..58dd9f0c77e1bc9af559a
> 71d0c7c
> > ce72d71c6da5 100644
> > ---
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> ArmVE
> > xpress.c
> > +++
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> A
> > +++ rmVExpress.c
> > @@ -140,6 +140,7 @@ LcdPlatformInitializeDisplay (
> > * buffer in bytes
> > *
> > * @retval EFI_SUCCESS Frame buffer memory allocation success.
> > + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize
> are NULL.
> > * @retval !(EFI_SUCCESS) Other errors.
> > **/
> > EFI_STATUS
> > @@ -151,6 +152,13 @@ LcdPlatformGetVram (
> > EFI_STATUS Status;
> > EFI_ALLOCATE_TYPE AllocationType;
> >
> > + // Check VramBaseAddress and VramSize are not NULL.
> > + if (VramBaseAddress == NULL || VramSize == NULL) {
> > + ASSERT (VramBaseAddress != NULL);
> > + ASSERT (VramSize != NULL);
> > + return EFI_INVALID_PARAMETER;
> > + }
> > +
> > // Set the vram size
> > *VramSize = LCD_VRAM_SIZE;
> >
> > @@ -169,6 +177,7 @@ LcdPlatformGetVram (
> > VramBaseAddress
> > );
> > if (EFI_ERROR (Status)) {
> > + ASSERT_EFI_ERROR (Status);
> > return Status;
> > }
> >
> > @@ -179,8 +188,8 @@ LcdPlatformGetVram (
> > *VramSize,
> > EFI_MEMORY_WC
> > );
> > - ASSERT_EFI_ERROR (Status);
> > if (EFI_ERROR (Status)) {
> > + ASSERT_EFI_ERROR (Status);
>
> What is the point of this change?
[[Evan Lloyd]] It is a minor efficiency improvement. Since the ASSERT can only fire when the if condition is true, it removes a duplicated test from the main (non-error) code flow. This is irrelevant on hardware, but actually significant when running debug builds on an emulator environment.
>
> > gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> > return Status;
> > }
> > @@ -215,6 +224,7 @@ LcdPlatformSetMode (
> > EFI_STATUS Status;
> >
> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> > return EFI_INVALID_PARAMETER;
> > }
> >
> > @@ -264,6 +274,7 @@ LcdPlatformSetMode (
> > *
> > * @retval EFI_SUCCESS Success if the requested mode is found.
> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > + * @retval EFI_INVALID_PARAMETER Info is NULL.
> > **/
> > EFI_STATUS
> > LcdPlatformQueryMode (
> > @@ -271,7 +282,9 @@ LcdPlatformQueryMode (
> > OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> > )
> > {
> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
>
> Please don't put anything that may have a side effect inside ASSERT (), since
> they are dropped from RELEASE builds. You can just use ASSERT (FALSE)
> here, or use a temp variable.
[[Evan Lloyd]] Agreed
>
>
> > + ASSERT (Info != NULL);
> > return EFI_INVALID_PARAMETER;
> > }
> >
> > @@ -334,6 +347,28 @@ LcdPlatformGetTimings (
> > )
> > {
> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
>
> same here
[[Evan Lloyd]] Agreed
>
> > + return EFI_INVALID_PARAMETER;
> > + }
> > +
> > + if (HRes == NULL
> > + || HSync == NULL
> > + || HBackPorch == NULL
> > + || HFrontPorch == NULL
> > + || VRes == NULL
> > + || VSync == NULL
> > + || VBackPorch == NULL
> > + || VFrontPorch == NULL)
> > + {
> > + // One of the pointers is NULL
> > + ASSERT (HRes != NULL);
> > + ASSERT (HSync != NULL);
> > + ASSERT (HBackPorch != NULL);
> > + ASSERT (HFrontPorch != NULL);
> > + ASSERT (VRes != NULL);
> > + ASSERT (VSync != NULL);
> > + ASSERT (VBackPorch != NULL);
> > + ASSERT (VFrontPorch != NULL);
> > return EFI_INVALID_PARAMETER;
> > }
> >
> > @@ -356,6 +391,7 @@ LcdPlatformGetTimings (
> > *
> > * @retval EFI_SUCCESS The requested mode is found.
> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> > **/
> > EFI_STATUS
> > LcdPlatformGetBpp (
> > @@ -363,7 +399,9 @@ LcdPlatformGetBpp (
> > OUT LCD_BPP * CONST Bpp
> > )
> > {
> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Bpp == NULL) {
> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> > + ASSERT (Bpp != NULL);
> > return EFI_INVALID_PARAMETER;
> > }
> >
> > diff --git
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> 11Lc
> > dArmVExpress.c
> >
> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> 11Lc
> > dArmVExpress.c index
> >
> 6ae13f06d8b396ea1c67f0bcd735a9d70f476400..5a4abd4c6f9e84d3d690a
> f7233c1
> > cebfe1ad339b 100644
> > ---
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> 11Lc
> > dArmVExpress.c
> > +++
> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> > +++ 11LcdArmVExpress.c
> > @@ -191,6 +191,7 @@ LcdPlatformInitializeDisplay (
> > * buffer in bytes
> > *
> > * @retval EFI_SUCCESS Frame buffer memory allocation success.
> > + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize is
> NULL.
> > * @retval !(EFI_SUCCESS) Other errors.
> > **/
> > EFI_STATUS
> > @@ -203,6 +204,13 @@ LcdPlatformGetVram (
> >
> > Status = EFI_SUCCESS;
> >
> > + // Check VramBaseAddress and VramSize are not NULL.
> > + if (VramBaseAddress == NULL || VramSize == NULL) {
> > + ASSERT (VramBaseAddress != NULL);
> > + ASSERT (VramSize != NULL);
> > + return EFI_INVALID_PARAMETER;
> > + }
> > +
> > // Is it on the motherboard or on the daughterboard?
> > switch (PL111_CLCD_SITE) {
> >
> > @@ -223,6 +231,7 @@ LcdPlatformGetVram (
> > VramBaseAddress
> > );
> > if (EFI_ERROR (Status)) {
> > + ASSERT_EFI_ERROR (Status);
> > return Status;
> > }
> >
> > @@ -233,8 +242,8 @@ LcdPlatformGetVram (
> > *VramSize,
> > EFI_MEMORY_WC
> > );
> > - ASSERT_EFI_ERROR (Status);
> > if (EFI_ERROR (Status)) {
> > + ASSERT_EFI_ERROR (Status);
>
> Please drop this change
[[Evan Lloyd]] As stated above, this is not inconsequential for some use cases. The ASSERT can only fire when the if is satisfied, so moving the ASSERT reduces the number of tests executed in normal execution (depending on optimisation level).
>
> > gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> (*VramSize));
> > return Status;
> > }
> > @@ -293,6 +302,7 @@ LcdPlatformSetMode (
> > UINT32 SysId;
> >
> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
>
> No function calls inside ASSERT () please
[[Evan Lloyd]] Agreed
>
> > return EFI_INVALID_PARAMETER;
> > }
> >
> > @@ -359,6 +369,7 @@ LcdPlatformSetMode (
> > * (on success).
> > *
> > * @retval EFI_SUCCESS Success if the requested mode is found.
> > + * @retval EFI_INVALID_PARAMETER Info is NULL.
> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > **/
> > EFI_STATUS
> > @@ -367,7 +378,9 @@ LcdPlatformQueryMode (
> > OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> > )
> > {
> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> > + ASSERT (Info != NULL);
> > return EFI_INVALID_PARAMETER;
> > }
> >
> > @@ -415,6 +428,7 @@ LcdPlatformQueryMode (
> > *
> > * @retval EFI_SUCCESS Success if the requested mode is found.
> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > + * @retval EFI_INVALID_PARAMETER One of the OUT parameters is
> NULL.
> > **/
> > EFI_STATUS
> > LcdPlatformGetTimings (
> > @@ -430,6 +444,28 @@ LcdPlatformGetTimings (
> > )
> > {
> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> > + return EFI_INVALID_PARAMETER;
> > + }
> > +
> > + if (HRes == NULL
> > + || HSync == NULL
> > + || HBackPorch == NULL
> > + || HFrontPorch == NULL
> > + || VRes == NULL
> > + || VSync == NULL
> > + || VBackPorch == NULL
> > + || VFrontPorch == NULL)
> > + {
> > + // One of the pointers is NULL
> > + ASSERT (HRes != NULL);
> > + ASSERT (HSync != NULL);
> > + ASSERT (HBackPorch != NULL);
> > + ASSERT (HFrontPorch != NULL);
> > + ASSERT (VRes != NULL);
> > + ASSERT (VSync != NULL);
> > + ASSERT (VBackPorch != NULL);
> > + ASSERT (VFrontPorch != NULL);
> > return EFI_INVALID_PARAMETER;
> > }
> >
> > @@ -452,6 +488,7 @@ LcdPlatformGetTimings (
> > *
> > * @retval EFI_SUCCESS The requested mode is found.
> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> > **/
> > EFI_STATUS
> > LcdPlatformGetBpp (
> > @@ -460,6 +497,8 @@ LcdPlatformGetBpp (
> > )
> > {
> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> > + ASSERT (Bpp != NULL);
> > return EFI_INVALID_PARAMETER;
> > }
> >
> > diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > index
> >
> 5f950579720fb69e0a481f697a5cc4038158b409..a266671a26f01d31e8dd
> b0cf7cbf
> > e59d2f4dc49c 100644
> > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> > @@ -109,15 +109,15 @@ LcdSetMode (
> > &VBackPorch,
> > &VFrontPorch
> > );
> > - ASSERT_EFI_ERROR (Status);
> > if (EFI_ERROR (Status)) {
> > - return EFI_DEVICE_ERROR;
> > + ASSERT_EFI_ERROR (Status);
> > + return Status;
> > }
> >
> > Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> > - ASSERT_EFI_ERROR (Status);
> > if (EFI_ERROR (Status)) {
> > - return EFI_DEVICE_ERROR;
> > + ASSERT_EFI_ERROR (Status);
> > + return Status;
> > }
> >
> > BytesPerPixel = GetBytesPerPixel (LcdBpp); diff --git
> > a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > index
> >
> 386e6140a69b045f77ee7fa60c4587d8bf4e7d54..f432c8d802614e8a0e4dd
> ab3898f
> > 6e0dbf9a1572 100644
> > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> > @@ -110,15 +110,15 @@ LcdSetMode (
> > &VBackPorch,
> > &VFrontPorch
> > );
> > - ASSERT_EFI_ERROR (Status);
> > if (EFI_ERROR (Status)) {
> > - return EFI_DEVICE_ERROR;
> > + ASSERT_EFI_ERROR (Status);
> > + return Status;
> > }
> >
> > Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> > - ASSERT_EFI_ERROR (Status);
> > if (EFI_ERROR (Status)) {
> > - return EFI_DEVICE_ERROR;
> > + ASSERT_EFI_ERROR (Status);
> > + return Status;
> > }
> >
> > // Disable the CLCD_LcdEn bit
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
2017-12-01 16:33 ` Evan Lloyd
@ 2017-12-01 17:34 ` Ard Biesheuvel
2017-12-01 17:58 ` Leif Lindholm
2017-12-05 20:46 ` Evan Lloyd
0 siblings, 2 replies; 69+ messages in thread
From: Ard Biesheuvel @ 2017-12-01 17:34 UTC (permalink / raw)
To: Evan Lloyd
Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org@arm.com,
leif.lindholm@linaro.org@arm.com, Matteo.Carlini@arm.com@arm.com,
nd@arm.com@arm.com
On 1 December 2017 at 16:33, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> Responses inline:
>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 13 October 2017 08:33
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: edk2-devel@lists.01.org; "ard.biesheuvel@linaro.org"@arm.com;
>> "leif.lindholm@linaro.org"@arm.com;
>> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
>> Subject: Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add
>> debug asserts
>>
>> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
>> > From: Girish Pathak <girish.pathak@arm.com>
>> >
>> > This change adds some debug assertions e.g to catch NULL pointer
>> > errors missing in PL11Lcd and HdLcd modules.
>> >
>> > This change also improves related error handling code.
>> >
>> > 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>
>> > ---
>> >
>> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
>> mVExpress.c | 44 ++++++++++++++++++--
>> >
>> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL11
>> 1LcdArmVExpress.c | 43 ++++++++++++++++++-
>> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
>> | 8 ++--
>> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
>> | 8 ++--
>> > 4 files changed, 90 insertions(+), 13 deletions(-)
>> >
>> > diff --git
>> >
>> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> ArmVE
>> > xpress.c
>> >
>> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> ArmVE
>> > xpress.c index
>> >
>> b9859a56988f7e5be0adbaa49048a683fe586bfe..58dd9f0c77e1bc9af559a
>> 71d0c7c
>> > ce72d71c6da5 100644
>> > ---
>> >
>> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> ArmVE
>> > xpress.c
>> > +++
>> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
>> A
>> > +++ rmVExpress.c
>> > @@ -140,6 +140,7 @@ LcdPlatformInitializeDisplay (
>> > * buffer in bytes
>> > *
>> > * @retval EFI_SUCCESS Frame buffer memory allocation success.
>> > + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize
>> are NULL.
>> > * @retval !(EFI_SUCCESS) Other errors.
>> > **/
>> > EFI_STATUS
>> > @@ -151,6 +152,13 @@ LcdPlatformGetVram (
>> > EFI_STATUS Status;
>> > EFI_ALLOCATE_TYPE AllocationType;
>> >
>> > + // Check VramBaseAddress and VramSize are not NULL.
>> > + if (VramBaseAddress == NULL || VramSize == NULL) {
>> > + ASSERT (VramBaseAddress != NULL);
>> > + ASSERT (VramSize != NULL);
>> > + return EFI_INVALID_PARAMETER;
>> > + }
>> > +
>> > // Set the vram size
>> > *VramSize = LCD_VRAM_SIZE;
>> >
>> > @@ -169,6 +177,7 @@ LcdPlatformGetVram (
>> > VramBaseAddress
>> > );
>> > if (EFI_ERROR (Status)) {
>> > + ASSERT_EFI_ERROR (Status);
>> > return Status;
>> > }
>> >
>> > @@ -179,8 +188,8 @@ LcdPlatformGetVram (
>> > *VramSize,
>> > EFI_MEMORY_WC
>> > );
>> > - ASSERT_EFI_ERROR (Status);
>> > if (EFI_ERROR (Status)) {
>> > + ASSERT_EFI_ERROR (Status);
>>
>> What is the point of this change?
> [[Evan Lloyd]] It is a minor efficiency improvement. Since the ASSERT can only fire when the if condition is true, it removes a duplicated test from the main (non-error) code flow. This is irrelevant on hardware, but actually significant when running debug builds on an emulator environment.
>
Fair enough. But I'd prefer to finally fix the DEBUG vs NOOPT build
targets for ARM/AARCH64. DEBUG was never intended to be -O0 (and it is
not on X86 either).
Code is complex enough as it is, and how to move trivial tests like
this around for 'performance' reasons is a dimension I would like to
avoid.
>>
>> > gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
>> > return Status;
>> > }
>> > @@ -215,6 +224,7 @@ LcdPlatformSetMode (
>> > EFI_STATUS Status;
>> >
>> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
>> > return EFI_INVALID_PARAMETER;
>> > }
>> >
>> > @@ -264,6 +274,7 @@ LcdPlatformSetMode (
>> > *
>> > * @retval EFI_SUCCESS Success if the requested mode is found.
>> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
>> > + * @retval EFI_INVALID_PARAMETER Info is NULL.
>> > **/
>> > EFI_STATUS
>> > LcdPlatformQueryMode (
>> > @@ -271,7 +282,9 @@ LcdPlatformQueryMode (
>> > OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
>> > )
>> > {
>> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
>> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
>>
>> Please don't put anything that may have a side effect inside ASSERT (), since
>> they are dropped from RELEASE builds. You can just use ASSERT (FALSE)
>> here, or use a temp variable.
>
> [[Evan Lloyd]] Agreed
>
>>
>>
>> > + ASSERT (Info != NULL);
>> > return EFI_INVALID_PARAMETER;
>> > }
>> >
>> > @@ -334,6 +347,28 @@ LcdPlatformGetTimings (
>> > )
>> > {
>> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
>>
>> same here
> [[Evan Lloyd]] Agreed
>>
>> > + return EFI_INVALID_PARAMETER;
>> > + }
>> > +
>> > + if (HRes == NULL
>> > + || HSync == NULL
>> > + || HBackPorch == NULL
>> > + || HFrontPorch == NULL
>> > + || VRes == NULL
>> > + || VSync == NULL
>> > + || VBackPorch == NULL
>> > + || VFrontPorch == NULL)
>> > + {
>> > + // One of the pointers is NULL
>> > + ASSERT (HRes != NULL);
>> > + ASSERT (HSync != NULL);
>> > + ASSERT (HBackPorch != NULL);
>> > + ASSERT (HFrontPorch != NULL);
>> > + ASSERT (VRes != NULL);
>> > + ASSERT (VSync != NULL);
>> > + ASSERT (VBackPorch != NULL);
>> > + ASSERT (VFrontPorch != NULL);
>> > return EFI_INVALID_PARAMETER;
>> > }
>> >
>> > @@ -356,6 +391,7 @@ LcdPlatformGetTimings (
>> > *
>> > * @retval EFI_SUCCESS The requested mode is found.
>> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
>> > + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
>> > **/
>> > EFI_STATUS
>> > LcdPlatformGetBpp (
>> > @@ -363,7 +399,9 @@ LcdPlatformGetBpp (
>> > OUT LCD_BPP * CONST Bpp
>> > )
>> > {
>> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Bpp == NULL) {
>> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
>> > + ASSERT (Bpp != NULL);
>> > return EFI_INVALID_PARAMETER;
>> > }
>> >
>> > diff --git
>> >
>> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
>> 11Lc
>> > dArmVExpress.c
>> >
>> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
>> 11Lc
>> > dArmVExpress.c index
>> >
>> 6ae13f06d8b396ea1c67f0bcd735a9d70f476400..5a4abd4c6f9e84d3d690a
>> f7233c1
>> > cebfe1ad339b 100644
>> > ---
>> >
>> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
>> 11Lc
>> > dArmVExpress.c
>> > +++
>> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
>> > +++ 11LcdArmVExpress.c
>> > @@ -191,6 +191,7 @@ LcdPlatformInitializeDisplay (
>> > * buffer in bytes
>> > *
>> > * @retval EFI_SUCCESS Frame buffer memory allocation success.
>> > + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize is
>> NULL.
>> > * @retval !(EFI_SUCCESS) Other errors.
>> > **/
>> > EFI_STATUS
>> > @@ -203,6 +204,13 @@ LcdPlatformGetVram (
>> >
>> > Status = EFI_SUCCESS;
>> >
>> > + // Check VramBaseAddress and VramSize are not NULL.
>> > + if (VramBaseAddress == NULL || VramSize == NULL) {
>> > + ASSERT (VramBaseAddress != NULL);
>> > + ASSERT (VramSize != NULL);
>> > + return EFI_INVALID_PARAMETER;
>> > + }
>> > +
>> > // Is it on the motherboard or on the daughterboard?
>> > switch (PL111_CLCD_SITE) {
>> >
>> > @@ -223,6 +231,7 @@ LcdPlatformGetVram (
>> > VramBaseAddress
>> > );
>> > if (EFI_ERROR (Status)) {
>> > + ASSERT_EFI_ERROR (Status);
>> > return Status;
>> > }
>> >
>> > @@ -233,8 +242,8 @@ LcdPlatformGetVram (
>> > *VramSize,
>> > EFI_MEMORY_WC
>> > );
>> > - ASSERT_EFI_ERROR (Status);
>> > if (EFI_ERROR (Status)) {
>> > + ASSERT_EFI_ERROR (Status);
>>
>> Please drop this change
>
> [[Evan Lloyd]] As stated above, this is not inconsequential for some use cases. The ASSERT can only fire when the if is satisfied, so moving the ASSERT reduces the number of tests executed in normal execution (depending on optimisation level).
>
As stated above, let's fix DEBUG vs NOOPT instead.
>>
>> > gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
>> (*VramSize));
>> > return Status;
>> > }
>> > @@ -293,6 +302,7 @@ LcdPlatformSetMode (
>> > UINT32 SysId;
>> >
>> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
>>
>> No function calls inside ASSERT () please
> [[Evan Lloyd]] Agreed
>
>>
>> > return EFI_INVALID_PARAMETER;
>> > }
>> >
>> > @@ -359,6 +369,7 @@ LcdPlatformSetMode (
>> > * (on success).
>> > *
>> > * @retval EFI_SUCCESS Success if the requested mode is found.
>> > + * @retval EFI_INVALID_PARAMETER Info is NULL.
>> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
>> > **/
>> > EFI_STATUS
>> > @@ -367,7 +378,9 @@ LcdPlatformQueryMode (
>> > OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
>> > )
>> > {
>> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
>> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
>> > + ASSERT (Info != NULL);
>> > return EFI_INVALID_PARAMETER;
>> > }
>> >
>> > @@ -415,6 +428,7 @@ LcdPlatformQueryMode (
>> > *
>> > * @retval EFI_SUCCESS Success if the requested mode is found.
>> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
>> > + * @retval EFI_INVALID_PARAMETER One of the OUT parameters is
>> NULL.
>> > **/
>> > EFI_STATUS
>> > LcdPlatformGetTimings (
>> > @@ -430,6 +444,28 @@ LcdPlatformGetTimings (
>> > )
>> > {
>> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
>> > + return EFI_INVALID_PARAMETER;
>> > + }
>> > +
>> > + if (HRes == NULL
>> > + || HSync == NULL
>> > + || HBackPorch == NULL
>> > + || HFrontPorch == NULL
>> > + || VRes == NULL
>> > + || VSync == NULL
>> > + || VBackPorch == NULL
>> > + || VFrontPorch == NULL)
>> > + {
>> > + // One of the pointers is NULL
>> > + ASSERT (HRes != NULL);
>> > + ASSERT (HSync != NULL);
>> > + ASSERT (HBackPorch != NULL);
>> > + ASSERT (HFrontPorch != NULL);
>> > + ASSERT (VRes != NULL);
>> > + ASSERT (VSync != NULL);
>> > + ASSERT (VBackPorch != NULL);
>> > + ASSERT (VFrontPorch != NULL);
>> > return EFI_INVALID_PARAMETER;
>> > }
>> >
>> > @@ -452,6 +488,7 @@ LcdPlatformGetTimings (
>> > *
>> > * @retval EFI_SUCCESS The requested mode is found.
>> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
>> > + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
>> > **/
>> > EFI_STATUS
>> > LcdPlatformGetBpp (
>> > @@ -460,6 +497,8 @@ LcdPlatformGetBpp (
>> > )
>> > {
>> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
>> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
>> > + ASSERT (Bpp != NULL);
>> > return EFI_INVALID_PARAMETER;
>> > }
>> >
>> > diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
>> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
>> > index
>> >
>> 5f950579720fb69e0a481f697a5cc4038158b409..a266671a26f01d31e8dd
>> b0cf7cbf
>> > e59d2f4dc49c 100644
>> > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
>> > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
>> > @@ -109,15 +109,15 @@ LcdSetMode (
>> > &VBackPorch,
>> > &VFrontPorch
>> > );
>> > - ASSERT_EFI_ERROR (Status);
>> > if (EFI_ERROR (Status)) {
>> > - return EFI_DEVICE_ERROR;
>> > + ASSERT_EFI_ERROR (Status);
>> > + return Status;
>> > }
>> >
>> > Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
>> > - ASSERT_EFI_ERROR (Status);
>> > if (EFI_ERROR (Status)) {
>> > - return EFI_DEVICE_ERROR;
>> > + ASSERT_EFI_ERROR (Status);
>> > + return Status;
>> > }
>> >
>> > BytesPerPixel = GetBytesPerPixel (LcdBpp); diff --git
>> > a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
>> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
>> > index
>> >
>> 386e6140a69b045f77ee7fa60c4587d8bf4e7d54..f432c8d802614e8a0e4dd
>> ab3898f
>> > 6e0dbf9a1572 100644
>> > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
>> > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
>> > @@ -110,15 +110,15 @@ LcdSetMode (
>> > &VBackPorch,
>> > &VFrontPorch
>> > );
>> > - ASSERT_EFI_ERROR (Status);
>> > if (EFI_ERROR (Status)) {
>> > - return EFI_DEVICE_ERROR;
>> > + ASSERT_EFI_ERROR (Status);
>> > + return Status;
>> > }
>> >
>> > Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
>> > - ASSERT_EFI_ERROR (Status);
>> > if (EFI_ERROR (Status)) {
>> > - return EFI_DEVICE_ERROR;
>> > + ASSERT_EFI_ERROR (Status);
>> > + return Status;
>> > }
>> >
>> > // Disable the CLCD_LcdEn bit
>> > --
>> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>> >
> IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
2017-12-01 17:34 ` Ard Biesheuvel
@ 2017-12-01 17:58 ` Leif Lindholm
2017-12-05 20:46 ` Evan Lloyd
1 sibling, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-12-01 17:58 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: evan.lloyd, matteo.carlini, edk2-devel
On Fri, Dec 01, 2017 at 05:34:52PM +0000, Ard Biesheuvel wrote:
> On 1 December 2017 at 16:33, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> > Responses inline:
> >
> >> -----Original Message-----
> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> >> Sent: 13 October 2017 08:33
> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
> >> Cc: edk2-devel@lists.01.org; "ard.biesheuvel@linaro.org"@arm.com;
> >> "leif.lindholm@linaro.org"@arm.com;
> >> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
> >> Subject: Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add
> >> debug asserts
> >>
> >> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> >> > From: Girish Pathak <girish.pathak@arm.com>
> >> >
> >> > This change adds some debug assertions e.g to catch NULL pointer
> >> > errors missing in PL11Lcd and HdLcd modules.
> >> >
> >> > This change also improves related error handling code.
> >> >
> >> > 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>
> >> > ---
> >> >
> >> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> >> mVExpress.c | 44 ++++++++++++++++++--
> >> >
> >> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL11
> >> 1LcdArmVExpress.c | 43 ++++++++++++++++++-
> >> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> | 8 ++--
> >> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> | 8 ++--
> >> > 4 files changed, 90 insertions(+), 13 deletions(-)
> >> >
> >> > diff --git
> >> >
> >> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c
> >> >
> >> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c index
> >> >
> >> b9859a56988f7e5be0adbaa49048a683fe586bfe..58dd9f0c77e1bc9af559a
> >> 71d0c7c
> >> > ce72d71c6da5 100644
> >> > ---
> >> >
> >> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c
> >> > +++
> >> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> A
> >> > +++ rmVExpress.c
> >> > @@ -140,6 +140,7 @@ LcdPlatformInitializeDisplay (
> >> > * buffer in bytes
> >> > *
> >> > * @retval EFI_SUCCESS Frame buffer memory allocation success.
> >> > + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize
> >> are NULL.
> >> > * @retval !(EFI_SUCCESS) Other errors.
> >> > **/
> >> > EFI_STATUS
> >> > @@ -151,6 +152,13 @@ LcdPlatformGetVram (
> >> > EFI_STATUS Status;
> >> > EFI_ALLOCATE_TYPE AllocationType;
> >> >
> >> > + // Check VramBaseAddress and VramSize are not NULL.
> >> > + if (VramBaseAddress == NULL || VramSize == NULL) {
> >> > + ASSERT (VramBaseAddress != NULL);
> >> > + ASSERT (VramSize != NULL);
> >> > + return EFI_INVALID_PARAMETER;
> >> > + }
> >> > +
> >> > // Set the vram size
> >> > *VramSize = LCD_VRAM_SIZE;
> >> >
> >> > @@ -169,6 +177,7 @@ LcdPlatformGetVram (
> >> > VramBaseAddress
> >> > );
> >> > if (EFI_ERROR (Status)) {
> >> > + ASSERT_EFI_ERROR (Status);
> >> > return Status;
> >> > }
> >> >
> >> > @@ -179,8 +188,8 @@ LcdPlatformGetVram (
> >> > *VramSize,
> >> > EFI_MEMORY_WC
> >> > );
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > + ASSERT_EFI_ERROR (Status);
> >>
> >> What is the point of this change?
> > [[Evan Lloyd]] It is a minor efficiency improvement. Since the
> > ASSERT can only fire when the if condition is true, it removes a
> > duplicated test from the main (non-error) code flow. This is
> > irrelevant on hardware, but actually significant when running
> > debug builds on an emulator environment.
>
> Fair enough. But I'd prefer to finally fix the DEBUG vs NOOPT build
> targets for ARM/AARCH64. DEBUG was never intended to be -O0 (and it is
> not on X86 either).
>
> Code is complex enough as it is, and how to move trivial tests like
> this around for 'performance' reasons is a dimension I would like to
> avoid.
Echoing from an irc discussion with Ard:
I think NOOPT (and a !-O0 DEBUG) would be good to have for the ARM
architectures as well, both for GCC and CLANG.
Evan, have you done any investigation into the impact of optimization
on emulation performance?
My completely unfounded guess would be -O1 should be a good fit for
that environment, and hence for DEBUG. It would remove some of the
more insane bloat of -O0 without starting heavy inlining.
But as always, real numbers beat guesses.
(If -O2 is better than -O1, is -Os better than either?)
/
Leif
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
2017-12-01 17:34 ` Ard Biesheuvel
2017-12-01 17:58 ` Leif Lindholm
@ 2017-12-05 20:46 ` Evan Lloyd
2017-12-07 14:55 ` Alexei Fedorov
1 sibling, 1 reply; 69+ messages in thread
From: Evan Lloyd @ 2017-12-05 20:46 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org@arm.com,
leif.lindholm@linaro.org@arm.com, Matteo.Carlini@arm.com@arm.com,
nd@arm.com@arm.com
> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 01 December 2017 17:35
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; ard.biesheuvel@linaro.org@arm.com
> <"ard.biesheuvel@linaro.org"@arm.com>;
> leif.lindholm@linaro.org@arm.com <"leif.lindholm@linaro.org"@arm.com>;
> Matteo.Carlini@arm.com@arm.com
> <"Matteo.Carlini@arm.com"@arm.com>; nd@arm.com@arm.com
> <"nd@arm.com"@arm.com>
> Subject: Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add
> debug asserts
>
> On 1 December 2017 at 16:33, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> > Responses inline:
> >
> >> -----Original Message-----
> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> >> Sent: 13 October 2017 08:33
> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
> >> Cc: edk2-devel@lists.01.org; "ard.biesheuvel@linaro.org"@arm.com;
> >> "leif.lindholm@linaro.org"@arm.com;
> >> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
> >> Subject: Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe:
> Add
> >> debug asserts
> >>
> >> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> >> > From: Girish Pathak <girish.pathak@arm.com>
> >> >
> >> > This change adds some debug assertions e.g to catch NULL pointer
> >> > errors missing in PL11Lcd and HdLcd modules.
> >> >
> >> > This change also improves related error handling code.
> >> >
> >> > 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>
> >> > ---
> >> >
> >>
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> >> mVExpress.c | 44 ++++++++++++++++++--
> >> >
> >>
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL11
> >> 1LcdArmVExpress.c | 43 ++++++++++++++++++-
> >> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> | 8 ++--
> >> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> | 8 ++--
> >> > 4 files changed, 90 insertions(+), 13 deletions(-)
> >> >
> >> > diff --git
> >> >
> >>
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c
> >> >
> >>
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c index
> >> >
> >>
> b9859a56988f7e5be0adbaa49048a683fe586bfe..58dd9f0c77e1bc9af559a
> >> 71d0c7c
> >> > ce72d71c6da5 100644
> >> > ---
> >> >
> >>
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c
> >> > +++
> >>
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> A
> >> > +++ rmVExpress.c
> >> > @@ -140,6 +140,7 @@ LcdPlatformInitializeDisplay (
> >> > * buffer in bytes
> >> > *
> >> > * @retval EFI_SUCCESS Frame buffer memory allocation
> success.
> >> > + * @retval EFI_INVALID_PARAMETER VramBaseAddress or
> VramSize
> >> are NULL.
> >> > * @retval !(EFI_SUCCESS) Other errors.
> >> > **/
> >> > EFI_STATUS
> >> > @@ -151,6 +152,13 @@ LcdPlatformGetVram (
> >> > EFI_STATUS Status;
> >> > EFI_ALLOCATE_TYPE AllocationType;
> >> >
> >> > + // Check VramBaseAddress and VramSize are not NULL.
> >> > + if (VramBaseAddress == NULL || VramSize == NULL) {
> >> > + ASSERT (VramBaseAddress != NULL);
> >> > + ASSERT (VramSize != NULL);
> >> > + return EFI_INVALID_PARAMETER;
> >> > + }
> >> > +
> >> > // Set the vram size
> >> > *VramSize = LCD_VRAM_SIZE;
> >> >
> >> > @@ -169,6 +177,7 @@ LcdPlatformGetVram (
> >> > VramBaseAddress
> >> > );
> >> > if (EFI_ERROR (Status)) {
> >> > + ASSERT_EFI_ERROR (Status);
> >> > return Status;
> >> > }
> >> >
> >> > @@ -179,8 +188,8 @@ LcdPlatformGetVram (
> >> > *VramSize,
> >> > EFI_MEMORY_WC
> >> > );
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > + ASSERT_EFI_ERROR (Status);
> >>
> >> What is the point of this change?
> > [[Evan Lloyd]] It is a minor efficiency improvement. Since the ASSERT can
> only fire when the if condition is true, it removes a duplicated test from the
> main (non-error) code flow. This is irrelevant on hardware, but actually
> significant when running debug builds on an emulator environment.
> >
>
> Fair enough. But I'd prefer to finally fix the DEBUG vs NOOPT build targets
> for ARM/AARCH64. DEBUG was never intended to be -O0 (and it is not on
> X86 either).
>
> Code is complex enough as it is, and how to move trivial tests like this
> around for 'performance' reasons is a dimension I would like to avoid.
[[Evan Lloyd]] I have no objection to the DEBUG build being updated from -O0.
I strongly suspect that it was set to that because it reduced the incidence of the r18 problem that has now been fixed.
However, I can certainly envisage circumstances when we might need to do an emulator run with -O0 used for the build - so the reordering would still be beneficial.
>
> >>
> >> > gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> (*VramSize));
> >> > return Status;
> >> > }
> >> > @@ -215,6 +224,7 @@ LcdPlatformSetMode (
> >> > EFI_STATUS Status;
> >> >
> >> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -264,6 +274,7 @@ LcdPlatformSetMode (
> >> > *
> >> > * @retval EFI_SUCCESS Success if the requested mode is
> found.
> >> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> >> > + * @retval EFI_INVALID_PARAMETER Info is NULL.
> >> > **/
> >> > EFI_STATUS
> >> > LcdPlatformQueryMode (
> >> > @@ -271,7 +282,9 @@ LcdPlatformQueryMode (
> >> > OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> >> > )
> >> > {
> >> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >>
> >> Please don't put anything that may have a side effect inside ASSERT
> >> (), since they are dropped from RELEASE builds. You can just use
> >> ASSERT (FALSE) here, or use a temp variable.
> >
> > [[Evan Lloyd]] Agreed
> >
> >>
> >>
> >> > + ASSERT (Info != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -334,6 +347,28 @@ LcdPlatformGetTimings (
> >> > )
> >> > {
> >> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >>
> >> same here
> > [[Evan Lloyd]] Agreed
> >>
> >> > + return EFI_INVALID_PARAMETER;
> >> > + }
> >> > +
> >> > + if (HRes == NULL
> >> > + || HSync == NULL
> >> > + || HBackPorch == NULL
> >> > + || HFrontPorch == NULL
> >> > + || VRes == NULL
> >> > + || VSync == NULL
> >> > + || VBackPorch == NULL
> >> > + || VFrontPorch == NULL)
> >> > + {
> >> > + // One of the pointers is NULL
> >> > + ASSERT (HRes != NULL);
> >> > + ASSERT (HSync != NULL);
> >> > + ASSERT (HBackPorch != NULL);
> >> > + ASSERT (HFrontPorch != NULL);
> >> > + ASSERT (VRes != NULL);
> >> > + ASSERT (VSync != NULL);
> >> > + ASSERT (VBackPorch != NULL);
> >> > + ASSERT (VFrontPorch != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -356,6 +391,7 @@ LcdPlatformGetTimings (
> >> > *
> >> > * @retval EFI_SUCCESS The requested mode is found.
> >> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> >> > + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> >> > **/
> >> > EFI_STATUS
> >> > LcdPlatformGetBpp (
> >> > @@ -363,7 +399,9 @@ LcdPlatformGetBpp (
> >> > OUT LCD_BPP * CONST Bpp
> >> > )
> >> > {
> >> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Bpp == NULL) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >> > + ASSERT (Bpp != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > diff --git
> >> >
> >>
> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> >> 11Lc
> >> > dArmVExpress.c
> >> >
> >>
> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> >> 11Lc
> >> > dArmVExpress.c index
> >> >
> >>
> 6ae13f06d8b396ea1c67f0bcd735a9d70f476400..5a4abd4c6f9e84d3d690a
> >> f7233c1
> >> > cebfe1ad339b 100644
> >> > ---
> >> >
> >>
> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> >> 11Lc
> >> > dArmVExpress.c
> >> > +++
> >>
> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> >> > +++ 11LcdArmVExpress.c
> >> > @@ -191,6 +191,7 @@ LcdPlatformInitializeDisplay (
> >> > * buffer in bytes
> >> > *
> >> > * @retval EFI_SUCCESS Frame buffer memory allocation
> success.
> >> > + * @retval EFI_INVALID_PARAMETER VramBaseAddress or
> VramSize is
> >> NULL.
> >> > * @retval !(EFI_SUCCESS) Other errors.
> >> > **/
> >> > EFI_STATUS
> >> > @@ -203,6 +204,13 @@ LcdPlatformGetVram (
> >> >
> >> > Status = EFI_SUCCESS;
> >> >
> >> > + // Check VramBaseAddress and VramSize are not NULL.
> >> > + if (VramBaseAddress == NULL || VramSize == NULL) {
> >> > + ASSERT (VramBaseAddress != NULL);
> >> > + ASSERT (VramSize != NULL);
> >> > + return EFI_INVALID_PARAMETER;
> >> > + }
> >> > +
> >> > // Is it on the motherboard or on the daughterboard?
> >> > switch (PL111_CLCD_SITE) {
> >> >
> >> > @@ -223,6 +231,7 @@ LcdPlatformGetVram (
> >> > VramBaseAddress
> >> > );
> >> > if (EFI_ERROR (Status)) {
> >> > + ASSERT_EFI_ERROR (Status);
> >> > return Status;
> >> > }
> >> >
> >> > @@ -233,8 +242,8 @@ LcdPlatformGetVram (
> >> > *VramSize,
> >> > EFI_MEMORY_WC
> >> > );
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > + ASSERT_EFI_ERROR (Status);
> >>
> >> Please drop this change
> >
> > [[Evan Lloyd]] As stated above, this is not inconsequential for some use
> cases. The ASSERT can only fire when the if is satisfied, so moving the
> ASSERT reduces the number of tests executed in normal execution
> (depending on optimisation level).
> >
>
> As stated above, let's fix DEBUG vs NOOPT instead.
>
> >>
> >> > gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> >> (*VramSize));
> >> > return Status;
> >> > }
> >> > @@ -293,6 +302,7 @@ LcdPlatformSetMode (
> >> > UINT32 SysId;
> >> >
> >> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >>
> >> No function calls inside ASSERT () please
> > [[Evan Lloyd]] Agreed
> >
> >>
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -359,6 +369,7 @@ LcdPlatformSetMode (
> >> > * (on success).
> >> > *
> >> > * @retval EFI_SUCCESS Success if the requested mode is
> found.
> >> > + * @retval EFI_INVALID_PARAMETER Info is NULL.
> >> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> >> > **/
> >> > EFI_STATUS
> >> > @@ -367,7 +378,9 @@ LcdPlatformQueryMode (
> >> > OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> >> > )
> >> > {
> >> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >> > + ASSERT (Info != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -415,6 +428,7 @@ LcdPlatformQueryMode (
> >> > *
> >> > * @retval EFI_SUCCESS Success if the requested mode is
> found.
> >> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> >> > + * @retval EFI_INVALID_PARAMETER One of the OUT parameters is
> >> NULL.
> >> > **/
> >> > EFI_STATUS
> >> > LcdPlatformGetTimings (
> >> > @@ -430,6 +444,28 @@ LcdPlatformGetTimings (
> >> > )
> >> > {
> >> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >> > + return EFI_INVALID_PARAMETER;
> >> > + }
> >> > +
> >> > + if (HRes == NULL
> >> > + || HSync == NULL
> >> > + || HBackPorch == NULL
> >> > + || HFrontPorch == NULL
> >> > + || VRes == NULL
> >> > + || VSync == NULL
> >> > + || VBackPorch == NULL
> >> > + || VFrontPorch == NULL)
> >> > + {
> >> > + // One of the pointers is NULL
> >> > + ASSERT (HRes != NULL);
> >> > + ASSERT (HSync != NULL);
> >> > + ASSERT (HBackPorch != NULL);
> >> > + ASSERT (HFrontPorch != NULL);
> >> > + ASSERT (VRes != NULL);
> >> > + ASSERT (VSync != NULL);
> >> > + ASSERT (VBackPorch != NULL);
> >> > + ASSERT (VFrontPorch != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -452,6 +488,7 @@ LcdPlatformGetTimings (
> >> > *
> >> > * @retval EFI_SUCCESS The requested mode is found.
> >> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> >> > + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> >> > **/
> >> > EFI_STATUS
> >> > LcdPlatformGetBpp (
> >> > @@ -460,6 +497,8 @@ LcdPlatformGetBpp (
> >> > )
> >> > {
> >> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >> > + ASSERT (Bpp != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> > index
> >> >
> >>
> 5f950579720fb69e0a481f697a5cc4038158b409..a266671a26f01d31e8dd
> >> b0cf7cbf
> >> > e59d2f4dc49c 100644
> >> > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> > @@ -109,15 +109,15 @@ LcdSetMode (
> >> > &VBackPorch,
> >> > &VFrontPorch
> >> > );
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > - return EFI_DEVICE_ERROR;
> >> > + ASSERT_EFI_ERROR (Status);
> >> > + return Status;
> >> > }
> >> >
> >> > Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > - return EFI_DEVICE_ERROR;
> >> > + ASSERT_EFI_ERROR (Status);
> >> > + return Status;
> >> > }
> >> >
> >> > BytesPerPixel = GetBytesPerPixel (LcdBpp); diff --git
> >> > a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> > index
> >> >
> >>
> 386e6140a69b045f77ee7fa60c4587d8bf4e7d54..f432c8d802614e8a0e4dd
> >> ab3898f
> >> > 6e0dbf9a1572 100644
> >> > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> > @@ -110,15 +110,15 @@ LcdSetMode (
> >> > &VBackPorch,
> >> > &VFrontPorch
> >> > );
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > - return EFI_DEVICE_ERROR;
> >> > + ASSERT_EFI_ERROR (Status);
> >> > + return Status;
> >> > }
> >> >
> >> > Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > - return EFI_DEVICE_ERROR;
> >> > + ASSERT_EFI_ERROR (Status);
> >> > + return Status;
> >> > }
> >> >
> >> > // Disable the CLCD_LcdEn bit
> >> > --
> >> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >> >
> > IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose the
> contents to any other person, use it for any purpose, or store or copy the
> information in any medium. Thank you.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
2017-12-05 20:46 ` Evan Lloyd
@ 2017-12-07 14:55 ` Alexei Fedorov
2017-12-07 15:10 ` Ard Biesheuvel
0 siblings, 1 reply; 69+ messages in thread
From: Alexei Fedorov @ 2017-12-07 14:55 UTC (permalink / raw)
To: Evan Lloyd, Ard Biesheuvel
Cc: edk2-devel@lists.01.org, leif.lindholm@linaro.org@arm.com,
nd@arm.com@arm.com, ard.biesheuvel@linaro.org@arm.com,
Matteo.Carlini@arm.com@arm.com
Hi,
I've compiled current HdLcd.c code with different optimisation levels for DEBUG build using GCC 7.2.1, and the assembler code below was generated for:
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR( Status )) {
return EFI_DEVICE_ERROR;
}
1. -O0 (default DEBUG option for AARCH64 before Ard's patch):
str x0, [x29, 72] //, Status
// r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79: ASSERT_EFI_ERROR (Status);
.loc 1 79 0
bl DebugAssertEnabled //
and w0, w0, 255 // _1, tmp150
cmp w0, 0 // _1,
beq .L4 //,
ldr x0, [x29, 72] // Status.9_2, Status
cmp x0, 0 // Status.9_2,
bge .L4 //,
2. -Os:
mov x19, x0 // Status,
// r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79: ASSERT_EFI_ERROR (Status);
.loc 1 79 0
bl DebugAssertEnabled //
.LVL15:
tst w0, 255 //
beq .L4 //,
tbz x19, #63, .L8 // Status,
3. -O3:
mov x19, x0 // Status,
.LVL14:
// r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79: ASSERT_EFI_ERROR (Status);
bl DebugAssertEnabled //
.LVL15:
tst w0, 255 //
beq .L5 //,
tbnz x19, #63, .L26 // Status,
with DebugAssertEnabled() compiled as:
DebugAssertEnabled:
.LFB4:
.loc 1 203 0
.cfi_startproc
// r:\edk2\MdePkg\Library\BaseDebugLibSerialPort\DebugLib.c:204: return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
.loc 1 204 0
adrp x0, _gPcd_FixedAtBuild_PcdDebugPropertyMask // tmp80,
add x0, x0, :lo12:_gPcd_FixedAtBuild_PcdDebugPropertyMask // tmp79, tmp80,
ldrb w0, [x0] // _gPcd_FixedAtBuild_PcdDebugPropertyMask.4_1, _gPcd_FixedAtBuild_PcdDebugPropertyMask
and w0, w0, 1 // _3, _2,
cmp w0, 0 // _3,
cset w0, ne // tmp82,
and w0, w0, 255 // _4, tmp81
// r:\edk2\MdePkg\Library\BaseDebugLibSerialPort\DebugLib.c:205: }
.loc 1 205 0
ret
As you can see each "ASSERT_EFI_ERROR (Status)" macro requires DebugAssertEnabled() call taking 8 instructions by itself + minimum 3 instructions (for -Os, -O3) for Status check, which will be performed by "if (EFI_ERROR( Status ))" anyway.
Please correct me if I'm wrong assuming that placing
ASSERT_EFI_ERROR (Status)
inside
if (EFI_ERROR( Status )) {
statement is an optimisation improvement.
Thank you for your cooperation.
Alexei.
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > + ASSERT_EFI_ERROR (Status);
> >>
> >> What is the point of this change?
> > [[Evan Lloyd]] It is a minor efficiency improvement. Since the ASSERT can
> only fire when the if condition is true, it removes a duplicated test from the
> main (non-error) code flow. This is irrelevant on hardware, but actually
> significant when running debug builds on an emulator environment.
> >
>
> Fair enough. But I'd prefer to finally fix the DEBUG vs NOOPT build targets
> for ARM/AARCH64. DEBUG was never intended to be -O0 (and it is not on
> X86 either).
>
> Code is complex enough as it is, and how to move trivial tests like this
> around for 'performance' reasons is a dimension I would like to avoid.
>[[Evan Lloyd]] I have no objection to the DEBUG build being updated from -O0.
>I strongly suspect that it was set to that because it reduced the incidence of the r18 problem that has now been fixed.
>However, I can certainly envisage circumstances when we might need to do an emulator run with -O0 used for the build - so the >
>reordering would still be beneficial.
________________________________
From: edk2-devel <edk2-devel-bounces@lists.01.org> on behalf of Evan Lloyd <Evan.Lloyd@arm.com>
Sent: 05 December 2017 20:46
To: Ard Biesheuvel
Cc: edk2-devel@lists.01.org; leif.lindholm@linaro.org@arm.com; nd@arm.com@arm.com; ard.biesheuvel@linaro.org@arm.com; Matteo.Carlini@arm.com@arm.com
Subject: Re: [edk2] [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 01 December 2017 17:35
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; ard.biesheuvel@linaro.org@arm.com
> <"ard.biesheuvel@linaro.org"@arm.com>;
> leif.lindholm@linaro.org@arm.com <"leif.lindholm@linaro.org"@arm.com>;
> Matteo.Carlini@arm.com@arm.com
> <"Matteo.Carlini@arm.com"@arm.com>; nd@arm.com@arm.com
> <"nd@arm.com"@arm.com>
> Subject: Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add
> debug asserts
>
> On 1 December 2017 at 16:33, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> > Responses inline:
> >
> >> -----Original Message-----
> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> >> Sent: 13 October 2017 08:33
> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
> >> Cc: edk2-devel@lists.01.org; "ard.biesheuvel@linaro.org"@arm.com;
> >> "leif.lindholm@linaro.org"@arm.com;
> >> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
> >> Subject: Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe:
> Add
> >> debug asserts
> >>
> >> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> >> > From: Girish Pathak <girish.pathak@arm.com>
> >> >
> >> > This change adds some debug assertions e.g to catch NULL pointer
> >> > errors missing in PL11Lcd and HdLcd modules.
> >> >
> >> > This change also improves related error handling code.
> >> >
> >> > 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>
> >> > ---
> >> >
> >>
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> >> mVExpress.c | 44 ++++++++++++++++++--
> >> >
> >>
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL11
> >> 1LcdArmVExpress.c | 43 ++++++++++++++++++-
> >> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> | 8 ++--
> >> > ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> | 8 ++--
> >> > 4 files changed, 90 insertions(+), 13 deletions(-)
> >> >
> >> > diff --git
> >> >
> >>
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c
> >> >
> >>
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c index
> >> >
> >>
> b9859a56988f7e5be0adbaa49048a683fe586bfe..58dd9f0c77e1bc9af559a
> >> 71d0c7c
> >> > ce72d71c6da5 100644
> >> > ---
> >> >
> >>
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> ArmVE
> >> > xpress.c
> >> > +++
> >>
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcd
> >> A
> >> > +++ rmVExpress.c
> >> > @@ -140,6 +140,7 @@ LcdPlatformInitializeDisplay (
> >> > * buffer in bytes
> >> > *
> >> > * @retval EFI_SUCCESS Frame buffer memory allocation
> success.
> >> > + * @retval EFI_INVALID_PARAMETER VramBaseAddress or
> VramSize
> >> are NULL.
> >> > * @retval !(EFI_SUCCESS) Other errors.
> >> > **/
> >> > EFI_STATUS
> >> > @@ -151,6 +152,13 @@ LcdPlatformGetVram (
> >> > EFI_STATUS Status;
> >> > EFI_ALLOCATE_TYPE AllocationType;
> >> >
> >> > + // Check VramBaseAddress and VramSize are not NULL.
> >> > + if (VramBaseAddress == NULL || VramSize == NULL) {
> >> > + ASSERT (VramBaseAddress != NULL);
> >> > + ASSERT (VramSize != NULL);
> >> > + return EFI_INVALID_PARAMETER;
> >> > + }
> >> > +
> >> > // Set the vram size
> >> > *VramSize = LCD_VRAM_SIZE;
> >> >
> >> > @@ -169,6 +177,7 @@ LcdPlatformGetVram (
> >> > VramBaseAddress
> >> > );
> >> > if (EFI_ERROR (Status)) {
> >> > + ASSERT_EFI_ERROR (Status);
> >> > return Status;
> >> > }
> >> >
> >> > @@ -179,8 +188,8 @@ LcdPlatformGetVram (
> >> > *VramSize,
> >> > EFI_MEMORY_WC
> >> > );
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > + ASSERT_EFI_ERROR (Status);
> >>
> >> What is the point of this change?
> > [[Evan Lloyd]] It is a minor efficiency improvement. Since the ASSERT can
> only fire when the if condition is true, it removes a duplicated test from the
> main (non-error) code flow. This is irrelevant on hardware, but actually
> significant when running debug builds on an emulator environment.
> >
>
> Fair enough. But I'd prefer to finally fix the DEBUG vs NOOPT build targets
> for ARM/AARCH64. DEBUG was never intended to be -O0 (and it is not on
> X86 either).
>
> Code is complex enough as it is, and how to move trivial tests like this
> around for 'performance' reasons is a dimension I would like to avoid.
[[Evan Lloyd]] I have no objection to the DEBUG build being updated from -O0.
I strongly suspect that it was set to that because it reduced the incidence of the r18 problem that has now been fixed.
However, I can certainly envisage circumstances when we might need to do an emulator run with -O0 used for the build - so the reordering would still be beneficial.
>
> >>
> >> > gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> (*VramSize));
> >> > return Status;
> >> > }
> >> > @@ -215,6 +224,7 @@ LcdPlatformSetMode (
> >> > EFI_STATUS Status;
> >> >
> >> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -264,6 +274,7 @@ LcdPlatformSetMode (
> >> > *
> >> > * @retval EFI_SUCCESS Success if the requested mode is
> found.
> >> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> >> > + * @retval EFI_INVALID_PARAMETER Info is NULL.
> >> > **/
> >> > EFI_STATUS
> >> > LcdPlatformQueryMode (
> >> > @@ -271,7 +282,9 @@ LcdPlatformQueryMode (
> >> > OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> >> > )
> >> > {
> >> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >>
> >> Please don't put anything that may have a side effect inside ASSERT
> >> (), since they are dropped from RELEASE builds. You can just use
> >> ASSERT (FALSE) here, or use a temp variable.
> >
> > [[Evan Lloyd]] Agreed
> >
> >>
> >>
> >> > + ASSERT (Info != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -334,6 +347,28 @@ LcdPlatformGetTimings (
> >> > )
> >> > {
> >> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >>
> >> same here
> > [[Evan Lloyd]] Agreed
> >>
> >> > + return EFI_INVALID_PARAMETER;
> >> > + }
> >> > +
> >> > + if (HRes == NULL
> >> > + || HSync == NULL
> >> > + || HBackPorch == NULL
> >> > + || HFrontPorch == NULL
> >> > + || VRes == NULL
> >> > + || VSync == NULL
> >> > + || VBackPorch == NULL
> >> > + || VFrontPorch == NULL)
> >> > + {
> >> > + // One of the pointers is NULL
> >> > + ASSERT (HRes != NULL);
> >> > + ASSERT (HSync != NULL);
> >> > + ASSERT (HBackPorch != NULL);
> >> > + ASSERT (HFrontPorch != NULL);
> >> > + ASSERT (VRes != NULL);
> >> > + ASSERT (VSync != NULL);
> >> > + ASSERT (VBackPorch != NULL);
> >> > + ASSERT (VFrontPorch != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -356,6 +391,7 @@ LcdPlatformGetTimings (
> >> > *
> >> > * @retval EFI_SUCCESS The requested mode is found.
> >> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> >> > + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> >> > **/
> >> > EFI_STATUS
> >> > LcdPlatformGetBpp (
> >> > @@ -363,7 +399,9 @@ LcdPlatformGetBpp (
> >> > OUT LCD_BPP * CONST Bpp
> >> > )
> >> > {
> >> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Bpp == NULL) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >> > + ASSERT (Bpp != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > diff --git
> >> >
> >>
> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> >> 11Lc
> >> > dArmVExpress.c
> >> >
> >>
> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> >> 11Lc
> >> > dArmVExpress.c index
> >> >
> >>
> 6ae13f06d8b396ea1c67f0bcd735a9d70f476400..5a4abd4c6f9e84d3d690a
> >> f7233c1
> >> > cebfe1ad339b 100644
> >> > ---
> >> >
> >>
> a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> >> 11Lc
> >> > dArmVExpress.c
> >> > +++
> >>
> b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL1
> >> > +++ 11LcdArmVExpress.c
> >> > @@ -191,6 +191,7 @@ LcdPlatformInitializeDisplay (
> >> > * buffer in bytes
> >> > *
> >> > * @retval EFI_SUCCESS Frame buffer memory allocation
> success.
> >> > + * @retval EFI_INVALID_PARAMETER VramBaseAddress or
> VramSize is
> >> NULL.
> >> > * @retval !(EFI_SUCCESS) Other errors.
> >> > **/
> >> > EFI_STATUS
> >> > @@ -203,6 +204,13 @@ LcdPlatformGetVram (
> >> >
> >> > Status = EFI_SUCCESS;
> >> >
> >> > + // Check VramBaseAddress and VramSize are not NULL.
> >> > + if (VramBaseAddress == NULL || VramSize == NULL) {
> >> > + ASSERT (VramBaseAddress != NULL);
> >> > + ASSERT (VramSize != NULL);
> >> > + return EFI_INVALID_PARAMETER;
> >> > + }
> >> > +
> >> > // Is it on the motherboard or on the daughterboard?
> >> > switch (PL111_CLCD_SITE) {
> >> >
> >> > @@ -223,6 +231,7 @@ LcdPlatformGetVram (
> >> > VramBaseAddress
> >> > );
> >> > if (EFI_ERROR (Status)) {
> >> > + ASSERT_EFI_ERROR (Status);
> >> > return Status;
> >> > }
> >> >
> >> > @@ -233,8 +242,8 @@ LcdPlatformGetVram (
> >> > *VramSize,
> >> > EFI_MEMORY_WC
> >> > );
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > + ASSERT_EFI_ERROR (Status);
> >>
> >> Please drop this change
> >
> > [[Evan Lloyd]] As stated above, this is not inconsequential for some use
> cases. The ASSERT can only fire when the if is satisfied, so moving the
> ASSERT reduces the number of tests executed in normal execution
> (depending on optimisation level).
> >
>
> As stated above, let's fix DEBUG vs NOOPT instead.
>
> >>
> >> > gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> >> (*VramSize));
> >> > return Status;
> >> > }
> >> > @@ -293,6 +302,7 @@ LcdPlatformSetMode (
> >> > UINT32 SysId;
> >> >
> >> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >>
> >> No function calls inside ASSERT () please
> > [[Evan Lloyd]] Agreed
> >
> >>
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -359,6 +369,7 @@ LcdPlatformSetMode (
> >> > * (on success).
> >> > *
> >> > * @retval EFI_SUCCESS Success if the requested mode is
> found.
> >> > + * @retval EFI_INVALID_PARAMETER Info is NULL.
> >> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> >> > **/
> >> > EFI_STATUS
> >> > @@ -367,7 +378,9 @@ LcdPlatformQueryMode (
> >> > OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> >> > )
> >> > {
> >> > - if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + if (ModeNumber >= LcdPlatformGetMaxMode () || Info == NULL) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >> > + ASSERT (Info != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -415,6 +428,7 @@ LcdPlatformQueryMode (
> >> > *
> >> > * @retval EFI_SUCCESS Success if the requested mode is
> found.
> >> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> >> > + * @retval EFI_INVALID_PARAMETER One of the OUT parameters is
> >> NULL.
> >> > **/
> >> > EFI_STATUS
> >> > LcdPlatformGetTimings (
> >> > @@ -430,6 +444,28 @@ LcdPlatformGetTimings (
> >> > )
> >> > {
> >> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >> > + return EFI_INVALID_PARAMETER;
> >> > + }
> >> > +
> >> > + if (HRes == NULL
> >> > + || HSync == NULL
> >> > + || HBackPorch == NULL
> >> > + || HFrontPorch == NULL
> >> > + || VRes == NULL
> >> > + || VSync == NULL
> >> > + || VBackPorch == NULL
> >> > + || VFrontPorch == NULL)
> >> > + {
> >> > + // One of the pointers is NULL
> >> > + ASSERT (HRes != NULL);
> >> > + ASSERT (HSync != NULL);
> >> > + ASSERT (HBackPorch != NULL);
> >> > + ASSERT (HFrontPorch != NULL);
> >> > + ASSERT (VRes != NULL);
> >> > + ASSERT (VSync != NULL);
> >> > + ASSERT (VBackPorch != NULL);
> >> > + ASSERT (VFrontPorch != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > @@ -452,6 +488,7 @@ LcdPlatformGetTimings (
> >> > *
> >> > * @retval EFI_SUCCESS The requested mode is found.
> >> > * @retval EFI_INVALID_PARAMETER Requested mode not found.
> >> > + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> >> > **/
> >> > EFI_STATUS
> >> > LcdPlatformGetBpp (
> >> > @@ -460,6 +497,8 @@ LcdPlatformGetBpp (
> >> > )
> >> > {
> >> > if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> >> > + ASSERT (ModeNumber < LcdPlatformGetMaxMode ());
> >> > + ASSERT (Bpp != NULL);
> >> > return EFI_INVALID_PARAMETER;
> >> > }
> >> >
> >> > diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> > index
> >> >
> >>
> 5f950579720fb69e0a481f697a5cc4038158b409..a266671a26f01d31e8dd
> >> b0cf7cbf
> >> > e59d2f4dc49c 100644
> >> > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> >> > @@ -109,15 +109,15 @@ LcdSetMode (
> >> > &VBackPorch,
> >> > &VFrontPorch
> >> > );
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > - return EFI_DEVICE_ERROR;
> >> > + ASSERT_EFI_ERROR (Status);
> >> > + return Status;
> >> > }
> >> >
> >> > Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > - return EFI_DEVICE_ERROR;
> >> > + ASSERT_EFI_ERROR (Status);
> >> > + return Status;
> >> > }
> >> >
> >> > BytesPerPixel = GetBytesPerPixel (LcdBpp); diff --git
> >> > a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> > b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> > index
> >> >
> >>
> 386e6140a69b045f77ee7fa60c4587d8bf4e7d54..f432c8d802614e8a0e4dd
> >> ab3898f
> >> > 6e0dbf9a1572 100644
> >> > --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> > +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> >> > @@ -110,15 +110,15 @@ LcdSetMode (
> >> > &VBackPorch,
> >> > &VFrontPorch
> >> > );
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > - return EFI_DEVICE_ERROR;
> >> > + ASSERT_EFI_ERROR (Status);
> >> > + return Status;
> >> > }
> >> >
> >> > Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> >> > - ASSERT_EFI_ERROR (Status);
> >> > if (EFI_ERROR (Status)) {
> >> > - return EFI_DEVICE_ERROR;
> >> > + ASSERT_EFI_ERROR (Status);
> >> > + return Status;
> >> > }
> >> >
> >> > // Disable the CLCD_LcdEn bit
> >> > --
> >> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >> >
> > IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose the
> contents to any other person, use it for any purpose, or store or copy the
> information in any medium. Thank you.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
2017-12-07 14:55 ` Alexei Fedorov
@ 2017-12-07 15:10 ` Ard Biesheuvel
2017-12-07 16:53 ` Alexei Fedorov
0 siblings, 1 reply; 69+ messages in thread
From: Ard Biesheuvel @ 2017-12-07 15:10 UTC (permalink / raw)
To: Alexei Fedorov
Cc: Evan Lloyd, edk2-devel@lists.01.org,
leif.lindholm@linaro.org@arm.com, nd@arm.com@arm.com,
ard.biesheuvel@linaro.org@arm.com, Matteo.Carlini@arm.com@arm.com
On 7 December 2017 at 14:55, Alexei Fedorov <Alexei.Fedorov@arm.com> wrote:
> Hi,
>
> I've compiled current HdLcd.c code with different optimisation levels for
> DEBUG build using GCC 7.2.1, and the assembler code below was generated for:
>
> ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR( Status )) {
> return EFI_DEVICE_ERROR;
> }
>
> -O0 (default DEBUG option for AARCH64 before Ard's patch):
>
>
> str x0, [x29, 72] //, Status
>
> // r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79:
> ASSERT_EFI_ERROR (Status);
> .loc 1 79 0
> bl DebugAssertEnabled //
> and w0, w0, 255 // _1, tmp150
> cmp w0, 0 // _1,
> beq .L4 //,
> ldr x0, [x29, 72] // Status.9_2, Status
> cmp x0, 0 // Status.9_2,
> bge .L4 //,
>
> 2. -Os:
>
> mov x19, x0 // Status,
> // r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79:
> ASSERT_EFI_ERROR (Status);
> .loc 1 79 0
> bl DebugAssertEnabled //
> .LVL15:
> tst w0, 255 //
> beq .L4 //,
> tbz x19, #63, .L8 // Status,
>
> 3. -O3:
>
> mov x19, x0 // Status,
> .LVL14:
> // r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79:
> ASSERT_EFI_ERROR (Status);
> bl DebugAssertEnabled //
> .LVL15:
> tst w0, 255 //
> beq .L5 //,
> tbnz x19, #63, .L26 // Status,
>
> with DebugAssertEnabled() compiled as:
>
> DebugAssertEnabled:
> .LFB4:
> .loc 1 203 0
> .cfi_startproc
> // r:\edk2\MdePkg\Library\BaseDebugLibSerialPort\DebugLib.c:204: return
> (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) &
> DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
> .loc 1 204 0
> adrp x0, _gPcd_FixedAtBuild_PcdDebugPropertyMask // tmp80,
> add x0, x0, :lo12:_gPcd_FixedAtBuild_PcdDebugPropertyMask //
> tmp79, tmp80,
> ldrb w0, [x0] // _gPcd_FixedAtBuild_PcdDebugPropertyMask.4_1,
> _gPcd_FixedAtBuild_PcdDebugPropertyMask
> and w0, w0, 1 // _3, _2,
> cmp w0, 0 // _3,
> cset w0, ne // tmp82,
> and w0, w0, 255 // _4, tmp81
> // r:\edk2\MdePkg\Library\BaseDebugLibSerialPort\DebugLib.c:205: }
> .loc 1 205 0
> ret
>
> As you can see each "ASSERT_EFI_ERROR (Status)" macro requires
> DebugAssertEnabled() call taking 8 instructions by itself + minimum 3
> instructions (for -Os, -O3) for Status check, which will be performed by "if
> (EFI_ERROR( Status ))" anyway.
> Please correct me if I'm wrong assuming that placing
> ASSERT_EFI_ERROR (Status)
> inside
> if (EFI_ERROR( Status )) {
> statement is an optimisation improvement.
>
Thanks for digging this up. This appears to be an oversight in the
definition of the ASSERT_EFI_ERROR () macro, which is currently
defined as
#if !defined(MDEPKG_NDEBUG)
#define ASSERT_EFI_ERROR(StatusParameter) \
do { \
if (DebugAssertEnabled ()) { \
if (EFI_ERROR (StatusParameter)) { \
which is obviously the wrong way around, given that the compiler can
never optimize away the function call, due to its potential side
effects (which it doesn't have)
So I will propose to fix this, by swapping the two if () statements.
Please let me know if the issue is still reproducible with that patch
applied.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
2017-12-07 15:10 ` Ard Biesheuvel
@ 2017-12-07 16:53 ` Alexei Fedorov
2017-12-08 21:39 ` Ard Biesheuvel
0 siblings, 1 reply; 69+ messages in thread
From: Alexei Fedorov @ 2017-12-07 16:53 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Evan Lloyd, edk2-devel@lists.01.org,
leif.lindholm@linaro.org@arm.com, nd@arm.com@arm.com,
ard.biesheuvel@linaro.org@arm.com, Matteo.Carlini@arm.com@arm.com
As expected with new ASSERT_EFI_ERROR () definition compiler generates 1 conditional branch at the start:
// r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79: ASSERT_EFI_ERROR (Status);
.loc 1 79 0
tbz x0, #63, .L4 // Status,
________________________________
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Sent: 07 December 2017 15:10:05
To: Alexei Fedorov
Cc: Evan Lloyd; edk2-devel@lists.01.org; leif.lindholm@linaro.org@arm.com; nd@arm.com@arm.com; ard.biesheuvel@linaro.org@arm.com; Matteo.Carlini@arm.com@arm.com
Subject: Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
On 7 December 2017 at 14:55, Alexei Fedorov <Alexei.Fedorov@arm.com> wrote:
> Hi,
>
> I've compiled current HdLcd.c code with different optimisation levels for
> DEBUG build using GCC 7.2.1, and the assembler code below was generated for:
>
> ASSERT_EFI_ERROR (Status);
> if (EFI_ERROR( Status )) {
> return EFI_DEVICE_ERROR;
> }
>
> -O0 (default DEBUG option for AARCH64 before Ard's patch):
>
>
> str x0, [x29, 72] //, Status
>
> // r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79:
> ASSERT_EFI_ERROR (Status);
> .loc 1 79 0
> bl DebugAssertEnabled //
> and w0, w0, 255 // _1, tmp150
> cmp w0, 0 // _1,
> beq .L4 //,
> ldr x0, [x29, 72] // Status.9_2, Status
> cmp x0, 0 // Status.9_2,
> bge .L4 //,
>
> 2. -Os:
>
> mov x19, x0 // Status,
> // r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79:
> ASSERT_EFI_ERROR (Status);
> .loc 1 79 0
> bl DebugAssertEnabled //
> .LVL15:
> tst w0, 255 //
> beq .L4 //,
> tbz x19, #63, .L8 // Status,
>
> 3. -O3:
>
> mov x19, x0 // Status,
> .LVL14:
> // r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79:
> ASSERT_EFI_ERROR (Status);
> bl DebugAssertEnabled //
> .LVL15:
> tst w0, 255 //
> beq .L5 //,
> tbnz x19, #63, .L26 // Status,
>
> with DebugAssertEnabled() compiled as:
>
> DebugAssertEnabled:
> .LFB4:
> .loc 1 203 0
> .cfi_startproc
> // r:\edk2\MdePkg\Library\BaseDebugLibSerialPort\DebugLib.c:204: return
> (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) &
> DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
> .loc 1 204 0
> adrp x0, _gPcd_FixedAtBuild_PcdDebugPropertyMask // tmp80,
> add x0, x0, :lo12:_gPcd_FixedAtBuild_PcdDebugPropertyMask //
> tmp79, tmp80,
> ldrb w0, [x0] // _gPcd_FixedAtBuild_PcdDebugPropertyMask.4_1,
> _gPcd_FixedAtBuild_PcdDebugPropertyMask
> and w0, w0, 1 // _3, _2,
> cmp w0, 0 // _3,
> cset w0, ne // tmp82,
> and w0, w0, 255 // _4, tmp81
> // r:\edk2\MdePkg\Library\BaseDebugLibSerialPort\DebugLib.c:205: }
> .loc 1 205 0
> ret
>
> As you can see each "ASSERT_EFI_ERROR (Status)" macro requires
> DebugAssertEnabled() call taking 8 instructions by itself + minimum 3
> instructions (for -Os, -O3) for Status check, which will be performed by "if
> (EFI_ERROR( Status ))" anyway.
> Please correct me if I'm wrong assuming that placing
> ASSERT_EFI_ERROR (Status)
> inside
> if (EFI_ERROR( Status )) {
> statement is an optimisation improvement.
>
Thanks for digging this up. This appears to be an oversight in the
definition of the ASSERT_EFI_ERROR () macro, which is currently
defined as
#if !defined(MDEPKG_NDEBUG)
#define ASSERT_EFI_ERROR(StatusParameter) \
do { \
if (DebugAssertEnabled ()) { \
if (EFI_ERROR (StatusParameter)) { \
which is obviously the wrong way around, given that the compiler can
never optimize away the function call, due to its potential side
effects (which it doesn't have)
So I will propose to fix this, by swapping the two if () statements.
Please let me know if the issue is still reproducible with that patch
applied.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts
2017-12-07 16:53 ` Alexei Fedorov
@ 2017-12-08 21:39 ` Ard Biesheuvel
0 siblings, 0 replies; 69+ messages in thread
From: Ard Biesheuvel @ 2017-12-08 21:39 UTC (permalink / raw)
To: Alexei Fedorov
Cc: Evan Lloyd, edk2-devel@lists.01.org,
leif.lindholm@linaro.org@arm.com, nd@arm.com@arm.com,
ard.biesheuvel@linaro.org@arm.com, Matteo.Carlini@arm.com@arm.com
On 7 December 2017 at 16:53, Alexei Fedorov <Alexei.Fedorov@arm.com> wrote:
> As expected with new ASSERT_EFI_ERROR () definition compiler generates 1
> conditional branch at the start:
>
>
> // r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79:
> ASSERT_EFI_ERROR (Status);
> .loc 1 79 0
> tbz x0, #63, .L4 // Status,
>
Thanks for confirming!
>
> ________________________________
> From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Sent: 07 December 2017 15:10:05
> To: Alexei Fedorov
> Cc: Evan Lloyd; edk2-devel@lists.01.org; leif.lindholm@linaro.org@arm.com;
> nd@arm.com@arm.com; ard.biesheuvel@linaro.org@arm.com;
> Matteo.Carlini@arm.com@arm.com
> Subject: Re: [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug
> asserts
>
> On 7 December 2017 at 14:55, Alexei Fedorov <Alexei.Fedorov@arm.com> wrote:
>> Hi,
>>
>> I've compiled current HdLcd.c code with different optimisation levels for
>> DEBUG build using GCC 7.2.1, and the assembler code below was generated
>> for:
>>
>> ASSERT_EFI_ERROR (Status);
>> if (EFI_ERROR( Status )) {
>> return EFI_DEVICE_ERROR;
>> }
>>
>> -O0 (default DEBUG option for AARCH64 before Ard's patch):
>>
>>
>> str x0, [x29, 72] //, Status
>>
>> // r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79:
>> ASSERT_EFI_ERROR (Status);
>> .loc 1 79 0
>> bl DebugAssertEnabled //
>> and w0, w0, 255 // _1, tmp150
>> cmp w0, 0 // _1,
>> beq .L4 //,
>> ldr x0, [x29, 72] // Status.9_2, Status
>> cmp x0, 0 // Status.9_2,
>> bge .L4 //,
>>
>> 2. -Os:
>>
>> mov x19, x0 // Status,
>> // r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79:
>> ASSERT_EFI_ERROR (Status);
>> .loc 1 79 0
>> bl DebugAssertEnabled //
>> .LVL15:
>> tst w0, 255 //
>> beq .L4 //,
>> tbz x19, #63, .L8 // Status,
>>
>> 3. -O3:
>>
>> mov x19, x0 // Status,
>> .LVL14:
>> // r:\edk2\ArmPlatformPkg\Drivers\LcdGraphicsOutputDxe\HdLcd.c:79:
>> ASSERT_EFI_ERROR (Status);
>> bl DebugAssertEnabled //
>> .LVL15:
>> tst w0, 255 //
>> beq .L5 //,
>> tbnz x19, #63, .L26 // Status,
>>
>> with DebugAssertEnabled() compiled as:
>>
>> DebugAssertEnabled:
>> .LFB4:
>> .loc 1 203 0
>> .cfi_startproc
>> // r:\edk2\MdePkg\Library\BaseDebugLibSerialPort\DebugLib.c:204: return
>> (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) &
>> DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
>> .loc 1 204 0
>> adrp x0, _gPcd_FixedAtBuild_PcdDebugPropertyMask // tmp80,
>> add x0, x0, :lo12:_gPcd_FixedAtBuild_PcdDebugPropertyMask //
>> tmp79, tmp80,
>> ldrb w0, [x0] // _gPcd_FixedAtBuild_PcdDebugPropertyMask.4_1,
>> _gPcd_FixedAtBuild_PcdDebugPropertyMask
>> and w0, w0, 1 // _3, _2,
>> cmp w0, 0 // _3,
>> cset w0, ne // tmp82,
>> and w0, w0, 255 // _4, tmp81
>> // r:\edk2\MdePkg\Library\BaseDebugLibSerialPort\DebugLib.c:205: }
>> .loc 1 205 0
>> ret
>>
>> As you can see each "ASSERT_EFI_ERROR (Status)" macro requires
>> DebugAssertEnabled() call taking 8 instructions by itself + minimum 3
>> instructions (for -Os, -O3) for Status check, which will be performed by
>> "if
>> (EFI_ERROR( Status ))" anyway.
>> Please correct me if I'm wrong assuming that placing
>> ASSERT_EFI_ERROR (Status)
>> inside
>> if (EFI_ERROR( Status )) {
>> statement is an optimisation improvement.
>>
>
> Thanks for digging this up. This appears to be an oversight in the
> definition of the ASSERT_EFI_ERROR () macro, which is currently
> defined as
>
> #if !defined(MDEPKG_NDEBUG)
> #define ASSERT_EFI_ERROR(StatusParameter) \
> do { \
> if (DebugAssertEnabled ()) { \
> if (EFI_ERROR (StatusParameter)) { \
>
> which is obviously the wrong way around, given that the compiler can
> never optimize away the function call, due to its potential side
> effects (which it doesn't have)
>
> So I will propose to fix this, by swapping the two if () statements.
> Please let me know if the issue is still reproducible with that patch
> applied.
> IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose the
> contents to any other person, use it for any purpose, or store or copy the
> information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 05/19] ArmPlatformPkg: PL111LcdArmVExpressLib: Minor code cleanup
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (3 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-12 19:33 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 06/19] ArmPlatformPkg: PL111Lcd: Replace magic number with macro evan.lloyd
` (13 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
This minor change removes some unecessary initializations and variables
in PL111LcdArmVExpress.c
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>
---
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 5a4abd4c6f9e84d3d690af7233c1cebfe1ad339b..b25a1ba93dbfd8f6450dbdf97194c15c30defa20 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -202,8 +202,6 @@ LcdPlatformGetVram (
{
EFI_STATUS Status;
- Status = EFI_SUCCESS;
-
// Check VramBaseAddress and VramSize are not NULL.
if (VramBaseAddress == NULL || VramSize == NULL) {
ASSERT (VramBaseAddress != NULL);
@@ -217,6 +215,7 @@ LcdPlatformGetVram (
case ARM_VE_MOTHERBOARD_SITE:
*VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
*VramSize = LCD_VRAM_SIZE;
+ Status = EFI_SUCCESS;
break;
case ARM_VE_DAUGHTERBOARD_1_SITE:
@@ -245,7 +244,6 @@ LcdPlatformGetVram (
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
- return Status;
}
break;
@@ -296,7 +294,6 @@ LcdPlatformSetMode (
)
{
EFI_STATUS Status;
- UINT32 LcdSite;
UINT32 OscillatorId;
SYS_CONFIG_FUNCTION Function;
UINT32 SysId;
@@ -306,9 +303,7 @@ LcdPlatformSetMode (
return EFI_INVALID_PARAMETER;
}
- LcdSite = PL111_CLCD_SITE;
-
- switch (LcdSite) {
+ switch (PL111_CLCD_SITE) {
case ARM_VE_MOTHERBOARD_SITE:
Function = SYS_CFG_OSC;
OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
@@ -353,7 +348,7 @@ LcdPlatformSetMode (
}
// Set the multiplexer
- Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, LcdSite);
+ Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, PL111_CLCD_SITE);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 05/19] ArmPlatformPkg: PL111LcdArmVExpressLib: Minor code cleanup
2017-09-26 20:15 ` [PATCH 05/19] ArmPlatformPkg: PL111LcdArmVExpressLib: Minor code cleanup evan.lloyd
@ 2017-10-12 19:33 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-12 19:33 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:15PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> This minor change removes some unecessary initializations and variables
> in PL111LcdArmVExpress.c
>
> 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: Leif Lindholm <leif.lindholm@linaro.org>
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 5a4abd4c6f9e84d3d690af7233c1cebfe1ad339b..b25a1ba93dbfd8f6450dbdf97194c15c30defa20 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -202,8 +202,6 @@ LcdPlatformGetVram (
> {
> EFI_STATUS Status;
>
> - Status = EFI_SUCCESS;
> -
> // Check VramBaseAddress and VramSize are not NULL.
> if (VramBaseAddress == NULL || VramSize == NULL) {
> ASSERT (VramBaseAddress != NULL);
> @@ -217,6 +215,7 @@ LcdPlatformGetVram (
> case ARM_VE_MOTHERBOARD_SITE:
> *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
> *VramSize = LCD_VRAM_SIZE;
> + Status = EFI_SUCCESS;
> break;
>
> case ARM_VE_DAUGHTERBOARD_1_SITE:
> @@ -245,7 +244,6 @@ LcdPlatformGetVram (
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> - return Status;
> }
> break;
>
> @@ -296,7 +294,6 @@ LcdPlatformSetMode (
> )
> {
> EFI_STATUS Status;
> - UINT32 LcdSite;
> UINT32 OscillatorId;
> SYS_CONFIG_FUNCTION Function;
> UINT32 SysId;
> @@ -306,9 +303,7 @@ LcdPlatformSetMode (
> return EFI_INVALID_PARAMETER;
> }
>
> - LcdSite = PL111_CLCD_SITE;
> -
> - switch (LcdSite) {
> + switch (PL111_CLCD_SITE) {
> case ARM_VE_MOTHERBOARD_SITE:
> Function = SYS_CFG_OSC;
> OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
> @@ -353,7 +348,7 @@ LcdPlatformSetMode (
> }
>
> // Set the multiplexer
> - Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, LcdSite);
> + Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, PL111_CLCD_SITE);
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 06/19] ArmPlatformPkg: PL111Lcd: Replace magic number with macro
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (4 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 05/19] ArmPlatformPkg: PL111LcdArmVExpressLib: Minor code cleanup evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-12 19:34 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 07/19] ArmPlatformPkg: PL111LcdArmVExpressLib: Use FixedPcdGet32 evan.lloyd
` (12 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
Minor code change, replaces magic number with macro in LCD disable.
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>
---
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
index f432c8d802614e8a0e4ddab3898f6e0dbf9a1572..12db9d910ed1d7874095a5f79fe588491811f75a 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
@@ -122,8 +122,7 @@ LcdSetMode (
}
// Disable the CLCD_LcdEn bit
- LcdControl = MmioRead32 (PL111_REG_LCD_CONTROL);
- MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl & ~1);
+ MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);
// Set Timings
MmioWrite32 (
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 06/19] ArmPlatformPkg: PL111Lcd: Replace magic number with macro
2017-09-26 20:15 ` [PATCH 06/19] ArmPlatformPkg: PL111Lcd: Replace magic number with macro evan.lloyd
@ 2017-10-12 19:34 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-12 19:34 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:16PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> Minor code change, replaces magic number with macro in LCD disable.
>
> 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>
Always appreciated.
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> index f432c8d802614e8a0e4ddab3898f6e0dbf9a1572..12db9d910ed1d7874095a5f79fe588491811f75a 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> @@ -122,8 +122,7 @@ LcdSetMode (
> }
>
> // Disable the CLCD_LcdEn bit
> - LcdControl = MmioRead32 (PL111_REG_LCD_CONTROL);
> - MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl & ~1);
> + MmioAnd32 (PL111_REG_LCD_CONTROL, ~PL111_CTRL_LCD_EN);
>
> // Set Timings
> MmioWrite32 (
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 07/19] ArmPlatformPkg: PL111LcdArmVExpressLib: Use FixedPcdGet32
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (5 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 06/19] ArmPlatformPkg: PL111Lcd: Replace magic number with macro evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-12 19:35 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 08/19] ArmPlatformPkg: PL11LcdArmVExpressLib: Improvement conditional evan.lloyd
` (11 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
PcdPL111LcdVideoModeOscId and PcdPL111LcdMaxMode are declared as fixed
PCDs. However code uses PcdGet32 call to get these values.
This change replaces PcdGet32 with FixedPcdGet32.
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>
---
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf | 2 +-
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
index 3fde707c33dbcbd8adbbf18bbba718b823194abc..1a044baf4698aa6bfa5cd6038f01e84f7a633ea9 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
@@ -39,6 +39,6 @@ [Protocols]
gEfiEdidDiscoveredProtocolGuid # Produced
gEfiEdidActiveProtocolGuid # Produced
-[Pcd]
+[FixedPcd]
gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index b25a1ba93dbfd8f6450dbdf97194c15c30defa20..59006c4cfd771fdd7ca1dab91728d4dafe2fe831 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -277,7 +277,7 @@ LcdPlatformGetMaxMode(VOID)
*/
// Set the maximum mode allowed
- return (PcdGet32 (PcdPL111LcdMaxMode));
+ return (FixedPcdGet32 (PcdPL111LcdMaxMode));
}
/** Set the requested display mode.
@@ -310,7 +310,7 @@ LcdPlatformSetMode (
break;
case ARM_VE_DAUGHTERBOARD_1_SITE:
Function = SYS_CFG_OSC_SITE1;
- OscillatorId = (UINT32)PcdGet32 (PcdPL111LcdVideoModeOscId);
+ OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
break;
default:
return EFI_UNSUPPORTED;
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 07/19] ArmPlatformPkg: PL111LcdArmVExpressLib: Use FixedPcdGet32
2017-09-26 20:15 ` [PATCH 07/19] ArmPlatformPkg: PL111LcdArmVExpressLib: Use FixedPcdGet32 evan.lloyd
@ 2017-10-12 19:35 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-12 19:35 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:17PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> PcdPL111LcdVideoModeOscId and PcdPL111LcdMaxMode are declared as fixed
> PCDs. However code uses PcdGet32 call to get these values.
> This change replaces PcdGet32 with FixedPcdGet32.
>
> 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: Leif Lindholm <leif.lindholm@linaro.org>
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf | 2 +-
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> index 3fde707c33dbcbd8adbbf18bbba718b823194abc..1a044baf4698aa6bfa5cd6038f01e84f7a633ea9 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> @@ -39,6 +39,6 @@ [Protocols]
> gEfiEdidDiscoveredProtocolGuid # Produced
> gEfiEdidActiveProtocolGuid # Produced
>
> -[Pcd]
> +[FixedPcd]
> gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
> gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index b25a1ba93dbfd8f6450dbdf97194c15c30defa20..59006c4cfd771fdd7ca1dab91728d4dafe2fe831 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -277,7 +277,7 @@ LcdPlatformGetMaxMode(VOID)
> */
>
> // Set the maximum mode allowed
> - return (PcdGet32 (PcdPL111LcdMaxMode));
> + return (FixedPcdGet32 (PcdPL111LcdMaxMode));
> }
>
> /** Set the requested display mode.
> @@ -310,7 +310,7 @@ LcdPlatformSetMode (
> break;
> case ARM_VE_DAUGHTERBOARD_1_SITE:
> Function = SYS_CFG_OSC_SITE1;
> - OscillatorId = (UINT32)PcdGet32 (PcdPL111LcdVideoModeOscId);
> + OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
> break;
> default:
> return EFI_UNSUPPORTED;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 08/19] ArmPlatformPkg: PL11LcdArmVExpressLib: Improvement conditional
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (6 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 07/19] ArmPlatformPkg: PL111LcdArmVExpressLib: Use FixedPcdGet32 evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-12 19:36 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 09/19] ArmPlatformPkg: HdLcdArmVExpressLib: Use FixedPcdGet32 evan.lloyd
` (10 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
PL111_CLCD_SITE and ARM_VE_MOTHERBOARD_SITE are both constants and
available at build time. Use conditional compilation to process the code
based on the value of PL111_CLCD_SITE, instead of selecting code in a
switch statement at runtime.
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>
---
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 40 +++++++-------------
1 file changed, 14 insertions(+), 26 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 59006c4cfd771fdd7ca1dab91728d4dafe2fe831..aa5a1ff9c1c25c51796b75230ca149ae3a92db4a 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -209,16 +209,11 @@ LcdPlatformGetVram (
return EFI_INVALID_PARAMETER;
}
- // Is it on the motherboard or on the daughterboard?
- switch (PL111_CLCD_SITE) {
-
- case ARM_VE_MOTHERBOARD_SITE:
+#if (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
*VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
*VramSize = LCD_VRAM_SIZE;
Status = EFI_SUCCESS;
- break;
-
- case ARM_VE_DAUGHTERBOARD_1_SITE:
+#elif (PL111_CLCD_SITE == ARM_VE_DAUGHTERBOARD_1_SITE)
*VramBaseAddress = (EFI_PHYSICAL_ADDRESS)LCD_VRAM_CORE_TILE_BASE;
*VramSize = LCD_VRAM_SIZE;
@@ -245,13 +240,9 @@ LcdPlatformGetVram (
ASSERT_EFI_ERROR (Status);
gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
}
- break;
-
- default:
- // Unsupported site
- Status = EFI_UNSUPPORTED;
- break;
- }
+#else
+#error PL111LcdVExpressLib: Unsupported PL111_CLCD_SITE
+#endif // (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
return Status;
}
@@ -303,18 +294,15 @@ LcdPlatformSetMode (
return EFI_INVALID_PARAMETER;
}
- switch (PL111_CLCD_SITE) {
- case ARM_VE_MOTHERBOARD_SITE:
- Function = SYS_CFG_OSC;
- OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
- break;
- case ARM_VE_DAUGHTERBOARD_1_SITE:
- Function = SYS_CFG_OSC_SITE1;
- OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
- break;
- default:
- return EFI_UNSUPPORTED;
- }
+#if (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
+ Function = SYS_CFG_OSC;
+ OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
+#elif (PL111_CLCD_SITE == ARM_VE_DAUGHTERBOARD_1_SITE)
+ Function = SYS_CFG_OSC_SITE1;
+ OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
+#else
+#error PL111LcdVExpressLib: Unsupported PL111_CLCD_SITE
+#endif // (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
// Set the video mode oscillator
Status = ArmPlatformSysConfigSetDevice (
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 08/19] ArmPlatformPkg: PL11LcdArmVExpressLib: Improvement conditional
2017-09-26 20:15 ` [PATCH 08/19] ArmPlatformPkg: PL11LcdArmVExpressLib: Improvement conditional evan.lloyd
@ 2017-10-12 19:36 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-12 19:36 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:18PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> PL111_CLCD_SITE and ARM_VE_MOTHERBOARD_SITE are both constants and
> available at build time. Use conditional compilation to process the code
> based on the value of PL111_CLCD_SITE, instead of selecting code in a
> switch statement at runtime.
>
> 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: Leif Lindholm <leif.lindholm@linaro.org>
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 40 +++++++-------------
> 1 file changed, 14 insertions(+), 26 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 59006c4cfd771fdd7ca1dab91728d4dafe2fe831..aa5a1ff9c1c25c51796b75230ca149ae3a92db4a 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -209,16 +209,11 @@ LcdPlatformGetVram (
> return EFI_INVALID_PARAMETER;
> }
>
> - // Is it on the motherboard or on the daughterboard?
> - switch (PL111_CLCD_SITE) {
> -
> - case ARM_VE_MOTHERBOARD_SITE:
> +#if (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
> *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)PL111_CLCD_VRAM_MOTHERBOARD_BASE;
> *VramSize = LCD_VRAM_SIZE;
> Status = EFI_SUCCESS;
> - break;
> -
> - case ARM_VE_DAUGHTERBOARD_1_SITE:
> +#elif (PL111_CLCD_SITE == ARM_VE_DAUGHTERBOARD_1_SITE)
> *VramBaseAddress = (EFI_PHYSICAL_ADDRESS)LCD_VRAM_CORE_TILE_BASE;
> *VramSize = LCD_VRAM_SIZE;
>
> @@ -245,13 +240,9 @@ LcdPlatformGetVram (
> ASSERT_EFI_ERROR (Status);
> gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> }
> - break;
> -
> - default:
> - // Unsupported site
> - Status = EFI_UNSUPPORTED;
> - break;
> - }
> +#else
> +#error PL111LcdVExpressLib: Unsupported PL111_CLCD_SITE
> +#endif // (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
>
> return Status;
> }
> @@ -303,18 +294,15 @@ LcdPlatformSetMode (
> return EFI_INVALID_PARAMETER;
> }
>
> - switch (PL111_CLCD_SITE) {
> - case ARM_VE_MOTHERBOARD_SITE:
> - Function = SYS_CFG_OSC;
> - OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
> - break;
> - case ARM_VE_DAUGHTERBOARD_1_SITE:
> - Function = SYS_CFG_OSC_SITE1;
> - OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
> - break;
> - default:
> - return EFI_UNSUPPORTED;
> - }
> +#if (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
> + Function = SYS_CFG_OSC;
> + OscillatorId = PL111_CLCD_MOTHERBOARD_VIDEO_MODE_OSC_ID;
> +#elif (PL111_CLCD_SITE == ARM_VE_DAUGHTERBOARD_1_SITE)
> + Function = SYS_CFG_OSC_SITE1;
> + OscillatorId = FixedPcdGet32 (PcdPL111LcdVideoModeOscId);
> +#else
> +#error PL111LcdVExpressLib: Unsupported PL111_CLCD_SITE
> +#endif // (PL111_CLCD_SITE == ARM_VE_MOTHERBOARD_SITE)
>
> // Set the video mode oscillator
> Status = ArmPlatformSysConfigSetDevice (
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 09/19] ArmPlatformPkg: HdLcdArmVExpressLib: Use FixedPcdGet32
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (7 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 08/19] ArmPlatformPkg: PL11LcdArmVExpressLib: Improvement conditional evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-12 19:38 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 10/19] ArmPlatformPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT evan.lloyd
` (9 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
PcdHdLcdVideoModeOscId is declared as a fixed PCD. However code
uses the PcdGet32 call to get this value.
This change replaces PcdGet32 with FixedPcdGet32.
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>
---
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf | 2 +-
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
index 4733bb8e662d64eca0976af21b2abb7036b4424b..bba851c9bd6089cee748b45f40599b24c1293785 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
@@ -39,6 +39,6 @@ [Protocols]
gEfiEdidDiscoveredProtocolGuid # Produced
gEfiEdidActiveProtocolGuid # Produced
-[Pcd]
+[FixedPcd]
gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index 58dd9f0c77e1bc9af559a71d0c7cce72d71c6da5..7b258f1fc9291ed2086da1e32dd5d0c7e4818dbd 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -230,11 +230,11 @@ LcdPlatformSetMode (
// Set the video mode oscillator
do {
- Status = ArmPlatformSysConfigSetDevice (
- SYS_CFG_OSC_SITE1,
- PcdGet32 (PcdHdLcdVideoModeOscId),
- mResolutions[ModeNumber].OscFreq
- );
+ Status = ArmPlatformSysConfigSetDevice (
+ SYS_CFG_OSC_SITE1,
+ FixedPcdGet32 (PcdHdLcdVideoModeOscId),
+ mResolutions[ModeNumber].OscFreq
+ );
} while (Status == EFI_TIMEOUT);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 09/19] ArmPlatformPkg: HdLcdArmVExpressLib: Use FixedPcdGet32
2017-09-26 20:15 ` [PATCH 09/19] ArmPlatformPkg: HdLcdArmVExpressLib: Use FixedPcdGet32 evan.lloyd
@ 2017-10-12 19:38 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-12 19:38 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:19PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> PcdHdLcdVideoModeOscId is declared as a fixed PCD. However code
> uses the PcdGet32 call to get this value.
> This change replaces PcdGet32 with FixedPcdGet32.
>
> 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>
For reference, I would have been happy for this one to be folded in
with the other fix of the same variant.
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf | 2 +-
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 10 +++++-----
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> index 4733bb8e662d64eca0976af21b2abb7036b4424b..bba851c9bd6089cee748b45f40599b24c1293785 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> @@ -39,6 +39,6 @@ [Protocols]
> gEfiEdidDiscoveredProtocolGuid # Produced
> gEfiEdidActiveProtocolGuid # Produced
>
> -[Pcd]
> +[FixedPcd]
> gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
> gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index 58dd9f0c77e1bc9af559a71d0c7cce72d71c6da5..7b258f1fc9291ed2086da1e32dd5d0c7e4818dbd 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -230,11 +230,11 @@ LcdPlatformSetMode (
>
> // Set the video mode oscillator
> do {
> - Status = ArmPlatformSysConfigSetDevice (
> - SYS_CFG_OSC_SITE1,
> - PcdGet32 (PcdHdLcdVideoModeOscId),
> - mResolutions[ModeNumber].OscFreq
> - );
> + Status = ArmPlatformSysConfigSetDevice (
> + SYS_CFG_OSC_SITE1,
> + FixedPcdGet32 (PcdHdLcdVideoModeOscId),
> + mResolutions[ModeNumber].OscFreq
> + );
However, something seems to have gone wrong with indentation here.
/
Leif
> } while (Status == EFI_TIMEOUT);
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 10/19] ArmPlatformPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (8 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 09/19] ArmPlatformPkg: HdLcdArmVExpressLib: Use FixedPcdGet32 evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-12 19:40 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 11/19] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP evan.lloyd
` (8 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
None of the ArmPlatformSys* functions return EFI_TIMEOUT. Hence checking
this in the do {} while loop in LcdPlatformSetMode is wrong. Therefore
remove this comparision and as a result remove the do {} while loop.
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>
---
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index 7b258f1fc9291ed2086da1e32dd5d0c7e4818dbd..a6c4f414685db907a3fbc9a009969be8a09f7415 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -229,25 +229,21 @@ LcdPlatformSetMode (
}
// Set the video mode oscillator
- do {
Status = ArmPlatformSysConfigSetDevice (
SYS_CFG_OSC_SITE1,
FixedPcdGet32 (PcdHdLcdVideoModeOscId),
mResolutions[ModeNumber].OscFreq
);
- } while (Status == EFI_TIMEOUT);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
// Set the DVI into the new mode
- do {
- Status = ArmPlatformSysConfigSet (
- SYS_CFG_DVIMODE,
- mResolutions[ModeNumber].Mode
- );
- } while (Status == EFI_TIMEOUT);
+ Status = ArmPlatformSysConfigSet (
+ SYS_CFG_DVIMODE,
+ mResolutions[ModeNumber].Mode
+ );
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 10/19] ArmPlatformPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT
2017-09-26 20:15 ` [PATCH 10/19] ArmPlatformPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT evan.lloyd
@ 2017-10-12 19:40 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-12 19:40 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:20PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> None of the ArmPlatformSys* functions return EFI_TIMEOUT. Hence checking
> this in the do {} while loop in LcdPlatformSetMode is wrong. Therefore
> remove this comparision and as a result remove the do {} while loop.
>
> 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>
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index 7b258f1fc9291ed2086da1e32dd5d0c7e4818dbd..a6c4f414685db907a3fbc9a009969be8a09f7415 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -229,25 +229,21 @@ LcdPlatformSetMode (
> }
>
> // Set the video mode oscillator
> - do {
> Status = ArmPlatformSysConfigSetDevice (
> SYS_CFG_OSC_SITE1,
> FixedPcdGet32 (PcdHdLcdVideoModeOscId),
> mResolutions[ModeNumber].OscFreq
> );
> - } while (Status == EFI_TIMEOUT);
And now I see the cause of the incorrect indentation in the previous patch.
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
>
> // Set the DVI into the new mode
> - do {
> - Status = ArmPlatformSysConfigSet (
> - SYS_CFG_DVIMODE,
> - mResolutions[ModeNumber].Mode
> - );
> - } while (Status == EFI_TIMEOUT);
> + Status = ArmPlatformSysConfigSet (
> + SYS_CFG_DVIMODE,
> + mResolutions[ModeNumber].Mode
> + );
Still, this is a 3-space indentation that should be a 2-space
indentation.
/
Leif
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 11/19] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (9 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 10/19] ArmPlatformPkg: HdLcdArmVExpressLib: Remove status check EFI_TIMEOUT evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-12 19:43 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 12/19] ArmPlatformPkg: Redefine LcdPlatformGetTimings function evan.lloyd
` (7 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
LcdIdentify function does not currently check presence of HDLCD
controller.
Implement this functionality by reading HDLCD_REG_VERSION and checking
against the PRODUCT_ID field to detect presence of HDLCD controller.
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>
---
ArmPlatformPkg/Include/Drivers/HdLcd.h | 4 +++-
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 22 +++++++++++++++++++-
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/ArmPlatformPkg/Include/Drivers/HdLcd.h b/ArmPlatformPkg/Include/Drivers/HdLcd.h
index 6df97a9dfee60e9fda615cf3bea1b6a164a42333..69b47cd720bae86081753affe2f3fafc8aa6c4d0 100644
--- a/ArmPlatformPkg/Include/Drivers/HdLcd.h
+++ b/ArmPlatformPkg/Include/Drivers/HdLcd.h
@@ -1,6 +1,6 @@
/** @file HDLcd.h
- Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -86,4 +86,6 @@
// Number of bytes per pixel
#define HDLCD_4BYTES_PER_PIXEL ((4 - 1) << 3)
+#define HDLCD_PRODUCT_ID 0x1CDC
+
#endif /* _HDLCD_H_ */
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
index a266671a26f01d31e8ddb0cf7cbfe59d2f4dc49c..33c555e75cafaf9affddd0992c4bd9f9289f6703 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
@@ -159,6 +159,22 @@ LcdShutdown (
MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
}
+/** Get the HDLCD Product Id (from the version register).
+**/
+STATIC
+UINT32 GetHdlcdProductId(VOID)
+{
+ return ((MmioRead32 (HDLCD_REG_VERSION)) >> 16) ;
+}
+
+/** Check if an HDLCD is present.
+**/
+STATIC
+BOOLEAN HdlcdPresent(VOID)
+{
+ return (GetHdlcdProductId() == HDLCD_PRODUCT_ID);
+}
+
/** Check for presence of HDLCD.
*
* @retval EFI_SUCCESS Platform implements HDLCD.
@@ -170,5 +186,9 @@ LcdIdentify (
VOID
)
{
- return EFI_SUCCESS;
+ if (HdlcdPresent()) {
+ return EFI_SUCCESS;
+ }
+
+ return EFI_NOT_FOUND;
}
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 11/19] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP
2017-09-26 20:15 ` [PATCH 11/19] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP evan.lloyd
@ 2017-10-12 19:43 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-12 19:43 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:21PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> LcdIdentify function does not currently check presence of HDLCD
> controller.
>
> Implement this functionality by reading HDLCD_REG_VERSION and checking
> against the PRODUCT_ID field to detect presence of HDLCD controller.
>
> 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>
> ---
> ArmPlatformPkg/Include/Drivers/HdLcd.h | 4 +++-
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 22 +++++++++++++++++++-
> 2 files changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/ArmPlatformPkg/Include/Drivers/HdLcd.h b/ArmPlatformPkg/Include/Drivers/HdLcd.h
> index 6df97a9dfee60e9fda615cf3bea1b6a164a42333..69b47cd720bae86081753affe2f3fafc8aa6c4d0 100644
> --- a/ArmPlatformPkg/Include/Drivers/HdLcd.h
> +++ b/ArmPlatformPkg/Include/Drivers/HdLcd.h
> @@ -1,6 +1,6 @@
> /** @file HDLcd.h
>
> - Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
> + Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD License
> @@ -86,4 +86,6 @@
> // Number of bytes per pixel
> #define HDLCD_4BYTES_PER_PIXEL ((4 - 1) << 3)
>
> +#define HDLCD_PRODUCT_ID 0x1CDC
> +
> #endif /* _HDLCD_H_ */
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> index a266671a26f01d31e8ddb0cf7cbfe59d2f4dc49c..33c555e75cafaf9affddd0992c4bd9f9289f6703 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> @@ -159,6 +159,22 @@ LcdShutdown (
> MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
> }
>
> +/** Get the HDLCD Product Id (from the version register).
> +**/
> +STATIC
> +UINT32 GetHdlcdProductId(VOID)
> +{
> + return ((MmioRead32 (HDLCD_REG_VERSION)) >> 16) ;
I was about to complain that this didn't use the functions from the
common PrimeCell helper library. Then I realised we didn't have one :(
One for the todo list.
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
> +}
> +
> +/** Check if an HDLCD is present.
> +**/
> +STATIC
> +BOOLEAN HdlcdPresent(VOID)
> +{
> + return (GetHdlcdProductId() == HDLCD_PRODUCT_ID);
> +}
> +
> /** Check for presence of HDLCD.
> *
> * @retval EFI_SUCCESS Platform implements HDLCD.
> @@ -170,5 +186,9 @@ LcdIdentify (
> VOID
> )
> {
> - return EFI_SUCCESS;
> + if (HdlcdPresent()) {
> + return EFI_SUCCESS;
> + }
> +
> + return EFI_NOT_FOUND;
> }
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 12/19] ArmPlatformPkg: Redefine LcdPlatformGetTimings function
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (10 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 11/19] ArmPlatformPkg: Implement LcdIdentify function for HDLCD GOP evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-13 7:49 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 13/19] ArmPlatformPkg: HdLcd Remove redundant Bpp evan.lloyd
` (6 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
The LcdPlatformGetTimings interface function takes similar sets of
multiple parameters for horizontal and vertical timings which can be
aggregated in a common data type. This change defines a structure
SCAN_TIMINGS for this which can be used to describe both horizontal and
vertical scan timings, and accordingly redefines the
LcdPlatformGetTiming interface, greatly reducing the amount of data
passed about.
Similarly the mode definition tables are also changed to use this data
type and thus enable pass through access.
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>
---
ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 32 ++--
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 122 +++++---------
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 177 ++++++++------------
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 55 +++---
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 48 +++---
5 files changed, 180 insertions(+), 254 deletions(-)
diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
index 48bdd8a51411137df040aa797fcff272785f7a35..f2f345b18fd15f2cde159fd42d3208a28f598a1f 100644
--- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
+++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
@@ -152,6 +152,14 @@ typedef enum {
LCD_BITS_PER_PIXEL_12_444
} LCD_BPP;
+// Display timing settings.
+typedef struct {
+ UINT32 Resolution;
+ UINT32 Sync;
+ UINT32 BackPorch;
+ UINT32 FrontPorch;
+} SCAN_TIMINGS;
+
/** Platform related initialization function.
*
* @param IN Handle Handle to the LCD device instance.
@@ -219,29 +227,19 @@ LcdPlatformQueryMode (
/** Returns the display timing information for the requested mode number.
*
* @param IN ModeNumber Mode Number.
- * @param OUT HRes Pointer to horizontal resolution.
- * @param OUT HSync Pointer to horizontal sync width.
- * @param OUT HBackPorch Pointer to horizontal back porch.
- * @param OUT HFrontPorch Pointer to horizontal front porch.
- * @param OUT VRes Pointer to vertical resolution.
- * @param OUT VSync Pointer to vertical sync width.
- * @param OUT VBackPorch Pointer to vertical back porch.
- * @param OUT VFrontPorch Pointer to vertical front porch.
-
+ * @param OUT Horizontal Pointer to horizontal timing parameters.
+ * (Resolution, Sync, Back porch, Front porch)
+ * @param OUT Vertical Pointer to vertical timing parameters.
+ * (Resolution, Sync, Back porch, Front porch)
+ *
* @retval EFI_SUCCESS Success if the requested mode is found.
* @retval EFI_INVALID_PARAMETER Requested mode not found.
**/
EFI_STATUS
LcdPlatformGetTimings (
IN UINT32 ModeNumber,
- OUT UINT32* HRes,
- OUT UINT32* HSync,
- OUT UINT32* HBackPorch,
- OUT UINT32* HFrontPorch,
- OUT UINT32* VRes,
- OUT UINT32* VSync,
- OUT UINT32* VBackPorch,
- OUT UINT32* VFrontPorch
+ OUT CONST SCAN_TIMINGS **Horizontal,
+ OUT CONST SCAN_TIMINGS **Vertical
);
/** Return bits per pixel information for a mode number.
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index a6c4f414685db907a3fbc9a009969be8a09f7415..dc2c5fb89923304c46d137ec8eaefc9418548d06 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -30,58 +30,52 @@
typedef struct {
UINT32 Mode;
- UINT32 HorizontalResolution;
- UINT32 VerticalResolution;
LCD_BPP Bpp;
UINT32 OscFreq;
// These are used by HDLCD
- UINT32 HSync;
- UINT32 HBackPorch;
- UINT32 HFrontPorch;
- UINT32 VSync;
- UINT32 VBackPorch;
- UINT32 VFrontPorch;
-} LCD_RESOLUTION;
+ SCAN_TIMINGS Horizontal;
+ SCAN_TIMINGS Vertical;
+} DISPLAY_MODE;
/** The display modes supported by the platform.
**/
-STATIC CONST LCD_RESOLUTION mResolutions[] = {
+STATIC CONST DISPLAY_MODE mDisplayModes[] = {
{ // Mode 0 : VGA : 640 x 480 x 24 bpp
- VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ VGA, LCD_BITS_PER_PIXEL_24,
VGA_OSC_FREQUENCY,
- VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
- VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+ {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+ {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
},
{ // Mode 1 : SVGA : 800 x 600 x 24 bpp
- SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ SVGA, LCD_BITS_PER_PIXEL_24,
SVGA_OSC_FREQUENCY,
- SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
- SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+ {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+ {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
},
{ // Mode 2 : XGA : 1024 x 768 x 24 bpp
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ XGA, LCD_BITS_PER_PIXEL_24,
XGA_OSC_FREQUENCY,
- XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
- XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+ {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+ {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
},
{ // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
- SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ SXGA, LCD_BITS_PER_PIXEL_24,
(SXGA_OSC_FREQUENCY/2),
- SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
- SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
+ {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
+ {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
},
{ // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
- UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ UXGA, LCD_BITS_PER_PIXEL_24,
(UXGA_OSC_FREQUENCY/2),
- UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
- UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
+ {UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH},
+ {UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH}
},
{ // Mode 5 : HD : 1920 x 1080 x 24 bpp
- HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ HD, LCD_BITS_PER_PIXEL_24,
(HD_OSC_FREQUENCY/2),
- HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
- HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
+ {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
+ {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
}
};
@@ -209,7 +203,7 @@ LcdPlatformGetMaxMode(VOID)
{
/* The following line will report correctly the total number of graphics modes
* that could be supported by the graphics driver: */
- return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
+ return (sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
}
/** Set the requested display mode.
@@ -232,7 +226,7 @@ LcdPlatformSetMode (
Status = ArmPlatformSysConfigSetDevice (
SYS_CFG_OSC_SITE1,
FixedPcdGet32 (PcdHdLcdVideoModeOscId),
- mResolutions[ModeNumber].OscFreq
+ mDisplayModes[ModeNumber].OscFreq
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
@@ -242,7 +236,7 @@ LcdPlatformSetMode (
// Set the DVI into the new mode
Status = ArmPlatformSysConfigSet (
SYS_CFG_DVIMODE,
- mResolutions[ModeNumber].Mode
+ mDisplayModes[ModeNumber].Mode
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
@@ -285,11 +279,11 @@ LcdPlatformQueryMode (
}
Info->Version = 0;
- Info->HorizontalResolution = mResolutions[ModeNumber].HorizontalResolution;
- Info->VerticalResolution = mResolutions[ModeNumber].VerticalResolution;
- Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
+ Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
+ Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
+ Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
- switch (mResolutions[ModeNumber].Bpp) {
+ switch (mDisplayModes[ModeNumber].Bpp) {
case LCD_BITS_PER_PIXEL_24:
Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
@@ -317,29 +311,20 @@ LcdPlatformQueryMode (
/** Returns the display timing information for the requested mode number.
*
* @param IN ModeNumber Mode Number.
- * @param OUT HRes Pointer to horizontal resolution.
- * @param OUT HSync Pointer to horizontal sync width.
- * @param OUT HBackPorch Pointer to horizontal back porch.
- * @param OUT HFrontPorch Pointer to horizontal front porch.
- * @param OUT VRes Pointer to vertical resolution.
- * @param OUT VSync Pointer to vertical sync width.
- * @param OUT VBackPorch Pointer to vertical back porch.
- * @param OUT VFrontPorch Pointer to vertical front porch.
+ * @param OUT Horizontal Pointer to horizontal timing parameters.
+ * (Resolution, Sync, Back porch, Front porch)
+ * @param OUT Vertical Pointer to vertical timing parameters.
+ * (Resolution, Sync, Back porch, Front porch)
+
*
* @retval EFI_SUCCESS Success if the requested mode is found.
* @retval EFI_INVALID_PARAMETER Requested mode not found.
**/
EFI_STATUS
LcdPlatformGetTimings (
- IN CONST UINT32 ModeNumber,
- OUT UINT32 * CONST HRes,
- OUT UINT32 * CONST HSync,
- OUT UINT32 * CONST HBackPorch,
- OUT UINT32 * CONST HFrontPorch,
- OUT UINT32 * CONST VRes,
- OUT UINT32 * CONST VSync,
- OUT UINT32 * CONST VBackPorch,
- OUT UINT32 * CONST VFrontPorch
+ IN CONST UINT32 ModeNumber,
+ OUT CONST SCAN_TIMINGS ** Horizontal,
+ OUT CONST SCAN_TIMINGS ** Vertical
)
{
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
@@ -347,35 +332,14 @@ LcdPlatformGetTimings (
return EFI_INVALID_PARAMETER;
}
- if (HRes == NULL
- || HSync == NULL
- || HBackPorch == NULL
- || HFrontPorch == NULL
- || VRes == NULL
- || VSync == NULL
- || VBackPorch == NULL
- || VFrontPorch == NULL)
- {
- // One of the pointers is NULL
- ASSERT (HRes != NULL);
- ASSERT (HSync != NULL);
- ASSERT (HBackPorch != NULL);
- ASSERT (HFrontPorch != NULL);
- ASSERT (VRes != NULL);
- ASSERT (VSync != NULL);
- ASSERT (VBackPorch != NULL);
- ASSERT (VFrontPorch != NULL);
+ if (Horizontal == NULL || Vertical == NULL) {
+ ASSERT (Horizontal != NULL);
+ ASSERT (Vertical != NULL);
return EFI_INVALID_PARAMETER;
}
- *HRes = mResolutions[ModeNumber].HorizontalResolution;
- *HSync = mResolutions[ModeNumber].HSync;
- *HBackPorch = mResolutions[ModeNumber].HBackPorch;
- *HFrontPorch = mResolutions[ModeNumber].HFrontPorch;
- *VRes = mResolutions[ModeNumber].VerticalResolution;
- *VSync = mResolutions[ModeNumber].VSync;
- *VBackPorch = mResolutions[ModeNumber].VBackPorch;
- *VFrontPorch = mResolutions[ModeNumber].VFrontPorch;
+ *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
+ *Vertical = &mDisplayModes[ModeNumber].Vertical;
return EFI_SUCCESS;
}
@@ -401,7 +365,7 @@ LcdPlatformGetBpp (
return EFI_INVALID_PARAMETER;
}
- *Bpp = mResolutions[ModeNumber].Bpp;
+ *Bpp = mDisplayModes[ModeNumber].Bpp;
return EFI_SUCCESS;
}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index aa5a1ff9c1c25c51796b75230ca149ae3a92db4a..753c5b615361f83625cdd4f0506909721da014b6 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -28,117 +28,111 @@
typedef struct {
UINT32 Mode;
- UINT32 HorizontalResolution;
- UINT32 VerticalResolution;
LCD_BPP Bpp;
UINT32 OscFreq;
- UINT32 HSync;
- UINT32 HBackPorch;
- UINT32 HFrontPorch;
- UINT32 VSync;
- UINT32 VBackPorch;
- UINT32 VFrontPorch;
-} LCD_RESOLUTION;
+ SCAN_TIMINGS Horizontal;
+ SCAN_TIMINGS Vertical;
+} DISPLAY_MODE;
/** The display modes supported by the platform.
**/
-STATIC CONST LCD_RESOLUTION mResolutions[] = {
+STATIC CONST DISPLAY_MODE mDisplayModes[] = {
{ // Mode 0 : VGA : 640 x 480 x 24 bpp
- VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ VGA, LCD_BITS_PER_PIXEL_24,
VGA_OSC_FREQUENCY,
- VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
- VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+ {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+ {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
},
{ // Mode 1 : SVGA : 800 x 600 x 24 bpp
- SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ SVGA, LCD_BITS_PER_PIXEL_24,
SVGA_OSC_FREQUENCY,
- SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
- SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+ {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+ {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
},
{ // Mode 2 : XGA : 1024 x 768 x 24 bpp
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ XGA, LCD_BITS_PER_PIXEL_24,
XGA_OSC_FREQUENCY,
- XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
- XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+ {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+ {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
},
{ // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
- SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ SXGA, LCD_BITS_PER_PIXEL_24,
(SXGA_OSC_FREQUENCY/2),
- SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
- SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
+ {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
+ {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
},
{ // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
- UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ UXGA, LCD_BITS_PER_PIXEL_24,
(UXGA_OSC_FREQUENCY/2),
- UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
- UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
+ {UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH},
+ {UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH}
},
{ // Mode 5 : HD : 1920 x 1080 x 24 bpp
- HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
+ HD, LCD_BITS_PER_PIXEL_24,
(HD_OSC_FREQUENCY/2),
- HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
- HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
+ {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
+ {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
},
{ // Mode 6 : VGA : 640 x 480 x 16 bpp (565 Mode)
- VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+ VGA, LCD_BITS_PER_PIXEL_16_565,
VGA_OSC_FREQUENCY,
- VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
- VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+ {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+ {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
},
{ // Mode 7 : SVGA : 800 x 600 x 16 bpp (565 Mode)
- SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+ SVGA, LCD_BITS_PER_PIXEL_16_565,
SVGA_OSC_FREQUENCY,
- SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
- SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+ {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+ {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
},
{ // Mode 8 : XGA : 1024 x 768 x 16 bpp (565 Mode)
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
+ XGA, LCD_BITS_PER_PIXEL_16_565,
XGA_OSC_FREQUENCY,
- XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
- XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+ {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+ {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
},
{ // Mode 9 : VGA : 640 x 480 x 15 bpp
- VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+ VGA, LCD_BITS_PER_PIXEL_16_555,
VGA_OSC_FREQUENCY,
- VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
- VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+ {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+ {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
},
{ // Mode 10 : SVGA : 800 x 600 x 15 bpp
- SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+ SVGA, LCD_BITS_PER_PIXEL_16_555,
SVGA_OSC_FREQUENCY,
- SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
- SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+ {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+ {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
},
{ // Mode 11 : XGA : 1024 x 768 x 15 bpp
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+ XGA, LCD_BITS_PER_PIXEL_16_555,
XGA_OSC_FREQUENCY,
- XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
- XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+ {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+ {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
},
{ // Mode 12 : XGA : 1024 x 768 x 15 bpp - All the timing info is derived from Linux Kernel Driver Settings
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
+ XGA, LCD_BITS_PER_PIXEL_16_555,
63500000,
- XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
- XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+ {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+ {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
},
{ // Mode 13 : VGA : 640 x 480 x 12 bpp (444 Mode)
- VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+ VGA, LCD_BITS_PER_PIXEL_12_444,
VGA_OSC_FREQUENCY,
- VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
- VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
+ {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+ {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
},
{ // Mode 14 : SVGA : 800 x 600 x 12 bpp (444 Mode)
- SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+ SVGA, LCD_BITS_PER_PIXEL_12_444,
SVGA_OSC_FREQUENCY,
- SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
- SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
+ {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+ {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
},
{ // Mode 15 : XGA : 1024 x 768 x 12 bpp (444 Mode)
- XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
+ XGA, LCD_BITS_PER_PIXEL_12_444,
XGA_OSC_FREQUENCY,
- XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
- XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
+ {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+ {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
}
};
@@ -308,7 +302,7 @@ LcdPlatformSetMode (
Status = ArmPlatformSysConfigSetDevice (
Function,
OscillatorId,
- mResolutions[ModeNumber].OscFreq
+ mDisplayModes[ModeNumber].OscFreq
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
@@ -326,7 +320,7 @@ LcdPlatformSetMode (
// Set the DVI into the new mode
Status = ArmPlatformSysConfigSet (
SYS_CFG_DVIMODE,
- mResolutions[ModeNumber].Mode
+ mDisplayModes[ModeNumber].Mode
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
@@ -368,11 +362,11 @@ LcdPlatformQueryMode (
}
Info->Version = 0;
- Info->HorizontalResolution = mResolutions[ModeNumber].HorizontalResolution;
- Info->VerticalResolution = mResolutions[ModeNumber].VerticalResolution;
- Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
+ Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
+ Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
+ Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
- switch (mResolutions[ModeNumber].Bpp) {
+ switch (mDisplayModes[ModeNumber].Bpp) {
case LCD_BITS_PER_PIXEL_24:
Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
@@ -400,14 +394,10 @@ LcdPlatformQueryMode (
/** Returns the display timing information for the requested mode number.
*
* @param IN ModeNumber Mode Number.
- * @param OUT HRes Pointer to horizontal resolution.
- * @param OUT HSync Pointer to horizontal sync width.
- * @param OUT HBackPorch Pointer to horizontal back porch.
- * @param OUT HFrontPorch Pointer to horizontal front porch.
- * @param OUT VRes Pointer to vertical resolution.
- * @param OUT VSync Pointer to vertical sync width.
- * @param OUT VBackPorch Pointer to vertical back porch.
- * @param OUT VFrontPorch Pointer to vertical front porch.
+ * @param OUT Horizontal Pointer to horizontal timing parameters.
+ * (Resolution, Sync, Back porch, Front porch)
+ * @param OUT Vertical Pointer to vertical timing parameters.
+ * (Resolution, Sync, Back porch, Front porch)
*
* @retval EFI_SUCCESS Success if the requested mode is found.
* @retval EFI_INVALID_PARAMETER Requested mode not found.
@@ -415,15 +405,9 @@ LcdPlatformQueryMode (
**/
EFI_STATUS
LcdPlatformGetTimings (
- IN CONST UINT32 ModeNumber,
- OUT UINT32 * CONST HRes,
- OUT UINT32 * CONST HSync,
- OUT UINT32 * CONST HBackPorch,
- OUT UINT32 * CONST HFrontPorch,
- OUT UINT32 * CONST VRes,
- OUT UINT32 * CONST VSync,
- OUT UINT32 * CONST VBackPorch,
- OUT UINT32 * CONST VFrontPorch
+ IN CONST UINT32 ModeNumber,
+ OUT CONST SCAN_TIMINGS ** Horizontal,
+ OUT CONST SCAN_TIMINGS ** Vertical
)
{
if (ModeNumber >= LcdPlatformGetMaxMode ()) {
@@ -431,35 +415,16 @@ LcdPlatformGetTimings (
return EFI_INVALID_PARAMETER;
}
- if (HRes == NULL
- || HSync == NULL
- || HBackPorch == NULL
- || HFrontPorch == NULL
- || VRes == NULL
- || VSync == NULL
- || VBackPorch == NULL
- || VFrontPorch == NULL)
+ if (Horizontal == NULL || Vertical == NULL)
{
// One of the pointers is NULL
- ASSERT (HRes != NULL);
- ASSERT (HSync != NULL);
- ASSERT (HBackPorch != NULL);
- ASSERT (HFrontPorch != NULL);
- ASSERT (VRes != NULL);
- ASSERT (VSync != NULL);
- ASSERT (VBackPorch != NULL);
- ASSERT (VFrontPorch != NULL);
+ ASSERT (Horizontal != NULL);
+ ASSERT (Vertical != NULL);
return EFI_INVALID_PARAMETER;
}
- *HRes = mResolutions[ModeNumber].HorizontalResolution;
- *HSync = mResolutions[ModeNumber].HSync;
- *HBackPorch = mResolutions[ModeNumber].HBackPorch;
- *HFrontPorch = mResolutions[ModeNumber].HFrontPorch;
- *VRes = mResolutions[ModeNumber].VerticalResolution;
- *VSync = mResolutions[ModeNumber].VSync;
- *VBackPorch = mResolutions[ModeNumber].VBackPorch;
- *VFrontPorch = mResolutions[ModeNumber].VFrontPorch;
+ *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
+ *Vertical = &mDisplayModes[ModeNumber].Vertical;
return EFI_SUCCESS;
}
@@ -485,7 +450,7 @@ LcdPlatformGetBpp (
return EFI_INVALID_PARAMETER;
}
- *Bpp = mResolutions[ModeNumber].Bpp;
+ *Bpp = mDisplayModes[ModeNumber].Bpp;
return EFI_SUCCESS;
}
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
index 33c555e75cafaf9affddd0992c4bd9f9289f6703..03153c06d314cb497c91889386ca6075c0c9f718 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
@@ -84,35 +84,25 @@ LcdSetMode (
IN CONST UINT32 ModeNumber
)
{
- EFI_STATUS Status;
- UINT32 HRes;
- UINT32 HSync;
- UINT32 HBackPorch;
- UINT32 HFrontPorch;
- UINT32 VRes;
- UINT32 VSync;
- UINT32 VBackPorch;
- UINT32 VFrontPorch;
- UINT32 BytesPerPixel;
- LCD_BPP LcdBpp;
+ EFI_STATUS Status;
+ CONST SCAN_TIMINGS *Horizontal;
+ CONST SCAN_TIMINGS *Vertical;
+ UINT32 BytesPerPixel;
+ LCD_BPP LcdBpp;
// Set the video mode timings and other relevant information
Status = LcdPlatformGetTimings (
ModeNumber,
- &HRes,
- &HSync,
- &HBackPorch,
- &HFrontPorch,
- &VRes,
- &VSync,
- &VBackPorch,
- &VFrontPorch
+ &Horizontal,
+ &Vertical
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
+ ASSERT (Horizontal != NULL);
+ ASSERT (Vertical != NULL);
Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
if (EFI_ERROR (Status)) {
@@ -126,21 +116,26 @@ LcdSetMode (
MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
// Update the frame buffer information with the new settings
- MmioWrite32 (HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
- MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
- MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, VRes - 1);
+ MmioWrite32 (
+ HDLCD_REG_FB_LINE_LENGTH,
+ Horizontal->Resolution * BytesPerPixel
+ );
+
+ MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, Horizontal->Resolution * BytesPerPixel);
+
+ MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, Vertical->Resolution - 1);
// Set the vertical timing information
- MmioWrite32 (HDLCD_REG_V_SYNC, VSync);
- MmioWrite32 (HDLCD_REG_V_BACK_PORCH, VBackPorch);
- MmioWrite32 (HDLCD_REG_V_DATA, VRes - 1);
- MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
+ MmioWrite32 (HDLCD_REG_V_SYNC, Vertical->Sync);
+ MmioWrite32 (HDLCD_REG_V_BACK_PORCH, Vertical->BackPorch);
+ MmioWrite32 (HDLCD_REG_V_DATA, Vertical->Resolution - 1);
+ MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, Vertical->FrontPorch);
// Set the horizontal timing information
- MmioWrite32 (HDLCD_REG_H_SYNC, HSync);
- MmioWrite32 (HDLCD_REG_H_BACK_PORCH, HBackPorch);
- MmioWrite32 (HDLCD_REG_H_DATA, HRes - 1);
- MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
+ MmioWrite32 (HDLCD_REG_H_SYNC, Horizontal->Sync);
+ MmioWrite32 (HDLCD_REG_H_BACK_PORCH, Horizontal->BackPorch);
+ MmioWrite32 (HDLCD_REG_H_DATA, Horizontal->Resolution - 1);
+ MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, Horizontal->FrontPorch);
// Enable the controller
MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_ENABLE);
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
index 12db9d910ed1d7874095a5f79fe588491811f75a..6de60491e9fd0c5bca71e743aac2862ff85f6e7e 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
@@ -86,34 +86,24 @@ LcdSetMode (
IN CONST UINT32 ModeNumber
)
{
- EFI_STATUS Status;
- UINT32 HRes;
- UINT32 HSync;
- UINT32 HBackPorch;
- UINT32 HFrontPorch;
- UINT32 VRes;
- UINT32 VSync;
- UINT32 VBackPorch;
- UINT32 VFrontPorch;
- UINT32 LcdControl;
- LCD_BPP LcdBpp;
+ EFI_STATUS Status;
+ CONST SCAN_TIMINGS *Horizontal;
+ CONST SCAN_TIMINGS *Vertical;
+ UINT32 LcdControl;
+ LCD_BPP LcdBpp;
// Set the video mode timings and other relevant information
Status = LcdPlatformGetTimings (
ModeNumber,
- &HRes,
- &HSync,
- &HBackPorch,
- &HFrontPorch,
- &VRes,
- &VSync,
- &VBackPorch,
- &VFrontPorch
+ &Horizontal,
+ &Vertical
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
+ ASSERT (Horizontal != NULL);
+ ASSERT (Vertical != NULL);
Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
if (EFI_ERROR (Status)) {
@@ -127,15 +117,29 @@ LcdSetMode (
// Set Timings
MmioWrite32 (
PL111_REG_LCD_TIMING_0,
- HOR_AXIS_PANEL (HBackPorch, HFrontPorch, HSync, HRes)
+ HOR_AXIS_PANEL (
+ Horizontal->BackPorch,
+ Horizontal->FrontPorch,
+ Horizontal->Sync,
+ Horizontal->Resolution
+ )
);
MmioWrite32 (
PL111_REG_LCD_TIMING_1,
- VER_AXIS_PANEL (VBackPorch, VFrontPorch, VSync, VRes)
+ VER_AXIS_PANEL (
+ Vertical->BackPorch,
+ Vertical->FrontPorch,
+ Vertical->Sync,
+ Vertical->Resolution
+ )
+ );
+
+ MmioWrite32 (
+ PL111_REG_LCD_TIMING_2,
+ CLK_SIG_POLARITY (Horizontal->Resolution)
);
- MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY (HRes));
MmioWrite32 (PL111_REG_LCD_TIMING_3, 0);
// PL111_REG_LCD_CONTROL
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 12/19] ArmPlatformPkg: Redefine LcdPlatformGetTimings function
2017-09-26 20:15 ` [PATCH 12/19] ArmPlatformPkg: Redefine LcdPlatformGetTimings function evan.lloyd
@ 2017-10-13 7:49 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-13 7:49 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:22PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> The LcdPlatformGetTimings interface function takes similar sets of
> multiple parameters for horizontal and vertical timings which can be
> aggregated in a common data type. This change defines a structure
> SCAN_TIMINGS for this which can be used to describe both horizontal and
> vertical scan timings, and accordingly redefines the
> LcdPlatformGetTiming interface, greatly reducing the amount of data
> passed about.
>
> Similarly the mode definition tables are also changed to use this data
> type and thus enable pass through access.
>
> 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>
> ---
> ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 32 ++--
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 122 +++++---------
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 177 ++++++++------------
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 55 +++---
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 48 +++---
> 5 files changed, 180 insertions(+), 254 deletions(-)
>
> diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> index 48bdd8a51411137df040aa797fcff272785f7a35..f2f345b18fd15f2cde159fd42d3208a28f598a1f 100644
> --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> @@ -152,6 +152,14 @@ typedef enum {
> LCD_BITS_PER_PIXEL_12_444
> } LCD_BPP;
>
> +// Display timing settings.
> +typedef struct {
> + UINT32 Resolution;
> + UINT32 Sync;
> + UINT32 BackPorch;
> + UINT32 FrontPorch;
> +} SCAN_TIMINGS;
> +
> /** Platform related initialization function.
> *
> * @param IN Handle Handle to the LCD device instance.
> @@ -219,29 +227,19 @@ LcdPlatformQueryMode (
> /** Returns the display timing information for the requested mode number.
> *
> * @param IN ModeNumber Mode Number.
> - * @param OUT HRes Pointer to horizontal resolution.
> - * @param OUT HSync Pointer to horizontal sync width.
> - * @param OUT HBackPorch Pointer to horizontal back porch.
> - * @param OUT HFrontPorch Pointer to horizontal front porch.
> - * @param OUT VRes Pointer to vertical resolution.
> - * @param OUT VSync Pointer to vertical sync width.
> - * @param OUT VBackPorch Pointer to vertical back porch.
> - * @param OUT VFrontPorch Pointer to vertical front porch.
> -
> + * @param OUT Horizontal Pointer to horizontal timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> + * @param OUT Vertical Pointer to vertical timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> + *
> * @retval EFI_SUCCESS Success if the requested mode is found.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> **/
> EFI_STATUS
> LcdPlatformGetTimings (
> IN UINT32 ModeNumber,
> - OUT UINT32* HRes,
> - OUT UINT32* HSync,
> - OUT UINT32* HBackPorch,
> - OUT UINT32* HFrontPorch,
> - OUT UINT32* VRes,
> - OUT UINT32* VSync,
> - OUT UINT32* VBackPorch,
> - OUT UINT32* VFrontPorch
> + OUT CONST SCAN_TIMINGS **Horizontal,
> + OUT CONST SCAN_TIMINGS **Vertical
> );
>
> /** Return bits per pixel information for a mode number.
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index a6c4f414685db907a3fbc9a009969be8a09f7415..dc2c5fb89923304c46d137ec8eaefc9418548d06 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -30,58 +30,52 @@
>
> typedef struct {
> UINT32 Mode;
> - UINT32 HorizontalResolution;
> - UINT32 VerticalResolution;
> LCD_BPP Bpp;
> UINT32 OscFreq;
>
> // These are used by HDLCD
> - UINT32 HSync;
> - UINT32 HBackPorch;
> - UINT32 HFrontPorch;
> - UINT32 VSync;
> - UINT32 VBackPorch;
> - UINT32 VFrontPorch;
> -} LCD_RESOLUTION;
> + SCAN_TIMINGS Horizontal;
> + SCAN_TIMINGS Vertical;
> +} DISPLAY_MODE;
>
> /** The display modes supported by the platform.
> **/
> -STATIC CONST LCD_RESOLUTION mResolutions[] = {
> +STATIC CONST DISPLAY_MODE mDisplayModes[] = {
> { // Mode 0 : VGA : 640 x 480 x 24 bpp
> - VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + VGA, LCD_BITS_PER_PIXEL_24,
> VGA_OSC_FREQUENCY,
> - VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> - VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> + {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> + {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
> },
> { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> - SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + SVGA, LCD_BITS_PER_PIXEL_24,
> SVGA_OSC_FREQUENCY,
> - SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> - SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> + {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> + {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
> },
> { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + XGA, LCD_BITS_PER_PIXEL_24,
> XGA_OSC_FREQUENCY,
> - XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> - XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> + {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> + {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
> },
> { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> - SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + SXGA, LCD_BITS_PER_PIXEL_24,
> (SXGA_OSC_FREQUENCY/2),
> - SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
> - SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
> + {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
> + {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
> },
> { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> - UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + UXGA, LCD_BITS_PER_PIXEL_24,
> (UXGA_OSC_FREQUENCY/2),
> - UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
> - UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
> + {UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH},
> + {UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH}
> },
> { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> - HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + HD, LCD_BITS_PER_PIXEL_24,
> (HD_OSC_FREQUENCY/2),
> - HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
> - HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
> + {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
> + {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
> }
> };
>
> @@ -209,7 +203,7 @@ LcdPlatformGetMaxMode(VOID)
> {
> /* The following line will report correctly the total number of graphics modes
> * that could be supported by the graphics driver: */
> - return (sizeof (mResolutions) / sizeof (LCD_RESOLUTION));
> + return (sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
> }
>
> /** Set the requested display mode.
> @@ -232,7 +226,7 @@ LcdPlatformSetMode (
> Status = ArmPlatformSysConfigSetDevice (
> SYS_CFG_OSC_SITE1,
> FixedPcdGet32 (PcdHdLcdVideoModeOscId),
> - mResolutions[ModeNumber].OscFreq
> + mDisplayModes[ModeNumber].OscFreq
This and the case below will need to be rebased onto something
that fixes the indentation from 3-space to 2-space, and updated.
> );
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> @@ -242,7 +236,7 @@ LcdPlatformSetMode (
> // Set the DVI into the new mode
> Status = ArmPlatformSysConfigSet (
> SYS_CFG_DVIMODE,
> - mResolutions[ModeNumber].Mode
> + mDisplayModes[ModeNumber].Mode
> );
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> @@ -285,11 +279,11 @@ LcdPlatformQueryMode (
> }
>
> Info->Version = 0;
> - Info->HorizontalResolution = mResolutions[ModeNumber].HorizontalResolution;
> - Info->VerticalResolution = mResolutions[ModeNumber].VerticalResolution;
> - Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
> + Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
> + Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
> + Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
>
> - switch (mResolutions[ModeNumber].Bpp) {
> + switch (mDisplayModes[ModeNumber].Bpp) {
> case LCD_BITS_PER_PIXEL_24:
> Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
> Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
> @@ -317,29 +311,20 @@ LcdPlatformQueryMode (
> /** Returns the display timing information for the requested mode number.
> *
> * @param IN ModeNumber Mode Number.
> - * @param OUT HRes Pointer to horizontal resolution.
> - * @param OUT HSync Pointer to horizontal sync width.
> - * @param OUT HBackPorch Pointer to horizontal back porch.
> - * @param OUT HFrontPorch Pointer to horizontal front porch.
> - * @param OUT VRes Pointer to vertical resolution.
> - * @param OUT VSync Pointer to vertical sync width.
> - * @param OUT VBackPorch Pointer to vertical back porch.
> - * @param OUT VFrontPorch Pointer to vertical front porch.
> + * @param OUT Horizontal Pointer to horizontal timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> + * @param OUT Vertical Pointer to vertical timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> +
> *
> * @retval EFI_SUCCESS Success if the requested mode is found.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> **/
> EFI_STATUS
> LcdPlatformGetTimings (
> - IN CONST UINT32 ModeNumber,
> - OUT UINT32 * CONST HRes,
> - OUT UINT32 * CONST HSync,
> - OUT UINT32 * CONST HBackPorch,
> - OUT UINT32 * CONST HFrontPorch,
> - OUT UINT32 * CONST VRes,
> - OUT UINT32 * CONST VSync,
> - OUT UINT32 * CONST VBackPorch,
> - OUT UINT32 * CONST VFrontPorch
> + IN CONST UINT32 ModeNumber,
> + OUT CONST SCAN_TIMINGS ** Horizontal,
> + OUT CONST SCAN_TIMINGS ** Vertical
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -347,35 +332,14 @@ LcdPlatformGetTimings (
> return EFI_INVALID_PARAMETER;
> }
>
> - if (HRes == NULL
> - || HSync == NULL
> - || HBackPorch == NULL
> - || HFrontPorch == NULL
> - || VRes == NULL
> - || VSync == NULL
> - || VBackPorch == NULL
> - || VFrontPorch == NULL)
> - {
> - // One of the pointers is NULL
> - ASSERT (HRes != NULL);
> - ASSERT (HSync != NULL);
> - ASSERT (HBackPorch != NULL);
> - ASSERT (HFrontPorch != NULL);
> - ASSERT (VRes != NULL);
> - ASSERT (VSync != NULL);
> - ASSERT (VBackPorch != NULL);
> - ASSERT (VFrontPorch != NULL);
> + if (Horizontal == NULL || Vertical == NULL) {
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> - *HRes = mResolutions[ModeNumber].HorizontalResolution;
> - *HSync = mResolutions[ModeNumber].HSync;
> - *HBackPorch = mResolutions[ModeNumber].HBackPorch;
> - *HFrontPorch = mResolutions[ModeNumber].HFrontPorch;
> - *VRes = mResolutions[ModeNumber].VerticalResolution;
> - *VSync = mResolutions[ModeNumber].VSync;
> - *VBackPorch = mResolutions[ModeNumber].VBackPorch;
> - *VFrontPorch = mResolutions[ModeNumber].VFrontPorch;
> + *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
> + *Vertical = &mDisplayModes[ModeNumber].Vertical;
>
> return EFI_SUCCESS;
> }
> @@ -401,7 +365,7 @@ LcdPlatformGetBpp (
> return EFI_INVALID_PARAMETER;
> }
>
> - *Bpp = mResolutions[ModeNumber].Bpp;
> + *Bpp = mDisplayModes[ModeNumber].Bpp;
>
> return EFI_SUCCESS;
> }
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index aa5a1ff9c1c25c51796b75230ca149ae3a92db4a..753c5b615361f83625cdd4f0506909721da014b6 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -28,117 +28,111 @@
>
> typedef struct {
> UINT32 Mode;
> - UINT32 HorizontalResolution;
> - UINT32 VerticalResolution;
> LCD_BPP Bpp;
> UINT32 OscFreq;
>
> - UINT32 HSync;
> - UINT32 HBackPorch;
> - UINT32 HFrontPorch;
> - UINT32 VSync;
> - UINT32 VBackPorch;
> - UINT32 VFrontPorch;
> -} LCD_RESOLUTION;
> + SCAN_TIMINGS Horizontal;
> + SCAN_TIMINGS Vertical;
> +} DISPLAY_MODE;
>
> /** The display modes supported by the platform.
> **/
> -STATIC CONST LCD_RESOLUTION mResolutions[] = {
> +STATIC CONST DISPLAY_MODE mDisplayModes[] = {
> { // Mode 0 : VGA : 640 x 480 x 24 bpp
Again, indentation needs fixing in earlier patch and this one
regenerated on top.
No further comments on this patch, other than : nice bit of cleanup.
/
Leif
> - VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + VGA, LCD_BITS_PER_PIXEL_24,
> VGA_OSC_FREQUENCY,
> - VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> - VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> + {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> + {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
> },
> { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> - SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + SVGA, LCD_BITS_PER_PIXEL_24,
> SVGA_OSC_FREQUENCY,
> - SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> - SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> + {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> + {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
> },
> { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + XGA, LCD_BITS_PER_PIXEL_24,
> XGA_OSC_FREQUENCY,
> - XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> - XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> + {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> + {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
> },
> { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> - SXGA, SXGA_H_RES_PIXELS, SXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + SXGA, LCD_BITS_PER_PIXEL_24,
> (SXGA_OSC_FREQUENCY/2),
> - SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH,
> - SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH
> + {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
> + {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
> },
> { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> - UXGA, UXGA_H_RES_PIXELS, UXGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + UXGA, LCD_BITS_PER_PIXEL_24,
> (UXGA_OSC_FREQUENCY/2),
> - UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH,
> - UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH
> + {UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH},
> + {UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH}
> },
> { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> - HD, HD_H_RES_PIXELS, HD_V_RES_PIXELS, LCD_BITS_PER_PIXEL_24,
> + HD, LCD_BITS_PER_PIXEL_24,
> (HD_OSC_FREQUENCY/2),
> - HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH,
> - HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH
> + {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
> + {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
> },
> { // Mode 6 : VGA : 640 x 480 x 16 bpp (565 Mode)
> - VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> + VGA, LCD_BITS_PER_PIXEL_16_565,
> VGA_OSC_FREQUENCY,
> - VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> - VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> + {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> + {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
> },
> { // Mode 7 : SVGA : 800 x 600 x 16 bpp (565 Mode)
> - SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> + SVGA, LCD_BITS_PER_PIXEL_16_565,
> SVGA_OSC_FREQUENCY,
> - SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> - SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> + {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> + {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
> },
> { // Mode 8 : XGA : 1024 x 768 x 16 bpp (565 Mode)
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_565,
> + XGA, LCD_BITS_PER_PIXEL_16_565,
> XGA_OSC_FREQUENCY,
> - XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> - XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> + {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> + {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
> },
> { // Mode 9 : VGA : 640 x 480 x 15 bpp
> - VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> + VGA, LCD_BITS_PER_PIXEL_16_555,
> VGA_OSC_FREQUENCY,
> - VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> - VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> + {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> + {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
> },
> { // Mode 10 : SVGA : 800 x 600 x 15 bpp
> - SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> + SVGA, LCD_BITS_PER_PIXEL_16_555,
> SVGA_OSC_FREQUENCY,
> - SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> - SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> + {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> + {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
> },
> { // Mode 11 : XGA : 1024 x 768 x 15 bpp
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> + XGA, LCD_BITS_PER_PIXEL_16_555,
> XGA_OSC_FREQUENCY,
> - XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> - XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> + {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> + {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
> },
> { // Mode 12 : XGA : 1024 x 768 x 15 bpp - All the timing info is derived from Linux Kernel Driver Settings
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_16_555,
> + XGA, LCD_BITS_PER_PIXEL_16_555,
> 63500000,
> - XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> - XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> + {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> + {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
> },
> { // Mode 13 : VGA : 640 x 480 x 12 bpp (444 Mode)
> - VGA, VGA_H_RES_PIXELS, VGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> + VGA, LCD_BITS_PER_PIXEL_12_444,
> VGA_OSC_FREQUENCY,
> - VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH,
> - VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH
> + {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> + {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
> },
> { // Mode 14 : SVGA : 800 x 600 x 12 bpp (444 Mode)
> - SVGA, SVGA_H_RES_PIXELS, SVGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> + SVGA, LCD_BITS_PER_PIXEL_12_444,
> SVGA_OSC_FREQUENCY,
> - SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH,
> - SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH
> + {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> + {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
> },
> { // Mode 15 : XGA : 1024 x 768 x 12 bpp (444 Mode)
> - XGA, XGA_H_RES_PIXELS, XGA_V_RES_PIXELS, LCD_BITS_PER_PIXEL_12_444,
> + XGA, LCD_BITS_PER_PIXEL_12_444,
> XGA_OSC_FREQUENCY,
> - XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH,
> - XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH
> + {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> + {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
> }
> };
>
> @@ -308,7 +302,7 @@ LcdPlatformSetMode (
> Status = ArmPlatformSysConfigSetDevice (
> Function,
> OscillatorId,
> - mResolutions[ModeNumber].OscFreq
> + mDisplayModes[ModeNumber].OscFreq
> );
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> @@ -326,7 +320,7 @@ LcdPlatformSetMode (
> // Set the DVI into the new mode
> Status = ArmPlatformSysConfigSet (
> SYS_CFG_DVIMODE,
> - mResolutions[ModeNumber].Mode
> + mDisplayModes[ModeNumber].Mode
> );
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> @@ -368,11 +362,11 @@ LcdPlatformQueryMode (
> }
>
> Info->Version = 0;
> - Info->HorizontalResolution = mResolutions[ModeNumber].HorizontalResolution;
> - Info->VerticalResolution = mResolutions[ModeNumber].VerticalResolution;
> - Info->PixelsPerScanLine = mResolutions[ModeNumber].HorizontalResolution;
> + Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
> + Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
> + Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
>
> - switch (mResolutions[ModeNumber].Bpp) {
> + switch (mDisplayModes[ModeNumber].Bpp) {
> case LCD_BITS_PER_PIXEL_24:
> Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
> Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
> @@ -400,14 +394,10 @@ LcdPlatformQueryMode (
> /** Returns the display timing information for the requested mode number.
> *
> * @param IN ModeNumber Mode Number.
> - * @param OUT HRes Pointer to horizontal resolution.
> - * @param OUT HSync Pointer to horizontal sync width.
> - * @param OUT HBackPorch Pointer to horizontal back porch.
> - * @param OUT HFrontPorch Pointer to horizontal front porch.
> - * @param OUT VRes Pointer to vertical resolution.
> - * @param OUT VSync Pointer to vertical sync width.
> - * @param OUT VBackPorch Pointer to vertical back porch.
> - * @param OUT VFrontPorch Pointer to vertical front porch.
> + * @param OUT Horizontal Pointer to horizontal timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> + * @param OUT Vertical Pointer to vertical timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> *
> * @retval EFI_SUCCESS Success if the requested mode is found.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> @@ -415,15 +405,9 @@ LcdPlatformQueryMode (
> **/
> EFI_STATUS
> LcdPlatformGetTimings (
> - IN CONST UINT32 ModeNumber,
> - OUT UINT32 * CONST HRes,
> - OUT UINT32 * CONST HSync,
> - OUT UINT32 * CONST HBackPorch,
> - OUT UINT32 * CONST HFrontPorch,
> - OUT UINT32 * CONST VRes,
> - OUT UINT32 * CONST VSync,
> - OUT UINT32 * CONST VBackPorch,
> - OUT UINT32 * CONST VFrontPorch
> + IN CONST UINT32 ModeNumber,
> + OUT CONST SCAN_TIMINGS ** Horizontal,
> + OUT CONST SCAN_TIMINGS ** Vertical
> )
> {
> if (ModeNumber >= LcdPlatformGetMaxMode ()) {
> @@ -431,35 +415,16 @@ LcdPlatformGetTimings (
> return EFI_INVALID_PARAMETER;
> }
>
> - if (HRes == NULL
> - || HSync == NULL
> - || HBackPorch == NULL
> - || HFrontPorch == NULL
> - || VRes == NULL
> - || VSync == NULL
> - || VBackPorch == NULL
> - || VFrontPorch == NULL)
> + if (Horizontal == NULL || Vertical == NULL)
> {
> // One of the pointers is NULL
> - ASSERT (HRes != NULL);
> - ASSERT (HSync != NULL);
> - ASSERT (HBackPorch != NULL);
> - ASSERT (HFrontPorch != NULL);
> - ASSERT (VRes != NULL);
> - ASSERT (VSync != NULL);
> - ASSERT (VBackPorch != NULL);
> - ASSERT (VFrontPorch != NULL);
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
> return EFI_INVALID_PARAMETER;
> }
>
> - *HRes = mResolutions[ModeNumber].HorizontalResolution;
> - *HSync = mResolutions[ModeNumber].HSync;
> - *HBackPorch = mResolutions[ModeNumber].HBackPorch;
> - *HFrontPorch = mResolutions[ModeNumber].HFrontPorch;
> - *VRes = mResolutions[ModeNumber].VerticalResolution;
> - *VSync = mResolutions[ModeNumber].VSync;
> - *VBackPorch = mResolutions[ModeNumber].VBackPorch;
> - *VFrontPorch = mResolutions[ModeNumber].VFrontPorch;
> + *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
> + *Vertical = &mDisplayModes[ModeNumber].Vertical;
>
> return EFI_SUCCESS;
> }
> @@ -485,7 +450,7 @@ LcdPlatformGetBpp (
> return EFI_INVALID_PARAMETER;
> }
>
> - *Bpp = mResolutions[ModeNumber].Bpp;
> + *Bpp = mDisplayModes[ModeNumber].Bpp;
>
> return EFI_SUCCESS;
> }
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> index 33c555e75cafaf9affddd0992c4bd9f9289f6703..03153c06d314cb497c91889386ca6075c0c9f718 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> @@ -84,35 +84,25 @@ LcdSetMode (
> IN CONST UINT32 ModeNumber
> )
> {
> - EFI_STATUS Status;
> - UINT32 HRes;
> - UINT32 HSync;
> - UINT32 HBackPorch;
> - UINT32 HFrontPorch;
> - UINT32 VRes;
> - UINT32 VSync;
> - UINT32 VBackPorch;
> - UINT32 VFrontPorch;
> - UINT32 BytesPerPixel;
> - LCD_BPP LcdBpp;
> + EFI_STATUS Status;
> + CONST SCAN_TIMINGS *Horizontal;
> + CONST SCAN_TIMINGS *Vertical;
> + UINT32 BytesPerPixel;
> + LCD_BPP LcdBpp;
>
>
> // Set the video mode timings and other relevant information
> Status = LcdPlatformGetTimings (
> ModeNumber,
> - &HRes,
> - &HSync,
> - &HBackPorch,
> - &HFrontPorch,
> - &VRes,
> - &VSync,
> - &VBackPorch,
> - &VFrontPorch
> + &Horizontal,
> + &Vertical
> );
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
>
> Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> if (EFI_ERROR (Status)) {
> @@ -126,21 +116,26 @@ LcdSetMode (
> MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
>
> // Update the frame buffer information with the new settings
> - MmioWrite32 (HDLCD_REG_FB_LINE_LENGTH, HRes * BytesPerPixel);
> - MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, HRes * BytesPerPixel);
> - MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, VRes - 1);
> + MmioWrite32 (
> + HDLCD_REG_FB_LINE_LENGTH,
> + Horizontal->Resolution * BytesPerPixel
> + );
> +
> + MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, Horizontal->Resolution * BytesPerPixel);
> +
> + MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, Vertical->Resolution - 1);
>
> // Set the vertical timing information
> - MmioWrite32 (HDLCD_REG_V_SYNC, VSync);
> - MmioWrite32 (HDLCD_REG_V_BACK_PORCH, VBackPorch);
> - MmioWrite32 (HDLCD_REG_V_DATA, VRes - 1);
> - MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, VFrontPorch);
> + MmioWrite32 (HDLCD_REG_V_SYNC, Vertical->Sync);
> + MmioWrite32 (HDLCD_REG_V_BACK_PORCH, Vertical->BackPorch);
> + MmioWrite32 (HDLCD_REG_V_DATA, Vertical->Resolution - 1);
> + MmioWrite32 (HDLCD_REG_V_FRONT_PORCH, Vertical->FrontPorch);
>
> // Set the horizontal timing information
> - MmioWrite32 (HDLCD_REG_H_SYNC, HSync);
> - MmioWrite32 (HDLCD_REG_H_BACK_PORCH, HBackPorch);
> - MmioWrite32 (HDLCD_REG_H_DATA, HRes - 1);
> - MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, HFrontPorch);
> + MmioWrite32 (HDLCD_REG_H_SYNC, Horizontal->Sync);
> + MmioWrite32 (HDLCD_REG_H_BACK_PORCH, Horizontal->BackPorch);
> + MmioWrite32 (HDLCD_REG_H_DATA, Horizontal->Resolution - 1);
> + MmioWrite32 (HDLCD_REG_H_FRONT_PORCH, Horizontal->FrontPorch);
>
> // Enable the controller
> MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_ENABLE);
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> index 12db9d910ed1d7874095a5f79fe588491811f75a..6de60491e9fd0c5bca71e743aac2862ff85f6e7e 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> @@ -86,34 +86,24 @@ LcdSetMode (
> IN CONST UINT32 ModeNumber
> )
> {
> - EFI_STATUS Status;
> - UINT32 HRes;
> - UINT32 HSync;
> - UINT32 HBackPorch;
> - UINT32 HFrontPorch;
> - UINT32 VRes;
> - UINT32 VSync;
> - UINT32 VBackPorch;
> - UINT32 VFrontPorch;
> - UINT32 LcdControl;
> - LCD_BPP LcdBpp;
> + EFI_STATUS Status;
> + CONST SCAN_TIMINGS *Horizontal;
> + CONST SCAN_TIMINGS *Vertical;
> + UINT32 LcdControl;
> + LCD_BPP LcdBpp;
>
> // Set the video mode timings and other relevant information
> Status = LcdPlatformGetTimings (
> ModeNumber,
> - &HRes,
> - &HSync,
> - &HBackPorch,
> - &HFrontPorch,
> - &VRes,
> - &VSync,
> - &VBackPorch,
> - &VFrontPorch
> + &Horizontal,
> + &Vertical
> );
> if (EFI_ERROR (Status)) {
> ASSERT_EFI_ERROR (Status);
> return Status;
> }
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
>
> Status = LcdPlatformGetBpp (ModeNumber, &LcdBpp);
> if (EFI_ERROR (Status)) {
> @@ -127,15 +117,29 @@ LcdSetMode (
> // Set Timings
> MmioWrite32 (
> PL111_REG_LCD_TIMING_0,
> - HOR_AXIS_PANEL (HBackPorch, HFrontPorch, HSync, HRes)
> + HOR_AXIS_PANEL (
> + Horizontal->BackPorch,
> + Horizontal->FrontPorch,
> + Horizontal->Sync,
> + Horizontal->Resolution
> + )
> );
>
> MmioWrite32 (
> PL111_REG_LCD_TIMING_1,
> - VER_AXIS_PANEL (VBackPorch, VFrontPorch, VSync, VRes)
> + VER_AXIS_PANEL (
> + Vertical->BackPorch,
> + Vertical->FrontPorch,
> + Vertical->Sync,
> + Vertical->Resolution
> + )
> + );
> +
> + MmioWrite32 (
> + PL111_REG_LCD_TIMING_2,
> + CLK_SIG_POLARITY (Horizontal->Resolution)
> );
>
> - MmioWrite32 (PL111_REG_LCD_TIMING_2, CLK_SIG_POLARITY (HRes));
> MmioWrite32 (PL111_REG_LCD_TIMING_3, 0);
>
> // PL111_REG_LCD_CONTROL
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 13/19] ArmPlatformPkg: HdLcd Remove redundant Bpp
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (11 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 12/19] ArmPlatformPkg: Redefine LcdPlatformGetTimings function evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-13 7:53 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 14/19] ArmPlatformPkg: Add PCD to select pixel format evan.lloyd
` (5 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: EvanLloyd <evan.lloyd@arm.com>
Because of copy/paste effects, HdLcdArmVExpress.c contained a
table entry "LCD_BPP Bpp;" specifying the Bits per Pixel for each mode.
However, all modes are LCD_BITS_PER_PIXEL_24.
This change removes the table entry and related use of the field.
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>
---
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 42 ++++++--------------
1 file changed, 13 insertions(+), 29 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index dc2c5fb89923304c46d137ec8eaefc9418548d06..2401cdb30cb7252964ce1f363aa26d99933c09be 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -30,7 +30,6 @@
typedef struct {
UINT32 Mode;
- LCD_BPP Bpp;
UINT32 OscFreq;
// These are used by HDLCD
@@ -42,37 +41,37 @@ typedef struct {
**/
STATIC CONST DISPLAY_MODE mDisplayModes[] = {
{ // Mode 0 : VGA : 640 x 480 x 24 bpp
- VGA, LCD_BITS_PER_PIXEL_24,
+ VGA,
VGA_OSC_FREQUENCY,
{VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
{VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
},
{ // Mode 1 : SVGA : 800 x 600 x 24 bpp
- SVGA, LCD_BITS_PER_PIXEL_24,
+ SVGA,
SVGA_OSC_FREQUENCY,
{SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
{SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
},
{ // Mode 2 : XGA : 1024 x 768 x 24 bpp
- XGA, LCD_BITS_PER_PIXEL_24,
+ XGA,
XGA_OSC_FREQUENCY,
{XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
{XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
},
{ // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
- SXGA, LCD_BITS_PER_PIXEL_24,
+ SXGA,
(SXGA_OSC_FREQUENCY/2),
{SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
{SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
},
{ // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
- UXGA, LCD_BITS_PER_PIXEL_24,
+ UXGA,
(UXGA_OSC_FREQUENCY/2),
{UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH},
{UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH}
},
{ // Mode 5 : HD : 1920 x 1080 x 24 bpp
- HD, LCD_BITS_PER_PIXEL_24,
+ HD,
(HD_OSC_FREQUENCY/2),
{HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
{HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
@@ -283,27 +282,12 @@ LcdPlatformQueryMode (
Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
- switch (mDisplayModes[ModeNumber].Bpp) {
- case LCD_BITS_PER_PIXEL_24:
- Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
- Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
- Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
- Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
- Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
- break;
-
- case LCD_BITS_PER_PIXEL_16_555:
- case LCD_BITS_PER_PIXEL_16_565:
- case LCD_BITS_PER_PIXEL_12_444:
- case LCD_BITS_PER_PIXEL_8:
- case LCD_BITS_PER_PIXEL_4:
- case LCD_BITS_PER_PIXEL_2:
- case LCD_BITS_PER_PIXEL_1:
- default:
- // These are not supported
- ASSERT (FALSE);
- break;
- }
+ /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
+ Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
+ Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
+ Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
+ Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
+ Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
return EFI_SUCCESS;
}
@@ -365,7 +349,7 @@ LcdPlatformGetBpp (
return EFI_INVALID_PARAMETER;
}
- *Bpp = mDisplayModes[ModeNumber].Bpp;
+ *Bpp = LCD_BITS_PER_PIXEL_24;
return EFI_SUCCESS;
}
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 13/19] ArmPlatformPkg: HdLcd Remove redundant Bpp
2017-09-26 20:15 ` [PATCH 13/19] ArmPlatformPkg: HdLcd Remove redundant Bpp evan.lloyd
@ 2017-10-13 7:53 ` Leif Lindholm
2017-10-17 14:32 ` Evan Lloyd
0 siblings, 1 reply; 69+ messages in thread
From: Leif Lindholm @ 2017-10-13 7:53 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:23PM +0100, evan.lloyd@arm.com wrote:
> From: EvanLloyd <evan.lloyd@arm.com>
>
> Because of copy/paste effects, HdLcdArmVExpress.c contained a
> table entry "LCD_BPP Bpp;" specifying the Bits per Pixel for each mode.
> However, all modes are LCD_BITS_PER_PIXEL_24.
>
> This change removes the table entry and related use of the field.
Since it looks to be modifying some of the same lines, I would prefer
to see this patch before the previous one. Or am I misreading that?
/
Leif
> 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>
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 42 ++++++--------------
> 1 file changed, 13 insertions(+), 29 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index dc2c5fb89923304c46d137ec8eaefc9418548d06..2401cdb30cb7252964ce1f363aa26d99933c09be 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -30,7 +30,6 @@
>
> typedef struct {
> UINT32 Mode;
> - LCD_BPP Bpp;
> UINT32 OscFreq;
>
> // These are used by HDLCD
> @@ -42,37 +41,37 @@ typedef struct {
> **/
> STATIC CONST DISPLAY_MODE mDisplayModes[] = {
> { // Mode 0 : VGA : 640 x 480 x 24 bpp
> - VGA, LCD_BITS_PER_PIXEL_24,
> + VGA,
> VGA_OSC_FREQUENCY,
> {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
> },
> { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> - SVGA, LCD_BITS_PER_PIXEL_24,
> + SVGA,
> SVGA_OSC_FREQUENCY,
> {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
> },
> { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> - XGA, LCD_BITS_PER_PIXEL_24,
> + XGA,
> XGA_OSC_FREQUENCY,
> {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
> },
> { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> - SXGA, LCD_BITS_PER_PIXEL_24,
> + SXGA,
> (SXGA_OSC_FREQUENCY/2),
> {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
> {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
> },
> { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> - UXGA, LCD_BITS_PER_PIXEL_24,
> + UXGA,
> (UXGA_OSC_FREQUENCY/2),
> {UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH, UXGA_H_FRONT_PORCH},
> {UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH, UXGA_V_FRONT_PORCH}
> },
> { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> - HD, LCD_BITS_PER_PIXEL_24,
> + HD,
> (HD_OSC_FREQUENCY/2),
> {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
> {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
> @@ -283,27 +282,12 @@ LcdPlatformQueryMode (
> Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
> Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
>
> - switch (mDisplayModes[ModeNumber].Bpp) {
> - case LCD_BITS_PER_PIXEL_24:
> - Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
> - Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
> - Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
> - Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
> - Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> - break;
> -
> - case LCD_BITS_PER_PIXEL_16_555:
> - case LCD_BITS_PER_PIXEL_16_565:
> - case LCD_BITS_PER_PIXEL_12_444:
> - case LCD_BITS_PER_PIXEL_8:
> - case LCD_BITS_PER_PIXEL_4:
> - case LCD_BITS_PER_PIXEL_2:
> - case LCD_BITS_PER_PIXEL_1:
> - default:
> - // These are not supported
> - ASSERT (FALSE);
> - break;
> - }
> + /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
> + Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
> + Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
> + Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
> + Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
> + Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
>
> return EFI_SUCCESS;
> }
> @@ -365,7 +349,7 @@ LcdPlatformGetBpp (
> return EFI_INVALID_PARAMETER;
> }
>
> - *Bpp = mDisplayModes[ModeNumber].Bpp;
> + *Bpp = LCD_BITS_PER_PIXEL_24;
>
> return EFI_SUCCESS;
> }
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 13/19] ArmPlatformPkg: HdLcd Remove redundant Bpp
2017-10-13 7:53 ` Leif Lindholm
@ 2017-10-17 14:32 ` Evan Lloyd
2017-10-17 15:40 ` Leif Lindholm
0 siblings, 1 reply; 69+ messages in thread
From: Evan Lloyd @ 2017-10-17 14:32 UTC (permalink / raw)
To: Leif Lindholm; +Cc: edk2-devel@lists.01.org
> -----Original Message-----
> From: Leif Lindholm [mailto:leif.lindholm@linaro.org]
> Sent: 13 October 2017 08:53
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org
> Subject: Re: [PATCH 13/19] ArmPlatformPkg: HdLcd Remove redundant Bpp
>
> On Tue, Sep 26, 2017 at 09:15:23PM +0100, evan.lloyd@arm.com wrote:
> > From: EvanLloyd <evan.lloyd@arm.com>
> >
> > Because of copy/paste effects, HdLcdArmVExpress.c contained a table
> > entry "LCD_BPP Bpp;" specifying the Bits per Pixel for each mode.
> > However, all modes are LCD_BITS_PER_PIXEL_24.
> >
> > This change removes the table entry and related use of the field.
>
> Since it looks to be modifying some of the same lines, I would prefer to see
> this patch before the previous one. Or am I misreading that?
[[Evan Lloyd]] It does modify some shared lines. In practice this change became obvious once the previous one had been made. I'm not sure I understand what benefit you see in changing the order. I am, however, sure of the cost of rework and re-test. Do you really need this order change? How would you feel about our rolling them both together?
Evan
>
> /
> Leif
>
> > 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>
> > ---
> >
> >
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArm
> VExp
> > ress.c | 42 ++++++--------------
> > 1 file changed, 13 insertions(+), 29 deletions(-)
> >
> > diff --git
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> mVE
> > xpress.c
> >
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> mVE
> > xpress.c index
> >
> dc2c5fb89923304c46d137ec8eaefc9418548d06..2401cdb30cb7252964ce1f36
> 3aa2
> > 6d99933c09be 100644
> > ---
> >
> a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> mVE
> > xpress.c
> > +++
> b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdA
> > +++ rmVExpress.c
> > @@ -30,7 +30,6 @@
> >
> > typedef struct {
> > UINT32 Mode;
> > - LCD_BPP Bpp;
> > UINT32 OscFreq;
> >
> > // These are used by HDLCD
> > @@ -42,37 +41,37 @@ typedef struct {
> > **/
> > STATIC CONST DISPLAY_MODE mDisplayModes[] = {
> > { // Mode 0 : VGA : 640 x 480 x 24 bpp
> > - VGA, LCD_BITS_PER_PIXEL_24,
> > + VGA,
> > VGA_OSC_FREQUENCY,
> > {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH,
> VGA_H_FRONT_PORCH},
> > {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH,
> VGA_V_FRONT_PORCH}
> > },
> > { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> > - SVGA, LCD_BITS_PER_PIXEL_24,
> > + SVGA,
> > SVGA_OSC_FREQUENCY,
> > {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH,
> SVGA_H_FRONT_PORCH},
> > {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH,
> SVGA_V_FRONT_PORCH}
> > },
> > { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> > - XGA, LCD_BITS_PER_PIXEL_24,
> > + XGA,
> > XGA_OSC_FREQUENCY,
> > {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH,
> XGA_H_FRONT_PORCH},
> > {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH,
> XGA_V_FRONT_PORCH}
> > },
> > { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> > - SXGA, LCD_BITS_PER_PIXEL_24,
> > + SXGA,
> > (SXGA_OSC_FREQUENCY/2),
> > {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH,
> SXGA_H_FRONT_PORCH},
> > {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH,
> SXGA_V_FRONT_PORCH}
> > },
> > { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> > - UXGA, LCD_BITS_PER_PIXEL_24,
> > + UXGA,
> > (UXGA_OSC_FREQUENCY/2),
> > {UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH,
> UXGA_H_FRONT_PORCH},
> > {UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH,
> UXGA_V_FRONT_PORCH}
> > },
> > { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> > - HD, LCD_BITS_PER_PIXEL_24,
> > + HD,
> > (HD_OSC_FREQUENCY/2),
> > {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH,
> HD_H_FRONT_PORCH},
> > {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH,
> HD_V_FRONT_PORCH}
> > @@ -283,27 +282,12 @@ LcdPlatformQueryMode (
> > Info->VerticalResolution =
> mDisplayModes[ModeNumber].Vertical.Resolution;
> > Info->PixelsPerScanLine =
> > mDisplayModes[ModeNumber].Horizontal.Resolution;
> >
> > - switch (mDisplayModes[ModeNumber].Bpp) {
> > - case LCD_BITS_PER_PIXEL_24:
> > - Info->PixelFormat =
> PixelRedGreenBlueReserved8BitPerColor;
> > - Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
> > - Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
> > - Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
> > - Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> > - break;
> > -
> > - case LCD_BITS_PER_PIXEL_16_555:
> > - case LCD_BITS_PER_PIXEL_16_565:
> > - case LCD_BITS_PER_PIXEL_12_444:
> > - case LCD_BITS_PER_PIXEL_8:
> > - case LCD_BITS_PER_PIXEL_4:
> > - case LCD_BITS_PER_PIXEL_2:
> > - case LCD_BITS_PER_PIXEL_1:
> > - default:
> > - // These are not supported
> > - ASSERT (FALSE);
> > - break;
> > - }
> > + /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
> > + Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
> > + Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
> > + Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
> > + Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
> > + Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> >
> > return EFI_SUCCESS;
> > }
> > @@ -365,7 +349,7 @@ LcdPlatformGetBpp (
> > return EFI_INVALID_PARAMETER;
> > }
> >
> > - *Bpp = mDisplayModes[ModeNumber].Bpp;
> > + *Bpp = LCD_BITS_PER_PIXEL_24;
> >
> > return EFI_SUCCESS;
> > }
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 13/19] ArmPlatformPkg: HdLcd Remove redundant Bpp
2017-10-17 14:32 ` Evan Lloyd
@ 2017-10-17 15:40 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-17 15:40 UTC (permalink / raw)
To: Evan Lloyd; +Cc: edk2-devel@lists.01.org
On Tue, Oct 17, 2017 at 02:32:05PM +0000, Evan Lloyd wrote:
>
>
> > -----Original Message-----
> > From: Leif Lindholm [mailto:leif.lindholm@linaro.org]
> > Sent: 13 October 2017 08:53
> > To: Evan Lloyd <Evan.Lloyd@arm.com>
> > Cc: edk2-devel@lists.01.org
> > Subject: Re: [PATCH 13/19] ArmPlatformPkg: HdLcd Remove redundant Bpp
> >
> > On Tue, Sep 26, 2017 at 09:15:23PM +0100, evan.lloyd@arm.com wrote:
> > > From: EvanLloyd <evan.lloyd@arm.com>
> > >
> > > Because of copy/paste effects, HdLcdArmVExpress.c contained a table
> > > entry "LCD_BPP Bpp;" specifying the Bits per Pixel for each mode.
> > > However, all modes are LCD_BITS_PER_PIXEL_24.
> > >
> > > This change removes the table entry and related use of the field.
> >
> > Since it looks to be modifying some of the same lines, I would prefer to see
> > this patch before the previous one. Or am I misreading that?
>
> [[Evan Lloyd]] It does modify some shared lines. In practice this
> change became obvious once the previous one had been made. I'm not
> sure I understand what benefit you see in changing the order. I am,
> however, sure of the cost of rework and re-test.
This rework is minor. If you or your team can use some help with the
git trickery that makes it simple, I'm happy to assist.
If you trust me, you can pick the result from
https://git.linaro.org/people/leif.lindholm/edk2.git/log/?h=166_gop_v1
(but the whole point of this is that I don't understand the changeset
up front, so I may have bungled something)
If your project schedule does not include the time to rework and
re-test patchsets, I'll have a strong word with your product manager
:)
> Do you really need
> this order change? How would you feel about our rolling them both
> together?
Not ideal. One is trivial cleanup, the other is an API change -
squashing them together makes it a lot less clear which is which, and
hence a lot harder to perform any sensible level of code review.
Also a heads up: when you rebase this series to edk2/master, you'll
encounter a breakage caused by
gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize being given the
same TokenValue as (now upstream)
gArmPlatformTokenSpaceGuid.PcdWatchdogCount.
/
Leif
> Evan
>
> >
> > /
> > Leif
> >
> > > 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>
> > > ---
> > >
> > >
> > ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArm
> > VExp
> > > ress.c | 42 ++++++--------------
> > > 1 file changed, 13 insertions(+), 29 deletions(-)
> > >
> > > diff --git
> > >
> > a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> > mVE
> > > xpress.c
> > >
> > b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> > mVE
> > > xpress.c index
> > >
> > dc2c5fb89923304c46d137ec8eaefc9418548d06..2401cdb30cb7252964ce1f36
> > 3aa2
> > > 6d99933c09be 100644
> > > ---
> > >
> > a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdAr
> > mVE
> > > xpress.c
> > > +++
> > b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdA
> > > +++ rmVExpress.c
> > > @@ -30,7 +30,6 @@
> > >
> > > typedef struct {
> > > UINT32 Mode;
> > > - LCD_BPP Bpp;
> > > UINT32 OscFreq;
> > >
> > > // These are used by HDLCD
> > > @@ -42,37 +41,37 @@ typedef struct {
> > > **/
> > > STATIC CONST DISPLAY_MODE mDisplayModes[] = {
> > > { // Mode 0 : VGA : 640 x 480 x 24 bpp
> > > - VGA, LCD_BITS_PER_PIXEL_24,
> > > + VGA,
> > > VGA_OSC_FREQUENCY,
> > > {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH,
> > VGA_H_FRONT_PORCH},
> > > {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH,
> > VGA_V_FRONT_PORCH}
> > > },
> > > { // Mode 1 : SVGA : 800 x 600 x 24 bpp
> > > - SVGA, LCD_BITS_PER_PIXEL_24,
> > > + SVGA,
> > > SVGA_OSC_FREQUENCY,
> > > {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH,
> > SVGA_H_FRONT_PORCH},
> > > {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH,
> > SVGA_V_FRONT_PORCH}
> > > },
> > > { // Mode 2 : XGA : 1024 x 768 x 24 bpp
> > > - XGA, LCD_BITS_PER_PIXEL_24,
> > > + XGA,
> > > XGA_OSC_FREQUENCY,
> > > {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH,
> > XGA_H_FRONT_PORCH},
> > > {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH,
> > XGA_V_FRONT_PORCH}
> > > },
> > > { // Mode 3 : SXGA : 1280 x 1024 x 24 bpp
> > > - SXGA, LCD_BITS_PER_PIXEL_24,
> > > + SXGA,
> > > (SXGA_OSC_FREQUENCY/2),
> > > {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH,
> > SXGA_H_FRONT_PORCH},
> > > {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH,
> > SXGA_V_FRONT_PORCH}
> > > },
> > > { // Mode 4 : UXGA : 1600 x 1200 x 24 bpp
> > > - UXGA, LCD_BITS_PER_PIXEL_24,
> > > + UXGA,
> > > (UXGA_OSC_FREQUENCY/2),
> > > {UXGA_H_RES_PIXELS, UXGA_H_SYNC, UXGA_H_BACK_PORCH,
> > UXGA_H_FRONT_PORCH},
> > > {UXGA_V_RES_PIXELS, UXGA_V_SYNC, UXGA_V_BACK_PORCH,
> > UXGA_V_FRONT_PORCH}
> > > },
> > > { // Mode 5 : HD : 1920 x 1080 x 24 bpp
> > > - HD, LCD_BITS_PER_PIXEL_24,
> > > + HD,
> > > (HD_OSC_FREQUENCY/2),
> > > {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH,
> > HD_H_FRONT_PORCH},
> > > {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH,
> > HD_V_FRONT_PORCH}
> > > @@ -283,27 +282,12 @@ LcdPlatformQueryMode (
> > > Info->VerticalResolution =
> > mDisplayModes[ModeNumber].Vertical.Resolution;
> > > Info->PixelsPerScanLine =
> > > mDisplayModes[ModeNumber].Horizontal.Resolution;
> > >
> > > - switch (mDisplayModes[ModeNumber].Bpp) {
> > > - case LCD_BITS_PER_PIXEL_24:
> > > - Info->PixelFormat =
> > PixelRedGreenBlueReserved8BitPerColor;
> > > - Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
> > > - Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
> > > - Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
> > > - Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> > > - break;
> > > -
> > > - case LCD_BITS_PER_PIXEL_16_555:
> > > - case LCD_BITS_PER_PIXEL_16_565:
> > > - case LCD_BITS_PER_PIXEL_12_444:
> > > - case LCD_BITS_PER_PIXEL_8:
> > > - case LCD_BITS_PER_PIXEL_4:
> > > - case LCD_BITS_PER_PIXEL_2:
> > > - case LCD_BITS_PER_PIXEL_1:
> > > - default:
> > > - // These are not supported
> > > - ASSERT (FALSE);
> > > - break;
> > > - }
> > > + /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
> > > + Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
> > > + Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
> > > + Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
> > > + Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
> > > + Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> > >
> > > return EFI_SUCCESS;
> > > }
> > > @@ -365,7 +349,7 @@ LcdPlatformGetBpp (
> > > return EFI_INVALID_PARAMETER;
> > > }
> > >
> > > - *Bpp = mDisplayModes[ModeNumber].Bpp;
> > > + *Bpp = LCD_BITS_PER_PIXEL_24;
> > >
> > > return EFI_SUCCESS;
> > > }
> > > --
> > > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> > >
> IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 14/19] ArmPlatformPkg: Add PCD to select pixel format
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (12 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 13/19] ArmPlatformPkg: HdLcd Remove redundant Bpp evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-25 14:27 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 15/19] ArmPlatformPkg: PCD to swap red/blue format for HDLCD evan.lloyd
` (4 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@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!
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 GOP driver.
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
GOP driver, 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>
---
ArmPlatformPkg/ArmPlatformPkg.dec | 9 ++++-
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf | 1 +
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf | 1 +
ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 6 +++-
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 23 ++++++++----
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 37 +++++++++-----------
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 32 +++++++++++------
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 16 ++++++++-
8 files changed, 83 insertions(+), 42 deletions(-)
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index b8a6b131632dc6788b73a034a41b9e3176dffafa..548d2b211753275337c6973e05227cee8451c185 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -1,6 +1,6 @@
#/** @file
#
-# Copyright (c) 2011-2016, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2017, ARM Limited. All rights reserved.
# Copyright (c) 2015, Intel Corporation. All rights reserved.
#
# This program and the accompanying materials
@@ -126,6 +126,13 @@ [PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L""|VOID*|0x0000001B
gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L""|VOID*|0x0000001C
+ # 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/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
index bba851c9bd6089cee748b45f40599b24c1293785..37756481596c7e978ed9ed0a932eeb2aa0a3b657 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
@@ -42,3 +42,4 @@ [Protocols]
[FixedPcd]
gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
+ gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
index 1a044baf4698aa6bfa5cd6038f01e84f7a633ea9..6f1cb3b55ff814d007718b5597f821dd20100477 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
@@ -42,3 +42,4 @@ [Protocols]
[FixedPcd]
gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId
+ gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
index f2f345b18fd15f2cde159fd42d3208a28f598a1f..d357c22c46b62966859793372c447883e12e1e80 100644
--- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
+++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
@@ -139,7 +139,6 @@
#define LCD_12BPP_444_BLUE_MASK 0x0000000F
#define LCD_12BPP_444_RESERVED_MASK 0x0000F000
-
// The enumeration indexes maps the PL111 LcdBpp values used in the LCD Control Register
typedef enum {
LCD_BITS_PER_PIXEL_1 = 0,
@@ -165,6 +164,10 @@ typedef struct {
* @param IN Handle Handle to the LCD device instance.
*
* @retval EFI_SUCCESS Platform initialization success.
+ * @retval EFI_UNSUPPORTED PcdGopPixelFormat must be
+ * PixelRedGreenBlueReserved8BitPerColor OR
+ * PixelBlueGreenRedReserved8BitPerColor
+ * any other format is not supported.
* @retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
@@ -216,6 +219,7 @@ LcdPlatformSetMode (
* (on success).
*
* @retval EFI_SUCCESS Success if the requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Info is NULL.
* @retval EFI_INVALID_PARAMETER Requested mode not found.
**/
EFI_STATUS
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
index 2401cdb30cb7252964ce1f363aa26d99933c09be..07730ed0d7a84b3fb64047bd1013fbc97301db53 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
@@ -15,7 +15,6 @@
#include <PiDxe.h>
#include <Library/ArmPlatformSysConfigLib.h>
-#include <Library/IoLib.h>
#include <Library/PcdLib.h>
#include <Library/DebugLib.h>
#include <Library/DxeServicesTableLib.h>
@@ -91,6 +90,10 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
/** HDLCD Platform specific initialization function.
*
* @retval EFI_SUCCESS Plaform library initialization success.
+ * @retval EFI_UNSUPPORTED PcdGopPixelFormat must be
+ * PixelRedGreenBlueReserved8BitPerColor OR
+ * PixelBlueGreenRedReserved8BitPerColor
+ * any other format is not supported.
* @retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
@@ -99,6 +102,7 @@ LcdPlatformInitializeDisplay (
)
{
EFI_STATUS Status;
+ EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
/* Set the FPGA multiplexer to select the video output from the
* motherboard or the daughterboard */
@@ -120,6 +124,16 @@ LcdPlatformInitializeDisplay (
NULL
);
+ // PixelBitMask and PixelBltOnly pixel formats are not supported
+ PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
+ if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
+ && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
+
+ ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
+ || PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
+ return EFI_UNSUPPORTED;
+ }
+
return Status;
}
@@ -282,12 +296,7 @@ LcdPlatformQueryMode (
Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
- /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
- Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
- Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
- Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
- Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
- Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
+ Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
return EFI_SUCCESS;
}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
index 753c5b615361f83625cdd4f0506909721da014b6..31d5e037e42a51f1c08e5bf2fa22eeb7be23e45f 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
@@ -149,6 +149,10 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
/** PL111 Platform specific initialization function.
*
* @retval EFI_SUCCESS Plaform library initialization success.
+ * @retval EFI_UNSUPPORTED PcdGopPixelFormat must be
+ * PixelRedGreenBlueReserved8BitPerColor OR
+ * PixelBlueGreenRedReserved8BitPerColor
+ * any other format is not supported
* @retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
@@ -157,6 +161,7 @@ LcdPlatformInitializeDisplay (
)
{
EFI_STATUS Status;
+ EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
// Set the FPGA multiplexer to select the video output from the motherboard or the daughterboard
Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, PL111_CLCD_SITE);
@@ -172,6 +177,16 @@ LcdPlatformInitializeDisplay (
);
}
+ // PixelBitMask and PixelBltOnly pixel formats are not supported
+ PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
+ if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
+ && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
+
+ ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
+ || PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
+ return EFI_UNSUPPORTED;
+ }
+
return Status;
}
@@ -366,27 +381,7 @@ LcdPlatformQueryMode (
Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
- switch (mDisplayModes[ModeNumber].Bpp) {
- case LCD_BITS_PER_PIXEL_24:
- Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
- Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
- Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
- Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
- Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
- break;
-
- case LCD_BITS_PER_PIXEL_16_555:
- case LCD_BITS_PER_PIXEL_16_565:
- case LCD_BITS_PER_PIXEL_12_444:
- case LCD_BITS_PER_PIXEL_8:
- case LCD_BITS_PER_PIXEL_4:
- case LCD_BITS_PER_PIXEL_2:
- case LCD_BITS_PER_PIXEL_1:
- default:
- // These are not supported
- ASSERT (FALSE);
- break;
- }
+ Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
return EFI_SUCCESS;
}
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
index 03153c06d314cb497c91889386ca6075c0c9f718..3ea7feca439e7ae9a610b6b3139ddbfad3ac6f9c 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
@@ -22,6 +22,8 @@
#include "LcdGraphicsOutputDxe.h"
+#define BYTES_PER_PIXEL 4
+
/**********************************************************************
*
* This file contains all the bits of the Lcd that are
@@ -66,10 +68,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;
}
@@ -77,7 +75,8 @@ LcdInitialize (
*
* @param ModeNumber Display mode number.
* @retval EFI_SUCCESS Display set mode success.
- * @retval EFI_DEVICE_ERROR If mode not found/supported.
+ * @retval EFI_DEVICE_ERROR Mode not found/supported.
+ * @retval !EFI_SUCCESS Other errors.
**/
EFI_STATUS
LcdSetMode (
@@ -87,9 +86,8 @@ LcdSetMode (
EFI_STATUS Status;
CONST SCAN_TIMINGS *Horizontal;
CONST 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 (
@@ -104,13 +102,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);
@@ -118,10 +125,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/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
index 6de60491e9fd0c5bca71e743aac2862ff85f6e7e..4bad2367982e16d5d23c4eab2e6d91bf7db1c031 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
@@ -80,6 +80,7 @@ LcdInitialize (
* @param ModeNumber Display mode number.
* @retval EFI_SUCCESS Display set mode success.
* @retval EFI_DEVICE_ERROR If mode not found/supported.
+ @retval !EFI_SUCCESS Other errors.
**/
EFI_STATUS
LcdSetMode (
@@ -92,6 +93,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,
@@ -111,6 +114,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);
@@ -144,7 +154,11 @@ LcdSetMode (
// PL111_REG_LCD_CONTROL
LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp)
- | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
+ | PL111_CTRL_LCD_TFT;
+
+ if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
+ LcdControl |= PL111_CTRL_BGR;
+ }
MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 14/19] ArmPlatformPkg: Add PCD to select pixel format
2017-09-26 20:15 ` [PATCH 14/19] ArmPlatformPkg: Add PCD to select pixel format evan.lloyd
@ 2017-10-25 14:27 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-25 14:27 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:24PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@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!
>
> 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 GOP driver.
>
> 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
> GOP driver, 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>
> ---
> ArmPlatformPkg/ArmPlatformPkg.dec | 9 ++++-
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf | 1 +
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf | 1 +
> ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 6 +++-
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c | 23 ++++++++----
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c | 37 +++++++++-----------
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 32 +++++++++++------
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c | 16 ++++++++-
> 8 files changed, 83 insertions(+), 42 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
> index b8a6b131632dc6788b73a034a41b9e3176dffafa..548d2b211753275337c6973e05227cee8451c185 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -1,6 +1,6 @@
> #/** @file
> #
> -# Copyright (c) 2011-2016, ARM Limited. All rights reserved.
> +# Copyright (c) 2011-2017, ARM Limited. All rights reserved.
> # Copyright (c) 2015, Intel Corporation. All rights reserved.
> #
> # This program and the accompanying materials
> @@ -126,6 +126,13 @@ [PcdsFixedAtBuild.common]
> gArmPlatformTokenSpaceGuid.PcdDefaultConInPaths|L""|VOID*|0x0000001B
> gArmPlatformTokenSpaceGuid.PcdDefaultConOutPaths|L""|VOID*|0x0000001C
>
> + # 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/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> index bba851c9bd6089cee748b45f40599b24c1293785..37756481596c7e978ed9ed0a932eeb2aa0a3b657 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> @@ -42,3 +42,4 @@ [Protocols]
> [FixedPcd]
> gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
> gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
> + gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> index 1a044baf4698aa6bfa5cd6038f01e84f7a633ea9..6f1cb3b55ff814d007718b5597f821dd20100477 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> @@ -42,3 +42,4 @@ [Protocols]
> [FixedPcd]
> gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
> gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId
> + gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
> diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> index f2f345b18fd15f2cde159fd42d3208a28f598a1f..d357c22c46b62966859793372c447883e12e1e80 100644
> --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> @@ -139,7 +139,6 @@
> #define LCD_12BPP_444_BLUE_MASK 0x0000000F
> #define LCD_12BPP_444_RESERVED_MASK 0x0000F000
>
> -
Spurious whitespace change adding an extra hunk to the patch, please drop.
> // The enumeration indexes maps the PL111 LcdBpp values used in the LCD Control Register
> typedef enum {
> LCD_BITS_PER_PIXEL_1 = 0,
> @@ -165,6 +164,10 @@ typedef struct {
> * @param IN Handle Handle to the LCD device instance.
> *
> * @retval EFI_SUCCESS Platform initialization success.
> + * @retval EFI_UNSUPPORTED PcdGopPixelFormat must be
> + * PixelRedGreenBlueReserved8BitPerColor OR
> + * PixelBlueGreenRedReserved8BitPerColor
> + * any other format is not supported.
> * @retval !(EFI_SUCCESS) Other errors.
> **/
> EFI_STATUS
> @@ -216,6 +219,7 @@ LcdPlatformSetMode (
> * (on success).
> *
> * @retval EFI_SUCCESS Success if the requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Info is NULL.
> * @retval EFI_INVALID_PARAMETER Requested mode not found.
> **/
> EFI_STATUS
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> index 2401cdb30cb7252964ce1f363aa26d99933c09be..07730ed0d7a84b3fb64047bd1013fbc97301db53 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress.c
> @@ -15,7 +15,6 @@
> #include <PiDxe.h>
>
> #include <Library/ArmPlatformSysConfigLib.h>
> -#include <Library/IoLib.h>
> #include <Library/PcdLib.h>
> #include <Library/DebugLib.h>
> #include <Library/DxeServicesTableLib.h>
> @@ -91,6 +90,10 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
> /** HDLCD Platform specific initialization function.
> *
> * @retval EFI_SUCCESS Plaform library initialization success.
> + * @retval EFI_UNSUPPORTED PcdGopPixelFormat must be
> + * PixelRedGreenBlueReserved8BitPerColor OR
> + * PixelBlueGreenRedReserved8BitPerColor
> + * any other format is not supported.
> * @retval !(EFI_SUCCESS) Other errors.
> **/
> EFI_STATUS
> @@ -99,6 +102,7 @@ LcdPlatformInitializeDisplay (
> )
> {
> EFI_STATUS Status;
> + EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
>
> /* Set the FPGA multiplexer to select the video output from the
> * motherboard or the daughterboard */
> @@ -120,6 +124,16 @@ LcdPlatformInitializeDisplay (
> NULL
> );
>
> + // PixelBitMask and PixelBltOnly pixel formats are not supported
> + PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> + if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
> + && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
> +
> + ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
> + || PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
> + return EFI_UNSUPPORTED;
> + }
> +
This block looks identical to a similar block in the next file.
Could this be a shared helper function?
> return Status;
> }
>
> @@ -282,12 +296,7 @@ LcdPlatformQueryMode (
> Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
> Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
>
> - /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */
> - Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
> - Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
> - Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
> - Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
> - Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> + Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
>
> return EFI_SUCCESS;
> }
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> index 753c5b615361f83625cdd4f0506909721da014b6..31d5e037e42a51f1c08e5bf2fa22eeb7be23e45f 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpress.c
> @@ -149,6 +149,10 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive = {
> /** PL111 Platform specific initialization function.
> *
> * @retval EFI_SUCCESS Plaform library initialization success.
> + * @retval EFI_UNSUPPORTED PcdGopPixelFormat must be
> + * PixelRedGreenBlueReserved8BitPerColor OR
> + * PixelBlueGreenRedReserved8BitPerColor
> + * any other format is not supported
> * @retval !(EFI_SUCCESS) Other errors.
> **/
> EFI_STATUS
> @@ -157,6 +161,7 @@ LcdPlatformInitializeDisplay (
> )
> {
> EFI_STATUS Status;
> + EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
>
> // Set the FPGA multiplexer to select the video output from the motherboard or the daughterboard
> Status = ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, PL111_CLCD_SITE);
> @@ -172,6 +177,16 @@ LcdPlatformInitializeDisplay (
> );
> }
>
> + // PixelBitMask and PixelBltOnly pixel formats are not supported
> + PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> + if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
> + && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
> +
> + ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
> + || PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
> + return EFI_UNSUPPORTED;
> + }
> +
(This one.)
> return Status;
> }
>
> @@ -366,27 +381,7 @@ LcdPlatformQueryMode (
> Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
> Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
>
> - switch (mDisplayModes[ModeNumber].Bpp) {
> - case LCD_BITS_PER_PIXEL_24:
> - Info->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
> - Info->PixelInformation.RedMask = LCD_24BPP_RED_MASK;
> - Info->PixelInformation.GreenMask = LCD_24BPP_GREEN_MASK;
> - Info->PixelInformation.BlueMask = LCD_24BPP_BLUE_MASK;
> - Info->PixelInformation.ReservedMask = LCD_24BPP_RESERVED_MASK;
> - break;
> -
> - case LCD_BITS_PER_PIXEL_16_555:
> - case LCD_BITS_PER_PIXEL_16_565:
> - case LCD_BITS_PER_PIXEL_12_444:
> - case LCD_BITS_PER_PIXEL_8:
> - case LCD_BITS_PER_PIXEL_4:
> - case LCD_BITS_PER_PIXEL_2:
> - case LCD_BITS_PER_PIXEL_1:
> - default:
> - // These are not supported
> - ASSERT (FALSE);
> - break;
> - }
> + Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
>
> return EFI_SUCCESS;
> }
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> index 03153c06d314cb497c91889386ca6075c0c9f718..3ea7feca439e7ae9a610b6b3139ddbfad3ac6f9c 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> @@ -22,6 +22,8 @@
>
> #include "LcdGraphicsOutputDxe.h"
>
> +#define BYTES_PER_PIXEL 4
> +
> /**********************************************************************
> *
> * This file contains all the bits of the Lcd that are
> @@ -66,10 +68,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;
> }
>
> @@ -77,7 +75,8 @@ LcdInitialize (
> *
> * @param ModeNumber Display mode number.
> * @retval EFI_SUCCESS Display set mode success.
> - * @retval EFI_DEVICE_ERROR If mode not found/supported.
> + * @retval EFI_DEVICE_ERROR Mode not found/supported.
> + * @retval !EFI_SUCCESS Other errors.
> **/
> EFI_STATUS
> LcdSetMode (
> @@ -87,9 +86,8 @@ LcdSetMode (
> EFI_STATUS Status;
> CONST SCAN_TIMINGS *Horizontal;
> CONST 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 (
> @@ -104,13 +102,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));
Could we have some parentheses above, to clarify (intended) precedence?
>
> // Disable the controller
> MmioWrite32 (HDLCD_REG_COMMAND, HDLCD_DISABLE);
> @@ -118,10 +125,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/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> index 6de60491e9fd0c5bca71e743aac2862ff85f6e7e..4bad2367982e16d5d23c4eab2e6d91bf7db1c031 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> @@ -80,6 +80,7 @@ LcdInitialize (
> * @param ModeNumber Display mode number.
> * @retval EFI_SUCCESS Display set mode success.
> * @retval EFI_DEVICE_ERROR If mode not found/supported.
> + @retval !EFI_SUCCESS Other errors.
> **/
> EFI_STATUS
> LcdSetMode (
> @@ -92,6 +93,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,
> @@ -111,6 +114,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);
>
> @@ -144,7 +154,11 @@ LcdSetMode (
>
> // PL111_REG_LCD_CONTROL
> LcdControl = PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp)
> - | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR;
> + | PL111_CTRL_LCD_TFT;
This is not a function call, so I do not believe the continuation line
should be indented.
/
Leif
> +
> + if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
> + LcdControl |= PL111_CTRL_BGR;
> + }
>
> MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl);
>
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 15/19] ArmPlatformPkg: PCD to swap red/blue format for HDLCD
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (13 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 14/19] ArmPlatformPkg: Add PCD to select pixel format evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-25 14:33 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 16/19] ArmPlatformPkg: Reorganize Lcd Graphics Output evan.lloyd
` (3 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
This change adds a new PCD PcdArmHdlcdSwapBlueRedSelect
to swap values for HDLCD RED_SELECT and BLUE_SELECT registers
on platforms where blue and red hardware lines are swapped.
If set to TRUE in the platform dsc, HDLCD driver will swap the values
while setting RED_SELECT and BLUE_SELECT registers. The default
value of the PCD is FALSE.
NOTE: The motive for this is that a discrepancy in the Red/Blue lines
exists between some VersatileExpress platforms. Rather than have
divergent code, this build switch allows a simple, pragmatic solution.
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>
---
ArmPlatformPkg/ArmPlatformPkg.dec | 3 +++
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf | 1 +
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 4 ++++
3 files changed, 8 insertions(+)
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index 548d2b211753275337c6973e05227cee8451c185..77eb789ad8fe4ddcbf25abefad2e7b7d3d5e1722 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -133,6 +133,9 @@ [PcdsFixedAtBuild.common]
# Default is set to UEFI console font format PixelBlueGreenRedReserved8BitPerColor
gArmPlatformTokenSpaceGuid.PcdGopPixelFormat|0x00000001|UINT32|0x00000040
+ ## If set, this will swap settings for HDLCD RED_SELECT and BLUE_SELECT registers
+ gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect|FALSE|BOOLEAN|0x00000045
+
[PcdsFixedAtBuild.common,PcdsDynamic.common]
## PL031 RealTimeClock
gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0|UINT32|0x00000024
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
index 26e580a594fc328187407ac4c1787f180fbf4b17..b050add98e3f9cf62ac335883193b9d0928c3dc9 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
@@ -55,6 +55,7 @@ [Protocols]
[FixedPcd]
gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase
+ gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect
[FeaturePcd]
gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
index 3ea7feca439e7ae9a610b6b3139ddbfad3ac6f9c..8f83d6ecba290994dbced1c11dfdb6d705323c03 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
@@ -109,7 +109,11 @@ LcdSetMode (
return Status;
}
+#if (!FixedPcdGetBool (PcdArmHdLcdSwapBlueRedSelect))
if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
+#else
+ if (ModeInfo.PixelFormat == PixelRedGreenBlueReserved8BitPerColor) {
+#endif
MmioWrite32 (HDLCD_REG_RED_SELECT, (8 << 8 | 16));
MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8 | 0));
} else {
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 15/19] ArmPlatformPkg: PCD to swap red/blue format for HDLCD
2017-09-26 20:15 ` [PATCH 15/19] ArmPlatformPkg: PCD to swap red/blue format for HDLCD evan.lloyd
@ 2017-10-25 14:33 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-25 14:33 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:25PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> This change adds a new PCD PcdArmHdlcdSwapBlueRedSelect
> to swap values for HDLCD RED_SELECT and BLUE_SELECT registers
> on platforms where blue and red hardware lines are swapped.
>
> If set to TRUE in the platform dsc, HDLCD driver will swap the values
> while setting RED_SELECT and BLUE_SELECT registers. The default
> value of the PCD is FALSE.
>
> NOTE: The motive for this is that a discrepancy in the Red/Blue lines
> exists between some VersatileExpress platforms. Rather than have
> divergent code, this build switch allows a simple, pragmatic solution.
Notes are generally a better fit for under the first --- line.
I have no other comments on this patch, so it's not worth updating it
for, just to keep in mind for future.
> 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>
> ---
> ArmPlatformPkg/ArmPlatformPkg.dec | 3 +++
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf | 1 +
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c | 4 ++++
> 3 files changed, 8 insertions(+)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
> index 548d2b211753275337c6973e05227cee8451c185..77eb789ad8fe4ddcbf25abefad2e7b7d3d5e1722 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -133,6 +133,9 @@ [PcdsFixedAtBuild.common]
> # Default is set to UEFI console font format PixelBlueGreenRedReserved8BitPerColor
> gArmPlatformTokenSpaceGuid.PcdGopPixelFormat|0x00000001|UINT32|0x00000040
>
> + ## If set, this will swap settings for HDLCD RED_SELECT and BLUE_SELECT registers
> + gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect|FALSE|BOOLEAN|0x00000045
> +
> [PcdsFixedAtBuild.common,PcdsDynamic.common]
> ## PL031 RealTimeClock
> gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0|UINT32|0x00000024
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
> index 26e580a594fc328187407ac4c1787f180fbf4b17..b050add98e3f9cf62ac335883193b9d0928c3dc9 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
> @@ -55,6 +55,7 @@ [Protocols]
>
> [FixedPcd]
> gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase
> + gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect
>
> [FeaturePcd]
> gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> index 3ea7feca439e7ae9a610b6b3139ddbfad3ac6f9c..8f83d6ecba290994dbced1c11dfdb6d705323c03 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> @@ -109,7 +109,11 @@ LcdSetMode (
> return Status;
> }
>
> +#if (!FixedPcdGetBool (PcdArmHdLcdSwapBlueRedSelect))
> if (ModeInfo.PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
> +#else
> + if (ModeInfo.PixelFormat == PixelRedGreenBlueReserved8BitPerColor) {
> +#endif
> MmioWrite32 (HDLCD_REG_RED_SELECT, (8 << 8 | 16));
> MmioWrite32 (HDLCD_REG_BLUE_SELECT, (8 << 8 | 0));
> } else {
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 16/19] ArmPlatformPkg: Reorganize Lcd Graphics Output
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (14 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 15/19] ArmPlatformPkg: PCD to swap red/blue format for HDLCD evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-25 14:44 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 17/19] ArmPlatformPkg: Additional display modes evan.lloyd
` (2 subsequent siblings)
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
Currently for ArmPlatformPkg, the UEFI Graphics Output Protocol is
implemented using platform specific Libraries
((PL111|Hd)LcdArmVExpressLib) and DXE drivers
((PL111|Hd)LcdGraphicsOutputDxe). The platform library handles
variations such as platform supported display modes, memory
management of the frame buffer, and clock/mux setting. The DXE driver
implements the GOP protocol and manages the respective display
controller. Although this implementation works for current platforms,
we think the way the current DXE driver sources are linked is
sub-optimal and needs to be improved, before additions.
This change effectively partitions HdLcd.c and PL111Lcd.c from
LcdGraphicsOutputProtocol and creates two libraries of type LcdHwLib
which can be selected in the platform specific .dsc file.
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>
---
ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf | 3 +-
ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf | 2 +-
ArmPlatformPkg/Drivers/{LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf => HdLcd/HdLcd.inf} | 25 +-------
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/{PL111LcdGraphicsOutputDxe.inf => LcdGraphicsOutputDxe.inf} | 15 ++---
ArmPlatformPkg/Drivers/{LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf => PL111Lcd/PL111Lcd.inf} | 28 ++-------
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h | 21 -------
ArmPlatformPkg/Include/Drivers/LcdHw.h | 64 ++++++++++++++++++++
ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 1 +
ArmPlatformPkg/Drivers/{LcdGraphicsOutputDxe => HdLcd}/HdLcd.c | 3 +-
ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c | 2 +
ArmPlatformPkg/Drivers/{LcdGraphicsOutputDxe => PL111Lcd}/PL111Lcd.c | 5 +-
11 files changed, 85 insertions(+), 84 deletions(-)
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
index 37756481596c7e978ed9ed0a932eeb2aa0a3b657..1fe93a53f81c46955c62383a2bad0e19a9662015 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
@@ -18,7 +18,7 @@ [Defines]
INF_VERSION = 0x00010005
BASE_NAME = HdLcdArmVExpress
FILE_GUID = 535a720e-06c0-4bb9-b563-452216abbed4
- MODULE_TYPE = DXE_DRIVER
+ MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = LcdPlatformLib
@@ -40,6 +40,5 @@ [Protocols]
gEfiEdidActiveProtocolGuid # Produced
[FixedPcd]
- gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
index 6f1cb3b55ff814d007718b5597f821dd20100477..f6d5bf76dd375d97bac63ca427cc231792b9e52b 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
@@ -18,7 +18,7 @@ [Defines]
INF_VERSION = 0x00010005
BASE_NAME = PL111LcdArmVExpressLib
FILE_GUID = b7f06f20-496f-11e0-a8e8-0002a5d5c51b
- MODULE_TYPE = DXE_DRIVER
+ MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = LcdPlatformLib
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/HdLcd/HdLcd.inf
similarity index 59%
rename from ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
rename to ArmPlatformPkg/Drivers/HdLcd/HdLcd.inf
index b050add98e3f9cf62ac335883193b9d0928c3dc9..e43c894538cfd7985862997aaa1b8a381cb6423a 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
+++ b/ArmPlatformPkg/Drivers/HdLcd/HdLcd.inf
@@ -16,15 +16,13 @@
[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = HdLcdGraphicsDxe
+ BASE_NAME = HdLcd
FILE_GUID = ce660500-824d-11e0-ac72-0002a5d5c51b
- MODULE_TYPE = DXE_DRIVER
+ MODULE_TYPE = BASE
VERSION_STRING = 1.0
- ENTRY_POINT = LcdGraphicsOutputDxeInitialize
+ LIBRARY_CLASS = LcdHwLib
[Sources.common]
- LcdGraphicsOutputDxe.c
- LcdGraphicsOutputBlt.c
HdLcd.c
[Packages]
@@ -39,26 +37,9 @@ [LibraryClasses]
UefiLib
BaseLib
DebugLib
- TimerLib
- UefiDriverEntryPoint
- UefiBootServicesTableLib
IoLib
- BaseMemoryLib
- LcdPlatformLib
-
-[Protocols]
- gEfiDevicePathProtocolGuid
- gEfiGraphicsOutputProtocolGuid # Produced
- gEfiEdidDiscoveredProtocolGuid # Produced
- gEfiEdidActiveProtocolGuid # Produced
- gEfiEdidOverrideProtocolGuid # Produced
[FixedPcd]
gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase
gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect
-[FeaturePcd]
- gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices
-
-[Depex]
- gEfiCpuArchProtocolGuid
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
similarity index 78%
copy from ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
copy to ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
index ad0348500326c4567f0e1b235c84b694e61306bf..edd03c7eb1c39e397c72a4c22e7d05ab21b53def 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
@@ -2,7 +2,7 @@
#
# Component description file for PL111LcdGraphicsOutputDxe module
#
-# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -15,8 +15,8 @@
[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = PL111LcdGraphicsDxe
- FILE_GUID = 407B4008-BF5B-11DF-9547-CF16E0D72085
+ BASE_NAME = LcdGraphicsDxe
+ FILE_GUID = 89464DAE-8DAA-41FE-A4C8-40D2175AF1E9
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = LcdGraphicsOutputDxeInitialize
@@ -24,7 +24,6 @@ [Defines]
[Sources.common]
LcdGraphicsOutputDxe.c
LcdGraphicsOutputBlt.c
- PL111Lcd.c
[Packages]
MdePkg/MdePkg.dec
@@ -38,22 +37,18 @@ [LibraryClasses]
UefiLib
BaseLib
DebugLib
- TimerLib
UefiDriverEntryPoint
UefiBootServicesTableLib
- IoLib
BaseMemoryLib
LcdPlatformLib
+ LcdHwLib
[Protocols]
gEfiDevicePathProtocolGuid
gEfiGraphicsOutputProtocolGuid
-[FixedPcd]
- gArmPlatformTokenSpaceGuid.PcdPL111LcdBase
-
[FeaturePcd]
gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices
[Depex]
- gEfiCpuArchProtocolGuid
+ TRUE
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.inf
similarity index 59%
rename from ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
rename to ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.inf
index ad0348500326c4567f0e1b235c84b694e61306bf..8e571a02476142af787db90c0ee240a784b74a63 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
+++ b/ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.inf
@@ -1,6 +1,6 @@
-#/** @file PL111LcdGraphicsOutputDxe.inf
+#/** @file PL111Lcd.inf
#
-# Component description file for PL111LcdGraphicsOutputDxe module
+# Component description file for PL111Lcd module
#
# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
# This program and the accompanying materials
@@ -15,15 +15,13 @@
[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = PL111LcdGraphicsDxe
+ BASE_NAME = PL111Lcd
FILE_GUID = 407B4008-BF5B-11DF-9547-CF16E0D72085
- MODULE_TYPE = DXE_DRIVER
+ MODULE_TYPE = BASE
VERSION_STRING = 1.0
- ENTRY_POINT = LcdGraphicsOutputDxeInitialize
+ LIBRARY_CLASS = LcdHwLib
[Sources.common]
- LcdGraphicsOutputDxe.c
- LcdGraphicsOutputBlt.c
PL111Lcd.c
[Packages]
@@ -34,26 +32,10 @@ [Packages]
ArmPlatformPkg/ArmPlatformPkg.dec
[LibraryClasses]
- ArmLib
UefiLib
BaseLib
DebugLib
- TimerLib
- UefiDriverEntryPoint
- UefiBootServicesTableLib
IoLib
- BaseMemoryLib
- LcdPlatformLib
-
-[Protocols]
- gEfiDevicePathProtocolGuid
- gEfiGraphicsOutputProtocolGuid
[FixedPcd]
gArmPlatformTokenSpaceGuid.PcdPL111LcdBase
-
-[FeaturePcd]
- gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices
-
-[Depex]
- gEfiCpuArchProtocolGuid
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
index 85e918de66624d61c6d0e05c5a67c516cd7619aa..76a710fda59279a6642dc2408c790afcf49360b8 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
@@ -19,7 +19,6 @@
#include <Library/DebugLib.h>
#include <Library/LcdPlatformLib.h>
-#include <Library/PcdLib.h>
#include <Library/UefiLib.h>
#include <Protocol/DevicePath.h>
@@ -92,7 +91,6 @@ UINTN
GetBytesPerPixel (
IN LCD_BPP Bpp
);
-
EFI_STATUS
EFIAPI
GraphicsOutputDxeInitialize (
@@ -105,23 +103,4 @@ InitializeDisplay (
IN LCD_INSTANCE* Instance
);
-EFI_STATUS
-LcdIdentify (
- VOID
-);
-
-EFI_STATUS
-LcdInitialize (
- EFI_PHYSICAL_ADDRESS VramBaseAddress
-);
-
-EFI_STATUS
-LcdSetMode (
- IN UINT32 ModeNumber
-);
-
-VOID
-LcdShutdown (
- VOID
-);
#endif /* LCD_GRAPHICS_OUTPUT_DXE_H_ */
diff --git a/ArmPlatformPkg/Include/Drivers/LcdHw.h b/ArmPlatformPkg/Include/Drivers/LcdHw.h
new file mode 100644
index 0000000000000000000000000000000000000000..1f5b9c0b7e7decbf1136614b5b1b482ccd805604
--- /dev/null
+++ b/ArmPlatformPkg/Include/Drivers/LcdHw.h
@@ -0,0 +1,64 @@
+/** @file LcdHw.h
+
+ This file contains interface functions for LcdHwLib of ArmPlatformPkg
+
+ Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef LCD_HW_H_
+#define LCD_HW_H_
+
+#include <Library/LcdPlatformLib.h>
+
+/** Check for presence of display
+ *
+ * @retval EFI_SUCCESS Platform implements display.
+ * @retval EFI_NOT_FOUND Display not found on the platform.
+ */
+EFI_STATUS
+LcdIdentify (
+ VOID
+);
+
+/** Initialize display.
+ *
+ * @param FrameBaseAddress Address of the frame buffer.
+ * @retval EFI_SUCCESS Display initialization success.
+ * @retval !(EFI_SUCCESS) Display initialization failure.
+ *
+**/
+EFI_STATUS
+LcdInitialize (
+ EFI_PHYSICAL_ADDRESS FrameBaseAddress
+);
+
+/** Set requested mode of the display.
+ *
+ * @param ModeNumber Display mode number.
+ * @retval EFI_SUCCESS Display set mode success.
+ * @retval EFI_DEVICE_ERROR If mode not found/supported.
+ *
+**/
+EFI_STATUS
+LcdSetMode (
+ IN UINT32 ModeNumber
+);
+
+
+/** De-initializes the display.
+ *
+**/
+VOID
+LcdShutdown (
+ VOID
+);
+
+#endif /* LCD_HW_H_ */
diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
index d357c22c46b62966859793372c447883e12e1e80..78b1780d82b8b698924cc55a292c30728a3e7060 100644
--- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
+++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
@@ -14,6 +14,7 @@
#ifndef LCD_PLATFORM_LIB_H_
#define LCD_PLATFORM_LIB_H_
+#include <Uefi/UefiBaseType.h>
#include <Protocol/GraphicsOutput.h>
#define LCD_VRAM_SIZE SIZE_8MB
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/HdLcd/HdLcd.c
similarity index 95%
rename from ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
rename to ArmPlatformPkg/Drivers/HdLcd/HdLcd.c
index 8f83d6ecba290994dbced1c11dfdb6d705323c03..d0f678acc7ac539f4e05a9b35ce28baded6c7244 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
+++ b/ArmPlatformPkg/Drivers/HdLcd/HdLcd.c
@@ -19,8 +19,7 @@
#include <Library/PcdLib.h>
#include <Drivers/HdLcd.h>
-
-#include "LcdGraphicsOutputDxe.h"
+#include <Drivers/LcdHw.h>
#define BYTES_PER_PIXEL 4
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
index c40c8e0fa6f4b5f7798aeb3c8bf3f261f14cb67b..e47142319045783cf98243a1372d933d89718922 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
+++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
@@ -20,6 +20,8 @@
#include <Guid/GlobalVariable.h>
+#include <Drivers/LcdHw.h>
+
#include "LcdGraphicsOutputDxe.h"
/**********************************************************************
diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.c
similarity index 95%
rename from ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
rename to ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.c
index 4bad2367982e16d5d23c4eab2e6d91bf7db1c031..439f4f9c1fd7c6339cfa75287f3fa3718de34d92 100644
--- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
+++ b/ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.c
@@ -11,13 +11,12 @@
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-
+#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Drivers/PL111Lcd.h>
-
-#include "LcdGraphicsOutputDxe.h"
+#include <Drivers/LcdHw.h>
/**********************************************************************
*
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 16/19] ArmPlatformPkg: Reorganize Lcd Graphics Output
2017-09-26 20:15 ` [PATCH 16/19] ArmPlatformPkg: Reorganize Lcd Graphics Output evan.lloyd
@ 2017-10-25 14:44 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-25 14:44 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:26PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> Currently for ArmPlatformPkg, the UEFI Graphics Output Protocol is
> implemented using platform specific Libraries
> ((PL111|Hd)LcdArmVExpressLib) and DXE drivers
> ((PL111|Hd)LcdGraphicsOutputDxe). The platform library handles
> variations such as platform supported display modes, memory
> management of the frame buffer, and clock/mux setting. The DXE driver
> implements the GOP protocol and manages the respective display
> controller. Although this implementation works for current platforms,
> we think the way the current DXE driver sources are linked is
> sub-optimal and needs to be improved, before additions.
>
> This change effectively partitions HdLcd.c and PL111Lcd.c from
> LcdGraphicsOutputProtocol and creates two libraries of type LcdHwLib
> which can be selected in the platform specific .dsc file.
>
> 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>
> ---
> ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf | 3 +-
> ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf | 2 +-
> ArmPlatformPkg/Drivers/{LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf => HdLcd/HdLcd.inf} | 25 +-------
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/{PL111LcdGraphicsOutputDxe.inf => LcdGraphicsOutputDxe.inf} | 15 ++---
> ArmPlatformPkg/Drivers/{LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf => PL111Lcd/PL111Lcd.inf} | 28 ++-------
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h | 21 -------
> ArmPlatformPkg/Include/Drivers/LcdHw.h | 64 ++++++++++++++++++++
> ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 1 +
> ArmPlatformPkg/Drivers/{LcdGraphicsOutputDxe => HdLcd}/HdLcd.c | 3 +-
> ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c | 2 +
> ArmPlatformPkg/Drivers/{LcdGraphicsOutputDxe => PL111Lcd}/PL111Lcd.c | 5 +-
> 11 files changed, 85 insertions(+), 84 deletions(-)
Oh, dear Lord...
Not you, git.
Could you resubmit this one with --no-renames on the git command line?
If an entire new set is likely to arrive soon, can you also do some
alphabetical sorting in the new .inf files?
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> index 37756481596c7e978ed9ed0a932eeb2aa0a3b657..1fe93a53f81c46955c62383a2bad0e19a9662015 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpressLib.inf
> @@ -18,7 +18,7 @@ [Defines]
> INF_VERSION = 0x00010005
> BASE_NAME = HdLcdArmVExpress
> FILE_GUID = 535a720e-06c0-4bb9-b563-452216abbed4
> - MODULE_TYPE = DXE_DRIVER
> + MODULE_TYPE = BASE
> VERSION_STRING = 1.0
> LIBRARY_CLASS = LcdPlatformLib
>
> @@ -40,6 +40,5 @@ [Protocols]
> gEfiEdidActiveProtocolGuid # Produced
>
> [FixedPcd]
> - gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode
> gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId
> gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> index 6f1cb3b55ff814d007718b5597f821dd20100477..f6d5bf76dd375d97bac63ca427cc231792b9e52b 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVExpressLib.inf
> @@ -18,7 +18,7 @@ [Defines]
> INF_VERSION = 0x00010005
> BASE_NAME = PL111LcdArmVExpressLib
> FILE_GUID = b7f06f20-496f-11e0-a8e8-0002a5d5c51b
> - MODULE_TYPE = DXE_DRIVER
> + MODULE_TYPE = BASE
> VERSION_STRING = 1.0
> LIBRARY_CLASS = LcdPlatformLib
>
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/HdLcd/HdLcd.inf
> similarity index 59%
> rename from ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
> rename to ArmPlatformPkg/Drivers/HdLcd/HdLcd.inf
> index b050add98e3f9cf62ac335883193b9d0928c3dc9..e43c894538cfd7985862997aaa1b8a381cb6423a 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcdGraphicsOutputDxe.inf
> +++ b/ArmPlatformPkg/Drivers/HdLcd/HdLcd.inf
> @@ -16,15 +16,13 @@
>
> [Defines]
> INF_VERSION = 0x00010005
> - BASE_NAME = HdLcdGraphicsDxe
> + BASE_NAME = HdLcd
> FILE_GUID = ce660500-824d-11e0-ac72-0002a5d5c51b
> - MODULE_TYPE = DXE_DRIVER
> + MODULE_TYPE = BASE
> VERSION_STRING = 1.0
> - ENTRY_POINT = LcdGraphicsOutputDxeInitialize
> + LIBRARY_CLASS = LcdHwLib
>
> [Sources.common]
> - LcdGraphicsOutputDxe.c
> - LcdGraphicsOutputBlt.c
> HdLcd.c
>
> [Packages]
> @@ -39,26 +37,9 @@ [LibraryClasses]
> UefiLib
> BaseLib
> DebugLib
> - TimerLib
> - UefiDriverEntryPoint
> - UefiBootServicesTableLib
> IoLib
Like here.
> - BaseMemoryLib
> - LcdPlatformLib
> -
> -[Protocols]
> - gEfiDevicePathProtocolGuid
> - gEfiGraphicsOutputProtocolGuid # Produced
> - gEfiEdidDiscoveredProtocolGuid # Produced
> - gEfiEdidActiveProtocolGuid # Produced
> - gEfiEdidOverrideProtocolGuid # Produced
>
> [FixedPcd]
> gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase
> gArmPlatformTokenSpaceGuid.PcdArmHdLcdSwapBlueRedSelect
>
> -[FeaturePcd]
> - gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices
> -
> -[Depex]
> - gEfiCpuArchProtocolGuid
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
> similarity index 78%
> copy from ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
> copy to ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
> index ad0348500326c4567f0e1b235c84b694e61306bf..edd03c7eb1c39e397c72a4c22e7d05ab21b53def 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.inf
> @@ -2,7 +2,7 @@
> #
> # Component description file for PL111LcdGraphicsOutputDxe module
> #
> -# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
> +# Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD License
> # which accompanies this distribution. The full text of the license may be found at
> @@ -15,8 +15,8 @@
>
> [Defines]
> INF_VERSION = 0x00010005
> - BASE_NAME = PL111LcdGraphicsDxe
> - FILE_GUID = 407B4008-BF5B-11DF-9547-CF16E0D72085
> + BASE_NAME = LcdGraphicsDxe
> + FILE_GUID = 89464DAE-8DAA-41FE-A4C8-40D2175AF1E9
> MODULE_TYPE = DXE_DRIVER
> VERSION_STRING = 1.0
> ENTRY_POINT = LcdGraphicsOutputDxeInitialize
> @@ -24,7 +24,6 @@ [Defines]
> [Sources.common]
> LcdGraphicsOutputDxe.c
> LcdGraphicsOutputBlt.c
> - PL111Lcd.c
>
> [Packages]
> MdePkg/MdePkg.dec
> @@ -38,22 +37,18 @@ [LibraryClasses]
> UefiLib
> BaseLib
> DebugLib
> - TimerLib
> UefiDriverEntryPoint
> UefiBootServicesTableLib
> - IoLib
> BaseMemoryLib
> LcdPlatformLib
> + LcdHwLib
And here.
>
> [Protocols]
> gEfiDevicePathProtocolGuid
> gEfiGraphicsOutputProtocolGuid
>
> -[FixedPcd]
> - gArmPlatformTokenSpaceGuid.PcdPL111LcdBase
> -
> [FeaturePcd]
> gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices
>
> [Depex]
> - gEfiCpuArchProtocolGuid
> + TRUE
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf b/ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.inf
> similarity index 59%
> rename from ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
> rename to ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.inf
> index ad0348500326c4567f0e1b235c84b694e61306bf..8e571a02476142af787db90c0ee240a784b74a63 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111LcdGraphicsOutputDxe.inf
> +++ b/ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.inf
> @@ -1,6 +1,6 @@
> -#/** @file PL111LcdGraphicsOutputDxe.inf
> +#/** @file PL111Lcd.inf
> #
> -# Component description file for PL111LcdGraphicsOutputDxe module
> +# Component description file for PL111Lcd module
> #
> # Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
> # This program and the accompanying materials
> @@ -15,15 +15,13 @@
>
> [Defines]
> INF_VERSION = 0x00010005
> - BASE_NAME = PL111LcdGraphicsDxe
> + BASE_NAME = PL111Lcd
> FILE_GUID = 407B4008-BF5B-11DF-9547-CF16E0D72085
> - MODULE_TYPE = DXE_DRIVER
> + MODULE_TYPE = BASE
> VERSION_STRING = 1.0
> - ENTRY_POINT = LcdGraphicsOutputDxeInitialize
> + LIBRARY_CLASS = LcdHwLib
>
> [Sources.common]
> - LcdGraphicsOutputDxe.c
> - LcdGraphicsOutputBlt.c
> PL111Lcd.c
>
> [Packages]
> @@ -34,26 +32,10 @@ [Packages]
> ArmPlatformPkg/ArmPlatformPkg.dec
>
> [LibraryClasses]
> - ArmLib
> UefiLib
> BaseLib
> DebugLib
> - TimerLib
> - UefiDriverEntryPoint
> - UefiBootServicesTableLib
> IoLib
And here.
> - BaseMemoryLib
> - LcdPlatformLib
> -
> -[Protocols]
> - gEfiDevicePathProtocolGuid
> - gEfiGraphicsOutputProtocolGuid
>
> [FixedPcd]
> gArmPlatformTokenSpaceGuid.PcdPL111LcdBase
> -
> -[FeaturePcd]
> - gArmPlatformTokenSpaceGuid.PcdGopDisableOnExitBootServices
> -
> -[Depex]
> - gEfiCpuArchProtocolGuid
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
> index 85e918de66624d61c6d0e05c5a67c516cd7619aa..76a710fda59279a6642dc2408c790afcf49360b8 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.h
> @@ -19,7 +19,6 @@
>
> #include <Library/DebugLib.h>
> #include <Library/LcdPlatformLib.h>
> -#include <Library/PcdLib.h>
> #include <Library/UefiLib.h>
>
> #include <Protocol/DevicePath.h>
> @@ -92,7 +91,6 @@ UINTN
> GetBytesPerPixel (
> IN LCD_BPP Bpp
> );
> -
Unrelated whitespace change.
> EFI_STATUS
> EFIAPI
> GraphicsOutputDxeInitialize (
> @@ -105,23 +103,4 @@ InitializeDisplay (
> IN LCD_INSTANCE* Instance
> );
>
> -EFI_STATUS
> -LcdIdentify (
> - VOID
> -);
> -
> -EFI_STATUS
> -LcdInitialize (
> - EFI_PHYSICAL_ADDRESS VramBaseAddress
> -);
> -
> -EFI_STATUS
> -LcdSetMode (
> - IN UINT32 ModeNumber
> -);
> -
> -VOID
> -LcdShutdown (
> - VOID
> -);
> #endif /* LCD_GRAPHICS_OUTPUT_DXE_H_ */
> diff --git a/ArmPlatformPkg/Include/Drivers/LcdHw.h b/ArmPlatformPkg/Include/Drivers/LcdHw.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..1f5b9c0b7e7decbf1136614b5b1b482ccd805604
> --- /dev/null
> +++ b/ArmPlatformPkg/Include/Drivers/LcdHw.h
> @@ -0,0 +1,64 @@
> +/** @file LcdHw.h
> +
> + This file contains interface functions for LcdHwLib of ArmPlatformPkg
> +
> + Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD License
> + which accompanies this distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef LCD_HW_H_
> +#define LCD_HW_H_
> +
> +#include <Library/LcdPlatformLib.h>
> +
> +/** Check for presence of display
> + *
> + * @retval EFI_SUCCESS Platform implements display.
> + * @retval EFI_NOT_FOUND Display not found on the platform.
> + */
> +EFI_STATUS
> +LcdIdentify (
> + VOID
> +);
> +
> +/** Initialize display.
> + *
> + * @param FrameBaseAddress Address of the frame buffer.
> + * @retval EFI_SUCCESS Display initialization success.
> + * @retval !(EFI_SUCCESS) Display initialization failure.
> + *
> +**/
> +EFI_STATUS
> +LcdInitialize (
> + EFI_PHYSICAL_ADDRESS FrameBaseAddress
> +);
> +
> +/** Set requested mode of the display.
> + *
> + * @param ModeNumber Display mode number.
> + * @retval EFI_SUCCESS Display set mode success.
> + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> + *
> +**/
> +EFI_STATUS
> +LcdSetMode (
> + IN UINT32 ModeNumber
> +);
> +
> +
> +/** De-initializes the display.
> + *
> +**/
> +VOID
> +LcdShutdown (
> + VOID
> +);
> +
> +#endif /* LCD_HW_H_ */
> diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> index d357c22c46b62966859793372c447883e12e1e80..78b1780d82b8b698924cc55a292c30728a3e7060 100644
> --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> @@ -14,6 +14,7 @@
> #ifndef LCD_PLATFORM_LIB_H_
> #define LCD_PLATFORM_LIB_H_
>
> +#include <Uefi/UefiBaseType.h>
> #include <Protocol/GraphicsOutput.h>
>
> #define LCD_VRAM_SIZE SIZE_8MB
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatformPkg/Drivers/HdLcd/HdLcd.c
> similarity index 95%
> rename from ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> rename to ArmPlatformPkg/Drivers/HdLcd/HdLcd.c
> index 8f83d6ecba290994dbced1c11dfdb6d705323c03..d0f678acc7ac539f4e05a9b35ce28baded6c7244 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c
> +++ b/ArmPlatformPkg/Drivers/HdLcd/HdLcd.c
> @@ -19,8 +19,7 @@
> #include <Library/PcdLib.h>
>
> #include <Drivers/HdLcd.h>
> -
> -#include "LcdGraphicsOutputDxe.h"
(For clarity - I have no issue with the unrelated whitespace change
above here, because it is not the only change in its hunk and it is
directly adjacent to the modification.)
/
Leif
> +#include <Drivers/LcdHw.h>
>
> #define BYTES_PER_PIXEL 4
>
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
> index c40c8e0fa6f4b5f7798aeb3c8bf3f261f14cb67b..e47142319045783cf98243a1372d933d89718922 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
> +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/LcdGraphicsOutputDxe.c
> @@ -20,6 +20,8 @@
>
> #include <Guid/GlobalVariable.h>
>
> +#include <Drivers/LcdHw.h>
> +
> #include "LcdGraphicsOutputDxe.h"
>
> /**********************************************************************
> diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.c
> similarity index 95%
> rename from ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> rename to ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.c
> index 4bad2367982e16d5d23c4eab2e6d91bf7db1c031..439f4f9c1fd7c6339cfa75287f3fa3718de34d92 100644
> --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c
> +++ b/ArmPlatformPkg/Drivers/PL111Lcd/PL111Lcd.c
> @@ -11,13 +11,12 @@
> WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>
> **/
> -
> +#include <Library/DebugLib.h>
> #include <Library/IoLib.h>
> #include <Library/MemoryAllocationLib.h>
>
> #include <Drivers/PL111Lcd.h>
> -
> -#include "LcdGraphicsOutputDxe.h"
> +#include <Drivers/LcdHw.h>
>
> /**********************************************************************
> *
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 17/19] ArmPlatformPkg: Additional display modes
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (15 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 16/19] ArmPlatformPkg: Reorganize Lcd Graphics Output evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-25 14:45 ` Leif Lindholm
2017-09-26 20:15 ` [PATCH 18/19] ArmPlatformPkg: Reserving framebuffer at build evan.lloyd
2017-09-26 20:15 ` [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver evan.lloyd
18 siblings, 1 reply; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
Add definitions for new display modes such as HD 720.
This has no effect on existing display drivers.
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>
---
ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 60 ++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
index 78b1780d82b8b698924cc55a292c30728a3e7060..c5d90bd4faff2dadc6b36440249ee8e0733616e0 100644
--- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
+++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
@@ -27,6 +27,11 @@
#define WSXGA 4
#define UXGA 5
#define HD 6
+#define WVGA 7
+#define QHD 8
+#define WSVGA 9
+#define HD720 10
+#define WXGA 11
// VGA Mode: 640 x 480
#define VGA_H_RES_PIXELS 640
@@ -119,6 +124,61 @@
#define HD_V_FRONT_PORCH ( 3 - 1)
#define HD_V_BACK_PORCH ( 32 - 1)
+// WVGA Mode: 800 x 480
+#define WVGA_H_RES_PIXELS 800
+#define WVGA_V_RES_PIXELS 480
+#define WVGA_OSC_FREQUENCY 29500000 /* 0x01C22260 */
+#define WVGA_H_SYNC ( 72 - 1)
+#define WVGA_H_FRONT_PORCH ( 24 - 1)
+#define WVGA_H_BACK_PORCH ( 96 - 1)
+#define WVGA_V_SYNC ( 7 - 1)
+#define WVGA_V_FRONT_PORCH ( 3 - 1)
+#define WVGA_V_BACK_PORCH ( 10 - 1)
+
+// QHD Mode: 960 x 540
+#define QHD_H_RES_PIXELS 960
+#define QHD_V_RES_PIXELS 540
+#define QHD_OSC_FREQUENCY 40750000 /* 0x026DCBB0 */
+#define QHD_H_SYNC ( 96 - 1)
+#define QHD_H_FRONT_PORCH ( 32 - 1)
+#define QHD_H_BACK_PORCH (128 - 1)
+#define QHD_V_SYNC ( 5 - 1)
+#define QHD_V_FRONT_PORCH ( 3 - 1)
+#define QHD_V_BACK_PORCH ( 14 - 1)
+
+// WSVGA Mode: 1024 x 600
+#define WSVGA_H_RES_PIXELS 1024
+#define WSVGA_V_RES_PIXELS 600
+#define WSVGA_OSC_FREQUENCY 49000000 /* 0x02EBAE40 */
+#define WSVGA_H_SYNC (104 - 1)
+#define WSVGA_H_FRONT_PORCH ( 40 - 1)
+#define WSVGA_H_BACK_PORCH (144 - 1)
+#define WSVGA_V_SYNC ( 10 - 1)
+#define WSVGA_V_FRONT_PORCH ( 3 - 1)
+#define WSVGA_V_BACK_PORCH ( 11 - 1)
+
+// HD720 Mode: 1280 x 720
+#define HD720_H_RES_PIXELS 1280
+#define HD720_V_RES_PIXELS 720
+#define HD720_OSC_FREQUENCY 74500000 /* 0x0470C7A0 */
+#define HD720_H_SYNC (128 - 1)
+#define HD720_H_FRONT_PORCH ( 64 - 1)
+#define HD720_H_BACK_PORCH (192 - 1)
+#define HD720_V_SYNC ( 5 - 1)
+#define HD720_V_FRONT_PORCH ( 3 - 1)
+#define HD720_V_BACK_PORCH ( 20 - 1)
+
+// WXGA Mode: 1280 x 800
+#define WXGA_H_RES_PIXELS 1280
+#define WXGA_V_RES_PIXELS 800
+#define WXGA_OSC_FREQUENCY 83500000 /* 0x04FA1BE0 */
+#define WXGA_H_SYNC (128 - 1)
+#define WXGA_H_FRONT_PORCH ( 72 - 1)
+#define WXGA_H_BACK_PORCH (200 - 1)
+#define WXGA_V_SYNC ( 6 - 1)
+#define WXGA_V_FRONT_PORCH ( 3 - 1)
+#define WXGA_V_BACK_PORCH ( 22 - 1)
+
// Colour Masks
#define LCD_24BPP_RED_MASK 0x00FF0000
#define LCD_24BPP_GREEN_MASK 0x0000FF00
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 17/19] ArmPlatformPkg: Additional display modes
2017-09-26 20:15 ` [PATCH 17/19] ArmPlatformPkg: Additional display modes evan.lloyd
@ 2017-10-25 14:45 ` Leif Lindholm
0 siblings, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-25 14:45 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:27PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> Add definitions for new display modes such as HD 720.
> This has no effect on existing display drivers.
>
> 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: Leif Lindholm <leif.lindholm@linaro.org>
> ---
> ArmPlatformPkg/Include/Library/LcdPlatformLib.h | 60 ++++++++++++++++++++
> 1 file changed, 60 insertions(+)
>
> diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> index 78b1780d82b8b698924cc55a292c30728a3e7060..c5d90bd4faff2dadc6b36440249ee8e0733616e0 100644
> --- a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> +++ b/ArmPlatformPkg/Include/Library/LcdPlatformLib.h
> @@ -27,6 +27,11 @@
> #define WSXGA 4
> #define UXGA 5
> #define HD 6
> +#define WVGA 7
> +#define QHD 8
> +#define WSVGA 9
> +#define HD720 10
> +#define WXGA 11
>
> // VGA Mode: 640 x 480
> #define VGA_H_RES_PIXELS 640
> @@ -119,6 +124,61 @@
> #define HD_V_FRONT_PORCH ( 3 - 1)
> #define HD_V_BACK_PORCH ( 32 - 1)
>
> +// WVGA Mode: 800 x 480
> +#define WVGA_H_RES_PIXELS 800
> +#define WVGA_V_RES_PIXELS 480
> +#define WVGA_OSC_FREQUENCY 29500000 /* 0x01C22260 */
> +#define WVGA_H_SYNC ( 72 - 1)
> +#define WVGA_H_FRONT_PORCH ( 24 - 1)
> +#define WVGA_H_BACK_PORCH ( 96 - 1)
> +#define WVGA_V_SYNC ( 7 - 1)
> +#define WVGA_V_FRONT_PORCH ( 3 - 1)
> +#define WVGA_V_BACK_PORCH ( 10 - 1)
> +
> +// QHD Mode: 960 x 540
> +#define QHD_H_RES_PIXELS 960
> +#define QHD_V_RES_PIXELS 540
> +#define QHD_OSC_FREQUENCY 40750000 /* 0x026DCBB0 */
> +#define QHD_H_SYNC ( 96 - 1)
> +#define QHD_H_FRONT_PORCH ( 32 - 1)
> +#define QHD_H_BACK_PORCH (128 - 1)
> +#define QHD_V_SYNC ( 5 - 1)
> +#define QHD_V_FRONT_PORCH ( 3 - 1)
> +#define QHD_V_BACK_PORCH ( 14 - 1)
> +
> +// WSVGA Mode: 1024 x 600
> +#define WSVGA_H_RES_PIXELS 1024
> +#define WSVGA_V_RES_PIXELS 600
> +#define WSVGA_OSC_FREQUENCY 49000000 /* 0x02EBAE40 */
> +#define WSVGA_H_SYNC (104 - 1)
> +#define WSVGA_H_FRONT_PORCH ( 40 - 1)
> +#define WSVGA_H_BACK_PORCH (144 - 1)
> +#define WSVGA_V_SYNC ( 10 - 1)
> +#define WSVGA_V_FRONT_PORCH ( 3 - 1)
> +#define WSVGA_V_BACK_PORCH ( 11 - 1)
> +
> +// HD720 Mode: 1280 x 720
> +#define HD720_H_RES_PIXELS 1280
> +#define HD720_V_RES_PIXELS 720
> +#define HD720_OSC_FREQUENCY 74500000 /* 0x0470C7A0 */
> +#define HD720_H_SYNC (128 - 1)
> +#define HD720_H_FRONT_PORCH ( 64 - 1)
> +#define HD720_H_BACK_PORCH (192 - 1)
> +#define HD720_V_SYNC ( 5 - 1)
> +#define HD720_V_FRONT_PORCH ( 3 - 1)
> +#define HD720_V_BACK_PORCH ( 20 - 1)
> +
> +// WXGA Mode: 1280 x 800
> +#define WXGA_H_RES_PIXELS 1280
> +#define WXGA_V_RES_PIXELS 800
> +#define WXGA_OSC_FREQUENCY 83500000 /* 0x04FA1BE0 */
> +#define WXGA_H_SYNC (128 - 1)
> +#define WXGA_H_FRONT_PORCH ( 72 - 1)
> +#define WXGA_H_BACK_PORCH (200 - 1)
> +#define WXGA_V_SYNC ( 6 - 1)
> +#define WXGA_V_FRONT_PORCH ( 3 - 1)
> +#define WXGA_V_BACK_PORCH ( 22 - 1)
> +
> // Colour Masks
> #define LCD_24BPP_RED_MASK 0x00FF0000
> #define LCD_24BPP_GREEN_MASK 0x0000FF00
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 18/19] ArmPlatformPkg: Reserving framebuffer at build
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (16 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 17/19] ArmPlatformPkg: Additional display modes evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-25 14:51 ` Leif Lindholm
2017-10-25 18:10 ` Ard Biesheuvel
2017-09-26 20:15 ` [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver evan.lloyd
18 siblings, 2 replies; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
Currently frame buffer memory is either reserved in special VRAM or
dynamically allocated using boot services memory allocation functions.
When allocated using boot services calls the memory has to be allocated
as EfiBootServicesData. Unfortunately failures have been seen with this
case. There is also an unfortunate lack of control on the placement of
the frmae buffer.
This change introduces two PCDs, PcdArmLcdFrameBufferBase and
PcdArmLcdFrameBufferSize which enable build time reservation of the
frame buffer, avoiding the need to allocate dynamically. This allows
the frame buffer to appear as "I/O memory" outside of the normal RAM
map, which is similar to the "VRAM" case.
This change has no impact on current code, only enables the option
of build time reservation of frame buffers.
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>
---
ArmPlatformPkg/ArmPlatformPkg.dec | 4 ++++
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf | 4 +++-
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c | 21 ++++++++++++++++++--
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index 77eb789ad8fe4ddcbf25abefad2e7b7d3d5e1722..0174f63e77f5b8430e106289366feb9a6577fb99 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -111,6 +111,10 @@ [PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdPL111LcdBase|0x0|UINT32|0x00000026
gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x0|UINT32|0x00000027
+ ## If set, frame buffer memory will be reserved and mapped in the system RAM
+ gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x0|UINT32|0x00000033
+ gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT64|0x00000034
+
## PL180 MCI
gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|UINT32|0x00000028
gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UINT32|0x00000029
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
index 9b16f7f0c4731ab72bfb1008a073e81842bae82b..60789e9b8ff1b936db04953a765fb164b0e85a40 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
@@ -1,5 +1,5 @@
#/* @file
-# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+# Copyright (c) 2011-2017, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -57,6 +57,8 @@ [FixedPcd]
gArmTokenSpaceGuid.PcdArmPrimaryCore
gArmPlatformTokenSpaceGuid.PcdCoreCount
+ gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
+ gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
[Ppis]
gArmMpCoreInfoPpiGuid
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
index 6379e81751fca5e7972c5c30f305be65fd1ae71d..5cd529750a3d2d3b0d381b58d875d378afaba2c2 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2016, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2017, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -20,8 +20,10 @@
#include <Library/MemoryAllocationLib.h>
#include <ArmPlatform.h>
+#define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
+
// Number of Virtual Memory Map Descriptors
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 9
+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR)
// DDR attributes
#define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
@@ -142,6 +144,21 @@ ArmPlatformGetVirtualMemoryMap (
//
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
+ // Map region for the frame buffer in the system RAM
+#if (FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0)
+ VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
+ VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
+ VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
+ /* Map as Normal Non-Cacheable memory, so that we can use the accelerated
+ * SetMem/CopyMem routines that may use unaligned accesses or
+ * DC ZVA instructions. If mapped as device memory, these routine may cause
+ * alignment faults.
+ * NOTE: The attribute value is misleading, it indicates memory map type as
+ * an un-cached, un-buffered but allows buffering and reordering.
+ */
+ VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
+#endif
+
// Map sparse memory region if present
if (HasSparseMemory) {
VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 18/19] ArmPlatformPkg: Reserving framebuffer at build
2017-09-26 20:15 ` [PATCH 18/19] ArmPlatformPkg: Reserving framebuffer at build evan.lloyd
@ 2017-10-25 14:51 ` Leif Lindholm
2017-10-25 18:10 ` Ard Biesheuvel
1 sibling, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-25 14:51 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:28PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> Currently frame buffer memory is either reserved in special VRAM or
> dynamically allocated using boot services memory allocation functions.
> When allocated using boot services calls the memory has to be allocated
> as EfiBootServicesData. Unfortunately failures have been seen with this
> case. There is also an unfortunate lack of control on the placement of
> the frmae buffer.
>
> This change introduces two PCDs, PcdArmLcdFrameBufferBase and
> PcdArmLcdFrameBufferSize which enable build time reservation of the
> frame buffer, avoiding the need to allocate dynamically. This allows
> the frame buffer to appear as "I/O memory" outside of the normal RAM
> map, which is similar to the "VRAM" case.
>
> This change has no impact on current code, only enables the option
> of build time reservation of frame buffers.
>
> 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>
> ---
> ArmPlatformPkg/ArmPlatformPkg.dec | 4 ++++
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf | 4 +++-
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c | 21 ++++++++++++++++++--
> 3 files changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
> index 77eb789ad8fe4ddcbf25abefad2e7b7d3d5e1722..0174f63e77f5b8430e106289366feb9a6577fb99 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -111,6 +111,10 @@ [PcdsFixedAtBuild.common]
> gArmPlatformTokenSpaceGuid.PcdPL111LcdBase|0x0|UINT32|0x00000026
> gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x0|UINT32|0x00000027
>
> + ## If set, frame buffer memory will be reserved and mapped in the system RAM
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x0|UINT32|0x00000033
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT64|0x00000034
> +
> ## PL180 MCI
> gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|UINT32|0x00000028
> gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UINT32|0x00000029
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> index 9b16f7f0c4731ab72bfb1008a073e81842bae82b..60789e9b8ff1b936db04953a765fb164b0e85a40 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> @@ -1,5 +1,5 @@
> #/* @file
> -# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
> +# Copyright (c) 2011-2017, ARM Limited. All rights reserved.
> #
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD License
> @@ -57,6 +57,8 @@ [FixedPcd]
> gArmTokenSpaceGuid.PcdArmPrimaryCore
>
> gArmPlatformTokenSpaceGuid.PcdCoreCount
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
>
> [Ppis]
> gArmMpCoreInfoPpiGuid
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> index 6379e81751fca5e7972c5c30f305be65fd1ae71d..5cd529750a3d2d3b0d381b58d875d378afaba2c2 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> @@ -1,6 +1,6 @@
> /** @file
> *
> -* Copyright (c) 2011-2016, ARM Limited. All rights reserved.
> +* Copyright (c) 2011-2017, ARM Limited. All rights reserved.
> *
> * This program and the accompanying materials
> * are licensed and made available under the terms and conditions of the BSD License
> @@ -20,8 +20,10 @@
> #include <Library/MemoryAllocationLib.h>
> #include <ArmPlatform.h>
>
> +#define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
> +
> // Number of Virtual Memory Map Descriptors
> -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 9
> +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR)
>
> // DDR attributes
> #define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
> @@ -142,6 +144,21 @@ ArmPlatformGetVirtualMemoryMap (
> //
> VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
>
> + // Map region for the frame buffer in the system RAM
> +#if (FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0)
> + VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> + VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> + VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
> + /* Map as Normal Non-Cacheable memory, so that we can use the accelerated
> + * SetMem/CopyMem routines that may use unaligned accesses or
> + * DC ZVA instructions. If mapped as device memory, these routine may cause
> + * alignment faults.
> + * NOTE: The attribute value is misleading, it indicates memory map type as
> + * an un-cached, un-buffered but allows buffering and reordering.
Well done on that note, I was about to object, because I keep
forgetting about that twist :)
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
> + */
> + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
> +#endif
> +
> // Map sparse memory region if present
> if (HasSparseMemory) {
> VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 18/19] ArmPlatformPkg: Reserving framebuffer at build
2017-09-26 20:15 ` [PATCH 18/19] ArmPlatformPkg: Reserving framebuffer at build evan.lloyd
2017-10-25 14:51 ` Leif Lindholm
@ 2017-10-25 18:10 ` Ard Biesheuvel
2017-12-01 16:56 ` Evan Lloyd
1 sibling, 1 reply; 69+ messages in thread
From: Ard Biesheuvel @ 2017-10-25 18:10 UTC (permalink / raw)
To: Evan Lloyd
Cc: edk2-devel@lists.01.org, "ard.biesheuvel, "leif.lindholm,
"Matteo.Carlini, "nd
On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> Currently frame buffer memory is either reserved in special VRAM or
> dynamically allocated using boot services memory allocation functions.
> When allocated using boot services calls the memory has to be allocated
> as EfiBootServicesData. Unfortunately failures have been seen with this
> case. There is also an unfortunate lack of control on the placement of
> the frmae buffer.
>
> This change introduces two PCDs, PcdArmLcdFrameBufferBase and
> PcdArmLcdFrameBufferSize which enable build time reservation of the
> frame buffer, avoiding the need to allocate dynamically. This allows
> the frame buffer to appear as "I/O memory" outside of the normal RAM
> map, which is similar to the "VRAM" case.
>
> This change has no impact on current code, only enables the option
> of build time reservation of frame buffers.
>
Where is the memory actually being reserved? And if it is reserved,
how can the OS reclaim it if it is not interested in using the GOP?
> 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>
> ---
> ArmPlatformPkg/ArmPlatformPkg.dec | 4 ++++
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf | 4 +++-
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c | 21 ++++++++++++++++++--
> 3 files changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
> index 77eb789ad8fe4ddcbf25abefad2e7b7d3d5e1722..0174f63e77f5b8430e106289366feb9a6577fb99 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -111,6 +111,10 @@ [PcdsFixedAtBuild.common]
> gArmPlatformTokenSpaceGuid.PcdPL111LcdBase|0x0|UINT32|0x00000026
> gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x0|UINT32|0x00000027
>
> + ## If set, frame buffer memory will be reserved and mapped in the system RAM
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x0|UINT32|0x00000033
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT64|0x00000034
> +
> ## PL180 MCI
> gArmPlatformTokenSpaceGuid.PcdPL180SysMciRegAddress|0x00000000|UINT32|0x00000028
> gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x00000000|UINT32|0x00000029
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> index 9b16f7f0c4731ab72bfb1008a073e81842bae82b..60789e9b8ff1b936db04953a765fb164b0e85a40 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> @@ -1,5 +1,5 @@
> #/* @file
> -# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
> +# Copyright (c) 2011-2017, ARM Limited. All rights reserved.
> #
> # This program and the accompanying materials
> # are licensed and made available under the terms and conditions of the BSD License
> @@ -57,6 +57,8 @@ [FixedPcd]
> gArmTokenSpaceGuid.PcdArmPrimaryCore
>
> gArmPlatformTokenSpaceGuid.PcdCoreCount
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
>
> [Ppis]
> gArmMpCoreInfoPpiGuid
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> index 6379e81751fca5e7972c5c30f305be65fd1ae71d..5cd529750a3d2d3b0d381b58d875d378afaba2c2 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> @@ -1,6 +1,6 @@
> /** @file
> *
> -* Copyright (c) 2011-2016, ARM Limited. All rights reserved.
> +* Copyright (c) 2011-2017, ARM Limited. All rights reserved.
> *
> * This program and the accompanying materials
> * are licensed and made available under the terms and conditions of the BSD License
> @@ -20,8 +20,10 @@
> #include <Library/MemoryAllocationLib.h>
> #include <ArmPlatform.h>
>
> +#define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
> +
> // Number of Virtual Memory Map Descriptors
> -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 9
> +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR)
>
> // DDR attributes
> #define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
> @@ -142,6 +144,21 @@ ArmPlatformGetVirtualMemoryMap (
> //
> VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
>
> + // Map region for the frame buffer in the system RAM
> +#if (FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize) != 0)
> + VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> + VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> + VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
> + /* Map as Normal Non-Cacheable memory, so that we can use the accelerated
> + * SetMem/CopyMem routines that may use unaligned accesses or
> + * DC ZVA instructions. If mapped as device memory, these routine may cause
> + * alignment faults.
> + * NOTE: The attribute value is misleading, it indicates memory map type as
> + * an un-cached, un-buffered but allows buffering and reordering.
> + */
> + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
> +#endif
> +
> // Map sparse memory region if present
> if (HasSparseMemory) {
> VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 18/19] ArmPlatformPkg: Reserving framebuffer at build
2017-10-25 18:10 ` Ard Biesheuvel
@ 2017-12-01 16:56 ` Evan Lloyd
2017-12-01 17:38 ` Ard Biesheuvel
0 siblings, 1 reply; 69+ messages in thread
From: Evan Lloyd @ 2017-12-01 16:56 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: edk2-devel@lists.01.org,
"ard.biesheuvel@linaro.org"@arm.com,
"leif.lindholm@linaro.org"@arm.com,
"Matteo.Carlini@arm.com"@arm.com,
"nd@arm.com"@arm.com
Responses inline
> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 25 October 2017 19:10
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; "ard.biesheuvel@linaro.org"@arm.com;
> "leif.lindholm@linaro.org"@arm.com;
> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
> Subject: Re: [PATCH 18/19] ArmPlatformPkg: Reserving framebuffer at
> build
>
> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> > From: Girish Pathak <girish.pathak@arm.com>
> >
> > Currently frame buffer memory is either reserved in special VRAM or
> > dynamically allocated using boot services memory allocation functions.
> > When allocated using boot services calls the memory has to be
> > allocated as EfiBootServicesData. Unfortunately failures have been
> > seen with this case. There is also an unfortunate lack of control on
> > the placement of the frmae buffer.
> >
> > This change introduces two PCDs, PcdArmLcdFrameBufferBase and
> > PcdArmLcdFrameBufferSize which enable build time reservation of the
> > frame buffer, avoiding the need to allocate dynamically. This allows
> > the frame buffer to appear as "I/O memory" outside of the normal RAM
> > map, which is similar to the "VRAM" case.
> >
> > This change has no impact on current code, only enables the option of
> > build time reservation of frame buffers.
> >
>
> Where is the memory actually being reserved? And if it is reserved, how can
> the OS reclaim it if it is not interested in using the GOP?
[[Evan Lloyd]] The memory is reserved by whatever sets the Pcd - normally the .dsc. It may or may not be system RAM.
If it is excised from system memory, then there is no way for the OS to reclaim it, as it can't differentiate that from the VRAM case.
I'm not sure I see the relevance of that anyway. Is our objective to provide restricted firmware tightly tuned for a specific operating system in an unrealistic mode, or to provide a generic example of firmware exercising the standard interfaces and testing real use cases?
Regards,
Evan
>
>
> > 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>
> > ---
> > ArmPlatformPkg/ArmPlatformPkg.dec | 4 ++++
> >
...
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 18/19] ArmPlatformPkg: Reserving framebuffer at build
2017-12-01 16:56 ` Evan Lloyd
@ 2017-12-01 17:38 ` Ard Biesheuvel
0 siblings, 0 replies; 69+ messages in thread
From: Ard Biesheuvel @ 2017-12-01 17:38 UTC (permalink / raw)
To: Evan Lloyd
Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org@arm.com,
leif.lindholm@linaro.org@arm.com, Matteo.Carlini@arm.com@arm.com,
nd@arm.com@arm.com
On 1 December 2017 at 16:56, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> Responses inline
>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 25 October 2017 19:10
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: edk2-devel@lists.01.org; "ard.biesheuvel@linaro.org"@arm.com;
>> "leif.lindholm@linaro.org"@arm.com;
>> "Matteo.Carlini@arm.com"@arm.com; "nd@arm.com"@arm.com
>> Subject: Re: [PATCH 18/19] ArmPlatformPkg: Reserving framebuffer at
>> build
>>
>> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
>> > From: Girish Pathak <girish.pathak@arm.com>
>> >
>> > Currently frame buffer memory is either reserved in special VRAM or
>> > dynamically allocated using boot services memory allocation functions.
>> > When allocated using boot services calls the memory has to be
>> > allocated as EfiBootServicesData. Unfortunately failures have been
>> > seen with this case. There is also an unfortunate lack of control on
>> > the placement of the frmae buffer.
>> >
>> > This change introduces two PCDs, PcdArmLcdFrameBufferBase and
>> > PcdArmLcdFrameBufferSize which enable build time reservation of the
>> > frame buffer, avoiding the need to allocate dynamically. This allows
>> > the frame buffer to appear as "I/O memory" outside of the normal RAM
>> > map, which is similar to the "VRAM" case.
>> >
>> > This change has no impact on current code, only enables the option of
>> > build time reservation of frame buffers.
>> >
>>
>> Where is the memory actually being reserved? And if it is reserved, how can
>> the OS reclaim it if it is not interested in using the GOP?
>
> [[Evan Lloyd]] The memory is reserved by whatever sets the Pcd - normally the .dsc. It may or may not be system RAM.
> If it is excised from system memory, then there is no way for the OS to reclaim it, as it can't differentiate that from the VRAM case.
> I'm not sure I see the relevance of that anyway. Is our objective to provide restricted firmware tightly tuned for a specific operating system in an unrealistic mode, or to provide a generic example of firmware exercising the standard interfaces and testing real use cases?
>
Is that intended as a rhetorical question? If you introduce a feature
that may take away RAM from the OS without a way to reclaim it, that
deserves a comment. At the very least, it would have saved me from
having to ask about it specifically.
Whether doing so is justified is another question, but that depends on
the expected users of this code (hence the need to document it)
--
Ard.
^ permalink raw reply [flat|nested] 69+ messages in thread
* [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver.
2017-09-26 20:15 [PATCH 00/19] ArmPlatformPkg: Update GOP evan.lloyd
` (17 preceding siblings ...)
2017-09-26 20:15 ` [PATCH 18/19] ArmPlatformPkg: Reserving framebuffer at build evan.lloyd
@ 2017-09-26 20:15 ` evan.lloyd
2017-10-25 15:31 ` Leif Lindholm
2017-11-28 18:17 ` Ard Biesheuvel
18 siblings, 2 replies; 69+ messages in thread
From: evan.lloyd @ 2017-09-26 20:15 UTC (permalink / raw)
To: edk2-devel
Cc: "ard.biesheuvel, "leif.lindholm, "Matteo.Carlini,
"nd
From: Girish Pathak <girish.pathak@arm.com>
This change adds support for the ARM Mali DP500/DP500/DP650 display
processors using the GOP protocol. It has been tested on FVP base
models + DP550 support.
This change does not modify functionality provided by PL111 or
HDLCD. The driver should be suitable for those platforms
that implement ARM Mali DP500/DP550/DP650 replacing PL111/HDLCD.
Only "Layer Graphics" of the ARM Mali DP is configured for rendering
the RGB/BGR format frame buffer to satisfy the UEFI GOP requirements
Other layers e.g. video layers are not configured.
NOTE: This change implements the Mali DP on models. Versions for actual
hardware are liable to require extra handling for clock input changes,
etc.
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>
---
ArmPlatformPkg/ArmPlatformPkg.dec | 4 +
ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec | 4 +-
ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf | 45 +++
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf | 3 +
ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf | 44 +++
ArmPlatformPkg/Include/Drivers/ArmMaliDp.h | 249 ++++++++++++
ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c | 377 ++++++++++++++++++
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c | 10 +-
ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c | 412 ++++++++++++++++++++
9 files changed, 1146 insertions(+), 2 deletions(-)
diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
index 0174f63e77f5b8430e106289366feb9a6577fb99..3be236413cb8e12ce32e6349732d2767fe0f3024 100644
--- a/ArmPlatformPkg/ArmPlatformPkg.dec
+++ b/ArmPlatformPkg/ArmPlatformPkg.dec
@@ -111,6 +111,10 @@ [PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdPL111LcdBase|0x0|UINT32|0x00000026
gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x0|UINT32|0x00000027
+ ## ARM Mali Display Processor DP500/DP550/DP650
+ gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase|0x0|UINT64|0x00000050
+ gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength|0x0|UINT32|0x00000051
+
## If set, frame buffer memory will be reserved and mapped in the system RAM
gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x0|UINT32|0x00000033
gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT64|0x00000034
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
index 3814513c2241c03a8c45fda92d571c65368f64b4..1a55b0434ab4bc53d631be2bffd313684bcea9c4 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
@@ -1,7 +1,7 @@
#/** @file
# Arm Versatile Express package.
#
-# Copyright (c) 2012-2015, ARM Limited. All rights reserved.
+# Copyright (c) 2012-2017, ARM Limited. All rights reserved.
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@@ -47,6 +47,8 @@ [PcdsFixedAtBuild.common]
gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId|1|UINT32|0x00000002
gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId|0|UINT32|0x00000003
+ gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode|0x0|UINT32|0x00000005
+
#
# Device path of block device on which Fastboot will flash partitions
#
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
new file mode 100644
index 0000000000000000000000000000000000000000..b85205a8ac6bfbd8befdd8634a7df89e213175bc
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
@@ -0,0 +1,45 @@
+#/** @file ArmMaliDpLib.inf
+#
+# Component description file for ArmMaliDpLib module
+#
+# Copyright (c) 2017, ARM Limited. All rights reserved.
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = ArmMaliDpLib
+ FILE_GUID = 36C47FED-2F3F-49C7-89CE-31B13F0431D8
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = LcdPlatformLib
+
+[Sources.common]
+ ArmMaliDpLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
+ ArmPlatformPkg/ArmPlatformPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ DxeServicesTableLib
+
+[FixedPcd.common]
+ gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
+ gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
+ gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
+
+ # MaxMode must be one number higher than the actual max mode,
+ # i.e. for actual maximum mode 2, set the value to 3.
+ # See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan 2017)
+ gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode
+
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
index 60789e9b8ff1b936db04953a765fb164b0e85a40..6ad7d94c8c76404c8a84345b5f992884ab5aca36 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
@@ -60,5 +60,8 @@ [FixedPcd]
gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
+ gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
+ gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength
+
[Ppis]
gArmMpCoreInfoPpiGuid
diff --git a/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf
new file mode 100644
index 0000000000000000000000000000000000000000..69155a123ef71ecf5361ab29e0ae71454c7ec6cd
--- /dev/null
+++ b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf
@@ -0,0 +1,44 @@
+#/** @file ArmMaliDp.inf
+#
+# Component description file for ArmMaliDp module
+#
+# Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = ArmMaliDp
+ FILE_GUID = E724AAF7-19E2-40A3-BAE1-D82A7C8B7A76
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = LcdHwLib
+
+[Sources.common]
+ ArmMaliDp.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ ArmPkg/ArmPkg.dec
+ ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
+ ArmPlatformPkg/ArmPlatformPkg.dec
+
+[LibraryClasses]
+ UefiLib
+ BaseLib
+ DebugLib
+ IoLib
+ BaseMemoryLib
+ LcdPlatformLib
+
+[FixedPcd]
+ gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
+
diff --git a/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h b/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h
new file mode 100644
index 0000000000000000000000000000000000000000..4955176800ea59f352399d9c6b590195d4ccfa41
--- /dev/null
+++ b/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h
@@ -0,0 +1,249 @@
+/** @file ArmMaliDp.h
+
+ File defines registers and other flags of ARM Mali DP display controller
+
+ Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#ifndef ARMMALIDP_H_
+#define ARMMALIDP_H_
+
+/**********************************************************************
+ *
+ * This header file contains all the bits of the ARM Mali DP that are
+ * platform independent.
+ *
+ **********************************************************************/
+#define DP_BASE (FixedPcdGet64 (PcdArmMaliDpBase))
+
+// MALI DP Ids
+#define MALIDP_500 0x500
+#define MALIDP_550 0x550
+#define MALIDP_650 0x650
+
+// DP500 Peripheral Ids
+#define DP500_ID_PART_0 0x00
+#define DP500_ID_DES_0 0xB
+#define DP500_ID_PART_1 0x5
+
+#define DP500_ID_REVISION 0x1
+#define DP500_ID_JEDEC 0x1
+#define DP500_ID_DES_1 0x3
+
+#define DP500_PERIPHERAL_ID0_VAL (DP500_ID_PART_0)
+#define DP500_PERIPHERAL_ID1_VAL ((DP500_ID_DES_0 << 4) \
+ | DP500_ID_PART_1)
+#define DP500_PERIPHERAL_ID2_VAL ((DP500_ID_REVISION << 4) \
+ | (DP500_ID_JEDEC << 3) \
+ | (DP500_ID_DES_1))
+
+// DP550 Peripheral Ids
+#define DP550_ID_PART_0 0x50
+#define DP550_ID_DES_0 0xB
+#define DP550_ID_PART_1 0x5
+
+#define DP550_ID_REVISION 0x0
+#define DP550_ID_JEDEC 0x1
+#define DP550_ID_DES_1 0x3
+
+#define DP550_PERIPHERAL_ID0_VAL (DP550_ID_PART_0)
+#define DP550_PERIPHERAL_ID1_VAL ((DP550_ID_DES_0 << 4) \
+ | DP550_ID_PART_1)
+#define DP550_PERIPHERAL_ID2_VAL ((DP550_ID_REVISION << 4) \
+ | (DP550_ID_JEDEC << 3) \
+ | (DP550_ID_DES_1))
+
+// DP650 Peripheral Ids
+#define DP650_ID_PART_0 0x50
+#define DP650_ID_DES_0 0xB
+#define DP650_ID_PART_1 0x6
+
+#define DP650_ID_REVISION 0x0
+#define DP650_ID_JEDEC 0x1
+#define DP650_ID_DES_1 0x3
+
+#define DP650_PERIPHERAL_ID0_VAL (DP650_ID_PART_0)
+#define DP650_PERIPHERAL_ID1_VAL ((DP650_ID_DES_0 << 4) \
+ | DP650_ID_PART_1)
+#define DP650_PERIPHERAL_ID2_VAL ((DP650_ID_REVISION << 4) \
+ | (DP650_ID_JEDEC << 3) \
+ | (DP650_ID_DES_1))
+
+// Display Engine (DE) control register offsets for DP550/DP650
+#define DP_DE_STATUS 0x00000
+#define DP_DE_IRQ_SET 0x00004
+#define DP_DE_IRQ_MASK 0x00008
+#define DP_DE_IRQ_CLEAR 0x0000C
+#define DP_DE_CONTROL 0x00010
+#define DP_DE_PROG_LINE 0x00014
+#define DP_DE_AXI_CONTROL 0x00018
+#define DP_DE_AXI_QOS 0x0001C
+#define DP_DE_DISPLAY_FUNCTION 0x00020
+
+#define DP_DE_H_INTERVALS 0x00030
+#define DP_DE_V_INTERVALS 0x00034
+#define DP_DE_SYNC_CONTROL 0x00038
+#define DP_DE_HV_ACTIVESIZE 0x0003C
+#define DP_DE_DISPLAY_SIDEBAND 0x00040
+#define DP_DE_BACKGROUND_COLOR 0x00044
+#define DP_DE_DISPLAY_SPLIT 0x00048
+#define DP_DE_OUTPUT_DEPTH 0x0004C
+
+// Display Engine (DE) control register offsets for DP500
+#define DP_DE_DP500_CORE_ID 0x00018
+#define DP_DE_DP500_CONTROL 0x0000C
+#define DP_DE_DP500_PROG_LINE 0x00010
+#define DP_DE_DP500_H_INTERVALS 0x00028
+#define DP_DE_DP500_V_INTERVALS 0x0002C
+#define DP_DE_DP500_SYNC_CONTROL 0x00030
+#define DP_DE_DP500_HV_ACTIVESIZE 0x00034
+#define DP_DE_DP500_BG_COLOR_RG 0x0003C
+#define DP_DE_DP500_BG_COLOR_B 0x00040
+
+/* Display Engine (DE) graphics layer (LG) register offsets
+ * NOTE: For DP500 it will be LG2.
+ */
+#define DE_LG_OFFSET 0x00300
+#define DP_DE_LG_FORMAT (DE_LG_OFFSET)
+#define DP_DE_LG_CONTROL (DE_LG_OFFSET + 0x04)
+#define DP_DE_LG_COMPOSE (DE_LG_OFFSET + 0x08)
+#define DP_DE_LG_IN_SIZE (DE_LG_OFFSET + 0x0C)
+#define DP_DE_LG_CMP_SIZE (DE_LG_OFFSET + 0x10)
+#define DP_DE_LG_OFFSET (DE_LG_OFFSET + 0x14)
+#define DP_DE_LG_H_STRIDE (DE_LG_OFFSET + 0x18)
+#define DP_DE_LG_PTR_LOW (DE_LG_OFFSET + 0x1C)
+#define DP_DE_LG_PTR_HIGH (DE_LG_OFFSET + 0x20)
+#define DP_DE_LG_CHROMA_KEY (DE_LG_OFFSET + 0x2C)
+#define DP_DE_LG_AD_CONTROL (DE_LG_OFFSET + 0x30)
+#define DP_DE_LG_MMU_CONTROL (DE_LG_OFFSET + 0x48)
+
+// Display core (DC) control register offsets.
+#define DP_DC_OFFSET 0x0C000
+#define DP_DC_STATUS (DP_DC_OFFSET + 0x00)
+#define DP_DC_IRQ_SET (DP_DC_OFFSET + 0x04)
+#define DP_DC_IRQ_MASK (DP_DC_OFFSET + 0x08)
+#define DP_DC_IRQ_CLEAR (DP_DC_OFFSET + 0x0C)
+#define DP_DC_CONTROL (DP_DC_OFFSET + 0x10)
+#define DP_DC_CONFIG_VALID (DP_DC_OFFSET + 0x14)
+#define DP_DC_CORE_ID (DP_DC_OFFSET + 0x18)
+
+// DP500 has a global configuration register.
+#define DP_DP500_CONFIG_VALID (0xF00)
+
+// Display core ID register offsets.
+#define DP_DC_ID_OFFSET 0x0FF00
+#define DP_DC_ID_PERIPHERAL_ID4 (DP_DC_ID_OFFSET + 0xD0)
+#define DP_DC_CONFIGURATION_ID (DP_DC_ID_OFFSET + 0xD4)
+#define DP_DC_PERIPHERAL_ID0 (DP_DC_ID_OFFSET + 0xE0)
+#define DP_DC_PERIPHERAL_ID1 (DP_DC_ID_OFFSET + 0xE4)
+#define DP_DC_PERIPHERAL_ID2 (DP_DC_ID_OFFSET + 0xE8)
+#define DP_DC_COMPONENT_ID0 (DP_DC_ID_OFFSET + 0xF0)
+#define DP_DC_COMPONENT_ID1 (DP_DC_ID_OFFSET + 0xF4)
+#define DP_DC_COMPONENT_ID2 (DP_DC_ID_OFFSET + 0xF8)
+#define DP_DC_COMPONENT_ID3 (DP_DC_ID_OFFSET + 0xFC)
+
+#define DP_DP500_ID_OFFSET 0x0F00
+#define DP_DP500_ID_PERIPHERAL_ID4 (DP_DP500_ID_OFFSET + 0xD0)
+#define DP_DP500_CONFIGURATION_ID (DP_DP500_ID_OFFSET + 0xD4)
+#define DP_DP500_PERIPHERAL_ID0 (DP_DP500_ID_OFFSET + 0xE0)
+#define DP_DP500_PERIPHERAL_ID1 (DP_DP500_ID_OFFSET + 0xE4)
+#define DP_DP500_PERIPHERAL_ID2 (DP_DP500_ID_OFFSET + 0xE8)
+#define DP_DP500_COMPONENT_ID0 (DP_DP500_ID_OFFSET + 0xF0)
+#define DP_DP500_COMPONENT_ID1 (DP_DP500_ID_OFFSET + 0xF4)
+#define DP_DP500_COMPONENT_ID2 (DP_DP500_ID_OFFSET + 0xF8)
+#define DP_DP500_COMPONENT_ID3 (DP_DP500_ID_OFFSET + 0xFC)
+
+// Display status configuration mode activation flag
+#define DP_DC_STATUS_CM_ACTIVE_FLAG (0x1U << 16)
+
+// Display core control configuration mode
+#define DP_DC_CONTROL_SRST_ACTIVE (0x1U << 18)
+#define DP_DC_CONTROL_CRST_ACTIVE (0x1U << 17)
+#define DP_DC_CONTROL_CM_ACTIVE (0x1U << 16)
+
+#define DP_DE_DP500_CONTROL_SOFTRESET_REQ (0x1U << 16)
+#define DP_DE_DP500_CONTROL_CONFIG_REQ (0x1U << 17)
+
+// Display core configuration valid register
+#define DP_DC_CONFIG_VALID_CVAL (0x1U)
+
+/* DC_CORE_ID
+ * Display core version register PRODUCT_ID
+ */
+#define DP_DC_CORE_ID_SHIFT 16
+#define DP_DE_DP500_CORE_ID_SHIFT DP_DC_CORE_ID_SHIFT
+
+// Timing settings
+#define DP_DE_HBACKPORCH_SHIFT 16
+#define DP_DE_VBACKPORCH_SHIFT 16
+#define DP_DE_VSP_SHIFT 28
+#define DP_DE_VSYNCWIDTH_SHIFT 16
+#define DP_DE_HSP_SHIFT 13
+#define DP_DE_V_ACTIVE_SHIFT 16
+
+// BACKGROUND_COLOR
+#define DP_DE_BG_R_PIXEL_SHIFT 16
+#define DP_DE_BG_G_PIXEL_SHIFT 8
+
+//Graphics layer LG_FORMAT Pixel Format
+#define DP_PIXEL_FORMAT_ARGB_8888 0x8
+#define DP_PIXEL_FORMAT_ABGR_8888 0x9
+#define DP_PIXEL_FORMAT_RGBA_8888 0xA
+#define DP_PIXEL_FORMAT_BGRA_8888 0xB
+#define DP_PIXEL_FORMAT_XRGB_8888 0x10
+#define DP_PIXEL_FORMAT_XBGR_8888 0x11
+#define DP_PIXEL_FORMAT_RGBX_8888 0x12
+#define DP_PIXEL_FORMAT_BGRX_8888 0x13
+#define DP_PIXEL_FORMAT_RGB_888 0x18
+#define DP_PIXEL_FORMAT_BGR_888 0x19
+
+// DP500 format code are different than DP550/DP650
+#define DP_PIXEL_FORMAT_DP500_ARGB_8888 0x2
+#define DP_PIXEL_FORMAT_DP500_ABGR_8888 0x3
+#define DP_PIXEL_FORMAT_DP500_XRGB_8888 0x4
+#define DP_PIXEL_FORMAT_DP500_XBGR_8888 0x5
+
+// Graphics layer LG_PTR_LOW and LG_PTR_HIGH
+#define DP_DE_LG_PTR_LOW_MASK 0xFFFFFFFFU
+#define DP_DE_LG_PTR_HIGH_SHIFT 32
+
+// Graphics layer LG_CONTROL register characteristics
+#define DP_DE_LG_L_ALPHA_SHIFT 16
+#define DP_DE_LG_CHK_SHIFT 15
+#define DP_DE_LG_PMUL_SHIFT 14
+#define DP_DE_LG_COM_SHIFT 12
+#define DP_DE_LG_VFP_SHIFT 11
+#define DP_DE_LG_HFP_SHIFT 10
+#define DP_DE_LG_ROTATION_SHIFT 8
+
+#define DP_DE_LG_LAYER_BLEND_NO_BG 0x0U
+#define DP_DE_LG_PIXEL_BLEND_NO_BG 0x1U
+#define DP_DE_LG_LAYER_BLEND_BG 0x2U
+#define DP_DE_LG_PIXEL_BLEND_BG 0x3U
+#define DP_DE_LG_ENABLE 0x1U
+
+// Graphics layer LG_IN_SIZE register characteristics
+#define DP_DE_LG_V_IN_SIZE_SHIFT 16
+
+// Graphics layer LG_CMP_SIZE register characteristics
+#define DP_DE_LG_V_CMP_SIZE_SHIFT 16
+#define DP_DE_LG_V_OFFSET_SHIFT 16
+
+// Helper display timing macro functions.
+#define H_INTERVALS(Hfp, Hbp) ((Hbp << DP_DE_HBACKPORCH_SHIFT) | Hfp)
+#define V_INTERVALS(Vfp, Vbp) ((Vbp << DP_DE_VBACKPORCH_SHIFT) | Vfp)
+#define SYNC_WIDTH(Hsw, Vsw) ((Vsw << DP_DE_VSYNCWIDTH_SHIFT) | Hsw)
+#define HV_ACTIVE(Hor, Ver) ((Ver << DP_DE_V_ACTIVE_SHIFT) | Hor)
+
+// Helper layer graphics macros.
+#define FRAME_IN_SIZE(Hor, Ver) ((Ver << DP_DE_LG_V_IN_SIZE_SHIFT) | Hor)
+#define FRAME_CMP_SIZE(Hor, Ver) ((Ver << DP_DE_LG_V_CMP_SIZE_SHIFT) | Hor)
+
+#endif /* ARMMALIDP_H_ */
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
new file mode 100644
index 0000000000000000000000000000000000000000..81924cc41f5898605038a1bc20af096fbb85d81c
--- /dev/null
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
@@ -0,0 +1,377 @@
+/** @file ArmMaliDpLib.c
+*
+* The file contains ARM Mali DP platform specific implementation.
+*
+* Copyright (c) 2017, ARM Ltd. All rights reserved.
+*
+* This program and the accompanying materials
+* are licensed and made available under the terms and conditions of the BSD License
+* which accompanies this distribution. The full text of the license may be found at
+* http://opensource.org/licenses/bsd-license.php
+*
+* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+#include <PiDxe.h>
+#include <Library/PcdLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DxeServicesTableLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/LcdPlatformLib.h>
+#include <ArmPlatform.h>
+
+/** Check an address is within 40 bits.
+ *
+ * The ARM Mali DP frame buffer address size can not be wider than 40 bits
+**/
+#define DP_VALID_BASE_ADDR(Address) ((Address >> 40) == 0)
+
+typedef struct {
+ UINT32 Mode;
+ UINT32 OscFreq;
+ SCAN_TIMINGS Horizontal;
+ SCAN_TIMINGS Vertical;
+} DISPLAY_MODE;
+
+/** The display modes implemented by this driver.
+ *
+ * On Models, the OSC frequencies (listed for each mode below) are not used.
+ * However these frequencies are useful on hardware plaforms where related
+ * clock (or PLL) settings are based on these pixel clocks.
+ *
+ * Since the clock settings are defined externally, the driver must
+ * communicate pixel clock frequencies to relevant modules
+ * responsible for setting clocks. e.g. SCP.
+**/
+STATIC CONST DISPLAY_MODE mDisplayModes[] = {
+ {
+ // Mode 0 : VGA : 640 x 480 x 24 bpp.
+ VGA,
+ VGA_OSC_FREQUENCY,
+ {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
+ {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
+ },
+ {
+ // Mode 1 : WVGA : 800 x 480 x 24 bpp.
+ WVGA,
+ WVGA_OSC_FREQUENCY,
+ {WVGA_H_RES_PIXELS, WVGA_H_SYNC, WVGA_H_BACK_PORCH, WVGA_H_FRONT_PORCH},
+ {WVGA_V_RES_PIXELS, WVGA_V_SYNC, WVGA_V_BACK_PORCH, WVGA_V_FRONT_PORCH}
+ },
+ {
+ // Mode 2 : SVGA : 800 x 600 x 24 bpp.
+ SVGA,
+ SVGA_OSC_FREQUENCY,
+ {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
+ {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
+ },
+ {
+ // Mode 3 : QHD : 960 x 540 x 24 bpp.
+ QHD,
+ QHD_OSC_FREQUENCY,
+ {QHD_H_RES_PIXELS, QHD_H_SYNC, QHD_H_BACK_PORCH, QHD_H_FRONT_PORCH},
+ {QHD_V_RES_PIXELS, QHD_V_SYNC, QHD_V_BACK_PORCH, QHD_V_FRONT_PORCH}
+ },
+ {
+ // Mode 4 : WSVGA : 1024 x 600 x 24 bpp.
+ WSVGA,
+ WSVGA_OSC_FREQUENCY,
+ {WSVGA_H_RES_PIXELS, WSVGA_H_SYNC, WSVGA_H_BACK_PORCH, WSVGA_H_FRONT_PORCH},
+ {WSVGA_V_RES_PIXELS, WSVGA_V_SYNC, WSVGA_V_BACK_PORCH, WSVGA_V_FRONT_PORCH}
+ },
+ {
+ // Mode 5 : XGA : 1024 x 768 x 24 bpp.
+ XGA,
+ XGA_OSC_FREQUENCY,
+ {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
+ {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
+ },
+ {
+ // Mode 6 : HD : 1280 x 720 x 24 bpp.
+ HD720,
+ HD720_OSC_FREQUENCY,
+ {HD720_H_RES_PIXELS, HD720_H_SYNC, HD720_H_BACK_PORCH, HD720_H_FRONT_PORCH},
+ {HD720_V_RES_PIXELS, HD720_V_SYNC, HD720_V_BACK_PORCH, HD720_V_FRONT_PORCH}
+ },
+ {
+ // Mode 7 : WXGA : 1280 x 800 x 24 bpp.
+ WXGA,
+ WXGA_OSC_FREQUENCY,
+ {WXGA_H_RES_PIXELS, WXGA_H_SYNC, WXGA_H_BACK_PORCH, WXGA_H_FRONT_PORCH},
+ {WXGA_V_RES_PIXELS, WXGA_V_SYNC, WXGA_V_BACK_PORCH, WXGA_V_FRONT_PORCH}
+ },
+ { // Mode 8 : SXGA : 1280 x 1024 x 24 bpp.
+ SXGA,
+ SXGA_OSC_FREQUENCY,
+ {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
+ {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
+ },
+ { // Mode 9 : WSXGA+ : 1680 x 1050 x 24 bpp.
+ WSXGA,
+ WSXGA_OSC_FREQUENCY,
+ {WSXGA_H_RES_PIXELS, WSXGA_H_SYNC, WSXGA_H_BACK_PORCH, WSXGA_H_FRONT_PORCH},
+ {WSXGA_V_RES_PIXELS,WSXGA_V_SYNC, WSXGA_V_BACK_PORCH, WSXGA_V_FRONT_PORCH}
+ },
+ {
+ // Mode 10 : HD : 1920 x 1080 x 24 bpp.
+ HD,
+ HD_OSC_FREQUENCY,
+ {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
+ {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
+ }
+};
+
+/** If PcdArmMaliDpMaxMode is 0, platform supports full range of modes
+ * else platform supports modes from 0 to PcdArmMaliDpMaxMode - 1
+**/
+STATIC CONST UINT32 mMaxMode = ((FixedPcdGet32 (PcdArmMaliDpMaxMode) != 0)
+ ? FixedPcdGet32 (PcdArmMaliDpMaxMode)
+ : sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
+
+
+/** Platform related initialization function.
+ *
+ * @retval EFI_SUCCESS Platform initialization success.
+ * @retval EFI_UNSUPPORTED PcdGopPixelFormat must be
+ * PixelRedGreenBlueReserved8BitPerColor OR
+ * PixelBlueGreenRedReserved8BitPerColor
+ * any other format is not supported.
+**/
+EFI_STATUS
+LcdPlatformInitializeDisplay (
+ IN CONST EFI_HANDLE Handle
+ )
+{
+ EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
+
+ (VOID)Handle;
+
+ // PixelBitMask and PixelBltOnly pixel formats are not supported
+ PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
+ if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
+ && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
+
+ ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
+ || PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/** Reserve VRAM memory in DRAM for the frame buffer
+ *
+ * (unless it is reserved already).
+ *
+ * The allocated address can be used to set the frame buffer as a base buffer
+ * address for any layer of the ARM Mali DP.
+ *
+ * @param OUT VramBaseAddress A pointer to the frame buffer address.
+ * @param OUT VramSize A pointer to the size of the frame
+ * buffer in bytes
+ *
+ * @retval EFI_SUCCESS Frame buffer memory allocation success.
+ * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize are NULL.
+ * @retval EFI_UNSUPPORTED Allocated address wider than 40 bits
+ * @retval !EFI_SUCCESS Other errors.
+**/
+EFI_STATUS
+LcdPlatformGetVram (
+ OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
+ OUT UINTN * CONST VramSize
+ )
+{
+ EFI_STATUS Status;
+
+ // Check VramBaseAddress and VramSize are not NULL.
+ if (VramBaseAddress == NULL || VramSize == NULL) {
+ ASSERT (VramBaseAddress != NULL);
+ ASSERT (VramSize != NULL);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // Set the VRAM size.
+ *VramSize = (UINTN)FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
+
+ // Check if memory is already reserved for the frame buffer.
+#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
+
+#if (!DP_VALID_BASE_ADDR (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase)))
+#error ARM Mali DP frame buffer base address cannot be wider than 40 bits.
+#else
+
+ *VramBaseAddress =
+ (EFI_PHYSICAL_ADDRESS)FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
+
+ Status = EFI_SUCCESS;
+#endif
+
+#else
+ // If not already reserved, attempt to allocate the VRAM from the DRAM.
+ Status = gBS->AllocatePages (
+ AllocateAnyPages,
+ EfiBootServicesData,
+ EFI_SIZE_TO_PAGES (*VramSize),
+ VramBaseAddress
+ );
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "ArmMaliDpLib: Failed to allocate frame buffer.\n"));
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // ARM Mali DP frame buffer base address can not be wider than 40 bits.
+ if (!DP_VALID_BASE_ADDR (*VramBaseAddress)) {
+ gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
+ ASSERT (DP_VALID_BASE_ADDR (*VramBaseAddress));
+ return EFI_UNSUPPORTED;
+ }
+
+ /* Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.
+ * For ARM/AArch64 EFI_MEMORY_WC memory is actually uncached.
+ */
+ Status = gDS->SetMemorySpaceAttributes (
+ *VramBaseAddress,
+ *VramSize,
+ EFI_MEMORY_WC
+ );
+
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
+ }
+
+#endif
+ return Status;
+}
+
+/** Return total number of modes supported.
+ *
+ * Note: Valid mode numbers are 0 to MaxMode - 1
+ * See Section 12.9 of the UEFI Specification 2.7
+ *
+ * @retval UINT32 Mode Number.
+**/
+UINT32
+LcdPlatformGetMaxMode (VOID)
+{
+ return mMaxMode;
+}
+
+/** Set the requested display mode.
+ *
+ * @param IN ModeNumber Mode Number.
+ *
+ * @retval EFI_SUCCESS Set mode success.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
+EFI_STATUS
+LcdPlatformSetMode (
+ IN CONST UINT32 ModeNumber
+ )
+{
+
+ if (ModeNumber >= mMaxMode) {
+ ASSERT (ModeNumber < mMaxMode);
+ return EFI_INVALID_PARAMETER;
+ }
+ /* On models, platform specific clock/mux settings are not required
+ * Display controller specific settings for Mali DP are done in LcdSetMode.
+ */
+ return EFI_SUCCESS;
+}
+
+/** Return information for the requested mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT Info Pointer for returned mode information
+ * (on success).
+ *
+ * @retval EFI_SUCCESS Requested mode found.
+ * @retval EFI_INVALID_PARAMETER Info is NULL.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+**/
+EFI_STATUS
+LcdPlatformQueryMode (
+ IN CONST UINT32 ModeNumber,
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
+ )
+{
+ if (ModeNumber >= mMaxMode || Info == NULL) {
+ ASSERT (ModeNumber < mMaxMode);
+ ASSERT (Info != NULL);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Info->Version = 0;
+ Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
+ Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
+ Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
+
+ Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
+
+ return EFI_SUCCESS;
+}
+
+/** Returns the display timing information for the requested mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT Horizontal Pointer to horizontal timing parameters.
+ * (Resolution, Sync, Back porch, Front porch)
+ * @param OUT Vertical Pointer to vertical timing parameters.
+ * (Resolution, Sync, Back porch, Front porch)
+ *
+ * @retval EFI_SUCCESS Requested mode found.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+ * @retval EFI_INVALID_PARAMETER One of the OUT parameters is NULL.
+**/
+EFI_STATUS
+LcdPlatformGetTimings (
+ IN UINT32 ModeNumber,
+ OUT CONST SCAN_TIMINGS ** Horizontal,
+ OUT CONST SCAN_TIMINGS ** Vertical
+ )
+{
+ if (ModeNumber >= mMaxMode || Horizontal == NULL || Vertical == NULL) {
+ ASSERT (ModeNumber < mMaxMode);
+ // One of the pointers is NULL
+ ASSERT (Horizontal != NULL);
+ ASSERT (Vertical != NULL);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
+ *Vertical = &mDisplayModes[ModeNumber].Vertical;
+
+ return EFI_SUCCESS;
+}
+
+/** Return bytes per pixel information for a mode number.
+ *
+ * @param IN ModeNumber Mode Number.
+ * @param OUT Bpp Pointer to value Bytes Per Pixel.
+ *
+ * @retval EFI_SUCCESS The requested mode is found.
+ * @retval EFI_INVALID_PARAMETER Requested mode not found.
+ * @retval EFI_INVALID_PARAMETER Bpp is NULL.
+**/
+EFI_STATUS
+LcdPlatformGetBpp (
+ IN CONST UINT32 ModeNumber,
+ OUT LCD_BPP * CONST Bpp
+ )
+{
+ if (ModeNumber >= mMaxMode || Bpp == NULL) {
+ // Check valid ModeNumber and Bpp.
+ ASSERT (ModeNumber < mMaxMode);
+ ASSERT (Bpp != NULL);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *Bpp = LCD_BITS_PER_PIXEL_24;
+
+ return EFI_SUCCESS;
+}
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
index 5cd529750a3d2d3b0d381b58d875d378afaba2c2..87a7a26132e39b933ecd2a95e38b2ab869cd4079 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
+++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
@@ -21,9 +21,10 @@
#include <ArmPlatform.h>
#define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
+#define DP_BASE_DESCRIPTOR ((FixedPcdGet64 (PcdArmMaliDpBase) != 0) ? 1 : 0)
// Number of Virtual Memory Map Descriptors
-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR)
+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR + DP_BASE_DESCRIPTOR)
// DDR attributes
#define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
@@ -159,6 +160,13 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
#endif
+#if (FixedPcdGet64 (PcdArmMaliDpBase) != 0)
+ // DP500/DP550/DP650 peripheral memory region
+ VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdArmMaliDpBase);
+ VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdArmMaliDpBase);
+ VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdArmMaliDpMemoryRegionLength);
+ VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
+#endif
// Map sparse memory region if present
if (HasSparseMemory) {
VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
diff --git a/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c
new file mode 100644
index 0000000000000000000000000000000000000000..ff7236371d27915d9f1e34162dce0954dde63a77
--- /dev/null
+++ b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c
@@ -0,0 +1,412 @@
+/** @file ArmMaliDp.c
+
+ ARM Mali DP 500/550/650 display controller driver
+
+ Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Library/IoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/LcdPlatformLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Drivers/ArmMaliDp.h>
+#include <Drivers/LcdHw.h>
+
+// CORE_ID of the MALI DP
+STATIC UINT32 gDpDeviceId;
+
+/** Disable the graphics layer
+ *
+ * This is done by clearing the EN bit
+ * of the LG_CONTROL register.
+**/
+STATIC
+VOID
+LayerGraphicsDisable (VOID)
+{
+ MmioAnd32 (DP_BASE + DP_DE_LG_CONTROL, ~DP_DE_LG_ENABLE);
+}
+
+/** Enable the graphics layer
+ *
+ * This is done by setting the EN bit
+ * of the LG_CONTROL register.
+**/
+STATIC
+VOID
+LayerGraphicsEnable (VOID)
+{
+ MmioOr32 (DP_BASE + DP_DE_LG_CONTROL, DP_DE_LG_ENABLE);
+}
+
+/** Set the frame address of the graphics layer.
+ *
+ * @param FrameBaseAddress Address of the data buffer
+ * to be used as a frame buffer.
+**/
+STATIC
+VOID
+LayerGraphicsSetFrame (
+ IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
+ )
+{
+ // Disable the graphics layer.
+ LayerGraphicsDisable ();
+
+ /* Set up memory address of the data buffer for graphics layer.
+ * write lower bits of the address.
+ */
+ MmioWrite32 (
+ DP_BASE + DP_DE_LG_PTR_LOW,
+ DP_DE_LG_PTR_LOW_MASK & FrameBaseAddress
+ );
+
+ // Write higher bits of the address.
+ MmioWrite32 (
+ DP_BASE + DP_DE_LG_PTR_HIGH,
+ (UINT32)(FrameBaseAddress >> DP_DE_LG_PTR_HIGH_SHIFT)
+ );
+
+ // Enable the graphics layer.
+ LayerGraphicsEnable ();
+}
+
+/** Configures various graphics layer characteristics.
+ *
+ * @param HRes Horizontal resolution of the graphics layer.
+ * @param VRes Vertical resolution of the graphics layer.
+**/
+STATIC
+VOID
+LayerGraphicsConfig (
+ IN CONST EFI_GRAPHICS_PIXEL_FORMAT UefiGfxPixelFormat,
+ IN CONST UINT32 HRes,
+ IN CONST UINT32 VRes
+ )
+{
+ UINT32 PixelFormat;
+
+ // Disable the graphics layer before configuring any settings.
+ LayerGraphicsDisable ();
+
+ // Setup graphics layer size.
+ MmioWrite32 (DP_BASE + DP_DE_LG_IN_SIZE, FRAME_IN_SIZE (HRes, VRes));
+
+ // Setup graphics layer composition size.
+ MmioWrite32 (DP_BASE + DP_DE_LG_CMP_SIZE, FRAME_CMP_SIZE (HRes, VRes));
+
+ // Setup memory stride (total visible pixels on a line * 4 ).
+ MmioWrite32 (DP_BASE + DP_DE_LG_H_STRIDE, (HRes * sizeof (UINT32)));
+
+ /* Set the format.
+ *
+ * In PixelBlueGreenRedReserved8BitPerColor format, byte 0 represents blue,
+ * byte 1 represents green, and byte 2 represents red, and byte 3 is reserved
+ * which is equivalent to XRGB format of the DP500/DP550/DP650. Whereas
+ * PixelRedGreenBlueReserved8BitPerColor is equivalent to XBGR of the
+ * DP500/DP550/DP650.
+ */
+ if (UefiGfxPixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
+ PixelFormat = (gDpDeviceId == MALIDP_500) ? DP_PIXEL_FORMAT_DP500_XRGB_8888
+ : DP_PIXEL_FORMAT_XRGB_8888;
+ } else {
+ PixelFormat = (gDpDeviceId == MALIDP_500) ? DP_PIXEL_FORMAT_DP500_XBGR_8888
+ : DP_PIXEL_FORMAT_XBGR_8888;
+ }
+
+ MmioWrite32 (DP_BASE + DP_DE_LG_FORMAT, PixelFormat);
+
+ // Enable graphics layer.
+ LayerGraphicsEnable ();
+}
+
+/** Configure timing information of the display.
+ * @param IN Horizontal Pointer to horizontal timing parameters.
+ * (Resolution, Sync, Back porch, Front porch)
+ * @param IN Vertical Pointer to vertical timing parameters.
+ * (Resolution, Sync, Back porch, Front porch)
+**/
+STATIC
+VOID
+SetDisplayEngineTiming (
+ IN CONST SCAN_TIMINGS * CONST Horizontal,
+ IN CONST SCAN_TIMINGS * CONST Vertical
+ )
+{
+ UINTN RegHIntervals;
+ UINTN RegVIntervals;
+ UINTN RegSyncControl;
+ UINTN RegHVActiveSize;
+
+ if (gDpDeviceId == MALIDP_500) {
+ // MALI DP500 timing registers.
+ RegHIntervals = DP_BASE + DP_DE_DP500_H_INTERVALS;
+ RegVIntervals = DP_BASE + DP_DE_DP500_V_INTERVALS;
+ RegSyncControl = DP_BASE + DP_DE_DP500_SYNC_CONTROL;
+ RegHVActiveSize = DP_BASE + DP_DE_DP500_HV_ACTIVESIZE;
+ } else {
+ // MALI DP550/DP650 timing registers.
+ RegHIntervals = DP_BASE + DP_DE_H_INTERVALS;
+ RegVIntervals = DP_BASE + DP_DE_V_INTERVALS;
+ RegSyncControl = DP_BASE + DP_DE_SYNC_CONTROL;
+ RegHVActiveSize = DP_BASE + DP_DE_HV_ACTIVESIZE;
+ }
+
+ // Horizontal back porch and front porch.
+ MmioWrite32 (
+ RegHIntervals,
+ H_INTERVALS (Horizontal->FrontPorch, Horizontal->BackPorch)
+ );
+
+ // Vertical back porch and front porch.
+ MmioWrite32 (
+ RegVIntervals,
+ V_INTERVALS (Vertical->FrontPorch, Vertical->BackPorch)
+ );
+
+ // Sync control, Horizontal and Vertical sync.
+ MmioWrite32 (
+ RegSyncControl,
+ SYNC_WIDTH (Horizontal->Sync, Vertical->Sync)
+ );
+
+ // Set up Horizontal and Vertical area size.
+ MmioWrite32 (
+ RegHVActiveSize,
+ HV_ACTIVE (Horizontal->Resolution, Vertical->Resolution)
+ );
+}
+
+/** Return CORE_ID of the ARM Mali DP.
+ *
+ * @retval 0 No Mali DP found.
+ * @retval 0x500 Mali DP core id for DP500.
+ * @retval 0x550 Mali DP core id for DP550.
+ * @retval 0x650 Mali DP core id for DP650.
+**/
+STATIC
+UINT32
+ArmMaliDpGetCoreId (
+ )
+{
+ UINT32 DpCoreId;
+
+ /* First check for DP500 as register offset for DP550/DP650 CORE_ID
+ * is beyond 3K/4K register space of the DP500.
+ */
+ DpCoreId = MmioRead32 (DP_BASE + DP_DE_DP500_CORE_ID);
+ DpCoreId >>= DP_DE_DP500_CORE_ID_SHIFT;
+
+ if (DpCoreId == MALIDP_500) {
+ return DpCoreId;
+ }
+
+ // Check for DP550 or DP650.
+ DpCoreId = MmioRead32 (DP_BASE + DP_DC_CORE_ID);
+ DpCoreId >>= DP_DC_CORE_ID_SHIFT;
+
+ if (DpCoreId == MALIDP_550
+ || DpCoreId == MALIDP_650) {
+ return DpCoreId;
+ }
+
+ return 0;
+}
+
+/** Check for presence of MALI.
+ *
+ * This function returns success if the platform implements
+ * DP500/DP550/DP650 ARM Mali display processor.
+ *
+ * @retval EFI_SUCCESS Platform implements DP500/DP550/DP650.
+ * @retval EFI_NOT_FOUND DP500/DP550/DP650 display processor not
+ * found on the platform.
+**/
+EFI_STATUS
+LcdIdentify (VOID)
+{
+ UINT32 DpCoreId;
+
+ DEBUG ((DEBUG_WARN,
+ "Probing ARM Mali DP500/DP550/DP650 at base address 0x%p\n",
+ DP_BASE
+ ));
+
+#if (DP_BASE == 0)
+#error "ARM Mali DP peripheral base address is invalid\n"
+#endif
+
+ DpCoreId = ArmMaliDpGetCoreId ();
+
+ if (DpCoreId != 0) {
+ DEBUG ((DEBUG_WARN, "Found ARM Mali DP %x\n", DpCoreId));
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_WARN, "ARM Mali DP not found...\n"));
+
+ return EFI_NOT_FOUND;
+}
+
+/** Initialize platform display.
+ *
+ * @param FrameBaseAddress Address of the frame buffer.
+ *
+ * @retval EFI_SUCCESS Display initialization success.
+ * @retval !(EFI_SUCCESS) Display initialization failure.
+**/
+EFI_STATUS
+LcdInitialize (
+ IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
+ )
+{
+ DEBUG ((DEBUG_WARN, "Frame buffer base address = %p\n", FrameBaseAddress));
+
+ gDpDeviceId = ArmMaliDpGetCoreId ();
+ if (gDpDeviceId == 0) {
+ DEBUG ((DEBUG_ERROR, "ARM Mali DP initialization fail,"
+ "no ARM Mali DP present\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ // We are using graphics layer of the Mali DP as a main frame buffer.
+ LayerGraphicsSetFrame (FrameBaseAddress);
+
+ return EFI_SUCCESS;
+}
+
+/** Set ARM Mali DP in cofiguration mode.
+ *
+ * The ARM Mali DP must be in the configuration mode for
+ * configuration of the H_INTERVALS, V_INTERVALS, SYNC_CONTROL
+ * and HV_ACTIVESIZE.
+**/
+STATIC
+VOID
+SetConfigurationMode (VOID)
+{
+ // Request configuration Mode.
+ if (gDpDeviceId == MALIDP_500) {
+ MmioOr32 (DP_BASE + DP_DE_DP500_CONTROL, DP_DE_DP500_CONTROL_CONFIG_REQ);
+ } else {
+ MmioOr32 (DP_BASE + DP_DC_CONTROL, DP_DC_CONTROL_CM_ACTIVE);
+ }
+}
+
+/** Set ARM Mali DP in normal mode.
+ *
+ * Normal mode is the main operating mode of the display processor
+ * in which display layer data is fetched from frame buffer and
+ * displayed.
+**/
+STATIC
+VOID
+SetNormalMode (VOID)
+{
+ // Disable configuration Mode.
+ if (gDpDeviceId == MALIDP_500) {
+ MmioAnd32 (DP_BASE + DP_DE_DP500_CONTROL, ~DP_DE_DP500_CONTROL_CONFIG_REQ);
+ } else {
+ MmioAnd32 (DP_BASE + DP_DC_CONTROL, ~DP_DC_CONTROL_CM_ACTIVE );
+ }
+}
+
+/** Set the global configuration valid flag.
+ *
+ * Any new configuration parameters written to the display engine are not
+ * activated until the global configuration valid flag is set in the
+ * CONFIG_VALID register.
+**/
+STATIC
+VOID
+SetConfigValid (VOID)
+{
+ if (gDpDeviceId == MALIDP_500) {
+ MmioOr32 (DP_BASE + DP_DP500_CONFIG_VALID, DP_DC_CONFIG_VALID);
+ } else {
+ MmioOr32 (DP_BASE + DP_DC_CONFIG_VALID, DP_DC_CONFIG_VALID );
+ }
+}
+
+/** Set requested mode of the display.
+ *
+ * @param ModeNumber Display mode number.
+ * @retval EFI_SUCCESS Display set mode success.
+ * @retval EFI_DEVICE_ERROR If mode not found/supported.
+ * @retval EFI_DEVICE_ERROR If mode does not support more
+ * than 24 bytes per pixel format.
+**/
+EFI_STATUS
+LcdSetMode (
+ IN CONST UINT32 ModeNumber
+ )
+{
+ EFI_STATUS Status;
+ CONST SCAN_TIMINGS *Horizontal;
+ CONST SCAN_TIMINGS *Vertical;
+
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
+
+ // Get the display mode timings and other relevant information.
+ Status = LcdPlatformGetTimings (
+ ModeNumber,
+ &Horizontal,
+ &Vertical
+ );
+
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+ ASSERT (Horizontal != NULL);
+ ASSERT (Vertical != NULL);
+
+ // Get the pixel format information.
+ Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // Request configuration mode.
+ SetConfigurationMode ();
+
+ // Configure the graphics layer.
+ LayerGraphicsConfig (
+ ModeInfo.PixelFormat,
+ Horizontal->Resolution,
+ Vertical->Resolution
+ );
+
+ // Set the display engine timings.
+ SetDisplayEngineTiming (Horizontal, Vertical);
+
+ // After configuration, set Mali DP in normal mode.
+ SetNormalMode ();
+
+ /* Any parameters written to the display engine are not activated until
+ * CONFIG_VALID is set.
+ */
+ SetConfigValid ();
+
+ return EFI_SUCCESS;
+}
+
+/**
+ * This function de-initializes the display.
+**/
+VOID
+LcdShutdown (VOID)
+{
+ // Disable graphics layer.
+ LayerGraphicsDisable ();
+}
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
^ permalink raw reply related [flat|nested] 69+ messages in thread
* Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver.
2017-09-26 20:15 ` [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver evan.lloyd
@ 2017-10-25 15:31 ` Leif Lindholm
2017-11-28 18:17 ` Ard Biesheuvel
1 sibling, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-10-25 15:31 UTC (permalink / raw)
To: evan.lloyd; +Cc: edk2-devel
On Tue, Sep 26, 2017 at 09:15:29PM +0100, evan.lloyd@arm.com wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> This change adds support for the ARM Mali DP500/DP500/DP650 display
> processors using the GOP protocol. It has been tested on FVP base
> models + DP550 support.
>
> This change does not modify functionality provided by PL111 or
> HDLCD. The driver should be suitable for those platforms
> that implement ARM Mali DP500/DP550/DP650 replacing PL111/HDLCD.
Do we have anyone able to test this on hardware?
The models are sometimes more forgiving...
> Only "Layer Graphics" of the ARM Mali DP is configured for rendering
> the RGB/BGR format frame buffer to satisfy the UEFI GOP requirements
> Other layers e.g. video layers are not configured.
>
> NOTE: This change implements the Mali DP on models. Versions for actual
> hardware are liable to require extra handling for clock input changes,
> etc.
Right. That's a no on my question above.
OK - but please drop this note. Or at least the "NOTE: This change
implements the Mali DP on models." bit.
> 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>
> ---
> ArmPlatformPkg/ArmPlatformPkg.dec | 4 +
> ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec | 4 +-
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf | 45 +++
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf | 3 +
> ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf | 44 +++
> ArmPlatformPkg/Include/Drivers/ArmMaliDp.h | 249 ++++++++++++
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c | 377 ++++++++++++++++++
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c | 10 +-
> ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c | 412 ++++++++++++++++++++
> 9 files changed, 1146 insertions(+), 2 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
> index 0174f63e77f5b8430e106289366feb9a6577fb99..3be236413cb8e12ce32e6349732d2767fe0f3024 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -111,6 +111,10 @@ [PcdsFixedAtBuild.common]
> gArmPlatformTokenSpaceGuid.PcdPL111LcdBase|0x0|UINT32|0x00000026
> gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x0|UINT32|0x00000027
>
> + ## ARM Mali Display Processor DP500/DP550/DP650
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase|0x0|UINT64|0x00000050
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength|0x0|UINT32|0x00000051
> +
> ## If set, frame buffer memory will be reserved and mapped in the system RAM
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x0|UINT32|0x00000033
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT64|0x00000034
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> index 3814513c2241c03a8c45fda92d571c65368f64b4..1a55b0434ab4bc53d631be2bffd313684bcea9c4 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> @@ -1,7 +1,7 @@
> #/** @file
> # Arm Versatile Express package.
> #
> -# Copyright (c) 2012-2015, ARM Limited. All rights reserved.
> +# Copyright (c) 2012-2017, ARM Limited. All rights reserved.
> #
> # This program and the accompanying materials are licensed and made available
> # under the terms and conditions of the BSD License which accompanies this
> @@ -47,6 +47,8 @@ [PcdsFixedAtBuild.common]
> gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId|1|UINT32|0x00000002
> gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId|0|UINT32|0x00000003
>
> + gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode|0x0|UINT32|0x00000005
> +
> #
> # Device path of block device on which Fastboot will flash partitions
> #
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
> new file mode 100644
> index 0000000000000000000000000000000000000000..b85205a8ac6bfbd8befdd8634a7df89e213175bc
> --- /dev/null
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
> @@ -0,0 +1,45 @@
> +#/** @file ArmMaliDpLib.inf
> +#
> +# Component description file for ArmMaliDpLib module
> +#
> +# Copyright (c) 2017, ARM Limited. All rights reserved.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#**/
> +
> +[Defines]
> + INF_VERSION = 0x00010005
Bump to something more recent?
> + BASE_NAME = ArmMaliDpLib
> + FILE_GUID = 36C47FED-2F3F-49C7-89CE-31B13F0431D8
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = LcdPlatformLib
> +
> +[Sources.common]
> + ArmMaliDpLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> + ArmPlatformPkg/ArmPlatformPkg.dec
Please sort alphabetically.
> +
> +[LibraryClasses]
> + BaseLib
> + DxeServicesTableLib
> +
> +[FixedPcd.common]
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
> + gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
> +
> + # MaxMode must be one number higher than the actual max mode,
> + # i.e. for actual maximum mode 2, set the value to 3.
> + # See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan 2017)
> + gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode
> +
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> index 60789e9b8ff1b936db04953a765fb164b0e85a40..6ad7d94c8c76404c8a84345b5f992884ab5aca36 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> @@ -60,5 +60,8 @@ [FixedPcd]
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
>
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength
> +
> [Ppis]
> gArmMpCoreInfoPpiGuid
> diff --git a/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf
> new file mode 100644
> index 0000000000000000000000000000000000000000..69155a123ef71ecf5361ab29e0ae71454c7ec6cd
> --- /dev/null
> +++ b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf
> @@ -0,0 +1,44 @@
> +#/** @file ArmMaliDp.inf
> +#
> +# Component description file for ArmMaliDp module
> +#
> +# Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#**/
> +
> +[Defines]
> + INF_VERSION = 0x00010005
Bump?
> + BASE_NAME = ArmMaliDp
> + FILE_GUID = E724AAF7-19E2-40A3-BAE1-D82A7C8B7A76
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = LcdHwLib
> +
> +[Sources.common]
> + ArmMaliDp.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + ArmPkg/ArmPkg.dec
> + ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> + ArmPlatformPkg/ArmPlatformPkg.dec
Sort alphabetically?
> +
> +[LibraryClasses]
> + UefiLib
> + BaseLib
> + DebugLib
> + IoLib
> + BaseMemoryLib
> + LcdPlatformLib
Sort alphabetically?
> +
> +[FixedPcd]
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
> +
> diff --git a/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h b/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..4955176800ea59f352399d9c6b590195d4ccfa41
> --- /dev/null
> +++ b/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h
> @@ -0,0 +1,249 @@
> +/** @file ArmMaliDp.h
> +
> + File defines registers and other flags of ARM Mali DP display controller
> +
> + Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD License
> + which accompanies this distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +#ifndef ARMMALIDP_H_
> +#define ARMMALIDP_H_
> +
> +/**********************************************************************
> + *
> + * This header file contains all the bits of the ARM Mali DP that are
> + * platform independent.
> + *
> + **********************************************************************/
> +#define DP_BASE (FixedPcdGet64 (PcdArmMaliDpBase))
> +
> +// MALI DP Ids
> +#define MALIDP_500 0x500
> +#define MALIDP_550 0x550
> +#define MALIDP_650 0x650
> +
> +// DP500 Peripheral Ids
> +#define DP500_ID_PART_0 0x00
> +#define DP500_ID_DES_0 0xB
> +#define DP500_ID_PART_1 0x5
> +
> +#define DP500_ID_REVISION 0x1
> +#define DP500_ID_JEDEC 0x1
> +#define DP500_ID_DES_1 0x3
> +
> +#define DP500_PERIPHERAL_ID0_VAL (DP500_ID_PART_0)
> +#define DP500_PERIPHERAL_ID1_VAL ((DP500_ID_DES_0 << 4) \
> + | DP500_ID_PART_1)
> +#define DP500_PERIPHERAL_ID2_VAL ((DP500_ID_REVISION << 4) \
> + | (DP500_ID_JEDEC << 3) \
> + | (DP500_ID_DES_1))
> +
> +// DP550 Peripheral Ids
> +#define DP550_ID_PART_0 0x50
> +#define DP550_ID_DES_0 0xB
> +#define DP550_ID_PART_1 0x5
> +
> +#define DP550_ID_REVISION 0x0
> +#define DP550_ID_JEDEC 0x1
> +#define DP550_ID_DES_1 0x3
> +
> +#define DP550_PERIPHERAL_ID0_VAL (DP550_ID_PART_0)
> +#define DP550_PERIPHERAL_ID1_VAL ((DP550_ID_DES_0 << 4) \
> + | DP550_ID_PART_1)
> +#define DP550_PERIPHERAL_ID2_VAL ((DP550_ID_REVISION << 4) \
> + | (DP550_ID_JEDEC << 3) \
> + | (DP550_ID_DES_1))
> +
> +// DP650 Peripheral Ids
> +#define DP650_ID_PART_0 0x50
> +#define DP650_ID_DES_0 0xB
> +#define DP650_ID_PART_1 0x6
> +
> +#define DP650_ID_REVISION 0x0
> +#define DP650_ID_JEDEC 0x1
> +#define DP650_ID_DES_1 0x3
> +
> +#define DP650_PERIPHERAL_ID0_VAL (DP650_ID_PART_0)
> +#define DP650_PERIPHERAL_ID1_VAL ((DP650_ID_DES_0 << 4) \
> + | DP650_ID_PART_1)
> +#define DP650_PERIPHERAL_ID2_VAL ((DP650_ID_REVISION << 4) \
> + | (DP650_ID_JEDEC << 3) \
> + | (DP650_ID_DES_1))
> +
> +// Display Engine (DE) control register offsets for DP550/DP650
> +#define DP_DE_STATUS 0x00000
> +#define DP_DE_IRQ_SET 0x00004
> +#define DP_DE_IRQ_MASK 0x00008
> +#define DP_DE_IRQ_CLEAR 0x0000C
> +#define DP_DE_CONTROL 0x00010
> +#define DP_DE_PROG_LINE 0x00014
> +#define DP_DE_AXI_CONTROL 0x00018
> +#define DP_DE_AXI_QOS 0x0001C
> +#define DP_DE_DISPLAY_FUNCTION 0x00020
> +
> +#define DP_DE_H_INTERVALS 0x00030
> +#define DP_DE_V_INTERVALS 0x00034
> +#define DP_DE_SYNC_CONTROL 0x00038
> +#define DP_DE_HV_ACTIVESIZE 0x0003C
> +#define DP_DE_DISPLAY_SIDEBAND 0x00040
> +#define DP_DE_BACKGROUND_COLOR 0x00044
> +#define DP_DE_DISPLAY_SPLIT 0x00048
> +#define DP_DE_OUTPUT_DEPTH 0x0004C
> +
> +// Display Engine (DE) control register offsets for DP500
> +#define DP_DE_DP500_CORE_ID 0x00018
> +#define DP_DE_DP500_CONTROL 0x0000C
> +#define DP_DE_DP500_PROG_LINE 0x00010
> +#define DP_DE_DP500_H_INTERVALS 0x00028
> +#define DP_DE_DP500_V_INTERVALS 0x0002C
> +#define DP_DE_DP500_SYNC_CONTROL 0x00030
> +#define DP_DE_DP500_HV_ACTIVESIZE 0x00034
> +#define DP_DE_DP500_BG_COLOR_RG 0x0003C
> +#define DP_DE_DP500_BG_COLOR_B 0x00040
> +
> +/* Display Engine (DE) graphics layer (LG) register offsets
> + * NOTE: For DP500 it will be LG2.
> + */
> +#define DE_LG_OFFSET 0x00300
> +#define DP_DE_LG_FORMAT (DE_LG_OFFSET)
> +#define DP_DE_LG_CONTROL (DE_LG_OFFSET + 0x04)
> +#define DP_DE_LG_COMPOSE (DE_LG_OFFSET + 0x08)
> +#define DP_DE_LG_IN_SIZE (DE_LG_OFFSET + 0x0C)
> +#define DP_DE_LG_CMP_SIZE (DE_LG_OFFSET + 0x10)
> +#define DP_DE_LG_OFFSET (DE_LG_OFFSET + 0x14)
> +#define DP_DE_LG_H_STRIDE (DE_LG_OFFSET + 0x18)
> +#define DP_DE_LG_PTR_LOW (DE_LG_OFFSET + 0x1C)
> +#define DP_DE_LG_PTR_HIGH (DE_LG_OFFSET + 0x20)
> +#define DP_DE_LG_CHROMA_KEY (DE_LG_OFFSET + 0x2C)
> +#define DP_DE_LG_AD_CONTROL (DE_LG_OFFSET + 0x30)
> +#define DP_DE_LG_MMU_CONTROL (DE_LG_OFFSET + 0x48)
> +
> +// Display core (DC) control register offsets.
> +#define DP_DC_OFFSET 0x0C000
> +#define DP_DC_STATUS (DP_DC_OFFSET + 0x00)
> +#define DP_DC_IRQ_SET (DP_DC_OFFSET + 0x04)
> +#define DP_DC_IRQ_MASK (DP_DC_OFFSET + 0x08)
> +#define DP_DC_IRQ_CLEAR (DP_DC_OFFSET + 0x0C)
> +#define DP_DC_CONTROL (DP_DC_OFFSET + 0x10)
> +#define DP_DC_CONFIG_VALID (DP_DC_OFFSET + 0x14)
> +#define DP_DC_CORE_ID (DP_DC_OFFSET + 0x18)
> +
> +// DP500 has a global configuration register.
> +#define DP_DP500_CONFIG_VALID (0xF00)
> +
> +// Display core ID register offsets.
> +#define DP_DC_ID_OFFSET 0x0FF00
> +#define DP_DC_ID_PERIPHERAL_ID4 (DP_DC_ID_OFFSET + 0xD0)
> +#define DP_DC_CONFIGURATION_ID (DP_DC_ID_OFFSET + 0xD4)
> +#define DP_DC_PERIPHERAL_ID0 (DP_DC_ID_OFFSET + 0xE0)
> +#define DP_DC_PERIPHERAL_ID1 (DP_DC_ID_OFFSET + 0xE4)
> +#define DP_DC_PERIPHERAL_ID2 (DP_DC_ID_OFFSET + 0xE8)
> +#define DP_DC_COMPONENT_ID0 (DP_DC_ID_OFFSET + 0xF0)
> +#define DP_DC_COMPONENT_ID1 (DP_DC_ID_OFFSET + 0xF4)
> +#define DP_DC_COMPONENT_ID2 (DP_DC_ID_OFFSET + 0xF8)
> +#define DP_DC_COMPONENT_ID3 (DP_DC_ID_OFFSET + 0xFC)
> +
> +#define DP_DP500_ID_OFFSET 0x0F00
> +#define DP_DP500_ID_PERIPHERAL_ID4 (DP_DP500_ID_OFFSET + 0xD0)
> +#define DP_DP500_CONFIGURATION_ID (DP_DP500_ID_OFFSET + 0xD4)
> +#define DP_DP500_PERIPHERAL_ID0 (DP_DP500_ID_OFFSET + 0xE0)
> +#define DP_DP500_PERIPHERAL_ID1 (DP_DP500_ID_OFFSET + 0xE4)
> +#define DP_DP500_PERIPHERAL_ID2 (DP_DP500_ID_OFFSET + 0xE8)
> +#define DP_DP500_COMPONENT_ID0 (DP_DP500_ID_OFFSET + 0xF0)
> +#define DP_DP500_COMPONENT_ID1 (DP_DP500_ID_OFFSET + 0xF4)
> +#define DP_DP500_COMPONENT_ID2 (DP_DP500_ID_OFFSET + 0xF8)
> +#define DP_DP500_COMPONENT_ID3 (DP_DP500_ID_OFFSET + 0xFC)
> +
> +// Display status configuration mode activation flag
> +#define DP_DC_STATUS_CM_ACTIVE_FLAG (0x1U << 16)
> +
> +// Display core control configuration mode
> +#define DP_DC_CONTROL_SRST_ACTIVE (0x1U << 18)
> +#define DP_DC_CONTROL_CRST_ACTIVE (0x1U << 17)
> +#define DP_DC_CONTROL_CM_ACTIVE (0x1U << 16)
> +
> +#define DP_DE_DP500_CONTROL_SOFTRESET_REQ (0x1U << 16)
> +#define DP_DE_DP500_CONTROL_CONFIG_REQ (0x1U << 17)
> +
> +// Display core configuration valid register
> +#define DP_DC_CONFIG_VALID_CVAL (0x1U)
> +
> +/* DC_CORE_ID
> + * Display core version register PRODUCT_ID
> + */
> +#define DP_DC_CORE_ID_SHIFT 16
> +#define DP_DE_DP500_CORE_ID_SHIFT DP_DC_CORE_ID_SHIFT
> +
> +// Timing settings
> +#define DP_DE_HBACKPORCH_SHIFT 16
> +#define DP_DE_VBACKPORCH_SHIFT 16
> +#define DP_DE_VSP_SHIFT 28
> +#define DP_DE_VSYNCWIDTH_SHIFT 16
> +#define DP_DE_HSP_SHIFT 13
> +#define DP_DE_V_ACTIVE_SHIFT 16
> +
> +// BACKGROUND_COLOR
> +#define DP_DE_BG_R_PIXEL_SHIFT 16
> +#define DP_DE_BG_G_PIXEL_SHIFT 8
> +
> +//Graphics layer LG_FORMAT Pixel Format
> +#define DP_PIXEL_FORMAT_ARGB_8888 0x8
> +#define DP_PIXEL_FORMAT_ABGR_8888 0x9
> +#define DP_PIXEL_FORMAT_RGBA_8888 0xA
> +#define DP_PIXEL_FORMAT_BGRA_8888 0xB
> +#define DP_PIXEL_FORMAT_XRGB_8888 0x10
> +#define DP_PIXEL_FORMAT_XBGR_8888 0x11
> +#define DP_PIXEL_FORMAT_RGBX_8888 0x12
> +#define DP_PIXEL_FORMAT_BGRX_8888 0x13
> +#define DP_PIXEL_FORMAT_RGB_888 0x18
> +#define DP_PIXEL_FORMAT_BGR_888 0x19
> +
> +// DP500 format code are different than DP550/DP650
> +#define DP_PIXEL_FORMAT_DP500_ARGB_8888 0x2
> +#define DP_PIXEL_FORMAT_DP500_ABGR_8888 0x3
> +#define DP_PIXEL_FORMAT_DP500_XRGB_8888 0x4
> +#define DP_PIXEL_FORMAT_DP500_XBGR_8888 0x5
> +
> +// Graphics layer LG_PTR_LOW and LG_PTR_HIGH
> +#define DP_DE_LG_PTR_LOW_MASK 0xFFFFFFFFU
> +#define DP_DE_LG_PTR_HIGH_SHIFT 32
> +
> +// Graphics layer LG_CONTROL register characteristics
> +#define DP_DE_LG_L_ALPHA_SHIFT 16
> +#define DP_DE_LG_CHK_SHIFT 15
> +#define DP_DE_LG_PMUL_SHIFT 14
> +#define DP_DE_LG_COM_SHIFT 12
> +#define DP_DE_LG_VFP_SHIFT 11
> +#define DP_DE_LG_HFP_SHIFT 10
> +#define DP_DE_LG_ROTATION_SHIFT 8
> +
> +#define DP_DE_LG_LAYER_BLEND_NO_BG 0x0U
> +#define DP_DE_LG_PIXEL_BLEND_NO_BG 0x1U
> +#define DP_DE_LG_LAYER_BLEND_BG 0x2U
> +#define DP_DE_LG_PIXEL_BLEND_BG 0x3U
> +#define DP_DE_LG_ENABLE 0x1U
> +
> +// Graphics layer LG_IN_SIZE register characteristics
> +#define DP_DE_LG_V_IN_SIZE_SHIFT 16
> +
> +// Graphics layer LG_CMP_SIZE register characteristics
> +#define DP_DE_LG_V_CMP_SIZE_SHIFT 16
> +#define DP_DE_LG_V_OFFSET_SHIFT 16
> +
> +// Helper display timing macro functions.
> +#define H_INTERVALS(Hfp, Hbp) ((Hbp << DP_DE_HBACKPORCH_SHIFT) | Hfp)
> +#define V_INTERVALS(Vfp, Vbp) ((Vbp << DP_DE_VBACKPORCH_SHIFT) | Vfp)
> +#define SYNC_WIDTH(Hsw, Vsw) ((Vsw << DP_DE_VSYNCWIDTH_SHIFT) | Hsw)
> +#define HV_ACTIVE(Hor, Ver) ((Ver << DP_DE_V_ACTIVE_SHIFT) | Hor)
> +
> +// Helper layer graphics macros.
> +#define FRAME_IN_SIZE(Hor, Ver) ((Ver << DP_DE_LG_V_IN_SIZE_SHIFT) | Hor)
> +#define FRAME_CMP_SIZE(Hor, Ver) ((Ver << DP_DE_LG_V_CMP_SIZE_SHIFT) | Hor)
> +
> +#endif /* ARMMALIDP_H_ */
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..81924cc41f5898605038a1bc20af096fbb85d81c
> --- /dev/null
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
> @@ -0,0 +1,377 @@
> +/** @file ArmMaliDpLib.c
> +*
> +* The file contains ARM Mali DP platform specific implementation.
> +*
> +* Copyright (c) 2017, ARM Ltd. All rights reserved.
> +*
> +* This program and the accompanying materials
> +* are licensed and made available under the terms and conditions of the BSD License
> +* which accompanies this distribution. The full text of the license may be found at
> +* http://opensource.org/licenses/bsd-license.php
> +*
> +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +*
> +**/
> +#include <PiDxe.h>
> +#include <Library/PcdLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/DxeServicesTableLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/LcdPlatformLib.h>
Please sort alphabetically (at least within the Library/ ones).
> +#include <ArmPlatform.h>
> +
> +/** Check an address is within 40 bits.
> + *
> + * The ARM Mali DP frame buffer address size can not be wider than 40 bits
> +**/
> +#define DP_VALID_BASE_ADDR(Address) ((Address >> 40) == 0)
> +
> +typedef struct {
> + UINT32 Mode;
> + UINT32 OscFreq;
> + SCAN_TIMINGS Horizontal;
> + SCAN_TIMINGS Vertical;
> +} DISPLAY_MODE;
> +
> +/** The display modes implemented by this driver.
> + *
> + * On Models, the OSC frequencies (listed for each mode below) are not used.
> + * However these frequencies are useful on hardware plaforms where related
> + * clock (or PLL) settings are based on these pixel clocks.
> + *
> + * Since the clock settings are defined externally, the driver must
> + * communicate pixel clock frequencies to relevant modules
> + * responsible for setting clocks. e.g. SCP.
> +**/
> +STATIC CONST DISPLAY_MODE mDisplayModes[] = {
> + {
> + // Mode 0 : VGA : 640 x 480 x 24 bpp.
> + VGA,
> + VGA_OSC_FREQUENCY,
> + {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> + {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 1 : WVGA : 800 x 480 x 24 bpp.
> + WVGA,
> + WVGA_OSC_FREQUENCY,
> + {WVGA_H_RES_PIXELS, WVGA_H_SYNC, WVGA_H_BACK_PORCH, WVGA_H_FRONT_PORCH},
> + {WVGA_V_RES_PIXELS, WVGA_V_SYNC, WVGA_V_BACK_PORCH, WVGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 2 : SVGA : 800 x 600 x 24 bpp.
> + SVGA,
> + SVGA_OSC_FREQUENCY,
> + {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> + {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 3 : QHD : 960 x 540 x 24 bpp.
> + QHD,
> + QHD_OSC_FREQUENCY,
> + {QHD_H_RES_PIXELS, QHD_H_SYNC, QHD_H_BACK_PORCH, QHD_H_FRONT_PORCH},
> + {QHD_V_RES_PIXELS, QHD_V_SYNC, QHD_V_BACK_PORCH, QHD_V_FRONT_PORCH}
> + },
> + {
> + // Mode 4 : WSVGA : 1024 x 600 x 24 bpp.
> + WSVGA,
> + WSVGA_OSC_FREQUENCY,
> + {WSVGA_H_RES_PIXELS, WSVGA_H_SYNC, WSVGA_H_BACK_PORCH, WSVGA_H_FRONT_PORCH},
> + {WSVGA_V_RES_PIXELS, WSVGA_V_SYNC, WSVGA_V_BACK_PORCH, WSVGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 5 : XGA : 1024 x 768 x 24 bpp.
> + XGA,
> + XGA_OSC_FREQUENCY,
> + {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> + {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 6 : HD : 1280 x 720 x 24 bpp.
> + HD720,
> + HD720_OSC_FREQUENCY,
> + {HD720_H_RES_PIXELS, HD720_H_SYNC, HD720_H_BACK_PORCH, HD720_H_FRONT_PORCH},
> + {HD720_V_RES_PIXELS, HD720_V_SYNC, HD720_V_BACK_PORCH, HD720_V_FRONT_PORCH}
> + },
> + {
> + // Mode 7 : WXGA : 1280 x 800 x 24 bpp.
> + WXGA,
> + WXGA_OSC_FREQUENCY,
> + {WXGA_H_RES_PIXELS, WXGA_H_SYNC, WXGA_H_BACK_PORCH, WXGA_H_FRONT_PORCH},
> + {WXGA_V_RES_PIXELS, WXGA_V_SYNC, WXGA_V_BACK_PORCH, WXGA_V_FRONT_PORCH}
> + },
> + { // Mode 8 : SXGA : 1280 x 1024 x 24 bpp.
> + SXGA,
> + SXGA_OSC_FREQUENCY,
> + {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
> + {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
> + },
> + { // Mode 9 : WSXGA+ : 1680 x 1050 x 24 bpp.
> + WSXGA,
> + WSXGA_OSC_FREQUENCY,
> + {WSXGA_H_RES_PIXELS, WSXGA_H_SYNC, WSXGA_H_BACK_PORCH, WSXGA_H_FRONT_PORCH},
> + {WSXGA_V_RES_PIXELS,WSXGA_V_SYNC, WSXGA_V_BACK_PORCH, WSXGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 10 : HD : 1920 x 1080 x 24 bpp.
> + HD,
> + HD_OSC_FREQUENCY,
> + {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
> + {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
> + }
> +};
> +
> +/** If PcdArmMaliDpMaxMode is 0, platform supports full range of modes
> + * else platform supports modes from 0 to PcdArmMaliDpMaxMode - 1
> +**/
> +STATIC CONST UINT32 mMaxMode = ((FixedPcdGet32 (PcdArmMaliDpMaxMode) != 0)
> + ? FixedPcdGet32 (PcdArmMaliDpMaxMode)
> + : sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
> +
> +
> +/** Platform related initialization function.
> + *
> + * @retval EFI_SUCCESS Platform initialization success.
> + * @retval EFI_UNSUPPORTED PcdGopPixelFormat must be
> + * PixelRedGreenBlueReserved8BitPerColor OR
> + * PixelBlueGreenRedReserved8BitPerColor
> + * any other format is not supported.
> +**/
> +EFI_STATUS
> +LcdPlatformInitializeDisplay (
> + IN CONST EFI_HANDLE Handle
> + )
> +{
> + EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
> +
> + (VOID)Handle;
> +
> + // PixelBitMask and PixelBltOnly pixel formats are not supported
> + PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> + if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
> + && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
> +
> + ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
> + || PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
> + return EFI_UNSUPPORTED;
> + }
This is the same sequence I asked for the existing drivers if it could
be a common function, isn't it?
Could it? :)
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Reserve VRAM memory in DRAM for the frame buffer
> + *
> + * (unless it is reserved already).
> + *
> + * The allocated address can be used to set the frame buffer as a base buffer
> + * address for any layer of the ARM Mali DP.
> + *
> + * @param OUT VramBaseAddress A pointer to the frame buffer address.
> + * @param OUT VramSize A pointer to the size of the frame
> + * buffer in bytes
> + *
> + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize are NULL.
> + * @retval EFI_UNSUPPORTED Allocated address wider than 40 bits
> + * @retval !EFI_SUCCESS Other errors.
> +**/
> +EFI_STATUS
> +LcdPlatformGetVram (
> + OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> + OUT UINTN * CONST VramSize
> + )
> +{
> + EFI_STATUS Status;
> +
> + // Check VramBaseAddress and VramSize are not NULL.
> + if (VramBaseAddress == NULL || VramSize == NULL) {
> + ASSERT (VramBaseAddress != NULL);
> + ASSERT (VramSize != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + // Set the VRAM size.
> + *VramSize = (UINTN)FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
> +
> + // Check if memory is already reserved for the frame buffer.
> +#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
This conditional adds a lot of complexity (and length) to this
function. Can we instead break this out into a conditionally-selected
helper function?
So, here we get:
Status = GetVramBuffer (VramBaseAddress, VramSize);
(or even return GetVramBuffer();)
Then somewhere above, we get
STATIC
EFI_STATUS
GetVramBuffer (
OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
OUT UINTN * CONST VramSize
)
#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
#if (!DP_VALID_BASE_ADDR (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase)))
#error ARM Mali DP frame buffer base address cannot be wider than
#endif
{
// VRAM already allocated - return it directly
*VramBaseAddress =
(EFI_PHYSICAL_ADDRESS)FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
return EFI_SUCCESS;
}
#else
{
EFI_STATUS Status;
// Attempt to allocate the VRAM from the DRAM.
Status = gBS->AllocatePages (
AllocateAnyPages,
EfiBootServicesData,
EFI_SIZE_TO_PAGES (*VramSize),
VramBaseAddress
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "ArmMaliDpLib: Failed to allocate frame
buffer.\n"));
ASSERT_EFI_ERROR (Status);
return Status;
}
// ARM Mali DP frame buffer base address can not be wider than 40
// bits.
if (!DP_VALID_BASE_ADDR (*VramBaseAddress)) {
gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
gBS->(*VramSize));
ASSERT (DP_VALID_BASE_ADDR (*VramBaseAddress));
return EFI_UNSUPPORTED;
}
/* Mark the VRAM as write-combining. The VRAM is inside the DRAM,
which is cacheable.
* For ARM/AArch64 EFI_MEMORY_WC memory is actually uncached.
*/
Status = gDS->SetMemorySpaceAttributes (
*VramBaseAddress,
*VramSize,
EFI_MEMORY_WC
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
gBS->(*VramSize));
}
}
#endif
?
> +
> +#if (!DP_VALID_BASE_ADDR (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase)))
> +#error ARM Mali DP frame buffer base address cannot be wider than 40 bits.
> +#else
> +
> + *VramBaseAddress =
> + (EFI_PHYSICAL_ADDRESS)FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> +
> + Status = EFI_SUCCESS;
> +#endif
> +
> +#else
> + // If not already reserved, attempt to allocate the VRAM from the DRAM.
> + Status = gBS->AllocatePages (
> + AllocateAnyPages,
> + EfiBootServicesData,
> + EFI_SIZE_TO_PAGES (*VramSize),
> + VramBaseAddress
> + );
> +
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "ArmMaliDpLib: Failed to allocate frame buffer.\n"));
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> +
> + // ARM Mali DP frame buffer base address can not be wider than 40 bits.
> + if (!DP_VALID_BASE_ADDR (*VramBaseAddress)) {
> + gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> + ASSERT (DP_VALID_BASE_ADDR (*VramBaseAddress));
> + return EFI_UNSUPPORTED;
> + }
> +
> + /* Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.
> + * For ARM/AArch64 EFI_MEMORY_WC memory is actually uncached.
> + */
> + Status = gDS->SetMemorySpaceAttributes (
> + *VramBaseAddress,
> + *VramSize,
> + EFI_MEMORY_WC
> + );
> +
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> + }
> +
> +#endif
> + return Status;
> +}
> +
> +/** Return total number of modes supported.
> + *
> + * Note: Valid mode numbers are 0 to MaxMode - 1
> + * See Section 12.9 of the UEFI Specification 2.7
> + *
> + * @retval UINT32 Mode Number.
> +**/
> +UINT32
> +LcdPlatformGetMaxMode (VOID)
> +{
> + return mMaxMode;
> +}
> +
> +/** Set the requested display mode.
> + *
> + * @param IN ModeNumber Mode Number.
> + *
> + * @retval EFI_SUCCESS Set mode success.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> +EFI_STATUS
> +LcdPlatformSetMode (
> + IN CONST UINT32 ModeNumber
> + )
> +{
> +
> + if (ModeNumber >= mMaxMode) {
> + ASSERT (ModeNumber < mMaxMode);
> + return EFI_INVALID_PARAMETER;
> + }
> + /* On models, platform specific clock/mux settings are not required
> + * Display controller specific settings for Mali DP are done in LcdSetMode.
> + */
> + return EFI_SUCCESS;
> +}
> +
> +/** Return information for the requested mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Info Pointer for returned mode information
> + * (on success).
> + *
> + * @retval EFI_SUCCESS Requested mode found.
> + * @retval EFI_INVALID_PARAMETER Info is NULL.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> +EFI_STATUS
> +LcdPlatformQueryMode (
> + IN CONST UINT32 ModeNumber,
> + OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> + )
> +{
> + if (ModeNumber >= mMaxMode || Info == NULL) {
> + ASSERT (ModeNumber < mMaxMode);
> + ASSERT (Info != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + Info->Version = 0;
> + Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
> + Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
> + Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
> +
> + Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Returns the display timing information for the requested mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Horizontal Pointer to horizontal timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> + * @param OUT Vertical Pointer to vertical timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> + *
> + * @retval EFI_SUCCESS Requested mode found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER One of the OUT parameters is NULL.
> +**/
> +EFI_STATUS
> +LcdPlatformGetTimings (
> + IN UINT32 ModeNumber,
> + OUT CONST SCAN_TIMINGS ** Horizontal,
> + OUT CONST SCAN_TIMINGS ** Vertical
> + )
> +{
> + if (ModeNumber >= mMaxMode || Horizontal == NULL || Vertical == NULL) {
> + ASSERT (ModeNumber < mMaxMode);
> + // One of the pointers is NULL
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
> + *Vertical = &mDisplayModes[ModeNumber].Vertical;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return bytes per pixel information for a mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Bpp Pointer to value Bytes Per Pixel.
> + *
> + * @retval EFI_SUCCESS The requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> +**/
> +EFI_STATUS
> +LcdPlatformGetBpp (
> + IN CONST UINT32 ModeNumber,
> + OUT LCD_BPP * CONST Bpp
> + )
> +{
> + if (ModeNumber >= mMaxMode || Bpp == NULL) {
> + // Check valid ModeNumber and Bpp.
> + ASSERT (ModeNumber < mMaxMode);
> + ASSERT (Bpp != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + *Bpp = LCD_BITS_PER_PIXEL_24;
> +
> + return EFI_SUCCESS;
> +}
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> index 5cd529750a3d2d3b0d381b58d875d378afaba2c2..87a7a26132e39b933ecd2a95e38b2ab869cd4079 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> @@ -21,9 +21,10 @@
> #include <ArmPlatform.h>
>
> #define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
> +#define DP_BASE_DESCRIPTOR ((FixedPcdGet64 (PcdArmMaliDpBase) != 0) ? 1 : 0)
>
> // Number of Virtual Memory Map Descriptors
> -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR)
> +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR + DP_BASE_DESCRIPTOR)
>
> // DDR attributes
> #define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
> @@ -159,6 +160,13 @@ ArmPlatformGetVirtualMemoryMap (
> VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
> #endif
>
> +#if (FixedPcdGet64 (PcdArmMaliDpBase) != 0)
> + // DP500/DP550/DP650 peripheral memory region
> + VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdArmMaliDpBase);
> + VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdArmMaliDpBase);
> + VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdArmMaliDpMemoryRegionLength);
> + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> +#endif
> // Map sparse memory region if present
> if (HasSparseMemory) {
> VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
> diff --git a/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..ff7236371d27915d9f1e34162dce0954dde63a77
> --- /dev/null
> +++ b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c
> @@ -0,0 +1,412 @@
> +/** @file ArmMaliDp.c
> +
> + ARM Mali DP 500/550/650 display controller driver
> +
> + Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
> +
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD License
> + which accompanies this distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <Library/IoLib.h>
> +#include <Library/DebugLib.h>
Swap above two lines?
> +#include <Library/LcdPlatformLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Drivers/ArmMaliDp.h>
> +#include <Drivers/LcdHw.h>
> +
> +// CORE_ID of the MALI DP
> +STATIC UINT32 gDpDeviceId;
> +
> +/** Disable the graphics layer
> + *
> + * This is done by clearing the EN bit
> + * of the LG_CONTROL register.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsDisable (VOID)
> +{
> + MmioAnd32 (DP_BASE + DP_DE_LG_CONTROL, ~DP_DE_LG_ENABLE);
> +}
> +
> +/** Enable the graphics layer
> + *
> + * This is done by setting the EN bit
> + * of the LG_CONTROL register.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsEnable (VOID)
> +{
> + MmioOr32 (DP_BASE + DP_DE_LG_CONTROL, DP_DE_LG_ENABLE);
> +}
> +
> +/** Set the frame address of the graphics layer.
> + *
> + * @param FrameBaseAddress Address of the data buffer
> + * to be used as a frame buffer.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsSetFrame (
> + IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
> + )
> +{
> + // Disable the graphics layer.
> + LayerGraphicsDisable ();
> +
> + /* Set up memory address of the data buffer for graphics layer.
> + * write lower bits of the address.
> + */
> + MmioWrite32 (
> + DP_BASE + DP_DE_LG_PTR_LOW,
> + DP_DE_LG_PTR_LOW_MASK & FrameBaseAddress
> + );
> +
> + // Write higher bits of the address.
> + MmioWrite32 (
> + DP_BASE + DP_DE_LG_PTR_HIGH,
> + (UINT32)(FrameBaseAddress >> DP_DE_LG_PTR_HIGH_SHIFT)
> + );
> +
> + // Enable the graphics layer.
> + LayerGraphicsEnable ();
> +}
> +
> +/** Configures various graphics layer characteristics.
> + *
> + * @param HRes Horizontal resolution of the graphics layer.
> + * @param VRes Vertical resolution of the graphics layer.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsConfig (
> + IN CONST EFI_GRAPHICS_PIXEL_FORMAT UefiGfxPixelFormat,
> + IN CONST UINT32 HRes,
> + IN CONST UINT32 VRes
> + )
> +{
> + UINT32 PixelFormat;
> +
> + // Disable the graphics layer before configuring any settings.
> + LayerGraphicsDisable ();
> +
> + // Setup graphics layer size.
> + MmioWrite32 (DP_BASE + DP_DE_LG_IN_SIZE, FRAME_IN_SIZE (HRes, VRes));
> +
> + // Setup graphics layer composition size.
> + MmioWrite32 (DP_BASE + DP_DE_LG_CMP_SIZE, FRAME_CMP_SIZE (HRes, VRes));
> +
> + // Setup memory stride (total visible pixels on a line * 4 ).
> + MmioWrite32 (DP_BASE + DP_DE_LG_H_STRIDE, (HRes * sizeof (UINT32)));
> +
> + /* Set the format.
> + *
> + * In PixelBlueGreenRedReserved8BitPerColor format, byte 0 represents blue,
> + * byte 1 represents green, and byte 2 represents red, and byte 3 is reserved
> + * which is equivalent to XRGB format of the DP500/DP550/DP650. Whereas
> + * PixelRedGreenBlueReserved8BitPerColor is equivalent to XBGR of the
> + * DP500/DP550/DP650.
> + */
> + if (UefiGfxPixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
> + PixelFormat = (gDpDeviceId == MALIDP_500) ? DP_PIXEL_FORMAT_DP500_XRGB_8888
> + : DP_PIXEL_FORMAT_XRGB_8888;
> + } else {
> + PixelFormat = (gDpDeviceId == MALIDP_500) ? DP_PIXEL_FORMAT_DP500_XBGR_8888
> + : DP_PIXEL_FORMAT_XBGR_8888;
> + }
> +
> + MmioWrite32 (DP_BASE + DP_DE_LG_FORMAT, PixelFormat);
> +
> + // Enable graphics layer.
> + LayerGraphicsEnable ();
> +}
> +
> +/** Configure timing information of the display.
> + * @param IN Horizontal Pointer to horizontal timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> + * @param IN Vertical Pointer to vertical timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> +**/
> +STATIC
> +VOID
> +SetDisplayEngineTiming (
> + IN CONST SCAN_TIMINGS * CONST Horizontal,
> + IN CONST SCAN_TIMINGS * CONST Vertical
> + )
> +{
> + UINTN RegHIntervals;
> + UINTN RegVIntervals;
> + UINTN RegSyncControl;
> + UINTN RegHVActiveSize;
> +
> + if (gDpDeviceId == MALIDP_500) {
> + // MALI DP500 timing registers.
> + RegHIntervals = DP_BASE + DP_DE_DP500_H_INTERVALS;
> + RegVIntervals = DP_BASE + DP_DE_DP500_V_INTERVALS;
> + RegSyncControl = DP_BASE + DP_DE_DP500_SYNC_CONTROL;
> + RegHVActiveSize = DP_BASE + DP_DE_DP500_HV_ACTIVESIZE;
> + } else {
> + // MALI DP550/DP650 timing registers.
> + RegHIntervals = DP_BASE + DP_DE_H_INTERVALS;
> + RegVIntervals = DP_BASE + DP_DE_V_INTERVALS;
> + RegSyncControl = DP_BASE + DP_DE_SYNC_CONTROL;
> + RegHVActiveSize = DP_BASE + DP_DE_HV_ACTIVESIZE;
> + }
> +
> + // Horizontal back porch and front porch.
> + MmioWrite32 (
> + RegHIntervals,
> + H_INTERVALS (Horizontal->FrontPorch, Horizontal->BackPorch)
> + );
> +
> + // Vertical back porch and front porch.
> + MmioWrite32 (
> + RegVIntervals,
> + V_INTERVALS (Vertical->FrontPorch, Vertical->BackPorch)
> + );
> +
> + // Sync control, Horizontal and Vertical sync.
> + MmioWrite32 (
> + RegSyncControl,
> + SYNC_WIDTH (Horizontal->Sync, Vertical->Sync)
> + );
> +
> + // Set up Horizontal and Vertical area size.
> + MmioWrite32 (
> + RegHVActiveSize,
> + HV_ACTIVE (Horizontal->Resolution, Vertical->Resolution)
> + );
> +}
> +
> +/** Return CORE_ID of the ARM Mali DP.
> + *
> + * @retval 0 No Mali DP found.
> + * @retval 0x500 Mali DP core id for DP500.
> + * @retval 0x550 Mali DP core id for DP550.
> + * @retval 0x650 Mali DP core id for DP650.
> +**/
> +STATIC
> +UINT32
> +ArmMaliDpGetCoreId (
> + )
> +{
> + UINT32 DpCoreId;
> +
> + /* First check for DP500 as register offset for DP550/DP650 CORE_ID
> + * is beyond 3K/4K register space of the DP500.
> + */
> + DpCoreId = MmioRead32 (DP_BASE + DP_DE_DP500_CORE_ID);
> + DpCoreId >>= DP_DE_DP500_CORE_ID_SHIFT;
> +
> + if (DpCoreId == MALIDP_500) {
> + return DpCoreId;
> + }
> +
> + // Check for DP550 or DP650.
> + DpCoreId = MmioRead32 (DP_BASE + DP_DC_CORE_ID);
> + DpCoreId >>= DP_DC_CORE_ID_SHIFT;
> +
> + if (DpCoreId == MALIDP_550
> + || DpCoreId == MALIDP_650) {
> + return DpCoreId;
> + }
> +
> + return 0;
> +}
> +
> +/** Check for presence of MALI.
> + *
> + * This function returns success if the platform implements
> + * DP500/DP550/DP650 ARM Mali display processor.
> + *
> + * @retval EFI_SUCCESS Platform implements DP500/DP550/DP650.
> + * @retval EFI_NOT_FOUND DP500/DP550/DP650 display processor not
> + * found on the platform.
> +**/
> +EFI_STATUS
> +LcdIdentify (VOID)
> +{
> + UINT32 DpCoreId;
> +
> + DEBUG ((DEBUG_WARN,
> + "Probing ARM Mali DP500/DP550/DP650 at base address 0x%p\n",
> + DP_BASE
> + ));
> +
> +#if (DP_BASE == 0)
> +#error "ARM Mali DP peripheral base address is invalid\n"
No quotes and \n on a #error.
Also, would it not make sense to place this one before its first use
in this function?
> +#endif
> +
> + DpCoreId = ArmMaliDpGetCoreId ();
> +
> + if (DpCoreId != 0) {
> + DEBUG ((DEBUG_WARN, "Found ARM Mali DP %x\n", DpCoreId));
> + return EFI_SUCCESS;
> + }
> +
> + DEBUG ((DEBUG_WARN, "ARM Mali DP not found...\n"));
> +
> + return EFI_NOT_FOUND;
> +}
> +
> +/** Initialize platform display.
> + *
> + * @param FrameBaseAddress Address of the frame buffer.
> + *
> + * @retval EFI_SUCCESS Display initialization success.
> + * @retval !(EFI_SUCCESS) Display initialization failure.
> +**/
> +EFI_STATUS
> +LcdInitialize (
> + IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
> + )
> +{
> + DEBUG ((DEBUG_WARN, "Frame buffer base address = %p\n", FrameBaseAddress));
> +
> + gDpDeviceId = ArmMaliDpGetCoreId ();
> + if (gDpDeviceId == 0) {
> + DEBUG ((DEBUG_ERROR, "ARM Mali DP initialization fail,"
> + "no ARM Mali DP present\n"));
> + return EFI_NOT_FOUND;
> + }
> +
> + // We are using graphics layer of the Mali DP as a main frame buffer.
> + LayerGraphicsSetFrame (FrameBaseAddress);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Set ARM Mali DP in cofiguration mode.
> + *
> + * The ARM Mali DP must be in the configuration mode for
> + * configuration of the H_INTERVALS, V_INTERVALS, SYNC_CONTROL
> + * and HV_ACTIVESIZE.
> +**/
> +STATIC
> +VOID
> +SetConfigurationMode (VOID)
> +{
> + // Request configuration Mode.
> + if (gDpDeviceId == MALIDP_500) {
> + MmioOr32 (DP_BASE + DP_DE_DP500_CONTROL, DP_DE_DP500_CONTROL_CONFIG_REQ);
> + } else {
> + MmioOr32 (DP_BASE + DP_DC_CONTROL, DP_DC_CONTROL_CM_ACTIVE);
> + }
> +}
> +
> +/** Set ARM Mali DP in normal mode.
> + *
> + * Normal mode is the main operating mode of the display processor
> + * in which display layer data is fetched from frame buffer and
> + * displayed.
> +**/
> +STATIC
> +VOID
> +SetNormalMode (VOID)
> +{
> + // Disable configuration Mode.
> + if (gDpDeviceId == MALIDP_500) {
> + MmioAnd32 (DP_BASE + DP_DE_DP500_CONTROL, ~DP_DE_DP500_CONTROL_CONFIG_REQ);
> + } else {
> + MmioAnd32 (DP_BASE + DP_DC_CONTROL, ~DP_DC_CONTROL_CM_ACTIVE );
There is a stray space character before close parentheses copied into
the else branch in this and the next function.
> + }
> +}
> +
> +/** Set the global configuration valid flag.
> + *
> + * Any new configuration parameters written to the display engine are not
> + * activated until the global configuration valid flag is set in the
> + * CONFIG_VALID register.
> +**/
> +STATIC
> +VOID
> +SetConfigValid (VOID)
> +{
> + if (gDpDeviceId == MALIDP_500) {
> + MmioOr32 (DP_BASE + DP_DP500_CONFIG_VALID, DP_DC_CONFIG_VALID);
> + } else {
> + MmioOr32 (DP_BASE + DP_DC_CONFIG_VALID, DP_DC_CONFIG_VALID );
Here too.
/
Leif
> + }
> +}
> +
> +/** Set requested mode of the display.
> + *
> + * @param ModeNumber Display mode number.
> + * @retval EFI_SUCCESS Display set mode success.
> + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> + * @retval EFI_DEVICE_ERROR If mode does not support more
> + * than 24 bytes per pixel format.
> +**/
> +EFI_STATUS
> +LcdSetMode (
> + IN CONST UINT32 ModeNumber
> + )
> +{
> + EFI_STATUS Status;
> + CONST SCAN_TIMINGS *Horizontal;
> + CONST SCAN_TIMINGS *Vertical;
> +
> + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
> +
> + // Get the display mode timings and other relevant information.
> + Status = LcdPlatformGetTimings (
> + ModeNumber,
> + &Horizontal,
> + &Vertical
> + );
> +
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
> +
> + // Get the pixel format information.
> + Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> +
> + // Request configuration mode.
> + SetConfigurationMode ();
> +
> + // Configure the graphics layer.
> + LayerGraphicsConfig (
> + ModeInfo.PixelFormat,
> + Horizontal->Resolution,
> + Vertical->Resolution
> + );
> +
> + // Set the display engine timings.
> + SetDisplayEngineTiming (Horizontal, Vertical);
> +
> + // After configuration, set Mali DP in normal mode.
> + SetNormalMode ();
> +
> + /* Any parameters written to the display engine are not activated until
> + * CONFIG_VALID is set.
> + */
> + SetConfigValid ();
> +
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + * This function de-initializes the display.
> +**/
> +VOID
> +LcdShutdown (VOID)
> +{
> + // Disable graphics layer.
> + LayerGraphicsDisable ();
> +}
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver.
2017-09-26 20:15 ` [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver evan.lloyd
2017-10-25 15:31 ` Leif Lindholm
@ 2017-11-28 18:17 ` Ard Biesheuvel
2017-12-01 13:12 ` Evan Lloyd
1 sibling, 1 reply; 69+ messages in thread
From: Ard Biesheuvel @ 2017-11-28 18:17 UTC (permalink / raw)
To: Evan Lloyd
Cc: edk2-devel@lists.01.org, Matteo Carlini, Leif Lindholm,
Girish Pathak
On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> From: Girish Pathak <girish.pathak@arm.com>
>
> This change adds support for the ARM Mali DP500/DP500/DP650 display
> processors using the GOP protocol. It has been tested on FVP base
> models + DP550 support.
>
> This change does not modify functionality provided by PL111 or
> HDLCD. The driver should be suitable for those platforms
> that implement ARM Mali DP500/DP550/DP650 replacing PL111/HDLCD.
>
> Only "Layer Graphics" of the ARM Mali DP is configured for rendering
> the RGB/BGR format frame buffer to satisfy the UEFI GOP requirements
> Other layers e.g. video layers are not configured.
>
> NOTE: This change implements the Mali DP on models. Versions for actual
> hardware are liable to require extra handling for clock input changes,
> etc.
>
> 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>
Hello Girish, Evan,
(replying to 19/19 because I cannot find the cover letter in my
edk2-devel archive but this really applies to the whole series)
I have been looking at these patches again now that I am trying to
clean up ArmPlatformPkg, which is currently a dumping ground for all
things vaguely ARM related, and is also structured quite differently
from other packages.
Ideally, ArmPlatformPkg should only contain the following:
- library class interfaces under Include/Library; header files kept
here should only contain elements that define API
- driver specific include files Include/IndustryStandard but *only* if
they cannot be kept locally with the driver in question
- libraries under Library/
- drivers under Drivers/
This aligns with the common arrangement adopted by most EDK2 packages.
This series does many different things, and does not distinguish at
all between common code and code living under ArmVExpressPkg. Given
that I am trying to move ArmVExpressPkg out of EDK2 into
edk2-platforms (where it arguably belongs) having this series in limbo
for two months is basically blocking my work, and so I would like to
explore ways to proceed with this without interfering with each
other's work too much. At the same time, the way the code is
structured is a continuation of the pattern I am trying to get rid of,
so they will need some rework anyway in order to be upstreamable IMHO.
So could we split it up please? Assuming the intention is the ability
to reuse the Mali code on non-VExpress platforms, I would like to see
that code proposed separately, without any mention of VExpressPkg.dec
whatsoever. If you introduce any library classes that abstract away
the differences between platforms, you can include a Null version of
such a library that simply does ASSERT (FALSE) in every function: this
allows the driver to be built standalone, and at the same time, forces
you to keep the abstractions pure. I intend to create a separate
ArmPlatformPkg.dsc platform description for CI purposes that covers
all drivers and libraries that remain after the refactor, and that
requires Null implementations of libraries that have no implementation
upstream.
Beyond that, it would be a matter of separating the cleanup patches
from the Mali platform support being added to VExpressPkg. The latter
could wait until the moment where the support is actually made live
and wired into an actual (physical or virtual) platform.
Please let me know what you think,
Regards,
Ard.
> ---
> ArmPlatformPkg/ArmPlatformPkg.dec | 4 +
> ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec | 4 +-
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf | 45 +++
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf | 3 +
> ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf | 44 +++
> ArmPlatformPkg/Include/Drivers/ArmMaliDp.h | 249 ++++++++++++
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c | 377 ++++++++++++++++++
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c | 10 +-
> ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c | 412 ++++++++++++++++++++
> 9 files changed, 1146 insertions(+), 2 deletions(-)
>
> diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec b/ArmPlatformPkg/ArmPlatformPkg.dec
> index 0174f63e77f5b8430e106289366feb9a6577fb99..3be236413cb8e12ce32e6349732d2767fe0f3024 100644
> --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -111,6 +111,10 @@ [PcdsFixedAtBuild.common]
> gArmPlatformTokenSpaceGuid.PcdPL111LcdBase|0x0|UINT32|0x00000026
> gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x0|UINT32|0x00000027
>
> + ## ARM Mali Display Processor DP500/DP550/DP650
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase|0x0|UINT64|0x00000050
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength|0x0|UINT32|0x00000051
> +
> ## If set, frame buffer memory will be reserved and mapped in the system RAM
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x0|UINT32|0x00000033
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT64|0x00000034
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> index 3814513c2241c03a8c45fda92d571c65368f64b4..1a55b0434ab4bc53d631be2bffd313684bcea9c4 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> @@ -1,7 +1,7 @@
> #/** @file
> # Arm Versatile Express package.
> #
> -# Copyright (c) 2012-2015, ARM Limited. All rights reserved.
> +# Copyright (c) 2012-2017, ARM Limited. All rights reserved.
> #
> # This program and the accompanying materials are licensed and made available
> # under the terms and conditions of the BSD License which accompanies this
> @@ -47,6 +47,8 @@ [PcdsFixedAtBuild.common]
> gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId|1|UINT32|0x00000002
> gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId|0|UINT32|0x00000003
>
> + gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode|0x0|UINT32|0x00000005
> +
> #
> # Device path of block device on which Fastboot will flash partitions
> #
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
> new file mode 100644
> index 0000000000000000000000000000000000000000..b85205a8ac6bfbd8befdd8634a7df89e213175bc
> --- /dev/null
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.inf
> @@ -0,0 +1,45 @@
> +#/** @file ArmMaliDpLib.inf
> +#
> +# Component description file for ArmMaliDpLib module
> +#
> +# Copyright (c) 2017, ARM Limited. All rights reserved.
> +#
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#**/
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = ArmMaliDpLib
> + FILE_GUID = 36C47FED-2F3F-49C7-89CE-31B13F0431D8
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = LcdPlatformLib
> +
> +[Sources.common]
> + ArmMaliDpLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> + ArmPlatformPkg/ArmPlatformPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + DxeServicesTableLib
> +
> +[FixedPcd.common]
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
> + gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
> +
> + # MaxMode must be one number higher than the actual max mode,
> + # i.e. for actual maximum mode 2, set the value to 3.
> + # See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan 2017)
> + gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode
> +
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> index 60789e9b8ff1b936db04953a765fb164b0e85a40..6ad7d94c8c76404c8a84345b5f992884ab5aca36 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLib.inf
> @@ -60,5 +60,8 @@ [FixedPcd]
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
>
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength
> +
> [Ppis]
> gArmMpCoreInfoPpiGuid
> diff --git a/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf
> new file mode 100644
> index 0000000000000000000000000000000000000000..69155a123ef71ecf5361ab29e0ae71454c7ec6cd
> --- /dev/null
> +++ b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf
> @@ -0,0 +1,44 @@
> +#/** @file ArmMaliDp.inf
> +#
> +# Component description file for ArmMaliDp module
> +#
> +# Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
> +# This program and the accompanying materials
> +# are licensed and made available under the terms and conditions of the BSD License
> +# which accompanies this distribution. The full text of the license may be found at
> +# http://opensource.org/licenses/bsd-license.php
> +#
> +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#**/
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = ArmMaliDp
> + FILE_GUID = E724AAF7-19E2-40A3-BAE1-D82A7C8B7A76
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = LcdHwLib
> +
> +[Sources.common]
> + ArmMaliDp.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + ArmPkg/ArmPkg.dec
> + ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> + ArmPlatformPkg/ArmPlatformPkg.dec
> +
> +[LibraryClasses]
> + UefiLib
> + BaseLib
> + DebugLib
> + IoLib
> + BaseMemoryLib
> + LcdPlatformLib
> +
> +[FixedPcd]
> + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
> +
> diff --git a/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h b/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h
> new file mode 100644
> index 0000000000000000000000000000000000000000..4955176800ea59f352399d9c6b590195d4ccfa41
> --- /dev/null
> +++ b/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h
> @@ -0,0 +1,249 @@
> +/** @file ArmMaliDp.h
> +
> + File defines registers and other flags of ARM Mali DP display controller
> +
> + Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD License
> + which accompanies this distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +#ifndef ARMMALIDP_H_
> +#define ARMMALIDP_H_
> +
> +/**********************************************************************
> + *
> + * This header file contains all the bits of the ARM Mali DP that are
> + * platform independent.
> + *
> + **********************************************************************/
> +#define DP_BASE (FixedPcdGet64 (PcdArmMaliDpBase))
> +
> +// MALI DP Ids
> +#define MALIDP_500 0x500
> +#define MALIDP_550 0x550
> +#define MALIDP_650 0x650
> +
> +// DP500 Peripheral Ids
> +#define DP500_ID_PART_0 0x00
> +#define DP500_ID_DES_0 0xB
> +#define DP500_ID_PART_1 0x5
> +
> +#define DP500_ID_REVISION 0x1
> +#define DP500_ID_JEDEC 0x1
> +#define DP500_ID_DES_1 0x3
> +
> +#define DP500_PERIPHERAL_ID0_VAL (DP500_ID_PART_0)
> +#define DP500_PERIPHERAL_ID1_VAL ((DP500_ID_DES_0 << 4) \
> + | DP500_ID_PART_1)
> +#define DP500_PERIPHERAL_ID2_VAL ((DP500_ID_REVISION << 4) \
> + | (DP500_ID_JEDEC << 3) \
> + | (DP500_ID_DES_1))
> +
> +// DP550 Peripheral Ids
> +#define DP550_ID_PART_0 0x50
> +#define DP550_ID_DES_0 0xB
> +#define DP550_ID_PART_1 0x5
> +
> +#define DP550_ID_REVISION 0x0
> +#define DP550_ID_JEDEC 0x1
> +#define DP550_ID_DES_1 0x3
> +
> +#define DP550_PERIPHERAL_ID0_VAL (DP550_ID_PART_0)
> +#define DP550_PERIPHERAL_ID1_VAL ((DP550_ID_DES_0 << 4) \
> + | DP550_ID_PART_1)
> +#define DP550_PERIPHERAL_ID2_VAL ((DP550_ID_REVISION << 4) \
> + | (DP550_ID_JEDEC << 3) \
> + | (DP550_ID_DES_1))
> +
> +// DP650 Peripheral Ids
> +#define DP650_ID_PART_0 0x50
> +#define DP650_ID_DES_0 0xB
> +#define DP650_ID_PART_1 0x6
> +
> +#define DP650_ID_REVISION 0x0
> +#define DP650_ID_JEDEC 0x1
> +#define DP650_ID_DES_1 0x3
> +
> +#define DP650_PERIPHERAL_ID0_VAL (DP650_ID_PART_0)
> +#define DP650_PERIPHERAL_ID1_VAL ((DP650_ID_DES_0 << 4) \
> + | DP650_ID_PART_1)
> +#define DP650_PERIPHERAL_ID2_VAL ((DP650_ID_REVISION << 4) \
> + | (DP650_ID_JEDEC << 3) \
> + | (DP650_ID_DES_1))
> +
> +// Display Engine (DE) control register offsets for DP550/DP650
> +#define DP_DE_STATUS 0x00000
> +#define DP_DE_IRQ_SET 0x00004
> +#define DP_DE_IRQ_MASK 0x00008
> +#define DP_DE_IRQ_CLEAR 0x0000C
> +#define DP_DE_CONTROL 0x00010
> +#define DP_DE_PROG_LINE 0x00014
> +#define DP_DE_AXI_CONTROL 0x00018
> +#define DP_DE_AXI_QOS 0x0001C
> +#define DP_DE_DISPLAY_FUNCTION 0x00020
> +
> +#define DP_DE_H_INTERVALS 0x00030
> +#define DP_DE_V_INTERVALS 0x00034
> +#define DP_DE_SYNC_CONTROL 0x00038
> +#define DP_DE_HV_ACTIVESIZE 0x0003C
> +#define DP_DE_DISPLAY_SIDEBAND 0x00040
> +#define DP_DE_BACKGROUND_COLOR 0x00044
> +#define DP_DE_DISPLAY_SPLIT 0x00048
> +#define DP_DE_OUTPUT_DEPTH 0x0004C
> +
> +// Display Engine (DE) control register offsets for DP500
> +#define DP_DE_DP500_CORE_ID 0x00018
> +#define DP_DE_DP500_CONTROL 0x0000C
> +#define DP_DE_DP500_PROG_LINE 0x00010
> +#define DP_DE_DP500_H_INTERVALS 0x00028
> +#define DP_DE_DP500_V_INTERVALS 0x0002C
> +#define DP_DE_DP500_SYNC_CONTROL 0x00030
> +#define DP_DE_DP500_HV_ACTIVESIZE 0x00034
> +#define DP_DE_DP500_BG_COLOR_RG 0x0003C
> +#define DP_DE_DP500_BG_COLOR_B 0x00040
> +
> +/* Display Engine (DE) graphics layer (LG) register offsets
> + * NOTE: For DP500 it will be LG2.
> + */
> +#define DE_LG_OFFSET 0x00300
> +#define DP_DE_LG_FORMAT (DE_LG_OFFSET)
> +#define DP_DE_LG_CONTROL (DE_LG_OFFSET + 0x04)
> +#define DP_DE_LG_COMPOSE (DE_LG_OFFSET + 0x08)
> +#define DP_DE_LG_IN_SIZE (DE_LG_OFFSET + 0x0C)
> +#define DP_DE_LG_CMP_SIZE (DE_LG_OFFSET + 0x10)
> +#define DP_DE_LG_OFFSET (DE_LG_OFFSET + 0x14)
> +#define DP_DE_LG_H_STRIDE (DE_LG_OFFSET + 0x18)
> +#define DP_DE_LG_PTR_LOW (DE_LG_OFFSET + 0x1C)
> +#define DP_DE_LG_PTR_HIGH (DE_LG_OFFSET + 0x20)
> +#define DP_DE_LG_CHROMA_KEY (DE_LG_OFFSET + 0x2C)
> +#define DP_DE_LG_AD_CONTROL (DE_LG_OFFSET + 0x30)
> +#define DP_DE_LG_MMU_CONTROL (DE_LG_OFFSET + 0x48)
> +
> +// Display core (DC) control register offsets.
> +#define DP_DC_OFFSET 0x0C000
> +#define DP_DC_STATUS (DP_DC_OFFSET + 0x00)
> +#define DP_DC_IRQ_SET (DP_DC_OFFSET + 0x04)
> +#define DP_DC_IRQ_MASK (DP_DC_OFFSET + 0x08)
> +#define DP_DC_IRQ_CLEAR (DP_DC_OFFSET + 0x0C)
> +#define DP_DC_CONTROL (DP_DC_OFFSET + 0x10)
> +#define DP_DC_CONFIG_VALID (DP_DC_OFFSET + 0x14)
> +#define DP_DC_CORE_ID (DP_DC_OFFSET + 0x18)
> +
> +// DP500 has a global configuration register.
> +#define DP_DP500_CONFIG_VALID (0xF00)
> +
> +// Display core ID register offsets.
> +#define DP_DC_ID_OFFSET 0x0FF00
> +#define DP_DC_ID_PERIPHERAL_ID4 (DP_DC_ID_OFFSET + 0xD0)
> +#define DP_DC_CONFIGURATION_ID (DP_DC_ID_OFFSET + 0xD4)
> +#define DP_DC_PERIPHERAL_ID0 (DP_DC_ID_OFFSET + 0xE0)
> +#define DP_DC_PERIPHERAL_ID1 (DP_DC_ID_OFFSET + 0xE4)
> +#define DP_DC_PERIPHERAL_ID2 (DP_DC_ID_OFFSET + 0xE8)
> +#define DP_DC_COMPONENT_ID0 (DP_DC_ID_OFFSET + 0xF0)
> +#define DP_DC_COMPONENT_ID1 (DP_DC_ID_OFFSET + 0xF4)
> +#define DP_DC_COMPONENT_ID2 (DP_DC_ID_OFFSET + 0xF8)
> +#define DP_DC_COMPONENT_ID3 (DP_DC_ID_OFFSET + 0xFC)
> +
> +#define DP_DP500_ID_OFFSET 0x0F00
> +#define DP_DP500_ID_PERIPHERAL_ID4 (DP_DP500_ID_OFFSET + 0xD0)
> +#define DP_DP500_CONFIGURATION_ID (DP_DP500_ID_OFFSET + 0xD4)
> +#define DP_DP500_PERIPHERAL_ID0 (DP_DP500_ID_OFFSET + 0xE0)
> +#define DP_DP500_PERIPHERAL_ID1 (DP_DP500_ID_OFFSET + 0xE4)
> +#define DP_DP500_PERIPHERAL_ID2 (DP_DP500_ID_OFFSET + 0xE8)
> +#define DP_DP500_COMPONENT_ID0 (DP_DP500_ID_OFFSET + 0xF0)
> +#define DP_DP500_COMPONENT_ID1 (DP_DP500_ID_OFFSET + 0xF4)
> +#define DP_DP500_COMPONENT_ID2 (DP_DP500_ID_OFFSET + 0xF8)
> +#define DP_DP500_COMPONENT_ID3 (DP_DP500_ID_OFFSET + 0xFC)
> +
> +// Display status configuration mode activation flag
> +#define DP_DC_STATUS_CM_ACTIVE_FLAG (0x1U << 16)
> +
> +// Display core control configuration mode
> +#define DP_DC_CONTROL_SRST_ACTIVE (0x1U << 18)
> +#define DP_DC_CONTROL_CRST_ACTIVE (0x1U << 17)
> +#define DP_DC_CONTROL_CM_ACTIVE (0x1U << 16)
> +
> +#define DP_DE_DP500_CONTROL_SOFTRESET_REQ (0x1U << 16)
> +#define DP_DE_DP500_CONTROL_CONFIG_REQ (0x1U << 17)
> +
> +// Display core configuration valid register
> +#define DP_DC_CONFIG_VALID_CVAL (0x1U)
> +
> +/* DC_CORE_ID
> + * Display core version register PRODUCT_ID
> + */
> +#define DP_DC_CORE_ID_SHIFT 16
> +#define DP_DE_DP500_CORE_ID_SHIFT DP_DC_CORE_ID_SHIFT
> +
> +// Timing settings
> +#define DP_DE_HBACKPORCH_SHIFT 16
> +#define DP_DE_VBACKPORCH_SHIFT 16
> +#define DP_DE_VSP_SHIFT 28
> +#define DP_DE_VSYNCWIDTH_SHIFT 16
> +#define DP_DE_HSP_SHIFT 13
> +#define DP_DE_V_ACTIVE_SHIFT 16
> +
> +// BACKGROUND_COLOR
> +#define DP_DE_BG_R_PIXEL_SHIFT 16
> +#define DP_DE_BG_G_PIXEL_SHIFT 8
> +
> +//Graphics layer LG_FORMAT Pixel Format
> +#define DP_PIXEL_FORMAT_ARGB_8888 0x8
> +#define DP_PIXEL_FORMAT_ABGR_8888 0x9
> +#define DP_PIXEL_FORMAT_RGBA_8888 0xA
> +#define DP_PIXEL_FORMAT_BGRA_8888 0xB
> +#define DP_PIXEL_FORMAT_XRGB_8888 0x10
> +#define DP_PIXEL_FORMAT_XBGR_8888 0x11
> +#define DP_PIXEL_FORMAT_RGBX_8888 0x12
> +#define DP_PIXEL_FORMAT_BGRX_8888 0x13
> +#define DP_PIXEL_FORMAT_RGB_888 0x18
> +#define DP_PIXEL_FORMAT_BGR_888 0x19
> +
> +// DP500 format code are different than DP550/DP650
> +#define DP_PIXEL_FORMAT_DP500_ARGB_8888 0x2
> +#define DP_PIXEL_FORMAT_DP500_ABGR_8888 0x3
> +#define DP_PIXEL_FORMAT_DP500_XRGB_8888 0x4
> +#define DP_PIXEL_FORMAT_DP500_XBGR_8888 0x5
> +
> +// Graphics layer LG_PTR_LOW and LG_PTR_HIGH
> +#define DP_DE_LG_PTR_LOW_MASK 0xFFFFFFFFU
> +#define DP_DE_LG_PTR_HIGH_SHIFT 32
> +
> +// Graphics layer LG_CONTROL register characteristics
> +#define DP_DE_LG_L_ALPHA_SHIFT 16
> +#define DP_DE_LG_CHK_SHIFT 15
> +#define DP_DE_LG_PMUL_SHIFT 14
> +#define DP_DE_LG_COM_SHIFT 12
> +#define DP_DE_LG_VFP_SHIFT 11
> +#define DP_DE_LG_HFP_SHIFT 10
> +#define DP_DE_LG_ROTATION_SHIFT 8
> +
> +#define DP_DE_LG_LAYER_BLEND_NO_BG 0x0U
> +#define DP_DE_LG_PIXEL_BLEND_NO_BG 0x1U
> +#define DP_DE_LG_LAYER_BLEND_BG 0x2U
> +#define DP_DE_LG_PIXEL_BLEND_BG 0x3U
> +#define DP_DE_LG_ENABLE 0x1U
> +
> +// Graphics layer LG_IN_SIZE register characteristics
> +#define DP_DE_LG_V_IN_SIZE_SHIFT 16
> +
> +// Graphics layer LG_CMP_SIZE register characteristics
> +#define DP_DE_LG_V_CMP_SIZE_SHIFT 16
> +#define DP_DE_LG_V_OFFSET_SHIFT 16
> +
> +// Helper display timing macro functions.
> +#define H_INTERVALS(Hfp, Hbp) ((Hbp << DP_DE_HBACKPORCH_SHIFT) | Hfp)
> +#define V_INTERVALS(Vfp, Vbp) ((Vbp << DP_DE_VBACKPORCH_SHIFT) | Vfp)
> +#define SYNC_WIDTH(Hsw, Vsw) ((Vsw << DP_DE_VSYNCWIDTH_SHIFT) | Hsw)
> +#define HV_ACTIVE(Hor, Ver) ((Ver << DP_DE_V_ACTIVE_SHIFT) | Hor)
> +
> +// Helper layer graphics macros.
> +#define FRAME_IN_SIZE(Hor, Ver) ((Ver << DP_DE_LG_V_IN_SIZE_SHIFT) | Hor)
> +#define FRAME_CMP_SIZE(Hor, Ver) ((Ver << DP_DE_LG_V_CMP_SIZE_SHIFT) | Hor)
> +
> +#endif /* ARMMALIDP_H_ */
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..81924cc41f5898605038a1bc20af096fbb85d81c
> --- /dev/null
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
> @@ -0,0 +1,377 @@
> +/** @file ArmMaliDpLib.c
> +*
> +* The file contains ARM Mali DP platform specific implementation.
> +*
> +* Copyright (c) 2017, ARM Ltd. All rights reserved.
> +*
> +* This program and the accompanying materials
> +* are licensed and made available under the terms and conditions of the BSD License
> +* which accompanies this distribution. The full text of the license may be found at
> +* http://opensource.org/licenses/bsd-license.php
> +*
> +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +*
> +**/
> +#include <PiDxe.h>
> +#include <Library/PcdLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/DxeServicesTableLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/LcdPlatformLib.h>
> +#include <ArmPlatform.h>
> +
> +/** Check an address is within 40 bits.
> + *
> + * The ARM Mali DP frame buffer address size can not be wider than 40 bits
> +**/
> +#define DP_VALID_BASE_ADDR(Address) ((Address >> 40) == 0)
> +
> +typedef struct {
> + UINT32 Mode;
> + UINT32 OscFreq;
> + SCAN_TIMINGS Horizontal;
> + SCAN_TIMINGS Vertical;
> +} DISPLAY_MODE;
> +
> +/** The display modes implemented by this driver.
> + *
> + * On Models, the OSC frequencies (listed for each mode below) are not used.
> + * However these frequencies are useful on hardware plaforms where related
> + * clock (or PLL) settings are based on these pixel clocks.
> + *
> + * Since the clock settings are defined externally, the driver must
> + * communicate pixel clock frequencies to relevant modules
> + * responsible for setting clocks. e.g. SCP.
> +**/
> +STATIC CONST DISPLAY_MODE mDisplayModes[] = {
> + {
> + // Mode 0 : VGA : 640 x 480 x 24 bpp.
> + VGA,
> + VGA_OSC_FREQUENCY,
> + {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH, VGA_H_FRONT_PORCH},
> + {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH, VGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 1 : WVGA : 800 x 480 x 24 bpp.
> + WVGA,
> + WVGA_OSC_FREQUENCY,
> + {WVGA_H_RES_PIXELS, WVGA_H_SYNC, WVGA_H_BACK_PORCH, WVGA_H_FRONT_PORCH},
> + {WVGA_V_RES_PIXELS, WVGA_V_SYNC, WVGA_V_BACK_PORCH, WVGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 2 : SVGA : 800 x 600 x 24 bpp.
> + SVGA,
> + SVGA_OSC_FREQUENCY,
> + {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH, SVGA_H_FRONT_PORCH},
> + {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH, SVGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 3 : QHD : 960 x 540 x 24 bpp.
> + QHD,
> + QHD_OSC_FREQUENCY,
> + {QHD_H_RES_PIXELS, QHD_H_SYNC, QHD_H_BACK_PORCH, QHD_H_FRONT_PORCH},
> + {QHD_V_RES_PIXELS, QHD_V_SYNC, QHD_V_BACK_PORCH, QHD_V_FRONT_PORCH}
> + },
> + {
> + // Mode 4 : WSVGA : 1024 x 600 x 24 bpp.
> + WSVGA,
> + WSVGA_OSC_FREQUENCY,
> + {WSVGA_H_RES_PIXELS, WSVGA_H_SYNC, WSVGA_H_BACK_PORCH, WSVGA_H_FRONT_PORCH},
> + {WSVGA_V_RES_PIXELS, WSVGA_V_SYNC, WSVGA_V_BACK_PORCH, WSVGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 5 : XGA : 1024 x 768 x 24 bpp.
> + XGA,
> + XGA_OSC_FREQUENCY,
> + {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH, XGA_H_FRONT_PORCH},
> + {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH, XGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 6 : HD : 1280 x 720 x 24 bpp.
> + HD720,
> + HD720_OSC_FREQUENCY,
> + {HD720_H_RES_PIXELS, HD720_H_SYNC, HD720_H_BACK_PORCH, HD720_H_FRONT_PORCH},
> + {HD720_V_RES_PIXELS, HD720_V_SYNC, HD720_V_BACK_PORCH, HD720_V_FRONT_PORCH}
> + },
> + {
> + // Mode 7 : WXGA : 1280 x 800 x 24 bpp.
> + WXGA,
> + WXGA_OSC_FREQUENCY,
> + {WXGA_H_RES_PIXELS, WXGA_H_SYNC, WXGA_H_BACK_PORCH, WXGA_H_FRONT_PORCH},
> + {WXGA_V_RES_PIXELS, WXGA_V_SYNC, WXGA_V_BACK_PORCH, WXGA_V_FRONT_PORCH}
> + },
> + { // Mode 8 : SXGA : 1280 x 1024 x 24 bpp.
> + SXGA,
> + SXGA_OSC_FREQUENCY,
> + {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH, SXGA_H_FRONT_PORCH},
> + {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH, SXGA_V_FRONT_PORCH}
> + },
> + { // Mode 9 : WSXGA+ : 1680 x 1050 x 24 bpp.
> + WSXGA,
> + WSXGA_OSC_FREQUENCY,
> + {WSXGA_H_RES_PIXELS, WSXGA_H_SYNC, WSXGA_H_BACK_PORCH, WSXGA_H_FRONT_PORCH},
> + {WSXGA_V_RES_PIXELS,WSXGA_V_SYNC, WSXGA_V_BACK_PORCH, WSXGA_V_FRONT_PORCH}
> + },
> + {
> + // Mode 10 : HD : 1920 x 1080 x 24 bpp.
> + HD,
> + HD_OSC_FREQUENCY,
> + {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH, HD_H_FRONT_PORCH},
> + {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH, HD_V_FRONT_PORCH}
> + }
> +};
> +
> +/** If PcdArmMaliDpMaxMode is 0, platform supports full range of modes
> + * else platform supports modes from 0 to PcdArmMaliDpMaxMode - 1
> +**/
> +STATIC CONST UINT32 mMaxMode = ((FixedPcdGet32 (PcdArmMaliDpMaxMode) != 0)
> + ? FixedPcdGet32 (PcdArmMaliDpMaxMode)
> + : sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
> +
> +
> +/** Platform related initialization function.
> + *
> + * @retval EFI_SUCCESS Platform initialization success.
> + * @retval EFI_UNSUPPORTED PcdGopPixelFormat must be
> + * PixelRedGreenBlueReserved8BitPerColor OR
> + * PixelBlueGreenRedReserved8BitPerColor
> + * any other format is not supported.
> +**/
> +EFI_STATUS
> +LcdPlatformInitializeDisplay (
> + IN CONST EFI_HANDLE Handle
> + )
> +{
> + EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
> +
> + (VOID)Handle;
> +
> + // PixelBitMask and PixelBltOnly pixel formats are not supported
> + PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> + if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
> + && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
> +
> + ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
> + || PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
> + return EFI_UNSUPPORTED;
> + }
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Reserve VRAM memory in DRAM for the frame buffer
> + *
> + * (unless it is reserved already).
> + *
> + * The allocated address can be used to set the frame buffer as a base buffer
> + * address for any layer of the ARM Mali DP.
> + *
> + * @param OUT VramBaseAddress A pointer to the frame buffer address.
> + * @param OUT VramSize A pointer to the size of the frame
> + * buffer in bytes
> + *
> + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize are NULL.
> + * @retval EFI_UNSUPPORTED Allocated address wider than 40 bits
> + * @retval !EFI_SUCCESS Other errors.
> +**/
> +EFI_STATUS
> +LcdPlatformGetVram (
> + OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> + OUT UINTN * CONST VramSize
> + )
> +{
> + EFI_STATUS Status;
> +
> + // Check VramBaseAddress and VramSize are not NULL.
> + if (VramBaseAddress == NULL || VramSize == NULL) {
> + ASSERT (VramBaseAddress != NULL);
> + ASSERT (VramSize != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + // Set the VRAM size.
> + *VramSize = (UINTN)FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
> +
> + // Check if memory is already reserved for the frame buffer.
> +#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
> +
> +#if (!DP_VALID_BASE_ADDR (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase)))
> +#error ARM Mali DP frame buffer base address cannot be wider than 40 bits.
> +#else
> +
> + *VramBaseAddress =
> + (EFI_PHYSICAL_ADDRESS)FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase);
> +
> + Status = EFI_SUCCESS;
> +#endif
> +
> +#else
> + // If not already reserved, attempt to allocate the VRAM from the DRAM.
> + Status = gBS->AllocatePages (
> + AllocateAnyPages,
> + EfiBootServicesData,
> + EFI_SIZE_TO_PAGES (*VramSize),
> + VramBaseAddress
> + );
> +
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "ArmMaliDpLib: Failed to allocate frame buffer.\n"));
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> +
> + // ARM Mali DP frame buffer base address can not be wider than 40 bits.
> + if (!DP_VALID_BASE_ADDR (*VramBaseAddress)) {
> + gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> + ASSERT (DP_VALID_BASE_ADDR (*VramBaseAddress));
> + return EFI_UNSUPPORTED;
> + }
> +
> + /* Mark the VRAM as write-combining. The VRAM is inside the DRAM, which is cacheable.
> + * For ARM/AArch64 EFI_MEMORY_WC memory is actually uncached.
> + */
> + Status = gDS->SetMemorySpaceAttributes (
> + *VramBaseAddress,
> + *VramSize,
> + EFI_MEMORY_WC
> + );
> +
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize));
> + }
> +
> +#endif
> + return Status;
> +}
> +
> +/** Return total number of modes supported.
> + *
> + * Note: Valid mode numbers are 0 to MaxMode - 1
> + * See Section 12.9 of the UEFI Specification 2.7
> + *
> + * @retval UINT32 Mode Number.
> +**/
> +UINT32
> +LcdPlatformGetMaxMode (VOID)
> +{
> + return mMaxMode;
> +}
> +
> +/** Set the requested display mode.
> + *
> + * @param IN ModeNumber Mode Number.
> + *
> + * @retval EFI_SUCCESS Set mode success.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> +EFI_STATUS
> +LcdPlatformSetMode (
> + IN CONST UINT32 ModeNumber
> + )
> +{
> +
> + if (ModeNumber >= mMaxMode) {
> + ASSERT (ModeNumber < mMaxMode);
> + return EFI_INVALID_PARAMETER;
> + }
> + /* On models, platform specific clock/mux settings are not required
> + * Display controller specific settings for Mali DP are done in LcdSetMode.
> + */
> + return EFI_SUCCESS;
> +}
> +
> +/** Return information for the requested mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Info Pointer for returned mode information
> + * (on success).
> + *
> + * @retval EFI_SUCCESS Requested mode found.
> + * @retval EFI_INVALID_PARAMETER Info is NULL.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> +**/
> +EFI_STATUS
> +LcdPlatformQueryMode (
> + IN CONST UINT32 ModeNumber,
> + OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> + )
> +{
> + if (ModeNumber >= mMaxMode || Info == NULL) {
> + ASSERT (ModeNumber < mMaxMode);
> + ASSERT (Info != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + Info->Version = 0;
> + Info->HorizontalResolution = mDisplayModes[ModeNumber].Horizontal.Resolution;
> + Info->VerticalResolution = mDisplayModes[ModeNumber].Vertical.Resolution;
> + Info->PixelsPerScanLine = mDisplayModes[ModeNumber].Horizontal.Resolution;
> +
> + Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Returns the display timing information for the requested mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Horizontal Pointer to horizontal timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> + * @param OUT Vertical Pointer to vertical timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> + *
> + * @retval EFI_SUCCESS Requested mode found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER One of the OUT parameters is NULL.
> +**/
> +EFI_STATUS
> +LcdPlatformGetTimings (
> + IN UINT32 ModeNumber,
> + OUT CONST SCAN_TIMINGS ** Horizontal,
> + OUT CONST SCAN_TIMINGS ** Vertical
> + )
> +{
> + if (ModeNumber >= mMaxMode || Horizontal == NULL || Vertical == NULL) {
> + ASSERT (ModeNumber < mMaxMode);
> + // One of the pointers is NULL
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
> + *Vertical = &mDisplayModes[ModeNumber].Vertical;
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Return bytes per pixel information for a mode number.
> + *
> + * @param IN ModeNumber Mode Number.
> + * @param OUT Bpp Pointer to value Bytes Per Pixel.
> + *
> + * @retval EFI_SUCCESS The requested mode is found.
> + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> +**/
> +EFI_STATUS
> +LcdPlatformGetBpp (
> + IN CONST UINT32 ModeNumber,
> + OUT LCD_BPP * CONST Bpp
> + )
> +{
> + if (ModeNumber >= mMaxMode || Bpp == NULL) {
> + // Check valid ModeNumber and Bpp.
> + ASSERT (ModeNumber < mMaxMode);
> + ASSERT (Bpp != NULL);
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + *Bpp = LCD_BITS_PER_PIXEL_24;
> +
> + return EFI_SUCCESS;
> +}
> diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> index 5cd529750a3d2d3b0d381b58d875d378afaba2c2..87a7a26132e39b933ecd2a95e38b2ab869cd4079 100644
> --- a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMem.c
> @@ -21,9 +21,10 @@
> #include <ArmPlatform.h>
>
> #define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
> +#define DP_BASE_DESCRIPTOR ((FixedPcdGet64 (PcdArmMaliDpBase) != 0) ? 1 : 0)
>
> // Number of Virtual Memory Map Descriptors
> -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR)
> +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 + FRAME_BUFFER_DESCRIPTOR + DP_BASE_DESCRIPTOR)
>
> // DDR attributes
> #define DDR_ATTRIBUTES_CACHED ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
> @@ -159,6 +160,13 @@ ArmPlatformGetVirtualMemoryMap (
> VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
> #endif
>
> +#if (FixedPcdGet64 (PcdArmMaliDpBase) != 0)
> + // DP500/DP550/DP650 peripheral memory region
> + VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdArmMaliDpBase);
> + VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64 (PcdArmMaliDpBase);
> + VirtualMemoryTable[Index].Length = FixedPcdGet32 (PcdArmMaliDpMemoryRegionLength);
> + VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> +#endif
> // Map sparse memory region if present
> if (HasSparseMemory) {
> VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
> diff --git a/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..ff7236371d27915d9f1e34162dce0954dde63a77
> --- /dev/null
> +++ b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c
> @@ -0,0 +1,412 @@
> +/** @file ArmMaliDp.c
> +
> + ARM Mali DP 500/550/650 display controller driver
> +
> + Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
> +
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD License
> + which accompanies this distribution. The full text of the license may be found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <Library/IoLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/LcdPlatformLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Drivers/ArmMaliDp.h>
> +#include <Drivers/LcdHw.h>
> +
> +// CORE_ID of the MALI DP
> +STATIC UINT32 gDpDeviceId;
> +
> +/** Disable the graphics layer
> + *
> + * This is done by clearing the EN bit
> + * of the LG_CONTROL register.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsDisable (VOID)
> +{
> + MmioAnd32 (DP_BASE + DP_DE_LG_CONTROL, ~DP_DE_LG_ENABLE);
> +}
> +
> +/** Enable the graphics layer
> + *
> + * This is done by setting the EN bit
> + * of the LG_CONTROL register.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsEnable (VOID)
> +{
> + MmioOr32 (DP_BASE + DP_DE_LG_CONTROL, DP_DE_LG_ENABLE);
> +}
> +
> +/** Set the frame address of the graphics layer.
> + *
> + * @param FrameBaseAddress Address of the data buffer
> + * to be used as a frame buffer.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsSetFrame (
> + IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
> + )
> +{
> + // Disable the graphics layer.
> + LayerGraphicsDisable ();
> +
> + /* Set up memory address of the data buffer for graphics layer.
> + * write lower bits of the address.
> + */
> + MmioWrite32 (
> + DP_BASE + DP_DE_LG_PTR_LOW,
> + DP_DE_LG_PTR_LOW_MASK & FrameBaseAddress
> + );
> +
> + // Write higher bits of the address.
> + MmioWrite32 (
> + DP_BASE + DP_DE_LG_PTR_HIGH,
> + (UINT32)(FrameBaseAddress >> DP_DE_LG_PTR_HIGH_SHIFT)
> + );
> +
> + // Enable the graphics layer.
> + LayerGraphicsEnable ();
> +}
> +
> +/** Configures various graphics layer characteristics.
> + *
> + * @param HRes Horizontal resolution of the graphics layer.
> + * @param VRes Vertical resolution of the graphics layer.
> +**/
> +STATIC
> +VOID
> +LayerGraphicsConfig (
> + IN CONST EFI_GRAPHICS_PIXEL_FORMAT UefiGfxPixelFormat,
> + IN CONST UINT32 HRes,
> + IN CONST UINT32 VRes
> + )
> +{
> + UINT32 PixelFormat;
> +
> + // Disable the graphics layer before configuring any settings.
> + LayerGraphicsDisable ();
> +
> + // Setup graphics layer size.
> + MmioWrite32 (DP_BASE + DP_DE_LG_IN_SIZE, FRAME_IN_SIZE (HRes, VRes));
> +
> + // Setup graphics layer composition size.
> + MmioWrite32 (DP_BASE + DP_DE_LG_CMP_SIZE, FRAME_CMP_SIZE (HRes, VRes));
> +
> + // Setup memory stride (total visible pixels on a line * 4 ).
> + MmioWrite32 (DP_BASE + DP_DE_LG_H_STRIDE, (HRes * sizeof (UINT32)));
> +
> + /* Set the format.
> + *
> + * In PixelBlueGreenRedReserved8BitPerColor format, byte 0 represents blue,
> + * byte 1 represents green, and byte 2 represents red, and byte 3 is reserved
> + * which is equivalent to XRGB format of the DP500/DP550/DP650. Whereas
> + * PixelRedGreenBlueReserved8BitPerColor is equivalent to XBGR of the
> + * DP500/DP550/DP650.
> + */
> + if (UefiGfxPixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
> + PixelFormat = (gDpDeviceId == MALIDP_500) ? DP_PIXEL_FORMAT_DP500_XRGB_8888
> + : DP_PIXEL_FORMAT_XRGB_8888;
> + } else {
> + PixelFormat = (gDpDeviceId == MALIDP_500) ? DP_PIXEL_FORMAT_DP500_XBGR_8888
> + : DP_PIXEL_FORMAT_XBGR_8888;
> + }
> +
> + MmioWrite32 (DP_BASE + DP_DE_LG_FORMAT, PixelFormat);
> +
> + // Enable graphics layer.
> + LayerGraphicsEnable ();
> +}
> +
> +/** Configure timing information of the display.
> + * @param IN Horizontal Pointer to horizontal timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> + * @param IN Vertical Pointer to vertical timing parameters.
> + * (Resolution, Sync, Back porch, Front porch)
> +**/
> +STATIC
> +VOID
> +SetDisplayEngineTiming (
> + IN CONST SCAN_TIMINGS * CONST Horizontal,
> + IN CONST SCAN_TIMINGS * CONST Vertical
> + )
> +{
> + UINTN RegHIntervals;
> + UINTN RegVIntervals;
> + UINTN RegSyncControl;
> + UINTN RegHVActiveSize;
> +
> + if (gDpDeviceId == MALIDP_500) {
> + // MALI DP500 timing registers.
> + RegHIntervals = DP_BASE + DP_DE_DP500_H_INTERVALS;
> + RegVIntervals = DP_BASE + DP_DE_DP500_V_INTERVALS;
> + RegSyncControl = DP_BASE + DP_DE_DP500_SYNC_CONTROL;
> + RegHVActiveSize = DP_BASE + DP_DE_DP500_HV_ACTIVESIZE;
> + } else {
> + // MALI DP550/DP650 timing registers.
> + RegHIntervals = DP_BASE + DP_DE_H_INTERVALS;
> + RegVIntervals = DP_BASE + DP_DE_V_INTERVALS;
> + RegSyncControl = DP_BASE + DP_DE_SYNC_CONTROL;
> + RegHVActiveSize = DP_BASE + DP_DE_HV_ACTIVESIZE;
> + }
> +
> + // Horizontal back porch and front porch.
> + MmioWrite32 (
> + RegHIntervals,
> + H_INTERVALS (Horizontal->FrontPorch, Horizontal->BackPorch)
> + );
> +
> + // Vertical back porch and front porch.
> + MmioWrite32 (
> + RegVIntervals,
> + V_INTERVALS (Vertical->FrontPorch, Vertical->BackPorch)
> + );
> +
> + // Sync control, Horizontal and Vertical sync.
> + MmioWrite32 (
> + RegSyncControl,
> + SYNC_WIDTH (Horizontal->Sync, Vertical->Sync)
> + );
> +
> + // Set up Horizontal and Vertical area size.
> + MmioWrite32 (
> + RegHVActiveSize,
> + HV_ACTIVE (Horizontal->Resolution, Vertical->Resolution)
> + );
> +}
> +
> +/** Return CORE_ID of the ARM Mali DP.
> + *
> + * @retval 0 No Mali DP found.
> + * @retval 0x500 Mali DP core id for DP500.
> + * @retval 0x550 Mali DP core id for DP550.
> + * @retval 0x650 Mali DP core id for DP650.
> +**/
> +STATIC
> +UINT32
> +ArmMaliDpGetCoreId (
> + )
> +{
> + UINT32 DpCoreId;
> +
> + /* First check for DP500 as register offset for DP550/DP650 CORE_ID
> + * is beyond 3K/4K register space of the DP500.
> + */
> + DpCoreId = MmioRead32 (DP_BASE + DP_DE_DP500_CORE_ID);
> + DpCoreId >>= DP_DE_DP500_CORE_ID_SHIFT;
> +
> + if (DpCoreId == MALIDP_500) {
> + return DpCoreId;
> + }
> +
> + // Check for DP550 or DP650.
> + DpCoreId = MmioRead32 (DP_BASE + DP_DC_CORE_ID);
> + DpCoreId >>= DP_DC_CORE_ID_SHIFT;
> +
> + if (DpCoreId == MALIDP_550
> + || DpCoreId == MALIDP_650) {
> + return DpCoreId;
> + }
> +
> + return 0;
> +}
> +
> +/** Check for presence of MALI.
> + *
> + * This function returns success if the platform implements
> + * DP500/DP550/DP650 ARM Mali display processor.
> + *
> + * @retval EFI_SUCCESS Platform implements DP500/DP550/DP650.
> + * @retval EFI_NOT_FOUND DP500/DP550/DP650 display processor not
> + * found on the platform.
> +**/
> +EFI_STATUS
> +LcdIdentify (VOID)
> +{
> + UINT32 DpCoreId;
> +
> + DEBUG ((DEBUG_WARN,
> + "Probing ARM Mali DP500/DP550/DP650 at base address 0x%p\n",
> + DP_BASE
> + ));
> +
> +#if (DP_BASE == 0)
> +#error "ARM Mali DP peripheral base address is invalid\n"
> +#endif
> +
> + DpCoreId = ArmMaliDpGetCoreId ();
> +
> + if (DpCoreId != 0) {
> + DEBUG ((DEBUG_WARN, "Found ARM Mali DP %x\n", DpCoreId));
> + return EFI_SUCCESS;
> + }
> +
> + DEBUG ((DEBUG_WARN, "ARM Mali DP not found...\n"));
> +
> + return EFI_NOT_FOUND;
> +}
> +
> +/** Initialize platform display.
> + *
> + * @param FrameBaseAddress Address of the frame buffer.
> + *
> + * @retval EFI_SUCCESS Display initialization success.
> + * @retval !(EFI_SUCCESS) Display initialization failure.
> +**/
> +EFI_STATUS
> +LcdInitialize (
> + IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
> + )
> +{
> + DEBUG ((DEBUG_WARN, "Frame buffer base address = %p\n", FrameBaseAddress));
> +
> + gDpDeviceId = ArmMaliDpGetCoreId ();
> + if (gDpDeviceId == 0) {
> + DEBUG ((DEBUG_ERROR, "ARM Mali DP initialization fail,"
> + "no ARM Mali DP present\n"));
> + return EFI_NOT_FOUND;
> + }
> +
> + // We are using graphics layer of the Mali DP as a main frame buffer.
> + LayerGraphicsSetFrame (FrameBaseAddress);
> +
> + return EFI_SUCCESS;
> +}
> +
> +/** Set ARM Mali DP in cofiguration mode.
> + *
> + * The ARM Mali DP must be in the configuration mode for
> + * configuration of the H_INTERVALS, V_INTERVALS, SYNC_CONTROL
> + * and HV_ACTIVESIZE.
> +**/
> +STATIC
> +VOID
> +SetConfigurationMode (VOID)
> +{
> + // Request configuration Mode.
> + if (gDpDeviceId == MALIDP_500) {
> + MmioOr32 (DP_BASE + DP_DE_DP500_CONTROL, DP_DE_DP500_CONTROL_CONFIG_REQ);
> + } else {
> + MmioOr32 (DP_BASE + DP_DC_CONTROL, DP_DC_CONTROL_CM_ACTIVE);
> + }
> +}
> +
> +/** Set ARM Mali DP in normal mode.
> + *
> + * Normal mode is the main operating mode of the display processor
> + * in which display layer data is fetched from frame buffer and
> + * displayed.
> +**/
> +STATIC
> +VOID
> +SetNormalMode (VOID)
> +{
> + // Disable configuration Mode.
> + if (gDpDeviceId == MALIDP_500) {
> + MmioAnd32 (DP_BASE + DP_DE_DP500_CONTROL, ~DP_DE_DP500_CONTROL_CONFIG_REQ);
> + } else {
> + MmioAnd32 (DP_BASE + DP_DC_CONTROL, ~DP_DC_CONTROL_CM_ACTIVE );
> + }
> +}
> +
> +/** Set the global configuration valid flag.
> + *
> + * Any new configuration parameters written to the display engine are not
> + * activated until the global configuration valid flag is set in the
> + * CONFIG_VALID register.
> +**/
> +STATIC
> +VOID
> +SetConfigValid (VOID)
> +{
> + if (gDpDeviceId == MALIDP_500) {
> + MmioOr32 (DP_BASE + DP_DP500_CONFIG_VALID, DP_DC_CONFIG_VALID);
> + } else {
> + MmioOr32 (DP_BASE + DP_DC_CONFIG_VALID, DP_DC_CONFIG_VALID );
> + }
> +}
> +
> +/** Set requested mode of the display.
> + *
> + * @param ModeNumber Display mode number.
> + * @retval EFI_SUCCESS Display set mode success.
> + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> + * @retval EFI_DEVICE_ERROR If mode does not support more
> + * than 24 bytes per pixel format.
> +**/
> +EFI_STATUS
> +LcdSetMode (
> + IN CONST UINT32 ModeNumber
> + )
> +{
> + EFI_STATUS Status;
> + CONST SCAN_TIMINGS *Horizontal;
> + CONST SCAN_TIMINGS *Vertical;
> +
> + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
> +
> + // Get the display mode timings and other relevant information.
> + Status = LcdPlatformGetTimings (
> + ModeNumber,
> + &Horizontal,
> + &Vertical
> + );
> +
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> + ASSERT (Horizontal != NULL);
> + ASSERT (Vertical != NULL);
> +
> + // Get the pixel format information.
> + Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> +
> + // Request configuration mode.
> + SetConfigurationMode ();
> +
> + // Configure the graphics layer.
> + LayerGraphicsConfig (
> + ModeInfo.PixelFormat,
> + Horizontal->Resolution,
> + Vertical->Resolution
> + );
> +
> + // Set the display engine timings.
> + SetDisplayEngineTiming (Horizontal, Vertical);
> +
> + // After configuration, set Mali DP in normal mode.
> + SetNormalMode ();
> +
> + /* Any parameters written to the display engine are not activated until
> + * CONFIG_VALID is set.
> + */
> + SetConfigValid ();
> +
> + return EFI_SUCCESS;
> +}
> +
> +/**
> + * This function de-initializes the display.
> +**/
> +VOID
> +LcdShutdown (VOID)
> +{
> + // Disable graphics layer.
> + LayerGraphicsDisable ();
> +}
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver.
2017-11-28 18:17 ` Ard Biesheuvel
@ 2017-12-01 13:12 ` Evan Lloyd
2017-12-01 17:18 ` Ard Biesheuvel
2017-12-01 17:29 ` Leif Lindholm
0 siblings, 2 replies; 69+ messages in thread
From: Evan Lloyd @ 2017-12-01 13:12 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: edk2-devel@lists.01.org, Matteo Carlini, Leif Lindholm,
Girish Pathak
> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 28 November 2017 18:18
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; Matteo Carlini <Matteo.Carlini@arm.com>;
> Leif Lindholm <leif.lindholm@linaro.org>; Girish Pathak
> <Girish.Pathak@arm.com>
> Subject: Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650
> GOP driver.
>
> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> > From: Girish Pathak <girish.pathak@arm.com>
> >
> > This change adds support for the ARM Mali DP500/DP500/DP650 display
> > processors using the GOP protocol. It has been tested on FVP base
> > models + DP550 support.
> >
> > This change does not modify functionality provided by PL111 or
> > HDLCD. The driver should be suitable for those platforms
> > that implement ARM Mali DP500/DP550/DP650 replacing PL111/HDLCD.
> >
> > Only "Layer Graphics" of the ARM Mali DP is configured for rendering
> > the RGB/BGR format frame buffer to satisfy the UEFI GOP requirements
> > Other layers e.g. video layers are not configured.
> >
> > NOTE: This change implements the Mali DP on models. Versions for actual
> > hardware are liable to require extra handling for clock input changes,
> > etc.
> >
> > 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>
>
> Hello Girish, Evan,
>
> (replying to 19/19 because I cannot find the cover letter in my
> edk2-devel archive but this really applies to the whole series)
>
> I have been looking at these patches again now that I am trying to
> clean up ArmPlatformPkg, which is currently a dumping ground for all
> things vaguely ARM related, and is also structured quite differently
> from other packages.
>
> Ideally, ArmPlatformPkg should only contain the following:
> - library class interfaces under Include/Library; header files kept
> here should only contain elements that define API
> - driver specific include files Include/IndustryStandard but *only* if
> they cannot be kept locally with the driver in question
> - libraries under Library/
> - drivers under Drivers/
>
> This aligns with the common arrangement adopted by most EDK2 packages.
>
> This series does many different things, and does not distinguish at
> all between common code and code living under ArmVExpressPkg. Given
[[Evan Lloyd]] All of the commits in the series are in ArmPlatformPkg.
You may be in the process of disentangling the VE specific bits, but hitherto that has not been a consideration. (Note: I'm not arguing against the disentangling, only pointing out that it was not a factor at the point we submitted the patches)
The reason there are so many commits is only that we have been asked to break things up into "bite sized" chunks for the convenience of maintainers.
The aim was to make each a coherent item with a simple justification.
> that I am trying to move ArmVExpressPkg out of EDK2 into
> edk2-platforms (where it arguably belongs) having this series in limbo
> for two months is basically blocking my work, and so I would like to
> explore ways to proceed with this without interfering with each
> other's work too much. At the same time, the way the code is
> structured is a continuation of the pattern I am trying to get rid of,
> so they will need some rework anyway in order to be upstreamable IMHO.
[[Evan Lloyd]] Not being psychic, we had not made allowance for your plans.
However, if you take the trouble to look at the changes, they achieve exactly the split you aim for.
The display type code (PL011 and HDLCD) is unravelled from the VE code.
All that remains would be to move the VE specific part into edk2-platforms.
>
> So could we split it up please? Assuming the intention is the ability
> to reuse the Mali code on non-VExpress platforms, I would like to see
> that code proposed separately, without any mention of VExpressPkg.dec
[[Evan Lloyd]] Given that the original code was unfortunate, I'm not sure that it makes much difference what order the changes get made.
Going West then North gets you to the same place as North then West (except near a pole).
If you accept that there was a logical progression in the changes made, then it might be better to not rejig things pointlessly.
> whatsoever. If you introduce any library classes that abstract away
> the differences between platforms, you can include a Null version of
> such a library that simply does ASSERT (FALSE) in every function: this
[[Evan Lloyd]] One could, indeed, do that. We, however, would be very reluctant to incur the overhead of rework in response to spurious cavils from a maintainer when it is of no direct relevance to us.
> allows the driver to be built standalone, and at the same time, forces
> you to keep the abstractions pure. I intend to create a separate
> ArmPlatformPkg.dsc platform description for CI purposes that covers
> all drivers and libraries that remain after the refactor, and that
> requires Null implementations of libraries that have no implementation
> upstream.
>
> Beyond that, it would be a matter of separating the cleanup patches
> from the Mali platform support being added to VExpressPkg. The latter
> could wait until the moment where the support is actually made live
> and wired into an actual (physical or virtual) platform.
>
> Please let me know what you think,
>
> Regards,
> Ard.
>
>
> > ---
> > ArmPlatformPkg/ArmPlatformPkg.dec | 4 +
> > ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec |
> 4 +-
> >
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.in
> f | 45 +++
> >
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExp
> ressLib.inf | 3 +
> > ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf |
> 44 +++
> > ArmPlatformPkg/Include/Drivers/ArmMaliDp.h | 249
> ++++++++++++
> >
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.c
> | 377 ++++++++++++++++++
> >
> ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMMe
> m.c | 10 +-
> > ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c |
> 412 ++++++++++++++++++++
> > 9 files changed, 1146 insertions(+), 2 deletions(-)
> >
> > diff --git a/ArmPlatformPkg/ArmPlatformPkg.dec
> b/ArmPlatformPkg/ArmPlatformPkg.dec
> > index
> 0174f63e77f5b8430e106289366feb9a6577fb99..3be236413cb8e12ce32e6
> 349732d2767fe0f3024 100644
> > --- a/ArmPlatformPkg/ArmPlatformPkg.dec
> > +++ b/ArmPlatformPkg/ArmPlatformPkg.dec
> > @@ -111,6 +111,10 @@ [PcdsFixedAtBuild.common]
> >
> gArmPlatformTokenSpaceGuid.PcdPL111LcdBase|0x0|UINT32|0x0000002
> 6
> >
> gArmPlatformTokenSpaceGuid.PcdArmHdLcdBase|0x0|UINT32|0x0000002
> 7
> >
> > + ## ARM Mali Display Processor DP500/DP550/DP650
> > +
> gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase|0x0|UINT64|0x000000
> 50
> > +
> gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength|0x0|U
> INT32|0x00000051
> > +
> > ## If set, frame buffer memory will be reserved and mapped in the
> system RAM
> >
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize|0x0|UINT32
> |0x00000033
> >
> gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase|0x0|UINT6
> 4|0x00000034
> > diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> > index
> 3814513c2241c03a8c45fda92d571c65368f64b4..1a55b0434ab4bc53d631
> be2bffd313684bcea9c4 100644
> > --- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> > +++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> > @@ -1,7 +1,7 @@
> > #/** @file
> > # Arm Versatile Express package.
> > #
> > -# Copyright (c) 2012-2015, ARM Limited. All rights reserved.
> > +# Copyright (c) 2012-2017, ARM Limited. All rights reserved.
> > #
> > # This program and the accompanying materials are licensed and made
> available
> > # under the terms and conditions of the BSD License which accompanies
> this
> > @@ -47,6 +47,8 @@ [PcdsFixedAtBuild.common]
> >
> gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId|1|UINT32|0
> x00000002
> >
> gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId|0|UINT32|0x00
> 000003
> >
> > +
> gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode|0x0|UINT32|0x0
> 0000005
> > +
> > #
> > # Device path of block device on which Fastboot will flash partitions
> > #
> > diff --git
> a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.
> inf
> b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.
> inf
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..b85205a8ac6bfbd8bef
> dd8634a7df89e213175bc
> > --- /dev/null
> > +++
> b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.
> inf
> > @@ -0,0 +1,45 @@
> > +#/** @file ArmMaliDpLib.inf
> > +#
> > +# Component description file for ArmMaliDpLib module
> > +#
> > +# Copyright (c) 2017, ARM Limited. All rights reserved.
> > +#
> > +# This program and the accompanying materials
> > +# are licensed and made available under the terms and conditions of the
> BSD License
> > +# which accompanies this distribution. The full text of the license may
> be found at
> > +# http://opensource.org/licenses/bsd-license.php
> > +#
> > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS
> IS" BASIS,
> > +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> > +#**/
> > +
> > +[Defines]
> > + INF_VERSION = 0x00010005
> > + BASE_NAME = ArmMaliDpLib
> > + FILE_GUID = 36C47FED-2F3F-49C7-89CE-31B13F0431D8
> > + MODULE_TYPE = BASE
> > + VERSION_STRING = 1.0
> > + LIBRARY_CLASS = LcdPlatformLib
> > +
> > +[Sources.common]
> > + ArmMaliDpLib.c
> > +
> > +[Packages]
> > + MdePkg/MdePkg.dec
> > + ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> > + ArmPlatformPkg/ArmPlatformPkg.dec
> > +
> > +[LibraryClasses]
> > + BaseLib
> > + DxeServicesTableLib
> > +
> > +[FixedPcd.common]
> > + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> > + gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
> > + gArmPlatformTokenSpaceGuid.PcdGopPixelFormat
> > +
> > + # MaxMode must be one number higher than the actual max mode,
> > + # i.e. for actual maximum mode 2, set the value to 3.
> > + # See Section 11.9 of the UEFI Specification 2.6 Errata A (Jan 2017)
> > + gArmVExpressTokenSpaceGuid.PcdArmMaliDpMaxMode
> > +
> > diff --git
> a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVE
> xpressLib.inf
> b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVE
> xpressLib.inf
> > index
> 60789e9b8ff1b936db04953a765fb164b0e85a40..6ad7d94c8c76404c8a84
> 345b5f992884ab5aca36 100644
> > ---
> a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVE
> xpressLib.inf
> > +++
> b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVE
> xpressLib.inf
> > @@ -60,5 +60,8 @@ [FixedPcd]
> > gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferBase
> > gArmPlatformTokenSpaceGuid.PcdArmLcdDdrFrameBufferSize
> >
> > + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
> > + gArmPlatformTokenSpaceGuid.PcdArmMaliDpMemoryRegionLength
> > +
> > [Ppis]
> > gArmMpCoreInfoPpiGuid
> > diff --git a/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf
> b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..69155a123ef71ecf536
> 1ab29e0ae71454c7ec6cd
> > --- /dev/null
> > +++ b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.inf
> > @@ -0,0 +1,44 @@
> > +#/** @file ArmMaliDp.inf
> > +#
> > +# Component description file for ArmMaliDp module
> > +#
> > +# Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
> > +# This program and the accompanying materials
> > +# are licensed and made available under the terms and conditions of the
> BSD License
> > +# which accompanies this distribution. The full text of the license may
> be found at
> > +# http://opensource.org/licenses/bsd-license.php
> > +#
> > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS
> IS" BASIS,
> > +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> > +#
> > +#**/
> > +
> > +[Defines]
> > + INF_VERSION = 0x00010005
> > + BASE_NAME = ArmMaliDp
> > + FILE_GUID = E724AAF7-19E2-40A3-BAE1-D82A7C8B7A76
> > + MODULE_TYPE = BASE
> > + VERSION_STRING = 1.0
> > + LIBRARY_CLASS = LcdHwLib
> > +
> > +[Sources.common]
> > + ArmMaliDp.c
> > +
> > +[Packages]
> > + MdePkg/MdePkg.dec
> > + MdeModulePkg/MdeModulePkg.dec
> > + ArmPkg/ArmPkg.dec
> > + ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec
> > + ArmPlatformPkg/ArmPlatformPkg.dec
> > +
> > +[LibraryClasses]
> > + UefiLib
> > + BaseLib
> > + DebugLib
> > + IoLib
> > + BaseMemoryLib
> > + LcdPlatformLib
> > +
> > +[FixedPcd]
> > + gArmPlatformTokenSpaceGuid.PcdArmMaliDpBase
> > +
> > diff --git a/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h
> b/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..4955176800ea59f352
> 399d9c6b590195d4ccfa41
> > --- /dev/null
> > +++ b/ArmPlatformPkg/Include/Drivers/ArmMaliDp.h
> > @@ -0,0 +1,249 @@
> > +/** @file ArmMaliDp.h
> > +
> > + File defines registers and other flags of ARM Mali DP display controller
> > +
> > + Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
> > + This program and the accompanying materials
> > + are licensed and made available under the terms and conditions of the
> BSD License
> > + which accompanies this distribution. The full text of the license may be
> found at
> > + http://opensource.org/licenses/bsd-license.php
> > +
> > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> > +
> > +**/
> > +#ifndef ARMMALIDP_H_
> > +#define ARMMALIDP_H_
> > +
> >
> +/*********************************************************
> *************
> > + *
> > + * This header file contains all the bits of the ARM Mali DP that are
> > + * platform independent.
> > + *
> > +
> **********************************************************
> ************/
> > +#define DP_BASE (FixedPcdGet64 (PcdArmMaliDpBase))
> > +
> > +// MALI DP Ids
> > +#define MALIDP_500 0x500
> > +#define MALIDP_550 0x550
> > +#define MALIDP_650 0x650
> > +
> > +// DP500 Peripheral Ids
> > +#define DP500_ID_PART_0 0x00
> > +#define DP500_ID_DES_0 0xB
> > +#define DP500_ID_PART_1 0x5
> > +
> > +#define DP500_ID_REVISION 0x1
> > +#define DP500_ID_JEDEC 0x1
> > +#define DP500_ID_DES_1 0x3
> > +
> > +#define DP500_PERIPHERAL_ID0_VAL (DP500_ID_PART_0)
> > +#define DP500_PERIPHERAL_ID1_VAL ((DP500_ID_DES_0 << 4)
> \
> > + | DP500_ID_PART_1)
> > +#define DP500_PERIPHERAL_ID2_VAL ((DP500_ID_REVISION << 4)
> \
> > + | (DP500_ID_JEDEC << 3) \
> > + | (DP500_ID_DES_1))
> > +
> > +// DP550 Peripheral Ids
> > +#define DP550_ID_PART_0 0x50
> > +#define DP550_ID_DES_0 0xB
> > +#define DP550_ID_PART_1 0x5
> > +
> > +#define DP550_ID_REVISION 0x0
> > +#define DP550_ID_JEDEC 0x1
> > +#define DP550_ID_DES_1 0x3
> > +
> > +#define DP550_PERIPHERAL_ID0_VAL (DP550_ID_PART_0)
> > +#define DP550_PERIPHERAL_ID1_VAL ((DP550_ID_DES_0 << 4)
> \
> > + | DP550_ID_PART_1)
> > +#define DP550_PERIPHERAL_ID2_VAL ((DP550_ID_REVISION << 4)
> \
> > + | (DP550_ID_JEDEC << 3) \
> > + | (DP550_ID_DES_1))
> > +
> > +// DP650 Peripheral Ids
> > +#define DP650_ID_PART_0 0x50
> > +#define DP650_ID_DES_0 0xB
> > +#define DP650_ID_PART_1 0x6
> > +
> > +#define DP650_ID_REVISION 0x0
> > +#define DP650_ID_JEDEC 0x1
> > +#define DP650_ID_DES_1 0x3
> > +
> > +#define DP650_PERIPHERAL_ID0_VAL (DP650_ID_PART_0)
> > +#define DP650_PERIPHERAL_ID1_VAL ((DP650_ID_DES_0 << 4)
> \
> > + | DP650_ID_PART_1)
> > +#define DP650_PERIPHERAL_ID2_VAL ((DP650_ID_REVISION << 4)
> \
> > + | (DP650_ID_JEDEC << 3) \
> > + | (DP650_ID_DES_1))
> > +
> > +// Display Engine (DE) control register offsets for DP550/DP650
> > +#define DP_DE_STATUS 0x00000
> > +#define DP_DE_IRQ_SET 0x00004
> > +#define DP_DE_IRQ_MASK 0x00008
> > +#define DP_DE_IRQ_CLEAR 0x0000C
> > +#define DP_DE_CONTROL 0x00010
> > +#define DP_DE_PROG_LINE 0x00014
> > +#define DP_DE_AXI_CONTROL 0x00018
> > +#define DP_DE_AXI_QOS 0x0001C
> > +#define DP_DE_DISPLAY_FUNCTION 0x00020
> > +
> > +#define DP_DE_H_INTERVALS 0x00030
> > +#define DP_DE_V_INTERVALS 0x00034
> > +#define DP_DE_SYNC_CONTROL 0x00038
> > +#define DP_DE_HV_ACTIVESIZE 0x0003C
> > +#define DP_DE_DISPLAY_SIDEBAND 0x00040
> > +#define DP_DE_BACKGROUND_COLOR 0x00044
> > +#define DP_DE_DISPLAY_SPLIT 0x00048
> > +#define DP_DE_OUTPUT_DEPTH 0x0004C
> > +
> > +// Display Engine (DE) control register offsets for DP500
> > +#define DP_DE_DP500_CORE_ID 0x00018
> > +#define DP_DE_DP500_CONTROL 0x0000C
> > +#define DP_DE_DP500_PROG_LINE 0x00010
> > +#define DP_DE_DP500_H_INTERVALS 0x00028
> > +#define DP_DE_DP500_V_INTERVALS 0x0002C
> > +#define DP_DE_DP500_SYNC_CONTROL 0x00030
> > +#define DP_DE_DP500_HV_ACTIVESIZE 0x00034
> > +#define DP_DE_DP500_BG_COLOR_RG 0x0003C
> > +#define DP_DE_DP500_BG_COLOR_B 0x00040
> > +
> > +/* Display Engine (DE) graphics layer (LG) register offsets
> > + * NOTE: For DP500 it will be LG2.
> > + */
> > +#define DE_LG_OFFSET 0x00300
> > +#define DP_DE_LG_FORMAT (DE_LG_OFFSET)
> > +#define DP_DE_LG_CONTROL (DE_LG_OFFSET + 0x04)
> > +#define DP_DE_LG_COMPOSE (DE_LG_OFFSET + 0x08)
> > +#define DP_DE_LG_IN_SIZE (DE_LG_OFFSET + 0x0C)
> > +#define DP_DE_LG_CMP_SIZE (DE_LG_OFFSET + 0x10)
> > +#define DP_DE_LG_OFFSET (DE_LG_OFFSET + 0x14)
> > +#define DP_DE_LG_H_STRIDE (DE_LG_OFFSET + 0x18)
> > +#define DP_DE_LG_PTR_LOW (DE_LG_OFFSET + 0x1C)
> > +#define DP_DE_LG_PTR_HIGH (DE_LG_OFFSET + 0x20)
> > +#define DP_DE_LG_CHROMA_KEY (DE_LG_OFFSET + 0x2C)
> > +#define DP_DE_LG_AD_CONTROL (DE_LG_OFFSET + 0x30)
> > +#define DP_DE_LG_MMU_CONTROL (DE_LG_OFFSET + 0x48)
> > +
> > +// Display core (DC) control register offsets.
> > +#define DP_DC_OFFSET 0x0C000
> > +#define DP_DC_STATUS (DP_DC_OFFSET + 0x00)
> > +#define DP_DC_IRQ_SET (DP_DC_OFFSET + 0x04)
> > +#define DP_DC_IRQ_MASK (DP_DC_OFFSET + 0x08)
> > +#define DP_DC_IRQ_CLEAR (DP_DC_OFFSET + 0x0C)
> > +#define DP_DC_CONTROL (DP_DC_OFFSET + 0x10)
> > +#define DP_DC_CONFIG_VALID (DP_DC_OFFSET + 0x14)
> > +#define DP_DC_CORE_ID (DP_DC_OFFSET + 0x18)
> > +
> > +// DP500 has a global configuration register.
> > +#define DP_DP500_CONFIG_VALID (0xF00)
> > +
> > +// Display core ID register offsets.
> > +#define DP_DC_ID_OFFSET 0x0FF00
> > +#define DP_DC_ID_PERIPHERAL_ID4 (DP_DC_ID_OFFSET + 0xD0)
> > +#define DP_DC_CONFIGURATION_ID (DP_DC_ID_OFFSET + 0xD4)
> > +#define DP_DC_PERIPHERAL_ID0 (DP_DC_ID_OFFSET + 0xE0)
> > +#define DP_DC_PERIPHERAL_ID1 (DP_DC_ID_OFFSET + 0xE4)
> > +#define DP_DC_PERIPHERAL_ID2 (DP_DC_ID_OFFSET + 0xE8)
> > +#define DP_DC_COMPONENT_ID0 (DP_DC_ID_OFFSET + 0xF0)
> > +#define DP_DC_COMPONENT_ID1 (DP_DC_ID_OFFSET + 0xF4)
> > +#define DP_DC_COMPONENT_ID2 (DP_DC_ID_OFFSET + 0xF8)
> > +#define DP_DC_COMPONENT_ID3 (DP_DC_ID_OFFSET + 0xFC)
> > +
> > +#define DP_DP500_ID_OFFSET 0x0F00
> > +#define DP_DP500_ID_PERIPHERAL_ID4 (DP_DP500_ID_OFFSET +
> 0xD0)
> > +#define DP_DP500_CONFIGURATION_ID (DP_DP500_ID_OFFSET +
> 0xD4)
> > +#define DP_DP500_PERIPHERAL_ID0 (DP_DP500_ID_OFFSET +
> 0xE0)
> > +#define DP_DP500_PERIPHERAL_ID1 (DP_DP500_ID_OFFSET +
> 0xE4)
> > +#define DP_DP500_PERIPHERAL_ID2 (DP_DP500_ID_OFFSET +
> 0xE8)
> > +#define DP_DP500_COMPONENT_ID0 (DP_DP500_ID_OFFSET +
> 0xF0)
> > +#define DP_DP500_COMPONENT_ID1 (DP_DP500_ID_OFFSET +
> 0xF4)
> > +#define DP_DP500_COMPONENT_ID2 (DP_DP500_ID_OFFSET +
> 0xF8)
> > +#define DP_DP500_COMPONENT_ID3 (DP_DP500_ID_OFFSET +
> 0xFC)
> > +
> > +// Display status configuration mode activation flag
> > +#define DP_DC_STATUS_CM_ACTIVE_FLAG (0x1U << 16)
> > +
> > +// Display core control configuration mode
> > +#define DP_DC_CONTROL_SRST_ACTIVE (0x1U << 18)
> > +#define DP_DC_CONTROL_CRST_ACTIVE (0x1U << 17)
> > +#define DP_DC_CONTROL_CM_ACTIVE (0x1U << 16)
> > +
> > +#define DP_DE_DP500_CONTROL_SOFTRESET_REQ (0x1U << 16)
> > +#define DP_DE_DP500_CONTROL_CONFIG_REQ (0x1U << 17)
> > +
> > +// Display core configuration valid register
> > +#define DP_DC_CONFIG_VALID_CVAL (0x1U)
> > +
> > +/* DC_CORE_ID
> > + * Display core version register PRODUCT_ID
> > + */
> > +#define DP_DC_CORE_ID_SHIFT 16
> > +#define DP_DE_DP500_CORE_ID_SHIFT DP_DC_CORE_ID_SHIFT
> > +
> > +// Timing settings
> > +#define DP_DE_HBACKPORCH_SHIFT 16
> > +#define DP_DE_VBACKPORCH_SHIFT 16
> > +#define DP_DE_VSP_SHIFT 28
> > +#define DP_DE_VSYNCWIDTH_SHIFT 16
> > +#define DP_DE_HSP_SHIFT 13
> > +#define DP_DE_V_ACTIVE_SHIFT 16
> > +
> > +// BACKGROUND_COLOR
> > +#define DP_DE_BG_R_PIXEL_SHIFT 16
> > +#define DP_DE_BG_G_PIXEL_SHIFT 8
> > +
> > +//Graphics layer LG_FORMAT Pixel Format
> > +#define DP_PIXEL_FORMAT_ARGB_8888 0x8
> > +#define DP_PIXEL_FORMAT_ABGR_8888 0x9
> > +#define DP_PIXEL_FORMAT_RGBA_8888 0xA
> > +#define DP_PIXEL_FORMAT_BGRA_8888 0xB
> > +#define DP_PIXEL_FORMAT_XRGB_8888 0x10
> > +#define DP_PIXEL_FORMAT_XBGR_8888 0x11
> > +#define DP_PIXEL_FORMAT_RGBX_8888 0x12
> > +#define DP_PIXEL_FORMAT_BGRX_8888 0x13
> > +#define DP_PIXEL_FORMAT_RGB_888 0x18
> > +#define DP_PIXEL_FORMAT_BGR_888 0x19
> > +
> > +// DP500 format code are different than DP550/DP650
> > +#define DP_PIXEL_FORMAT_DP500_ARGB_8888 0x2
> > +#define DP_PIXEL_FORMAT_DP500_ABGR_8888 0x3
> > +#define DP_PIXEL_FORMAT_DP500_XRGB_8888 0x4
> > +#define DP_PIXEL_FORMAT_DP500_XBGR_8888 0x5
> > +
> > +// Graphics layer LG_PTR_LOW and LG_PTR_HIGH
> > +#define DP_DE_LG_PTR_LOW_MASK 0xFFFFFFFFU
> > +#define DP_DE_LG_PTR_HIGH_SHIFT 32
> > +
> > +// Graphics layer LG_CONTROL register characteristics
> > +#define DP_DE_LG_L_ALPHA_SHIFT 16
> > +#define DP_DE_LG_CHK_SHIFT 15
> > +#define DP_DE_LG_PMUL_SHIFT 14
> > +#define DP_DE_LG_COM_SHIFT 12
> > +#define DP_DE_LG_VFP_SHIFT 11
> > +#define DP_DE_LG_HFP_SHIFT 10
> > +#define DP_DE_LG_ROTATION_SHIFT 8
> > +
> > +#define DP_DE_LG_LAYER_BLEND_NO_BG 0x0U
> > +#define DP_DE_LG_PIXEL_BLEND_NO_BG 0x1U
> > +#define DP_DE_LG_LAYER_BLEND_BG 0x2U
> > +#define DP_DE_LG_PIXEL_BLEND_BG 0x3U
> > +#define DP_DE_LG_ENABLE 0x1U
> > +
> > +// Graphics layer LG_IN_SIZE register characteristics
> > +#define DP_DE_LG_V_IN_SIZE_SHIFT 16
> > +
> > +// Graphics layer LG_CMP_SIZE register characteristics
> > +#define DP_DE_LG_V_CMP_SIZE_SHIFT 16
> > +#define DP_DE_LG_V_OFFSET_SHIFT 16
> > +
> > +// Helper display timing macro functions.
> > +#define H_INTERVALS(Hfp, Hbp) ((Hbp <<
> DP_DE_HBACKPORCH_SHIFT) | Hfp)
> > +#define V_INTERVALS(Vfp, Vbp) ((Vbp <<
> DP_DE_VBACKPORCH_SHIFT) | Vfp)
> > +#define SYNC_WIDTH(Hsw, Vsw) ((Vsw <<
> DP_DE_VSYNCWIDTH_SHIFT) | Hsw)
> > +#define HV_ACTIVE(Hor, Ver) ((Ver << DP_DE_V_ACTIVE_SHIFT) |
> Hor)
> > +
> > +// Helper layer graphics macros.
> > +#define FRAME_IN_SIZE(Hor, Ver) ((Ver <<
> DP_DE_LG_V_IN_SIZE_SHIFT) | Hor)
> > +#define FRAME_CMP_SIZE(Hor, Ver) ((Ver <<
> DP_DE_LG_V_CMP_SIZE_SHIFT) | Hor)
> > +
> > +#endif /* ARMMALIDP_H_ */
> > diff --git
> a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.
> c
> b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.
> c
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..81924cc41f58986050
> 38a1bc20af096fbb85d81c
> > --- /dev/null
> > +++
> b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmMaliDpLib/ArmMaliDpLib.
> c
> > @@ -0,0 +1,377 @@
> > +/** @file ArmMaliDpLib.c
> > +*
> > +* The file contains ARM Mali DP platform specific implementation.
> > +*
> > +* Copyright (c) 2017, ARM Ltd. All rights reserved.
> > +*
> > +* This program and the accompanying materials
> > +* are licensed and made available under the terms and conditions of the
> BSD License
> > +* which accompanies this distribution. The full text of the license may
> be found at
> > +* http://opensource.org/licenses/bsd-license.php
> > +*
> > +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS
> IS" BASIS,
> > +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> > +*
> > +**/
> > +#include <PiDxe.h>
> > +#include <Library/PcdLib.h>
> > +#include <Library/DebugLib.h>
> > +#include <Library/DxeServicesTableLib.h>
> > +#include <Library/UefiBootServicesTableLib.h>
> > +#include <Library/MemoryAllocationLib.h>
> > +#include <Library/LcdPlatformLib.h>
> > +#include <ArmPlatform.h>
> > +
> > +/** Check an address is within 40 bits.
> > + *
> > + * The ARM Mali DP frame buffer address size can not be wider than 40
> bits
> > +**/
> > +#define DP_VALID_BASE_ADDR(Address) ((Address >> 40) == 0)
> > +
> > +typedef struct {
> > + UINT32 Mode;
> > + UINT32 OscFreq;
> > + SCAN_TIMINGS Horizontal;
> > + SCAN_TIMINGS Vertical;
> > +} DISPLAY_MODE;
> > +
> > +/** The display modes implemented by this driver.
> > + *
> > + * On Models, the OSC frequencies (listed for each mode below) are not
> used.
> > + * However these frequencies are useful on hardware plaforms where
> related
> > + * clock (or PLL) settings are based on these pixel clocks.
> > + *
> > + * Since the clock settings are defined externally, the driver must
> > + * communicate pixel clock frequencies to relevant modules
> > + * responsible for setting clocks. e.g. SCP.
> > +**/
> > +STATIC CONST DISPLAY_MODE mDisplayModes[] = {
> > + {
> > + // Mode 0 : VGA : 640 x 480 x 24 bpp.
> > + VGA,
> > + VGA_OSC_FREQUENCY,
> > + {VGA_H_RES_PIXELS, VGA_H_SYNC, VGA_H_BACK_PORCH,
> VGA_H_FRONT_PORCH},
> > + {VGA_V_RES_PIXELS, VGA_V_SYNC, VGA_V_BACK_PORCH,
> VGA_V_FRONT_PORCH}
> > + },
> > + {
> > + // Mode 1 : WVGA : 800 x 480 x 24 bpp.
> > + WVGA,
> > + WVGA_OSC_FREQUENCY,
> > + {WVGA_H_RES_PIXELS, WVGA_H_SYNC, WVGA_H_BACK_PORCH,
> WVGA_H_FRONT_PORCH},
> > + {WVGA_V_RES_PIXELS, WVGA_V_SYNC, WVGA_V_BACK_PORCH,
> WVGA_V_FRONT_PORCH}
> > + },
> > + {
> > + // Mode 2 : SVGA : 800 x 600 x 24 bpp.
> > + SVGA,
> > + SVGA_OSC_FREQUENCY,
> > + {SVGA_H_RES_PIXELS, SVGA_H_SYNC, SVGA_H_BACK_PORCH,
> SVGA_H_FRONT_PORCH},
> > + {SVGA_V_RES_PIXELS, SVGA_V_SYNC, SVGA_V_BACK_PORCH,
> SVGA_V_FRONT_PORCH}
> > + },
> > + {
> > + // Mode 3 : QHD : 960 x 540 x 24 bpp.
> > + QHD,
> > + QHD_OSC_FREQUENCY,
> > + {QHD_H_RES_PIXELS, QHD_H_SYNC, QHD_H_BACK_PORCH,
> QHD_H_FRONT_PORCH},
> > + {QHD_V_RES_PIXELS, QHD_V_SYNC, QHD_V_BACK_PORCH,
> QHD_V_FRONT_PORCH}
> > + },
> > + {
> > + // Mode 4 : WSVGA : 1024 x 600 x 24 bpp.
> > + WSVGA,
> > + WSVGA_OSC_FREQUENCY,
> > + {WSVGA_H_RES_PIXELS, WSVGA_H_SYNC, WSVGA_H_BACK_PORCH,
> WSVGA_H_FRONT_PORCH},
> > + {WSVGA_V_RES_PIXELS, WSVGA_V_SYNC, WSVGA_V_BACK_PORCH,
> WSVGA_V_FRONT_PORCH}
> > + },
> > + {
> > + // Mode 5 : XGA : 1024 x 768 x 24 bpp.
> > + XGA,
> > + XGA_OSC_FREQUENCY,
> > + {XGA_H_RES_PIXELS, XGA_H_SYNC, XGA_H_BACK_PORCH,
> XGA_H_FRONT_PORCH},
> > + {XGA_V_RES_PIXELS, XGA_V_SYNC, XGA_V_BACK_PORCH,
> XGA_V_FRONT_PORCH}
> > + },
> > + {
> > + // Mode 6 : HD : 1280 x 720 x 24 bpp.
> > + HD720,
> > + HD720_OSC_FREQUENCY,
> > + {HD720_H_RES_PIXELS, HD720_H_SYNC, HD720_H_BACK_PORCH,
> HD720_H_FRONT_PORCH},
> > + {HD720_V_RES_PIXELS, HD720_V_SYNC, HD720_V_BACK_PORCH,
> HD720_V_FRONT_PORCH}
> > + },
> > + {
> > + // Mode 7 : WXGA : 1280 x 800 x 24 bpp.
> > + WXGA,
> > + WXGA_OSC_FREQUENCY,
> > + {WXGA_H_RES_PIXELS, WXGA_H_SYNC, WXGA_H_BACK_PORCH,
> WXGA_H_FRONT_PORCH},
> > + {WXGA_V_RES_PIXELS, WXGA_V_SYNC, WXGA_V_BACK_PORCH,
> WXGA_V_FRONT_PORCH}
> > + },
> > + { // Mode 8 : SXGA : 1280 x 1024 x 24 bpp.
> > + SXGA,
> > + SXGA_OSC_FREQUENCY,
> > + {SXGA_H_RES_PIXELS, SXGA_H_SYNC, SXGA_H_BACK_PORCH,
> SXGA_H_FRONT_PORCH},
> > + {SXGA_V_RES_PIXELS, SXGA_V_SYNC, SXGA_V_BACK_PORCH,
> SXGA_V_FRONT_PORCH}
> > + },
> > + { // Mode 9 : WSXGA+ : 1680 x 1050 x 24 bpp.
> > + WSXGA,
> > + WSXGA_OSC_FREQUENCY,
> > + {WSXGA_H_RES_PIXELS, WSXGA_H_SYNC, WSXGA_H_BACK_PORCH,
> WSXGA_H_FRONT_PORCH},
> > + {WSXGA_V_RES_PIXELS,WSXGA_V_SYNC, WSXGA_V_BACK_PORCH,
> WSXGA_V_FRONT_PORCH}
> > + },
> > + {
> > + // Mode 10 : HD : 1920 x 1080 x 24 bpp.
> > + HD,
> > + HD_OSC_FREQUENCY,
> > + {HD_H_RES_PIXELS, HD_H_SYNC, HD_H_BACK_PORCH,
> HD_H_FRONT_PORCH},
> > + {HD_V_RES_PIXELS, HD_V_SYNC, HD_V_BACK_PORCH,
> HD_V_FRONT_PORCH}
> > + }
> > +};
> > +
> > +/** If PcdArmMaliDpMaxMode is 0, platform supports full range of
> modes
> > + * else platform supports modes from 0 to PcdArmMaliDpMaxMode - 1
> > +**/
> > +STATIC CONST UINT32 mMaxMode = ((FixedPcdGet32
> (PcdArmMaliDpMaxMode) != 0)
> > + ? FixedPcdGet32 (PcdArmMaliDpMaxMode)
> > + : sizeof (mDisplayModes) / sizeof (DISPLAY_MODE));
> > +
> > +
> > +/** Platform related initialization function.
> > + *
> > + * @retval EFI_SUCCESS Platform initialization success.
> > + * @retval EFI_UNSUPPORTED PcdGopPixelFormat must be
> > + * PixelRedGreenBlueReserved8BitPerColor OR
> > + * PixelBlueGreenRedReserved8BitPerColor
> > + * any other format is not supported.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformInitializeDisplay (
> > + IN CONST EFI_HANDLE Handle
> > + )
> > +{
> > + EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
> > +
> > + (VOID)Handle;
> > +
> > + // PixelBitMask and PixelBltOnly pixel formats are not supported
> > + PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> > + if (PixelFormat != PixelRedGreenBlueReserved8BitPerColor
> > + && PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
> > +
> > + ASSERT (PixelFormat == PixelRedGreenBlueReserved8BitPerColor
> > + || PixelFormat == PixelBlueGreenRedReserved8BitPerColor);
> > + return EFI_UNSUPPORTED;
> > + }
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Reserve VRAM memory in DRAM for the frame buffer
> > + *
> > + * (unless it is reserved already).
> > + *
> > + * The allocated address can be used to set the frame buffer as a base
> buffer
> > + * address for any layer of the ARM Mali DP.
> > + *
> > + * @param OUT VramBaseAddress A pointer to the frame buffer
> address.
> > + * @param OUT VramSize A pointer to the size of the frame
> > + * buffer in bytes
> > + *
> > + * @retval EFI_SUCCESS Frame buffer memory allocation success.
> > + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize
> are NULL.
> > + * @retval EFI_UNSUPPORTED Allocated address wider than 40 bits
> > + * @retval !EFI_SUCCESS Other errors.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformGetVram (
> > + OUT EFI_PHYSICAL_ADDRESS * CONST VramBaseAddress,
> > + OUT UINTN * CONST VramSize
> > + )
> > +{
> > + EFI_STATUS Status;
> > +
> > + // Check VramBaseAddress and VramSize are not NULL.
> > + if (VramBaseAddress == NULL || VramSize == NULL) {
> > + ASSERT (VramBaseAddress != NULL);
> > + ASSERT (VramSize != NULL);
> > + return EFI_INVALID_PARAMETER;
> > + }
> > +
> > + // Set the VRAM size.
> > + *VramSize = (UINTN)FixedPcdGet32 (PcdArmLcdDdrFrameBufferSize);
> > +
> > + // Check if memory is already reserved for the frame buffer.
> > +#if (FixedPcdGet64 (PcdArmLcdDdrFrameBufferBase) != 0)
> > +
> > +#if (!DP_VALID_BASE_ADDR (FixedPcdGet64
> (PcdArmLcdDdrFrameBufferBase)))
> > +#error ARM Mali DP frame buffer base address cannot be wider than 40
> bits.
> > +#else
> > +
> > + *VramBaseAddress =
> > + (EFI_PHYSICAL_ADDRESS)FixedPcdGet64
> (PcdArmLcdDdrFrameBufferBase);
> > +
> > + Status = EFI_SUCCESS;
> > +#endif
> > +
> > +#else
> > + // If not already reserved, attempt to allocate the VRAM from the
> DRAM.
> > + Status = gBS->AllocatePages (
> > + AllocateAnyPages,
> > + EfiBootServicesData,
> > + EFI_SIZE_TO_PAGES (*VramSize),
> > + VramBaseAddress
> > + );
> > +
> > + if (EFI_ERROR (Status)) {
> > + DEBUG ((DEBUG_ERROR, "ArmMaliDpLib: Failed to allocate frame
> buffer.\n"));
> > + ASSERT_EFI_ERROR (Status);
> > + return Status;
> > + }
> > +
> > + // ARM Mali DP frame buffer base address can not be wider than 40
> bits.
> > + if (!DP_VALID_BASE_ADDR (*VramBaseAddress)) {
> > + gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> (*VramSize));
> > + ASSERT (DP_VALID_BASE_ADDR (*VramBaseAddress));
> > + return EFI_UNSUPPORTED;
> > + }
> > +
> > + /* Mark the VRAM as write-combining. The VRAM is inside the DRAM,
> which is cacheable.
> > + * For ARM/AArch64 EFI_MEMORY_WC memory is actually uncached.
> > + */
> > + Status = gDS->SetMemorySpaceAttributes (
> > + *VramBaseAddress,
> > + *VramSize,
> > + EFI_MEMORY_WC
> > + );
> > +
> > + if (EFI_ERROR (Status)) {
> > + ASSERT_EFI_ERROR (Status);
> > + gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES
> (*VramSize));
> > + }
> > +
> > +#endif
> > + return Status;
> > +}
> > +
> > +/** Return total number of modes supported.
> > + *
> > + * Note: Valid mode numbers are 0 to MaxMode - 1
> > + * See Section 12.9 of the UEFI Specification 2.7
> > + *
> > + * @retval UINT32 Mode Number.
> > +**/
> > +UINT32
> > +LcdPlatformGetMaxMode (VOID)
> > +{
> > + return mMaxMode;
> > +}
> > +
> > +/** Set the requested display mode.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + *
> > + * @retval EFI_SUCCESS Set mode success.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformSetMode (
> > + IN CONST UINT32 ModeNumber
> > + )
> > +{
> > +
> > + if (ModeNumber >= mMaxMode) {
> > + ASSERT (ModeNumber < mMaxMode);
> > + return EFI_INVALID_PARAMETER;
> > + }
> > + /* On models, platform specific clock/mux settings are not required
> > + * Display controller specific settings for Mali DP are done in
> LcdSetMode.
> > + */
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Return information for the requested mode number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT Info Pointer for returned mode information
> > + * (on success).
> > + *
> > + * @retval EFI_SUCCESS Requested mode found.
> > + * @retval EFI_INVALID_PARAMETER Info is NULL.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformQueryMode (
> > + IN CONST UINT32 ModeNumber,
> > + OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info
> > + )
> > +{
> > + if (ModeNumber >= mMaxMode || Info == NULL) {
> > + ASSERT (ModeNumber < mMaxMode);
> > + ASSERT (Info != NULL);
> > + return EFI_INVALID_PARAMETER;
> > + }
> > +
> > + Info->Version = 0;
> > + Info->HorizontalResolution =
> mDisplayModes[ModeNumber].Horizontal.Resolution;
> > + Info->VerticalResolution =
> mDisplayModes[ModeNumber].Vertical.Resolution;
> > + Info->PixelsPerScanLine =
> mDisplayModes[ModeNumber].Horizontal.Resolution;
> > +
> > + Info->PixelFormat = FixedPcdGet32 (PcdGopPixelFormat);
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Returns the display timing information for the requested mode
> number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT Horizontal Pointer to horizontal timing
> parameters.
> > + * (Resolution, Sync, Back porch, Front porch)
> > + * @param OUT Vertical Pointer to vertical timing parameters.
> > + * (Resolution, Sync, Back porch, Front porch)
> > + *
> > + * @retval EFI_SUCCESS Requested mode found.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > + * @retval EFI_INVALID_PARAMETER One of the OUT parameters is
> NULL.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformGetTimings (
> > + IN UINT32 ModeNumber,
> > + OUT CONST SCAN_TIMINGS ** Horizontal,
> > + OUT CONST SCAN_TIMINGS ** Vertical
> > + )
> > +{
> > + if (ModeNumber >= mMaxMode || Horizontal == NULL || Vertical ==
> NULL) {
> > + ASSERT (ModeNumber < mMaxMode);
> > + // One of the pointers is NULL
> > + ASSERT (Horizontal != NULL);
> > + ASSERT (Vertical != NULL);
> > + return EFI_INVALID_PARAMETER;
> > + }
> > +
> > + *Horizontal = &mDisplayModes[ModeNumber].Horizontal;
> > + *Vertical = &mDisplayModes[ModeNumber].Vertical;
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Return bytes per pixel information for a mode number.
> > + *
> > + * @param IN ModeNumber Mode Number.
> > + * @param OUT Bpp Pointer to value Bytes Per Pixel.
> > + *
> > + * @retval EFI_SUCCESS The requested mode is found.
> > + * @retval EFI_INVALID_PARAMETER Requested mode not found.
> > + * @retval EFI_INVALID_PARAMETER Bpp is NULL.
> > +**/
> > +EFI_STATUS
> > +LcdPlatformGetBpp (
> > + IN CONST UINT32 ModeNumber,
> > + OUT LCD_BPP * CONST Bpp
> > + )
> > +{
> > + if (ModeNumber >= mMaxMode || Bpp == NULL) {
> > + // Check valid ModeNumber and Bpp.
> > + ASSERT (ModeNumber < mMaxMode);
> > + ASSERT (Bpp != NULL);
> > + return EFI_INVALID_PARAMETER;
> > + }
> > +
> > + *Bpp = LCD_BITS_PER_PIXEL_24;
> > +
> > + return EFI_SUCCESS;
> > +}
> > diff --git
> a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSM
> Mem.c
> b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSM
> Mem.c
> > index
> 5cd529750a3d2d3b0d381b58d875d378afaba2c2..87a7a26132e39b933ec
> d2a95e38b2ab869cd4079 100644
> > ---
> a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSM
> Mem.c
> > +++
> b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSM
> Mem.c
> > @@ -21,9 +21,10 @@
> > #include <ArmPlatform.h>
> >
> > #define FRAME_BUFFER_DESCRIPTOR ((FixedPcdGet64
> (PcdArmLcdDdrFrameBufferBase) != 0) ? 1 : 0)
> > +#define DP_BASE_DESCRIPTOR ((FixedPcdGet64
> (PcdArmMaliDpBase) != 0) ? 1 : 0)
> >
> > // Number of Virtual Memory Map Descriptors
> > -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 +
> FRAME_BUFFER_DESCRIPTOR)
> > +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS (9 +
> FRAME_BUFFER_DESCRIPTOR + DP_BASE_DESCRIPTOR)
> >
> > // DDR attributes
> > #define DDR_ATTRIBUTES_CACHED
> ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
> > @@ -159,6 +160,13 @@ ArmPlatformGetVirtualMemoryMap (
> > VirtualMemoryTable[Index].Attributes =
> ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED;
> > #endif
> >
> > +#if (FixedPcdGet64 (PcdArmMaliDpBase) != 0)
> > + // DP500/DP550/DP650 peripheral memory region
> > + VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64
> (PcdArmMaliDpBase);
> > + VirtualMemoryTable[Index].VirtualBase = FixedPcdGet64
> (PcdArmMaliDpBase);
> > + VirtualMemoryTable[Index].Length = FixedPcdGet32
> (PcdArmMaliDpMemoryRegionLength);
> > + VirtualMemoryTable[Index].Attributes =
> ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> > +#endif
> > // Map sparse memory region if present
> > if (HasSparseMemory) {
> > VirtualMemoryTable[++Index].PhysicalBase = SparseMemoryBase;
> > diff --git a/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c
> b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c
> > new file mode 100644
> > index
> 0000000000000000000000000000000000000000..ff7236371d27915d9f1
> e34162dce0954dde63a77
> > --- /dev/null
> > +++ b/ArmPlatformPkg/Drivers/ArmMaliDp/ArmMaliDp.c
> > @@ -0,0 +1,412 @@
> > +/** @file ArmMaliDp.c
> > +
> > + ARM Mali DP 500/550/650 display controller driver
> > +
> > + Copyright (c) 2017, ARM Ltd. All rights reserved.<BR>
> > +
> > + This program and the accompanying materials
> > + are licensed and made available under the terms and conditions of the
> BSD License
> > + which accompanies this distribution. The full text of the license may be
> found at
> > + http://opensource.org/licenses/bsd-license.php
> > +
> > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> > +
> > +**/
> > +
> > +#include <Library/IoLib.h>
> > +#include <Library/DebugLib.h>
> > +#include <Library/LcdPlatformLib.h>
> > +#include <Library/MemoryAllocationLib.h>
> > +#include <Drivers/ArmMaliDp.h>
> > +#include <Drivers/LcdHw.h>
> > +
> > +// CORE_ID of the MALI DP
> > +STATIC UINT32 gDpDeviceId;
> > +
> > +/** Disable the graphics layer
> > + *
> > + * This is done by clearing the EN bit
> > + * of the LG_CONTROL register.
> > +**/
> > +STATIC
> > +VOID
> > +LayerGraphicsDisable (VOID)
> > +{
> > + MmioAnd32 (DP_BASE + DP_DE_LG_CONTROL, ~DP_DE_LG_ENABLE);
> > +}
> > +
> > +/** Enable the graphics layer
> > + *
> > + * This is done by setting the EN bit
> > + * of the LG_CONTROL register.
> > +**/
> > +STATIC
> > +VOID
> > +LayerGraphicsEnable (VOID)
> > +{
> > + MmioOr32 (DP_BASE + DP_DE_LG_CONTROL, DP_DE_LG_ENABLE);
> > +}
> > +
> > +/** Set the frame address of the graphics layer.
> > + *
> > + * @param FrameBaseAddress Address of the data buffer
> > + * to be used as a frame buffer.
> > +**/
> > +STATIC
> > +VOID
> > +LayerGraphicsSetFrame (
> > + IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
> > + )
> > +{
> > + // Disable the graphics layer.
> > + LayerGraphicsDisable ();
> > +
> > + /* Set up memory address of the data buffer for graphics layer.
> > + * write lower bits of the address.
> > + */
> > + MmioWrite32 (
> > + DP_BASE + DP_DE_LG_PTR_LOW,
> > + DP_DE_LG_PTR_LOW_MASK & FrameBaseAddress
> > + );
> > +
> > + // Write higher bits of the address.
> > + MmioWrite32 (
> > + DP_BASE + DP_DE_LG_PTR_HIGH,
> > + (UINT32)(FrameBaseAddress >> DP_DE_LG_PTR_HIGH_SHIFT)
> > + );
> > +
> > + // Enable the graphics layer.
> > + LayerGraphicsEnable ();
> > +}
> > +
> > +/** Configures various graphics layer characteristics.
> > + *
> > + * @param HRes Horizontal resolution of the graphics layer.
> > + * @param VRes Vertical resolution of the graphics layer.
> > +**/
> > +STATIC
> > +VOID
> > +LayerGraphicsConfig (
> > + IN CONST EFI_GRAPHICS_PIXEL_FORMAT UefiGfxPixelFormat,
> > + IN CONST UINT32 HRes,
> > + IN CONST UINT32 VRes
> > + )
> > +{
> > + UINT32 PixelFormat;
> > +
> > + // Disable the graphics layer before configuring any settings.
> > + LayerGraphicsDisable ();
> > +
> > + // Setup graphics layer size.
> > + MmioWrite32 (DP_BASE + DP_DE_LG_IN_SIZE, FRAME_IN_SIZE (HRes,
> VRes));
> > +
> > + // Setup graphics layer composition size.
> > + MmioWrite32 (DP_BASE + DP_DE_LG_CMP_SIZE, FRAME_CMP_SIZE
> (HRes, VRes));
> > +
> > + // Setup memory stride (total visible pixels on a line * 4 ).
> > + MmioWrite32 (DP_BASE + DP_DE_LG_H_STRIDE, (HRes * sizeof
> (UINT32)));
> > +
> > + /* Set the format.
> > + *
> > + * In PixelBlueGreenRedReserved8BitPerColor format, byte 0 represents
> blue,
> > + * byte 1 represents green, and byte 2 represents red, and byte 3 is
> reserved
> > + * which is equivalent to XRGB format of the DP500/DP550/DP650.
> Whereas
> > + * PixelRedGreenBlueReserved8BitPerColor is equivalent to XBGR of the
> > + * DP500/DP550/DP650.
> > + */
> > + if (UefiGfxPixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
> > + PixelFormat = (gDpDeviceId == MALIDP_500) ?
> DP_PIXEL_FORMAT_DP500_XRGB_8888
> > + : DP_PIXEL_FORMAT_XRGB_8888;
> > + } else {
> > + PixelFormat = (gDpDeviceId == MALIDP_500) ?
> DP_PIXEL_FORMAT_DP500_XBGR_8888
> > + : DP_PIXEL_FORMAT_XBGR_8888;
> > + }
> > +
> > + MmioWrite32 (DP_BASE + DP_DE_LG_FORMAT, PixelFormat);
> > +
> > + // Enable graphics layer.
> > + LayerGraphicsEnable ();
> > +}
> > +
> > +/** Configure timing information of the display.
> > + * @param IN Horizontal Pointer to horizontal timing parameters.
> > + * (Resolution, Sync, Back porch, Front porch)
> > + * @param IN Vertical Pointer to vertical timing parameters.
> > + * (Resolution, Sync, Back porch, Front porch)
> > +**/
> > +STATIC
> > +VOID
> > +SetDisplayEngineTiming (
> > + IN CONST SCAN_TIMINGS * CONST Horizontal,
> > + IN CONST SCAN_TIMINGS * CONST Vertical
> > + )
> > +{
> > + UINTN RegHIntervals;
> > + UINTN RegVIntervals;
> > + UINTN RegSyncControl;
> > + UINTN RegHVActiveSize;
> > +
> > + if (gDpDeviceId == MALIDP_500) {
> > + // MALI DP500 timing registers.
> > + RegHIntervals = DP_BASE + DP_DE_DP500_H_INTERVALS;
> > + RegVIntervals = DP_BASE + DP_DE_DP500_V_INTERVALS;
> > + RegSyncControl = DP_BASE + DP_DE_DP500_SYNC_CONTROL;
> > + RegHVActiveSize = DP_BASE + DP_DE_DP500_HV_ACTIVESIZE;
> > + } else {
> > + // MALI DP550/DP650 timing registers.
> > + RegHIntervals = DP_BASE + DP_DE_H_INTERVALS;
> > + RegVIntervals = DP_BASE + DP_DE_V_INTERVALS;
> > + RegSyncControl = DP_BASE + DP_DE_SYNC_CONTROL;
> > + RegHVActiveSize = DP_BASE + DP_DE_HV_ACTIVESIZE;
> > + }
> > +
> > + // Horizontal back porch and front porch.
> > + MmioWrite32 (
> > + RegHIntervals,
> > + H_INTERVALS (Horizontal->FrontPorch, Horizontal->BackPorch)
> > + );
> > +
> > + // Vertical back porch and front porch.
> > + MmioWrite32 (
> > + RegVIntervals,
> > + V_INTERVALS (Vertical->FrontPorch, Vertical->BackPorch)
> > + );
> > +
> > + // Sync control, Horizontal and Vertical sync.
> > + MmioWrite32 (
> > + RegSyncControl,
> > + SYNC_WIDTH (Horizontal->Sync, Vertical->Sync)
> > + );
> > +
> > + // Set up Horizontal and Vertical area size.
> > + MmioWrite32 (
> > + RegHVActiveSize,
> > + HV_ACTIVE (Horizontal->Resolution, Vertical->Resolution)
> > + );
> > +}
> > +
> > +/** Return CORE_ID of the ARM Mali DP.
> > + *
> > + * @retval 0 No Mali DP found.
> > + * @retval 0x500 Mali DP core id for DP500.
> > + * @retval 0x550 Mali DP core id for DP550.
> > + * @retval 0x650 Mali DP core id for DP650.
> > +**/
> > +STATIC
> > +UINT32
> > +ArmMaliDpGetCoreId (
> > + )
> > +{
> > + UINT32 DpCoreId;
> > +
> > + /* First check for DP500 as register offset for DP550/DP650 CORE_ID
> > + * is beyond 3K/4K register space of the DP500.
> > + */
> > + DpCoreId = MmioRead32 (DP_BASE + DP_DE_DP500_CORE_ID);
> > + DpCoreId >>= DP_DE_DP500_CORE_ID_SHIFT;
> > +
> > + if (DpCoreId == MALIDP_500) {
> > + return DpCoreId;
> > + }
> > +
> > + // Check for DP550 or DP650.
> > + DpCoreId = MmioRead32 (DP_BASE + DP_DC_CORE_ID);
> > + DpCoreId >>= DP_DC_CORE_ID_SHIFT;
> > +
> > + if (DpCoreId == MALIDP_550
> > + || DpCoreId == MALIDP_650) {
> > + return DpCoreId;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +/** Check for presence of MALI.
> > + *
> > + * This function returns success if the platform implements
> > + * DP500/DP550/DP650 ARM Mali display processor.
> > + *
> > + * @retval EFI_SUCCESS Platform implements
> DP500/DP550/DP650.
> > + * @retval EFI_NOT_FOUND DP500/DP550/DP650 display
> processor not
> > + * found on the platform.
> > +**/
> > +EFI_STATUS
> > +LcdIdentify (VOID)
> > +{
> > + UINT32 DpCoreId;
> > +
> > + DEBUG ((DEBUG_WARN,
> > + "Probing ARM Mali DP500/DP550/DP650 at base address 0x%p\n",
> > + DP_BASE
> > + ));
> > +
> > +#if (DP_BASE == 0)
> > +#error "ARM Mali DP peripheral base address is invalid\n"
> > +#endif
> > +
> > + DpCoreId = ArmMaliDpGetCoreId ();
> > +
> > + if (DpCoreId != 0) {
> > + DEBUG ((DEBUG_WARN, "Found ARM Mali DP %x\n", DpCoreId));
> > + return EFI_SUCCESS;
> > + }
> > +
> > + DEBUG ((DEBUG_WARN, "ARM Mali DP not found...\n"));
> > +
> > + return EFI_NOT_FOUND;
> > +}
> > +
> > +/** Initialize platform display.
> > + *
> > + * @param FrameBaseAddress Address of the frame buffer.
> > + *
> > + * @retval EFI_SUCCESS Display initialization success.
> > + * @retval !(EFI_SUCCESS) Display initialization failure.
> > +**/
> > +EFI_STATUS
> > +LcdInitialize (
> > + IN CONST EFI_PHYSICAL_ADDRESS FrameBaseAddress
> > + )
> > +{
> > + DEBUG ((DEBUG_WARN, "Frame buffer base address = %p\n",
> FrameBaseAddress));
> > +
> > + gDpDeviceId = ArmMaliDpGetCoreId ();
> > + if (gDpDeviceId == 0) {
> > + DEBUG ((DEBUG_ERROR, "ARM Mali DP initialization fail,"
> > + "no ARM Mali DP present\n"));
> > + return EFI_NOT_FOUND;
> > + }
> > +
> > + // We are using graphics layer of the Mali DP as a main frame buffer.
> > + LayerGraphicsSetFrame (FrameBaseAddress);
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/** Set ARM Mali DP in cofiguration mode.
> > + *
> > + * The ARM Mali DP must be in the configuration mode for
> > + * configuration of the H_INTERVALS, V_INTERVALS, SYNC_CONTROL
> > + * and HV_ACTIVESIZE.
> > +**/
> > +STATIC
> > +VOID
> > +SetConfigurationMode (VOID)
> > +{
> > + // Request configuration Mode.
> > + if (gDpDeviceId == MALIDP_500) {
> > + MmioOr32 (DP_BASE + DP_DE_DP500_CONTROL,
> DP_DE_DP500_CONTROL_CONFIG_REQ);
> > + } else {
> > + MmioOr32 (DP_BASE + DP_DC_CONTROL,
> DP_DC_CONTROL_CM_ACTIVE);
> > + }
> > +}
> > +
> > +/** Set ARM Mali DP in normal mode.
> > + *
> > + * Normal mode is the main operating mode of the display processor
> > + * in which display layer data is fetched from frame buffer and
> > + * displayed.
> > +**/
> > +STATIC
> > +VOID
> > +SetNormalMode (VOID)
> > +{
> > + // Disable configuration Mode.
> > + if (gDpDeviceId == MALIDP_500) {
> > + MmioAnd32 (DP_BASE + DP_DE_DP500_CONTROL,
> ~DP_DE_DP500_CONTROL_CONFIG_REQ);
> > + } else {
> > + MmioAnd32 (DP_BASE + DP_DC_CONTROL,
> ~DP_DC_CONTROL_CM_ACTIVE );
> > + }
> > +}
> > +
> > +/** Set the global configuration valid flag.
> > + *
> > + * Any new configuration parameters written to the display engine are
> not
> > + * activated until the global configuration valid flag is set in the
> > + * CONFIG_VALID register.
> > +**/
> > +STATIC
> > +VOID
> > +SetConfigValid (VOID)
> > +{
> > + if (gDpDeviceId == MALIDP_500) {
> > + MmioOr32 (DP_BASE + DP_DP500_CONFIG_VALID,
> DP_DC_CONFIG_VALID);
> > + } else {
> > + MmioOr32 (DP_BASE + DP_DC_CONFIG_VALID,
> DP_DC_CONFIG_VALID );
> > + }
> > +}
> > +
> > +/** Set requested mode of the display.
> > + *
> > + * @param ModeNumber Display mode number.
> > + * @retval EFI_SUCCESS Display set mode success.
> > + * @retval EFI_DEVICE_ERROR If mode not found/supported.
> > + * @retval EFI_DEVICE_ERROR If mode does not support more
> > + * than 24 bytes per pixel format.
> > +**/
> > +EFI_STATUS
> > +LcdSetMode (
> > + IN CONST UINT32 ModeNumber
> > + )
> > +{
> > + EFI_STATUS Status;
> > + CONST SCAN_TIMINGS *Horizontal;
> > + CONST SCAN_TIMINGS *Vertical;
> > +
> > + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo;
> > +
> > + // Get the display mode timings and other relevant information.
> > + Status = LcdPlatformGetTimings (
> > + ModeNumber,
> > + &Horizontal,
> > + &Vertical
> > + );
> > +
> > + if (EFI_ERROR (Status)) {
> > + ASSERT_EFI_ERROR (Status);
> > + return Status;
> > + }
> > + ASSERT (Horizontal != NULL);
> > + ASSERT (Vertical != NULL);
> > +
> > + // Get the pixel format information.
> > + Status = LcdPlatformQueryMode (ModeNumber, &ModeInfo);
> > + if (EFI_ERROR (Status)) {
> > + ASSERT_EFI_ERROR (Status);
> > + return Status;
> > + }
> > +
> > + // Request configuration mode.
> > + SetConfigurationMode ();
> > +
> > + // Configure the graphics layer.
> > + LayerGraphicsConfig (
> > + ModeInfo.PixelFormat,
> > + Horizontal->Resolution,
> > + Vertical->Resolution
> > + );
> > +
> > + // Set the display engine timings.
> > + SetDisplayEngineTiming (Horizontal, Vertical);
> > +
> > + // After configuration, set Mali DP in normal mode.
> > + SetNormalMode ();
> > +
> > + /* Any parameters written to the display engine are not activated until
> > + * CONFIG_VALID is set.
> > + */
> > + SetConfigValid ();
> > +
> > + return EFI_SUCCESS;
> > +}
> > +
> > +/**
> > + * This function de-initializes the display.
> > +**/
> > +VOID
> > +LcdShutdown (VOID)
> > +{
> > + // Disable graphics layer.
> > + LayerGraphicsDisable ();
> > +}
> > --
> > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
> >
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver.
2017-12-01 13:12 ` Evan Lloyd
@ 2017-12-01 17:18 ` Ard Biesheuvel
2017-12-05 20:03 ` Evan Lloyd
2017-12-01 17:29 ` Leif Lindholm
1 sibling, 1 reply; 69+ messages in thread
From: Ard Biesheuvel @ 2017-12-01 17:18 UTC (permalink / raw)
To: Evan Lloyd
Cc: edk2-devel@lists.01.org, Matteo Carlini, Leif Lindholm,
Girish Pathak
On 1 December 2017 at 13:12, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>
>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 28 November 2017 18:18
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: edk2-devel@lists.01.org; Matteo Carlini <Matteo.Carlini@arm.com>;
>> Leif Lindholm <leif.lindholm@linaro.org>; Girish Pathak
>> <Girish.Pathak@arm.com>
>> Subject: Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650
>> GOP driver.
>>
>> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
>> > From: Girish Pathak <girish.pathak@arm.com>
>> >
>> > This change adds support for the ARM Mali DP500/DP500/DP650 display
>> > processors using the GOP protocol. It has been tested on FVP base
>> > models + DP550 support.
>> >
>> > This change does not modify functionality provided by PL111 or
>> > HDLCD. The driver should be suitable for those platforms
>> > that implement ARM Mali DP500/DP550/DP650 replacing PL111/HDLCD.
>> >
>> > Only "Layer Graphics" of the ARM Mali DP is configured for rendering
>> > the RGB/BGR format frame buffer to satisfy the UEFI GOP requirements
>> > Other layers e.g. video layers are not configured.
>> >
>> > NOTE: This change implements the Mali DP on models. Versions for actual
>> > hardware are liable to require extra handling for clock input changes,
>> > etc.
>> >
>> > 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>
>>
>> Hello Girish, Evan,
>>
>> (replying to 19/19 because I cannot find the cover letter in my
>> edk2-devel archive but this really applies to the whole series)
>>
>> I have been looking at these patches again now that I am trying to
>> clean up ArmPlatformPkg, which is currently a dumping ground for all
>> things vaguely ARM related, and is also structured quite differently
>> from other packages.
>>
>> Ideally, ArmPlatformPkg should only contain the following:
>> - library class interfaces under Include/Library; header files kept
>> here should only contain elements that define API
>> - driver specific include files Include/IndustryStandard but *only* if
>> they cannot be kept locally with the driver in question
>> - libraries under Library/
>> - drivers under Drivers/
>>
>> This aligns with the common arrangement adopted by most EDK2 packages.
>>
>> This series does many different things, and does not distinguish at
>> all between common code and code living under ArmVExpressPkg. Given
>
> [[Evan Lloyd]] All of the commits in the series are in ArmPlatformPkg.
> You may be in the process of disentangling the VE specific bits, but hitherto that has not been a consideration. (Note: I'm not arguing against the disentangling, only pointing out that it was not a factor at the point we submitted the patches)
> The reason there are so many commits is only that we have been asked to break things up into "bite sized" chunks for the convenience of maintainers.
> The aim was to make each a coherent item with a simple justification.
>
>> that I am trying to move ArmVExpressPkg out of EDK2 into
>> edk2-platforms (where it arguably belongs) having this series in limbo
>> for two months is basically blocking my work, and so I would like to
>> explore ways to proceed with this without interfering with each
>> other's work too much. At the same time, the way the code is
>> structured is a continuation of the pattern I am trying to get rid of,
>> so they will need some rework anyway in order to be upstreamable IMHO.
>
> [[Evan Lloyd]] Not being psychic, we had not made allowance for your plans.
> However, if you take the trouble to look at the changes, they achieve exactly the split you aim for.
> The display type code (PL011 and HDLCD) is unravelled from the VE code.
> All that remains would be to move the VE specific part into edk2-platforms.
>
>>
>> So could we split it up please? Assuming the intention is the ability
>> to reuse the Mali code on non-VExpress platforms, I would like to see
>> that code proposed separately, without any mention of VExpressPkg.dec
>
> [[Evan Lloyd]] Given that the original code was unfortunate, I'm not sure that it makes much difference what order the changes get made.
> Going West then North gets you to the same place as North then West (except near a pole).
> If you accept that there was a logical progression in the changes made, then it might be better to not rejig things pointlessly.
>
>> whatsoever. If you introduce any library classes that abstract away
>> the differences between platforms, you can include a Null version of
>> such a library that simply does ASSERT (FALSE) in every function: this
>
> [[Evan Lloyd]] One could, indeed, do that. We, however, would be very reluctant to incur the overhead of rework in response to spurious cavils from a maintainer when it is of no direct relevance to us.
>
I don't think the suggestion that we evil maintainers are nothing but
an impediment to the likes of you and your team members doing the
actual work is justified.
We are all on the same team here, and the goal is to make UEFI code
reusable for the customers of /your/ employer. Throwing stuff over the
fence != upstreaming, and it is my job as a maintainer to ensure that
code is still maintainable long after the original authors have moved
on to something else.
ArmPlatformPkg is a perfect example where code reuse is much more
difficult than it needs to be, and we as maintainers need to deal with
contributors from other companies that have used it as 'guidance' for
how to architect their UEFI firmware, which is usually filled with
vexpress-isms that date back to before anyone currently involved with
UEFI can remember.
This is why I have taken the time to sit down, go through all the crap
code, clean it up, refactor it and propose it on the list as
improvements. I even went so far as taking the preparatory Mali work
of your team and rebase it so that we can keep the bits that we may
share, and move the bits out that should not be kept in main EDK2
because they are being taken as gospel by engineers that are new to
ARM+UEFI.
If this is too much to deal with for you, then fine, don't upstream
your code. But if you do, you are going to have to play nice with the
others, including the maintainers.
--
Ard.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver.
2017-12-01 17:18 ` Ard Biesheuvel
@ 2017-12-05 20:03 ` Evan Lloyd
2017-12-05 21:27 ` Ard Biesheuvel
0 siblings, 1 reply; 69+ messages in thread
From: Evan Lloyd @ 2017-12-05 20:03 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: edk2-devel@lists.01.org, Matteo Carlini, Leif Lindholm,
Girish Pathak
> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 01 December 2017 17:19
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; Matteo Carlini <Matteo.Carlini@arm.com>;
> Leif Lindholm <leif.lindholm@linaro.org>; Girish Pathak
> <Girish.Pathak@arm.com>
> Subject: Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650
> GOP driver.
>
> On 1 December 2017 at 13:12, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> >> Sent: 28 November 2017 18:18
> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
> >> Cc: edk2-devel@lists.01.org; Matteo Carlini <Matteo.Carlini@arm.com>;
> >> Leif Lindholm <leif.lindholm@linaro.org>; Girish Pathak
> >> <Girish.Pathak@arm.com>
> >> Subject: Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650
> GOP
> >> driver.
> >>
> >> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
> >> > From: Girish Pathak <girish.pathak@arm.com>
> >> >
> >> > This change adds support for the ARM Mali DP500/DP500/DP650
> display
> >> > processors using the GOP protocol. It has been tested on FVP base
> >> > models + DP550 support.
> >> >
> >> > This change does not modify functionality provided by PL111 or
> >> > HDLCD. The driver should be suitable for those platforms that
> >> > implement ARM Mali DP500/DP550/DP650 replacing PL111/HDLCD.
> >> >
> >> > Only "Layer Graphics" of the ARM Mali DP is configured for
> >> > rendering the RGB/BGR format frame buffer to satisfy the UEFI GOP
> >> > requirements Other layers e.g. video layers are not configured.
> >> >
> >> > NOTE: This change implements the Mali DP on models. Versions for
> >> > actual hardware are liable to require extra handling for clock
> >> > input changes, etc.
> >> >
> >> > 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>
> >>
> >> Hello Girish, Evan,
> >>
> >> (replying to 19/19 because I cannot find the cover letter in my
> >> edk2-devel archive but this really applies to the whole series)
> >>
> >> I have been looking at these patches again now that I am trying to
> >> clean up ArmPlatformPkg, which is currently a dumping ground for all
> >> things vaguely ARM related, and is also structured quite differently
> >> from other packages.
> >>
> >> Ideally, ArmPlatformPkg should only contain the following:
> >> - library class interfaces under Include/Library; header files kept
> >> here should only contain elements that define API
> >> - driver specific include files Include/IndustryStandard but *only*
> >> if they cannot be kept locally with the driver in question
> >> - libraries under Library/
> >> - drivers under Drivers/
> >>
> >> This aligns with the common arrangement adopted by most EDK2
> packages.
> >>
> >> This series does many different things, and does not distinguish at
> >> all between common code and code living under ArmVExpressPkg. Given
> >
> > [[Evan Lloyd]] All of the commits in the series are in ArmPlatformPkg.
> > You may be in the process of disentangling the VE specific bits, but
> > hitherto that has not been a consideration. (Note: I'm not arguing against
> the disentangling, only pointing out that it was not a factor at the point we
> submitted the patches) The reason there are so many commits is only that
> we have been asked to break things up into "bite sized" chunks for the
> convenience of maintainers.
> > The aim was to make each a coherent item with a simple justification.
> >
> >> that I am trying to move ArmVExpressPkg out of EDK2 into
> >> edk2-platforms (where it arguably belongs) having this series in
> >> limbo for two months is basically blocking my work, and so I would
> >> like to explore ways to proceed with this without interfering with
> >> each other's work too much. At the same time, the way the code is
> >> structured is a continuation of the pattern I am trying to get rid
> >> of, so they will need some rework anyway in order to be upstreamable
> IMHO.
> >
> > [[Evan Lloyd]] Not being psychic, we had not made allowance for your
> plans.
> > However, if you take the trouble to look at the changes, they achieve
> exactly the split you aim for.
> > The display type code (PL011 and HDLCD) is unravelled from the VE code.
> > All that remains would be to move the VE specific part into edk2-
> platforms.
> >
> >>
> >> So could we split it up please? Assuming the intention is the ability
> >> to reuse the Mali code on non-VExpress platforms, I would like to see
> >> that code proposed separately, without any mention of VExpressPkg.dec
> >
> > [[Evan Lloyd]] Given that the original code was unfortunate, I'm not sure
> that it makes much difference what order the changes get made.
> > Going West then North gets you to the same place as North then West
> (except near a pole).
> > If you accept that there was a logical progression in the changes made,
> then it might be better to not rejig things pointlessly.
> >
> >> whatsoever. If you introduce any library classes that abstract away
> >> the differences between platforms, you can include a Null version of
> >> such a library that simply does ASSERT (FALSE) in every function:
> >> this
> >
> > [[Evan Lloyd]] One could, indeed, do that. We, however, would be very
> reluctant to incur the overhead of rework in response to spurious cavils
> from a maintainer when it is of no direct relevance to us.
> >
>
> I don't think the suggestion that we evil maintainers are nothing but an
> impediment to the likes of you and your team members doing the actual
> work is justified.
>
> We are all on the same team here, and the goal is to make UEFI code
> reusable for the customers of /your/ employer. Throwing stuff over the
> fence != upstreaming, and it is my job as a maintainer to ensure that code is
> still maintainable long after the original authors have moved on to
> something else.
>
> ArmPlatformPkg is a perfect example where code reuse is much more
> difficult than it needs to be, and we as maintainers need to deal with
> contributors from other companies that have used it as 'guidance' for how
> to architect their UEFI firmware, which is usually filled with vexpress-isms
> that date back to before anyone currently involved with UEFI can remember.
>
> This is why I have taken the time to sit down, go through all the crap code,
> clean it up, refactor it and propose it on the list as improvements. I even
> went so far as taking the preparatory Mali work of your team and rebase it
> so that we can keep the bits that we may share, and move the bits out that
> should not be kept in main EDK2 because they are being taken as gospel by
> engineers that are new to
> ARM+UEFI.
>
> If this is too much to deal with for you, then fine, don't upstream your code.
> But if you do, you are going to have to play nice with the others, including
> the maintainers.
>
[[Evan Lloyd]] Hi Ard. Firstly, I apologize, I assumed from your name that you were Dutch and would therefore probably have a lively sense of humour. Of course, if I have touched a nerve, that is unfortunate and I'm sorry.
I agree that cleaning up the code is important, worthwhile, and an objective for us all. What can be a difficulty is our very different conceptions of what clean means.
You should be aware though that a certain amount of whingeing is to be expected when dealing with Brits. (Ask Leif - he knows! Or any Australian.)
I do not disagree with your intent - but I do sometimes feel that the criteria applied do not take into account the cost/benefit aspects, and seek to air that point. I shall endeavour to make such points in a less bantering way in future.
Regards,
Evan
> --
> Ard.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver.
2017-12-05 20:03 ` Evan Lloyd
@ 2017-12-05 21:27 ` Ard Biesheuvel
2017-12-07 20:21 ` Evan Lloyd
0 siblings, 1 reply; 69+ messages in thread
From: Ard Biesheuvel @ 2017-12-05 21:27 UTC (permalink / raw)
To: Evan Lloyd
Cc: edk2-devel@lists.01.org, Matteo Carlini, Leif Lindholm,
Girish Pathak
On 5 December 2017 at 20:03, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>
>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 01 December 2017 17:19
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: edk2-devel@lists.01.org; Matteo Carlini <Matteo.Carlini@arm.com>;
>> Leif Lindholm <leif.lindholm@linaro.org>; Girish Pathak
>> <Girish.Pathak@arm.com>
>> Subject: Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650
>> GOP driver.
>>
>> On 1 December 2017 at 13:12, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>> >
>> >
>> >> -----Original Message-----
>> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> >> Sent: 28 November 2017 18:18
>> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> >> Cc: edk2-devel@lists.01.org; Matteo Carlini <Matteo.Carlini@arm.com>;
>> >> Leif Lindholm <leif.lindholm@linaro.org>; Girish Pathak
>> >> <Girish.Pathak@arm.com>
>> >> Subject: Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650
>> GOP
>> >> driver.
>> >>
>> >> On 26 September 2017 at 21:15, <evan.lloyd@arm.com> wrote:
>> >> > From: Girish Pathak <girish.pathak@arm.com>
>> >> >
>> >> > This change adds support for the ARM Mali DP500/DP500/DP650
>> display
>> >> > processors using the GOP protocol. It has been tested on FVP base
>> >> > models + DP550 support.
>> >> >
>> >> > This change does not modify functionality provided by PL111 or
>> >> > HDLCD. The driver should be suitable for those platforms that
>> >> > implement ARM Mali DP500/DP550/DP650 replacing PL111/HDLCD.
>> >> >
>> >> > Only "Layer Graphics" of the ARM Mali DP is configured for
>> >> > rendering the RGB/BGR format frame buffer to satisfy the UEFI GOP
>> >> > requirements Other layers e.g. video layers are not configured.
>> >> >
>> >> > NOTE: This change implements the Mali DP on models. Versions for
>> >> > actual hardware are liable to require extra handling for clock
>> >> > input changes, etc.
>> >> >
>> >> > 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>
>> >>
>> >> Hello Girish, Evan,
>> >>
>> >> (replying to 19/19 because I cannot find the cover letter in my
>> >> edk2-devel archive but this really applies to the whole series)
>> >>
>> >> I have been looking at these patches again now that I am trying to
>> >> clean up ArmPlatformPkg, which is currently a dumping ground for all
>> >> things vaguely ARM related, and is also structured quite differently
>> >> from other packages.
>> >>
>> >> Ideally, ArmPlatformPkg should only contain the following:
>> >> - library class interfaces under Include/Library; header files kept
>> >> here should only contain elements that define API
>> >> - driver specific include files Include/IndustryStandard but *only*
>> >> if they cannot be kept locally with the driver in question
>> >> - libraries under Library/
>> >> - drivers under Drivers/
>> >>
>> >> This aligns with the common arrangement adopted by most EDK2
>> packages.
>> >>
>> >> This series does many different things, and does not distinguish at
>> >> all between common code and code living under ArmVExpressPkg. Given
>> >
>> > [[Evan Lloyd]] All of the commits in the series are in ArmPlatformPkg.
>> > You may be in the process of disentangling the VE specific bits, but
>> > hitherto that has not been a consideration. (Note: I'm not arguing against
>> the disentangling, only pointing out that it was not a factor at the point we
>> submitted the patches) The reason there are so many commits is only that
>> we have been asked to break things up into "bite sized" chunks for the
>> convenience of maintainers.
>> > The aim was to make each a coherent item with a simple justification.
>> >
>> >> that I am trying to move ArmVExpressPkg out of EDK2 into
>> >> edk2-platforms (where it arguably belongs) having this series in
>> >> limbo for two months is basically blocking my work, and so I would
>> >> like to explore ways to proceed with this without interfering with
>> >> each other's work too much. At the same time, the way the code is
>> >> structured is a continuation of the pattern I am trying to get rid
>> >> of, so they will need some rework anyway in order to be upstreamable
>> IMHO.
>> >
>> > [[Evan Lloyd]] Not being psychic, we had not made allowance for your
>> plans.
>> > However, if you take the trouble to look at the changes, they achieve
>> exactly the split you aim for.
>> > The display type code (PL011 and HDLCD) is unravelled from the VE code.
>> > All that remains would be to move the VE specific part into edk2-
>> platforms.
>> >
>> >>
>> >> So could we split it up please? Assuming the intention is the ability
>> >> to reuse the Mali code on non-VExpress platforms, I would like to see
>> >> that code proposed separately, without any mention of VExpressPkg.dec
>> >
>> > [[Evan Lloyd]] Given that the original code was unfortunate, I'm not sure
>> that it makes much difference what order the changes get made.
>> > Going West then North gets you to the same place as North then West
>> (except near a pole).
>> > If you accept that there was a logical progression in the changes made,
>> then it might be better to not rejig things pointlessly.
>> >
>> >> whatsoever. If you introduce any library classes that abstract away
>> >> the differences between platforms, you can include a Null version of
>> >> such a library that simply does ASSERT (FALSE) in every function:
>> >> this
>> >
>> > [[Evan Lloyd]] One could, indeed, do that. We, however, would be very
>> reluctant to incur the overhead of rework in response to spurious cavils
>> from a maintainer when it is of no direct relevance to us.
>> >
>>
>> I don't think the suggestion that we evil maintainers are nothing but an
>> impediment to the likes of you and your team members doing the actual
>> work is justified.
>>
>> We are all on the same team here, and the goal is to make UEFI code
>> reusable for the customers of /your/ employer. Throwing stuff over the
>> fence != upstreaming, and it is my job as a maintainer to ensure that code is
>> still maintainable long after the original authors have moved on to
>> something else.
>>
>> ArmPlatformPkg is a perfect example where code reuse is much more
>> difficult than it needs to be, and we as maintainers need to deal with
>> contributors from other companies that have used it as 'guidance' for how
>> to architect their UEFI firmware, which is usually filled with vexpress-isms
>> that date back to before anyone currently involved with UEFI can remember.
>>
>> This is why I have taken the time to sit down, go through all the crap code,
>> clean it up, refactor it and propose it on the list as improvements. I even
>> went so far as taking the preparatory Mali work of your team and rebase it
>> so that we can keep the bits that we may share, and move the bits out that
>> should not be kept in main EDK2 because they are being taken as gospel by
>> engineers that are new to
>> ARM+UEFI.
>>
>> If this is too much to deal with for you, then fine, don't upstream your code.
>> But if you do, you are going to have to play nice with the others, including
>> the maintainers.
>>
> [[Evan Lloyd]] Hi Ard. Firstly, I apologize, I assumed from your name that you were Dutch and would therefore probably have a lively sense of humour. Of course, if I have touched a nerve, that is unfortunate and I'm sorry.
No, the apparently blatantly obvious tongue-in-cheek nature of your
response was completely lost on me. But I know a person who does have
a lively sense of humour, so next time I will ask him for help.
> I agree that cleaning up the code is important, worthwhile, and an objective for us all. What can be a difficulty is our very different conceptions of what clean means.
>
Fair enough. But as maintainers, we take ownership of your code, with
the implied promise to keep it in a working state. I don't think it is
unreasonable that we get to dictate some of the terms under which that
occurs.
> You should be aware though that a certain amount of whingeing is to be expected when dealing with Brits. (Ask Leif - he knows! Or any Australian.)
> I do not disagree with your intent - but I do sometimes feel that the criteria applied do not take into account the cost/benefit aspects, and seek to air that point. I shall endeavour to make such points in a less bantering way in future.
>
Thanks.
I think one of the misconceptions may be that upstreaming is something
one does once the code is completely finished. Instead, please involve
us much sooner if you intend to upstream your code (or just Leif for
confidential stuff). That way, any effort invested in the code
benefits your product as well as the open source, rather than shipping
one version, and having to go back and change stuff for the version
that ends up upstream.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver.
2017-12-05 21:27 ` Ard Biesheuvel
@ 2017-12-07 20:21 ` Evan Lloyd
2017-12-07 21:10 ` Ard Biesheuvel
0 siblings, 1 reply; 69+ messages in thread
From: Evan Lloyd @ 2017-12-07 20:21 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: edk2-devel@lists.01.org, Matteo Carlini, Leif Lindholm,
Girish Pathak
Hi Ard.
> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: 05 December 2017 21:28
> To: Evan Lloyd <Evan.Lloyd@arm.com>
> Cc: edk2-devel@lists.01.org; Matteo Carlini <Matteo.Carlini@arm.com>;
> Leif Lindholm <leif.lindholm@linaro.org>; Girish Pathak
> <Girish.Pathak@arm.com>
> Subject: Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650
> GOP driver.
>
> On 5 December 2017 at 20:03, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> >> Sent: 01 December 2017 17:19
> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
> >> Cc: edk2-devel@lists.01.org; Matteo Carlini <Matteo.Carlini@arm.com>;
> >> Leif Lindholm <leif.lindholm@linaro.org>; Girish Pathak
> >> <Girish.Pathak@arm.com>
> >> Subject: Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650
> GOP
> >> driver.
> >>
...
> >> >
> >> >> whatsoever. If you introduce any library classes that abstract
> >> >> away the differences between platforms, you can include a Null
> >> >> version of such a library that simply does ASSERT (FALSE) in every
> function:
> >> >> this
> >> >
> >> > [[Evan Lloyd]] One could, indeed, do that. We, however, would be
> >> > very
> >> reluctant to incur the overhead of rework in response to spurious
> >> cavils from a maintainer when it is of no direct relevance to us.
> >> >
> >>
> >> I don't think the suggestion that we evil maintainers are nothing but
> >> an impediment to the likes of you and your team members doing the
> >> actual work is justified.
> >>
> >> We are all on the same team here, and the goal is to make UEFI code
> >> reusable for the customers of /your/ employer. Throwing stuff over
> >> the fence != upstreaming, and it is my job as a maintainer to ensure
> >> that code is still maintainable long after the original authors have
> >> moved on to something else.
> >>
> >> ArmPlatformPkg is a perfect example where code reuse is much more
> >> difficult than it needs to be, and we as maintainers need to deal
> >> with contributors from other companies that have used it as
> >> 'guidance' for how to architect their UEFI firmware, which is usually
> >> filled with vexpress-isms that date back to before anyone currently
> involved with UEFI can remember.
> >>
> >> This is why I have taken the time to sit down, go through all the
> >> crap code, clean it up, refactor it and propose it on the list as
> >> improvements. I even went so far as taking the preparatory Mali work
> >> of your team and rebase it so that we can keep the bits that we may
> >> share, and move the bits out that should not be kept in main EDK2
> >> because they are being taken as gospel by engineers that are new to
> >> ARM+UEFI.
> >>
> >> If this is too much to deal with for you, then fine, don't upstream your
> code.
> >> But if you do, you are going to have to play nice with the others,
> >> including the maintainers.
> >>
> > [[Evan Lloyd]] Hi Ard. Firstly, I apologize, I assumed from your name that
> you were Dutch and would therefore probably have a lively sense of
> humour. Of course, if I have touched a nerve, that is unfortunate and I'm
> sorry.
>
> No, the apparently blatantly obvious tongue-in-cheek nature of your
> response was completely lost on me. But I know a person who does have a
> lively sense of humour, so next time I will ask him for help.
[[Evan Lloyd]] I would like to extend my apology. From comments others have made it is apparent that my wording was too easily interpreted as just offensive. I shall try and resist the temptation to make such points with dubious attempts at humour in the future, at least on fora like this where they are out of place. Het spijt me.
>
> > I agree that cleaning up the code is important, worthwhile, and an
> objective for us all. What can be a difficulty is our very different
> conceptions of what clean means.
> >
>
> Fair enough. But as maintainers, we take ownership of your code, with the
> implied promise to keep it in a working state. I don't think it is
> unreasonable that we get to dictate some of the terms under which that
> occurs.
>
> > You should be aware though that a certain amount of whingeing is to be
> > expected when dealing with Brits. (Ask Leif - he knows! Or any Australian.)
> I do not disagree with your intent - but I do sometimes feel that the criteria
> applied do not take into account the cost/benefit aspects, and seek to air
> that point. I shall endeavour to make such points in a less bantering way in
> future.
> >
>
> Thanks.
>
> I think one of the misconceptions may be that upstreaming is something
> one does once the code is completely finished. Instead, please involve us
> much sooner if you intend to upstream your code (or just Leif for
> confidential stuff). That way, any effort invested in the code benefits your
> product as well as the open source, rather than shipping one version, and
> having to go back and change stuff for the version that ends up upstream.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver.
2017-12-07 20:21 ` Evan Lloyd
@ 2017-12-07 21:10 ` Ard Biesheuvel
0 siblings, 0 replies; 69+ messages in thread
From: Ard Biesheuvel @ 2017-12-07 21:10 UTC (permalink / raw)
To: Evan Lloyd
Cc: edk2-devel@lists.01.org, Matteo Carlini, Leif Lindholm,
Girish Pathak
On 7 December 2017 at 20:21, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
> Hi Ard.
>
>> -----Original Message-----
>> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> Sent: 05 December 2017 21:28
>> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> Cc: edk2-devel@lists.01.org; Matteo Carlini <Matteo.Carlini@arm.com>;
>> Leif Lindholm <leif.lindholm@linaro.org>; Girish Pathak
>> <Girish.Pathak@arm.com>
>> Subject: Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650
>> GOP driver.
>>
>> On 5 December 2017 at 20:03, Evan Lloyd <Evan.Lloyd@arm.com> wrote:
>> >
>> >
>> >> -----Original Message-----
>> >> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
>> >> Sent: 01 December 2017 17:19
>> >> To: Evan Lloyd <Evan.Lloyd@arm.com>
>> >> Cc: edk2-devel@lists.01.org; Matteo Carlini <Matteo.Carlini@arm.com>;
>> >> Leif Lindholm <leif.lindholm@linaro.org>; Girish Pathak
>> >> <Girish.Pathak@arm.com>
>> >> Subject: Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650
>> GOP
>> >> driver.
>> >>
> ...
>> >> >
>> >> >> whatsoever. If you introduce any library classes that abstract
>> >> >> away the differences between platforms, you can include a Null
>> >> >> version of such a library that simply does ASSERT (FALSE) in every
>> function:
>> >> >> this
>> >> >
>> >> > [[Evan Lloyd]] One could, indeed, do that. We, however, would be
>> >> > very
>> >> reluctant to incur the overhead of rework in response to spurious
>> >> cavils from a maintainer when it is of no direct relevance to us.
>> >> >
>> >>
>> >> I don't think the suggestion that we evil maintainers are nothing but
>> >> an impediment to the likes of you and your team members doing the
>> >> actual work is justified.
>> >>
>> >> We are all on the same team here, and the goal is to make UEFI code
>> >> reusable for the customers of /your/ employer. Throwing stuff over
>> >> the fence != upstreaming, and it is my job as a maintainer to ensure
>> >> that code is still maintainable long after the original authors have
>> >> moved on to something else.
>> >>
>> >> ArmPlatformPkg is a perfect example where code reuse is much more
>> >> difficult than it needs to be, and we as maintainers need to deal
>> >> with contributors from other companies that have used it as
>> >> 'guidance' for how to architect their UEFI firmware, which is usually
>> >> filled with vexpress-isms that date back to before anyone currently
>> involved with UEFI can remember.
>> >>
>> >> This is why I have taken the time to sit down, go through all the
>> >> crap code, clean it up, refactor it and propose it on the list as
>> >> improvements. I even went so far as taking the preparatory Mali work
>> >> of your team and rebase it so that we can keep the bits that we may
>> >> share, and move the bits out that should not be kept in main EDK2
>> >> because they are being taken as gospel by engineers that are new to
>> >> ARM+UEFI.
>> >>
>> >> If this is too much to deal with for you, then fine, don't upstream your
>> code.
>> >> But if you do, you are going to have to play nice with the others,
>> >> including the maintainers.
>> >>
>> > [[Evan Lloyd]] Hi Ard. Firstly, I apologize, I assumed from your name that
>> you were Dutch and would therefore probably have a lively sense of
>> humour. Of course, if I have touched a nerve, that is unfortunate and I'm
>> sorry.
>>
>> No, the apparently blatantly obvious tongue-in-cheek nature of your
>> response was completely lost on me. But I know a person who does have a
>> lively sense of humour, so next time I will ask him for help.
>
> [[Evan Lloyd]] I would like to extend my apology. From comments others have made it is apparent that my wording was too easily interpreted as just offensive. I shall try and resist the temptation to make such points with dubious attempts at humour in the future, at least on fora like this where they are out of place. Het spijt me.
>
Thanks Evan, I appreciate that. Courier 10pt simply does not convey
the nuance in your writing, and I suppose the open source world may
have its own idiosyncrasies that are not always obvious to people who
are working on the outside. And for the record, you're wrong about me
not having a sense of humour: according to my mother, both my jokes
are hilarious.
^ permalink raw reply [flat|nested] 69+ messages in thread
* Re: [PATCH 19/19] ArmPlatformPkg: New DP500/DP550/DP650 GOP driver.
2017-12-01 13:12 ` Evan Lloyd
2017-12-01 17:18 ` Ard Biesheuvel
@ 2017-12-01 17:29 ` Leif Lindholm
1 sibling, 0 replies; 69+ messages in thread
From: Leif Lindholm @ 2017-12-01 17:29 UTC (permalink / raw)
To: Evan Lloyd
Cc: Ard Biesheuvel, edk2-devel@lists.01.org, Matteo Carlini,
Girish Pathak
On Fri, Dec 01, 2017 at 01:12:49PM +0000, Evan Lloyd wrote:
> > whatsoever. If you introduce any library classes that abstract away
> > the differences between platforms, you can include a Null version of
> > such a library that simply does ASSERT (FALSE) in every function: this
>
> [[Evan Lloyd]] One could, indeed, do that. We, however, would be
> very reluctant to incur the overhead of rework in response to
> spurious cavils from a maintainer when it is of no direct relevance
> to us.
Rework is the expected norm for the first version of any patchset.
If that is not calculated into your schedules, you will continue to be
disappointed.
An open source project is not a scrapyard for proprietary code, it is
a collaborative environment where people and organisations work
together to achieve better results than they could hope for
individually.
Like these suggestions for rework are of no direct relevance to you,
your patches are of no direct relevance for the project - yet we have
taken the time to sit down, try to understand them, and give feedback
on how they could be improved to be of greater value to the community
as a whole.
I don't think I would be taking to hard a line if I suggest that you
apologise to Ard for your statement above.
Yes, we're all permitted to get annoyed and throw our toys out of the
pram from time to time, but personal attacks are not acceptable.
/
Leif
^ permalink raw reply [flat|nested] 69+ messages in thread