From patchwork Wed Apr 11 15:22:20 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: 10335699 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 3BD526053B for ; Wed, 11 Apr 2018 15:23:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E82C2897C for ; Wed, 11 Apr 2018 15:23:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22CF228980; Wed, 11 Apr 2018 15:23:52 +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 5B1C32897C for ; Wed, 11 Apr 2018 15:23:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9F8DC6E6AF; Wed, 11 Apr 2018 15:23:33 +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-eopbgr20050.outbound.protection.outlook.com [40.107.2.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB6366E6AA for ; Wed, 11 Apr 2018 15:23:28 +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=E/VFP+graKBbKHxd/ET0ovRGbB+/riAHruMPkBJMErU=; b=sC6CiGnFkbk1XlvxAkNbU4gwQWB4GtJKUS61U4IKudLPq1wqlYsE07WDnUx3T+0ubk4xR5yaoz4/kJEW+5wjJid9Em2pYH1ff/Kx/dInTLgcKq3CPAnuAy2YOJBM+dJ2BFMtUax6YuwlrcDo4Dl2CvGWliOAPpRPzMKzd/Uta9g= 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:27 +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 09/18] drm_hwcomposer: Handle writeback connectors Date: Wed, 11 Apr 2018 16:22:20 +0100 Message-Id: <1523460149-1740-10-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:a/X6egfBOZ24LGpCNNbN2NI/xEczaggGBtVu8ORWD3A3gQh7sITlKvb11Yz7yUVxuyebIXnbrp9VEkNmC6tuLPfueRs0HxiwKtzu9ZFxSFFDUT90dwdwkGaqWy3xTzmxm7t1L+qUqHkGOYvFpN4lAVamobtNo1x/9jqdp8vS27awmZ7Fj+4GA+xaWBoRb/w2GVhEnn70F2UC0mKoFbGlfrzXjIV9GX6FCZAQ7ShKgV/fPife6t56NGUONNSLtzOf; 25:2E31IgK9VYuJ5Gh9n128OAJzT94tNoK7Gjunsf4HJ0YRRxEnamutiGuQa9DisQI0bUv5lhCyQWF8GBQOMScRHhAV3y8oVd4zGo/i6agGlkYqf8bCGhSAyiblgVG/HjI8JDlQS18Ey1096N0sxUcr7ks5lutektw1jN/ULk1VrCmeV7s8d6YOfFKcjiHdtF0f4UMnwGs4mGCs2h1uxNmKtTmyo4rWRlgLRbIyJ75Mc4hd6tREViDMTpEZPSMlJKg4KEPUcX60nDHIIl0tm6Gr0n0SYhDbb46ekiWLv1cfNWciDvijqtPAQTzA7c0zKhYvLa5Rs4Q1MDxaMosdhIrmRA==; 31:C6CTK0SeqrIayH5NiEp28LhACNl5hIRzFEj0+C3JV29BKoJVOwdsjwESxaRyj/HKKflYtTD7jyF9/H5h95hCQZSQgnRiZsevF7lu2OqV/NVb4KKi062aPE9qwAmSJ7bJYWTCaS9iFnGuVwDGPGBWhgUlbvqoKPkViLWJDKz9v3zutuAPv0gWmu6Lga9HN/zYIAPHx++0zYdDM4hbWaZY0ywMz7Iwh8rwpL33cadxXjs= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1249: NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 20:ljLe40aJIV7Jt014/FYLFNu9oaJuoqG4SnL/WFnLbUgFeNwvBub9e3gFJJPeG899UynHk9U4NOxanykx/1OpljHbsmpgBqSirOFGVTPFPJcJzQ7ww/jYReApwOe1IM/1lKAIWxz+2cwTepXkX3/4kaVdfupKWZGRtbOx/3cuhW8=; 4:tvelRKIiwQ2ILXUAqDkyl7CgqEFkFCSlqx2OQoB36yauPsNlAxOiPdq51KpAm4oZo/MHQWxaBzBri+YT3N2IkVvlLakbYANC1GveV8K05+Z4DCdu/WEiTDF/wm+5qbbWhkZgVHejZvlllJiDSurH7eezyGfTeJVP2zERfxlZXXsKToKARAx4gHRQk1KfzZdTb7EbmvFomuGfhRRkngRIXuMl9WmkEfEFKc73Gweu9v/Sa3Nyk0IAdVtQRd7FHlD/Z4QCwfnS5QTt2vxfCAb8oNtVbIWUsJI71qfK1IHeQk9EGOIqXLssWNTYwV/fhreZ 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:G3YZiTVN2soUHias+HhIg7OmDBevcYvVQPogpBd?= =?us-ascii?Q?ZQCYSziB79TW/KeO8jwaE/nnSyC0Pj2W7I4lDZuKZrjcnX3/lSXx60ewx37G?= =?us-ascii?Q?d8LmVbFGbyjAX6y7f4BSn47RyTBQBe8ykAbTIXeHYaJof8saIqQ7fUyfbrsH?= =?us-ascii?Q?kAajwvct3Dwz/wu34Bcrr32Pfqu7MtTbZ+oGIaH98aS4Usicp+0C5076idYb?= =?us-ascii?Q?BwLNark0wdTsWBiZFHBAR3R81EnhBClptOK7BucrxYiUBgL65OUBm+QR27DD?= =?us-ascii?Q?z5H1QIRfKMrHahaABxggQkMPXPCECM4lGu1EttyUPckGpBr72A0d7jbpe+Y5?= =?us-ascii?Q?q7vdgUxEogvXRV7xFx99+OW0tKdpE7JybJc8CMAmewDqyyM529PUIVEyKD5R?= =?us-ascii?Q?sHfER3l7guhkip0hiwZytWuxGtK0h4HcF3v8AfsZ7ocktDQfAN1CRMxATjFN?= =?us-ascii?Q?LkYgZ9qC2ZE5SIIJPMWj9Ez4G1enlVMGYU6HeikbPLgWXcZdT3in0ciV6r+f?= =?us-ascii?Q?IQlWo3SoOGgS20E/LUUen6DJrQmSjaY0lqY09CpRLd16AOkTW5VuSFf8p8H7?= =?us-ascii?Q?Nu3HbZCHW0kc2514WltpjdlF/zMbAzS3enRE8jMzh6/VrazUMtf1+Z+Okpqx?= =?us-ascii?Q?VUqJduCik2It0Pqg4yYOA+7Z3RzDE9dyZO8/JMA7NBw/6Jxxw20rE7DkV21a?= =?us-ascii?Q?d4sfNqtVsnOiNaYi0Z9fC90hK0Uwegwr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wI4O+BlaakRXB5gda6ouclwPTCsldfJnxXLu0BGI8CMoLAMNVOiAVNLjgsJac1ButYoXj6eZlaOhTU7M9A5UaxXJRWfS8/hyizoD8i3l4EjK9fc0fGwMzmOkqzCLJ7A0dMpgA41YenSlP+5GONM07o31cflvKjRYyMFBbuSUgfXRPNv83hNzjm9D7SAkEPtdA7BhWP7QrB1ppD+ciKAoas31yFqkVToqcYKbvPem0JrrS3zhWaBpbYFF9A==; 5:TsCewQ9SAK3GZx6DVZphoiCEUcZHQY1bby5VOYpQRTEKKpct7gBU4m3V5OQTe8EObRpGOuA6g9VVHwYxo3kdlrk7Uu5LKLgkRyvEXrYr79u9LH19Qe6Mgmkn6EOEJ82p6AbjIIgOeT1KU2Tyb1DtRVm9smF04+PAFF19XFksMeQ=; 24:oweCSS4eVYr7FLnzQ+J9q0a1++LjiQ5qOmqRcRW6u59WuFvIgjBb02qPvfQZT6JJq8F75W4Wqvg03q6GTrYUFlUGrUDKvgPAE6M5tzBr7rk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 7:w2sx6MxhUhV7TorXqiNRiI4JSNsbugo7v2UzAuCpKAow2zBWDoo+Y4Z6fqTutgAsGPLkWhAoU+rzuCGsFCDGw5w0dMIFsM65U020d5y1HPumEFOmG/X7Xo2dmDGWOfAAy3BjqaeqTLg0bm2vr+feWyydTkdr/kO9wy645uRDQtId80GeDMWS4IJeIwHnRUPb3tkpskLfunfshRdXpplu/LK3H2gt/TlGc1vXcae7rlssrilNy8wIxNEZcNK1mumn X-MS-Office365-Filtering-Correlation-Id: 4df0a8c8-7ae6-438a-b128-08d59fc02cb3 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2018 15:23:27.0390 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4df0a8c8-7ae6-438a-b128-08d59fc02cb3 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 When writeback connectors are available assign them to displays, in order to be able to use them for flattening of the current displayed scene. The pipeline for each display will look like this: CRTC ---- encoder ------------ display connector. |------- writeback enc ------ writeback connector. However, the writeback connector will be later used/enabled only if one of the following conditions are met: - Could be a clone of the display connector, as pointed by the possible_clones property. - The display_connector is disconnected, so we are safe to use it for flattening the scene that's already presented on another display. Signed-off-by: Alexandru Gheorghe --- drmresources.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- drmresources.h | 3 +++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/drmresources.cpp b/drmresources.cpp index 39f50be..fef6835 100644 --- a/drmresources.cpp +++ b/drmresources.cpp @@ -64,6 +64,14 @@ int DrmResources::Init(ResourceManager *resource_manager, char *path, return ret; } +#ifdef DRM_CLIENT_CAP_WRITEBACK_CONNECTORS + ret = drmSetClientCap(fd(), DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1); + if (ret) { + ALOGI("Failed to set writeback cap %d", ret); + ret = 0; + } +#endif + drmModeResPtr res = drmModeGetResources(fd()); if (!res) { ALOGE("Failed to get DrmResources resources"); @@ -169,7 +177,7 @@ int DrmResources::Init(ResourceManager *resource_manager, char *path, conn->set_display(0); displays_[0] = 0; found_primary = true; - } else { + } else if (conn->external()) { conn->set_display(display_num); displays_[display_num] = display_num; ++display_num; @@ -230,6 +238,8 @@ int DrmResources::Init(ResourceManager *resource_manager, char *path, } for (auto &conn : connectors_) { + if (conn->writeback()) + continue; ret = CreateDisplayPipe(conn.get()); if (ret) { ALOGE("Failed CreateDisplayPipe %d with %d", conn->id(), ret); @@ -245,7 +255,15 @@ bool DrmResources::HandlesDisplay(int display) const { DrmConnector *DrmResources::GetConnectorForDisplay(int display) const { for (auto &conn : connectors_) { - if (conn->display() == display) + if (conn->display() == display && !conn->writeback()) + return conn.get(); + } + return NULL; +} + +DrmConnector *DrmResources::GetWritebackConnectorForDisplay(int display) const { + for (auto &conn : connectors_) { + if (conn->display() == display && conn->writeback()) return conn.get(); } return NULL; @@ -280,6 +298,7 @@ int DrmResources::TryEncoderForDisplay(int display, DrmEncoder *enc) { DrmCrtc *crtc = enc->crtc(); if (crtc && crtc->can_bind(display)) { crtc->set_display(display); + enc->set_display(display); return 0; } @@ -306,6 +325,7 @@ int DrmResources::CreateDisplayPipe(DrmConnector *connector) { if (connector->encoder()) { int ret = TryEncoderForDisplay(display, connector->encoder()); if (!ret) { + AttachWriteback(connector); return 0; } else if (ret != -EAGAIN) { ALOGE("Could not set mode %d/%d", display, ret); @@ -317,6 +337,7 @@ int DrmResources::CreateDisplayPipe(DrmConnector *connector) { int ret = TryEncoderForDisplay(display, enc); if (!ret) { connector->set_encoder(enc); + AttachWriteback(connector); return 0; } else if (ret != -EAGAIN) { ALOGE("Could not set mode %d/%d", display, ret); @@ -328,6 +349,43 @@ int DrmResources::CreateDisplayPipe(DrmConnector *connector) { return -ENODEV; } +/* + * Attach writeback connector to the CRTC linked to the display_conn + * + */ +int DrmResources::AttachWriteback(DrmConnector *display_conn) { + int ret = -EINVAL; + if (display_conn->writeback()) + return -EINVAL; + DrmEncoder *display_enc = display_conn->encoder(); + if (!display_enc) + return -EINVAL; + DrmCrtc *display_crtc = display_enc->crtc(); + if (!display_crtc) + return -EINVAL; + if (GetWritebackConnectorForDisplay(display_crtc->display()) != NULL) + return -EINVAL; + for (auto &writeback_conn : connectors_) { + if (writeback_conn->display() >= 0 || !writeback_conn->writeback()) + continue; + for (DrmEncoder *writeback_enc : writeback_conn->possible_encoders()) { + for (DrmCrtc *possible_crtc : writeback_enc->possible_crtcs()) { + if (possible_crtc != display_crtc) + continue; + // Use just encoders which had not been bound already + if (writeback_enc->can_bind(display_crtc->display())) { + writeback_enc->set_crtc(display_crtc); + writeback_conn->set_encoder(writeback_enc); + writeback_conn->set_display(display_crtc->display()); + writeback_conn->UpdateModes(); + return 0; + } + } + } + } + return ret; +} + int DrmResources::CreatePropertyBlob(void *data, size_t length, uint32_t *blob_id) { struct drm_mode_create_blob create_blob; diff --git a/drmresources.h b/drmresources.h index 4cdcd87..4fb17fc 100644 --- a/drmresources.h +++ b/drmresources.h @@ -59,6 +59,8 @@ class DrmResources { } DrmConnector *GetConnectorForDisplay(int display) const; + DrmConnector *GetWritebackConnectorForDisplay(int display) const; + DrmConnector *FindWritebackConnector(int display) const; DrmCrtc *GetCrtcForDisplay(int display) const; DrmPlane *GetPlane(uint32_t id) const; DrmEventListener *event_listener(); @@ -84,6 +86,7 @@ class DrmResources { DrmProperty *property); int CreateDisplayPipe(DrmConnector *connector); + int AttachWriteback(DrmConnector *display_conn); UniqueFd fd_; uint32_t mode_id_ = 0;