Skip to content

5" Touch Display 2 -> ili9881c panel does not respect orientation #7266

@GabeDeBacker

Description

@GabeDeBacker

Describe the bug

There have been may forum issues regarding the issue that users cannot get the Raspberry Pi 5" Touch Display 2 to respect rotation from portrait (the default) to landscape.

ret = of_drm_get_panel_orientation(dsi->dev.of_node, &ctx->orientation);

But is never sent to the device via something like this:

#define ILI9881C_MADCTL        0x36
#define ILI9881C_MADCTL_MY     BIT(7)
#define ILI9881C_MADCTL_MX     BIT(6)
#define ILI9881C_MADCTL_MV     BIT(5)
#define ILI9881C_MADCTL_BGR    BIT(3)

static u8 ili9881c_madctl_for_orientation(enum drm_panel_orientation o)
{
    u8 v = ILI9881C_MADCTL_BGR;

    switch (o) {
    case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
        v |= ILI9881C_MADCTL_MV | ILI9881C_MADCTL_MX;
        break;
    case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
        v |= ILI9881C_MADCTL_MV | ILI9881C_MADCTL_MY;                                                                                                      break;
    case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
        v |= ILI9881C_MADCTL_MX | ILI9881C_MADCTL_MY;
        break;
    case DRM_MODE_PANEL_ORIENTATION_NORMAL:
    default:
        break;
    }

    return v;
}

static int ili9881c_prepare(struct drm_panel *panel)
{
/...existing code.../
u8 madctl = ili9881c_madctl_for_orientation(ctx->orientation);
                ret = mipi_dsi_dcs_write(ctx->dsi, ILI9881C_MADCTL, &madctl, 1);
                if (ret < 0)
                        dev_err(&ctx->dsi->dev, "failed to set MADCTL: %d\n", ret);

Steps to reproduce the behaviour

This forum post pretty much says it all

https://forums.raspberrypi.com/viewtopic.php?t=379649

Device (s)

Raspberry Pi 3 Mod. B+

System

cat /etc/rpi-issue
Raspberry Pi reference 2025-12-04
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 4997bf4e4e49bc3305eb182a4a08bd023529da04, stage2
 vcgencmd version
Aug 20 2025 17:04:09
Copyright (c) 2012 Broadcom
version cd866525580337c0aee4b25880e1f5f9f674fb24 (clean) (release) (start)
uname -a
Linux ArzelPi 6.12.62+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.62-1+rpt1 (2025-12-18) aarch64 GNU/Linux

Logs

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions