Porting display driver in diffrent memory bytes aligned

Description

I try to porting lvgl’s display driver and use disp_drv.full_refresh = 1;.However, for some reasons, the display memory of the LCD must be aligned at 64 bytes. This is not the same as the LVGL video memory arrangement. So I can’t directly use the LCD display setting as the LVGL display buffer. Two different buffer memory arrangements might look like the following:
1678416583516
They don’t have the same length in the x direction. Here is the code I implemented:

void lv_port_disp_init()
{
  lv_color_t* buf_2_1 = malloc (screen_w * screen_h * sizeof(lv_color_t)); 
  lv_color_t* buf_2_2 = malloc (screen_w * screen_h * sizeof(lv_color_t));                         
  lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, screen_w * screen_h);
  ...
  disp_drv.flush_cb = disp_flush;
  ...
}
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
	if(disp_flush_enabled) {
		SURFACE* dst = get_target_buffer();
		void* buff = dst->pixels;
        int32_t y;
        for(y = area->y1; y <= area->y2; y++) {
			memcpy(buff, &(color_p->full), dst->pitch);
			color_p += dst->w;
			buff += dst->pitch;
        }
         
		flip();
    }
    lv_disp_flush_ready(disp_drv);
}

In disp_flush I must copy pixels line by line to LCD`s display buff, It’s too inefficient.

What MCU/Processor/Board and compiler are you using?

AMAZON2, GCC

What LVGL version are you using?

LVGL8.3

What do you want to achieve?

void lv_port_disp_init()
{
  lv_color_t* buf_2_1 = get_lcd_display_buff1(); 
  lv_color_t* buf_2_2 = get_lcd_display_buff2();                         
  lv_disp_draw_buf_init(&draw_buf_dsc_2, buf_2_1, buf_2_2, screen_w * screen_h);
  ...
  disp_drv.flush_cb = disp_flush;
  ...
}
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
	if(disp_flush_enabled) {
		flip();
    }
    lv_disp_flush_ready(disp_drv);
}
  • Direct use of LCD display
  • Just ‘flip’ on refresh