Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / mesa / drivers / dri / common / vblank.h
1 /* -*- mode: c; c-basic-offset: 3 -*- */
2 /*
3  * (c) Copyright IBM Corporation 2002
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * on the rights to use, copy, modify, merge, publish, distribute, sub
10  * license, and/or sell copies of the Software, and to permit persons to whom
11  * the Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the next
14  * paragraph) shall be included in all copies or substantial portions of the
15  * 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 NON-INFRINGEMENT.  IN NO EVENT SHALL
20  * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
21  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23  * USE OR OTHER DEALINGS IN THE SOFTWARE.
24  *
25  * Authors:
26  *    Ian Romanick <idr@us.ibm.com>
27  */
28
29 #ifndef DRI_VBLANK_H
30 #define DRI_VBLANK_H
31
32 #include "main/context.h"
33 #include "dri_util.h"
34 #include "xmlconfig.h"
35
36 #define VBLANK_FLAG_INTERVAL  (1U << 0)  /* Respect the swap_interval setting
37                                           */
38 #define VBLANK_FLAG_THROTTLE  (1U << 1)  /* Wait 1 refresh since last call.
39                                           */
40 #define VBLANK_FLAG_SYNC      (1U << 2)  /* Sync to the next refresh.
41                                           */
42 #define VBLANK_FLAG_NO_IRQ    (1U << 7)  /* DRM has no IRQ to wait on.
43                                           */
44 #define VBLANK_FLAG_SECONDARY (1U << 8)  /* Wait for secondary vblank.
45                                           */
46
47 extern int driGetMSC32( __DRIscreen * priv, int64_t * count );
48 extern int driDrawableGetMSC32( __DRIscreen * priv,
49                                 __DRIdrawable * drawablePrivate,
50                                 int64_t * count);
51 extern int driWaitForMSC32( __DRIdrawable *priv,
52     int64_t target_msc, int64_t divisor, int64_t remainder, int64_t * msc );
53 extern GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache );
54 extern void driDrawableInitVBlank ( __DRIdrawable *priv );
55 extern unsigned driGetVBlankInterval( const  __DRIdrawable *priv );
56 extern void driGetCurrentVBlank( __DRIdrawable *priv );
57 extern int driWaitForVBlank( __DRIdrawable *priv,
58                              GLboolean * missed_deadline );
59
60 #undef usleep
61 #include <unistd.h>  /* for usleep() */
62 #include <sched.h>   /* for sched_yield() */
63
64 #define DO_USLEEP(nr)                                                   \
65    do {                                                                 \
66       if (0) fprintf(stderr, "%s: usleep for %u\n", __FUNCTION__, nr ); \
67       if (1) usleep( nr );                                              \
68       sched_yield();                                                    \
69    } while( 0 )
70
71 #endif /* DRI_VBLANK_H */