pipe-loader: introduce pipe_loader_sw_probe_null helper function
[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 struct drisw_loader_funcs;
48
49 enum pipe_loader_device_type {
50 PIPE_LOADER_DEVICE_SOFTWARE,
51 PIPE_LOADER_DEVICE_PCI,
52 PIPE_LOADER_DEVICE_PLATFORM,
53 NUM_PIPE_LOADER_DEVICE_TYPES
54 };
55
56 /**
57 * A device known to the pipe loader.
58 */
59 struct pipe_loader_device {
60 enum pipe_loader_device_type type;
61
62 union {
63 struct {
64 int vendor_id;
65 int chip_id;
66 } pci;
67 } u; /**< Discriminated by \a type */
68
69 const char *driver_name;
70 const struct pipe_loader_ops *ops;
71 };
72
73 /**
74 * Get a list of known devices.
75 *
76 * \param devs Array that will be filled with pointers to the devices
77 * available in the system.
78 * \param ndev Maximum number of devices to return.
79 * \return Number of devices available in the system.
80 */
81 int
82 pipe_loader_probe(struct pipe_loader_device **devs, int ndev);
83
84 /**
85 * Create a pipe_screen for the specified device.
86 *
87 * \param dev Device the screen will be created for.
88 * \param library_paths Colon-separated list of filesystem paths that
89 * will be used to look for the pipe driver
90 * module that handles this device.
91 */
92 struct pipe_screen *
93 pipe_loader_create_screen(struct pipe_loader_device *dev,
94 const char *library_paths);
95
96 /**
97 * Release resources allocated for a list of devices.
98 *
99 * Should be called when the specified devices are no longer in use to
100 * release any resources allocated by pipe_loader_probe.
101 *
102 * \param devs Devices to release.
103 * \param ndev Number of devices to release.
104 */
105 void
106 pipe_loader_release(struct pipe_loader_device **devs, int ndev);
107
108 #ifdef HAVE_WINSYS_XLIB
109
110 /**
111 * Initialize Xlib for an associated display.
112 *
113 * This function is platform-specific.
114 *
115 * \sa pipe_loader_probe
116 */
117 bool
118 pipe_loader_sw_probe_xlib(struct pipe_loader_device **devs, Display *display);
119
120 #endif
121
122 /**
123 * Initialize sw dri device give the drisw_loader_funcs.
124 *
125 * This function is platform-specific.
126 *
127 * \sa pipe_loader_probe
128 */
129 bool
130 pipe_loader_sw_probe_dri(struct pipe_loader_device **devs,
131 struct drisw_loader_funcs *drisw_lf);
132
133
134 /**
135 * Initialize a null sw device.
136 *
137 * This function is platform-specific.
138 *
139 * \sa pipe_loader_probe
140 */
141 bool
142 pipe_loader_sw_probe_null(struct pipe_loader_device **devs);
143
144 /**
145 * Get a list of known software devices.
146 *
147 * This function is platform-specific.
148 *
149 * \sa pipe_loader_probe
150 */
151 int
152 pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev);
153
154 #ifdef HAVE_PIPE_LOADER_DRM
155
156 /**
157 * Get a list of known DRM devices.
158 *
159 * This function is platform-specific.
160 *
161 * \sa pipe_loader_probe
162 */
163 int
164 pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev);
165
166 /**
167 * Initialize a DRM device in an already opened fd.
168 *
169 * This function is platform-specific.
170 *
171 * \sa pipe_loader_probe
172 *
173 * \param auth_x If true, the pipe-loader will attempt to
174 * authenticate with the X server.
175 */
176 bool
177 pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd,
178 boolean auth_x);
179
180 #endif
181
182 #ifdef __cplusplus
183 }
184 #endif
185
186 #endif /* PIPE_LOADER_H */