From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Subject: Re: [PATCH -v3 3/4] drm/i915: split intel_cursor_plane_update() into check() and commit() Date: Thu, 4 Sep 2014 18:04:16 +0300 Message-ID: <20140904150416.GJ4193@intel.com> References: <1409775018-16819-1-git-send-email-gustavo@padovan.org> <1409775018-16819-4-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-4-git-send-email-gustavo@padovan.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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:17PM -0300, Gustavo Padovan wrote: > From: Gustavo Padovan > = > Due to the upcoming atomic modesetting feature we need to separate > some update functions into a check step that can fail and a commit > step that should, ideally, never fail. > = > The commit part can still fail, but that should be solved in another > upcoming patch. > = > Signed-off-by: Gustavo Padovan > --- > drivers/gpu/drm/i915/intel_display.c | 104 ++++++++++++++++++++++-------= ------ > 1 file changed, 67 insertions(+), 37 deletions(-) > = > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/= intel_display.c > index 22d3902..c3f1967 100644 > --- a/drivers/gpu/drm/i915/intel_display.c > +++ b/drivers/gpu/drm/i915/intel_display.c > @@ -11896,51 +11896,42 @@ intel_cursor_plane_disable(struct drm_plane *pl= ane) > } > = > static int > -intel_cursor_plane_update(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_cursor_plane(struct drm_plane *plane, > + struct intel_plane_state *state) > { > - struct intel_crtc *intel_crtc =3D to_intel_crtc(crtc); > - struct intel_framebuffer *intel_fb =3D to_intel_framebuffer(fb); > - struct drm_i915_gem_object *obj =3D intel_fb->obj; > - 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, > - }; > - bool visible; > - int ret; > + 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; > = > - ret =3D drm_plane_helper_check_update(plane, crtc, fb, > - &src, &dest, &clip, > + return drm_plane_helper_check_update(plane, crtc, fb, > + src, dest, clip, > DRM_PLANE_HELPER_NO_SCALING, > DRM_PLANE_HELPER_NO_SCALING, > - true, true, &visible); > - if (ret) > - return ret; > + true, true, &state->visible); > +} > = > - crtc->cursor_x =3D crtc_x; > - crtc->cursor_y =3D crtc_y; > +static int > +intel_commit_cursor_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 intel_crtc *intel_crtc =3D to_intel_crtc(crtc); > + struct intel_framebuffer *intel_fb =3D to_intel_framebuffer(fb); > + struct drm_i915_gem_object *obj =3D intel_fb->obj; > + struct drm_rect *dest =3D &state->dst; > + int crtc_w, crtc_h; > + > + crtc->cursor_x =3D state->dst.x1; > + crtc->cursor_y =3D state->dst.y1; > if (fb !=3D crtc->cursor->fb) { > + crtc_w =3D drm_rect_width(dest); > + crtc_h =3D drm_rect_height(dest); These would need to be the original unclipped coordinates since we program the cursor hardware with those and the hardware clips itself. > return intel_crtc_cursor_set_obj(crtc, obj, crtc_w, crtc_h); > } else { > - intel_crtc_update_cursor(crtc, visible); > + intel_crtc_update_cursor(crtc, state->visible); > = > intel_frontbuffer_flip(crtc->dev, > INTEL_FRONTBUFFER_CURSOR(intel_crtc->pipe)); > @@ -11948,6 +11939,45 @@ intel_cursor_plane_update(struct drm_plane *plan= e, struct drm_crtc *crtc, > return 0; > } > } > + > +static int > +intel_cursor_plane_update(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_crtc *intel_crtc =3D to_intel_crtc(crtc); > + struct intel_plane_state state; > + 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; > + > + ret =3D intel_check_cursor_plane(plane, &state); > + if (ret) > + return ret; > + > + return intel_commit_cursor_plane(plane, &state); > +} > + > static const struct drm_plane_funcs intel_cursor_plane_funcs =3D { > .update_plane =3D intel_cursor_plane_update, > .disable_plane =3D intel_cursor_plane_disable, > -- = > 1.9.3 -- = Ville Syrj=E4l=E4 Intel OTC