Support external MIPI DSI display on Android 11

Which version of system do you use? Khadas official images, self built images, or others?

Self built image (Linux version 5.4.125-android11-2-g602415380f33-dirty)

Please describe your issue below:

I have 1024x600 MIPI DSI display with GT911 touch controller. I connect it to my VIM4 board. I change resolution in uboot (board/khadas/configs/kvim4.h) and in dts (arch/arm64/boot/dts/amlogic/mesont7_an400-panel.dtsi).

--- a/arch/arm64/boot/dts/amlogic/mesont7_an400-panel.dtsi
+++ b/arch/arm64/boot/dts/amlogic/mesont7_an400-panel.dtsi
@@ -271,7 +271,7 @@
                mipi_1{
                        model_name = "TS101";
                        interface = "mipi";
-                       basic_setting = <1920 1200 /*h_active, v_active*/
+                       basic_setting = <1024 600 /*h_active, v_active*/
                                2066 1229 /*h_period, v_period*/
                                8 /*lcd_bits*/
                                154 86>; /*screen_widht, screen_height*/

Itā€™s work correct in uboot and ubuntu 22, but on Android i have distorted image.
Ubuntu
Android uboot
Android

I found a solution on the forum (Add support of external MIPI DSI display in VIM3 Android 9 - #20 by Terry) and try to change resolution in file:

--- a/common/hwc/HwcConfig.cpp
+++ b/common/hwc/HwcConfig.cpp
@@ -14,8 +14,10 @@
 #include <misc.h>
 #include <DrmTypes.h>
 
-//#defined HWC_PRIMARY_FRAMEBUFFER_WIDTH 2160
-//#defined HWC_PRIMARY_FRAMEBUFFER_HEIGHT 3840
+#undef HWC_PRIMARY_FRAMEBUFFER_WIDTH
+#define HWC_PRIMARY_FRAMEBUFFER_WIDTH 1024
+#undef HWC_PRIMARY_FRAMEBUFFER_HEIGHT
+#define HWC_PRIMARY_FRAMEBUFFER_HEIGHT 600

But it didnā€™t work. Why does the display stop working correctly after the start of android?

Hello, the MIPI display not only needs h_active and v_active data, but also needs h_period, h_period, lcd_timing, dsi_init_on, dsi_init_off these parameters and timing

These parameters in mesont7_an400-panel.dtsi need to be consistent with the parameters of your 1024x600 screen. For this parameter, you can refer to the specifications of the screen factory or the screen

Yes, sure. The problem is that when I tried to fill in these parameters according to the datasheet, I got an even worse image.

Why does the display work on ubuntu firmware without other parameters?

You can check the log in uboot. We have made some compatibility with different MIPI screens under uboot. You can compare and modify it according to the log in uboot during the boot process. The driver of ubuntu may be different from that of Android, but Android driver MIPI screens must meet their parameters and timing requirements

@EvgenSen Our code is compatible with several mipi screens by default (recognized by reading the touch screen through I2C), and your mipi screen is horizontal. You can refer to TS101 to make modifications, so you also need to make the following modifications:

bootloader/uboot$ git diff
--- a/cmd/amlogic/cmd_kbi.c
+++ b/cmd/amlogic/cmd_kbi.c
@@ -1171,7 +1171,9 @@ static int tp_i2c_read(uint reg, const char *cp)
 
 static int do_check_panel(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
-       khadas_mipi_id = tp_i2c_read(0xA8,TP05_CHIP_ADDR);
+       khadas_mipi_id = 2;//tp_i2c_read(0xA8,TP05_CHIP_ADDR);
+       return 0;
+
        printf("TP05 id=0x%x\n",khadas_mipi_id);

hardware/amlogic/hwcomposer$ git diff
--- a/common/hwc/HwcConfig.cpp
+++ b/common/hwc/HwcConfig.cpp
@@ -48,8 +48,8 @@ int32_t HwcConfig::getFramebufferSize(int disp, uint32_t & width, uint32_t & hei
                width = HWC_PRIMARY_FRAMEBUFFER_HEIGHT;
                height = HWC_PRIMARY_FRAMEBUFFER_WIDTH;
             } else if(atoi(value) == 2) {
-               width = 1920*2;
-               height = 1200*2;
+               width = 1024*2;
+               height = 600*2;
             } else {

system/core$ git diff
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -1039,8 +1039,8 @@ static void export_lcd_status() {
                InitPropertySet("ro.minui.default_rotation", "ROTATION_NONE");
                InitPropertySet("ro.vendor.sf.rotation", "0");
                InitPropertySet("ro.surface_flinger.primary_display_orientation", "ORIENTATION_0");
-               InitPropertySet("ro.surface_flinger.max_graphics_width", "3840");//1920*2
-               InitPropertySet("ro.surface_flinger.max_graphics_height", "2400");//1200*2
+               InitPropertySet("ro.surface_flinger.max_graphics_width", "2048");//1024*2
+               InitPropertySet("ro.surface_flinger.max_graphics_height", "1200");//600*2
1 Like

This patch helped me, thanks a lot. But there is one problem. The navigation buttons disappeared from the screen. I connected the monitor via hdmi, it has them
HDMI Display
MIPI Display
At the same time, pressing the buttons works, only the display does not work

@EvgenSen add the following modificationsļ¼š

device/khadas$ git diff
--- a/kvim4/kvim4.mk
+++ b/kvim4/kvim4.mk
@@ -88,7 +88,7 @@ PRODUCT_PACKAGES += \
 
 NEED_ISP := true
 
-PRODUCT_SUPPORT_4K_UI := true
+PRODUCT_SUPPORT_4K_UI := false

If not, add the following modificationsļ¼š

hardware/amlogic/hwcomposer$ git diff
--- a/common/hwc/HwcConfig.cpp
+++ b/common/hwc/HwcConfig.cpp
@@ -48,8 +48,8 @@ int32_t HwcConfig::getFramebufferSize(int disp, uint32_t & width, uint32_t & hei
                width = HWC_PRIMARY_FRAMEBUFFER_HEIGHT;
                height = HWC_PRIMARY_FRAMEBUFFER_WIDTH;
             } else if(atoi(value) == 2) {
-               width = 1920*2;
-               height = 1200*2;
+               width = 1024;
+               height = 600;
             } else {

system/core$ git diff
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -1039,8 +1039,8 @@ static void export_lcd_status() {
                InitPropertySet("ro.minui.default_rotation", "ROTATION_NONE");
                InitPropertySet("ro.vendor.sf.rotation", "0");
                InitPropertySet("ro.surface_flinger.primary_display_orientation", "ORIENTATION_0");
-               InitPropertySet("ro.surface_flinger.max_graphics_width", "3840");//1920*2
-               InitPropertySet("ro.surface_flinger.max_graphics_height", "2400");//1200*2
+               InitPropertySet("ro.surface_flinger.max_graphics_width", "1024");//1024
+               InitPropertySet("ro.surface_flinger.max_graphics_height", "600");//600
1 Like

The first modification only changed the density on my display.
But the second modification returned the navigation buttons, everything works good.
Thanks for the help!