]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/gpu/drm/amd/display/dc/core/dc_surface.c
941b3671375d68cf19e06535c3d19eaffa7325c4
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 ******************************************************************************/
37 static bool construct(struct dc_context
*ctx
, struct dc_plane_state
*surface
)
40 memset(&surface
->hdr_static_ctx
,
41 0, sizeof(struct dc_hdr_static_metadata
));
45 static void destruct(struct dc_plane_state
*surface
)
47 if (surface
->gamma_correction
!= NULL
) {
48 dc_gamma_release(&surface
->gamma_correction
);
50 if (surface
->in_transfer_func
!= NULL
) {
51 dc_transfer_func_release(
52 surface
->in_transfer_func
);
53 surface
->in_transfer_func
= NULL
;
57 /*******************************************************************************
59 ******************************************************************************/
60 void enable_surface_flip_reporting(struct dc_plane_state
*surface
,
61 uint32_t controller_id
)
63 surface
->irq_source
= controller_id
+ DC_IRQ_SOURCE_PFLIP1
- 1;
64 /*register_flip_interrupt(surface);*/
67 struct dc_plane_state
*dc_create_surface(const struct dc
*dc
)
69 struct core_dc
*core_dc
= DC_TO_CORE(dc
);
71 struct dc_plane_state
*surface
= dm_alloc(sizeof(*surface
));
76 if (false == construct(core_dc
->ctx
, surface
))
90 const struct dc_surface_status
*dc_surface_get_status(
91 const struct dc_plane_state
*dc_surface
)
93 const struct dc_surface_status
*surface_status
;
94 struct core_dc
*core_dc
;
99 !dc_surface
->ctx
->dc
) {
101 return NULL
; /* remove this if above assert never hit */
104 surface_status
= &dc_surface
->status
;
105 core_dc
= DC_TO_CORE(dc_surface
->ctx
->dc
);
107 if (core_dc
->current_context
== NULL
)
110 for (i
= 0; i
< core_dc
->res_pool
->pipe_count
; i
++) {
111 struct pipe_ctx
*pipe_ctx
=
112 &core_dc
->current_context
->res_ctx
.pipe_ctx
[i
];
114 if (pipe_ctx
->surface
!= dc_surface
)
117 core_dc
->hwss
.update_pending_status(pipe_ctx
);
120 return surface_status
;
123 void dc_surface_retain(struct dc_plane_state
*surface
)
125 ASSERT(surface
->ref_count
> 0);
126 ++surface
->ref_count
;
129 void dc_surface_release(struct dc_plane_state
*surface
)
131 ASSERT(surface
->ref_count
> 0);
132 --surface
->ref_count
;
134 if (surface
->ref_count
== 0) {
140 void dc_gamma_retain(struct dc_gamma
*gamma
)
142 ASSERT(gamma
->ref_count
> 0);
146 void dc_gamma_release(struct dc_gamma
**gamma
)
148 ASSERT((*gamma
)->ref_count
> 0);
149 --(*gamma
)->ref_count
;
151 if ((*gamma
)->ref_count
== 0)
157 struct dc_gamma
*dc_create_gamma()
159 struct dc_gamma
*gamma
= dm_alloc(sizeof(*gamma
));
172 void dc_transfer_func_retain(struct dc_transfer_func
*tf
)
174 ASSERT(tf
->ref_count
> 0);
178 void dc_transfer_func_release(struct dc_transfer_func
*tf
)
180 ASSERT(tf
->ref_count
> 0);
183 if (tf
->ref_count
== 0)
187 struct dc_transfer_func
*dc_create_transfer_func()
189 struct dc_transfer_func
*tf
= dm_alloc(sizeof(*tf
));