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) */
31 #include "core_types.h"
32 #include "transform.h"
35 /*******************************************************************************
37 ******************************************************************************/
38 static void construct(struct dc_context *ctx, struct dc_plane_state *plane_state)
40 plane_state->ctx = ctx;
43 static void destruct(struct dc_plane_state *plane_state)
45 if (plane_state->gamma_correction != NULL) {
46 dc_gamma_release(&plane_state->gamma_correction);
48 if (plane_state->in_transfer_func != NULL) {
49 dc_transfer_func_release(
50 plane_state->in_transfer_func);
51 plane_state->in_transfer_func = NULL;
55 /*******************************************************************************
57 ******************************************************************************/
58 void enable_surface_flip_reporting(struct dc_plane_state *plane_state,
59 uint32_t controller_id)
61 plane_state->irq_source = controller_id + DC_IRQ_SOURCE_PFLIP1 - 1;
62 /*register_flip_interrupt(surface);*/
65 struct dc_plane_state *dc_create_plane_state(struct dc *dc)
67 struct dc *core_dc = dc;
69 struct dc_plane_state *plane_state = kzalloc(sizeof(*plane_state),
72 if (NULL == plane_state)
75 kref_init(&plane_state->refcount);
76 construct(core_dc->ctx, plane_state);
81 const struct dc_plane_status *dc_plane_get_status(
82 const struct dc_plane_state *plane_state)
84 const struct dc_plane_status *plane_status;
90 !plane_state->ctx->dc) {
92 return NULL; /* remove this if above assert never hit */
95 plane_status = &plane_state->status;
96 core_dc = plane_state->ctx->dc;
98 if (core_dc->current_state == NULL)
101 for (i = 0; i < core_dc->res_pool->pipe_count; i++) {
102 struct pipe_ctx *pipe_ctx =
103 &core_dc->current_state->res_ctx.pipe_ctx[i];
105 if (pipe_ctx->plane_state != plane_state)
108 core_dc->hwss.update_pending_status(pipe_ctx);
114 void dc_plane_state_retain(struct dc_plane_state *plane_state)
116 kref_get(&plane_state->refcount);
119 static void dc_plane_state_free(struct kref *kref)
121 struct dc_plane_state *plane_state = container_of(kref, struct dc_plane_state, refcount);
122 destruct(plane_state);
126 void dc_plane_state_release(struct dc_plane_state *plane_state)
128 kref_put(&plane_state->refcount, dc_plane_state_free);
131 void dc_gamma_retain(struct dc_gamma *gamma)
133 kref_get(&gamma->refcount);
136 static void dc_gamma_free(struct kref *kref)
138 struct dc_gamma *gamma = container_of(kref, struct dc_gamma, refcount);
142 void dc_gamma_release(struct dc_gamma **gamma)
144 kref_put(&(*gamma)->refcount, dc_gamma_free);
148 struct dc_gamma *dc_create_gamma()
150 struct dc_gamma *gamma = kzalloc(sizeof(*gamma), GFP_KERNEL);
155 kref_init(&gamma->refcount);
162 void dc_transfer_func_retain(struct dc_transfer_func *tf)
164 kref_get(&tf->refcount);
167 static void dc_transfer_func_free(struct kref *kref)
169 struct dc_transfer_func *tf = container_of(kref, struct dc_transfer_func, refcount);
173 void dc_transfer_func_release(struct dc_transfer_func *tf)
175 kref_put(&tf->refcount, dc_transfer_func_free);
178 struct dc_transfer_func *dc_create_transfer_func()
180 struct dc_transfer_func *tf = kzalloc(sizeof(*tf), GFP_KERNEL);
185 kref_init(&tf->refcount);