|
|
/*
|
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2019. All rights reserved.
|
|
|
* Description: hungary iapi interface
|
|
|
* Author: sdk
|
|
|
* Create: 2019-01-10
|
|
|
*/
|
|
|
#include "uapi_gfx2d.h"
|
|
|
#include <string.h>
|
|
|
#include <stdint.h>
|
|
|
#include "soc_errno.h"
|
|
|
#include "mpi_gfx2d.h"
|
|
|
#include "securec.h"
|
|
|
/*
|
|
|
* brief Open gfx2d device. CNcomment: 打开gfx2d设备 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[in] dev_id (input). CNcomment: 枚举类型,设备类型 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_gfx2d_open(uapi_gfx2d_dev_id dev_id)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
|
|
|
if (dev_id >= UAPI_GFX2D_DEV_ID_MAX) {
|
|
|
return SOC_ERR_GFX2D_INVALID_DEVID;
|
|
|
}
|
|
|
|
|
|
ret = mpi_tde_open();
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
return ret;
|
|
|
}
|
|
|
ret = mpi_hwc_open(dev_id);
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
mpi_tde_close();
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* brief Close gfx2d device. CNcomment: 关闭gfx2d设备 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[in] dev_id (input). CNcomment: 枚举类型,设备类型 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: API系统调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_gfx2d_close(uapi_gfx2d_dev_id dev_id)
|
|
|
{
|
|
|
if (dev_id >= UAPI_GFX2D_DEV_ID_MAX) {
|
|
|
return SOC_ERR_GFX2D_INVALID_DEVID;
|
|
|
}
|
|
|
|
|
|
mpi_tde_close();
|
|
|
return mpi_hwc_close(dev_id);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* brief Create gfx2d task. CNcomment: 创建gfx2d任务 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[in] dev_id (input). CNcomment: 枚举类型,设备类型 CNend
|
|
|
* retval ::td_handle CNcomment: gfx2d任务句柄值 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_handle uapi_gfx2d_create(uapi_gfx2d_dev_id dev_id)
|
|
|
{
|
|
|
if (dev_id >= UAPI_GFX2D_DEV_ID_MAX) {
|
|
|
return TD_INVALID_HANDLE;
|
|
|
}
|
|
|
return mpi_tde_begin_job();
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* brief Add gfx2d blit operation. CNcomment: gfx2d搬移操作 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[in] handle (input). CNcomment: td_handle类型,任务句柄 CNend
|
|
|
* param[in] surface_list (input). CNcomment: 指针类型,输入surface信息 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: gfx2d搬移操作调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_gfx2d_bitblit(td_handle handle, uapi_gfx2d_list *surface_list)
|
|
|
{
|
|
|
td_s32 ret;
|
|
|
if (surface_list == TD_NULL) {
|
|
|
return SOC_ERR_GFX2D_NULL_PTR;
|
|
|
}
|
|
|
if (surface_list->dst_surface == TD_NULL) {
|
|
|
return SOC_ERR_GFX2D_NULL_PTR;
|
|
|
}
|
|
|
ret = mpi_tde_check_open();
|
|
|
if (ret != TD_SUCCESS) {
|
|
|
return ret;
|
|
|
}
|
|
|
switch (surface_list->ops_mode) {
|
|
|
case UAPI_GFX2D_OPS_NONE: /* default bit blit */
|
|
|
case UAPI_GFX2D_OPS_BIT_BLIT:
|
|
|
return mpi_tde_bit_blit(handle, surface_list);
|
|
|
case UAPI_GFX2D_OPS_QUICK_COPY:
|
|
|
return mpi_tde_quick_copy(handle, surface_list);
|
|
|
case UAPI_GFX2D_OPS_QUICK_FILL:
|
|
|
return mpi_tde_quick_fill(handle, surface_list);
|
|
|
case UAPI_GFX2D_OPS_QUICK_RESIZE:
|
|
|
return mpi_tde_quick_resize(handle, surface_list);
|
|
|
case UAPI_GFX2D_OPS_QUICK_DEFLICKER:
|
|
|
return mpi_tde_quick_deflicker(handle, surface_list);
|
|
|
case UAPI_GFX2D_OPS_SOLID_DRAW:
|
|
|
return mpi_tde_solid_draw(handle, surface_list);
|
|
|
case UAPI_GFX2D_OPS_ROTATE:
|
|
|
return SOC_ERR_GFX2D_UNSUPPORTED_OPERATION;
|
|
|
case UAPI_GFX2D_OPS_PATTERN_FILL:
|
|
|
return mpi_tde_pattern_fill(handle, surface_list);
|
|
|
default:
|
|
|
return SOC_ERR_GFX2D_INVALID_OPS;
|
|
|
}
|
|
|
return SOC_ERR_GFX2D_UNSUPPORTED_OPERATION;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* brief Add gfx2d composition operation. CNcomment: gfx2d叠加操作 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[in] handle (input). CNcomment: td_handle类型,任务句柄 CNend
|
|
|
* param[in] surface_list (input). CNcomment: 指针类型,输入surface信息 CNend
|
|
|
* param[in] is_sync (input). CNcomment: bool类型,是否同步提交 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: gfx2d叠加操作调用失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_gfx2d_compose(td_handle handle, uapi_gfx2d_list *surface_list, td_bool is_sync)
|
|
|
{
|
|
|
td_s32 ret, err;
|
|
|
size_t dst_size;
|
|
|
gfx2d_cmd_compose compose_cmd = {0};
|
|
|
drv_gfx2d_compose_msg *compose = TD_NULL;
|
|
|
|
|
|
TD_UNUSED(handle);
|
|
|
|
|
|
if ((surface_list == NULL) || (surface_list->dst_surface == NULL) || (surface_list->src_surfaces == NULL)) {
|
|
|
return SOC_ERR_GFX2D_NULL_PTR;
|
|
|
}
|
|
|
|
|
|
if (surface_list->src_surface_cnt > 10 || surface_list->src_surface_cnt < 1) { /* 10 :max layers */
|
|
|
return SOC_ERR_GFX2D_INVALID_COMPOSECNT;
|
|
|
}
|
|
|
|
|
|
compose_cmd.dev_id = 0;
|
|
|
compose_cmd.work_sync = is_sync;
|
|
|
compose_cmd.is_compose_support = GFX2D_SUPPORT_MARK;
|
|
|
|
|
|
if (compose_cmd.work_sync == TD_TRUE) {
|
|
|
compose_cmd.time_out = 1000; /* timeout 1000ms */
|
|
|
}
|
|
|
|
|
|
compose = (drv_gfx2d_compose_msg *)malloc(surface_list->src_surface_cnt * sizeof(drv_gfx2d_compose_msg));
|
|
|
if (compose == TD_NULL) {
|
|
|
return SOC_ERR_GFX2D_NO_MEM;
|
|
|
}
|
|
|
dst_size = surface_list->src_surface_cnt * sizeof(drv_gfx2d_compose_msg);
|
|
|
err = memset_s(compose, dst_size, 0, surface_list->src_surface_cnt * sizeof(drv_gfx2d_compose_msg));
|
|
|
if (err != EOK) {
|
|
|
free(compose);
|
|
|
return err;
|
|
|
}
|
|
|
hwc_convert_surface_iapi_to_drv(surface_list->dst_surface, &compose_cmd.dest_surface);
|
|
|
hwc_convert_compose_iapi_to_drv(surface_list->src_surfaces, compose, surface_list->src_surface_cnt);
|
|
|
|
|
|
compose_cmd.compose_list.back_color = surface_list->dst_surface->background_color;
|
|
|
compose_cmd.compose_list.compose_cnt = surface_list->src_surface_cnt;
|
|
|
compose_cmd.compose_list.compose = (td_u64)(uintptr_t)compose;
|
|
|
|
|
|
ret = mpi_hwc_compose(surface_list, &compose_cmd, compose);
|
|
|
|
|
|
free(compose);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* brief Submit gfx2d task. CNcomment: 提交gfx2d任务 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[in] handle (input). CNcomment: td_handle类型,任务句柄 CNend
|
|
|
* param[in] is_sync (input). CNcomment: bool类型,是否同步提交 CNend
|
|
|
* param[in] time_out (input). CNcomment: 整型类型,超时时间 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: 提交gfx2d任务失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_gfx2d_submit(td_handle handle, td_bool is_sync, td_u32 time_out)
|
|
|
{
|
|
|
return mpi_tde_end_job(handle, is_sync, is_sync, time_out);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* brief Cancel gfx2d task. CNcomment: 取消gfx2d任务 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[in] handle (input). CNcomment: td_handle类型,任务句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: 取消gfx2d任务失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_gfx2d_cancel(td_handle handle)
|
|
|
{
|
|
|
return mpi_tde_cancel_job(handle);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* brief Obtains the gfx2d task status. CNcomment: 获取gfx2d任务状态 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[in] handle (input). CNcomment: td_handle类型,任务句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功,gfx2d任务已完成 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: gfx2d任务未完成 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_gfx2d_get_status(td_handle handle)
|
|
|
{
|
|
|
return mpi_tde_wait_for_done(handle);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* brief Obtains the gfx2d hardware status. CNcomment: 获取gfx2d硬件状态 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[in] dev_id (input). CNcomment: 枚举类型,设备类型 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功,gfx2d所有任务都已完成 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: gfx2d所有任务未完成 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_gfx2d_get_hw_status(uapi_gfx2d_dev_id dev_id)
|
|
|
{
|
|
|
if (dev_id >= UAPI_GFX2D_DEV_ID_MAX) {
|
|
|
return SOC_ERR_GFX2D_INVALID_DEVID;
|
|
|
}
|
|
|
|
|
|
return mpi_tde_wait_all_done();
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* brief Reset gfx2d device. CNcomment: 重置gfx2d设备 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[in] handle (input). CNcomment: td_handle类型,任务句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功,gfx2d重置成功 CNend
|
|
|
* retval ::TD_FAILURE Calling this API fails. CNcomment: gfx2d重置失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_gfx2d_destroy(td_handle handle)
|
|
|
{
|
|
|
if (handle == (td_handle)SOC_ERR_GFX2D_INVALID_HANDLE) {
|
|
|
return SOC_ERR_GFX2D_INVALID_PARA;
|
|
|
}
|
|
|
return mpi_tde_cancel_job(handle);
|
|
|
}
|
|
|
|
|
|
td_s32 uapi_gfx2d_get_capability(uapi_gfx2d_capability *capability)
|
|
|
{
|
|
|
return mpi_gfx2d_get_capability(capability);
|
|
|
}
|