moonlight-stream / moonlight-qt

GameStream client for PCs (Windows, Mac, Linux, and Steam Link)
GNU General Public License v3.0
9.21k stars 543 forks source link

Custom Resolution on moonlight-qt raspberry pi 4 #967

Open cstrassmair opened 1 year ago

cstrassmair commented 1 year ago

Hello,

i have reactivated a raspberry pi 4 with moonlight-qt installed. It runs all fine on 1080p, 1440p etc.

But i have a Custom Resolution Monitor with 3840x1200 connected to the rpi4 In Moonlight-qt i have set it to custom - 3840x1200

When connecting to Host with Nvidia RTX 3060 TI on 3840x1200 Resolution it gives me a wrong resolution. I can play arround but i wont get the right result.

When starting Moonlight on Windows PC with 3840x1200 Monitor Connected it runs all fine.

Any help is welcome!

Thanks! Christoph

Bobbar commented 1 year ago

Are you launching Moonlight from the desktop GUI or TTY terminal?

cstrassmair commented 1 year ago

Autostart from tty terminal

Bobbar commented 1 year ago

You may be able to force the resolution via /boot/config/cmdline.txt.

Here is what I use for 1440p at 10-bit color: video=HDMI-A-1:2560x1440M-10@60

M = CVT timing. 10 = 10 bpp color. @60 = 60 Hz refresh rate.

Your resolution isn't CVT, so you probably want to try: video=HDMI-A-1:3840x1200@60

Just add that to the beginning of the existing cmdline text, be sure to include a space between it and the next option (usually console=)

See https://www.kernel.org/doc/Documentation/fb/modedb.txt

Also, the libdrm-tests package contains the modetest tool which you can use to test different resolutions and parameters on the fly.


You may also find that you need to force the resolution for Moonlight as well, as it tends to re-init the display and will switch back to what ever the preferred resolution is. This can be done with the QT_QPA_PLATFORM env variable.

So add QT_QPA_PLATFORM=linuxfb:size=3840x1200 to the beginning of your Moonlight launch script. (ex. QT_QPA_PLATFORM=linuxfb:size=3840x1200 moonlight-qt)

ticianolg commented 1 year ago

You may be able to force the resolution via /boot/config/cmdline.txt.

Here is what I use for 1440p at 10-bit color: video=HDMI-A-1:2560x1440M-10@60

M = CVT timing. 10 = 10 bpp color. @60 = 60 Hz refresh rate.

Your resolution isn't CVT, so you probably want to try: video=HDMI-A-1:3840x1200@60

Just add that to the beginning of the existing cmdline text, be sure to include a space between it and the next option (usually console=)

See https://www.kernel.org/doc/Documentation/fb/modedb.txt

Also, the libdrm-tests package contains the modetest tool which you can use to test different resolutions and parameters on the fly.

You may also find that you need to force the resolution for Moonlight as well, as it tends to re-init the display and will switch back to what ever the preferred resolution is. This can be done with the QT_QPA_PLATFORM env variable.

So add QT_QPA_PLATFORM=linuxfb:size=3840x1200 to the beginning of your Moonlight launch script. (ex. QT_QPA_PLATFORM=linuxfb:size=3840x1200 moonlight-qt)

I'm using this at the moment and it works. However I'm having a (tolerable) side effect. Maybe because linuxfb will force software rendering as explained in qt documentation here, the moonlight interface is kinda broken.

Bobbar commented 1 year ago

Yeah, I have the same issue. I wonder if we can leave out the linuxfb and just pass size?

I had originally seen that suggestion on a Discord post so I'm unsure how "correct" that solution is.

ticianolg commented 1 year ago

Yeah, I have the same issue. I wonder if we can leave out the linuxfb and just pass size?

I had originally seen that suggestion on a Discord post so I'm unsure how "correct" that solution is.

I don't think it will work because "size" is a parameter to linuxfb QT plugin.

I tried to put the QT_QPA_PLATFORM=eglfs and use the QT_QPA_EGLFS_KMS_CONFIG variable to point to a json file (explained in the Custom Configuration section of QT documentation). I use a systemd service to start moonlight-qt, like this:

