public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Gustavo Padovan <gustavo@padovan.org>
Cc: intel-gfx@lists.freedesktop.org,
	Gustavo Padovan <gustavo.padovan@collabora.co.uk>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH -v3 4/4] drm/i915: split intel_primary_plane_setplane() into check() and commit()
Date: Thu, 4 Sep 2014 18:07:06 +0300	[thread overview]
Message-ID: <20140904150706.GK4193@intel.com> (raw)
In-Reply-To: <1409775018-16819-5-git-send-email-gustavo@padovan.org>

On Wed, Sep 03, 2014 at 05:10:18PM -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> 
> As a preparation for atomic updates we need to split the code to check
> everything we are going to commit first. This patch starts the work to
> split intel_primary_plane_setplane() into check() and commit() parts.
> 
> More work is expected on this to get a better split of the two steps.
> Ideally the commit() step should never fail.
> 
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 130 +++++++++++++++++++----------------
>  1 file changed, 72 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index c3f1967..1e3985b 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -11663,63 +11663,37 @@ disable_unpin:
>  }
>  
>  static int
> -intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc,
> -			     struct drm_framebuffer *fb, int crtc_x, int crtc_y,
> -			     unsigned int crtc_w, unsigned int crtc_h,
> -			     uint32_t src_x, uint32_t src_y,
> -			     uint32_t src_w, uint32_t src_h)
> +intel_check_primary_plane(struct drm_plane *plane,
> +			  struct intel_plane_state *state)
> +{
> +	struct drm_crtc *crtc = state->crtc;
> +	struct drm_framebuffer *fb = state->fb;
> +	struct drm_rect *dest = &state->dst;
> +	struct drm_rect *src = &state->src;
> +	const struct drm_rect *clip = &state->clip;
> +
> +	return drm_plane_helper_check_update(plane, crtc, fb,
> +					    src, dest, clip,
> +					    DRM_PLANE_HELPER_NO_SCALING,
> +					    DRM_PLANE_HELPER_NO_SCALING,
> +					    false, true, &state->visible);
> +}
> +
> +static int
> +intel_commit_primary_plane(struct drm_plane *plane,
> +			   struct intel_plane_state *state)
>  {
> +	struct drm_crtc *crtc = state->crtc;
> +	struct drm_framebuffer *fb = state->fb;
>  	struct drm_device *dev = crtc->dev;
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  	struct drm_i915_gem_object *obj = intel_fb_obj(fb);
>  	struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb);
> -	struct drm_rect dest = {
> -		/* integer pixels */
> -		.x1 = crtc_x,
> -		.y1 = crtc_y,
> -		.x2 = crtc_x + crtc_w,
> -		.y2 = crtc_y + crtc_h,
> -	};
> -	struct drm_rect src = {
> -		/* 16.16 fixed point */
> -		.x1 = src_x,
> -		.y1 = src_y,
> -		.x2 = src_x + src_w,
> -		.y2 = src_y + src_h,
> -	};
> -	const struct drm_rect clip = {
> -		/* integer pixels */
> -		.x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0,
> -		.y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0,
> -	};
> -	const struct {
> -		int crtc_x, crtc_y;
> -		unsigned int crtc_w, crtc_h;
> -		uint32_t src_x, src_y, src_w, src_h;
> -	} orig = {
> -		.crtc_x = crtc_x,
> -		.crtc_y = crtc_y,
> -		.crtc_w = crtc_w,
> -		.crtc_h = crtc_h,
> -		.src_x = src_x,
> -		.src_y = src_y,
> -		.src_w = src_w,
> -		.src_h = src_h,
> -	};
>  	struct intel_plane *intel_plane = to_intel_plane(plane);
> -	bool visible;
> +	struct drm_rect *src = &state->src;
>  	int ret;
>  
> -	ret = drm_plane_helper_check_update(plane, crtc, fb,
> -					    &src, &dest, &clip,
> -					    DRM_PLANE_HELPER_NO_SCALING,
> -					    DRM_PLANE_HELPER_NO_SCALING,
> -					    false, true, &visible);
> -
> -	if (ret)
> -		return ret;
> -
>  	/*
>  	 * If the CRTC isn't enabled, we're just pinning the framebuffer,
>  	 * updating the fb pointer, and returning without touching the
> @@ -11754,7 +11728,7 @@ intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc,
>  	 * happens if userspace explicitly disables the plane by passing fb=0
>  	 * because plane->fb still gets set and pinned.
>  	 */
> -	if (!visible) {
> +	if (!state->visible) {
>  		mutex_lock(&dev->struct_mutex);
>  
>  		/*
> @@ -11801,7 +11775,7 @@ intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc,
>  				intel_disable_fbc(dev);
>  			}
>  		}
> -		ret = intel_pipe_set_base(crtc, src.x1, src.y1, fb);
> +		ret = intel_pipe_set_base(crtc, src->x1, src->y1, fb);
>  		if (ret)
>  			return ret;
>  
> @@ -11809,19 +11783,59 @@ intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc,
>  			intel_enable_primary_hw_plane(plane, crtc);
>  	}
>  
> -	intel_plane->crtc_x = orig.crtc_x;
> -	intel_plane->crtc_y = orig.crtc_y;
> -	intel_plane->crtc_w = orig.crtc_w;
> -	intel_plane->crtc_h = orig.crtc_h;
> -	intel_plane->src_x = orig.src_x;
> -	intel_plane->src_y = orig.src_y;
> -	intel_plane->src_w = orig.src_w;
> -	intel_plane->src_h = orig.src_h;
> +	intel_plane->crtc_x = state->orig_dst.x1;
> +	intel_plane->crtc_y = state->orig_dst.y1;
> +	intel_plane->crtc_w = drm_rect_width(&state->orig_dst);
> +	intel_plane->crtc_h = drm_rect_height(&state->orig_dst);
> +	intel_plane->src_x = state->orig_src.x1;
> +	intel_plane->src_y = state->orig_src.y1;
> +	intel_plane->src_w = drm_rect_width(&state->orig_src);
> +	intel_plane->src_h = drm_rect_height(&state->orig_src);
>  	intel_plane->obj = obj;
>  
>  	return 0;
>  }
>  
> +static int
> +intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc,
> +			     struct drm_framebuffer *fb, int crtc_x, int crtc_y,
> +			     unsigned int crtc_w, unsigned int crtc_h,
> +			     uint32_t src_x, uint32_t src_y,
> +			     uint32_t src_w, uint32_t src_h)
> +{
> +	struct intel_plane_state state;
> +	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> +	int ret;
> +
> +	state.crtc = crtc;
> +	state.fb = fb;
> +
> +	/* sample coordinates in 16.16 fixed point */
> +	state.src.x1 = src_x;
> +	state.src.x2 = src_x + src_w;
> +	state.src.y1 = src_y;
> +	state.src.y2 = src_y + src_h;
> +
> +	/* integer pixels */
> +	state.dst.x1 = crtc_x;
> +	state.dst.x2 = crtc_x + crtc_w;
> +	state.dst.y1 = crtc_y;
> +	state.dst.y2 = crtc_y + crtc_h;
> +
> +	state.clip.x1 = 0;
> +	state.clip.y1 = 0;
> +	state.clip.x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0;
> +	state.clip.y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0;
> +

Forgot to populate orig_src/dst here.

> +	ret = intel_check_primary_plane(plane, &state);
> +	if (ret)
> +		return ret;
> +
> +	intel_commit_primary_plane(plane, &state);
> +
> +	return 0;
> +}
> +
>  /* Common destruction function for both primary and cursor planes */
>  static void intel_plane_destroy(struct drm_plane *plane)
>  {
> -- 
> 1.9.3

-- 
Ville Syrjälä
Intel OTC

      reply	other threads:[~2014-09-04 15:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03 20:10 [PATCH -v3 0/4] split plane's updates functions into check() and commit() Gustavo Padovan
2014-09-03 20:10 ` [PATCH -v3 1/4] drm/i915: create struct intel_plane_state Gustavo Padovan
2014-09-03 20:10 ` [PATCH -v3 2/4] drm/i915: split intel_update_plane into check() and commit() Gustavo Padovan
2014-09-04 15:18   ` Ville Syrjälä
2014-09-03 20:10 ` [PATCH -v3 3/4] drm/i915: split intel_cursor_plane_update() " Gustavo Padovan
2014-09-04 15:04   ` Ville Syrjälä
2014-09-03 20:10 ` [PATCH -v3 4/4] drm/i915: split intel_primary_plane_setplane() " Gustavo Padovan
2014-09-04 15:07   ` Ville Syrjälä [this message]

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=20140904150706.GK4193@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=gustavo@padovan.org \
    --cc=intel-gfx@lists.freedesktop.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