From patchwork Tue Mar 6 01:48:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schake X-Patchwork-Id: 10260505 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 7B75A60134 for ; Tue, 6 Mar 2018 01:49:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C46A28D62 for ; Tue, 6 Mar 2018 01:49:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60FE028D65; Tue, 6 Mar 2018 01:49:20 +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 0F49C28D62 for ; Tue, 6 Mar 2018 01:49:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A2DB76E514; Tue, 6 Mar 2018 01:49:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id A55C96E511 for ; Tue, 6 Mar 2018 01:49:08 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id z9so19125508wmb.3 for ; Mon, 05 Mar 2018 17:49:08 -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:in-reply-to:references; bh=oLX6XkDQq3x6xACJU+6H56LFhifGqtdAhy/nXnZYm+g=; b=f/An32Zp7uM8je6gqvqPXiacoaf3LDTfAt9UiAkoZM5GWpR8z/l0g17rPlQ30Oc10h +ZZXhGUSlzvVpv80GYaBDI8RmmMRIvdMWx1ZPrEchUakjGiazbas+SVqxXGxxNPRztND skox1lqvMdG+lz+gKn0fdNqL6AkWzo5tDSUPRStwOv2uQ6C2e9OJlaXUlG5qj8RoTbX2 ZWizEYePNf7WpAcFJsrC7cEAZDEQ9FDxDJ5lC0paU4Bq1ZSVvNAmxLX2j/ntlCZGYkc0 jsbvB9HPHwTLyOVw3sxjv3BHRP7wtF2is7LY56W7BJCxabungtnNJ0hpnRU8uJdvhPIx 4f+w== 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:in-reply-to :references; bh=oLX6XkDQq3x6xACJU+6H56LFhifGqtdAhy/nXnZYm+g=; b=EnG5eY8iRAYpB3agEXUJX2VcYwntCUfIqEMWWOg20eYXnqDJYynka4CGibjONkJOnI YYcglVEEB0xsvQ3qe5I7ZbnFGf9+WIBVj3k+jVdtwjKVHlUckY2oQl8jm93X+ICD9IuJ bDwglraO74besHw7QXQju6kEDFzHtWGqzToWlLN5KLKnZSgKGV4V3vRTOXS2R9RHuisL cp8oKhiMceZp51HzFLwdRly/mFP+f0U7jzG0cA2v//73bfLvSJuOk+IxJgi20ssK2KF8 9CG+R32lnXlIi7FCluMc8+GfbFjjK3qbg2DxBTk22SsdOkokU101+YqVm969rcSf1vbB 0pWQ== X-Gm-Message-State: AElRT7FINRofm37IJJ2RNHm1EuxskfzcONP9ltBx/IvqrTPITbM/atHY Y0cHzobd2l2RYo5v389AjhM= X-Google-Smtp-Source: AG47ELvc4B3gIbIwQ19iFdurdzaaxQt6zv9Xg4EMsbrD/QzAxBzCUWzwVsF1iMXoP7R5UYYPIvkRGw== X-Received: by 10.28.106.18 with SMTP id f18mr9852041wmc.51.1520300947080; Mon, 05 Mar 2018 17:49:07 -0800 (PST) Received: from localhost.localdomain (x4db58e23.dyn.telefonica.de. [77.181.142.35]) by smtp.gmail.com with ESMTPSA id b185sm8048974wmb.24.2018.03.05.17.49.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Mar 2018 17:49:06 -0800 (PST) From: Stefan Schake To: eric@anholt.net Subject: [PATCH 2/3] drm/vc4: Check if plane requires background fill Date: Tue, 6 Mar 2018 02:48:38 +0100 Message-Id: <1520300919-103427-3-git-send-email-stschake@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520300919-103427-1-git-send-email-stschake@gmail.com> References: <1520300919-103427-1-git-send-email-stschake@gmail.com> 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: airlied@linux.ie, linux-rpi-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Stefan Schake MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Considering a single plane only, we have to enable background color when the plane has an alpha format and could be blending from the background or when it doesn't cover the entire screen. Signed-off-by: Stefan Schake --- drivers/gpu/drm/vc4/vc4_drv.h | 6 ++++++ drivers/gpu/drm/vc4/vc4_plane.c | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h index fefa166..7cc6390 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h @@ -302,6 +302,12 @@ struct vc4_hvs { struct vc4_plane { struct drm_plane base; + + /* Set when the plane has per-pixel alpha content or does not cover + * the entire screen. This is a hint to the CRTC that it might need + * to enable background color fill. + */ + bool needs_bg_fill; }; static inline struct vc4_plane * diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 3d0c8a2..c299e29 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -517,10 +517,12 @@ static int vc4_plane_mode_set(struct drm_plane *plane, { struct vc4_dev *vc4 = to_vc4_dev(plane->dev); struct vc4_plane_state *vc4_state = to_vc4_plane_state(state); + struct vc4_plane *vc4_plane = to_vc4_plane(plane); struct drm_framebuffer *fb = state->fb; u32 ctl0_offset = vc4_state->dlist_count; const struct hvs_format *format = vc4_get_hvs_format(fb->format->format); int num_planes = drm_format_num_planes(format->drm); + bool covers_screen; u32 scl0, scl1, pitch0; u32 lbm_size, tiling; unsigned long irqflags; @@ -625,7 +627,7 @@ static int vc4_plane_mode_set(struct drm_plane *plane, SCALER_POS2_ALPHA_MODE_PIPELINE : SCALER_POS2_ALPHA_MODE_FIXED, SCALER_POS2_ALPHA_MODE) | - (format->has_alpha ? SCALER_POS2_ALPHA_PREMULT : 0) | + (fb->format->has_alpha ? SCALER_POS2_ALPHA_PREMULT : 0) | VC4_SET_FIELD(vc4_state->src_w[0], SCALER_POS2_WIDTH) | VC4_SET_FIELD(vc4_state->src_h[0], SCALER_POS2_HEIGHT)); @@ -701,6 +703,17 @@ static int vc4_plane_mode_set(struct drm_plane *plane, vc4_state->dlist[ctl0_offset] |= VC4_SET_FIELD(vc4_state->dlist_count, SCALER_CTL0_SIZE); + /* crtc_* are already clipped coordinates. */ + covers_screen = vc4_state->crtc_x == 0 && vc4_state->crtc_y == 0 && + vc4_state->crtc_w == state->crtc->mode.hdisplay && + vc4_state->crtc_h == state->crtc->mode.vdisplay; + /* Background fill might be necessary when the plane has per-pixel + * alpha content and blends from the background or does not cover + * the entire screen. + */ + vc4_plane->needs_bg_fill = fb->format->has_alpha || !covers_screen; + + return 0; }