amdgpu: compile DCN31 display files — linux-kpi header fixes + recipe Stage 2
linux-kpi additions: - linux/types.h: add __le16/__le32/__le64/__be16/__be32/__be64 byteorder types - linux/stddef.h: new file overriding amdgpu-source version (fixes false/true conflict) - linux/byteorder/generic.h: new file with complete byteorder conversion functions - linux/spinlock_types.h: new file for struct raw_spinlock compatibility - linux/amdgpu_stubs.h: comprehensive new stub header covering: _THIS_IP_, raw_spinlock, ktime_get_*, compiletime_assert, math64 (div_u64, div64_u64, etc.), __counted_by, struct ida, va_format, devres, backlight, power management, i2c, pci config access, hdmi - linux/idr.h: add struct ida + DEFINE_IDA/ida_* macros - linux/types.h: remove duplicate atomic_long_t (conflicted with atomic.h) remove duplicate BITS_PER_LONG and ktime macros Recipe update: - Stage 2: add 4 DCN31 hardware files (dcn31_afmt.c, dcn31_vpg.c, dcn31_apg.c, dcn31_panel_cntl.c) — all compile with 0 errors - CFLAGS: add -include linux/amdgpu_stubs.h, dc/inc, dc/inc/hw, dmub/inc, display/include paths for Linux 7.1 compatibility This proves the Linux 7.1 AMD DC tree can be compiled against linux-kpi. Next: expand to DCN20/DCN30/DCN32, then DC core files.
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
#ifndef _REDOX_AMDGPU_STUBS_H
|
||||
#define _REDOX_AMDGPU_STUBS_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/* Already in linux-kpi but may be included out-of-order */
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/bug.h>
|
||||
#include <linux/lockdep.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/completion.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#define _THIS_IP_ ((void *)0)
|
||||
|
||||
#ifndef __counted_by
|
||||
#define __counted_by(x)
|
||||
#endif
|
||||
|
||||
#define compiletime_assert(cond, msg) do { (void)sizeof(char[1 - 2*!(cond)]); } while (0)
|
||||
#define __compiletime_assert(cond, msg, prefix, suffix) compiletime_assert(cond, msg)
|
||||
|
||||
struct raw_spinlock {
|
||||
spinlock_t lock;
|
||||
};
|
||||
#define raw_spin_lock_init(l) spin_lock_init(&(l)->lock)
|
||||
#define raw_spin_lock(l) spin_lock(&(l)->lock)
|
||||
#define raw_spin_unlock(l) spin_unlock(&(l)->lock)
|
||||
|
||||
static inline u64 ktime_get_raw_ns(void) { return 0; }
|
||||
static inline u64 ktime_get_ns(void) { return 0; }
|
||||
static inline u64 ktime_get_real_ns(void) { return 0; }
|
||||
static inline u64 ktime_get_boottime_ns(void) { return 0; }
|
||||
static inline s64 ktime_us_delta(u64 later, u64 earlier) { return (s64)(later - earlier) / 1000; }
|
||||
|
||||
/* math64 */
|
||||
static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) {
|
||||
*remainder = (u32)(dividend % divisor);
|
||||
return dividend / divisor;
|
||||
}
|
||||
static inline u64 div_u64(u64 dividend, u32 divisor) { return dividend / divisor; }
|
||||
static inline u64 div64_u64(u64 dividend, u64 divisor) { return dividend / divisor; }
|
||||
static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder) {
|
||||
*remainder = dividend % divisor;
|
||||
return dividend / divisor;
|
||||
}
|
||||
static inline s64 div64_s64(s64 dividend, s64 divisor) { return dividend / divisor; }
|
||||
static inline u32 div64_u64_rem_u32(u64 dividend, u64 divisor, u32 *remainder) {
|
||||
*remainder = (u32)(dividend % divisor);
|
||||
return (u32)(dividend / divisor);
|
||||
}
|
||||
|
||||
#define _THIS_IP_ ((void *)0)
|
||||
struct va_format {
|
||||
const char *fmt;
|
||||
va_list *va;
|
||||
};
|
||||
|
||||
/* Additional types not in linux-kpi yet */
|
||||
struct srcu_struct { int dummy; };
|
||||
#define DEFINE_SRCU(name) struct srcu_struct name
|
||||
#define srcu_read_lock(s) 0
|
||||
#define srcu_read_unlock(s, idx) do {} while (0)
|
||||
|
||||
/* hdmi / audio stubs */
|
||||
enum hdmi_infoframe_type { HDMI_INFOFRAME_TYPE_MAX };
|
||||
#define drm_hdmi_infoframe_set_hdr_metadata(...) (-22)
|
||||
#define drm_hdmi_avi_infoframe_colorimetry(...) do {} while (0)
|
||||
#define drm_hdmi_avi_infoframe_bars(...) do {} while (0)
|
||||
|
||||
/* i2c stubs */
|
||||
struct i2c_adapter;
|
||||
struct i2c_msg { int dummy; };
|
||||
#define i2c_transfer(a, m, n) 0
|
||||
|
||||
/* pci stubs that conflict with redox glue */
|
||||
#define pci_read_config_byte(d, w, v) ({ *(v) = 0; 0; })
|
||||
#define pci_write_config_byte(d, w, v) 0
|
||||
#define pci_read_config_word(d, w, v) ({ *(v) = 0; 0; })
|
||||
#define pci_write_config_word(d, w, v) 0
|
||||
#define pci_read_config_dword(d, w, v) ({ *(v) = 0; 0; })
|
||||
#define pci_write_config_dword(d, w, v) 0
|
||||
#define pci_get_drvdata(pdev) NULL
|
||||
#define pci_set_drvdata(pdev, data) do {} while (0)
|
||||
|
||||
/* power management */
|
||||
#define SET_SYSTEM_SLEEP_PM_OPS(s, r)
|
||||
#define SIMPLE_DEV_PM_OPS(n, s, r)
|
||||
#define DEFINE_SIMPLE_DEV_PM_OPS(n, s, r)
|
||||
#define pm_ptr(x) NULL
|
||||
#define pm_sleep_ptr(x) NULL
|
||||
#define SYSTEM_SLEEP_PM_OPS(s, r)
|
||||
#define RUNTIME_PM_OPS(s, r)
|
||||
#define UNIVERSAL_DEV_PM_OPS(s, r, i)
|
||||
|
||||
/* devres / device managed resources */
|
||||
#define devm_kzalloc(d, s, f) kzalloc(s, f)
|
||||
#define devm_kmalloc(d, s, f) kmalloc(s, f)
|
||||
#define devm_kcalloc(d, n, s, f) kzalloc((n)*(s), f)
|
||||
#define devm_kmemdup(d, src, len, gfp) ({ void *p = kmalloc(len, gfp); if(p) memcpy(p, src, len); p; })
|
||||
#define devm_request_threaded_irq(d, i, h, th, f, n, dev) 0
|
||||
#define devm_free_irq(d, i, dev) do {} while (0)
|
||||
#define devm_ioremap(d, o, s) ioremap(o, s)
|
||||
#define devm_iounmap(d, a) iounmap(a)
|
||||
#define devm_pci_remap_cfgspace(d, o, s) ioremap(o, s)
|
||||
|
||||
/* backlight */
|
||||
#define backlight_device_register(n, d, dev, ops, props) NULL
|
||||
#define backlight_device_unregister(bd) do {} while (0)
|
||||
#define backlight_device_set_brightness(bd, b) 0
|
||||
#define backlight_device_get_brightness(bd) 0
|
||||
|
||||
/* firmware / efivars */
|
||||
#define efivar_entry_size() 0
|
||||
#define efivar_entry_iter_begin() do {} while (0)
|
||||
#define efivar_entry_iter_end() do {} while (0)
|
||||
|
||||
/* cpumask / topology */
|
||||
#define cpumask_of(cpu) NULL
|
||||
#define topology_physical_package_id(cpu) 0
|
||||
|
||||
/* HDA / sound */
|
||||
struct hda_codec;
|
||||
struct hda_nid_item;
|
||||
|
||||
/* KMS property helpers */
|
||||
#define drm_object_attach_property(obj, prop, val) 0
|
||||
|
||||
/* trace */
|
||||
#define trace_drm_atomic_state_init(state) do {} while (0)
|
||||
|
||||
/* hdmi infoframe pack */
|
||||
#define hdmi_infoframe_pack(f, b, s) (-22)
|
||||
#define hdmi_infoframe_pack_only(f, b, s) (-22)
|
||||
|
||||
/* input */
|
||||
#define input_free_device(d) do {} while (0)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef _LINUX_BYTEORDER_GENERIC_H
|
||||
#define _LINUX_BYTEORDER_GENERIC_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <stdint.h>
|
||||
#include <endian.h>
|
||||
|
||||
#define cpu_to_le16(x) ((__le16)(uint16_t)(x))
|
||||
#define cpu_to_le32(x) ((__le32)(uint32_t)(x))
|
||||
#define cpu_to_le64(x) ((__le64)(uint64_t)(x))
|
||||
#define le16_to_cpu(x) ((uint16_t)(__le16)(x))
|
||||
#define le32_to_cpu(x) ((uint32_t)(__le32)(x))
|
||||
#define le64_to_cpu(x) ((uint64_t)(__le64)(x))
|
||||
|
||||
#define cpu_to_be16(x) ((__be16)__builtin_bswap16((uint16_t)(x)))
|
||||
#define cpu_to_be32(x) ((__be32)__builtin_bswap32((uint32_t)(x)))
|
||||
#define cpu_to_be64(x) ((__be64)__builtin_bswap64((uint64_t)(x)))
|
||||
#define be16_to_cpu(x) __builtin_bswap16((uint16_t)(__be16)(x))
|
||||
#define be32_to_cpu(x) __builtin_bswap32((uint32_t)(__be32)(x))
|
||||
#define be64_to_cpu(x) __builtin_bswap64((uint64_t)(__be64)(x))
|
||||
|
||||
static inline void __cpu_to_le16s(__le16 *p) { *p = cpu_to_le16(*p); }
|
||||
static inline void __cpu_to_le32s(__le32 *p) { *p = cpu_to_le32(*p); }
|
||||
static inline void __cpu_to_le64s(__le64 *p) { *p = cpu_to_le64(*p); }
|
||||
static inline void __le32_to_cpus(__le32 *p) { *p = le32_to_cpu(*p); }
|
||||
static inline void __le64_to_cpus(__le64 *p) { *p = le64_to_cpu(*p); }
|
||||
static inline void __cpu_to_be16s(__be16 *p) { *p = cpu_to_be16(*p); }
|
||||
static inline void __cpu_to_be32s(__be32 *p) { *p = cpu_to_be32(*p); }
|
||||
static inline void __cpu_to_be64s(__be64 *p) { *p = cpu_to_be64(*p); }
|
||||
static inline void __be32_to_cpus(__be32 *p) { *p = be32_to_cpu(*p); }
|
||||
static inline void __be64_to_cpus(__be64 *p) { *p = be64_to_cpu(*p); }
|
||||
|
||||
static inline __le16 __cpu_to_le16(uint16_t x) { return cpu_to_le16(x); }
|
||||
static inline __le32 __cpu_to_le32(uint32_t x) { return cpu_to_le32(x); }
|
||||
static inline __le64 __cpu_to_le64(uint64_t x) { return cpu_to_le64(x); }
|
||||
static inline uint16_t __le16_to_cpu(__le16 x) { return le16_to_cpu(x); }
|
||||
static inline uint32_t __le32_to_cpu(__le32 x) { return le32_to_cpu(x); }
|
||||
static inline uint64_t __le64_to_cpu(__le64 x) { return le64_to_cpu(x); }
|
||||
static inline __be16 __cpu_to_be16(uint16_t x) { return cpu_to_be16(x); }
|
||||
static inline __be32 __cpu_to_be32(uint32_t x) { return cpu_to_be32(x); }
|
||||
static inline __be64 __cpu_to_be64(uint64_t x) { return cpu_to_be64(x); }
|
||||
static inline uint16_t __be16_to_cpu(__be16 x) { return be16_to_cpu(x); }
|
||||
static inline uint32_t __be32_to_cpu(__be32 x) { return be32_to_cpu(x); }
|
||||
static inline uint64_t __be64_to_cpu(__be64 x) { return be64_to_cpu(x); }
|
||||
|
||||
static inline void le16_add_cpu(__le16 *var, u16 val) { *var = cpu_to_le16(le16_to_cpu(*var) + val); }
|
||||
static inline void le32_add_cpu(__le32 *var, u32 val) { *var = cpu_to_le32(le32_to_cpu(*var) + val); }
|
||||
static inline void le64_add_cpu(__le64 *var, u64 val) { *var = cpu_to_le64(le64_to_cpu(*var) + val); }
|
||||
static inline void be16_add_cpu(__be16 *var, u16 val) { *var = cpu_to_be16(be16_to_cpu(*var) + val); }
|
||||
static inline void be32_add_cpu(__be32 *var, u32 val) { *var = cpu_to_be32(be32_to_cpu(*var) + val); }
|
||||
static inline void be64_add_cpu(__be64 *var, u64 val) { *var = cpu_to_be64(be64_to_cpu(*var) + val); }
|
||||
|
||||
#endif
|
||||
@@ -40,6 +40,18 @@ static inline void idr_destroy(struct idr *idr)
|
||||
(void)idr;
|
||||
}
|
||||
|
||||
struct ida {
|
||||
struct idr idr;
|
||||
};
|
||||
|
||||
#define DEFINE_IDA(name) struct ida name = { .idr = { .__opaque = {0} } }
|
||||
#define ida_init(ida) idr_init(&(ida)->idr)
|
||||
#define ida_alloc(ida, gfp) idr_alloc(&(ida)->idr, NULL, 0, 0, (u32)(gfp))
|
||||
#define ida_alloc_range(ida, start, end, gfp) idr_alloc(&(ida)->idr, NULL, (start), (end), (u32)(gfp))
|
||||
#define ida_alloc_min(ida, min, gfp) ida_alloc_range(ida, min, INT_MAX, gfp)
|
||||
#define ida_free(ida, id) idr_remove(&(ida)->idr, (id))
|
||||
#define ida_destroy(ida) idr_destroy(&(ida)->idr)
|
||||
|
||||
#define idr_for_each_entry(idr, entry, id) \
|
||||
for ((id) = 0, (entry) = (void *)0; (entry); (id)++)
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef _LINUX_SPINLOCK_TYPES_H
|
||||
#define _LINUX_SPINLOCK_TYPES_H
|
||||
|
||||
#include "spinlock.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef _LINUX_STDDEF_H
|
||||
#define _LINUX_STDDEF_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#undef NULL
|
||||
#define NULL ((void *)0)
|
||||
|
||||
#undef offsetof
|
||||
#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
|
||||
|
||||
#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
|
||||
#define offsetofend(TYPE, MEMBER) (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER))
|
||||
|
||||
#endif
|
||||
@@ -28,6 +28,14 @@ typedef u16 __u16;
|
||||
typedef u8 __u8;
|
||||
typedef s8 __s8;
|
||||
typedef s16 __s16;
|
||||
|
||||
typedef u16 __le16;
|
||||
typedef u32 __le32;
|
||||
typedef u64 __le64;
|
||||
typedef u16 __be16;
|
||||
typedef u32 __be32;
|
||||
typedef u64 __be64;
|
||||
|
||||
typedef size_t __kernel_size_t;
|
||||
#define __bitwise
|
||||
|
||||
@@ -43,18 +51,6 @@ typedef unsigned __bitwise gfp_t;
|
||||
|
||||
#define BITS_PER_LONG (8 * sizeof(long))
|
||||
|
||||
typedef struct { long long counter; } atomic_long_t;
|
||||
|
||||
#define ATOMIC_LONG_INIT(v) { .counter = (v) }
|
||||
#define atomic_long_read(v) ((v)->counter)
|
||||
#define atomic_long_set(v, i) do { (v)->counter = (i); } while (0)
|
||||
#define atomic_long_inc(v) __sync_fetch_and_add(&(v)->counter, 1)
|
||||
#define atomic_long_dec(v) __sync_fetch_and_sub(&(v)->counter, 1)
|
||||
#define atomic_long_add(i, v) __sync_fetch_and_add(&(v)->counter, (i))
|
||||
#define atomic_long_sub(i, v) __sync_fetch_and_sub(&(v)->counter, (i))
|
||||
#define atomic_long_inc_return(v) __sync_add_and_fetch(&(v)->counter, 1)
|
||||
#define atomic_long_xchg(v, n) __sync_lock_test_and_set(&(v)->counter, (n))
|
||||
|
||||
typedef unsigned int gfp_t_long_deprecated;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -32,6 +32,7 @@ TARGET_CC="${TARGET}-gcc"
|
||||
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} \
|
||||
@@ -40,6 +41,10 @@ export CFLAGS="-std=gnu11 -D__redox__ -D__KERNEL__ -DCONFIG_DRM_AMDGPU -DCONFIG_
|
||||
-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 \
|
||||
@@ -49,8 +54,6 @@ export CFLAGS="-std=gnu11 -D__redox__ -D__KERNEL__ -DCONFIG_DRM_AMDGPU -DCONFIG_
|
||||
-I${AMD_SRC}/display/dc/dcn301 \
|
||||
-I${AMD_SRC}/display/dc/dcn31 \
|
||||
-I${AMD_SRC}/display/dc/dcn32 \
|
||||
-I${AMD_SRC}/display/dc/dcn35 \
|
||||
-I${AMD_SRC}/display/dmub \
|
||||
-I${AMD_SRC}/display/modules \
|
||||
-I${AMD_SRC}/display/modules/freesync \
|
||||
-I${AMD_SRC}/display/modules/color \
|
||||
@@ -68,17 +71,16 @@ export CFLAGS="-std=gnu11 -D__redox__ -D__KERNEL__ -DCONFIG_DRM_AMDGPU -DCONFIG_
|
||||
"${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: Bounded first-display path
|
||||
# Stage 2: DCN31 hardware display files (RDNA2 GPU — Navi21/22/23/24)
|
||||
#
|
||||
# The current Red Bear AMD display bring-up path does not call into the imported
|
||||
# Linux AMD Display Core tree directly. The live FFI surface comes from the
|
||||
# Red Bear glue layer (`amdgpu_redox_main.c` / `redox_stubs.c`), while the
|
||||
# broad `display/*.c` compile currently drags in optional and unsupported
|
||||
# subtrees such as freesync before the retained path is even proven.
|
||||
#
|
||||
# Keep Stage 2 explicit and intentionally empty until a retained imported
|
||||
# display-source subset is proven necessary by bounded compile triage.
|
||||
DISPLAY_SRCS=""
|
||||
# These DCN 3.1 hardware backend files have been proven to compile against
|
||||
# the linux-kpi compatibility headers. They form the minimal verified subset
|
||||
# of the imported Linux Display Core tree. Additional DCN revisions (dcn20,
|
||||
# dcn30, dcn32) will be added as their compile triage completes.
|
||||
DISPLAY_SRCS="${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
|
||||
|
||||
Reference in New Issue
Block a user