| 1 | /* |
| 2 | * Copyright 2012-15 Advanced Micro Devices, Inc. |
| 3 | * |
| 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: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 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. |
| 21 | * |
| 22 | * Authors: AMD |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #include "core_types.h" |
| 27 | #include "dc_common.h" |
| 28 | #include "basics/conversion.h" |
| 29 | |
| 30 | bool is_rgb_cspace(enum dc_color_space output_color_space) |
| 31 | { |
| 32 | switch (output_color_space) { |
| 33 | case COLOR_SPACE_SRGB: |
| 34 | case COLOR_SPACE_SRGB_LIMITED: |
| 35 | case COLOR_SPACE_2020_RGB_FULLRANGE: |
| 36 | case COLOR_SPACE_2020_RGB_LIMITEDRANGE: |
| 37 | case COLOR_SPACE_ADOBERGB: |
| 38 | return true; |
| 39 | case COLOR_SPACE_YCBCR601: |
| 40 | case COLOR_SPACE_YCBCR709: |
| 41 | case COLOR_SPACE_YCBCR601_LIMITED: |
| 42 | case COLOR_SPACE_YCBCR709_LIMITED: |
| 43 | case COLOR_SPACE_2020_YCBCR_LIMITED: |
| 44 | case COLOR_SPACE_2020_YCBCR_FULL: |
| 45 | return false; |
| 46 | default: |
| 47 | /* Add a case to switch */ |
| 48 | BREAK_TO_DEBUGGER(); |
| 49 | return false; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | bool is_lower_pipe_tree_visible(struct pipe_ctx *pipe_ctx) |
| 54 | { |
| 55 | if (pipe_ctx->plane_state && pipe_ctx->plane_state->visible) |
| 56 | return true; |
| 57 | if (pipe_ctx->bottom_pipe && is_lower_pipe_tree_visible(pipe_ctx: pipe_ctx->bottom_pipe)) |
| 58 | return true; |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | bool is_upper_pipe_tree_visible(struct pipe_ctx *pipe_ctx) |
| 63 | { |
| 64 | if (pipe_ctx->plane_state && pipe_ctx->plane_state->visible) |
| 65 | return true; |
| 66 | if (pipe_ctx->top_pipe && is_upper_pipe_tree_visible(pipe_ctx: pipe_ctx->top_pipe)) |
| 67 | return true; |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | bool is_pipe_tree_visible(struct pipe_ctx *pipe_ctx) |
| 72 | { |
| 73 | if (pipe_ctx->plane_state && pipe_ctx->plane_state->visible) |
| 74 | return true; |
| 75 | if (pipe_ctx->top_pipe && is_upper_pipe_tree_visible(pipe_ctx: pipe_ctx->top_pipe)) |
| 76 | return true; |
| 77 | if (pipe_ctx->bottom_pipe && is_lower_pipe_tree_visible(pipe_ctx: pipe_ctx->bottom_pipe)) |
| 78 | return true; |
| 79 | return false; |
| 80 | } |
| 81 | |
| 82 | void build_prescale_params(struct dc_bias_and_scale *bias_and_scale, |
| 83 | const struct dc_plane_state *plane_state) |
| 84 | { |
| 85 | if (plane_state->format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN |
| 86 | && plane_state->format != SURFACE_PIXEL_FORMAT_INVALID |
| 87 | && plane_state->input_csc_color_matrix.enable_adjustment |
| 88 | && plane_state->coeff_reduction_factor.value != 0) { |
| 89 | bias_and_scale->scale_blue = fixed_point_to_int_frac( |
| 90 | arg: dc_fixpt_mul(arg1: plane_state->coeff_reduction_factor, |
| 91 | arg2: dc_fixpt_from_fraction(numerator: 256, denominator: 255)), |
| 92 | integer_bits: 2, |
| 93 | fractional_bits: 13); |
| 94 | bias_and_scale->scale_red = bias_and_scale->scale_blue; |
| 95 | bias_and_scale->scale_green = bias_and_scale->scale_blue; |
| 96 | } else { |
| 97 | bias_and_scale->scale_blue = 0x2000; |
| 98 | bias_and_scale->scale_red = 0x2000; |
| 99 | bias_and_scale->scale_green = 0x2000; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | |