]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - drivers/gpu/drm/amd/display/dc/core/dc_surface.c
2 * Copyright 2015 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 /* DC interface (public) */
27 #include "dm_services.h"
30 /* DC core (private) */
32 #include "transform.h"
34 /*******************************************************************************
36 ******************************************************************************/
38 struct core_surface
protected;
39 enum dc_irq_source irq_source
;
44 struct core_gamma
protected;
48 #define DC_SURFACE_TO_SURFACE(dc_surface) container_of(dc_surface, struct surface, protected.public)
49 #define CORE_SURFACE_TO_SURFACE(core_surface) container_of(core_surface, struct surface, protected)
51 #define DC_GAMMA_TO_GAMMA(dc_gamma) \
52 container_of(dc_gamma, struct gamma, protected.public)
53 #define CORE_GAMMA_TO_GAMMA(core_gamma) \
54 container_of(core_gamma, struct gamma, protected)
56 /*******************************************************************************
58 ******************************************************************************/
59 static bool construct(struct dc_context
*ctx
, struct surface
*surface
)
61 surface
->protected.ctx
= ctx
;
65 static void destruct(struct surface
*surface
)
70 /*******************************************************************************
72 ******************************************************************************/
73 void enable_surface_flip_reporting(struct dc_surface
*dc_surface
,
74 uint32_t controller_id
)
76 struct surface
*surface
= DC_SURFACE_TO_SURFACE(dc_surface
);
77 surface
->irq_source
= controller_id
+ DC_IRQ_SOURCE_PFLIP1
- 1;
78 /*register_flip_interrupt(surface);*/
81 struct dc_surface
*dc_create_surface(const struct dc
*dc
)
83 struct core_dc
*core_dc
= DC_TO_CORE(dc
);
85 struct surface
*surface
= dm_alloc(sizeof(*surface
));
90 if (false == construct(core_dc
->ctx
, surface
))
93 dc_surface_retain(&surface
->protected.public);
95 return &surface
->protected.public;
104 const struct dc_surface_status
*dc_surface_get_status(
105 const struct dc_surface
*dc_surface
)
107 struct dc_surface_status
*surface_status
;
108 struct core_surface
*core_surface
;
109 struct core_dc
*core_dc
;
112 if (dc_surface
== NULL
)
115 core_surface
= DC_SURFACE_TO_CORE(dc_surface
);
117 if (core_surface
== NULL
|| core_surface
->ctx
== NULL
)
120 surface_status
= &core_surface
->status
;
122 if (core_surface
->ctx
== NULL
|| core_surface
->ctx
->dc
== NULL
)
125 core_dc
= DC_TO_CORE(core_surface
->ctx
->dc
);
128 if (core_dc
->current_context
== NULL
)
131 for (i
= 0; i
< core_dc
->current_context
->res_ctx
.pool
->pipe_count
;
133 struct pipe_ctx
*pipe_ctx
=
134 &core_dc
->current_context
->res_ctx
.pipe_ctx
[i
];
136 if (pipe_ctx
->surface
!=
137 DC_SURFACE_TO_CORE(dc_surface
))
140 core_dc
->hwss
.update_pending_status(pipe_ctx
);
143 return surface_status
;
146 void dc_surface_retain(const struct dc_surface
*dc_surface
)
148 struct surface
*surface
= DC_SURFACE_TO_SURFACE(dc_surface
);
150 ++surface
->ref_count
;
153 void dc_surface_release(const struct dc_surface
*dc_surface
)
155 struct surface
*surface
= DC_SURFACE_TO_SURFACE(dc_surface
);
157 --surface
->ref_count
;
159 if (surface
->ref_count
== 0) {
165 static bool construct_gamma(struct gamma
*gamma
)
170 static void destruct_gamma(struct gamma
*gamma
)
175 void dc_gamma_retain(const struct dc_gamma
*dc_gamma
)
177 struct gamma
*gamma
= DC_GAMMA_TO_GAMMA(dc_gamma
);
182 void dc_gamma_release(const struct dc_gamma
*dc_gamma
)
184 struct gamma
*gamma
= DC_GAMMA_TO_GAMMA(dc_gamma
);
187 if (gamma
->ref_count
== 0) {
188 destruct_gamma(gamma
);
193 struct dc_gamma
*dc_create_gamma()
195 struct gamma
*gamma
= dm_alloc(sizeof(*gamma
));
200 if (false == construct_gamma(gamma
))
203 dc_gamma_retain(&gamma
->protected.public);
205 return &gamma
->protected.public;