From 3e96f94d2cda8e5c9180e116aac6c57537fb970c Mon Sep 17 00:00:00 2001 From: Gil Dekel Date: Wed, 13 Nov 2024 14:51:24 -0500 Subject: SF: Parse Physical display size in framework More EDID fields are required as a part of migrating to EDID-based display IDs. This CL parses the physical display size in CM from bytes 21-22 of block 0 in the EDID blob and serves it as a part of the Edid struct. Later, amongst others, this value will be used to fabricate a unique display ID that is based on the display's EDID. See: 1. EDID spec: https://glenwing.github.io/docs/VESA-EEDID-A2.pdf 2. https://en.wikipedia.org/wiki/Extended_Display_Identification_Data#Structure,_version_1.4 Flag: com.android.graphics.surfaceflinger.flags.stable_edid_ids Bug: 378922658 Test: DisplayIdentification_test Change-Id: I0bb27f267421941aa56f6147082a05ea3b13f33f --- libs/ui/DisplayIdentification.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libs/ui/DisplayIdentification.cpp') diff --git a/libs/ui/DisplayIdentification.cpp b/libs/ui/DisplayIdentification.cpp index 8b13d78840..503f92ff32 100644 --- a/libs/ui/DisplayIdentification.cpp +++ b/libs/ui/DisplayIdentification.cpp @@ -212,6 +212,15 @@ std::optional parseEdid(const DisplayIdentificationData& edid) { ALOGW_IF(manufactureOrModelYear <= 0xf, "Invalid EDID: model year or manufacture year cannot be in the range [0x0, 0xf]."); + constexpr size_t kMaxHorizontalPhysicalSizeOffset = 21; + constexpr size_t kMaxVerticalPhysicalSizeOffset = 22; + if (edid.size() < kMaxVerticalPhysicalSizeOffset + sizeof(uint8_t)) { + ALOGE("Invalid EDID: display's physical size is truncated."); + return {}; + } + ui::Size maxPhysicalSizeInCm(edid[kMaxHorizontalPhysicalSizeOffset], + edid[kMaxVerticalPhysicalSizeOffset]); + constexpr size_t kDescriptorOffset = 54; if (edid.size() < kDescriptorOffset) { ALOGE("Invalid EDID: descriptors are missing."); @@ -346,6 +355,7 @@ std::optional parseEdid(const DisplayIdentificationData& edid) { .displayName = displayName, .manufactureOrModelYear = manufactureOrModelYear, .manufactureWeek = manufactureWeek, + .physicalSizeInCm = maxPhysicalSizeInCm, .cea861Block = cea861Block, .preferredDetailedTimingDescriptor = preferredDetailedTimingDescriptor, }; -- cgit v1.2.3-59-g8ed1b