@@ -105,14 +105,19 @@ FF_MAYBE_UNUSED static const char* drmFindRenderFromCard(const char* drmCardKey,
105
105
106
106
static const char * drmDetectAmdSpecific (const FFGPUOptions * options , FFGPUResult * gpu , const char * drmKey , FFstrbuf * buffer )
107
107
{
108
- #if FF_HAVE_DRM_AMDGPU
109
108
const char * error = drmFindRenderFromCard (drmKey , buffer );
110
109
if (error ) return error ;
111
- return ffDrmDetectAmdgpu (options , gpu , buffer -> chars );
112
- #else
113
- FF_UNUSED (options , gpu , drmKey , buffer );
114
- return "Fastfetch is not compiled with libdrm_amdgpu support" ;
110
+ if (ffStrbufEqualS (& gpu -> driver , "radeon" ))
111
+ return ffDrmDetectRadeon (options , gpu , buffer -> chars );
112
+ else
113
+ {
114
+ #if FF_HAVE_DRM_AMDGPU
115
+ return ffDrmDetectAmdgpu (options , gpu , buffer -> chars );
116
+ #else
117
+ FF_UNUSED (options , gpu , drmKey , buffer );
118
+ return "Fastfetch is not compiled with libdrm_amdgpu support" ;
115
119
#endif
120
+ }
116
121
}
117
122
118
123
static void pciDetectAmdSpecific (const FFGPUOptions * options , FFGPUResult * gpu , FFstrbuf * pciDir , FFstrbuf * buffer )
@@ -135,47 +140,50 @@ static void pciDetectAmdSpecific(const FFGPUOptions* options, FFGPUResult* gpu,
135
140
ffStrbufAppendC (pciDir , '/' );
136
141
137
142
const uint32_t hwmonLen = pciDir -> length ;
138
- ffStrbufAppendS (pciDir , "in1_input" ); // Northbridge voltage in millivolts (APUs only)
139
- if (ffPathExists (pciDir -> chars , FF_PATHTYPE_ANY ))
140
- gpu -> type = FF_GPU_TYPE_INTEGRATED ;
141
- else
142
- gpu -> type = FF_GPU_TYPE_DISCRETE ;
143
-
144
143
uint64_t value = 0 ;
145
144
if (options -> temp )
146
145
{
147
- ffStrbufSubstrBefore (pciDir , hwmonLen );
148
146
ffStrbufAppendS (pciDir , "temp1_input" ); // The on die GPU temperature in millidegrees Celsius
149
147
if (ffReadFileBuffer (pciDir -> chars , buffer ) && (value = ffStrbufToUInt (buffer , 0 )))
150
148
gpu -> temperature = (double ) value / 1000 ;
151
149
}
152
150
153
- if (options -> driverSpecific )
151
+ if (ffStrbufEqualS ( & gpu -> driver , "amdgpu" )) // Ancient radeon drivers don't have these files
154
152
{
155
- ffStrbufSubstrBefore (pciDir , pciDirLen );
156
- ffStrbufAppendS (pciDir , "/mem_info_vis_vram_total" );
157
- if (ffReadFileBuffer (pciDir -> chars , buffer ) && (value = ffStrbufToUInt (buffer , 0 )))
158
- {
159
- if (gpu -> type == FF_GPU_TYPE_DISCRETE )
160
- gpu -> dedicated .total = value ;
161
- else
162
- gpu -> shared .total = value ;
153
+ ffStrbufSubstrBefore (pciDir , hwmonLen );
154
+ ffStrbufAppendS (pciDir , "in1_input" ); // Northbridge voltage in millivolts (APUs only)
155
+ if (ffPathExists (pciDir -> chars , FF_PATHTYPE_ANY ))
156
+ gpu -> type = FF_GPU_TYPE_INTEGRATED ;
157
+ else
158
+ gpu -> type = FF_GPU_TYPE_DISCRETE ;
163
159
164
- ffStrbufSubstrBefore (pciDir , pciDir -> length - (uint32_t ) strlen ("/mem_info_vis_vram_total" ));
165
- ffStrbufAppendS (pciDir , "/mem_info_vis_vram_used" );
160
+ if (options -> driverSpecific )
161
+ {
162
+ ffStrbufSubstrBefore (pciDir , pciDirLen );
163
+ ffStrbufAppendS (pciDir , "/mem_info_vis_vram_total" );
166
164
if (ffReadFileBuffer (pciDir -> chars , buffer ) && (value = ffStrbufToUInt (buffer , 0 )))
167
165
{
168
166
if (gpu -> type == FF_GPU_TYPE_DISCRETE )
169
- gpu -> dedicated .used = value ;
167
+ gpu -> dedicated .total = value ;
170
168
else
171
- gpu -> shared .used = value ;
169
+ gpu -> shared .total = value ;
170
+
171
+ ffStrbufSubstrBefore (pciDir , pciDir -> length - (uint32_t ) strlen ("/mem_info_vis_vram_total" ));
172
+ ffStrbufAppendS (pciDir , "/mem_info_vis_vram_used" );
173
+ if (ffReadFileBuffer (pciDir -> chars , buffer ) && (value = ffStrbufToUInt (buffer , 0 )))
174
+ {
175
+ if (gpu -> type == FF_GPU_TYPE_DISCRETE )
176
+ gpu -> dedicated .used = value ;
177
+ else
178
+ gpu -> shared .used = value ;
179
+ }
172
180
}
173
- }
174
181
175
- ffStrbufSubstrBefore (pciDir , pciDirLen );
176
- ffStrbufAppendS (pciDir , "/gpu_busy_percent" );
177
- if (ffReadFileBuffer (pciDir -> chars , buffer ) && (value = ffStrbufToUInt (buffer , 0 )))
178
- gpu -> coreUsage = (double ) value ;
182
+ ffStrbufSubstrBefore (pciDir , pciDirLen );
183
+ ffStrbufAppendS (pciDir , "/gpu_busy_percent" );
184
+ if (ffReadFileBuffer (pciDir -> chars , buffer ) && (value = ffStrbufToUInt (buffer , 0 )))
185
+ gpu -> coreUsage = (double ) value ;
186
+ }
179
187
}
180
188
}
181
189
0 commit comments