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;
42 plane_state->gamma_correction = dc_create_gamma();
43 plane_state->gamma_correction->is_identity = true;
45 plane_state->in_transfer_func = dc_create_transfer_func();
46 plane_state->in_transfer_func->type = TF_TYPE_BYPASS;
49 static void destruct(struct dc_plane_state *plane_state)
51 if (plane_state->gamma_correction != NULL) {
52 dc_gamma_release(&plane_state->gamma_correction);
54 if (plane_state->in_transfer_func != NULL) {
55 dc_transfer_func_release(
56 plane_state->in_transfer_func);
57 plane_state->in_transfer_func = NULL;
61 /*******************************************************************************
63 ******************************************************************************/
64 void enable_surface_flip_reporting(struct dc_plane_state *plane_state,
65 uint32_t controller_id)
67 plane_state->irq_source = controller_id + DC_IRQ_SOURCE_PFLIP1 - 1;
68 /*register_flip_interrupt(surface);*/
71 struct dc_plane_state *dc_create_plane_state(struct dc *dc)
73 struct dc *core_dc = dc;
75 struct dc_plane_state *plane_state = kvzalloc(sizeof(*plane_state),
78 if (NULL == plane_state)
81 kref_init(&plane_state->refcount);
82 construct(core_dc->ctx, plane_state);
88 *****************************************************************************
89 * Function: dc_plane_get_status
92 * Looks up the pipe context of plane_state and updates the pending status
93 * of the pipe context. Then returns plane_state->status
95 * @param [in] plane_state: pointer to the plane_state to get the status of
96 *****************************************************************************
98 const struct dc_plane_status *dc_plane_get_status(
99 const struct dc_plane_state *plane_state)
101 const struct dc_plane_status *plane_status;
107 !plane_state->ctx->dc) {
109 return NULL; /* remove this if above assert never hit */
112 plane_status = &plane_state->status;
113 core_dc = plane_state->ctx->dc;
115 if (core_dc->current_state == NULL)
118 for (i = 0; i < core_dc->res_pool->pipe_count; i++) {
119 struct pipe_ctx *pipe_ctx =
120 &core_dc->current_state->res_ctx.pipe_ctx[i];
122 if (pipe_ctx->plane_state != plane_state)
125 core_dc->hwss.update_pending_status(pipe_ctx);
131 void dc_plane_state_retain(struct dc_plane_state *plane_state)
133 kref_get(&plane_state->refcount);
136 static void dc_plane_state_free(struct kref *kref)
138 struct dc_plane_state *plane_state = container_of(kref, struct dc_plane_state, refcount);
139 destruct(plane_state);
143 void dc_plane_state_release(struct dc_plane_state *plane_state)
145 kref_put(&plane_state->refcount, dc_plane_state_free);
148 void dc_gamma_retain(struct dc_gamma *gamma)
150 kref_get(&gamma->refcount);
153 static void dc_gamma_free(struct kref *kref)
155 struct dc_gamma *gamma = container_of(kref, struct dc_gamma, refcount);
159 void dc_gamma_release(struct dc_gamma **gamma)
161 kref_put(&(*gamma)->refcount, dc_gamma_free);
165 struct dc_gamma *dc_create_gamma(void)
167 struct dc_gamma *gamma = kvzalloc(sizeof(*gamma), GFP_KERNEL);
172 kref_init(&gamma->refcount);
179 void dc_transfer_func_retain(struct dc_transfer_func *tf)
181 kref_get(&tf->refcount);
184 static void dc_transfer_func_free(struct kref *kref)
186 struct dc_transfer_func *tf = container_of(kref, struct dc_transfer_func, refcount);
190 void dc_transfer_func_release(struct dc_transfer_func *tf)
192 kref_put(&tf->refcount, dc_transfer_func_free);
195 struct dc_transfer_func *dc_create_transfer_func(void)
197 struct dc_transfer_func *tf = kvzalloc(sizeof(*tf), GFP_KERNEL);
202 kref_init(&tf->refcount);