When installing the Raspberry Pi 7" Touch Screen, and you have the special enclosure for it, when booting, you’ll realize that the image is upside down. Very annoying. So how do you fix it? If you search the web, you most likely will stumble on instructions that don’t work. That’s because they are for the older X11 Windowing system, not the system that comes with the latest version of the Raspberry Pi OS. That system is called Wayland. Here’s how to remedy this.

Flip the Raspberry Pi 7" touch screen 180° (Wayland / labwc)

If your case mounts the official Raspberry Pi Touch Display upside down, you need to flip two things: the picture and the touch coordinates. These steps are for current Raspberry Pi OS, which uses the labwc Wayland desktop.

Which setups this applies to

Tested on

BoardRaspberry Pi 3 Model B+
OSRaspberry Pi OS 13 “Trixie”, 32-bit (armhf)
Kernel6.18 (rpi-v7)
Graphics driverKMS (dtoverlay=vc4-kms-v3d, the default)
Desktoplabwc (Wayland), wlroots 0.20
DisplayOfficial 7" Touch Display v1 (800×480), connector DSI-1, touch controller ft5x06

It should work the same on a Pi 4 or Pi 5 running Raspberry Pi OS Bookworm or Trixie with labwc. labwc became the default desktop on all Pis in late 2024.

Doesn’t apply to

  • X11 / the “legacy” desktop (LXDE/Openbox): X11 rotates with xrandr and an Xorg config instead.
  • Wayfire, the early Bookworm desktop: not tested.
  • The old firmware display driver (fkms or no KMS overlay): there the old display_rotate / lcd_rotate settings in config.txt were the way to rotate.
  • Touch Display 2 (720×1280, 2024): a different panel and driver. It has its own rotation option in the device tree.
  • HDMI screens: use the Screen Configuration tool instead.

Before you start

Check which connector the display is on:

wlr-randr

On a Pi 3 or Pi 4 it’s DSI-1. On a Pi 5 it may be DSI-2. If yours is different, use that name everywhere below instead of DSI-1.

1. Flip the picture

  1. Open the kernel command line:
    sudo nano /boot/firmware/cmdline.txt
    
  2. Go to the end of the single line, add a space, then add:
    video=DSI-1:800x480@60,panel_orientation=upside_down
    
    Keep everything on one line. Don’t press Enter.
  3. Save and exit (Ctrl+O, Enter, Ctrl+X).

2. Flip the touch coordinates

The touch controller isn’t rotated with the picture, so flip its coordinates with a libinput calibration matrix:

echo 'ENV{ID_INPUT_TOUCHSCREEN}=="1", ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 0 -1 1"' \
  | sudo tee /etc/udev/rules.d/99-touch-flip.rules

3. Check the touch-to-display mapping

  1. Check that labwc maps the touch controller to the display:
    grep -i touch /etc/xdg/labwc/rc.xml
    
  2. It should show:
    <touch deviceName="10-0038 generic ft5x06 (79)" mapToOutput="DSI-1" mouseEmulation="yes"/>
    
  3. If it doesn’t, look up the device name and add that line inside <libinput> in rc.xml:
    sudo apt install libinput-tools
    sudo libinput list-devices | grep -i -A1 touch
    

4. Reboot

sudo reboot

5. Check it works

  1. The picture is upside down compared to before.
  2. Tap something near a corner of the screen. The pointer or tap should land right under your finger.
  3. If touch lands in the mirrored spot in only one direction, change the matrix in /etc/udev/rules.d/99-touch-flip.rules, then reboot:
    • Only left/right is wrong: "-1 0 1 0 1 0"
    • Only up/down is wrong: "1 0 0 0 -1 1"

Why it works this way on Wayland

panel_orientation=upside_down tells the kernel the panel is mounted upside down. labwc reads that and rotates the picture in the display hardware, but still reports the screen’s transform as normal. That’s why you must not also rotate the screen in Screen Configuration or kanshi: the two rotations cancel out and the picture is back the way it was.

Don’t use

  • Rotating in Screen Configuration / kanshi: leave the transform at normal, as explained above.
  • dtoverlay=vc4-kms-dsi-7inch,inverted: often suggested, but the firmware ignores it (sudo vclog -m shows Unknown dtparam 'inverted' - ignored).
  • display_rotate / lcd_rotate in config.txt: these settings are for the old display driver, not the one Raspberry Pi OS uses now.