Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/fbc: dirty rect support for FBC

Dirty rectangle feature allows FBC to recompress a subsection
of a frame. When this feature is enabled, display will read
the scan lines between dirty rectangle start line and dirty
rectangle end line in subsequent frames.

Use the merged damage clip stored in the plane state to
configure the FBC dirty rect areas.

v2: - Move dirty rect handling to fbc state (Ville)

v3: - Use intel_fbc_dirty_rect_update_noarm (Ville)
- Split plane damage collection and dirty rect preparation
- Handle case where dirty rect fall outside the visible region

v4: - A state variable to check if we need to update dirty rect
registers in case intel_fbc_can_flip_nuke() (Ville)

v5: - No need to use a separate valid flag, updates to the
conditions for prepare damage rect (Ville)
- Usage of locks in fbc dirty rect related functions (Ville)

v6: - updates dirty rect handling (Ville)

v7: - Loop through all planes in atomic state is good enough (Ville)

Bspec: 68881, 71675, 73424
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
Signed-off-by: Mika Kahola <mika.kahola@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250228093802.27091-8-vinod.govindapillai@intel.com

authored by

Vinod Govindapillai and committed by
Mika Kahola
194ecad0 5adac4c9

+93
+3
drivers/gpu/drm/i915/display/intel_atomic_plane.c
··· 818 818 819 819 trace_intel_plane_update_noarm(plane_state, crtc); 820 820 821 + if (plane->fbc) 822 + intel_fbc_dirty_rect_update_noarm(dsb, plane); 823 + 821 824 if (plane->update_noarm) 822 825 plane->update_noarm(dsb, plane, crtc_state, plane_state); 823 826 }
+2
drivers/gpu/drm/i915/display/intel_display.c
··· 7272 7272 7273 7273 intel_atomic_prepare_plane_clear_colors(state); 7274 7274 7275 + intel_fbc_prepare_dirty_rect(state); 7276 + 7275 7277 for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) 7276 7278 intel_atomic_dsb_finish(state, crtc); 7277 7279
+84
drivers/gpu/drm/i915/display/intel_fbc.c
··· 88 88 u16 override_cfb_stride; 89 89 u16 interval; 90 90 s8 fence_id; 91 + struct drm_rect dirty_rect; 91 92 }; 92 93 93 94 struct intel_fbc { ··· 524 523 struct intel_display *display = fbc->display; 525 524 u32 dpfc_ctl; 526 525 526 + if (HAS_FBC_DIRTY_RECT(display)) 527 + intel_de_write(display, XE3_FBC_DIRTY_CTL(fbc->id), 0); 528 + 527 529 /* Disable compression */ 528 530 dpfc_ctl = intel_de_read(display, ILK_DPFC_CONTROL(fbc->id)); 529 531 if (dpfc_ctl & DPFC_CTL_EN) { ··· 668 664 dpfc_ctl = ivb_dpfc_ctl(fbc); 669 665 if (DISPLAY_VER(display) >= 20) 670 666 intel_de_write(display, ILK_DPFC_CONTROL(fbc->id), dpfc_ctl); 667 + 668 + if (HAS_FBC_DIRTY_RECT(display)) 669 + intel_de_write(display, XE3_FBC_DIRTY_CTL(fbc->id), 670 + FBC_DIRTY_RECT_EN); 671 671 672 672 intel_de_write(display, ILK_DPFC_CONTROL(fbc->id), 673 673 DPFC_CTL_EN | dpfc_ctl); ··· 1202 1194 return skl_fbc_tiling_valid(plane_state); 1203 1195 else 1204 1196 return i8xx_fbc_tiling_valid(plane_state); 1197 + } 1198 + 1199 + static void 1200 + intel_fbc_dirty_rect_update(struct intel_dsb *dsb, struct intel_fbc *fbc) 1201 + { 1202 + struct intel_display *display = fbc->display; 1203 + const struct drm_rect *fbc_dirty_rect = &fbc->state.dirty_rect; 1204 + 1205 + lockdep_assert_held(&fbc->lock); 1206 + 1207 + intel_de_write_dsb(display, dsb, XE3_FBC_DIRTY_RECT(fbc->id), 1208 + FBC_DIRTY_RECT_START_LINE(fbc_dirty_rect->y1) | 1209 + FBC_DIRTY_RECT_END_LINE(fbc_dirty_rect->y2 - 1)); 1210 + } 1211 + 1212 + void 1213 + intel_fbc_dirty_rect_update_noarm(struct intel_dsb *dsb, 1214 + struct intel_plane *plane) 1215 + { 1216 + struct intel_display *display = to_intel_display(plane); 1217 + struct intel_fbc *fbc = plane->fbc; 1218 + 1219 + if (!HAS_FBC_DIRTY_RECT(display)) 1220 + return; 1221 + 1222 + mutex_lock(&fbc->lock); 1223 + 1224 + if (fbc->state.plane == plane) 1225 + intel_fbc_dirty_rect_update(dsb, fbc); 1226 + 1227 + mutex_unlock(&fbc->lock); 1228 + } 1229 + 1230 + static void 1231 + __intel_fbc_prepare_dirty_rect(const struct intel_plane_state *plane_state) 1232 + { 1233 + struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 1234 + struct intel_fbc *fbc = plane->fbc; 1235 + struct drm_rect *fbc_dirty_rect = &fbc->state.dirty_rect; 1236 + int width = drm_rect_width(&plane_state->uapi.src) >> 16; 1237 + const struct drm_rect *damage = &plane_state->damage; 1238 + int y_offset = plane_state->view.color_plane[0].y; 1239 + 1240 + lockdep_assert_held(&fbc->lock); 1241 + 1242 + if (drm_rect_visible(damage)) 1243 + *fbc_dirty_rect = *damage; 1244 + else 1245 + /* dirty rect must cover at least one line */ 1246 + *fbc_dirty_rect = DRM_RECT_INIT(0, y_offset, width, 1); 1247 + } 1248 + 1249 + void 1250 + intel_fbc_prepare_dirty_rect(struct intel_atomic_state *state) 1251 + { 1252 + struct intel_display *display = to_intel_display(state); 1253 + struct intel_plane_state *plane_state; 1254 + struct intel_plane *plane; 1255 + int i; 1256 + 1257 + if (!HAS_FBC_DIRTY_RECT(display)) 1258 + return; 1259 + 1260 + for_each_new_intel_plane_in_state(state, plane, plane_state, i) { 1261 + struct intel_fbc *fbc = plane->fbc; 1262 + 1263 + if (!fbc) 1264 + continue; 1265 + 1266 + mutex_lock(&fbc->lock); 1267 + 1268 + if (fbc->state.plane == plane) 1269 + __intel_fbc_prepare_dirty_rect(plane_state); 1270 + 1271 + mutex_unlock(&fbc->lock); 1272 + } 1205 1273 } 1206 1274 1207 1275 static void intel_fbc_update_state(struct intel_atomic_state *state,
+4
drivers/gpu/drm/i915/display/intel_fbc.h
··· 13 13 struct intel_crtc; 14 14 struct intel_crtc_state; 15 15 struct intel_display; 16 + struct intel_dsb; 16 17 struct intel_fbc; 17 18 struct intel_plane; 18 19 struct intel_plane_state; ··· 48 47 void intel_fbc_reset_underrun(struct intel_display *display); 49 48 void intel_fbc_crtc_debugfs_add(struct intel_crtc *crtc); 50 49 void intel_fbc_debugfs_register(struct intel_display *display); 50 + void intel_fbc_prepare_dirty_rect(struct intel_atomic_state *state); 51 + void intel_fbc_dirty_rect_update_noarm(struct intel_dsb *dsb, 52 + struct intel_plane *plane); 51 53 52 54 #endif /* __INTEL_FBC_H__ */