1 /* Copyright 2012-17 Advanced Micro Devices, Inc.
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:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
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.
28 #include "dc_hw_types.h"
30 #define MAX_DWB_PIPES 3
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 */
50 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
51 /* DCN1.x supports 2 pipes */
55 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
63 sf_output_format
= 0x00000002,
64 sf_capture_rate
= 0x00000004,
68 enum dwb_capture_rate
{
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. */
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
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 */
90 unsigned int support_dwb
:1;
91 unsigned int support_ogam
:1;
92 unsigned int support_wbscl
:1;
93 unsigned int support_ocsc
:1;
95 unsigned int reserved2
[10]; /* Reserved for future use, MUST BE 0. */
100 /* Reserved ========================================================================= */
101 unsigned int reserved
[8]; /* Reserved fields */
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 */
109 /* CNV: WND Related parameters ====================================================== */
110 unsigned int capture_rate
; /* Captures once every (capture_rate+1) frames */
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 */
118 /* SISCL Related parameters ========================================================= */
119 unsigned int dest_width
; /* Destination width */
120 unsigned int dest_height
; /* Destination height */
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
;
129 /* Reserved ========================================================================= */
130 unsigned int reserved
[8]; /* Reserved fields */
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 */
142 /* / - dwb_frame_info is the info of the dumping data */
143 struct dwb_frame_info
{
147 unsigned int luma_pitch
;
148 unsigned int chroma_pitch
;
149 enum dwb_scaler_mode format
;
153 struct dwb_basic_settings basic_settings
;
154 struct dwb_advanced_settings advanced_settings
;
158 const struct dwbc_funcs
*funcs
;
159 struct dc_context
*ctx
;
160 struct dwbc_cfg config
;
161 struct dwb_status status
;
166 bool (*get_caps
)(struct dwbc
*dwbc
, struct dwb_caps
*caps
);
168 bool (*enable
)(struct dwbc
*dwbc
);
170 bool (*disable
)(struct dwbc
*dwbc
);
172 bool (*get_status
)(struct dwbc
*dwbc
, struct dwb_status
*status
);
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
);
178 bool (*set_basic_settings
)(struct dwbc
*dwbc
,
179 const struct dwb_basic_settings
*basic_settings
);
181 bool (*get_basic_settings
)(struct dwbc
*dwbc
,
182 struct dwb_basic_settings
*basic_settings
);
184 bool (*set_advanced_settings
)(struct dwbc
*dwbc
,
185 const struct dwb_advanced_settings
*advanced_settings
);
187 bool (*get_advanced_settings
)(struct dwbc
*dwbc
,
188 struct dwb_advanced_settings
*advanced_settings
);
190 bool (*reset_advanced_settings
)(struct dwbc
*dwbc
);