页次: 1
我现在使用LVGL,想把disp_flush效率提升。于是就使用了DMA,将color_p的数据搬运到LCD的buffer中,但是每次只能搬运几个字节。感觉像是cache同步问题,对cache进行了强制更新,也没用。请问有什么好办法?
DMA设置:
DMA_Init();
g_dma.Type = NDMA;//类型
g_dma.Ch = 0;//通道
g_dma.Continuous_Mode_Enable = 0;//连续模式
g_dma.Read_Byte_Counter_Enable = 0;//读计数值使能
//---------
g_dma.Source_Address_Type = DMA_ADDRESS_TYEP_LINEER;//源地址类型
g_dma.Source_DRQ_Type = NDMAS_DRQ_Type_SDRAM_Memory;//源类型
g_dma.Source_Data_Width = DMA_DATA_WIDTH_32;//源数据宽度
g_dma.Source_Burst_Length = DMA_BURST_LENGTH_4;//BURST
//-----------
g_dma.Destination_Address_Type = DMA_ADDRESS_TYEP_LINEER;//目标地址类型
g_dma.Destination_DRQ_Type = NDMAD_DRQ_Type_SDRAM_Memory;//目标类型
g_dma.Destination_Data_Width = DMA_DATA_WIDTH_32;//目标数据宽度
g_dma.Destination_Burst_Length = DMA_BURST_LENGTH_4;//BURST
更改后的disp_flush函数
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
int32_t x;
int32_t y;
g_dma.Source_Address = (unsigned int)color_p;
g_dma.Byte_Counter = (area->x2 + 1 - area->x1) * 2;//Byte计数
for(y = area->y1; y <= area->y2; y++) {
MMU_CleanDCacheArray(g_dma.Source_Address, g_dma.Byte_Counter);
g_dma.Destination_Address = (unsigned int)BT + y * LV_HOR_RES_MAX * 2 + area->x1 * 2;
DMA_Config(&g_dma);
DMA_Enable(&g_dma);
while (DMA_Get_Full_TIP(&g_dma));
DMA_Disable(&g_dma);
MMU_InvalidateDCacheArray(g_dma.Destination_Address, g_dma.Byte_Counter);
g_dma.Source_Address += (area->x2 + 1 - area->x1) * 2;
}
/* IMPORTANT!!!
* Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
int ftfont_rander(unsigned long u32c, FontCharRec *fcr){
struct FTContext *ctx = &g_ftctx;
FT_UInt glyph_index;
FTC_SBitRec *ftsbrec;
if(ctx->ftmgr == NULL){
return 1;
}
/* Request face object from cache
if (FTC_Manager_LookupFace(ctx->ftmgr, ctx, &ctx->ftface)) {
return 2;
}*/
// Request size object from cache
if (FTC_Manager_LookupSize(ctx->ftmgr, &ctx->ftscaler, &ctx->ftsize)) {
return 3;
}
// Request glyph index from cache
glyph_index = FTC_CMapCache_Lookup(ctx->ftcache, ctx, 0, u32c);
// Request bitmap from cache
if (FTC_SBitCache_Lookup(ctx->ftsbcache, &ctx->ftitype, glyph_index, &ftsbrec, NULL)) {
return 4;
}
fcr->w = ftsbrec->width;
fcr->h = ftsbrec->height;
fcr->left = ftsbrec->left;
fcr->top = ftsbrec->top;
fcr->pitch = ftsbrec->pitch;
fcr->w_adv = ftsbrec->xadvance;
fcr->h_adv = ftsbrec->yadvance;
fcr->buffer = ftsbrec->buffer;
return 0;
}
页次: 1