linux-qubasis

linux oasis port as a qubes template

git clone https://9o.is/git/linux-qubasis.git

commit 1a96043b4c3a53ddddcab8da515cf70b5a99c81b
parent 8ca0164047fef9ed1bff19d4800e79c972aa16f3
Author: Jul <jul@9o.is>
Date:   Thu, 27 Nov 2025 13:33:37 -0500

add libdrm

Diffstat:
M.gitmodules | 4++++
Mpkg/gen.sh | 1+
Apkg/libdrm/config.h | 17+++++++++++++++++
Apkg/libdrm/fourcc.lua | 44++++++++++++++++++++++++++++++++++++++++++++
Apkg/libdrm/gen.sh | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mqubes/example/gen.sh | 1+
6 files changed, 161 insertions(+), 0 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -38,6 +38,10 @@ path = pkg/fzy/src url = https://github.com/jhawthorn/fzy.git ignore = all +[submodule "libdrm"] + path = pkg/libdrm/src + url = https://gitlab.freedesktop.org/mesa/drm.git + ignore = all [submodule "libevdev"] path = pkg/libevdev/src url = https://gitlab.freedesktop.org/libevdev/libevdev.git diff --git a/pkg/gen.sh b/pkg/gen.sh @@ -25,6 +25,7 @@ pkg freetype pkg fspec-sync pkg fzy pkg less +pkg libdrm pkg libevdev pkg libinput pkg libpciaccess diff --git a/pkg/libdrm/config.h b/pkg/libdrm/config.h @@ -0,0 +1,17 @@ +#define HAVE_ALLOCA_H 1 +#define HAVE_CAIRO 0 +#define HAVE_EXYNOS 0 +#define HAVE_FREEDRENO_KGSL 0 +#define HAVE_LIBDRM_ATOMIC_PRIMITIVES 1 +#define HAVE_LIB_ATOMIC_OPS 0 +#define HAVE_OPEN_MEMSTREAM 1 +#define HAVE_RADEON 0 +#define HAVE_SYS_SELECT_H 1 +#define HAVE_SYS_SYSCTL_H 0 +#define HAVE_VALGRIND 0 +#define HAVE_VC4 0 +#define HAVE_VISIBILITY 1 +#define HAVE_VMWGFX 0 +#define MAJOR_IN_SYSMACROS 1 +#define UDEV 0 +#define _GNU_SOURCE 1 diff --git a/pkg/libdrm/fourcc.lua b/pkg/libdrm/fourcc.lua @@ -0,0 +1,44 @@ +io.write[[ +/* AUTOMATICALLY GENERATED by fourcc.lua. 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) }, +]] + +local vendors = { + ARM=true, + SAMSUNG=true, + QCOM=true, + VIVANTE=true, + NVIDIA=true, + BROADCOM=true, + ALLWINNER=true, +} +for line in io.lines() do + local mod = line:match('^#define I915_FORMAT_MOD_([%w_]+)') + if mod then + io.write(string.format(' { DRM_MODIFIER_INTEL(%s, %s) },\n', mod, mod)) + end + local vendor, mod = line:match('^#define DRM_FORMAT_MOD_(%w+)_([%w_]+)%s') + if vendors[vendor] then + if vendor ~= 'ARM' or not mod:match('^TYPE_') then + io.write(string.format(' { DRM_MODIFIER(%s, %s, %s) },\n', vendor, mod, mod)) + end + end + local vendor = line:match('^#define DRM_FORMAT_MOD_VENDOR_([%w_]+)') + if vendor then + table.insert(vendors, vendor) + end +end + +io.write[[ +}; +static const struct drmFormatModifierVendorInfo drm_format_modifier_vendor_table[] = { +]] +for _, vendor in ipairs(vendors) do + io.write(string.format(' { DRM_FORMAT_MOD_VENDOR_%s, "%s" },\n', vendor, vendor)) +end +io.write[[ +}; +]] diff --git a/pkg/libdrm/gen.sh b/pkg/libdrm/gen.sh @@ -0,0 +1,94 @@ +VIDEO_DRIVERS='intel nouveau amdgpu' #'intel nouveau amdgpu' + +git libdrm-2.4.120 + +has_driver() { + has $1 $VIDEO_DRIVERS +} + +driver_flag() { + has_driver $1 && printf 1 || printf 0 +} + +cflags " + -DHAVE_INTEL=$(driver_flag intel) + -DHAVE_NOUVEAU=$(driver_flag nouveau) + -DHAVE_AMDGPU=$(driver_flag amdgpu) + -include $dir/config.h + -I$dir + -I$outdir + -I$srcdir + -I$srcdir/include/drm + -isystem $pkgdir/linux-headers/include + -Wno-format + -Wno-unused-parameter + -Wno-overflow +" + +include " + xf86drm.h + xf86drmMode.h + amdgpu/amdgpu.h + include/drm/drm.h + include/drm/drm_fourcc.h + include/drm/drm_mode.h + include/drm/drm_sarea.h + include/drm/i915_drm.h + include/drm/amdgpu_drm.h +" + +dep " + libpciaccess/headers + linux-headers/headers + $outdir/generated_static_table_fourcc.h +" + +rule fourcc 'lua $dir/fourcc.lua <$in >$out' +bind description 'FOURCC $out' + +fourcc generated_static_table_fourcc.h include/drm/drm_fourcc.h + +lib libdrm.a " + xf86drm.c + xf86drmHash.c + xf86drmMode.c + xf86drmRandom.c + xf86drmSL.c +" + +if has_driver intel; then + lib libdrm_intel.a --src-prefix intel -isystem $pkgdir/libpciaccess/include \ + -Wno-pedantic -Wno-missing-field-initializers " + intel_bufmgr.c + intel_bufmgr_fake.c + intel_bufmgr_gem.c + intel_decode.c + mm.c + $pkgdir/libpciaccess/libpciaccess.a + " +fi + +if has_driver nouveau; then + lib libdrm_nouveau.a --src-prefix nouveau -Wno-pedantic " + abi16.c + bufctx.c + nouveau.c + pushbuf.c + " +fi + +if has_driver amdgpu; then + lib libdrm_amdgpu.a --src-prefix amdgpu -Wno-pedantic -Wno-attributes \ + -D'AMDGPU_ASIC_ID_TABLE=\"%s/share/libdrm/amdgpu.ids\"' " + amdgpu_asic_id.c + amdgpu_bo.c + amdgpu_cs.c + amdgpu_device.c + amdgpu_gpu_info.c + amdgpu_vamgr.c + amdgpu_vm.c + handle_table.c + " + + share --prefix libdrm data/amdgpu.ids +fi diff --git a/qubes/example/gen.sh b/qubes/example/gen.sh @@ -18,6 +18,7 @@ pkg e2fsprogs pkg fspec-sync pkg fzy pkg less +pkg libdrm pkg libinput pkg mandoc pkg netbsd-curses