Zero-copy buffer swaps can be used in xf86-video-fbturbo for GLES/DRI2
applications only when a certain minimal framebuffer size is available.
In order to make everything easier for the end users, just override
the fb0_framebuffer_num/fb1_framebuffer_num settings from FEX and
increase them when necessary.

Do it only when CMA is enabled. Otherwise this may be dangerous when
the user controls the size of disp framebuffer reservation via kernel
cmdline.

Signed-off-by: Siarhei Siamashka <siarhei.siamas...@gmail.com>
---
 drivers/video/sunxi/disp/dev_fb.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/video/sunxi/disp/dev_fb.c 
b/drivers/video/sunxi/disp/dev_fb.c
index 6946222..aae088e 100644
--- a/drivers/video/sunxi/disp/dev_fb.c
+++ b/drivers/video/sunxi/disp/dev_fb.c
@@ -339,6 +339,27 @@ parser_disp_init_para(__disp_init_t *init_para)
        }
        init_para->scaler_mode[1] = value;
 
+#if defined(CONFIG_MALI) && defined(CONFIG_FB_SUNXI_UMP) && defined(CONFIG_CMA)
+       /*
+        * It is best to ensure that the offscreen framebuffer area has
+        * enough space for two more frames with 32-bit color depth. This
+        * is needed for zero-copy buffer swaps in xf86-video-fbturbo DDX.
+        */
+       for (i = 0; i < 2; i++) {
+               if (init_para->format[i] == DISP_FORMAT_ARGB8888 ||
+                   init_para->format[i] == DISP_FORMAT_ARGB888) {
+                       init_para->buffer_num[i] =
+                               max(init_para->buffer_num[i], 3U);
+               } else if (init_para->format[i] == DISP_FORMAT_RGB888) {
+                       init_para->buffer_num[i] =
+                               max(init_para->buffer_num[i], 4U);
+               } else {
+                       init_para->buffer_num[i] =
+                               max(init_para->buffer_num[i], 5U);
+               }
+       }
+#endif
+
        __inf("====display init para begin====\n");
        __inf("b_init:%d\n", init_para->b_init);
        __inf("disp_mode:%d\n\n", init_para->disp_mode);
-- 
2.4.10

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to