00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "main/glheader.h"
00030 #include "pipe/p_thread.h"
00031 #include <GL/internal/glcore.h>
00032 #include "state_tracker/st_public.h"
00033 #include "intel_context.h"
00034 #include "i830_dri.h"
00035
00036
00037
00038 pipe_static_mutex( lockMutex );
00039
00040
00041 static void
00042 intelContendedLock(struct intel_context *intel, uint flags)
00043 {
00044 __DRIdrawablePrivate *dPriv = intel->driDrawable;
00045 __DRIscreenPrivate *sPriv = intel->driScreen;
00046 struct intel_screen *intelScreen = intel_screen(sPriv);
00047 drmI830Sarea *sarea = intel->sarea;
00048
00049 drmGetLock(intel->driFd, intel->hHWContext, flags);
00050
00051 DBG(LOCK, "%s - got contended lock\n", __progname);
00052
00053
00054
00055
00056
00057
00058 if (dPriv)
00059 DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
00060
00061 if (sarea->width != intelScreen->front.width ||
00062 sarea->height != intelScreen->front.height) {
00063
00064 intelUpdateScreenRotation(sPriv, sarea);
00065 }
00066 }
00067
00068
00069
00070
00071 void LOCK_HARDWARE( struct intel_context *intel )
00072 {
00073 char __ret = 0;
00074
00075 pipe_mutex_lock(lockMutex);
00076 assert(!intel->locked);
00077
00078 DRM_CAS(intel->driHwLock, intel->hHWContext,
00079 (DRM_LOCK_HELD|intel->hHWContext), __ret);
00080
00081 if (__ret)
00082 intelContendedLock( intel, 0 );
00083
00084 DBG(LOCK, "%s - locked\n", __progname);
00085
00086 intel->locked = 1;
00087 }
00088
00089
00090
00091
00092 void UNLOCK_HARDWARE( struct intel_context *intel )
00093 {
00094 assert(intel->locked);
00095 intel->locked = 0;
00096
00097 DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
00098
00099 pipe_mutex_unlock(lockMutex);
00100
00101 DBG(LOCK, "%s - unlocked\n", __progname);
00102 }