aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.14.71/0553-drm-amd-display-Create-dm_crtc_state-stubs.patch
blob: 77c7a6e29aca7d99db71cdefec9fd4ef4b7e30cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
From 67278a2f946afa91de077344b24095ccfa034606 Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Date: Tue, 27 Jun 2017 17:24:00 -0400
Subject: [PATCH 0553/4131] drm/amd/display: Create dm_crtc_state stubs.

These stubs are initial only since we need to flatten
DC objects (steran at least) to implement deep copy.

Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c    | 74 +++++++++++++++++++++-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.h    | 10 +++
 2 files changed, 81 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
index 6cbbf77..abbf575 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
@@ -1018,16 +1018,84 @@ static int amdgpu_atomic_helper_page_flip(struct drm_crtc *crtc,
 	return ret;
 }
 
+static void dm_crtc_destroy_state(struct drm_crtc *crtc,
+					   struct drm_crtc_state *state)
+{
+	struct dm_crtc_state *cur = to_dm_crtc_state(state);
+
+	if (cur->dc_stream) {
+		/* TODO Destroy dc_stream objects are stream object is flattened */
+		dm_free(cur->dc_stream);
+	} else
+		WARN_ON(1);
+
+	__drm_atomic_helper_crtc_destroy_state(state);
+
+
+	kfree(state);
+}
+
+static void dm_crtc_reset_state(struct drm_crtc *crtc)
+{
+	struct dm_crtc_state *state;
+
+	if (crtc->state)
+		dm_crtc_destroy_state(crtc, crtc->state);
+
+	state = kzalloc(sizeof(*state), GFP_KERNEL);
+	if (WARN_ON(!state))
+		return;
+
+
+	crtc->state = &state->base;
+	crtc->state->crtc = crtc;
+
+	state->dc_stream = dm_alloc(sizeof(*state->dc_stream));
+	WARN_ON(!state->dc_stream);
+}
+
+static struct drm_crtc_state *
+dm_crtc_duplicate_state(struct drm_crtc *crtc)
+{
+	struct dm_crtc_state *state, *cur;
+	struct dc_stream *dc_stream;
+
+	if (WARN_ON(!crtc->state))
+		return NULL;
+
+	cur = to_dm_crtc_state(crtc->state);
+	if (WARN_ON(!cur->dc_stream))
+		return NULL;
+
+	dc_stream = dm_alloc(sizeof(*dc_stream));
+	if (WARN_ON(!dc_stream))
+		return NULL;
+
+	state = dm_alloc(sizeof(*state));
+	if (WARN_ON(!state)) {
+		dm_free(dc_stream);
+		return NULL;
+	}
+
+	__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
+
+	state->dc_stream = dc_stream;
+
+	/* TODO Duplicate dc_stream after objects are stream object is flattened */
+
+	return &state->base;
+}
+
 /* Implemented only the options currently availible for the driver */
 static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = {
-	.reset = drm_atomic_helper_crtc_reset,
+	.reset = dm_crtc_reset_state,
 	.destroy = amdgpu_dm_crtc_destroy,
 	.gamma_set = drm_atomic_helper_legacy_gamma_set,
 	.set_config = drm_atomic_helper_set_config,
 	.set_property = drm_atomic_helper_crtc_set_property,
 	.page_flip = amdgpu_atomic_helper_page_flip,
-	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
-	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+	.atomic_duplicate_state = dm_crtc_duplicate_state,
+	.atomic_destroy_state = dm_crtc_destroy_state,
 };
 
 static enum drm_connector_status
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 6411dd1..1091725 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
@@ -32,6 +32,16 @@ struct amdgpu_framebuffer;
 struct amdgpu_display_manager;
 struct dc_validation_set;
 struct dc_surface;
+/* TODO rename to dc_stream_state */
+struct  dc_stream;
+
+
+struct dm_crtc_state {
+	struct drm_crtc_state base;
+	struct dc_stream *dc_stream;
+};
+
+#define to_dm_crtc_state(x)    container_of(x, struct dm_crtc_state, base)
 
 struct dm_plane_state {
 	struct drm_plane_state base;
-- 
2.7.4