OSDN Git Service

drm_hwcomposer: Add a minimum DPI to keep things sane
authorJohn Stultz <john.stultz@linaro.org>
Wed, 29 Mar 2017 18:31:53 +0000 (11:31 -0700)
committerRob Herring <robh@kernel.org>
Thu, 30 Mar 2017 13:28:54 +0000 (08:28 -0500)
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.

Change-Id: I39a1376a2c2ed1c27f09e5d716a6941b507fc5f8
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>
Signed-off-by: Rob Herring <robh@kernel.org>
hwcomposer.cpp

index 59722e9..39c91ee 100644 (file)
@@ -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;
     }
   }