aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0076-drm-amd-display-Fix-programming-of-gamma-end-points.patch
blob: c1298db935d75cf8823a04fa0b9ad703ac31da97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
From 0800489d0ff1410b2b1371353871b2333bc0959d Mon Sep 17 00:00:00 2001
From: Anthony Koo <Anthony.Koo@amd.com>
Date: Fri, 16 Dec 2016 12:12:03 -0500
Subject: [PATCH 0076/4131] drm/amd/display: Fix programming of gamma end
 points

Signed-off-by: Anthony Koo <anthony.koo@amd.com>
Reviewed-by: Anthony Koo <Anthony.Koo@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/display/dc/calcs/gamma_calcs.c | 51 ++++++++++++----------
 1 file changed, 27 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/calcs/gamma_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/gamma_calcs.c
index 729652a..5cd408d 100644
--- a/drivers/gpu/drm/amd/display/dc/calcs/gamma_calcs.c
+++ b/drivers/gpu/drm/amd/display/dc/calcs/gamma_calcs.c
@@ -245,6 +245,8 @@ static bool build_hw_curve_configuration(
 	uint32_t segments = 0;
 	uint32_t max_number;
 
+	int8_t num_regions = 0;
+
 	bool result = false;
 
 	if (!number_of_points) {
@@ -273,6 +275,7 @@ static bool build_hw_curve_configuration(
 		ASSERT(curve_config->segments[i] >= 0);
 
 		segments += (1 << curve_config->segments[i]);
+		++num_regions;
 
 		++i;
 	}
@@ -284,12 +287,14 @@ static bool build_hw_curve_configuration(
 		uint32_t offset = 0;
 		int8_t begin = curve_config->begin;
 		int32_t region_number = 0;
+		struct fixed31_32 magic_number =
+				dal_fixed31_32_from_fraction(249, 1000);
 
 		i = begin;
 
 		while ((index < max_number) &&
 			(region_number < max_regions_number) &&
-			(i <= 1)) {
+			(i < (begin + num_regions))) {
 			int32_t j = 0;
 
 			segments = curve_config->segments[region_number];
@@ -345,8 +350,7 @@ static bool build_hw_curve_configuration(
 				divisor);
 
 			points[index].x = region1;
-
-			round_custom_float_6_12(points + index);
+			points[index].adjusted_x = region1;
 
 			++index;
 			++region_number;
@@ -366,9 +370,10 @@ static bool build_hw_curve_configuration(
 			++i;
 		}
 
-		points[index].x = region1;
-
-		round_custom_float_6_12(points + index);
+		points[index].x =
+				dal_fixed31_32_add(region1, magic_number);
+		points[index].adjusted_x =
+				dal_fixed31_32_add(region1, magic_number);
 
 		*number_of_points = index;
 
@@ -1215,15 +1220,11 @@ static void rebuild_curve_configuration_magic(
 		const struct hw_x_point *coordinates_x,
 		uint32_t hw_points_num)
 {
-	const struct fixed31_32 magic_number =
-		dal_fixed31_32_from_fraction(249, 1000);
-
 	struct fixed31_32 y_r;
 	struct fixed31_32 y_g;
 	struct fixed31_32 y_b;
 
 	struct fixed31_32 y1_min;
-	struct fixed31_32 y2_max;
 	struct fixed31_32 y3_max;
 
 	y_r = rgb_resulted[0].red;
@@ -1238,29 +1239,31 @@ static void rebuild_curve_configuration_magic(
 					arr_points[0].y,
 					arr_points[0].x);
 
-	arr_points[1].x = dal_fixed31_32_add(
-			coordinates_x[hw_points_num - 1].adjusted_x,
-			magic_number);
-
-	arr_points[2].x = arr_points[1].x;
-
-	y_r = rgb_resulted[hw_points_num - 1].red;
-	y_g = rgb_resulted[hw_points_num - 1].green;
-	y_b = rgb_resulted[hw_points_num - 1].blue;
-
-	y2_max = dal_fixed31_32_max(y_r, dal_fixed31_32_max(y_g, y_b));
-
-	arr_points[1].y = y2_max;
+	/* this should be cleaned up as it's confusing my understanding (KK) is
+	 * that REGAMMA_CNTLA_EXP_REGION_END is the X value for the region end
+	 * REGAMMA_CNTLA_EXP_REGION_END_BASE is Y value for the above X
+	 * REGAMMA_CNTLA_EXP_REGION_END_SLOPE is the slope beyond (X,Y) above
+	 * currently when programming REGION_END = m_arrPoints[1].x,
+	 * REGION_END_BASE = m_arrPoints[1].y, REGION_END_SLOPE=1
+	 * we don't use m_arrPoints[2] at all after this function,
+	 * and its purpose isn't clear to me
+	 */
+	arr_points[1].x = coordinates_x[hw_points_num].adjusted_x;
+	arr_points[2].x = coordinates_x[hw_points_num].adjusted_x;
 
 	y_r = rgb_resulted[hw_points_num].red;
 	y_g = rgb_resulted[hw_points_num].green;
 	y_b = rgb_resulted[hw_points_num].blue;
 
+	/* see comment above, m_arrPoints[1].y should be the Y value for the
+	 * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1)
+	 */
 	y3_max = dal_fixed31_32_max(y_r, dal_fixed31_32_max(y_g, y_b));
 
+	arr_points[1].y = y3_max;
 	arr_points[2].y = y3_max;
 
-	arr_points[2].slope = dal_fixed31_32_one;
+	arr_points[2].slope = dal_fixed31_32_zero;
 }
 
 static bool convert_to_custom_float_format(
-- 
2.7.4