xref: /dflybsd-src/sys/dev/drm/amd/display/dc/inc/hw/opp.h (revision b843c749addef9340ee7d4e250b09fdd492602a1)
1*b843c749SSergey Zigachev /*
2*b843c749SSergey Zigachev  * Copyright 2012-15 Advanced Micro Devices, Inc.
3*b843c749SSergey Zigachev  *
4*b843c749SSergey Zigachev  * Permission is hereby granted, free of charge, to any person obtaining a
5*b843c749SSergey Zigachev  * copy of this software and associated documentation files (the "Software"),
6*b843c749SSergey Zigachev  * to deal in the Software without restriction, including without limitation
7*b843c749SSergey Zigachev  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*b843c749SSergey Zigachev  * and/or sell copies of the Software, and to permit persons to whom the
9*b843c749SSergey Zigachev  * Software is furnished to do so, subject to the following conditions:
10*b843c749SSergey Zigachev  *
11*b843c749SSergey Zigachev  * The above copyright notice and this permission notice shall be included in
12*b843c749SSergey Zigachev  * all copies or substantial portions of the Software.
13*b843c749SSergey Zigachev  *
14*b843c749SSergey Zigachev  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*b843c749SSergey Zigachev  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*b843c749SSergey Zigachev  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17*b843c749SSergey Zigachev  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*b843c749SSergey Zigachev  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*b843c749SSergey Zigachev  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*b843c749SSergey Zigachev  * OTHER DEALINGS IN THE SOFTWARE.
21*b843c749SSergey Zigachev  *
22*b843c749SSergey Zigachev  * Authors: AMD
23*b843c749SSergey Zigachev  *
24*b843c749SSergey Zigachev  */
25*b843c749SSergey Zigachev 
26*b843c749SSergey Zigachev #ifndef __DAL_OPP_H__
27*b843c749SSergey Zigachev #define __DAL_OPP_H__
28*b843c749SSergey Zigachev 
29*b843c749SSergey Zigachev #include "hw_shared.h"
30*b843c749SSergey Zigachev #include "dc_hw_types.h"
31*b843c749SSergey Zigachev #include "transform.h"
32*b843c749SSergey Zigachev #include "mpc.h"
33*b843c749SSergey Zigachev 
34*b843c749SSergey Zigachev struct fixed31_32;
35*b843c749SSergey Zigachev 
36*b843c749SSergey Zigachev /* TODO: Need cleanup */
37*b843c749SSergey Zigachev enum clamping_range {
38*b843c749SSergey Zigachev 	CLAMPING_FULL_RANGE = 0,	   /* No Clamping */
39*b843c749SSergey Zigachev 	CLAMPING_LIMITED_RANGE_8BPC,   /* 8  bpc: Clamping 1  to FE */
40*b843c749SSergey Zigachev 	CLAMPING_LIMITED_RANGE_10BPC, /* 10 bpc: Clamping 4  to 3FB */
41*b843c749SSergey Zigachev 	CLAMPING_LIMITED_RANGE_12BPC, /* 12 bpc: Clamping 10 to FEF */
42*b843c749SSergey Zigachev 	/* Use programmable clampping value on FMT_CLAMP_COMPONENT_R/G/B. */
43*b843c749SSergey Zigachev 	CLAMPING_LIMITED_RANGE_PROGRAMMABLE
44*b843c749SSergey Zigachev };
45*b843c749SSergey Zigachev 
46*b843c749SSergey Zigachev struct clamping_and_pixel_encoding_params {
47*b843c749SSergey Zigachev 	enum dc_pixel_encoding pixel_encoding; /* Pixel Encoding */
48*b843c749SSergey Zigachev 	enum clamping_range clamping_level; /* Clamping identifier */
49*b843c749SSergey Zigachev 	enum dc_color_depth c_depth; /* Deep color use. */
50*b843c749SSergey Zigachev };
51*b843c749SSergey Zigachev 
52*b843c749SSergey Zigachev struct bit_depth_reduction_params {
53*b843c749SSergey Zigachev 	struct {
54*b843c749SSergey Zigachev 		/* truncate/round */
55*b843c749SSergey Zigachev 		/* trunc/round enabled*/
56*b843c749SSergey Zigachev 		uint32_t TRUNCATE_ENABLED:1;
57*b843c749SSergey Zigachev 		/* 2 bits: 0=6 bpc, 1=8 bpc, 2 = 10bpc*/
58*b843c749SSergey Zigachev 		uint32_t TRUNCATE_DEPTH:2;
59*b843c749SSergey Zigachev 		/* truncate or round*/
60*b843c749SSergey Zigachev 		uint32_t TRUNCATE_MODE:1;
61*b843c749SSergey Zigachev 
62*b843c749SSergey Zigachev 		/* spatial dither */
63*b843c749SSergey Zigachev 		/* Spatial Bit Depth Reduction enabled*/
64*b843c749SSergey Zigachev 		uint32_t SPATIAL_DITHER_ENABLED:1;
65*b843c749SSergey Zigachev 		/* 2 bits: 0=6 bpc, 1 = 8 bpc, 2 = 10bpc*/
66*b843c749SSergey Zigachev 		uint32_t SPATIAL_DITHER_DEPTH:2;
67*b843c749SSergey Zigachev 		/* 0-3 to select patterns*/
68*b843c749SSergey Zigachev 		uint32_t SPATIAL_DITHER_MODE:2;
69*b843c749SSergey Zigachev 		/* Enable RGB random dithering*/
70*b843c749SSergey Zigachev 		uint32_t RGB_RANDOM:1;
71*b843c749SSergey Zigachev 		/* Enable Frame random dithering*/
72*b843c749SSergey Zigachev 		uint32_t FRAME_RANDOM:1;
73*b843c749SSergey Zigachev 		/* Enable HighPass random dithering*/
74*b843c749SSergey Zigachev 		uint32_t HIGHPASS_RANDOM:1;
75*b843c749SSergey Zigachev 
76*b843c749SSergey Zigachev 		/* temporal dither*/
77*b843c749SSergey Zigachev 		 /* frame modulation enabled*/
78*b843c749SSergey Zigachev 		uint32_t FRAME_MODULATION_ENABLED:1;
79*b843c749SSergey Zigachev 		/* same as for trunc/spatial*/
80*b843c749SSergey Zigachev 		uint32_t FRAME_MODULATION_DEPTH:2;
81*b843c749SSergey Zigachev 		/* 2/4 gray levels*/
82*b843c749SSergey Zigachev 		uint32_t TEMPORAL_LEVEL:1;
83*b843c749SSergey Zigachev 		uint32_t FRC25:2;
84*b843c749SSergey Zigachev 		uint32_t FRC50:2;
85*b843c749SSergey Zigachev 		uint32_t FRC75:2;
86*b843c749SSergey Zigachev 	} flags;
87*b843c749SSergey Zigachev 
88*b843c749SSergey Zigachev 	uint32_t r_seed_value;
89*b843c749SSergey Zigachev 	uint32_t b_seed_value;
90*b843c749SSergey Zigachev 	uint32_t g_seed_value;
91*b843c749SSergey Zigachev 	enum dc_pixel_encoding pixel_encoding;
92*b843c749SSergey Zigachev };
93*b843c749SSergey Zigachev 
94*b843c749SSergey Zigachev enum wide_gamut_regamma_mode {
95*b843c749SSergey Zigachev 	/*  0x0  - BITS2:0 Bypass */
96*b843c749SSergey Zigachev 	WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_BYPASS,
97*b843c749SSergey Zigachev 	/*  0x1  - Fixed curve sRGB 2.4 */
98*b843c749SSergey Zigachev 	WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_SRGB24,
99*b843c749SSergey Zigachev 	/*  0x2  - Fixed curve xvYCC 2.22 */
100*b843c749SSergey Zigachev 	WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_XYYCC22,
101*b843c749SSergey Zigachev 	/*  0x3  - Programmable control A */
102*b843c749SSergey Zigachev 	WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_A,
103*b843c749SSergey Zigachev 	/*  0x4  - Programmable control B */
104*b843c749SSergey Zigachev 	WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_B,
105*b843c749SSergey Zigachev 	/*  0x0  - BITS6:4 Bypass */
106*b843c749SSergey Zigachev 	WIDE_GAMUT_REGAMMA_MODE_OVL_BYPASS,
107*b843c749SSergey Zigachev 	/*  0x1  - Fixed curve sRGB 2.4 */
108*b843c749SSergey Zigachev 	WIDE_GAMUT_REGAMMA_MODE_OVL_SRGB24,
109*b843c749SSergey Zigachev 	/*  0x2  - Fixed curve xvYCC 2.22 */
110*b843c749SSergey Zigachev 	WIDE_GAMUT_REGAMMA_MODE_OVL_XYYCC22,
111*b843c749SSergey Zigachev 	/*  0x3  - Programmable control A */
112*b843c749SSergey Zigachev 	WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_A,
113*b843c749SSergey Zigachev 	/*  0x4  - Programmable control B */
114*b843c749SSergey Zigachev 	WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_B
115*b843c749SSergey Zigachev };
116*b843c749SSergey Zigachev 
117*b843c749SSergey Zigachev struct gamma_pixel {
118*b843c749SSergey Zigachev 	struct fixed31_32 r;
119*b843c749SSergey Zigachev 	struct fixed31_32 g;
120*b843c749SSergey Zigachev 	struct fixed31_32 b;
121*b843c749SSergey Zigachev };
122*b843c749SSergey Zigachev 
123*b843c749SSergey Zigachev enum channel_name {
124*b843c749SSergey Zigachev 	CHANNEL_NAME_RED,
125*b843c749SSergey Zigachev 	CHANNEL_NAME_GREEN,
126*b843c749SSergey Zigachev 	CHANNEL_NAME_BLUE
127*b843c749SSergey Zigachev };
128*b843c749SSergey Zigachev 
129*b843c749SSergey Zigachev struct custom_float_format {
130*b843c749SSergey Zigachev 	uint32_t mantissa_bits;
131*b843c749SSergey Zigachev 	uint32_t exponenta_bits;
132*b843c749SSergey Zigachev 	bool sign;
133*b843c749SSergey Zigachev };
134*b843c749SSergey Zigachev 
135*b843c749SSergey Zigachev struct custom_float_value {
136*b843c749SSergey Zigachev 	uint32_t mantissa;
137*b843c749SSergey Zigachev 	uint32_t exponenta;
138*b843c749SSergey Zigachev 	uint32_t value;
139*b843c749SSergey Zigachev 	bool negative;
140*b843c749SSergey Zigachev };
141*b843c749SSergey Zigachev 
142*b843c749SSergey Zigachev struct hw_x_point {
143*b843c749SSergey Zigachev 	uint32_t custom_float_x;
144*b843c749SSergey Zigachev 	struct fixed31_32 x;
145*b843c749SSergey Zigachev 	struct fixed31_32 regamma_y_red;
146*b843c749SSergey Zigachev 	struct fixed31_32 regamma_y_green;
147*b843c749SSergey Zigachev 	struct fixed31_32 regamma_y_blue;
148*b843c749SSergey Zigachev 
149*b843c749SSergey Zigachev };
150*b843c749SSergey Zigachev 
151*b843c749SSergey Zigachev struct pwl_float_data_ex {
152*b843c749SSergey Zigachev 	struct fixed31_32 r;
153*b843c749SSergey Zigachev 	struct fixed31_32 g;
154*b843c749SSergey Zigachev 	struct fixed31_32 b;
155*b843c749SSergey Zigachev 	struct fixed31_32 delta_r;
156*b843c749SSergey Zigachev 	struct fixed31_32 delta_g;
157*b843c749SSergey Zigachev 	struct fixed31_32 delta_b;
158*b843c749SSergey Zigachev };
159*b843c749SSergey Zigachev 
160*b843c749SSergey Zigachev enum hw_point_position {
161*b843c749SSergey Zigachev 	/* hw point sits between left and right sw points */
162*b843c749SSergey Zigachev 	HW_POINT_POSITION_MIDDLE,
163*b843c749SSergey Zigachev 	/* hw point lays left from left (smaller) sw point */
164*b843c749SSergey Zigachev 	HW_POINT_POSITION_LEFT,
165*b843c749SSergey Zigachev 	/* hw point lays stays from right (bigger) sw point */
166*b843c749SSergey Zigachev 	HW_POINT_POSITION_RIGHT
167*b843c749SSergey Zigachev };
168*b843c749SSergey Zigachev 
169*b843c749SSergey Zigachev struct gamma_point {
170*b843c749SSergey Zigachev 	int32_t left_index;
171*b843c749SSergey Zigachev 	int32_t right_index;
172*b843c749SSergey Zigachev 	enum hw_point_position pos;
173*b843c749SSergey Zigachev 	struct fixed31_32 coeff;
174*b843c749SSergey Zigachev };
175*b843c749SSergey Zigachev 
176*b843c749SSergey Zigachev struct pixel_gamma_point {
177*b843c749SSergey Zigachev 	struct gamma_point r;
178*b843c749SSergey Zigachev 	struct gamma_point g;
179*b843c749SSergey Zigachev 	struct gamma_point b;
180*b843c749SSergey Zigachev };
181*b843c749SSergey Zigachev 
182*b843c749SSergey Zigachev struct gamma_coefficients {
183*b843c749SSergey Zigachev 	struct fixed31_32 a0[3];
184*b843c749SSergey Zigachev 	struct fixed31_32 a1[3];
185*b843c749SSergey Zigachev 	struct fixed31_32 a2[3];
186*b843c749SSergey Zigachev 	struct fixed31_32 a3[3];
187*b843c749SSergey Zigachev 	struct fixed31_32 user_gamma[3];
188*b843c749SSergey Zigachev 	struct fixed31_32 user_contrast;
189*b843c749SSergey Zigachev 	struct fixed31_32 user_brightness;
190*b843c749SSergey Zigachev };
191*b843c749SSergey Zigachev 
192*b843c749SSergey Zigachev struct pwl_float_data {
193*b843c749SSergey Zigachev 	struct fixed31_32 r;
194*b843c749SSergey Zigachev 	struct fixed31_32 g;
195*b843c749SSergey Zigachev 	struct fixed31_32 b;
196*b843c749SSergey Zigachev };
197*b843c749SSergey Zigachev 
198*b843c749SSergey Zigachev struct mpc_tree_cfg {
199*b843c749SSergey Zigachev 	int num_pipes;
200*b843c749SSergey Zigachev 	int dpp[MAX_PIPES];
201*b843c749SSergey Zigachev 	int mpcc[MAX_PIPES];
202*b843c749SSergey Zigachev };
203*b843c749SSergey Zigachev 
204*b843c749SSergey Zigachev struct output_pixel_processor {
205*b843c749SSergey Zigachev 	struct dc_context *ctx;
206*b843c749SSergey Zigachev 	uint32_t inst;
207*b843c749SSergey Zigachev 	struct pwl_params regamma_params;
208*b843c749SSergey Zigachev 	struct mpc_tree mpc_tree_params;
209*b843c749SSergey Zigachev 	bool mpcc_disconnect_pending[MAX_PIPES];
210*b843c749SSergey Zigachev 	const struct opp_funcs *funcs;
211*b843c749SSergey Zigachev };
212*b843c749SSergey Zigachev 
213*b843c749SSergey Zigachev enum fmt_stereo_action {
214*b843c749SSergey Zigachev 	FMT_STEREO_ACTION_ENABLE = 0,
215*b843c749SSergey Zigachev 	FMT_STEREO_ACTION_DISABLE,
216*b843c749SSergey Zigachev 	FMT_STEREO_ACTION_UPDATE_POLARITY
217*b843c749SSergey Zigachev };
218*b843c749SSergey Zigachev 
219*b843c749SSergey Zigachev struct opp_grph_csc_adjustment {
220*b843c749SSergey Zigachev 	//enum grph_color_adjust_option color_adjust_option;
221*b843c749SSergey Zigachev 	enum dc_color_space c_space;
222*b843c749SSergey Zigachev 	enum dc_color_depth color_depth; /* clean up to uint32_t */
223*b843c749SSergey Zigachev 	enum graphics_csc_adjust_type   csc_adjust_type;
224*b843c749SSergey Zigachev 	int32_t adjust_divider;
225*b843c749SSergey Zigachev 	int32_t grph_cont;
226*b843c749SSergey Zigachev 	int32_t grph_sat;
227*b843c749SSergey Zigachev 	int32_t grph_bright;
228*b843c749SSergey Zigachev 	int32_t grph_hue;
229*b843c749SSergey Zigachev };
230*b843c749SSergey Zigachev 
231*b843c749SSergey Zigachev /* Underlay related types */
232*b843c749SSergey Zigachev 
233*b843c749SSergey Zigachev struct hw_adjustment_range {
234*b843c749SSergey Zigachev 	int32_t hw_default;
235*b843c749SSergey Zigachev 	int32_t min;
236*b843c749SSergey Zigachev 	int32_t max;
237*b843c749SSergey Zigachev 	int32_t step;
238*b843c749SSergey Zigachev 	uint32_t divider; /* (actually HW range is min/divider; divider !=0) */
239*b843c749SSergey Zigachev };
240*b843c749SSergey Zigachev 
241*b843c749SSergey Zigachev enum ovl_csc_adjust_item {
242*b843c749SSergey Zigachev 	OVERLAY_BRIGHTNESS = 0,
243*b843c749SSergey Zigachev 	OVERLAY_GAMMA,
244*b843c749SSergey Zigachev 	OVERLAY_CONTRAST,
245*b843c749SSergey Zigachev 	OVERLAY_SATURATION,
246*b843c749SSergey Zigachev 	OVERLAY_HUE,
247*b843c749SSergey Zigachev 	OVERLAY_ALPHA,
248*b843c749SSergey Zigachev 	OVERLAY_ALPHA_PER_PIX,
249*b843c749SSergey Zigachev 	OVERLAY_COLOR_TEMPERATURE
250*b843c749SSergey Zigachev };
251*b843c749SSergey Zigachev 
252*b843c749SSergey Zigachev enum oppbuf_display_segmentation {
253*b843c749SSergey Zigachev 	OPPBUF_DISPLAY_SEGMENTATION_1_SEGMENT = 0,
254*b843c749SSergey Zigachev 	OPPBUF_DISPLAY_SEGMENTATION_2_SEGMENT = 1,
255*b843c749SSergey Zigachev 	OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT = 2,
256*b843c749SSergey Zigachev 	OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT_SPLIT_LEFT = 3,
257*b843c749SSergey Zigachev 	OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT_SPLIT_RIGHT = 4
258*b843c749SSergey Zigachev };
259*b843c749SSergey Zigachev 
260*b843c749SSergey Zigachev struct oppbuf_params {
261*b843c749SSergey Zigachev 	uint32_t active_width;
262*b843c749SSergey Zigachev 	enum oppbuf_display_segmentation mso_segmentation;
263*b843c749SSergey Zigachev 	uint32_t mso_overlap_pixel_num;
264*b843c749SSergey Zigachev 	uint32_t pixel_repetition;
265*b843c749SSergey Zigachev };
266*b843c749SSergey Zigachev 
267*b843c749SSergey Zigachev struct opp_funcs {
268*b843c749SSergey Zigachev 
269*b843c749SSergey Zigachev 
270*b843c749SSergey Zigachev 	/* FORMATTER RELATED */
271*b843c749SSergey Zigachev 
272*b843c749SSergey Zigachev 	void (*opp_program_fmt)(
273*b843c749SSergey Zigachev 			struct output_pixel_processor *opp,
274*b843c749SSergey Zigachev 			struct bit_depth_reduction_params *fmt_bit_depth,
275*b843c749SSergey Zigachev 			struct clamping_and_pixel_encoding_params *clamping);
276*b843c749SSergey Zigachev 
277*b843c749SSergey Zigachev 	void (*opp_set_dyn_expansion)(
278*b843c749SSergey Zigachev 		struct output_pixel_processor *opp,
279*b843c749SSergey Zigachev 		enum dc_color_space color_sp,
280*b843c749SSergey Zigachev 		enum dc_color_depth color_dpth,
281*b843c749SSergey Zigachev 		enum signal_type signal);
282*b843c749SSergey Zigachev 
283*b843c749SSergey Zigachev 	void (*opp_program_bit_depth_reduction)(
284*b843c749SSergey Zigachev 		struct output_pixel_processor *opp,
285*b843c749SSergey Zigachev 		const struct bit_depth_reduction_params *params);
286*b843c749SSergey Zigachev 
287*b843c749SSergey Zigachev 	/* underlay related */
288*b843c749SSergey Zigachev 	void (*opp_get_underlay_adjustment_range)(
289*b843c749SSergey Zigachev 			struct output_pixel_processor *opp,
290*b843c749SSergey Zigachev 			enum ovl_csc_adjust_item overlay_adjust_item,
291*b843c749SSergey Zigachev 			struct hw_adjustment_range *range);
292*b843c749SSergey Zigachev 
293*b843c749SSergey Zigachev 	void (*opp_destroy)(struct output_pixel_processor **opp);
294*b843c749SSergey Zigachev 
295*b843c749SSergey Zigachev 	void (*opp_program_stereo)(
296*b843c749SSergey Zigachev 		struct output_pixel_processor *opp,
297*b843c749SSergey Zigachev 		bool enable,
298*b843c749SSergey Zigachev 		const struct dc_crtc_timing *timing);
299*b843c749SSergey Zigachev 
300*b843c749SSergey Zigachev 	void (*opp_pipe_clock_control)(
301*b843c749SSergey Zigachev 			struct output_pixel_processor *opp,
302*b843c749SSergey Zigachev 			bool enable);
303*b843c749SSergey Zigachev 
304*b843c749SSergey Zigachev };
305*b843c749SSergey Zigachev 
306*b843c749SSergey Zigachev #endif
307