Commit graph

196 commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
b75275c757 power-profiles-daemon: Add debug info when the bus names are aquired 2024-02-14 17:38:39 +01:00
Mario Limonciello
18a9c66681 Use python argparse and decorators instead of reinventing both 2024-02-14 10:37:14 -06:00
Mario Limonciello
718fde54d2 Don't modify powerprofilesctl at build time
Python version and binary used at build time might not be the same
as the installed OS.  Instead reference python3 from environment.
2024-02-14 00:03:31 -06:00
Mario Limonciello
c750f7e791 Reformat powerprofilesctl.in with black 2024-02-14 00:03:31 -06:00
Mario Limonciello
ba2cf0d6f8 Add a Version property and read it with powerprofilesctl 2024-02-14 00:03:28 -06:00
Marco Trevisan (Treviño)
40f3361473 power-profiles-daemon: Emit ProfileReleased when an holder is released
We used to send the signal only when cleaning up the holders, but we
should notify them also when an holder has been released for whatever
reason.
2024-02-14 05:17:49 +00:00
Marco Trevisan (Treviño)
91e907e11f power-profiles-daemon: Emit requester released signal on matching iface/path 2024-02-14 05:17:49 +00:00
Mario Limonciello
e5b107a625 Send signals on both interfaces
Some clients (notably GNOME) look specifically for both the path and
interface.  To avoid breaking them on profile change events make sure
to emit signals on both the legacy and modern interface.
2024-02-14 05:17:49 +00:00
Mario Limonciello
70849a6686 amdgpu: Handle disconnected panels correctly
Some systems have multiple GPUs with an eDP output but the panel
isn't connected to all of them (or it's controlled by a mux).

Handle this case by ensuring that the panel is connected when
before writing an attribute.
2024-02-13 23:20:42 +00:00
Mario Limonciello
07a77652b1 Add support for POWER_PROFILE_DAEMON_ACTION_BLOCK
This can let people avoid loading actions that on their system
in the event of a problem or desire not to use.
2024-02-13 23:20:42 +00:00
Mario Limonciello
41ed5d33a8 Add support for a amdgpu panel power savings action
This activates the DRM connector attribute `panel_power_savings`
which takes a range from 0 to 4 to indicate how aggresively to enable
panel power savings.

Link: https://lore.kernel.org/amd-gfx/0b94b25a-9ffa-41a5-b931-ad84e1892d36@amd.com/T/#m079d7c357626cf3a80cd9ba6239b3fe4fcf8937e
2024-02-13 23:20:42 +00:00
Mario Limonciello
9a740c02d6 Add a ppd_utils_write_sysfs_int() helper
Suggested-by: Marco Trevisan (Treviño) <mail@3v1n0.net>
2024-02-13 23:20:42 +00:00
Mario Limonciello
002255cbdd Change the ppd_action_probe() return type to PpdProbeResult 2024-02-13 23:20:42 +00:00
Mario Limonciello
15ce19d623 Move PpdProbeResult to ppd-profile.h
It's used by both `PpdDriver` and `PpdAction`
2024-02-13 23:20:42 +00:00
Mario Limonciello
c749dfc444 Fix launching powerprofilesctl
The active profile is on org.freedesktop.DBus.Properties

Fixes: 3b29b0e ("cleanup: Use UPower namespace as default DBus name preserving old one")
2024-02-13 16:12:16 -06:00
Marco Trevisan (Treviño)
32f5abfb82 powerprofilesctl: Use global variable to hold names and infaces 2024-02-13 20:44:29 +00:00
Marco Trevisan (Treviño)
3b29b0e52b cleanup: Use UPower namespace as default DBus name preserving old one
Expose the daemon as 'org.freedesktop.UPower.PowerProfiles' by default
but we also own the old 'net.hadess.PowerProfiles' name for
compatibility resons.

Also dbus objects are now registered also in the path
/org/freedesktop/UPower/PowerProfiles and they implement the
org.freedesktop.UPower.PowerProfiles interface.

Even in this case we preserve the compatibility with the old ones.

To make this switch as most reliable as possible, the code is now
generated for dbus configuration files preserving the previous ones as
base.

