• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "state_tracker/drm_driver.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 struct pipe_screen;
44 struct drisw_loader_funcs;
45 
46 enum pipe_loader_device_type {
47    PIPE_LOADER_DEVICE_SOFTWARE,
48    PIPE_LOADER_DEVICE_PCI,
49    PIPE_LOADER_DEVICE_PLATFORM,
50    NUM_PIPE_LOADER_DEVICE_TYPES
51 };
52 
53 /**
54  * A device known to the pipe loader.
55  */
56 struct pipe_loader_device {
57    enum pipe_loader_device_type type;
58 
59    union {
60       struct {
61          int vendor_id;
62          int chip_id;
63       } pci;
64    } u; /**< Discriminated by \a type */
65 
66    char *driver_name;
67    const struct pipe_loader_ops *ops;
68 };
69 
70 /**
71  * Get a list of known devices.
72  *
73  * \param devs Array that will be filled with pointers to the devices
74  *             available in the system.
75  * \param ndev Maximum number of devices to return.
76  * \return Number of devices available in the system.
77  */
78 int
79 pipe_loader_probe(struct pipe_loader_device **devs, int ndev);
80 
81 /**
82  * Create a pipe_screen for the specified device.
83  *
84  * \param dev Device the screen will be created for.
85  */
86 struct pipe_screen *
87 pipe_loader_create_screen(struct pipe_loader_device *dev);
88 
89 /**
90  * Query the configuration parameters for the specified device.
91  *
92  * \param dev Device that will be queried.
93  * \param conf The drm_conf id of the option to be queried.
94  */
95 const struct drm_conf_ret *
96 pipe_loader_configuration(struct pipe_loader_device *dev,
97                           enum drm_conf conf);
98 
99 /**
100  * Release resources allocated for a list of devices.
101  *
102  * Should be called when the specified devices are no longer in use to
103  * release any resources allocated by pipe_loader_probe.
104  *
105  * \param devs Devices to release.
106  * \param ndev Number of devices to release.
107  */
108 void
109 pipe_loader_release(struct pipe_loader_device **devs, int ndev);
110 
111 /**
112  * Initialize sw dri device give the drisw_loader_funcs.
113  *
114  * This function is platform-specific.
115  *
116  * \sa pipe_loader_probe
117  */
118 bool
119 pipe_loader_sw_probe_dri(struct pipe_loader_device **devs,
120                          struct drisw_loader_funcs *drisw_lf);
121 
122 /**
123  * Initialize a kms backed sw device given an fd.
124  *
125  * This function is platform-specific.
126  *
127  * \sa pipe_loader_probe
128  */
129 bool
130 pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, int fd);
131 
132 /**
133  * Initialize a null sw device.
134  *
135  * This function is platform-specific.
136  *
137  * \sa pipe_loader_probe
138  */
139 bool
140 pipe_loader_sw_probe_null(struct pipe_loader_device **devs);
141 
142 /**
143  * Get a list of known software devices.
144  *
145  * This function is platform-specific.
146  *
147  * \sa pipe_loader_probe
148  */
149 int
150 pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev);
151 
152 /**
153  * Get a software device wrapped atop another device.
154  *
155  * This function is platform-specific.
156  *
157  * \sa pipe_loader_probe
158  */
159 boolean
160 pipe_loader_sw_probe_wrapped(struct pipe_loader_device **dev,
161                              struct pipe_screen *screen);
162 
163 /**
164  * Get a list of known DRM devices.
165  *
166  * This function is platform-specific.
167  *
168  * \sa pipe_loader_probe
169  */
170 int
171 pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev);
172 
173 /**
174  * Initialize a DRM device in an already opened fd.
175  *
176  * This function is platform-specific.
177  *
178  * \sa pipe_loader_probe
179  */
180 bool
181 pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd);
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif /* PIPE_LOADER_H */
188