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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
/*
* Copyright 2015 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
/* DC interface (public) */
#include "dm_services.h"
#include "dc.h"
/* DC core (private) */
#include "core_types.h"
#include "transform.h"
/*******************************************************************************
* Private functions
******************************************************************************/
static bool construct(struct dc_context *ctx, struct dc_plane_state *plane_state)
{
plane_state->ctx = ctx;
memset(&plane_state->hdr_static_ctx,
0, sizeof(struct dc_hdr_static_metadata));
return true;
}
static void destruct(struct dc_plane_state *plane_state)
{
if (plane_state->gamma_correction != NULL) {
dc_gamma_release(&plane_state->gamma_correction);
}
if (plane_state->in_transfer_func != NULL) {
dc_transfer_func_release(
plane_state->in_transfer_func);
plane_state->in_transfer_func = NULL;
}
}
/*******************************************************************************
* Public functions
******************************************************************************/
void enable_surface_flip_reporting(struct dc_plane_state *plane_state,
uint32_t controller_id)
{
plane_state->irq_source = controller_id + DC_IRQ_SOURCE_PFLIP1 - 1;
/*register_flip_interrupt(surface);*/
}
struct dc_plane_state *dc_create_plane_state(struct dc *dc)
{
struct dc *core_dc = dc;
struct dc_plane_state *plane_state = kzalloc(sizeof(*plane_state),
GFP_KERNEL);
if (NULL == plane_state)
goto alloc_fail;
if (false == construct(core_dc->ctx, plane_state))
goto construct_fail;
atomic_inc(&plane_state->ref_count);
return plane_state;
construct_fail:
kfree(plane_state);
alloc_fail:
return NULL;
}
const struct dc_plane_status *dc_plane_get_status(
const struct dc_plane_state *plane_state)
{
const struct dc_plane_status *plane_status;
struct dc *core_dc;
int i;
if (!plane_state ||
!plane_state->ctx ||
!plane_state->ctx->dc) {
ASSERT(0);
return NULL; /* remove this if above assert never hit */
}
plane_status = &plane_state->status;
core_dc = plane_state->ctx->dc;
if (core_dc->current_state == NULL)
return NULL;
for (i = 0; i < core_dc->res_pool->pipe_count; i++) {
struct pipe_ctx *pipe_ctx =
&core_dc->current_state->res_ctx.pipe_ctx[i];
if (pipe_ctx->plane_state != plane_state)
continue;
core_dc->hwss.update_pending_status(pipe_ctx);
}
return plane_status;
}
void dc_plane_state_retain(struct dc_plane_state *plane_state)
{
ASSERT(atomic_read(&plane_state->ref_count) > 0);
atomic_inc(&plane_state->ref_count);
}
void dc_plane_state_release(struct dc_plane_state *plane_state)
{
ASSERT(atomic_read(&plane_state->ref_count) > 0);
atomic_dec(&plane_state->ref_count);
if (atomic_read(&plane_state->ref_count) == 0) {
destruct(plane_state);
kfree(plane_state);
}
}
void dc_gamma_retain(struct dc_gamma *gamma)
{
ASSERT(atomic_read(&gamma->ref_count) > 0);
atomic_inc(&gamma->ref_count);
}
void dc_gamma_release(struct dc_gamma **gamma)
{
ASSERT(atomic_read(&(*gamma)->ref_count) > 0);
atomic_dec(&(*gamma)->ref_count);
if (atomic_read(&(*gamma)->ref_count) == 0)
kfree((*gamma));
*gamma = NULL;
}
struct dc_gamma *dc_create_gamma()
{
struct dc_gamma *gamma = kzalloc(sizeof(*gamma), GFP_KERNEL);
if (gamma == NULL)
goto alloc_fail;
atomic_inc(&gamma->ref_count);
return gamma;
alloc_fail:
return NULL;
}
void dc_transfer_func_retain(struct dc_transfer_func *tf)
{
ASSERT(atomic_read(&tf->ref_count) > 0);
atomic_inc(&tf->ref_count);
}
void dc_transfer_func_release(struct dc_transfer_func *tf)
{
ASSERT(atomic_read(&tf->ref_count) > 0);
atomic_dec(&tf->ref_count);
if (atomic_read(&tf->ref_count) == 0)
kfree(tf);
}
struct dc_transfer_func *dc_create_transfer_func()
{
struct dc_transfer_func *tf = kzalloc(sizeof(*tf), GFP_KERNEL);
if (tf == NULL)
goto alloc_fail;
atomic_inc(&tf->ref_count);
return tf;
alloc_fail:
return NULL;
}
|