]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h
82347ba480fe7af5ede5754e5a1459fb24409ee9
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / amd / display / dc / inc / hw / dwb.h
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 "dc_hw_types.h"
29
30 #define MAX_DWB_PIPES 3
31
32 enum dce_version;
33
34 enum dwb_sw_version {
35 dwb_ver_1_0 = 1,
36 };
37
38 enum dwb_source {
39 dwb_src_scl = 0, /* for DCE7x/9x, DCN won't support. */
40 dwb_src_blnd, /* for DCE7x/9x */
41 dwb_src_fmt, /* for DCE7x/9x */
42 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
43 dwb_src_otg0 = 0x100, /* for DCN1.x, register: mmDWB_SOURCE_SELECT */
44 dwb_src_otg1, /* for DCN1.x */
45 dwb_src_otg2, /* for DCN1.x */
46 dwb_src_otg3, /* for DCN1.x */
47 #endif
48 };
49
50 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
51 /* DCN1.x supports 2 pipes */
52 #endif
53 enum dwb_pipe {
54 dwb_pipe0 = 0,
55 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
56 dwb_pipe1,
57 #endif
58 dwb_pipe_max_num,
59 };
60
61 enum setting_flags {
62 sf_pipe = 0x00000001,
63 sf_output_format = 0x00000002,
64 sf_capture_rate = 0x00000004,
65 sf_all = 0xffffffff,
66 };
67
68 enum dwb_capture_rate {
69
70 dwb_capture_rate_0 = 0, /* Every frame is captured. */
71 dwb_capture_rate_1 = 1, /* Every other frame is captured. */
72 dwb_capture_rate_2 = 2, /* Every 3rd frame is captured. */
73 dwb_capture_rate_3 = 3, /* Every 4th frame is captured. */
74 };
75
76 enum dwb_scaler_mode {
77 dwb_scaler_mode_bypass444 = 0,
78 dwb_scaler_mode_rgb444 = 1,
79 dwb_scaler_mode_yuv444 = 2,
80 dwb_scaler_mode_yuv420 = 3
81 };
82
83 struct dwb_caps {
84 enum dce_version hw_version; /* DCN engine version. */
85 enum dwb_sw_version sw_version; /* DWB sw implementation version. */
86 unsigned int reserved[6]; /* Reserved for future use, MUST BE 0. */
87 unsigned int adapter_id;
88 unsigned int num_pipes; /* number of DWB pipes */
89 struct {
90 unsigned int support_dwb :1;
91 unsigned int support_ogam :1;
92 unsigned int support_wbscl :1;
93 unsigned int support_ocsc :1;
94 } caps;
95 unsigned int reserved2[10]; /* Reserved for future use, MUST BE 0. */
96 };
97
98 struct dwb_status {
99 bool enabled;
100 /* Reserved ========================================================================= */
101 unsigned int reserved[8]; /* Reserved fields */
102 };
103
104 struct dwb_basic_settings {
105 /* General DWB related input parameters ============================================= */
106 enum dwb_source input_src_select; /* Select input source: (DCE) 0: SCL; 1: BLND; 2: FMT; (DCN) OTG* or MPC* */
107 enum dwb_pipe input_pipe_select; /* Select input pipe: 0: PIPE0; 1: PIPE1; 2: PIPE2 */
108
109 /* CNV: WND Related parameters ====================================================== */
110 unsigned int capture_rate; /* Captures once every (capture_rate+1) frames */
111
112 /* CNV: CSC Related parameters ====================================================== */
113 unsigned int start_x; /* Horizontal window start position */
114 unsigned int start_y; /* Vertical window start position */
115 unsigned int src_width; /* Width of window captured within source window */
116 unsigned int src_height; /* Height of window captured within source window */
117
118 /* SISCL Related parameters ========================================================= */
119 unsigned int dest_width; /* Destination width */
120 unsigned int dest_height; /* Destination height */
121
122 /* MCIF bufer parameters ========================================================= */
123 unsigned long long luma_address[4];
124 unsigned long long chroma_address[4];
125 unsigned int luma_pitch;
126 unsigned int chroma_pitch;
127 unsigned int slice_lines;
128
129 /* Reserved ========================================================================= */
130 unsigned int reserved[8]; /* Reserved fields */
131
132 };
133
134 struct dwb_advanced_settings {
135 enum setting_flags uFlag;
136 enum dwb_pipe pipe; /* default = DWB_PIPE_ALL */
137 enum dwb_scaler_mode out_format; /* default = DWBScalerMode_YUV420 */
138 enum dwb_capture_rate capture_rate; /* default = Every frame is captured */
139 unsigned int reserved[64]; /* reserved for future use, must be 0 */
140 };
141
142 /* / - dwb_frame_info is the info of the dumping data */
143 struct dwb_frame_info {
144 unsigned int size;
145 unsigned int width;
146 unsigned int height;
147 unsigned int luma_pitch;
148 unsigned int chroma_pitch;
149 enum dwb_scaler_mode format;
150 };
151
152 struct dwbc_cfg {
153 struct dwb_basic_settings basic_settings;
154 struct dwb_advanced_settings advanced_settings;
155 };
156
157 struct dwbc {
158 const struct dwbc_funcs *funcs;
159 struct dc_context *ctx;
160 struct dwbc_cfg config;
161 struct dwb_status status;
162 int inst;
163 };
164
165 struct dwbc_funcs {
166 bool (*get_caps)(struct dwbc *dwbc, struct dwb_caps *caps);
167
168 bool (*enable)(struct dwbc *dwbc);
169
170 bool (*disable)(struct dwbc *dwbc);
171
172 bool (*get_status)(struct dwbc *dwbc, struct dwb_status *status);
173
174 bool (*dump_frame)(struct dwbc *dwbc, struct dwb_frame_info *frame_info,
175 unsigned char *luma_buffer, unsigned char *chroma_buffer,
176 unsigned char *dest_luma_buffer, unsigned char *dest_chroma_buffer);
177
178 bool (*set_basic_settings)(struct dwbc *dwbc,
179 const struct dwb_basic_settings *basic_settings);
180
181 bool (*get_basic_settings)(struct dwbc *dwbc,
182 struct dwb_basic_settings *basic_settings);
183
184 bool (*set_advanced_settings)(struct dwbc *dwbc,
185 const struct dwb_advanced_settings *advanced_settings);
186
187 bool (*get_advanced_settings)(struct dwbc *dwbc,
188 struct dwb_advanced_settings *advanced_settings);
189
190 bool (*reset_advanced_settings)(struct dwbc *dwbc);
191 };
192
193 #endif