@@ -263,6 +263,34 @@ static const char* drmDetectIntelSpecific(FFGPUResult* gpu, const char* drmKey,
263263 #endif
264264}
265265
266+ static const char * pciDetectNouveauSpecific (const FFGPUOptions * options , FFGPUResult * gpu , FFstrbuf * pciDir , FFstrbuf * buffer )
267+ {
268+ if (options -> temp )
269+ {
270+ const uint32_t pciDirLen = pciDir -> length ;
271+ ffStrbufAppendS (pciDir , "/hwmon/" );
272+ FF_AUTO_CLOSE_DIR DIR * dirp = opendir (pciDir -> chars );
273+ if (dirp )
274+ {
275+ struct dirent * entry ;
276+ while ((entry = readdir (dirp )))
277+ {
278+ if (entry -> d_name [0 ] == '.' ) continue ;
279+ ffStrbufAppendS (pciDir , entry -> d_name );
280+ ffStrbufAppendS (pciDir , "/temp1_input" );
281+ if (ffReadFileBuffer (pciDir -> chars , buffer ))
282+ {
283+ uint64_t value = ffStrbufToUInt (buffer , 0 );
284+ if (value > 0 ) gpu -> temperature = (double ) value / 1000.0 ;
285+ }
286+ break ;
287+ }
288+ }
289+ ffStrbufSubstrBefore (pciDir , pciDirLen );
290+ }
291+ return NULL ;
292+ }
293+
266294static const char * drmDetectNouveauSpecific (FFGPUResult * gpu , const char * drmKey , FFstrbuf * buffer )
267295{
268296 #if FF_HAVE_DRM
@@ -386,6 +414,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
386414 }
387415 else if (gpu -> vendor .chars == FF_GPU_VENDOR_NAME_NVIDIA && ffStrbufEqualS (& gpu -> driver , "nouveau" ))
388416 {
417+ pciDetectNouveauSpecific (options , gpu , deviceDir , buffer );
389418 if (options -> driverSpecific && drmKey )
390419 drmDetectNouveauSpecific (gpu , drmKey , buffer );
391420 }
0 commit comments