Tests are now performed checking both names, to ensure again that we're
not breaking the expectations for the old APIs consumers.
2024-02-13 20:44:29 +00:00
Marco Trevisan (Treviño)
520622ba70 data: Rename policykit policies to UPower namespace
We're part of UPower now so let's use the freedesktop standard namespace
2024-02-13 20:44:29 +00:00
Marco Trevisan (Treviño)
53115abf35 build: Bump meson requirement to 0.58
It's still quite old, but provides some features we may want to use in
future, so let's use a newer version since we're about to release a new
major version of p-p-d too.
2024-02-13 20:44:29 +00:00
Marco Trevisan (Treviño)
f37b74b65a build: Support building with old polkit
Some distros as LTS ones may still have old versions of polkit
gobject.

Since we only depend on the new polkit because of auto-pointers,
let's add a tiny compatibility layer to make possible to get
p-p-d also working on older stable distros as OEMs may like.
2024-02-13 21:18:25 +01:00
Mario Limonciello
9f25cec345 Install custom debug message handler
Remove a lot of the unnecessary stuff about the process, and instead
pad out the domain to make it more accessible.

If running on an interactive terminal add color coding for warnings
and errors. If this behavior is not desirable for an interactive terminal,
NO_COLOR=0 can be set in the environment.
2024-02-13 20:10:30 +00:00
Mario Limonciello
e11eb6c28e Set the log domain for all source files 2024-02-13 20:10:30 +00:00
Mario Limonciello
3247b511e2 Fix running test suite without root
Running Tests.test_fake_driver breaks stdin on a real terminal unless
the test suite is run as root.  It doesn't make sense for the fake
driver to capture stdin unless we are sure that we're interactive.

Lookup whether stdout is a tty and only run the keyboard setup in
probe for the fake driver if we're sure we're interactive.
2024-02-07 23:17:18 -06:00
Mario Limonciello
59d5116f9d trivial: fix end of file on C files
Ensure that all files end in a new line
2024-02-03 09:05:45 -06:00
Marco Trevisan (Treviño)
85f3bb066c power-profiles-daemon: Do not leak blocked drivers list 2024-02-03 15:35:45 +01:00
Marco Trevisan (Treviño)
a784413762 power-profiles-daemon: Random indentation fixes 2024-02-03 15:35:23 +01:00
Marco Trevisan (Treviño)
ee1cfb36fc power-profiles-daemon: Steal strings when possible 2024-02-03 15:34:26 +01:00
Marco Trevisan (Treviño)
6923594b9f cleanup: Be consistent on spacing before function calls 2024-02-03 15:34:25 +01:00
Marco Trevisan (Treviño)
b88875c550 ppd-driver: Use NULL values if values are unset 2024-02-02 19:15:33 +01:00
Mario Limonciello
05cea66718 Fix compatibility with older Dbus API
Ensure that the 'Driver' key is populated.
Fixes: https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/issues/136
2024-02-02 10:51:31 -06:00
Bastien Nocera
19275d52fa main: Fix Python traceback when Ctrl+C'ing a launched app 2024-01-26 12:20:17 +01:00
Bastien Nocera
c19bede0d7 main: Return return code from launched executable
Using powerprofilesctl to launch an app would always result in what was
detected as success, because the code wasn't propagating the retval from
the launched application.
2024-01-26 12:19:55 +01:00
Mario Limonciello
0cdf32c3db Don't change governor for amd-pstate at probe
Make the change specifically when changing modes and only set powersave
for balance and powersaver profiles.
2024-01-15 06:38:25 +00:00
Mario Limonciello
5fd9d0e6dd Disable loading amd-pstate when the PM profile is a server or undefined
This mirrors the behavior used by Kernel 6.5 and later where amd-pstate
is configured to default into 'performance' by the kernel.  It's not
as useful in server to be changing it.

Link: 32f80b9adf
2024-01-15 06:28:23 +00:00
Mario Limonciello
bec7dfdf34 Add support for driver blocklist by environment variable
Drivers can be blocked from loading via `POWER_PROFILE_DAEMON_DRIVER_BLOCK`
which is a comma separated value listing the drivers to block.

This is an escape hatch in case CPU or platform driver are failing and a user
would like to block them.
2024-01-15 06:17:42 +00:00
Mario Limonciello
61f7650e35 Allow both CPU and platform drivers to be simultaneously active
This is done by designating all drivers as CPU drivers or platform drivers.
One of each driver can be active at any given time.

