1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 #include "main/glheader.h"
30 #include "pipe/p_thread.h"
31 #include <GL/internal/glcore.h>
32 #include "state_tracker/st_public.h"
33 #include "intel_context.h"
38 pipe_static_mutex( lockMutex
);
42 intelContendedLock(struct intel_context
*intel
, uint flags
)
44 __DRIdrawablePrivate
*dPriv
= intel
->driDrawable
;
45 __DRIscreenPrivate
*sPriv
= intel
->driScreen
;
46 struct intel_screen
*intelScreen
= intel_screen(sPriv
);
47 drmI830Sarea
*sarea
= intel
->sarea
;
49 drmGetLock(intel
->driFd
, intel
->hHWContext
, flags
);
51 DBG(LOCK
, "%s - got contended lock\n", __progname
);
53 /* If the window moved, may need to set a new cliprect now.
55 * NOTE: This releases and regains the hw lock, so all state
56 * checking must be done *after* this call:
59 DRI_VALIDATE_DRAWABLE_INFO(sPriv
, dPriv
);
61 if (sarea
->width
!= intelScreen
->front
.width
||
62 sarea
->height
!= intelScreen
->front
.height
) {
64 intelUpdateScreenRotation(sPriv
, sarea
);
69 /* Lock the hardware and validate our state.
71 void LOCK_HARDWARE( struct intel_context
*intel
)
75 pipe_mutex_lock(lockMutex
);
76 assert(!intel
->locked
);
78 DRM_CAS(intel
->driHwLock
, intel
->hHWContext
,
79 (DRM_LOCK_HELD
|intel
->hHWContext
), __ret
);
82 intelContendedLock( intel
, 0 );
84 DBG(LOCK
, "%s - locked\n", __progname
);
90 /* Unlock the hardware using the global current context
92 void UNLOCK_HARDWARE( struct intel_context
*intel
)
94 assert(intel
->locked
);
97 DRM_UNLOCK(intel
->driFd
, intel
->driHwLock
, intel
->hHWContext
);
99 pipe_mutex_unlock(lockMutex
);
101 DBG(LOCK
, "%s - unlocked\n", __progname
);