drm_hwcomposer: work around for bad edid display size and dpi.
drm-hwc computes the dpi by dividing the resolution by the size of
the panel. That should technically be correct at full resolution,
however the panel size comes from the edid and in practice display
manufacturers are not the most reliable when populating edid. This is
leads to some wildly inaccurate dpi value that can change the aspect
ratio of the screen from 16:9 to 4:3.
Since edid are unreliable one simple work around is to only use one
dpi value, the width is the most likely to be correct as it is the less
likely to have bezels.
Change-Id: I8fce08dc137129b5176050bb2c61055571f1cca8
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index dad568c..30bf740 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -306,7 +306,6 @@
static const int32_t kUmPerInch = 25400;
auto mm_width = configs_.mm_width;
- auto mm_height = configs_.mm_height;
auto attribute = static_cast<HWC2::Attribute>(attribute_in);
switch (attribute) {
case HWC2::Attribute::Width:
@@ -319,18 +318,17 @@
// in nanoseconds
*value = static_cast<int>(1E9 / hwc_config.mode.GetVRefresh());
break;
+ case HWC2::Attribute::DpiY:
+ // ideally this should be vdisplay/mm_heigth, however mm_height
+ // comes from edid parsing and is highly unreliable. Viewing the
+ // rarity of anisotropic displays, falling back to a single value
+ // for dpi yield more correct output.
case HWC2::Attribute::DpiX:
// Dots per 1000 inches
*value = mm_width ? int(hwc_config.mode.GetRawMode().hdisplay *
kUmPerInch / mm_width)
: -1;
break;
- case HWC2::Attribute::DpiY:
- // Dots per 1000 inches
- *value = mm_height ? int(hwc_config.mode.GetRawMode().vdisplay *
- kUmPerInch / mm_height)
- : -1;
- break;
#if __ANDROID_API__ > 29
case HWC2::Attribute::ConfigGroup:
/* Dispite ConfigGroup is a part of HWC2.4 API, framework