Fixing Raspberry Pi HDMI Black Screen After Switching TV Inputs

When I used my Raspberry Pi 5 on a TV, I noticed a frustrating problem: if I switched the TV input to another device and then came back to the Pi, the screen was often black. The system itself was still running. I could reach a terminal with Ctrl+Alt+F5 or over SSH, but the desktop would not return without restarting LightDM or even rebooting.

After some investigation, the problem turned out to be how the Pi handles HDMI hotplug detection. When the TV input changes, the Pi can think the monitor is gone. Wayfire, the default Wayland compositor on Raspberry Pi OS, then disables the output. When I switch back, the Pi sometimes fails to re-enable it.

The Fix

The simplest and most effective solution was to force the Pi to always believe a monitor is connected and to pin it to a known good resolution. This is done by editing the firmware config file:

sudo nano /boot/firmware/config.txt

Add these lines at the end:

Keep HDMI alive across TV input switches

hdmi_force_hotplug=1
hdmi_drive=2
hdmi_group=1
hdmi_mode=16 # 1080p60

Save, then reboot.

With this change, the Pi always drives HDMI at 1080p60. The TV can switch inputs freely and when I return, the desktop is still there instantly. No more black screen, no more restarting LightDM.

Why This Works

  • hdmi_force_hotplug=1 tells the Pi to treat HDMI as connected even if the hotplug signal drops.
  • hdmi_group and hdmi_mode lock the output to a standard 1080p60 mode so the Pi does not depend on the TV’s EDID information every time it reappears.
  • The GPU never tears down the display pipeline, so Wayfire does not need to guess or reconfigure the screen.

Conclusion

If your Raspberry Pi goes blank when switching TV inputs, forcing HDMI hotplug and mode in config.txt is usually all you need. It is a simple one time change that makes the desktop behave reliably.

Leave a Reply

Your email address will not be published. Required fields are marked *