From patchwork Wed Apr 11 15:22:29 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: 10335717 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 CDB1560365 for ; Wed, 11 Apr 2018 15:24:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF85528984 for ; Wed, 11 Apr 2018 15:24:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3D5928980; Wed, 11 Apr 2018 15:24:43 +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 25D0A2897C for ; Wed, 11 Apr 2018 15:24:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 535B86E694; Wed, 11 Apr 2018 15:23:49 +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-ve1eur02on0617.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::617]) by gabe.freedesktop.org (Postfix) with ESMTPS id D39846E6B9 for ; Wed, 11 Apr 2018 15:23:44 +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=ilbQ1l+XduueOkA92ukB1IE/KBQX8PVD+RWUdu19nQQ=; b=MCZdeR6FCY+SEAVgVAs0Bzsi+Wj6azc3993W3qA4Z5PH7c9JQGjWAUjpHSoIAAxB3aOfMCtT5MKYChAqzHRoJNo86jIsqAMdsJsOTdjo09pDBbTL83xy+P2mQAOs163FuprY5rZsNDKrKkNoEyeREgIOrx6OOa//6BYVCczQEdM= 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:41 +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 18/18] drm_hwcomposer: Flatten scene asynchronously Date: Wed, 11 Apr 2018 16:22:29 +0100 Message-Id: <1523460149-1740-19-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:QCHmf2Ilu0Eip7H6D2RelpU1+d8jvdlZyqe2UJQhO5SuSdkT4X9Vf14oGs5YTpNzcLxvwt5wr2dg4dHKEo3ccmlU74gNV9DiD5NWoSPl85EzYi6NeUaELFSbH5VQYHh+zRCDMpfSjXJFcEeuabjljDtPX2tHx8iLxa+7f9RdZM5arm9LJ0GQBq+DwX0ZU0LIby0h8f5hDiKS/ywC3S47Ow9giv1KhUubzz3NvXEabXCOGu2GY3/foT9U5/yXVDUB; 25:1ndUFKvYgTPj74G5crhJJIEOWkkjzSxr29PMHg/B1sZz3a7Fzd9qf+Zpc+RwgQleKqNoIek0vlRaMaOUr448oQjKBaCdyg16fgJMh0d/+ufFIs39WDA1uWBGv1Y0IoDpVYfBExSVG7cUjJgQh2Zjd0nUpDn9vHZhk1x/5nQBUPg/e9vklxojr4h78shWn8wM4okgxdUEwROWDy2AOc3RySy/FcqjvbaYvZZl67tl0TJMYPSniJRU3zaXq2K+nui09HI7JkXnv5hh8++4q4dcATi6+wyRja3Jve2n5ehebGfZDpTdnNVgmB9BwiN/Vqq3Ju4yYy3qO0QrEn2GmtfsMw==; 31:yIHRg1c2aGjRzetrv+U++PavmL9Ayajv5G549wv9SzLjDHFzEe3AsoZMlAnipFpc3y7GDJdAh8WOudD6LQH6/I2nLfXh7RZhnWgJZxROeit+K5jJytGIn536J/+L/j8F3rn+0mtlU63Ugns/2g8c3gNg4tKOKayfpQrZ0l3x14GizL2MwAD2fE5roGMrpvUnHKV0cw5IWz94toaotvBig2/Dumii2WwVNXqE8/ovwUo= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1249: NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 20:Lvaf3ej3lKlH0Uo1aIribb5RFswcEVtd+qtH100xfXTeK8cyNSPfz6bOKUVKqjlDt31mao/mfTFxZ0uusAYgbatdOy5aTRITrKjnj/aKmgHaTwQ8mlPteYZP/qnUW0vR5dndJoKt/I+TPGk4en04jyt1Z/TxORoxjRInuGYVmRc=; 4:a+b1zplQGpf6yR6aQhhBT9fwFQZR9ljxSKqFvWRmsnnGOM7xOwB4TamXiz8uI47I8w51Eu3GHVOm/jY0oXQvnrkeA0rWwhFjVg95i0ZDsTYsrMxd1fqiDvBy0w9g8L5iiERyRf+7plv3fS7V0FKHywcqlXPeqU0S8syO/+BY3UW//qjpT786gOecGSDe8ZJVGi2wo4n1AFFdsn77KlLKqkujLDZLreeG/MbkrPUzdG7ilzZQxfUjivgZ4qW7MrWaBMoSwcNEqF9Im71owG1JNBouLv0Fl49BrWcjiXChXNTTzF3KslN2QhTYNrkT48tI 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:qxM0LEbXBhzjm+JKeHV12TX77MWv1fhYZ8HUblW?= =?us-ascii?Q?I/aUf8mFJDYNbJfZv4wNfyjLJrM0MCXKbxSeZfSP0obbVo+FaPIH3Z7K7tzj?= =?us-ascii?Q?VLZ3aRC/yCRSfmys2slrEFcDR3R4ErZnfey6PDGJ/17KtfYxSdmLJu6/Vls+?= =?us-ascii?Q?gYIZEvcL21NtbzZNIAiYc1f9eszZJ2Mtuv+wlbyDI9BBbAhuuhSXJTJ0kNrG?= =?us-ascii?Q?JRsFK0QOhFiVdZ1frCYCX9ijJNOrIz+aAseKlDCX8BzVS01PJdTOXJ40a2aI?= =?us-ascii?Q?XUtcxTArePCVUMPrmVlAaaGJdiu30iyBuUtIINjZj+gZiQ7CM6JGqn+qdlPU?= =?us-ascii?Q?nM28huVeAzKPWGCv2EuGHo125G2wEfLSdvtT5RbEY+Z2xkTYAh4iak1zb/9B?= =?us-ascii?Q?TIqHe7l5ahTVdWwISWupiybeem0GN2D3BhES7bN87E55aU43mozIBwVqIzad?= =?us-ascii?Q?ICVkX4AjuFx9U9z5nRp66DalWJIKhX7TckaTOolbJnR+iM6hDWf+dlrNdcui?= =?us-ascii?Q?WcKz08hFOxe1Afe7IdAVg48RTOssLzmx/CVmTjTkr4J+Q/9sjiSCgs2SJ6u/?= =?us-ascii?Q?Qaq6Fvn7gqjHJ/x5mwu2GYoJ+hUFPKomeln3lRbzml7EXOK4AG/PYO9sevdd?= =?us-ascii?Q?r62WLg+y5eYUTjBrWPS9MYgdtt4l3+qrN/rfnrqOjTctQO1Tga0WSJaHMhft?= =?us-ascii?Q?qVRNoBocl0OkgYZOani/tE7AGtmB9qgaeWizevgVB026T2eilUJKWCKJSsDY?= =?us-ascii?Q?yYRxQqa8BMdkGg6FEVnj80JG8ysdhFCYD4cuwstIWr2k28v3MAwygiFabDnG?= =?us-ascii?Q?J1P/fmJKop3tGOOXMEOJA/xd09g0ZVZSQGuHojSjCa+I6Ie+deQIvT0PZQZS?= =?us-ascii?Q?dmeUh8KTtuvg8N8rsPAa/daRurve6j1OQNvHl1nOu9RcV87zXb/5ArgPIjXg?= =?us-ascii?Q?t9KT8/A+cOiZk5uQgCBrHWf76fo+LoyICg+QhIW05S5NEYFKDGjI4/NYYNer?= =?us-ascii?Q?CbTgquYBtrOBTchKs6zZKLsr3xxbjUBRqvbt6IBE+Zr9PaI+LtAX7hf1zx3l?= =?us-ascii?Q?QaQiY/bWjhtjH3LDRPtxXedvjxAAQbnD/rmpN1j9XqwFp+0hLlmEDAsqY4CG?= =?us-ascii?Q?bEql9fR3RO5cppGXJuj7XXt6T+gi2NFbtpvdIxgsMd0ZtKik3v5KoxfFxLDV?= =?us-ascii?Q?qC/qpfP0dZYKjqW8=3D?= X-Microsoft-Antispam-Message-Info: dqPEd5CVjdQfI3kk6JcxZI61j+NGukGV2iE/My2qY4m0niz29py39tBXrvVoMVg/v4KnSXC9kPFs9GefBh1k22S4vsA1oBM4X01445lE3sFuEG8ytDjPXfEuaEwlvsZ6sGUhO3QEoL574w2NE90ccBcBmBuo6i4IfvXVKY3EiBjQkBe28A18o9UEsUlsnsD+ X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 6:PCAcml/Np5RlgmETc0UIKmxl0iW+BQfB/TsROtTBvsns8SKZCrkXEbQ87zpGybDiwM81FlCYr3iHGBAZxTdH1/4sfoswyyAICYolTEO+AHX9Oqecwh2Pd9Zz48BGp9XwjKU2hzVGLcj11GS3NfQPrg9Bu/d4E1tvixhSfSnAr8YVHFj7ZCbcP60aEqZR9q1atbXJviK5bBs1RVqFW88vV53QbQmXOUI8kjF3KHfvfWUp62y9dNEvSiNkGgxony+a/QHw9imADSfId7BybvY8opOVzDmiz1zPTMDRWoIvJ8lhNTk1CI/S8mScLq/ISO0qrDCBndK0i1PhU/lTAwoMVtit+9mHLH34XV9t+G0xEiMaKFYZDSpLMf9K5PxlsKLtkezpwx6ezgiF479PVZ3XrD5hS/PSVOMjwB8i+ZPPMvx+7BaBwQS+r2vxoYyj5NlwEj7WoBfO6sZ145DyJpHllQ==; 5:VDg1rNYOLEPLEQCGvmq6EsCLZdDKCTBJPV/lSBuyMwhQuRS8ATwEhEsRMR+rXrNeNJZjrZnDu2QX9TwpkDNM0W2lXnk3UHUJHQJbHq7UUQZ0Wgvzr1D8NoYvB9dDxnLxOw0ZPBjx8C8XE0QKknlYGPluGH+XyKa68m0uq1761wk=; 24:D8nQlr9NFYTTWcDODrlrCeaw0T5JAvc8E/HUB+iIUocDCJYIF+hybkwwThnf3goBEhjpEUudCUpWjtWPecOCyXNyGIM/EN2RmToZ5p788kU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 7:j/Id3tHqJrwl17XSEN3c8TLCcu5EvrwelnHNCPo9k+WjGtFwraj4GCslmRFQZ2pkdGbrhD4v2nrkCQyrPYEkPQe0pNZ/FnsBW78IGtDqIne7CzqG0mmhwBpoZM6IbHXbomSjEWQMx6taf4M/5PpnAAls5lob83+g62fFGMTlhUE1TRMOsF4i8+qJtqxjzvDBhqSQTznf8l8Jhmd2Hg9xNBfLXJBUomD1UQWfW+LbjuADZ3sT9+Abe6x73KJYoEsP X-MS-Office365-Filtering-Correlation-Id: 019543ff-7c9e-4e5b-02f4-08d59fc0355c X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2018 15:23:41.4898 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 019543ff-7c9e-4e5b-02f4-08d59fc0355c 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 The steps for flattening a scene on a dedicated crtc are: 1. Find an available and unused crtc(the display connector is disconnected). 2. Copy layers from active composition. 3. Plan layers of copy on the unused crtc. This is realized by using a newly created DrmDisplayCompositor object. 4. Commit copy to the unsed crtc and get the result as a writeback_comp. 5. Copy the writeback comp and commit(if needed) to the display. The copying of the writeback comp is needed because the crtc might not be on the same dri node so the buffers will have to be re-imported. Signed-off-by: Alexandru Gheorghe --- drmdisplaycompositor.cpp | 173 ++++++++++++++++++++++++++++++++++++++++++++++- drmdisplaycompositor.h | 5 ++ 2 files changed, 177 insertions(+), 1 deletion(-) diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp index cb670e6..72d0226 100644 --- a/drmdisplaycompositor.cpp +++ b/drmdisplaycompositor.cpp @@ -973,6 +973,84 @@ int DrmDisplayCompositor::ApplyComposition( return ret; } +int DrmDisplayCompositor::FlattenOnDisplay( + std::unique_ptr &src, + std::unique_ptr &writeback, + DrmConnector *writeback_conn, DrmMode &src_mode) { + int ret = 0; + ret = writeback_conn->UpdateModes(); + if (ret) { + ALOGE("Failed to update modes %d", ret); + return ret; + } + for (const DrmMode &mode : writeback_conn->modes()) { + if (mode.h_display() == src_mode.h_display() && + mode.v_display() == src_mode.v_display()) { + writeback->SetDisplayMode(mode); + mode_.mode = mode; + if (mode_.blob_id) + drm_->DestroyPropertyBlob(mode_.blob_id); + std::tie(ret, mode_.blob_id) = CreateModeBlob(mode_.mode); + if (ret) { + ALOGE("Failed to create mode blob for display %d", display_); + return ret; + } + mode_.needs_modeset = true; + break; + } + } + if (mode_.blob_id <= 0) { + ALOGE("Failed to find similar mode"); + return -EINVAL; + } + + std::vector primary_planes; + std::vector overlay_planes; + SquashState squash_state; + DrmCrtc *crtc = drm_->GetCrtcForDisplay(display_); + if (!crtc) { + ALOGE("Failed to find crtc for display %d", display_); + return -EINVAL; + } + + // TODO what happens if planes could go to both CRTCs, don't think it's + // handled anywhere + for (auto &plane : drm_->planes()) { + if (!plane->GetCrtcSupported(*crtc)) + continue; + if (plane->type() == DRM_PLANE_TYPE_PRIMARY) + primary_planes.push_back(plane.get()); + else if (plane->type() == DRM_PLANE_TYPE_OVERLAY) + overlay_planes.push_back(plane.get()); + } + ret = src->Plan(&squash_state, &primary_planes, &overlay_planes); + if (ret) { + ALOGE("Failed to plan the composition ret = %d", ret); + return ret; + } + if (src->squash_regions().size() > 0) { + ALOGE("Abandon we don't want to fire up the GPU"); + return -EINVAL; + } + + // Disable the planes we're not using + for (auto i = primary_planes.begin(); i != primary_planes.end();) { + src->AddPlaneDisable(*i); + i = primary_planes.erase(i); + } + for (auto i = overlay_planes.begin(); i != overlay_planes.end();) { + src->AddPlaneDisable(*i); + i = overlay_planes.erase(i); + } + + ret = WritebackComposite(src.get(), writeback.get(), writeback_conn); + if (ret) { + ALOGE("Failed to writeback ret=%d", ret); + return ret; + } + return 0; +} + int DrmDisplayCompositor::WritebackComposite(DrmDisplayComposition *src, DrmDisplayComposition *dst, DrmConnector *writeback_conn) { @@ -1088,6 +1166,97 @@ int DrmDisplayCompositor::FlattenSynchronously(DrmConnector *writeback_conn) { return 0; } +int DrmDisplayCompositor::FlattenAsynchronously( + DrmConnector *writeback_conn) { + if (writeback_conn->display() == display_) { + ALOGE("Cannot flatten asynchronously on the same display"); + return -EINVAL; + } + ALOGI("FlattenAsynchronously on a different display"); + int ret = 0; + ResourceManager *resource_manager = drm_->resource_manager(); + DrmResources *drm_resource = + resource_manager->GetDrmResources(writeback_conn->display()); + if (!drm_resource) { + ALOGE("Failed to find resources for display = %d", + writeback_conn->display()); + return -EINVAL; + } + DrmDisplayCompositor drmdisplaycompositor; + ret = drmdisplaycompositor.Init(drm_resource, writeback_conn->display()); + if (ret) { + ALOGE("Failed to init drmdisplaycompositor = %d", ret); + } + /* Copy of the active_composition, needed because of two things: + * 1) Not to hold the lock for the whole time we are accessing + * active_composition + * 2) Will be committed on a crtc that might not be on the same + * dri node, so buffers need to be imported on the right node. + */ + std::unique_ptr copy_comp = + drmdisplaycompositor.CreateInitializedComposition(); + /* Flattened composition with only one layer that is built + * using the writeback connector + */ + std::unique_ptr writeback_comp = + drmdisplaycompositor.CreateInitializedComposition(); + /* Copy of the writeback composition that will be committed to the display, + * needed because of 2)from above + */ + std::unique_ptr next_comp = + CreateInitializedComposition(); + + DrmCrtc *crtc = NULL; + if (!copy_comp || !next_comp || !writeback_comp) + return -EINVAL; + AutoLock lock(&lock_, __FUNCTION__); + if ((ret = lock.Lock())) + return ret; + if (CountdownExpired()) { + crtc = active_composition_->crtc(); + ret = copy_comp->CopyLayers(active_composition_.get()); + if (ret) + return ret; + } else { + return -EINVAL; + } + lock.Unlock(); + ret = drmdisplaycompositor.FlattenOnDisplay(copy_comp, writeback_comp, + writeback_conn, mode_.mode); + if (ret) { + ALOGE("Failed to plan ret = %d", ret); + return ret; + } + + DrmCompositionPlane squashed_comp(DrmCompositionPlane::Type::kPrecomp, NULL, + crtc); + for (auto &plane : drm_->planes()) { + if (plane->type() == DRM_PLANE_TYPE_PRIMARY) + squashed_comp.set_plane(plane.get()); + else + next_comp->AddPlaneDisable(plane.get()); + } + next_comp->layers().emplace_back(); + DrmHwcLayer &src_layer = writeback_comp->layers().back(); + DrmHwcLayer &next_layer = next_comp->layers().back(); + next_layer.PopulateFromDrmHwcLayer(&src_layer); + ret = next_layer.buffer.ImportBuffer( + next_layer.sf_handle, resource_manager->GetImporter(display_).get()); + if (ret) { + ALOGE("Failed to import framebuffer for display %d", ret); + return ret; + } + squashed_comp.source_layers().push_back(0); + ret = next_comp->AddPlaneComposition(std::move(squashed_comp)); + if (ret) { + ALOGE("Failed to add plane composition %d", ret); + return ret; + } + ApplyFrame(std::move(next_comp), 0, true); + ALOGE("Apply frame end scope"); + return ret; +} + int DrmDisplayCompositor::FlattenScene() { DrmConnector *writeback_conn = drm_->resource_manager()->AvailableWritebackConnector(display_); @@ -1103,7 +1272,9 @@ int DrmDisplayCompositor::FlattenScene() { if (src_planes_with_layer <= 1) return -EALREADY; - if (writeback_conn->display() == display_) { + if (writeback_conn->display() != display_) { + return FlattenAsynchronously(writeback_conn); + } else { return FlattenSynchronously(writeback_conn); } diff --git a/drmdisplaycompositor.h b/drmdisplaycompositor.h index 4cc4a5e..a218bb7 100644 --- a/drmdisplaycompositor.h +++ b/drmdisplaycompositor.h @@ -137,6 +137,11 @@ class DrmDisplayCompositor { int status, bool writeback = false); int FlattenScene(); int FlattenSynchronously(DrmConnector *writeback_conn); + int FlattenAsynchronously(DrmConnector *writeback_conn); + int FlattenOnDisplay(std::unique_ptr &src, + std::unique_ptr &writeback, + DrmConnector *writeback_conn, + DrmMode &src_mode); int WritebackComposite(DrmDisplayComposition *src, DrmDisplayComposition *dst, DrmConnector *writeback_conn);