From patchwork Wed Apr 11 15:22:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru-Cosmin Gheorghe X-Patchwork-Id: 10335711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E242C60365 for ; Wed, 11 Apr 2018 15:24:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D25762897C for ; Wed, 11 Apr 2018 15:24:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3A7C28980; Wed, 11 Apr 2018 15:24:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 32F902897C for ; Wed, 11 Apr 2018 15:24:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D1E606E5A8; Wed, 11 Apr 2018 15:23:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20065.outbound.protection.outlook.com [40.107.2.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 110A96E65D for ; Wed, 11 Apr 2018 15:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=OflGyDPNaLgD5xkwE7CcTFhtrL/yP63TNO51Qwmxies=; b=cT/YASddKmB33zFeAdraOEL7YW84f/Au8bC4GjjPRX3EmwDcUAjjZKi/0li+5U8qYzqeVA+wYWSIV5xDFsISU4t57cM/Nh89jEoqLEludrh6YNw3CrKpDGzNddTDm3JD8mglJJ+eZqFBjYQmIce2T+5O6wVhLOC4ty8KNR0kNZk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Alexandru-Cosmin.Gheorghe@arm.com; Received: from e114479-lin.cambridge.arm.com (217.140.96.140) by AM5PR0801MB1249.eurprd08.prod.outlook.com (2603:10a6:203:1e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.675.10; Wed, 11 Apr 2018 15:23:36 +0000 From: Alexandru Gheorghe To: dri-devel@lists.freedesktop.org, liviu.dudau@arm.com, brian.starkey@arm.com, ayan.halder@arm.com, seanpaul@chromium.org Subject: [PATCH hwc v2 15/18] drm_hwcomposer: Add worker to trigger scene flattenning Date: Wed, 11 Apr 2018 16:22:26 +0100 Message-Id: <1523460149-1740-16-git-send-email-alexandru-cosmin.gheorghe@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523460149-1740-1-git-send-email-alexandru-cosmin.gheorghe@arm.com> References: <1523460149-1740-1-git-send-email-alexandru-cosmin.gheorghe@arm.com> MIME-Version: 1.0 X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: VI1PR0701CA0066.eurprd07.prod.outlook.com (2603:10a6:800:5f::28) To AM5PR0801MB1249.eurprd08.prod.outlook.com (2603:10a6:203:1e::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020); SRVR:AM5PR0801MB1249; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 3:LFQDM5PMaidPdJhJeK0IZ+k/YsnX2G8i1I9IbHfBdj2mBk+Jz2RNPr3D1H4Rb6CdR/NOWY7HfBGGPV3BjHzQuNyMgFGr9LiUNwdpiRC4KIkP6qtSYBZaBxOkC1VhYTGKp6EBWXw8njwE1UXo5KSbkgKi3X2+mw3ZPw7KLFHc3Cpi5zK6ns/ATYwZe+k1cWO6zF6kIz0pxmC//jEfJoRCUkk4lLOagbCAZQqcQG7t7weiTe8QKSSaQrjj0VZYob+J; 25:spoIIdtUgl1R12xyOo5M+s8e2OKMTuPo+K8hFFkkTxSxjsxP03thc97xoF8nckPdzF9xRCUvl5Nqh+hzDepg5PyknBPc4JEDOS0qDED/K1zKcQ6Y2eBPVjYR1Cg3iMWpPL/ww3N+8jORGzSsJiScSmkxI5o3wXRNieORAM+PVW7tu600D4doxWk2DLWMCyYKMNNqjzMX/szAznj+UXJJr/kBF8wTUvPs/wJZc+uARxJNGo74YK6nonUQj2CHdKtK4SkMuOrOLLqcUuOsDKInAU9OId0XIhfWFdt0iPpjnvFZCHPfJTK/ZeAirHKk5a/Y8oUNkl47d+Po9GIo9lmZ+w==; 31:D4MDncF95QbGjQduNQhbrE9DAaNDqNjtiF8oF32ercdfxwQFOyjeSmU61MBz2LQ+genwrJ8pzub+pZyA8frurQjDbiNi3WFz/FxuOtDoEUiNU9gehwB+LdBg62T9VId5afrnbu7KDzO5XeVFsgqod2VDWXsqv2P9gaZlSo/3tDvtZv1RnmyA4KFhI0IPDtkAOc31dbDO3YmX0uisHjE4O5YDNBewn8W0EawmIE3yDCk= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1249: NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 20:L8QN/n0v50NpstUrZGHRIAJWvhLUyeKekIPTLrffG9/Bwq0SBAafwJR5lywn8IESc1BMKAiqh9Lc24U44AEf9PUHAg7V2Jrhe5OVogCP7CyZKBgnOZW4f8Q45iLmJGDntSesW17MKQMS0lZq+f5ntOiQ9SarfOciCr0hxRVzb+Q=; 4:gN2qREl2QkorY3dCJM/+/WkSVoxNdK3cT6P7FWBaKw+iDJcyxqjnhJNULd+lEsuwXm9dD3krziGkRTB+yzlZ5tvhg3UsNGKdgiAehimG7rnAyy6o0pM4NhmX/JOakqcV3VYx800nHkZpqVb2nKH0WqGnsIdEGueZXeVDuzllHdsxCSPRwYIM0611rfb8vB359DqaGddIM2eUoiT8UyaGu4wwzI1vbFRMEZXiJVOwyH0V1aa1qe9Rux/UpJKuPUb6RjhhdBpAPKWzNkorI7B/p0ur6N7KeS7i6/yAL8xc0n12QLvxMv/NS4Y0d260yDF0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231221)(944501327)(52105095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:AM5PR0801MB1249; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB1249; X-Forefront-PRVS: 0639027A9E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(346002)(396003)(376002)(366004)(39860400002)(189003)(199004)(16526019)(478600001)(305945005)(50226002)(16586007)(68736007)(7736002)(86362001)(81156014)(8676002)(316002)(81166006)(4326008)(25786009)(2906002)(50466002)(8936002)(6486002)(105586002)(48376002)(186003)(956004)(5660300001)(6666003)(72206003)(106356001)(476003)(53936002)(3846002)(76176011)(51416003)(52116002)(47776003)(7696005)(36756003)(66066001)(11346002)(446003)(386003)(97736004)(59450400001)(6116002)(2616005)(26005)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0801MB1249; H:e114479-lin.cambridge.arm.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0801MB1249; 23:a7UJ/yozO0LIcbGyzbOJrSmiboQ57TT5dHeeHM6?= =?us-ascii?Q?XU4F70YbZB7XOLxsHSO6caYDtzoDC6p5xcN2+dUo6lunmC8a5bRcEXPnD03y?= =?us-ascii?Q?pf0C6adoOQur1fCo4Kd/edPAfgPfxnc+LPKajfIaXsJMGPaNcftIo29MXIv0?= =?us-ascii?Q?yyNDtc5Ssc1mBCzwHsYWB68NvyWb3Qy+Vlu/Z1KuSAqw310axbSnu70J+W9X?= =?us-ascii?Q?xLNbXqqjIIpaT19e0mr6h8fgA3/vNZiIYkC5FE+cZr3uvFmMDT5sRw2A3Amu?= =?us-ascii?Q?23wqMYE+pGvU/z4om+3IHVwAE6YZD0SJg23KEhvt7KPyR4KswEYmN6aLeoaz?= =?us-ascii?Q?dpTcrJf6NXKUa9fdcle//Cju4x82MQY0LPA8hNoVGuBMNVThCQgrQCDozaph?= =?us-ascii?Q?8Y70WvsziuQBnUtLjSUiNyiX9Z75ZyiMfGKgkBx2T7Jsyd0kV3ZIM8tZXJv2?= =?us-ascii?Q?U4eQ7g92XDe3AGXF90SLZesKNUs+7hkm3REynEQjd+vvSCB7l/GRA9RANU28?= =?us-ascii?Q?BN0AJc6m397YdDeI+E03jIW2qsr/QBhq9yDP0RfoYW0+ANWSSMqfZf97adN7?= =?us-ascii?Q?rjHIdKK4lnrdODtGF07HcqU4nC1yC3lwHXq0pwOYgIpTOrgUBJas9x29VFzV?= =?us-ascii?Q?xOQjw2nwTAYAXgDG9YbAKC76r4RrOrFxxawmESuX5RbnmISKqP0gvO09FRus?= =?us-ascii?Q?2wwydyjJxJXPDGCOyNvQwDXbEPUYkn21OP+0NvLE3Pyi4FCl0BCCRzPjT4Pw?= =?us-ascii?Q?5q4qhb1yeN8Eapqn6JRNNE+sGWiwc6HtT5B9V5v2xfMOf6d3plS7+MKgR7hS?= =?us-ascii?Q?YM/ie78FEALRtVquX6ympaalto6195LEgHBDTeIAh6nAaRBchlYciKlOuiWT?= =?us-ascii?Q?1vMclzPa9676m97yq4sWLOLqWgcSqCszb8rykgiTtvjblHrLjExFRoHcgu79?= =?us-ascii?Q?3tQ3haDAfnh1vvXxOjCVbc/9KLUUmV0K2X8cfSWAKEZHe3Rr+OWFp81iks0p?= =?us-ascii?Q?/hJqAjBZl+pvzo2nkV6NUE6Nq3ZRDlOb/s9C7LtMCKH9182Vmhoaz6R69EF9?= =?us-ascii?Q?i09rrm2AAefN/OlQaKNcXMo5uxVPQIwUutvSWRY3JBnQr+1W62ZNFhD2hUMr?= =?us-ascii?Q?Er+Pjxfy+EqQUQ7H/iPTSw6Qi3FZF2zcmhi5OlRCOfT7SzftDVzkuAS5OhNr?= =?us-ascii?Q?3K8y9vvZBaHMSTQA=3D?= X-Microsoft-Antispam-Message-Info: ietAT0GT9A9kq/P0/8Y2wJSI/nRoJKBeHXbkto5qSm2gFeunWr/CkVfSeeoi+aKqgHv+hjzLqkSyiAaUm0NcUp2wJrYJOhUHyM75VgR54a0jCKb0rfSVPBggwy5FSivhRWe76j/dfvXyIzprkempuGWVu0OWg1H8gAETATS0A1oNSLtOZ/Eg2sQGGYdLXZEw X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 6:pxgE39TI+TR6CNjXtE2oOH+14j7T+rfZ+i62fe5CLBxP8qrmjFidGeAcrf43FGORL2zEZm/AUnDHrNej2Sl5pkePKZdk52EyF/V2kWlI404L2Ejgk/fj5M0VH2zedmBnm4IGRARjxtkMMCj0+UQa2cjgFv7KC3U4C2oQA3ZOLPRySmJe1AVcBLN4xKZ0tGKMV3KIg+lu6t/hfheVrp6fR848EI+Wt2AXUwYybcWB4d8OryvSXY/C16lSH8BKS8YalnBHG1qq1ng8GAKF5mACaP5Uw8qKLAT+4twxoQe3PSy1lj33RGCHY029hOf0o+qcGaHCYF9YSNP4WDJxdHmclsMXiU5L++1rM3oKMug2LdsAET2YHvRtdeIu/GkmVWNhJ1sl1zvu3JDU5/DW4UmFZMEef68yR5YdCzYPUdlvPGRVmygKytWk1dN3fBex+WcIgIyzDojzMqx/XTNXkMOFkw==; 5:5DZoFjvAj2IJ3evlVQ/GHCm9FM+mRrVK3ZDso+UI9GmJknL5q8lJgG/diED6UTKUE5BsqHTnxSpolIKHFbTGgJ18Aq5El7c1/VXTrB8HeVOZyZh5Ixc+JwZiVqfvZ4QCp+0tWRV4C3QSaa66ogV589EOTAE0alUCIEw5j0dTHUM=; 24:MhoSdo7soF+J3Xf6Hhc9eof+6hkyVNQLPRQoM4E3ihrfpfbO2b5EMyeB4DFwrBw9udCPqWjlR8K9wTPxTZ7RdEtzFfxzwmTkSWTFx0ke1+c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 7:yEeoLBVeB8jjYmucVgnsOV/aibO4klOkJOIXn5xYRHmJt7P251eouDMW77YoLb7Hy+EJLgpx2J5oTb1/MK/KAHv1+DwxpU5otpUrewAEDMMOIzNRmuOLA9BMzNKwJXBl/UWAHfFV17fC9DJ2cp7AfI+7yAOGKs2Tvy4Ofmgmz6HZo6xkAAtGGBbSNtfqsURRTJaiB6y69zaHhzeCAVd7FhCX8+hS5mxFiDFiPDBm4YqU58U70AzvErafFdtjeyz2 X-MS-Office365-Filtering-Correlation-Id: cceefad4-163d-4444-43df-08d59fc03245 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2018 15:23:36.3836 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cceefad4-163d-4444-43df-08d59fc03245 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1249 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nd@arm.com, Alexandru Gheorghe Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a vsync worker that calls back into the DrmDisplayCompositor, for now at every 60 vsyncs if the scene does not change we trigger the flattening of the scene using the writeback connector. Other, more complex and proper heuristics could be implemented later on. Signed-off-by: Alexandru Gheorghe --- drmdisplaycompositor.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++--- drmdisplaycompositor.h | 12 +++++++++++- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp index 576539b..e535e8a 100644 --- a/drmdisplaycompositor.cpp +++ b/drmdisplaycompositor.cpp @@ -39,6 +39,20 @@ namespace android { +class CompositorVsyncCallback : public VsyncCallback { + public: + CompositorVsyncCallback(DrmDisplayCompositor *compositor) + : compositor_(compositor) { + } + + void Callback(int display, int64_t timestamp) { + compositor_->Vsync(display, timestamp); + } + + private: + DrmDisplayCompositor *compositor_; +}; + void SquashState::Init(DrmHwcLayer *layers, size_t num_layers) { generation_number_++; valid_history_ = 0; @@ -183,7 +197,8 @@ DrmDisplayCompositor::DrmDisplayCompositor() framebuffer_index_(0), squash_framebuffer_index_(0), dump_frames_composited_(0), - dump_last_timestamp_ns_(0) { + dump_last_timestamp_ns_(0), + flatten_countdown_(FLATTEN_COUNTDOWN_INIT) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) return; @@ -193,7 +208,7 @@ DrmDisplayCompositor::DrmDisplayCompositor() DrmDisplayCompositor::~DrmDisplayCompositor() { if (!initialized_) return; - + vsync_worker_.Exit(); int ret = pthread_mutex_lock(&lock_); if (ret) ALOGE("Failed to acquire compositor lock %d", ret); @@ -222,7 +237,9 @@ int DrmDisplayCompositor::Init(DrmResources *drm, int display) { return ret; } planner_ = Planner::CreateInstance(drm); - + vsync_worker_.Init(drm_, display_); + auto callback = std::make_shared(this); + vsync_worker_.RegisterCallback(callback); initialized_ = true; return 0; } @@ -896,6 +913,10 @@ int DrmDisplayCompositor::ApplyComposition( return ret; } +int DrmDisplayCompositor::FlattenScene() { + return -EINVAL; +} + int DrmDisplayCompositor::SquashAll() { AutoLock lock(&lock_, "compositor"); int ret = lock.Lock(); @@ -1044,6 +1065,24 @@ move_layers_back: return ret; } +bool DrmDisplayCompositor::CountdownExpired() const { + return flatten_countdown_ <= 0; +} + +void DrmDisplayCompositor::Vsync(int display, int64_t timestamp) { + AutoLock lock(&lock_, __FUNCTION__); + if (lock.Lock()) + return; + flatten_countdown_--; + if (CountdownExpired()) { + lock.Unlock(); + int ret = FlattenScene(); + ALOGI("scene flattening triggered for display %d at timestamp %" PRIu64 + " result = %d \n", + display, timestamp, ret); + } +} + void DrmDisplayCompositor::Dump(std::ostringstream *out) const { int ret = pthread_mutex_lock(&lock_); if (ret) diff --git a/drmdisplaycompositor.h b/drmdisplaycompositor.h index b35ef70..26201b9 100644 --- a/drmdisplaycompositor.h +++ b/drmdisplaycompositor.h @@ -29,11 +29,16 @@ #include #include +#include // One for the front, one for the back, and one for cases where we need to // squash a frame that the hw can't display with hw overlays. #define DRM_DISPLAY_BUFFERS 3 +// If a scene is still for this number of vblanks flatten it to reduce power +// consumption. +#define FLATTEN_COUNTDOWN_INIT 60 + namespace android { class GLWorkerCompositor; @@ -92,7 +97,7 @@ class DrmDisplayCompositor { int Composite(); int SquashAll(); void Dump(std::ostringstream *out) const; - + void Vsync(int display, int64_t timestamp); std::tuple GetActiveModeResolution(); SquashState *squash_state() { @@ -128,6 +133,9 @@ class DrmDisplayCompositor { void ClearDisplay(); void ApplyFrame(std::unique_ptr composition, int status, bool writeback = false); + int FlattenScene(); + + bool CountdownExpired() const; std::tuple CreateModeBlob(const DrmMode &mode); @@ -157,6 +165,8 @@ class DrmDisplayCompositor { // we need to reset them on every Dump() call. mutable uint64_t dump_frames_composited_; mutable uint64_t dump_last_timestamp_ns_; + VSyncWorker vsync_worker_; + int64_t flatten_countdown_; std::unique_ptr planner_; }; }