Commit 8ae5b155 authored by Lewis Huang's avatar Lewis Huang Committed by Alex Deucher

drm/amd/display: change global buffer to local buffer

[Why]
Multi-adapter calculate regamma table at the same time.
Two thread used the same global variable cause race
condition.

[How]
Change global buffer to local buffer
Signed-off-by: default avatarLewis Huang <Lewis.Huang@amd.com>
Reviewed-by: default avatarAric Cyr <Aric.Cyr@amd.com>
Acked-by: default avatarQingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent eec3303d
...@@ -195,10 +195,13 @@ static int __set_legacy_tf(struct dc_transfer_func *func, ...@@ -195,10 +195,13 @@ static int __set_legacy_tf(struct dc_transfer_func *func,
bool has_rom) bool has_rom)
{ {
struct dc_gamma *gamma = NULL; struct dc_gamma *gamma = NULL;
struct calculate_buffer cal_buffer = {0};
bool res; bool res;
ASSERT(lut && lut_size == MAX_COLOR_LEGACY_LUT_ENTRIES); ASSERT(lut && lut_size == MAX_COLOR_LEGACY_LUT_ENTRIES);
cal_buffer.buffer_index = -1;
gamma = dc_create_gamma(); gamma = dc_create_gamma();
if (!gamma) if (!gamma)
return -ENOMEM; return -ENOMEM;
...@@ -208,7 +211,7 @@ static int __set_legacy_tf(struct dc_transfer_func *func, ...@@ -208,7 +211,7 @@ static int __set_legacy_tf(struct dc_transfer_func *func,
__drm_lut_to_dc_gamma(lut, gamma, true); __drm_lut_to_dc_gamma(lut, gamma, true);
res = mod_color_calculate_regamma_params(func, gamma, true, has_rom, res = mod_color_calculate_regamma_params(func, gamma, true, has_rom,
NULL); NULL, &cal_buffer);
dc_gamma_release(&gamma); dc_gamma_release(&gamma);
...@@ -221,10 +224,13 @@ static int __set_output_tf(struct dc_transfer_func *func, ...@@ -221,10 +224,13 @@ static int __set_output_tf(struct dc_transfer_func *func,
bool has_rom) bool has_rom)
{ {
struct dc_gamma *gamma = NULL; struct dc_gamma *gamma = NULL;
struct calculate_buffer cal_buffer = {0};
bool res; bool res;
ASSERT(lut && lut_size == MAX_COLOR_LUT_ENTRIES); ASSERT(lut && lut_size == MAX_COLOR_LUT_ENTRIES);
cal_buffer.buffer_index = -1;
gamma = dc_create_gamma(); gamma = dc_create_gamma();
if (!gamma) if (!gamma)
return -ENOMEM; return -ENOMEM;
...@@ -248,7 +254,7 @@ static int __set_output_tf(struct dc_transfer_func *func, ...@@ -248,7 +254,7 @@ static int __set_output_tf(struct dc_transfer_func *func,
*/ */
gamma->type = GAMMA_CS_TFM_1D; gamma->type = GAMMA_CS_TFM_1D;
res = mod_color_calculate_regamma_params(func, gamma, false, res = mod_color_calculate_regamma_params(func, gamma, false,
has_rom, NULL); has_rom, NULL, &cal_buffer);
} }
dc_gamma_release(&gamma); dc_gamma_release(&gamma);
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
MOD_COLOR = color_gamma.o MOD_COLOR = color_gamma.o
ifdef CONFIG_DRM_AMD_DC_DCN
MOD_COLOR += color_table.o
endif
AMD_DAL_MOD_COLOR = $(addprefix $(AMDDALPATH)/modules/color/,$(MOD_COLOR)) AMD_DAL_MOD_COLOR = $(addprefix $(AMDDALPATH)/modules/color/,$(MOD_COLOR))
#$(info ************ DAL COLOR MODULE MAKEFILE ************) #$(info ************ DAL COLOR MODULE MAKEFILE ************)
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#ifndef COLOR_MOD_COLOR_GAMMA_H_ #ifndef COLOR_MOD_COLOR_GAMMA_H_
#define COLOR_MOD_COLOR_GAMMA_H_ #define COLOR_MOD_COLOR_GAMMA_H_
#include "color_table.h"
struct dc_transfer_func; struct dc_transfer_func;
struct dc_gamma; struct dc_gamma;
struct dc_transfer_func_distributed_points; struct dc_transfer_func_distributed_points;
...@@ -83,6 +85,12 @@ struct freesync_hdr_tf_params { ...@@ -83,6 +85,12 @@ struct freesync_hdr_tf_params {
unsigned int skip_tm; // skip tm unsigned int skip_tm; // skip tm
}; };
struct calculate_buffer {
int buffer_index;
struct fixed31_32 buffer[NUM_PTS_IN_REGION];
struct fixed31_32 gamma_of_2;
};
struct translate_from_linear_space_args { struct translate_from_linear_space_args {
struct fixed31_32 arg; struct fixed31_32 arg;
struct fixed31_32 a0; struct fixed31_32 a0;
...@@ -90,6 +98,7 @@ struct translate_from_linear_space_args { ...@@ -90,6 +98,7 @@ struct translate_from_linear_space_args {
struct fixed31_32 a2; struct fixed31_32 a2;
struct fixed31_32 a3; struct fixed31_32 a3;
struct fixed31_32 gamma; struct fixed31_32 gamma;
struct calculate_buffer *cal_buffer;
}; };
void setup_x_points_distribution(void); void setup_x_points_distribution(void);
...@@ -99,7 +108,8 @@ void precompute_de_pq(void); ...@@ -99,7 +108,8 @@ void precompute_de_pq(void);
bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf, bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
const struct dc_gamma *ramp, bool mapUserRamp, bool canRomBeUsed, const struct dc_gamma *ramp, bool mapUserRamp, bool canRomBeUsed,
const struct freesync_hdr_tf_params *fs_params); const struct freesync_hdr_tf_params *fs_params,
struct calculate_buffer *cal_buffer);
bool mod_color_calculate_degamma_params(struct dc_color_caps *dc_caps, bool mod_color_calculate_degamma_params(struct dc_color_caps *dc_caps,
struct dc_transfer_func *output_tf, struct dc_transfer_func *output_tf,
...@@ -109,10 +119,12 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans, ...@@ -109,10 +119,12 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
struct dc_transfer_func_distributed_points *points); struct dc_transfer_func_distributed_points *points);
bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf, bool calculate_user_regamma_coeff(struct dc_transfer_func *output_tf,
const struct regamma_lut *regamma); const struct regamma_lut *regamma,
struct calculate_buffer *cal_buffer);
bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf, bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf,
const struct regamma_lut *regamma); const struct regamma_lut *regamma,
struct calculate_buffer *cal_buffer);
#endif /* COLOR_MOD_COLOR_GAMMA_H_ */ #endif /* COLOR_MOD_COLOR_GAMMA_H_ */
/*
* Copyright (c) 2019 Advanced Micro Devices, Inc. (unpublished)
*
* 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 "color_table.h"
static struct fixed31_32 pq_table[MAX_HW_POINTS + 2];
static struct fixed31_32 de_pq_table[MAX_HW_POINTS + 2];
static bool pq_initialized;
static bool de_pg_initialized;
bool mod_color_is_table_init(enum table_type type)
{
bool ret = false;
if (type == type_pq_table)
ret = pq_initialized;
if (type == type_de_pq_table)
ret = de_pg_initialized;
return ret;
}
struct fixed31_32 *mod_color_get_table(enum table_type type)
{
struct fixed31_32 *table = NULL;
if (type == type_pq_table)
table = pq_table;
if (type == type_de_pq_table)
table = de_pq_table;
return table;
}
void mod_color_set_table_init_state(enum table_type type, bool state)
{
if (type == type_pq_table)
pq_initialized = state;
if (type == type_de_pq_table)
de_pg_initialized = state;
}
/*
* Copyright 2016 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 COLOR_MOD_COLOR_TABLE_H_
#define COLOR_MOD_COLOR_TABLE_H_
#include "dc_types.h"
#define NUM_PTS_IN_REGION 16
#define NUM_REGIONS 32
#define MAX_HW_POINTS (NUM_PTS_IN_REGION*NUM_REGIONS)
enum table_type {
type_pq_table,
type_de_pq_table
};
bool mod_color_is_table_init(enum table_type type);
struct fixed31_32 *mod_color_get_table(enum table_type type);
void mod_color_set_table_init_state(enum table_type type, bool state);
#endif /* COLOR_MOD_COLOR_TABLE_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment