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

drm/i915: Finish intel_sprite.c struct intel_display conversion

intel_sprite.c was partially converted to struct intel_display.
Finish the job now that we can deal with the platform checks
as well.

And while at it we also move the 'display' variable declaration
to be the first thing in most functions, consistency. We can
actually do that now since intel_display() accepts the intel_plane
and intel_plane_state types.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250206185533.32306-9-ville.syrjala@linux.intel.com

+43 -56
+1 -1
drivers/gpu/drm/i915/display/intel_crtc.c
··· 336 336 if (DISPLAY_VER(dev_priv) >= 9) 337 337 plane = skl_universal_plane_create(dev_priv, pipe, PLANE_2 + sprite); 338 338 else 339 - plane = intel_sprite_plane_create(dev_priv, pipe, sprite); 339 + plane = intel_sprite_plane_create(display, pipe, sprite); 340 340 if (IS_ERR(plane)) { 341 341 ret = PTR_ERR(plane); 342 342 goto fail;
+39 -52
drivers/gpu/drm/i915/display/intel_sprite.c
··· 66 66 static void 67 67 chv_sprite_update_csc(const struct intel_plane_state *plane_state) 68 68 { 69 + struct intel_display *display = to_intel_display(plane_state); 69 70 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 70 - struct intel_display *display = to_intel_display(plane->base.dev); 71 71 const struct drm_framebuffer *fb = plane_state->hw.fb; 72 72 enum plane_id plane_id = plane->id; 73 73 /* ··· 138 138 static void 139 139 vlv_sprite_update_clrc(const struct intel_plane_state *plane_state) 140 140 { 141 + struct intel_display *display = to_intel_display(plane_state); 141 142 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 142 - struct intel_display *display = to_intel_display(plane->base.dev); 143 143 const struct drm_framebuffer *fb = plane_state->hw.fb; 144 144 enum pipe pipe = plane->pipe; 145 145 enum plane_id plane_id = plane->id; ··· 341 341 342 342 static void vlv_sprite_update_gamma(const struct intel_plane_state *plane_state) 343 343 { 344 + struct intel_display *display = to_intel_display(plane_state); 344 345 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 345 - struct intel_display *display = to_intel_display(plane->base.dev); 346 346 const struct drm_framebuffer *fb = plane_state->hw.fb; 347 347 enum pipe pipe = plane->pipe; 348 348 enum plane_id plane_id = plane->id; ··· 368 368 const struct intel_crtc_state *crtc_state, 369 369 const struct intel_plane_state *plane_state) 370 370 { 371 - struct intel_display *display = to_intel_display(plane->base.dev); 371 + struct intel_display *display = to_intel_display(plane); 372 372 enum pipe pipe = plane->pipe; 373 373 enum plane_id plane_id = plane->id; 374 374 int crtc_x = plane_state->uapi.dst.x1; ··· 390 390 const struct intel_crtc_state *crtc_state, 391 391 const struct intel_plane_state *plane_state) 392 392 { 393 - struct intel_display *display = to_intel_display(plane->base.dev); 394 - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 393 + struct intel_display *display = to_intel_display(plane); 395 394 enum pipe pipe = plane->pipe; 396 395 enum plane_id plane_id = plane->id; 397 396 const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; ··· 403 404 404 405 linear_offset = intel_fb_xy_to_linear(x, y, plane_state, 0); 405 406 406 - if (IS_CHERRYVIEW(dev_priv) && pipe == PIPE_B) 407 + if (display->platform.cherryview && pipe == PIPE_B) 407 408 chv_sprite_update_csc(plane_state); 408 409 409 410 if (key->flags) { ··· 439 440 struct intel_plane *plane, 440 441 const struct intel_crtc_state *crtc_state) 441 442 { 442 - struct intel_display *display = to_intel_display(plane->base.dev); 443 + struct intel_display *display = to_intel_display(plane); 443 444 enum pipe pipe = plane->pipe; 444 445 enum plane_id plane_id = plane->id; 445 446 ··· 644 645 645 646 static bool ivb_need_sprite_gamma(const struct intel_plane_state *plane_state) 646 647 { 647 - struct drm_i915_private *dev_priv = 648 - to_i915(plane_state->uapi.plane->dev); 648 + struct intel_display *display = to_intel_display(plane_state); 649 649 const struct drm_framebuffer *fb = plane_state->hw.fb; 650 650 651 651 return fb->format->cpp[0] == 8 && 652 - (IS_IVYBRIDGE(dev_priv) || IS_HASWELL(dev_priv)); 652 + (display->platform.ivybridge || display->platform.haswell); 653 653 } 654 654 655 655 static u32 ivb_sprite_ctl(const struct intel_crtc_state *crtc_state, 656 656 const struct intel_plane_state *plane_state) 657 657 { 658 - struct drm_i915_private *dev_priv = 659 - to_i915(plane_state->uapi.plane->dev); 658 + struct intel_display *display = to_intel_display(plane_state); 660 659 const struct drm_framebuffer *fb = plane_state->hw.fb; 661 660 unsigned int rotation = plane_state->hw.rotation; 662 661 const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; ··· 662 665 663 666 sprctl = SPRITE_ENABLE; 664 667 665 - if (IS_IVYBRIDGE(dev_priv)) 668 + if (display->platform.ivybridge) 666 669 sprctl |= SPRITE_TRICKLE_FEED_DISABLE; 667 670 668 671 switch (fb->format->format) { ··· 751 754 752 755 static void ivb_sprite_update_gamma(const struct intel_plane_state *plane_state) 753 756 { 757 + struct intel_display *display = to_intel_display(plane_state); 754 758 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 755 - struct intel_display *display = to_intel_display(plane->base.dev); 756 759 enum pipe pipe = plane->pipe; 757 760 u16 gamma[18]; 758 761 int i; ··· 784 787 const struct intel_crtc_state *crtc_state, 785 788 const struct intel_plane_state *plane_state) 786 789 { 787 - struct intel_display *display = to_intel_display(plane->base.dev); 788 - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 790 + struct intel_display *display = to_intel_display(plane); 789 791 enum pipe pipe = plane->pipe; 790 792 int crtc_x = plane_state->uapi.dst.x1; 791 793 int crtc_y = plane_state->uapi.dst.y1; ··· 805 809 SPRITE_POS_Y(crtc_y) | SPRITE_POS_X(crtc_x)); 806 810 intel_de_write_fw(display, SPRSIZE(pipe), 807 811 SPRITE_HEIGHT(crtc_h - 1) | SPRITE_WIDTH(crtc_w - 1)); 808 - if (IS_IVYBRIDGE(dev_priv)) 812 + if (display->platform.ivybridge) 809 813 intel_de_write_fw(display, SPRSCALE(pipe), sprscale); 810 814 } 811 815 ··· 815 819 const struct intel_crtc_state *crtc_state, 816 820 const struct intel_plane_state *plane_state) 817 821 { 818 - struct intel_display *display = to_intel_display(plane->base.dev); 819 - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 822 + struct intel_display *display = to_intel_display(plane); 820 823 enum pipe pipe = plane->pipe; 821 824 const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; 822 825 u32 sprsurf_offset = plane_state->view.color_plane[0].offset; ··· 836 841 837 842 /* HSW consolidates SPRTILEOFF and SPRLINOFF into a single SPROFFSET 838 843 * register */ 839 - if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { 844 + if (display->platform.haswell || display->platform.broadwell) { 840 845 intel_de_write_fw(display, SPROFFSET(pipe), 841 846 SPRITE_OFFSET_Y(y) | SPRITE_OFFSET_X(x)); 842 847 } else { ··· 862 867 struct intel_plane *plane, 863 868 const struct intel_crtc_state *crtc_state) 864 869 { 865 - struct intel_display *display = to_intel_display(plane->base.dev); 866 - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 870 + struct intel_display *display = to_intel_display(plane); 867 871 enum pipe pipe = plane->pipe; 868 872 869 873 intel_de_write_fw(display, SPRCTL(pipe), 0); 870 874 /* Disable the scaler */ 871 - if (IS_IVYBRIDGE(dev_priv)) 875 + if (display->platform.ivybridge) 872 876 intel_de_write_fw(display, SPRSCALE(pipe), 0); 873 877 intel_de_write_fw(display, SPRSURF(pipe), 0); 874 878 } ··· 876 882 ivb_sprite_get_hw_state(struct intel_plane *plane, 877 883 enum pipe *pipe) 878 884 { 879 - struct intel_display *display = to_intel_display(plane->base.dev); 885 + struct intel_display *display = to_intel_display(plane); 880 886 enum intel_display_power_domain power_domain; 881 887 intel_wakeref_t wakeref; 882 888 bool ret; ··· 996 1002 static u32 g4x_sprite_ctl(const struct intel_crtc_state *crtc_state, 997 1003 const struct intel_plane_state *plane_state) 998 1004 { 999 - struct drm_i915_private *dev_priv = 1000 - to_i915(plane_state->uapi.plane->dev); 1005 + struct intel_display *display = to_intel_display(plane_state); 1001 1006 const struct drm_framebuffer *fb = plane_state->hw.fb; 1002 1007 unsigned int rotation = plane_state->hw.rotation; 1003 1008 const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; ··· 1004 1011 1005 1012 dvscntr = DVS_ENABLE; 1006 1013 1007 - if (IS_SANDYBRIDGE(dev_priv)) 1014 + if (display->platform.sandybridge) 1008 1015 dvscntr |= DVS_TRICKLE_FEED_DISABLE; 1009 1016 1010 1017 switch (fb->format->format) { ··· 1065 1072 1066 1073 static void g4x_sprite_update_gamma(const struct intel_plane_state *plane_state) 1067 1074 { 1075 + struct intel_display *display = to_intel_display(plane_state); 1068 1076 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 1069 - struct intel_display *display = to_intel_display(plane->base.dev); 1070 1077 const struct drm_framebuffer *fb = plane_state->hw.fb; 1071 1078 enum pipe pipe = plane->pipe; 1072 1079 u16 gamma[8]; ··· 1095 1102 1096 1103 static void ilk_sprite_update_gamma(const struct intel_plane_state *plane_state) 1097 1104 { 1105 + struct intel_display *display = to_intel_display(plane_state); 1098 1106 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 1099 - struct intel_display *display = to_intel_display(plane->base.dev); 1100 1107 const struct drm_framebuffer *fb = plane_state->hw.fb; 1101 1108 enum pipe pipe = plane->pipe; 1102 1109 u16 gamma[17]; ··· 1125 1132 const struct intel_crtc_state *crtc_state, 1126 1133 const struct intel_plane_state *plane_state) 1127 1134 { 1128 - struct intel_display *display = to_intel_display(plane->base.dev); 1135 + struct intel_display *display = to_intel_display(plane); 1129 1136 enum pipe pipe = plane->pipe; 1130 1137 int crtc_x = plane_state->uapi.dst.x1; 1131 1138 int crtc_y = plane_state->uapi.dst.y1; ··· 1155 1162 const struct intel_crtc_state *crtc_state, 1156 1163 const struct intel_plane_state *plane_state) 1157 1164 { 1158 - struct intel_display *display = to_intel_display(plane->base.dev); 1159 - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 1165 + struct intel_display *display = to_intel_display(plane); 1160 1166 enum pipe pipe = plane->pipe; 1161 1167 const struct drm_intel_sprite_colorkey *key = &plane_state->ckey; 1162 1168 u32 dvssurf_offset = plane_state->view.color_plane[0].offset; ··· 1187 1195 intel_de_write_fw(display, DVSSURF(pipe), 1188 1196 intel_plane_ggtt_offset(plane_state) + dvssurf_offset); 1189 1197 1190 - if (IS_G4X(dev_priv)) 1198 + if (display->platform.g4x) 1191 1199 g4x_sprite_update_gamma(plane_state); 1192 1200 else 1193 1201 ilk_sprite_update_gamma(plane_state); ··· 1198 1206 struct intel_plane *plane, 1199 1207 const struct intel_crtc_state *crtc_state) 1200 1208 { 1201 - struct intel_display *display = to_intel_display(plane->base.dev); 1209 + struct intel_display *display = to_intel_display(plane); 1202 1210 enum pipe pipe = plane->pipe; 1203 1211 1204 1212 intel_de_write_fw(display, DVSCNTR(pipe), 0); ··· 1211 1219 g4x_sprite_get_hw_state(struct intel_plane *plane, 1212 1220 enum pipe *pipe) 1213 1221 { 1214 - struct intel_display *display = to_intel_display(plane->base.dev); 1222 + struct intel_display *display = to_intel_display(plane); 1215 1223 enum intel_display_power_domain power_domain; 1216 1224 intel_wakeref_t wakeref; 1217 1225 bool ret; ··· 1251 1259 g4x_sprite_check_scaling(struct intel_crtc_state *crtc_state, 1252 1260 struct intel_plane_state *plane_state) 1253 1261 { 1254 - struct intel_display *display = to_intel_display(crtc_state); 1262 + struct intel_display *display = to_intel_display(plane_state); 1255 1263 const struct drm_framebuffer *fb = plane_state->hw.fb; 1256 1264 const struct drm_rect *src = &plane_state->uapi.src; 1257 1265 const struct drm_rect *dst = &plane_state->uapi.dst; ··· 1317 1325 g4x_sprite_check(struct intel_crtc_state *crtc_state, 1318 1326 struct intel_plane_state *plane_state) 1319 1327 { 1320 - struct intel_display *display = to_intel_display(crtc_state); 1321 - struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 1322 - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 1328 + struct intel_display *display = to_intel_display(plane_state); 1323 1329 int min_scale = DRM_PLANE_NO_SCALING; 1324 1330 int max_scale = DRM_PLANE_NO_SCALING; 1325 1331 int ret; ··· 1326 1336 if (DISPLAY_VER(display) < 7) { 1327 1337 min_scale = 1; 1328 1338 max_scale = 16 << 16; 1329 - } else if (IS_IVYBRIDGE(dev_priv)) { 1339 + } else if (display->platform.ivybridge) { 1330 1340 min_scale = 1; 1331 1341 max_scale = 2 << 16; 1332 1342 } ··· 1362 1372 1363 1373 int chv_plane_check_rotation(const struct intel_plane_state *plane_state) 1364 1374 { 1365 - struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 1366 - struct intel_display *display = to_intel_display(plane->base.dev); 1367 - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 1375 + struct intel_display *display = to_intel_display(plane_state); 1368 1376 unsigned int rotation = plane_state->hw.rotation; 1369 1377 1370 1378 /* CHV ignores the mirror bit when the rotate bit is set :( */ 1371 - if (IS_CHERRYVIEW(dev_priv) && 1379 + if (display->platform.cherryview && 1372 1380 rotation & DRM_MODE_ROTATE_180 && 1373 1381 rotation & DRM_MODE_REFLECT_X) { 1374 1382 drm_dbg_kms(display->drm, ··· 1568 1580 }; 1569 1581 1570 1582 struct intel_plane * 1571 - intel_sprite_plane_create(struct drm_i915_private *dev_priv, 1583 + intel_sprite_plane_create(struct intel_display *display, 1572 1584 enum pipe pipe, int sprite) 1573 1585 { 1574 - struct intel_display *display = &dev_priv->display; 1575 1586 struct intel_plane *plane; 1576 1587 const struct drm_plane_funcs *plane_funcs; 1577 1588 unsigned int supported_rotations; ··· 1583 1596 if (IS_ERR(plane)) 1584 1597 return plane; 1585 1598 1586 - if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { 1599 + if (display->platform.valleyview || display->platform.cherryview) { 1587 1600 plane->update_noarm = vlv_sprite_update_noarm; 1588 1601 plane->update_arm = vlv_sprite_update_arm; 1589 1602 plane->disable_arm = vlv_sprite_disable_arm; ··· 1597 1610 if (intel_scanout_needs_vtd_wa(display)) 1598 1611 plane->vtd_guard = 128; 1599 1612 1600 - if (IS_CHERRYVIEW(dev_priv) && pipe == PIPE_B) { 1613 + if (display->platform.cherryview && pipe == PIPE_B) { 1601 1614 formats = chv_pipe_b_sprite_formats; 1602 1615 num_formats = ARRAY_SIZE(chv_pipe_b_sprite_formats); 1603 1616 } else { ··· 1613 1626 plane->get_hw_state = ivb_sprite_get_hw_state; 1614 1627 plane->check_plane = g4x_sprite_check; 1615 1628 1616 - if (IS_BROADWELL(dev_priv) || IS_HASWELL(dev_priv)) { 1629 + if (display->platform.broadwell || display->platform.haswell) { 1617 1630 plane->max_stride = hsw_sprite_max_stride; 1618 1631 plane->min_cdclk = hsw_plane_min_cdclk; 1619 1632 } else { ··· 1643 1656 if (intel_scanout_needs_vtd_wa(display)) 1644 1657 plane->vtd_guard = 64; 1645 1658 1646 - if (IS_SANDYBRIDGE(dev_priv)) { 1659 + if (display->platform.sandybridge) { 1647 1660 formats = snb_sprite_formats; 1648 1661 num_formats = ARRAY_SIZE(snb_sprite_formats); 1649 1662 ··· 1656 1669 } 1657 1670 } 1658 1671 1659 - if (IS_CHERRYVIEW(dev_priv) && pipe == PIPE_B) { 1672 + if (display->platform.cherryview && pipe == PIPE_B) { 1660 1673 supported_rotations = 1661 1674 DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_180 | 1662 1675 DRM_MODE_REFLECT_X;
+3 -3
drivers/gpu/drm/i915/display/intel_sprite.h
··· 8 8 9 9 #include <linux/types.h> 10 10 11 - struct drm_i915_private; 12 11 struct intel_crtc_state; 12 + struct intel_display; 13 13 struct intel_plane_state; 14 14 enum pipe; 15 15 16 16 #ifdef I915 17 - struct intel_plane *intel_sprite_plane_create(struct drm_i915_private *dev_priv, 17 + struct intel_plane *intel_sprite_plane_create(struct intel_display *display, 18 18 enum pipe pipe, int plane); 19 19 int intel_plane_check_src_coordinates(struct intel_plane_state *plane_state); 20 20 int chv_plane_check_rotation(const struct intel_plane_state *plane_state); ··· 26 26 int vlv_plane_min_cdclk(const struct intel_crtc_state *crtc_state, 27 27 const struct intel_plane_state *plane_state); 28 28 #else 29 - static inline struct intel_plane *intel_sprite_plane_create(struct drm_i915_private *dev_priv, 29 + static inline struct intel_plane *intel_sprite_plane_create(struct intel_display *display, 30 30 int pipe, int plane) 31 31 { 32 32 return NULL;