forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/gpu/drm/amd/display/dc/core/dc_surface.c
....@@ -23,6 +23,8 @@
2323 *
2424 */
2525
26
+#include <linux/mm.h>
27
+
2628 /* DC interface (public) */
2729 #include "dm_services.h"
2830 #include "dc.h"
....@@ -35,18 +37,33 @@
3537 /*******************************************************************************
3638 * Private functions
3739 ******************************************************************************/
38
-static void construct(struct dc_context *ctx, struct dc_plane_state *plane_state)
40
+static void dc_plane_construct(struct dc_context *ctx, struct dc_plane_state *plane_state)
3941 {
4042 plane_state->ctx = ctx;
4143
4244 plane_state->gamma_correction = dc_create_gamma();
43
- plane_state->gamma_correction->is_identity = true;
45
+ if (plane_state->gamma_correction != NULL)
46
+ plane_state->gamma_correction->is_identity = true;
4447
4548 plane_state->in_transfer_func = dc_create_transfer_func();
46
- plane_state->in_transfer_func->type = TF_TYPE_BYPASS;
49
+ if (plane_state->in_transfer_func != NULL) {
50
+ plane_state->in_transfer_func->type = TF_TYPE_BYPASS;
51
+ }
52
+ plane_state->in_shaper_func = dc_create_transfer_func();
53
+ if (plane_state->in_shaper_func != NULL) {
54
+ plane_state->in_shaper_func->type = TF_TYPE_BYPASS;
55
+ }
56
+
57
+ plane_state->lut3d_func = dc_create_3dlut_func();
58
+
59
+ plane_state->blend_tf = dc_create_transfer_func();
60
+ if (plane_state->blend_tf != NULL) {
61
+ plane_state->blend_tf->type = TF_TYPE_BYPASS;
62
+ }
63
+
4764 }
4865
49
-static void destruct(struct dc_plane_state *plane_state)
66
+static void dc_plane_destruct(struct dc_plane_state *plane_state)
5067 {
5168 if (plane_state->gamma_correction != NULL) {
5269 dc_gamma_release(&plane_state->gamma_correction);
....@@ -56,6 +73,22 @@
5673 plane_state->in_transfer_func);
5774 plane_state->in_transfer_func = NULL;
5875 }
76
+ if (plane_state->in_shaper_func != NULL) {
77
+ dc_transfer_func_release(
78
+ plane_state->in_shaper_func);
79
+ plane_state->in_shaper_func = NULL;
80
+ }
81
+ if (plane_state->lut3d_func != NULL) {
82
+ dc_3dlut_func_release(
83
+ plane_state->lut3d_func);
84
+ plane_state->lut3d_func = NULL;
85
+ }
86
+ if (plane_state->blend_tf != NULL) {
87
+ dc_transfer_func_release(
88
+ plane_state->blend_tf);
89
+ plane_state->blend_tf = NULL;
90
+ }
91
+
5992 }
6093
6194 /*******************************************************************************
....@@ -70,16 +103,14 @@
70103
71104 struct dc_plane_state *dc_create_plane_state(struct dc *dc)
72105 {
73
- struct dc *core_dc = dc;
74
-
75106 struct dc_plane_state *plane_state = kvzalloc(sizeof(*plane_state),
76
- GFP_KERNEL);
107
+ GFP_KERNEL);
77108
78109 if (NULL == plane_state)
79110 return NULL;
80111
81112 kref_init(&plane_state->refcount);
82
- construct(core_dc->ctx, plane_state);
113
+ dc_plane_construct(dc->ctx, plane_state);
83114
84115 return plane_state;
85116 }
....@@ -99,7 +130,7 @@
99130 const struct dc_plane_state *plane_state)
100131 {
101132 const struct dc_plane_status *plane_status;
102
- struct dc *core_dc;
133
+ struct dc *dc;
103134 int i;
104135
105136 if (!plane_state ||
....@@ -110,19 +141,32 @@
110141 }
111142
112143 plane_status = &plane_state->status;
113
- core_dc = plane_state->ctx->dc;
144
+ dc = plane_state->ctx->dc;
114145
115
- if (core_dc->current_state == NULL)
146
+ if (dc->current_state == NULL)
116147 return NULL;
117148
118
- for (i = 0; i < core_dc->res_pool->pipe_count; i++) {
149
+ /* Find the current plane state and set its pending bit to false */
150
+ for (i = 0; i < dc->res_pool->pipe_count; i++) {
119151 struct pipe_ctx *pipe_ctx =
120
- &core_dc->current_state->res_ctx.pipe_ctx[i];
152
+ &dc->current_state->res_ctx.pipe_ctx[i];
121153
122154 if (pipe_ctx->plane_state != plane_state)
123155 continue;
124156
125
- core_dc->hwss.update_pending_status(pipe_ctx);
157
+ pipe_ctx->plane_state->status.is_flip_pending = false;
158
+
159
+ break;
160
+ }
161
+
162
+ for (i = 0; i < dc->res_pool->pipe_count; i++) {
163
+ struct pipe_ctx *pipe_ctx =
164
+ &dc->current_state->res_ctx.pipe_ctx[i];
165
+
166
+ if (pipe_ctx->plane_state != plane_state)
167
+ continue;
168
+
169
+ dc->hwss.update_pending_status(pipe_ctx);
126170 }
127171
128172 return plane_status;
....@@ -136,7 +180,7 @@
136180 static void dc_plane_state_free(struct kref *kref)
137181 {
138182 struct dc_plane_state *plane_state = container_of(kref, struct dc_plane_state, refcount);
139
- destruct(plane_state);
183
+ dc_plane_destruct(plane_state);
140184 kvfree(plane_state);
141185 }
142186
....@@ -207,4 +251,38 @@
207251 return NULL;
208252 }
209253
254
+static void dc_3dlut_func_free(struct kref *kref)
255
+{
256
+ struct dc_3dlut *lut = container_of(kref, struct dc_3dlut, refcount);
257
+
258
+ kvfree(lut);
259
+}
260
+
261
+struct dc_3dlut *dc_create_3dlut_func(void)
262
+{
263
+ struct dc_3dlut *lut = kvzalloc(sizeof(*lut), GFP_KERNEL);
264
+
265
+ if (lut == NULL)
266
+ goto alloc_fail;
267
+
268
+ kref_init(&lut->refcount);
269
+ lut->state.raw = 0;
270
+
271
+ return lut;
272
+
273
+alloc_fail:
274
+ return NULL;
275
+
276
+}
277
+
278
+void dc_3dlut_func_release(struct dc_3dlut *lut)
279
+{
280
+ kref_put(&lut->refcount, dc_3dlut_func_free);
281
+}
282
+
283
+void dc_3dlut_func_retain(struct dc_3dlut *lut)
284
+{
285
+ kref_get(&lut->refcount);
286
+}
287
+
210288