aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0067-drm-amd-display-Refactor-to-move-color-helper-into-m.patch
blob: 99b4e8d867cef6a2186de89e88d4c9ddc4c62a16 (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
From f66f6ae0ebc1fee69c1a55c60776baaea1057d29 Mon Sep 17 00:00:00 2001
From: Anthony Koo <Anthony.Koo@amd.com>
Date: Wed, 14 Dec 2016 16:26:27 -0500
Subject: [PATCH 0067/4131] drm/amd/display: Refactor to move color helper into
 module

Refactor part 2 - Moving color helper into color module

The color module will need table defined in the helper in order to calculate
the logical regamma curve, and also to fully handle gamut remapping.

Signed-off-by: Anthony Koo <anthony.koo@amd.com>
Reviewed-by: Aric Cyr <Aric.Cyr@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 .../drm/amd/display/modules/color/color_helper.c   | 199 +++++++++++++++++++++
 .../drm/amd/display/modules/color/color_helper.h   |  50 ++++++
 .../gpu/drm/amd/display/modules/inc/mod_color.h    |   4 +-
 3 files changed, 251 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/modules/color/color_helper.c
 create mode 100644 drivers/gpu/drm/amd/display/modules/color/color_helper.h

diff --git a/drivers/gpu/drm/amd/display/modules/color/color_helper.c b/drivers/gpu/drm/amd/display/modules/color/color_helper.c
new file mode 100644
index 0000000..c47d296
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/modules/color/color_helper.c
@@ -0,0 +1,199 @@
+
+/**
+ *  @file
+ *  @date Copyright (c) 2008 Advanced Micro Devices, Inc. (unpublished)
+ *
+ *  @brief Helper functions for color gamut calculation
+ *
+ *  @internal
+ *  All rights reserved.  This notice is intended as a precaution against
+ *  inadvertent publication and does not imply publication or any waiver
+ *  of confidentiality.  The year included in the foregoing notice is the
+ *  year of creation of the work.
+ */
+
+#include "dm_services.h"
+#include "dc.h"
+#include "mod_color.h"
+#include "color_helper.h"
+
+const struct gamut_space_entry predefined_gamuts[] = {
+	/*                         x_red y_red x_gr  y_gr  x_blue y_blue   a0        a1     a2  a3  gamma */
+	[gamut_type_bt709]	= {6400, 3300, 3000, 6000, 1500,  600,     180000,   4500,  99, 99, 2200},
+	[gamut_type_bt601]	= {6400, 3300, 2900, 6000, 1500,  600,     180000,   4500,  99, 99, 2200},
+	[gamut_type_adobe_rgb]	= {6400, 3300, 2100, 7100, 1500,  600,     180000,   4500,  99, 99, 2200},
+	[gamut_type_srgb]	= {6400, 3300, 3000, 6000, 1500,  600,      31308,  12920,  55, 55, 2400},
+	[gamut_type_bt2020]	= {7080, 2920, 1700, 7970, 1310,  460,     180000,   4500,  99, 99, 2200}
+};
+
+const struct white_point_coodinates_entry predefined_white_points[] = {
+	[white_point_type_5000k_horizon]	= {5000, 3473, 3561},
+	[white_point_type_6500k_noon]		= {6500, 3127, 3290},
+	[white_point_type_7500k_north_sky]	= {7500, 3022, 3129},
+	[white_point_type_9300k]		= {9300, 2866, 2950}
+};
+
+const unsigned int white_point_entries = 91;
+
+const struct white_point_coodinates_entry white_point_temps[] = {
+	/*001*/{1000, 6499, 3474},
+	/*002*/{1100, 6361, 3594},
+	/*003*/{1200, 6226, 3703},
+	/*004*/{1300, 6095, 3801},
+	/*005*/{1400, 5966, 3887},
+	/*006*/{1500, 5841, 3962},
+	/*007*/{1600, 5720, 4025},
+	/*008*/{1700, 5601, 4076},
+	/*009*/{1800, 5486, 4118},
+	/*010*/{1900, 5375, 4150},
+	/*011*/{2000, 5267, 4173},
+	/*012*/{2100, 5162, 4188},
+	/*013*/{2200, 5062, 4196},
+	/*014*/{2300, 4965, 4198},
+	/*015*/{2400, 4872, 4194},
+	/*016*/{2500, 4782, 4186},
+	/*017*/{2600, 4696, 4173},
+	/*018*/{2700, 4614, 4158},
+	/*019*/{2800, 4535, 4139},
+	/*020*/{2900, 4460, 4118},
+	/*021*/{3000, 4388, 4095},
+	/*022*/{3100, 4320, 4070},
+	/*023*/{3200, 4254, 4044},
+	/*024*/{3300, 4192, 4018},
+	/*025*/{3400, 4132, 3990},
+	/*026*/{3500, 4075, 3962},
+	/*027*/{3600, 4021, 3934},
+	/*028*/{3700, 3969, 3905},
+	/*029*/{3800, 3919, 3877},
+	/*030*/{3900, 3872, 3849},
+	/*031*/{4000, 3827, 3820},
+	/*032*/{4100, 3784, 3793},
+	/*033*/{4200, 3743, 3765},
+	/*034*/{4300, 3704, 3738},
+	/*035*/{4400, 3666, 3711},
+	/*036*/{4500, 3631, 3685},
+	/*037*/{4600, 3596, 3659},
+	/*038*/{4700, 3563, 3634},
+	/*039*/{4800, 3532, 3609},
+	/*040*/{4900, 3502, 3585},
+	/*041*/{5000, 3473, 3561},
+	/*042*/{5100, 3446, 3538},
+	/*043*/{5200, 3419, 3516},
+	/*044*/{5300, 3394, 3494},
+	/*045*/{5400, 3369, 3472},
+	/*046*/{5500, 3346, 3451},
+	/*047*/{5600, 3323, 3431},
+	/*048*/{5700, 3302, 3411},
+	/*049*/{5800, 3281, 3392},
+	/*050*/{5900, 3261, 3373},
+	/*051*/{6000, 3242, 3355},
+	/*052*/{6100, 3223, 3337},
+	/*053*/{6200, 3205, 3319},
+	/*054*/{6300, 3188, 3302},
+	/*055*/{6400, 3161, 3296},
+	/*056*/{6500, 3127, 3290}, /* This is  the real white point sRGB */
+	/*057*/{6600, 3126, 3264},
+	/*058*/{6700, 3125, 3238},
+	/*059*/{6800, 3110, 3224},
+	/*060*/{6900, 3097, 3209},
+	/*061*/{7000, 3083, 3195},
+	/*062*/{7100, 3070, 3181},
+	/*063*/{7200, 3058, 3168},
+	/*064*/{7300, 3045, 3154},
+	/*065*/{7400, 3034, 3142},
+	/*066*/{7500, 3022, 3129},
+	/*067*/{7600, 3011, 3117},
+	/*068*/{7700, 3000, 3105},
+	/*069*/{7800, 2990, 3094},
+	/*070*/{7900, 2980, 3082},
+	/*071*/{8000, 2970, 3071},
+	/*072*/{8100, 2961, 3061},
+	/*073*/{8200, 2952, 3050},
+	/*074*/{8300, 2943, 3040},
+	/*075*/{8400, 2934, 3030},
+	/*076*/{8500, 2926, 3020},
+	/*077*/{8600, 2917, 3011},
+	/*078*/{8700, 2910, 3001},
+	/*079*/{8800, 2902, 2992},
+	/*080*/{8900, 2894, 2983},
+	/*081*/{9000, 2887, 2975},
+	/*082*/{9100, 2880, 2966},
+	/*083*/{9200, 2873, 2958},
+	/*084*/{9300, 2866, 2950},
+	/*085*/{9400, 2860, 2942},
+	/*086*/{9500, 2853, 2934},
+	/*087*/{9600, 2847, 2927},
+	/*088*/{9700, 2841, 2919},
+	/*089*/{9800, 2835, 2912},
+	/*090*/{9900, 2829, 2905},
+	/*091*/{10000, 2824, 2898}
+};
+
+bool mod_color_find_predefined_gamut(
+		struct gamut_space_coordinates *out_gamut,
+		enum predefined_gamut_type type)
+{
+	out_gamut->redX = predefined_gamuts[type].redX;
+	out_gamut->redY = predefined_gamuts[type].redY;
+	out_gamut->greenX = predefined_gamuts[type].greenX;
+	out_gamut->greenY = predefined_gamuts[type].greenY;
+	out_gamut->blueX = predefined_gamuts[type].blueX;
+	out_gamut->blueY = predefined_gamuts[type].blueY;
+
+	return true;
+}
+
+bool mod_color_find_predefined_white_point(
+		struct white_point_coodinates *out_white_point,
+		enum predefined_white_point_type type)
+{
+	out_white_point->whiteX = predefined_white_points[type].whiteX;
+	out_white_point->whiteY = predefined_white_points[type].whiteY;
+
+	return true;
+}
+
+bool mod_color_find_white_point_from_temperature(
+		struct white_point_coodinates *out_white_point,
+		unsigned int temperature)
+{
+	int i;
+	unsigned int found = false;
+	struct white_point_coodinates_entry temp_white_point =
+			white_point_temps[55];
+
+	if (temperature < 1000 || temperature > 10000)
+		return false;
+
+	for (i = 0; i < white_point_entries; i++) {
+		if (temperature == white_point_temps[i].temperature) {
+			temp_white_point = white_point_temps[i];
+			found = true;
+			break;
+		}
+	}
+
+	out_white_point->whiteX = temp_white_point.whiteX;
+	out_white_point->whiteY = temp_white_point.whiteY;
+
+	return found;
+}
+
+bool mod_color_find_temperature_from_white_point(
+		struct white_point_coodinates *in_white_point,
+		unsigned int *out_temperature)
+{
+	unsigned int i;
+	*out_temperature = 6500;
+
+	for (i = 0; i < white_point_entries; i++) {
+		if (in_white_point->whiteX == white_point_temps[i].whiteX &&
+			in_white_point->whiteY == white_point_temps[i].whiteY) {
+			*out_temperature = white_point_temps[i].temperature;
+			return true;
+		}
+	}
+
+	return false;
+}
+
diff --git a/drivers/gpu/drm/amd/display/modules/color/color_helper.h b/drivers/gpu/drm/amd/display/modules/color/color_helper.h
new file mode 100644
index 0000000..c0e6334
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/modules/color/color_helper.h
@@ -0,0 +1,50 @@
+/**
+ *  @file
+ *  @date Copyright (c) 2008 Advanced Micro Devices, Inc. (unpublished)
+ *
+ *  @brief Helper functions for color gamut calculation
+ *
+ *  @internal
+ *  All rights reserved.  This notice is intended as a precaution against
+ *  inadvertent publication and does not imply publication or any waiver
+ *  of confidentiality.  The year included in the foregoing notice is the
+ *  year of creation of the work.
+ */
+
+#ifndef COLOR_MOD_COLOR_HELPER_H_
+#define COLOR_MOD_COLOR_HELPER_H_
+
+enum predefined_gamut_type {
+	gamut_type_bt709,
+	gamut_type_bt601,
+	gamut_type_adobe_rgb,
+	gamut_type_srgb,
+	gamut_type_bt2020,
+	gamut_type_unknown,
+};
+
+enum predefined_white_point_type {
+	white_point_type_5000k_horizon,
+	white_point_type_6500k_noon,
+	white_point_type_7500k_north_sky,
+	white_point_type_9300k,
+	white_point_type_unknown,
+};
+
+bool mod_color_find_predefined_gamut(
+		struct gamut_space_coordinates *out_gamut,
+		enum predefined_gamut_type type);
+
+bool mod_color_find_predefined_white_point(
+		struct white_point_coodinates *out_white_point,
+		unsigned int index);
+
+bool mod_color_find_white_point_from_temperature(
+		struct white_point_coodinates *out_white_point,
+		unsigned int temperature);
+
+bool mod_color_find_temperature_from_white_point(
+		struct white_point_coodinates *in_white_point,
+		unsigned int *out_temperature);
+
+#endif /* COLOR_MOD_COLOR_HELPER_H_ */
diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_color.h b/drivers/gpu/drm/amd/display/modules/inc/mod_color.h
index 91abc17..787c2c0 100644
--- a/drivers/gpu/drm/amd/display/modules/inc/mod_color.h
+++ b/drivers/gpu/drm/amd/display/modules/inc/mod_color.h
@@ -28,6 +28,7 @@
 #define MOD_COLOR_H_
 
 #include "dm_services.h"
+#include "color_helper.h"
 
 struct mod_color {
 	int dummy;
@@ -54,7 +55,6 @@ struct gamut_space_coordinates {
 };
 
 struct gamut_space_entry {
-	unsigned int index;
 	unsigned int redX;
 	unsigned int redY;
 	unsigned int greenX;
@@ -75,7 +75,7 @@ struct white_point_coodinates {
 };
 
 struct white_point_coodinates_entry {
-	unsigned int index;
+	unsigned int temperature;
 	unsigned int whiteX;
 	unsigned int whiteY;
 };
-- 
2.7.4