Skip to content

Commit e57bef6

Browse files
Allow to specify path to live PowerPlay table with --sysfs-device-path.
1 parent 65aa27b commit e57bef6

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

ohgodatool-args.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
void PrintUsage(char *BinName)
1010
{
1111
printf("OhGodATool %s\n", OHGODATOOL_VERSION);
12-
printf("Usage: %s [-i GPUIdx | -f VBIOSFile] [Generic Options] [--core-state StateIdx] [--mem-state StateIdx] [--volt-state StateIdx] [State modification options]\n", BinName);
12+
printf("Usage: %s [-i GPUIdx | -f VBIOSFile] [Generic Options] [sysfs options] [--core-state StateIdx] [--mem-state StateIdx] [--volt-state StateIdx] [State modification options]\n", BinName);
1313
printf("Generic modification options:\n");
1414
printf("\t--set-fanspeed <percent>\n\t--set-tdp <W>\n\t--set-tdc <W>\n\t--set-max-power <W>\n");
1515
printf("\t--set-max-core-clock <Mhz>\n\t--set-max-mem-clock <Mhz>\n");
16+
printf("sysfs options:\n");
17+
printf("\t--sysfs-device-path <path>\tSets the device path in sysfs (used only together with -i GPUIdx)\n");
1618
printf("State selection options (must be used before state modification options; -1 indicates last existing state):\n");
1719
printf("\t--core-state <index>\n\t--mem-state <index>\n\t--volt-state <index>\n");
1820
printf("State modification options:\n");
@@ -57,6 +59,12 @@ bool ParseCmdLine(ArgsObj *Args, int argc, char **argv)
5759
Args->VBIOSFileName = strdup(argv[++i]);
5860
Args->VBIOSFileProvided = true;
5961
}
62+
else if (!strcmp("--sysfs-device-path", argv[i]))
63+
{
64+
NEXT_ARG_CHECK();
65+
Args->sysfsDevicePath = strdup(argv[++i]);
66+
Args->sysfsDevicePathProvided = true;
67+
}
6068
else if(!strcmp("--mem-state", argv[i]))
6169
{
6270
NEXT_ARG_CHECK();

ohgodatool.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ int main(int argc, char **argv)
7979
}
8080
else
8181
{
82-
sprintf(FilePath, "/sys/class/drm/card%d/device/pp_table", Config.GPUIdx);
82+
if (Config.sysfsDevicePathProvided)
83+
sprintf(FilePath, "%s/pp_table", Config.sysfsDevicePath);
84+
else
85+
sprintf(FilePath, "/sys/class/drm/card%d/device/pp_table", Config.GPUIdx);
8386

8487
PPFile = fopen(FilePath, "rb+");
8588

ohgodatool.h

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ typedef struct _ArgsObj
1212
bool GPUIdxProvided, VoltageStateIdxProvided, SetCoreVDDCIdx, SetVDDCI, SetMVDD, SetCoreVDDCOff, SetVDDCGFXOff;
1313
bool SetTDP, SetTDC, SetMaxPower, SetMaxCoreClk, SetMaxMemClk, VBIOSFileProvided;
1414

15+
bool sysfsDevicePathProvided;
16+
char *sysfsDevicePath;
17+
1518
bool ShowMemStates, ShowCoreStates, ShowVoltageStates, ShowFanspeed, ShowTemp;
1619

1720
int32_t MemStateIdx, CoreStateIdx, VoltStateIdx;

0 commit comments

Comments
 (0)