this post was submitted on 06 May 2025
73 points (98.7% liked)

Linux Gaming

18353 readers
470 users here now

Discussions and news about gaming on the GNU/Linux family of operating systems (including the Steam Deck). Potentially a $HOME away from home for disgruntled /r/linux_gaming denizens of the redditarian demesne.

This page can be subscribed to via RSS.

Original /r/linux_gaming pengwing by uoou.

No memes/shitposts/low-effort posts, please.

Resources

WWW:

Discord:

IRC:

Matrix:

Telegram:

founded 2 years ago
MODERATORS
 

Virtual displays for Sunshine/Moonlight without dongle on amdgpu in Bazzite-Gnome

Introduction

Users of GPUs leveraging the amdgpu driver can create virtual displays without using any dongle for use with Sunshine. This can be done via a kernel parameter as described here and here. However we opt for bringing up the screen during multiuser-target. This has the advantage of a faster boottime and it keeps the splash screen intact.

Preparation

Install Sunshine

To install Sunshine open a terminal and enter:

ujust setup-sunshine

Identify ports

You need to identify actual ports on your GPU to map the virtual display to. The following command will list potential ports (DP-1 - DP-X, HDMI-1 - HDMI-X).

for p in /sys/class/drm/*/status; do con=${p%/status}; echo -n "${con#*/card?-}: "; cat $p; done

Any disconnected port will do.

Prepare EDID firmware to accomodate your target screen

To make the kernel aware of the proper resolution and refresh rate of your virtual display we need an EDID firmware file. This can either be retrieved for example here [1]. Alternatively you can also create a tailored EDID file with this handy tool [2]. The tool takes a modeline from xorg and generates the EDID bin from it. To get a modeline for your target resolution you can use this website [3]. To prepare and use edid-generator on Bazzite-Gnome proceed as follows in a terminal:

ujust distrobox-assemble //Choose Ubuntu
distrobox enter ubuntu
sudo apt install zsh edid-decode automake dos2unix
mkdir -p ~/build/
cd ~/build/
git clone https://github.com/akatrevorjay/edid-generator
cd edid-generator
./modeline2edid - <<< 'Modeline "2560x1600" 348.16 2560 2752 3032 3504 1600 1601 1604 1656 -HSync +Vsync' //Replace with your modeline in the single brackets
make

You should now have a .bin file named according to the content of the first brackets in the modline. Copy this into your local firmware folder. Carry on in the terminal:

mkdir -p /usr/local/lib/firmware
sudo cp 2560x1600.bin /usr/local/lib/firmware/

Test your target display

We will now create a helper script to enable your virtual display.

Open the editor of your choice and paste the following, then replace DP-2 with a non connected interface and 2560x1600.bin with your EDID file:

#!/bin/bash
cat /usr/local/lib/firmware/2560x1600.bin > /sys/kernel/debug/dri/0/DP-2/edid_override
echo on > /sys/kernel/debug/dri/0/DP-2/force
echo 1 > /sys/kernel/debug/dri/0/DP-2/trigger_hotplug

Save the file as "enable-screens.sh". Then make it available to the root user:

sudo cp enable-screens.sh /usr/local/sbin/
sudo chmod +x /usr/local/sbin/enable-screens.sh

You can now test if everything works:

sudo /usr/local/sbin/enable-screens.sh
gnome-control-center display

The control center should now start up with the display section and show the newly created display.

Automation

Automatically bring up screen via systemd

You can trigger the script on startup via a systemd unit file. For this open the editor of your choice and paste the following:

[Unit]
Description=Enable Virtual Displays

[Service]
ExecStart=/usr/bin/bash /usr/local/sbin/enable-screens.sh

[Install]
WantedBy=multi-user.target

Save under "/etc/systemd/system/enable-screens.service". Then enable the service and reboot:

sudo systemctl daemon-reload
sudo systemctl enable enable-screens.service
systemctl reboot

After the system has restarted check your display is available in control center:

gnome-control-center display

Autostarting Sunshine

Sunshine autostart is currently not working in bazzite-gnome [4]. To work around this use xdg autostart.

sudo cp /usr/share/applications/sunshine.desktop /etc/xdg/autostart/

Switching screens in Sunshine

Gnome has recently added gdctl as a tool to manipulate screen layout across X and Wayland. This can be used in a Sunlight application in "Do Command" and "Undo Command" to setup the appropriate screen configuration. I use this to enable a multiscreen setup in desktop mode, but I also have an exclusive desktop mode just on my tablet and exclusive Big Picture to my tablet.

