Compare commits

..

10 Commits

Author SHA1 Message Date
LeRoyce Pearson d3f9b3ca14 feat: add build.zig 2024-04-19 18:22:59 -06:00
Simon Ser 362b5b0a88 xf86drm: document drmDevicesEqual()
I always need to double-check what the return value means when
using that function (since it's not a bool).

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-04-11 12:11:30 +02:00
David Heidelberg 1179edb49a include poll.h instead of sys/poll.h
Fixes: f803a45e74 ("add libsync.h helper")
Fixes: 4c18828e16 ("tegra: Add job and push buffer APIs")
Signed-off-by: David Heidelberg <david@ixit.cz>
2024-04-10 23:27:16 +00:00
Simon Ser f94a79a7a7 ci: use "meson setup" sub-command
"meson" without a sub-command is deprecated.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-03-29 16:09:47 +01:00
Simon Ser 5a9cfb3c59 ci: build with meson --fatal-meson-warnings
This catches uses of deprecated features.

Signed-off-by: Simon Ser <contact@emersion.fr>
2024-03-29 11:44:09 +01:00
Joaquim Monteiro 764ed8b916
meson: Fix broken str.format usage
str.format used to allow any type as an argument, which often resulted
in using an internal string representation. This is considered broken
behavior, and is deprecated since Meson 1.3.0.

Signed-off-by: Joaquim Monteiro <joaquim.monteiro@protonmail.com>
2024-03-29 10:24:22 +00:00
Joaquim Monteiro fbb83f74d6
meson: Replace usages of deprecated ExternalProgram.path()
!347 fixed some of these, but not all.

Signed-off-by: Joaquim Monteiro <joaquim.monteiro@protonmail.com>
2024-03-29 10:23:52 +00:00
Pierre-Eric Pelloux-Prayer c7c3c14bfc amdgpu: fix deinit logic
The devices weren't removed from dev_list.

Instead of just fixing the issue by adding:

   if (*node) *node = dev->next;

after the while loop, use this opportunity to use a clearer
control flow.

Fixes: 7275ef8e ("amdgpu: add amdgpu_device_initialize2")
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
2024-03-27 08:55:26 +01:00
Matt Turner c45ffb1edf symbols-check: Add _fbss, _fdata, _ftext
These are exported on mips/mips64.

See also: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11955
2024-03-25 15:35:58 +00:00
Matt Turner 525e80447f symbols-check: Add _GLOBAL_OFFSET_TABLE_
This is exported on hppa/parisc.

See also: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26978

Bug: https://bugs.gentoo.org/927204
2024-03-25 15:35:58 +00:00
16 changed files with 281 additions and 15 deletions

4
.gitignore vendored
View File

@ -1 +1,3 @@
/build*
/build*/
/zig-cache/
/zig-out/

View File

@ -190,8 +190,8 @@ x86_64-freebsd-container_prep:
variables:
GIT_DEPTH: 10
script:
- meson build
--auto-features=enabled
- meson setup build
--fatal-meson-warnings --auto-features=enabled
-D udev=true
- ninja -C build
- ninja -C build test
@ -213,7 +213,7 @@ x86_64-freebsd-container_prep:
# the workspace to see details about the failed tests.
- |
set +e
/app/vmctl exec "pkg info; cd $CI_PROJECT_NAME ; meson build --auto-features=enabled -D etnaviv=disabled -D nouveau=disabled -D valgrind=disabled && ninja -C build"
/app/vmctl exec "pkg info; cd $CI_PROJECT_NAME ; meson setup build --fatal-meson-warnings --auto-features=enabled -D etnaviv=disabled -D nouveau=disabled -D valgrind=disabled && ninja -C build"
set -ex
scp -r vm:$CI_PROJECT_NAME/build/meson-logs .
/app/vmctl exec "ninja -C $CI_PROJECT_NAME/build install"

View File

@ -95,11 +95,17 @@ static int amdgpu_get_auth(int fd, int *auth)
static void amdgpu_device_free_internal(amdgpu_device_handle dev)
{
amdgpu_device_handle *node = &dev_list;
/* Remove dev from dev_list, if it was added there. */
while (*node != dev && *node && (*node)->next)
node = &(*node)->next;
if (dev == dev_list) {
dev_list = dev->next;
} else {
for (amdgpu_device_handle node = dev_list; node; node = node->next) {
if (node->next == dev) {
node->next = dev->next;
break;
}
}
}
close(dev->fd);
if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))

59
build.zig Normal file
View File

