This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository enlightenment.

View the commit online.

commit cffaa41734bcaabc415dca446f43f6b442b2fdab
Author: Carsten Haitzler <[email protected]>
AuthorDate: Sun Jan 25 12:27:36 2026 +0000

    e system - cpufreq - set gpu to match cpu power level for amdgpu
    
    adds amdgpu support for power level alongside cpu
---
 src/bin/system/e_system_cpufreq.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/src/bin/system/e_system_cpufreq.c b/src/bin/system/e_system_cpufreq.c
index 95e24ef22..431373989 100644
--- a/src/bin/system/e_system_cpufreq.c
+++ b/src/bin/system/e_system_cpufreq.c
@@ -189,6 +189,39 @@ sys_cpu_pwr_energy_set(int v)
   return 1;
 }
 
+static int
+sys_gpu_amdgpu_pwr_energy_set(int v)
+{
+  const char *path = "/sys/bus/pci/drivers/amdgpu";
+  const char *lv_str[4] = { "low", "auto", "auto", "high" };
+  const char *s;
+  Eina_Iterator *it;
+  char buf[PATH_MAX];
+  FILE *f;
+  int ret = 0;
+
+  it = eina_file_ls(path);
+  if (!it) return ret;
+  // find dirs with : in name for pciid and look for perf level file
+  EINA_ITERATOR_FOREACH(it, s)
+    {
+      if (!s) continue;
+      if (strchr(s, ':'))
+        {
+          snprintf(buf, sizeof(buf), "%s/power_dpm_force_performance_level", s);
+          f = fopen(buf, "w");
+          if (f)
+            { //  found perf level file - write string
+              if (fwrite(lv_str[v], strlen(lv_str[v]), 1, f) == 1) ret = 1;
+              fclose(f);
+            }
+        }
+      eina_stringshare_del(s);
+    }
+  eina_iterator_free(it);
+  return ret;
+}
+
 static int
 sys_cpu_pwr_pstate_set(int v)
 {
@@ -280,6 +313,9 @@ _cb_cpufreq_pwr_set(void *data EINA_UNUSED, const char *params)
           if (!sys_cpu_pwr_governor_set(v)) goto err;
         }
     }
+  // if we have amd gpus - try this
+  sys_gpu_amdgpu_pwr_energy_set(v);
+  // XXX: in future support other gpu drivers?
   e_system_inout_command_send("cpufreq-pwr-set", "ok");
   return;
 err:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to