@@ -11689,6 +11689,65 @@ intel_primary_plane_disable(struct drm_plane *plane)
11689
11689
return 0 ;
11690
11690
}
11691
11691
11692
+ /**
11693
+ * intel_prepare_plane_fb - Prepare fb for usage on plane
11694
+ * @plane: drm plane to prepare for
11695
+ * @fb: framebuffer to prepare for presentation
11696
+ *
11697
+ * Prepares a framebuffer for usage on a display plane. Generally this
11698
+ * involves pinning the underlying object and updating the frontbuffer tracking
11699
+ * bits. Some older platforms need special physical address handling for
11700
+ * cursor planes.
11701
+ *
11702
+ * Returns 0 on success, negative error code on failure.
11703
+ */
11704
+ int
11705
+ intel_prepare_plane_fb (struct drm_plane * plane ,
11706
+ struct drm_framebuffer * fb )
11707
+ {
11708
+ struct drm_device * dev = plane -> dev ;
11709
+ struct intel_plane * intel_plane = to_intel_plane (plane );
11710
+ enum pipe pipe = intel_plane -> pipe ;
11711
+ struct drm_i915_gem_object * obj = intel_fb_obj (fb );
11712
+ struct drm_i915_gem_object * old_obj = intel_fb_obj (plane -> fb );
11713
+ unsigned frontbuffer_bits = 0 ;
11714
+ int ret = 0 ;
11715
+
11716
+ if (WARN_ON (fb == plane -> fb || !obj ))
11717
+ return 0 ;
11718
+
11719
+ switch (plane -> type ) {
11720
+ case DRM_PLANE_TYPE_PRIMARY :
11721
+ frontbuffer_bits = INTEL_FRONTBUFFER_PRIMARY (pipe );
11722
+ break ;
11723
+ case DRM_PLANE_TYPE_CURSOR :
11724
+ frontbuffer_bits = INTEL_FRONTBUFFER_CURSOR (pipe );
11725
+ break ;
11726
+ case DRM_PLANE_TYPE_OVERLAY :
11727
+ frontbuffer_bits = INTEL_FRONTBUFFER_SPRITE (pipe );
11728
+ break ;
11729
+ }
11730
+
11731
+ mutex_lock (& dev -> struct_mutex );
11732
+
11733
+ if (plane -> type == DRM_PLANE_TYPE_CURSOR &&
11734
+ INTEL_INFO (dev )-> cursor_needs_physical ) {
11735
+ int align = IS_I830 (dev ) ? 16 * 1024 : 256 ;
11736
+ ret = i915_gem_object_attach_phys (obj , align );
11737
+ if (ret )
11738
+ DRM_DEBUG_KMS ("failed to attach phys object\n" );
11739
+ } else {
11740
+ ret = intel_pin_and_fence_fb_obj (plane , fb , NULL );
11741
+ }
11742
+
11743
+ if (ret == 0 )
11744
+ i915_gem_track_fb (old_obj , obj , frontbuffer_bits );
11745
+
11746
+ mutex_unlock (& dev -> struct_mutex );
11747
+
11748
+ return ret ;
11749
+ }
11750
+
11692
11751
static int
11693
11752
intel_check_primary_plane (struct drm_plane * plane ,
11694
11753
struct intel_plane_state * state )
@@ -11706,42 +11765,6 @@ intel_check_primary_plane(struct drm_plane *plane,
11706
11765
false, true, & state -> visible );
11707
11766
}
11708
11767
11709
- static int
11710
- intel_prepare_primary_plane (struct drm_plane * plane ,
11711
- struct intel_plane_state * state )
11712
- {
11713
- struct drm_crtc * crtc = state -> base .crtc ;
11714
- struct drm_framebuffer * fb = state -> base .fb ;
11715
- struct drm_device * dev = crtc -> dev ;
11716
- struct intel_crtc * intel_crtc = to_intel_crtc (crtc );
11717
- enum pipe pipe = intel_crtc -> pipe ;
11718
- struct drm_i915_gem_object * obj = intel_fb_obj (fb );
11719
- struct drm_i915_gem_object * old_obj = intel_fb_obj (plane -> fb );
11720
- int ret ;
11721
-
11722
- intel_crtc_wait_for_pending_flips (crtc );
11723
-
11724
- if (intel_crtc_has_pending_flip (crtc )) {
11725
- DRM_ERROR ("pipe is still busy with an old pageflip\n" );
11726
- return - EBUSY ;
11727
- }
11728
-
11729
- if (old_obj != obj ) {
11730
- mutex_lock (& dev -> struct_mutex );
11731
- ret = intel_pin_and_fence_fb_obj (plane , fb , NULL );
11732
- if (ret == 0 )
11733
- i915_gem_track_fb (old_obj , obj ,
11734
- INTEL_FRONTBUFFER_PRIMARY (pipe ));
11735
- mutex_unlock (& dev -> struct_mutex );
11736
- if (ret != 0 ) {
11737
- DRM_DEBUG_KMS ("pin & fence failed\n" );
11738
- return ret ;
11739
- }
11740
- }
11741
-
11742
- return 0 ;
11743
- }
11744
-
11745
11768
static void
11746
11769
intel_commit_primary_plane (struct drm_plane * plane ,
11747
11770
struct intel_plane_state * state )
@@ -11843,6 +11866,7 @@ intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc,
11843
11866
uint32_t src_x , uint32_t src_y ,
11844
11867
uint32_t src_w , uint32_t src_h )
11845
11868
{
11869
+ struct drm_framebuffer * old_fb = plane -> fb ;
11846
11870
struct intel_plane_state state ;
11847
11871
struct intel_crtc * intel_crtc = to_intel_crtc (crtc );
11848
11872
int ret ;
@@ -11874,9 +11898,18 @@ intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc,
11874
11898
if (ret )
11875
11899
return ret ;
11876
11900
11877
- ret = intel_prepare_primary_plane (plane , & state );
11878
- if (ret )
11879
- return ret ;
11901
+ intel_crtc_wait_for_pending_flips (crtc );
11902
+
11903
+ if (intel_crtc_has_pending_flip (crtc )) {
11904
+ DRM_ERROR ("pipe is still busy with an old pageflip\n" );
11905
+ return - EBUSY ;
11906
+ }
11907
+
11908
+ if (fb != old_fb && fb ) {
11909
+ ret = intel_prepare_plane_fb (plane , fb );
11910
+ if (ret )
11911
+ return ret ;
11912
+ }
11880
11913
11881
11914
intel_commit_primary_plane (plane , & state );
11882
11915
@@ -12013,42 +12046,6 @@ intel_check_cursor_plane(struct drm_plane *plane,
12013
12046
return ret ;
12014
12047
}
12015
12048
12016
- static int
12017
- intel_prepare_cursor_plane (struct drm_plane * plane ,
12018
- struct intel_plane_state * state )
12019
- {
12020
- struct drm_device * dev = plane -> dev ;
12021
- struct drm_framebuffer * fb = state -> base .fb ;
12022
- struct intel_crtc * intel_crtc = to_intel_crtc (state -> base .crtc );
12023
- struct drm_i915_gem_object * obj = intel_fb_obj (fb );
12024
- struct drm_i915_gem_object * old_obj = intel_fb_obj (plane -> fb );
12025
- enum pipe pipe = intel_crtc -> pipe ;
12026
- int ret = 0 ;
12027
-
12028
- if (old_obj != obj ) {
12029
- /* we only need to pin inside GTT if cursor is non-phy */
12030
- mutex_lock (& dev -> struct_mutex );
12031
- if (!INTEL_INFO (dev )-> cursor_needs_physical ) {
12032
- if (obj )
12033
- ret = intel_pin_and_fence_fb_obj (plane , fb , NULL );
12034
- } else {
12035
- int align = IS_I830 (dev ) ? 16 * 1024 : 256 ;
12036
- if (obj )
12037
- ret = i915_gem_object_attach_phys (obj , align );
12038
- if (ret )
12039
- DRM_DEBUG_KMS ("failed to attach phys object\n" );
12040
- }
12041
-
12042
- if (ret == 0 )
12043
- i915_gem_track_fb (intel_crtc -> cursor_bo , obj ,
12044
- INTEL_FRONTBUFFER_CURSOR (pipe ));
12045
-
12046
- mutex_unlock (& dev -> struct_mutex );
12047
- }
12048
-
12049
- return ret ;
12050
- }
12051
-
12052
12049
static void
12053
12050
intel_commit_cursor_plane (struct drm_plane * plane ,
12054
12051
struct intel_plane_state * state )
@@ -12058,6 +12055,7 @@ intel_commit_cursor_plane(struct drm_plane *plane,
12058
12055
struct intel_crtc * intel_crtc = to_intel_crtc (crtc );
12059
12056
struct intel_plane * intel_plane = to_intel_plane (plane );
12060
12057
struct drm_i915_gem_object * obj = intel_fb_obj (state -> base .fb );
12058
+ struct drm_i915_gem_object * old_obj = intel_fb_obj (plane -> fb );
12061
12059
enum pipe pipe = intel_crtc -> pipe ;
12062
12060
unsigned old_width ;
12063
12061
uint32_t addr ;
@@ -12079,6 +12077,17 @@ intel_commit_cursor_plane(struct drm_plane *plane,
12079
12077
if (intel_crtc -> cursor_bo == obj )
12080
12078
goto update ;
12081
12079
12080
+ /*
12081
+ * 'prepare' is only called when fb != NULL; we still need to update
12082
+ * frontbuffer tracking for the 'disable' case here.
12083
+ */
12084
+ if (!obj ) {
12085
+ mutex_lock (& dev -> struct_mutex );
12086
+ i915_gem_track_fb (old_obj , NULL ,
12087
+ INTEL_FRONTBUFFER_CURSOR (pipe ));
12088
+ mutex_unlock (& dev -> struct_mutex );
12089
+ }
12090
+
12082
12091
if (!obj )
12083
12092
addr = 0 ;
12084
12093
else if (!INTEL_INFO (dev )-> cursor_needs_physical )
@@ -12118,6 +12127,7 @@ intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
12118
12127
uint32_t src_x , uint32_t src_y ,
12119
12128
uint32_t src_w , uint32_t src_h )
12120
12129
{
12130
+ struct drm_framebuffer * old_fb = plane -> fb ;
12121
12131
struct intel_crtc * intel_crtc = to_intel_crtc (crtc );
12122
12132
struct intel_plane_state state ;
12123
12133
int ret ;
@@ -12149,9 +12159,11 @@ intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
12149
12159
if (ret )
12150
12160
return ret ;
12151
12161
12152
- ret = intel_prepare_cursor_plane (plane , & state );
12153
- if (ret )
12154
- return ret ;
12162
+ if (fb != old_fb && fb ) {
12163
+ ret = intel_prepare_plane_fb (plane , fb );
12164
+ if (ret )
12165
+ return ret ;
12166
+ }
12155
12167
12156
12168
intel_commit_cursor_plane (plane , & state );
12157
12169
0 commit comments