mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 13:30:12 +01:00
util: Add a simple no-op libdrm shim
Make it easier to deal with build configs that do not have libdrm. Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Eric Engestrom <eric@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21636>
This commit is contained in:
parent
b73b701579
commit
e05abb1345
1 changed files with 80 additions and 0 deletions
80
src/util/libdrm.h
Normal file
80
src/util/libdrm.h
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright © 2023 Google, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* A simple header that either gives you the real libdrm or a no-op shim,
|
||||
* depending on whether HAVE_LIBDRM is defined. This is intended to avoid
|
||||
* the proliferation of #ifdef'ery to support environments without libdrm.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_LIBDRM
|
||||
#include <xf86drm.h>
|
||||
#else
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#define DRM_NODE_PRIMARY 0
|
||||
#define DRM_NODE_CONTROL 1
|
||||
#define DRM_NODE_RENDER 2
|
||||
#define DRM_NODE_MAX 3
|
||||
|
||||
#define DRM_BUS_PCI 0
|
||||
#define DRM_BUS_USB 1
|
||||
#define DRM_BUS_PLATFORM 2
|
||||
#define DRM_BUS_HOST1X 3
|
||||
|
||||
typedef struct _drmDevice {
|
||||
char **nodes; /* DRM_NODE_MAX sized array */
|
||||
int available_nodes; /* DRM_NODE_* bitmask */
|
||||
int bustype;
|
||||
/* ... */
|
||||
} drmDevice, *drmDevicePtr;
|
||||
|
||||
static inline int
|
||||
drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices)
|
||||
{
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static inline void
|
||||
drmFreeDevices(drmDevicePtr devices[], int count) {}
|
||||
|
||||
typedef struct _drmVersion {
|
||||
int version_major; /**< Major version */
|
||||
int version_minor; /**< Minor version */
|
||||
int version_patchlevel; /**< Patch level */
|
||||
int name_len; /**< Length of name buffer */
|
||||
char *name; /**< Name of driver */
|
||||
int date_len; /**< Length of date buffer */
|
||||
char *date; /**< User-space buffer to hold date */
|
||||
int desc_len; /**< Length of desc buffer */
|
||||
char *desc; /**< User-space buffer to hold desc */
|
||||
} drmVersion, *drmVersionPtr;
|
||||
|
||||
static inline struct _drmVersion *
|
||||
drmGetVersion(int fd) { return NULL; }
|
||||
|
||||
static inline void
|
||||
drmFreeVersion(struct _drmVersion *v) {}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue