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
is_rgb_cspace(enum dc_color_space output_color_space)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
is_lower_pipe_tree_visible(struct pipe_ctx * pipe_ctx)52 bool is_lower_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_lower_pipe_tree_visible(pipe_ctx->bottom_pipe))
57 return true;
58 return false;
59 }
60
is_upper_pipe_tree_visible(struct pipe_ctx * pipe_ctx)61 bool is_upper_pipe_tree_visible(struct pipe_ctx *pipe_ctx)
62 {
63 if (pipe_ctx->plane_state && pipe_ctx->plane_state->visible)
64 return true;
65 if (pipe_ctx->top_pipe && is_upper_pipe_tree_visible(pipe_ctx->top_pipe))
66 return true;
67 return false;
68 }
69
is_pipe_tree_visible(struct pipe_ctx * pipe_ctx)70 bool is_pipe_tree_visible(struct pipe_ctx *pipe_ctx)
71 {
72 if (pipe_ctx->plane_state && pipe_ctx->plane_state->visible)
73 return true;
74 if (pipe_ctx->top_pipe && is_upper_pipe_tree_visible(pipe_ctx->top_pipe))
75 return true;
76 if (pipe_ctx->bottom_pipe && is_lower_pipe_tree_visible(pipe_ctx->bottom_pipe))
77 return true;
78 return false;
79 }
80
build_prescale_params(struct dc_bias_and_scale * bias_and_scale,const struct dc_plane_state * plane_state)81 void build_prescale_params(struct dc_bias_and_scale *bias_and_scale,
82 const struct dc_plane_state *plane_state)
83 {
84 if (plane_state->format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN
85 && plane_state->format != SURFACE_PIXEL_FORMAT_INVALID
86 && plane_state->input_csc_color_matrix.enable_adjustment
87 && plane_state->coeff_reduction_factor.value != 0) {
88 bias_and_scale->scale_blue = fixed_point_to_int_frac(
89 dc_fixpt_mul(plane_state->coeff_reduction_factor,
90 dc_fixpt_from_fraction(256, 255)),
91 2,
92 13);
93 bias_and_scale->scale_red = bias_and_scale->scale_blue;
94 bias_and_scale->scale_green = bias_and_scale->scale_blue;
95 } else {
96 bias_and_scale->scale_blue = 0x2000;
97 bias_and_scale->scale_red = 0x2000;
98 bias_and_scale->scale_green = 0x2000;
99 }
100 }
101
102