xref: /openbmc/linux/drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h (revision 15e3ae36)
1 /* Copyright 2012-17 Advanced Micro Devices, Inc.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a
4  * copy of this software and associated documentation files (the "Software"),
5  * to deal in the Software without restriction, including without limitation
6  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7  * and/or sell copies of the Software, and to permit persons to whom the
8  * Software is furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
16  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
17  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19  * OTHER DEALINGS IN THE SOFTWARE.
20  *
21  * Authors: AMD
22  *
23  */
24 
25 #ifndef __DC_DWBC_H__
26 #define __DC_DWBC_H__
27 
28 #include "dal_types.h"
29 #include "dc_hw_types.h"
30 
31 #define DWB_SW_V2	1
32 #define DWB_MCIF_BUF_COUNT 4
33 
34 /* forward declaration of mcif_wb struct */
35 struct mcif_wb;
36 
37 
38 enum dwb_sw_version {
39 	dwb_ver_1_0 = 1,
40 	dwb_ver_2_0 = 2,
41 };
42 
43 enum dwb_source {
44 	dwb_src_scl = 0,	/* for DCE7x/9x, DCN won't support. */
45 	dwb_src_blnd,		/* for DCE7x/9x */
46 	dwb_src_fmt,		/* for DCE7x/9x */
47 	dwb_src_otg0 = 0x100,	/* for DCN1.x/DCN2.x, register: mmDWB_SOURCE_SELECT */
48 	dwb_src_otg1,		/* for DCN1.x/DCN2.x */
49 	dwb_src_otg2,		/* for DCN1.x/DCN2.x */
50 	dwb_src_otg3,		/* for DCN1.x/DCN2.x */
51 };
52 
53 /* DCN1.x, DCN2.x support 2 pipes */
54 enum dwb_pipe {
55 	dwb_pipe0 = 0,
56 #if defined(CONFIG_DRM_AMD_DC_DCN)
57 	dwb_pipe1,
58 #endif
59 	dwb_pipe_max_num,
60 };
61 
62 enum dwb_frame_capture_enable {
63 	DWB_FRAME_CAPTURE_DISABLE = 0,
64 	DWB_FRAME_CAPTURE_ENABLE = 1,
65 };
66 
67 enum wbscl_coef_filter_type_sel {
68 	WBSCL_COEF_LUMA_VERT_FILTER = 0,
69 	WBSCL_COEF_CHROMA_VERT_FILTER = 1,
70 	WBSCL_COEF_LUMA_HORZ_FILTER = 2,
71 	WBSCL_COEF_CHROMA_HORZ_FILTER = 3
72 };
73 
74 
75 struct dwb_warmup_params {
76 	bool	warmup_en;	/* false: normal mode, true: enable pattern generator */
77 	bool	warmup_mode;	/* false: 420, true: 444 */
78 	bool	warmup_depth;	/* false: 8bit, true: 10bit */
79 	int	warmup_data;	/* Data to be sent by pattern generator (same for each pixel component) */
80 	int	warmup_width;	/* Pattern width (pixels) */
81 	int	warmup_height;	/* Pattern height (lines) */
82 };
83 
84 struct dwb_caps {
85 	enum dce_version hw_version;	/* DCN engine version. */
86 	enum dwb_sw_version sw_version;	/* DWB sw implementation version. */
87 	unsigned int	reserved[6];	/* Reserved for future use, MUST BE 0. */
88 	unsigned int	adapter_id;
89 	unsigned int	num_pipes;	/* number of DWB pipes */
90 	struct {
91 		unsigned int support_dwb	:1;
92 		unsigned int support_ogam	:1;
93 		unsigned int support_wbscl	:1;
94 		unsigned int support_ocsc	:1;
95 		unsigned int support_stereo :1;
96 	} caps;
97 	unsigned int	 reserved2[9];	/* Reserved for future use, MUST BE 0. */
98 };
99 
100 struct dwbc {
101 	const struct dwbc_funcs *funcs;
102 	struct dc_context *ctx;
103 	int inst;
104 	struct mcif_wb *mcif;
105 	bool status;
106 	int inputSrcSelect;
107 	bool dwb_output_black;
108 	enum dc_transfer_func_predefined tf;
109 	enum dc_color_space output_color_space;
110 	bool dwb_is_efc_transition;
111 	bool dwb_is_drc;
112 	int wb_src_plane_inst;/*hubp, mpcc, inst*/
113 	bool update_privacymask;
114 	uint32_t mask_id;
115         int otg_inst;
116         bool mvc_cfg;
117 };
118 
119 struct dwbc_funcs {
120 	bool (*get_caps)(
121 		struct dwbc *dwbc,
122 		struct dwb_caps *caps);
123 
124 	bool (*enable)(
125 		struct dwbc *dwbc,
126 		struct dc_dwb_params *params);
127 
128 	bool (*disable)(struct dwbc *dwbc);
129 
130 	bool (*update)(
131 		struct dwbc *dwbc,
132 		struct dc_dwb_params *params);
133 
134 	bool (*is_enabled)(
135 		struct dwbc *dwbc);
136 
137 	void (*set_stereo)(
138 		struct dwbc *dwbc,
139 		struct dwb_stereo_params *stereo_params);
140 
141 	void (*set_new_content)(
142 		struct dwbc *dwbc,
143 		bool is_new_content);
144 
145 
146 	void (*set_warmup)(
147 		struct dwbc *dwbc,
148 		struct dwb_warmup_params *warmup_params);
149 
150 
151 	bool (*get_dwb_status)(
152 		struct dwbc *dwbc);
153 	void (*dwb_set_scaler)(
154 		struct dwbc *dwbc,
155 		struct dc_dwb_params *params);
156 };
157 
158 #endif
159