diff mbox

external/drm_hwcomposer: Add a minimum DPI to keep things sane

Message ID 1490812313-25255-1-git-send-email-john.stultz@linaro.org
State New
Headers show

Commit Message

John Stultz March 29, 2017, 6:31 p.m. UTC
Currently the drm_hwcomposer can look at EDID data to determine
the DPI for the screen. However, on many 21"+ monitors, the DPI may
be quite low (sub-100), despite having resonable resolution.

Since Android will scale the display to the DPI with touch targets
sized for a phone (assuming you're holding the device), this
results in insanely tiny fonts and very small icons, providing a
bad expeirence on a standard monitor.

To try to remedy this, set a minimum DPI (160dpi) to ensure that
we don't try to scale things down too far.

Cc: Rob Herring <rob.herring@linaro.org>
Cc: Vishal Bhoj <vishal.bhoj@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>

---
 hwcomposer.cpp | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

-- 
2.7.4
diff mbox

Patch

diff --git a/hwcomposer.cpp b/hwcomposer.cpp
index 59722e9..39c91ee 100644
--- a/hwcomposer.cpp
+++ b/hwcomposer.cpp
@@ -48,6 +48,7 @@ 
 #include <utils/Trace.h>
 
 #define UM_PER_INCH 25400
+#define MIN_DPI 160 /* Min 160 DPI value to keep things sane*/
 
 namespace android {
 
@@ -760,13 +761,20 @@  static int hwc_get_display_attributes(struct hwc_composer_device_1 *dev,
         values[i] = mode.v_display();
         break;
       case HWC_DISPLAY_DPI_X:
-        /* Dots per 1000 inches */
-        values[i] = mm_width ? (mode.h_display() * UM_PER_INCH) / mm_width : 0;
+	if (mm_width) {
+            /* Dots per 1000 inches */
+            int32_t dpki = (mode.h_display() * UM_PER_INCH) / mm_width;
+            values[i] = std::max(dpki, MIN_DPI*1000);
+	} else
+            values[i] = 0;
         break;
       case HWC_DISPLAY_DPI_Y:
-        /* Dots per 1000 inches */
-        values[i] =
-            mm_height ? (mode.v_display() * UM_PER_INCH) / mm_height : 0;
+        if (mm_height) {
+            /* Dots per 1000 inches */
+            int32_t dpki = (mode.v_display() * UM_PER_INCH) / mm_height;
+            values[i] = std::max(dpki, MIN_DPI*1000);
+        } else
+            values[i] = 0;
         break;
     }
   }