From patchwork Wed Mar 29 18:31:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 96212 Delivered-To: patches@linaro.org Received: by 10.140.89.233 with SMTP id v96csp2331764qgd; Wed, 29 Mar 2017 11:31:59 -0700 (PDT) X-Received: by 10.99.55.78 with SMTP id g14mr1915635pgn.191.1490812319453; Wed, 29 Mar 2017 11:31:59 -0700 (PDT) Return-Path: Received: from mail-pg0-x22d.google.com (mail-pg0-x22d.google.com. [2607:f8b0:400e:c05::22d]) by mx.google.com with ESMTPS id a1si8132619pgf.369.2017.03.29.11.31.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Mar 2017 11:31:59 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22d as permitted sender) client-ip=2607:f8b0:400e:c05::22d; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c05::22d as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-pg0-x22d.google.com with SMTP id 81so15008252pgh.2 for ; Wed, 29 Mar 2017 11:31:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=yniKi7MQ0lJEzluUAPzSq0SF7LzBaPj6YdNsQSeTjCc=; b=QmLQiRY2ddQf9n/6F44dYJy8GrDsocZXXwOI9h3FX5TjcXCyWK6GzoHXyghM/01t1m gW+o1XVd3KbZm3Zea+9nFhyFbEcEX3k4pq/aAt2rDlmroxppn+dodG3UQTrqDr4yBJy7 OvvxJONB9oRKZ3x9tfbNAg0NOnax+ogJOY+zU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=yniKi7MQ0lJEzluUAPzSq0SF7LzBaPj6YdNsQSeTjCc=; b=ncm/S7Sps39EZOC9ywCHkGMcWVEwrgwIZbjNiYv/ZpeVqBOATyrPCb6woGX8IRZf63 j7jo6YizZegNM+htoM5J81n4w/mvtgo04ygoeCb5m3+oOTEY/+grwYeYSfrFjjRCvh4n 4NiENQ4E7aNbz4vdwqmkWJBlJ6wIj0qPWU5jsUfW5Qy9/JtY9Btd/+UsqT/NeTm/S5VT fpsS31oGBZ+fkqwV91B00OhcSvYB0mWSjPD7Aa5oa0lvYcbuTQ06hHnMGEkMAUmm1qoC BnZPYGHciXKA217dzRZ0esLy/x1fys59fVwkv55m1rDpU6M+fXKvuyUWKgowOn6tAE2o jaRA== X-Gm-Message-State: AFeK/H3KlZmElEa6q6QBf52RVVk25bF7IVyFfySTaXF7OEvx1sk1BmX/gPweM0D7FjOor3qGijY= X-Received: by 10.99.101.197 with SMTP id z188mr1979488pgb.164.1490812319002; Wed, 29 Mar 2017 11:31:59 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id m20sm14887960pgd.32.2017.03.29.11.31.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Mar 2017 11:31:57 -0700 (PDT) From: John Stultz To: Cc: John Stultz , Rob Herring , Vishal Bhoj , Amit Pundir , Sumit Semwal Subject: [PATCH] external/drm_hwcomposer: Add a minimum DPI to keep things sane Date: Wed, 29 Mar 2017 11:31:53 -0700 Message-Id: <1490812313-25255-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 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 Cc: Vishal Bhoj Cc: Amit Pundir Cc: Sumit Semwal Signed-off-by: John Stultz --- hwcomposer.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/hwcomposer.cpp b/hwcomposer.cpp index 59722e9..39c91ee 100644 --- a/hwcomposer.cpp +++ b/hwcomposer.cpp @@ -48,6 +48,7 @@ #include #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; } }