All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH] drm/i915/vdsc: Fix first_line_bpg_offset calculation
@ 2023-08-03 16:02 Suraj Kandpal
  2023-08-03 18:31 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: Suraj Kandpal @ 2023-08-03 16:02 UTC (permalink / raw)
  To: intel-gfx; +Cc: juha-pekka.heikkila, william.tseng

On checking DSC1.1 Errata and DSC 1.2 spec the current formula
we were using was incorrect to calculate first_line_bpg_offset.
The new fixed formula is derived from C model.

Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
 drivers/gpu/drm/i915/display/intel_vdsc.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_vdsc.c b/drivers/gpu/drm/i915/display/intel_vdsc.c
index 9d76c2756784..a344c6ab8767 100644
--- a/drivers/gpu/drm/i915/display/intel_vdsc.c
+++ b/drivers/gpu/drm/i915/display/intel_vdsc.c
@@ -65,6 +65,9 @@ intel_vdsc_set_min_max_qp(struct drm_dsc_config *vdsc_cfg, int buf,
 		intel_lookup_range_max_qp(bpc, buf, bpp, vdsc_cfg->native_420);
 }
 
+#define CLAMP_TO(val, _min, _max) \
+	max(_min, min(val, _max))
+
 /*
  * We are using the method provided in DSC 1.2a C-Model in codec_main.c
  * Above method use a common formula to derive values for any combination of DSC
@@ -80,13 +83,19 @@ calculate_rc_params(struct drm_dsc_config *vdsc_cfg)
 	int bpc = vdsc_cfg->bits_per_component;
 	int bpp = vdsc_cfg->bits_per_pixel >> 4;
 	int qp_bpc_modifier = (bpc - 8) * 2;
+	int uncompressed_bpg_rate;
+	int first_line_bpg_offset;
 	u32 res, buf_i, bpp_i;
 
 	if (vdsc_cfg->slice_height >= 8)
-		vdsc_cfg->first_line_bpg_offset =
-			12 + DIV_ROUND_UP((9 * min(34, vdsc_cfg->slice_height - 8)), 100);
+		first_line_bpg_offset =
+			12 + (9 * min(34, vdsc_cfg->slice_height - 8)) / 100;
 	else
-		vdsc_cfg->first_line_bpg_offset = 2 * (vdsc_cfg->slice_height - 1);
+		first_line_bpg_offset = 2 * (vdsc_cfg->slice_height - 1);
+
+	uncompressed_bpg_rate = (3 * bpc + (vdsc_cfg->convert_rgb ? 0 : 2)) * 3;
+	vdsc_cfg->first_line_bpg_offset = CLAMP_TO(first_line_bpg_offset, 0,
+						   uncompressed_bpg_rate - 3 * bpp);
 
 	/*
 	 * According to DSC 1.2 spec in Section 4.1 if native_420 is set:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-08-14 12:55 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03 16:02 [Intel-gfx] [PATCH] drm/i915/vdsc: Fix first_line_bpg_offset calculation Suraj Kandpal
2023-08-03 18:31 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2023-08-03 18:31 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-08-03 18:47 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-08-04  2:12 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-08-04  7:55 ` [Intel-gfx] [PATCH] " Nautiyal, Ankit K
2023-08-07  2:45   ` Tseng, William
2023-08-04  8:28 ` Suraj Kandpal
2023-08-04  8:37   ` Suraj Kandpal
2023-08-14 11:30     ` Jani Nikula
2023-08-14 12:55       ` Kandpal, Suraj
2023-08-04 10:30 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/vdsc: Fix first_line_bpg_offset calculation (rev3) Patchwork
2023-08-04 10:30 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-08-04 10:44 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-08-04 15:28 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

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.