@ -0,0 +1,59 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const lib = b.addStaticLibrary(.{
.name = "drm",
.target = target,
.optimize = optimize,
});
lib.root_module.c_std = .C11;
lib.addCSourceFiles(.{
.files = &.{
"xf86drm.c",
"xf86drmHash.c",
"xf86drmRandom.c",
"xf86drmSL.c",
"xf86drmMode.c",
},
});
lib.addIncludePath(.{ .path = "include/drm" });
lib.linkLibC();
lib.defineCMacro("HAVE_OPEN_MEMSTREAM", "1");
// TODO: Figure out if where this varies
lib.defineCMacro("MAJOR_IN_SYSMACROS", "1");
// lib.defineCMacro("MAJOR_IN_MKDEV", "1");
lib.installHeader("libsync.h", "libsync.h");
lib.installHeader("xf86drm.h", "xf86drm.h");
lib.installHeader("xf86drmMode.h", "xf86drmMode.h");
lib.installHeadersDirectoryOptions(.{
.source_dir = .{ .path = "include/drm" },
.install_dir = .header,
.install_subdir = "libdrm",
});
b.installArtifact(lib);
// const lib_unit_tests = b.addTest(.{
// .root_source_file = .{ .path = "src/root.zig" },
// .target = target,
// .optimize = optimize,
// });
// const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
// const exe_unit_tests = b.addTest(.{
// .root_source_file = .{ .path = "src/main.zig" },
// .target = target,
// .optimize = optimize,
// });
// const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
// const test_step = b.step("test", "Run unit tests");
// test_step.dependOn(&run_lib_unit_tests.step);
// test_step.dependOn(&run_exe_unit_tests.step);
}

19
build.zig.zon Normal file
View File

@ -0,0 +1,19 @@
.{
.name = "drm",
.version = "2.4.120",
// This field is optional.
// This is currently advisory only; Zig does not yet do anything
// with this value.
//.minimum_zig_version = "0.11.0",
.dependencies = .{ },
// Specifies the set of files and directories that are included in this package.
// Only files and directories listed here are included in the `hash` that
// is computed for this package.
// Paths are relative to the build root. Use the empty string (`""`) to refer to
// the build root itself.
// A directory listed here means that all files within, recursively, are included.
.paths = .{ "" },
}

View File

@ -56,6 +56,6 @@ test(
args : [
'--lib', libdrm_exynos,
'--symbols-file', files('exynos-symbols.txt'),
'--nm', prog_nm.path(),
'--nm', prog_nm.full_path(),
],
)

113
gen_table_fourcc.zig Normal file
View File

@ -0,0 +1,113 @@
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const argv = try std.process.argsAlloc(gpa.allocator());
defer std.process.argsFree(gpa.allocator(), argv);
const filename = argv[1];
const contents = try std.fs.cwd().readFileAlloc(gpa.allocator(), filename, 50 * 1024 * 1024);
defer gpa.allocator().free(contents);
const stdout = std.io.getStdOut();
const out = stdout.writer();
try out.writeAll(
\\/* AUTOMATICALLY GENERATED by gen_table_fourcc.py. You should modify
\\ that script instead of adding here entries manually! */
\\static const struct drmFormatModifierInfo drm_format_modifier_table[] = {
\\ { DRM_MODIFIER_INVALID(NONE, INVALID) },
\\ { DRM_MODIFIER_LINEAR(NONE, LINEAR) },
\\
);
var line_iter = std.mem.splitScalar(u8, contents, '\n');
check_each_line: while (line_iter.next()) |line| {
errdefer std.log.debug("line = \"{}\"", .{std.zig.fmtEscapes(line)});
if (matchStart(line, "#define I915_FORMAT_MOD_")) |after| {
const modifier_end = std.mem.indexOfAny(u8, after, "\t ") orelse return error.Invalid;
const modifier = after[0..modifier_end];
for (modifier) |character| {
if (character != '_' and !std.ascii.isAlphanumeric(character)) {
continue :check_each_line;
}
}
try out.print(
\\ {{ DRM_MODIFIER_INTEL({[modifier]s}, {[modifier]s}) }},
\\
, .{
.modifier = modifier,
});
} else if (matchStart(line, "#define DRM_FORMAT_MOD_")) |after| {
const end_of_identifier = std.mem.indexOfAny(u8, after, "\t ") orelse return error.Invalid;
const identifier = after[0..end_of_identifier];
const end_of_vendor = std.mem.indexOfScalar(u8, identifier, '_') orelse continue;
const vendor_str = identifier[0..end_of_vendor];
const modifier = identifier[end_of_vendor + 1 ..];
for (modifier) |character| {
if (character != '_' and !std.ascii.isAlphanumeric(character)) {
continue :check_each_line;
}
}
const Vendor = enum { ARM, SAMSUNG, QCOM, VIVANTE, NVIDIA, BROADCOM, ALLWINNER };
const vendor = std.meta.stringToEnum(Vendor, vendor_str) orelse continue;
if (vendor == .ARM) {
if (std.mem.eql(u8, modifier, "TYPE_AFBC")) continue;
if (std.mem.eql(u8, modifier, "TYPE_MISC")) continue;
if (std.mem.eql(u8, modifier, "TYPE_AFRC")) continue;
}
try out.print(
\\ {{ DRM_MODIFIER({[vendor]s}, {[modifier]s}, {[modifier]s}) }},
\\
, .{
.vendor = @tagName(vendor),
.modifier = modifier,
});
}
}
try out.writeAll(
\\};
\\static const struct drmFormatModifierVendorInfo drm_format_modifier_vendor_table[] = {
\\
);
line_iter.reset();
check_each_line: while (line_iter.next()) |line| {
if (matchStart(line, "#define DRM_FORMAT_MOD_VENDOR_")) |after| {
const modifier_end = std.mem.indexOfAny(u8, after, "\t ") orelse return error.Invalid;
const modifier = after[0..modifier_end];
for (modifier) |character| {
if (character != '_' and !std.ascii.isAlphanumeric(character)) {
continue :check_each_line;
}
}
try out.print(
\\ {{ DRM_FORMAT_MOD_VENDOR_{[modifier]s}, "{[modifier]s}" }},
\\
, .{
.modifier = modifier,
});
}
}
try out.writeAll(
\\};
\\
);
}
fn matchStart(haystack: []const u8, needle: []const u8) ?[]const u8 {
if (std.mem.startsWith(u8, haystack, needle)) {
return haystack[needle.len..];
}
return null;
}

