From patchwork Thu Feb 22 03:54:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schake X-Patchwork-Id: 10234569 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 D03CA60349 for ; Thu, 22 Feb 2018 03:54:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFCC8287CE for ; Thu, 22 Feb 2018 03:54:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C230D287D2; Thu, 22 Feb 2018 03:54:45 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 3A32A287CE for ; Thu, 22 Feb 2018 03:54:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 427186EB6B; Thu, 22 Feb 2018 03:54:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id C65026EB6B for ; Thu, 22 Feb 2018 03:54:40 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id k87so1221056wmi.0 for ; Wed, 21 Feb 2018 19:54:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Xf4AFlw7TYbpr//9NvD6LLiHcmtM2O2LvVx5+r/Mxvo=; b=kEJmalap62bIULtusXzFNK/XAU7VtGUi3NzhSshF4PZVL7ZqzS0NqZllWkMu5STxo0 XUnZfhc4G4GlMMgcpzvQEnIQIcc1v0Di/GXiFd9Ir7LjCJZi7VT5Xo2ZNNf6hBr/k1WH GkHZgTY7HMJJgoJlZOVG+SX38ZRvxlD7Nxh4kudR8zEkGKfM7aQE7n8/b4mX+a+mx5Ps HtdeANIVKCUccJF6vJCtYFC+G5Z0XymnlcgqgGCLVgJ9swN+wP6RIune4GmPj+T+afUM ybOqLi3CxE0H7G3f8uyXg/ogQsNhKEoM8gZASAWnVrm3fuvKbA0OyYceXtzW8K/4KOO3 ao5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Xf4AFlw7TYbpr//9NvD6LLiHcmtM2O2LvVx5+r/Mxvo=; b=YfptRyuJ24KkTKHVLzRvC/iaqY37Jhb06GXtQjBZVkcCc1n9bjYPxfywKuZ4gWdagY yWugdaM3qivJ78mwR3AemAS2X2b9QjXDRIHwOxucIjA9cRbW1JLTNnpj5t6sOAcgAjYu +jEnBBVQy3nkdUW281A0DGB5wQlMkjws0Qt+vsz6s2zyhluYdP4bE48ieaTpgPNSyp3A t8V/lyIq6OSPoVFYrX2/IgorHsfDiBB+Yw4cGG3kseoJ9e4pqsmOTnOczJqJ/n4cpPvs dwRRju732B1CVkSt+7je7TNmBeBuSlbVTZrJ32P4HOB9tD07zk8pR9sdr2oo0//CNDCV uhtA== X-Gm-Message-State: APf1xPABfDzDsHUg5I0ye7A0fHsiUXC2MQUMA83hOrSQZ5EKDVPWrp0v 3rQzOmtqokFLhY8G3+OzhocBTQ== X-Google-Smtp-Source: AH8x2272vmQb8PGYQYmXSpoLqRE0u+JoQwkwbDhtoBNNISWh9+ZzMOhcAEmq0j/YHdF1D69WE6/J9Q== X-Received: by 10.28.164.196 with SMTP id n187mr3403006wme.141.1519271678551; Wed, 21 Feb 2018 19:54:38 -0800 (PST) Received: from localhost.localdomain (x4e30c838.dyn.telefonica.de. [78.48.200.56]) by smtp.gmail.com with ESMTPSA id a14sm12600429wra.27.2018.02.21.19.54.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Feb 2018 19:54:37 -0800 (PST) From: Stefan Schake To: dri-devel Subject: [RFC PATCH hwc] drm_hwcomposer: set CRTC background color when available Date: Thu, 22 Feb 2018 04:54:08 +0100 Message-Id: <1519271648-33102-1-git-send-email-stschake@gmail.com> X-Mailer: git-send-email 2.7.4 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: Stefan Schake MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Android assumes an implicit black background layer is always present behind all layers it specifies for composition. drm_hwcomposer currently punts responsibility for this to the kernel/DRM platform and puts layers with per-pixel alpha content on the primary plane when requested. On some platforms (e.g. VC4) a background color fill has a cycle cost for the hardware composer and is not enabled by default. Instead, userland can request a background color through a CRTC property. Use this property to specify the implicit black background Android expects. Signed-off-by: Stefan Schake --- Kernel changes for this (background_color) are available here: https://github.com/stschake/linux/commits/background-upstream Sending as RFC because I'm not entirely clear on whose responsibility this should be, on most DRM drivers it seems to be implicit. I think a case could also be made that VC4 should not accept alpha formats on the lowest layer or enable background color fill when given one anyway. On the other hand, userland control over background color seems desirable regardless and is a feature of multiple hardware composers (i915, vc4, omap). drmcrtc.cpp | 11 +++++++++++ drmcrtc.h | 2 ++ drmdisplaycompositor.cpp | 15 +++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/drmcrtc.cpp b/drmcrtc.cpp index 1b354fe..d7bcd7a 100644 --- a/drmcrtc.cpp +++ b/drmcrtc.cpp @@ -52,6 +52,13 @@ int DrmCrtc::Init() { ALOGE("Failed to get OUT_FENCE_PTR property"); return ret; } + + ret = drm_->GetCrtcProperty(*this, "background_color", + &background_color_property_); + if (ret) { + ALOGI("Failed to get background_color property"); + // This is an optional property + } return 0; } @@ -86,4 +93,8 @@ const DrmProperty &DrmCrtc::mode_property() const { const DrmProperty &DrmCrtc::out_fence_ptr_property() const { return out_fence_ptr_property_; } + +const DrmProperty &DrmCrtc::background_color_property() const { + return background_color_property_; +} } diff --git a/drmcrtc.h b/drmcrtc.h index c5a5599..704573a 100644 --- a/drmcrtc.h +++ b/drmcrtc.h @@ -46,6 +46,7 @@ class DrmCrtc { const DrmProperty &active_property() const; const DrmProperty &mode_property() const; const DrmProperty &out_fence_ptr_property() const; + const DrmProperty &background_color_property() const; private: DrmResources *drm_; @@ -59,6 +60,7 @@ class DrmCrtc { DrmProperty active_property_; DrmProperty mode_property_; DrmProperty out_fence_ptr_property_; + DrmProperty background_color_property_; }; } diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp index e556e86..69c52dd 100644 --- a/drmdisplaycompositor.cpp +++ b/drmdisplaycompositor.cpp @@ -527,6 +527,21 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp, return ret; } + if (crtc->background_color_property().id() != 0) { + // Background color is specified as a 16 bit per channel RGBA value. + // Set a fully opaque black background as Android HWC expects. + const uint64_t background_color = 0xFFFF; + + ret = drmModeAtomicAddProperty(pset, crtc->id(), + crtc->background_color_property().id(), + background_color) < 0; + if (ret) { + ALOGE("Failed to add CRTC background_color to pset: %d", ret); + drmModeAtomicFree(pset); + return ret; + } + } + ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->mode_property().id(), mode_.blob_id) < 0 || drmModeAtomicAddProperty(pset, connector->id(),