ffb_fifo.h revision dbbd9e4b
1/*
2 * Acceleration for the Creator and Creator3D framebuffer - fifo macros.
3 *
4 * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
5 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20 * JAKUB JELINEK OR DAVID MILLER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 * IN THE SOFTWARE.
24 */
25/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_fifo.h,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
26
27#ifndef FFBFIFO_H
28#define FFBFIFO_H
29
30#include "ffb.h"
31
32/* This is the smallest FFB fifo size I know of. -DaveM */
33#define FFB_FIFO_MIN	124
34
35#define FFBFifo(__fpriv, __n) \
36do { 	int __cur_slots = (__fpriv)->fifo_cache; \
37	if((__cur_slots - (__n)) < 0) { \
38		ffb_fbcPtr __ffb = pFfb->regs; \
39		do {	__cur_slots = (((int)__ffb->ucsr & FFB_UCSR_FIFO_MASK) - 4); \
40		} while((__cur_slots - (__n)) < 0); \
41	} (__fpriv)->fifo_cache = (__cur_slots - (__n)); \
42} while(0)
43
44/* While we are polling for the raster processor to idle, cache the
45 * fifo count as well.
46 */
47#define FFBWait(__fpriv, __ffb) \
48if ((__fpriv)->rp_active != 0) { \
49	unsigned int __regval = (__ffb)->ucsr; \
50	while((__regval & FFB_UCSR_RP_BUSY) != 0) { \
51		__regval = (__ffb)->ucsr; \
52	} \
53	(__fpriv)->fifo_cache = ((int)(__regval & FFB_UCSR_FIFO_MASK)) - 4; \
54	(__fpriv)->rp_active = 0; \
55} while(0)
56
57/* DEBUGGING:  You can use this if you suspect corruption is occuring
58 *             because someone is touching the framebuffer while the
59 *	       raster processor is active.  If you enable this and the
60 *	       problem goes away, odds are your suspicions are correct.
61 */
62#undef FORCE_WAIT_EVERY_ROP
63#ifdef FORCE_WAIT_EVERY_ROP
64#define FFBSync(__fpriv, __ffb)	FFBWait(__fpriv, __ffb)
65#else
66#define FFBSync(__fpriv, __ffb)	do { } while(0)
67#endif
68
69#endif /* FFBFIFO_H */
70