diff --git a/base/buffer_handle.h b/base/buffer_handle.h new file mode 100644 index 0000000000000000000000000000000000000000..6b352819a5c25c2b5e01caa5e993a81d1730df71 --- /dev/null +++ b/base/buffer_handle.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INCLUDE_BUFFER_HANDLE_H +#define INCLUDE_BUFFER_HANDLE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + int32_t fd; /**< buffer fd, -1 if not supported */ + int32_t width; /**< the width of memory */ + int32_t stride; /**< the stride of memory */ + int32_t height; /**< the heigh of memory */ + int32_t size; /* < size of memory */ + int32_t format; /**< the format of memory */ + uint64_t usage; /**< the usage of memory */ + void *virAddr; /**< Virtual address of memory */ + uint64_t phyAddr; /**< Physical address */ + int32_t key; /**< Shared memory key */ + uint32_t reserveFds; /**< the number of reserved fd value */ + uint32_t reserveInts; /**< the number of reserved integer value */ + int32_t reserve[0]; /**< the data */ +} BufferHandle; + +#ifdef __cplusplus +} +#endif + +#endif // INCLUDE_BUFFER_HANDLE_H diff --git a/display/hal/BUILD.gn b/display/hal/BUILD.gn index a81643411a166aceb4872193da0462f8f2d4bd9f..5e6d932e004e6ad88e66d41956e12b04d47406eb 100644 --- a/display/hal/BUILD.gn +++ b/display/hal/BUILD.gn @@ -27,9 +27,9 @@ if (defined(ohos_lite)) { config("display_hdi_public_config") { visibility = [ ":*" ] include_dirs = [ + "//drivers/peripheral/base", "//drivers/peripheral/display/interfaces/include", "//third_party/bounds_checking_function/include", - "//foundation/graphic/standard/utils/include", ] } @@ -40,6 +40,7 @@ if (defined(ohos_lite)) { ":hdi_display_gralloc", ":hdi_display_layer", ] + public_configs = [ ":display_hdi_public_config" ] } group("hdi_display_device") { diff --git a/display/hal/default/BUILD.gn b/display/hal/default/BUILD.gn index 98590d3fbff1a46617d0bcd2616b072ea5c93dbd..4e26d9223f56de02322b88315ad4d6360fbb4d38 100644 --- a/display/hal/default/BUILD.gn +++ b/display/hal/default/BUILD.gn @@ -22,12 +22,11 @@ shared_library("display_layer") { include_dirs = [ "//drivers/peripheral/display/hal", "//drivers/peripheral/display/interfaces/include", - "//third_party/bounds_checking_function/include", - "//drivers/framework/ability/sbuf/include", + "//drivers/adapter/uhdf/posix/include", "//drivers/framework/include/utils", + "//drivers/framework/ability/sbuf/include", "//drivers/framework/utils/include", "//drivers/framework/include/core", - "//drivers/framework/include/osal", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits", ] deps = [ @@ -53,10 +52,13 @@ shared_library("display_gralloc") { sources = [ "display_gralloc.c" ] include_dirs = [ "//drivers/peripheral/display/hal", + "//drivers/drivers/peripheral/display/hal", "//drivers/peripheral/display/interfaces/include", - "//third_party/bounds_checking_function/include", + "//drivers/framework/include/utils", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits", + "//drivers/adapter/uhdf/posix/include", ] + deps = [ "//drivers/adapter/uhdf/posix:hdf_posix_osal", "//third_party/bounds_checking_function:libsec_shared", @@ -79,9 +81,11 @@ shared_library("display_gfx") { include_dirs = [ "//drivers/peripheral/display/hal", "//drivers/peripheral/display/interfaces/include", - "//third_party/bounds_checking_function/include", + "//drivers/framework/include/utils", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits", + "//drivers/adapter/uhdf/posix/include", ] + deps = [ "//drivers/adapter/uhdf/posix:hdf_posix_osal", "//third_party/bounds_checking_function:libsec_shared", diff --git a/display/hal/default/display_gralloc.c b/display/hal/default/display_gralloc.c index 86397bdc15ad04a10537855a8902098d119b5c56..5ba419cbe95eb09674da6f2d94d48bee92c9fd8c 100644 --- a/display/hal/default/display_gralloc.c +++ b/display/hal/default/display_gralloc.c @@ -15,35 +15,128 @@ #include "display_gralloc.h" #include +#include #include #include #include #include -#include "hdf_log.h" +#include "buffer_handle.h" #include "display_type.h" +#include "disp_common.h" +#include "hdf_log.h" #define DEFAULT_READ_WRITE_PERMISSIONS 0666 -#define MAX_MALLOC_SIZE 0x10000000UL +#define MAX_MALLOC_SIZE 0x10000000L #define SHM_MAX_KEY 10000 #define SHM_START_KEY 1 +#define INVALID_SHMID -1 +#define BITS_PER_BYTE 8 -static int32_t AllocMem(GrallocBuffer *buffer) -{ - static int32_t key = SHM_START_KEY; +#define DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d)) +#define ALIGN_UP(x, a) ((((x) + ((a)-1)) / (a)) * (a)) +#define HEIGHT_ALIGN 2U +#define WIDTH_ALIGN 8U +#define MAX_PLANES 3 + +typedef struct { + BufferHandle hdl; int32_t shmid; +} PriBufferHandle; - if (buffer == NULL) { - HDF_LOGE("%s: buffer is null", __func__); - return DISPLAY_NULL_PTR; +typedef struct { + uint32_t numPlanes; + uint32_t radio[MAX_PLANES]; +} PlaneLayoutInfo; + +typedef struct { + uint32_t format; + uint32_t bitsPerPixel; // bits per pixel for first plane + const PlaneLayoutInfo *planes; +} FormatInfo; + +static const PlaneLayoutInfo g_yuv420SPLayout = { + .numPlanes = 2, + .radio = { 4, 2 }, +}; + +static const PlaneLayoutInfo g_yuv420PLayout = { + .numPlanes = 3, + .radio = { 4, 1, 1 }, +}; + +static const FormatInfo *GetFormatInfo(uint32_t format) +{ + static const FormatInfo fmtInfos[] = { + {PIXEL_FMT_RGBX_8888, 32, NULL}, {PIXEL_FMT_RGBA_8888, 32, NULL}, + {PIXEL_FMT_BGRX_8888, 32, NULL}, {PIXEL_FMT_BGRA_8888, 32, NULL}, + {PIXEL_FMT_RGB_888, 24, NULL}, {PIXEL_FMT_BGR_565, 16, NULL}, + {PIXEL_FMT_RGBA_5551, 16, NULL}, {PIXEL_FMT_RGB_565, 16, NULL}, + {PIXEL_FMT_BGRX_4444, 16, NULL}, {PIXEL_FMT_BGRA_4444, 16, NULL}, + {PIXEL_FMT_RGBA_4444, 16, NULL}, {PIXEL_FMT_RGBX_4444, 16, NULL}, + {PIXEL_FMT_BGRX_5551, 16, NULL}, {PIXEL_FMT_BGRA_5551, 16, NULL}, + {PIXEL_FMT_YCBCR_420_SP, 8, &g_yuv420SPLayout}, {PIXEL_FMT_YCRCB_420_SP, 8, &g_yuv420SPLayout}, + {PIXEL_FMT_YCBCR_420_P, 8, &g_yuv420PLayout}, {PIXEL_FMT_YCRCB_420_P, 8, &g_yuv420PLayout}, + }; + + for (uint32_t i = 0; i < sizeof(fmtInfos) / sizeof(FormatInfo); i++) { + if (fmtInfos[i].format == format) { + return &fmtInfos[i]; + } } - HDF_LOGD("%s: buffer->type = %d, buffer->size = %u", __func__, buffer->type, buffer->size); - if ((buffer->size > MAX_MALLOC_SIZE) || (buffer->size == 0)) { - HDF_LOGE("%s: size is invalid, size = %u", __func__, buffer->size); + HDF_LOGE("the format can not support %d %d", format, PIXEL_FMT_RGBA_8888); + return NULL; +} + +static uint32_t AdjustStrideFromFormat(uint32_t format, uint32_t width) +{ + const FormatInfo *fmtInfo = GetFormatInfo(format); + if ((fmtInfo != NULL) && (fmtInfo->planes != NULL)) { + uint32_t sum = fmtInfo->planes->radio[0]; + for (uint32_t i = 1; (i < fmtInfo->planes->numPlanes) && (i < MAX_PLANES); i++) { + sum += fmtInfo->planes->radio[i]; + } + if (sum > 0) { + width = DIV_ROUND_UP((width * sum), fmtInfo->planes->radio[0]); + } + } + return width; +} + +static int32_t InitBufferHandle(PriBufferHandle* buffer, const AllocInfo* info) +{ + int32_t size; + int32_t stride; + int32_t h = ALIGN_UP(info->height, HEIGHT_ALIGN); + const FormatInfo *fmtInfo = GetFormatInfo(info->format); + if (fmtInfo == NULL) { + HDF_LOGE("can not get format information : %d", buffer->hdl.format); return DISPLAY_FAILURE; } + + stride = ALIGN_UP(AdjustStrideFromFormat(info->format, info->width), WIDTH_ALIGN) * + fmtInfo->bitsPerPixel / BITS_PER_BYTE; + size = h * stride; + buffer->hdl.width = info->width; + buffer->hdl.stride = stride; + buffer->hdl.height = info->height; + buffer->hdl.size = size; + buffer->hdl.usage = info->usage; + buffer->hdl.fd = -1; + buffer->shmid = INVALID_SHMID; + buffer->hdl.format = info->format; + buffer->hdl.reserveInts = (sizeof(PriBufferHandle) - sizeof(BufferHandle) - + buffer->hdl.reserveFds * sizeof(uint32_t)) / sizeof(uint32_t); + return DISPLAY_SUCCESS; +} + +static int32_t AllocShm(BufferHandle *buffer) +{ + static int32_t key = SHM_START_KEY; + int32_t shmid; + while ((shmid = shmget(key, buffer->size, IPC_CREAT | IPC_EXCL | DEFAULT_READ_WRITE_PERMISSIONS)) < 0) { if (errno != EEXIST) { - HDF_LOGE("%s: fail to alloc shared memory, errno = %d", __func__, errno); + HDF_LOGE("%s: fail to alloc the shared memory, errno = %d", __func__, errno); return DISPLAY_FAILURE; } key++; @@ -53,70 +146,121 @@ static int32_t AllocMem(GrallocBuffer *buffer) } void *pBase = shmat(shmid, NULL, 0); if (pBase == ((void *)-1)) { - HDF_LOGE("%s: fail to shmat shared memory, errno = %d", __func__, errno); + HDF_LOGE("%s: Fail to attach the shared memory, errno = %d", __func__, errno); + if (shmctl(shmid, IPC_RMID, 0) == -1) { + HDF_LOGE("%s: Fail to free shmid, errno = %d", __func__, errno); + } return DISPLAY_FAILURE; } buffer->virAddr = pBase; - buffer->hdl.key = key; - buffer->hdl.shmid = shmid; - HDF_LOGD("%s: key = %d, shmid = %d", __func__, key, shmid); + buffer->key = key; + ((PriBufferHandle*)buffer)->shmid = shmid; key++; if (key >= SHM_MAX_KEY) { key = SHM_START_KEY; } - (void)memset_s(buffer->virAddr, buffer->size, 0xff, buffer->size); return DISPLAY_SUCCESS; } -static void FreeMem(GrallocBuffer *buffer) +static int32_t AllocMem(const AllocInfo* info, BufferHandle **buffer) { - if (buffer == NULL || buffer->virAddr == NULL) { - HDF_LOGE("%s: pointer is null", __func__); - return; + int32_t ret; + DISPLAY_CHK_RETURN((buffer == NULL), DISPLAY_NULL_PTR, HDF_LOGE("%s: in buffer is null", __func__)); + DISPLAY_CHK_RETURN((info == NULL), DISPLAY_NULL_PTR, HDF_LOGE("%s: in info is null", __func__)); + PriBufferHandle* priBuffer = calloc(1, sizeof(PriBufferHandle)); + DISPLAY_CHK_RETURN((priBuffer == NULL), DISPLAY_NULL_PTR, HDF_LOGE("%s: can not calloc errno : %d", + __func__, errno)); + ret = InitBufferHandle(priBuffer, info); + DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, HDF_LOGE("%s: can not init buffe handle", + __func__); goto OUT); + + BufferHandle *bufferHdl = &priBuffer->hdl; + DISPLAY_CHK_RETURN(((bufferHdl->size > MAX_MALLOC_SIZE) || (bufferHdl->size == 0)), + DISPLAY_FAILURE, HDF_LOGE("%s: size is invalid %d ", __func__, bufferHdl->size); goto out); + + if (bufferHdl->usage == HBM_USE_MEM_SHARE) { + ret = AllocShm(bufferHdl); + } else { + HDF_LOGE("%s: not support memory usage: 0x%" PRIx64 "", __func__, bufferHdl->usage); + ret = DISPLAY_NOT_SUPPORT; } + +OUT: + if ((ret != DISPLAY_SUCCESS) && (bufferHdl != NULL)) { + free(bufferHdl); + bufferHdl = NULL; + } + *buffer = bufferHdl; + return ret; +} + +static void FreeShm(BufferHandle *buffer) +{ + CHECK_NULLPOINTER_RETURN(buffer->virAddr); if (shmdt(buffer->virAddr) == -1) { - HDF_LOGE("%s: fail to free shared memory, errno = %d", __func__, errno); + HDF_LOGE("%s: Fail to free shared memory, errno = %d", __func__, errno); } - if (shmctl(buffer->hdl.shmid, IPC_RMID, 0) == -1) { - HDF_LOGE("%s: fail to free shmid, errno = %d", __func__, errno); + if (shmctl(((PriBufferHandle*)buffer)->shmid, IPC_RMID, 0) == -1) { + HDF_LOGE("%s: Fail to free shmid, errno = %d", __func__, errno); } } -static void *Mmap(GrallocBuffer *buffer) +static void FreeMem(BufferHandle *buffer) { - int32_t shmid; + CHECK_NULLPOINTER_RETURN(buffer); + if ((buffer->size > MAX_MALLOC_SIZE) || (buffer->size == 0)) { + HDF_LOGE("%s: size is invalid, buffer->size = %d", __func__, buffer->size); + return; + } - if (buffer == NULL) { - HDF_LOGE("%s: buffer is null", __func__); + if (buffer->usage == HBM_USE_MEM_SHARE) { + FreeShm(buffer); + return; + } else { + HDF_LOGE("%s: not support memory usage: 0x%" PRIx64 "", __func__, buffer->usage); + } +} + +static void *Mmap(BufferHandle *buffer) +{ + CHECK_NULLPOINTER_RETURN_VALUE(buffer, NULL); + if ((buffer->size > MAX_MALLOC_SIZE) || (buffer->size == 0)) { + HDF_LOGE("%s: size is invalid, buffer->size = %d", __func__, buffer->size); return NULL; } - HDF_LOGD("%s: buffer->hdl.key = %d, buffer->hdl.shmid = %d", __func__, buffer->hdl.key, buffer->hdl.shmid); - shmid = shmget(buffer->hdl.key, buffer->size, IPC_EXCL | DEFAULT_READ_WRITE_PERMISSIONS); + int32_t shmid = shmget(buffer->key, buffer->size, IPC_EXCL | DEFAULT_READ_WRITE_PERMISSIONS); if (shmid < 0) { - HDF_LOGE("%s: fail to mmap shared memory, errno = %d", __func__, errno); + HDF_LOGE("%s: Fail to mmap the shared memory, errno = %d", __func__, errno); return NULL; } void *pBase = shmat(shmid, NULL, 0); if (pBase == ((void *)-1)) { - HDF_LOGE("%s: fail to shmat share memory, errno = %d", __func__, errno); + HDF_LOGE("%s: Fail to attach the shared memory, errno = %d", __func__, errno); return NULL; } - buffer->hdl.shmid = shmid; - HDF_LOGD("%s: shmid = %d", __func__, shmid); + ((PriBufferHandle*)buffer)->shmid = shmid; + HDF_LOGI("%s: Mmap shared memory succeed", __func__); return pBase; } -static int32_t Unmap(GrallocBuffer *buffer) +static int32_t Unmap(BufferHandle *buffer) { - if (buffer == NULL || buffer->virAddr == NULL) { - HDF_LOGE("%s: pointer is null", __func__); - return DISPLAY_NULL_PTR; + CHECK_NULLPOINTER_RETURN_VALUE(buffer, DISPLAY_NULL_PTR); + CHECK_NULLPOINTER_RETURN_VALUE(buffer->virAddr, DISPLAY_NULL_PTR); + if ((buffer->size > MAX_MALLOC_SIZE) || (buffer->size == 0)) { + HDF_LOGE("%s: size is invalid, buffer->size = %d", __func__, buffer->size); + return DISPLAY_FAILURE; } + if (shmdt(buffer->virAddr) == -1) { - HDF_LOGE("%s: fail to unmap shared memory, errno = %d", __func__, errno); + HDF_LOGE("%s: Fail to unmap shared memory errno = %d", __func__, errno); return DISPLAY_FAILURE; } + int32_t shmid = ((PriBufferHandle*)buffer)->shmid; + if ((shmid != INVALID_SHMID) && (shmctl(shmid, IPC_RMID, 0) == -1)) { + HDF_LOGE("%s: Fail to free shmid, errno = %d", __func__, errno); + } return DISPLAY_SUCCESS; } @@ -150,4 +294,4 @@ int32_t GrallocUninitialize(GrallocFuncs *funcs) free(funcs); HDF_LOGI("%s: gralloc uninitialize success", __func__); return DISPLAY_SUCCESS; -} \ No newline at end of file +} diff --git a/display/hal/default/display_layer.c b/display/hal/default/display_layer.c index 8292326866f72e803edf4921a7b8d0b12d9e00e2..ee7a825e9710b5c1d78f58fc59e8dd48c1c1f40e 100644 --- a/display/hal/default/display_layer.c +++ b/display/hal/default/display_layer.c @@ -83,7 +83,7 @@ static void SetBackground(void) } } -static int32_t OpenLayer(uint32_t devId, const LayerInfo *layerInfo, uint32_t *layerId) +static int32_t CreateLayer(uint32_t devId, const LayerInfo *layerInfo, uint32_t *layerId) { if (layerInfo == NULL || layerId == NULL) { HDF_LOGE("%s: pointer is null", __func__); @@ -238,7 +238,7 @@ int32_t LayerInitialize(LayerFuncs **funcs) lFuncs->InitDisplay = InitDisplay; lFuncs->DeinitDisplay = DeinitDisplay; lFuncs->GetDisplayInfo = GetDisplayInfo; - lFuncs->OpenLayer = OpenLayer; + lFuncs->CreateLayer = CreateLayer; lFuncs->CloseLayer = CloseLayer; lFuncs->Flush = Flush; lFuncs->GetLayerBuffer = GetLayerBuffer; diff --git a/display/hal/disp_common.h b/display/hal/disp_common.h index 9687d847be96f57904b920103b4efa49f9785cd2..e2d1d1949532b51a343908f16cea712898af81f2 100644 --- a/display/hal/disp_common.h +++ b/display/hal/disp_common.h @@ -15,6 +15,7 @@ #ifndef DISP_COMMON_H #define DISP_COMMON_H +#include #include "hdf_log.h" #ifdef HDF_LOG_TAG @@ -36,6 +37,22 @@ } \ } while (0) +#define DISPLAY_CHK_RETURN(val, ret, ...) \ + do { \ + if (val) { \ + __VA_ARGS__; \ + return (ret); \ + } \ + } while (0) + +#define DISPLAY_CHK_RETURN_NOT_VALUE(val, ...) \ + do { \ + if (val) { \ + __VA_ARGS__; \ + return; \ + } \ + } while (0) + enum LayerId { GRA_LAYER_0, GRA_LAYER_1, diff --git a/display/hal/disp_hal.c b/display/hal/disp_hal.c index 7fed9a096a71f65cbbfbc558450d5e65480ebee0..ed181c04795d754f01c776eeab74da1ca7736c9f 100644 --- a/display/hal/disp_hal.c +++ b/display/hal/disp_hal.c @@ -167,12 +167,12 @@ EXIT: return DISPLAY_FAILURE; } -static int32_t SetPowerStatus(uint32_t devId, PowerStatus pStatus) +static int32_t SetPowerStatus(uint32_t devId, DispPowerStatus status) { - return DispEventProcess(devId, DISP_CMD_SET_POWERSTATUS, pStatus); + return DispEventProcess(devId, DISP_CMD_SET_POWERSTATUS, status); } -static int32_t GetPowerStatus(uint32_t devId, PowerStatus *pStatus) +static int32_t GetPowerStatus(uint32_t devId, DispPowerStatus *pStatus) { return DispGetParaProcess(devId, DISP_CMD_GET_POWERSTATUS, pStatus); } @@ -206,24 +206,3 @@ HalFuncs *GetHalFuncs(void) } return hFuncs; } - -int32_t DispInit(uint32_t devId) -{ - HDF_LOGI("%s: driver has inited", __func__); - return DISPLAY_SUCCESS; -} - -int32_t DispOn(uint32_t devId) -{ - return SetPowerStatus(devId, POWER_STATUS_ON); -} - -int32_t DispOff(uint32_t devId) -{ - return SetPowerStatus(devId, POWER_STATUS_OFF); -} - -int32_t DispGetInfo(uint32_t devId, struct DispInfo *info) -{ - return GetInfo(devId, info); -} diff --git a/display/hal/disp_hal.h b/display/hal/disp_hal.h index 3d90d4f8188578212f20a6583ee198d384e7fa2c..adfe12eab639abff8c040e1f8cbc288eb2b75585 100644 --- a/display/hal/disp_hal.h +++ b/display/hal/disp_hal.h @@ -16,6 +16,7 @@ #ifndef DISP_HAL_H #define DISP_HAL_H #include "disp_common.h" +#include "display_type.h" #define DISP_SERVICE_NAME "hdf_disp" @@ -27,14 +28,6 @@ enum DispCmd { DISP_CMD_GET_BACKLIGHT, }; -typedef enum { - POWER_STATUS_ON, - POWER_STATUS_STANDBY, - POWER_STATUS_SUSPEND, - POWER_STATUS_OFF, - POWER_STATUS_BUTT -} PowerStatus; - struct DispPara { uint32_t devId; void *par; @@ -42,19 +35,12 @@ struct DispPara { }; typedef struct { - int32_t (*SetPowerStatus)(uint32_t devId, PowerStatus pStatus); - int32_t (*GetPowerStatus)(uint32_t devId, PowerStatus *pStatus); + int32_t (*SetPowerStatus)(uint32_t devId, DispPowerStatus pStatus); + int32_t (*GetPowerStatus)(uint32_t devId, DispPowerStatus *pStatus); int32_t (*SetBacklight)(uint32_t devId, uint32_t level); int32_t (*GetBacklight)(uint32_t devId, uint32_t *level); int32_t (*GetInfo)(uint32_t devId, struct DispInfo *info); } HalFuncs; HalFuncs *GetHalFuncs(void); - -int32_t DispInit(uint32_t devId); -int32_t DispOn(uint32_t devId); -int32_t DispOff(uint32_t devId); -int32_t SetBacklight(uint32_t devId, uint32_t level); -int32_t DispGetInfo(uint32_t devId, struct DispInfo *info); - #endif /* DISP_HAL_H */ diff --git a/display/interfaces/include/display_device.h b/display/interfaces/include/display_device.h index 2a67ba8611e3291b161ade08bc6283808ef4921d..d0cfd7579fb082b52fc96451d6e8aa58c0692ff9 100644 --- a/display/interfaces/include/display_device.h +++ b/display/interfaces/include/display_device.h @@ -62,7 +62,7 @@ typedef struct { * @since 1.0 * @version 1.0 */ - int32_t (*SetDisplayPowerStatus)(uint32_t devId, PowerStatus status); + int32_t (*SetDisplayPowerStatus)(uint32_t devId, DispPowerStatus status); /** * @brief Obtains the power status. @@ -78,7 +78,7 @@ typedef struct { * @since 1.0 * @version 1.0 */ - int32_t (*GetDisplayPowerStatus)(uint32_t devId, PowerStatus *status); + int32_t (*GetDisplayPowerStatus)(uint32_t devId, DispPowerStatus *status); /** * @brief Sets the backlight level. diff --git a/display/interfaces/include/display_type.h b/display/interfaces/include/display_type.h index cdc3526a8bcbc8cba619c59b7bc83ff0259bce75..9f6ffce41f7a296a074de76132b96ba548a9983f 100644 --- a/display/interfaces/include/display_type.h +++ b/display/interfaces/include/display_type.h @@ -46,7 +46,7 @@ #include #include #include -#include +#include "buffer_handle.h" #ifdef __cplusplus extern "C" { @@ -89,6 +89,8 @@ enum { HBM_USE_CPU_WRITE = (1 << 1), /**< CPU will write the memory */ HBM_USE_MEM_MMZ = (1 << 2), /**< will use mmz to allocate memory */ HBM_USE_MEM_DMA = (1 << 3), /**< the allocator should support dma buffer */ + HBM_USE_MEM_SHARE = (1 << 4), /**< the allocator should support shared memory buffer*/ + HBM_USE_MEM_MMZ_CACHE = (1 << 5), /**< will use mmz to allocate memory with cache*/ }; /** @@ -145,19 +147,6 @@ typedef enum { ROTATE_BUTT /**< Invalid operation */ } TransformType; -/** - * @brief Enumerates memory types. - * - * Memory is allocated based on the type specified by the GUI. - * - */ -typedef enum { - NORMAL_MEM = 0, /**< Memory without cache */ - CACHE_MEM, /**< Memory with cache */ - SHM_MEM, /**< Shared memory */ - DMA_MEM /**< DMA Memory */ -} MemType; - /** * @brief Enumerates image blending types. * @@ -280,16 +269,6 @@ typedef struct { uint8_t gAlpha; /**< Global alpha value, ranging from 0 to 255 */ } LayerAlpha; -/** - * @brief Defines the memory buffer, such as virtual and physical memory addresses. - * - */ -typedef struct { - BufferHandle hdl; /**< Buffer handle */ - MemType type; /**< Type of the requested memory */ - uint32_t size; /**< Size of the requested memory */ - void *virAddr; /**< Virtual address of the requested memory */ -} GrallocBuffer; /** * @brief Defines buffer data of a layer, including the virtual and physical memory addresses. @@ -457,7 +436,6 @@ typedef struct { uint32_t height; /**< The height of the request allocation */ uint64_t usage; /**< The usage of the request allocation */ PixelFormat format; /**< The format of the request allocation */ - MemType type; /**< The memory of the request allocation */ } AllocInfo; /** * @brief Enumerates power status. @@ -469,7 +447,7 @@ typedef enum { POWER_STATUS_SUSPEND, /**< The power status is suspend */ POWER_STATUS_OFF, /**< The power status is off */ POWER_STATUS_BUTT -} PowerStatus; +} DispPowerStatus; /** * @brief Enumerates composition type for special layer diff --git a/display/interfaces_lite/include/display_gfx.h b/display/interfaces_lite/include/display_gfx.h deleted file mode 100644 index 1b9e770fc3f7380fb00ac39bd52655d6dcdf73b2..0000000000000000000000000000000000000000 --- a/display/interfaces_lite/include/display_gfx.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @addtogroup Display - * @{ - * - * @brief Defines driver functions of the display module. - * - * This module provides driver functions for the graphics subsystem, including graphics layer management, - * device control, graphics hardware acceleration, display memory management, and callbacks. - * - * @since 1.0 - * @version 2.0 - */ - -/** - * @file display_gfx.h - * - * @brief Declares the driver functions for implementing hardware acceleration. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef DISPLAY_GFX_H -#define DISPLAY_GFX_H -#include "display_type.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Defines pointers to the hardware acceleration driver functions. - */ -typedef struct { - /** - * @brief Initializes hardware acceleration. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see DeinitGfx - * @since 1.0 - * @version 1.0 - */ - int32_t (*InitGfx)(void); - - /** - * @brief Deinitializes hardware acceleration. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see InitGfx - * @since 1.0 - * @version 1.0 - */ - int32_t (*DeinitGfx)(void); - - /** - * @brief Fills a rectangle with a given color on the canvas. - * - * @param surface Indicates the pointer to the canvas. - * @param rect Indicates the pointer to the rectangle to fill. - * @param color Indicates the color to fill. - * @param opt Indicates the pointer to the hardware acceleration option. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*FillRect)(ISurface *surface, IRect *rect, uint32_t color, GfxOpt *opt); - - /** - * @brief Draws a rectangle with a given color on the canvas. - * - * @param surface Indicates the pointer to the canvas. - * @param rect Indicates the pointer to the rectangle to draw. - * @param color Indicates the color to draw. - * @param opt Indicates the pointer to the hardware acceleration option. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*DrawRectangle)(ISurface *surface, Rectangle *rect, uint32_t color, GfxOpt *opt); - - /** - * @brief Draws a straight line with a given color on the canvas. - * - * @param surface Indicates the pointer to the canvas. - * @param line Indicates the pointer to the line to draw. - * @param opt Indicates the pointer to the hardware acceleration option. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*DrawLine)(ISurface *surface, ILine *line, GfxOpt *opt); - - /** - * @brief Draws a circle with a specified center and radius on the canvas using a given color. - * - * @param surface Indicates the pointer to the canvas. - * @param circle Indicates the pointer to the circle to draw. - * @param opt Indicates the pointer to the hardware acceleration option. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*DrawCircle)(ISurface *surface, ICircle *circle, GfxOpt *opt); - - /** - * @brief Blits bitmaps. - * - * During bit blit, color space conversion (CSC), scaling, and rotation can be implemented. - * - * @param srcSurface Indicates the pointer to the source bitmap. - * @param srcRect Indicates the pointer to the rectangle of the source bitmap. - * @param dstSurface Indicates the pointer to the destination bitmap. - * @param dstRect Indicates the pointer to the rectangle of the destination bitmap. - * @param opt Indicates the pointer to the hardware acceleration option. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*Blit)(ISurface *srcSurface, IRect *srcRect, ISurface *dstSurface, IRect *dstRect, GfxOpt *opt); - - /** - * @brief Synchronizes hardware acceleration when it is used to draw and blit bitmaps. - * - * This function blocks the process until hardware acceleration is complete. - * - * @param timeOut Indicates the timeout duration for hardware acceleration synchronization. The value 0 - * indicates no timeout, so the process waits until hardware acceleration is complete. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*Sync)(int32_t timeOut); -} GfxFuncs; - -/** - * @brief Initializes the hardware acceleration module to obtain the pointer to functions for hardware acceleration - * operations. - * - * @param funcs Indicates the double pointer to functions for hardware acceleration operations. Memory is allocated - * automatically when you initiate the hardware acceleration module, so you can simply use the pointer to gain access - * to the functions. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ -int32_t GfxInitialize(GfxFuncs **funcs); - -/** - * @brief Deinitializes the hardware acceleration module to release the pointer to functions for hardware - * acceleration operations. - * - * @param funcs Indicates the pointer to the functions for hardware acceleration operations. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ -int32_t GfxUninitialize(GfxFuncs *funcs); - -#ifdef __cplusplus -} -#endif -#endif -/** @} */ diff --git a/display/interfaces_lite/include/display_gralloc.h b/display/interfaces_lite/include/display_gralloc.h deleted file mode 100644 index 7ab76c9d532904a262fd9d61f1621b1f5162ece0..0000000000000000000000000000000000000000 --- a/display/interfaces_lite/include/display_gralloc.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @addtogroup Display - * @{ - * - * @brief Defines driver functions of the display module. - * - * This module provides driver functions for the graphics subsystem, including graphics layer management, - * device control, graphics hardware acceleration, display memory management, and callbacks. - * @since 1.0 - * @version 2.0 - */ - - -/** - * @file display_gralloc.h - * - * @brief Declares the driver functions for memory. - * - * @since 1.0 - * @version 2.0 - */ - -#ifndef DISPLAY_GRALLOC_H -#define DISPLAY_GRALLOC_H -#include "display_type.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Defines pointers to the memory driver functions. - */ -typedef struct { - /** - * @brief Allocates memory based on the parameters passed by the GUI. - * - * The allocated memory can be classified into shared memory, memory with cache, and memory without cache. - * - * @param buffer Indicates the pointer to the buffer of the memory to allocate. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*AllocMem)(GrallocBuffer *buffer); - - /** - * @brief Releases memory. - * - * @param buffer Indicates the pointer to the buffer of the memory to release. - * - * @since 1.0 - * @version 1.0 - */ - void (*FreeMem)(GrallocBuffer *buffer); - - /** - * @brief Maps memory to memory without cache in the process's address space. - * - * @param buffer Indicates the pointer to the buffer of the memory to map. - * - * @return Returns the pointer to a valid address if the operation is successful; returns NULL otherwise. - * @since 1.0 - * @version 1.0 - */ - void *(*Mmap)(GrallocBuffer *buffer); - - /** - * @brief Maps memory to memory with cache in the process's address space. - * - * @param buffer Indicates the pointer to the buffer of the memory to map. - * - * @return Returns the pointer to a valid address if the operation is successful; returns NULL otherwise. - * @since 1.0 - * @version 1.0 - */ - void *(*MmapCache)(GrallocBuffer *buffer); - - /** - * @brief Unmaps memory, that is, removes any mappings in the process's address space. - * - * @param buffer Indicates the pointer to the buffer of the memory to unmap. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*Unmap)(GrallocBuffer *buffer); - - /** - * @brief Flushes data from the cache to memory and invalidates the data in the cache. - * - * @param buffer Indicates the pointer to the buffer of the cache to flush. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*FlushCache)(GrallocBuffer *buffer); - - /** - * @brief Flushes data from the cache mapped via {@link Mmap} to memory and invalidates the data in the cache. - * - * @param buffer Indicates the pointer to the buffer of the cache to flush. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*FlushMCache)(GrallocBuffer *buffer); -} GrallocFuncs; - -/** - * @brief Initializes the memory module to obtain the pointer to functions for memory operations. - * - * @param funcs Indicates the double pointer to functions for memory operations. Memory is allocated automatically when - * you initiate the memory module initialization, so you can simply use the pointer to gain access to the functions. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ -int32_t GrallocInitialize(GrallocFuncs **funcs); - -/** - * @brief Deinitializes the memory module to release the memory allocated to the pointer to functions for memory - * operations. - * - * @param funcs Indicates the pointer to functions for memory operations. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ -int32_t GrallocUninitialize(GrallocFuncs *funcs); - -#ifdef __cplusplus -} -#endif -#endif -/** @} */ diff --git a/display/interfaces_lite/include/display_layer.h b/display/interfaces_lite/include/display_layer.h deleted file mode 100644 index 1e0b848295bd37f13543dd3d119e66f3c72b235c..0000000000000000000000000000000000000000 --- a/display/interfaces_lite/include/display_layer.h +++ /dev/null @@ -1,575 +0,0 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @addtogroup Display - * @{ - * - * @brief Defines driver functions of the display module. - * - * This module provides driver functions for the graphics subsystem, including graphics layer management, - * device control, graphics hardware acceleration, display memory management, and callbacks. - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file display_layer.h - * - * @brief Declares the driver functions for implementing layer operations. - * - * @since 1.0 - * @version 2.0 - */ - -#ifndef DISPLAY_LAYTER_H -#define DISPLAY_LAYTER_H -#include "display_type.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Defines pointers to the layer driver functions. - */ -typedef struct { - /** - * @brief Initializes a display device. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see DeinitDisplay - * @since 1.0 - * @version 1.0 - */ - int32_t (*InitDisplay)(uint32_t devId); - - /** - * @brief Deinitializes a display device. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see InitDisplay - * @since 1.0 - * @version 1.0 - */ - int32_t (*DeinitDisplay)(uint32_t devId); - - /** - * @brief Obtains information about a display device. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param dispInfo Indicates the pointer to the display device information obtained. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*GetDisplayInfo)(uint32_t devId, DisplayInfo *dispInfo); - - /** - * @brief Opens a layer on a specified display device. - * - * Before using a layer on the GUI, you must open the layer based on the layer information. After the layer is - * opened, you can obtain the layer ID and then use other functions based on the layer ID. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerInfo Indicates the pointer to the layer information passed to open a layer, including the layer - * type, layer size, and pixel format. - * @param layerId Indicates the pointer to the layer ID, which identifies a unique layer. The layer ID is returned - * to the GUI after the layer is successfully opened. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see CloseLayer - * @since 1.0 - * @version 1.0 - */ - int32_t (*OpenLayer)(uint32_t devId, const LayerInfo *layerInfo, uint32_t *layerId); - - /** - * @brief Closes a layer that is no longer required on a specified display device. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see OpenLayer - * @since 1.0 - * @version 1.0 - */ - int32_t (*CloseLayer)(uint32_t devId, uint32_t layerId); - - /** - * @brief Sets whether a layer is visible. - * - * A visible layer is displayed on the screen, whereas an invisible layer is not displayed on the screen. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param visible Indicates the visibility to set for the layer. The value true means to set the layer to be - * visible, and false means the opposite. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see GetLayerVisibleState - * @since 1.0 - * @version 1.0 - */ - int32_t (*SetLayerVisible)(uint32_t devId, uint32_t layerId, bool visible); - - /** - * @brief Checks whether a layer is visible. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param visible Indicates the pointer to the obtained layer visibility. The value true indicates that the - * layer is visible, and false indicates that the layer is invisible. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see SetLayerVisible - * @since 1.0 - * @version 1.0 - */ - int32_t (*GetLayerVisibleState)(uint32_t devId, uint32_t layerId, bool *visible); - - /** - * @brief Sets the size of a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param rect Indicates the pointer to the layer size to set, in pixels. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see GetLayerSize - * @since 1.0 - * @version 1.0 - */ - int32_t (*SetLayerSize)(uint32_t devId, uint32_t layerId, IRect *rect); - - /** - * @brief Obtains the size of a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param rect Indicates the pointer to the obtained layer size. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see SetLayerSize - * @since 1.0 - * @version 1.0 - */ - int32_t (*GetLayerSize)(uint32_t devId, uint32_t layerId, IRect *rect); - - /** - * @brief Sets the rectangular area to crop for a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param rect Indicates the pointer to the rectangular area to crop. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*SetLayerCrop)(uint32_t devId, uint32_t layerId, IRect *rect); - - /** - * @brief Sets the z-order for a layer. - * - * A larger z-order value indicates a higher layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param zorder Indicates the z-order to set. The value is an integer ranging from 0 to 255. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see GetLayerZorder - * @since 1.0 - * @version 1.0 - */ - int32_t (*SetLayerZorder)(uint32_t devId, uint32_t layerId, uint32_t zorder); - - /** - * @brief Obtains the z-order of a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param zorder Indicates the pointer to the obtained z-order. The value is an integer ranging from 0 to 255. - * A larger z-order value indicates a higher layer. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see SetLayerZorder - * @since 1.0 - * @version 1.0 - */ - int32_t (*GetLayerZorder)(uint32_t devId, uint32_t layerId, uint32_t *zorder); - - /** - * @brief Sets layer premultiplication. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param preMul Specifies whether to enable layer premultiplication. The value 1 means to enable layer - * premultiplication, and 0 means the opposite. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see GetLayerPreMulti - * @since 1.0 - * @version 1.0 - */ - int32_t (*SetLayerPreMulti)(uint32_t devId, uint32_t layerId, bool preMul); - - /** - * @brief Obtains the premultiplication flag of a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param preMul Indicates the pointer to the obtained layer premultiplication flag. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see SetLayerPreMulti - * @since 1.0 - * @version 1.0 - */ - int32_t (*GetLayerPreMulti)(uint32_t devId, uint32_t layerId, bool *preMul); - - /** - * @brief Sets the alpha value for a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param alpha Indicates the pointer to the alpha value to set. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see GetLayerAlpha - * @since 1.0 - * @version 1.0 - */ - int32_t (*SetLayerAlpha)(uint32_t devId, uint32_t layerId, LayerAlpha *alpha); - - /** - * @brief Obtains the alpha value of a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param alpha Indicates the pointer to the obtained alpha value. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see SetLayerAlpha - * @since 1.0 - * @version 1.0 - */ - int32_t (*GetLayerAlpha)(uint32_t devId, uint32_t layerId, LayerAlpha *alpha); - - /** - * @brief Sets the color key for a layer. The color key is used during layer overlay. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param enable Specify whether to enable the color key. - * @param key Indicates the color key. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see GetLayerColorKey - * @since 1.0 - * @version 1.0 - */ - int32_t (*SetLayerColorKey)(uint32_t devId, uint32_t layerId, bool enable, uint32_t key); - - /** - * @brief Obtains the color key of a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param enable Indicates the pointer to the color key enable bit. - * @param key Indicates the pointer to the color key. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see SetLayerColorKey - * @since 1.0 - * @version 1.0 - */ - int32_t (*GetLayerColorKey)(uint32_t devId, uint32_t layerId, bool *enable, uint32_t *key); - - /** - * @brief Sets the palette for a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param palette Indicates the pointer to the palette to set. - * @param len Indicates the length of the palette. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see GetLayerPalette - * @since 1.0 - * @version 1.0 - */ - int32_t (*SetLayerPalette)(uint32_t devId, uint32_t layerId, uint32_t *palette, uint32_t len); - - /** - * @brief Obtains the palette of a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param palette Indicates the pointer to the obtained palette. - * @param len Indicates the length of the palette. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see SetLayerPalette - * @since 1.0 - * @version 1.0 - */ - int32_t (*GetLayerPalette)(uint32_t devId, uint32_t layerId, uint32_t *palette, uint32_t len); - - /** - * @brief Sets the transform mode for rotating, scaling, or moving a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param type Indicates the transformation mode to set. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*SetTransformMode)(uint32_t devId, uint32_t layerId, TransformType type); - - /** - * @brief Sets the compression feature for a layer. - * - * In specific scenarios, images need to be compressed. You can set whether to enable layer compression. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param compType Specifies whether to enable the compression feature. The value true>/b> means to enable - * compression, and false> means the opposite. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see GetLayerCompression - * @since 1.0 - * @version 1.0 - */ - int32_t (*SetLayerCompression)(uint32_t devId, uint32_t layerId, int32_t compType); - - /** - * @brief Checks whether the compression feature is enabled for a layer. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param compType Indicates the pointer to the variable specifying whether the compression feature is enabled. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see SetLayerCompression - * @since 1.0 - * @version 1.0 - */ - int32_t (*GetLayerCompression)(uint32_t devId, uint32_t layerId, int32_t *compType); - - /** - * @brief Sets the flushing area for a layer. - * - * After the GUI draws an image, you must set the layer flushing area before calling the {@link Flush} function to - * flush the screen. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param region Indicates the pointer to the flushing area to set. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*SetLayerDirtyRegion)(uint32_t devId, uint32_t layerId, IRect *region); - - /** - * @brief Obtains the buffer of a layer. - * - * After drawing a picture in the buffer, the application calls the {@link Flush} function to display the picture - * on the screen. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param buffer Indicates the pointer to the obtained buffer. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see Flush - * @since 1.0 - * @version 1.0 - */ - int32_t (*GetLayerBuffer)(uint32_t devId, uint32_t layerId, LayerBuffer *buffer); - - /** - * @brief Flushes a layer. - * - * Display data in the buffer is flushed to a specified layer so that the image data is displayed on the screen. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param buffer Indicates the pointer to the buffer in which the display data is to flush. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*Flush)(uint32_t devId, uint32_t layerId, LayerBuffer *buffer); - - /** - * @brief Waits for the arrival of vertical blanking. - * - * This function blocks the process until vertical blanking arrives, implementing the synchronization between - * software and hardware. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param layerId Indicates the layer ID, which identifies a unique layer. You can perform operations on the layer - * with the specified layer ID. - * @param timeOut Indicates the maximum duration that the process waits for the arrival of vertical blanking. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*WaitForVBlank)(uint32_t devId, uint32_t layerId, int32_t timeOut); - - /** - * @brief Implements the snapshot feature. - * - * This function saves the screenshot of image data on the display device to the buffer for debugging or as - * requested by applications. - * - * @param devId Indicates the ID of a display device. The value ranges from 0 to 4, where 0 indicates the first - * display device and 4 indicates the last display device. - * @param buffer Indicates the pointer to the buffer for saving screenshots. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @since 1.0 - * @version 1.0 - */ - int32_t (*SnapShot)(uint32_t devId, LayerBuffer *buffer); -} LayerFuncs; - -/** - * @brief Initializes the layer to apply for resources used by the layer and obtain the pointer to functions for - * layer operations. - * - * @param funcs Indicates the double pointer to functions for layer operations. Memory is allocated automatically when - * you initiate the layer module, so you can simply use the pointer to gain access to the functions. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see LayerUninitialize - * @since 1.0 - * @version 1.0 - */ -int32_t LayerInitialize(LayerFuncs **funcs); - -/** - * @brief Deinitializes the layer module to release the memory allocated to the pointer to functions for - * layer operations. - * - * @param funcs Indicates the pointer to functions for layer operations. - * - * @return Returns 0 if the operation is successful; returns an error code defined in {@link DispErrCode} - * otherwise. - * @see LayerInitialize - * @since 1.0 - * @version 1.0 - */ -int32_t LayerUninitialize(LayerFuncs *funcs); - -#ifdef __cplusplus -} -#endif -#endif -/** @} */ diff --git a/display/interfaces_lite/include/display_type.h b/display/interfaces_lite/include/display_type.h deleted file mode 100644 index 17960ff11e6c334e7ccd10d6a4ad3a9ed5d8ed18..0000000000000000000000000000000000000000 --- a/display/interfaces_lite/include/display_type.h +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @addtogroup Display - * @{ - * - * @brief Defines driver functions of the display module. - * - * This module provides driver functions for the graphics subsystem, including graphics layer management, - * device control, graphics hardware acceleration, display memory management, and callbacks. - * - * @since 1.0 - * @version 2.0 - */ - -/** - * @file display_type.h - * - * @brief Declares the data types used by the display driver functions. - * - * @since 1.0 - * @version 2.0 - */ - -#ifndef DISPLAY_TYPE_H -#define DISPLAY_TYPE_H -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Enumerates return values of the functions. - * - */ -typedef enum { - DISPLAY_SUCCESS = 0, /**< Success */ - DISPLAY_FAILURE = -1, /**< Failure */ - DISPLAY_FD_ERR = -2, /**< File handle (FD) error */ - DISPLAY_PARAM_ERR = -3, /**< Parameter error */ - DISPLAY_NULL_PTR = -4, /**< Null pointer */ - DISPLAY_NOT_SUPPORT = -5, /**< Unsupported feature */ - DISPLAY_NOMEM = -6, /**< Insufficient memory */ - DISPLAY_SYS_BUSY = -7, /**< System busy */ - DISPLAY_NOT_PERM = -8 /**< Forbidden operation */ -} DispErrCode; - -/** - * @brief Enumerates layer types. - * - */ -typedef enum { - LAYER_TYPE_GRAPHIC, /* < Graphic layer */ - LAYER_TYPE_OVERLAY, /* < Overlay layer */ - LAYER_TYPE_SDIEBAND, /* < Sideband layer */ - LAYER_TYPE_BUTT /* < Empty layer */ -} LayerType; - -/** - * @brief Enumerates pixel formats. - * - */ -typedef enum { - PIXEL_FMT_CLUT8 = 0, /**< CLUT8 format */ - PIXEL_FMT_CLUT1, /**< CLUT1 format */ - PIXEL_FMT_CLUT4, /**< CLUT4 format */ - PIXEL_FMT_RGB_565, /**< RGB565 format */ - PIXEL_FMT_RGBA_5658, /**< RGBA5658 format */ - PIXEL_FMT_RGBX_4444, /**< RGBX4444 format */ - PIXEL_FMT_RGBA_4444, /**< RGBA4444 format */ - PIXEL_FMT_RGB_444, /**< RGB444 format */ - PIXEL_FMT_RGBX_5551, /**< RGBX5551 format */ - PIXEL_FMT_RGBA_5551, /**< RGBA5551 format */ - PIXEL_FMT_RGB_555, /**< RGB555 format */ - PIXEL_FMT_RGBX_8888, /**< RGBX8888 format */ - PIXEL_FMT_RGBA_8888, /**< RGBA8888 format */ - PIXEL_FMT_RGB_888, /**< RGB888 format */ - PIXEL_FMT_BGR_565, /**< BGR565 format */ - PIXEL_FMT_BGRX_4444, /**< BGRX4444 format */ - PIXEL_FMT_BGRA_4444, /**< BGRA4444 format */ - PIXEL_FMT_BGRX_5551, /**< BGRX5551 format */ - PIXEL_FMT_BGRA_5551, /**< BGRA5551 format */ - PIXEL_FMT_BGRX_8888, /**< BGRX8888 format */ - PIXEL_FMT_BGRA_8888, /**< BGRA8888 format */ - PIXEL_FMT_YUV_422_I, /**< YUV422 interleaved format */ - PIXEL_FMT_YCBCR_422_SP, /**< YCBCR422 semi-planar format */ - PIXEL_FMT_YCRCB_422_SP, /**< YCRCB422 semi-planar format */ - PIXEL_FMT_YCBCR_420_SP, /**< YCBCR420 semi-planar format */ - PIXEL_FMT_YCRCB_420_SP, /**< YCRCB420 semi-planar format */ - PIXEL_FMT_YCBCR_422_P, /**< YCBCR422 planar format */ - PIXEL_FMT_YCRCB_422_P, /**< YCRCB422 planar format */ - PIXEL_FMT_YCBCR_420_P, /**< YCBCR420 planar format */ - PIXEL_FMT_YCRCB_420_P, /**< YCRCB420 planar format */ - PIXEL_FMT_YUYV_422_PKG, /**< YUYV422 packed format */ - PIXEL_FMT_UYVY_422_PKG, /**< UYVY422 packed format */ - PIXEL_FMT_YVYU_422_PKG, /**< YVYU422 packed format */ - PIXEL_FMT_VYUY_422_PKG, /**< VYUY422 packed format */ - PIXEL_FMT_BUTT /**< Invalid pixel format */ -} PixelFormat; - -/** - * @brief Enumerates transform types of images. - * - */ -typedef enum { - ROTATE_NONE = 0, /**< No rotation */ - ROTATE_90, /**< Rotation by 90 degrees */ - ROTATE_180, /**< Rotation by 180 degrees */ - ROTATE_270, /**< Rotation by 270 degrees */ - ROTATE_BUTT /**< Invalid operation */ -} TransformType; - -/** - * @brief Enumerates memory types. - * - * Memory is allocated based on the type specified by the GUI. - * - */ -typedef enum { - NORMAL_MEM = 0, /* < Memory without cache */ - CACHE_MEM, /* < Memory with cache */ - SHM_MEM /* < Shared memory */ -} MemType; - -/** - * @brief Enumerates image blending types. - * - * The system combines images based on a specified blending type during hardware acceleration. - * - */ -typedef enum { - BLEND_NONE = 0, /**< No blending */ - BLEND_CLEAR, /**< CLEAR blending */ - BLEND_SRC, /**< SRC blending */ - BLEND_SRCOVER, /**< SRC_OVER blending */ - BLEND_DSTOVER, /**< DST_OVER blending */ - BLEND_SRCIN, /**< SRC_IN blending */ - BLEND_DSTIN, /**< DST_IN blending */ - BLEND_SRCOUT, /**< SRC_OUT blending */ - BLEND_DSTOUT, /**< DST_OUT blending */ - BLEND_SRCATOP, /**< SRC_ATOP blending */ - BLEND_DSTATOP, /**< DST_ATOP blending */ - BLEND_ADD, /**< ADD blending */ - BLEND_XOR, /**< XOR blending */ - BLEND_DST, /**< DST blending */ - BLEND_AKS, /**< AKS blending */ - BLEND_AKD, /**< AKD blending */ - BLEND_BUTT /**< Null operation */ -} BlendType; - -/** - * @brief Enumerates ROP types supported by hardware acceleration. - * - * ROP performs bitwise Boolean operations (including bitwise AND and bitwise OR) on the RGB color and - * alpha values of the foreground bitmap with those of the background bitmap, and then outputs the result. - * - */ -typedef enum { - ROP_BLACK = 0, /**< Blackness */ - ROP_NOTMERGEPEN, /**< ~(S2+S1) */ - ROP_MASKNOTPEN, /**< ~S2&S1 */ - ROP_NOTCOPYPEN, /**< ~S2 */ - ROP_MASKPENNOT, /**< S2&~S1 */ - ROP_NOT, /**< ~S1 */ - ROP_XORPEN, /**< S2^S1 */ - ROP_NOTMASKPEN, /**< ~(S2&S1) */ - ROP_MASKPEN, /**< S2&S1 */ - ROP_NOTXORPEN, /**< ~(S2^S1) */ - ROP_NOP, /**< S1 */ - ROP_MERGENOTPEN, /**< ~S2+S1 */ - ROP_COPYPE, /**< S2 */ - ROP_MERGEPENNOT, /**< S2+~S1 */ - ROP_MERGEPEN, /**< S2+S1 */ - ROP_WHITE, /**< Whiteness */ - ROP_BUTT /**< Invalid ROP type */ -} RopType; - -/** - * @brief Enumerates color key types supported by hardware acceleration. - * - */ -typedef enum { - CKEY_NONE = 0, /**< No color key */ - CKEY_SRC, /**< Source color key */ - CKEY_DST, /**< Destination color key */ - CKEY_BUTT /**< Null operation */ -} ColorKey; - -/** - * @brief Enumerates mirror types supported by hardware acceleration. - * - */ -typedef enum { - MIRROR_NONE = 0, /**< No mirror */ - MIRROR_LR, /**< Left and right mirrors */ - MIRROR_TB, /**< Top and bottom mirrors */ - MIRROR_BUTT /**< Null operation */ -} MirrorType; - -/** - * @brief Enumerates connection types of hot plugging. - * - */ -typedef enum { - INVALID = 0, /**< Invalid connection */ - CONNECTED, /**< Connected */ - DISCONNECTED /**< Disconnected */ -} Connection; - -/** - * @brief Defines display information. - * - */ -typedef struct { - uint32_t width; /**< Display width */ - uint32_t height; /**< Display height */ - int32_t rotAngle; /**< Rotation angle of the display */ -} DisplayInfo; - -/** - * @brief Defines layer information. - * - * LayerInfo must be passed to the {@link OpenLayer} function, which creates a layer based on the layer - * information. - * - */ -typedef struct { - int32_t width; /**< Layer width */ - int32_t height; /**< Layer height */ - LayerType type; /**< Layer type, which can be a graphic layer, overlay layer, or sideband layer */ - int32_t bpp; /**< Number of bits occupied by each pixel */ - PixelFormat pixFormat; /**< Pixel format of the layer */ -} LayerInfo; - -/** - * @brief Defines alpha information about a layer. - * - */ -typedef struct { - bool enGlobalAlpha; /**< Global alpha enable bit */ - bool enPixelAlpha; /**< Pixel alpha enable bit */ - uint8_t alpha0; /**< Alpha0 value, ranging from 0 to 255 */ - uint8_t alpha1; /**< Alpha1 value, ranging from 0 to 255 */ - uint8_t gAlpha; /**< Global alpha value, ranging from 0 to 255 */ -} LayerAlpha; - -/** - * @brief Defines the buffer handle, including the shared memory key, shared memory ID, and physical memory address. - * - */ -typedef struct { - int32_t key; /* < Shared memory key */ - int32_t shmid; /* < Unique ID of the shared memory */ - uint64_t phyAddr; /* < Physical memory address */ -} BufferHandle; - -/** - * @brief Defines the memory buffer, such as virtual and physical memory addresses. - * - */ -typedef struct { - BufferHandle hdl; /**< Buffer handle */ - MemType type; /**< Type of the requested memory */ - uint32_t size; /**< Size of the requested memory */ - void *virAddr; /**< Virtual address of the requested memory */ -} GrallocBuffer; - -/** - * @brief Defines buffer data of a layer, including the virtual and physical memory addresses. - * - */ -typedef struct { - uint64_t phyAddr; /**< Physical memory address */ - void *virAddr; /**< Virtual memory address */ -} BufferData; - -/** - * @brief Defines the buffer, which is used to store layer data. - * - */ -typedef struct { - int32_t fenceId; /* < Fence ID of the buffer */ - int32_t width; /* < Buffer width */ - int32_t height; /* < Buffer height */ - int32_t pitch; /* < Number of bytes from one row of pixels in memory to the next */ - PixelFormat pixFormat; /* < Pixel format of the buffer */ - BufferData data; /* < Layer buffer data */ -} LayerBuffer; - -/** - * @brief Defines the information about a rectangle. - * - */ -typedef struct { - int32_t x; /**< Start X coordinate of the rectangle */ - int32_t y; /**< Start Y coordinate of the rectangle */ - int32_t w; /**< Width of the rectangle */ - int32_t h; /**< Height of the rectangle */ -} IRect; - -/** - * @brief Stores surface information for hardware acceleration, such as draw image and bit blit. - * - */ -typedef struct { - uint64_t phyAddr; /**< Start physical address of an image */ - int32_t height; /**< Image height */ - int32_t width; /**< Image width */ - int32_t stride; /**< Image stride */ - PixelFormat enColorFmt; /**< Image format */ - bool bYCbCrClut; /**< Whether the color lookup table (CLUT) is in the YCbCr space */ - bool bAlphaMax255; /**< Maximum alpha value of an image (255 or 128) */ - bool bAlphaExt1555; /**< ARGB1555 alpha extension enable bit */ - uint8_t alpha0; /**< Value of alpha0, ranging from 0 to 255 */ - uint8_t alpha1; /**< Value of alpha1, ranging from 0 to 255 */ - uint64_t cbcrPhyAddr; /**< CbCr physical address */ - int32_t cbcrStride; /**< CbCr stride */ - uint64_t clutPhyAddr; /**< Start physical address of the CLUT, used for color extension or correction */ -} ISurface; - -/** - * @brief Describes a line to help draw lines in hardware acceleration. - * - */ -typedef struct { - int32_t x0; /**< X coordinate of the start point of a line */ - int32_t y0; /**< Y coordinate of the start point of a line */ - int32_t x1; /**< X coordinate of the end point of a line */ - int32_t y1; /**< Y coordinate of the end point of a line */ - uint32_t color; /**< Line color */ -} ILine; - -/** - * @brief Describes a circle to help draw circles in hardware acceleration. - * - */ -typedef struct { - int32_t x; /**< X coordinate of a circle center */ - int32_t y; /**< Y coordinate of a circle center */ - int32_t r; /**< Radius of a circle */ - uint32_t color; /**< Circle color */ -} ICircle; - -/** - * @brief Describes a rectangle to help draw rectangles in hardware acceleration. - * - */ -typedef struct { - IRect rect; /**< Bounds of a rectangle */ - uint32_t color; /**< Rectangle color */ -} Rectangle; - -/** - * @brief Defines hardware acceleration options. - * - */ -typedef struct { - bool enGlobalAlpha; /**< Golbal alpha enable bit */ - uint32_t globalAlpha; /**< Global alpha value */ - bool enPixelAlpha; /**< Pixel alpha enable bit */ - BlendType blendType; /**< Blending type */ - ColorKey colorKeyFrom; /**< Color key mode */ - bool enableRop; /**< Raster operations pipeline (ROP) enable bit */ - RopType colorRopType; /**< Color ROP type */ - RopType alphaRopType; /**< Alpha ROP type */ - bool enableScale; /**< Scaling enable bit */ - TransformType rotateType; /**< Rotation type */ - MirrorType mirrorType; /**< Mirror type */ -} GfxOpt; - -#ifdef __cplusplus -} -#endif -#endif -/* @} */ diff --git a/display/test/unittest/BUILD.gn b/display/test/unittest/BUILD.gn index 22ba04620b6dc1a105af2316c3cb71b6e4815bff..884972783114e0a8f2a296e9075fbf07f9e3d318 100644 --- a/display/test/unittest/BUILD.gn +++ b/display/test/unittest/BUILD.gn @@ -29,7 +29,8 @@ unittest("hdf_peripheral_display_test") { "//drivers/framework/include", "//drivers/framework/test/unittest/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits", - "//drivers/peripheral/display/interfaces_lite/include", + "//drivers/peripheral/base", + "//drivers/peripheral/display/interfaces/include", ] sources = [ diff --git a/display/test/unittest/common/display_test.c b/display/test/unittest/common/display_test.c index 8a08949f002c80f541514b3fa61c75e2a391aa4d..bf6d61d896c286ed806db31cb2f1188bfaca66cf 100644 --- a/display/test/unittest/common/display_test.c +++ b/display/test/unittest/common/display_test.c @@ -20,16 +20,15 @@ #include "loadbmp_test.h" DisplayTest g_displayTest; -static GrallocBuffer g_buffer; +static BufferHandle* g_buffer; -static int32_t LoadBmp(const int8_t *fileName, GrallocBuffer *buffer) +static int32_t LoadBmp(const int8_t *fileName, BufferHandle **buffer) { int32_t ret; uint8_t *pBuf = NULL; OsdSurface surface; OsdBitMapFileHeader bmpFileHeader = {0}; OsdBitMapInfo bmpInfo = {0}; - const int32_t bytesPerPix = LAYER_BPP / BITS_PER_BYTE; if (fileName == NULL) { HDF_LOGE("%s: fileName is null", __func__); @@ -39,20 +38,24 @@ static int32_t LoadBmp(const int8_t *fileName, GrallocBuffer *buffer) HDF_LOGE("%s: GetBmpInfo err", __func__); return DISPLAY_FAILURE; } - buffer->size = bytesPerPix * (bmpInfo.header.width + 1) * (bmpInfo.header.height + 1); - buffer->type = NORMAL_MEM; + AllocInfo info = { + .width = bmpInfo.header.width + 1, + .height = bmpInfo.header.height + 1, + .format = PIXEL_FMT_RGBA_8888, + .usage = HBM_USE_MEM_MMZ + }; // alloc picture buffer if (g_displayTest.grallocFuncs->AllocMem != NULL) { - ret = g_displayTest.grallocFuncs->AllocMem(buffer); + ret = g_displayTest.grallocFuncs->AllocMem(&info, buffer); if (ret != DISPLAY_SUCCESS) { HDF_LOGE("%s: pictureBuf alloc failure", __func__); return DISPLAY_FAILURE; } } // load bmp picture - pBuf = (uint8_t *)buffer->virAddr; + pBuf = (uint8_t *)(*buffer)->virAddr; surface.colorFmt = OSD_COLOR_FMT_RGB1555; - CreateSurfaceByBitMap(fileName, &surface, pBuf, buffer->size); + CreateSurfaceByBitMap(fileName, &surface, pBuf, (*buffer)->size); return DISPLAY_SUCCESS; } @@ -190,7 +193,7 @@ int32_t GetDisplayInfoTest(void) return DISPLAY_SUCCESS; } -int32_t OpenLayerTest(void) +int32_t CreateLayerTest(void) { int32_t ret; LayerInfo layInfo; @@ -198,10 +201,10 @@ int32_t OpenLayerTest(void) g_displayTest.devId = 0; // create layer GetLayerInfo(&layInfo); - if (g_displayTest.layerFuncs->OpenLayer != NULL) { - ret = g_displayTest.layerFuncs->OpenLayer(g_displayTest.devId, &layInfo, &g_displayTest.layerId); + if (g_displayTest.layerFuncs->CreateLayer != NULL) { + ret = g_displayTest.layerFuncs->CreateLayer(g_displayTest.devId, &layInfo, &g_displayTest.layerId); if (ret != DISPLAY_SUCCESS) { - HDF_LOGE("%s: OpenLayer fail", __func__); + HDF_LOGE("%s: CreateLayer fail", __func__); return DISPLAY_FAILURE; } } @@ -319,7 +322,7 @@ int32_t BlitTest(void) int32_t ret; ISurface srcSurface = {0}; ISurface dstSurface = {0}; - GrallocBuffer pictureBuf; + BufferHandle* pictureBuf = NULL; int32_t layerBufSize = g_displayTest.displayInfo.width * g_displayTest.displayInfo.height * PIXEL_BYTE; // clean the layer buffer @@ -332,7 +335,7 @@ int32_t BlitTest(void) } // use picture buffer to create source surface IRect srcRect = {0, 0, SAMPLE_IMAGE_WIDTH, SAMPLE_IMAGE_HEIGHT}; - PicSourceSurfaceInit(&srcSurface, pictureBuf.hdl.phyAddr, LAYER_BPP); + PicSourceSurfaceInit(&srcSurface, pictureBuf->phyAddr, LAYER_BPP); // use layer buffer to create dest surface IRect dstRect = srcRect; DestSurfaceInit(&dstSurface, g_displayTest.buffer.data.phyAddr, LAYER_BPP); @@ -349,7 +352,7 @@ int32_t BlitTest(void) EXIT: /* free picture buffer */ if (g_displayTest.grallocFuncs->FreeMem != NULL) { - g_displayTest.grallocFuncs->FreeMem(&pictureBuf); + g_displayTest.grallocFuncs->FreeMem(pictureBuf); } return ret; } @@ -382,12 +385,14 @@ int32_t AllocMemTest1(void) { int32_t ret = DISPLAY_FAILURE; - (void)memset_s(&g_buffer, sizeof(GrallocBuffer), 0, sizeof(GrallocBuffer)); - g_buffer.type = NORMAL_MEM; - g_buffer.size = SAMPLE_IMAGE_WIDTH * SAMPLE_IMAGE_HEIGHT * LAYER_BPP / BITS_PER_BYTE; - + AllocInfo info = { + .width = SAMPLE_IMAGE_WIDTH, + .height = SAMPLE_IMAGE_HEIGHT, + .format = PIXEL_FMT_RGBA_8888, + .usage = HBM_USE_MEM_MMZ + }; if (g_displayTest.grallocFuncs->AllocMem != NULL) { - ret = g_displayTest.grallocFuncs->AllocMem(&g_buffer); + ret = g_displayTest.grallocFuncs->AllocMem(&info, &g_buffer); } if (ret != DISPLAY_SUCCESS) { HDF_LOGE("%s: normal memory allocMem failed", __func__); @@ -400,12 +405,15 @@ int32_t MmapCacheTest(void) { int32_t ret = DISPLAY_FAILURE; void *mapCacheAddr = NULL; + AllocInfo info = { + .width = SAMPLE_RECT_WIDTH, + .height = SAMPLE_RECT_HEIGHT, + .format = PIXEL_FMT_RGBA_8888, + .usage = HBM_USE_MEM_MMZ_CACHE + }; - (void)memset_s(&g_buffer, sizeof(GrallocBuffer), 0, sizeof(GrallocBuffer)); - g_buffer.type = NORMAL_MEM; - g_buffer.size = SAMPLE_RECT_WIDTH * SAMPLE_RECT_HEIGHT * PIXEL_BYTE; if (g_displayTest.grallocFuncs->AllocMem != NULL) { - ret = g_displayTest.grallocFuncs->AllocMem(&g_buffer); + ret = g_displayTest.grallocFuncs->AllocMem(&info, &g_buffer); } if (ret != DISPLAY_SUCCESS) { HDF_LOGE("%s: normal memory allocMem failed", __func__); @@ -413,7 +421,7 @@ int32_t MmapCacheTest(void) } if (g_displayTest.grallocFuncs->MmapCache != NULL) { - mapCacheAddr = g_displayTest.grallocFuncs->MmapCache(&g_buffer); + mapCacheAddr = g_displayTest.grallocFuncs->MmapCache(g_buffer); if (mapCacheAddr == NULL) { return DISPLAY_FAILURE; } @@ -424,7 +432,7 @@ int32_t MmapCacheTest(void) int32_t FreeMemTest(void) { if (g_displayTest.grallocFuncs->FreeMem != NULL) { - g_displayTest.grallocFuncs->FreeMem(&g_buffer); + g_displayTest.grallocFuncs->FreeMem(g_buffer); } return DISPLAY_SUCCESS; } @@ -432,12 +440,15 @@ int32_t FreeMemTest(void) int32_t AllocMemTest2(void) { int32_t ret = DISPLAY_FAILURE; + AllocInfo info = { + .width = SAMPLE_IMAGE_WIDTH, + .height = SAMPLE_IMAGE_HEIGHT, + .format = PIXEL_FMT_RGBA_8888, + .usage = HBM_USE_MEM_MMZ + }; - (void)memset_s(&g_buffer, sizeof(GrallocBuffer), 0, sizeof(GrallocBuffer)); - g_buffer.type = CACHE_MEM; - g_buffer.size = SAMPLE_IMAGE_WIDTH * SAMPLE_IMAGE_HEIGHT * LAYER_BPP / BITS_PER_BYTE; if (g_displayTest.grallocFuncs->AllocMem != NULL) { - ret = g_displayTest.grallocFuncs->AllocMem(&g_buffer); + ret = g_displayTest.grallocFuncs->AllocMem(&info, &g_buffer); } if (ret != DISPLAY_SUCCESS) { HDF_LOGE("%s: cache memory allocMem failed", __func__); @@ -452,7 +463,7 @@ int32_t FlushMCacheTest(void) int32_t ret; if (g_displayTest.grallocFuncs->FlushMCache != NULL) { - ret = g_displayTest.grallocFuncs->FlushMCache(&g_buffer); + ret = g_displayTest.grallocFuncs->FlushMCache(g_buffer); if (ret != DISPLAY_SUCCESS) { return ret; } diff --git a/display/test/unittest/common/display_test.h b/display/test/unittest/common/display_test.h index 4c43d2ceae00c428979662e867fdf6f0f990cf51..b2c3ed4325807544b6164f2009d235cf119eca4d 100644 --- a/display/test/unittest/common/display_test.h +++ b/display/test/unittest/common/display_test.h @@ -74,7 +74,7 @@ int32_t DisplayUninit(void); int32_t InitDisplayTest(void); int32_t DeinitDisplayTest(void); int32_t GetDisplayInfoTest(void); -int32_t OpenLayerTest(void); +int32_t CreateLayerTest(void); int32_t CloseLayerTest(void); int32_t SetLayerVisibleTest(void); int32_t SetLayerDirtyRegionTest(void); diff --git a/display/test/unittest/common/hdi_display_test.cpp b/display/test/unittest/common/hdi_display_test.cpp index 090e13646f163bcafcd68344cc78259e845333c7..2a182059a35688834f3b39f7d1103cf597a9214f 100644 --- a/display/test/unittest/common/hdi_display_test.cpp +++ b/display/test/unittest/common/hdi_display_test.cpp @@ -92,18 +92,18 @@ HWTEST_F(HdiDisplayTest, GetDisplayInfoTest001, TestSize.Level1) } /** - * @tc.name: OpenLayerTest001 + * @tc.name: CreateLayer001 * @tc.desc: open layer test * @tc.type: FUNC * @tc.require: AR000F868K, AR000F868O */ -HWTEST_F(HdiDisplayTest, OpenLayerTest001, TestSize.Level1) +HWTEST_F(HdiDisplayTest, CreateLayerTest001, TestSize.Level1) { int32_t ret; - ret = OpenLayerTest(); + ret = CreateLayerTest(); if (ret != DISPLAY_SUCCESS) { - HDF_LOGE("%s: OpenLayerTest fail", __func__); + HDF_LOGE("%s: CreateLayerTest fail", __func__); ASSERT_TRUE(0); } EXPECT_EQ(0, ret);