From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= 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 Message-ID: <20140904150706.GK4193@intel.com> References: <1409775018-16819-1-git-send-email-gustavo@padovan.org> <1409775018-16819-5-git-send-email-gustavo@padovan.org> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <1409775018-16819-5-git-send-email-gustavo@padovan.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Gustavo Padovan Cc: intel-gfx@lists.freedesktop.org, Gustavo Padovan , dri-devel@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Wed, Sep 03, 2014 at 05:10:18PM -0300, Gustavo Padovan wrote: > From: Gustavo Padovan > = > 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 > --- > 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 *c= rtc, > - 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 =3D state->crtc; > + struct drm_framebuffer *fb =3D state->fb; > + struct drm_rect *dest =3D &state->dst; > + struct drm_rect *src =3D &state->src; > + const struct drm_rect *clip =3D &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 =3D state->crtc; > + struct drm_framebuffer *fb =3D state->fb; > struct drm_device *dev =3D crtc->dev; > struct drm_i915_private *dev_priv =3D dev->dev_private; > struct intel_crtc *intel_crtc =3D to_intel_crtc(crtc); > struct drm_i915_gem_object *obj =3D intel_fb_obj(fb); > struct drm_i915_gem_object *old_obj =3D intel_fb_obj(plane->fb); > - struct drm_rect dest =3D { > - /* integer pixels */ > - .x1 =3D crtc_x, > - .y1 =3D crtc_y, > - .x2 =3D crtc_x + crtc_w, > - .y2 =3D crtc_y + crtc_h, > - }; > - struct drm_rect src =3D { > - /* 16.16 fixed point */ > - .x1 =3D src_x, > - .y1 =3D src_y, > - .x2 =3D src_x + src_w, > - .y2 =3D src_y + src_h, > - }; > - const struct drm_rect clip =3D { > - /* integer pixels */ > - .x2 =3D intel_crtc->active ? intel_crtc->config.pipe_src_w : 0, > - .y2 =3D 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 =3D { > - .crtc_x =3D crtc_x, > - .crtc_y =3D crtc_y, > - .crtc_w =3D crtc_w, > - .crtc_h =3D crtc_h, > - .src_x =3D src_x, > - .src_y =3D src_y, > - .src_w =3D src_w, > - .src_h =3D src_h, > - }; > struct intel_plane *intel_plane =3D to_intel_plane(plane); > - bool visible; > + struct drm_rect *src =3D &state->src; > int ret; > = > - ret =3D 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 *pl= ane, struct drm_crtc *crtc, > * happens if userspace explicitly disables the plane by passing fb=3D0 > * 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 *pl= ane, struct drm_crtc *crtc, > intel_disable_fbc(dev); > } > } > - ret =3D intel_pipe_set_base(crtc, src.x1, src.y1, fb); > + ret =3D 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 =3D orig.crtc_x; > - intel_plane->crtc_y =3D orig.crtc_y; > - intel_plane->crtc_w =3D orig.crtc_w; > - intel_plane->crtc_h =3D orig.crtc_h; > - intel_plane->src_x =3D orig.src_x; > - intel_plane->src_y =3D orig.src_y; > - intel_plane->src_w =3D orig.src_w; > - intel_plane->src_h =3D orig.src_h; > + intel_plane->crtc_x =3D state->orig_dst.x1; > + intel_plane->crtc_y =3D state->orig_dst.y1; > + intel_plane->crtc_w =3D drm_rect_width(&state->orig_dst); > + intel_plane->crtc_h =3D drm_rect_height(&state->orig_dst); > + intel_plane->src_x =3D state->orig_src.x1; > + intel_plane->src_y =3D state->orig_src.y1; > + intel_plane->src_w =3D drm_rect_width(&state->orig_src); > + intel_plane->src_h =3D drm_rect_height(&state->orig_src); > intel_plane->obj =3D obj; > = > return 0; > } > = > +static int > +intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *c= rtc, > + 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 =3D to_intel_crtc(crtc); > + int ret; > + > + state.crtc =3D crtc; > + state.fb =3D fb; > + > + /* sample coordinates in 16.16 fixed point */ > + state.src.x1 =3D src_x; > + state.src.x2 =3D src_x + src_w; > + state.src.y1 =3D src_y; > + state.src.y2 =3D src_y + src_h; > + > + /* integer pixels */ > + state.dst.x1 =3D crtc_x; > + state.dst.x2 =3D crtc_x + crtc_w; > + state.dst.y1 =3D crtc_y; > + state.dst.y2 =3D crtc_y + crtc_h; > + > + state.clip.x1 =3D 0; > + state.clip.y1 =3D 0; > + state.clip.x2 =3D intel_crtc->active ? intel_crtc->config.pipe_src_w : = 0; > + state.clip.y2 =3D intel_crtc->active ? intel_crtc->config.pipe_src_h : = 0; > + Forgot to populate orig_src/dst here. > + ret =3D 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=E4l=E4 Intel OTC