When setting an active profile CPU driver is set first as this is less likely to have
failures. If failures occur setting the platform driver then the CPU driver is undone.

If both profiles are degraded then the string for the reason from both drivers will be
comma separated to be compatible with existing API and users.

This is leveraged from https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/merge_requests/123

Fixes: https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/issues/107
Fixes: https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/issues/125
Fixes: https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/issues/124
Fixes: https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/issues/122
Fixes: https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/issues/129
Fixes: https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/issues/131
2024-01-15 06:17:42 +00:00
Mario Limonciello
e1b53d1f64 Update G_DEFINE_TYPE whitespace
This is a macro not a function.
2024-01-15 06:17:42 +00:00
Bastien Nocera
be37aea01b intel-pstate: Add more debug to driver probe
Make it easier to see which features are used on the system by
summarising the features the driver will use.

** (power-profiles-daemon:126721): DEBUG: Found Intel p-state settings
** (power-profiles-daemon:126721): DEBUG: 	Energy Performance Preference: yes
** (power-profiles-daemon:126721): DEBUG: 	Energy Performance Bias: yes
** (power-profiles-daemon:126721): DEBUG: 	Has Turbo: yes

Closes: #120
2023-11-21 14:24:09 +01:00
Bastien Nocera
6eaf337c33 intel-pstate: Remove unused variable
src/ppd-driver-intel-pstate.c:174:22: warning: unused variable 'gov_path' [-Wunused-variable]
    g_autofree char *gov_path = NULL;
                     ^
2023-04-26 14:28:14 +02:00
Prajna Sariputra
db60051aea main: Add amd_pstate-based driver
The AMD P-states driver has added support for active mode in kernel 6.3,
which exposes a similar interface for controlling energy performance
preference as the Intel P-state driver, with the same presets present,
so make use of it.

See:
https://www.kernel.org/doc/html/v6.3/admin-guide/pm/amd-pstate.html

Closes: #108
2023-04-26 14:23:18 +02:00
Bastien Nocera
0cb116f351 main: Fix pylint warnings
src/powerprofilesctl:137:0: C0325: Unnecessary parens after '=' keyword (superfluous-parens)
src/powerprofilesctl:126:4: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)
src/powerprofilesctl:134:4: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)
src/powerprofilesctl:154:4: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)
2023-03-16 15:04:48 +01:00
Bastien Nocera
1116e54128 platform-profile: "cool" should be balanced
The "cool" profile isn't a low-power mode, but a mode where the fans are
always running to reduce the temperature, presumably to allow it to run
faster.

At the same time, we need to handle the lack of low-power profile on HP
machines as they only had a cool mode and no low-power mode.

Closes: #89
2023-02-08 16:06:48 +01:00
Bastien Nocera
eefb002ac5 main: Check that profile exists before switching to it
Don't allow switching to an unsupported profile, or holding that
unsupported profile, as that might cause problems for front-ends that
can't display that combination.

See https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1504
2022-09-08 11:44:19 +02:00
Bastien Nocera
674732919a utils: Add debug to monitoring helper
As we don't have easy access to the full path of the attribute
we're monitoring elsewhere.
2022-09-08 11:37:28 +02:00
Bastien Nocera
50eb7d3441 intel-pstate: Reapply energy_perf_bias on resume
From https://www.kernel.org/doc/html/v5.17/admin-guide/pm/intel_epb.html?highlight=energy_perf_bias:
"
There are systems where the platform firmware resets the EPB during
system-wide transitions from sleep states back into the working state
effectively causing the previous EPB updates by user space to be lost.
"

So reapply energy_perf_bias on resume.
2022-06-28 15:50:27 +02:00
Bastien Nocera
d42af96f9d intel-pstate: Probe EPB on startup 2022-06-28 15:50:27 +02:00
Bastien Nocera
6d03eddcf4 intel-pstate: Add EPB application 2022-06-28 15:50:27 +02:00
Bastien Nocera
f212ffdac9 intel-pstate: Factor out writing to sysfs files 2022-06-28 15:50:27 +02:00
Bastien Nocera
30ce9b1c68 intel-pstate: Rename profile_to_pref() 2022-06-28 15:50:27 +02:00
Bastien Nocera
bc5433e788 intel-pstate: Split probing EPP 2022-06-28 15:50:27 +02:00