CPU (FreeBSD): actually support temp detection

This commit is contained in:
Carter Li
2023-06-22 04:06:08 +00:00
parent f7059783dc
commit 85597e4d46
5 changed files with 30 additions and 12 deletions
+1 -1
View File
@@ -462,7 +462,7 @@ elseif(BSD)
src/detection/gtk_qt/qt.c
src/detection/sound/sound_linux.c
src/detection/swap/swap_bsd.c
src/detection/temps/temps_linux.c
src/detection/temps/temps_bsd.c
src/detection/terminalfont/terminalfont_linux.c
src/detection/terminalshell/terminalshell_linux.c
src/detection/theme/theme_linux.c
+3 -9
View File
@@ -1,5 +1,6 @@
#include "cpu.h"
#include "common/sysctl.h"
#include "detection/temps/temps_bsd.h"
const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu)
{
@@ -12,17 +13,10 @@ const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FF
cpu->frequencyMin = ffSysctlGetInt("hw.clockrate", 0) / 1000.0;
cpu->frequencyMax = cpu->frequencyMin;
cpu->temperature = FF_CPU_TEMP_UNSET;
if (options->temp)
{
FF_STRBUF_AUTO_DESTROY cpuTemp = ffStrbufCreate();
if(ffSysctlGetString("hw.acpi.thermal.tz0.temperature", &cpuTemp))
cpu->temperature = FF_CPU_TEMP_UNSET;
else
cpu->temperature = ffStrbufToDouble(&cpuTemp);
}
else
cpu->temperature = FF_CPU_TEMP_UNSET;
ffDetectThermalTemp(&cpu->temperature);
return NULL;
}
+5 -2
View File
@@ -122,7 +122,7 @@ static void pciDetectDriverName(FFGPUResult* gpu, PCIData* pci, struct pci_dev*
}
}
static void pciDetectTemperatur(FFGPUResult* gpu, struct pci_dev* device)
FF_MAYBE_UNUSED static void pciDetectTemperatur(FFGPUResult* gpu, struct pci_dev* device)
{
const FFTempsResult* tempsResult = ffDetectTemps();
@@ -171,7 +171,7 @@ static void detectType(FFGPUResult* gpu, const PCIData* pci, struct pci_dev* dev
gpu->type = FF_GPU_TYPE_INTEGRATED;
}
static void pciHandleDevice(const FFinstance* instance, const FFGPUOptions* options, FFlist* results, PCIData* pci, struct pci_dev* device)
static void pciHandleDevice(const FFinstance* instance, FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* results, PCIData* pci, struct pci_dev* device)
{
pci->ffpci_fill_info(device, PCI_FILL_CLASS);
@@ -206,8 +206,11 @@ static void pciHandleDevice(const FFinstance* instance, const FFGPUOptions* opti
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->temperature = FF_GPU_TEMP_UNSET;
#ifdef __linux__
if(options->temp)
pciDetectTemperatur(gpu, device);
#endif
}
jmp_buf pciInitJmpBuf;
+13
View File
@@ -0,0 +1,13 @@
#include "temps_bsd.h"
#include "common/sysctl.h"
const char* ffDetectThermalTemp(double* current)
{
int temp = ffSysctlGetInt("hw.acpi.thermal.tz0.temperature", -999999);
if (temp == -999999)
return "ffSysctlGetInt(\"hw.acpi.thermal.tz0.temperature\") failed";
// In tenth of degrees Kelvin
*current = (double) temp / 10 - 273.15;
return NULL;
}
+8
View File
@@ -0,0 +1,8 @@
#pragma once
#ifndef FF_INCLUDED_detection_temps_windows
#define FF_INCLUDED_detection_temps_windows
const char* ffDetectThermalTemp(double* current);
#endif