xref: /openbmc/linux/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h (revision 8781e5df)
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 
27 #ifndef __DAL_DPP_H__
28 #define __DAL_DPP_H__
29 
30 #include "transform.h"
31 
32 struct dpp {
33 	const struct dpp_funcs *funcs;
34 	struct dc_context *ctx;
35 	int inst;
36 	struct dpp_caps *caps;
37 	struct pwl_params regamma_params;
38 	struct pwl_params degamma_params;
39 	struct dpp_cursor_attributes cur_attr;
40 
41 	struct pwl_params shaper_params;
42 	bool cm_bypass_mode;
43 };
44 
45 struct dpp_input_csc_matrix {
46 	enum dc_color_space color_space;
47 	uint16_t regval[12];
48 };
49 
50 struct dpp_grph_csc_adjustment {
51 	struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
52 	enum graphics_gamut_adjust_type gamut_adjust_type;
53 };
54 
55 struct cnv_color_keyer_params {
56 	int color_keyer_en;
57 	int color_keyer_mode;
58 	int color_keyer_alpha_low;
59 	int color_keyer_alpha_high;
60 	int color_keyer_red_low;
61 	int color_keyer_red_high;
62 	int color_keyer_green_low;
63 	int color_keyer_green_high;
64 	int color_keyer_blue_low;
65 	int color_keyer_blue_high;
66 };
67 
68 /* new for dcn2: set the 8bit alpha values based on the 2 bit alpha
69  *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT0   default: 0b00000000
70  *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT1   default: 0b01010101
71  *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT2   default: 0b10101010
72  *ALPHA_2BIT_LUT. ALPHA_2BIT_LUT3   default: 0b11111111
73  */
74 struct cnv_alpha_2bit_lut {
75 	int lut0;
76 	int lut1;
77 	int lut2;
78 	int lut3;
79 };
80 
81 struct dcn_dpp_state {
82 	uint32_t is_enabled;
83 	uint32_t igam_lut_mode;
84 	uint32_t igam_input_format;
85 	uint32_t dgam_lut_mode;
86 	uint32_t rgam_lut_mode;
87 	uint32_t gamut_remap_mode;
88 	uint32_t gamut_remap_c11_c12;
89 	uint32_t gamut_remap_c13_c14;
90 	uint32_t gamut_remap_c21_c22;
91 	uint32_t gamut_remap_c23_c24;
92 	uint32_t gamut_remap_c31_c32;
93 	uint32_t gamut_remap_c33_c34;
94 };
95 
96 struct CM_bias_params {
97 	uint32_t cm_bias_cr_r;
98 	uint32_t cm_bias_y_g;
99 	uint32_t cm_bias_cb_b;
100 	uint32_t cm_bias_format;
101 };
102 
103 struct dpp_funcs {
104 
105 	void (*dpp_program_cm_dealpha)(struct dpp *dpp_base,
106 		uint32_t enable, uint32_t additive_blending);
107 
108 	void (*dpp_program_cm_bias)(
109 		struct dpp *dpp_base,
110 		struct CM_bias_params *bias_params);
111 
112 	void (*dpp_read_state)(struct dpp *dpp, struct dcn_dpp_state *s);
113 
114 	void (*dpp_reset)(struct dpp *dpp);
115 
116 	void (*dpp_set_scaler)(struct dpp *dpp,
117 			const struct scaler_data *scl_data);
118 
119 	void (*dpp_set_pixel_storage_depth)(
120 			struct dpp *dpp,
121 			enum lb_pixel_depth depth,
122 			const struct bit_depth_reduction_params *bit_depth_params);
123 
124 	bool (*dpp_get_optimal_number_of_taps)(
125 			struct dpp *dpp,
126 			struct scaler_data *scl_data,
127 			const struct scaling_taps *in_taps);
128 
129 	void (*dpp_set_gamut_remap)(
130 			struct dpp *dpp,
131 			const struct dpp_grph_csc_adjustment *adjust);
132 
133 	void (*dpp_set_csc_default)(
134 		struct dpp *dpp,
135 		enum dc_color_space colorspace);
136 
137 	void (*dpp_set_csc_adjustment)(
138 		struct dpp *dpp,
139 		const uint16_t *regval);
140 
141 	void (*dpp_power_on_regamma_lut)(
142 		struct dpp *dpp,
143 		bool power_on);
144 
145 	void (*dpp_program_regamma_lut)(
146 			struct dpp *dpp,
147 			const struct pwl_result_data *rgb,
148 			uint32_t num);
149 
150 	void (*dpp_configure_regamma_lut)(
151 			struct dpp *dpp,
152 			bool is_ram_a);
153 
154 	void (*dpp_program_regamma_lutb_settings)(
155 			struct dpp *dpp,
156 			const struct pwl_params *params);
157 
158 	void (*dpp_program_regamma_luta_settings)(
159 			struct dpp *dpp,
160 			const struct pwl_params *params);
161 
162 	void (*dpp_program_regamma_pwl)(
163 		struct dpp *dpp,
164 		const struct pwl_params *params,
165 		enum opp_regamma mode);
166 
167 	void (*dpp_program_bias_and_scale)(
168 			struct dpp *dpp,
169 			struct dc_bias_and_scale *params);
170 
171 	void (*dpp_set_degamma)(
172 			struct dpp *dpp_base,
173 			enum ipp_degamma_mode mode);
174 
175 	void (*dpp_program_input_lut)(
176 			struct dpp *dpp_base,
177 			const struct dc_gamma *gamma);
178 
179 	void (*dpp_program_degamma_pwl)(struct dpp *dpp_base,
180 									 const struct pwl_params *params);
181 
182 	void (*dpp_setup)(
183 			struct dpp *dpp_base,
184 			enum surface_pixel_format format,
185 			enum expansion_mode mode,
186 			struct dc_csc_transform input_csc_color_matrix,
187 			enum dc_color_space input_color_space,
188 			struct cnv_alpha_2bit_lut *alpha_2bit_lut);
189 
190 	void (*dpp_full_bypass)(struct dpp *dpp_base);
191 
192 	void (*set_cursor_attributes)(
193 			struct dpp *dpp_base,
194 			struct dc_cursor_attributes *cursor_attributes);
195 
196 	void (*set_cursor_position)(
197 			struct dpp *dpp_base,
198 			const struct dc_cursor_position *pos,
199 			const struct dc_cursor_mi_param *param,
200 			uint32_t width,
201 			uint32_t height
202 			);
203 
204 	void (*dpp_set_hdr_multiplier)(
205 			struct dpp *dpp_base,
206 			uint32_t multiplier);
207 
208 	void (*set_optional_cursor_attributes)(
209 			struct dpp *dpp_base,
210 			struct dpp_cursor_attributes *attr);
211 
212 	void (*dpp_dppclk_control)(
213 			struct dpp *dpp_base,
214 			bool dppclk_div,
215 			bool enable);
216 
217 	bool (*dpp_program_blnd_lut)(
218 			struct dpp *dpp,
219 			const struct pwl_params *params);
220 	bool (*dpp_program_shaper_lut)(
221 			struct dpp *dpp,
222 			const struct pwl_params *params);
223 	bool (*dpp_program_3dlut)(
224 			struct dpp *dpp,
225 			struct tetrahedral_params *params);
226 	void (*dpp_cnv_set_alpha_keyer)(
227 			struct dpp *dpp_base,
228 			struct cnv_color_keyer_params *color_keyer);
229 };
230 
231 
232 
233 #endif
234