Skip to content

Commit 76710c8

Browse files
committed
Temps (macOS): support M4x
1 parent 70820e4 commit 76710c8

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

src/detection/cpu/cpu_apple.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ static double detectCpuTemp(const FFstrbuf* cpuName)
1515
case 1: error = ffDetectSmcTemps(FF_TEMP_CPU_M1X, &result); break;
1616
case 2: error = ffDetectSmcTemps(FF_TEMP_CPU_M2X, &result); break;
1717
case 3: error = ffDetectSmcTemps(FF_TEMP_CPU_M3X, &result); break;
18+
case 4: error = ffDetectSmcTemps(FF_TEMP_CPU_M4X, &result); break;
1819
default: error = "Unsupported Apple Silicon CPU";
1920
}
2021
}

src/detection/gpu/gpu_apple.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ static double detectGpuTemp(const FFstrbuf* gpuName)
2121
case 1: error = ffDetectSmcTemps(FF_TEMP_GPU_M1X, &result); break;
2222
case 2: error = ffDetectSmcTemps(FF_TEMP_GPU_M2X, &result); break;
2323
case 3: error = ffDetectSmcTemps(FF_TEMP_GPU_M3X, &result); break;
24+
case 4: error = ffDetectSmcTemps(FF_TEMP_GPU_M4X, &result); break;
2425
default: error = "Unsupported Apple Silicon GPU";
2526
}
2627
}

src/util/apple/smc_temps.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static const char *smcReadValue(io_connect_t conn, const UInt32Char_t key, doubl
269269
return NULL;
270270
}
271271

272-
static bool detectTemp(io_connect_t conn, const char *sensor, double* sum)
272+
static bool detectTemp(io_connect_t conn, const char* sensor, double* sum)
273273
{
274274
double temp = 0;
275275
const char* error = smcReadValue(conn, sensor, &temp);
@@ -280,7 +280,7 @@ static bool detectTemp(io_connect_t conn, const char *sensor, double* sum)
280280
return true;
281281
}
282282

283-
const char *ffDetectSmcTemps(enum FFTempType type, double *result)
283+
const char* ffDetectSmcTemps(enum FFTempType type, double* result)
284284
{
285285
static io_connect_t conn;
286286
if (!conn)
@@ -353,6 +353,21 @@ const char *ffDetectSmcTemps(enum FFTempType type, double *result)
353353
count += detectTemp(conn, "Tf4E", result); // CPU performance core 12
354354
break;
355355

356+
case FF_TEMP_CPU_M4X:
357+
count += detectTemp(conn, "Te05", result); // CPU efficiency core 1
358+
count += detectTemp(conn, "Te0S", result); // CPU efficiency core 2
359+
count += detectTemp(conn, "Te09", result); // CPU efficiency core 3
360+
count += detectTemp(conn, "Te0H", result); // CPU efficiency core 4
361+
count += detectTemp(conn, "Tp01", result); // CPU performance core 1
362+
count += detectTemp(conn, "Tp05", result); // CPU performance core 2
363+
count += detectTemp(conn, "Tp09", result); // CPU performance core 3
364+
count += detectTemp(conn, "Tp0D", result); // CPU performance core 4
365+
count += detectTemp(conn, "Tp0V", result); // CPU performance core 5
366+
count += detectTemp(conn, "Tp0Y", result); // CPU performance core 6
367+
count += detectTemp(conn, "Tp0b", result); // CPU performance core 7
368+
count += detectTemp(conn, "Tp0e", result); // CPU performance core 8
369+
break;
370+
356371
case FF_TEMP_GPU_INTEL:
357372
count += detectTemp(conn, "TCGC", result); // GPU Intel Graphics
358373
goto gpu_unknown;
@@ -390,6 +405,19 @@ const char *ffDetectSmcTemps(enum FFTempType type, double *result)
390405
count += detectTemp(conn, "Tf2A", result); // GPU 8
391406
break;
392407

408+
case FF_TEMP_GPU_M4X:
409+
count += detectTemp(conn, "Tg0G", result); // GPU 1 (Basic)
410+
count += detectTemp(conn, "Tg0H", result); // GPU 2 (Basic)
411+
count += detectTemp(conn, "Tg1U", result); // GPU 1 (Pro / Max)
412+
count += detectTemp(conn, "Tg1k", result); // GPU 2 (Pro / Max)
413+
count += detectTemp(conn, "Tg0K", result); // GPU 3
414+
count += detectTemp(conn, "Tg0L", result); // GPU 4
415+
count += detectTemp(conn, "Tg0d", result); // GPU 5
416+
count += detectTemp(conn, "Tg0e", result); // GPU 6
417+
count += detectTemp(conn, "Tg0j", result); // GPU 7
418+
count += detectTemp(conn, "Tg0k", result); // GPU 8
419+
break;
420+
393421
case FF_TEMP_BATTERY:
394422
count += detectTemp(conn, "TB1T", result); // Battery
395423
count += detectTemp(conn, "TB2T", result); // Battery

src/util/apple/smc_temps.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ enum FFTempType
1515
FF_TEMP_CPU_M1X,
1616
FF_TEMP_CPU_M2X,
1717
FF_TEMP_CPU_M3X,
18+
FF_TEMP_CPU_M4X,
1819

1920
FF_TEMP_GPU_INTEL,
2021
FF_TEMP_GPU_AMD,
2122
FF_TEMP_GPU_UNKNOWN,
2223
FF_TEMP_GPU_M1X,
2324
FF_TEMP_GPU_M2X,
2425
FF_TEMP_GPU_M3X,
26+
FF_TEMP_GPU_M4X,
2527

2628
FF_TEMP_BATTERY,
2729

2830
FF_TEMP_MEMORY,
2931
};
3032

31-
const char *ffDetectSmcTemps(enum FFTempType type, double* result);
33+
const char* ffDetectSmcTemps(enum FFTempType type, double* result);

0 commit comments

Comments
 (0)