Subversion Repositories Kolibri OS

Rev

Rev 4401 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4401 Rev 5080
Line 25... Line 25...
25
#include 
25
#include 
26
#include 
26
#include 
27
#include 
27
#include 
28
#include 
28
#include 
29
#include 
29
#include 
-
 
30
#include 
Line 30... Line 31...
30
 
31
 
31
#include "util/u_memory.h"
32
#include "util/u_memory.h"
Line 32... Line 33...
32
#include "egllog.h"
33
#include "egllog.h"
Line 136... Line 137...
136
 
137
 
Line 137... Line 138...
137
   FREE(drmdpy->device_name);
138
   FREE(drmdpy->device_name);
138
 
139
 
139
   if (drmdpy->own_gbm) {
-
 
140
      gbm_device_destroy(&drmdpy->gbmdrm->base.base);
-
 
141
      if (drmdpy->fd >= 0)
140
   if (drmdpy->own_gbm) {
Line 142... Line 141...
142
         close(drmdpy->fd);
141
      gbm_device_destroy(&drmdpy->gbmdrm->base.base);
143
   }
142
   }
Line 154... Line 153...
154
static char *
153
static char *
155
drm_get_device_name(int fd)
154
drm_get_device_name(int fd)
156
{
155
{
157
   char *device_name = NULL;
156
   char *device_name = NULL;
158
#ifdef HAVE_LIBUDEV
157
#ifdef HAVE_LIBUDEV
159
   struct udev *udev;
-
 
160
   struct udev_device *device;
-
 
161
   struct stat buf;
-
 
162
   const char *tmp;
-
 
163
 
-
 
164
   udev = udev_new();
-
 
165
   if (fstat(fd, &buf) < 0) {
-
 
166
      _eglLog(_EGL_WARNING, "failed to stat fd %d", fd);
-
 
167
      goto outudev;
-
 
168
   }
-
 
169
 
-
 
170
   device = udev_device_new_from_devnum(udev, 'c', buf.st_rdev);
-
 
171
   if (device == NULL) {
-
 
172
      _eglLog(_EGL_WARNING,
-
 
173
              "could not create udev device for fd %d", fd);
-
 
174
      goto outdevice;
-
 
175
   }
-
 
176
 
-
 
177
   tmp = udev_device_get_devnode(device);
-
 
178
   if (!tmp)
-
 
179
      goto outdevice;
-
 
180
   device_name = strdup(tmp);
-
 
181
 
-
 
182
outdevice:
-
 
183
   udev_device_unref(device);
-
 
184
outudev:
-
 
185
   udev_unref(udev);
-
 
186
 
-
 
187
#endif
158
#endif
188
   return device_name;
159
   return device_name;
189
}
160
}
Line 190... Line 161...
190
 
161
 
Line 312... Line 283...
312
   int own_gbm = 0;
283
   int own_gbm = 0;
Line 313... Line 284...
313
 
284
 
Line 314... Line 285...
314
   gbm = dpy;
285
   gbm = dpy;
315
 
-
 
316
   if (gbm == NULL) {
-
 
317
      const char *device_name="/dev/dri/card0";
286
 
318
#ifdef O_CLOEXEC
287
   if (gbm == NULL) {
319
      fd = open(device_name, O_RDWR | O_CLOEXEC);
-
 
320
      if (fd == -1 && errno == EINVAL)
-
 
321
#endif
-
 
322
      {
288
      fd = get_service("DISPLAY");
323
         fd = open(device_name, O_RDWR);
-
 
324
         if (fd != -1)
289
      if (fd == NULL)
325
            fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
290
        return NULL;
326
      }
291
 
327
      /* FIXME: Use an internal constructor to create a gbm
292
      /* FIXME: Use an internal constructor to create a gbm
328
       * device with gallium backend directly, without setenv */
293
       * device with gallium backend directly, without setenv */
329
      setenv("GBM_BACKEND", "gbm_gallium_drm.so", 1);
294
//      setenv("GBM_BACKEND", "gbm_gallium_drm.so", 1);
330
      gbm = gbm_gallium_drm_device(gbm_create_device(fd));
295
      gbm = gbm_gallium_drm_device(gbm_create_device(fd));
Line 331... Line 296...
331
      own_gbm = 1;
296
      own_gbm = 1;