Skip to content

Commit 62fe860

Browse files
Syboxez BlankSyboxez Blank
authored andcommitted
Hardcoded variables at top of script instead of spreading throughout. Backup EDID, but no restore yet
1 parent 3724257 commit 62fe860

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

gfx/temp-hack/swedid-root

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,39 @@
33
# This script requires running as root. "sudo" is called from "gfx/video_crt_switch.c", thus requiring a sudoers rule to non-interactively grant root permissions when running "/usr/local/bin/swedid-root" (this script)
44
# switchres binary must be in root's PATH
55

6-
# Hardcoding Display for now as DP-1
6+
# TODO: Get below values from RetroArch's video output settings instead of hardcoding.
7+
8+
# Hardcode GPU number and Display name. Change these before running.
9+
_display="DP-1"
10+
_gpu="1"
11+
12+
# Hardcode ini path or switchres monitor preset. Change this before running
13+
_sw_args="--ini /home/syboxez/.config/retroarch/config/switchres.ini"
14+
15+
# Change $3 to $5 when no longer hardcoding Display or GPU
716
if [ -z "$3" ]; then
8-
echo "Usage: $0 [HRes] [VRes] [VFreq] [Display]"
17+
echo "Usage: $0 [HRes] [VRes] [VFreq] [GPU Num] [Display]"
918
exit 1
1019
fi
1120

12-
# Hardcoding Display
21+
# Change $4 to $6 when no longer hardcoding
1322
if [ -n "$4" ]; then
1423
echo "Too many arguments"
15-
echo "Usage: $0 [HRes] [VRes] [VFreq] [Display]"
24+
echo "Usage: $0 [HRes] [VRes] [VFreq] [GPU Num] [Display]"
1625
exit 1
1726
fi
1827

28+
# Backup EDID if backup doesn't exist
29+
# Currently hardcoding GPU number and display name. Change this before running!
30+
if [ ! -f /tmp/edid.bak ]; then
31+
echo "Backing up EDID to /tmp/edid.bak"
32+
dd if=/sys/class/drm/card"$_gpu"-"$_display"/edid of=/tmp/edid.bak bs=256
33+
else
34+
echo "EDID already backed up to /tmp/edid.bak. Skipping backup."
35+
fi
36+
37+
# TODO: Restore EDID after RA closes instead of attempting to use xrandr, which is what happens now.
38+
1939
# Generate temperary working directory to generate EDID binary, then delete after applying
2040
_tmpdir=$(mktemp -d)
2141
if [ -z "$_tmpdir" ]; then
@@ -24,11 +44,10 @@ if [ -z "$_tmpdir" ]; then
2444
fi
2545
cd "$_tmpdir"
2646

27-
switchres --ini /home/syboxez/.config/retroarch/config/switchres.ini --edid $1 $2 $3
47+
switchres $_sw_args --edid $1 $2 $3
2848

29-
#Replace "1" with GPU number, replace "DP-1" with display
30-
cat "$_tmpdir"/custom.bin > /sys/kernel/debug/dri/1/DP-1/edid_override
31-
echo 1 > /sys/kernel/debug/dri/1/DP-1/trigger_hotplug
49+
cat "$_tmpdir"/custom.bin > /sys/kernel/debug/dri/"$_gpu"/"$_display"/edid_override
50+
echo 1 > /sys/kernel/debug/dri/"$_gpu"/"$_display"/trigger_hotplug
3251

3352
cd /tmp
3453
rm -rf "$_tmpdir"

0 commit comments

Comments
 (0)