From patchwork Wed Apr 11 15:22:27 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: 10335715 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 663C26053B for ; Wed, 11 Apr 2018 15:24:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59C002897C for ; Wed, 11 Apr 2018 15:24:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E24328980; Wed, 11 Apr 2018 15:24:38 +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 AF07B2897C for ; Wed, 11 Apr 2018 15:24:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F315F6E6B7; Wed, 11 Apr 2018 15:23:43 +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-ve1eur02on0606.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::606]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2175D6E6AC for ; Wed, 11 Apr 2018 15:23:41 +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=1CPeL5ZWNHxDsAOtS5MW+/f8ZK/WcURbndFj7+ZHXRQ=; b=KUZdCAzACAks8WtNalLL1c0hdDyAtputfqpllKAGBubKmNsjmm33qnDpmjdtxLLiWKmtg3iJtC38LZ29amRI6YKszU+ZCjhCC2lAf9VVWJ4DMYIR1VnB/XxqIiMbyJTFlvtouixewoh8kEuBRqBNlW2nCcPSj9DH+Zlx6Y6yhsQ= 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:37 +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 16/18] drm_hwcomposer: Find writeback connector for scene flattening Date: Wed, 11 Apr 2018 16:22:27 +0100 Message-Id: <1523460149-1740-17-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:Wk3MAzg+zA5LZgrsStGOCf5lVvImT83rAMDHHoOY7EDVvBlilVsQwFoqcQFOyPBGr6zIHs73MGGfsDUmWhDxxxX8G+9RPMUaoKnZx/biTil3a5Zfm4KoT8LdY5n5HEiLKdJ6i+VTRviSlR3bsLikOojY+mUyuaRTYImm272CKRleeiazlW40hLldcABVp7YW1LFBUhPALbVA0Pf/K2wCUOvAyjCbpZd8iPvJGEWYgx3b+ri+mXqyEOKIeZ5V8pNS; 25:+v0WX49Q+Hn/rXtErzYla79xOkqCOJLujDL7QvWmpHM6dXLKdIK1FK7O9a+BAMIHOThbYH/Xr78hvGGuZPst/mhwH1vXdBqd6m4IbL9KfHbwWZVAGPGTFA2eXDj60sWf/phXxkJsb3w2u1XKlGjp/JreM+Pe7DGBxclxztsoCVMZPRff3p+t3PTHkV19pedvsQ05jSlkUYWNv2TJ0daTHUwgahpvChUZonk9otfjoye0lvr9NzQ4tckRffSEoaKHwqwHi04Fi5TdVNIDCr8JqoVT48y9JJVrjvzGg2DvcBYiQHligcGiOQISoV/1I2z1RSjLHGBq7VgIXoFQ6ehJYg==; 31:WCHjMO9832L/foDvJHgx53NqOYMP6Zpl/C54zp3cD5k1UVF8bUlmaDR4FfqlmCUoF3A0ZFgvr6wFCzGyXKR95TIPFpaQdWmfKcPD9oUTDIUD9z8oXZ9RmNtHNsI7T2WNnsQtdNOLGUSBhyakPx5TDBjsZTeyGSXd94x6gFsLUi94vbJOZK0YRPkQbZDLmEQYL3nLwc2/x29Q83r2XxXz4sDgHDtiUVgtXCEapZzz12o= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1249: NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 20:jV7JdxksYHZJpTMPJiXcrghreKKqmp35G87bAG0gRD8BVQ+2ep/T5F/oxULeWA6QVGgOlZI1HXjYkSv70TwUsClCgQ4Y5zxhK7CTEYbXR5dlhvQXc7ahGe55aOtRLsmmxCmwMRmGPRUdmrR7OqkYZE/fzn87LJ8rxZMV9PD9MBc=; 4:duyGaEvzWPqO91Lejv0NzjJyHaNdkIKyv/1wgcnx8CS9OJveqFOUp4CmXOAn3hsJmmGjuZ9xom00RzIU5Pn1a2XWDNKJQThsft6wVvoKOVGgEkN6p8STPcsnaunI/0clQ1H9gUFQmjoJAYTcju/TJWQS1LoC5JkqJEjtfihyZFk2Icr7WNq7LLOsl7Wp31qlSair96LYO+6+E/I0mlppWvq59vHF6/DOM0+PX/ymRLAJH5BFyUHGO973v3brXxl7IAb1Po6eBp+V1ddyf99bTMgWmj1e8i630+NWmV/jXIl2Iv9wRBgNVN/MgcYEzy4f 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)(5890100001)(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:xWXDhIb5/68AmhYNAffsMgobHV6oL2UL7TkPCX/?= =?us-ascii?Q?4dQeQshxm7Mr1kYpoh2+WwgLLtAurR/uXBHIqN44aPjyzmP45vV6LIzq9Y9m?= =?us-ascii?Q?QQ62qgt0tNqK1PcPynn8P/dWxDMv0jBAQOp33oyacg8qkY7in+lLkkOdyxQA?= =?us-ascii?Q?K6vJFzvoM4FyI7NvuQtIXTOtLYj899UAYqmHTgLoMq72RgQlnGbFwpzRT1ES?= =?us-ascii?Q?DR3f2tYSF0KSGvZ7AmsHj8Vk7o8IBpN/vWQ9Wr8Gy47tNykOE8qhpHGPuoy/?= =?us-ascii?Q?M+cofiyHR3uVR7O7aq2PvPLexG1SPMJWjdCmBYTtKGdOTEmy2ZTiBNX96B6Q?= =?us-ascii?Q?/tafmYWihb5NV/TAftbme1P5cteb9w7RU3HSYtWiAmZGYm/GX/Uc/ET4mk8l?= =?us-ascii?Q?8fCjt9rU9iwPyx6xdI4fNpkyhyv2TwbSb9WpTuj8fSrGwNvt4ZZp0NVnMGg3?= =?us-ascii?Q?M79VH4Hy5nFnJtuc0YtXDenlifV3xN9vD9/ZrDRkVRMk34EMrHrjABelNhbx?= =?us-ascii?Q?Mh6dJL1vObyQoWe02XmatyZtDoChxHjwXkEQ16PPy50BYZExN+XSjDweI4Vc?= =?us-ascii?Q?7PKprycTn4/seP+7Q9ghUWdYd9CvaCPRpUtpA11f03dETqgxt4+b05M/L03B?= =?us-ascii?Q?nJOP/eCxL/VywXWlkc/tKe529BvM7ztqptqJN3DcbZjYdzZa334vl6tmotyV?= =?us-ascii?Q?MDjCP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kMR2ZhjZWiLd745Flku9byyB/DV4Ph9rM39dR3xPPnAJjITc1D97C8zZZ6REjrfqT8mE0oNc7x6r7BZmtqMBlXxXm3bF8l8g5suMyJBdHNGCrvODEIX7qOmEZwaQtDvyrFDwVnPKEdgCEcB0JvwSOCLQWNRbWRI37rvJOv0OgJ7pbLdzJ4FsFDekYYXMULSvnKv+Ts1+t0E+KyQteY3Sus0vc0oVZFD0ftJqnOGby7vFRbb4lITzuyMBzWKD8AUYPgIYS329/o996f68NjlfJL/zwiZ14+eS7+L605HJJTZCw==; 5:WY3IF5yUoK0w7S9xHAy89h+J4qVOBAlkw0V0RCycwCd3wUW6EsO19S7Q/93CGn9+oSacJ16q9ouH3zegLnyxNxsGxNAENnq4f5wcBguWjYNMrD1U6cSQAQaNgvrgoEpnuno0BQ92PjD/kTjlVmlWCGSEAvV3UKDvjUO48v+d1ac=; 24:sEaEHxi0/HdZDH+RxRHaea2oVIDRZ3YpIeVQchK7i1/FZ1yYkwY1WES9vdujKWy4qIYr5pZKI9zNdoNoMz9BJLq2/Fxj8qsf15A23fZS3qU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 7:UPR7O+21gsYO7V+PqHV/F0CFrjt9M6NQwwXT8Z6oUtWkb+lKT1v6unuO3yxRI9MFUvb046HghMyN5AJgDc7BkDoBTpDM916dbcUU1aNQrrC33pvFha/78FNuzR6JqndQDdaVvOo0ASKoBPR5tDLLx6iOaYo+UzjtnhB/WDWO3/95A+kZNe2m2QvINLc9aZSFkWlMUR0CFTYLB3+eeVIMw2SRLxUIGLVgucGXx4siUThbFWFDlBC8VZ6YiZdsUz0L X-MS-Office365-Filtering-Correlation-Id: e6da3f2a-b015-4dd6-323f-08d59fc03328 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2018 15:23:37.8728 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6da3f2a-b015-4dd6-323f-08d59fc03328 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 logic for finding a suitable writeback connector, there are two possibilities for finding an usable writeback connector: 1) Attached to the same CRTC as the display and can function concurrently with the display connector. 2) On a different CRTC and the display connector is not used (state != DRM_MODE_CONNECTED). What's not handled here and should be handle is what happens if connector changes state while flattening, but since hotplug is not wired yet, it's not something we should worry about. Signed-off-by: Alexandru Gheorghe --- drmresources.cpp | 25 +++++++++++++++++++++++++ drmresources.h | 2 +- resourcemanager.cpp | 24 ++++++++++++++++++++++++ resourcemanager.h | 1 + 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/drmresources.cpp b/drmresources.cpp index fef6835..70126a4 100644 --- a/drmresources.cpp +++ b/drmresources.cpp @@ -269,6 +269,31 @@ DrmConnector *DrmResources::GetWritebackConnectorForDisplay(int display) const { return NULL; } +// TODO what happens when hotplugging +DrmConnector *DrmResources::AvailableWritebackConnector(int display) const { + DrmConnector *writeback_conn = GetWritebackConnectorForDisplay(display); + DrmConnector *display_conn = GetConnectorForDisplay(display); + // If we have a writeback already attached to the same CRTC, just use that, if + // possible + if (display_conn && writeback_conn && + writeback_conn->encoder()->can_clone(display_conn->encoder())) + return writeback_conn; + + // Use another CRTC if available and doesn't have any connector + for (auto &crtc : crtcs_) { + if (crtc->display() == display) + continue; + display_conn = GetConnectorForDisplay(crtc->display()); + // If we have a display connected don't use it for writeback + if (display_conn && display_conn->state() == DRM_MODE_CONNECTED) + continue; + writeback_conn = GetWritebackConnectorForDisplay(crtc->display()); + if (writeback_conn) + return writeback_conn; + } + return NULL; +} + DrmCrtc *DrmResources::GetCrtcForDisplay(int display) const { for (auto &crtc : crtcs_) { if (crtc->display() == display) diff --git a/drmresources.h b/drmresources.h index 4fb17fc..9176b8e 100644 --- a/drmresources.h +++ b/drmresources.h @@ -60,7 +60,7 @@ class DrmResources { DrmConnector *GetConnectorForDisplay(int display) const; DrmConnector *GetWritebackConnectorForDisplay(int display) const; - DrmConnector *FindWritebackConnector(int display) const; + DrmConnector *AvailableWritebackConnector(int display) const; DrmCrtc *GetCrtcForDisplay(int display) const; DrmPlane *GetPlane(uint32_t id) const; DrmEventListener *event_listener(); diff --git a/resourcemanager.cpp b/resourcemanager.cpp index e7b654e..b2a4458 100644 --- a/resourcemanager.cpp +++ b/resourcemanager.cpp @@ -49,6 +49,30 @@ int ResourceManager::Init() { (const hw_module_t **)&gralloc_); } +DrmConnector *ResourceManager::AvailableWritebackConnector(int display) { + DrmResources *drm_resource = GetDrmResources(display); + DrmConnector *writeback_conn = NULL; + if (drm_resource) { + writeback_conn = drm_resource->AvailableWritebackConnector(display); + if (writeback_conn) { + ALOGI("Use writeback connected to display %d\n", + writeback_conn->display()); + return writeback_conn; + } + } + for (auto &drm : drms_) { + if (drm.get() == drm_resource) + continue; + writeback_conn = drm->AvailableWritebackConnector(display); + if (writeback_conn) { + ALOGI("Use writeback connected to display %d\n", + writeback_conn->display()); + return writeback_conn; + } + } + return writeback_conn; +} + DrmResources *ResourceManager::GetDrmResources(int display) { for (uint32_t i = 0; i < drms_.size(); i++) { if (drms_[i]->HandlesDisplay(display)) diff --git a/resourcemanager.h b/resourcemanager.h index b8caa9a..57f7a2a 100644 --- a/resourcemanager.h +++ b/resourcemanager.h @@ -18,6 +18,7 @@ class ResourceManager { DrmResources *GetDrmResources(int display); std::shared_ptr GetImporter(int display); const gralloc_module_t *GetGralloc(); + DrmConnector *AvailableWritebackConnector(int display); private: std::vector> drms_;