diff options
author | Matt Roper <matthew.d.roper@intel.com> | 2014-12-01 18:40:16 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-12-05 19:46:25 -0500 |
commit | c59cb179aaf444931cf9c547a514e383da3d2526 (patch) | |
tree | 38dd7450c92e4c80673a4ea73d755908fb41c3d4 /drivers/gpu/drm/i915/intel_display.c | |
parent | 38f3ce3af5742eb5a3e9b01997f5ab85109c5762 (diff) |
drm/i915: Consolidate top-level .update_plane() handlers
Our .update_plane() handlers do the same check/prepare/commit/cleanup
steps regardless of plane type. Consolidate them all into a single
function that calls check/commit through a vtable.
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@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 | 112 |
1 files changed, 33 insertions, 79 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 0488700b10f7..f6334e6b378a 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -11782,12 +11782,23 @@ intel_check_primary_plane(struct drm_plane *plane, | |||
11782 | struct drm_rect *dest = &state->dst; | 11782 | struct drm_rect *dest = &state->dst; |
11783 | struct drm_rect *src = &state->src; | 11783 | struct drm_rect *src = &state->src; |
11784 | const struct drm_rect *clip = &state->clip; | 11784 | const struct drm_rect *clip = &state->clip; |
11785 | int ret; | ||
11786 | |||
11787 | ret = drm_plane_helper_check_update(plane, crtc, fb, | ||
11788 | src, dest, clip, | ||
11789 | DRM_PLANE_HELPER_NO_SCALING, | ||
11790 | DRM_PLANE_HELPER_NO_SCALING, | ||
11791 | false, true, &state->visible); | ||
11792 | if (ret) | ||
11793 | return ret; | ||
11785 | 11794 | ||
11786 | return drm_plane_helper_check_update(plane, crtc, fb, | 11795 | intel_crtc_wait_for_pending_flips(crtc); |
11787 | src, dest, clip, | 11796 | if (intel_crtc_has_pending_flip(crtc)) { |
11788 | DRM_PLANE_HELPER_NO_SCALING, | 11797 | DRM_ERROR("pipe is still busy with an old pageflip\n"); |
11789 | DRM_PLANE_HELPER_NO_SCALING, | 11798 | return -EBUSY; |
11790 | false, true, &state->visible); | 11799 | } |
11800 | |||
11801 | return 0; | ||
11791 | } | 11802 | } |
11792 | 11803 | ||
11793 | static void | 11804 | static void |
@@ -11873,16 +11884,17 @@ intel_commit_primary_plane(struct drm_plane *plane, | |||
11873 | } | 11884 | } |
11874 | } | 11885 | } |
11875 | 11886 | ||
11876 | static int | 11887 | int |
11877 | intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc, | 11888 | intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, |
11878 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, | 11889 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, |
11879 | unsigned int crtc_w, unsigned int crtc_h, | 11890 | unsigned int crtc_w, unsigned int crtc_h, |
11880 | uint32_t src_x, uint32_t src_y, | 11891 | uint32_t src_x, uint32_t src_y, |
11881 | uint32_t src_w, uint32_t src_h) | 11892 | uint32_t src_w, uint32_t src_h) |
11882 | { | 11893 | { |
11883 | struct drm_device *dev = plane->dev; | 11894 | struct drm_device *dev = plane->dev; |
11884 | struct drm_framebuffer *old_fb = plane->fb; | 11895 | struct drm_framebuffer *old_fb = plane->fb; |
11885 | struct intel_plane_state state; | 11896 | struct intel_plane_state state; |
11897 | struct intel_plane *intel_plane = to_intel_plane(plane); | ||
11886 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 11898 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
11887 | int ret; | 11899 | int ret; |
11888 | 11900 | ||
@@ -11909,24 +11921,17 @@ intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
11909 | state.orig_src = state.src; | 11921 | state.orig_src = state.src; |
11910 | state.orig_dst = state.dst; | 11922 | state.orig_dst = state.dst; |
11911 | 11923 | ||
11912 | ret = intel_check_primary_plane(plane, &state); | 11924 | ret = intel_plane->check_plane(plane, &state); |
11913 | if (ret) | 11925 | if (ret) |
11914 | return ret; | 11926 | return ret; |
11915 | 11927 | ||
11916 | intel_crtc_wait_for_pending_flips(crtc); | ||
11917 | |||
11918 | if (intel_crtc_has_pending_flip(crtc)) { | ||
11919 | DRM_ERROR("pipe is still busy with an old pageflip\n"); | ||
11920 | return -EBUSY; | ||
11921 | } | ||
11922 | |||
11923 | if (fb != old_fb && fb) { | 11928 | if (fb != old_fb && fb) { |
11924 | ret = intel_prepare_plane_fb(plane, fb); | 11929 | ret = intel_prepare_plane_fb(plane, fb); |
11925 | if (ret) | 11930 | if (ret) |
11926 | return ret; | 11931 | return ret; |
11927 | } | 11932 | } |
11928 | 11933 | ||
11929 | intel_commit_primary_plane(plane, &state); | 11934 | intel_plane->commit_plane(plane, &state); |
11930 | 11935 | ||
11931 | if (fb != old_fb && old_fb) { | 11936 | if (fb != old_fb && old_fb) { |
11932 | if (intel_crtc->active) | 11937 | if (intel_crtc->active) |
@@ -11934,6 +11939,8 @@ intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
11934 | intel_cleanup_plane_fb(plane, old_fb); | 11939 | intel_cleanup_plane_fb(plane, old_fb); |
11935 | } | 11940 | } |
11936 | 11941 | ||
11942 | plane->fb = fb; | ||
11943 | |||
11937 | return 0; | 11944 | return 0; |
11938 | } | 11945 | } |
11939 | 11946 | ||
@@ -11946,7 +11953,7 @@ static void intel_plane_destroy(struct drm_plane *plane) | |||
11946 | } | 11953 | } |
11947 | 11954 | ||
11948 | static const struct drm_plane_funcs intel_primary_plane_funcs = { | 11955 | static const struct drm_plane_funcs intel_primary_plane_funcs = { |
11949 | .update_plane = intel_primary_plane_setplane, | 11956 | .update_plane = intel_update_plane, |
11950 | .disable_plane = intel_primary_plane_disable, | 11957 | .disable_plane = intel_primary_plane_disable, |
11951 | .destroy = intel_plane_destroy, | 11958 | .destroy = intel_plane_destroy, |
11952 | .set_property = intel_plane_set_property | 11959 | .set_property = intel_plane_set_property |
@@ -11968,6 +11975,8 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, | |||
11968 | primary->pipe = pipe; | 11975 | primary->pipe = pipe; |
11969 | primary->plane = pipe; | 11976 | primary->plane = pipe; |
11970 | primary->rotation = BIT(DRM_ROTATE_0); | 11977 | primary->rotation = BIT(DRM_ROTATE_0); |
11978 | primary->check_plane = intel_check_primary_plane; | ||
11979 | primary->commit_plane = intel_commit_primary_plane; | ||
11971 | if (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4) | 11980 | if (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4) |
11972 | primary->plane = !pipe; | 11981 | primary->plane = !pipe; |
11973 | 11982 | ||
@@ -12133,65 +12142,8 @@ update: | |||
12133 | } | 12142 | } |
12134 | } | 12143 | } |
12135 | 12144 | ||
12136 | static int | ||
12137 | intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, | ||
12138 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, | ||
12139 | unsigned int crtc_w, unsigned int crtc_h, | ||
12140 | uint32_t src_x, uint32_t src_y, | ||
12141 | uint32_t src_w, uint32_t src_h) | ||
12142 | { | ||
12143 | struct drm_device *dev = plane->dev; | ||
12144 | struct drm_framebuffer *old_fb = plane->fb; | ||
12145 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
12146 | struct intel_plane_state state; | ||
12147 | int ret; | ||
12148 | |||
12149 | state.base.crtc = crtc; | ||
12150 | state.base.fb = fb; | ||
12151 | |||
12152 | /* sample coordinates in 16.16 fixed point */ | ||
12153 | state.src.x1 = src_x; | ||
12154 | state.src.x2 = src_x + src_w; | ||
12155 | state.src.y1 = src_y; | ||
12156 | state.src.y2 = src_y + src_h; | ||
12157 | |||
12158 | /* integer pixels */ | ||
12159 | state.dst.x1 = crtc_x; | ||
12160 | state.dst.x2 = crtc_x + crtc_w; | ||
12161 | state.dst.y1 = crtc_y; | ||
12162 | state.dst.y2 = crtc_y + crtc_h; | ||
12163 | |||
12164 | state.clip.x1 = 0; | ||
12165 | state.clip.y1 = 0; | ||
12166 | state.clip.x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0; | ||
12167 | state.clip.y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0; | ||
12168 | |||
12169 | state.orig_src = state.src; | ||
12170 | state.orig_dst = state.dst; | ||
12171 | |||
12172 | ret = intel_check_cursor_plane(plane, &state); | ||
12173 | if (ret) | ||
12174 | return ret; | ||
12175 | |||
12176 | if (fb != old_fb && fb) { | ||
12177 | ret = intel_prepare_plane_fb(plane, fb); | ||
12178 | if (ret) | ||
12179 | return ret; | ||
12180 | } | ||
12181 | |||
12182 | intel_commit_cursor_plane(plane, &state); | ||
12183 | |||
12184 | if (fb != old_fb && old_fb) { | ||
12185 | if (intel_crtc->active) | ||
12186 | intel_wait_for_vblank(dev, intel_crtc->pipe); | ||
12187 | intel_cleanup_plane_fb(plane, old_fb); | ||
12188 | } | ||
12189 | |||
12190 | return 0; | ||
12191 | } | ||
12192 | |||
12193 | static const struct drm_plane_funcs intel_cursor_plane_funcs = { | 12145 | static const struct drm_plane_funcs intel_cursor_plane_funcs = { |
12194 | .update_plane = intel_cursor_plane_update, | 12146 | .update_plane = intel_update_plane, |
12195 | .disable_plane = intel_cursor_plane_disable, | 12147 | .disable_plane = intel_cursor_plane_disable, |
12196 | .destroy = intel_plane_destroy, | 12148 | .destroy = intel_plane_destroy, |
12197 | .set_property = intel_plane_set_property, | 12149 | .set_property = intel_plane_set_property, |
@@ -12211,6 +12163,8 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, | |||
12211 | cursor->pipe = pipe; | 12163 | cursor->pipe = pipe; |
12212 | cursor->plane = pipe; | 12164 | cursor->plane = pipe; |
12213 | cursor->rotation = BIT(DRM_ROTATE_0); | 12165 | cursor->rotation = BIT(DRM_ROTATE_0); |
12166 | cursor->check_plane = intel_check_cursor_plane; | ||
12167 | cursor->commit_plane = intel_commit_cursor_plane; | ||
12214 | 12168 | ||
12215 | drm_universal_plane_init(dev, &cursor->base, 0, | 12169 | drm_universal_plane_init(dev, &cursor->base, 0, |
12216 | &intel_cursor_plane_funcs, | 12170 | &intel_cursor_plane_funcs, |