pipe-loader: introduce pipe_loader_sw_probe_xlib helper
[mesa.git] / src / gallium / auxiliary / pipe-loader / pipe_loader.h
1 /**************************************************************************
2 *
3 * Copyright 2012 Francisco Jerez
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
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /**
29 * \file Library that provides device enumeration and creation of
30 * winsys/pipe_screen instances.
31 */
32
33 #ifndef PIPE_LOADER_H
34 #define PIPE_LOADER_H
35
36 #include "pipe/p_compiler.h"
37
38 #ifdef HAVE_WINSYS_XLIB
39 #include <X11/Xlib.h>
40 #endif
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 struct pipe_screen;
47
48 enum pipe_loader_device_type {
49 PIPE_LOADER_DEVICE_SOFTWARE,
50 PIPE_LOADER_DEVICE_PCI,
51 PIPE_LOADER_DEVICE_PLATFORM,
52 NUM_PIPE_LOADER_DEVICE_TYPES
53 };
54
55 /**
56 * A device known to the pipe loader.
57 */
58 struct pipe_loader_device {
59 enum pipe_loader_device_type type;
60
61 union {
62 struct {
63 int vendor_id;
64 int chip_id;
65 } pci;
66 } u; /**< Discriminated by \a type */
67
68 const char *driver_name;
69 const struct pipe_loader_ops *ops;
70 };
71
72 /**
73 * Get a list of known devices.
74 *
75 * \param devs Array that will be filled with pointers to the devices
76 * available in the system.
77 * \param ndev Maximum number of devices to return.
78 * \return Number of devices available in the system.
79 */
80 int
81 pipe_loader_probe(struct pipe_loader_device **devs, int ndev);
82
83 /**
84 * Create a pipe_screen for the specified device.
85 *
86 * \param dev Device the screen will be created for.
87 * \param library_paths Colon-separated list of filesystem paths that
88 * will be used to look for the pipe driver
89 * module that handles this device.
90 */
91 struct pipe_screen *
92 pipe_loader_create_screen(struct pipe_loader_device *dev,
93 const char *library_paths);
94
95 /**
96 * Release resources allocated for a list of devices.
97 *
98 * Should be called when the specified devices are no longer in use to
99 * release any resources allocated by pipe_loader_probe.
100 *
101 * \param devs Devices to release.
102 * \param ndev Number of devices to release.
103 */
104 void
105 pipe_loader_release(struct pipe_loader_device **devs, int ndev);
106
107 #ifdef HAVE_WINSYS_XLIB
108
109 /**
110 * Initialize Xlib for an associated display.
111 *
112 * This function is platform-specific.
113 *
114 * \sa pipe_loader_probe
115 */
116 bool
117 pipe_loader_sw_probe_xlib(struct pipe_loader_device **devs, Display *display);
118
119 #endif
120
121 /**
122 * Get a list of known software devices.
123 *
124 * This function is platform-specific.
125 *
126 * \sa pipe_loader_probe
127 */
128 int
129 pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev);
130
131 #ifdef HAVE_PIPE_LOADER_DRM
132
133 /**
134 * Get a list of known DRM devices.
135 *
136 * This function is platform-specific.
137 *
138 * \sa pipe_loader_probe
139 */
140 int
141 pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev);
142
143 /**
144 * Initialize a DRM device in an already opened fd.
145 *
146 * This function is platform-specific.
147 *
148 * \sa pipe_loader_probe
149 *
150 * \param auth_x If true, the pipe-loader will attempt to
151 * authenticate with the X server.
152 */
153 bool
154 pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd,
155 boolean auth_x);
156
157 #endif
158
159 #ifdef __cplusplus
160 }
161 #endif
162
163 #endif /* PIPE_LOADER_H */