Skip to content

Commit

Permalink
fix(legion): Adjust priv-write patch to only prevent writes to non-ba…
Browse files Browse the repository at this point in the history
…cklight hardware control without the enable flag
  • Loading branch information
KyleGospo committed Dec 30, 2023
1 parent c988c7d commit 8a0df51
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions spec_files/jupiter-hw-support/priv-write.patch
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,17 @@ index 296996e..ae0ae3e 100755
if [[ $EUID -ne 0 ]];
then
exec pkexec --disable-internal-agent "$0" "$@"
@@ -12,21 +15,25 @@
@@ -12,21 +15,21 @@

function CommitWrite()
{
- if [ ! -z "$WRITE_VALUE" ]
- then
- echo "commit: $WRITE_VALUE -> $WRITE_PATH" | systemd-cat -t p-steamos-priv-write -p warning
- echo "$WRITE_VALUE" > "$WRITE_PATH"
+ if [[ ":Jupiter:" =~ ":$SYS_ID:" || ":Galileo:" =~ ":$SYS_ID:" || "$ENABLE_HARDWARE_CONTROL_ON_NON_DECK_HARDWARE" = 1 ]]; then
+ if [ ! -z "$WRITE_VALUE" ]
+ then
+ echo "commit: $WRITE_VALUE -> $WRITE_PATH" | systemd-cat -t p-steamos-priv-write -p warning
+ chmod a+w "$WRITE_PATH"
+ echo "$WRITE_VALUE" > "$WRITE_PATH"
+ fi
+ chmod a+w "$WRITE_PATH"
+ echo "chmod a+w: $WRITE_PATH" | systemd-cat -t p-steamos-priv-write -p warning
+
+ echo "chmod a+w: $WRITE_PATH" | systemd-cat -t p-steamos-priv-write -p warning
+ else
+ echo "commit: Skipped - see /etc/default/steam-hardware-control" | systemd-cat -t p-steamos-priv-write -p warning
if [ ! -z "$WRITE_VALUE" ]
then
echo "commit: $WRITE_VALUE -> $WRITE_PATH" | systemd-cat -t p-steamos-priv-write -p warning
echo "$WRITE_VALUE" > "$WRITE_PATH"
fi

- chmod a+w "$WRITE_PATH"
Expand All @@ -45,25 +37,42 @@ index 296996e..ae0ae3e 100755
exit 1
}

@@ -40,11 +47,19 @@
@@ -40,15 +43,35 @@
fi

if [[ "$WRITE_PATH" == /sys/class/drm/card*/device/power_dpm_force_performance_level ]]; then
- CommitWrite
+ for i in $(ls /sys/class/drm/card*/device/power_dpm_force_performance_level)
+ do
+ WRITE_PATH="$i"
+ CommitWrite
+ done
+ if [[ ":Jupiter:" =~ ":$SYS_ID:" || ":Galileo:" =~ ":$SYS_ID:" || "$ENABLE_HARDWARE_CONTROL_ON_NON_DECK_HARDWARE" = 1 ]]; then
+ for i in $(ls /sys/class/drm/card*/device/power_dpm_force_performance_level)
+ do
+ WRITE_PATH="$i"
+ CommitWrite
+ done
+ else
+ echo "commit: Skipped - see /etc/default/steam-hardware-control" | systemd-cat -t p-steamos-priv-write -p warning
+ fi
fi

if [[ "$WRITE_PATH" == /sys/class/drm/card*/device/pp_od_clk_voltage ]]; then
- CommitWrite
+ for i in $(ls /sys/class/drm/card*/device/pp_od_clk_voltage)
+ do
+ WRITE_PATH="$i"
+ CommitWrite
+ done
+ if [[ ":Jupiter:" =~ ":$SYS_ID:" || ":Galileo:" =~ ":$SYS_ID:" || "$ENABLE_HARDWARE_CONTROL_ON_NON_DECK_HARDWARE" = 1 ]]; then
+ for i in $(ls /sys/class/drm/card*/device/pp_od_clk_voltage)
+ do
+ WRITE_PATH="$i"
+ CommitWrite
+ done
+ else
+ echo "commit: Skipped - see /etc/default/steam-hardware-control" | systemd-cat -t p-steamos-priv-write -p warning
+ fi
fi

if [[ "$WRITE_PATH" == /sys/class/hwmon/hwmon*/power*_cap ]]; then
- CommitWrite
+ if [[ ":Jupiter:" =~ ":$SYS_ID:" || ":Galileo:" =~ ":$SYS_ID:" || "$ENABLE_HARDWARE_CONTROL_ON_NON_DECK_HARDWARE" = 1 ]]; then
+ CommitWrite
+ else
+ echo "commit: Skipped - see /etc/default/steam-hardware-control" | systemd-cat -t p-steamos-priv-write -p warning
+ fi
fi

if [[ "$WRITE_PATH" == /sys/devices/platform/*/*/*/iio:device*/in_illuminance_integration_time ]]; then

0 comments on commit 8a0df51

Please sign in to comment.