@@ -1934,6 +1934,40 @@ static unsigned int intel_tile_size(const struct drm_i915_private *dev_priv)
19341934 return IS_GEN(dev_priv, 2) ? 2048 : 4096;
19351935}
19361936
1937+ static bool is_ccs_plane(const struct drm_framebuffer *fb, int plane)
1938+ {
1939+ if (!is_ccs_modifier(fb->modifier))
1940+ return false;
1941+
1942+ return plane >= fb->format->num_planes / 2;
1943+ }
1944+
1945+ static bool is_aux_plane(const struct drm_framebuffer *fb, int plane)
1946+ {
1947+ if (is_ccs_modifier(fb->modifier))
1948+ return is_ccs_plane(fb, plane);
1949+
1950+ return plane == 1;
1951+ }
1952+
1953+ static int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane)
1954+ {
1955+ WARN_ON(!is_ccs_modifier(fb->modifier) ||
1956+ (main_plane && main_plane >= fb->format->num_planes / 2));
1957+
1958+ return fb->format->num_planes / 2 + main_plane;
1959+ }
1960+
1961+ /* Return either the main plane's CCS or - if not a CCS FB - UV plane */
1962+ static int
1963+ intel_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane)
1964+ {
1965+ if (is_ccs_modifier(fb->modifier))
1966+ return main_to_ccs_plane(fb, main_plane);
1967+
1968+ return 1;
1969+ }
1970+
19371971static unsigned int
19381972intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane)
19391973{
@@ -1949,7 +1983,7 @@ intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane)
19491983 else
19501984 return 512;
19511985 case I915_FORMAT_MOD_Y_TILED_CCS:
1952- if (color_plane == 1 )
1986+ if (is_ccs_plane(fb, color_plane) )
19531987 return 128;
19541988 /* fall through */
19551989 case I915_FORMAT_MOD_Y_TILED:
@@ -1958,7 +1992,7 @@ intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane)
19581992 else
19591993 return 512;
19601994 case I915_FORMAT_MOD_Yf_TILED_CCS:
1961- if (color_plane == 1 )
1995+ if (is_ccs_plane(fb, color_plane) )
19621996 return 128;
19631997 /* fall through */
19641998 case I915_FORMAT_MOD_Yf_TILED:
@@ -2075,7 +2109,7 @@ static unsigned int intel_surf_alignment(const struct drm_framebuffer *fb,
20752109 struct drm_i915_private *dev_priv = to_i915(fb->dev);
20762110
20772111 /* AUX_DIST needs only 4K alignment */
2078- if (color_plane == 1 )
2112+ if (is_aux_plane(fb, color_plane) )
20792113 return 4096;
20802114
20812115 switch (fb->modifier) {
@@ -3461,10 +3495,11 @@ static bool skl_check_main_ccs_coordinates(struct intel_plane_state *plane_state
34613495 const struct drm_framebuffer *fb = plane_state->hw.fb;
34623496 int hsub = fb->format->hsub;
34633497 int vsub = fb->format->vsub;
3464- int aux_x = plane_state->color_plane[1].x;
3465- int aux_y = plane_state->color_plane[1].y;
3466- u32 aux_offset = plane_state->color_plane[1].offset;
3467- u32 alignment = intel_surf_alignment(fb, 1);
3498+ int ccs_plane = main_to_ccs_plane(fb, 0);
3499+ int aux_x = plane_state->color_plane[ccs_plane].x;
3500+ int aux_y = plane_state->color_plane[ccs_plane].y;
3501+ u32 aux_offset = plane_state->color_plane[ccs_plane].offset;
3502+ u32 alignment = intel_surf_alignment(fb, ccs_plane);
34683503
34693504 while (aux_offset >= main_offset && aux_y <= main_y) {
34703505 int x, y;
@@ -3477,18 +3512,22 @@ static bool skl_check_main_ccs_coordinates(struct intel_plane_state *plane_state
34773512
34783513 x = aux_x / hsub;
34793514 y = aux_y / vsub;
3480- aux_offset = intel_plane_adjust_aligned_offset(&x, &y, plane_state, 1,
3481- aux_offset, aux_offset - alignment);
3515+ aux_offset = intel_plane_adjust_aligned_offset(&x, &y,
3516+ plane_state,
3517+ ccs_plane,
3518+ aux_offset,
3519+ aux_offset -
3520+ alignment);
34823521 aux_x = x * hsub + aux_x % hsub;
34833522 aux_y = y * vsub + aux_y % vsub;
34843523 }
34853524
34863525 if (aux_x != main_x || aux_y != main_y)
34873526 return false;
34883527
3489- plane_state->color_plane[1 ].offset = aux_offset;
3490- plane_state->color_plane[1 ].x = aux_x;
3491- plane_state->color_plane[1 ].y = aux_y;
3528+ plane_state->color_plane[ccs_plane ].offset = aux_offset;
3529+ plane_state->color_plane[ccs_plane ].x = aux_x;
3530+ plane_state->color_plane[ccs_plane ].y = aux_y;
34923531
34933532 return true;
34943533}
@@ -3504,7 +3543,10 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state)
35043543 int h = drm_rect_height(&plane_state->uapi.src) >> 16;
35053544 int max_width;
35063545 int max_height;
3507- u32 alignment, offset, aux_offset = plane_state->color_plane[1].offset;
3546+ u32 alignment;
3547+ u32 offset;
3548+ int aux_plane = intel_main_to_aux_plane(fb, 0);
3549+ u32 aux_offset = plane_state->color_plane[aux_plane].offset;
35083550
35093551 if (INTEL_GEN(dev_priv) >= 11)
35103552 max_width = icl_max_plane_width(fb, 0, rotation);
@@ -3570,7 +3612,8 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state)
35703612 offset, offset - alignment);
35713613 }
35723614
3573- if (x != plane_state->color_plane[1].x || y != plane_state->color_plane[1].y) {
3615+ if (x != plane_state->color_plane[aux_plane].x ||
3616+ y != plane_state->color_plane[aux_plane].y) {
35743617 DRM_DEBUG_KMS("Unable to find suitable display surface offset due to CCS\n");
35753618 return -EINVAL;
35763619 }
0 commit comments