dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: "Daniel Vetter" <daniel@ffwll.ch>,
	dri-devel@lists.freedesktop.org,
	linux-samsung-soc@vger.kernel.org,
	"Inki Dae" <inki.dae@samsung.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Joonyoung Shim" <jy0922.shim@samsung.com>,
	"Seung-Woo Kim" <sw0312.kim@samsung.com>,
	"Andrzej Hajda" <a.hajda@samsung.com>,
	"Krzysztof Kozlowski" <k.kozlowski@samsung.com>,
	"Bartlomiej Zolnierkiewicz" <b.zolnierkie@samsung.com>,
	"Tobias Jakobi" <tjakobi@math.uni-bielefeld.de>,
	"Gustavo Padovan" <gustavo@padovan.org>,
	"Benjamin Gaignard" <benjamin.gaignard@linaro.org>,
	vincent.abriou@st.com, fabien.dessenne@st.com
Subject: Re: [PATCH v2 2/3] drm/exynos: use generic code for managing zpos plane property
Date: Tue, 12 Jan 2016 11:39:32 +0100	[thread overview]
Message-ID: <20160112103932.GE4588@phenom.ffwll.local> (raw)
In-Reply-To: <5694C8A3.9000906@samsung.com>

On Tue, Jan 12, 2016 at 10:34:27AM +0100, Marek Szyprowski wrote:
> Hello,
> 
> On 2016-01-11 16:13, Daniel Vetter wrote:
> >On Mon, Jan 11, 2016 at 12:03:04PM +0100, Marek Szyprowski wrote:
> >>This patch replaces zpos property handling custom code in Exynos DRM
> >>driver with calls to generic DRM code.
> >>
> >>Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> >>---
> >>  drivers/gpu/drm/exynos/exynos_drm_drv.h   |  1 -
> >>  drivers/gpu/drm/exynos/exynos_drm_plane.c | 66 +++++++------------------------
> >>  drivers/gpu/drm/exynos/exynos_mixer.c     | 19 +++++++--
> >>  3 files changed, 30 insertions(+), 56 deletions(-)
> >>
> >>diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> >>index 17b5ded72ff1..244ae6c4482c 100644
> >>--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> >>+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> >>@@ -217,7 +217,6 @@ struct exynos_drm_private {
> >>  	 * this array is used to be aware of which crtc did it request vblank.
> >>  	 */
> >>  	struct drm_crtc *crtc[MAX_CRTC];
> >>-	struct drm_property *plane_zpos_property;
> >>  	unsigned long da_start;
> >>  	unsigned long da_space_size;
> >>diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
> >>index d86227236f55..ba46bc3de796 100644
> >>--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
> >>+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
> >>@@ -137,9 +137,9 @@ static void exynos_drm_plane_reset(struct drm_plane *plane)
> >>  	exynos_state = kzalloc(sizeof(*exynos_state), GFP_KERNEL);
> >>  	if (exynos_state) {
> >>-		exynos_state->zpos = exynos_plane->config->zpos;
> >>  		plane->state = &exynos_state->base;
> >>  		plane->state->plane = plane;
> >>+		plane->state->zpos = exynos_plane->config->zpos;
> >>  	}
> >>  }
> >>@@ -155,7 +155,6 @@ exynos_drm_plane_duplicate_state(struct drm_plane *plane)
> >>  		return NULL;
> >>  	__drm_atomic_helper_plane_duplicate_state(plane, &copy->base);
> >>-	copy->zpos = exynos_state->zpos;
> >>  	return &copy->base;
> >>  }
> >>@@ -168,43 +167,6 @@ static void exynos_drm_plane_destroy_state(struct drm_plane *plane,
> >>  	kfree(old_exynos_state);
> >>  }
> >>-static int exynos_drm_plane_atomic_set_property(struct drm_plane *plane,
> >>-						struct drm_plane_state *state,
> >>-						struct drm_property *property,
> >>-						uint64_t val)
> >>-{
> >>-	struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane);
> >>-	struct exynos_drm_plane_state *exynos_state =
> >>-					to_exynos_plane_state(state);
> >>-	struct exynos_drm_private *dev_priv = plane->dev->dev_private;
> >>-	const struct exynos_drm_plane_config *config = exynos_plane->config;
> >>-
> >>-	if (property == dev_priv->plane_zpos_property &&
> >>-	    (config->capabilities & EXYNOS_DRM_PLANE_CAP_ZPOS))
> >>-		exynos_state->zpos = val;
> >>-	else
> >>-		return -EINVAL;
> >>-
> >>-	return 0;
> >>-}
> >>-
> >>-static int exynos_drm_plane_atomic_get_property(struct drm_plane *plane,
> >>-					  const struct drm_plane_state *state,
> >>-					  struct drm_property *property,
> >>-					  uint64_t *val)
> >>-{
> >>-	const struct exynos_drm_plane_state *exynos_state =
> >>-		container_of(state, const struct exynos_drm_plane_state, base);
> >>-	struct exynos_drm_private *dev_priv = plane->dev->dev_private;
> >>-
> >>-	if (property == dev_priv->plane_zpos_property)
> >>-		*val = exynos_state->zpos;
> >>-	else
> >>-		return -EINVAL;
> >>-
> >>-	return 0;
> >>-}
> >>-
> >>  static struct drm_plane_funcs exynos_plane_funcs = {
> >>  	.update_plane	= drm_atomic_helper_update_plane,
> >>  	.disable_plane	= drm_atomic_helper_disable_plane,
> >>@@ -213,8 +175,6 @@ static struct drm_plane_funcs exynos_plane_funcs = {
> >>  	.reset		= exynos_drm_plane_reset,
> >>  	.atomic_duplicate_state = exynos_drm_plane_duplicate_state,
> >>  	.atomic_destroy_state = exynos_drm_plane_destroy_state,
> >>-	.atomic_set_property = exynos_drm_plane_atomic_set_property,
> >>-	.atomic_get_property = exynos_drm_plane_atomic_get_property,
> >>  };
> >>  static int
> >>@@ -302,20 +262,21 @@ static const struct drm_plane_helper_funcs plane_helper_funcs = {
> >>  };
> >>  static void exynos_plane_attach_zpos_property(struct drm_plane *plane,
> >>-					      unsigned int zpos)
> >>+					      unsigned int zpos, bool immutable)
> >>  {
> >>  	struct drm_device *dev = plane->dev;
> >>-	struct exynos_drm_private *dev_priv = dev->dev_private;
> >>  	struct drm_property *prop;
> >>-	prop = dev_priv->plane_zpos_property;
> >>-	if (!prop) {
> >>-		prop = drm_property_create_range(dev, 0, "zpos",
> >>-						 0, MAX_PLANE - 1);
> >>-		if (!prop)
> >>-			return;
> >>-
> >>-		dev_priv->plane_zpos_property = prop;
> >>+	if (immutable) {
> >>+		if (!dev->mode_config.zpos_immutable_property)
> >>+			if (!drm_mode_create_zpos_immutable_property(dev))
> >>+				return;
> >>+		prop = dev->mode_config.zpos_immutable_property;
> >>+	} else {
> >>+		if (!dev->mode_config.zpos_property)
> >>+			if (!drm_mode_create_zpos_property(dev))
> >>+				return;
> >>+		prop = dev->mode_config.zpos_property;
> >>  	}
> >>  	drm_object_attach_property(&plane->base, prop, zpos);
> >>@@ -344,7 +305,8 @@ int exynos_plane_init(struct drm_device *dev,
> >>  	exynos_plane->index = index;
> >>  	exynos_plane->config = config;
> >>-	exynos_plane_attach_zpos_property(&exynos_plane->base, config->zpos);
> >>+	exynos_plane_attach_zpos_property(&exynos_plane->base, config->zpos,
> >>+			   !(config->capabilities & EXYNOS_DRM_PLANE_CAP_ZPOS));
> >>  	return 0;
> >>  }
> >>diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
> >>index b5fbc1cbf024..6ab68eca0004 100644
> >>--- a/drivers/gpu/drm/exynos/exynos_mixer.c
> >>+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
> >>@@ -34,6 +34,7 @@
> >>  #include <linux/component.h>
> >>  #include <drm/exynos_drm.h>
> >>+#include <drm/drm_atomic_helper.h>
> >>  #include "exynos_drm_drv.h"
> >>  #include "exynos_drm_crtc.h"
> >>@@ -95,6 +96,8 @@ struct mixer_context {
> >>  	struct drm_device	*drm_dev;
> >>  	struct exynos_drm_crtc	*crtc;
> >>  	struct exynos_drm_plane	planes[MIXER_WIN_NR];
> >>+	struct drm_plane	*zpos_planes[MIXER_WIN_NR];
> >>+	int			num_planes;
> >>  	int			pipe;
> >>  	unsigned long		flags;
> >>  	bool			interlace;
> >>@@ -478,6 +481,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
> >>  	struct drm_display_mode *mode = &state->base.crtc->state->adjusted_mode;
> >>  	struct mixer_resources *res = &ctx->mixer_res;
> >>  	struct drm_framebuffer *fb = state->base.fb;
> >>+	unsigned int priority = state->base.normalized_zpos + 1;
> >>  	unsigned long flags;
> >>  	dma_addr_t luma_addr[2], chroma_addr[2];
> >>  	bool tiled_mode = false;
> >>@@ -562,7 +566,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
> >>  	mixer_cfg_scan(ctx, mode->vdisplay);
> >>  	mixer_cfg_rgb_fmt(ctx, mode->vdisplay);
> >>-	mixer_cfg_layer(ctx, plane->index, state->zpos + 1, true);
> >>+	mixer_cfg_layer(ctx, plane->index, priority, true);
> >>  	mixer_cfg_vp_blend(ctx);
> >>  	mixer_run(ctx);
> >>@@ -587,6 +591,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
> >>  	struct drm_display_mode *mode = &state->base.crtc->state->adjusted_mode;
> >>  	struct mixer_resources *res = &ctx->mixer_res;
> >>  	struct drm_framebuffer *fb = state->base.fb;
> >>+	unsigned int priority = state->base.normalized_zpos + 1;
> >>  	unsigned long flags;
> >>  	unsigned int win = plane->index;
> >>  	unsigned int x_ratio = 0, y_ratio = 0;
> >>@@ -678,7 +683,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
> >>  	mixer_cfg_scan(ctx, mode->vdisplay);
> >>  	mixer_cfg_rgb_fmt(ctx, mode->vdisplay);
> >>-	mixer_cfg_layer(ctx, win, state->zpos + 1, true);
> >>+	mixer_cfg_layer(ctx, win, priority, true);
> >>  	mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->pixel_format));
> >>  	/* layer update mandatory for mixer 16.0.33.0 */
> >>@@ -981,6 +986,12 @@ static void mixer_atomic_begin(struct exynos_drm_crtc *crtc)
> >>  	if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
> >>  		return;
> >>+	/*
> >>+	 * Normalizing up to 3 planes is cheap, no need for checking
> >>+	 * if zpos has been really changed.
> >>+	 */
> >>+	drm_atomic_helper_normalize_zpos(mixer_ctx->zpos_planes,
> >>+					 mixer_ctx->num_planes);
> >Hm, this is a bit a cumbersome interface for drivers and will make
> >converting over to the normalized zpos more work. Can't we handle this in
> >the atomic helpers directly? I'm thinking of the following flow:
> >
> >- if new_plane_state->zpos != old_plane_state->zpos then set new_crtc_state->zpos_changed
> >- if new_crtc_state->plane_mask != old_crtc_state->plane_mask ||
> >   new_crtc_state->zpos_changed then recompute normilized zpos.
> >
> >Imo that would fit well in drm_atomic_helper_check_planes().
> >
> >With that bit of additional logic drivers can just use normlized_zpos and
> >don't need to care about anything really.
> 
> Okay, I will try to implement this logic.

Just to avoid another respin: If you do so I think it still makes sense to
export the current set of functions, for drivers which don't use helpers
or need to figure out the normalized zpos earlier or whatever.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2016-01-12 10:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11 11:03 [PATCH v2 0/3] drm/exynos: introduce generic zpos property Marek Szyprowski
2016-01-11 11:03 ` [PATCH v2 1/3] drm: add " Marek Szyprowski
2016-01-11 15:14   ` Daniel Vetter
2016-01-11 11:03 ` [PATCH v2 2/3] drm/exynos: use generic code for managing zpos plane property Marek Szyprowski
2016-01-11 15:13   ` Daniel Vetter
2016-01-12  9:34     ` Marek Szyprowski
2016-01-12 10:39       ` Daniel Vetter [this message]
2016-01-11 11:03 ` [PATCH v2 3/3] drm: simplify initialization of rotation property Marek Szyprowski

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=20160112103932.GE4588@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=a.hajda@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fabien.dessenne@st.com \
    --cc=gustavo@padovan.org \
    --cc=inki.dae@samsung.com \
    --cc=jy0922.shim@samsung.com \
    --cc=k.kozlowski@samsung.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=sw0312.kim@samsung.com \
    --cc=tjakobi@math.uni-bielefeld.de \
    --cc=ville.syrjala@linux.intel.com \
    --cc=vincent.abriou@st.com \
    /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