From nobody Thu Dec 26 13:26:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1506456990873880.5716091866216; Tue, 26 Sep 2017 13:16:30 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C6D0821E43B4C; Tue, 26 Sep 2017 13:12:41 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9D30C2007D1EB for ; Tue, 26 Sep 2017 13:12:27 -0700 (PDT) Received: from E111747.Emea.Arm.com (e111747.emea.arm.com [10.1.27.40]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id v8QKFY5d017392; Tue, 26 Sep 2017 21:15:38 +0100 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=evan.lloyd@arm.com; receiver=edk2-devel@lists.01.org From: evan.lloyd@arm.com To: edk2-devel@lists.01.org Date: Tue, 26 Sep 2017 21:15:24 +0100 Message-Id: <20170926201529.11644-15-evan.lloyd@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170926201529.11644-1-evan.lloyd@arm.com> References: <20170926201529.11644-1-evan.lloyd@arm.com> Subject: [edk2] [PATCH 14/19] ArmPlatformPkg: Add PCD to select pixel format X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "ard.biesheuvel@linaro.org"@arm.com, "leif.lindholm@linaro.org"@arm.com, "nd@arm.com"@arm.com, "Matteo.Carlini@arm.com"@arm.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak 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 Signed-off-by: Evan Lloyd --- ArmPlatformPkg/ArmPlatformPkg.dec = | 9 ++++- ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress= Lib.inf | 1 + ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVE= xpressLib.inf | 1 + ArmPlatformPkg/Include/Library/LcdPlatformLib.h = | 6 +++- ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress= .c | 23 ++++++++---- ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVE= xpress.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/ArmPlatform= Pkg.dec index b8a6b131632dc6788b73a034a41b9e3176dffafa..548d2b211753275337c6973e052= 27cee8451c185 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 =20 + # Graphics Output Pixel format + # 0 : PixelRedGreenBlueReserved8BitPerColor + # 1 : PixelBlueGreenRedReserved8BitPerColor + # 2 : PixelBitMask + # Default is set to UEFI console font format PixelBlueGreenRedReserved8B= itPerColor + gArmPlatformTokenSpaceGuid.PcdGopPixelFormat|0x00000001|UINT32|0x00000040 + [PcdsFixedAtBuild.common,PcdsDynamic.common] ## PL031 RealTimeClock gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x0|UINT32|0x00000024 diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLc= dArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpres= sLib/HdLcdArmVExpressLib.inf index bba851c9bd6089cee748b45f40599b24c1293785..37756481596c7e978ed9ed0a932= eeb2aa0a3b657 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx= pressLib.inf +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx= pressLib.inf @@ -42,3 +42,4 @@ [Protocols] [FixedPcd] gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode gArmVExpressTokenSpaceGuid.PcdHdLcdVideoModeOscId + gArmPlatformTokenSpaceGuid.PcdGopPixelFormat diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/P= L111LcdArmVExpressLib.inf b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdA= rmVExpressLib/PL111LcdArmVExpressLib.inf index 1a044baf4698aa6bfa5cd6038f01e84f7a633ea9..6f1cb3b55ff814d007718b5597f= 821dd20100477 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd= ArmVExpressLib.inf +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd= ArmVExpressLib.inf @@ -42,3 +42,4 @@ [Protocols] [FixedPcd] gArmVExpressTokenSpaceGuid.PcdPL111LcdMaxMode gArmVExpressTokenSpaceGuid.PcdPL111LcdVideoModeOscId + gArmPlatformTokenSpaceGuid.PcdGopPixelFormat diff --git a/ArmPlatformPkg/Include/Library/LcdPlatformLib.h b/ArmPlatformP= kg/Include/Library/LcdPlatformLib.h index f2f345b18fd15f2cde159fd42d3208a28f598a1f..d357c22c46b62966859793372c4= 47883e12e1e80 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 =20 - // The enumeration indexes maps the PL111 LcdBpp values used in the LCD Co= ntrol Register typedef enum { LCD_BITS_PER_PIXEL_1 =3D 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/HdLc= dArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/= HdLcdArmVExpress.c index 2401cdb30cb7252964ce1f363aa26d99933c09be..07730ed0d7a84b3fb64047bd101= 3fbc97301db53 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx= press.c +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx= press.c @@ -15,7 +15,6 @@ #include =20 #include -#include #include #include #include @@ -91,6 +90,10 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive =3D { /** 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; =20 /* Set the FPGA multiplexer to select the video output from the * motherboard or the daughterboard */ @@ -120,6 +124,16 @@ LcdPlatformInitializeDisplay ( NULL ); =20 + // PixelBitMask and PixelBltOnly pixel formats are not supported + PixelFormat =3D FixedPcdGet32 (PcdGopPixelFormat); + if (PixelFormat !=3D PixelRedGreenBlueReserved8BitPerColor + && PixelFormat !=3D PixelBlueGreenRedReserved8BitPerColor) { + + ASSERT (PixelFormat =3D=3D PixelRedGreenBlueReserved8BitPerColor + || PixelFormat =3D=3D PixelBlueGreenRedReserved8BitPerColor); + return EFI_UNSUPPORTED; + } + return Status; } =20 @@ -282,12 +296,7 @@ LcdPlatformQueryMode ( Info->VerticalResolution =3D mDisplayModes[ModeNumber].Vertical.Resoluti= on; Info->PixelsPerScanLine =3D mDisplayModes[ModeNumber].Horizontal.Resolut= ion; =20 - /* Bits per Pixel is always LCD_BITS_PER_PIXEL_24 */ - Info->PixelFormat =3D PixelRedGreenBlueReserved8BitPer= Color; - Info->PixelInformation.RedMask =3D LCD_24BPP_RED_MASK; - Info->PixelInformation.GreenMask =3D LCD_24BPP_GREEN_MASK; - Info->PixelInformation.BlueMask =3D LCD_24BPP_BLUE_MASK; - Info->PixelInformation.ReservedMask =3D LCD_24BPP_RESERVED_MASK; + Info->PixelFormat =3D FixedPcdGet32 (PcdGopPixelFormat); =20 return EFI_SUCCESS; } diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/P= L111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVEx= pressLib/PL111LcdArmVExpress.c index 753c5b615361f83625cdd4f0506909721da014b6..31d5e037e42a51f1c08e5bf2fa2= 2eeb7be23e45f 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd= ArmVExpress.c +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd= ArmVExpress.c @@ -149,6 +149,10 @@ EFI_EDID_ACTIVE_PROTOCOL mEdidActive =3D { /** 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; =20 // Set the FPGA multiplexer to select the video output from the motherbo= ard or the daughterboard Status =3D ArmPlatformSysConfigSet (SYS_CFG_MUXFPGA, PL111_CLCD_SITE); @@ -172,6 +177,16 @@ LcdPlatformInitializeDisplay ( ); } =20 + // PixelBitMask and PixelBltOnly pixel formats are not supported + PixelFormat =3D FixedPcdGet32 (PcdGopPixelFormat); + if (PixelFormat !=3D PixelRedGreenBlueReserved8BitPerColor + && PixelFormat !=3D PixelBlueGreenRedReserved8BitPerColor) { + + ASSERT (PixelFormat =3D=3D PixelRedGreenBlueReserved8BitPerColor + || PixelFormat =3D=3D PixelBlueGreenRedReserved8BitPerColor); + return EFI_UNSUPPORTED; + } + return Status; } =20 @@ -366,27 +381,7 @@ LcdPlatformQueryMode ( Info->VerticalResolution =3D mDisplayModes[ModeNumber].Vertical.Resoluti= on; Info->PixelsPerScanLine =3D mDisplayModes[ModeNumber].Horizontal.Resolut= ion; =20 - switch (mDisplayModes[ModeNumber].Bpp) { - case LCD_BITS_PER_PIXEL_24: - Info->PixelFormat =3D PixelRedGreenBlueReserved8Bi= tPerColor; - Info->PixelInformation.RedMask =3D LCD_24BPP_RED_MASK; - Info->PixelInformation.GreenMask =3D LCD_24BPP_GREEN_MASK; - Info->PixelInformation.BlueMask =3D LCD_24BPP_BLUE_MASK; - Info->PixelInformation.ReservedMask =3D 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 =3D FixedPcdGet32 (PcdGopPixelFormat); =20 return EFI_SUCCESS; } diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatf= ormPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c index 03153c06d314cb497c91889386ca6075c0c9f718..3ea7feca439e7ae9a610b6b3139= ddbfad3ac6f9c 100644 --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c @@ -22,6 +22,8 @@ =20 #include "LcdGraphicsOutputDxe.h" =20 +#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 ); =20 - 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; } =20 @@ -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; =20 + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo; =20 // Set the video mode timings and other relevant information Status =3D LcdPlatformGetTimings ( @@ -104,13 +102,22 @@ LcdSetMode ( ASSERT (Horizontal !=3D NULL); ASSERT (Vertical !=3D NULL); =20 - Status =3D LcdPlatformGetBpp (ModeNumber, &LcdBpp); + // Get the pixel format information. + Status =3D LcdPlatformQueryMode (ModeNumber, &ModeInfo); if (EFI_ERROR (Status)) { ASSERT_EFI_ERROR (Status); return Status; } =20 - BytesPerPixel =3D GetBytesPerPixel (LcdBpp); + if (ModeInfo.PixelFormat =3D=3D 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)); =20 // 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 ); =20 - MmioWrite32 (HDLCD_REG_FB_LINE_PITCH, Horizontal->Resolution * BytesPerP= ixel); + MmioWrite32 ( + HDLCD_REG_FB_LINE_PITCH, + Horizontal->Resolution * BYTES_PER_PIXEL + ); =20 MmioWrite32 (HDLCD_REG_FB_LINE_COUNT, Vertical->Resolution - 1); =20 diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPl= atformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c index 6de60491e9fd0c5bca71e743aac2862ff85f6e7e..4bad2367982e16d5d23c4eab2e6= d91bf7db1c031 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; =20 + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION ModeInfo; + // Set the video mode timings and other relevant information Status =3D LcdPlatformGetTimings ( ModeNumber, @@ -111,6 +114,13 @@ LcdSetMode ( return Status; } =20 + // Get the pixel format information. + Status =3D 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); =20 @@ -144,7 +154,11 @@ LcdSetMode ( =20 // PL111_REG_LCD_CONTROL LcdControl =3D PL111_CTRL_LCD_EN | PL111_CTRL_LCD_BPP (LcdBpp) - | PL111_CTRL_LCD_TFT | PL111_CTRL_BGR; + | PL111_CTRL_LCD_TFT; + + if (ModeInfo.PixelFormat =3D=3D PixelBlueGreenRedReserved8BitPerColor) { + LcdControl |=3D PL111_CTRL_BGR; + } =20 MmioWrite32 (PL111_REG_LCD_CONTROL, LcdControl); =20 --=20 Guid("CE165669-3EF3-493F-B85D-6190EE5B9759") _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel