Best practice to rotate 90 degrees and flip screen for the Framebuffer


we have successfully connected a S231AJ1 Innolux Display (Datasheet: link). Its resolution is officially 1920 * 256, but indeed, it is just 1920 * 158 because of a black stripe. The problem is the following:
The text on the screen is rotated and mirror-inverted. Hence, we would like to have the display rotated and mirrored, so that we have the console output (text is not mirrored any more) over the whole size of 60cm (not only 5cm). Within the datasheet, you can find on page … that this is normal for the display.

We think, ideally, we change this in the framebuffer. Maybe, we can change it in the uenv? In recherches, we detected the variable called IPU_ROTATE_90_RIGHT_VFLIP. We think, this is the right option, but we do not know how to use set it correctly and where…

Our perfect solution was to set it just for one lvds channel.

Hopefully, you can help.

Thank you very much!


Please have a look at the following questions:



AFAIK there is no way that the current IPU driver can display the framebuffer rotated.
The enumeration you point to is AFAIK used when with camera inputs or camera inputs copied into the framebuffer to be displayed. (BTW. you look at really old kernel sources)

This NXP community thread is about patching the kernel for basic rotation support. It may or may not work for your case.


Hi Max,

i have create this patch:
drivers/video/fbdev/mxc/ldb.c | 34 ++++++++++++++++++++++++++++++++±
1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/mxc/ldb.c b/drivers/video/fbdev/mxc/ldb.c
index 66a8fe5..2f25e43 100644
--- a/drivers/video/fbdev/mxc/ldb.c
+++ b/drivers/video/fbdev/mxc/ldb.c
@@ -106,6 +106,38 @@ struct ldb_data {
 	struct clk *div_sel_clk[2];
+// This mus be 98 I think
+ * fb_videomode_to_var_with_offset 
+ *- convert fb_videomode to fb_var_screeninfo
+ * @var: pointer to struct fb_var_screeninfo
+ * @mode: pointer to struct fb_videomode
+ */
+void fb_videomode_to_var_with_offset(struct fb_var_screeninfo *var,
+			 const struct fb_videomode *mode)
+	var->xres = mode->xres;
+	var->yres = mode->yres;
+	var->xres_virtual = (mode->xres - UNVISABLE_ON_XRES);
+	var->yres_virtual = (mode->yres - UNVISABLE_ON_YRES);
+	var->xoffset = UNVISABLE_ON_XRES;
+	var->yoffset = UNVISABLE_ON_YRES;
+	var->pixclock = mode->pixclock;
+	var->left_margin = mode->left_margin;
+	var->right_margin = mode->right_margin;
+	var->upper_margin = mode->upper_margin;
+	var->lower_margin = mode->lower_margin;
+	var->hsync_len = mode->hsync_len;
+	var->vsync_len = mode->vsync_len;
+	var->sync = mode->sync;
+	var->vmode = mode->vmode & FB_VMODE_MASK;
+	var->rotate = FB_ROTATE_CW;
 static const struct crtc_mux imx6q_lvds0_crtc_mux[] = {
 		.crtc = CRTC_IPU1_DI0,
@@ -348,7 +380,7 @@ static int ldb_init(struct mxc_dispdrv_handle *mddh,
 			fb_videomode_from_videomode(&vm, &native_mode);
 		fb_add_videomode(&fb_vm, &fbi->modelist);
-		fb_videomode_to_var(&fbi->var, &fb_vm);
+		fb_videomode_to_var_with_offset(&fbi->var, &fb_vm);
 	fb_find_mode(&fbi->var, fbi, setting->dft_mode_str, &fb_vm,

With this patch I get:

root@apalis-imx6:~# more /sys/class/graphics/fb0/rotate

Now the Text on the display is flipped. This is the first step. Now I can see the Text on the display upended and have not hold a mirror to read the Text. :smiley:
I will test more and report my results.

If you have a better easier way to set the rotation please let me know.

FYI, Max will be back next week.

Hi Max,

we build a YOCTO Linux Image without X11. We just use eglfs for our Aplikations. Thats why we don’t have xrandr. Many of our Applikations use QT5. There it would be possible to rotate it. But we would also like to see the console output. That’s why we would like to change it direkt in the creation of the Framebuffer.

The IPU has the ability to rotate the Framebuffer (See Here: GITHUB). The Only Problem is I’m not shure were in the Kernel I must set this parameter.

Best Regards


sorry, but I don’t think so. Please take a look at:

root@apalis-imx6:~# ls -l /sys/class/graphics/fb0/
total 0
-rw-r--r-- 1 root root 4096 Jul 28 16:17 bits_per_pixel
-rw-r--r-- 1 root root 4096 Jul 28 16:17 blank
-rw-r--r-- 1 root root 4096 Jul 28 16:17 console
-rw-r--r-- 1 root root 4096 Jul 28 16:17 cursor
-r--r--r-- 1 root root 4096 Jul 28 16:17 dev
lrwxrwxrwx 1 root root    0 Jul 28 16:17 device -> ../../../fb@0
-r--r--r-- 1 root root 4096 Jul 28 16:17 fsl_disp_dev_property
-rw-r--r-- 1 root root 4096 Jul 28 16:17 fsl_disp_property
-rw-r--r-- 1 root root 4096 Jul 28 16:17 mode
-rw-r--r-- 1 root root 4096 Jul 28 16:17 modes
-r--r--r-- 1 root root 4096 Jul 28 16:17 name
-rw-r--r-- 1 root root 4096 Jul 28 16:17 pan
drwxr-xr-x 2 root root    0 Jul 28 16:17 power
-rw-r--r-- 1 root root 4096 Jul 28 16:17 rotate
-rw-r--r-- 1 root root 4096 Jul 28 16:17 state
-r--r--r-- 1 root root 4096 Jul 28 16:17 stride
lrwxrwxrwx 1 root root    0 Mar 16 14:23 subsystem -> ../../../../../class/graphics
-rw-r--r-- 1 root root 4096 Mar 16 14:23 uevent
-rw-r--r-- 1 root root 4096 Jul 28 16:17 virtual_size
root@apalis-imx6:~# more /sys/class/graphics/fb0/rotate

Please correct me, If I’m wrong. I think this is the LVDS framebuffer driver. Here is an option rotate. That’s why I think there is a way. I don’t have found any Information in the Kernel or in the internet how to set rotate. I have tried to echo values and test many other things but nothing happens.

In the research I found that NXP comminty thread. From there I have the Idea to patch the Kernel. Why do you think this is not possible?

Thank you.
At the moment I try to rotate direct in ipu_init_channel_buffer.

hello @Alias_Alias,
does the rotation work now?