|
4 | 4 | #include "detection/gpu/gpu_driver_specific.h" |
5 | 5 | #include "common/io/io.h" |
6 | 6 | #include "common/library.h" |
| 7 | +#include "modules/gpu/option.h" |
| 8 | +#include "util/FFstrbuf.h" |
7 | 9 | #include "util/stringUtils.h" |
8 | 10 | #include "util/mallocHelper.h" |
9 | 11 |
|
10 | 12 | #include <inttypes.h> |
| 13 | +#include <stdint.h> |
11 | 14 |
|
12 | 15 | #ifdef FF_HAVE_DRM_AMDGPU |
13 | 16 | #include <amdgpu.h> |
@@ -263,7 +266,7 @@ static const char* drmDetectIntelSpecific(FFGPUResult* gpu, const char* drmKey, |
263 | 266 | #endif |
264 | 267 | } |
265 | 268 |
|
266 | | -static const char* pciDetectNouveauSpecific(const FFGPUOptions* options, FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer) |
| 269 | +static const char* pciDetectTempGeneral(const FFGPUOptions* options, FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer) |
267 | 270 | { |
268 | 271 | if (options->temp) |
269 | 272 | { |
@@ -306,6 +309,48 @@ static const char* drmDetectNouveauSpecific(FFGPUResult* gpu, const char* drmKey |
306 | 309 | #endif |
307 | 310 | } |
308 | 311 |
|
| 312 | +static const char* pciDetectZxSpecific(const FFGPUOptions* options, FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf* buffer) |
| 313 | +{ |
| 314 | + gpu->type = FF_GPU_TYPE_INTEGRATED; |
| 315 | + |
| 316 | + const uint32_t pciDirLen = pciDir->length; |
| 317 | + ffStrbufAppendS(pciDir, "/zx_info/eclk"); |
| 318 | + if (ffReadFileBuffer(pciDir->chars, buffer)) |
| 319 | + gpu->frequency = (uint32_t) ffStrbufToUInt(buffer, FF_GPU_FREQUENCY_UNSET); |
| 320 | + ffStrbufSubstrBefore(pciDir, pciDirLen); |
| 321 | + |
| 322 | + if (options->driverSpecific) |
| 323 | + { |
| 324 | + ffStrbufAppendS(pciDir, "/zx_info/engine_3d_usage"); |
| 325 | + if (ffReadFileBuffer(pciDir->chars, buffer)) |
| 326 | + gpu->coreUsage = ffStrbufToDouble(buffer, FF_GPU_CORE_USAGE_UNSET); |
| 327 | + ffStrbufSubstrBefore(pciDir, pciDirLen); |
| 328 | + |
| 329 | + ffStrbufAppendS(pciDir, "/zx_info/fb_size"); |
| 330 | + if (ffReadFileBuffer(pciDir->chars, buffer)) |
| 331 | + gpu->shared.total = ffStrbufToUInt(buffer, FF_GPU_VMEM_SIZE_UNSET); |
| 332 | + ffStrbufSubstrBefore(pciDir, pciDirLen); |
| 333 | + |
| 334 | + if (gpu->shared.total != FF_GPU_VMEM_SIZE_UNSET) |
| 335 | + { |
| 336 | + gpu->shared.total *= 1024 * 1024; |
| 337 | + |
| 338 | + ffStrbufAppendS(pciDir, "/zx_info/free_fb_mem"); |
| 339 | + if (ffReadFileBuffer(pciDir->chars, buffer)) |
| 340 | + gpu->shared.used = ffStrbufToUInt(buffer, FF_GPU_VMEM_SIZE_UNSET); |
| 341 | + ffStrbufSubstrBefore(pciDir, pciDirLen); |
| 342 | + |
| 343 | + if (gpu->shared.used != FF_GPU_VMEM_SIZE_UNSET) |
| 344 | + { |
| 345 | + gpu->shared.used *= 1024 * 1024; |
| 346 | + gpu->shared.used = gpu->shared.total - gpu->shared.used; |
| 347 | + } |
| 348 | + } |
| 349 | + } |
| 350 | + |
| 351 | + return NULL; |
| 352 | +} |
| 353 | + |
309 | 354 | static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf* buffer, FFstrbuf* deviceDir, const char* drmKey) |
310 | 355 | { |
311 | 356 | const uint32_t drmDirPathLength = deviceDir->length; |
@@ -417,10 +462,15 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf |
417 | 462 | } |
418 | 463 | else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && ffStrbufEqualS(&gpu->driver, "nouveau")) |
419 | 464 | { |
420 | | - pciDetectNouveauSpecific(options, gpu, deviceDir, buffer); |
| 465 | + pciDetectTempGeneral(options, gpu, deviceDir, buffer); |
421 | 466 | if (options->driverSpecific && drmKey) |
422 | 467 | drmDetectNouveauSpecific(gpu, drmKey, buffer); |
423 | 468 | } |
| 469 | + else if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_ZHAOXIN && ffStrbufStartsWithS(&gpu->driver, "zx")) |
| 470 | + { |
| 471 | + pciDetectTempGeneral(options, gpu, deviceDir, buffer); |
| 472 | + pciDetectZxSpecific(options, gpu, deviceDir, buffer); |
| 473 | + } |
424 | 474 | else |
425 | 475 | { |
426 | 476 | ffGPUDetectDriverSpecific(options, gpu, (FFGpuDriverPciBusId) { |
|
0 commit comments