aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Anderson <scott@anderso.nz>2019-12-17 21:34:13 +1300
committerSimon Ser <contact@emersion.fr>2019-12-18 14:39:09 +0100
commite2063b276bc1e9556adc09d42b87e63848389710 (patch)
treecb823f055efc4b87805a1f3d240625b4a89b86d7
parenta2aee4ab10ecfdd6d059aa2f5f42316fcda6c3eb (diff)
downloadexternal_drm_info-e2063b276bc1e9556adc09d42b87e63848389710.tar.gz
external_drm_info-e2063b276bc1e9556adc09d42b87e63848389710.tar.bz2
external_drm_info-e2063b276bc1e9556adc09d42b87e63848389710.zip
Add libdrm wrap file
This pulls in libdrm to get the latest Linux userspace API headers, but does not actually build or link against the libdrm subproject. This allows us to remove compat.h, as we can assume we always have the latest headers.
-rw-r--r--.build.yml1
-rw-r--r--.gitignore1
-rw-r--r--compat.h126
-rw-r--r--json.c14
-rw-r--r--meson.build65
-rw-r--r--pretty.c2
-rw-r--r--subprojects/libdrm.wrap4
7 files changed, 57 insertions, 156 deletions
diff --git a/.build.yml b/.build.yml
index feeb3bf..db70c17 100644
--- a/.build.yml
+++ b/.build.yml
@@ -8,6 +8,7 @@ sources:
tasks:
- setup: |
cd drm_info
+ meson subprojects download
meson build
- build: |
cd drm_info
diff --git a/.gitignore b/.gitignore
index 3d6b41c..bdf7500 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
subprojects/packagecache
subprojects/json-c-0.13.1
+subprojects/libdrm
diff --git a/compat.h b/compat.h
deleted file mode 100644
index 861ceeb..0000000
--- a/compat.h
+++ /dev/null
@@ -1,126 +0,0 @@
-#ifndef COMPAT_H
-#define COMPAT_H
-
-#include <drm_fourcc.h>
-#include "config.h"
-
-/*
- * Defines for compatibility with old libdrm.
- * The oldest version we target is whatever version Debian stable has.
- */
-
-#define VERSION(maj, min, pat) (((maj) << 16) | ((min) << 8) | (pat))
-#define LIBDRM_VERSION VERSION(LIBDRM_MAJ, LIBDRM_MIN, LIBDRM_PAT)
-
-#if LIBDRM_VERSION < VERSION(2, 4, 75)
-#define DRM_BUS_PCI 0
-#define DRM_BUS_USB 1
-#define DRM_BUS_PLATFORM 2
-#define DRM_BUS_HOST1X 3
-#endif /* LIBDRM_VERSION < VERSION(2, 4, 75) */
-
-#if LIBDRM_VERSION < VERSION(2, 4, 78)
-#define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12
-#endif /* LIBDRM_VERSION < VERSION(2, 4, 78) */
-
-#if LIBDRM_VERSION < VERSION(2, 4, 82)
-#define DRM_CAP_SYNCOBJ 0x13
-#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ')
-#define DRM_FORMAT_RG1616 fourcc_code('R', 'G', '3', '2')
-#define DRM_FORMAT_GR1616 fourcc_code('G', 'R', '3', '2')
-#define DRM_FORMAT_MOD_VENDOR_VIVANTE 0x06
-#define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07
-#define DRM_FORMAT_MOD_VENDOR_NONE 0
-#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0)
-#define DRM_FORMAT_MOD_VIVANTE_TILED fourcc_mod_code(VIVANTE, 1)
-#define DRM_FORMAT_MOD_VIVANTE_SUPER_TILED fourcc_mod_code(VIVANTE, 2)
-#define DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED fourcc_mod_code(VIVANTE, 3)
-#define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, 4)
-#define DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED fourcc_mod_code(BROADCOM, 1)
-#endif /* LIBDRM_VERSION < VERSION(2, 4, 82) */
-
-#if LIBDRM_VERSION < VERSION(2, 4, 83)
-#define DRM_FORMAT_RESERVED ((1ULL << 56) - 1)
-#define DRM_FORMAT_MOD_INVALID fourcc_mod_code(NONE, DRM_FORMAT_RESERVED)
-#define I915_FORMAT_MOD_Y_TILED_CCS fourcc_mod_code(INTEL, 4)
-#define I915_FORMAT_MOD_Yf_TILED_CCS fourcc_mod_code(INTEL, 5)
-#endif /* LIBDRM_VERSION < VERSION(2, 4, 83) */
-
-#if LIBDRM_VERSION < VERSION(2, 4, 86)
-#define DRM_MODE_PICTURE_ASPECT_NONE 0
-#define DRM_MODE_PICTURE_ASPECT_4_3 1
-#define DRM_MODE_PICTURE_ASPECT_16_9 2
-#define DRM_MODE_FLAG_PIC_AR_MASK (0x0F<<19)
-#define DRM_MODE_FLAG_PIC_AR_NONE (DRM_MODE_PICTURE_ASPECT_NONE<<19)
-#define DRM_MODE_FLAG_PIC_AR_4_3 (DRM_MODE_PICTURE_ASPECT_4_3<<19)
-#define DRM_MODE_FLAG_PIC_AR_16_9 (DRM_MODE_PICTURE_ASPECT_16_9<<19)
-#endif /* LIBDRM_VERSION < VERSION(2, 4, 86) */
-
-#if LIBDRM_VERSION < VERSION(2, 4, 91)
-#define DRM_FORMAT_MOD_VENDOR_NVIDIA 0x03
-#define DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED fourcc_mod_code(NVIDIA, 1)
-#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(v) \
- fourcc_mod_code(NVIDIA, 0x10 | ((v) & 0xf))
-#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB \
- fourcc_mod_code(NVIDIA, 0x10)
-#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB \
- fourcc_mod_code(NVIDIA, 0x11)
-#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB \
- fourcc_mod_code(NVIDIA, 0x12)
-#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB \
- fourcc_mod_code(NVIDIA, 0x13)
-#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB \
- fourcc_mod_code(NVIDIA, 0x14)
-#define DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB \
- fourcc_mod_code(NVIDIA, 0x15)
-#endif /* LIBDRM_VERSION < VERSION(2, 4, 91) */
-
-#if LIBDRM_VERSION < VERSION(2, 4, 95)
-#define DRM_CLIENT_CAP_ASPECT_RATIO 4
-#define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS 5
-#define DRM_MODE_PICTURE_ASPECT_64_27 3
-#define DRM_MODE_PICTURE_ASPECT_256_135 4
-#define DRM_MODE_FLAG_PIC_AR_64_27 (DRM_MODE_PICTURE_ASPECT_64_27<<19)
-#define DRM_MODE_FLAG_PIC_AR_256_135 (DRM_MODE_PICTURE_ASPECT_256_135<<19)
-#define DRM_FORMAT_INVALID 0
-#define DRM_MODE_CONNECTOR_WRITEBACK 18
-#define DRM_FORMAT_MOD_VENDOR_ARM 0x08
-#define __fourcc_mod_broadcom_param_shift 8
-#define __fourcc_mod_broadcom_param_bits 48
-#define fourcc_mod_broadcom_code(val, params) \
- fourcc_mod_code(BROADCOM, ((((__u64)params) << __fourcc_mod_broadcom_param_shift) | val))
-#define fourcc_mod_broadcom_param(m) \
- ((int)(((m) >> __fourcc_mod_broadcom_param_shift) & \
- ((1ULL << __fourcc_mod_broadcom_param_bits) - 1)))
-#define fourcc_mod_broadcom_mod(m) \
- ((m) & ~(((1ULL << __fourcc_mod_broadcom_param_bits) - 1) << \
- __fourcc_mod_broadcom_param_shift))
-#define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(v) \
- fourcc_mod_broadcom_code(2, v)
-#define DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(v) \
- fourcc_mod_broadcom_code(3, v)
-#define DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(v) \
- fourcc_mod_broadcom_code(4, v)
-#define DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(v) \
- fourcc_mod_broadcom_code(5, v)
-#define DRM_FORMAT_MOD_BROADCOM_SAND32 \
- DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(0)
-#define DRM_FORMAT_MOD_BROADCOM_SAND64 \
- DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(0)
-#define DRM_FORMAT_MOD_BROADCOM_SAND128 \
- DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(0)
-#define DRM_FORMAT_MOD_BROADCOM_SAND256 \
- DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(0)
-#define DRM_FORMAT_MOD_BROADCOM_UIF fourcc_mod_code(BROADCOM, 6)
-#endif /* LIBDRM_VERSION < VERSION(2, 4, 95) */
-
-#if LIBDRM_VERSION < VERSION(2, 4, 98)
-#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09
-#define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1)
-#endif /* LIBDRM_VERSION < VERSION(2, 4, 98) */
-
-#if LIBDRM_VERSION < VERSION(2, 4, 99)
-#define DRM_CAP_SYNCOBJ_TIMELINE 0x14
-#endif /* LIBDRM_VERSION < VERSION(2, 4, 99) */
-
-#endif
diff --git a/json.c b/json.c
index a8c13ca..9c85ecc 100644
--- a/json.c
+++ b/json.c
@@ -13,8 +13,6 @@
#include <xf86drm.h>
#include <xf86drmMode.h>
-#include "compat.h"
-#include "config.h"
#include "drm_info.h"
static const struct {
@@ -163,7 +161,6 @@ static struct json_object *device_info(int fd)
json_object_object_add(device_data_obj, "subsystem_device",
new_json_object_uint64(pci->subdevice_id));
break;
-#if LIBDRM_VERSION >= VERSION(2, 4, 75)
case DRM_BUS_PLATFORM:;
drmPlatformDeviceInfo *platform = dev->deviceinfo.platform;
device_data_obj = json_object_new_object();
@@ -173,7 +170,6 @@ static struct json_object *device_info(int fd)
json_object_new_string(platform->compatible[i]));
json_object_object_add(device_data_obj, "compatible", compatible_arr);
break;
-#endif
}
json_object_object_add(obj, "device_data", device_data_obj);
@@ -182,7 +178,6 @@ static struct json_object *device_info(int fd)
return obj;
}
-#if LIBDRM_VERSION >= VERSION(2, 4, 83)
static struct json_object *in_formats_info(int fd, uint32_t blob_id)
{
struct json_object *arr = json_object_new_array();
@@ -218,15 +213,6 @@ static struct json_object *in_formats_info(int fd, uint32_t blob_id)
return arr;
}
-#else
-static struct json_object *in_formats_info(int fd, uint32_t blob_id)
-{
- (void)fd;
- (void)blob_id;
-
- return NULL;
-}
-#endif
static struct json_object *mode_info(const drmModeModeInfo *mode)
{
diff --git a/meson.build b/meson.build
index 6241cf0..a58bc4a 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,7 @@
project('drm_info', 'c',
version: '2.1.0',
license: 'MIT',
- meson_version: '>=0.46.0',
+ meson_version: '>=0.49.0',
default_options: [
'c_std=c11',
'warning_level=2',
@@ -10,30 +10,67 @@ project('drm_info', 'c',
add_project_arguments('-D_POSIX_C_SOURCE=200809L', language: 'c')
-conf = configuration_data()
-libdrm = dependency('libdrm', version: '>= 2.4.74')
jsonc = dependency('json-c', version: '>=0.13', fallback: ['json-c', 'json_c'])
+libdrm = dependency('libdrm',
+ fallback: ['libdrm', 'ext_libdrm'],
+ default_options: [
+ 'libkms=false',
+ 'intel=false',
+ 'radeon=false',
+ 'amdgpu=false',
+ 'nouveau=false',
+ 'vmwgfx=false',
+ 'omap=false',
+ 'exynos=false',
+ 'freedreno=false',
+ 'tegra=false',
+ 'vc4=false',
+ 'etnaviv=false',
+ 'cairo-tests=false',
+ 'man-pages=false',
+ 'valgrind=false',
+ ],
+)
-libdrm_ver = libdrm.version().split('.')
-conf.set('LIBDRM_MAJ', libdrm_ver[0])
-conf.set('LIBDRM_MIN', libdrm_ver[1])
-conf.set('LIBDRM_PAT', libdrm_ver[2])
+inc = []
+# libdrm pretty consistently pulls in the linux userspace API headers.
+# We want a new libdrm to get all of the #defines in those headers, but
+# we don't actually need to link against a new version of libdrm itself.
+#
+# We need to make sure we don't use any new libdrm functions, but those
+# are added very infrequently, so this is unlikely to be an issue.
+if libdrm.version().version_compare('<2.4.99')
+ if libdrm.type_name() == 'internal'
+ error('libdrm subproject out of date. Run `meson subprojects update`.')
+ endif
-config_h = configure_file(
- configuration: conf,
- output: 'config.h',
-)
+ msg = [
+ 'System libdrm version does not have latest Linux DRM headers.',
+ 'Attempting to use headers from meson subproject if present.',
+ 'If this fails, update your system libdrm or run `meson subprojects download`.',
+ ]
+ foreach s : msg
+ warning(s)
+ endforeach
+
+ fourcc_h = files('subprojects/libdrm/include/drm/drm_fourcc.h')
+ inc += include_directories('subprojects/libdrm/include/drm')
+ libdrm = libdrm.partial_dependency(link_args: true)
+elif libdrm.type_name() == 'internal'
+ fourcc_h = files('subprojects/libdrm/include/drm/drm_fourcc.h')
+else
+ fourcc_h = files(libdrm.get_pkgconfig_variable('includedir') / 'libdrm/drm_fourcc.h')
+endif
python3 = import('python').find_installation()
-drm_fourcc_h_path = join_paths(libdrm.get_pkgconfig_variable('includedir'), 'libdrm/drm_fourcc.h')
-fourcc_py = join_paths(meson.source_root(), 'fourcc.py')
tables_h = custom_target('tables_h',
output : 'tables.h',
- command : [python3, fourcc_py, drm_fourcc_h_path, '@OUTPUT@'])
+ command : [python3, files('fourcc.py'), fourcc_h, '@OUTPUT@'])
executable('drm_info',
[files('main.c', 'json.c', 'pretty.c'), tables_h],
+ include_directories: inc,
dependencies: [libdrm, jsonc],
install: true,
)
diff --git a/pretty.c b/pretty.c
index 4f220f2..b21f4f7 100644
--- a/pretty.c
+++ b/pretty.c
@@ -7,8 +7,6 @@
#include <xf86drm.h>
#include <xf86drmMode.h>
-#include "compat.h"
-#include "config.h"
#include "drm_info.h"
#include "tables.h"
diff --git a/subprojects/libdrm.wrap b/subprojects/libdrm.wrap
new file mode 100644
index 0000000..b96f854
--- /dev/null
+++ b/subprojects/libdrm.wrap
@@ -0,0 +1,4 @@
+[wrap-git]
+url = https://gitlab.freedesktop.org/mesa/drm.git
+revision = libdrm-2.4.99
+depth = 1