sys/dev/drm/amd/display/dc/core/dc_surface.c
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 204 205 206 207 208 | /* * 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" #include "dpp.h" /******************************************************************************* * Private functions ******************************************************************************/ static void construct(struct dc_context *ctx, struct dc_plane_state *plane_state) { plane_state->ctx = ctx; plane_state->gamma_correction = dc_create_gamma(); plane_state->gamma_correction->is_identity = true; plane_state->in_transfer_func = dc_create_transfer_func(); plane_state->in_transfer_func->type = TF_TYPE_BYPASS; } 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) return NULL; kref_init(&plane_state->refcount); construct(core_dc->ctx, plane_state); return plane_state; } /** ***************************************************************************** * Function: dc_plane_get_status * * @brief * Looks up the pipe context of plane_state and updates the pending status * of the pipe context. Then returns plane_state->status * * @param [in] plane_state: pointer to the plane_state to get the status of ***************************************************************************** */ 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) { kref_get(&plane_state->refcount); } static void dc_plane_state_free(struct kref *kref) { struct dc_plane_state *plane_state = container_of(kref, struct dc_plane_state, refcount); destruct(plane_state); kvfree(plane_state); } void dc_plane_state_release(struct dc_plane_state *plane_state) { kref_put(&plane_state->refcount, dc_plane_state_free); } void dc_gamma_retain(struct dc_gamma *gamma) { kref_get(&gamma->refcount); } static void dc_gamma_free(struct kref *kref) { struct dc_gamma *gamma = container_of(kref, struct dc_gamma, refcount); kvfree(gamma); } void dc_gamma_release(struct dc_gamma **gamma) { kref_put(&(*gamma)->refcount, dc_gamma_free); *gamma = NULL; } struct dc_gamma *dc_create_gamma(void) { struct dc_gamma *gamma = kzalloc(sizeof(*gamma), GFP_KERNEL); if (gamma == NULL) goto alloc_fail; kref_init(&gamma->refcount); return gamma; alloc_fail: return NULL; } void dc_transfer_func_retain(struct dc_transfer_func *tf) { kref_get(&tf->refcount); } static void dc_transfer_func_free(struct kref *kref) { struct dc_transfer_func *tf = container_of(kref, struct dc_transfer_func, refcount); kvfree(tf); } void dc_transfer_func_release(struct dc_transfer_func *tf) { kref_put(&tf->refcount, dc_transfer_func_free); } struct dc_transfer_func *dc_create_transfer_func(void) { struct dc_transfer_func *tf = kzalloc(sizeof(*tf), GFP_KERNEL); if (tf == NULL) goto alloc_fail; kref_init(&tf->refcount); return tf; alloc_fail: return NULL; } |