545 lines
22 KiB
C
545 lines
22 KiB
C
/**
|
|
* @file lv_gpu_sdrv_dma2d.c
|
|
*
|
|
*/
|
|
|
|
/*********************
|
|
* INCLUDES
|
|
*********************/
|
|
#include "lv_gpu_sdrv_dma2d.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "lvgl.h"
|
|
#include <dispss/disp.h>
|
|
#include <dispss/disp_data_type.h>
|
|
#include <g2dlite/g2dlite.h>
|
|
#include <asw/asw.h>
|
|
#include "hal_g2dlite.h"
|
|
#include "hal_asw.h"
|
|
#include "hal_sys.h"
|
|
#include "hal_gpu.h"
|
|
#include "hal_disp.h"
|
|
#if LV_USE_GPU_SEMIDRIVE_G2D
|
|
|
|
/*********************
|
|
* DEFINES
|
|
*********************/
|
|
|
|
#if LV_COLOR_16_SWAP
|
|
// TODO: F7 has red blue swap bit in control register for all layers and output
|
|
#error "Can't use DMA2D with LV_COLOR_16_SWAP 1"
|
|
#endif
|
|
|
|
#if LV_COLOR_DEPTH == 8
|
|
#error "Can't use DMA2D with LV_COLOR_DEPTH == 8"
|
|
#endif
|
|
|
|
#if LV_COLOR_DEPTH == 16
|
|
#define LV_DMA2D_COLOR_FORMAT LV_DMA2D_RGB565
|
|
#elif LV_COLOR_DEPTH == 32
|
|
#define LV_DMA2D_COLOR_FORMAT LV_DMA2D_ARGB8888
|
|
#else
|
|
/*Can't use GPU with other formats*/
|
|
#endif
|
|
|
|
/**********************
|
|
* TYPEDEFS
|
|
**********************/
|
|
#define DMA_SYNC_TIMEOUT (1000)
|
|
/**********************
|
|
* STATIC PROTOTYPES
|
|
**********************/
|
|
|
|
/************************************new define*********************************************/
|
|
|
|
static int LV_TransformFmtType(LV_GPU_Format fmtType, HAL_Format *outFmt)
|
|
{
|
|
switch (fmtType) {
|
|
case HAL_FMT_A8:
|
|
*outFmt = LV_FMT_A8;
|
|
break;
|
|
case HAL_FMT_RGB565:
|
|
*outFmt = LV_FMT_RGB565;
|
|
break;
|
|
case HAL_FMT_ARGB4444:
|
|
*outFmt = LV_FMT_ARGB4444;
|
|
break;
|
|
case HAL_FMT_ARGB1555:
|
|
*outFmt = LV_FMT_ARGB1555;
|
|
break;
|
|
case HAL_FMT_RGB888:
|
|
*outFmt = LV_FMT_RGB888;
|
|
break;
|
|
case HAL_FMT_ARGB8888:
|
|
*outFmt = LV_FMT_ARGB8888;
|
|
break;
|
|
default:
|
|
LV_LOG_ERROR("error [dma2d][%s][%d]:can't support this fmt:%d!\r\n", __FUNCTION__, __LINE__, fmtType);
|
|
return HAL_GPU_ERR_PARAM;
|
|
}
|
|
|
|
return HAL_SUCCESS;
|
|
}
|
|
|
|
static int LV_TransformBlendMode(lv_draw_mask_res_t maskRes, HAL_G2DLITE_BlendMode *blendMode)
|
|
{
|
|
switch (maskRes) {
|
|
case LV_DRAW_MASK_RES_TRANSP:
|
|
case LV_DRAW_MASK_RES_FULL_COVER:
|
|
*blendMode = BLEND_PIXEL_NONE;
|
|
break;
|
|
case LV_DRAW_MASK_RES_CHANGED:
|
|
*blendMode = BLEND_PIXEL_COVERAGE;
|
|
break;
|
|
default:
|
|
LV_LOG_ERROR("error [dma2d][%s][%d]:can't support this maskRes:%d!\r\n", __FUNCTION__, __LINE__, maskRes);
|
|
return HAL_GPU_ERR_PARAM;
|
|
}
|
|
return HAL_SUCCESS;
|
|
}
|
|
|
|
int LV_GPU_G2DLITE_Init(void)
|
|
{
|
|
return HAL_G2DLITE_Init();
|
|
}
|
|
|
|
int LV_GPU_G2DLITE_Deinit(void)
|
|
{
|
|
return HAL_G2DLITE_Deinit();
|
|
}
|
|
|
|
int LV_GPU_G2DLITE_ClearRect(LV_GPU_OutputInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_G2DLITE_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->area, HAL_G2DLITE_ERR_PARAM);
|
|
#endif
|
|
HAL_G2DLITE_OutputInfo clearInfo = {0};
|
|
clearInfo.buf = (uint8_t *)info->buf;
|
|
int ret = LV_TransformFmtType(info->fmt, &clearInfo.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
clearInfo.stride = info->stride;
|
|
clearInfo.dstRect.x = info->area.x1;
|
|
clearInfo.dstRect.y = info->area.y1;
|
|
return HAL_G2DLITE_ClearRect(&clearInfo);
|
|
}
|
|
|
|
int LV_GPU_G2DLITE_FillRect(const LV_GPU_FillRectInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_G2DLITE_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->area, HAL_G2DLITE_ERR_PARAM);
|
|
#endif
|
|
HAL_FillRectInfo fillInfo = {0};
|
|
fillInfo.buf = (uint8_t *)info->buf;
|
|
fillInfo.color = info->color.full;
|
|
int ret = LV_TransformFmtType(info->fmt, &fillInfo.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
fillInfo.stride = info->stride;
|
|
fillInfo.dstRect.x = info->area.x1;
|
|
fillInfo.dstRect.y = info->area.y1;
|
|
fillInfo.dstRect.w = lv_area_get_width(&info->area);
|
|
fillInfo.dstRect.h = lv_area_get_height(&info->area);
|
|
|
|
return HAL_G2DLITE_FillRect(&fillInfo);
|
|
}
|
|
|
|
int LV_GPU_G2DLITE_FillMask(LV_GPU_FillMaskInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_G2DLITE_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->output.area, HAL_G2DLITE_ERR_PARAM);
|
|
#endif
|
|
HAL_G2DLITE_FillMaskInfo fillMask = {0};
|
|
fillMask.maskInfo.buf = (uint8_t *)info->maskInfo.buf;
|
|
fillMask.maskInfo.color = info->maskInfo.color.full;
|
|
fillMask.maskInfo.stride = info->maskInfo.stride;
|
|
|
|
fillMask.output.buf = (uint8_t *)info->output.buf;
|
|
fillMask.output.stride = info->output.stride;
|
|
int ret = LV_TransformFmtType(info->output.fmt, &fillMask.output.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
fillMask.output.dstRect.x = info->output.area.x1;
|
|
fillMask.output.dstRect.y = info->output.area.y1;
|
|
fillMask.output.dstRect.w = lv_area_get_width(&info->output.area);
|
|
fillMask.output.dstRect.h = lv_area_get_height(&info->output.area);
|
|
|
|
return HAL_G2DLITE_FillMask(&fillMask);
|
|
}
|
|
|
|
int LV_GPU_G2DLITE_BlendImg(const LV_GPU_BlendImgInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_G2DLITE_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->output.area, HAL_G2DLITE_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(info->fgSurface.srcArea, HAL_G2DLITE_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(info->fgSurface.dstArea, HAL_G2DLITE_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(info->bgSurface.srcArea, HAL_G2DLITE_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(info->bgSurface.dstArea, HAL_G2DLITE_ERR_PARAM);
|
|
#endif
|
|
|
|
HAL_G2DLITE_BlendImgInfo blendImg = {0};
|
|
blendImg.bgSurface.alpha = info->bgSurface.alpha;
|
|
int ret = LV_TransformBlendMode(info->bgSurface.maskRes, &blendImg.bgSurface.blendMode);
|
|
LV_CHECK_RETURN(ret, "transform blend mode");
|
|
blendImg.bgSurface.buf = (uint8_t *)info->bgSurface.buf;
|
|
ret = LV_TransformFmtType(info->bgSurface.fmt, &blendImg.bgSurface.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
blendImg.bgSurface.stride = info->bgSurface.stride;
|
|
blendImg.bgSurface.srcRect.x = info->bgSurface.srcArea.x1;
|
|
blendImg.bgSurface.srcRect.y = info->bgSurface.srcArea.y1;
|
|
blendImg.bgSurface.srcRect.w = lv_area_get_width(&info->bgSurface.srcArea);
|
|
blendImg.bgSurface.srcRect.h = lv_area_get_height(&info->bgSurface.srcArea);
|
|
blendImg.bgSurface.dstRect.x = info->bgSurface.dstArea.x1;
|
|
blendImg.bgSurface.dstRect.y = info->bgSurface.dstArea.y1;
|
|
blendImg.bgSurface.dstRect.w = lv_area_get_width(&info->bgSurface.dstArea);
|
|
blendImg.bgSurface.dstRect.h = lv_area_get_height(&info->bgSurface.dstArea);
|
|
|
|
blendImg.fgSurface.alpha = info->bgSurface.alpha;
|
|
ret = LV_TransformBlendMode(info->fgSurface.maskRes, &blendImg.fgSurface.blendMode);
|
|
LV_CHECK_RETURN(ret, "transform blend mode");
|
|
blendImg.fgSurface.buf = (uint8_t *)info->fgSurface.buf;
|
|
ret = LV_TransformFmtType(info->fgSurface.fmt, &blendImg.fgSurface.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
blendImg.fgSurface.stride = info->fgSurface.stride;
|
|
blendImg.fgSurface.srcRect.x = info->fgSurface.srcArea.x1;
|
|
blendImg.fgSurface.srcRect.y = info->fgSurface.srcArea.y1;
|
|
blendImg.fgSurface.srcRect.w = lv_area_get_width(&info->fgSurface.srcArea);
|
|
blendImg.fgSurface.srcRect.h = lv_area_get_height(&info->fgSurface.srcArea);
|
|
blendImg.fgSurface.dstRect.x = info->fgSurface.dstArea.x1;
|
|
blendImg.fgSurface.dstRect.y = info->fgSurface.dstArea.y1;
|
|
blendImg.fgSurface.dstRect.w = lv_area_get_width(&info->fgSurface.dstArea);
|
|
blendImg.fgSurface.dstRect.h = lv_area_get_height(&info->fgSurface.dstArea);
|
|
|
|
blendImg.output.buf = (uint8_t *)info->output.buf;
|
|
ret = LV_TransformFmtType(info->output.fmt, &blendImg.output.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
blendImg.output.stride = info->output.stride;
|
|
blendImg.output.dstRect.x = info->output.area.x1;
|
|
blendImg.output.dstRect.y = info->output.area.y1;
|
|
blendImg.output.dstRect.w = lv_area_get_width(&info->output.area);
|
|
blendImg.output.dstRect.h = lv_area_get_height(&info->output.area);
|
|
|
|
return HAL_G2DLITE_BlendImg(&blendImg);
|
|
}
|
|
|
|
int LV_GPU_G2DLITE_BlendRleImg(const LV_GPU_BlendImgInfo *info, LV_GPU_RleInfo *rleInfo)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_G2DLITE_NULL_PTR);
|
|
LV_CHECK_NULLPTR_RETURN(rleInfo, HAL_G2DLITE_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->output.area, HAL_G2DLITE_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(info->fgSurface.srcArea, HAL_G2DLITE_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(info->fgSurface.dstArea, HAL_G2DLITE_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(info->bgSurface.srcArea, HAL_G2DLITE_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(info->bgSurface.dstArea, HAL_G2DLITE_ERR_PARAM);
|
|
#endif
|
|
HAL_G2DLITE_BlendImgInfo blendImg = {0};
|
|
blendImg.bgSurface.alpha = info->bgSurface.alpha;
|
|
int ret = LV_TransformBlendMode(info->bgSurface.maskRes, &blendImg.bgSurface.blendMode);
|
|
LV_CHECK_RETURN(ret, "transform blend mode");
|
|
blendImg.bgSurface.buf = (uint8_t *)info->bgSurface.buf;
|
|
ret = LV_TransformFmtType(info->bgSurface.fmt, &blendImg.bgSurface.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
blendImg.bgSurface.stride = info->bgSurface.stride;
|
|
blendImg.bgSurface.srcRect.x = info->bgSurface.srcArea.x1;
|
|
blendImg.bgSurface.srcRect.y = info->bgSurface.srcArea.y1;
|
|
blendImg.bgSurface.srcRect.w = lv_area_get_width(&info->bgSurface.srcArea);
|
|
blendImg.bgSurface.srcRect.h = lv_area_get_height(&info->bgSurface.srcArea);
|
|
blendImg.bgSurface.dstRect.x = info->bgSurface.dstArea.x1;
|
|
blendImg.bgSurface.dstRect.y = info->bgSurface.dstArea.y1;
|
|
blendImg.bgSurface.dstRect.w = lv_area_get_width(&info->bgSurface.dstArea);
|
|
blendImg.bgSurface.dstRect.h = lv_area_get_height(&info->bgSurface.dstArea);
|
|
|
|
blendImg.fgSurface.alpha = info->fgSurface.alpha;
|
|
ret = LV_TransformBlendMode(info->fgSurface.maskRes, &blendImg.fgSurface.blendMode);
|
|
LV_CHECK_RETURN(ret, "transform blend mode");
|
|
blendImg.fgSurface.buf = (uint8_t *)info->fgSurface.buf;
|
|
ret = LV_TransformFmtType(info->fgSurface.fmt, &blendImg.fgSurface.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
blendImg.fgSurface.stride = info->fgSurface.stride;
|
|
blendImg.fgSurface.srcRect.x = info->fgSurface.srcArea.x1;
|
|
blendImg.fgSurface.srcRect.y = info->fgSurface.srcArea.y1;
|
|
blendImg.fgSurface.srcRect.w = lv_area_get_width(&info->fgSurface.srcArea);
|
|
blendImg.fgSurface.srcRect.h = lv_area_get_height(&info->fgSurface.srcArea);
|
|
blendImg.fgSurface.dstRect.x = info->fgSurface.dstArea.x1;
|
|
blendImg.fgSurface.dstRect.y = info->fgSurface.dstArea.y1;
|
|
blendImg.fgSurface.dstRect.w = lv_area_get_width(&info->fgSurface.dstArea);
|
|
blendImg.fgSurface.dstRect.h = lv_area_get_height(&info->fgSurface.dstArea);
|
|
|
|
blendImg.output.buf = (uint8_t *)info->output.buf;
|
|
ret = LV_TransformFmtType(info->output.fmt, &blendImg.output.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
blendImg.output.stride = info->output.stride;
|
|
blendImg.output.dstRect.x = info->output.area.x1;
|
|
blendImg.output.dstRect.y = info->output.area.y1;
|
|
blendImg.output.dstRect.w = lv_area_get_width(&info->output.area);
|
|
blendImg.output.dstRect.h = lv_area_get_height(&info->output.area);
|
|
|
|
HAL_G2DLITE_RleInfo rle;
|
|
rle.rleType = (HAL_G2DLITE_RleSurfaceType)rleInfo->rleType;
|
|
|
|
return HAL_G2DLITE_BlendRleImg(&blendImg, &rle);
|
|
}
|
|
|
|
|
|
int LV_GPU_G2DLITE_BlendMask(const LV_GPU_BlendMaskInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_G2DLITE_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->output.area, HAL_G2DLITE_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(info->surfaceInfo.srcArea, HAL_G2DLITE_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(info->surfaceInfo.dstArea, HAL_G2DLITE_ERR_PARAM);
|
|
#endif
|
|
|
|
HAL_G2DLITE_BlendMaskInfo blendMask = {0};
|
|
blendMask.maskInfo.buf = (uint8_t *)info->maskInfo.buf;
|
|
blendMask.maskInfo.color = info->maskInfo.color.full;
|
|
blendMask.maskInfo.stride = info->maskInfo.stride;
|
|
|
|
blendMask.surfaceInfo.alpha = info->surfaceInfo.alpha;
|
|
int ret = LV_TransformBlendMode(info->surfaceInfo.maskRes, &blendMask.surfaceInfo.blendMode);
|
|
LV_CHECK_RETURN(ret, "transform blend mode");
|
|
blendMask.surfaceInfo.buf = (uint8_t *)info->surfaceInfo.buf;
|
|
ret = LV_TransformFmtType(info->surfaceInfo.fmt, &blendMask.surfaceInfo.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
blendMask.surfaceInfo.stride = info->surfaceInfo.stride;
|
|
blendMask.surfaceInfo.srcRect.x = info->surfaceInfo.srcArea.x1;
|
|
blendMask.surfaceInfo.srcRect.y = info->surfaceInfo.srcArea.y1;
|
|
blendMask.surfaceInfo.srcRect.w = lv_area_get_width(&info->surfaceInfo.srcArea);
|
|
blendMask.surfaceInfo.srcRect.h = lv_area_get_height(&info->surfaceInfo.srcArea);
|
|
blendMask.surfaceInfo.dstRect.x = info->surfaceInfo.dstArea.x1;
|
|
blendMask.surfaceInfo.dstRect.y = info->surfaceInfo.dstArea.y1;
|
|
blendMask.surfaceInfo.dstRect.w = lv_area_get_width(&info->surfaceInfo.dstArea);
|
|
blendMask.surfaceInfo.dstRect.h = lv_area_get_height(&info->surfaceInfo.dstArea);
|
|
|
|
blendMask.output.buf = (uint8_t *)info->output.buf;
|
|
ret = LV_TransformFmtType(info->output.fmt, &blendMask.output.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
blendMask.output.stride = info->output.stride;
|
|
blendMask.output.dstRect.x = info->output.area.x1;
|
|
blendMask.output.dstRect.y = info->output.area.y1;
|
|
blendMask.output.dstRect.w = lv_area_get_width(&info->output.area);
|
|
blendMask.output.dstRect.h = lv_area_get_height(&info->output.area);
|
|
return HAL_G2DLITE_BlendMask(&blendMask);
|
|
}
|
|
|
|
int LV_GPU_G2DLITE_FastCopy(const LV_GPU_FastCopyInfo *in, LV_GPU_FastCopyInfo *out)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(in, HAL_G2DLITE_NULL_PTR);
|
|
LV_CHECK_NULLPTR_RETURN(out, HAL_G2DLITE_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(in->area, HAL_G2DLITE_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(out->area, HAL_G2DLITE_ERR_PARAM);
|
|
#endif
|
|
|
|
HAL_G2DLITE_FastCopyInfo src = {0};
|
|
HAL_G2DLITE_FastCopyInfo dst = {0};
|
|
int ret = LV_TransformFmtType(in->fmt, &src.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
src.buf = (uint8_t *)in->buf;
|
|
src.rect.x = in->area.x1;
|
|
src.rect.y = in->area.y1;
|
|
src.rect.w = lv_area_get_width(&in->area);
|
|
src.rect.h = lv_area_get_height(&in->area);
|
|
src.stride = in->stride;
|
|
|
|
ret = LV_TransformFmtType(out->fmt, &dst.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
dst.buf = (uint8_t *)out->buf;
|
|
dst.rect.x = out->area.x1;
|
|
dst.rect.y = out->area.y1;
|
|
dst.rect.w = lv_area_get_width(&out->area);
|
|
dst.rect.h = lv_area_get_height(&out->area);
|
|
dst.stride = out->stride;
|
|
|
|
return HAL_G2DLITE_FastCopy(&src, &dst);
|
|
}
|
|
|
|
int LV_GPU_ASW_FillRect(const LV_GPU_FillRectInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_ASW_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->area, HAL_ASW_ERR_PARAM);
|
|
#endif
|
|
HAL_FillRectInfo fillInfo = {0};
|
|
fillInfo.buf = (uint8_t *)info->buf;
|
|
fillInfo.color = info->color.full;
|
|
int ret = LV_TransformFmtType(info->fmt, &fillInfo.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
fillInfo.stride = info->stride;
|
|
fillInfo.dstRect.x = info->area.x1;
|
|
fillInfo.dstRect.y = info->area.y1;
|
|
fillInfo.dstRect.w = lv_area_get_width(&info->area);
|
|
fillInfo.dstRect.h = lv_area_get_height(&info->area);
|
|
|
|
return HAL_ASW_FillRect(&fillInfo);
|
|
}
|
|
|
|
int LV_GPU_ASW_FillTriangle(const LV_GPU_FillRatriaInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_ASW_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->area, HAL_ASW_ERR_PARAM);
|
|
#endif
|
|
|
|
HAL_FillRatriaInfo fillInfo = {0};
|
|
fillInfo.type = (HAL_TRIANLE_Type)info->type;
|
|
int ret = LV_TransformFmtType(info->fmt, &fillInfo.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
fillInfo.color = info->color.full;
|
|
fillInfo.dstRect.w = lv_area_get_width(&info->area);
|
|
fillInfo.dstRect.h = lv_area_get_height(&info->area);
|
|
fillInfo.dstRect.x = info->area.x1;
|
|
fillInfo.dstRect.y = info->area.y1;
|
|
fillInfo.buf = (uint8_t *)info->buf;
|
|
fillInfo.stride = info->stride;
|
|
return HAL_ASW_FillTriangle(&fillInfo);
|
|
}
|
|
|
|
void *LV_GPU_DISP_GetHandle(LV_GPU_ScreenType type)
|
|
{
|
|
if (type != LV_SCREEN_TYPE_CLUSTER) {
|
|
LV_LOG_ERROR("error [dma2d]: can't support this type:%d!\n", type);
|
|
return NULL;
|
|
}
|
|
return HAL_DISP_GetHandle(type);
|
|
}
|
|
int LV_GPU_DISP_Post(void *handle, const LV_GPU_DisplayInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_ASW_NULL_PTR);
|
|
LV_CHECK_NULLPTR_RETURN(handle, HAL_ASW_NULL_PTR);
|
|
if (info->winCnt > LV_GPU_WIN_MAX_CNT) {
|
|
LV_LOG_ERROR("error [dma2d]: info->winCnt[%u] No more than %d!\r\n", info->winCnt, LV_GPU_WIN_MAX_CNT);
|
|
return HAL_DISP_ERR_PARAM;
|
|
}
|
|
#endif
|
|
HAL_DISP_Info halInfo;
|
|
memset(&halInfo, 0, sizeof(halInfo));
|
|
halInfo.winCnt = info->winCnt;
|
|
for (int i = 0; i < info->winCnt; i++) {
|
|
const LV_GPU_WindowInfo *winInfo = &info->winInfo[i];
|
|
HAL_DISP_WindowInfo *halWinInfo = &halInfo.winInfo[i];
|
|
LV_CHECK_AREA_RETURN(winInfo->src, HAL_DISP_ERR_PARAM);
|
|
LV_CHECK_AREA_RETURN(winInfo->dst, HAL_DISP_ERR_PARAM);
|
|
halWinInfo->id = winInfo->id;
|
|
halWinInfo->dirty = winInfo->dirty;
|
|
halWinInfo->en = winInfo->en;
|
|
int ret = LV_TransformFmtType(winInfo->fmt, &halWinInfo->fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
halWinInfo->src.x = winInfo->src.x1;
|
|
halWinInfo->src.y = winInfo->src.y1;
|
|
halWinInfo->src.w = lv_area_get_width(&winInfo->src);
|
|
halWinInfo->src.h = lv_area_get_height(&winInfo->src);
|
|
for (int j = 0; j < HAL_DISP_YUVA_ADDR_CNT; j++) {
|
|
halWinInfo->addr[j] = (uint8_t *)winInfo->addr[j];
|
|
halWinInfo->srcStride[j] = winInfo->srcStride[j];
|
|
}
|
|
halWinInfo->dst.x = winInfo->dst.x1;
|
|
halWinInfo->dst.y = winInfo->dst.y1;
|
|
halWinInfo->dst.w = lv_area_get_width(&winInfo->dst);;
|
|
halWinInfo->dst.h = lv_area_get_height(&winInfo->dst);
|
|
halWinInfo->zOrder = winInfo->zOrder;
|
|
halWinInfo->enAlpha = winInfo->enAlpha;
|
|
halWinInfo->alpha = winInfo->alpha;
|
|
halWinInfo->enCkey = winInfo->enCkey;
|
|
halWinInfo->security = winInfo->security;
|
|
}
|
|
|
|
return HAL_DISP_Post(handle, &halInfo);
|
|
}
|
|
|
|
int LV_GPU_Rotate(const LV_GPU_RotateInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_ASW_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->srcArea, HAL_ASW_ERR_PARAM);
|
|
#endif
|
|
|
|
HAL_RotateInfo rotateInfo = {0};
|
|
rotateInfo.srcRect.x = info->srcArea.x1;
|
|
rotateInfo.srcRect.y = info->srcArea.y1;
|
|
rotateInfo.srcRect.w = lv_area_get_width(&info->srcArea);
|
|
rotateInfo.srcRect.h = lv_area_get_height(&info->srcArea);
|
|
rotateInfo.srcBuf = (uint8_t *)info->srcBuf;
|
|
int ret = LV_TransformFmtType(info->srcFmt, &rotateInfo.srcFmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
rotateInfo.srcStride = info->srcStride;
|
|
|
|
rotateInfo.dstBuf = (uint8_t *)info->dstBuf;
|
|
ret = LV_TransformFmtType(info->dstFmt, &rotateInfo.dstFmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
rotateInfo.dstWidth = info->dstWidth;
|
|
rotateInfo.dstHeight = info->dstHeight;
|
|
rotateInfo.dstStride = info->dstStride;
|
|
|
|
rotateInfo.angle = info->angle;
|
|
rotateInfo.bgColor = info->bgColor.full;
|
|
|
|
return HAL_GPU_Rotate(&rotateInfo);
|
|
}
|
|
|
|
int LV_GPU_CleanCacheRange(const LV_GPU_CacheInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_ASW_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->area, HAL_ASW_ERR_PARAM);
|
|
#endif
|
|
HAL_SYS_CacheInfo cacheInfo = {0};
|
|
cacheInfo.buf = (uint8_t *)info->buf;
|
|
int ret = LV_TransformFmtType(info->fmt, &cacheInfo.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
cacheInfo.rect.x = info->area.x1;
|
|
cacheInfo.rect.y = info->area.y1;
|
|
cacheInfo.rect.w = lv_area_get_width(&info->area);
|
|
cacheInfo.rect.h = lv_area_get_height(&info->area);
|
|
cacheInfo.stride = info->stride;
|
|
|
|
return HAL_SYS_CleanCacheRange(&cacheInfo);
|
|
}
|
|
|
|
int LV_GPU_InvalidateCacheRange(const LV_GPU_CacheInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_ASW_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->area, HAL_ASW_ERR_PARAM);
|
|
#endif
|
|
HAL_SYS_CacheInfo cacheInfo = {0};
|
|
cacheInfo.buf = (uint8_t *)info->buf;
|
|
int ret = LV_TransformFmtType(info->fmt, &cacheInfo.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
cacheInfo.rect.x = info->area.x1;
|
|
cacheInfo.rect.y = info->area.y1;
|
|
cacheInfo.rect.w = lv_area_get_width(&info->area);
|
|
cacheInfo.rect.h = lv_area_get_height(&info->area);
|
|
cacheInfo.stride = info->stride;
|
|
|
|
return HAL_SYS_InvalidateCacheRange(&cacheInfo);
|
|
}
|
|
|
|
int LV_GPU_CleanInvalidateCacheRange(const LV_GPU_CacheInfo *info)
|
|
{
|
|
#if HAL_DEBUG_MODE
|
|
LV_CHECK_NULLPTR_RETURN(info, HAL_ASW_NULL_PTR);
|
|
LV_CHECK_AREA_RETURN(info->area, HAL_ASW_ERR_PARAM);
|
|
#endif
|
|
HAL_SYS_CacheInfo cacheInfo = {0};
|
|
cacheInfo.buf = (uint8_t *)info->buf;
|
|
int ret = LV_TransformFmtType(info->fmt, &cacheInfo.fmt);
|
|
LV_CHECK_RETURN(ret, "transform fmt type");
|
|
cacheInfo.rect.x = info->area.x1;
|
|
cacheInfo.rect.y = info->area.y1;
|
|
cacheInfo.rect.w = lv_area_get_width(&info->area);
|
|
cacheInfo.rect.h = lv_area_get_height(&info->area);
|
|
cacheInfo.stride = info->stride;
|
|
|
|
return HAL_SYS_CleanInvalidateCacheRange(&cacheInfo);
|
|
}
|
|
|
|
void LV_GPU_CleanInvalidateCacheAll(void)
|
|
{
|
|
HAL_SYS_CleanInvalidateCacheAll();
|
|
}
|
|
#endif
|