xref: /linux/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dwb.c (revision 36ec807b627b4c0a0a382f0ae48eac7187d14b2b)
1345429a6SHarry Wentland /*
2345429a6SHarry Wentland  * Copyright 2012-17 Advanced Micro Devices, Inc.
3345429a6SHarry Wentland  *
4345429a6SHarry Wentland  * Permission is hereby granted, free of charge, to any person obtaining a
5345429a6SHarry Wentland  * copy of this software and associated documentation files (the "Software"),
6345429a6SHarry Wentland  * to deal in the Software without restriction, including without limitation
7345429a6SHarry Wentland  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8345429a6SHarry Wentland  * and/or sell copies of the Software, and to permit persons to whom the
9345429a6SHarry Wentland  * Software is furnished to do so, subject to the following conditions:
10345429a6SHarry Wentland  *
11345429a6SHarry Wentland  * The above copyright notice and this permission notice shall be included in
12345429a6SHarry Wentland  * all copies or substantial portions of the Software.
13345429a6SHarry Wentland  *
14345429a6SHarry Wentland  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15345429a6SHarry Wentland  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16345429a6SHarry Wentland  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17345429a6SHarry Wentland  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18345429a6SHarry Wentland  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19345429a6SHarry Wentland  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20345429a6SHarry Wentland  * OTHER DEALINGS IN THE SOFTWARE.
21345429a6SHarry Wentland  *
22345429a6SHarry Wentland  * Authors: AMD
23345429a6SHarry Wentland  *
24345429a6SHarry Wentland  */
25345429a6SHarry Wentland 
26345429a6SHarry Wentland 
27345429a6SHarry Wentland #include "reg_helper.h"
28345429a6SHarry Wentland #include "resource.h"
29345429a6SHarry Wentland #include "dwb.h"
30345429a6SHarry Wentland #include "dcn20_dwb.h"
31345429a6SHarry Wentland 
32345429a6SHarry Wentland 
33345429a6SHarry Wentland #define REG(reg)\
34345429a6SHarry Wentland 	dwbc20->dwbc_regs->reg
35345429a6SHarry Wentland 
36345429a6SHarry Wentland #define CTX \
37345429a6SHarry Wentland 	dwbc20->base.ctx
38345429a6SHarry Wentland 
3972c6473aSCharlene Liu #define DC_LOGGER \
4072c6473aSCharlene Liu 	dwbc20->base.ctx->logger
41345429a6SHarry Wentland #undef FN
42345429a6SHarry Wentland #define FN(reg_name, field_name) \
43345429a6SHarry Wentland 	dwbc20->dwbc_shift->field_name, dwbc20->dwbc_mask->field_name
44345429a6SHarry Wentland 
45345429a6SHarry Wentland enum dwb_outside_pix_strategy {
46345429a6SHarry Wentland 	DWB_OUTSIDE_PIX_STRATEGY_BLACK = 0,
47345429a6SHarry Wentland 	DWB_OUTSIDE_PIX_STRATEGY_EDGE  = 1
48345429a6SHarry Wentland };
49345429a6SHarry Wentland 
dwb2_get_caps(struct dwbc * dwbc,struct dwb_caps * caps)50345429a6SHarry Wentland static bool dwb2_get_caps(struct dwbc *dwbc, struct dwb_caps *caps)
51345429a6SHarry Wentland {
5272c6473aSCharlene Liu 	struct dcn20_dwbc *dwbc20 = TO_DCN20_DWBC(dwbc);
53345429a6SHarry Wentland 	if (caps) {
54345429a6SHarry Wentland 		caps->adapter_id = 0;	/* we only support 1 adapter currently */
55345429a6SHarry Wentland 		caps->hw_version = DCN_VERSION_2_0;
56345429a6SHarry Wentland 		caps->num_pipes = 1;
57345429a6SHarry Wentland 		memset(&caps->reserved, 0, sizeof(caps->reserved));
58345429a6SHarry Wentland 		memset(&caps->reserved2, 0, sizeof(caps->reserved2));
59345429a6SHarry Wentland 		caps->sw_version = dwb_ver_1_0;
60345429a6SHarry Wentland 		caps->caps.support_dwb = true;
61345429a6SHarry Wentland 		caps->caps.support_ogam = false;
62345429a6SHarry Wentland 		caps->caps.support_wbscl = false;
63345429a6SHarry Wentland 		caps->caps.support_ocsc = false;
6472c6473aSCharlene Liu 		DC_LOG_DWB("%s SUPPORTED! inst = %d", __func__, dwbc20->base.inst);
65345429a6SHarry Wentland 		return true;
66345429a6SHarry Wentland 	} else {
6772c6473aSCharlene Liu 		DC_LOG_DWB("%s NOT SUPPORTED! inst = %d", __func__, dwbc20->base.inst);
68345429a6SHarry Wentland 		return false;
69345429a6SHarry Wentland 	}
70345429a6SHarry Wentland }
71345429a6SHarry Wentland 
dwb2_config_dwb_cnv(struct dwbc * dwbc,struct dc_dwb_params * params)72345429a6SHarry Wentland void dwb2_config_dwb_cnv(struct dwbc *dwbc, struct dc_dwb_params *params)
73345429a6SHarry Wentland {
74345429a6SHarry Wentland 	struct dcn20_dwbc *dwbc20 = TO_DCN20_DWBC(dwbc);
7572c6473aSCharlene Liu 	DC_LOG_DWB("%s inst = %d", __func__, dwbc20->base.inst);
76345429a6SHarry Wentland 
77345429a6SHarry Wentland 	/* Set DWB source size */
78345429a6SHarry Wentland 	REG_UPDATE_2(CNV_SOURCE_SIZE, CNV_SOURCE_WIDTH, params->cnv_params.src_width,
79345429a6SHarry Wentland 			CNV_SOURCE_HEIGHT, params->cnv_params.src_height);
80345429a6SHarry Wentland 
81345429a6SHarry Wentland 	/* source size is not equal the source size, then enable cropping. */
82345429a6SHarry Wentland 	if (params->cnv_params.crop_en) {
83345429a6SHarry Wentland 		REG_UPDATE(CNV_MODE, CNV_WINDOW_CROP_EN, 1);
84345429a6SHarry Wentland 		REG_UPDATE(CNV_WINDOW_START, CNV_WINDOW_START_X, params->cnv_params.crop_x);
85345429a6SHarry Wentland 		REG_UPDATE(CNV_WINDOW_START, CNV_WINDOW_START_Y, params->cnv_params.crop_y);
86345429a6SHarry Wentland 		REG_UPDATE(CNV_WINDOW_SIZE,  CNV_WINDOW_WIDTH,   params->cnv_params.crop_width);
87345429a6SHarry Wentland 		REG_UPDATE(CNV_WINDOW_SIZE,  CNV_WINDOW_HEIGHT,  params->cnv_params.crop_height);
88345429a6SHarry Wentland 	} else {
89345429a6SHarry Wentland 		REG_UPDATE(CNV_MODE, CNV_WINDOW_CROP_EN, 0);
90345429a6SHarry Wentland 	}
91345429a6SHarry Wentland 
92345429a6SHarry Wentland 	/* Set CAPTURE_RATE */
93345429a6SHarry Wentland 	REG_UPDATE(CNV_MODE, CNV_FRAME_CAPTURE_RATE, params->capture_rate);
94345429a6SHarry Wentland 
95345429a6SHarry Wentland 	/* Set CNV output pixel depth */
96345429a6SHarry Wentland 	REG_UPDATE(CNV_MODE, CNV_OUT_BPC, params->cnv_params.cnv_out_bpc);
97345429a6SHarry Wentland }
98345429a6SHarry Wentland 
dwb2_enable(struct dwbc * dwbc,struct dc_dwb_params * params)99345429a6SHarry Wentland static bool dwb2_enable(struct dwbc *dwbc, struct dc_dwb_params *params)
100345429a6SHarry Wentland {
101345429a6SHarry Wentland 	struct dcn20_dwbc *dwbc20 = TO_DCN20_DWBC(dwbc);
102345429a6SHarry Wentland 
103345429a6SHarry Wentland 	/* Only chroma scaling (sub-sampling) is supported in DCN2 */
10472c6473aSCharlene Liu 	if ((params->cnv_params.src_width  != params->dest_width) ||
10572c6473aSCharlene Liu 	    (params->cnv_params.src_height != params->dest_height)) {
10672c6473aSCharlene Liu 
10772c6473aSCharlene Liu 		DC_LOG_DWB("%s inst = %d, FAILED!LUMA SCALING NOT SUPPORTED", __func__, dwbc20->base.inst);
108345429a6SHarry Wentland 		return false;
109345429a6SHarry Wentland 	}
11072c6473aSCharlene Liu 	DC_LOG_DWB("%s inst = %d, ENABLED", __func__, dwbc20->base.inst);
111345429a6SHarry Wentland 
112345429a6SHarry Wentland 	/* disable power gating */
113345429a6SHarry Wentland 	//REG_UPDATE_5(WB_EC_CONFIG, DISPCLK_R_WB_GATE_DIS, 1,
114345429a6SHarry Wentland 	//			 DISPCLK_G_WB_GATE_DIS, 1, DISPCLK_G_WBSCL_GATE_DIS, 1,
115345429a6SHarry Wentland 	//			 WB_LB_LS_DIS, 1, WB_LUT_LS_DIS, 1);
116345429a6SHarry Wentland 
117345429a6SHarry Wentland 	/* Set WB_ENABLE (not double buffered; capture not enabled) */
118345429a6SHarry Wentland 	REG_UPDATE(WB_ENABLE, WB_ENABLE, 1);
119345429a6SHarry Wentland 
120345429a6SHarry Wentland 	/* Set CNV parameters */
121345429a6SHarry Wentland 	dwb2_config_dwb_cnv(dwbc, params);
122345429a6SHarry Wentland 
123345429a6SHarry Wentland 	/* Set scaling parameters */
124345429a6SHarry Wentland 	dwb2_set_scaler(dwbc, params);
125345429a6SHarry Wentland 
126345429a6SHarry Wentland 	/* Enable DWB capture enable (double buffered) */
127345429a6SHarry Wentland 	REG_UPDATE(CNV_MODE, CNV_FRAME_CAPTURE_EN, DWB_FRAME_CAPTURE_ENABLE);
128345429a6SHarry Wentland 
129345429a6SHarry Wentland 	// disable warmup
130345429a6SHarry Wentland 	REG_UPDATE(WB_WARM_UP_MODE_CTL1, GMC_WARM_UP_ENABLE, 0);
131345429a6SHarry Wentland 
132345429a6SHarry Wentland 	return true;
133345429a6SHarry Wentland }
134345429a6SHarry Wentland 
dwb2_disable(struct dwbc * dwbc)135345429a6SHarry Wentland bool dwb2_disable(struct dwbc *dwbc)
136345429a6SHarry Wentland {
137345429a6SHarry Wentland 	struct dcn20_dwbc *dwbc20 = TO_DCN20_DWBC(dwbc);
13872c6473aSCharlene Liu 	DC_LOG_DWB("%s inst = %d, Disabled", __func__, dwbc20->base.inst);
139345429a6SHarry Wentland 
140345429a6SHarry Wentland 	/* disable CNV */
141345429a6SHarry Wentland 	REG_UPDATE(CNV_MODE, CNV_FRAME_CAPTURE_EN, DWB_FRAME_CAPTURE_DISABLE);
142345429a6SHarry Wentland 
143345429a6SHarry Wentland 	/* disable WB */
144345429a6SHarry Wentland 	REG_UPDATE(WB_ENABLE, WB_ENABLE, 0);
145345429a6SHarry Wentland 
146345429a6SHarry Wentland 	/* soft reset */
147345429a6SHarry Wentland 	REG_UPDATE(WB_SOFT_RESET, WB_SOFT_RESET, 1);
148345429a6SHarry Wentland 	REG_UPDATE(WB_SOFT_RESET, WB_SOFT_RESET, 0);
149345429a6SHarry Wentland 
150345429a6SHarry Wentland 	/* enable power gating */
151345429a6SHarry Wentland 	//REG_UPDATE_5(WB_EC_CONFIG, DISPCLK_R_WB_GATE_DIS, 0,
152345429a6SHarry Wentland 	//			 DISPCLK_G_WB_GATE_DIS, 0, DISPCLK_G_WBSCL_GATE_DIS, 0,
153345429a6SHarry Wentland 	//			 WB_LB_LS_DIS, 0, WB_LUT_LS_DIS, 0);
154345429a6SHarry Wentland 
155345429a6SHarry Wentland 	return true;
156345429a6SHarry Wentland }
157345429a6SHarry Wentland 
dwb2_update(struct dwbc * dwbc,struct dc_dwb_params * params)158345429a6SHarry Wentland static bool dwb2_update(struct dwbc *dwbc, struct dc_dwb_params *params)
159345429a6SHarry Wentland {
160345429a6SHarry Wentland 	struct dcn20_dwbc *dwbc20 = TO_DCN20_DWBC(dwbc);
161345429a6SHarry Wentland 	unsigned int pre_locked;
162345429a6SHarry Wentland 
163345429a6SHarry Wentland 	/* Only chroma scaling (sub-sampling) is supported in DCN2 */
16472c6473aSCharlene Liu 	if ((params->cnv_params.src_width != params->dest_width) ||
16572c6473aSCharlene Liu 			(params->cnv_params.src_height != params->dest_height)) {
16672c6473aSCharlene Liu 		DC_LOG_DWB("%s inst = %d, FAILED!LUMA SCALING NOT SUPPORTED", __func__, dwbc20->base.inst);
167345429a6SHarry Wentland 		return false;
168345429a6SHarry Wentland 	}
16972c6473aSCharlene Liu 	DC_LOG_DWB("%s inst = %d, scaling", __func__, dwbc20->base.inst);
170345429a6SHarry Wentland 
171345429a6SHarry Wentland 	/*
172345429a6SHarry Wentland 	 * Check if the caller has already locked CNV registers.
173345429a6SHarry Wentland 	 * If so: assume the caller will unlock, so don't touch the lock.
174345429a6SHarry Wentland 	 * If not: lock them for this update, then unlock after the
175345429a6SHarry Wentland 	 * update is complete.
176345429a6SHarry Wentland 	 */
177345429a6SHarry Wentland 	REG_GET(CNV_UPDATE, CNV_UPDATE_LOCK, &pre_locked);
178345429a6SHarry Wentland 
179345429a6SHarry Wentland 	if (pre_locked == 0) {
180345429a6SHarry Wentland 		/* Lock DWB registers */
181345429a6SHarry Wentland 		REG_UPDATE(CNV_UPDATE, CNV_UPDATE_LOCK, 1);
182345429a6SHarry Wentland 	}
183345429a6SHarry Wentland 
184345429a6SHarry Wentland 	/* Set CNV parameters */
185345429a6SHarry Wentland 	dwb2_config_dwb_cnv(dwbc, params);
186345429a6SHarry Wentland 
187345429a6SHarry Wentland 	/* Set scaling parameters */
188345429a6SHarry Wentland 	dwb2_set_scaler(dwbc, params);
189345429a6SHarry Wentland 
190345429a6SHarry Wentland 	if (pre_locked == 0) {
191345429a6SHarry Wentland 		/* Unlock DWB registers */
192345429a6SHarry Wentland 		REG_UPDATE(CNV_UPDATE, CNV_UPDATE_LOCK, 0);
193345429a6SHarry Wentland 	}
194345429a6SHarry Wentland 
195345429a6SHarry Wentland 	return true;
196345429a6SHarry Wentland }
197345429a6SHarry Wentland 
dwb2_is_enabled(struct dwbc * dwbc)198345429a6SHarry Wentland bool dwb2_is_enabled(struct dwbc *dwbc)
199345429a6SHarry Wentland {
200345429a6SHarry Wentland 	struct dcn20_dwbc *dwbc20 = TO_DCN20_DWBC(dwbc);
201345429a6SHarry Wentland 	unsigned int wb_enabled = 0;
202345429a6SHarry Wentland 	unsigned int cnv_frame_capture_en = 0;
203345429a6SHarry Wentland 
204345429a6SHarry Wentland 	REG_GET(WB_ENABLE, WB_ENABLE, &wb_enabled);
205345429a6SHarry Wentland 	REG_GET(CNV_MODE, CNV_FRAME_CAPTURE_EN, &cnv_frame_capture_en);
206345429a6SHarry Wentland 
207345429a6SHarry Wentland 	return ((wb_enabled != 0) && (cnv_frame_capture_en != 0));
208345429a6SHarry Wentland }
209345429a6SHarry Wentland 
dwb2_set_stereo(struct dwbc * dwbc,struct dwb_stereo_params * stereo_params)210345429a6SHarry Wentland void dwb2_set_stereo(struct dwbc *dwbc,
211345429a6SHarry Wentland 		struct dwb_stereo_params *stereo_params)
212345429a6SHarry Wentland {
213345429a6SHarry Wentland 	struct dcn20_dwbc *dwbc20 = TO_DCN20_DWBC(dwbc);
21472c6473aSCharlene Liu 	DC_LOG_DWB("%s inst = %d, enabled =%d", __func__,\
21572c6473aSCharlene Liu 		dwbc20->base.inst, stereo_params->stereo_enabled);
216345429a6SHarry Wentland 
217345429a6SHarry Wentland 	if (stereo_params->stereo_enabled) {
218345429a6SHarry Wentland 		REG_UPDATE(CNV_MODE, CNV_STEREO_TYPE,     stereo_params->stereo_type);
219345429a6SHarry Wentland 		REG_UPDATE(CNV_MODE, CNV_EYE_SELECTION,   stereo_params->stereo_eye_select);
220345429a6SHarry Wentland 		REG_UPDATE(CNV_MODE, CNV_STEREO_POLARITY, stereo_params->stereo_polarity);
221345429a6SHarry Wentland 	} else {
222345429a6SHarry Wentland 		REG_UPDATE(CNV_MODE, CNV_EYE_SELECTION, 0);
223345429a6SHarry Wentland 	}
224345429a6SHarry Wentland }
225345429a6SHarry Wentland 
dwb2_set_new_content(struct dwbc * dwbc,bool is_new_content)226345429a6SHarry Wentland void dwb2_set_new_content(struct dwbc *dwbc,
227345429a6SHarry Wentland 						bool is_new_content)
228345429a6SHarry Wentland {
229345429a6SHarry Wentland 	struct dcn20_dwbc *dwbc20 = TO_DCN20_DWBC(dwbc);
23072c6473aSCharlene Liu 	DC_LOG_DWB("%s inst = %d", __func__, dwbc20->base.inst);
231345429a6SHarry Wentland 
232345429a6SHarry Wentland 	REG_UPDATE(CNV_MODE, CNV_NEW_CONTENT, is_new_content);
233345429a6SHarry Wentland }
234345429a6SHarry Wentland 
dwb2_set_warmup(struct dwbc * dwbc,struct dwb_warmup_params * warmup_params)235345429a6SHarry Wentland static void dwb2_set_warmup(struct dwbc *dwbc,
236345429a6SHarry Wentland 		struct dwb_warmup_params *warmup_params)
237345429a6SHarry Wentland {
238345429a6SHarry Wentland 	struct dcn20_dwbc *dwbc20 = TO_DCN20_DWBC(dwbc);
23972c6473aSCharlene Liu 	DC_LOG_DWB("%s inst = %d", __func__, dwbc20->base.inst);
240345429a6SHarry Wentland 
241345429a6SHarry Wentland 	REG_UPDATE(WB_WARM_UP_MODE_CTL1, GMC_WARM_UP_ENABLE, warmup_params->warmup_en);
242345429a6SHarry Wentland 	REG_UPDATE(WB_WARM_UP_MODE_CTL1, WIDTH_WARMUP, warmup_params->warmup_width);
243345429a6SHarry Wentland 	REG_UPDATE(WB_WARM_UP_MODE_CTL1, HEIGHT_WARMUP, warmup_params->warmup_height);
244345429a6SHarry Wentland 
245345429a6SHarry Wentland 	REG_UPDATE(WB_WARM_UP_MODE_CTL2, DATA_VALUE_WARMUP, warmup_params->warmup_data);
246345429a6SHarry Wentland 	REG_UPDATE(WB_WARM_UP_MODE_CTL2, MODE_WARMUP, warmup_params->warmup_mode);
247345429a6SHarry Wentland 	REG_UPDATE(WB_WARM_UP_MODE_CTL2, DATA_DEPTH_WARMUP, warmup_params->warmup_depth);
248345429a6SHarry Wentland }
249345429a6SHarry Wentland 
dwb2_set_scaler(struct dwbc * dwbc,struct dc_dwb_params * params)250345429a6SHarry Wentland void dwb2_set_scaler(struct dwbc *dwbc, struct dc_dwb_params *params)
251345429a6SHarry Wentland {
252345429a6SHarry Wentland 	struct dcn20_dwbc *dwbc20 = TO_DCN20_DWBC(dwbc);
25372c6473aSCharlene Liu 	DC_LOG_DWB("%s inst = %d", __func__, dwbc20->base.inst);
254345429a6SHarry Wentland 
255345429a6SHarry Wentland 	/* Program scaling mode */
256345429a6SHarry Wentland 	REG_UPDATE_2(WBSCL_MODE, WBSCL_MODE, params->out_format,
257345429a6SHarry Wentland 			WBSCL_OUT_BIT_DEPTH, params->output_depth);
258345429a6SHarry Wentland 
259345429a6SHarry Wentland 	if (params->out_format != dwb_scaler_mode_bypass444) {
260345429a6SHarry Wentland 		/* Program output size */
261345429a6SHarry Wentland 		REG_UPDATE(WBSCL_DEST_SIZE, WBSCL_DEST_WIDTH,	params->dest_width);
262345429a6SHarry Wentland 		REG_UPDATE(WBSCL_DEST_SIZE, WBSCL_DEST_HEIGHT,	params->dest_height);
263345429a6SHarry Wentland 
264345429a6SHarry Wentland 		/* Program round offsets */
265345429a6SHarry Wentland 		REG_UPDATE(WBSCL_ROUND_OFFSET, WBSCL_ROUND_OFFSET_Y_RGB, 0x40);
266345429a6SHarry Wentland 		REG_UPDATE(WBSCL_ROUND_OFFSET, WBSCL_ROUND_OFFSET_CBCR,  0x200);
267345429a6SHarry Wentland 
268345429a6SHarry Wentland 		/* Program clamp values */
269345429a6SHarry Wentland 		REG_UPDATE(WBSCL_CLAMP_Y_RGB,	WBSCL_CLAMP_UPPER_Y_RGB,	0x3fe);
270345429a6SHarry Wentland 		REG_UPDATE(WBSCL_CLAMP_Y_RGB,	WBSCL_CLAMP_LOWER_Y_RGB,	0x1);
271345429a6SHarry Wentland 		REG_UPDATE(WBSCL_CLAMP_CBCR,	WBSCL_CLAMP_UPPER_CBCR,		0x3fe);
272345429a6SHarry Wentland 		REG_UPDATE(WBSCL_CLAMP_CBCR,	WBSCL_CLAMP_LOWER_CBCR,		0x1);
273345429a6SHarry Wentland 
274345429a6SHarry Wentland 		/* Program outside pixel strategy to use edge pixels */
275345429a6SHarry Wentland 		REG_UPDATE(WBSCL_OUTSIDE_PIX_STRATEGY, WBSCL_OUTSIDE_PIX_STRATEGY, DWB_OUTSIDE_PIX_STRATEGY_EDGE);
276345429a6SHarry Wentland 
277345429a6SHarry Wentland 		if (params->cnv_params.crop_en) {
278345429a6SHarry Wentland 			/* horizontal scale */
279345429a6SHarry Wentland 			dwb_program_horz_scalar(dwbc20, params->cnv_params.crop_width,
280345429a6SHarry Wentland 							params->dest_width,
281345429a6SHarry Wentland 							params->scaler_taps);
282345429a6SHarry Wentland 
283345429a6SHarry Wentland 			/* vertical scale */
284345429a6SHarry Wentland 			dwb_program_vert_scalar(dwbc20, params->cnv_params.crop_height,
285345429a6SHarry Wentland 							params->dest_height,
286345429a6SHarry Wentland 							params->scaler_taps,
287345429a6SHarry Wentland 							params->subsample_position);
288345429a6SHarry Wentland 		} else {
289345429a6SHarry Wentland 			/* horizontal scale */
290345429a6SHarry Wentland 			dwb_program_horz_scalar(dwbc20, params->cnv_params.src_width,
291345429a6SHarry Wentland 							params->dest_width,
292345429a6SHarry Wentland 							params->scaler_taps);
293345429a6SHarry Wentland 
294345429a6SHarry Wentland 			/* vertical scale */
295345429a6SHarry Wentland 			dwb_program_vert_scalar(dwbc20, params->cnv_params.src_height,
296345429a6SHarry Wentland 							params->dest_height,
297345429a6SHarry Wentland 							params->scaler_taps,
298345429a6SHarry Wentland 							params->subsample_position);
299345429a6SHarry Wentland 		}
300345429a6SHarry Wentland 	}
301345429a6SHarry Wentland 
30271fb6ed2SRodrigo Siqueira 
30371fb6ed2SRodrigo Siqueira 	if (dwbc20->dwbc_mask->WBSCL_COEF_RAM_SEL) {
30471fb6ed2SRodrigo Siqueira 		/* Swap double buffered coefficient set */
30571fb6ed2SRodrigo Siqueira 		uint32_t wbscl_mode = REG_READ(WBSCL_MODE);
30671fb6ed2SRodrigo Siqueira 		bool coef_ram_current = get_reg_field_value_ex(
30771fb6ed2SRodrigo Siqueira 			wbscl_mode, dwbc20->dwbc_mask->WBSCL_COEF_RAM_SEL_CURRENT,
30871fb6ed2SRodrigo Siqueira 			dwbc20->dwbc_shift->WBSCL_COEF_RAM_SEL_CURRENT);
30971fb6ed2SRodrigo Siqueira 
31071fb6ed2SRodrigo Siqueira 		REG_UPDATE(WBSCL_MODE, WBSCL_COEF_RAM_SEL, !coef_ram_current);
31171fb6ed2SRodrigo Siqueira 	}
31271fb6ed2SRodrigo Siqueira 
313345429a6SHarry Wentland }
314345429a6SHarry Wentland 
3155fd1bea5STom Rix static const struct dwbc_funcs dcn20_dwbc_funcs = {
316345429a6SHarry Wentland 	.get_caps		= dwb2_get_caps,
317345429a6SHarry Wentland 	.enable			= dwb2_enable,
318345429a6SHarry Wentland 	.disable		= dwb2_disable,
319345429a6SHarry Wentland 	.update			= dwb2_update,
320345429a6SHarry Wentland 	.is_enabled		= dwb2_is_enabled,
321345429a6SHarry Wentland 	.set_stereo		= dwb2_set_stereo,
322345429a6SHarry Wentland 	.set_new_content	= dwb2_set_new_content,
323345429a6SHarry Wentland 	.set_warmup		= dwb2_set_warmup,
324345429a6SHarry Wentland 	.dwb_set_scaler		= dwb2_set_scaler,
325345429a6SHarry Wentland };
326345429a6SHarry Wentland 
dcn20_dwbc_construct(struct dcn20_dwbc * dwbc20,struct dc_context * ctx,const struct dcn20_dwbc_registers * dwbc_regs,const struct dcn20_dwbc_shift * dwbc_shift,const struct dcn20_dwbc_mask * dwbc_mask,int inst)327345429a6SHarry Wentland void dcn20_dwbc_construct(struct dcn20_dwbc *dwbc20,
328345429a6SHarry Wentland 		struct dc_context *ctx,
329345429a6SHarry Wentland 		const struct dcn20_dwbc_registers *dwbc_regs,
330345429a6SHarry Wentland 		const struct dcn20_dwbc_shift *dwbc_shift,
331345429a6SHarry Wentland 		const struct dcn20_dwbc_mask *dwbc_mask,
332345429a6SHarry Wentland 		int inst)
333345429a6SHarry Wentland {
334345429a6SHarry Wentland 	dwbc20->base.ctx = ctx;
335345429a6SHarry Wentland 
336345429a6SHarry Wentland 	dwbc20->base.inst = inst;
337345429a6SHarry Wentland 	dwbc20->base.funcs = &dcn20_dwbc_funcs;
338345429a6SHarry Wentland 
339345429a6SHarry Wentland 	dwbc20->dwbc_regs = dwbc_regs;
340345429a6SHarry Wentland 	dwbc20->dwbc_shift = dwbc_shift;
341345429a6SHarry Wentland 	dwbc20->dwbc_mask = dwbc_mask;
342345429a6SHarry Wentland }
343345429a6SHarry Wentland 
344