All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qingqing Zhuo <qingqing.zhuo@amd.com>
To: amd-gfx@lists.freedesktop.org
Cc: Felipe <Felipe.Clark@amd.com>,
	Eryk.Brol@amd.com, Sunpeng.Li@amd.com, Harry.Wentland@amd.com,
	Qingqing.Zhuo@amd.com, Rodrigo.Siqueira@amd.com,
	Bhawanpreet.Lakha@amd.com, bindu.r@amd.com
Subject: [PATCH 10/13] drm/amd/display: Fix OGAM LUT calculation precision
Date: Tue,  8 Dec 2020 14:28:41 -0500	[thread overview]
Message-ID: <20201208192844.23580-11-qingqing.zhuo@amd.com> (raw)
In-Reply-To: <20201208192844.23580-1-qingqing.zhuo@amd.com>

From: Felipe <Felipe.Clark@amd.com>

[Why]
The OGAM LUT precision was accumulating too much error
in the higher end.

[How]
Instead of calculating all points of the LUT in relation
to the previous ones, perform a full calculation in one
of the intermediate segments to stop error propagation.

Signed-off-by: Felipe Clark <Felipe.Clark@amd.com>
Reviewed-by: Krunoslav Kovac <Krunoslav.Kovac@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
---
 .../amd/display/modules/color/color_gamma.c   | 22 ++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
index eced40a2fce4..5c67e12b2e55 100644
--- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
+++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
@@ -30,6 +30,14 @@
 #include "opp.h"
 #include "color_gamma.h"
 
+/* When calculating LUT values the first region and at least one subsequent
+ * region are calculated with full precision. These defines are a demarcation
+ * of where the second region starts and ends.
+ * These are hardcoded values to avoid recalculating them in loops.
+ */
+#define PRECISE_LUT_REGION_START 224
+#define PRECISE_LUT_REGION_END 239
+
 static struct hw_x_point coordinates_x[MAX_HW_POINTS + 2];
 
 // these are helpers for calculations to reduce stack usage
@@ -346,7 +354,13 @@ static struct fixed31_32 translate_from_linear_space(
 					dc_fixpt_recip(args->gamma));
 		}
 		scratch_1 = dc_fixpt_add(one, args->a3);
-		if (cal_buffer->buffer_index < 16)
+		/* In the first region (first 16 points) and in the
+		 * region delimited by START/END we calculate with
+		 * full precision to avoid error accumulation. 
+		 */
+		if ((cal_buffer->buffer_index >= PRECISE_LUT_REGION_START &&
+			cal_buffer->buffer_index <= PRECISE_LUT_REGION_END) ||
+			(cal_buffer->buffer_index < 16))
 			scratch_2 = dc_fixpt_pow(args->arg,
 					dc_fixpt_recip(args->gamma));
 		else
@@ -397,9 +411,7 @@ static struct fixed31_32 translate_from_linear_space_long(
 					dc_fixpt_recip(args->gamma))),
 					args->a2);
 	else
-		return dc_fixpt_mul(
-			args->arg,
-			args->a1);
+		return dc_fixpt_mul(args->arg, args->a1);
 }
 
 static struct fixed31_32 calculate_gamma22(struct fixed31_32 arg, bool use_eetf, struct calculate_buffer *cal_buffer)
@@ -717,7 +729,6 @@ static struct fixed31_32 calculate_mapped_value(
 		BREAK_TO_DEBUGGER();
 		result = dc_fixpt_zero;
 	} else {
-		BREAK_TO_DEBUGGER();
 		result = dc_fixpt_one;
 	}
 
@@ -976,6 +987,7 @@ static bool build_freesync_hdr(struct pwl_float_data_ex *rgb_regamma,
 		cal_buffer->buffer_index = 0; // see var definition for more info
 	rgb += 32; // first 32 points have problems with fixed point, too small
 	coord_x += 32;
+
 	for (i = 32; i <= hw_points_num; i++) {
 		if (!is_clipped) {
 			if (use_eetf) {
-- 
2.17.1

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

  parent reply	other threads:[~2020-12-08 19:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 19:28 [PATCH 00/13] DC Patches December 14th, 2020 Qingqing Zhuo
2020-12-08 19:28 ` [PATCH 01/13] drm/amd/display: Change pstate expected timeout warning to 180us on linux Qingqing Zhuo
2020-12-08 19:28 ` [PATCH 02/13] drm/amd/display: Add missing DP_SEC register definitions and masks Qingqing Zhuo
2020-12-08 19:28 ` [PATCH 03/13] drm/amd/display: HP Reverb G2 VR fails to light up Qingqing Zhuo
2020-12-08 19:28 ` [PATCH 04/13] drm/amd/display: Fix to be able to stop crc calculation Qingqing Zhuo
2020-12-08 19:28 ` [PATCH 05/13] drm/amd/display: add dcn30_link_encoder_validate_output_with_stream to header Qingqing Zhuo
2020-12-08 19:28 ` [PATCH 06/13] drm/amd/display: Add DP info frame update for dcn30 Qingqing Zhuo
2020-12-08 19:28 ` [PATCH 07/13] drm/amd/display: delay fp2 programming until vactive before lock Qingqing Zhuo
2020-12-08 19:28 ` [PATCH 08/13] drm/amd/display: updated wm table for Renoir Qingqing Zhuo
2020-12-08 19:28 ` [PATCH 09/13] drm/amd/display: Only update FP2 for full updates Qingqing Zhuo
2020-12-08 19:28 ` Qingqing Zhuo [this message]
2020-12-08 19:28 ` [PATCH 11/13] drm/amd/display: Fix cleanup typo in MPCC visual confirm Qingqing Zhuo
2020-12-08 19:28 ` [PATCH 12/13] drm/amd/display: [FW Promotion] Release 0.0.46 Qingqing Zhuo
2020-12-08 19:28 ` [PATCH 13/13] drm/amd/display: 3.2.116 Qingqing Zhuo

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=20201208192844.23580-11-qingqing.zhuo@amd.com \
    --to=qingqing.zhuo@amd.com \
    --cc=Bhawanpreet.Lakha@amd.com \
    --cc=Eryk.Brol@amd.com \
    --cc=Felipe.Clark@amd.com \
    --cc=Harry.Wentland@amd.com \
    --cc=Rodrigo.Siqueira@amd.com \
    --cc=Sunpeng.Li@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=bindu.r@amd.com \
    /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.