From: Jernej Skrabec <jernej.skrabec@siol.net>
To: maxime.ripard@free-electrons.com
Cc: wens@csie.org, airlied@linux.ie, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org, icenowy@aosc.io,
linux-sunxi@googlegroups.com
Subject: [PATCH 04/17] drm/sun4i: Use values calculated by atomic check
Date: Mon, 27 Nov 2017 21:57:37 +0100 [thread overview]
Message-ID: <20171127205750.19277-5-jernej.skrabec@siol.net> (raw)
In-Reply-To: <20171127205750.19277-1-jernej.skrabec@siol.net>
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 <jernej.skrabec@siol.net>
---
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);
--
2.15.0
next prev parent reply other threads:[~2017-11-27 21:02 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-27 20:57 [PATCH 00/17] Improve DE2 support Jernej Skrabec
2017-11-27 20:57 ` [PATCH 01/17] drm/sun4i: Refactor DE2 code Jernej Skrabec
2017-11-28 15:54 ` Maxime Ripard
2017-11-28 18:49 ` Jernej Škrabec
2017-11-27 20:57 ` [PATCH 02/17] drm/sun4i: Start using layer id in DE2 driver Jernej Skrabec
2017-11-28 20:21 ` Maxime Ripard
2017-11-27 20:57 ` [PATCH 03/17] drm/sun4i: Add constraints checking to " Jernej Skrabec
2017-11-27 20:57 ` Jernej Skrabec [this message]
2017-11-27 20:57 ` [PATCH 05/17] drm/sun4i: Reorder some code in DE2 Jernej Skrabec
2017-11-28 20:26 ` Maxime Ripard
2017-11-27 20:57 ` [PATCH 06/17] drm/sun4i: Add multi plane support to DE2 driver Jernej Skrabec
2017-11-27 20:57 ` [PATCH 07/17] drm/sun4i: Add support for all HW supported DE2 RGB formats Jernej Skrabec
2017-11-27 20:57 ` [PATCH 08/17] drm/sun4i: Add support for DE2 VI planes Jernej Skrabec
2017-11-28 21:00 ` Maxime Ripard
2017-11-28 21:28 ` Jernej Škrabec
2017-11-29 22:01 ` Jernej Škrabec
2017-11-27 20:57 ` [PATCH 09/17] drm/sun4i: Add scaler library for DE2 Jernej Skrabec
2017-11-28 20:40 ` Maxime Ripard
2017-11-27 20:57 ` [PATCH 10/17] drm/sun4i: Add scaler configuration to DE2 mixers Jernej Skrabec
2017-11-28 20:31 ` Maxime Ripard
2017-11-27 20:57 ` [PATCH 11/17] drm/sun4i: Wire in DE2 scaler support Jernej Skrabec
2017-11-28 20:42 ` Maxime Ripard
2017-11-29 21:48 ` [linux-sunxi] " Julian Calaby
2017-11-29 21:59 ` Jernej Škrabec
2017-11-27 20:57 ` [PATCH 12/17] drm/sun4i: Add CCSC property to DE2 configuration Jernej Skrabec
2017-11-28 12:02 ` Icenowy Zheng
2017-11-28 20:43 ` Maxime Ripard
2017-11-28 20:44 ` Maxime Ripard
2017-11-27 20:57 ` [PATCH 13/17] drm/sun4i: Add DE2 CSC library Jernej Skrabec
2017-11-28 20:55 ` Maxime Ripard
2017-11-28 21:43 ` Jernej Škrabec
2017-11-29 3:20 ` Chen-Yu Tsai
2017-11-29 15:27 ` Maxime Ripard
2017-11-27 20:57 ` [PATCH 14/17] drm/sun4i: Add DE2 definitions for YUV formats Jernej Skrabec
2017-11-27 20:57 ` [PATCH 15/17] drm/sun4i: Expand DE2 scaler lib with YUV support Jernej Skrabec
2017-11-27 20:57 ` [PATCH 16/17] drm/sun4i: Wire in DE2 " Jernej Skrabec
2017-11-27 20:57 ` [PATCH 17/17] [DO NOT MERGE]drm/sun4i: Change zpos of bottom VI plane Jernej Skrabec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171127205750.19277-5-jernej.skrabec@siol.net \
--to=jernej.skrabec@siol.net \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=icenowy@aosc.io \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=maxime.ripard@free-electrons.com \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).