drm_radeon_cmd_buffer_t * cmdbuf, int n) 
drm_radeon_kcmd_buffer_t * cmdbuf, int n) 
static int r300_emit_cliprects(drm_radeon_private_t * dev_priv,			       drm_radeon_cmd_buffer_t * cmdbuf, int n){	drm_clip_rect_t box;	int nr;	int i;	RING_LOCALS;	nr = cmdbuf->nbox - n;	if (nr > R300_SIMULTANEOUS_CLIPRECTS)		nr = R300_SIMULTANEOUS_CLIPRECTS;	DRM_DEBUG("%i cliprects\n", nr);	if (nr) {		BEGIN_RING(6 + nr * 2);		OUT_RING(CP_PACKET0(R300_RE_CLIPRECT_TL_0, nr * 2 - 1));		for (i = 0; i < nr; ++i) {			if (DRM_COPY_FROM_USER_UNCHECKED			    (&box, &cmdbuf->boxes[n + i], sizeof(box))) {				DRM_ERROR("copy cliprect faulted\n");				return DRM_ERR(EFAULT);			}			box.x1 =			    (box.x1 +			     R300_CLIPRECT_OFFSET) & R300_CLIPRECT_MASK;			box.y1 =			    (box.y1 +			     R300_CLIPRECT_OFFSET) & R300_CLIPRECT_MASK;			box.x2 =			    (box.x2 +			     R300_CLIPRECT_OFFSET) & R300_CLIPRECT_MASK;			box.y2 =			    (box.y2 +			     R300_CLIPRECT_OFFSET) & R300_CLIPRECT_MASK;			OUT_RING((box.x1 << R300_CLIPRECT_X_SHIFT) |				 (box.y1 << R300_CLIPRECT_Y_SHIFT));			OUT_RING((box.x2 << R300_CLIPRECT_X_SHIFT) |				 (box.y2 << R300_CLIPRECT_Y_SHIFT));		}		OUT_RING_REG(R300_RE_CLIPRECT_CNTL, r300_cliprect_cntl[nr - 1]);		/* TODO/SECURITY: Force scissors to a safe value, otherwise the		 * client might be able to trample over memory.		 * The impact should be very limited, but I'd rather be safe than		 * sorry.		 */		OUT_RING(CP_PACKET0(R300_RE_SCISSORS_TL, 1));		OUT_RING(0);		OUT_RING(R300_SCISSORS_X_MASK | R300_SCISSORS_Y_MASK);		ADVANCE_RING();	} else {		/* Why we allow zero cliprect rendering:		 * There are some commands in a command buffer that must be submitted		 * even when there are no cliprects, e.g. DMA buffer discard		 * or state setting (though state setting could be avoided by		 * simulating a loss of context).		 *		 * Now since the cmdbuf interface is so chaotic right now (and is		 * bound to remain that way for a bit until things settle down),		 * it is basically impossible to filter out the commands that are		 * necessary and those that aren't.		 *		 * So I choose the safe way and don't do any filtering at all;		 * instead, I simply set up the engine so that all rendering		 * can't produce any fragments.		 */		BEGIN_RING(2);		OUT_RING_REG(R300_RE_CLIPRECT_CNTL, 0);		ADVANCE_RING();	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/b3a83639895a422b25f72eec0a5d1d88c3ac4e9e/r300_cmdbuf.c/buggy/drivers/char/drm/r300_cmdbuf.c