For the multiscreen "Do Command" add (I use scale on the small tablet screen to get a readable UI):

gdctl set --logical-monitor --primary --monitor DP-1 --logical-monitor --monitor DP-2 --scale 2 --right-of DP-1

In "Undo Command":

gdctl set --logical-monitor --primary --monitor DP-1

You can now connect to the application from your device with Moonlight.

Conclusion

I hope this little guide was helpful. Please put pointers to problems and I will try to correct them in the original post. Feel free to also share your successes. Enjoy your virtual display and Sunshine/Moonlight.

top 15 comments
sorted by: hot top controversial new old
[–] baduhai@sopuli.xyz 1 points 14 hours ago

Common AMD Linux W.

This is awesome, I'll try it this weekend

[–] newthrowaway20@lemmy.world 1 points 17 hours ago (1 children)

Artemis and Apollo already do this. Is this implementation any different?

[–] mighty_bombero@feddit.org 1 points 17 hours ago* (last edited 16 hours ago)

Do they now have Linux support? I thought this was limited to Windows as host at this time?

[–] glitching@lemmy.ml 1 points 20 hours ago (1 children)

thanks. looks easy enough to implement on other distros. this was my primary issue on why I wouldn't use it, it just seemed bonkers to me to have the game I'm playing on my other device simultaneously being blasted on the main monitor.

the only thing missing would be runtime on/off/reconfigure, as I abhor rebooting.

[–] mighty_bombero@feddit.org 2 points 19 hours ago

This was also my motivation for investigating this. With a script like the "enable-screens.sh" you can do runtime reconfiguration of the virtual displays. Apparently this only works if the kernel is not in a "lockdown" state. So this would depend on the distribution. And you have the "Switching the screens" section. It describes how to set up an application in Sunshine so that when you connect one screen turns of and back on again when you disconnect. I hope these two points fit your requirements.

[–] edinbruh@feddit.it 3 points 1 day ago (1 children)

Hmmmm

Do you actually need a full fake edid for your usecase? I think you are looking for the video= kernel parameter, which forces a port to be active, and adds a mode (resolution and refreshrate) to it's list of supported modes

[–] mighty_bombero@feddit.org 3 points 1 day ago* (last edited 1 day ago)

I first had it running with the kernel parameters. For this see the second link in the introduction. The problem there was it added to boot time, as the kernel generates an error message. Passing an EDID as kernel parameter was complicated, due initramfs modification being tricky on Bazzite (at least acccording to my limited understanding). So I moved to this method where I initialize the virtual display via the KMS debug API later in the boot process. This can also be used to arbitrarily modify the virtual display. I have not looked into doing it via parameter. Can you share the example commands?

[–] MigratingApe@lemmy.dbzer0.com 1 points 1 day ago (2 children)

Wait, is this really needed? I cannot just stream my normal main display?

[–] Ulrich@feddit.org 8 points 1 day ago* (last edited 1 day ago) (1 children)

No it's not needed. But currently you need to have a display plugged in and turned on. This works around that so you could run a game streaming server without one.

Also particularly useful for those like me who have it connected to a TV because for some reason GPUs still don't support HDMI-CEC which turns on a TV when the device is turned on.

I believe.

[–] mighty_bombero@feddit.org 3 points 1 day ago* (last edited 1 day ago) (1 children)

Yes. This allows the host's display to be shut down and match exactly the resolution of the target display. It also makes for a very performant dual screen setup for work. I can use my tablet with a kick-stand as second screen for a terminal session or a video with very good latency.

[–] Ulrich@feddit.org 1 points 1 day ago (1 children)

and match exactly the resolution of the target display

Oh shit I didn't realize that. Does it also match the frame rate and graphics settings?

Big problem I have with all these streaming services is that you have to change all this stuff every time you switch displays.

[–] mighty_bombero@feddit.org 2 points 1 day ago* (last edited 1 day ago) (1 children)

Yes, once you disable the host's display you can target the refresh rate of the client's display. But you still might to have to change resolution in-game depending on the game, I think.

[–] Ulrich@feddit.org 1 points 1 day ago

Well it's a step in the right direction!

[–] mighty_bombero@feddit.org 3 points 1 day ago

Sure you can but you would mirror the resolution of your main display. I'm using a FHD 16:9 but stream to a 16:10 tablet and a 4k TV. So having the true resolution of the target display improves the image quality.

[–] LainTrain@lemmy.dbzer0.com 1 points 1 day ago

This is really cool, shame it's only amd :/