Subversion Repositories Kolibri OS

Rev

Rev 4358 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4358 Serge 1
/*
2
 * Copyright © 2011 Intel Corporation
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 * copy of this software and associated documentation files (the "Software"),
6
 * to deal in the Software without restriction, including without limitation
7
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
 * and/or sell copies of the Software, and to permit persons to whom the
9
 * Software is furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice (including the next
12
 * paragraph) shall be included in all copies or substantial portions of the
13
 * Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
 * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 * DEALINGS IN THE SOFTWARE.
23
 *
24
 * Authors:
25
 *    Benjamin Franzke 
26
 */
27
 
28
#include "gbm_gallium_drmint.h"
29
 
30
#include "util/u_memory.h"
31
#include "util/u_inlines.h"
32
#include "pipe-loader/pipe_loader.h"
33
 
34
static const char *
35
get_library_search_path(void)
36
{
5080 serge 37
   const char *search_path;
4358 Serge 38
 
5080 serge 39
   search_path = "/kolibrios/drivers/gallium-pipe/";
4358 Serge 40
 
41
   return search_path;
42
}
43
 
44
int
45
gallium_screen_create(struct gbm_gallium_drm_device *gdrm)
46
{
47
   struct pipe_loader_device *dev;
48
#ifdef HAVE_PIPE_LOADER_DRM
49
   int ret;
50
 
51
   ret = pipe_loader_drm_probe_fd(&dev, gdrm->base.base.fd);
52
   if (!ret)
53
      return -1;
54
#endif /* HAVE_PIPE_LOADER_DRM */
55
 
56
   gdrm->screen = pipe_loader_create_screen(dev, get_library_search_path());
57
   if (gdrm->screen == NULL) {
58
      debug_printf("failed to load driver: %s\n", gdrm->base.driver_name);
59
      pipe_loader_release(&dev, 1);
60
      return -1;
61
   };
62
 
63
   gdrm->driver = dev;
64
   gdrm->base.driver_name = strdup(dev->driver_name);
65
   return 0;
66
}
67
 
68
void
69
gallium_screen_destroy(struct gbm_gallium_drm_device *gdrm)
70
{
71
   FREE(gdrm->base.driver_name);
72
   gdrm->screen->destroy(gdrm->screen);
73
   pipe_loader_release((struct pipe_loader_device **)&gdrm->driver, 1);
74
}
75
 
76
GBM_EXPORT struct gbm_backend gbm_backend = {
77
   .backend_name = "gallium_drm",
78
   .create_device = gbm_gallium_drm_device_create,
79
};