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: 44 return false; 45 default: 46 /* Add a case to switch */ 47 BREAK_TO_DEBUGGER(); 48 return false; 49 } 50 } 51 52 bool is_child_pipe_tree_visible(struct pipe_ctx *pipe_ctx) 53 { 54 if (pipe_ctx->plane_state && pipe_ctx->plane_state->visible) 55 return true; 56 if (pipe_ctx->bottom_pipe && is_child_pipe_tree_visible(pipe_ctx->bottom_pipe)) 57 return true; 58 if (pipe_ctx->next_odm_pipe && is_child_pipe_tree_visible(pipe_ctx->next_odm_pipe)) 59 return true; 60 return false; 61 } 62 63 bool is_parent_pipe_tree_visible(struct pipe_ctx *pipe_ctx) 64 { 65 if (pipe_ctx->plane_state && pipe_ctx->plane_state->visible) 66 return true; 67 if (pipe_ctx->top_pipe && is_parent_pipe_tree_visible(pipe_ctx->top_pipe)) 68 return true; 69 if (pipe_ctx->prev_odm_pipe && is_parent_pipe_tree_visible(pipe_ctx->prev_odm_pipe)) 70 return true; 71 return false; 72 } 73 74 bool is_pipe_tree_visible(struct pipe_ctx *pipe_ctx) 75 { 76 if (pipe_ctx->plane_state && pipe_ctx->plane_state->visible) 77 return true; 78 if (pipe_ctx->top_pipe && is_parent_pipe_tree_visible(pipe_ctx->top_pipe)) 79 return true; 80 if (pipe_ctx->bottom_pipe && is_child_pipe_tree_visible(pipe_ctx->bottom_pipe)) 81 return true; 82 if (pipe_ctx->prev_odm_pipe && is_parent_pipe_tree_visible(pipe_ctx->prev_odm_pipe)) 83 return true; 84 if (pipe_ctx->next_odm_pipe && is_child_pipe_tree_visible(pipe_ctx->next_odm_pipe)) 85 return true; 86 return false; 87 } 88 89 void build_prescale_params(struct dc_bias_and_scale *bias_and_scale, 90 const struct dc_plane_state *plane_state) 91 { 92 if (plane_state->format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN 93 && plane_state->format != SURFACE_PIXEL_FORMAT_INVALID 94 && plane_state->input_csc_color_matrix.enable_adjustment 95 && plane_state->coeff_reduction_factor.value != 0) { 96 bias_and_scale->scale_blue = fixed_point_to_int_frac( 97 dc_fixpt_mul(plane_state->coeff_reduction_factor, 98 dc_fixpt_from_fraction(256, 255)), 99 2, 100 13); 101 bias_and_scale->scale_red = bias_and_scale->scale_blue; 102 bias_and_scale->scale_green = bias_and_scale->scale_blue; 103 } else { 104 bias_and_scale->scale_blue = 0x2000; 105 bias_and_scale->scale_red = 0x2000; 106 bias_and_scale->scale_green = 0x2000; 107 } 108 } 109 110