All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Subject: [PATCH 37/39] drm/i915/tgl: Gen-12 render decompression
Date: Fri, 16 Aug 2019 01:05:01 -0700	[thread overview]
Message-ID: <20190816080503.28594-38-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20190816080503.28594-1-lucas.demarchi@intel.com>

From: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>

Gen-12 decompression is supported with Y-tiled main surface. The CCS is
linear and has 4 bits of data for each main surface cache line pair, a
ratio of 1:256. Gen-12 display decompression is incompatible with buffers
compressed by earlier GPUs, so make use of a new modifier to identify
gen-12 compression. Another notable change is that decompression is
supported on all planes except cursor and on all pipes. This patch adds
decompression support for [A,X]BGR888 pixel formats.

Bspec: Render Decompression (18437)

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 63 +++++++++++++++++---
 drivers/gpu/drm/i915/display/intel_sprite.c  | 23 ++++---
 2 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 81c1d359edb2..89067a9f4a3c 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -1928,6 +1928,10 @@ intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane)
 		if (color_plane == 1)
 			return 128;
 		/* fall through */
+	case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS:
+		if (color_plane == 1)
+			return cpp;
+		/* fall through */
 	case I915_FORMAT_MOD_Y_TILED:
 		if (IS_GEN(dev_priv, 2) || HAS_128_BYTE_Y_TILING(dev_priv))
 			return 128;
