xref: /dflybsd-src/sys/dev/drm/amd/display/dc/dcn10/dcn10_hubp.c (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 #include "dm_services.h"
26*b843c749SSergey Zigachev #include "dce_calcs.h"
27*b843c749SSergey Zigachev #include "reg_helper.h"
28*b843c749SSergey Zigachev #include "basics/conversion.h"
29*b843c749SSergey Zigachev #include "dcn10_hubp.h"
30*b843c749SSergey Zigachev 
31*b843c749SSergey Zigachev #define REG(reg)\
32*b843c749SSergey Zigachev 	hubp1->hubp_regs->reg
33*b843c749SSergey Zigachev 
34*b843c749SSergey Zigachev #define CTX \
35*b843c749SSergey Zigachev 	hubp1->base.ctx
36*b843c749SSergey Zigachev 
37*b843c749SSergey Zigachev #undef FN
38*b843c749SSergey Zigachev #define FN(reg_name, field_name) \
39*b843c749SSergey Zigachev 	hubp1->hubp_shift->field_name, hubp1->hubp_mask->field_name
40*b843c749SSergey Zigachev 
hubp1_set_blank(struct hubp * hubp,bool blank)41*b843c749SSergey Zigachev void hubp1_set_blank(struct hubp *hubp, bool blank)
42*b843c749SSergey Zigachev {
43*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
44*b843c749SSergey Zigachev 	uint32_t blank_en = blank ? 1 : 0;
45*b843c749SSergey Zigachev 
46*b843c749SSergey Zigachev 	REG_UPDATE_2(DCHUBP_CNTL,
47*b843c749SSergey Zigachev 			HUBP_BLANK_EN, blank_en,
48*b843c749SSergey Zigachev 			HUBP_TTU_DISABLE, blank_en);
49*b843c749SSergey Zigachev 
50*b843c749SSergey Zigachev 	if (blank) {
51*b843c749SSergey Zigachev 		uint32_t reg_val = REG_READ(DCHUBP_CNTL);
52*b843c749SSergey Zigachev 
53*b843c749SSergey Zigachev 		if (reg_val) {
54*b843c749SSergey Zigachev 			/* init sequence workaround: in case HUBP is
55*b843c749SSergey Zigachev 			 * power gated, this wait would timeout.
56*b843c749SSergey Zigachev 			 *
57*b843c749SSergey Zigachev 			 * we just wrote reg_val to non-0, if it stay 0
58*b843c749SSergey Zigachev 			 * it means HUBP is gated
59*b843c749SSergey Zigachev 			 */
60*b843c749SSergey Zigachev 			REG_WAIT(DCHUBP_CNTL,
61*b843c749SSergey Zigachev 					HUBP_NO_OUTSTANDING_REQ, 1,
62*b843c749SSergey Zigachev 					1, 200);
63*b843c749SSergey Zigachev 		}
64*b843c749SSergey Zigachev 
65*b843c749SSergey Zigachev 		hubp->mpcc_id = 0xf;
66*b843c749SSergey Zigachev 		hubp->opp_id = 0xf;
67*b843c749SSergey Zigachev 	}
68*b843c749SSergey Zigachev }
69*b843c749SSergey Zigachev 
hubp1_disconnect(struct hubp * hubp)70*b843c749SSergey Zigachev static void hubp1_disconnect(struct hubp *hubp)
71*b843c749SSergey Zigachev {
72*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
73*b843c749SSergey Zigachev 
74*b843c749SSergey Zigachev 	REG_UPDATE(DCHUBP_CNTL,
75*b843c749SSergey Zigachev 			HUBP_TTU_DISABLE, 1);
76*b843c749SSergey Zigachev 
77*b843c749SSergey Zigachev 	REG_UPDATE(CURSOR_CONTROL,
78*b843c749SSergey Zigachev 			CURSOR_ENABLE, 0);
79*b843c749SSergey Zigachev }
80*b843c749SSergey Zigachev 
hubp1_disable_control(struct hubp * hubp,bool disable_hubp)81*b843c749SSergey Zigachev static void hubp1_disable_control(struct hubp *hubp, bool disable_hubp)
82*b843c749SSergey Zigachev {
83*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
84*b843c749SSergey Zigachev 	uint32_t disable = disable_hubp ? 1 : 0;
85*b843c749SSergey Zigachev 
86*b843c749SSergey Zigachev 	REG_UPDATE(DCHUBP_CNTL,
87*b843c749SSergey Zigachev 			HUBP_DISABLE, disable);
88*b843c749SSergey Zigachev }
89*b843c749SSergey Zigachev 
hubp1_get_underflow_status(struct hubp * hubp)90*b843c749SSergey Zigachev static unsigned int hubp1_get_underflow_status(struct hubp *hubp)
91*b843c749SSergey Zigachev {
92*b843c749SSergey Zigachev 	uint32_t hubp_underflow = 0;
93*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
94*b843c749SSergey Zigachev 
95*b843c749SSergey Zigachev 	REG_GET(DCHUBP_CNTL,
96*b843c749SSergey Zigachev 		HUBP_UNDERFLOW_STATUS,
97*b843c749SSergey Zigachev 		&hubp_underflow);
98*b843c749SSergey Zigachev 
99*b843c749SSergey Zigachev 	return hubp_underflow;
100*b843c749SSergey Zigachev }
101*b843c749SSergey Zigachev 
hubp1_set_hubp_blank_en(struct hubp * hubp,bool blank)102*b843c749SSergey Zigachev static void hubp1_set_hubp_blank_en(struct hubp *hubp, bool blank)
103*b843c749SSergey Zigachev {
104*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
105*b843c749SSergey Zigachev 	uint32_t blank_en = blank ? 1 : 0;
106*b843c749SSergey Zigachev 
107*b843c749SSergey Zigachev 	REG_UPDATE(DCHUBP_CNTL, HUBP_BLANK_EN, blank_en);
108*b843c749SSergey Zigachev }
109*b843c749SSergey Zigachev 
hubp1_vready_workaround(struct hubp * hubp,struct _vcs_dpi_display_pipe_dest_params_st * pipe_dest)110*b843c749SSergey Zigachev static void hubp1_vready_workaround(struct hubp *hubp,
111*b843c749SSergey Zigachev 		struct _vcs_dpi_display_pipe_dest_params_st *pipe_dest)
112*b843c749SSergey Zigachev {
113*b843c749SSergey Zigachev 	uint32_t value = 0;
114*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
115*b843c749SSergey Zigachev 
116*b843c749SSergey Zigachev 	/* set HBUBREQ_DEBUG_DB[12] = 1 */
117*b843c749SSergey Zigachev 	value = REG_READ(HUBPREQ_DEBUG_DB);
118*b843c749SSergey Zigachev 
119*b843c749SSergey Zigachev 	/* hack mode disable */
120*b843c749SSergey Zigachev 	value |= 0x100;
121*b843c749SSergey Zigachev 	value &= ~0x1000;
122*b843c749SSergey Zigachev 
123*b843c749SSergey Zigachev 	if ((pipe_dest->vstartup_start - 2*(pipe_dest->vready_offset+pipe_dest->vupdate_width
124*b843c749SSergey Zigachev 		+ pipe_dest->vupdate_offset) / pipe_dest->htotal) <= pipe_dest->vblank_end) {
125*b843c749SSergey Zigachev 		/* if (eco_fix_needed(otg_global_sync_timing)
126*b843c749SSergey Zigachev 		 * set HBUBREQ_DEBUG_DB[12] = 1 */
127*b843c749SSergey Zigachev 		value |= 0x1000;
128*b843c749SSergey Zigachev 	}
129*b843c749SSergey Zigachev 
130*b843c749SSergey Zigachev 	REG_WRITE(HUBPREQ_DEBUG_DB, value);
131*b843c749SSergey Zigachev }
132*b843c749SSergey Zigachev 
hubp1_program_tiling(struct hubp * hubp,const union dc_tiling_info * info,const enum surface_pixel_format pixel_format)133*b843c749SSergey Zigachev void hubp1_program_tiling(
134*b843c749SSergey Zigachev 	struct hubp *hubp,
135*b843c749SSergey Zigachev 	const union dc_tiling_info *info,
136*b843c749SSergey Zigachev 	const enum surface_pixel_format pixel_format)
137*b843c749SSergey Zigachev {
138*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
139*b843c749SSergey Zigachev 
140*b843c749SSergey Zigachev 	REG_UPDATE_6(DCSURF_ADDR_CONFIG,
141*b843c749SSergey Zigachev 			NUM_PIPES, log_2(info->gfx9.num_pipes),
142*b843c749SSergey Zigachev 			NUM_BANKS, log_2(info->gfx9.num_banks),
143*b843c749SSergey Zigachev 			PIPE_INTERLEAVE, info->gfx9.pipe_interleave,
144*b843c749SSergey Zigachev 			NUM_SE, log_2(info->gfx9.num_shader_engines),
145*b843c749SSergey Zigachev 			NUM_RB_PER_SE, log_2(info->gfx9.num_rb_per_se),
146*b843c749SSergey Zigachev 			MAX_COMPRESSED_FRAGS, log_2(info->gfx9.max_compressed_frags));
147*b843c749SSergey Zigachev 
148*b843c749SSergey Zigachev 	REG_UPDATE_4(DCSURF_TILING_CONFIG,
149*b843c749SSergey Zigachev 			SW_MODE, info->gfx9.swizzle,
150*b843c749SSergey Zigachev 			META_LINEAR, info->gfx9.meta_linear,
151*b843c749SSergey Zigachev 			RB_ALIGNED, info->gfx9.rb_aligned,
152*b843c749SSergey Zigachev 			PIPE_ALIGNED, info->gfx9.pipe_aligned);
153*b843c749SSergey Zigachev }
154*b843c749SSergey Zigachev 
hubp1_program_size(struct hubp * hubp,enum surface_pixel_format format,const union plane_size * plane_size,struct dc_plane_dcc_param * dcc)155*b843c749SSergey Zigachev void hubp1_program_size(
156*b843c749SSergey Zigachev 	struct hubp *hubp,
157*b843c749SSergey Zigachev 	enum surface_pixel_format format,
158*b843c749SSergey Zigachev 	const union plane_size *plane_size,
159*b843c749SSergey Zigachev 	struct dc_plane_dcc_param *dcc)
160*b843c749SSergey Zigachev {
161*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
162*b843c749SSergey Zigachev 	uint32_t pitch, meta_pitch, pitch_c, meta_pitch_c;
163*b843c749SSergey Zigachev 
164*b843c749SSergey Zigachev 	/* Program data and meta surface pitch (calculation from addrlib)
165*b843c749SSergey Zigachev 	 * 444 or 420 luma
166*b843c749SSergey Zigachev 	 */
167*b843c749SSergey Zigachev 	if (format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN && format < SURFACE_PIXEL_FORMAT_SUBSAMPLE_END) {
168*b843c749SSergey Zigachev 		ASSERT(plane_size->video.chroma_pitch != 0);
169*b843c749SSergey Zigachev 		/* Chroma pitch zero can cause system hang! */
170*b843c749SSergey Zigachev 
171*b843c749SSergey Zigachev 		pitch = plane_size->video.luma_pitch - 1;
172*b843c749SSergey Zigachev 		meta_pitch = dcc->video.meta_pitch_l - 1;
173*b843c749SSergey Zigachev 		pitch_c = plane_size->video.chroma_pitch - 1;
174*b843c749SSergey Zigachev 		meta_pitch_c = dcc->video.meta_pitch_c - 1;
175*b843c749SSergey Zigachev 	} else {
176*b843c749SSergey Zigachev 		pitch = plane_size->grph.surface_pitch - 1;
177*b843c749SSergey Zigachev 		meta_pitch = dcc->grph.meta_pitch - 1;
178*b843c749SSergey Zigachev 		pitch_c = 0;
179*b843c749SSergey Zigachev 		meta_pitch_c = 0;
180*b843c749SSergey Zigachev 	}
181*b843c749SSergey Zigachev 
182*b843c749SSergey Zigachev 	if (!dcc->enable) {
183*b843c749SSergey Zigachev 		meta_pitch = 0;
184*b843c749SSergey Zigachev 		meta_pitch_c = 0;
185*b843c749SSergey Zigachev 	}
186*b843c749SSergey Zigachev 
187*b843c749SSergey Zigachev 	REG_UPDATE_2(DCSURF_SURFACE_PITCH,
188*b843c749SSergey Zigachev 			PITCH, pitch, META_PITCH, meta_pitch);
189*b843c749SSergey Zigachev 
190*b843c749SSergey Zigachev 	if (format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN)
191*b843c749SSergey Zigachev 		REG_UPDATE_2(DCSURF_SURFACE_PITCH_C,
192*b843c749SSergey Zigachev 			PITCH_C, pitch_c, META_PITCH_C, meta_pitch_c);
193*b843c749SSergey Zigachev }
194*b843c749SSergey Zigachev 
hubp1_program_rotation(struct hubp * hubp,enum dc_rotation_angle rotation,bool horizontal_mirror)195*b843c749SSergey Zigachev void hubp1_program_rotation(
196*b843c749SSergey Zigachev 	struct hubp *hubp,
197*b843c749SSergey Zigachev 	enum dc_rotation_angle rotation,
198*b843c749SSergey Zigachev 	bool horizontal_mirror)
199*b843c749SSergey Zigachev {
200*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
201*b843c749SSergey Zigachev 	uint32_t mirror;
202*b843c749SSergey Zigachev 
203*b843c749SSergey Zigachev 
204*b843c749SSergey Zigachev 	if (horizontal_mirror)
205*b843c749SSergey Zigachev 		mirror = 1;
206*b843c749SSergey Zigachev 	else
207*b843c749SSergey Zigachev 		mirror = 0;
208*b843c749SSergey Zigachev 
209*b843c749SSergey Zigachev 	/* Program rotation angle and horz mirror - no mirror */
210*b843c749SSergey Zigachev 	if (rotation == ROTATION_ANGLE_0)
211*b843c749SSergey Zigachev 		REG_UPDATE_2(DCSURF_SURFACE_CONFIG,
212*b843c749SSergey Zigachev 				ROTATION_ANGLE, 0,
213*b843c749SSergey Zigachev 				H_MIRROR_EN, mirror);
214*b843c749SSergey Zigachev 	else if (rotation == ROTATION_ANGLE_90)
215*b843c749SSergey Zigachev 		REG_UPDATE_2(DCSURF_SURFACE_CONFIG,
216*b843c749SSergey Zigachev 				ROTATION_ANGLE, 1,
217*b843c749SSergey Zigachev 				H_MIRROR_EN, mirror);
218*b843c749SSergey Zigachev 	else if (rotation == ROTATION_ANGLE_180)
219*b843c749SSergey Zigachev 		REG_UPDATE_2(DCSURF_SURFACE_CONFIG,
220*b843c749SSergey Zigachev 				ROTATION_ANGLE, 2,
221*b843c749SSergey Zigachev 				H_MIRROR_EN, mirror);
222*b843c749SSergey Zigachev 	else if (rotation == ROTATION_ANGLE_270)
223*b843c749SSergey Zigachev 		REG_UPDATE_2(DCSURF_SURFACE_CONFIG,
224*b843c749SSergey Zigachev 				ROTATION_ANGLE, 3,
225*b843c749SSergey Zigachev 				H_MIRROR_EN, mirror);
226*b843c749SSergey Zigachev }
227*b843c749SSergey Zigachev 
hubp1_program_pixel_format(struct hubp * hubp,enum surface_pixel_format format)228*b843c749SSergey Zigachev void hubp1_program_pixel_format(
229*b843c749SSergey Zigachev 	struct hubp *hubp,
230*b843c749SSergey Zigachev 	enum surface_pixel_format format)
231*b843c749SSergey Zigachev {
232*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
233*b843c749SSergey Zigachev 	uint32_t red_bar = 3;
234*b843c749SSergey Zigachev 	uint32_t blue_bar = 2;
235*b843c749SSergey Zigachev 
236*b843c749SSergey Zigachev 	/* swap for ABGR format */
237*b843c749SSergey Zigachev 	if (format == SURFACE_PIXEL_FORMAT_GRPH_ABGR8888
238*b843c749SSergey Zigachev 			|| format == SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010
239*b843c749SSergey Zigachev 			|| format == SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS
240*b843c749SSergey Zigachev 			|| format == SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F) {
241*b843c749SSergey Zigachev 		red_bar = 2;
242*b843c749SSergey Zigachev 		blue_bar = 3;
243*b843c749SSergey Zigachev 	}
244*b843c749SSergey Zigachev 
245*b843c749SSergey Zigachev 	REG_UPDATE_2(HUBPRET_CONTROL,
246*b843c749SSergey Zigachev 			CROSSBAR_SRC_CB_B, blue_bar,
247*b843c749SSergey Zigachev 			CROSSBAR_SRC_CR_R, red_bar);
248*b843c749SSergey Zigachev 
249*b843c749SSergey Zigachev 	/* Mapping is same as ipp programming (cnvc) */
250*b843c749SSergey Zigachev 
251*b843c749SSergey Zigachev 	switch (format)	{
252*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
253*b843c749SSergey Zigachev 		REG_UPDATE(DCSURF_SURFACE_CONFIG,
254*b843c749SSergey Zigachev 				SURFACE_PIXEL_FORMAT, 1);
255*b843c749SSergey Zigachev 		break;
256*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
257*b843c749SSergey Zigachev 		REG_UPDATE(DCSURF_SURFACE_CONFIG,
258*b843c749SSergey Zigachev 				SURFACE_PIXEL_FORMAT, 3);
259*b843c749SSergey Zigachev 		break;
260*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
261*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
262*b843c749SSergey Zigachev 		REG_UPDATE(DCSURF_SURFACE_CONFIG,
263*b843c749SSergey Zigachev 				SURFACE_PIXEL_FORMAT, 8);
264*b843c749SSergey Zigachev 		break;
265*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
266*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
267*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
268*b843c749SSergey Zigachev 		REG_UPDATE(DCSURF_SURFACE_CONFIG,
269*b843c749SSergey Zigachev 				SURFACE_PIXEL_FORMAT, 10);
270*b843c749SSergey Zigachev 		break;
271*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
272*b843c749SSergey Zigachev 		REG_UPDATE(DCSURF_SURFACE_CONFIG,
273*b843c749SSergey Zigachev 				SURFACE_PIXEL_FORMAT, 22);
274*b843c749SSergey Zigachev 		break;
275*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
276*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:/*we use crossbar already*/
277*b843c749SSergey Zigachev 		REG_UPDATE(DCSURF_SURFACE_CONFIG,
278*b843c749SSergey Zigachev 				SURFACE_PIXEL_FORMAT, 24);
279*b843c749SSergey Zigachev 		break;
280*b843c749SSergey Zigachev 
281*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
282*b843c749SSergey Zigachev 		REG_UPDATE(DCSURF_SURFACE_CONFIG,
283*b843c749SSergey Zigachev 				SURFACE_PIXEL_FORMAT, 65);
284*b843c749SSergey Zigachev 		break;
285*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
286*b843c749SSergey Zigachev 		REG_UPDATE(DCSURF_SURFACE_CONFIG,
287*b843c749SSergey Zigachev 				SURFACE_PIXEL_FORMAT, 64);
288*b843c749SSergey Zigachev 		break;
289*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
290*b843c749SSergey Zigachev 		REG_UPDATE(DCSURF_SURFACE_CONFIG,
291*b843c749SSergey Zigachev 				SURFACE_PIXEL_FORMAT, 67);
292*b843c749SSergey Zigachev 		break;
293*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
294*b843c749SSergey Zigachev 		REG_UPDATE(DCSURF_SURFACE_CONFIG,
295*b843c749SSergey Zigachev 				SURFACE_PIXEL_FORMAT, 66);
296*b843c749SSergey Zigachev 		break;
297*b843c749SSergey Zigachev 	case SURFACE_PIXEL_FORMAT_VIDEO_AYCrCb8888:
298*b843c749SSergey Zigachev 		REG_UPDATE(DCSURF_SURFACE_CONFIG,
299*b843c749SSergey Zigachev 				SURFACE_PIXEL_FORMAT, 12);
300*b843c749SSergey Zigachev 		break;
301*b843c749SSergey Zigachev 	default:
302*b843c749SSergey Zigachev 		BREAK_TO_DEBUGGER();
303*b843c749SSergey Zigachev 		break;
304*b843c749SSergey Zigachev 	}
305*b843c749SSergey Zigachev 
306*b843c749SSergey Zigachev 	/* don't see the need of program the xbar in DCN 1.0 */
307*b843c749SSergey Zigachev }
308*b843c749SSergey Zigachev 
hubp1_program_surface_flip_and_addr(struct hubp * hubp,const struct dc_plane_address * address,bool flip_immediate)309*b843c749SSergey Zigachev bool hubp1_program_surface_flip_and_addr(
310*b843c749SSergey Zigachev 	struct hubp *hubp,
311*b843c749SSergey Zigachev 	const struct dc_plane_address *address,
312*b843c749SSergey Zigachev 	bool flip_immediate)
313*b843c749SSergey Zigachev {
314*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
315*b843c749SSergey Zigachev 
316*b843c749SSergey Zigachev 	/* program flip type */
317*b843c749SSergey Zigachev 	REG_SET(DCSURF_FLIP_CONTROL, 0,
318*b843c749SSergey Zigachev 			SURFACE_FLIP_TYPE, flip_immediate);
319*b843c749SSergey Zigachev 
320*b843c749SSergey Zigachev 	/* HW automatically latch rest of address register on write to
321*b843c749SSergey Zigachev 	 * DCSURF_PRIMARY_SURFACE_ADDRESS if SURFACE_UPDATE_LOCK is not used
322*b843c749SSergey Zigachev 	 *
323*b843c749SSergey Zigachev 	 * program high first and then the low addr, order matters!
324*b843c749SSergey Zigachev 	 */
325*b843c749SSergey Zigachev 	switch (address->type) {
326*b843c749SSergey Zigachev 	case PLN_ADDR_TYPE_GRAPHICS:
327*b843c749SSergey Zigachev 		/* DCN1.0 does not support const color
328*b843c749SSergey Zigachev 		 * TODO: program DCHUBBUB_RET_PATH_DCC_CFGx_0/1
329*b843c749SSergey Zigachev 		 * base on address->grph.dcc_const_color
330*b843c749SSergey Zigachev 		 * x = 0, 2, 4, 6 for pipe 0, 1, 2, 3 for rgb and luma
331*b843c749SSergey Zigachev 		 * x = 1, 3, 5, 7 for pipe 0, 1, 2, 3 for chroma
332*b843c749SSergey Zigachev 		 */
333*b843c749SSergey Zigachev 
334*b843c749SSergey Zigachev 		if (address->grph.addr.quad_part == 0)
335*b843c749SSergey Zigachev 			break;
336*b843c749SSergey Zigachev 
337*b843c749SSergey Zigachev 		REG_UPDATE_2(DCSURF_SURFACE_CONTROL,
338*b843c749SSergey Zigachev 				PRIMARY_SURFACE_TMZ, address->tmz_surface,
339*b843c749SSergey Zigachev 				PRIMARY_META_SURFACE_TMZ, address->tmz_surface);
340*b843c749SSergey Zigachev 
341*b843c749SSergey Zigachev 		if (address->grph.meta_addr.quad_part != 0) {
342*b843c749SSergey Zigachev 			REG_SET(DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH, 0,
343*b843c749SSergey Zigachev 					PRIMARY_META_SURFACE_ADDRESS_HIGH,
344*b843c749SSergey Zigachev 					address->grph.meta_addr.high_part);
345*b843c749SSergey Zigachev 
346*b843c749SSergey Zigachev 			REG_SET(DCSURF_PRIMARY_META_SURFACE_ADDRESS, 0,
347*b843c749SSergey Zigachev 					PRIMARY_META_SURFACE_ADDRESS,
348*b843c749SSergey Zigachev 					address->grph.meta_addr.low_part);
349*b843c749SSergey Zigachev 		}
350*b843c749SSergey Zigachev 
351*b843c749SSergey Zigachev 		REG_SET(DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH, 0,
352*b843c749SSergey Zigachev 				PRIMARY_SURFACE_ADDRESS_HIGH,
353*b843c749SSergey Zigachev 				address->grph.addr.high_part);
354*b843c749SSergey Zigachev 
355*b843c749SSergey Zigachev 		REG_SET(DCSURF_PRIMARY_SURFACE_ADDRESS, 0,
356*b843c749SSergey Zigachev 				PRIMARY_SURFACE_ADDRESS,
357*b843c749SSergey Zigachev 				address->grph.addr.low_part);
358*b843c749SSergey Zigachev 		break;
359*b843c749SSergey Zigachev 	case PLN_ADDR_TYPE_VIDEO_PROGRESSIVE:
360*b843c749SSergey Zigachev 		if (address->video_progressive.luma_addr.quad_part == 0
361*b843c749SSergey Zigachev 			|| address->video_progressive.chroma_addr.quad_part == 0)
362*b843c749SSergey Zigachev 			break;
363*b843c749SSergey Zigachev 
364*b843c749SSergey Zigachev 		REG_UPDATE_4(DCSURF_SURFACE_CONTROL,
365*b843c749SSergey Zigachev 				PRIMARY_SURFACE_TMZ, address->tmz_surface,
366*b843c749SSergey Zigachev 				PRIMARY_SURFACE_TMZ_C, address->tmz_surface,
367*b843c749SSergey Zigachev 				PRIMARY_META_SURFACE_TMZ, address->tmz_surface,
368*b843c749SSergey Zigachev 				PRIMARY_META_SURFACE_TMZ_C, address->tmz_surface);
369*b843c749SSergey Zigachev 
370*b843c749SSergey Zigachev 		if (address->video_progressive.luma_meta_addr.quad_part != 0) {
371*b843c749SSergey Zigachev 			REG_SET(DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH_C, 0,
372*b843c749SSergey Zigachev 				PRIMARY_META_SURFACE_ADDRESS_HIGH_C,
373*b843c749SSergey Zigachev 				address->video_progressive.chroma_meta_addr.high_part);
374*b843c749SSergey Zigachev 
375*b843c749SSergey Zigachev 			REG_SET(DCSURF_PRIMARY_META_SURFACE_ADDRESS_C, 0,
376*b843c749SSergey Zigachev 				PRIMARY_META_SURFACE_ADDRESS_C,
377*b843c749SSergey Zigachev 				address->video_progressive.chroma_meta_addr.low_part);
378*b843c749SSergey Zigachev 
379*b843c749SSergey Zigachev 			REG_SET(DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH, 0,
380*b843c749SSergey Zigachev 				PRIMARY_META_SURFACE_ADDRESS_HIGH,
381*b843c749SSergey Zigachev 				address->video_progressive.luma_meta_addr.high_part);
382*b843c749SSergey Zigachev 
383*b843c749SSergey Zigachev 			REG_SET(DCSURF_PRIMARY_META_SURFACE_ADDRESS, 0,
384*b843c749SSergey Zigachev 				PRIMARY_META_SURFACE_ADDRESS,
385*b843c749SSergey Zigachev 				address->video_progressive.luma_meta_addr.low_part);
386*b843c749SSergey Zigachev 		}
387*b843c749SSergey Zigachev 
388*b843c749SSergey Zigachev 		REG_SET(DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C, 0,
389*b843c749SSergey Zigachev 			PRIMARY_SURFACE_ADDRESS_HIGH_C,
390*b843c749SSergey Zigachev 			address->video_progressive.chroma_addr.high_part);
391*b843c749SSergey Zigachev 
392*b843c749SSergey Zigachev 		REG_SET(DCSURF_PRIMARY_SURFACE_ADDRESS_C, 0,
393*b843c749SSergey Zigachev 			PRIMARY_SURFACE_ADDRESS_C,
394*b843c749SSergey Zigachev 			address->video_progressive.chroma_addr.low_part);
395*b843c749SSergey Zigachev 
396*b843c749SSergey Zigachev 		REG_SET(DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH, 0,
397*b843c749SSergey Zigachev 			PRIMARY_SURFACE_ADDRESS_HIGH,
398*b843c749SSergey Zigachev 			address->video_progressive.luma_addr.high_part);
399*b843c749SSergey Zigachev 
400*b843c749SSergey Zigachev 		REG_SET(DCSURF_PRIMARY_SURFACE_ADDRESS, 0,
401*b843c749SSergey Zigachev 			PRIMARY_SURFACE_ADDRESS,
402*b843c749SSergey Zigachev 			address->video_progressive.luma_addr.low_part);
403*b843c749SSergey Zigachev 		break;
404*b843c749SSergey Zigachev 	case PLN_ADDR_TYPE_GRPH_STEREO:
405*b843c749SSergey Zigachev 		if (address->grph_stereo.left_addr.quad_part == 0)
406*b843c749SSergey Zigachev 			break;
407*b843c749SSergey Zigachev 		if (address->grph_stereo.right_addr.quad_part == 0)
408*b843c749SSergey Zigachev 			break;
409*b843c749SSergey Zigachev 
410*b843c749SSergey Zigachev 		REG_UPDATE_8(DCSURF_SURFACE_CONTROL,
411*b843c749SSergey Zigachev 				PRIMARY_SURFACE_TMZ, address->tmz_surface,
412*b843c749SSergey Zigachev 				PRIMARY_SURFACE_TMZ_C, address->tmz_surface,
413*b843c749SSergey Zigachev 				PRIMARY_META_SURFACE_TMZ, address->tmz_surface,
414*b843c749SSergey Zigachev 				PRIMARY_META_SURFACE_TMZ_C, address->tmz_surface,
415*b843c749SSergey Zigachev 				SECONDARY_SURFACE_TMZ, address->tmz_surface,
416*b843c749SSergey Zigachev 				SECONDARY_SURFACE_TMZ_C, address->tmz_surface,
417*b843c749SSergey Zigachev 				SECONDARY_META_SURFACE_TMZ, address->tmz_surface,
418*b843c749SSergey Zigachev 				SECONDARY_META_SURFACE_TMZ_C, address->tmz_surface);
419*b843c749SSergey Zigachev 
420*b843c749SSergey Zigachev 		if (address->grph_stereo.right_meta_addr.quad_part != 0) {
421*b843c749SSergey Zigachev 
422*b843c749SSergey Zigachev 			REG_SET(DCSURF_SECONDARY_META_SURFACE_ADDRESS_HIGH, 0,
423*b843c749SSergey Zigachev 					SECONDARY_META_SURFACE_ADDRESS_HIGH,
424*b843c749SSergey Zigachev 					address->grph_stereo.right_meta_addr.high_part);
425*b843c749SSergey Zigachev 
426*b843c749SSergey Zigachev 			REG_SET(DCSURF_SECONDARY_META_SURFACE_ADDRESS, 0,
427*b843c749SSergey Zigachev 					SECONDARY_META_SURFACE_ADDRESS,
428*b843c749SSergey Zigachev 					address->grph_stereo.right_meta_addr.low_part);
429*b843c749SSergey Zigachev 		}
430*b843c749SSergey Zigachev 		if (address->grph_stereo.left_meta_addr.quad_part != 0) {
431*b843c749SSergey Zigachev 
432*b843c749SSergey Zigachev 			REG_SET(DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH, 0,
433*b843c749SSergey Zigachev 					PRIMARY_META_SURFACE_ADDRESS_HIGH,
434*b843c749SSergey Zigachev 					address->grph_stereo.left_meta_addr.high_part);
435*b843c749SSergey Zigachev 
436*b843c749SSergey Zigachev 			REG_SET(DCSURF_PRIMARY_META_SURFACE_ADDRESS, 0,
437*b843c749SSergey Zigachev 					PRIMARY_META_SURFACE_ADDRESS,
438*b843c749SSergey Zigachev 					address->grph_stereo.left_meta_addr.low_part);
439*b843c749SSergey Zigachev 		}
440*b843c749SSergey Zigachev 
441*b843c749SSergey Zigachev 		REG_SET(DCSURF_SECONDARY_SURFACE_ADDRESS_HIGH, 0,
442*b843c749SSergey Zigachev 				SECONDARY_SURFACE_ADDRESS_HIGH,
443*b843c749SSergey Zigachev 				address->grph_stereo.right_addr.high_part);
444*b843c749SSergey Zigachev 
445*b843c749SSergey Zigachev 		REG_SET(DCSURF_SECONDARY_SURFACE_ADDRESS, 0,
446*b843c749SSergey Zigachev 				SECONDARY_SURFACE_ADDRESS,
447*b843c749SSergey Zigachev 				address->grph_stereo.right_addr.low_part);
448*b843c749SSergey Zigachev 
449*b843c749SSergey Zigachev 		REG_SET(DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH, 0,
450*b843c749SSergey Zigachev 				PRIMARY_SURFACE_ADDRESS_HIGH,
451*b843c749SSergey Zigachev 				address->grph_stereo.left_addr.high_part);
452*b843c749SSergey Zigachev 
453*b843c749SSergey Zigachev 		REG_SET(DCSURF_PRIMARY_SURFACE_ADDRESS, 0,
454*b843c749SSergey Zigachev 				PRIMARY_SURFACE_ADDRESS,
455*b843c749SSergey Zigachev 				address->grph_stereo.left_addr.low_part);
456*b843c749SSergey Zigachev 		break;
457*b843c749SSergey Zigachev 	default:
458*b843c749SSergey Zigachev 		BREAK_TO_DEBUGGER();
459*b843c749SSergey Zigachev 		break;
460*b843c749SSergey Zigachev 	}
461*b843c749SSergey Zigachev 
462*b843c749SSergey Zigachev 	hubp->request_address = *address;
463*b843c749SSergey Zigachev 
464*b843c749SSergey Zigachev 	return true;
465*b843c749SSergey Zigachev }
466*b843c749SSergey Zigachev 
hubp1_dcc_control(struct hubp * hubp,bool enable,bool independent_64b_blks)467*b843c749SSergey Zigachev void hubp1_dcc_control(struct hubp *hubp, bool enable,
468*b843c749SSergey Zigachev 		bool independent_64b_blks)
469*b843c749SSergey Zigachev {
470*b843c749SSergey Zigachev 	uint32_t dcc_en = enable ? 1 : 0;
471*b843c749SSergey Zigachev 	uint32_t dcc_ind_64b_blk = independent_64b_blks ? 1 : 0;
472*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
473*b843c749SSergey Zigachev 
474*b843c749SSergey Zigachev 	REG_UPDATE_4(DCSURF_SURFACE_CONTROL,
475*b843c749SSergey Zigachev 			PRIMARY_SURFACE_DCC_EN, dcc_en,
476*b843c749SSergey Zigachev 			PRIMARY_SURFACE_DCC_IND_64B_BLK, dcc_ind_64b_blk,
477*b843c749SSergey Zigachev 			SECONDARY_SURFACE_DCC_EN, dcc_en,
478*b843c749SSergey Zigachev 			SECONDARY_SURFACE_DCC_IND_64B_BLK, dcc_ind_64b_blk);
479*b843c749SSergey Zigachev }
480*b843c749SSergey Zigachev 
hubp1_program_surface_config(struct hubp * hubp,enum surface_pixel_format format,union dc_tiling_info * tiling_info,union plane_size * plane_size,enum dc_rotation_angle rotation,struct dc_plane_dcc_param * dcc,bool horizontal_mirror)481*b843c749SSergey Zigachev void hubp1_program_surface_config(
482*b843c749SSergey Zigachev 	struct hubp *hubp,
483*b843c749SSergey Zigachev 	enum surface_pixel_format format,
484*b843c749SSergey Zigachev 	union dc_tiling_info *tiling_info,
485*b843c749SSergey Zigachev 	union plane_size *plane_size,
486*b843c749SSergey Zigachev 	enum dc_rotation_angle rotation,
487*b843c749SSergey Zigachev 	struct dc_plane_dcc_param *dcc,
488*b843c749SSergey Zigachev 	bool horizontal_mirror)
489*b843c749SSergey Zigachev {
490*b843c749SSergey Zigachev 	hubp1_dcc_control(hubp, dcc->enable, dcc->grph.independent_64b_blks);
491*b843c749SSergey Zigachev 	hubp1_program_tiling(hubp, tiling_info, format);
492*b843c749SSergey Zigachev 	hubp1_program_size(hubp, format, plane_size, dcc);
493*b843c749SSergey Zigachev 	hubp1_program_rotation(hubp, rotation, horizontal_mirror);
494*b843c749SSergey Zigachev 	hubp1_program_pixel_format(hubp, format);
495*b843c749SSergey Zigachev }
496*b843c749SSergey Zigachev 
hubp1_program_requestor(struct hubp * hubp,struct _vcs_dpi_display_rq_regs_st * rq_regs)497*b843c749SSergey Zigachev void hubp1_program_requestor(
498*b843c749SSergey Zigachev 		struct hubp *hubp,
499*b843c749SSergey Zigachev 		struct _vcs_dpi_display_rq_regs_st *rq_regs)
500*b843c749SSergey Zigachev {
501*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
502*b843c749SSergey Zigachev 
503*b843c749SSergey Zigachev 	REG_UPDATE(HUBPRET_CONTROL,
504*b843c749SSergey Zigachev 			DET_BUF_PLANE1_BASE_ADDRESS, rq_regs->plane1_base_address);
505*b843c749SSergey Zigachev 	REG_SET_4(DCN_EXPANSION_MODE, 0,
506*b843c749SSergey Zigachev 			DRQ_EXPANSION_MODE, rq_regs->drq_expansion_mode,
507*b843c749SSergey Zigachev 			PRQ_EXPANSION_MODE, rq_regs->prq_expansion_mode,
508*b843c749SSergey Zigachev 			MRQ_EXPANSION_MODE, rq_regs->mrq_expansion_mode,
509*b843c749SSergey Zigachev 			CRQ_EXPANSION_MODE, rq_regs->crq_expansion_mode);
510*b843c749SSergey Zigachev 	REG_SET_8(DCHUBP_REQ_SIZE_CONFIG, 0,
511*b843c749SSergey Zigachev 		CHUNK_SIZE, rq_regs->rq_regs_l.chunk_size,
512*b843c749SSergey Zigachev 		MIN_CHUNK_SIZE, rq_regs->rq_regs_l.min_chunk_size,
513*b843c749SSergey Zigachev 		META_CHUNK_SIZE, rq_regs->rq_regs_l.meta_chunk_size,
514*b843c749SSergey Zigachev 		MIN_META_CHUNK_SIZE, rq_regs->rq_regs_l.min_meta_chunk_size,
515*b843c749SSergey Zigachev 		DPTE_GROUP_SIZE, rq_regs->rq_regs_l.dpte_group_size,
516*b843c749SSergey Zigachev 		MPTE_GROUP_SIZE, rq_regs->rq_regs_l.mpte_group_size,
517*b843c749SSergey Zigachev 		SWATH_HEIGHT, rq_regs->rq_regs_l.swath_height,
518*b843c749SSergey Zigachev 		PTE_ROW_HEIGHT_LINEAR, rq_regs->rq_regs_l.pte_row_height_linear);
519*b843c749SSergey Zigachev 	REG_SET_8(DCHUBP_REQ_SIZE_CONFIG_C, 0,
520*b843c749SSergey Zigachev 		CHUNK_SIZE_C, rq_regs->rq_regs_c.chunk_size,
521*b843c749SSergey Zigachev 		MIN_CHUNK_SIZE_C, rq_regs->rq_regs_c.min_chunk_size,
522*b843c749SSergey Zigachev 		META_CHUNK_SIZE_C, rq_regs->rq_regs_c.meta_chunk_size,
523*b843c749SSergey Zigachev 		MIN_META_CHUNK_SIZE_C, rq_regs->rq_regs_c.min_meta_chunk_size,
524*b843c749SSergey Zigachev 		DPTE_GROUP_SIZE_C, rq_regs->rq_regs_c.dpte_group_size,
525*b843c749SSergey Zigachev 		MPTE_GROUP_SIZE_C, rq_regs->rq_regs_c.mpte_group_size,
526*b843c749SSergey Zigachev 		SWATH_HEIGHT_C, rq_regs->rq_regs_c.swath_height,
527*b843c749SSergey Zigachev 		PTE_ROW_HEIGHT_LINEAR_C, rq_regs->rq_regs_c.pte_row_height_linear);
528*b843c749SSergey Zigachev }
529*b843c749SSergey Zigachev 
530*b843c749SSergey Zigachev 
hubp1_program_deadline(struct hubp * hubp,struct _vcs_dpi_display_dlg_regs_st * dlg_attr,struct _vcs_dpi_display_ttu_regs_st * ttu_attr)531*b843c749SSergey Zigachev void hubp1_program_deadline(
532*b843c749SSergey Zigachev 		struct hubp *hubp,
533*b843c749SSergey Zigachev 		struct _vcs_dpi_display_dlg_regs_st *dlg_attr,
534*b843c749SSergey Zigachev 		struct _vcs_dpi_display_ttu_regs_st *ttu_attr)
535*b843c749SSergey Zigachev {
536*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
537*b843c749SSergey Zigachev 
538*b843c749SSergey Zigachev 	/* DLG - Per hubp */
539*b843c749SSergey Zigachev 	REG_SET_2(BLANK_OFFSET_0, 0,
540*b843c749SSergey Zigachev 		REFCYC_H_BLANK_END, dlg_attr->refcyc_h_blank_end,
541*b843c749SSergey Zigachev 		DLG_V_BLANK_END, dlg_attr->dlg_vblank_end);
542*b843c749SSergey Zigachev 
543*b843c749SSergey Zigachev 	REG_SET(BLANK_OFFSET_1, 0,
544*b843c749SSergey Zigachev 		MIN_DST_Y_NEXT_START, dlg_attr->min_dst_y_next_start);
545*b843c749SSergey Zigachev 
546*b843c749SSergey Zigachev 	REG_SET(DST_DIMENSIONS, 0,
547*b843c749SSergey Zigachev 		REFCYC_PER_HTOTAL, dlg_attr->refcyc_per_htotal);
548*b843c749SSergey Zigachev 
549*b843c749SSergey Zigachev 	REG_SET_2(DST_AFTER_SCALER, 0,
550*b843c749SSergey Zigachev 		REFCYC_X_AFTER_SCALER, dlg_attr->refcyc_x_after_scaler,
551*b843c749SSergey Zigachev 		DST_Y_AFTER_SCALER, dlg_attr->dst_y_after_scaler);
552*b843c749SSergey Zigachev 
553*b843c749SSergey Zigachev 	if (REG(PREFETCH_SETTINS))
554*b843c749SSergey Zigachev 		REG_SET_2(PREFETCH_SETTINS, 0,
555*b843c749SSergey Zigachev 			DST_Y_PREFETCH, dlg_attr->dst_y_prefetch,
556*b843c749SSergey Zigachev 			VRATIO_PREFETCH, dlg_attr->vratio_prefetch);
557*b843c749SSergey Zigachev 	else
558*b843c749SSergey Zigachev 		REG_SET_2(PREFETCH_SETTINGS, 0,
559*b843c749SSergey Zigachev 			DST_Y_PREFETCH, dlg_attr->dst_y_prefetch,
560*b843c749SSergey Zigachev 			VRATIO_PREFETCH, dlg_attr->vratio_prefetch);
561*b843c749SSergey Zigachev 
562*b843c749SSergey Zigachev 	REG_SET_2(VBLANK_PARAMETERS_0, 0,
563*b843c749SSergey Zigachev 		DST_Y_PER_VM_VBLANK, dlg_attr->dst_y_per_vm_vblank,
564*b843c749SSergey Zigachev 		DST_Y_PER_ROW_VBLANK, dlg_attr->dst_y_per_row_vblank);
565*b843c749SSergey Zigachev 
566*b843c749SSergey Zigachev 	REG_SET(REF_FREQ_TO_PIX_FREQ, 0,
567*b843c749SSergey Zigachev 		REF_FREQ_TO_PIX_FREQ, dlg_attr->ref_freq_to_pix_freq);
568*b843c749SSergey Zigachev 
569*b843c749SSergey Zigachev 	/* DLG - Per luma/chroma */
570*b843c749SSergey Zigachev 	REG_SET(VBLANK_PARAMETERS_1, 0,
571*b843c749SSergey Zigachev 		REFCYC_PER_PTE_GROUP_VBLANK_L, dlg_attr->refcyc_per_pte_group_vblank_l);
572*b843c749SSergey Zigachev 
573*b843c749SSergey Zigachev 	REG_SET(VBLANK_PARAMETERS_3, 0,
574*b843c749SSergey Zigachev 		REFCYC_PER_META_CHUNK_VBLANK_L, dlg_attr->refcyc_per_meta_chunk_vblank_l);
575*b843c749SSergey Zigachev 
576*b843c749SSergey Zigachev 	if (REG(NOM_PARAMETERS_0))
577*b843c749SSergey Zigachev 		REG_SET(NOM_PARAMETERS_0, 0,
578*b843c749SSergey Zigachev 			DST_Y_PER_PTE_ROW_NOM_L, dlg_attr->dst_y_per_pte_row_nom_l);
579*b843c749SSergey Zigachev 
580*b843c749SSergey Zigachev 	if (REG(NOM_PARAMETERS_1))
581*b843c749SSergey Zigachev 		REG_SET(NOM_PARAMETERS_1, 0,
582*b843c749SSergey Zigachev 			REFCYC_PER_PTE_GROUP_NOM_L, dlg_attr->refcyc_per_pte_group_nom_l);
583*b843c749SSergey Zigachev 
584*b843c749SSergey Zigachev 	REG_SET(NOM_PARAMETERS_4, 0,
585*b843c749SSergey Zigachev 		DST_Y_PER_META_ROW_NOM_L, dlg_attr->dst_y_per_meta_row_nom_l);
586*b843c749SSergey Zigachev 
587*b843c749SSergey Zigachev 	REG_SET(NOM_PARAMETERS_5, 0,
588*b843c749SSergey Zigachev 		REFCYC_PER_META_CHUNK_NOM_L, dlg_attr->refcyc_per_meta_chunk_nom_l);
589*b843c749SSergey Zigachev 
590*b843c749SSergey Zigachev 	REG_SET_2(PER_LINE_DELIVERY_PRE, 0,
591*b843c749SSergey Zigachev 		REFCYC_PER_LINE_DELIVERY_PRE_L, dlg_attr->refcyc_per_line_delivery_pre_l,
592*b843c749SSergey Zigachev 		REFCYC_PER_LINE_DELIVERY_PRE_C, dlg_attr->refcyc_per_line_delivery_pre_c);
593*b843c749SSergey Zigachev 
594*b843c749SSergey Zigachev 	REG_SET_2(PER_LINE_DELIVERY, 0,
595*b843c749SSergey Zigachev 		REFCYC_PER_LINE_DELIVERY_L, dlg_attr->refcyc_per_line_delivery_l,
596*b843c749SSergey Zigachev 		REFCYC_PER_LINE_DELIVERY_C, dlg_attr->refcyc_per_line_delivery_c);
597*b843c749SSergey Zigachev 
598*b843c749SSergey Zigachev 	if (REG(PREFETCH_SETTINS_C))
599*b843c749SSergey Zigachev 		REG_SET(PREFETCH_SETTINS_C, 0,
600*b843c749SSergey Zigachev 			VRATIO_PREFETCH_C, dlg_attr->vratio_prefetch_c);
601*b843c749SSergey Zigachev 	else
602*b843c749SSergey Zigachev 		REG_SET(PREFETCH_SETTINGS_C, 0,
603*b843c749SSergey Zigachev 			VRATIO_PREFETCH_C, dlg_attr->vratio_prefetch_c);
604*b843c749SSergey Zigachev 
605*b843c749SSergey Zigachev 	REG_SET(VBLANK_PARAMETERS_2, 0,
606*b843c749SSergey Zigachev 		REFCYC_PER_PTE_GROUP_VBLANK_C, dlg_attr->refcyc_per_pte_group_vblank_c);
607*b843c749SSergey Zigachev 
608*b843c749SSergey Zigachev 	REG_SET(VBLANK_PARAMETERS_4, 0,
609*b843c749SSergey Zigachev 		REFCYC_PER_META_CHUNK_VBLANK_C, dlg_attr->refcyc_per_meta_chunk_vblank_c);
610*b843c749SSergey Zigachev 
611*b843c749SSergey Zigachev 	if (REG(NOM_PARAMETERS_2))
612*b843c749SSergey Zigachev 		REG_SET(NOM_PARAMETERS_2, 0,
613*b843c749SSergey Zigachev 			DST_Y_PER_PTE_ROW_NOM_C, dlg_attr->dst_y_per_pte_row_nom_c);
614*b843c749SSergey Zigachev 
615*b843c749SSergey Zigachev 	if (REG(NOM_PARAMETERS_3))
616*b843c749SSergey Zigachev 		REG_SET(NOM_PARAMETERS_3, 0,
617*b843c749SSergey Zigachev 			REFCYC_PER_PTE_GROUP_NOM_C, dlg_attr->refcyc_per_pte_group_nom_c);
618*b843c749SSergey Zigachev 
619*b843c749SSergey Zigachev 	REG_SET(NOM_PARAMETERS_6, 0,
620*b843c749SSergey Zigachev 		DST_Y_PER_META_ROW_NOM_C, dlg_attr->dst_y_per_meta_row_nom_c);
621*b843c749SSergey Zigachev 
622*b843c749SSergey Zigachev 	REG_SET(NOM_PARAMETERS_7, 0,
623*b843c749SSergey Zigachev 		REFCYC_PER_META_CHUNK_NOM_C, dlg_attr->refcyc_per_meta_chunk_nom_c);
624*b843c749SSergey Zigachev 
625*b843c749SSergey Zigachev 	/* TTU - per hubp */
626*b843c749SSergey Zigachev 	REG_SET_2(DCN_TTU_QOS_WM, 0,
627*b843c749SSergey Zigachev 		QoS_LEVEL_LOW_WM, ttu_attr->qos_level_low_wm,
628*b843c749SSergey Zigachev 		QoS_LEVEL_HIGH_WM, ttu_attr->qos_level_high_wm);
629*b843c749SSergey Zigachev 
630*b843c749SSergey Zigachev 	REG_SET_2(DCN_GLOBAL_TTU_CNTL, 0,
631*b843c749SSergey Zigachev 		MIN_TTU_VBLANK, ttu_attr->min_ttu_vblank,
632*b843c749SSergey Zigachev 		QoS_LEVEL_FLIP, ttu_attr->qos_level_flip);
633*b843c749SSergey Zigachev 
634*b843c749SSergey Zigachev 	/* TTU - per luma/chroma */
635*b843c749SSergey Zigachev 	/* Assumed surf0 is luma and 1 is chroma */
636*b843c749SSergey Zigachev 
637*b843c749SSergey Zigachev 	REG_SET_3(DCN_SURF0_TTU_CNTL0, 0,
638*b843c749SSergey Zigachev 		REFCYC_PER_REQ_DELIVERY, ttu_attr->refcyc_per_req_delivery_l,
639*b843c749SSergey Zigachev 		QoS_LEVEL_FIXED, ttu_attr->qos_level_fixed_l,
640*b843c749SSergey Zigachev 		QoS_RAMP_DISABLE, ttu_attr->qos_ramp_disable_l);
641*b843c749SSergey Zigachev 
642*b843c749SSergey Zigachev 	REG_SET(DCN_SURF0_TTU_CNTL1, 0,
643*b843c749SSergey Zigachev 		REFCYC_PER_REQ_DELIVERY_PRE,
644*b843c749SSergey Zigachev 		ttu_attr->refcyc_per_req_delivery_pre_l);
645*b843c749SSergey Zigachev 
646*b843c749SSergey Zigachev 	REG_SET_3(DCN_SURF1_TTU_CNTL0, 0,
647*b843c749SSergey Zigachev 		REFCYC_PER_REQ_DELIVERY, ttu_attr->refcyc_per_req_delivery_c,
648*b843c749SSergey Zigachev 		QoS_LEVEL_FIXED, ttu_attr->qos_level_fixed_c,
649*b843c749SSergey Zigachev 		QoS_RAMP_DISABLE, ttu_attr->qos_ramp_disable_c);
650*b843c749SSergey Zigachev 
651*b843c749SSergey Zigachev 	REG_SET(DCN_SURF1_TTU_CNTL1, 0,
652*b843c749SSergey Zigachev 		REFCYC_PER_REQ_DELIVERY_PRE,
653*b843c749SSergey Zigachev 		ttu_attr->refcyc_per_req_delivery_pre_c);
654*b843c749SSergey Zigachev 
655*b843c749SSergey Zigachev 	REG_SET_3(DCN_CUR0_TTU_CNTL0, 0,
656*b843c749SSergey Zigachev 		REFCYC_PER_REQ_DELIVERY, ttu_attr->refcyc_per_req_delivery_cur0,
657*b843c749SSergey Zigachev 		QoS_LEVEL_FIXED, ttu_attr->qos_level_fixed_cur0,
658*b843c749SSergey Zigachev 		QoS_RAMP_DISABLE, ttu_attr->qos_ramp_disable_cur0);
659*b843c749SSergey Zigachev 	REG_SET(DCN_CUR0_TTU_CNTL1, 0,
660*b843c749SSergey Zigachev 		REFCYC_PER_REQ_DELIVERY_PRE, ttu_attr->refcyc_per_req_delivery_pre_cur0);
661*b843c749SSergey Zigachev }
662*b843c749SSergey Zigachev 
hubp1_setup(struct hubp * hubp,struct _vcs_dpi_display_dlg_regs_st * dlg_attr,struct _vcs_dpi_display_ttu_regs_st * ttu_attr,struct _vcs_dpi_display_rq_regs_st * rq_regs,struct _vcs_dpi_display_pipe_dest_params_st * pipe_dest)663*b843c749SSergey Zigachev static void hubp1_setup(
664*b843c749SSergey Zigachev 		struct hubp *hubp,
665*b843c749SSergey Zigachev 		struct _vcs_dpi_display_dlg_regs_st *dlg_attr,
666*b843c749SSergey Zigachev 		struct _vcs_dpi_display_ttu_regs_st *ttu_attr,
667*b843c749SSergey Zigachev 		struct _vcs_dpi_display_rq_regs_st *rq_regs,
668*b843c749SSergey Zigachev 		struct _vcs_dpi_display_pipe_dest_params_st *pipe_dest)
669*b843c749SSergey Zigachev {
670*b843c749SSergey Zigachev 	/* otg is locked when this func is called. Register are double buffered.
671*b843c749SSergey Zigachev 	 * disable the requestors is not needed
672*b843c749SSergey Zigachev 	 */
673*b843c749SSergey Zigachev 	hubp1_program_requestor(hubp, rq_regs);
674*b843c749SSergey Zigachev 	hubp1_program_deadline(hubp, dlg_attr, ttu_attr);
675*b843c749SSergey Zigachev 	hubp1_vready_workaround(hubp, pipe_dest);
676*b843c749SSergey Zigachev }
677*b843c749SSergey Zigachev 
hubp1_is_flip_pending(struct hubp * hubp)678*b843c749SSergey Zigachev bool hubp1_is_flip_pending(struct hubp *hubp)
679*b843c749SSergey Zigachev {
680*b843c749SSergey Zigachev 	uint32_t flip_pending = 0;
681*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
682*b843c749SSergey Zigachev 	struct dc_plane_address earliest_inuse_address;
683*b843c749SSergey Zigachev 
684*b843c749SSergey Zigachev 	REG_GET(DCSURF_FLIP_CONTROL,
685*b843c749SSergey Zigachev 			SURFACE_FLIP_PENDING, &flip_pending);
686*b843c749SSergey Zigachev 
687*b843c749SSergey Zigachev 	REG_GET(DCSURF_SURFACE_EARLIEST_INUSE,
688*b843c749SSergey Zigachev 			SURFACE_EARLIEST_INUSE_ADDRESS, &earliest_inuse_address.grph.addr.low_part);
689*b843c749SSergey Zigachev 
690*b843c749SSergey Zigachev 	REG_GET(DCSURF_SURFACE_EARLIEST_INUSE_HIGH,
691*b843c749SSergey Zigachev 			SURFACE_EARLIEST_INUSE_ADDRESS_HIGH, &earliest_inuse_address.grph.addr.high_part);
692*b843c749SSergey Zigachev 
693*b843c749SSergey Zigachev 	if (flip_pending)
694*b843c749SSergey Zigachev 		return true;
695*b843c749SSergey Zigachev 
696*b843c749SSergey Zigachev 	if (earliest_inuse_address.grph.addr.quad_part != hubp->request_address.grph.addr.quad_part)
697*b843c749SSergey Zigachev 		return true;
698*b843c749SSergey Zigachev 
699*b843c749SSergey Zigachev 	return false;
700*b843c749SSergey Zigachev }
701*b843c749SSergey Zigachev 
702*b843c749SSergey Zigachev uint32_t aperture_default_system = 1;
703*b843c749SSergey Zigachev uint32_t context0_default_system; /* = 0;*/
704*b843c749SSergey Zigachev 
hubp1_set_vm_system_aperture_settings(struct hubp * hubp,struct vm_system_aperture_param * apt)705*b843c749SSergey Zigachev static void hubp1_set_vm_system_aperture_settings(struct hubp *hubp,
706*b843c749SSergey Zigachev 		struct vm_system_aperture_param *apt)
707*b843c749SSergey Zigachev {
708*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
709*b843c749SSergey Zigachev 	PHYSICAL_ADDRESS_LOC mc_vm_apt_default;
710*b843c749SSergey Zigachev 	PHYSICAL_ADDRESS_LOC mc_vm_apt_low;
711*b843c749SSergey Zigachev 	PHYSICAL_ADDRESS_LOC mc_vm_apt_high;
712*b843c749SSergey Zigachev 
713*b843c749SSergey Zigachev 	mc_vm_apt_default.quad_part = apt->sys_default.quad_part >> 12;
714*b843c749SSergey Zigachev 	mc_vm_apt_low.quad_part = apt->sys_low.quad_part >> 12;
715*b843c749SSergey Zigachev 	mc_vm_apt_high.quad_part = apt->sys_high.quad_part >> 12;
716*b843c749SSergey Zigachev 
717*b843c749SSergey Zigachev 	REG_SET_2(DCN_VM_SYSTEM_APERTURE_DEFAULT_ADDR_MSB, 0,
718*b843c749SSergey Zigachev 		MC_VM_SYSTEM_APERTURE_DEFAULT_SYSTEM, aperture_default_system, /* 1 = system physical memory */
719*b843c749SSergey Zigachev 		MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_MSB, mc_vm_apt_default.high_part);
720*b843c749SSergey Zigachev 	REG_SET(DCN_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB, 0,
721*b843c749SSergey Zigachev 		MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB, mc_vm_apt_default.low_part);
722*b843c749SSergey Zigachev 
723*b843c749SSergey Zigachev 	REG_SET(DCN_VM_SYSTEM_APERTURE_LOW_ADDR_MSB, 0,
724*b843c749SSergey Zigachev 			MC_VM_SYSTEM_APERTURE_LOW_ADDR_MSB, mc_vm_apt_low.high_part);
725*b843c749SSergey Zigachev 	REG_SET(DCN_VM_SYSTEM_APERTURE_LOW_ADDR_LSB, 0,
726*b843c749SSergey Zigachev 			MC_VM_SYSTEM_APERTURE_LOW_ADDR_LSB, mc_vm_apt_low.low_part);
727*b843c749SSergey Zigachev 
728*b843c749SSergey Zigachev 	REG_SET(DCN_VM_SYSTEM_APERTURE_HIGH_ADDR_MSB, 0,
729*b843c749SSergey Zigachev 			MC_VM_SYSTEM_APERTURE_HIGH_ADDR_MSB, mc_vm_apt_high.high_part);
730*b843c749SSergey Zigachev 	REG_SET(DCN_VM_SYSTEM_APERTURE_HIGH_ADDR_LSB, 0,
731*b843c749SSergey Zigachev 			MC_VM_SYSTEM_APERTURE_HIGH_ADDR_LSB, mc_vm_apt_high.low_part);
732*b843c749SSergey Zigachev }
733*b843c749SSergey Zigachev 
hubp1_set_vm_context0_settings(struct hubp * hubp,const struct vm_context0_param * vm0)734*b843c749SSergey Zigachev static void hubp1_set_vm_context0_settings(struct hubp *hubp,
735*b843c749SSergey Zigachev 		const struct vm_context0_param *vm0)
736*b843c749SSergey Zigachev {
737*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
738*b843c749SSergey Zigachev 	/* pte base */
739*b843c749SSergey Zigachev 	REG_SET(DCN_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR_MSB, 0,
740*b843c749SSergey Zigachev 			VM_CONTEXT0_PAGE_TABLE_BASE_ADDR_MSB, vm0->pte_base.high_part);
741*b843c749SSergey Zigachev 	REG_SET(DCN_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LSB, 0,
742*b843c749SSergey Zigachev 			VM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LSB, vm0->pte_base.low_part);
743*b843c749SSergey Zigachev 
744*b843c749SSergey Zigachev 	/* pte start */
745*b843c749SSergey Zigachev 	REG_SET(DCN_VM_CONTEXT0_PAGE_TABLE_START_ADDR_MSB, 0,
746*b843c749SSergey Zigachev 			VM_CONTEXT0_PAGE_TABLE_START_ADDR_MSB, vm0->pte_start.high_part);
747*b843c749SSergey Zigachev 	REG_SET(DCN_VM_CONTEXT0_PAGE_TABLE_START_ADDR_LSB, 0,
748*b843c749SSergey Zigachev 			VM_CONTEXT0_PAGE_TABLE_START_ADDR_LSB, vm0->pte_start.low_part);
749*b843c749SSergey Zigachev 
750*b843c749SSergey Zigachev 	/* pte end */
751*b843c749SSergey Zigachev 	REG_SET(DCN_VM_CONTEXT0_PAGE_TABLE_END_ADDR_MSB, 0,
752*b843c749SSergey Zigachev 			VM_CONTEXT0_PAGE_TABLE_END_ADDR_MSB, vm0->pte_end.high_part);
753*b843c749SSergey Zigachev 	REG_SET(DCN_VM_CONTEXT0_PAGE_TABLE_END_ADDR_LSB, 0,
754*b843c749SSergey Zigachev 			VM_CONTEXT0_PAGE_TABLE_END_ADDR_LSB, vm0->pte_end.low_part);
755*b843c749SSergey Zigachev 
756*b843c749SSergey Zigachev 	/* fault handling */
757*b843c749SSergey Zigachev 	REG_SET_2(DCN_VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR_MSB, 0,
758*b843c749SSergey Zigachev 			VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR_MSB, vm0->fault_default.high_part,
759*b843c749SSergey Zigachev 			VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_SYSTEM, context0_default_system);
760*b843c749SSergey Zigachev 	REG_SET(DCN_VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR_LSB, 0,
761*b843c749SSergey Zigachev 			VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR_LSB, vm0->fault_default.low_part);
762*b843c749SSergey Zigachev 
763*b843c749SSergey Zigachev 	/* control: enable VM PTE*/
764*b843c749SSergey Zigachev 	REG_SET_2(DCN_VM_MX_L1_TLB_CNTL, 0,
765*b843c749SSergey Zigachev 			ENABLE_L1_TLB, 1,
766*b843c749SSergey Zigachev 			SYSTEM_ACCESS_MODE, 3);
767*b843c749SSergey Zigachev }
768*b843c749SSergey Zigachev 
min_set_viewport(struct hubp * hubp,const struct rect * viewport,const struct rect * viewport_c)769*b843c749SSergey Zigachev void min_set_viewport(
770*b843c749SSergey Zigachev 	struct hubp *hubp,
771*b843c749SSergey Zigachev 	const struct rect *viewport,
772*b843c749SSergey Zigachev 	const struct rect *viewport_c)
773*b843c749SSergey Zigachev {
774*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
775*b843c749SSergey Zigachev 
776*b843c749SSergey Zigachev 	REG_SET_2(DCSURF_PRI_VIEWPORT_DIMENSION, 0,
777*b843c749SSergey Zigachev 		  PRI_VIEWPORT_WIDTH, viewport->width,
778*b843c749SSergey Zigachev 		  PRI_VIEWPORT_HEIGHT, viewport->height);
779*b843c749SSergey Zigachev 
780*b843c749SSergey Zigachev 	REG_SET_2(DCSURF_PRI_VIEWPORT_START, 0,
781*b843c749SSergey Zigachev 		  PRI_VIEWPORT_X_START, viewport->x,
782*b843c749SSergey Zigachev 		  PRI_VIEWPORT_Y_START, viewport->y);
783*b843c749SSergey Zigachev 
784*b843c749SSergey Zigachev 	/*for stereo*/
785*b843c749SSergey Zigachev 	REG_SET_2(DCSURF_SEC_VIEWPORT_DIMENSION, 0,
786*b843c749SSergey Zigachev 		  SEC_VIEWPORT_WIDTH, viewport->width,
787*b843c749SSergey Zigachev 		  SEC_VIEWPORT_HEIGHT, viewport->height);
788*b843c749SSergey Zigachev 
789*b843c749SSergey Zigachev 	REG_SET_2(DCSURF_SEC_VIEWPORT_START, 0,
790*b843c749SSergey Zigachev 		  SEC_VIEWPORT_X_START, viewport->x,
791*b843c749SSergey Zigachev 		  SEC_VIEWPORT_Y_START, viewport->y);
792*b843c749SSergey Zigachev 
793*b843c749SSergey Zigachev 	/* DC supports NV12 only at the moment */
794*b843c749SSergey Zigachev 	REG_SET_2(DCSURF_PRI_VIEWPORT_DIMENSION_C, 0,
795*b843c749SSergey Zigachev 		  PRI_VIEWPORT_WIDTH_C, viewport_c->width,
796*b843c749SSergey Zigachev 		  PRI_VIEWPORT_HEIGHT_C, viewport_c->height);
797*b843c749SSergey Zigachev 
798*b843c749SSergey Zigachev 	REG_SET_2(DCSURF_PRI_VIEWPORT_START_C, 0,
799*b843c749SSergey Zigachev 		  PRI_VIEWPORT_X_START_C, viewport_c->x,
800*b843c749SSergey Zigachev 		  PRI_VIEWPORT_Y_START_C, viewport_c->y);
801*b843c749SSergey Zigachev }
802*b843c749SSergey Zigachev 
hubp1_read_state(struct hubp * hubp)803*b843c749SSergey Zigachev void hubp1_read_state(struct hubp *hubp)
804*b843c749SSergey Zigachev {
805*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
806*b843c749SSergey Zigachev 	struct dcn_hubp_state *s = &hubp1->state;
807*b843c749SSergey Zigachev 	struct _vcs_dpi_display_dlg_regs_st *dlg_attr = &s->dlg_attr;
808*b843c749SSergey Zigachev 	struct _vcs_dpi_display_ttu_regs_st *ttu_attr = &s->ttu_attr;
809*b843c749SSergey Zigachev 	struct _vcs_dpi_display_rq_regs_st *rq_regs = &s->rq_regs;
810*b843c749SSergey Zigachev 
811*b843c749SSergey Zigachev 	/* Requester */
812*b843c749SSergey Zigachev 	REG_GET(HUBPRET_CONTROL,
813*b843c749SSergey Zigachev 			DET_BUF_PLANE1_BASE_ADDRESS, &rq_regs->plane1_base_address);
814*b843c749SSergey Zigachev 	REG_GET_4(DCN_EXPANSION_MODE,
815*b843c749SSergey Zigachev 			DRQ_EXPANSION_MODE, &rq_regs->drq_expansion_mode,
816*b843c749SSergey Zigachev 			PRQ_EXPANSION_MODE, &rq_regs->prq_expansion_mode,
817*b843c749SSergey Zigachev 			MRQ_EXPANSION_MODE, &rq_regs->mrq_expansion_mode,
818*b843c749SSergey Zigachev 			CRQ_EXPANSION_MODE, &rq_regs->crq_expansion_mode);
819*b843c749SSergey Zigachev 	REG_GET_8(DCHUBP_REQ_SIZE_CONFIG,
820*b843c749SSergey Zigachev 		CHUNK_SIZE, &rq_regs->rq_regs_l.chunk_size,
821*b843c749SSergey Zigachev 		MIN_CHUNK_SIZE, &rq_regs->rq_regs_l.min_chunk_size,
822*b843c749SSergey Zigachev 		META_CHUNK_SIZE, &rq_regs->rq_regs_l.meta_chunk_size,
823*b843c749SSergey Zigachev 		MIN_META_CHUNK_SIZE, &rq_regs->rq_regs_l.min_meta_chunk_size,
824*b843c749SSergey Zigachev 		DPTE_GROUP_SIZE, &rq_regs->rq_regs_l.dpte_group_size,
825*b843c749SSergey Zigachev 		MPTE_GROUP_SIZE, &rq_regs->rq_regs_l.mpte_group_size,
826*b843c749SSergey Zigachev 		SWATH_HEIGHT, &rq_regs->rq_regs_l.swath_height,
827*b843c749SSergey Zigachev 		PTE_ROW_HEIGHT_LINEAR, &rq_regs->rq_regs_l.pte_row_height_linear);
828*b843c749SSergey Zigachev 	REG_GET_8(DCHUBP_REQ_SIZE_CONFIG_C,
829*b843c749SSergey Zigachev 		CHUNK_SIZE_C, &rq_regs->rq_regs_c.chunk_size,
830*b843c749SSergey Zigachev 		MIN_CHUNK_SIZE_C, &rq_regs->rq_regs_c.min_chunk_size,
831*b843c749SSergey Zigachev 		META_CHUNK_SIZE_C, &rq_regs->rq_regs_c.meta_chunk_size,
832*b843c749SSergey Zigachev 		MIN_META_CHUNK_SIZE_C, &rq_regs->rq_regs_c.min_meta_chunk_size,
833*b843c749SSergey Zigachev 		DPTE_GROUP_SIZE_C, &rq_regs->rq_regs_c.dpte_group_size,
834*b843c749SSergey Zigachev 		MPTE_GROUP_SIZE_C, &rq_regs->rq_regs_c.mpte_group_size,
835*b843c749SSergey Zigachev 		SWATH_HEIGHT_C, &rq_regs->rq_regs_c.swath_height,
836*b843c749SSergey Zigachev 		PTE_ROW_HEIGHT_LINEAR_C, &rq_regs->rq_regs_c.pte_row_height_linear);
837*b843c749SSergey Zigachev 
838*b843c749SSergey Zigachev 	/* DLG - Per hubp */
839*b843c749SSergey Zigachev 	REG_GET_2(BLANK_OFFSET_0,
840*b843c749SSergey Zigachev 		REFCYC_H_BLANK_END, &dlg_attr->refcyc_h_blank_end,
841*b843c749SSergey Zigachev 		DLG_V_BLANK_END, &dlg_attr->dlg_vblank_end);
842*b843c749SSergey Zigachev 
843*b843c749SSergey Zigachev 	REG_GET(BLANK_OFFSET_1,
844*b843c749SSergey Zigachev 		MIN_DST_Y_NEXT_START, &dlg_attr->min_dst_y_next_start);
845*b843c749SSergey Zigachev 
846*b843c749SSergey Zigachev 	REG_GET(DST_DIMENSIONS,
847*b843c749SSergey Zigachev 		REFCYC_PER_HTOTAL, &dlg_attr->refcyc_per_htotal);
848*b843c749SSergey Zigachev 
849*b843c749SSergey Zigachev 	REG_GET_2(DST_AFTER_SCALER,
850*b843c749SSergey Zigachev 		REFCYC_X_AFTER_SCALER, &dlg_attr->refcyc_x_after_scaler,
851*b843c749SSergey Zigachev 		DST_Y_AFTER_SCALER, &dlg_attr->dst_y_after_scaler);
852*b843c749SSergey Zigachev 
853*b843c749SSergey Zigachev 	if (REG(PREFETCH_SETTINS))
854*b843c749SSergey Zigachev 		REG_GET_2(PREFETCH_SETTINS,
855*b843c749SSergey Zigachev 			DST_Y_PREFETCH, &dlg_attr->dst_y_prefetch,
856*b843c749SSergey Zigachev 			VRATIO_PREFETCH, &dlg_attr->vratio_prefetch);
857*b843c749SSergey Zigachev 	else
858*b843c749SSergey Zigachev 		REG_GET_2(PREFETCH_SETTINGS,
859*b843c749SSergey Zigachev 			DST_Y_PREFETCH, &dlg_attr->dst_y_prefetch,
860*b843c749SSergey Zigachev 			VRATIO_PREFETCH, &dlg_attr->vratio_prefetch);
861*b843c749SSergey Zigachev 
862*b843c749SSergey Zigachev 	REG_GET_2(VBLANK_PARAMETERS_0,
863*b843c749SSergey Zigachev 		DST_Y_PER_VM_VBLANK, &dlg_attr->dst_y_per_vm_vblank,
864*b843c749SSergey Zigachev 		DST_Y_PER_ROW_VBLANK, &dlg_attr->dst_y_per_row_vblank);
865*b843c749SSergey Zigachev 
866*b843c749SSergey Zigachev 	REG_GET(REF_FREQ_TO_PIX_FREQ,
867*b843c749SSergey Zigachev 		REF_FREQ_TO_PIX_FREQ, &dlg_attr->ref_freq_to_pix_freq);
868*b843c749SSergey Zigachev 
869*b843c749SSergey Zigachev 	/* DLG - Per luma/chroma */
870*b843c749SSergey Zigachev 	REG_GET(VBLANK_PARAMETERS_1,
871*b843c749SSergey Zigachev 		REFCYC_PER_PTE_GROUP_VBLANK_L, &dlg_attr->refcyc_per_pte_group_vblank_l);
872*b843c749SSergey Zigachev 
873*b843c749SSergey Zigachev 	REG_GET(VBLANK_PARAMETERS_3,
874*b843c749SSergey Zigachev 		REFCYC_PER_META_CHUNK_VBLANK_L, &dlg_attr->refcyc_per_meta_chunk_vblank_l);
875*b843c749SSergey Zigachev 
876*b843c749SSergey Zigachev 	if (REG(NOM_PARAMETERS_0))
877*b843c749SSergey Zigachev 		REG_GET(NOM_PARAMETERS_0,
878*b843c749SSergey Zigachev 			DST_Y_PER_PTE_ROW_NOM_L, &dlg_attr->dst_y_per_pte_row_nom_l);
879*b843c749SSergey Zigachev 
880*b843c749SSergey Zigachev 	if (REG(NOM_PARAMETERS_1))
881*b843c749SSergey Zigachev 		REG_GET(NOM_PARAMETERS_1,
882*b843c749SSergey Zigachev 			REFCYC_PER_PTE_GROUP_NOM_L, &dlg_attr->refcyc_per_pte_group_nom_l);
883*b843c749SSergey Zigachev 
884*b843c749SSergey Zigachev 	REG_GET(NOM_PARAMETERS_4,
885*b843c749SSergey Zigachev 		DST_Y_PER_META_ROW_NOM_L, &dlg_attr->dst_y_per_meta_row_nom_l);
886*b843c749SSergey Zigachev 
887*b843c749SSergey Zigachev 	REG_GET(NOM_PARAMETERS_5,
888*b843c749SSergey Zigachev 		REFCYC_PER_META_CHUNK_NOM_L, &dlg_attr->refcyc_per_meta_chunk_nom_l);
889*b843c749SSergey Zigachev 
890*b843c749SSergey Zigachev 	REG_GET_2(PER_LINE_DELIVERY_PRE,
891*b843c749SSergey Zigachev 		REFCYC_PER_LINE_DELIVERY_PRE_L, &dlg_attr->refcyc_per_line_delivery_pre_l,
892*b843c749SSergey Zigachev 		REFCYC_PER_LINE_DELIVERY_PRE_C, &dlg_attr->refcyc_per_line_delivery_pre_c);
893*b843c749SSergey Zigachev 
894*b843c749SSergey Zigachev 	REG_GET_2(PER_LINE_DELIVERY,
895*b843c749SSergey Zigachev 		REFCYC_PER_LINE_DELIVERY_L, &dlg_attr->refcyc_per_line_delivery_l,
896*b843c749SSergey Zigachev 		REFCYC_PER_LINE_DELIVERY_C, &dlg_attr->refcyc_per_line_delivery_c);
897*b843c749SSergey Zigachev 
898*b843c749SSergey Zigachev 	if (REG(PREFETCH_SETTINS_C))
899*b843c749SSergey Zigachev 		REG_GET(PREFETCH_SETTINS_C,
900*b843c749SSergey Zigachev 			VRATIO_PREFETCH_C, &dlg_attr->vratio_prefetch_c);
901*b843c749SSergey Zigachev 	else
902*b843c749SSergey Zigachev 		REG_GET(PREFETCH_SETTINGS_C,
903*b843c749SSergey Zigachev 			VRATIO_PREFETCH_C, &dlg_attr->vratio_prefetch_c);
904*b843c749SSergey Zigachev 
905*b843c749SSergey Zigachev 	REG_GET(VBLANK_PARAMETERS_2,
906*b843c749SSergey Zigachev 		REFCYC_PER_PTE_GROUP_VBLANK_C, &dlg_attr->refcyc_per_pte_group_vblank_c);
907*b843c749SSergey Zigachev 
908*b843c749SSergey Zigachev 	REG_GET(VBLANK_PARAMETERS_4,
909*b843c749SSergey Zigachev 		REFCYC_PER_META_CHUNK_VBLANK_C, &dlg_attr->refcyc_per_meta_chunk_vblank_c);
910*b843c749SSergey Zigachev 
911*b843c749SSergey Zigachev 	if (REG(NOM_PARAMETERS_2))
912*b843c749SSergey Zigachev 		REG_GET(NOM_PARAMETERS_2,
913*b843c749SSergey Zigachev 			DST_Y_PER_PTE_ROW_NOM_C, &dlg_attr->dst_y_per_pte_row_nom_c);
914*b843c749SSergey Zigachev 
915*b843c749SSergey Zigachev 	if (REG(NOM_PARAMETERS_3))
916*b843c749SSergey Zigachev 		REG_GET(NOM_PARAMETERS_3,
917*b843c749SSergey Zigachev 			REFCYC_PER_PTE_GROUP_NOM_C, &dlg_attr->refcyc_per_pte_group_nom_c);
918*b843c749SSergey Zigachev 
919*b843c749SSergey Zigachev 	REG_GET(NOM_PARAMETERS_6,
920*b843c749SSergey Zigachev 		DST_Y_PER_META_ROW_NOM_C, &dlg_attr->dst_y_per_meta_row_nom_c);
921*b843c749SSergey Zigachev 
922*b843c749SSergey Zigachev 	REG_GET(NOM_PARAMETERS_7,
923*b843c749SSergey Zigachev 		REFCYC_PER_META_CHUNK_NOM_C, &dlg_attr->refcyc_per_meta_chunk_nom_c);
924*b843c749SSergey Zigachev 
925*b843c749SSergey Zigachev 	/* TTU - per hubp */
926*b843c749SSergey Zigachev 	REG_GET_2(DCN_TTU_QOS_WM,
927*b843c749SSergey Zigachev 		QoS_LEVEL_LOW_WM, &ttu_attr->qos_level_low_wm,
928*b843c749SSergey Zigachev 		QoS_LEVEL_HIGH_WM, &ttu_attr->qos_level_high_wm);
929*b843c749SSergey Zigachev 
930*b843c749SSergey Zigachev 	REG_GET_2(DCN_GLOBAL_TTU_CNTL,
931*b843c749SSergey Zigachev 		MIN_TTU_VBLANK, &ttu_attr->min_ttu_vblank,
932*b843c749SSergey Zigachev 		QoS_LEVEL_FLIP, &ttu_attr->qos_level_flip);
933*b843c749SSergey Zigachev 
934*b843c749SSergey Zigachev 	/* TTU - per luma/chroma */
935*b843c749SSergey Zigachev 	/* Assumed surf0 is luma and 1 is chroma */
936*b843c749SSergey Zigachev 
937*b843c749SSergey Zigachev 	REG_GET_3(DCN_SURF0_TTU_CNTL0,
938*b843c749SSergey Zigachev 		REFCYC_PER_REQ_DELIVERY, &ttu_attr->refcyc_per_req_delivery_l,
939*b843c749SSergey Zigachev 		QoS_LEVEL_FIXED, &ttu_attr->qos_level_fixed_l,
940*b843c749SSergey Zigachev 		QoS_RAMP_DISABLE, &ttu_attr->qos_ramp_disable_l);
941*b843c749SSergey Zigachev 
942*b843c749SSergey Zigachev 	REG_GET(DCN_SURF0_TTU_CNTL1,
943*b843c749SSergey Zigachev 		REFCYC_PER_REQ_DELIVERY_PRE,
944*b843c749SSergey Zigachev 		&ttu_attr->refcyc_per_req_delivery_pre_l);
945*b843c749SSergey Zigachev 
946*b843c749SSergey Zigachev 	REG_GET_3(DCN_SURF1_TTU_CNTL0,
947*b843c749SSergey Zigachev 		REFCYC_PER_REQ_DELIVERY, &ttu_attr->refcyc_per_req_delivery_c,
948*b843c749SSergey Zigachev 		QoS_LEVEL_FIXED, &ttu_attr->qos_level_fixed_c,
949*b843c749SSergey Zigachev 		QoS_RAMP_DISABLE, &ttu_attr->qos_ramp_disable_c);
950*b843c749SSergey Zigachev 
951*b843c749SSergey Zigachev 	REG_GET(DCN_SURF1_TTU_CNTL1,
952*b843c749SSergey Zigachev 		REFCYC_PER_REQ_DELIVERY_PRE,
953*b843c749SSergey Zigachev 		&ttu_attr->refcyc_per_req_delivery_pre_c);
954*b843c749SSergey Zigachev 
955*b843c749SSergey Zigachev 	/* Rest of hubp */
956*b843c749SSergey Zigachev 	REG_GET(DCSURF_SURFACE_CONFIG,
957*b843c749SSergey Zigachev 			SURFACE_PIXEL_FORMAT, &s->pixel_format);
958*b843c749SSergey Zigachev 
959*b843c749SSergey Zigachev 	REG_GET(DCSURF_SURFACE_EARLIEST_INUSE_HIGH,
960*b843c749SSergey Zigachev 			SURFACE_EARLIEST_INUSE_ADDRESS_HIGH, &s->inuse_addr_hi);
961*b843c749SSergey Zigachev 
962*b843c749SSergey Zigachev 	REG_GET_2(DCSURF_PRI_VIEWPORT_DIMENSION,
963*b843c749SSergey Zigachev 			PRI_VIEWPORT_WIDTH, &s->viewport_width,
964*b843c749SSergey Zigachev 			PRI_VIEWPORT_HEIGHT, &s->viewport_height);
965*b843c749SSergey Zigachev 
966*b843c749SSergey Zigachev 	REG_GET_2(DCSURF_SURFACE_CONFIG,
967*b843c749SSergey Zigachev 			ROTATION_ANGLE, &s->rotation_angle,
968*b843c749SSergey Zigachev 			H_MIRROR_EN, &s->h_mirror_en);
969*b843c749SSergey Zigachev 
970*b843c749SSergey Zigachev 	REG_GET(DCSURF_TILING_CONFIG,
971*b843c749SSergey Zigachev 			SW_MODE, &s->sw_mode);
972*b843c749SSergey Zigachev 
973*b843c749SSergey Zigachev 	REG_GET(DCSURF_SURFACE_CONTROL,
974*b843c749SSergey Zigachev 			PRIMARY_SURFACE_DCC_EN, &s->dcc_en);
975*b843c749SSergey Zigachev 
976*b843c749SSergey Zigachev 	REG_GET_3(DCHUBP_CNTL,
977*b843c749SSergey Zigachev 			HUBP_BLANK_EN, &s->blank_en,
978*b843c749SSergey Zigachev 			HUBP_TTU_DISABLE, &s->ttu_disable,
979*b843c749SSergey Zigachev 			HUBP_UNDERFLOW_STATUS, &s->underflow_status);
980*b843c749SSergey Zigachev 
981*b843c749SSergey Zigachev 	REG_GET(DCN_GLOBAL_TTU_CNTL,
982*b843c749SSergey Zigachev 			MIN_TTU_VBLANK, &s->min_ttu_vblank);
983*b843c749SSergey Zigachev 
984*b843c749SSergey Zigachev 	REG_GET_2(DCN_TTU_QOS_WM,
985*b843c749SSergey Zigachev 			QoS_LEVEL_LOW_WM, &s->qos_level_low_wm,
986*b843c749SSergey Zigachev 			QoS_LEVEL_HIGH_WM, &s->qos_level_high_wm);
987*b843c749SSergey Zigachev }
988*b843c749SSergey Zigachev 
hubp1_get_cursor_pitch(unsigned int pitch)989*b843c749SSergey Zigachev enum cursor_pitch hubp1_get_cursor_pitch(unsigned int pitch)
990*b843c749SSergey Zigachev {
991*b843c749SSergey Zigachev 	enum cursor_pitch hw_pitch;
992*b843c749SSergey Zigachev 
993*b843c749SSergey Zigachev 	switch (pitch) {
994*b843c749SSergey Zigachev 	case 64:
995*b843c749SSergey Zigachev 		hw_pitch = CURSOR_PITCH_64_PIXELS;
996*b843c749SSergey Zigachev 		break;
997*b843c749SSergey Zigachev 	case 128:
998*b843c749SSergey Zigachev 		hw_pitch = CURSOR_PITCH_128_PIXELS;
999*b843c749SSergey Zigachev 		break;
1000*b843c749SSergey Zigachev 	case 256:
1001*b843c749SSergey Zigachev 		hw_pitch = CURSOR_PITCH_256_PIXELS;
1002*b843c749SSergey Zigachev 		break;
1003*b843c749SSergey Zigachev 	default:
1004*b843c749SSergey Zigachev 		DC_ERR("Invalid cursor pitch of %d. "
1005*b843c749SSergey Zigachev 				"Only 64/128/256 is supported on DCN.\n", pitch);
1006*b843c749SSergey Zigachev 		hw_pitch = CURSOR_PITCH_64_PIXELS;
1007*b843c749SSergey Zigachev 		break;
1008*b843c749SSergey Zigachev 	}
1009*b843c749SSergey Zigachev 	return hw_pitch;
1010*b843c749SSergey Zigachev }
1011*b843c749SSergey Zigachev 
hubp1_get_lines_per_chunk(unsigned int cur_width,enum dc_cursor_color_format format)1012*b843c749SSergey Zigachev static enum cursor_lines_per_chunk hubp1_get_lines_per_chunk(
1013*b843c749SSergey Zigachev 		unsigned int cur_width,
1014*b843c749SSergey Zigachev 		enum dc_cursor_color_format format)
1015*b843c749SSergey Zigachev {
1016*b843c749SSergey Zigachev 	enum cursor_lines_per_chunk line_per_chunk;
1017*b843c749SSergey Zigachev 
1018*b843c749SSergey Zigachev 	if (format == CURSOR_MODE_MONO)
1019*b843c749SSergey Zigachev 		/* impl B. expansion in CUR Buffer reader */
1020*b843c749SSergey Zigachev 		line_per_chunk = CURSOR_LINE_PER_CHUNK_16;
1021*b843c749SSergey Zigachev 	else if (cur_width <= 32)
1022*b843c749SSergey Zigachev 		line_per_chunk = CURSOR_LINE_PER_CHUNK_16;
1023*b843c749SSergey Zigachev 	else if (cur_width <= 64)
1024*b843c749SSergey Zigachev 		line_per_chunk = CURSOR_LINE_PER_CHUNK_8;
1025*b843c749SSergey Zigachev 	else if (cur_width <= 128)
1026*b843c749SSergey Zigachev 		line_per_chunk = CURSOR_LINE_PER_CHUNK_4;
1027*b843c749SSergey Zigachev 	else
1028*b843c749SSergey Zigachev 		line_per_chunk = CURSOR_LINE_PER_CHUNK_2;
1029*b843c749SSergey Zigachev 
1030*b843c749SSergey Zigachev 	return line_per_chunk;
1031*b843c749SSergey Zigachev }
1032*b843c749SSergey Zigachev 
hubp1_cursor_set_attributes(struct hubp * hubp,const struct dc_cursor_attributes * attr)1033*b843c749SSergey Zigachev void hubp1_cursor_set_attributes(
1034*b843c749SSergey Zigachev 		struct hubp *hubp,
1035*b843c749SSergey Zigachev 		const struct dc_cursor_attributes *attr)
1036*b843c749SSergey Zigachev {
1037*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
1038*b843c749SSergey Zigachev 	enum cursor_pitch hw_pitch = hubp1_get_cursor_pitch(attr->pitch);
1039*b843c749SSergey Zigachev 	enum cursor_lines_per_chunk lpc = hubp1_get_lines_per_chunk(
1040*b843c749SSergey Zigachev 			attr->width, attr->color_format);
1041*b843c749SSergey Zigachev 
1042*b843c749SSergey Zigachev 	hubp->curs_attr = *attr;
1043*b843c749SSergey Zigachev 
1044*b843c749SSergey Zigachev 	REG_UPDATE(CURSOR_SURFACE_ADDRESS_HIGH,
1045*b843c749SSergey Zigachev 			CURSOR_SURFACE_ADDRESS_HIGH, attr->address.high_part);
1046*b843c749SSergey Zigachev 	REG_UPDATE(CURSOR_SURFACE_ADDRESS,
1047*b843c749SSergey Zigachev 			CURSOR_SURFACE_ADDRESS, attr->address.low_part);
1048*b843c749SSergey Zigachev 
1049*b843c749SSergey Zigachev 	REG_UPDATE_2(CURSOR_SIZE,
1050*b843c749SSergey Zigachev 			CURSOR_WIDTH, attr->width,
1051*b843c749SSergey Zigachev 			CURSOR_HEIGHT, attr->height);
1052*b843c749SSergey Zigachev 
1053*b843c749SSergey Zigachev 	REG_UPDATE_3(CURSOR_CONTROL,
1054*b843c749SSergey Zigachev 			CURSOR_MODE, attr->color_format,
1055*b843c749SSergey Zigachev 			CURSOR_PITCH, hw_pitch,
1056*b843c749SSergey Zigachev 			CURSOR_LINES_PER_CHUNK, lpc);
1057*b843c749SSergey Zigachev 
1058*b843c749SSergey Zigachev 	REG_SET_2(CURSOR_SETTINS, 0,
1059*b843c749SSergey Zigachev 			/* no shift of the cursor HDL schedule */
1060*b843c749SSergey Zigachev 			CURSOR0_DST_Y_OFFSET, 0,
1061*b843c749SSergey Zigachev 			 /* used to shift the cursor chunk request deadline */
1062*b843c749SSergey Zigachev 			CURSOR0_CHUNK_HDL_ADJUST, 3);
1063*b843c749SSergey Zigachev }
1064*b843c749SSergey Zigachev 
hubp1_cursor_set_position(struct hubp * hubp,const struct dc_cursor_position * pos,const struct dc_cursor_mi_param * param)1065*b843c749SSergey Zigachev void hubp1_cursor_set_position(
1066*b843c749SSergey Zigachev 		struct hubp *hubp,
1067*b843c749SSergey Zigachev 		const struct dc_cursor_position *pos,
1068*b843c749SSergey Zigachev 		const struct dc_cursor_mi_param *param)
1069*b843c749SSergey Zigachev {
1070*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
1071*b843c749SSergey Zigachev 	int src_x_offset = pos->x - pos->x_hotspot - param->viewport.x;
1072*b843c749SSergey Zigachev 	int x_hotspot = pos->x_hotspot;
1073*b843c749SSergey Zigachev 	int y_hotspot = pos->y_hotspot;
1074*b843c749SSergey Zigachev 	uint32_t dst_x_offset;
1075*b843c749SSergey Zigachev 	uint32_t cur_en = pos->enable ? 1 : 0;
1076*b843c749SSergey Zigachev 
1077*b843c749SSergey Zigachev 	/*
1078*b843c749SSergey Zigachev 	 * Guard aganst cursor_set_position() from being called with invalid
1079*b843c749SSergey Zigachev 	 * attributes
1080*b843c749SSergey Zigachev 	 *
1081*b843c749SSergey Zigachev 	 * TODO: Look at combining cursor_set_position() and
1082*b843c749SSergey Zigachev 	 * cursor_set_attributes() into cursor_update()
1083*b843c749SSergey Zigachev 	 */
1084*b843c749SSergey Zigachev 	if (hubp->curs_attr.address.quad_part == 0)
1085*b843c749SSergey Zigachev 		return;
1086*b843c749SSergey Zigachev 
1087*b843c749SSergey Zigachev 	if (param->rotation == ROTATION_ANGLE_90 || param->rotation == ROTATION_ANGLE_270) {
1088*b843c749SSergey Zigachev 		src_x_offset = pos->y - pos->y_hotspot - param->viewport.x;
1089*b843c749SSergey Zigachev 		y_hotspot = pos->x_hotspot;
1090*b843c749SSergey Zigachev 		x_hotspot = pos->y_hotspot;
1091*b843c749SSergey Zigachev 	}
1092*b843c749SSergey Zigachev 
1093*b843c749SSergey Zigachev 	if (param->mirror) {
1094*b843c749SSergey Zigachev 		x_hotspot = param->viewport.width - x_hotspot;
1095*b843c749SSergey Zigachev 		src_x_offset = param->viewport.x + param->viewport.width - src_x_offset;
1096*b843c749SSergey Zigachev 	}
1097*b843c749SSergey Zigachev 
1098*b843c749SSergey Zigachev 	dst_x_offset = (src_x_offset >= 0) ? src_x_offset : 0;
1099*b843c749SSergey Zigachev 	dst_x_offset *= param->ref_clk_khz;
1100*b843c749SSergey Zigachev 	dst_x_offset /= param->pixel_clk_khz;
1101*b843c749SSergey Zigachev 
1102*b843c749SSergey Zigachev 	ASSERT(param->h_scale_ratio.value);
1103*b843c749SSergey Zigachev 
1104*b843c749SSergey Zigachev 	if (param->h_scale_ratio.value)
1105*b843c749SSergey Zigachev 		dst_x_offset = dc_fixpt_floor(dc_fixpt_div(
1106*b843c749SSergey Zigachev 				dc_fixpt_from_int(dst_x_offset),
1107*b843c749SSergey Zigachev 				param->h_scale_ratio));
1108*b843c749SSergey Zigachev 
1109*b843c749SSergey Zigachev 	if (src_x_offset >= (int)param->viewport.width)
1110*b843c749SSergey Zigachev 		cur_en = 0;  /* not visible beyond right edge*/
1111*b843c749SSergey Zigachev 
1112*b843c749SSergey Zigachev 	if (src_x_offset + (int)hubp->curs_attr.width <= 0)
1113*b843c749SSergey Zigachev 		cur_en = 0;  /* not visible beyond left edge*/
1114*b843c749SSergey Zigachev 
1115*b843c749SSergey Zigachev 	if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0)
1116*b843c749SSergey Zigachev 		hubp->funcs->set_cursor_attributes(hubp, &hubp->curs_attr);
1117*b843c749SSergey Zigachev 
1118*b843c749SSergey Zigachev 	REG_UPDATE(CURSOR_CONTROL,
1119*b843c749SSergey Zigachev 			CURSOR_ENABLE, cur_en);
1120*b843c749SSergey Zigachev 
1121*b843c749SSergey Zigachev 	REG_SET_2(CURSOR_POSITION, 0,
1122*b843c749SSergey Zigachev 			CURSOR_X_POSITION, pos->x,
1123*b843c749SSergey Zigachev 			CURSOR_Y_POSITION, pos->y);
1124*b843c749SSergey Zigachev 
1125*b843c749SSergey Zigachev 	REG_SET_2(CURSOR_HOT_SPOT, 0,
1126*b843c749SSergey Zigachev 			CURSOR_HOT_SPOT_X, x_hotspot,
1127*b843c749SSergey Zigachev 			CURSOR_HOT_SPOT_Y, y_hotspot);
1128*b843c749SSergey Zigachev 
1129*b843c749SSergey Zigachev 	REG_SET(CURSOR_DST_OFFSET, 0,
1130*b843c749SSergey Zigachev 			CURSOR_DST_X_OFFSET, dst_x_offset);
1131*b843c749SSergey Zigachev 	/* TODO Handle surface pixel formats other than 4:4:4 */
1132*b843c749SSergey Zigachev }
1133*b843c749SSergey Zigachev 
hubp1_clk_cntl(struct hubp * hubp,bool enable)1134*b843c749SSergey Zigachev void hubp1_clk_cntl(struct hubp *hubp, bool enable)
1135*b843c749SSergey Zigachev {
1136*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
1137*b843c749SSergey Zigachev 	uint32_t clk_enable = enable ? 1 : 0;
1138*b843c749SSergey Zigachev 
1139*b843c749SSergey Zigachev 	REG_UPDATE(HUBP_CLK_CNTL, HUBP_CLOCK_ENABLE, clk_enable);
1140*b843c749SSergey Zigachev }
1141*b843c749SSergey Zigachev 
hubp1_vtg_sel(struct hubp * hubp,uint32_t otg_inst)1142*b843c749SSergey Zigachev void hubp1_vtg_sel(struct hubp *hubp, uint32_t otg_inst)
1143*b843c749SSergey Zigachev {
1144*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
1145*b843c749SSergey Zigachev 
1146*b843c749SSergey Zigachev 	REG_UPDATE(DCHUBP_CNTL, HUBP_VTG_SEL, otg_inst);
1147*b843c749SSergey Zigachev }
1148*b843c749SSergey Zigachev 
1149*b843c749SSergey Zigachev static const struct hubp_funcs dcn10_hubp_funcs = {
1150*b843c749SSergey Zigachev 	.hubp_program_surface_flip_and_addr =
1151*b843c749SSergey Zigachev 			hubp1_program_surface_flip_and_addr,
1152*b843c749SSergey Zigachev 	.hubp_program_surface_config =
1153*b843c749SSergey Zigachev 			hubp1_program_surface_config,
1154*b843c749SSergey Zigachev 	.hubp_is_flip_pending = hubp1_is_flip_pending,
1155*b843c749SSergey Zigachev 	.hubp_setup = hubp1_setup,
1156*b843c749SSergey Zigachev 	.hubp_set_vm_system_aperture_settings = hubp1_set_vm_system_aperture_settings,
1157*b843c749SSergey Zigachev 	.hubp_set_vm_context0_settings = hubp1_set_vm_context0_settings,
1158*b843c749SSergey Zigachev 	.set_blank = hubp1_set_blank,
1159*b843c749SSergey Zigachev 	.dcc_control = hubp1_dcc_control,
1160*b843c749SSergey Zigachev 	.mem_program_viewport = min_set_viewport,
1161*b843c749SSergey Zigachev 	.set_hubp_blank_en = hubp1_set_hubp_blank_en,
1162*b843c749SSergey Zigachev 	.set_cursor_attributes	= hubp1_cursor_set_attributes,
1163*b843c749SSergey Zigachev 	.set_cursor_position	= hubp1_cursor_set_position,
1164*b843c749SSergey Zigachev 	.hubp_disconnect = hubp1_disconnect,
1165*b843c749SSergey Zigachev 	.hubp_clk_cntl = hubp1_clk_cntl,
1166*b843c749SSergey Zigachev 	.hubp_vtg_sel = hubp1_vtg_sel,
1167*b843c749SSergey Zigachev 	.hubp_read_state = hubp1_read_state,
1168*b843c749SSergey Zigachev 	.hubp_disable_control =  hubp1_disable_control,
1169*b843c749SSergey Zigachev 	.hubp_get_underflow_status = hubp1_get_underflow_status,
1170*b843c749SSergey Zigachev 
1171*b843c749SSergey Zigachev };
1172*b843c749SSergey Zigachev 
1173*b843c749SSergey Zigachev /*****************************************/
1174*b843c749SSergey Zigachev /* Constructor, Destructor               */
1175*b843c749SSergey Zigachev /*****************************************/
1176*b843c749SSergey Zigachev 
dcn10_hubp_construct(struct dcn10_hubp * hubp1,struct dc_context * ctx,uint32_t inst,const struct dcn_mi_registers * hubp_regs,const struct dcn_mi_shift * hubp_shift,const struct dcn_mi_mask * hubp_mask)1177*b843c749SSergey Zigachev void dcn10_hubp_construct(
1178*b843c749SSergey Zigachev 	struct dcn10_hubp *hubp1,
1179*b843c749SSergey Zigachev 	struct dc_context *ctx,
1180*b843c749SSergey Zigachev 	uint32_t inst,
1181*b843c749SSergey Zigachev 	const struct dcn_mi_registers *hubp_regs,
1182*b843c749SSergey Zigachev 	const struct dcn_mi_shift *hubp_shift,
1183*b843c749SSergey Zigachev 	const struct dcn_mi_mask *hubp_mask)
1184*b843c749SSergey Zigachev {
1185*b843c749SSergey Zigachev 	hubp1->base.funcs = &dcn10_hubp_funcs;
1186*b843c749SSergey Zigachev 	hubp1->base.ctx = ctx;
1187*b843c749SSergey Zigachev 	hubp1->hubp_regs = hubp_regs;
1188*b843c749SSergey Zigachev 	hubp1->hubp_shift = hubp_shift;
1189*b843c749SSergey Zigachev 	hubp1->hubp_mask = hubp_mask;
1190*b843c749SSergey Zigachev 	hubp1->base.inst = inst;
1191*b843c749SSergey Zigachev 	hubp1->base.opp_id = 0xf;
1192*b843c749SSergey Zigachev 	hubp1->base.mpcc_id = 0xf;
1193*b843c749SSergey Zigachev }
1194*b843c749SSergey Zigachev 
1195*b843c749SSergey Zigachev 
1196