aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2015-01-28 09:01:22 -0500
committerThierry Reding <treding@nvidia.com>2015-04-02 12:49:20 -0400
commit3b59b7ac02e434f267f7cb1ef8fe48c23ddbe9a2 (patch)
tree877536afd737fae1bdcd1634a1fb5d79b455fb59
parentf5e7840b0c4368f8cdbb055188c2a0eef50c3052 (diff)
drm/tegra: dc: Use base atomic state helpers
Instead of duplicating the code, make use of the newly introduced atomic state duplicate and destroy helpers. This allows changes to the base atomic state handling to automatically propagate to the Tegra driver and thereby prevent breakage resulting from both copies going out of sync. Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/gpu/drm/tegra/dc.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 9e329465ab11..d12c701ed292 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -425,8 +425,8 @@ static void tegra_plane_reset(struct drm_plane *plane)
425{ 425{
426 struct tegra_plane_state *state; 426 struct tegra_plane_state *state;
427 427
428 if (plane->state && plane->state->fb) 428 if (plane->state)
429 drm_framebuffer_unreference(plane->state->fb); 429 __drm_atomic_helper_plane_destroy_state(plane, plane->state);
430 430
431 kfree(plane->state); 431 kfree(plane->state);
432 plane->state = NULL; 432 plane->state = NULL;
@@ -443,12 +443,14 @@ static struct drm_plane_state *tegra_plane_atomic_duplicate_state(struct drm_pla
443 struct tegra_plane_state *state = to_tegra_plane_state(plane->state); 443 struct tegra_plane_state *state = to_tegra_plane_state(plane->state);
444 struct tegra_plane_state *copy; 444 struct tegra_plane_state *copy;
445 445
446 copy = kmemdup(state, sizeof(*state), GFP_KERNEL); 446 copy = kmalloc(sizeof(*copy), GFP_KERNEL);
447 if (!copy) 447 if (!copy)
448 return NULL; 448 return NULL;
449 449
450 if (copy->base.fb) 450 __drm_atomic_helper_plane_duplicate_state(plane, &copy->base);
451 drm_framebuffer_reference(copy->base.fb); 451 copy->tiling = state->tiling;
452 copy->format = state->format;
453 copy->swap = state->swap;
452 454
453 return &copy->base; 455 return &copy->base;
454} 456}
@@ -456,9 +458,7 @@ static struct drm_plane_state *tegra_plane_atomic_duplicate_state(struct drm_pla
456static void tegra_plane_atomic_destroy_state(struct drm_plane *plane, 458static void tegra_plane_atomic_destroy_state(struct drm_plane *plane,
457 struct drm_plane_state *state) 459 struct drm_plane_state *state)
458{ 460{
459 if (state->fb) 461 __drm_atomic_helper_plane_destroy_state(plane, state);
460 drm_framebuffer_unreference(state->fb);
461
462 kfree(state); 462 kfree(state);
463} 463}
464 464
@@ -1002,6 +1002,9 @@ static void tegra_crtc_reset(struct drm_crtc *crtc)
1002{ 1002{
1003 struct tegra_dc_state *state; 1003 struct tegra_dc_state *state;
1004 1004
1005 if (crtc->state)
1006 __drm_atomic_helper_crtc_destroy_state(crtc, crtc->state);
1007
1005 kfree(crtc->state); 1008 kfree(crtc->state);
1006 crtc->state = NULL; 1009 crtc->state = NULL;
1007 1010
@@ -1018,14 +1021,15 @@ tegra_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
1018 struct tegra_dc_state *state = to_dc_state(crtc->state); 1021 struct tegra_dc_state *state = to_dc_state(crtc->state);
1019 struct tegra_dc_state *copy; 1022 struct tegra_dc_state *copy;
1020 1023
1021 copy = kmemdup(state, sizeof(*state), GFP_KERNEL); 1024 copy = kmalloc(sizeof(*copy), GFP_KERNEL);
1022 if (!copy) 1025 if (!copy)
1023 return NULL; 1026 return NULL;
1024 1027
1025 copy->base.mode_changed = false; 1028 __drm_atomic_helper_crtc_duplicate_state(crtc, &copy->base);
1026 copy->base.active_changed = false; 1029 copy->clk = state->clk;
1027 copy->base.planes_changed = false; 1030 copy->pclk = state->pclk;
1028 copy->base.event = NULL; 1031 copy->div = state->div;
1032 copy->planes = state->planes;
1029 1033
1030 return &copy->base; 1034 return &copy->base;
1031} 1035}
@@ -1033,6 +1037,7 @@ tegra_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
1033static void tegra_crtc_atomic_destroy_state(struct drm_crtc *crtc, 1037static void tegra_crtc_atomic_destroy_state(struct drm_crtc *crtc,
1034 struct drm_crtc_state *state) 1038 struct drm_crtc_state *state)
1035{ 1039{
1040 __drm_atomic_helper_crtc_destroy_state(crtc, state);
1036 kfree(state); 1041 kfree(state);
1037} 1042}
1038 1043