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 
40 };
41 
42 struct dpp_grph_csc_adjustment {
43 	struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
44 	enum graphics_gamut_adjust_type gamut_adjust_type;
45 };
46 
47 struct dcn_dpp_state {
48 	uint32_t igam_lut_mode;
49 	uint32_t igam_input_format;
50 	uint32_t dgam_lut_mode;
51 	uint32_t rgam_lut_mode;
52 	uint32_t gamut_remap_mode;
53 	uint32_t gamut_remap_c11_c12;
54 	uint32_t gamut_remap_c13_c14;
55 	uint32_t gamut_remap_c21_c22;
56 	uint32_t gamut_remap_c23_c24;
57 	uint32_t gamut_remap_c31_c32;
58 	uint32_t gamut_remap_c33_c34;
59 };
60 
61 struct dpp_funcs {
62 	void (*dpp_read_state)(struct dpp *dpp, struct dcn_dpp_state *s);
63 
64 	void (*dpp_reset)(struct dpp *dpp);
65 
66 	void (*dpp_set_scaler)(struct dpp *dpp,
67 			const struct scaler_data *scl_data);
68 
69 	void (*dpp_set_pixel_storage_depth)(
70 			struct dpp *dpp,
71 			enum lb_pixel_depth depth,
72 			const struct bit_depth_reduction_params *bit_depth_params);
73 
74 	bool (*dpp_get_optimal_number_of_taps)(
75 			struct dpp *dpp,
76 			struct scaler_data *scl_data,
77 			const struct scaling_taps *in_taps);
78 
79 	void (*dpp_set_gamut_remap)(
80 			struct dpp *dpp,
81 			const struct dpp_grph_csc_adjustment *adjust);
82 
83 	void (*dpp_set_csc_default)(
84 		struct dpp *dpp,
85 		enum dc_color_space colorspace);
86 
87 	void (*dpp_set_csc_adjustment)(
88 		struct dpp *dpp,
89 		const uint16_t *regval);
90 
91 	void (*dpp_power_on_regamma_lut)(
92 		struct dpp *dpp,
93 		bool power_on);
94 
95 	void (*dpp_program_regamma_lut)(
96 			struct dpp *dpp,
97 			const struct pwl_result_data *rgb,
98 			uint32_t num);
99 
100 	void (*dpp_configure_regamma_lut)(
101 			struct dpp *dpp,
102 			bool is_ram_a);
103 
104 	void (*dpp_program_regamma_lutb_settings)(
105 			struct dpp *dpp,
106 			const struct pwl_params *params);
107 
108 	void (*dpp_program_regamma_luta_settings)(
109 			struct dpp *dpp,
110 			const struct pwl_params *params);
111 
112 	void (*dpp_program_regamma_pwl)(
113 		struct dpp *dpp,
114 		const struct pwl_params *params,
115 		enum opp_regamma mode);
116 
117 	void (*dpp_program_bias_and_scale)(
118 			struct dpp *dpp,
119 			struct dc_bias_and_scale *params);
120 
121 	void (*dpp_set_degamma)(
122 			struct dpp *dpp_base,
123 			enum ipp_degamma_mode mode);
124 
125 	void (*dpp_program_input_lut)(
126 			struct dpp *dpp_base,
127 			const struct dc_gamma *gamma);
128 
129 	void (*dpp_program_degamma_pwl)(struct dpp *dpp_base,
130 									 const struct pwl_params *params);
131 
132 	void (*dpp_setup)(
133 			struct dpp *dpp_base,
134 			enum surface_pixel_format format,
135 			enum expansion_mode mode,
136 			struct dc_csc_transform input_csc_color_matrix,
137 			enum dc_color_space input_color_space);
138 
139 	void (*dpp_full_bypass)(struct dpp *dpp_base);
140 
141 	void (*set_cursor_attributes)(
142 			struct dpp *dpp_base,
143 			enum dc_cursor_color_format color_format);
144 
145 	void (*set_cursor_position)(
146 			struct dpp *dpp_base,
147 			const struct dc_cursor_position *pos,
148 			const struct dc_cursor_mi_param *param,
149 			uint32_t width
150 			);
151 	void (*dpp_set_hdr_multiplier)(
152 			struct dpp *dpp_base,
153 			uint32_t multiplier);
154 	void (*set_optional_cursor_attributes)(
155 			struct dpp *dpp_base,
156 			struct dpp_cursor_attributes *attr);
157 
158 	void (*dpp_dppclk_control)(
159 			struct dpp *dpp_base,
160 			bool dppclk_div,
161 			bool enable);
162 
163 };
164 
165 
166 
167 #endif
168