summaryrefslogtreecommitdiffstats
path: root/src/egl/drivers/xdri/driinit.c
blob: 3e54f0bd4d8be3e9550835bab68c0f3ee1cbae23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
 * DRI initialization.  The DRI loaders are defined in src/glx/x11/.
 */

#include <stdlib.h>
#include <sys/time.h>

#include "glxclient.h"
#include "driinit.h"

/* for __DRI_SYSTEM_TIME extension */
_X_HIDDEN int
__glXGetUST(int64_t * ust)
{
   struct timeval tv;

   if (ust == NULL) {
      return -EFAULT;
   }

   if (gettimeofday(&tv, NULL) == 0) {
      ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
      return 0;
   }
   else {
      return -errno;
   }
}

_X_HIDDEN GLboolean
__driGetMscRateOML(__DRIdrawable * draw,
                   int32_t * numerator, int32_t * denominator, void *private)
{
   return GL_FALSE;
}

/* ignore glx extensions */
_X_HIDDEN void
__glXEnableDirectExtension(__GLXscreenConfigs * psc, const char *name)
{
}

_X_HIDDEN __GLXDRIdisplay *
__driCreateDisplay(__GLXdisplayPrivate *dpyPriv, int *version)
{
   __GLXDRIdisplay *driDisplay = NULL;
   int ver = 0;
   char *env;
   int force_sw;

   env = getenv("EGL_SOFTWARE");
   force_sw = (env && *env != '0');

   /* try DRI2 first */
   if (!force_sw) {
      driDisplay = dri2CreateDisplay(dpyPriv->dpy);
      if (driDisplay) {
         /* fill in the required field */
         dpyPriv->dri2Display = driDisplay;
         ver = 2;
      }
   }

   /* and then DRI */
   if (!force_sw && !driDisplay) {
      driDisplay = driCreateDisplay(dpyPriv->dpy);
      if (driDisplay) {
         dpyPriv->driDisplay = driDisplay;
         ver = 1;
      }
   }

   /* and then DRISW */
   if (!driDisplay) {
      driDisplay = driswCreateDisplay(dpyPriv->dpy);
      if (driDisplay) {
         dpyPriv->driDisplay = driDisplay;
         ver = 0;
      }
   }

   if (version)
      *version = ver;
   return driDisplay;
}