adjustor 2.1.6__tar.gz → 3.0.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. {adjustor-2.1.6/src/adjustor.egg-info → adjustor-3.0.0}/PKG-INFO +2 -1
  2. {adjustor-2.1.6 → adjustor-3.0.0}/pyproject.toml +2 -1
  3. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/core/const.py +1 -0
  4. adjustor-3.0.0/src/adjustor/drivers/amd/__init__.py +97 -0
  5. adjustor-3.0.0/src/adjustor/drivers/amd/settings.yml +42 -0
  6. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/drivers/asus/__init__.py +17 -6
  7. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/drivers/asus/settings.yml +11 -11
  8. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/drivers/lenovo/__init__.py +29 -5
  9. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/drivers/smu/__init__.py +15 -2
  10. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/events.py +3 -3
  11. adjustor-3.0.0/src/adjustor/fuse/__init__.py +3 -0
  12. adjustor-3.0.0/src/adjustor/fuse/driver.py +392 -0
  13. adjustor-3.0.0/src/adjustor/fuse/gpu.py +91 -0
  14. adjustor-3.0.0/src/adjustor/fuse/utils.py +169 -0
  15. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/hhd.py +109 -34
  16. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/settings.yml +31 -3
  17. {adjustor-2.1.6 → adjustor-3.0.0/src/adjustor.egg-info}/PKG-INFO +2 -1
  18. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor.egg-info/SOURCES.txt +7 -2
  19. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor.egg-info/requires.txt +1 -0
  20. adjustor-2.1.6/src/adjustor/utils.py +0 -24
  21. {adjustor-2.1.6 → adjustor-3.0.0}/LICENSE +0 -0
  22. {adjustor-2.1.6 → adjustor-3.0.0}/MANIFEST.in +0 -0
  23. {adjustor-2.1.6 → adjustor-3.0.0}/readme.md +0 -0
  24. {adjustor-2.1.6 → adjustor-3.0.0}/setup.cfg +0 -0
  25. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/__init__.py +0 -0
  26. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/__main__.py +0 -0
  27. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/core/__init__.py +0 -0
  28. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/core/acpi.py +0 -0
  29. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/core/alib.py +0 -0
  30. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/core/lenovo.py +0 -0
  31. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/core/platform.py +0 -0
  32. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/drivers/__init__.py +0 -0
  33. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/drivers/lenovo/settings.yml +0 -0
  34. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/drivers/smu/qam.yml +0 -0
  35. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/drivers/smu/smu.yml +0 -0
  36. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor/i18n.py +0 -0
  37. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor.egg-info/dependency_links.txt +0 -0
  38. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor.egg-info/entry_points.txt +0 -0
  39. {adjustor-2.1.6 → adjustor-3.0.0}/src/adjustor.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: adjustor
3
- Version: 2.1.6
3
+ Version: 3.0.0
4
4
  Summary: Adjustor, a userspace program for managing the TDP of handheld devices.
5
5
  Author-email: Kapenekakis Antheas <pypi@antheas.dev>
6
6
  Project-URL: Homepage, https://github.com/hhd-dev/adjustor
@@ -15,6 +15,7 @@ Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
16
  Requires-Dist: rich>=13.5.2
17
17
  Requires-Dist: pyroute2>=0.7.3
18
+ Requires-Dist: fuse-python>=1.0.7
18
19
 
19
20
  # Adjustor
20
21
  Home of the Adjustor TDP plugin for Handheld Daemon.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "adjustor"
3
- version = "2.1.6"
3
+ version = "3.0.0"
4
4
  authors = [
5
5
  { name="Kapenekakis Antheas", email="pypi@antheas.dev" },
6
6
  ]
