移动了文件位置
This commit is contained in:
544
middleware/littlevgl/lvgl_sdrv/gpu/lv_gpu_sdrv_dma2d.c
Normal file
544
middleware/littlevgl/lvgl_sdrv/gpu/lv_gpu_sdrv_dma2d.c
Normal file
@@ -0,0 +1,544 @@
|
||||
/**
|
||||
* @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
|
||||
59
middleware/littlevgl/lvgl_sdrv/gpu/lv_gpu_sdrv_dma2d.h
Normal file
59
middleware/littlevgl/lvgl_sdrv/gpu/lv_gpu_sdrv_dma2d.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @file lv_gpu_sdrv_dma2d.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_GPU_SEMIDRIVE_DMA2D_H
|
||||
#define LV_GPU_SEMIDRIVE_DMA2D_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_gpu_sdrv_dma2d_define.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define LV_DMA2D_ARGB8888 0
|
||||
#define LV_DMA2D_RGB888 1
|
||||
#define LV_DMA2D_RGB565 2
|
||||
#define LV_DMA2D_ARGB1555 3
|
||||
#define LV_DMA2D_ARGB4444 4
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*************************new define***********************************
|
||||
*********************************************************************/
|
||||
int LV_GPU_G2DLITE_Init(void);
|
||||
int LV_GPU_G2DLITE_Deinit(void);
|
||||
int LV_GPU_G2DLITE_FillRect(const LV_GPU_FillRectInfo *info);
|
||||
int LV_GPU_G2DLITE_FillMask(LV_GPU_FillMaskInfo *info);
|
||||
int LV_GPU_G2DLITE_BlendImg(const LV_GPU_BlendImgInfo *info);
|
||||
int LV_GPU_G2DLITE_BlendRleImg(const LV_GPU_BlendImgInfo *info, LV_GPU_RleInfo *rleInfo);
|
||||
int LV_GPU_G2DLITE_BlendMask(const LV_GPU_BlendMaskInfo *info);
|
||||
int LV_GPU_G2DLITE_FastCopy(const LV_GPU_FastCopyInfo *in, LV_GPU_FastCopyInfo *out);
|
||||
|
||||
int LV_GPU_ASW_FillRect(const LV_GPU_FillRectInfo *info);
|
||||
int LV_GPU_ASW_FillTriangle(const LV_GPU_FillRatriaInfo *info);
|
||||
|
||||
void *LV_GPU_DISP_GetHandle(LV_GPU_ScreenType type);
|
||||
int LV_GPU_DISP_Post(void *handle, const LV_GPU_DisplayInfo *info);
|
||||
|
||||
int LV_GPU_Rotate(const LV_GPU_RotateInfo *info);
|
||||
int LV_GPU_CleanCacheRange(const LV_GPU_CacheInfo *info);
|
||||
int LV_GPU_InvalidateCacheRange(const LV_GPU_CacheInfo *info);
|
||||
int LV_GPU_CleanInvalidateCacheRange(const LV_GPU_CacheInfo *info);
|
||||
void LV_GPU_CleanInvalidateCacheAll(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*lv_gpu_sdrv_DMA2D_H*/
|
||||
199
middleware/littlevgl/lvgl_sdrv/gpu/lv_gpu_sdrv_dma2d_define.h
Normal file
199
middleware/littlevgl/lvgl_sdrv/gpu/lv_gpu_sdrv_dma2d_define.h
Normal file
@@ -0,0 +1,199 @@
|
||||
/**
|
||||
* @file lv_gpu_sdrv_dma2d_define.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_GPU_SEMIDRIVE_DMA2D_DEFINE_H
|
||||
#define LV_GPU_SEMIDRIVE_DMA2D_DEFINE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_GPU_WIN_MAX_CNT 2
|
||||
#define LV_GPU_YUVA_ADDR_CNT 4
|
||||
|
||||
/* fmt */
|
||||
typedef enum {
|
||||
LV_FMT_A8 = 0, /* alpha 8bit */
|
||||
LV_FMT_RGB565, /* rgb565 */
|
||||
LV_FMT_ARGB4444, /* argb4444 */
|
||||
LV_FMT_ARGB1555, /* argb1555 */
|
||||
LV_FMT_RGB888, /* rgb888 */
|
||||
LV_FMT_ARGB8888, /* argb8888 */
|
||||
LV_FMT_BUTT
|
||||
} LV_GPU_Format;
|
||||
|
||||
typedef enum {
|
||||
LV_TRIANGLE_TOP_LEFT = 0, /* shows the triangle in the top left corner */
|
||||
LV_TRIANGLE_BOTTOM_LEFT, /* shows the triangle in the bottom left corner */
|
||||
LV_TRIANGLE_TOP_RIGHT, /* shows the triangle in the top right corner */
|
||||
LV_TRIANGLE_BOTTOM_RIGHT, /* shows the triangle in the bottom right corner */
|
||||
LV_TRIANGLE_BUTT
|
||||
} LV_GPU_TRIANLE_Type;
|
||||
|
||||
typedef struct {
|
||||
lv_color_t color; /* full color, A:bit[31:24], R:bit[23:16], G:bit[15:8], B:bit[7:0] */
|
||||
LV_GPU_Format fmt; /* buf fmt */
|
||||
lv_color_t *buf; /* buf addr */
|
||||
lv_coord_t stride; /* buf stride */
|
||||
lv_area_t area; /* full rect */
|
||||
} LV_GPU_FillRectInfo;
|
||||
|
||||
typedef struct {
|
||||
LV_GPU_TRIANLE_Type type; /* The area type of a triangle */
|
||||
LV_GPU_Format fmt; /* The format type of a triangle */
|
||||
lv_color_t color; /* The color of a triangle, A:bit[31:24], R:bit[23:16], G:bit[15:8], B:bit[7:0]*/
|
||||
lv_area_t area; /* The color of a triangle */
|
||||
lv_color_t *buf; /* The buf of a triangle */
|
||||
lv_coord_t stride; /* The stride of buf */
|
||||
} LV_GPU_FillRatriaInfo;
|
||||
|
||||
typedef enum {
|
||||
LV_GPU_RLE_IN_BG_SURFACE = 0, /* run-length encoding in the background surface */
|
||||
LV_GPU_RLE_IN_FG_SURFACE, /* run-length encoding in the foreground surface */
|
||||
LV_GPU_RLE_BUTT
|
||||
} LV_GPU_RleSurfaceType;
|
||||
|
||||
typedef struct {
|
||||
LV_GPU_RleSurfaceType rleType;
|
||||
} LV_GPU_RleInfo;
|
||||
|
||||
typedef struct {
|
||||
lv_color_t *buf; // surface buf addr
|
||||
lv_opa_t alpha; // surface alpha
|
||||
lv_coord_t stride; // surface buf stride
|
||||
LV_GPU_Format fmt; // surface format type
|
||||
lv_area_t srcArea; // surface source rect
|
||||
lv_area_t dstArea; // surface destination rect
|
||||
lv_draw_mask_res_t maskRes; // surface blend mode
|
||||
} LV_GPU_SurfaceInfo;
|
||||
|
||||
typedef struct {
|
||||
lv_color_t *buf; // output buf addr
|
||||
lv_coord_t stride; // output rect buf stride
|
||||
LV_GPU_Format fmt; // output rect buf format
|
||||
lv_area_t area; // Output to the area of the output rectangle
|
||||
} LV_GPU_OutputInfo;
|
||||
|
||||
typedef struct {
|
||||
LV_GPU_SurfaceInfo fgSurface; // need to synthetic the upper surface
|
||||
LV_GPU_SurfaceInfo bgSurface; // need to synthesize the lower surface
|
||||
LV_GPU_OutputInfo output; // outout rect info
|
||||
} LV_GPU_BlendImgInfo;
|
||||
|
||||
typedef struct {
|
||||
lv_opa_t *buf; // mask area buf
|
||||
lv_color32_t color; // mask area color, ARGB888, A:bit[31:24], R:bit[23:16], G:bit[15:8], B:bit[7:0]
|
||||
lv_coord_t stride; // mask area buf stride
|
||||
} LV_GPU_MaskInfo;
|
||||
|
||||
typedef struct {
|
||||
LV_GPU_SurfaceInfo surfaceInfo; // need to synthetic the surface
|
||||
LV_GPU_OutputInfo output; // outout area info
|
||||
LV_GPU_MaskInfo maskInfo; // need to synthetic the mask area info
|
||||
} LV_GPU_BlendMaskInfo;
|
||||
|
||||
typedef struct {
|
||||
LV_GPU_OutputInfo output; // outout area info
|
||||
LV_GPU_MaskInfo maskInfo; // need to synthetic the mask area info
|
||||
} LV_GPU_FillMaskInfo;
|
||||
|
||||
typedef struct {
|
||||
lv_color_t *buf; // copy area buf addr
|
||||
LV_GPU_Format fmt; // copy area format
|
||||
lv_area_t area; // copy region location
|
||||
lv_coord_t stride; // copy area buf stride
|
||||
} LV_GPU_FastCopyInfo;
|
||||
|
||||
typedef struct {
|
||||
lv_area_t srcArea; /* the rect for rotate */
|
||||
lv_color_t *srcBuf; /* the rect buf for rotation */
|
||||
LV_GPU_Format srcFmt; /* the rect format for rotation */
|
||||
lv_coord_t srcStride; /* the rect buf stride */
|
||||
|
||||
lv_color_t *dstBuf; /* output rect buf */
|
||||
LV_GPU_Format dstFmt; /* output rect format*/
|
||||
lv_coord_t dstWidth; /* output rect widtht*/
|
||||
lv_coord_t dstHeight; /* output rect height*/
|
||||
lv_coord_t dstStride; /* output rect buf strde*/
|
||||
|
||||
double angle; /* rotate angle */
|
||||
/* ARGB888, A:bit[31:24], R:bit[23:16], G:bit[15:8], B:bit[7:0]
|
||||
Pixels outside the rotated region fill the background color */
|
||||
lv_color32_t bgColor;
|
||||
} LV_GPU_RotateInfo;
|
||||
|
||||
typedef struct {
|
||||
lv_color_t *buf; /* cache buf addr */
|
||||
lv_area_t area; /* clean cache rect */
|
||||
LV_GPU_Format fmt; /* cache format */
|
||||
lv_coord_t stride; /* cache buf format */
|
||||
} LV_GPU_CacheInfo;
|
||||
|
||||
typedef struct {
|
||||
unsigned int id;
|
||||
int dirty;
|
||||
int en;
|
||||
LV_GPU_Format fmt;
|
||||
lv_area_t src;
|
||||
lv_color_t *addr[LV_GPU_YUVA_ADDR_CNT];//YUVA
|
||||
lv_coord_t srcStride[LV_GPU_YUVA_ADDR_CNT];
|
||||
lv_area_t dst;
|
||||
int enCkey;
|
||||
int ckey;
|
||||
int enAlpha;
|
||||
char alpha;
|
||||
int zOrder;
|
||||
int security;
|
||||
} LV_GPU_WindowInfo;
|
||||
typedef struct {
|
||||
unsigned int winCnt;
|
||||
LV_GPU_WindowInfo winInfo[LV_GPU_WIN_MAX_CNT];
|
||||
} LV_GPU_DisplayInfo;
|
||||
|
||||
typedef enum {
|
||||
LV_SCREEN_TYPE_CLUSTER = 0,
|
||||
LV_SCREEN_TYPE_BUTT
|
||||
} LV_GPU_ScreenType;
|
||||
/*************************
|
||||
* DEFINES FUNCTION
|
||||
*************************/
|
||||
#define LV_CHECK_NULLPTR_RETURN(ptr_, errno_) \
|
||||
do { \
|
||||
if ((ptr_) == NULL) { \
|
||||
LV_LOG_ERROR("error [dma2d][%s][%d]: %s is null!\r\n", __FUNCTION__, __LINE__, #ptr_); \
|
||||
return errno_; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
#define LV_CHECK_AREA_RETURN(area_, errno_) \
|
||||
do { \
|
||||
if ((area_.x1 > area_.x2) && (area_.y1 > area_.y2)) { \
|
||||
LV_LOG_ERROR("error [dma2d][%s][%d]: %s x1[%d] Must be smaller than x2[%d] and area y1[%d] Must be smaller than y2[%d]!\r\n", \
|
||||
__FUNCTION__, __LINE__, #area_, area_.x1, area_.x2, area_.y1, area_.y2); \
|
||||
return errno_; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
#define LV_CHECK_RETURN(ret_, str_) \
|
||||
do { \
|
||||
if ((ret_) != HAL_SUCCESS) { \
|
||||
LV_LOG_ERROR("error [dma2d][%s][%d]: %s fail,ret:%#x!!\r\n", __FUNCTION__, __LINE__, str_, ret_); \
|
||||
return ret_; \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_GPU_SEMIDRIVE_DMA2D_DEFINE_H*/
|
||||
Reference in New Issue
Block a user