Commit aff20230 authored by Yongqiang Sun's avatar Yongqiang Sun Committed by Alex Deucher

drm/amd/display: Set gamma to NULL at release

Signed-off-by: default avatarYongqiang Sun <yongqiang.sun@amd.com>
Reviewed-by: default avatarTony Cheng <Tony.Cheng@amd.com>
Acked-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent d5de97a2
...@@ -1458,7 +1458,7 @@ void dc_update_surfaces_for_target(struct dc *dc, struct dc_surface_update *upda ...@@ -1458,7 +1458,7 @@ void dc_update_surfaces_for_target(struct dc *dc, struct dc_surface_update *upda
if (updates[i].gamma && if (updates[i].gamma &&
updates[i].gamma != surface->public.gamma_correction) { updates[i].gamma != surface->public.gamma_correction) {
if (surface->public.gamma_correction != NULL) if (surface->public.gamma_correction != NULL)
dc_gamma_release(surface->public. dc_gamma_release(&surface->public.
gamma_correction); gamma_correction);
dc_gamma_retain(updates[i].gamma); dc_gamma_retain(updates[i].gamma);
......
...@@ -74,8 +74,7 @@ static bool construct(struct dc_context *ctx, struct surface *surface) ...@@ -74,8 +74,7 @@ static bool construct(struct dc_context *ctx, struct surface *surface)
static void destruct(struct surface *surface) static void destruct(struct surface *surface)
{ {
if (surface->protected.public.gamma_correction != NULL) { if (surface->protected.public.gamma_correction != NULL) {
dc_gamma_release(surface->protected.public.gamma_correction); dc_gamma_release(&surface->protected.public.gamma_correction);
surface->protected.public.gamma_correction = NULL;
} }
if (surface->protected.public.in_transfer_func != NULL) { if (surface->protected.public.in_transfer_func != NULL) {
dc_transfer_func_release( dc_transfer_func_release(
...@@ -189,15 +188,17 @@ void dc_gamma_retain(const struct dc_gamma *dc_gamma) ...@@ -189,15 +188,17 @@ void dc_gamma_retain(const struct dc_gamma *dc_gamma)
++gamma->ref_count; ++gamma->ref_count;
} }
void dc_gamma_release(const struct dc_gamma *dc_gamma) void dc_gamma_release(const struct dc_gamma **dc_gamma)
{ {
struct gamma *gamma = DC_GAMMA_TO_GAMMA(dc_gamma); struct gamma *gamma = DC_GAMMA_TO_GAMMA(*dc_gamma);
ASSERT(gamma->ref_count > 0); ASSERT(gamma->ref_count > 0);
--gamma->ref_count; --gamma->ref_count;
if (gamma->ref_count == 0) if (gamma->ref_count == 0)
dm_free(gamma); dm_free(gamma);
*dc_gamma = NULL;
} }
struct dc_gamma *dc_create_gamma() struct dc_gamma *dc_create_gamma()
......
...@@ -318,7 +318,7 @@ void dc_surface_retain(const struct dc_surface *dc_surface); ...@@ -318,7 +318,7 @@ void dc_surface_retain(const struct dc_surface *dc_surface);
void dc_surface_release(const struct dc_surface *dc_surface); void dc_surface_release(const struct dc_surface *dc_surface);
void dc_gamma_retain(const struct dc_gamma *dc_gamma); void dc_gamma_retain(const struct dc_gamma *dc_gamma);
void dc_gamma_release(const struct dc_gamma *dc_gamma); void dc_gamma_release(const struct dc_gamma **dc_gamma);
struct dc_gamma *dc_create_gamma(void); struct dc_gamma *dc_create_gamma(void);
void dc_transfer_func_retain(const struct dc_transfer_func *dc_tf); void dc_transfer_func_retain(const struct dc_transfer_func *dc_tf);
......
...@@ -1557,7 +1557,7 @@ void mod_color_destroy(struct mod_color *mod_color) ...@@ -1557,7 +1557,7 @@ void mod_color_destroy(struct mod_color *mod_color)
for (i = 0; i < core_color->num_sinks; i++) for (i = 0; i < core_color->num_sinks; i++)
if (core_color->state[i].gamma) if (core_color->state[i].gamma)
dc_gamma_release(core_color->state[i].gamma); dc_gamma_release(&core_color->state[i].gamma);
dm_free(core_color->state); dm_free(core_color->state);
...@@ -1749,8 +1749,7 @@ bool mod_color_remove_sink(struct mod_color *mod_color, ...@@ -1749,8 +1749,7 @@ bool mod_color_remove_sink(struct mod_color *mod_color,
for (i = 0; i < core_color->num_sinks; i++) { for (i = 0; i < core_color->num_sinks; i++) {
if (core_color->caps[i].sink == sink) { if (core_color->caps[i].sink == sink) {
if (core_color->state[i].gamma) { if (core_color->state[i].gamma) {
dc_gamma_release(core_color->state[i].gamma); dc_gamma_release(&core_color->state[i].gamma);
core_color->state[i].gamma = NULL;
} }
/* To remove this sink, shift everything after down */ /* To remove this sink, shift everything after down */
...@@ -2444,8 +2443,7 @@ bool mod_color_set_input_gamma_correction(struct mod_color *mod_color, ...@@ -2444,8 +2443,7 @@ bool mod_color_set_input_gamma_correction(struct mod_color *mod_color,
if (core_color->state[sink_index].gamma != gamma) { if (core_color->state[sink_index].gamma != gamma) {
if (core_color->state[sink_index].gamma) if (core_color->state[sink_index].gamma)
dc_gamma_release( dc_gamma_release(
core_color->state[sink_index]. &core_color->state[sink_index].gamma);
gamma);
dc_gamma_retain(gamma); dc_gamma_retain(gamma);
core_color->state[sink_index].gamma = gamma; core_color->state[sink_index].gamma = gamma;
......
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