1 #include "EdidInfo.h" 2 3 #include "Common.h" 4 5 namespace aidl::android::hardware::graphics::composer3::impl { parse(std::span<const uint8_t> blob)6std::optional<EdidInfo> EdidInfo::parse(std::span<const uint8_t> blob) { 7 constexpr size_t kEdidDescriptorOffset = 54; 8 constexpr size_t kEdidDescriptorLength = 18; 9 10 blob = blob.subspan(kEdidDescriptorOffset); 11 12 using byte_view = std::span<const uint8_t>; 13 byte_view descriptor(blob.data(), kEdidDescriptorLength); 14 if (descriptor[0] == 0 && descriptor[1] == 0) { 15 ALOGE("%s: missing preferred detailed timing descriptor", __FUNCTION__); 16 return std::nullopt; 17 } 18 19 const uint8_t w_mm_lsb = descriptor[12]; 20 const uint8_t h_mm_lsb = descriptor[13]; 21 const uint8_t w_and_h_mm_msb = descriptor[14]; 22 23 return EdidInfo{ 24 .mWidthMillimeters = 25 static_cast<uint32_t>(w_mm_lsb) | ((static_cast<uint32_t>(w_and_h_mm_msb) & 0xf0) << 4), 26 .mHeightMillimeters = 27 static_cast<uint32_t>(h_mm_lsb) | ((static_cast<uint32_t>(w_and_h_mm_msb) & 0xf) << 8), 28 }; 29 } 30 } // namespace aidl::android::hardware::graphics::composer3::impl 31