aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/display
diff options
context:
space:
mode:
authorVitaly Prosyak <vitaly.prosyak@amd.com>2017-02-07 11:41:37 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-09-26 17:14:18 -0400
commite266fdf6944749e100b065b5a95c7bb33d2aa2d6 (patch)
treeab8f08249e930141a3fb6f226b8bd645b03a142d /drivers/gpu/drm/amd/display
parent67c3bd40b3b97cac40e01aaef712ccf4af5a48b1 (diff)
drm/amd/display: Enable regamma 25 segments and use double buffer.
Moved custom floating point calculation to the shared place between dce's. Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com> Reviewed-by: Tony Cheng <Tony.Cheng@amd.com> Acked-by: Harry Wentland <Harry.Wentland@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display')
-rw-r--r--drivers/gpu/drm/amd/display/dc/calcs/Makefile2
-rw-r--r--drivers/gpu/drm/amd/display/dc/calcs/custom_float.c197
-rw-r--r--drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c171
-rw-r--r--drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h3
-rw-r--r--drivers/gpu/drm/amd/display/dc/inc/custom_float.h40
5 files changed, 240 insertions, 173 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/Makefile b/drivers/gpu/drm/amd/display/dc/calcs/Makefile
index 4bb08aea6a03..2f4c8e771b8f 100644
--- a/drivers/gpu/drm/amd/display/dc/calcs/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/calcs/Makefile
@@ -3,7 +3,7 @@
3# It calculates Bandwidth and Watermarks values for HW programming 3# It calculates Bandwidth and Watermarks values for HW programming
4# 4#
5 5
6BW_CALCS = bandwidth_calcs.o bw_fixed.o 6BW_CALCS = bandwidth_calcs.o bw_fixed.o custom_float.o
7 7
8AMD_DAL_BW_CALCS = $(addprefix $(AMDDALPATH)/dc/calcs/,$(BW_CALCS)) 8AMD_DAL_BW_CALCS = $(addprefix $(AMDDALPATH)/dc/calcs/,$(BW_CALCS))
9 9
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/custom_float.c b/drivers/gpu/drm/amd/display/dc/calcs/custom_float.c
new file mode 100644
index 000000000000..7243c37f569e
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/calcs/custom_float.c
@@ -0,0 +1,197 @@
1/*
2 * Copyright 2017 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: AMD
23 *
24 */
25#include "dm_services.h"
26#include "custom_float.h"
27
28
29static bool build_custom_float(
30 struct fixed31_32 value,
31 const struct custom_float_format *format,
32 bool *negative,
33 uint32_t *mantissa,
34 uint32_t *exponenta)
35{
36 uint32_t exp_offset = (1 << (format->exponenta_bits - 1)) - 1;
37
38 const struct fixed31_32 mantissa_constant_plus_max_fraction =
39 dal_fixed31_32_from_fraction(
40 (1LL << (format->mantissa_bits + 1)) - 1,
41 1LL << format->mantissa_bits);
42
43 struct fixed31_32 mantiss;
44
45 if (dal_fixed31_32_eq(
46 value,
47 dal_fixed31_32_zero)) {
48 *negative = false;
49 *mantissa = 0;
50 *exponenta = 0;
51 return true;
52 }
53
54 if (dal_fixed31_32_lt(
55 value,
56 dal_fixed31_32_zero)) {
57 *negative = format->sign;
58 value = dal_fixed31_32_neg(value);
59 } else {
60 *negative = false;
61 }
62
63 if (dal_fixed31_32_lt(
64 value,
65 dal_fixed31_32_one)) {
66 uint32_t i = 1;
67
68 do {
69 value = dal_fixed31_32_shl(value, 1);
70 ++i;
71 } while (dal_fixed31_32_lt(
72 value,
73 dal_fixed31_32_one));
74
75 --i;
76
77 if (exp_offset <= i) {
78 *mantissa = 0;
79 *exponenta = 0;
80 return true;
81 }
82
83 *exponenta = exp_offset - i;
84 } else if (dal_fixed31_32_le(
85 mantissa_constant_plus_max_fraction,
86 value)) {
87 uint32_t i = 1;
88
89 do {
90 value = dal_fixed31_32_shr(value, 1);
91 ++i;
92 } while (dal_fixed31_32_lt(
93 mantissa_constant_plus_max_fraction,
94 value));
95
96 *exponenta = exp_offset + i - 1;
97 } else {
98 *exponenta = exp_offset;
99 }
100
101 mantiss = dal_fixed31_32_sub(
102 value,
103 dal_fixed31_32_one);
104
105 if (dal_fixed31_32_lt(
106 mantiss,
107 dal_fixed31_32_zero) ||
108 dal_fixed31_32_lt(
109 dal_fixed31_32_one,
110 mantiss))
111 mantiss = dal_fixed31_32_zero;
112 else
113 mantiss = dal_fixed31_32_shl(
114 mantiss,
115 format->mantissa_bits);
116
117 *mantissa = dal_fixed31_32_floor(mantiss);
118
119 return true;
120}
121
122static bool setup_custom_float(
123 const struct custom_float_format *format,
124 bool negative,
125 uint32_t mantissa,
126 uint32_t exponenta,
127 uint32_t *result)
128{
129 uint32_t i = 0;
130 uint32_t j = 0;
131
132 uint32_t value = 0;
133
134 /* verification code:
135 * once calculation is ok we can remove it
136 */
137
138 const uint32_t mantissa_mask =
139 (1 << (format->mantissa_bits + 1)) - 1;
140
141 const uint32_t exponenta_mask =
142 (1 << (format->exponenta_bits + 1)) - 1;
143
144 if (mantissa & ~mantissa_mask) {
145 BREAK_TO_DEBUGGER();
146 mantissa = mantissa_mask;
147 }
148
149 if (exponenta & ~exponenta_mask) {
150 BREAK_TO_DEBUGGER();
151 exponenta = exponenta_mask;
152 }
153
154 /* end of verification code */
155
156 while (i < format->mantissa_bits) {
157 uint32_t mask = 1 << i;
158
159 if (mantissa & mask)
160 value |= mask;
161
162 ++i;
163 }
164
165 while (j < format->exponenta_bits) {
166 uint32_t mask = 1 << j;
167
168 if (exponenta & mask)
169 value |= mask << i;
170
171 ++j;
172 }
173
174 if (negative && format->sign)
175 value |= 1 << (i + j);
176
177 *result = value;
178
179 return true;
180}
181
182bool convert_to_custom_float_format(
183 struct fixed31_32 value,
184 const struct custom_float_format *format,
185 uint32_t *result)
186{
187 uint32_t mantissa;
188 uint32_t exponenta;
189 bool negative;
190
191 return build_custom_float(
192 value, format, &negative, &mantissa, &exponenta) &&
193 setup_custom_float(
194 format, negative, mantissa, exponenta, result);
195}
196
197
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
index 6a5cec0d4e1f..88a2fa99f5da 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
@@ -49,6 +49,7 @@
49/* include DCE11 register header files */ 49/* include DCE11 register header files */
50#include "dce/dce_11_0_d.h" 50#include "dce/dce_11_0_d.h"
51#include "dce/dce_11_0_sh_mask.h" 51#include "dce/dce_11_0_sh_mask.h"
52#include "custom_float.h"
52 53
53struct dce110_hw_seq_reg_offsets { 54struct dce110_hw_seq_reg_offsets {
54 uint32_t crtc; 55 uint32_t crtc;
@@ -286,174 +287,6 @@ static bool dce110_set_input_transfer_func(
286 return result; 287 return result;
287} 288}
288 289
289static bool build_custom_float(
290 struct fixed31_32 value,
291 const struct custom_float_format *format,
292 bool *negative,
293 uint32_t *mantissa,
294 uint32_t *exponenta)
295{
296 uint32_t exp_offset = (1 << (format->exponenta_bits - 1)) - 1;
297
298 const struct fixed31_32 mantissa_constant_plus_max_fraction =
299 dal_fixed31_32_from_fraction(
300 (1LL << (format->mantissa_bits + 1)) - 1,
301 1LL << format->mantissa_bits);
302
303 struct fixed31_32 mantiss;
304
305 if (dal_fixed31_32_eq(
306 value,
307 dal_fixed31_32_zero)) {
308 *negative = false;
309 *mantissa = 0;
310 *exponenta = 0;
311 return true;
312 }
313
314 if (dal_fixed31_32_lt(
315 value,
316 dal_fixed31_32_zero)) {
317 *negative = format->sign;
318 value = dal_fixed31_32_neg(value);
319 } else {
320 *negative = false;
321 }
322
323 if (dal_fixed31_32_lt(
324 value,
325 dal_fixed31_32_one)) {
326 uint32_t i = 1;
327
328 do {
329 value = dal_fixed31_32_shl(value, 1);
330 ++i;
331 } while (dal_fixed31_32_lt(
332 value,
333 dal_fixed31_32_one));
334
335 --i;
336
337 if (exp_offset <= i) {
338 *mantissa = 0;
339 *exponenta = 0;
340 return true;
341 }
342
343 *exponenta = exp_offset - i;
344 } else if (dal_fixed31_32_le(
345 mantissa_constant_plus_max_fraction,
346 value)) {
347 uint32_t i = 1;
348
349 do {
350 value = dal_fixed31_32_shr(value, 1);
351 ++i;
352 } while (dal_fixed31_32_lt(
353 mantissa_constant_plus_max_fraction,
354 value));
355
356 *exponenta = exp_offset + i - 1;
357 } else {
358 *exponenta = exp_offset;
359 }
360
361 mantiss = dal_fixed31_32_sub(
362 value,
363 dal_fixed31_32_one);
364
365 if (dal_fixed31_32_lt(
366 mantiss,
367 dal_fixed31_32_zero) ||
368 dal_fixed31_32_lt(
369 dal_fixed31_32_one,
370 mantiss))
371 mantiss = dal_fixed31_32_zero;
372 else
373 mantiss = dal_fixed31_32_shl(
374 mantiss,
375 format->mantissa_bits);
376
377 *mantissa = dal_fixed31_32_floor(mantiss);
378
379 return true;
380}
381
382static bool setup_custom_float(
383 const struct custom_float_format *format,
384 bool negative,
385 uint32_t mantissa,
386 uint32_t exponenta,
387 uint32_t *result)
388{
389 uint32_t i = 0;
390 uint32_t j = 0;
391
392 uint32_t value = 0;
393
394 /* verification code:
395 * once calculation is ok we can remove it
396 */
397
398 const uint32_t mantissa_mask =
399 (1 << (format->mantissa_bits + 1)) - 1;
400
401 const uint32_t exponenta_mask =
402 (1 << (format->exponenta_bits + 1)) - 1;
403
404 if (mantissa & ~mantissa_mask) {
405 BREAK_TO_DEBUGGER();
406 mantissa = mantissa_mask;
407 }
408
409 if (exponenta & ~exponenta_mask) {
410 BREAK_TO_DEBUGGER();
411 exponenta = exponenta_mask;
412 }
413
414 /* end of verification code */
415
416 while (i < format->mantissa_bits) {
417 uint32_t mask = 1 << i;
418
419 if (mantissa & mask)
420 value |= mask;
421
422 ++i;
423 }
424
425 while (j < format->exponenta_bits) {
426 uint32_t mask = 1 << j;
427
428 if (exponenta & mask)
429 value |= mask << i;
430
431 ++j;
432 }
433
434 if (negative && format->sign)
435 value |= 1 << (i + j);
436
437 *result = value;
438
439 return true;
440}
441
442static bool convert_to_custom_float_format(
443 struct fixed31_32 value,
444 const struct custom_float_format *format,
445 uint32_t *result)
446{
447 uint32_t mantissa;
448 uint32_t exponenta;
449 bool negative;
450
451 return build_custom_float(
452 value, format, &negative, &mantissa, &exponenta) &&
453 setup_custom_float(
454 format, negative, mantissa, exponenta, result);
455}
456
457static bool convert_to_custom_float( 290static bool convert_to_custom_float(
458 struct pwl_result_data *rgb_resulted, 291 struct pwl_result_data *rgb_resulted,
459 struct curve_points *arr_points, 292 struct curve_points *arr_points,
@@ -579,7 +412,7 @@ static bool convert_to_custom_float(
579 return true; 412 return true;
580} 413}
581 414
582bool dce110_translate_regamma_to_hw_format(const struct dc_transfer_func 415static bool dce110_translate_regamma_to_hw_format(const struct dc_transfer_func
583 *output_tf, struct pwl_params *regamma_params) 416 *output_tf, struct pwl_params *regamma_params)
584{ 417{
585 struct curve_points *arr_points; 418 struct curve_points *arr_points;
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h
index 68632dd28155..a6b4d0d2429f 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h
@@ -58,8 +58,5 @@ void dce110_power_down(struct core_dc *dc);
58 58
59void dce110_update_pending_status(struct pipe_ctx *pipe_ctx); 59void dce110_update_pending_status(struct pipe_ctx *pipe_ctx);
60 60
61bool dce110_translate_regamma_to_hw_format(const struct dc_transfer_func
62 *output_tf, struct pwl_params *regamma_params);
63
64#endif /* __DC_HWSS_DCE110_H__ */ 61#endif /* __DC_HWSS_DCE110_H__ */
65 62
diff --git a/drivers/gpu/drm/amd/display/dc/inc/custom_float.h b/drivers/gpu/drm/amd/display/dc/inc/custom_float.h
new file mode 100644
index 000000000000..f57239672216
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/inc/custom_float.h
@@ -0,0 +1,40 @@
1/*
2 * Copyright 2017 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: AMD
23 *
24 */
25
26#ifndef CUSTOM_FLOAT_H_
27#define CUSTOM_FLOAT_H_
28
29#include "bw_fixed.h"
30#include "hw_shared.h"
31#include "opp.h"
32
33
34bool convert_to_custom_float_format(
35 struct fixed31_32 value,
36 const struct custom_float_format *format,
37 uint32_t *result);
38
39
40#endif //CUSTOM_FLOAT_H_