2 * Copyright 2012-15 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
26 #include "core_types.h"
27 #include "dc_common.h"
28 #include "basics/conversion.h"
30 bool is_rgb_cspace(enum dc_color_space output_color_space
)
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
:
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
:
46 /* Add a case to switch */
52 bool is_lower_pipe_tree_visible(struct pipe_ctx
*pipe_ctx
)
54 if (pipe_ctx
->plane_state
&& pipe_ctx
->plane_state
->visible
)
56 if (pipe_ctx
->bottom_pipe
&& is_lower_pipe_tree_visible(pipe_ctx
->bottom_pipe
))
61 bool is_upper_pipe_tree_visible(struct pipe_ctx
*pipe_ctx
)
63 if (pipe_ctx
->plane_state
&& pipe_ctx
->plane_state
->visible
)
65 if (pipe_ctx
->top_pipe
&& is_upper_pipe_tree_visible(pipe_ctx
->top_pipe
))
70 bool is_pipe_tree_visible(struct pipe_ctx
*pipe_ctx
)
72 if (pipe_ctx
->plane_state
&& pipe_ctx
->plane_state
->visible
)
74 if (pipe_ctx
->top_pipe
&& is_upper_pipe_tree_visible(pipe_ctx
->top_pipe
))
76 if (pipe_ctx
->bottom_pipe
&& is_lower_pipe_tree_visible(pipe_ctx
->bottom_pipe
))
81 void build_prescale_params(struct dc_bias_and_scale
*bias_and_scale
,
82 const struct dc_plane_state
*plane_state
)
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)),
93 bias_and_scale
->scale_red
= bias_and_scale
->scale_blue
;
94 bias_and_scale
->scale_green
= bias_and_scale
->scale_blue
;
96 bias_and_scale
->scale_blue
= 0x2000;
97 bias_and_scale
->scale_red
= 0x2000;
98 bias_and_scale
->scale_green
= 0x2000;