xserver/msutil/drm_defines.h
stefan11111 d79cae9bb4 treewide: Add and use fallbacks for libdrm and libgbm
Similar to https://github.com/X11Libre/xserver/pull/2296

Signed-off-by: stefan11111 <stefan11111github@gmail.com>
2026-09-09 11:33:33 +02:00

142 lines
3.8 KiB
C

/* SPDX-License-Identifier: MIT OR X11
*
* Copyright © 2026 stefan11111 <stefan11111@shitposting.expert>
*/
#ifndef __DRM_DEFINES_H__
#define __DRM_DEFINES_H__
#ifdef WITH_LIBDRM
#include <drm_fourcc.h>
#else
/* libdrm compat */
#define DRM_FORMAT_C8 0x20203843
#define DRM_FORMAT_R8 0x20203852
#define DRM_FORMAT_G8 0x20203847
#define DRM_FORMAT_RGB565 0x36314752
#define DRM_FORMAT_BGR565 0x36314742
#define DRM_FORMAT_XRGB1555 0x35315258
#define DRM_FORMAT_XBGR1555 0x35314258
#define DRM_FORMAT_ARGB1555 0x35315241
#define DRM_FORMAT_ABGR1555 0x35314241
#define DRM_FORMAT_GR88 0x38385247
#define DRM_FORMAT_RGB888 0x34324752
#define DRM_FORMAT_BGR888 0x34324742
#define DRM_FORMAT_XRGB8888 0x34325258
#define DRM_FORMAT_XBGR8888 0x34324258
#define DRM_FORMAT_RGBX8888 0x34325852
#define DRM_FORMAT_BGRX8888 0x34325842
#define DRM_FORMAT_ARGB8888 0x34325241
#define DRM_FORMAT_ABGR8888 0x34324241
#define DRM_FORMAT_RGBA8888 0x34324152
#define DRM_FORMAT_BGRA8888 0x34324142
#define DRM_FORMAT_XRGB2101010 0x30335258
#define DRM_FORMAT_XBGR2101010 0x30334258
#define DRM_FORMAT_ARGB2101010 0x30335241
#define DRM_FORMAT_ABGR2101010 0x30334241
/* 64-bit HDR Formats */
#define DRM_FORMAT_XRGB16161616F 0x48345258
#define DRM_FORMAT_XBGR16161616F 0x48344258
#define DRM_FORMAT_ARGB16161616F 0x48345241
#define DRM_FORMAT_ABGR16161616F 0x48344241
#define DRM_FORMAT_XRGB16161616 0x38345258
#define DRM_FORMAT_XBGR16161616 0x38344258
#define DRM_FORMAT_ARGB16161616 0x38345241
#define DRM_FORMAT_ABGR16161616 0x38344241
#endif
/* Modifiers */
#ifndef DRM_FORMAT_MOD_LINEAR
#define DRM_FORMAT_MOD_LINEAR 0ULL
#endif
#ifndef DRM_FORMAT_MOD_INVALID
#define DRM_FORMAT_MOD_INVALID 0x00ffffffffffffffULL
#endif
/* DRM_CAP_* */
#ifndef DRM_CAP_DUMB_BUFFER
#define DRM_CAP_DUMB_BUFFER 0x1
#endif
#ifndef DRM_CAP_VBLANK_HIGH_CRTC
#define DRM_CAP_VBLANK_HIGH_CRTC 0x2
#endif
#ifndef DRM_CAP_DUMB_PREFERRED_DEPTH
#define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3
#endif
#ifndef DRM_CAP_DUMB_PREFER_SHADOW
#define DRM_CAP_DUMB_PREFER_SHADOW 0x4
#endif
#ifndef DRM_CAP_PRIME
#define DRM_CAP_PRIME 0x5
#endif
#ifndef DRM_PRIME_CAP_IMPORT
#define DRM_PRIME_CAP_IMPORT 0x1
#endif
#ifndef DRM_PRIME_CAP_EXPORT
#define DRM_PRIME_CAP_EXPORT 0x2
#endif
#ifndef DRM_CAP_TIMESTAMP_MONOTONIC
#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
#endif
#ifndef DRM_CAP_ASYNC_PAGE_FLIP
#define DRM_CAP_ASYNC_PAGE_FLIP 0x7
#endif
#ifndef DRM_CAP_CURSOR_WIDTH
#define DRM_CAP_CURSOR_WIDTH 0x8
#endif
#ifndef DRM_CAP_CURSOR_HEIGHT
#define DRM_CAP_CURSOR_HEIGHT 0x9
#endif
#ifndef DRM_CAP_ADDFB2_MODIFIERS
#define DRM_CAP_ADDFB2_MODIFIERS 0x10
#endif
#ifndef DRM_CAP_PAGE_FLIP_TARGET
#define DRM_CAP_PAGE_FLIP_TARGET 0x11
#endif
#ifndef DRM_CAP_CRTC_IN_VBLANK_EVENT
#define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12
#endif
#ifndef DRM_CAP_SYNCOBJ
#define DRM_CAP_SYNCOBJ 0x13
#endif
#ifndef DRM_CAP_SYNCOBJ_TIMELINE
#define DRM_CAP_SYNCOBJ_TIMELINE 0x14
#endif
#ifndef DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP
#define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP 0x15
#endif
#ifdef GLAMOR_HAS_GBM
#include <gbm.h>
#else
/* gbm compat */
#define GBM_FORMAT_R8 DRM_FORMAT_R8
#define GBM_FORMAT_ARGB1555 DRM_FORMAT_ARGB1555
#define GBM_FORMAT_RGB565 DRM_FORMAT_RGB565
#define GBM_FORMAT_XRGB8888 DRM_FORMAT_XRGB8888
#define GBM_FORMAT_ARGB2101010 DRM_FORMAT_ARGB2101010
#define GBM_FORMAT_ARGB8888 DRM_FORMAT_ARGB8888
#endif
/* gbm compat */
#ifndef GBM_MAX_PLANES
#define GBM_MAX_PLANES 4
#endif
/*
* XXX These are not defined to the actual values,
* so that they do not interfere with older libgbm
*/
#ifndef GBM_HAVE_BO_USE_LINEAR
#define GBM_BO_USE_LINEAR 0
#endif
#ifndef GBM_HAVE_BO_USE_FRONT_RENDERING
#define GBM_BO_USE_FRONT_RENDERING 0
#endif
#endif /* __DRM_DEFINES_H__ */