[PATCH 27/81] drm/amd/display: Create dm_atomic_state

sunpeng.li at amd.com sunpeng.li at amd.com
Tue Jul 25 13:53:47 UTC 2017


From: Harry Wentland <harry.wentland at amd.com>

We really want to use the new private_atomic_state but can't right now
as we have to maintain some backward compatibility to older kernels. For
now let's follow Intel's approach and extend the drm_atomic_state.

Change-Id: I848bda7aa11d7731684e90e0d9e88191e8db8fb2
Signed-off-by: Harry Wentland <harry.wentland at amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng at amd.com>
Acked-by: Harry Wentland <Harry.Wentland at amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 37 +++++++++++++++++++++-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.h    |  8 +++--
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index e856f62..1b69848 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -634,11 +634,46 @@ const struct amdgpu_ip_block_version dm_ip_block =
 	.funcs = &amdgpu_dm_funcs,
 };
 
+
+struct drm_atomic_state *
+dm_atomic_state_alloc(struct drm_device *dev)
+{
+	struct dm_atomic_state *state = kzalloc(sizeof(*state), GFP_KERNEL);
+
+	if (!state || drm_atomic_state_init(dev, &state->base) < 0) {
+		kfree(state);
+		return NULL;
+	}
+
+	return &state->base;
+}
+
+void dm_atomic_state_clear(struct drm_atomic_state *s)
+{
+	struct dm_atomic_state *state = to_dm_atomic_state(s);
+	drm_atomic_state_default_clear(&state->base);
+}
+
+
+static void dm_atomic_state_free(struct drm_atomic_state *state)
+{
+	struct dm_atomic_state *dm_state = to_dm_atomic_state(state);
+
+	drm_atomic_state_default_release(state);
+
+	kfree(dm_state);
+}
+
+
+
 static const struct drm_mode_config_funcs amdgpu_dm_mode_funcs = {
 	.fb_create = amdgpu_user_framebuffer_create,
 	.output_poll_changed = amdgpu_output_poll_changed,
 	.atomic_check = amdgpu_dm_atomic_check,
-	.atomic_commit = drm_atomic_helper_commit
+	.atomic_commit = drm_atomic_helper_commit,
+	.atomic_state_alloc = dm_atomic_state_alloc,
+	.atomic_state_clear = dm_atomic_state_clear,
+	.atomic_state_free = dm_atomic_state_free,
 };
 
 static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = {
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h
index f5f4936..9ba7fdd 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h
@@ -27,6 +27,7 @@
 #define __AMDGPU_DM_TYPES_H__
 
 #include <drm/drmP.h>
+#include <drm/drm_atomic.h>
 
 struct amdgpu_framebuffer;
 struct amdgpu_display_manager;
@@ -48,11 +49,12 @@ struct dm_crtc_state {
 
 #define to_dm_crtc_state(x)    container_of(x, struct dm_crtc_state, base)
 
-struct dm_plane_state {
-	struct drm_plane_state base;
-	struct dc_surface *dc_surface;
+struct dm_atomic_state {
+	struct drm_atomic_state base;
 };
 
+#define to_dm_atomic_state(x) container_of(x, struct dm_atomic_state, base)
+
 
 /*TODO Jodan Hersen use the one in amdgpu_dm*/
 int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
-- 
2.7.4



More information about the amd-gfx mailing list