@@ -18,6 +18,7 @@ classifiers = [
18
18
  dependencies = [
19
19
  "rich>=13.5.2",
20
20
  "pyroute2>=0.7.3",
21
+ "fuse-python>=1.0.7",
21
22
  ]
22
23
 
23
24
  [project.urls]
@@ -54,4 +54,5 @@ CPU_DATA: dict[str, tuple[dict[str, DeviceParams], dict[str, AlibParams]]] = {
54
54
  "AMD Ryzen 7 6800U": (DEV_PARAMS_6040, ALIB_PARAMS_6040),
55
55
  "AMD Ryzen 7 7840U": (DEV_PARAMS_7040, ALIB_PARAMS_7040),
56
56
  "AMD Ryzen 7 8840U": (DEV_PARAMS_8040, ALIB_PARAMS_8040),
57
+ # AMD Athlon Silver 3050e (Win600, will it support tdp?)
57
58
  }
@@ -0,0 +1,97 @@
1
+ import logging
2
+
3
+ from hhd.plugins import Context, HHDPlugin, load_relative_yaml
4
+ from hhd.plugins.conf import Config
5
+
6
+ from adjustor.fuse.gpu import (
7
+ get_igpu_status,
8
+ set_gpu_auto,
9
+ set_gpu_manual,
10
+ set_cpu_boost,
11
+ )
12
+
13
+ logger = logging.getLogger(__name__)
14
+
15
+
16
+ class AmdGPUPlugin(HHDPlugin):
17
+
18
+ def __init__(
19
+ self,
20
+ ) -> None:
21
+ self.name = f"adjustor_gpu"
22
+ self.priority = 8
23
+ self.log = "agpu"
24
+ self.enabled = False
25
+ self.initialized = False
26
+ self.old_mode = None
27
+ self.old_freq = None
28
+ self.supports_boost = False
29
+ self.old_boost = None
30
+ self.logged_boost = False
31
+
32
+ def settings(self):
33
+ if not self.enabled:
34
+ self.initialized = False
35
+ return {}
36
+
37
+ status = get_igpu_status()
38
+ if not status:
39
+ logger.error("Could not get frequency status. Disabling AMD GPU plugin.")
40
+ return {}
41
+
42
+ self.initialized = True
43
+ sets = load_relative_yaml("./settings.yml")
44
+
45
+ freq = sets["children"]["level"]["modes"]["manual"]["children"]["frequency"]
46
+ freq["min"] = status.freq_min
47
+ freq["max"] = status.freq_max
48
+ freq["default"] = ((status.freq_min + status.freq_max) // 200) * 100
49
+
50
+ self.supports_boost = status.cpu_boost is not None
51
+ if self.supports_boost:
52
+ if not self.logged_boost:
53
+ logger.info(f"CPU Boost toggling is supported.")
54
+ else:
55
+ if not self.logged_boost:
56
+ logger.warning(f"CPU Boost toggling is not supported.")
57
+ del sets["children"]["cpu_boost"]
58
+ self.logged_boost = True
59
+ return {"tdp": {"amd_gpu": sets}}
60
+
61
+ def open(
62
+ self,
63
+ emit,
64
+ context: Context,
65
+ ):
66
+ self.emit = emit
67
+
68
+ def update(self, conf: Config):
69
+ self.enabled = conf["hhd.settings.tdp_enable"].to(bool)
70
+ if not self.initialized:
71
+ return
72
+
73
+ new_mode = conf["tdp.amd_gpu.level.mode"].to(str)
74
+ new_freq = conf["tdp.amd_gpu.level.manual.frequency"].to(int)
75
+ if new_mode != self.old_mode or new_freq != self.old_freq:
76
+ self.old_mode = new_mode
77
+ self.old_freq = new_freq
78
+
79
+ try:
80
+ if new_mode == "manual":
81
+ set_gpu_manual(new_freq)
82
+ else:
83
+ set_gpu_auto()
84
+ except Exception as e:
85
+ logger.error(f"Failed to set GPU mode:\n{e}")
86
+
87
+ if self.supports_boost:
88
+ new_boost = conf["tdp.amd_gpu.cpu_boost"].to(bool)
89
+ if new_boost != self.old_boost:
90
+ self.old_boost = new_boost
91
+ try:
92
+ set_cpu_boost(new_boost)
93
+ except Exception as e:
94
+ logger.error(f"Failed to set CPU boost:\n{e}")
95
+
96
+ def close(self):
97
+ pass
@@ -0,0 +1,42 @@
1
+ title: GPU Settings
2
+ type: container
3
+ tags: [ hide-title ]
4
+ children:
5
+ level:
6
+ type: mode
7
+ title: GPU Frequency
8
+ hint: >-
9
+ Pins the GPU to a certain frequency.
10
+ Helps in certain games that are CPU or GPU heavy
11
+ by shifting power to or from the GPU.
12
+ Has a minor effect.
13
+ default: auto
14
+ modes:
15
+ auto:
16
+ type: container
17
+ title: Auto
18
+ hint: >-
19
+ Lets the GPU manage its own frequency.
20
+ manual:
21
+ type: container
22
+ title: Manual
23
+ hint: >-
24
+ Sets the GPU frequency manually.
25
+ children:
26
+ frequency:
27
+ title: Frequency
28
+ unit: MHz
29
+ type: int
30
+ min: 300
31
+ max: 2000
32
+ step: 100
33
+ default: 1000
34
+
35
+ cpu_boost:
36
+ type: bool
37
+ title: CPU Boost
38
+ default: True
39
+ hint: >-
40
+ Enables or disables the CPU boost frequencies.
41
+ Disabling lowers total consumption by 2W with
42
+ minimal performance impact.
@@ -1,11 +1,11 @@
1
1
  import logging
2
- import time
3
- from typing import cast
4
2
  import os
3
+ import time
4
+ from typing import Sequence
5
+
6
+ from hhd.plugins import Config, Context, Event, HHDPlugin, load_relative_yaml
5
7
 
6
- from hhd.plugins import Context, HHDPlugin, load_relative_yaml
7
- from hhd.plugins.conf import Config
8
- from adjustor.core.platform import get_platform_choices, set_platform_profile
8
+ from adjustor.core.platform import set_platform_profile
9
9
 
10
10
  logger = logging.getLogger(__name__)
11
11
 
@@ -123,6 +123,7 @@ class AsusDriverPlugin(HHDPlugin):
123
123
 
124
124
  self.queue_fan = None
125
125
  self.queue_tdp = None
126
+ self.new_tdp = None
126
127
 
127
128
  def settings(self):
128
129
  if not self.enabled:
@@ -198,7 +199,12 @@ class AsusDriverPlugin(HHDPlugin):
198
199
  pass
199
200
 
200
201
  # Check user changed values
201
- steady = conf["tdp.asus.tdp"].to(int)
202
+ if self.new_tdp:
203
+ steady = self.new_tdp
204
+ self.new_tdp = None
205
+ conf["tdp.asus.tdp"] = steady
206
+ else:
207
+ steady = conf["tdp.asus.tdp"].to(int)
202
208
 
203
209
  steady_updated = steady and steady != self.old_conf["tdp"].to(int)
204
210
 
@@ -302,5 +308,10 @@ class AsusDriverPlugin(HHDPlugin):
302
308
  if self.startup:
303
309
  self.startup = False
304
310
 
311
+ def notify(self, events: Sequence[Event]):
312
+ for ev in events:
313
+ if ev["type"] == "tdp":
314
+ self.new_tdp = ev["tdp"]
315
+
305
316
  def close(self):
306
317
  pass
@@ -113,14 +113,14 @@ children:
113
113
  p95: 95%
114
114
  default: disabled
115
115
 
116
- disclaimer:
117
- title: Sleep Bug
118
- type: display
119
- tags: [ non-essential ]
120
- default: >-
121
- There is an Asus kernel/BIOS bug that will sometimes limit TDP to 10W
122
- after sleep.
123
- As the kernel driver is used, this is unfixable from within
124
- Handheld Daemon (currently investigated).
125
- As an alternative, use SimpleDeckyTDP with RyzenAdj after
126
- disabling TDP controls from "Settings".
116
+ # disclaimer:
117
+ # title: Sleep Bug
118
+ # type: display
119
+ # tags: [ non-essential ]
120
+ # default: >-
121
+ # There is an Asus kernel/BIOS bug that will sometimes limit TDP to 10W
122
+ # after sleep.
123
+ # As the kernel driver is used, this is unfixable from within
124
+ # Handheld Daemon (currently investigated).
125
+ # As an alternative, use SimpleDeckyTDP with RyzenAdj after
126
+ # disabling TDP controls from "Settings".
@@ -1,8 +1,8 @@
1
1
  import logging
2
2
  import time
3
- from typing import cast
3
+ from typing import Sequence, cast
4
4
 
5
- from hhd.plugins import Context, HHDPlugin, HHDSettings, load_relative_yaml
5
+ from hhd.plugins import Context, Event, HHDPlugin, load_relative_yaml
6
6
  from hhd.plugins.conf import Config
7
7
 
8
8
  from adjustor.core.lenovo import (
@@ -24,8 +24,8 @@ from adjustor.core.lenovo import (
24
24
 
25
25
  logger = logging.getLogger(__name__)
26
26
 
27
- APPLY_DELAY = 2.2
28
- TDP_DELAY = 0.2
27
+ APPLY_DELAY = 0.5
28
+ TDP_DELAY = 0
29
29
 
30
30
 
31
31
  class LenovoDriverPlugin(HHDPlugin):
@@ -42,6 +42,7 @@ class LenovoDriverPlugin(HHDPlugin):
42
42
 
43
43
  self.queue_fan = None
44
44
  self.queue_tdp = None
45
+ self.new_tdp = None
45
46
 
46
47
  def settings(self):
47
48
  if not self.enabled:
@@ -119,7 +120,22 @@ class LenovoDriverPlugin(HHDPlugin):
119
120
  #
120
121
 
121
122
  # Update tdp mode if user changed through the app
122
- mode = conf["tdp.lenovo.tdp.mode"].to(str)
123
+ new_tdp = self.new_tdp
124
+ self.new_tdp = None
125
+ if new_tdp:
126
+ # For TDP values received from steam, set the appropriate
127
+ # mode to get a better experience.
128
+ if new_tdp == 8:
129
+ mode = "quiet"
130
+ elif new_tdp == 15:
131
+ mode = "balanced"
132
+ elif new_tdp == 20:
133
+ mode = "performance"
134
+ else:
135
+ mode = "custom"
136
+ conf["tdp.lenovo.tdp.mode"] = mode
137
+ else:
138
+ mode = conf["tdp.lenovo.tdp.mode"].to(str)
123
139
  if mode is not None and mode != self.old_conf["tdp.mode"].to(str):
124
140
  set_tdp_mode(cast(TdpMode, mode))
125
141
  tdp_reset = True
@@ -146,6 +162,9 @@ class LenovoDriverPlugin(HHDPlugin):
146
162
  if new_mode == "custom":
147
163
  # Check user changed values
148
164
  steady = conf["tdp.lenovo.tdp.custom.tdp"].to(int)
165
+ if new_tdp:
166
+ steady = new_tdp
167
+ conf["tdp.lenovo.tdp.custom.tdp"] = steady
149
168
 
150
169
  old_steady = steady
151
170
  if self.enforce_limits:
@@ -243,5 +262,10 @@ class LenovoDriverPlugin(HHDPlugin):
243
262
  if self.startup:
244
263
  self.startup = False
245
264
 
265
+ def notify(self, events: Sequence[Event]):
266
+ for ev in events:
267
+ if ev["type"] == "tdp":
268
+ self.new_tdp = ev["tdp"]
269
+
246
270
  def close(self):
247
271
  pass
@@ -1,11 +1,12 @@
1
1
  import logging
2
2
  import time
3
3
 
4
- from hhd.plugins import Context, HHDPlugin, load_relative_yaml
4
+ from hhd.plugins import Context, HHDPlugin, load_relative_yaml, Event
5
5
  from hhd.plugins.conf import Config
6
6
 
7
7
  from adjustor.core.alib import AlibParams, DeviceParams, alib
8
8
  from adjustor.core.platform import get_platform_choices, set_platform_profile
9
+ from typing import Sequence
9
10
 
10
11
  logger = logging.getLogger(__name__)
11
12
 
@@ -35,6 +36,7 @@ class SmuQamPlugin(HHDPlugin):
35
36
 
36
37
  self.old_tdp = None
37
38
  self.old_boost = None
39
+ self.new_tdp = None
38
40
  self.is_set = False
39
41
  self.lims = self.dev.get("skin_limit", self.dev.get("stapm_limit", None))
40
42
 
@@ -97,7 +99,13 @@ class SmuQamPlugin(HHDPlugin):
97
99
  return
98
100
 
99
101
  curr = time.time()
100
- new_tdp = conf["tdp.qam.tdp"].to(int)
102
+ if self.new_tdp:
103
+ new_tdp = self.new_tdp
104
+ self.new_tdp = None
105
+ conf["tdp.qam.tdp"] = new_tdp
106
+ else:
107
+ new_tdp = conf["tdp.qam.tdp"].to(int)
108
+
101
109
  if self.startup and self.lims:
102
110
  _, smin, _, smax, _ = self.lims
103
111
  if smin and new_tdp < smin:
@@ -313,5 +321,10 @@ class SmuDriverPlugin(HHDPlugin):
313
321
  else:
314
322
  conf["tdp.smu.status"] = "Not Set"
315
323
 
324
+ def notify(self, events: Sequence[Event]):
325
+ for ev in events:
326
+ if ev["type"] == "tdp":
327
+ self.new_tdp = ev["tdp"]
328
+
316
329
  def close(self):
317
330
  pass
@@ -9,8 +9,8 @@ from pyroute2 import AcpiEventSocket # type: ignore
9
9
  logger = logging.getLogger(__name__)
10
10
 
11
11
  EVENT_MATCHES: Sequence[tuple[dict[str, Any], str]] = [
12
- ({"device_class": "ac_adapter", "data": 0}, "dc"),
13
- ({"device_class": "ac_adapter", "data": 256}, "ac"),
12
+ ({"device_class": b"ac_adapter", "data": 0}, "dc"),
13
+ ({"device_class": b"ac_adapter", "data": 256}, "ac"),
14
14
  ({"device_class": b"battery"}, "battery"),
15
15
  # Legion GO TDP event
16
16
  ({"bus_id": b"D320289E-8FEA-"}, "tdp"),
@@ -44,7 +44,7 @@ def loop_process_events(emit: Emitter, should_exit: TEvent):
44
44
 
45
45
  if matches:
46
46
  if etype != "battery":
47
- emit({"type": "acpi", "event": etype})
47
+ emit({"type": "acpi", "event": etype}) # type: ignore
48
48
  found = True
49
49
  break
50
50
 
@@ -0,0 +1,3 @@
1
+ from .utils import start_tdp_client, prepare_tdp_mount
2
+
3
+ __all__ = ["start_tdp_client", "prepare_tdp_mount"]