View File

@ -0,0 +1,58 @@
/* AUTOMATICALLY GENERATED by gen_table_fourcc.py. You should modify
that script instead of adding here entries manually! */
static const struct drmFormatModifierInfo drm_format_modifier_table[] = {
{ DRM_MODIFIER_INVALID(NONE, INVALID) },
{ DRM_MODIFIER_LINEAR(NONE, LINEAR) },
{ DRM_MODIFIER_INTEL(X_TILED, X_TILED) },
{ DRM_MODIFIER_INTEL(Y_TILED, Y_TILED) },
{ DRM_MODIFIER_INTEL(Yf_TILED, Yf_TILED) },
{ DRM_MODIFIER_INTEL(Y_TILED_CCS, Y_TILED_CCS) },
{ DRM_MODIFIER_INTEL(Yf_TILED_CCS, Yf_TILED_CCS) },
{ DRM_MODIFIER_INTEL(Y_TILED_GEN12_RC_CCS, Y_TILED_GEN12_RC_CCS) },
{ DRM_MODIFIER_INTEL(Y_TILED_GEN12_MC_CCS, Y_TILED_GEN12_MC_CCS) },
{ DRM_MODIFIER_INTEL(Y_TILED_GEN12_RC_CCS_CC, Y_TILED_GEN12_RC_CCS_CC) },
{ DRM_MODIFIER_INTEL(4_TILED, 4_TILED) },
{ DRM_MODIFIER_INTEL(4_TILED_DG2_RC_CCS, 4_TILED_DG2_RC_CCS) },
{ DRM_MODIFIER_INTEL(4_TILED_DG2_MC_CCS, 4_TILED_DG2_MC_CCS) },
{ DRM_MODIFIER_INTEL(4_TILED_DG2_RC_CCS_CC, 4_TILED_DG2_RC_CCS_CC) },
{ DRM_MODIFIER_INTEL(4_TILED_MTL_RC_CCS, 4_TILED_MTL_RC_CCS) },
{ DRM_MODIFIER_INTEL(4_TILED_MTL_MC_CCS, 4_TILED_MTL_MC_CCS) },
{ DRM_MODIFIER_INTEL(4_TILED_MTL_RC_CCS_CC, 4_TILED_MTL_RC_CCS_CC) },
{ DRM_MODIFIER(SAMSUNG, 64_32_TILE, 64_32_TILE) },
{ DRM_MODIFIER(SAMSUNG, 16_16_TILE, 16_16_TILE) },
{ DRM_MODIFIER(QCOM, COMPRESSED, COMPRESSED) },
{ DRM_MODIFIER(QCOM, TILED3, TILED3) },
{ DRM_MODIFIER(QCOM, TILED2, TILED2) },
{ DRM_MODIFIER(VIVANTE, TILED, TILED) },
{ DRM_MODIFIER(VIVANTE, SUPER_TILED, SUPER_TILED) },
{ DRM_MODIFIER(VIVANTE, SPLIT_TILED, SPLIT_TILED) },
{ DRM_MODIFIER(VIVANTE, SPLIT_SUPER_TILED, SPLIT_SUPER_TILED) },
{ DRM_MODIFIER(NVIDIA, TEGRA_TILED, TEGRA_TILED) },
{ DRM_MODIFIER(NVIDIA, 16BX2_BLOCK_ONE_GOB, 16BX2_BLOCK_ONE_GOB) },
{ DRM_MODIFIER(NVIDIA, 16BX2_BLOCK_TWO_GOB, 16BX2_BLOCK_TWO_GOB) },
{ DRM_MODIFIER(NVIDIA, 16BX2_BLOCK_FOUR_GOB, 16BX2_BLOCK_FOUR_GOB) },
{ DRM_MODIFIER(NVIDIA, 16BX2_BLOCK_EIGHT_GOB, 16BX2_BLOCK_EIGHT_GOB) },
{ DRM_MODIFIER(NVIDIA, 16BX2_BLOCK_SIXTEEN_GOB, 16BX2_BLOCK_SIXTEEN_GOB) },
{ DRM_MODIFIER(NVIDIA, 16BX2_BLOCK_THIRTYTWO_GOB, 16BX2_BLOCK_THIRTYTWO_GOB) },
{ DRM_MODIFIER(BROADCOM, VC4_T_TILED, VC4_T_TILED) },
{ DRM_MODIFIER(BROADCOM, SAND32, SAND32) },
{ DRM_MODIFIER(BROADCOM, SAND64, SAND64) },
{ DRM_MODIFIER(BROADCOM, SAND128, SAND128) },
{ DRM_MODIFIER(BROADCOM, SAND256, SAND256) },
{ DRM_MODIFIER(BROADCOM, UIF, UIF) },
{ DRM_MODIFIER(ARM, 16X16_BLOCK_U_INTERLEAVED, 16X16_BLOCK_U_INTERLEAVED) },
{ DRM_MODIFIER(ALLWINNER, TILED, TILED) },
};
static const struct drmFormatModifierVendorInfo drm_format_modifier_vendor_table[] = {
{ DRM_FORMAT_MOD_VENDOR_NONE, "NONE" },
{ DRM_FORMAT_MOD_VENDOR_INTEL, "INTEL" },
{ DRM_FORMAT_MOD_VENDOR_AMD, "AMD" },
{ DRM_FORMAT_MOD_VENDOR_NVIDIA, "NVIDIA" },
{ DRM_FORMAT_MOD_VENDOR_SAMSUNG, "SAMSUNG" },
{ DRM_FORMAT_MOD_VENDOR_QCOM, "QCOM" },
{ DRM_FORMAT_MOD_VENDOR_VIVANTE, "VIVANTE" },
{ DRM_FORMAT_MOD_VENDOR_BROADCOM, "BROADCOM" },
{ DRM_FORMAT_MOD_VENDOR_ARM, "ARM" },
{ DRM_FORMAT_MOD_VENDOR_ALLWINNER, "ALLWINNER" },
{ DRM_FORMAT_MOD_VENDOR_AMLOGIC, "AMLOGIC" },
};

