1 /*
2  * Copyright © 2023 Google, Inc.
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, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  */
23 
24 /*
25  * A simple header that either gives you the real libdrm or a no-op shim,
26  * depending on whether HAVE_LIBDRM is defined.  This is intended to avoid
27  * the proliferation of #ifdef'ery to support environments without libdrm.
28  */
29 
30 #ifdef HAVE_LIBDRM
31 #include <xf86drm.h>
32 #else
33 
34 #include <errno.h>
35 
36 #define DRM_NODE_PRIMARY 0
37 #define DRM_NODE_CONTROL 1
38 #define DRM_NODE_RENDER  2
39 #define DRM_NODE_MAX     3
40 
41 #define DRM_BUS_PCI       0
42 #define DRM_BUS_USB       1
43 #define DRM_BUS_PLATFORM  2
44 #define DRM_BUS_HOST1X    3
45 
46 typedef struct _drmDevice {
47     char **nodes; /* DRM_NODE_MAX sized array */
48     int available_nodes; /* DRM_NODE_* bitmask */
49     int bustype;
50     /* ... */
51 } drmDevice, *drmDevicePtr;
52 
53 static inline int
drmGetDevices2(uint32_t flags,drmDevicePtr devices[],int max_devices)54 drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices)
55 {
56    return -ENOENT;
57 }
58 
59 static inline void
drmFreeDevices(drmDevicePtr devices[],int count)60 drmFreeDevices(drmDevicePtr devices[], int count) {}
61 
62 typedef struct _drmVersion {
63     int     version_major;        /**< Major version */
64     int     version_minor;        /**< Minor version */
65     int     version_patchlevel;   /**< Patch level */
66     int     name_len;             /**< Length of name buffer */
67     char    *name;                /**< Name of driver */
68     int     date_len;             /**< Length of date buffer */
69     char    *date;                /**< User-space buffer to hold date */
70     int     desc_len;             /**< Length of desc buffer */
71     char    *desc;                /**< User-space buffer to hold desc */
72 } drmVersion, *drmVersionPtr;
73 
74 static inline struct _drmVersion *
drmGetVersion(int fd)75 drmGetVersion(int fd) { return NULL; }
76 
77 static inline void
drmFreeVersion(struct _drmVersion * v)78 drmFreeVersion(struct _drmVersion *v) {}
79 
80 #endif
81