diff options
author | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2014-09-05 16:22:31 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-09-19 08:43:05 -0400 |
commit | 852e787c4cb9fcc34cf81d2a764a1aee2d9f24bd (patch) | |
tree | 3d199e96844d3f8c032189dd5dd8e074a7df9341 /drivers/gpu/drm/i915/intel_display.c | |
parent | 96d61a7f267ff355a401ca23a732810027d10ba2 (diff) |
drm/i915: split intel_cursor_plane_update() into check() and commit()
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 <gustavo.padovan@collabora.co.uk>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 106 |
1 files changed, 69 insertions, 37 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index c5079f2c49f3..8de7d4cf03da 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -12040,51 +12040,41 @@ intel_cursor_plane_disable(struct drm_plane *plane) | |||
12040 | } | 12040 | } |
12041 | 12041 | ||
12042 | static int | 12042 | static int |
12043 | intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, | 12043 | intel_check_cursor_plane(struct drm_plane *plane, |
12044 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, | 12044 | struct intel_plane_state *state) |
12045 | unsigned int crtc_w, unsigned int crtc_h, | ||
12046 | uint32_t src_x, uint32_t src_y, | ||
12047 | uint32_t src_w, uint32_t src_h) | ||
12048 | { | 12045 | { |
12049 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 12046 | struct drm_crtc *crtc = state->crtc; |
12050 | struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); | 12047 | struct drm_framebuffer *fb = state->fb; |
12051 | struct drm_i915_gem_object *obj = intel_fb->obj; | 12048 | struct drm_rect *dest = &state->dst; |
12052 | struct drm_rect dest = { | 12049 | struct drm_rect *src = &state->src; |
12053 | /* integer pixels */ | 12050 | const struct drm_rect *clip = &state->clip; |
12054 | .x1 = crtc_x, | ||
12055 | .y1 = crtc_y, | ||
12056 | .x2 = crtc_x + crtc_w, | ||
12057 | .y2 = crtc_y + crtc_h, | ||
12058 | }; | ||
12059 | struct drm_rect src = { | ||
12060 | /* 16.16 fixed point */ | ||
12061 | .x1 = src_x, | ||
12062 | .y1 = src_y, | ||
12063 | .x2 = src_x + src_w, | ||
12064 | .y2 = src_y + src_h, | ||
12065 | }; | ||
12066 | const struct drm_rect clip = { | ||
12067 | /* integer pixels */ | ||
12068 | .x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0, | ||
12069 | .y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0, | ||
12070 | }; | ||
12071 | bool visible; | ||
12072 | int ret; | ||
12073 | 12051 | ||
12074 | ret = drm_plane_helper_check_update(plane, crtc, fb, | 12052 | return drm_plane_helper_check_update(plane, crtc, fb, |
12075 | &src, &dest, &clip, | 12053 | src, dest, clip, |
12076 | DRM_PLANE_HELPER_NO_SCALING, | 12054 | DRM_PLANE_HELPER_NO_SCALING, |
12077 | DRM_PLANE_HELPER_NO_SCALING, | 12055 | DRM_PLANE_HELPER_NO_SCALING, |
12078 | true, true, &visible); | 12056 | true, true, &state->visible); |
12079 | if (ret) | 12057 | } |
12080 | return ret; | ||
12081 | 12058 | ||
12082 | crtc->cursor_x = crtc_x; | 12059 | static int |
12083 | crtc->cursor_y = crtc_y; | 12060 | intel_commit_cursor_plane(struct drm_plane *plane, |
12061 | struct intel_plane_state *state) | ||
12062 | { | ||
12063 | struct drm_crtc *crtc = state->crtc; | ||
12064 | struct drm_framebuffer *fb = state->fb; | ||
12065 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
12066 | struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); | ||
12067 | struct drm_i915_gem_object *obj = intel_fb->obj; | ||
12068 | int crtc_w, crtc_h; | ||
12069 | |||
12070 | crtc->cursor_x = state->orig_dst.x1; | ||
12071 | crtc->cursor_y = state->orig_dst.y1; | ||
12084 | if (fb != crtc->cursor->fb) { | 12072 | if (fb != crtc->cursor->fb) { |
12073 | crtc_w = drm_rect_width(&state->orig_dst); | ||
12074 | crtc_h = drm_rect_height(&state->orig_dst); | ||
12085 | return intel_crtc_cursor_set_obj(crtc, obj, crtc_w, crtc_h); | 12075 | return intel_crtc_cursor_set_obj(crtc, obj, crtc_w, crtc_h); |
12086 | } else { | 12076 | } else { |
12087 | intel_crtc_update_cursor(crtc, visible); | 12077 | intel_crtc_update_cursor(crtc, state->visible); |
12088 | 12078 | ||
12089 | intel_frontbuffer_flip(crtc->dev, | 12079 | intel_frontbuffer_flip(crtc->dev, |
12090 | INTEL_FRONTBUFFER_CURSOR(intel_crtc->pipe)); | 12080 | INTEL_FRONTBUFFER_CURSOR(intel_crtc->pipe)); |
@@ -12092,6 +12082,48 @@ intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, | |||
12092 | return 0; | 12082 | return 0; |
12093 | } | 12083 | } |
12094 | } | 12084 | } |
12085 | |||
12086 | static int | ||
12087 | intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, | ||
12088 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, | ||
12089 | unsigned int crtc_w, unsigned int crtc_h, | ||
12090 | uint32_t src_x, uint32_t src_y, | ||
12091 | uint32_t src_w, uint32_t src_h) | ||
12092 | { | ||
12093 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
12094 | struct intel_plane_state state; | ||
12095 | int ret; | ||
12096 | |||
12097 | state.crtc = crtc; | ||
12098 | state.fb = fb; | ||
12099 | |||
12100 | /* sample coordinates in 16.16 fixed point */ | ||
12101 | state.src.x1 = src_x; | ||
12102 | state.src.x2 = src_x + src_w; | ||
12103 | state.src.y1 = src_y; | ||
12104 | state.src.y2 = src_y + src_h; | ||
12105 | |||
12106 | /* integer pixels */ | ||
12107 | state.dst.x1 = crtc_x; | ||
12108 | state.dst.x2 = crtc_x + crtc_w; | ||
12109 | state.dst.y1 = crtc_y; | ||
12110 | state.dst.y2 = crtc_y + crtc_h; | ||
12111 | |||
12112 | state.clip.x1 = 0; | ||
12113 | state.clip.y1 = 0; | ||
12114 | state.clip.x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0; | ||
12115 | state.clip.y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0; | ||
12116 | |||
12117 | state.orig_src = state.src; | ||
12118 | state.orig_dst = state.dst; | ||
12119 | |||
12120 | ret = intel_check_cursor_plane(plane, &state); | ||
12121 | if (ret) | ||
12122 | return ret; | ||
12123 | |||
12124 | return intel_commit_cursor_plane(plane, &state); | ||
12125 | } | ||
12126 | |||
12095 | static const struct drm_plane_funcs intel_cursor_plane_funcs = { | 12127 | static const struct drm_plane_funcs intel_cursor_plane_funcs = { |
12096 | .update_plane = intel_cursor_plane_update, | 12128 | .update_plane = intel_cursor_plane_update, |
12097 | .disable_plane = intel_cursor_plane_disable, | 12129 | .disable_plane = intel_cursor_plane_disable, |