From patchwork Mon Nov 27 20:57:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 10078073 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 E6A59602BD for ; Mon, 27 Nov 2017 20:59:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8DFB29062 for ; Mon, 27 Nov 2017 20:59:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC96429065; Mon, 27 Nov 2017 20:59:49 +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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4AD7A29062 for ; Mon, 27 Nov 2017 20:59:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=P4JW2SMQssK4ks02aU324AnZRYuZ8P+F37vQ+i4FJPE=; b=Aekyyb4WQKR8AWtj2ieIfhJ16H 0nTlnuQ3tqXVxLGvD7VAbIw4g1uWlyY7WzZhCJGNiLDQ/Ka2uGNqZePS2GEZC4KVx9Fex9PDq6Kfv 10F5cDx6p7dBDUp+x4T5ZL8xrorPN0lGC1CTVizmFMBqDgCswAa77bVfL48jVk7XaTGn6QpXKvnuo yRf9m4HnCkQzefk6asd7sTMfxqZqZhFEJhFgOdTeQ+PkIzulSXIPL8TBfe8swNUJb9gc0LBbW/9YS GTWNZJTqOC1cf2LHHiaOZGKXe7kuCzZrRw9/W6D9PWp99sPysITrrky++sxsfJBib9veK7KiWfQPx L03qAa5Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eJQVI-0002Ko-Cg; Mon, 27 Nov 2017 20:59:48 +0000 Received: from mailoutvs3.siol.net ([213.250.19.136] helo=mail.siol.net) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eJQTy-00016t-Ol for linux-arm-kernel@lists.infradead.org; Mon, 27 Nov 2017 20:58:32 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTP id 04486521746; Mon, 27 Nov 2017 21:58:08 +0100 (CET) X-Virus-Scanned: amavisd-new at psrvmta09.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta09.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id eX9ULyCRN_yA; Mon, 27 Nov 2017 21:58:07 +0100 (CET) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTPS id 55A9B52174A; Mon, 27 Nov 2017 21:58:07 +0100 (CET) Received: from localhost.localdomain (cpe-86-58-68-135.ftth.triera.net [86.58.68.135]) (Authenticated sender: 031275009) by mail.siol.net (Postfix) with ESMTPSA id 03E3F521746; Mon, 27 Nov 2017 21:58:05 +0100 (CET) From: Jernej Skrabec To: maxime.ripard@free-electrons.com Subject: [PATCH 04/17] drm/sun4i: Use values calculated by atomic check Date: Mon, 27 Nov 2017 21:57:37 +0100 Message-Id: <20171127205750.19277-5-jernej.skrabec@siol.net> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171127205750.19277-1-jernej.skrabec@siol.net> References: <20171127205750.19277-1-jernej.skrabec@siol.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171127_125827_322144_7B47473C X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: airlied@linux.ie, linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, wens@csie.org, linux-arm-kernel@lists.infradead.org, icenowy@aosc.io MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we have properly clipped coordinates in plane state structure, use them. This also fixes bug where source x and y were adjusted for negative value, but width and height weren't. It wasn't discovered because primary plane usually doesn't have negative coordinates. Signed-off-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun8i_layer.c | 5 ++++ drivers/gpu/drm/sun4i/sun8i_mixer.c | 52 ++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_layer.c b/drivers/gpu/drm/sun4i/sun8i_layer.c index 54739e12311d..511d2f8afef6 100644 --- a/drivers/gpu/drm/sun4i/sun8i_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_layer.c @@ -68,6 +68,11 @@ static void sun8i_mixer_layer_atomic_update(struct drm_plane *plane, struct sun8i_layer *layer = plane_to_sun8i_layer(plane); struct sun8i_mixer *mixer = layer->mixer; + if (!plane->state->visible) { + sun8i_mixer_layer_enable(mixer, layer->id, false); + return; + } + sun8i_mixer_update_layer_coord(mixer, layer->id, plane); sun8i_mixer_update_layer_formats(mixer, layer->id, plane); sun8i_mixer_update_layer_buffer(mixer, layer->id, plane); diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c index 37eb5f6f8ee8..6aa3240186c1 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c @@ -91,28 +91,34 @@ int sun8i_mixer_update_layer_coord(struct sun8i_mixer *mixer, { struct drm_plane_state *state = plane->state; struct drm_framebuffer *fb = state->fb; + u32 width, height, size; DRM_DEBUG_DRIVER("Updating layer %d\n", layer); + /* + * Same source and destination width and height are guaranteed + * by atomic check function. + */ + width = drm_rect_width(&state->dst); + height = drm_rect_height(&state->dst); + size = SUN8I_MIXER_SIZE(width, height); + if (plane->type == DRM_PLANE_TYPE_PRIMARY) { DRM_DEBUG_DRIVER("Primary layer, updating global size W: %u H: %u\n", - state->crtc_w, state->crtc_h); - regmap_write(mixer->engine.regs, SUN8I_MIXER_GLOBAL_SIZE, - SUN8I_MIXER_SIZE(state->crtc_w, - state->crtc_h)); + width, height); + regmap_write(mixer->engine.regs, + SUN8I_MIXER_GLOBAL_SIZE, + size); DRM_DEBUG_DRIVER("Updating blender size\n"); regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_ATTR_INSIZE(layer), - SUN8I_MIXER_SIZE(state->crtc_w, - state->crtc_h)); + size); regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_OUTSIZE, - SUN8I_MIXER_SIZE(state->crtc_w, - state->crtc_h)); + size); DRM_DEBUG_DRIVER("Updating channel size\n"); regmap_write(mixer->engine.regs, SUN8I_MIXER_CHAN_UI_OVL_SIZE(layer), - SUN8I_MIXER_SIZE(state->crtc_w, - state->crtc_h)); + size); } /* Set the line width */ @@ -122,18 +128,17 @@ int sun8i_mixer_update_layer_coord(struct sun8i_mixer *mixer, fb->pitches[0]); /* Set height and width */ - DRM_DEBUG_DRIVER("Layer size W: %u H: %u\n", - state->crtc_w, state->crtc_h); + DRM_DEBUG_DRIVER("Layer size W: %u H: %u\n", width, height); regmap_write(mixer->engine.regs, SUN8I_MIXER_CHAN_UI_LAYER_SIZE(layer, 0), - SUN8I_MIXER_SIZE(state->crtc_w, state->crtc_h)); + size); /* Set base coordinates */ DRM_DEBUG_DRIVER("Layer coordinates X: %d Y: %d\n", - state->crtc_x, state->crtc_y); + state->dst.x1, state->dst.y1); regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_ATTR_COORD(layer), - SUN8I_MIXER_COORD(state->crtc_x, state->crtc_y)); + SUN8I_MIXER_COORD(state->dst.x1, state->dst.y1)); return 0; } @@ -193,21 +198,8 @@ int sun8i_mixer_update_layer_buffer(struct sun8i_mixer *mixer, paddr = gem->paddr + fb->offsets[0]; /* Fixup framebuffer address for src coordinates */ - paddr += (state->src_x >> 16) * bpp; - paddr += (state->src_y >> 16) * fb->pitches[0]; - - /* - * The hardware cannot correctly deal with negative crtc - * coordinates, the display is cropped to the requested size, - * but the display content is not moved. - * Manually move the display content by fixup the framebuffer - * address when crtc_x or crtc_y is negative, like what we - * have did for src_x and src_y. - */ - if (state->crtc_x < 0) - paddr += -state->crtc_x * bpp; - if (state->crtc_y < 0) - paddr += -state->crtc_y * fb->pitches[0]; + paddr += (state->src.x1 >> 16) * bpp; + paddr += (state->src.y1 >> 16) * fb->pitches[0]; DRM_DEBUG_DRIVER("Setting buffer address to %pad\n", &paddr);