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#include "dm_services.h"
28#include "dc.h"
29
30
31#include "core_types.h"
32#include "transform.h"
33#include "dpp.h"
34
35
36
37
38static void construct(struct dc_context *ctx, struct dc_plane_state *plane_state)
39{
40 plane_state->ctx = ctx;
41
42 plane_state->gamma_correction = dc_create_gamma();
43 plane_state->gamma_correction->is_identity = true;
44
45 plane_state->in_transfer_func = dc_create_transfer_func();
46 plane_state->in_transfer_func->type = TF_TYPE_BYPASS;
47 plane_state->in_transfer_func->ctx = ctx;
48}
49
50static void destruct(struct dc_plane_state *plane_state)
51{
52 if (plane_state->gamma_correction != NULL) {
53 dc_gamma_release(&plane_state->gamma_correction);
54 }
55 if (plane_state->in_transfer_func != NULL) {
56 dc_transfer_func_release(
57 plane_state->in_transfer_func);
58 plane_state->in_transfer_func = NULL;
59 }
60}
61
62
63
64
65void enable_surface_flip_reporting(struct dc_plane_state *plane_state,
66 uint32_t controller_id)
67{
68 plane_state->irq_source = controller_id + DC_IRQ_SOURCE_PFLIP1 - 1;
69
70}
71
72struct dc_plane_state *dc_create_plane_state(struct dc *dc)
73{
74 struct dc *core_dc = dc;
75
76 struct dc_plane_state *plane_state = kvzalloc(sizeof(*plane_state),
77 GFP_KERNEL);
78
79 if (NULL == plane_state)
80 return NULL;
81
82 kref_init(&plane_state->refcount);
83 construct(core_dc->ctx, plane_state);
84
85 return plane_state;
86}
87
88
89
90
91
92
93
94
95
96
97
98
99const struct dc_plane_status *dc_plane_get_status(
100 const struct dc_plane_state *plane_state)
101{
102 const struct dc_plane_status *plane_status;
103 struct dc *core_dc;
104 int i;
105
106 if (!plane_state ||
107 !plane_state->ctx ||
108 !plane_state->ctx->dc) {
109 ASSERT(0);
110 return NULL;
111 }
112
113 plane_status = &plane_state->status;
114 core_dc = plane_state->ctx->dc;
115
116 if (core_dc->current_state == NULL)
117 return NULL;
118
119 for (i = 0; i < core_dc->res_pool->pipe_count; i++) {
120 struct pipe_ctx *pipe_ctx =
121 &core_dc->current_state->res_ctx.pipe_ctx[i];
122
123 if (pipe_ctx->plane_state != plane_state)
124 continue;
125
126 core_dc->hwss.update_pending_status(pipe_ctx);
127 }
128
129 return plane_status;
130}
131
132void dc_plane_state_retain(struct dc_plane_state *plane_state)
133{
134 kref_get(&plane_state->refcount);
135}
136
137static void dc_plane_state_free(struct kref *kref)
138{
139 struct dc_plane_state *plane_state = container_of(kref, struct dc_plane_state, refcount);
140 destruct(plane_state);
141 kvfree(plane_state);
142}
143
144void dc_plane_state_release(struct dc_plane_state *plane_state)
145{
146 kref_put(&plane_state->refcount, dc_plane_state_free);
147}
148
149void dc_gamma_retain(struct dc_gamma *gamma)
150{
151 kref_get(&gamma->refcount);
152}
153
154static void dc_gamma_free(struct kref *kref)
155{
156 struct dc_gamma *gamma = container_of(kref, struct dc_gamma, refcount);
157 kvfree(gamma);
158}
159
160void dc_gamma_release(struct dc_gamma **gamma)
161{
162 kref_put(&(*gamma)->refcount, dc_gamma_free);
163 *gamma = NULL;
164}
165
166struct dc_gamma *dc_create_gamma(void)
167{
168 struct dc_gamma *gamma = kvzalloc(sizeof(*gamma), GFP_KERNEL);
169
170 if (gamma == NULL)
171 goto alloc_fail;
172
173 kref_init(&gamma->refcount);
174 return gamma;
175
176alloc_fail:
177 return NULL;
178}
179
180void dc_transfer_func_retain(struct dc_transfer_func *tf)
181{
182 kref_get(&tf->refcount);
183}
184
185static void dc_transfer_func_free(struct kref *kref)
186{
187 struct dc_transfer_func *tf = container_of(kref, struct dc_transfer_func, refcount);
188 kvfree(tf);
189}
190
191void dc_transfer_func_release(struct dc_transfer_func *tf)
192{
193 kref_put(&tf->refcount, dc_transfer_func_free);
194}
195
196struct dc_transfer_func *dc_create_transfer_func(void)
197{
198 struct dc_transfer_func *tf = kvzalloc(sizeof(*tf), GFP_KERNEL);
199
200 if (tf == NULL)
201 goto alloc_fail;
202
203 kref_init(&tf->refcount);
204
205 return tf;
206
207alloc_fail:
208 return NULL;
209}
210
211
212