@@ -1272,6 +1272,32 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
12721272 intel_plane_unpin_fb (old_plane_state );
12731273}
12741274
1275+ /* Handle Y-tiling, only if DPT is enabled (otherwise disabling tiling is easier)
1276+ * All DPT hardware have 128-bytes width tiling, so Y-tile dimension is 32x32
1277+ * pixels for 32bits pixels.
1278+ */
1279+ #define YTILE_WIDTH 32
1280+ #define YTILE_HEIGHT 32
1281+ #define YTILE_SIZE (YTILE_WIDTH * YTILE_HEIGHT * 4)
1282+
1283+ static unsigned int intel_ytile_get_offset (unsigned int width , unsigned int x , unsigned int y )
1284+ {
1285+ u32 offset ;
1286+ unsigned int swizzle ;
1287+ unsigned int width_in_blocks = DIV_ROUND_UP (width , 32 );
1288+
1289+ /* Block offset */
1290+ offset = ((y / YTILE_HEIGHT ) * width_in_blocks + (x / YTILE_WIDTH )) * YTILE_SIZE ;
1291+
1292+ x = x % YTILE_WIDTH ;
1293+ y = y % YTILE_HEIGHT ;
1294+
1295+ /* bit order inside a block is x4 x3 x2 y4 y3 y2 y1 y0 x1 x0 */
1296+ swizzle = (x & 3 ) | ((y & 0x1f ) << 2 ) | ((x & 0x1c ) << 5 );
1297+ offset += swizzle * 4 ;
1298+ return offset ;
1299+ }
1300+
12751301static void intel_panic_flush (struct drm_plane * plane )
12761302{
12771303 struct intel_plane_state * plane_state = to_intel_plane_state (plane -> state );
@@ -1295,6 +1321,35 @@ static void intel_panic_flush(struct drm_plane *plane)
12951321 iplane -> disable_tiling (iplane );
12961322}
12971323
1324+ static unsigned int (* intel_get_tiling_func (u64 fb_modifier ))(unsigned int width ,
1325+ unsigned int x ,
1326+ unsigned int y )
1327+ {
1328+ switch (fb_modifier ) {
1329+ case I915_FORMAT_MOD_Y_TILED :
1330+ case I915_FORMAT_MOD_Y_TILED_CCS :
1331+ case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC :
1332+ case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS :
1333+ case I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS :
1334+ return intel_ytile_get_offset ;
1335+ case I915_FORMAT_MOD_4_TILED :
1336+ case I915_FORMAT_MOD_4_TILED_DG2_RC_CCS :
1337+ case I915_FORMAT_MOD_4_TILED_DG2_MC_CCS :
1338+ case I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC :
1339+ case I915_FORMAT_MOD_4_TILED_MTL_RC_CCS :
1340+ case I915_FORMAT_MOD_4_TILED_MTL_RC_CCS_CC :
1341+ case I915_FORMAT_MOD_4_TILED_MTL_MC_CCS :
1342+ case I915_FORMAT_MOD_4_TILED_BMG_CCS :
1343+ case I915_FORMAT_MOD_4_TILED_LNL_CCS :
1344+ case I915_FORMAT_MOD_X_TILED :
1345+ case I915_FORMAT_MOD_Yf_TILED :
1346+ case I915_FORMAT_MOD_Yf_TILED_CCS :
1347+ default :
1348+ /* Not supported yet */
1349+ return NULL ;
1350+ }
1351+ }
1352+
12981353static int intel_get_scanout_buffer (struct drm_plane * plane ,
12991354 struct drm_scanout_buffer * sb )
13001355{
@@ -1320,8 +1375,13 @@ static int intel_get_scanout_buffer(struct drm_plane *plane,
13201375 } else {
13211376 int ret ;
13221377 /* Can't disable tiling if DPT is in use */
1323- if (intel_fb_uses_dpt (fb ))
1324- return - EOPNOTSUPP ;
1378+ if (intel_fb_uses_dpt (fb )) {
1379+ if (fb -> format -> cpp [0 ] != 4 )
1380+ return - EOPNOTSUPP ;
1381+ intel_fb -> panic_tiling = intel_get_tiling_func (fb -> modifier );
1382+ if (!intel_fb -> panic_tiling )
1383+ return - EOPNOTSUPP ;
1384+ }
13251385 sb -> private = intel_fb ;
13261386 ret = intel_bo_panic_setup (sb );
13271387 if (ret )
0 commit comments