| .. | .. |
|---|
| 23 | 23 | * |
|---|
| 24 | 24 | */ |
|---|
| 25 | 25 | |
|---|
| 26 | +#include <linux/mm.h> |
|---|
| 27 | + |
|---|
| 26 | 28 | /* DC interface (public) */ |
|---|
| 27 | 29 | #include "dm_services.h" |
|---|
| 28 | 30 | #include "dc.h" |
|---|
| .. | .. |
|---|
| 35 | 37 | /******************************************************************************* |
|---|
| 36 | 38 | * Private functions |
|---|
| 37 | 39 | ******************************************************************************/ |
|---|
| 38 | | -static void construct(struct dc_context *ctx, struct dc_plane_state *plane_state) |
|---|
| 40 | +static void dc_plane_construct(struct dc_context *ctx, struct dc_plane_state *plane_state) |
|---|
| 39 | 41 | { |
|---|
| 40 | 42 | plane_state->ctx = ctx; |
|---|
| 41 | 43 | |
|---|
| 42 | 44 | plane_state->gamma_correction = dc_create_gamma(); |
|---|
| 43 | | - plane_state->gamma_correction->is_identity = true; |
|---|
| 45 | + if (plane_state->gamma_correction != NULL) |
|---|
| 46 | + plane_state->gamma_correction->is_identity = true; |
|---|
| 44 | 47 | |
|---|
| 45 | 48 | plane_state->in_transfer_func = dc_create_transfer_func(); |
|---|
| 46 | | - plane_state->in_transfer_func->type = TF_TYPE_BYPASS; |
|---|
| 49 | + if (plane_state->in_transfer_func != NULL) { |
|---|
| 50 | + plane_state->in_transfer_func->type = TF_TYPE_BYPASS; |
|---|
| 51 | + } |
|---|
| 52 | + plane_state->in_shaper_func = dc_create_transfer_func(); |
|---|
| 53 | + if (plane_state->in_shaper_func != NULL) { |
|---|
| 54 | + plane_state->in_shaper_func->type = TF_TYPE_BYPASS; |
|---|
| 55 | + } |
|---|
| 56 | + |
|---|
| 57 | + plane_state->lut3d_func = dc_create_3dlut_func(); |
|---|
| 58 | + |
|---|
| 59 | + plane_state->blend_tf = dc_create_transfer_func(); |
|---|
| 60 | + if (plane_state->blend_tf != NULL) { |
|---|
| 61 | + plane_state->blend_tf->type = TF_TYPE_BYPASS; |
|---|
| 62 | + } |
|---|
| 63 | + |
|---|
| 47 | 64 | } |
|---|
| 48 | 65 | |
|---|
| 49 | | -static void destruct(struct dc_plane_state *plane_state) |
|---|
| 66 | +static void dc_plane_destruct(struct dc_plane_state *plane_state) |
|---|
| 50 | 67 | { |
|---|
| 51 | 68 | if (plane_state->gamma_correction != NULL) { |
|---|
| 52 | 69 | dc_gamma_release(&plane_state->gamma_correction); |
|---|
| .. | .. |
|---|
| 56 | 73 | plane_state->in_transfer_func); |
|---|
| 57 | 74 | plane_state->in_transfer_func = NULL; |
|---|
| 58 | 75 | } |
|---|
| 76 | + if (plane_state->in_shaper_func != NULL) { |
|---|
| 77 | + dc_transfer_func_release( |
|---|
| 78 | + plane_state->in_shaper_func); |
|---|
| 79 | + plane_state->in_shaper_func = NULL; |
|---|
| 80 | + } |
|---|
| 81 | + if (plane_state->lut3d_func != NULL) { |
|---|
| 82 | + dc_3dlut_func_release( |
|---|
| 83 | + plane_state->lut3d_func); |
|---|
| 84 | + plane_state->lut3d_func = NULL; |
|---|
| 85 | + } |
|---|
| 86 | + if (plane_state->blend_tf != NULL) { |
|---|
| 87 | + dc_transfer_func_release( |
|---|
| 88 | + plane_state->blend_tf); |
|---|
| 89 | + plane_state->blend_tf = NULL; |
|---|
| 90 | + } |
|---|
| 91 | + |
|---|
| 59 | 92 | } |
|---|
| 60 | 93 | |
|---|
| 61 | 94 | /******************************************************************************* |
|---|
| .. | .. |
|---|
| 70 | 103 | |
|---|
| 71 | 104 | struct dc_plane_state *dc_create_plane_state(struct dc *dc) |
|---|
| 72 | 105 | { |
|---|
| 73 | | - struct dc *core_dc = dc; |
|---|
| 74 | | - |
|---|
| 75 | 106 | struct dc_plane_state *plane_state = kvzalloc(sizeof(*plane_state), |
|---|
| 76 | | - GFP_KERNEL); |
|---|
| 107 | + GFP_KERNEL); |
|---|
| 77 | 108 | |
|---|
| 78 | 109 | if (NULL == plane_state) |
|---|
| 79 | 110 | return NULL; |
|---|
| 80 | 111 | |
|---|
| 81 | 112 | kref_init(&plane_state->refcount); |
|---|
| 82 | | - construct(core_dc->ctx, plane_state); |
|---|
| 113 | + dc_plane_construct(dc->ctx, plane_state); |
|---|
| 83 | 114 | |
|---|
| 84 | 115 | return plane_state; |
|---|
| 85 | 116 | } |
|---|
| .. | .. |
|---|
| 99 | 130 | const struct dc_plane_state *plane_state) |
|---|
| 100 | 131 | { |
|---|
| 101 | 132 | const struct dc_plane_status *plane_status; |
|---|
| 102 | | - struct dc *core_dc; |
|---|
| 133 | + struct dc *dc; |
|---|
| 103 | 134 | int i; |
|---|
| 104 | 135 | |
|---|
| 105 | 136 | if (!plane_state || |
|---|
| .. | .. |
|---|
| 110 | 141 | } |
|---|
| 111 | 142 | |
|---|
| 112 | 143 | plane_status = &plane_state->status; |
|---|
| 113 | | - core_dc = plane_state->ctx->dc; |
|---|
| 144 | + dc = plane_state->ctx->dc; |
|---|
| 114 | 145 | |
|---|
| 115 | | - if (core_dc->current_state == NULL) |
|---|
| 146 | + if (dc->current_state == NULL) |
|---|
| 116 | 147 | return NULL; |
|---|
| 117 | 148 | |
|---|
| 118 | | - for (i = 0; i < core_dc->res_pool->pipe_count; i++) { |
|---|
| 149 | + /* Find the current plane state and set its pending bit to false */ |
|---|
| 150 | + for (i = 0; i < dc->res_pool->pipe_count; i++) { |
|---|
| 119 | 151 | struct pipe_ctx *pipe_ctx = |
|---|
| 120 | | - &core_dc->current_state->res_ctx.pipe_ctx[i]; |
|---|
| 152 | + &dc->current_state->res_ctx.pipe_ctx[i]; |
|---|
| 121 | 153 | |
|---|
| 122 | 154 | if (pipe_ctx->plane_state != plane_state) |
|---|
| 123 | 155 | continue; |
|---|
| 124 | 156 | |
|---|
| 125 | | - core_dc->hwss.update_pending_status(pipe_ctx); |
|---|
| 157 | + pipe_ctx->plane_state->status.is_flip_pending = false; |
|---|
| 158 | + |
|---|
| 159 | + break; |
|---|
| 160 | + } |
|---|
| 161 | + |
|---|
| 162 | + for (i = 0; i < dc->res_pool->pipe_count; i++) { |
|---|
| 163 | + struct pipe_ctx *pipe_ctx = |
|---|
| 164 | + &dc->current_state->res_ctx.pipe_ctx[i]; |
|---|
| 165 | + |
|---|
| 166 | + if (pipe_ctx->plane_state != plane_state) |
|---|
| 167 | + continue; |
|---|
| 168 | + |
|---|
| 169 | + dc->hwss.update_pending_status(pipe_ctx); |
|---|
| 126 | 170 | } |
|---|
| 127 | 171 | |
|---|
| 128 | 172 | return plane_status; |
|---|
| .. | .. |
|---|
| 136 | 180 | static void dc_plane_state_free(struct kref *kref) |
|---|
| 137 | 181 | { |
|---|
| 138 | 182 | struct dc_plane_state *plane_state = container_of(kref, struct dc_plane_state, refcount); |
|---|
| 139 | | - destruct(plane_state); |
|---|
| 183 | + dc_plane_destruct(plane_state); |
|---|
| 140 | 184 | kvfree(plane_state); |
|---|
| 141 | 185 | } |
|---|
| 142 | 186 | |
|---|
| .. | .. |
|---|
| 207 | 251 | return NULL; |
|---|
| 208 | 252 | } |
|---|
| 209 | 253 | |
|---|
| 254 | +static void dc_3dlut_func_free(struct kref *kref) |
|---|
| 255 | +{ |
|---|
| 256 | + struct dc_3dlut *lut = container_of(kref, struct dc_3dlut, refcount); |
|---|
| 257 | + |
|---|
| 258 | + kvfree(lut); |
|---|
| 259 | +} |
|---|
| 260 | + |
|---|
| 261 | +struct dc_3dlut *dc_create_3dlut_func(void) |
|---|
| 262 | +{ |
|---|
| 263 | + struct dc_3dlut *lut = kvzalloc(sizeof(*lut), GFP_KERNEL); |
|---|
| 264 | + |
|---|
| 265 | + if (lut == NULL) |
|---|
| 266 | + goto alloc_fail; |
|---|
| 267 | + |
|---|
| 268 | + kref_init(&lut->refcount); |
|---|
| 269 | + lut->state.raw = 0; |
|---|
| 270 | + |
|---|
| 271 | + return lut; |
|---|
| 272 | + |
|---|
| 273 | +alloc_fail: |
|---|
| 274 | + return NULL; |
|---|
| 275 | + |
|---|
| 276 | +} |
|---|
| 277 | + |
|---|
| 278 | +void dc_3dlut_func_release(struct dc_3dlut *lut) |
|---|
| 279 | +{ |
|---|
| 280 | + kref_put(&lut->refcount, dc_3dlut_func_free); |
|---|
| 281 | +} |
|---|
| 282 | + |
|---|
| 283 | +void dc_3dlut_func_retain(struct dc_3dlut *lut) |
|---|
| 284 | +{ |
|---|
| 285 | + kref_get(&lut->refcount); |
|---|
| 286 | +} |
|---|
| 287 | + |
|---|
| 210 | 288 | |
|---|