Files
RedBear-OS/local/recipes/gpu/amdgpu/recipe.toml
T
vasilito 1882e44302 amdgpu: expand Stage 2 to 10 DCN files (DCN20+DCN30+DCN31)
Add dpp, mmhubbub include paths. Add ilog2 macro.
10 of 11 tested DCN files now compile with 0 errors.
dnc30_cm_common.c excluded — dcn30_cm_common.h missing from Linux 7.1 tree.
2026-06-01 11:23:06 +03:00

170 lines
5.9 KiB
TOML

# AMD GPU retained display glue path for Redox OS
# Scope: bounded Red Bear display glue path for init, connector detection, and modeset.
# Imported Linux AMD DC / TTM / amdgpu core trees remain adjacent source under compile triage and
# are not part of the default retained build path. Full acceleration still requires broader GPU work
# plus Mesa radeonsi backend enablement.
[source]
# Local overlay recipe. The extracted Linux 7.1 AMDGPU tree lives next to this
# recipe at ../amdgpu-source and is referenced by the custom build script below.
path = "source"
[build]
template = "custom"
dependencies = [
"redox-driver-sys",
"linux-kpi",
"firmware-loader",
]
script = """
DYNAMIC_INIT
# Paths
AMD_ROOT="${COOKBOOK_SOURCE}/../../amdgpu-source/gpu/drm/amd"
AMD_SRC="${AMD_ROOT}"
INCLUDES="${COOKBOOK_SOURCE}/../../amdgpu-source/include"
LINUX_KPI="${COOKBOOK_ROOT}/local/recipes/drivers/linux-kpi/source/src/c_headers"
REDOX_GLUE="${COOKBOOK_SOURCE}"
TARGET_CC="${TARGET}-gcc"
# Compiler flags for the bounded retained AMD path. Legacy AMD DC config defines remain here only
# for header compatibility with the adjacent imported Linux source trees.
export CFLAGS="-std=gnu11 -D__redox__ -D__KERNEL__ -DCONFIG_DRM_AMDGPU -DCONFIG_DRM_AMD_DC \
-DCONFIG_DRM_AMD_DC_DML2=1 \
-DCONFIG_DRM_AMD_DC_FP -DCONFIG_DRM_AMD_ACP \
-include linux/amdgpu_stubs.h \
-I${LINUX_KPI} \
-I${REDOX_GLUE} \
-I${INCLUDES} \
-I${INCLUDES}/drm \
-I${AMD_SRC}/include \
-I${AMD_SRC}/include/asic_reg \
-I${AMD_SRC}/display \
-I${AMD_SRC}/display/dc \
-I${AMD_SRC}/display/include \
-I${AMD_SRC}/display/dc/inc \
-I${AMD_SRC}/display/dc/inc/hw \
-I${AMD_SRC}/display/dmub/inc \
-I${AMD_SRC}/display/dc/dml \
-I${AMD_SRC}/display/dc/dml2_0 \
-I${AMD_SRC}/display/dc/dml2_0/dml21 \
-I${AMD_SRC}/display/dc/dcn20 \
-I${AMD_SRC}/display/dc/dcn21 \
-I${AMD_SRC}/display/dc/dcn30 \
-I${AMD_SRC}/display/dc/dcn301 \
-I${AMD_SRC}/display/dc/dcn31 \
-I${AMD_SRC}/display/dc/dcn32 \
-I${AMD_SRC}/display/dc/dpp \
-I${AMD_SRC}/display/dc/mmhubbub \
-I${AMD_SRC}/display/modules \
-I${AMD_SRC}/display/modules/freesync \
-I${AMD_SRC}/display/modules/color \
-I${AMD_SRC}/display/modules/info_packet \
-I${AMD_SRC}/display/modules/power \
-I${AMD_SRC}/pm/swsmu \
-I${AMD_SRC}/pm/swsmu/inc \
-I${AMD_SRC}/pm/powerplay \
-I${AMD_SRC}/pm/powerplay/inc \
-I${AMD_SRC}/pm/powerplay/hwmgr \
-fPIC -O2 -Wall -Wno-unused-function -Wno-unused-variable \
-Wno-address-of-packed-member -Wno-initializer-overrides"
# Stage 1: Compile Redox glue code
"${TARGET_CC}" -c ${CFLAGS} "${REDOX_GLUE}/amdgpu_redox_main.c" -o amdgpu_redox_main.o
"${TARGET_CC}" -c ${CFLAGS} "${REDOX_GLUE}/redox_stubs.c" -o redox_stubs.o
# Stage 2: DCN hardware display files
#
# These DCN hardware backend files have been proven to compile against
# the linux-kpi compatibility headers. DCN31 covers RDNA2 (Navi21-24),
# DCN20 covers RDNA1 (Navi10/14/12), DCN30 covers additional RDNA2.
DISPLAY_SRCS="${AMD_SRC}/display/dc/dcn20/dcn20_dwb.c
${AMD_SRC}/display/dc/dcn20/dcn20_dwb_scl.c
${AMD_SRC}/display/dc/dcn20/dcn20_vmid.c
${AMD_SRC}/display/dc/dcn30/dcn30_afmt.c
${AMD_SRC}/display/dc/dcn30/dcn30_mmhubbub.c
${AMD_SRC}/display/dc/dcn30/dcn30_vpg.c
${AMD_SRC}/display/dc/dcn31/dcn31_afmt.c
${AMD_SRC}/display/dc/dcn31/dcn31_vpg.c
${AMD_SRC}/display/dc/dcn31/dcn31_apg.c
${AMD_SRC}/display/dc/dcn31/dcn31_panel_cntl.c"
success=0
failed=0
for src in $DISPLAY_SRCS; do
obj=$(basename "${src%.c}.o")
if "${TARGET_CC}" -c ${CFLAGS} "$src" -o "$obj" 2>"${obj}.log"; then
success=$((success + 1))
else
failed=$((failed + 1))
echo "ERROR: failed to compile $(basename $src)"
cat "${obj}.log"
exit 1
fi
done
echo "Stage 2: bounded AMD display path compiled ${success} imported display files, ${failed} failed"
# Stage 3: Imported TTM path
#
# The current bounded Red Bear display path uses Rust-side GEM/GTT/ring handling in
# `redox-drm`, not the imported Linux TTM stack. Keep this explicit and empty until
# the bounded path proves a concrete need for imported TTM code.
TTM_SRCS=""
success=0
failed=0
for src in $TTM_SRCS; do
obj=$(basename "${src%.c}.o")
if "${TARGET_CC}" -c ${CFLAGS} "$src" -o "$obj" 2>"${obj}.log"; then
success=$((success + 1))
else
failed=$((failed + 1))
echo "ERROR: failed to compile $(basename $src)"
cat "${obj}.log"
exit 1
fi
done
echo "Stage 3: bounded imported TTM path compiled ${success} files, ${failed} failed"
# Stage 4: Imported amdgpu core path
#
# The current bounded Red Bear display path uses the custom glue layer for init,
# connector enumeration, and modeset, while Rust-side code owns GEM/GTT/ring state.
# Keep imported amdgpu core sources out of the retained compile surface until the
# bounded path proves a specific dependency on them.
CORE_SRCS=""
success=0
failed=0
for src_name in $CORE_SRCS; do
src="${AMD_SRC}/amdgpu/${src_name}"
if [ -f "$src" ]; then
obj="${src_name%.c}.o"
if "${TARGET_CC}" -c ${CFLAGS} "$src" -o "$obj" 2>"${obj}.log"; then
success=$((success + 1))
else
failed=$((failed + 1))
echo "ERROR: failed to compile $src_name"
cat "${obj}.log"
exit 1
fi
fi
done
echo "Stage 4: amdgpu core compiled ${success} files, ${failed} failed"
# Stage 5: Link into shared library
OBJS=""
for obj in $(find . -name '*.o' -size +0c); do
OBJS="$OBJS $obj"
done
if [ -z "$OBJS" ]; then
echo "ERROR: no object files compiled successfully"
exit 1
fi
"${TARGET_CC}" -shared -o libamdgpu_dc_redox.so $OBJS -lm -lpthread
# Install
mkdir -p "${COOKBOOK_STAGE}/usr/lib/redox/drivers"
cp libamdgpu_dc_redox.so "${COOKBOOK_STAGE}/usr/lib/redox/drivers/"
mkdir -p "${COOKBOOK_STAGE}/usr/include/amdgpu-redox"
cp "${REDOX_GLUE}/redox_glue.h" "${COOKBOOK_STAGE}/usr/include/amdgpu-redox/"
"""