View File

@ -104,6 +104,6 @@ test(
args : [
'--lib', libdrm_intel,
'--symbols-file', files('intel-symbols.txt'),
'--nm', prog_nm.path(),
'--nm', prog_nm.full_path(),
],
)

View File

@ -33,7 +33,7 @@
#include <stdint.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <poll.h>
#include <unistd.h>
#if defined(__cplusplus)

View File

@ -235,7 +235,7 @@ config_file = configure_file(
configuration : config,
output : 'config.h',
)
add_project_arguments('-include', '@0@'.format(config_file), language : 'c')
add_project_arguments('-include', meson.current_build_dir() / 'config.h', language : 'c')
inc_root = include_directories('.')
inc_drm = include_directories('include/drm')

View File

@ -56,6 +56,6 @@ test(
args : [
'--lib', libdrm_omap,
'--symbols-file', files('omap-symbols.txt'),
'--nm', prog_nm.path(),
'--nm', prog_nm.full_path(),
],
)

View File

@ -7,6 +7,7 @@ import subprocess
# This list contains symbols that _might_ be exported for some platforms
PLATFORM_SYMBOLS = [
'_GLOBAL_OFFSET_TABLE_',
'__bss_end__',
'__bss_start__',
'__bss_start',
@ -16,6 +17,9 @@ PLATFORM_SYMBOLS = [
'_end',
'_fini',
'_init',
'_fbss',
'_fdata',
'_ftext',
]

View File

@ -33,7 +33,7 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <poll.h>
#include "private.h"

View File

@ -59,6 +59,6 @@ test(
args : [
'--lib', libdrm_tegra,
'--symbols-file', files('tegra-symbols.txt'),
'--nm', prog_nm.path(),
'--nm', prog_nm.full_path(),
],
)

View File

@ -926,6 +926,11 @@ extern int drmGetDeviceFromDevId(dev_t dev_id, uint32_t flags, drmDevicePtr *dev
*/
extern int drmGetNodeTypeFromDevId(dev_t devid);
/**
* Check if two drmDevice pointers represent the same DRM device.
*
* Returns 1 if the devices are equal, 0 otherwise.
*/
extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b);
extern int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle);