2025-03-04 6:04 AM
When trying to rotate the display on an STM32MP157C board from landscape (800x480) to portrait (480x800) mode, I'm experiencing issues. Using the /sys/class/graphics/fb0/rotate interface doesn't actually rotate the display, and using Qt's EGLFS with rotation settings results in only half the screen being rotated properly.
This changes the value but doesn't affect display.
Using EGLFS KMS config with rotation:
QString configPath = "/tmp/eglfs_kms.json";
QFile configFile(configPath);
if (configFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
configFile.write("{\n"
" \"device\": \"/dev/dri/card0\",\n"
" \"outputs\": [\n"
" {\n"
" \"name\": \"DPI-1\",\n"
" \"mode\": \"480x800\",\n"
" \"transform\": \"rotate-90\"\n"
" }\n"
" ]\n"
"}\n");
configFile.close();
qputenv("QT_QPA_EGLFS_KMS_CONFIG", configPath.toUtf8());
}
This partially works (screen reports correct orientation) but only half the screen is correctly rotated.
3.QML-based rotation:
Item {
width: parent.height
height: parent.width
anchors.centerIn: parent
rotation: 90
transformOrigin: Item.Center
// Content goes here
}
This somewhat works , but i dont this this is a proper solution
4.Setting various environment variables:
QT_QPA_EGLFS_ROTATION=90
QSG_RENDER_LOOP=basic
5.I tried different variations of the EGLFS configuration, including:
{
"device": "/dev/dri/card0",
"hwcursor": false,
"outputs": [
{
"name": "DPI-1",
"mode": "800x480",
"transform": "rotate-90"
}
]
}
And:
{
"device": "/dev/dri/card0",
"hwcursor": false,
"gbm": true,
"outputs": [
{
"name": "DPI-1",
"format": "xrgb8888",
"rotation": 90
}
]
}
6.Checked the device tree, which shows:
display-controller@5a001000 {
compatible = "st,stm32-ltdc";
reg = <0x5a001000 0x400>;
interrupts = <0x00 0x58 0x04 0x00 0x59 0x04>;
clocks = <0x0e 0xa7>;
clock-names = "lcd";
resets = <0x0e 0xc00>;
status = "okay";
/* No rotation property here */
}
7.Used modetest to inspect DRM properties:
The output shows mode support for 800x480 but no explicit rotation property.
From my debugging logs, when using the EGLFS configuration, Qt correctly reports the screen orientation as portrait:
=== SCREEN INFORMATION ===
Screen size: QSize(480, 800)
Physical size (mm): QSizeF(86, 154)
Platform: "eglfs"
Orientation: Qt::PortraitOrientation
However, visually, only half the screen appears correctly rotated. The debug logs show that the EGLFS configuration is being loaded correctly:
qt.qpa.eglfs.kms: Loading KMS setup from "/tmp/eglfs_kms.json"
qt.qpa.eglfs.kms: Adding QPlatformScreen 0x816d0 ( "UNKNOWN1" ) to QPA with geometry QRect(0,0 480x800)
When examining the available planes with modetest, I see:
qt.qpa.eglfs.kms: Loading KMS setup from "/tmp/eglfs_kms.json"
qt.qpa.eglfs.kms: Adding QPlatformScreen 0x816d0 ( "UNKNOWN1" ) to QPA with geometry QRect(0,0 480x800)
Currently, I'm using a QML-based rotation approach, but it causes performance issues with animations and effects. I'm looking for a proper hardware-accelerated rotation solution that works with the STM32 LTDC controller.
How can I get proper full-screen rotation with the STM32 LTDC controller? Is there a specific driver setting or Qt configuration I'm missing? Are there known limitations with this hardware?