summaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorVitaly Prosyak <vitaly.prosyak@amd.com>2017-02-07 10:41:37 -0600
committerAlex Deucher <alexander.deucher@amd.com>2017-09-26 17:14:18 -0400
commite266fdf6944749e100b065b5a95c7bb33d2aa2d6 (patch)
treeab8f08249e930141a3fb6f226b8bd645b03a142d /drivers/gpu
parent67c3bd40b3b97cac40e01aaef712ccf4af5a48b1 (diff)
downloadlinux-e266fdf6944749e100b065b5a95c7bb33d2aa2d6.tar.bz2
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')
-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 @@
# It calculates Bandwidth and Watermarks values for HW programming
#
-BW_CALCS = bandwidth_calcs.o bw_fixed.o
+BW_CALCS = bandwidth_calcs.o bw_fixed.o custom_float.o
AMD_DAL_BW_CALCS = $(addprefix $(AMDDALPATH)/dc/calcs/,$(BW_CALCS))
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 @@
+/*
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+#include "dm_services.h"
+#include "custom_float.h"
+
+
+static bool build_custom_float(
+ struct fixed31_32 value,
+ const struct custom_float_format *format,
+ bool *negative,
+ uint32_t *mantissa,
+ uint32_t *exponenta)
+{
+ uint32_t exp_offset = (1 << (format->exponenta_bits - 1)) - 1;
+
+ const struct fixed31_32 mantissa_constant_plus_max_fraction =
+ dal_fixed31_32_from_fraction(
+ (1LL << (format->mantissa_bits + 1)) - 1,
+ 1LL << format->mantissa_bits);
+
+ struct fixed31_32 mantiss;
+
+ if (dal_fixed31_32_eq(
+ value,
+ dal_fixed31_32_zero)) {
+ *negative = false;
+ *mantissa = 0;
+ *exponenta = 0;
+ return true;
+ }
+
+ if (dal_fixed31_32_lt(
+ value,
+ dal_fixed31_32_zero)) {
+ *negative = format->sign;
+ value = dal_fixed31_32_neg(value);
+ } else {
+ *negative = false;
+ }
+
+ if (dal_fixed31_32_lt(
+ value,
+ dal_fixed31_32_one)) {
+ uint32_t i = 1;
+
+ do {
+ value = dal_fixed31_32_shl(value, 1);
+ ++i;
+ } while (dal_fixed31_32_lt(
+ value,
+ dal_fixed31_32_one));
+
+ --i;
+
+ if (exp_offset <= i) {
+ *mantissa = 0;
+ *exponenta = 0;
+ return true;
+ }
+
+ *exponenta = exp_offset - i;
+ } else if (dal_fixed31_32_le(
+ mantissa_constant_plus_max_fraction,
+ value)) {
+ uint32_t i = 1;
+
+ do {
+ value = dal_fixed31_32_shr(value, 1);
+ ++i;
+ } while (dal_fixed31_32_lt(
+ mantissa_constant_plus_max_fraction,
+ value));
+
+ *exponenta = exp_offset + i - 1;
+ } else {
+ *exponenta = exp_offset;
+ }
+
+ mantiss = dal_fixed31_32_sub(
+ value,
+ dal_fixed31_32_one);
+
+ if (dal_fixed31_32_lt(
+ mantiss,
+ dal_fixed31_32_zero) ||
+ dal_fixed31_32_lt(
+ dal_fixed31_32_one,
+ mantiss))
+ mantiss = dal_fixed31_32_zero;
+ else
+ mantiss = dal_fixed31_32_shl(
+ mantiss,
+ format->mantissa_bits);
+
+ *mantissa = dal_fixed31_32_floor(mantiss);
+
+ return true;
+}
+
+static bool setup_custom_float(
+ const struct custom_float_format *format,
+ bool negative,
+ uint32_t mantissa,
+ uint32_t exponenta,
+ uint32_t *result)
+{
+ uint32_t i = 0;
+ uint32_t j = 0;
+
+ uint32_t value = 0;
+
+ /* verification code:
+ * once calculation is ok we can remove it
+ */
+
+ const uint32_t mantissa_mask =
+ (1 << (format->mantissa_bits + 1)) - 1;
+
+ const uint32_t exponenta_mask =
+ (1 << (format->exponenta_bits + 1)) - 1;
+
+ if (mantissa & ~mantissa_mask) {
+ BREAK_TO_DEBUGGER();
+ mantissa = mantissa_mask;
+ }
+
+ if (exponenta & ~exponenta_mask) {
+ BREAK_TO_DEBUGGER();
+ exponenta = exponenta_mask;
+ }
+
+ /* end of verification code */
+
+ while (i < format->mantissa_bits) {
+ uint32_t mask = 1 << i;
+
+ if (mantissa & mask)
+ value |= mask;
+
+ ++i;
+ }
+
+ while (j < format->exponenta_bits) {
+ uint32_t mask = 1 << j;
+
+ if (exponenta & mask)
+ value |= mask << i;
+
+ ++j;
+ }
+
+ if (negative && format->sign)
+ value |= 1 << (i + j);
+
+ *result = value;
+
+ return true;
+}
+
+bool convert_to_custom_float_format(
+ struct fixed31_32 value,
+ const struct custom_float_format *format,
+ uint32_t *result)
+{
+ uint32_t mantissa;
+ uint32_t exponenta;
+ bool negative;
+
+ return build_custom_float(
+ value, format, &negative, &mantissa, &exponenta) &&
+ setup_custom_float(
+ format, negative, mantissa, exponenta, result);
+}
+
+
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 @@
/* include DCE11 register header files */
#include "dce/dce_11_0_d.h"
#include "dce/dce_11_0_sh_mask.h"
+#include "custom_float.h"
struct dce110_hw_seq_reg_offsets {
uint32_t crtc;
@@ -286,174 +287,6 @@ static bool dce110_set_input_transfer_func(
return result;
}
-static bool build_custom_float(
- struct fixed31_32 value,
- const struct custom_float_format *format,
- bool *negative,
- uint32_t *mantissa,
- uint32_t *exponenta)
-{
- uint32_t exp_offset = (1 << (format->exponenta_bits - 1)) - 1;
-
- const struct fixed31_32 mantissa_constant_plus_max_fraction =
- dal_fixed31_32_from_fraction(
- (1LL << (format->mantissa_bits + 1)) - 1,
- 1LL << format->mantissa_bits);
-
- struct fixed31_32 mantiss;
-
- if (dal_fixed31_32_eq(
- value,
- dal_fixed31_32_zero)) {
- *negative = false;
- *mantissa = 0;
- *exponenta = 0;
- return true;
- }
-
- if (dal_fixed31_32_lt(
- value,
- dal_fixed31_32_zero)) {
- *negative = format->sign;
- value = dal_fixed31_32_neg(value);
- } else {
- *negative = false;
- }
-
- if (dal_fixed31_32_lt(
- value,
- dal_fixed31_32_one)) {
- uint32_t i = 1;
-
- do {
- value = dal_fixed31_32_shl(value, 1);
- ++i;
- } while (dal_fixed31_32_lt(
- value,
- dal_fixed31_32_one));
-
- --i;
-
- if (exp_offset <= i) {
- *mantissa = 0;
- *exponenta = 0;
- return true;
- }
-
- *exponenta = exp_offset - i;
- } else if (dal_fixed31_32_le(
- mantissa_constant_plus_max_fraction,
- value)) {
- uint32_t i = 1;
-
- do {
- value = dal_fixed31_32_shr(value, 1);
- ++i;
- } while (dal_fixed31_32_lt(
- mantissa_constant_plus_max_fraction,
- value));
-
- *exponenta = exp_offset + i - 1;
- } else {
- *exponenta = exp_offset;
- }
-
- mantiss = dal_fixed31_32_sub(
- value,
- dal_fixed31_32_one);
-
- if (dal_fixed31_32_lt(
- mantiss,
- dal_fixed31_32_zero) ||
- dal_fixed31_32_lt(
- dal_fixed31_32_one,
- mantiss))
- mantiss = dal_fixed31_32_zero;
- else
- mantiss = dal_fixed31_32_shl(
- mantiss,
- format->mantissa_bits);
-
- *mantissa = dal_fixed31_32_floor(mantiss);
-
- return true;
-}
-
-static bool setup_custom_float(
- const struct custom_float_format *format,
- bool negative,
- uint32_t mantissa,
- uint32_t exponenta,
- uint32_t *result)
-{
- uint32_t i = 0;
- uint32_t j = 0;
-
- uint32_t value = 0;
-
- /* verification code:
- * once calculation is ok we can remove it
- */
-
- const uint32_t mantissa_mask =
- (1 << (format->mantissa_bits + 1)) - 1;
-
- const uint32_t exponenta_mask =
- (1 << (format->exponenta_bits + 1)) - 1;
-
- if (mantissa & ~mantissa_mask) {
- BREAK_TO_DEBUGGER();
- mantissa = mantissa_mask;
- }
-
- if (exponenta & ~exponenta_mask) {
- BREAK_TO_DEBUGGER();
- exponenta = exponenta_mask;
- }
-
- /* end of verification code */
-
- while (i < format->mantissa_bits) {
- uint32_t mask = 1 << i;
-
- if (mantissa & mask)
- value |= mask;
-
- ++i;
- }
-
- while (j < format->exponenta_bits) {
- uint32_t mask = 1 << j;
-
- if (exponenta & mask)
- value |= mask << i;
-
- ++j;
- }
-
- if (negative && format->sign)
- value |= 1 << (i + j);
-
- *result = value;
-
- return true;
-}
-
-static bool convert_to_custom_float_format(
- struct fixed31_32 value,
- const struct custom_float_format *format,
- uint32_t *result)
-{
- uint32_t mantissa;
- uint32_t exponenta;
- bool negative;
-
- return build_custom_float(
- value, format, &negative, &mantissa, &exponenta) &&
- setup_custom_float(
- format, negative, mantissa, exponenta, result);
-}
-
static bool convert_to_custom_float(
struct pwl_result_data *rgb_resulted,
struct curve_points *arr_points,
@@ -579,7 +412,7 @@ static bool convert_to_custom_float(
return true;
}
-bool dce110_translate_regamma_to_hw_format(const struct dc_transfer_func
+static bool dce110_translate_regamma_to_hw_format(const struct dc_transfer_func
*output_tf, struct pwl_params *regamma_params)
{
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);
void dce110_update_pending_status(struct pipe_ctx *pipe_ctx);
-bool dce110_translate_regamma_to_hw_format(const struct dc_transfer_func
- *output_tf, struct pwl_params *regamma_params);
-
#endif /* __DC_HWSS_DCE110_H__ */
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 @@
+/*
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#ifndef CUSTOM_FLOAT_H_
+#define CUSTOM_FLOAT_H_
+
+#include "bw_fixed.h"
+#include "hw_shared.h"
+#include "opp.h"
+
+
+bool convert_to_custom_float_format(
+ struct fixed31_32 value,
+ const struct custom_float_format *format,
+ uint32_t *result);
+
+
+#endif //CUSTOM_FLOAT_H_