drm/amd/display: Fix Gamma Adjustment
authorAmy Zhang <Amy.Zhang@amd.com>
Mon, 12 Dec 2016 15:32:24 +0000 (10:32 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2017 21:04:48 +0000 (17:04 -0400)
- Gamma correction is not properly copied to the surface after refactor
- Make sure gamma correction is copied with correct retain

Signed-off-by: Amy Zhang <Amy.Zhang@amd.com>
Reviewed-by: Anthony Koo <Anthony.Koo@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/core/dc_surface.c
drivers/gpu/drm/amd/display/dc/dc.h

index de99d71f904250a38fff125bb4b8c50b40f51eaf..41df500817ad19d4370e820223eebb6293f0f4e4 100644 (file)
@@ -1302,8 +1302,8 @@ bool dc_commit_surfaces_to_target(
 
        for (i = 0; i < new_surface_count; i++) {
                updates[i].surface = new_surfaces[i];
-               updates[i].gamma = (struct dc_gamma *)new_surfaces[i]->gamma_correction;
-
+               updates[i].gamma =
+                       (struct dc_gamma *)new_surfaces[i]->gamma_correction;
                flip_addr[i].address = new_surfaces[i]->address;
                flip_addr[i].flip_immediate = new_surfaces[i]->flip_immediate;
                plane_info[i].color_space = new_surfaces[i]->color_space;
@@ -1444,6 +1444,16 @@ void dc_update_surfaces_for_target(struct dc *dc, struct dc_surface_update *upda
                                        pipe_ctx->scl_data.recout.width -= 2;
                                }
                        }
+
+                       if (updates[i].gamma) {
+                               if (surface->public.gamma_correction != NULL)
+                                       dc_gamma_release(surface->public.
+                                                       gamma_correction);
+
+                               dc_gamma_retain(updates[i].gamma);
+                               surface->public.gamma_correction =
+                                                       updates[i].gamma;
+                       }
                }
        }
 
index b89d3b5d0ba0bb1dbb79e74ff9fbd9dced737890..06d8b326714ab1d389455d7be817956d3b0eebf6 100644 (file)
@@ -64,7 +64,8 @@ static bool construct(struct dc_context *ctx, struct surface *surface)
 
 static void destruct(struct surface *surface)
 {
-
+       if (surface->protected.public.gamma_correction != NULL)
+               dc_gamma_release(surface->protected.public.gamma_correction);
 }
 
 /*******************************************************************************
index bb7cdde3e37bc2ef0abfff211c2608120f04f2e1..7733292d42f87f23d9a415d66dc2f4305a8a7011 100644 (file)
@@ -312,6 +312,7 @@ const struct dc_surface_status *dc_surface_get_status(
 void dc_surface_retain(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_release(const struct dc_gamma *dc_gamma);
 struct dc_gamma *dc_create_gamma(void);