[Unit]
Description=moonlight gamestream client

[Service]
Type=simple
Environment="QT_QPA_PLATFORM=eglfs"
Environment="QT_QPA_EGLFS_KMS_CONFIG=/home/pi/eglfs.json"
User=pi
ExecStart=moonlight-qt

[Install]
WantedBy=multi-user.target

Then I created the json file with the following content:

{
  "device": "/dev/dri/card1",
   "hwcursor": false,
   "pbuffers": true,
   "outputs": [
   {
      "name": "HDMI-A-1",
      "virtualIndex":0,
      "mode": "2560x1440"
    }
  ]
}

However moonlight started with 4k resolution (which I'm trying to avoid).

gschintgen commented 1 month ago

Did any of you have any success with forcing moonlight's resolution?

I'm facing the same issue on a x86 mini PC where I'm running moonlight -eglfs since no display server is installed. Unfortunately there are a few modes that my 4k TV doesn't seem to like. The PC can boot just fine in multiple display modes (I can set them using video= kernel parameter), but as soon as moonlight starts the TV no longer recognizes the signal. Ideally moonlight would just keep the currently used mode by default.

Bobbar commented 1 month ago

@gschintgen

Have you tried the QT_QPA_PLATFORM=linuxfb:size= command suggested above?

https://github.com/moonlight-stream/moonlight-qt/issues/967#issuecomment-1468653313

gschintgen commented 4 weeks ago

@gschintgen

Have you tried the QT_QPA_PLATFORM=linuxfb:size= command suggested above?

I did some experiments, without success:

  1. QT_QPA_PLATFORM=linuxfb:size=1920x1080 -> moonlight complains that it can't find the framebuffer. Even adding ...size=1920x1080,fb=/dev/fb0 (as documented) doesn't help.
  2. I tried setting QT_QPA_EGLFS_KMS_CONFIG to a custom config json, with and without additional QT_QPA_EGLFS_INTEGRATION=eglfs_kms. No success.

It's as if moonlight completely ignored all those env variables, but QT_QPA_EGLFS_PHYSICAL_WIDTH/HEIGHT do in fact work!

(On a side note I no longer had any issues for a brief time after a kernel update and with the TV's gamemode disabled. But after re-enabling gamemode the one mode that is still highly problematic is the one that moonlight automatically switches to.)

gschintgen commented 4 weeks ago

I think I finally nailed it. Unfortunately I'm not sure if this is also helpful for the original report with the custom resolution.

The reason why the QT_QPA_EGLFS_KMS_CONFIG was silently(!) ignored is that I had the output name "wrong". On my mini PC the HDMI port is internally known as DP-3. At least that's the name printed by the (very handy) modetest utility. But Qt seems to have a slightly different naming scheme. The relevant logging output can be obtained by: QT_LOGGING_RULES="qt.qpa.*=true" moonlight -platform eglfs. In my case, Qt knows the output as DP3 (without the hyphen). As soon as I fixed my .json file the config file was indeed taken into consideration!

(Huge thanks to falter on discord for their post about fixing a Pi4 setup)

Here's my json file:

{
  "device": "/dev/dri/card0",
  "outputs": [
    {
      "name": "DP3",
      "mode": "1920x1080"
    }
  ]
}
dvnkln commented 5 days ago

Running into almost the same problem and was only able to resolve it thanks to @gschintgen / the discord post by falter.

I have my pi 4 attached to a 4k TV trying to stream from a 1440p PC. Running moonlight 6.0.1 my screen is cut off if i set it to 1440p because moonlight is starting in 4k and stubbornly keeps it this way. It's completely ignoring the pi resolution which was set manually to 1440p via /boot/firmware/cmdline.txt (i confirmed the pi's resolution via fbset -s).

Only setting a custom qt resolution via QT_QPA_EAGLFS_KMS_CONFIG as described above is making moonlight usable at 1440p. An option to manually set another resolution for the moonlight-qt gui itself would get rid of this.

Even though in 6.0.0 there was no problem with adjusting the resolution (at least for me). Something must have changed with 6.0.1.