18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci#include "radeonfb.h"
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci/* the accelerated functions here are patterned after the
58c2ecf20Sopenharmony_ci * "ACCEL_MMIO" ifdef branches in XFree86
68c2ecf20Sopenharmony_ci * --dte
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_cistatic void radeon_fixup_offset(struct radeonfb_info *rinfo)
108c2ecf20Sopenharmony_ci{
118c2ecf20Sopenharmony_ci	u32 local_base;
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci	/* *** Ugly workaround *** */
148c2ecf20Sopenharmony_ci	/*
158c2ecf20Sopenharmony_ci	 * On some platforms, the video memory is mapped at 0 in radeon chip space
168c2ecf20Sopenharmony_ci	 * (like PPCs) by the firmware. X will always move it up so that it's seen
178c2ecf20Sopenharmony_ci	 * by the chip to be at the same address as the PCI BAR.
188c2ecf20Sopenharmony_ci	 * That means that when switching back from X, there is a mismatch between
198c2ecf20Sopenharmony_ci	 * the offsets programmed into the engine. This means that potentially,
208c2ecf20Sopenharmony_ci	 * accel operations done before radeonfb has a chance to re-init the engine
218c2ecf20Sopenharmony_ci	 * will have incorrect offsets, and potentially trash system memory !
228c2ecf20Sopenharmony_ci	 *
238c2ecf20Sopenharmony_ci	 * The correct fix is for fbcon to never call any accel op before the engine
248c2ecf20Sopenharmony_ci	 * has properly been re-initialized (by a call to set_var), but this is a
258c2ecf20Sopenharmony_ci	 * complex fix. This workaround in the meantime, called before every accel
268c2ecf20Sopenharmony_ci	 * operation, makes sure the offsets are in sync.
278c2ecf20Sopenharmony_ci	 */
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci	radeon_fifo_wait (1);
308c2ecf20Sopenharmony_ci	local_base = INREG(MC_FB_LOCATION) << 16;
318c2ecf20Sopenharmony_ci	if (local_base == rinfo->fb_local_base)
328c2ecf20Sopenharmony_ci		return;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	rinfo->fb_local_base = local_base;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	radeon_fifo_wait (3);
378c2ecf20Sopenharmony_ci	OUTREG(DEFAULT_PITCH_OFFSET, (rinfo->pitch << 0x16) |
388c2ecf20Sopenharmony_ci				     (rinfo->fb_local_base >> 10));
398c2ecf20Sopenharmony_ci	OUTREG(DST_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10));
408c2ecf20Sopenharmony_ci	OUTREG(SRC_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10));
418c2ecf20Sopenharmony_ci}
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cistatic void radeonfb_prim_fillrect(struct radeonfb_info *rinfo,
448c2ecf20Sopenharmony_ci				   const struct fb_fillrect *region)
458c2ecf20Sopenharmony_ci{
468c2ecf20Sopenharmony_ci	radeon_fifo_wait(4);
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci	OUTREG(DP_GUI_MASTER_CNTL,
498c2ecf20Sopenharmony_ci		rinfo->dp_gui_master_cntl  /* contains, like GMC_DST_32BPP */
508c2ecf20Sopenharmony_ci                | GMC_BRUSH_SOLID_COLOR
518c2ecf20Sopenharmony_ci                | ROP3_P);
528c2ecf20Sopenharmony_ci	if (radeon_get_dstbpp(rinfo->depth) != DST_8BPP)
538c2ecf20Sopenharmony_ci		OUTREG(DP_BRUSH_FRGD_CLR, rinfo->pseudo_palette[region->color]);
548c2ecf20Sopenharmony_ci	else
558c2ecf20Sopenharmony_ci		OUTREG(DP_BRUSH_FRGD_CLR, region->color);
568c2ecf20Sopenharmony_ci	OUTREG(DP_WRITE_MSK, 0xffffffff);
578c2ecf20Sopenharmony_ci	OUTREG(DP_CNTL, (DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM));
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci	radeon_fifo_wait(2);
608c2ecf20Sopenharmony_ci	OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL);
618c2ecf20Sopenharmony_ci	OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE));
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	radeon_fifo_wait(2);
648c2ecf20Sopenharmony_ci	OUTREG(DST_Y_X, (region->dy << 16) | region->dx);
658c2ecf20Sopenharmony_ci	OUTREG(DST_WIDTH_HEIGHT, (region->width << 16) | region->height);
668c2ecf20Sopenharmony_ci}
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_civoid radeonfb_fillrect(struct fb_info *info, const struct fb_fillrect *region)
698c2ecf20Sopenharmony_ci{
708c2ecf20Sopenharmony_ci	struct radeonfb_info *rinfo = info->par;
718c2ecf20Sopenharmony_ci	struct fb_fillrect modded;
728c2ecf20Sopenharmony_ci	int vxres, vyres;
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	if (info->state != FBINFO_STATE_RUNNING)
758c2ecf20Sopenharmony_ci		return;
768c2ecf20Sopenharmony_ci	if (info->flags & FBINFO_HWACCEL_DISABLED) {
778c2ecf20Sopenharmony_ci		cfb_fillrect(info, region);
788c2ecf20Sopenharmony_ci		return;
798c2ecf20Sopenharmony_ci	}
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	radeon_fixup_offset(rinfo);
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	vxres = info->var.xres_virtual;
848c2ecf20Sopenharmony_ci	vyres = info->var.yres_virtual;
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	memcpy(&modded, region, sizeof(struct fb_fillrect));
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	if(!modded.width || !modded.height ||
898c2ecf20Sopenharmony_ci	   modded.dx >= vxres || modded.dy >= vyres)
908c2ecf20Sopenharmony_ci		return;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci	if(modded.dx + modded.width  > vxres) modded.width  = vxres - modded.dx;
938c2ecf20Sopenharmony_ci	if(modded.dy + modded.height > vyres) modded.height = vyres - modded.dy;
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	radeonfb_prim_fillrect(rinfo, &modded);
968c2ecf20Sopenharmony_ci}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cistatic void radeonfb_prim_copyarea(struct radeonfb_info *rinfo,
998c2ecf20Sopenharmony_ci				   const struct fb_copyarea *area)
1008c2ecf20Sopenharmony_ci{
1018c2ecf20Sopenharmony_ci	int xdir, ydir;
1028c2ecf20Sopenharmony_ci	u32 sx, sy, dx, dy, w, h;
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci	w = area->width; h = area->height;
1058c2ecf20Sopenharmony_ci	dx = area->dx; dy = area->dy;
1068c2ecf20Sopenharmony_ci	sx = area->sx; sy = area->sy;
1078c2ecf20Sopenharmony_ci	xdir = sx - dx;
1088c2ecf20Sopenharmony_ci	ydir = sy - dy;
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci	if ( xdir < 0 ) { sx += w-1; dx += w-1; }
1118c2ecf20Sopenharmony_ci	if ( ydir < 0 ) { sy += h-1; dy += h-1; }
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci	radeon_fifo_wait(3);
1148c2ecf20Sopenharmony_ci	OUTREG(DP_GUI_MASTER_CNTL,
1158c2ecf20Sopenharmony_ci		rinfo->dp_gui_master_cntl /* i.e. GMC_DST_32BPP */
1168c2ecf20Sopenharmony_ci		| GMC_BRUSH_NONE
1178c2ecf20Sopenharmony_ci		| GMC_SRC_DSTCOLOR
1188c2ecf20Sopenharmony_ci		| ROP3_S
1198c2ecf20Sopenharmony_ci		| DP_SRC_SOURCE_MEMORY );
1208c2ecf20Sopenharmony_ci	OUTREG(DP_WRITE_MSK, 0xffffffff);
1218c2ecf20Sopenharmony_ci	OUTREG(DP_CNTL, (xdir>=0 ? DST_X_LEFT_TO_RIGHT : 0)
1228c2ecf20Sopenharmony_ci			| (ydir>=0 ? DST_Y_TOP_TO_BOTTOM : 0));
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci	radeon_fifo_wait(2);
1258c2ecf20Sopenharmony_ci	OUTREG(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL);
1268c2ecf20Sopenharmony_ci	OUTREG(WAIT_UNTIL, (WAIT_2D_IDLECLEAN | WAIT_DMA_GUI_IDLE));
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci	radeon_fifo_wait(3);
1298c2ecf20Sopenharmony_ci	OUTREG(SRC_Y_X, (sy << 16) | sx);
1308c2ecf20Sopenharmony_ci	OUTREG(DST_Y_X, (dy << 16) | dx);
1318c2ecf20Sopenharmony_ci	OUTREG(DST_HEIGHT_WIDTH, (h << 16) | w);
1328c2ecf20Sopenharmony_ci}
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_civoid radeonfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
1368c2ecf20Sopenharmony_ci{
1378c2ecf20Sopenharmony_ci	struct radeonfb_info *rinfo = info->par;
1388c2ecf20Sopenharmony_ci	struct fb_copyarea modded;
1398c2ecf20Sopenharmony_ci	u32 vxres, vyres;
1408c2ecf20Sopenharmony_ci	modded.sx = area->sx;
1418c2ecf20Sopenharmony_ci	modded.sy = area->sy;
1428c2ecf20Sopenharmony_ci	modded.dx = area->dx;
1438c2ecf20Sopenharmony_ci	modded.dy = area->dy;
1448c2ecf20Sopenharmony_ci	modded.width  = area->width;
1458c2ecf20Sopenharmony_ci	modded.height = area->height;
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci	if (info->state != FBINFO_STATE_RUNNING)
1488c2ecf20Sopenharmony_ci		return;
1498c2ecf20Sopenharmony_ci	if (info->flags & FBINFO_HWACCEL_DISABLED) {
1508c2ecf20Sopenharmony_ci		cfb_copyarea(info, area);
1518c2ecf20Sopenharmony_ci		return;
1528c2ecf20Sopenharmony_ci	}
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci	radeon_fixup_offset(rinfo);
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci	vxres = info->var.xres_virtual;
1578c2ecf20Sopenharmony_ci	vyres = info->var.yres_virtual;
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci	if(!modded.width || !modded.height ||
1608c2ecf20Sopenharmony_ci	   modded.sx >= vxres || modded.sy >= vyres ||
1618c2ecf20Sopenharmony_ci	   modded.dx >= vxres || modded.dy >= vyres)
1628c2ecf20Sopenharmony_ci		return;
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	if(modded.sx + modded.width > vxres)  modded.width = vxres - modded.sx;
1658c2ecf20Sopenharmony_ci	if(modded.dx + modded.width > vxres)  modded.width = vxres - modded.dx;
1668c2ecf20Sopenharmony_ci	if(modded.sy + modded.height > vyres) modded.height = vyres - modded.sy;
1678c2ecf20Sopenharmony_ci	if(modded.dy + modded.height > vyres) modded.height = vyres - modded.dy;
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci	radeonfb_prim_copyarea(rinfo, &modded);
1708c2ecf20Sopenharmony_ci}
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_civoid radeonfb_imageblit(struct fb_info *info, const struct fb_image *image)
1738c2ecf20Sopenharmony_ci{
1748c2ecf20Sopenharmony_ci	struct radeonfb_info *rinfo = info->par;
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	if (info->state != FBINFO_STATE_RUNNING)
1778c2ecf20Sopenharmony_ci		return;
1788c2ecf20Sopenharmony_ci	radeon_engine_idle();
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci	cfb_imageblit(info, image);
1818c2ecf20Sopenharmony_ci}
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ciint radeonfb_sync(struct fb_info *info)
1848c2ecf20Sopenharmony_ci{
1858c2ecf20Sopenharmony_ci	struct radeonfb_info *rinfo = info->par;
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci	if (info->state != FBINFO_STATE_RUNNING)
1888c2ecf20Sopenharmony_ci		return 0;
1898c2ecf20Sopenharmony_ci	radeon_engine_idle();
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci	return 0;
1928c2ecf20Sopenharmony_ci}
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_civoid radeonfb_engine_reset(struct radeonfb_info *rinfo)
1958c2ecf20Sopenharmony_ci{
1968c2ecf20Sopenharmony_ci	u32 clock_cntl_index, mclk_cntl, rbbm_soft_reset;
1978c2ecf20Sopenharmony_ci	u32 host_path_cntl;
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci	radeon_engine_flush (rinfo);
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci	clock_cntl_index = INREG(CLOCK_CNTL_INDEX);
2028c2ecf20Sopenharmony_ci	mclk_cntl = INPLL(MCLK_CNTL);
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	OUTPLL(MCLK_CNTL, (mclk_cntl |
2058c2ecf20Sopenharmony_ci			   FORCEON_MCLKA |
2068c2ecf20Sopenharmony_ci			   FORCEON_MCLKB |
2078c2ecf20Sopenharmony_ci			   FORCEON_YCLKA |
2088c2ecf20Sopenharmony_ci			   FORCEON_YCLKB |
2098c2ecf20Sopenharmony_ci			   FORCEON_MC |
2108c2ecf20Sopenharmony_ci			   FORCEON_AIC));
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci	host_path_cntl = INREG(HOST_PATH_CNTL);
2138c2ecf20Sopenharmony_ci	rbbm_soft_reset = INREG(RBBM_SOFT_RESET);
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci	if (IS_R300_VARIANT(rinfo)) {
2168c2ecf20Sopenharmony_ci		u32 tmp;
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci		OUTREG(RBBM_SOFT_RESET, (rbbm_soft_reset |
2198c2ecf20Sopenharmony_ci					 SOFT_RESET_CP |
2208c2ecf20Sopenharmony_ci					 SOFT_RESET_HI |
2218c2ecf20Sopenharmony_ci					 SOFT_RESET_E2));
2228c2ecf20Sopenharmony_ci		INREG(RBBM_SOFT_RESET);
2238c2ecf20Sopenharmony_ci		OUTREG(RBBM_SOFT_RESET, 0);
2248c2ecf20Sopenharmony_ci		tmp = INREG(RB2D_DSTCACHE_MODE);
2258c2ecf20Sopenharmony_ci		OUTREG(RB2D_DSTCACHE_MODE, tmp | (1 << 17)); /* FIXME */
2268c2ecf20Sopenharmony_ci	} else {
2278c2ecf20Sopenharmony_ci		OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset |
2288c2ecf20Sopenharmony_ci					SOFT_RESET_CP |
2298c2ecf20Sopenharmony_ci					SOFT_RESET_HI |
2308c2ecf20Sopenharmony_ci					SOFT_RESET_SE |
2318c2ecf20Sopenharmony_ci					SOFT_RESET_RE |
2328c2ecf20Sopenharmony_ci					SOFT_RESET_PP |
2338c2ecf20Sopenharmony_ci					SOFT_RESET_E2 |
2348c2ecf20Sopenharmony_ci					SOFT_RESET_RB);
2358c2ecf20Sopenharmony_ci		INREG(RBBM_SOFT_RESET);
2368c2ecf20Sopenharmony_ci		OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset & (u32)
2378c2ecf20Sopenharmony_ci					~(SOFT_RESET_CP |
2388c2ecf20Sopenharmony_ci					  SOFT_RESET_HI |
2398c2ecf20Sopenharmony_ci					  SOFT_RESET_SE |
2408c2ecf20Sopenharmony_ci					  SOFT_RESET_RE |
2418c2ecf20Sopenharmony_ci					  SOFT_RESET_PP |
2428c2ecf20Sopenharmony_ci					  SOFT_RESET_E2 |
2438c2ecf20Sopenharmony_ci					  SOFT_RESET_RB));
2448c2ecf20Sopenharmony_ci		INREG(RBBM_SOFT_RESET);
2458c2ecf20Sopenharmony_ci	}
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	OUTREG(HOST_PATH_CNTL, host_path_cntl | HDP_SOFT_RESET);
2488c2ecf20Sopenharmony_ci	INREG(HOST_PATH_CNTL);
2498c2ecf20Sopenharmony_ci	OUTREG(HOST_PATH_CNTL, host_path_cntl);
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci	if (!IS_R300_VARIANT(rinfo))
2528c2ecf20Sopenharmony_ci		OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset);
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci	OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index);
2558c2ecf20Sopenharmony_ci	OUTPLL(MCLK_CNTL, mclk_cntl);
2568c2ecf20Sopenharmony_ci}
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_civoid radeonfb_engine_init (struct radeonfb_info *rinfo)
2598c2ecf20Sopenharmony_ci{
2608c2ecf20Sopenharmony_ci	unsigned long temp;
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci	/* disable 3D engine */
2638c2ecf20Sopenharmony_ci	OUTREG(RB3D_CNTL, 0);
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	radeonfb_engine_reset(rinfo);
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci	radeon_fifo_wait (1);
2688c2ecf20Sopenharmony_ci	if (IS_R300_VARIANT(rinfo)) {
2698c2ecf20Sopenharmony_ci		OUTREG(RB2D_DSTCACHE_MODE, INREG(RB2D_DSTCACHE_MODE) |
2708c2ecf20Sopenharmony_ci		       RB2D_DC_AUTOFLUSH_ENABLE |
2718c2ecf20Sopenharmony_ci		       RB2D_DC_DC_DISABLE_IGNORE_PE);
2728c2ecf20Sopenharmony_ci	} else {
2738c2ecf20Sopenharmony_ci		/* This needs to be double checked with ATI. Latest X driver
2748c2ecf20Sopenharmony_ci		 * completely "forgets" to set this register on < r3xx, and
2758c2ecf20Sopenharmony_ci		 * we used to just write 0 there... I'll keep the 0 and update
2768c2ecf20Sopenharmony_ci		 * that when we have sorted things out on X side.
2778c2ecf20Sopenharmony_ci		 */
2788c2ecf20Sopenharmony_ci		OUTREG(RB2D_DSTCACHE_MODE, 0);
2798c2ecf20Sopenharmony_ci	}
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci	radeon_fifo_wait (3);
2828c2ecf20Sopenharmony_ci	/* We re-read MC_FB_LOCATION from card as it can have been
2838c2ecf20Sopenharmony_ci	 * modified by XFree drivers (ouch !)
2848c2ecf20Sopenharmony_ci	 */
2858c2ecf20Sopenharmony_ci	rinfo->fb_local_base = INREG(MC_FB_LOCATION) << 16;
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci	OUTREG(DEFAULT_PITCH_OFFSET, (rinfo->pitch << 0x16) |
2888c2ecf20Sopenharmony_ci				     (rinfo->fb_local_base >> 10));
2898c2ecf20Sopenharmony_ci	OUTREG(DST_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10));
2908c2ecf20Sopenharmony_ci	OUTREG(SRC_PITCH_OFFSET, (rinfo->pitch << 0x16) | (rinfo->fb_local_base >> 10));
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci	radeon_fifo_wait (1);
2938c2ecf20Sopenharmony_ci#if defined(__BIG_ENDIAN)
2948c2ecf20Sopenharmony_ci	OUTREGP(DP_DATATYPE, HOST_BIG_ENDIAN_EN, ~HOST_BIG_ENDIAN_EN);
2958c2ecf20Sopenharmony_ci#else
2968c2ecf20Sopenharmony_ci	OUTREGP(DP_DATATYPE, 0, ~HOST_BIG_ENDIAN_EN);
2978c2ecf20Sopenharmony_ci#endif
2988c2ecf20Sopenharmony_ci	radeon_fifo_wait (2);
2998c2ecf20Sopenharmony_ci	OUTREG(DEFAULT_SC_TOP_LEFT, 0);
3008c2ecf20Sopenharmony_ci	OUTREG(DEFAULT_SC_BOTTOM_RIGHT, (DEFAULT_SC_RIGHT_MAX |
3018c2ecf20Sopenharmony_ci					 DEFAULT_SC_BOTTOM_MAX));
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	temp = radeon_get_dstbpp(rinfo->depth);
3048c2ecf20Sopenharmony_ci	rinfo->dp_gui_master_cntl = ((temp << 8) | GMC_CLR_CMP_CNTL_DIS);
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci	radeon_fifo_wait (1);
3078c2ecf20Sopenharmony_ci	OUTREG(DP_GUI_MASTER_CNTL, (rinfo->dp_gui_master_cntl |
3088c2ecf20Sopenharmony_ci				    GMC_BRUSH_SOLID_COLOR |
3098c2ecf20Sopenharmony_ci				    GMC_SRC_DATATYPE_COLOR));
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci	radeon_fifo_wait (7);
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	/* clear line drawing regs */
3148c2ecf20Sopenharmony_ci	OUTREG(DST_LINE_START, 0);
3158c2ecf20Sopenharmony_ci	OUTREG(DST_LINE_END, 0);
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	/* set brush color regs */
3188c2ecf20Sopenharmony_ci	OUTREG(DP_BRUSH_FRGD_CLR, 0xffffffff);
3198c2ecf20Sopenharmony_ci	OUTREG(DP_BRUSH_BKGD_CLR, 0x00000000);
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci	/* set source color regs */
3228c2ecf20Sopenharmony_ci	OUTREG(DP_SRC_FRGD_CLR, 0xffffffff);
3238c2ecf20Sopenharmony_ci	OUTREG(DP_SRC_BKGD_CLR, 0x00000000);
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci	/* default write mask */
3268c2ecf20Sopenharmony_ci	OUTREG(DP_WRITE_MSK, 0xffffffff);
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci	radeon_engine_idle ();
3298c2ecf20Sopenharmony_ci}
330