0

I want to force both Raspberry 4 HDMI output's to 1920x1080@60Hz in desktop mode where either one output doesn't necessarily have a HDMI connected but usually will but often not at the same time. When connected it should use the same resolution as which I forced it to do. This is because of video processing output software I'm using that should always output the same resolution, no matter what. The end result is for an art project which uses projectors, which all support 1920x1080@60Hz but can vary in model and brand.

In Raspberry Pi OS releases before Bookworm this was possible through config.txt:

hdmi_force_hotplug=1
hdmi_mode=xx

Because of the new default desktop Wayland this is now different, but I am confused on how to do it properly. The config.txt documentation explains that we cannot set the hdmi settings here anymore.

The HDMI settings used to be configured by firmware via settings in config.txt; this configuration is now instead done by KMS via settings in cmdline.txt.

And if I check the above link from the quote it shows that indeed I can change the HDMI settings there like this by editing the .config/wayfire.ini:

[output:HDMI-A-1]
mode = 1920x1080@60

But when I read on it also shows this:

The part of the output: line (HDMI-A-1 in the example shown here) matches the display options described for KMS. The mode line is similar to that used by KMS, but slightly different. Consult the Wayfire documentation for more extensive information.

The KMS linked page then proceeds:

If no video entry is present in cmdline.txt then the Linux kernel will read the EDID of an HDMI-connected monitor, and automatically pick the best display resolution supported by your monitor / television. If you’re using Raspberry Pi OS Lite, or the "boot to CLI" mode of Raspberry Pi OS, and you want to change the resolution of the text console, then you’ll need to add a video setting to cmdline.txt...

How I read this, the cmdline.txt takes precedence over wayland.ini. Am I correct here? Or what happens when only the settings are changed in wayland.ini and not the cmdline.text or vice versa?

2 Answers 2

0

The documentation you linked says:-

"The Screen Configuration tool (arandr) is a graphical tool for selecting display modes and setting up multiple displays. You can find this tool in the desktop Preferences menu. Use the Layout menu option to select the screen, resolution, and orientation."

1
  • This does not work when there's no HDMI connected on either or both of the ports. The Pi makes up something itself, also shifts the main display around from to whatever is connected and not.
    – kleurbleur
    Nov 5, 2023 at 12:01
0

If both arandr and Setting your display’s resolution and rotation as noted in the Raspberry pi documentation and adding "video=HDMI-A-1:1920x1080@60" to /boot/cmdline.txt options do not work, you can try running this script every n seconds:

#!/usr/bin/env bash
eval $(grep -osPahm1 "\0(WAYLAND_DISPLAY|DBUS_[A-Z_]+|XDG_[A-Z_]+|DISPLAY)=[^\0]+" /proc/*/environ | cut -d= -f1- | sort | uniq | tr -d '\0' | sed 's/^/export /g')
[ "$WAYLAND_DISPLAY" != "" ] || export WAYLAND_DISPLAY=$(ls $XDG_RUNTIME_DIR/wayland-[0-9])

for p in /sys/class/drm/*/status; do con=${p%/status};
  device=${con#*/card?-}
  status=$(cat $p);
  echo "$device: $status";
  if [ $status == "connected" ];
  then
    echo "Setting resolution on $device"
    wlr-randr --output $device --mode 1920x1080@60
  fi
done

This basically forces all your displays to 1920x1080 60Mhz if possible using these steps:

  1. Starts bash (probably not needed but just there to be sure since I tested it with bash)
  2. Loads your wayland environment variables (not needed if you run it from a terminal inside X)
  3. Tries to load WAYLAND_DISPLAY again if it was not already in your environment (not needed if you run a from a terminal inside X)
  4. Loops over your display devices
  5. When display is connected, it changes the resolution to 1920x1080 60Mhz.

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.