Skip to content

Commit b3b6e5f

Browse files
committed
GPU (Linux): refactor; add amdgpu DRM connector
1 parent e0296b7 commit b3b6e5f

File tree

3 files changed

+248
-120
lines changed

3 files changed

+248
-120
lines changed

src/detection/gpu/gpu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define FF_GPU_VMEM_SIZE_UNSET ((uint64_t)-1)
88
#define FF_GPU_FREQUENCY_UNSET 0
99
#define FF_GPU_CORE_USAGE_UNSET (0/0.0)
10-
#define FF_GPU_INDEX_UNSET ((uint8_t)-1)
10+
#define FF_GPU_INDEX_UNSET ((uint32_t)-1)
1111

1212
extern const char* FF_GPU_VENDOR_NAME_APPLE;
1313
extern const char* FF_GPU_VENDOR_NAME_AMD;
@@ -40,7 +40,7 @@ typedef struct FFGPUResult
4040
uint32_t frequency; // Maximum time clock frequency in MHz
4141
FFGPUMemory dedicated;
4242
FFGPUMemory shared;
43-
uint64_t deviceId; // Used internally, may be uninitialized
43+
uint64_t deviceId;
4444
} FFGPUResult;
4545

4646
const char* ffDetectGPU(const FFGPUOptions* options, FFlist* result);

src/detection/gpu/gpu_asahi.h

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#if __aarch64__ && FF_HAVE_DRM
2+
3+
#include <drm.h>
4+
#include <fcntl.h>
5+
#include <sys/ioctl.h>
6+
7+
#if __has_include(<drm/asahi_drm.h>)
8+
9+
#include <drm/asahi_drm.h>
10+
11+
#else
12+
13+
// https://github.com/AsahiLinux/linux/blob/asahi/include/uapi/drm/asahi_drm.h
14+
/* SPDX-License-Identifier: MIT */
15+
/* Copyright (C) The Asahi Linux Contributors */
16+
17+
#define DRM_ASAHI_UNSTABLE_UABI_VERSION10011
18+
19+
#define DRM_ASAHI_GET_PARAMS0x00
20+
#define DRM_ASAHI_MAX_CLUSTERS32
21+
struct drm_asahi_params_global
22+
{
23+
__u32 unstable_uabi_version;
24+
__u32 pad0;
25+
26+
__u64 feat_compat;
27+
__u64 feat_incompat;
28+
29+
__u32 gpu_generation;
30+
__u32 gpu_variant;
31+
__u32 gpu_revision;
32+
__u32 chip_id;
33+
34+
__u32 num_dies;
35+
__u32 num_clusters_total;
36+
__u32 num_cores_per_cluster;
37+
__u32 num_frags_per_cluster;
38+
__u32 num_gps_per_cluster;
39+
__u32 num_cores_total_active;
40+
__u64 core_masks[DRM_ASAHI_MAX_CLUSTERS];
41+
42+
__u32 vm_page_size;
43+
__u32 pad1;
44+
__u64 vm_user_start;
45+
__u64 vm_user_end;
46+
__u64 vm_usc_start;
47+
__u64 vm_usc_end;
48+
__u64 vm_kernel_min_size;
49+
50+
__u32 max_syncs_per_submission;
51+
__u32 max_commands_per_submission;
52+
__u32 max_commands_in_flight;
53+
__u32 max_attachments;
54+
55+
__u32 timer_frequency_hz;
56+
__u32 min_frequency_khz;
57+
__u32 max_frequency_khz;
58+
__u32 max_power_mw;
59+
60+
__u32 result_render_size;
61+
__u32 result_compute_size;
62+
63+
__u32 firmware_version[4];
64+
};
65+
66+
struct drm_asahi_get_params
67+
{
68+
/** @extensions: Pointer to the first extension struct, if any */
69+
__u64 extensions;
70+
71+
/** @param: Parameter group to fetch (MBZ) */
72+
__u32 param_group;
73+
74+
/** @pad: MBZ */
75+
__u32 pad;
76+
77+
/** @value: User pointer to write parameter struct */
78+
__u64 pointer;
79+
80+
/** @value: Size of user buffer, max size supported on return */
81+
__u64 size;
82+
};
83+
84+
enum
85+
{
86+
DRM_IOCTL_ASAHI_GET_PARAMS = DRM_IOWR(DRM_COMMAND_BASE + DRM_ASAHI_GET_PARAMS, struct drm_asahi_get_params),
87+
};
88+
89+
#endif // __has_include
90+
91+
#endif // FF_HAVE_DRM

0 commit comments

Comments
 (0)