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
| Board | Raspberry Pi 3 Model B+ |
| OS | Raspberry Pi OS 13 “Trixie”, 32-bit (armhf) |
| Kernel | 6.18 (rpi-v7) |
| Graphics driver | KMS (dtoverlay=vc4-kms-v3d, the default) |
| Desktop | labwc (Wayland), wlroots 0.20 |
| Display | Official 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
xrandrand an Xorg config instead. - Wayfire, the early Bookworm desktop: not tested.
- The old firmware display driver (
fkmsor no KMS overlay): there the olddisplay_rotate/lcd_rotatesettings inconfig.txtwere 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
- Open the kernel command line:
sudo nano /boot/firmware/cmdline.txt - Go to the end of the single line, add a space, then add:
Keep everything on one line. Don’t press Enter.video=DSI-1:800x480@60,panel_orientation=upside_down - 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
- Check that labwc maps the touch controller to the display:
grep -i touch /etc/xdg/labwc/rc.xml - It should show:
<touch deviceName="10-0038 generic ft5x06 (79)" mapToOutput="DSI-1" mouseEmulation="yes"/> - If it doesn’t, look up the device name and add that line inside
<libinput>inrc.xml:sudo apt install libinput-tools sudo libinput list-devices | grep -i -A1 touch
4. Reboot
sudo reboot
5. Check it works
- The picture is upside down compared to before.
- Tap something near a corner of the screen. The pointer or tap should land right under your finger.
- 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"
- Only left/right is wrong:
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 -mshowsUnknown dtparam 'inverted' - ignored).display_rotate/lcd_rotateinconfig.txt: these settings are for the old display driver, not the one Raspberry Pi OS uses now.
