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.
30 #include "transform.h"
33 const struct dpp_funcs
*funcs
;
34 struct dc_context
*ctx
;
36 struct dpp_caps
*caps
;
37 struct pwl_params regamma_params
;
38 struct pwl_params degamma_params
;
39 struct dpp_cursor_attributes cur_attr
;
41 struct pwl_params shaper_params
;
45 struct dpp_input_csc_matrix
{
46 enum dc_color_space color_space
;
50 static const struct dpp_input_csc_matrix __maybe_unused dpp_input_csc_matrix
[] = {
52 {0x2000, 0, 0, 0, 0, 0x2000, 0, 0, 0, 0, 0x2000, 0} },
53 {COLOR_SPACE_SRGB_LIMITED
,
54 {0x2000, 0, 0, 0, 0, 0x2000, 0, 0, 0, 0, 0x2000, 0} },
55 {COLOR_SPACE_YCBCR601
,
56 {0x2cdd, 0x2000, 0, 0xe991, 0xe926, 0x2000, 0xf4fd, 0x10ef,
57 0, 0x2000, 0x38b4, 0xe3a6} },
58 {COLOR_SPACE_YCBCR601_LIMITED
,
59 {0x3353, 0x2568, 0, 0xe400, 0xe5dc, 0x2568, 0xf367, 0x1108,
60 0, 0x2568, 0x40de, 0xdd3a} },
61 {COLOR_SPACE_YCBCR709
,
62 {0x3265, 0x2000, 0, 0xe6ce, 0xf105, 0x2000, 0xfa01, 0xa7d, 0,
63 0x2000, 0x3b61, 0xe24f} },
65 {COLOR_SPACE_YCBCR709_LIMITED
,
66 {0x39a6, 0x2568, 0, 0xe0d6, 0xeedd, 0x2568, 0xf925, 0x9a8, 0,
67 0x2568, 0x43ee, 0xdbb2} }
70 struct dpp_grph_csc_adjustment
{
71 struct fixed31_32 temperature_matrix
[CSC_TEMPERATURE_MATRIX_SIZE
];
72 enum graphics_gamut_adjust_type gamut_adjust_type
;
75 struct cnv_color_keyer_params
{
78 int color_keyer_alpha_low
;
79 int color_keyer_alpha_high
;
80 int color_keyer_red_low
;
81 int color_keyer_red_high
;
82 int color_keyer_green_low
;
83 int color_keyer_green_high
;
84 int color_keyer_blue_low
;
85 int color_keyer_blue_high
;
88 /* new for dcn2: set the 8bit alpha values based on the 2 bit alpha
89 *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT0 default: 0b00000000
90 *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT1 default: 0b01010101
91 *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT2 default: 0b10101010
92 *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT3 default: 0b11111111
94 struct cnv_alpha_2bit_lut
{
101 struct dcn_dpp_state
{
103 uint32_t igam_lut_mode
;
104 uint32_t igam_input_format
;
105 uint32_t dgam_lut_mode
;
106 uint32_t rgam_lut_mode
;
107 uint32_t gamut_remap_mode
;
108 uint32_t gamut_remap_c11_c12
;
109 uint32_t gamut_remap_c13_c14
;
110 uint32_t gamut_remap_c21_c22
;
111 uint32_t gamut_remap_c23_c24
;
112 uint32_t gamut_remap_c31_c32
;
113 uint32_t gamut_remap_c33_c34
;
116 struct CM_bias_params
{
117 uint32_t cm_bias_cr_r
;
118 uint32_t cm_bias_y_g
;
119 uint32_t cm_bias_cb_b
;
120 uint32_t cm_bias_format
;
124 bool (*dpp_program_gamcor_lut
)(
125 struct dpp
*dpp_base
, const struct pwl_params
*params
);
127 void (*dpp_set_pre_degam
)(struct dpp
*dpp_base
,
128 enum dc_transfer_func_predefined tr
);
130 void (*dpp_program_cm_dealpha
)(struct dpp
*dpp_base
,
131 uint32_t enable
, uint32_t additive_blending
);
133 void (*dpp_program_cm_bias
)(
134 struct dpp
*dpp_base
,
135 struct CM_bias_params
*bias_params
);
137 void (*dpp_read_state
)(struct dpp
*dpp
, struct dcn_dpp_state
*s
);
139 void (*dpp_reset
)(struct dpp
*dpp
);
141 void (*dpp_set_scaler
)(struct dpp
*dpp
,
142 const struct scaler_data
*scl_data
);
144 void (*dpp_set_pixel_storage_depth
)(
146 enum lb_pixel_depth depth
,
147 const struct bit_depth_reduction_params
*bit_depth_params
);
149 bool (*dpp_get_optimal_number_of_taps
)(
151 struct scaler_data
*scl_data
,
152 const struct scaling_taps
*in_taps
);
154 void (*dpp_set_gamut_remap
)(
156 const struct dpp_grph_csc_adjustment
*adjust
);
158 void (*dpp_set_csc_default
)(
160 enum dc_color_space colorspace
);
162 void (*dpp_set_csc_adjustment
)(
164 const uint16_t *regval
);
166 void (*dpp_power_on_regamma_lut
)(
170 void (*dpp_program_regamma_lut
)(
172 const struct pwl_result_data
*rgb
,
175 void (*dpp_configure_regamma_lut
)(
179 void (*dpp_program_regamma_lutb_settings
)(
181 const struct pwl_params
*params
);
183 void (*dpp_program_regamma_luta_settings
)(
185 const struct pwl_params
*params
);
187 void (*dpp_program_regamma_pwl
)(
189 const struct pwl_params
*params
,
190 enum opp_regamma mode
);
192 void (*dpp_program_bias_and_scale
)(
194 struct dc_bias_and_scale
*params
);
196 void (*dpp_set_degamma
)(
197 struct dpp
*dpp_base
,
198 enum ipp_degamma_mode mode
);
200 void (*dpp_program_input_lut
)(
201 struct dpp
*dpp_base
,
202 const struct dc_gamma
*gamma
);
204 void (*dpp_program_degamma_pwl
)(struct dpp
*dpp_base
,
205 const struct pwl_params
*params
);
208 struct dpp
*dpp_base
,
209 enum surface_pixel_format format
,
210 enum expansion_mode mode
,
211 struct dc_csc_transform input_csc_color_matrix
,
212 enum dc_color_space input_color_space
,
213 struct cnv_alpha_2bit_lut
*alpha_2bit_lut
);
215 void (*dpp_full_bypass
)(struct dpp
*dpp_base
);
217 void (*set_cursor_attributes
)(
218 struct dpp
*dpp_base
,
219 struct dc_cursor_attributes
*cursor_attributes
);
221 void (*set_cursor_position
)(
222 struct dpp
*dpp_base
,
223 const struct dc_cursor_position
*pos
,
224 const struct dc_cursor_mi_param
*param
,
229 void (*dpp_set_hdr_multiplier
)(
230 struct dpp
*dpp_base
,
231 uint32_t multiplier
);
233 void (*set_optional_cursor_attributes
)(
234 struct dpp
*dpp_base
,
235 struct dpp_cursor_attributes
*attr
);
237 void (*dpp_dppclk_control
)(
238 struct dpp
*dpp_base
,
242 bool (*dpp_program_blnd_lut
)(
244 const struct pwl_params
*params
);
245 bool (*dpp_program_shaper_lut
)(
247 const struct pwl_params
*params
);
248 bool (*dpp_program_3dlut
)(
250 struct tetrahedral_params
*params
);
251 void (*dpp_cnv_set_alpha_keyer
)(
252 struct dpp
*dpp_base
,
253 struct cnv_color_keyer_params
*color_keyer
);