From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.34.94; helo=nam01-by2-obe.outbound.protection.outlook.com; envelope-from=christopher.co@microsoft.com; receiver=edk2-devel@lists.01.org Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0094.outbound.protection.outlook.com [104.47.34.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EAC75202E5446 for ; Wed, 18 Jul 2018 21:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oi0INPiiaix4kJnYlDn8tQVHEttn8krn/palIR6ns1c=; b=Kd7QDXX9vGdmHmjLlk8q9ACIN1DPcUVujVd1lzP48lFOuH/zsyG3PiboAfjJ5tD3MnWrG6pvfujWjl7vQZV1rDxeWPIOc28UOVypl8c76byUGcpPStEOSx2fcBNv8q5Oz6Tx/27GtEwtySy7D+A442RtDf+h2JGjmgt7RJlrtj0= Received: from DM5PR2101MB1128.namprd21.prod.outlook.com (52.132.133.20) by DM5PR2101MB0983.namprd21.prod.outlook.com (52.132.133.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.0; Thu, 19 Jul 2018 04:11:20 +0000 Received: from DM5PR2101MB1128.namprd21.prod.outlook.com ([fe80::b4d3:dabb:9372:9740]) by DM5PR2101MB1128.namprd21.prod.outlook.com ([fe80::b4d3:dabb:9372:9740%2]) with mapi id 15.20.0995.008; Thu, 19 Jul 2018 04:11:20 +0000 From: Chris Co To: "edk2-devel@lists.01.org" CC: Ard Biesheuvel , Leif Lindholm , Michael D Kinney Thread-Topic: [PATCH edk2-platforms 2/7] Silicon/NXP: Add iMX display library support Thread-Index: AQHUHxaMz7LaA3Y3+E+NtjbCWMVNlw== Date: Thu, 19 Jul 2018 04:11:20 +0000 Message-ID: <20180719041103.9072-3-christopher.co@microsoft.com> References: <20180719041103.9072-1-christopher.co@microsoft.com> In-Reply-To: <20180719041103.9072-1-christopher.co@microsoft.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BN6PR11CA0037.namprd11.prod.outlook.com (2603:10b6:404:4b::23) To DM5PR2101MB1128.namprd21.prod.outlook.com (2603:10b6:4:a8::20) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2001:4898:80e8:1:d144:e4c:c05:68bd] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB0983; 6:FzbmyAAmg8yd1IiR/ZQfyKIPNewxF7ixpzz0T8UTs6vnLvabtcPlAle9aKddQD/6lMzXuCw0//QtTLm2bKVPZY6NZt+XtTiLcgGjmr+QTv2U+2mb5v0gTwbtMzi+QoDJnZXIdn/m17QELlppt0x81W1zObuxMpaFUhTM/xvQfIQohi8y4UY34sMTnTTUARDGeHClRmMA265TJ/vI9AWEPrdCsVXLf8mYkMb4b1ydiGsswUhAF1ZwDiVxBuIQhBQU0HPE3dbDU3G2G8rqjmxcxrNiIAwkTXIQYiKjY56XsBmGfTbByZ120UKxUvhKnv/WVp2VMufXz0OahENvvCVHd+UzZqiVAs9jWkm/3wv9eniCAwNOxbcrpjletaleh1tJFQoIKKAqfmzwmsLI+v+IQzfON30HPvPTX9hWqK0D8UUjBt+MQIy3uAmOSROeRfNVIxVOqQfAoDtmhdrsRC5J6A==; 5:788IV4CQ9S55PI1tJX5gMolJvpgZse6065SCge3MNmEtqNrCMppecHoFZnYp3xZhfIqnTE36Uy7ErtyAjmZFUniVdxJu/XuXVgwc5SH7iABmIemKiUid3z2lO3ZwqV9yvvAVs9B2i08Rc3jaOPzjHjB6UYqSZSiVH8tiSNqmDrE=; 7:qxscX/ztg9iQWlFXRLkpcsAk4P+s6KQf9jwpkVG5ygEZrtZOdNYbiVLouM1iOULR9YnmE43leKiLRghCrqi9egRwgt4r3pad0/KxvkCZ4U4kqVIUNDrsI8NHfFfnsf8AuoCyOwnkv2vPRBdhRc0EGOVt6nygNoekCkVsjhsFjQch6Rdb5r3UHS9mGS4B5Ea/j+izKmS9PnvrxGkKygglSfBjQAuhY1FHqWuuIHHQ8fxcWPA6iZXUO0HFlBd962yw x-ms-office365-filtering-correlation-id: e1eec296-12f7-48c8-301d-08d5ed2dae6b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600067)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7193020); SRVR:DM5PR2101MB0983; x-ms-traffictypediagnostic: DM5PR2101MB0983: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Christopher.Co@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231311)(944501410)(52105095)(2018427008)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:DM5PR2101MB0983; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0983; x-forefront-prvs: 0738AF4208 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(396003)(346002)(366004)(376002)(39860400002)(189003)(199004)(25786009)(8936002)(4326008)(53936002)(386003)(53376002)(6506007)(68736007)(52116002)(86612001)(6916009)(76176011)(5640700003)(6512007)(10090500001)(6436002)(106356001)(6306002)(6486002)(14444005)(5660300001)(105586002)(256004)(2351001)(8676002)(81166006)(7736002)(305945005)(81156014)(36756003)(478600001)(5250100002)(99286004)(1076002)(14454004)(46003)(54906003)(186003)(2501003)(10290500003)(16799955002)(72206003)(966005)(22452003)(102836004)(486006)(2900100001)(2906002)(6116002)(446003)(2616005)(476003)(316002)(15188155005)(575784001)(86362001)(11346002)(97736004); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0983; H:DM5PR2101MB1128.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 2ocfY1/TBcSxdr4Ezdewi2FLK1yUhyTFqXLGLETBJhN5/9N2BCfi372fO+ULwzLe12fiSn7NZETSbPqAlwptN36k0vBgkgyk1Vhe6caz4hsW5bUSFHUyfTRW+qkwCmhovW/L6K/NfUzBOndnloxjZXBq9DASlAFIhnshHiY7Xhs26Uw3Q1Ne3NADpqRvoecSWFKyAVJtwyk1t0rP5Q4D8iHB+KBvtpCmnHFZREi41epqY4TVV4lh7LsiTCiQRzaaesWypeyqhS5PlILrD1zsE3EEesoUHlwTIrVSAbCpnaw3gksUa7ik91a2LcfLx0zAXL/+ykd7cxq+t6Cd8d35P2+wAp/09qGJ3AGLYYGMaMI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1eec296-12f7-48c8-301d-08d5ed2dae6b X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jul 2018 04:11:20.2583 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0983 Subject: [PATCH edk2-platforms 2/7] Silicon/NXP: Add iMX display library support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2018 04:11:22 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This adds support for processing EDID data on NXP i.MX platforms. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Christopher Co Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Michael D Kinney --- Silicon/NXP/iMXPlatformPkg/Include/iMXDisplay.h | 95 += ++++++++++++++ Silicon/NXP/iMXPlatformPkg/Library/iMXDisplayLib/iMXDisplayLib.c | 125 += +++++++++++++++++++ Silicon/NXP/iMXPlatformPkg/Library/iMXDisplayLib/iMXDisplayLib.inf | 31 += ++++ 3 files changed, 251 insertions(+) diff --git a/Silicon/NXP/iMXPlatformPkg/Include/iMXDisplay.h b/Silicon/NXP/= iMXPlatformPkg/Include/iMXDisplay.h new file mode 100644 index 000000000000..d805c6b4bc39 --- /dev/null +++ b/Silicon/NXP/iMXPlatformPkg/Include/iMXDisplay.h @@ -0,0 +1,95 @@ +/** @file +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +* +**/ + +#ifndef __IMX_DISPLAY_H__ +#define __IMX_DISPLAY_H__ + +#define EDID_MIN_SIZE 128 +#define EDID_I2C_ADDRESS 0x50 + +// +// The first DTD is the preferred timing, refer to 3.1 VESA EDID spec. +// +#define EDID_DTD_1_OFFSET 0x36 +#define EDID_DTD_2_OFFSET 0x48 +#define EDID_DTD_3_OFFSET 0x5A +#define EDID_DTD_4_OFFSET 0x6C + +typedef enum { + PIXEL_FORMAT_ARGB32, + PIXEL_FORMAT_BGRA32, +} PIXEL_FORMAT; + +typedef struct _DISPLAY_TIMING { + UINT32 PixelClock; + UINT32 HActive; + UINT32 HBlank; + UINT32 VActive; + UINT32 VBlank; + UINT32 HSync; + UINT32 VSync; + UINT32 HSyncOffset; + UINT32 VSyncOffset; + UINT32 HImageSize; + UINT32 VImageSize; + UINT32 HBorder; + UINT32 VBorder; + UINT32 EdidFlags; + UINT32 Flags; + UINT32 PixelRepetition; + UINT32 Bpp; + PIXEL_FORMAT PixelFormat; +} DISPLAY_TIMING, *PDISPLAY_TIMING, DTD; + +typedef struct _DETAILED_TIMING_DESCRIPTOR { + UINT8 PixelClock[2]; + UINT8 HActive; + UINT8 HBlank; + UINT8 HActiveBlank; + UINT8 VActive; + UINT8 VBlank; + UINT8 VActiveBlank; + UINT8 HSyncOffset; + UINT8 HSyncWidth; + UINT8 VSyncOffsetWidth; + UINT8 HVOffsetWidth; + UINT8 HImageSize; + UINT8 VImageSize; + UINT8 HVImageSize; + UINT8 HBorder; + UINT8 VBorder; + UINT8 EdidFlags; +} DETAILED_TIMING_DESCRIPTOR, *PDETAILED_TIMING_DESCRIPTOR; + +// +// Convert detailed timing descriptor to display timing format +// +EFI_STATUS +ConvertDTDToDisplayTiming ( + DETAILED_TIMING_DESCRIPTOR* DTDPtr, + DISPLAY_TIMING* DisplayTimingPtr + ); + +VOID +PrintDisplayTiming ( + char *DisplayTimingName, + DISPLAY_TIMING* DisplayTimingPtr + ); + +EFI_STATUS +ValidateEdidData ( + UINT8* EdidDataPtr + ); + +#endif // __IMX_DISPLAY_H__ diff --git a/Silicon/NXP/iMXPlatformPkg/Library/iMXDisplayLib/iMXDisplayLib= .c b/Silicon/NXP/iMXPlatformPkg/Library/iMXDisplayLib/iMXDisplayLib.c new file mode 100644 index 000000000000..67f3cd074cb5 --- /dev/null +++ b/Silicon/NXP/iMXPlatformPkg/Library/iMXDisplayLib/iMXDisplayLib.c @@ -0,0 +1,125 @@ +/** @file +* +* Copyright (c) Microsoft Corporation. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +* +**/ + +#include +#include + +#include + +EFI_STATUS +ConvertDTDToDisplayTiming( + DETAILED_TIMING_DESCRIPTOR* DTDPtr, + DISPLAY_TIMING* DisplayTimingPtr + ) +{ + DEBUG((DEBUG_INFO,"++ConvertDTDToDisplayTiming()\r\n")); + // Refer to 3.10.2 VESA EDID spec + UINT32 edidPixelClock =3D + (DTDPtr->PixelClock[0] | (DTDPtr->PixelClock[1] << 8)); + + DisplayTimingPtr->PixelClock =3D edidPixelClock * 10000; + DisplayTimingPtr->HActive =3D (DTDPtr->HActiveBlank & 0xF0); + DisplayTimingPtr->HActive =3D (DisplayTimingPtr->HActive << 4) | DTDPt= r->HActive; + DisplayTimingPtr->HBlank =3D (DTDPtr->HActiveBlank & 0x0F); + DisplayTimingPtr->HBlank =3D (DisplayTimingPtr->HBlank << 8) | DTDPtr-= >HBlank; + DisplayTimingPtr->VActive =3D (DTDPtr->VActiveBlank & 0xF0); + DisplayTimingPtr->VActive =3D (DisplayTimingPtr->VActive << 4) | DTDPt= r->VActive; + DisplayTimingPtr->VBlank =3D (DTDPtr->VActiveBlank & 0x0F); + DisplayTimingPtr->VBlank =3D (DisplayTimingPtr->VBlank << 8) | DTDPtr-= >VBlank; + DisplayTimingPtr->HSyncOffset =3D (DTDPtr->HVOffsetWidth & 0xC0); + DisplayTimingPtr->HSyncOffset =3D (DisplayTimingPtr->HSyncOffset << 2)= | DTDPtr->HSyncOffset; + DisplayTimingPtr->VSyncOffset =3D (DTDPtr->HVOffsetWidth & 0x0C); + DisplayTimingPtr->VSyncOffset =3D (DisplayTimingPtr->VSyncOffset << 2)= | ((DTDPtr->VSyncOffsetWidth & 0xF0) >> 4); + DisplayTimingPtr->HSync =3D (DTDPtr->HVOffsetWidth & 0x30); + DisplayTimingPtr->HSync =3D (DisplayTimingPtr->HSync << 4) | DTDPtr->H= SyncWidth; + DisplayTimingPtr->VSync =3D (DTDPtr->HVOffsetWidth & 0x03); + DisplayTimingPtr->VSync =3D (DisplayTimingPtr->VSync << 4) | (DTDPtr->= VSyncOffsetWidth & 0x0F); + DisplayTimingPtr->HImageSize =3D ((DTDPtr->HVImageSize & 0xF0) << 4) |= DTDPtr->HImageSize; + DisplayTimingPtr->VImageSize =3D ((DTDPtr->HVImageSize & 0x0F) << 8) |= DTDPtr->VImageSize; + DisplayTimingPtr->HBorder =3D DTDPtr->HBorder; + DisplayTimingPtr->VBorder =3D DTDPtr->VBorder; + DisplayTimingPtr->EdidFlags =3D DTDPtr->EdidFlags; + DisplayTimingPtr->Flags =3D 0; + DEBUG((DEBUG_INFO,"--ConvertDTDToDisplayTiming()=3Dok\r\n")); + return EFI_SUCCESS; +} + +VOID +PrintDisplayTiming ( + char *DisplayTimingNamePtr, + DISPLAY_TIMING* DisplayTimingPtr + ) +{ + DEBUG((DEBUG_INFO, "**********************\n")); + DEBUG((DEBUG_INFO, "%a\n", DisplayTimingNamePtr)); + DEBUG((DEBUG_INFO, "**********************\n")); + DEBUG((DEBUG_INFO, "PixelClock %d\n", DisplayTimingPtr->PixelClock)); + DEBUG((DEBUG_INFO, "HActive %d\n", DisplayTimingPtr->HActive)); + DEBUG((DEBUG_INFO, "HBlank %d\n", DisplayTimingPtr->HBlank)); + DEBUG((DEBUG_INFO, "VActive %d\n", DisplayTimingPtr->VActive)); + DEBUG((DEBUG_INFO, "VBlank %d\n", DisplayTimingPtr->VBlank)); + DEBUG((DEBUG_INFO, "HSync %d\n", DisplayTimingPtr->HSync)); + DEBUG((DEBUG_INFO, "VSync %d\n", DisplayTimingPtr->VSync)); + DEBUG((DEBUG_INFO, "HSyncOffset %d\n", DisplayTimingPtr->HSyncOffset))= ; + DEBUG((DEBUG_INFO, "VSyncOffset %d\n", DisplayTimingPtr->VSyncOffset))= ; + DEBUG((DEBUG_INFO, "HBorder %d\n", DisplayTimingPtr->HBorder)); + DEBUG((DEBUG_INFO, "VBorder %d\n", DisplayTimingPtr->VBorder)); + DEBUG((DEBUG_INFO, "EdidFlags %d\n", DisplayTimingPtr->EdidFlags)); + DEBUG((DEBUG_INFO, "Flags %d\n", DisplayTimingPtr->Flags)); + DEBUG((DEBUG_INFO, "PixelRepetition %d\n", DisplayTimingPtr->PixelRepe= tition)); + DEBUG((DEBUG_INFO, "BPP %d\n", DisplayTimingPtr->Bpp)); + DEBUG((DEBUG_INFO, "PixelFormat %d\n", DisplayTimingPtr->PixelFormat))= ; + DEBUG((DEBUG_INFO, "**********************\n")); +} + +EFI_STATUS +ValidateEdidData ( + UINT8* EdidDataPtr + ) +{ + UINT8 checksum, index; + DEBUG((DEBUG_INFO,"++ValidateEdidData()\r\n")); + + // + // Check if the EDID header matches + // + if (EdidDataPtr[0] !=3D 0x00 || + EdidDataPtr[1] !=3D 0xFF || + EdidDataPtr[2] !=3D 0xFF || + EdidDataPtr[3] !=3D 0xFF || + EdidDataPtr[4] !=3D 0xFF || + EdidDataPtr[5] !=3D 0xFF || + EdidDataPtr[6] !=3D 0xFF || + EdidDataPtr[7] !=3D 0x00) { + + DEBUG((DEBUG_ERROR, "Invalid EDID header\n")); + return EFI_INVALID_PARAMETER; + } + + // + // Validate EDID checksum + // + checksum =3D 0; + for (index =3D 0; index < EDID_MIN_SIZE; index++) { + checksum +=3D EdidDataPtr[index]; + } + + if (checksum !=3D 0) { + + DEBUG((DEBUG_ERROR, "Invalid EDID checksum\n")); + return EFI_INVALID_PARAMETER; + } + DEBUG((DEBUG_INFO,"--ValidateEdidData()=3Dok\r\n")); + return EFI_SUCCESS; +} diff --git a/Silicon/NXP/iMXPlatformPkg/Library/iMXDisplayLib/iMXDisplayLib= .inf b/Silicon/NXP/iMXPlatformPkg/Library/iMXDisplayLib/iMXDisplayLib.inf new file mode 100644 index 000000000000..06a6ebaa10f9 --- /dev/null +++ b/Silicon/NXP/iMXPlatformPkg/Library/iMXDisplayLib/iMXDisplayLib.inf @@ -0,0 +1,31 @@ +## @file +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD 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 IM= PLIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D iMXDisplayLib + FILE_GUID =3D C0408490-F09B-4CFA-9A2F-5159F2705323 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D iMXDisplayLib + +[Packages] + MdePkg/MdePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + Silicon/NXP/iMXPlatformPkg/iMXPlatformPkg.dec + +[LibraryClasses] + +[Sources.common] + iMXDisplayLib.c --=20 2.16.2.gvfs.1.33.gf5370f1