1 /* -*- mode: c; c-basic-offset: 3 -*-
3 * Copyright 2000 VA Linux Systems Inc., Fremont, California.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
32 * Gareth Hughes <gareth@valinux.com>
36 #ifndef __TDFX_LOCK_H__
37 #define __TDFX_LOCK_H__
39 /* You can turn this on to find locking conflicts.
41 #define DEBUG_LOCKING 0
44 extern char *prevLockFile
;
45 extern int prevLockLine
;
47 #define DEBUG_LOCK() \
49 prevLockFile = (__FILE__); \
50 prevLockLine = (__LINE__); \
53 #define DEBUG_RESET() \
59 #define DEBUG_CHECK_LOCK() \
61 if ( prevLockFile ) { \
63 "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
64 prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
73 #define DEBUG_CHECK_LOCK()
75 #endif /* DEBUG_LOCKING */
78 extern void tdfxGetLock( tdfxContextPtr fxMesa
);
81 /* !!! We may want to separate locks from locks with validation.
82 This could be used to improve performance for those things
83 commands that do not do any drawing !!! */
85 #define DRM_LIGHT_LOCK_RETURN(fd,lock,context,__ret) \
87 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
88 if (__ret) drmGetLock(fd,context,0); \
91 #define LOCK_HARDWARE( fxMesa ) \
96 DRM_CAS( fxMesa->driHwLock, fxMesa->hHWContext, \
97 DRM_LOCK_HELD | fxMesa->hHWContext, __ret ); \
99 tdfxGetLock( fxMesa ); \
104 /* Unlock the hardware using the global current context */
105 #define UNLOCK_HARDWARE( fxMesa ) \
107 DRM_UNLOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext ); \
112 * This pair of macros makes a loop over the drawing operations
113 * so it is not self contained and doesn't have the nice single
114 * statement semantics of most macros.
116 #define BEGIN_CLIP_LOOP(fxMesa) \
118 LOCK_HARDWARE( fxMesa ); \
119 BEGIN_CLIP_LOOP_LOCKED( fxMesa )
121 #define BEGIN_CLIP_LOOP_LOCKED(fxMesa) \
123 int _nc = fxMesa->numClipRects; \
125 if (fxMesa->numClipRects > 1) { \
126 int _height = fxMesa->screen_height; \
127 fxMesa->Glide.grClipWindow(fxMesa->pClipRects[_nc].x1, \
128 _height - fxMesa->pClipRects[_nc].y2, \
129 fxMesa->pClipRects[_nc].x2, \
130 _height - fxMesa->pClipRects[_nc].y1); \
134 #define END_CLIP_LOOP_LOCKED( fxMesa ) \
138 #define END_CLIP_LOOP( fxMesa ) \
139 END_CLIP_LOOP_LOCKED( fxMesa ); \
140 UNLOCK_HARDWARE( fxMesa ); \
143 #endif /* __TDFX_LOCK_H__ */