This article introduces how to rotate the screen angle in Linux system to solve the display mode of different product forms. Ubuntu and Debian systems can realize screen rotation through xrandr tool. Demonstration using tactile intelligent EVB3568 Hongmeng development board, equipped with Rockchip RK3568 chip, quad-core A55 processor, main frequency 2.0Ghz; 1T computing power NPU; the new OpenHarmony5.0 Release firmware has been released.
How to rotate the screen in Linux
Execute xrandr -o normal/inverted/left/right to temporarily rotate the screen direction. Command description:
Normal: indicates a clockwise rotation of 0 degrees;
right: means rotating 90 degrees clockwise;
inverted: means rotating 180 degrees clockwise;
left: indicates a 270 degree clockwise rotation;
Take the inverted command as an example:
linaro@linaro-alip:~$ xrandr -o inverted
Modify the /etc/default/xrandr startup file to achieve permanent rotation. Take 180 degrees rotation as an example, the command is as follows:
root@ido:~# vi /etc/default/xrandr #!/bin/sh /usr/bin/xrandr -o inverted root@ido:~#Permanent rotation - Applicable to Debian system
Modify the startup file, the directory is as follows:
/home/linaro/.config/lxsession/LXDE/autostart, add the xrandr command inside to achieve permanent rotation, which will still take effect after the motherboard is restarted. Taking 180 degree rotation as an example, the command is as follows:
linaro@linaro-alip:~$ vi /home/linaro/.config/lxsession/LXDE/autostart @lxpanel --profile LXDE @pcmanfm --desktop --profile LXDE @xscreensaver - no -splash xrandr -o inverted linaro@linaro-alip:~$Problems that may occur when rotating the screen
Modify the following directory files:
/etc/X11/xorg.conf.d/20-modesetting.conf
The specific modifications are as follows:
(1) Change Option "FlipFB" "always" to Option "FlipFB" "none"
(2) Change Option "UseGammaLUT" "true" to #Option "UseGammaLUT" "true"
(3) Restart to take effect
Section "Device" Identifier "Rockchip Graphics" Driver "modesetting" ### Use Rockchip RGA 2D HW accel # Option "AccelMethod" "exa" ### Use GPU HW accel Option "AccelMethod" "glamor" Option "DRI" "2 " ### Set to "always" to avoid tearing, could lead to up 50% performance loss Option "FlipFB" "none" ### Limit flip rate and drop frames for "FlipFB" to reduce performance lost # Option "MaxFlipRate" "60" Option "NoEDID" "true" # Option "UseGammaLUT" "true" EndSection Section "Screen" Identifier " Default Screen" Device "Rockchip Graphics" Monitor "Default Monitor" EndSection ### Valid values for rotation are "normal" , "left" , "right" Section "Monitor" Identifier "Default Monitor" Option "Rotate" "normal" EndSection
Option "FlipFB" "always" Meaning: This option controls framebuffer flipping. When set to "always", it forces framebuffer flipping to be enabled. This flipping helps reduce image tearing, but may incur a performance penalty, especially when frequent updates or large-scale drawing of the screen are required (such as during rotation).
Issue: In the configuration, setting FlipFB to "always" may force the driver to handle the display pipeline in a certain way, causing the rotation operation to fail. Because rotation greatly increases the need for access to display memory and frame buffer updates, "always" may cause the flip operation to conflict with the rotation requirements, thus triggering the error.
Option "FlipFB" "none" Meaning: Setting to "none" disables frame buffer flipping. This means that the system no longer tries to handle flipping in a specific way, reducing extra operations, making the rotation operation smoother. Although it may cause slight screen tearing, this setting is more suitable for screen rotation needs. Effect: By disabling frame buffer flipping, memory access conflicts or resource contention issues are reduced, allowing the rotation function to work properly.
Option "UseGammaLUT" "true" Meaning: This option controls whether to use the Gamma Look-Up Table (Gamma LUT). Gamma correction is used to adjust the brightness or contrast of the display output to achieve better image effects. Turning on UseGammaLUT will introduce additional image processing steps, especially in color correction, which will affect the GPU load. Problem: Although gamma correction is not directly related to screen rotation itself, turning on gamma correction will cause the system to perform additional color adjustments on each frame, which may affect the performance during rotation. If the graphics card driver or hardware does not support gamma correction well, it may cause conflicts with the rotation operation, ultimately affecting the update and display of the screen.
Option UseGammaLUT "true" Meaning: Commenting out this option disables gamma correction, reducing the system's processing burden for each frame. This is beneficial for operations that require frequent image updates (such as screen rotation) because the system's image processing becomes more lightweight. Effect: By disabling the gamma LUT, image processing becomes simpler, so that rotation operations are not hindered by additional color processing.
Product Introduction
The tactile intelligent EVB3568 Hongmeng development board is a Hongmeng development board/industrial control motherboard developed based on RK3568, suitable for various smart display terminals, industrial automation terminals and edge computing gateway products.