@@ -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;
}
}
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