From patchwork Thu May 17 22:08:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 136213 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp477508lji; Thu, 17 May 2018 15:08:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoYto2eBIgka+xmLggj039OKVcO9WKtwSVyW1CUKO+/PhFd9gZNo2jKK4Vltrd1nhneqNId X-Received: by 2002:a62:828c:: with SMTP id w134-v6mr6713146pfd.138.1526594902820; Thu, 17 May 2018 15:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526594902; cv=none; d=google.com; s=arc-20160816; b=bzzQ8spdEXdwItrEU+WLtXUovnBGnAGsb6mWL9bN8NIzFp2LcFhg9tWTkfyijAPrun Gu3Gl5d6NJpxyPA/dZLdwE88ZknHx4wjQd4tNfPqb8eUGZpd5szY1GfnQCMV2YnnG5aC EXIruDPyxTkRZ7gMq4wf4KxS1Sn8SwSjSZ6ejHVqfdl34HhTDalF/iSfz1wIEhPnLSZN k0Gx6m9uT2P8B6xHJWKqpGixWAdL9hlyItqyKHNEAXATbabzmRCNOr88O91S5PnYvUAy toS7MNfukpgMzV7HWEgZxRyr0zcI+wF1zmMjKST9OvcU7jExV9InUTsF3HpRDPk3zqHq Bbgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=VNbWBY4Gwxsf9aXLg9QbulgL1tT0kILgILzITBaZf1o=; b=LRFzE4H9C2NMbCtxKFH8sIR81Ny4luaJlmcTkn8h3E8Uh8VKA3INLJdACyaKc5sHAL 5Z0jCkb/bJwJdNZ0NSFfFskbxVwBEpkBMqUJekEnyEZIzP0eLmV8iKvU0riUN9B+eOsq liU5T7RCTbe0SDxCEDxJYkVd52HSJ0cyZBl95nWGOObz+mKVfdZNJXviO25bDeYjbcaR xxIQLgZ2NIXvT/Ka8pJL8jHGA+UUo5WmIbH05FWnK86A1YOFhIaxsmeuyshGtGyjEx8w FhjN+9dIwobNi/RrSchgApGxn+YhKuKu8o0wxehOrO4Sk0qqcN7Gr5fTN+V/pXGKLARe KYZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id n4-v6si5971001pfk.277.2018.05.17.15.08.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 May 2018 15:08:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4FA4F6EBCC; Thu, 17 May 2018 22:08:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oi0-f53.google.com (mail-oi0-f53.google.com [209.85.218.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 098DF6EBD9 for ; Thu, 17 May 2018 22:08:19 +0000 (UTC) Received: by mail-oi0-f53.google.com with SMTP id p62-v6so5418946oie.10 for ; Thu, 17 May 2018 15:08:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=V9LNysd1ey2vo13SvL3qrCcNzZ3H0Q2OhxztLfIJfRY=; b=VvnF/5vYIs38DRiPbMhrWoYXuq4nFv8ayZti89zg+/ittfZaproudOpFqKbaqHC24q +4soINl1n0J+XrpjrwcgH3ZT+GXvPVxfFowXhqzJHu+5Rla3naZRNIkW6nEnX7EEH0Si 5twcgftoYHMxiSpOmKbOlfpJeKyzRcpebwHl9FV/FvWTSpwGxBv8WM3/h2ebwvXMLcYZ J5fiY2F0gFrzQyF1h2ThA3Ddsa1t+6OquamIM7W/GtAESgJe+GCqL+W5VAY6Deqno3un H2rTTc8Ma2IcT3R2MkAT5Vc254Tx15aqQ5I1kg8N3/Q5LqWuLDQt5L0v1VOKglGmph/E Qh8w== X-Gm-Message-State: ALKqPwc6fgBDnthK7AZmFnD+e15+KsQMzxxj6AH9/7zKWtDpYcnRfLPb QRUxOqmj/Q7tBCxQrD4ZXcVvZVE= X-Received: by 2002:aca:2b13:: with SMTP id i19-v6mr4084196oik.292.1526594898019; Thu, 17 May 2018 15:08:18 -0700 (PDT) Received: from xps15.herring.priv (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id n14-v6sm3128728otf.8.2018.05.17.15.08.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 May 2018 15:08:17 -0700 (PDT) From: Rob Herring To: dri-devel@lists.freedesktop.org, Stefan Schake , John Stultz , Sean Paul , Alexandru-Cosmin Gheorghe , Robert Foss Subject: [PATCH hwc] drm_hwcomposer: Support assigning planes in ValidateDisplay Date: Thu, 17 May 2018 17:08:16 -0500 Message-Id: <20180517220816.31504-1-robh@kernel.org> X-Mailer: git-send-email 2.17.0 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In order to assign planes to layers in ValidateDisplay, testing compositing with a DRM atomic modeset test is needed as PresentDisplay is too late. This means most of PresentDisplay needs to be run from ValidateDisplay, so refactor PresentDisplay and plumb a test flag down the stack. Signed-off-by: Rob Herring --- Based on my GL comp removal work. Adding atomic test path turned out to be easier than using the Planner directly. drmdisplaycompositor.cpp | 4 +- drmdisplaycompositor.h | 2 +- drmhwctwo.cpp | 79 ++++++++++++++++++++++++++++++++++------ drmhwctwo.h | 1 + 4 files changed, 73 insertions(+), 13 deletions(-) diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp index 2f9f6c6772da..ceee6b1a4bd6 100644 --- a/drmdisplaycompositor.cpp +++ b/drmdisplaycompositor.cpp @@ -469,7 +469,7 @@ void DrmDisplayCompositor::ApplyFrame( } int DrmDisplayCompositor::ApplyComposition( - std::unique_ptr composition) { + std::unique_ptr composition, bool test) { int ret = 0; switch (composition->type()) { case DRM_COMPOSITION_TYPE_FRAME: @@ -481,6 +481,8 @@ int DrmDisplayCompositor::ApplyComposition( ALOGE("Commit test failed for display %d, FIXME", display_); return ret; } + if (test) + return 0; } ApplyFrame(std::move(composition), ret); diff --git a/drmdisplaycompositor.h b/drmdisplaycompositor.h index ed46873c3409..7c5ebb005dc4 100644 --- a/drmdisplaycompositor.h +++ b/drmdisplaycompositor.h @@ -43,7 +43,7 @@ class DrmDisplayCompositor { int Init(DrmResources *drm, int display); std::unique_ptr CreateComposition() const; - int ApplyComposition(std::unique_ptr composition); + int ApplyComposition(std::unique_ptr composition, bool test); int Composite(); void Dump(std::ostringstream *out) const; diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp index deaf14363e8c..19f73e721154 100644 --- a/drmhwctwo.cpp +++ b/drmhwctwo.cpp @@ -480,8 +480,7 @@ void DrmHwcTwo::HwcDisplay::AddFenceToRetireFence(int fd) { } } -HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *retire_fence) { - supported(__func__); +HWC2::Error DrmHwcTwo::HwcDisplay::CreateComposition(bool test) { std::vector layers_map; layers_map.emplace_back(); DrmCompositionDisplayLayersMap &map = layers_map.back(); @@ -494,7 +493,13 @@ HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *retire_fence) { uint32_t client_z_order = 0; std::map z_map; for (std::pair &l : layers_) { - switch (l.second.validated_type()) { + HWC2::Composition comp_type; + if (test) + comp_type = l.second.sf_type(); + else + comp_type = l.second.validated_type(); + + switch (comp_type) { case HWC2::Composition::Device: z_map.emplace(std::make_pair(l.second.z_order(), &l.second)); break; @@ -510,6 +515,10 @@ HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *retire_fence) { if (use_client_layer) z_map.emplace(std::make_pair(client_z_order, &client_layer_)); + if (z_map.empty()) + return HWC2::Error::BadLayer; + + // now that they're ordered by z, add them to the composition for (std::pair &l : z_map) { DrmHwcLayer layer; @@ -521,10 +530,6 @@ HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *retire_fence) { } map.layers.emplace_back(std::move(layer)); } - if (map.layers.empty()) { - *retire_fence = -1; - return HWC2::Error::None; - } std::unique_ptr composition = compositor_.CreateComposition(); @@ -555,13 +560,29 @@ HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *retire_fence) { i = overlay_planes.erase(i); } - AddFenceToRetireFence(composition->take_out_fence()); + if (!test) + AddFenceToRetireFence(composition->take_out_fence()); - ret = compositor_.ApplyComposition(std::move(composition)); + ret = compositor_.ApplyComposition(std::move(composition), test); if (ret) { ALOGE("Failed to apply the frame composition ret=%d", ret); return HWC2::Error::BadParameter; } + return HWC2::Error::None; +} + +HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *retire_fence) { + supported(__func__); + HWC2::Error ret; + + ret = CreateComposition(false); + if (ret == HWC2::Error::BadLayer) { + // Can we really have no client or device layers? + *retire_fence = -1; + return HWC2::Error::None; + } + if (ret != HWC2::Error::None) + return ret; // The retire fence returned here is for the last frame, so return it and // promote the next retire fence @@ -586,7 +607,7 @@ HWC2::Error DrmHwcTwo::HwcDisplay::SetActiveConfig(hwc2_config_t config) { compositor_.CreateComposition(); composition->Init(drm_, crtc_, importer_.get(), planner_.get(), frame_no_); int ret = composition->SetDisplayMode(*mode); - ret = compositor_.ApplyComposition(std::move(composition)); + ret = compositor_.ApplyComposition(std::move(composition), false); if (ret) { ALOGE("Failed to queue dpms composition on %d", ret); return HWC2::Error::BadConfig; @@ -666,7 +687,7 @@ HWC2::Error DrmHwcTwo::HwcDisplay::SetPowerMode(int32_t mode_in) { compositor_.CreateComposition(); composition->Init(drm_, crtc_, importer_.get(), planner_.get(), frame_no_); composition->SetDpmsMode(dpms_value); - int ret = compositor_.ApplyComposition(std::move(composition)); + int ret = compositor_.ApplyComposition(std::move(composition), false); if (ret) { ALOGE("Failed to apply the dpms composition ret=%d", ret); return HWC2::Error::BadParameter; @@ -683,11 +704,47 @@ HWC2::Error DrmHwcTwo::HwcDisplay::SetVsyncEnabled(int32_t enabled) { HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types, uint32_t *num_requests) { supported(__func__); + size_t plane_count = 0; *num_types = 0; *num_requests = 0; + size_t avail_planes = primary_planes_.size() + overlay_planes_.size(); + + HWC2::Error ret; + + for (std::pair &l : layers_) + l.second.set_validated_type(HWC2::Composition::Invalid); + + ret = CreateComposition(true); + if (ret != HWC2::Error::None) + // Assume the test failed due to overlay planes + avail_planes = 1; + + std::map z_map; + for (std::pair &l : layers_) { + if (l.second.sf_type() == HWC2::Composition::Device) + z_map.emplace(std::make_pair(l.second.z_order(), &l.second)); + } + + /* + * If more layers then planes, save one plane + * for client composited layers + */ + if (avail_planes < layers_.size()) + avail_planes--; + + for (std::pair &l : z_map) { + if (!avail_planes--) + break; + l.second->set_validated_type(HWC2::Composition::Device); + } + for (std::pair &l : layers_) { DrmHwcTwo::HwcLayer &layer = l.second; switch (layer.sf_type()) { + case HWC2::Composition::Device: + if (layer.validated_type() == HWC2::Composition::Device) + break; + // fall thru case HWC2::Composition::SolidColor: case HWC2::Composition::Cursor: case HWC2::Composition::Sideband: diff --git a/drmhwctwo.h b/drmhwctwo.h index 0490e2ac7f85..bbf55d9a08bc 100644 --- a/drmhwctwo.h +++ b/drmhwctwo.h @@ -171,6 +171,7 @@ class DrmHwcTwo : public hwc2_device_t { float *min_luminance); HWC2::Error GetReleaseFences(uint32_t *num_elements, hwc2_layer_t *layers, int32_t *fences); + HWC2::Error CreateComposition(bool test); HWC2::Error PresentDisplay(int32_t *retire_fence); HWC2::Error SetActiveConfig(hwc2_config_t config); HWC2::Error SetClientTarget(buffer_handle_t target, int32_t acquire_fence,