From patchwork Tue Sep 26 06:24:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foss X-Patchwork-Id: 9971061 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 0C40260393 for ; Tue, 26 Sep 2017 06:25:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EED3E28EBC for ; Tue, 26 Sep 2017 06:25:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E394728EBF; Tue, 26 Sep 2017 06:25:55 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 D549928ECB for ; Tue, 26 Sep 2017 06:25:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 86D7C6E401; Tue, 26 Sep 2017 06:25:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F3926E3D5 for ; Tue, 26 Sep 2017 06:25:02 +0000 (UTC) Received: from localhost.localdomain (unknown [IPv6:2a02:8109:9a3f:ee3b:c7ab:3df6:4b82:1a62]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: robertfoss) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 03B9E26C27F; Tue, 26 Sep 2017 07:25:00 +0100 (BST) From: Robert Foss To: dri-devel@lists.freedesktop.org, Sean Paul Subject: [PATCH hwc v1 3/6] drm_hwcomposer: Submit in-fence to DRM Date: Tue, 26 Sep 2017 08:24:43 +0200 Message-Id: <20170926062446.6412-4-robert.foss@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170926062446.6412-1-robert.foss@collabora.com> References: <20170926062446.6412-1-robert.foss@collabora.com> Cc: Robert Foss X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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" X-Virus-Scanned: ClamAV using ClamSMTP Add support for in-fences through the IN_FENCE_FD property. In-fences signal when their associated buffer may be read by DRM/KMS. Signed-off-by: Robert Foss --- drmdisplaycompositor.cpp | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp index bd670cf..71c0451 100644 --- a/drmdisplaycompositor.cpp +++ b/drmdisplaycompositor.cpp @@ -529,6 +529,7 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, std::vector &source_layers = comp_plane.source_layers(); int fb_id = -1; + int fence_fd = -1; DrmHwcRect display_frame; DrmHwcRect source_crop; uint64_t rotation = 0; @@ -547,30 +548,12 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, break; } DrmHwcLayer &layer = layers[source_layers.front()]; - if (!test_only && layer.acquire_fence.get() >= 0) { - int acquire_fence = layer.acquire_fence.get(); - int total_fence_timeout = 0; - for (int i = 0; i < kAcquireWaitTries; ++i) { - int fence_timeout = kAcquireWaitTimeoutMs * (1 << i); - total_fence_timeout += fence_timeout; - ret = sync_wait(acquire_fence, fence_timeout); - if (ret) - ALOGW("Acquire fence %d wait %d failed (%d). Total time %d", - acquire_fence, i, ret, total_fence_timeout); - else - break; - } - if (ret) { - ALOGE("Failed to wait for acquire %d/%d", acquire_fence, ret); - break; - } - layer.acquire_fence.Close(); - } if (!layer.buffer) { ALOGE("Expected a valid framebuffer for pset"); break; } fb_id = layer.buffer->fb_id; + fence_fd = layer.acquire_fence.get(); display_frame = layer.display_frame; source_crop = layer.source_crop; if (layer.blending == DrmHwcBlending::kPreMult) @@ -587,7 +570,21 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, rotation |= 1 << DRM_ROTATE_180; else if (layer.transform & DrmHwcTransform::kRotate270) rotation |= 1 << DRM_ROTATE_270; + + if (fence_fd != -1) { + int prop_id = plane->in_fence_fd_property().id(); + if (prop_id == 0) { + ALOGE("Failed to get IN_FENCE_FD property id"); + break; + } + ret = drmModeAtomicAddProperty(pset, plane->id(), prop_id, fence_fd); + if (ret < 0) { + ALOGE("Failed to add IN_FENCE_FD property to pset: %d", ret); + break; + } + } } + // Disable the plane if there's no framebuffer if (fb_id < 0) { ret = drmModeAtomicAddProperty(pset, plane->id(),