@@ -2061,6 +2065,8 @@ static unsigned int intel_surf_alignment(const struct drm_framebuffer *fb,
 		if (INTEL_GEN(dev_priv) >= 9)
 			return 256 * 1024;
 		return 0;
+	case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS:
+		return 4 * 4 * 1024;
 	case I915_FORMAT_MOD_Y_TILED_CCS:
 	case I915_FORMAT_MOD_Yf_TILED_CCS:
 	case I915_FORMAT_MOD_Y_TILED:
@@ -2258,7 +2264,8 @@ static u32 intel_adjust_tile_offset(int *x, int *y,
 
 static bool is_surface_linear(u64 modifier, int color_plane)
 {
-	return modifier == DRM_FORMAT_MOD_LINEAR;
+	return modifier == DRM_FORMAT_MOD_LINEAR ||
+	       (modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS && color_plane == 1);
 }
 
 static u32 intel_adjust_aligned_offset(int *x, int *y,
@@ -2445,6 +2452,7 @@ static unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier)
 		return I915_TILING_X;
 	case I915_FORMAT_MOD_Y_TILED:
 	case I915_FORMAT_MOD_Y_TILED_CCS:
+	case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS:
 		return I915_TILING_Y;
 	default:
 		return I915_TILING_NONE;
@@ -2465,7 +2473,7 @@ static unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier)
  * us a ratio of one byte in the CCS for each 8x16 pixels in the
  * main surface.
  */
-static const struct drm_format_info ccs_formats[] = {
+static const struct drm_format_info skl_ccs_formats[] = {
 	{ .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2,
 	  .cpp = { 4, 1, }, .hsub = 8, .vsub = 16, },
 	{ .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2,
@@ -2476,6 +2484,24 @@ static const struct drm_format_info ccs_formats[] = {
 	  .cpp = { 4, 1, }, .hsub = 8, .vsub = 16, .has_alpha = true, },
 };
 
+/*
+ * Gen-12 compression uses 4 bits of CCS data for each cache line pair in the
+ * main surface. And each 64B CCS cache line represents an area of 4x1 Y-tiles
+ * in the main surface. With 4 byte pixels and each Y-tile having dimensions of
+ * 32x32 pixels, the ratio turns out to 1B in the CCS for every 2 x 32 pixels in
+ * the main surface.
+ */
+static const struct drm_format_info gen12_ccs_formats[] = {
+	{ .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 2,
+	  .cpp = { 4, 1, }, .hsub = 2, .vsub = 32, },
+	{ .format = DRM_FORMAT_XBGR8888, .depth = 24, .num_planes = 2,
+	  .cpp = { 4, 1, }, .hsub = 2, .vsub = 32, },
+	{ .format = DRM_FORMAT_ARGB8888, .depth = 32, .num_planes = 2,
+	  .cpp = { 4, 1, }, .hsub = 2, .vsub = 32, .has_alpha = true },
+	{ .format = DRM_FORMAT_ABGR8888, .depth = 32, .num_planes = 2,
+	  .cpp = { 4, 1, }, .hsub = 2, .vsub = 32, .has_alpha = true },
+};
+
 static const struct drm_format_info *
 lookup_format_info(const struct drm_format_info formats[],
 		   int num_formats, u32 format)
@@ -2496,8 +2522,12 @@ intel_get_format_info(const struct drm_mode_fb_cmd2 *cmd)
 	switch (cmd->modifier[0]) {
 	case I915_FORMAT_MOD_Y_TILED_CCS:
 	case I915_FORMAT_MOD_Yf_TILED_CCS:
-		return lookup_format_info(ccs_formats,
-					  ARRAY_SIZE(ccs_formats),
+		return lookup_format_info(skl_ccs_formats,
+					  ARRAY_SIZE(skl_ccs_formats),
+					  cmd->pixel_format);
+	case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS:
+		return lookup_format_info(gen12_ccs_formats,
+					  ARRAY_SIZE(gen12_ccs_formats),
 					  cmd->pixel_format);
 	default:
 		return NULL;
@@ -2506,7 +2536,8 @@ intel_get_format_info(const struct drm_mode_fb_cmd2 *cmd)
 
 bool is_ccs_modifier(u64 modifier)
 {
-	return modifier == I915_FORMAT_MOD_Y_TILED_CCS ||
+	return modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS ||
+	       modifier == I915_FORMAT_MOD_Y_TILED_CCS ||
 	       modifier == I915_FORMAT_MOD_Yf_TILED_CCS;
 }
 
@@ -2675,7 +2706,13 @@ intel_fill_fb_info(struct drm_i915_private *dev_priv,
 			int main_x, main_y;
 			int ccs_x, ccs_y;
 
-			intel_tile_dims(fb, i, &tile_width, &tile_height);
+			if (!is_surface_linear(fb->modifier, i)) {
+				intel_tile_dims(fb, i, &tile_width, &tile_height);
+			} else {
+				tile_width = 64/cpp;
+				tile_height = 1;
+			}
+
 			tile_width *= hsub;
 			tile_height *= vsub;
 
@@ -4065,6 +4102,8 @@ static u32 skl_plane_ctl_tiling(u64 fb_modifier)
 	case I915_FORMAT_MOD_Y_TILED:
 		return PLANE_CTL_TILED_Y;
 	case I915_FORMAT_MOD_Y_TILED_CCS:
+		/* fall through */
+	case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS:
 		return PLANE_CTL_TILED_Y | PLANE_CTL_RENDER_DECOMPRESSION_ENABLE;
 	case I915_FORMAT_MOD_Yf_TILED:
 		return PLANE_CTL_TILED_YF;
@@ -9844,7 +9883,9 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
 	case PLANE_CTL_TILED_Y:
 		plane_config->tiling = I915_TILING_Y;
 		if (val & PLANE_CTL_RENDER_DECOMPRESSION_ENABLE)
-			fb->modifier = I915_FORMAT_MOD_Y_TILED_CCS;
+			fb->modifier = INTEL_GEN(dev_priv) >= 12 ?
+				I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS :
+				I915_FORMAT_MOD_Y_TILED_CCS;
 		else
 			fb->modifier = I915_FORMAT_MOD_Y_TILED;
 		break;
@@ -15716,6 +15757,14 @@ static int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
 		    is_ccs_modifier(fb->modifier))
 			stride_alignment *= 4;
 
+		/*
+		 * The main surface pitch must be paded to a multiple of four
+		 * tile widths.
+		 */
+		if (fb->modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS &&
+		    i == 0)
+			stride_alignment *= 4;
+
 		if (fb->pitches[i] & (stride_alignment - 1)) {
 			DRM_DEBUG_KMS("plane %d pitch (%d) must be at least %u byte aligned\n",
 				      i, fb->pitches[i], stride_alignment);
diff --git a/drivers/gpu/drm/i915/display/intel_sprite.c b/drivers/gpu/drm/i915/display/intel_sprite.c
index 71dae3c2f9db..73d32017be89 100644
--- a/drivers/gpu/drm/i915/display/intel_sprite.c
+++ b/drivers/gpu/drm/i915/display/intel_sprite.c
@@ -547,6 +547,7 @@ skl_program_plane(struct intel_plane *plane,
 	const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;
 	u32 surf_addr = plane_state->color_plane[color_plane].offset;
 	u32 stride = skl_plane_stride(plane_state, color_plane);
+	u32 aux_dist = plane_state->color_plane[1].offset - surf_addr;
 	u32 aux_stride = skl_plane_stride(plane_state, 1);
 	int crtc_x = plane_state->base.dst.x1;
 	int crtc_y = plane_state->base.dst.y1;
@@ -588,8 +589,10 @@ skl_program_plane(struct intel_plane *plane,
 	I915_WRITE_FW(PLANE_STRIDE(pipe, plane_id), stride);
 	I915_WRITE_FW(PLANE_POS(pipe, plane_id), (crtc_y << 16) | crtc_x);
 	I915_WRITE_FW(PLANE_SIZE(pipe, plane_id), (src_h << 16) | src_w);
-	I915_WRITE_FW(PLANE_AUX_DIST(pipe, plane_id),
-		      (plane_state->color_plane[1].offset - surf_addr) | aux_stride);
+
+	if (INTEL_GEN(dev_priv) < 12)
+		aux_dist |= aux_stride;
+	I915_WRITE_FW(PLANE_AUX_DIST(pipe, plane_id), aux_dist);
 
 	if (icl_is_hdr_plane(dev_priv, plane_id)) {
 		u32 cus_ctl = 0;
@@ -1745,7 +1748,8 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state,
 	    (fb->modifier == I915_FORMAT_MOD_Y_TILED ||
 	     fb->modifier == I915_FORMAT_MOD_Yf_TILED ||
 	     fb->modifier == I915_FORMAT_MOD_Y_TILED_CCS ||
-	     fb->modifier == I915_FORMAT_MOD_Yf_TILED_CCS)) {
+	     fb->modifier == I915_FORMAT_MOD_Yf_TILED_CCS ||
+	     fb->modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS)) {
 		DRM_DEBUG_KMS("Y/Yf tiling not supported in IF-ID mode\n");
 		return -EINVAL;
 	}
@@ -2157,7 +2161,8 @@ static const u64 skl_plane_format_modifiers_ccs[] = {
 	DRM_FORMAT_MOD_INVALID
 };
 
-static const u64 gen12_plane_format_modifiers_noccs[] = {
+static const u64 gen12_plane_format_modifiers_ccs[] = {
+	I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS,
 	I915_FORMAT_MOD_Y_TILED,
 	I915_FORMAT_MOD_X_TILED,
 	DRM_FORMAT_MOD_LINEAR,
@@ -2319,6 +2324,7 @@ static bool gen12_plane_format_mod_supported(struct drm_plane *_plane,
 	case DRM_FORMAT_MOD_LINEAR:
 	case I915_FORMAT_MOD_X_TILED:
 	case I915_FORMAT_MOD_Y_TILED:
+	case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS:
 		break;
 	default:
 		return false;
@@ -2329,6 +2335,9 @@ static bool gen12_plane_format_mod_supported(struct drm_plane *_plane,
 	case DRM_FORMAT_XBGR8888:
 	case DRM_FORMAT_ARGB8888:
 	case DRM_FORMAT_ABGR8888:
+		if (is_ccs_modifier(modifier))
+			return true;
+		/* fall through */
 	case DRM_FORMAT_RGB565:
 	case DRM_FORMAT_XRGB2101010:
 	case DRM_FORMAT_XBGR2101010:
@@ -2524,13 +2533,11 @@ skl_universal_plane_create(struct drm_i915_private *dev_priv,
 		formats = skl_get_plane_formats(dev_priv, pipe,
 						plane_id, &num_formats);
 
+	plane->has_ccs = skl_plane_has_ccs(dev_priv, pipe, plane_id);
 	if (INTEL_GEN(dev_priv) >= 12) {
-		/* TODO: Implement support for gen-12 CCS modifiers */
-		plane->has_ccs = false;
-		modifiers = gen12_plane_format_modifiers_noccs;
+		modifiers = gen12_plane_format_modifiers_ccs;
 		plane_funcs = &gen12_plane_funcs;
 	} else {
-		plane->has_ccs = skl_plane_has_ccs(dev_priv, pipe, plane_id);
 		if (plane->has_ccs)
 			modifiers = skl_plane_format_modifiers_ccs;
 		else
-- 
2.21.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2019-08-16  8:07 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-16  8:04 [PATCH 00/39] Tiger Lake batch 3 Lucas De Marchi
2019-08-16  8:04 ` [PATCH 01/39] drm/i915/tgl: do not use DDIC Lucas De Marchi
2019-08-16  8:04 ` [PATCH 02/39] drm/i915/psr: Make PSR registers relative to transcoders Lucas De Marchi
2019-08-16  8:04 ` [PATCH 03/39] drm/i915: Add transcoder restriction to PSR2 Lucas De Marchi
2019-08-16  8:04 ` [PATCH 04/39] drm/i915: Do not unmask PSR interruption in IRQ postinstall Lucas De Marchi
2019-08-16  8:04 ` [PATCH 05/39] drm/i915/psr: Only handle interruptions of the transcoder in use Lucas De Marchi
2019-08-16  8:04 ` [PATCH 06/39] drm/i915/bdw+: Enable PSR in any eDP port Lucas De Marchi
2019-08-22 16:20   ` Gupta, Anshuman
2019-08-22 16:42     ` Gupta, Anshuman
2019-08-16  8:04 ` [PATCH 07/39] drm/i915: Guard and warn if more than one eDP panel is present Lucas De Marchi
2019-08-16  8:04 ` [PATCH 08/39] drm/i915/tgl: Change PSR2 transcoder restriction Lucas De Marchi
2019-08-16 21:28   ` Lucas De Marchi
2019-08-16 21:59     ` Souza, Jose
2019-08-16  8:04 ` [PATCH 09/39] drm/i915: Do not read PSR2 register in transcoders without PSR2 Lucas De Marchi
2019-08-16  8:04 ` [PATCH 10/39] drm/i915/tgl: PSR link standby is not supported anymore Lucas De Marchi
2019-08-22  9:54   ` Gupta, Anshuman
2019-08-16  8:04 ` [PATCH 11/39] drm/i915/tgl: Access the right register when handling PSR interruptions Lucas De Marchi
2019-08-16  8:04 ` [PATCH 12/39] drm/i915/tgl: Add maximum resolution supported by PSR2 HW Lucas De Marchi
2019-08-22 16:46   ` Gupta, Anshuman
2019-08-16  8:04 ` [PATCH 13/39] drm/i915/mst: Do not hardcoded the crtcs that encoder can connect Lucas De Marchi
2019-08-16  8:04 ` [PATCH 14/39] drm/i915: Add for_each_new_intel_connector_in_state() Lucas De Marchi
2019-08-22 12:55   ` Maarten Lankhorst
2019-08-16  8:04 ` [PATCH 15/39] drm: Add for_each_oldnew_intel_crtc_in_state_reverse() Lucas De Marchi
2019-08-16  8:04 ` [PATCH 16/39] drm/i915: Disable pipes in reverse order Lucas De Marchi
2019-08-16  8:04 ` [PATCH 17/39] drm/i915/tgl: Select master transcoder in DP MST Lucas De Marchi
2019-08-16  8:04 ` [PATCH 18/39] drm/i915/tgl: Introduce initial Tiger Lake workarounds Lucas De Marchi
2019-08-16  8:04 ` [PATCH 19/39] drm/i915/tgl: Implement Wa_1406941453 Lucas De Marchi
2019-08-16  8:04 ` [PATCH 20/39] drm/i915/tgl: Enable VD HCP/MFX sub-pipe power gating Lucas De Marchi
2019-08-16  8:04 ` [PATCH 21/39] drm/i915/tgl: Do not apply WaIncreaseDefaultTLBEntries from GEN12 onwards Lucas De Marchi
2019-08-16  8:04 ` [PATCH 22/39] drm/i915/tgl: implement WaProgramMgsrForCorrectSliceSpecificMmioReads Lucas De Marchi
2019-08-16  8:04 ` [PATCH 23/39] drm/i915/tgl: Register state context definition for Gen12 Lucas De Marchi
2019-08-16  8:04 ` [PATCH 24/39] drm/i915/tgl: move DP_TP_* to transcoder Lucas De Marchi
2019-08-16  8:04 ` [PATCH 25/39] drm/i915/tgl: Implement TGL DisplayPort training sequence Lucas De Marchi
2019-08-19 14:21   ` Maarten Lankhorst
2019-08-19 21:26     ` Souza, Jose
2019-08-16  8:04 ` [PATCH 26/39] HACK: drm/i915/tgl: Gen12 render context size Lucas De Marchi
2019-08-16  8:04 ` [PATCH 27/39] drm/i915/tgl: add Gen12 default indirect ctx offset Lucas De Marchi
2019-08-16  8:04 ` [PATCH 28/39] drm/i915/tgl: add GEN12_MAX_CONTEXT_HW_ID Lucas De Marchi
2019-08-16  8:04 ` [PATCH 29/39] drm/i915/tgl: Report valid VDBoxes with SFC capability Lucas De Marchi
2019-08-16  8:04 ` [PATCH 30/39] drm/i915/tgl: Move GTCR register to cope with GAM MMIO address remap Lucas De Marchi
2019-08-16  8:04 ` [PATCH 31/39] drm/i915/tgl: Updated Private PAT programming Lucas De Marchi
2019-08-16  8:04 ` [PATCH 32/39] drm/i915/tgl/perf: use the same oa ctx_id format as icl Lucas De Marchi
2019-08-16  8:04 ` [PATCH 33/39] drm/i915/perf: add a parameter to control the size of OA buffer Lucas De Marchi
2019-08-19 18:31   ` Umesh Nerlige Ramappa
2019-08-21  8:37   ` Lionel Landwerlin
2019-08-22 10:43   ` Joonas Lahtinen
2019-08-22 12:13     ` Lionel Landwerlin
2019-08-23  8:30       ` Lucas De Marchi
2019-08-16  8:04 ` [PATCH 34/39] drm/i915/tgl: Add perf support on TGL Lucas De Marchi
2019-08-16  8:04 ` [PATCH 35/39] drm/i915/tgl: Gen-12 display loses Yf tiling and legacy CCS support Lucas De Marchi
2019-08-16  8:05 ` [PATCH 36/39] drm/framebuffer/tgl: Format modifier for Intel Gen-12 render compression Lucas De Marchi
2019-08-16  8:05 ` Lucas De Marchi [this message]
2019-08-16  8:05 ` [PATCH 38/39] drm/framebuffer/tgl: Format modifier for Intel Gen-12 media compression Lucas De Marchi
2019-08-16  8:05 ` [PATCH 39/39] drm/i915/tgl: " Lucas De Marchi
2019-08-16  9:37 ` ✗ Fi.CI.CHECKPATCH: warning for Tiger Lake batch 3 Patchwork
2019-08-16  9:51 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-08-16  9:57 ` ✓ Fi.CI.BAT: success " Patchwork
2019-08-16 21:26 ` ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190816080503.28594-38-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=daniel.vetter@intel.com \
    --cc=dhinakaran.pandiyan@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.