diff --git a/zh-cn/device_api/hdi/display/display_device.h b/zh-cn/device_api/hdi/display/display_device.h new file mode 100644 index 0000000000000000000000000000000000000000..6b45dd4674c186e14eae2056459a6f38d18c7a47 --- /dev/null +++ b/zh-cn/device_api/hdi/display/display_device.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2022 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 显示模块驱动接口定义。 + * + * 提供给图形系统使用的驱动接口,包括图层管理、设备控制、图形硬件加速、显示内存管理和回调接口等。 + * @since 1.0 + * @version 2.0 + */ + + /** + * @file display_device.h + * + * @brief 显示设备控制接口声明。 + * + * @since 1.0 + * @version 2.0 + */ + +#ifndef DISPLAY_DEVICE_H +#define DISPLAY_DEVICE_H +#include "display_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 显示设备控制接口结构体,定义显示设备控制接口函数指针。 + */ +typedef struct { + /** + * @brief 设置电源状态 + * + * 在系统休眠或者唤醒时,display服务或电源管理模块设置电源状态,以使驱动IC能正常进入对应的模式。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param status 设置的电源状态,display服务控制显示设备进入on、off等状态{具体参考@link PowerStatus}。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetDisplayPowerStatus)(uint32_t devId, PowerStatus status); + + /** + * @brief 获取电源状态 + * + * 获取devId对应设备的电源状态 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param status 获取到的devId对应设备的电源状态{具体参考@link PowerStatus}。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetDisplayPowerStatus)(uint32_t devId, PowerStatus *status); + + /** + * @brief 设置背光等级 + * + * 设置devId对应设备的背光等级 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param level 将要设置的具体背光值 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetDisplayBacklight)(uint32_t devId, uint32_t level); + + /** + * @brief 获取背光等级 + * + * 获取devId对应设备的背光等级 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param level 获取到的具体背光值。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetDisplayBacklight)(uint32_t devId, uint32_t *level); +} DeviceFuncs; + +/** + * @brief 实现显示设备控制接口的初始化,申请操作显示设备控制接口的资源,并获取对应的操作接口 + * + * @param funcs 显示设备控制接口指针,初始化时分配内存,调用者不需要分配内存,调用者获取该指针用于操作显示设备。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * otherwise. + * @since 1.0 + * @version 1.0 + */ +int32_t DeviceInitialize(DeviceFuncs **funcs); + +/** + * @brief 取消显示设备控制接口的初始化,释放控制接口使用到的资源。 + * + * @param funcs 显示设备控制接口指针,用于释放初始化函数中分配的操作指针内存。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ +int32_t DeviceUninitialize(DeviceFuncs *funcs); + +#ifdef __cplusplus +} +#endif +#endif +/* @} */ \ No newline at end of file diff --git a/zh-cn/device_api/hdi/display/display_gfx.h b/zh-cn/device_api/hdi/display/display_gfx.h new file mode 100644 index 0000000000000000000000000000000000000000..7d229b5793c3e48201fe391ae8998f38aabf6b75 --- /dev/null +++ b/zh-cn/device_api/hdi/display/display_gfx.h @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2022 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 显示模块驱动接口定义。 + * + * 提供给图形系统使用的驱动接口,包括图层管理、设备控制、图形硬件加速、显示内存管理和回调接口等。 + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file display_gfx.h + * + * @brief 显示硬件加速驱动接口声明。 + * + * @since 1.0 + * @version 1.0 + */ + +#ifndef DISPLAY_GFX_H +#define DISPLAY_GFX_H +#include "display_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 显示硬件加速驱动接口结构体,定义硬件加速驱动接口函数指针。 + */ +typedef struct { + /** + * @brief 初始化硬件加速。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see DeinitGfx + * @since 1.0 + * @version 1.0 + */ + int32_t (*InitGfx)(void); + + /** + * @brief 去初始化硬件加速。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see InitGfx + * @since 1.0 + * @version 1.0 + */ + int32_t (*DeinitGfx)(void); + + /** + * @brief 填充矩形,用一种颜色填充画布上指定矩形区域的矩形框。 + * + * @param surface 画布。 + * @param rect 填充的矩形区域。 + * @param color 填充的颜色。 + * @param opt 硬件加速选项。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*FillRect)(ISurface *surface, IRect *rect, uint32_t color, GfxOpt *opt); + + /** + * @brief 绘制矩形框,用一种颜色在画布上绘制指定区域的矩形框。 + * + * @param surface 画布。 + * @param rect 矩形框结构。 + * @param color 绘制的颜色。 + * @param opt 硬件加速选项。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*DrawRectangle)(ISurface *surface, Rectangle *rect, uint32_t color, GfxOpt *opt); + + /** + * @brief 绘制直线,使用一种颜色在画布上绘制一条直线。 + * + * @param surface 画布。 + * @param line 直线结构。 + * @param opt 硬件加速选项。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*DrawLine)(ISurface *surface, ILine *line, GfxOpt *opt); + + /** + * @brief 绘制圆形,使用一种颜色在画布上绘制指定圆心和半径的圆。 + * + * @param surface 画布。 + * @param circle 圆形结构。 + * @param opt 硬件加速选项。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*DrawCircle)(ISurface *surface, ICircle *circle, GfxOpt *opt); + + /** + * @brief 位图搬移 + * + * 在位图搬移过程中,可以实现色彩空间转换、缩放、旋转等功能。 + * + * @param srcSurface 源位图信息。 + * @param srcRect 源位图搬移区域。 + * @param dstSurface 目标位图信息。 + * @param dstRect 目标位图区域。 + * @param opt 硬件加速选项。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*Blit)(ISurface *srcSurface, IRect *srcRect, ISurface *dstSurface, IRect *dstRect, GfxOpt *opt); + + /** + * @brief 硬件加速同步。 + * + * 在使用硬件加速模块进行图像绘制、图像叠加、图像搬移时,通过调用该接口进行硬件同步,该接口会等待硬件加速完成。 + * + * @param timeOut 硬件加速同步超时设置,设置为0表示无超时,等待直到硬件加速完成。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*Sync)(int32_t timeOut); +} GfxFuncs; + +/** + * @brief 获取硬件加速相关的操作接口指针。 + * + * @param funcs 硬件加速模块操作接口指针,调用者不需要分配内存,调用者获取该指针操作硬件加速。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ +int32_t GfxInitialize(GfxFuncs **funcs); + +/** + * @brief 释放硬件加速相关的操作接口指针。 + * + * @param funcs 硬件加速操作接口指针。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ +int32_t GfxUninitialize(GfxFuncs *funcs); + +#ifdef __cplusplus +} +#endif +#endif +/** @} */ \ No newline at end of file diff --git a/zh-cn/device_api/hdi/display/display_gralloc.h b/zh-cn/device_api/hdi/display/display_gralloc.h new file mode 100644 index 0000000000000000000000000000000000000000..e71f7d1f0b9a3f2626519906e9091b6c02942047 --- /dev/null +++ b/zh-cn/device_api/hdi/display/display_gralloc.h @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2022 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 显示模块驱动接口定义。 + * + * 提供给图形系统使用的驱动接口,包括图层管理、设备控制、图形硬件加速、显示内存管理和回调接口等。 + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file display_gralloc.h + * + * @brief 显示内存驱动接口声明。 + * + * @since 1.0 + * @version 1.0 + */ + +#ifndef DISPLAY_GRALLOC_H +#define DISPLAY_GRALLOC_H +#include "display_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 显示内存驱动接口结构体,定义显示内存驱动接口函数指针。 + */ +typedef struct { + /** + * @brief 显示内存分配。 + * + * 根据GUI图形系统传递的参数分配内存,分配的内存根据类型可分为共享内存、cache内存和非cache内存等。 + * + * @param buffer 指向申请的内存buffer指针。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*AllocMem)(GrallocBuffer *buffer); + + /** + * @brief 显示内存释放。 + * + * @param buffer 待释放的内存buffer指针。 + * + * @since 1.0 + * @version 1.0 + */ + void (*FreeMem)(GrallocBuffer *buffer); + + /** + * @brief 显示内存映射,将内存映射到对应的进程地址空间中。 + * + * @param buffer 待映射内存buffer指针。 + * + * @return 成功返回有效地址,失败返回NULL + * @since 1.0 + * @version 1.0 + */ + void *(*Mmap)(GrallocBuffer *buffer); + + /** + * @brief 显示内存映射,将内存映射为cache内存到对应的进程地址空间中。 + * + * @param buffer 待映射内存buffer指针。 + * + * @return 成功返回有效地址,失败返回NULL + * @since 1.0 + * @version 1.0 + */ + void *(*MmapCache)(GrallocBuffer *buffer); + + /** + * @brief 内存反映射,将内存进行反映射。 + * + * @param buffer 待反映射内存buffer指针。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*Unmap)(GrallocBuffer *buffer); + + /** + * @brief 刷新cache,刷新cache里的内容到内存并且使cache里的内容无效。 + * + * @param buffer 待刷新cache的buffer指针。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*FlushCache)(GrallocBuffer *buffer); + + /** + * @brief 刷新Mmap映射的cache,刷新Mmap映射的cache里的内容到内存并且使cache里的内容无效。 + * + * @param buffer 待刷新cache的buffer指针。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*FlushMCache)(GrallocBuffer *buffer); +} GrallocFuncs; + +/** + * @brief 初始化内存模块,并获取内存提供的操作接口。 + * + * @param funcs 内存模块操作接口指针,初始化内存模块时分配内存,调用者不需要分配内存,调用者获取该指针操作内存。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ +int32_t GrallocInitialize(GrallocFuncs **funcs); + +/** + * @brief 取消初始化内存模块,并释放内存操作接口指针。 + * + * @param funcs 内存操作接口指针,用于释放内存初始化函数中分配的操作指针内存。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ +int32_t GrallocUninitialize(GrallocFuncs *funcs); + +#ifdef __cplusplus +} +#endif +#endif +/** @} */ \ No newline at end of file diff --git a/zh-cn/device_api/hdi/display/display_layer.h b/zh-cn/device_api/hdi/display/display_layer.h new file mode 100644 index 0000000000000000000000000000000000000000..869e84750949087f79a304ee7979b0ec205adda3 --- /dev/null +++ b/zh-cn/device_api/hdi/display/display_layer.h @@ -0,0 +1,541 @@ +/* + * Copyright (c) 2022 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 显示模块驱动接口定义。 + * + * 提供给图形系统使用的驱动接口,包括图层管理、设备控制、图形硬件加速、显示内存管理和回调接口等。 + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file display_layer.h + * + * @brief 显示图层驱动接口声明。 + * + * @since 1.0 + * @version 1.0 + */ + +#ifndef DISPLAY_LAYTER_H +#define DISPLAY_LAYTER_H +#include "display_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 显示图层驱动接口结构体,定义显示图层驱动接口函数指针。 + */ +typedef struct { + /** + * @brief 初始化显示设备。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see DeinitDisplay + * @since 1.0 + * @version 1.0 + */ + int32_t (*InitDisplay)(uint32_t devId); + + /** + * @brief 取消初始化显示设备。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see InitDisplay + * @since 1.0 + * @version 1.0 + */ + int32_t (*DeinitDisplay)(uint32_t devId); + + /** + * @brief 获取显示设备相关信息。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param dispInfo 显示相关信息。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetDisplayInfo)(uint32_t devId, DisplayInfo *dispInfo); + + /** + * @brief 打开图层 + * + * GUI在使用图层时,需要先根据图层信息打开图层,打开图层成功可获得图层ID,根据图层ID使用图层各接口。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerInfo 图层信息,上层GUI打开图层时需传递图层信息,包括图层类型,图层大小,像素格式等信息。 + * @param layerId 图层ID,打开图层成功后返回给GUI的图层ID,用于标识唯一的图层。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see CloseLayer + * @since 1.0 + * @version 1.0 + */ + int32_t (*OpenLayer)(uint32_t devId, const LayerInfo *layerInfo, uint32_t *layerId); + + /** + * @brief 关闭图层 + * + * 在完成显示后,如果不在需要使用图层,调用关闭图层接口关闭图层。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see OpenLayer + * @since 1.0 + * @version 1.0 + */ + int32_t (*CloseLayer)(uint32_t devId, uint32_t layerId); + + /** + * @brief 设置图层是否可见 + * + * 不可见情况下图层不显示在屏幕上,可见情况下图层显示在屏幕上。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param visible 待设置的图层可见标识,设置true表示图层可见,设置false表示图层不可见。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see GetLayerVisibleState + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetLayerVisible)(uint32_t devId, uint32_t layerId, bool visible); + + /** + * @brief 获取图层是否可见状态。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param visible 保存获取的图层可见状态,为true表示图层可见,为false表示图层不可见。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see SetLayerVisible + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetLayerVisibleState)(uint32_t devId, uint32_t layerId, bool *visible); + + /** + * @brief 设置图层大小。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param rect 待设置的图层大小,单位为像素。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see GetLayerSize + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetLayerSize)(uint32_t devId, uint32_t layerId, IRect *rect); + + /** + * @brief 获取图层大小。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param rect 保存获取的图层大小。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see SetLayerSize + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetLayerSize)(uint32_t devId, uint32_t layerId, IRect *rect); + + /** + * @brief 设置图层裁剪区域。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param rect 待设置的裁剪区域。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetLayerCrop)(uint32_t devId, uint32_t layerId, IRect *rect); + + /** + * @brief 设置图层Z轴次序 + * + * 图层的Z序值越大,图层越靠上显示。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param zorder 待设置的图层Z序,为整数值,取值范围为[0, 255],值越大图层越往上排列。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see GetLayerZorder + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetLayerZorder)(uint32_t devId, uint32_t layerId, uint32_t zorder); + + /** + * @brief 获取图层Z轴次序。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param zorder 保存获取的图层Z轴次序,为整数值,取值范围为[0, 255],值越大图层越往上排列。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see SetLayerZorder + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetLayerZorder)(uint32_t devId, uint32_t layerId, uint32_t *zorder); + + /** + * @brief 设置图层预乘。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param preMul 待设置的图层预乘使能标识,1表示使能图层预乘,0表示不使能图层预乘。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see GetLayerPreMulti + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetLayerPreMulti)(uint32_t devId, uint32_t layerId, bool preMul); + + /** + * @brief 获取图层预乘标识。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param preMul 保存获取的图层预乘使能标识。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see SetLayerPreMulti + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetLayerPreMulti)(uint32_t devId, uint32_t layerId, bool *preMul); + + /** + * @brief 设置图层alpha值。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param alpha 待设置的图层alpha值。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see GetLayerAlpha + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetLayerAlpha)(uint32_t devId, uint32_t layerId, LayerAlpha *alpha); + + /** + * @brief 获取图层alpha值。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param alpha 保存获取的图层alpha值。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see SetLayerAlpha + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetLayerAlpha)(uint32_t devId, uint32_t layerId, LayerAlpha *alpha); + + /** + * @brief 设置图层colorkey属性,在图层叠加时使用。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param enable 待设置的色键使能标识。 + * @param key 待设置的色键值,即颜色值。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see GetLayerColorKey + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetLayerColorKey)(uint32_t devId, uint32_t layerId, bool enable, uint32_t key); + + /** + * @brief 获取图层colorkey。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param enable 保存获取的enable 色键使能标识。 + * @param key 保存获取的色键值,即颜色值。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see SetLayerColorKey + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetLayerColorKey)(uint32_t devId, uint32_t layerId, bool *enable, uint32_t *key); + + /** + * @brief 设置图层调色板。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param palette 待设置的图层调色板。 + * @param len 调色板长度。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see GetLayerPalette + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetLayerPalette)(uint32_t devId, uint32_t layerId, uint32_t *palette, uint32_t len); + + /** + * @brief 获取图层调色板。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param palette 保存获取的图层调色板。 + * @param len 调色板长度。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see SetLayerPalette + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetLayerPalette)(uint32_t devId, uint32_t layerId, uint32_t *palette, uint32_t len); + + /** + * @brief 设置图层变换模式,根据不同的场景设置图层的旋转、缩放、移位等。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param type 待设置的图层变换模式。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetTransformMode)(uint32_t devId, uint32_t layerId, TransformType type); + + /** + * @brief 设置图层压缩功能 + * + * 在特定场景下,需要对图像数据进行压缩,可设置启动或关闭图层压缩功能。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param compType 图层压缩使能标识。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see GetLayerCompression + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetLayerCompression)(uint32_t devId, uint32_t layerId, int32_t compType); + + /** + * @brief 获取图层压缩功能是否打开。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param compType 保存获取的图层压缩功能状态。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see SetLayerCompression + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetLayerCompression)(uint32_t devId, uint32_t layerId, int32_t *compType); + + /** + * @brief 设置图层刷新区域 + * + * GUI图形系统绘制好图像数据后,在调用Flush接口刷新屏幕之前需要设置图层刷新区域。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param region 待设置的刷新区域。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetLayerDirtyRegion)(uint32_t devId, uint32_t layerId, IRect *region); + + /** + * @brief 获取图层的buffer + * + * 向buffer中绘图后,调用Flush接口显示到屏幕上。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param buffer 保存获取的图层buffer。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see Flush + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetLayerBuffer)(uint32_t devId, uint32_t layerId, LayerBuffer *buffer); + + /** + * @brief 刷新图层 + * + * 将buffer显示数据刷新到指定的layerId图层上,实现图像数据显示到屏幕上。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param buffer 待刷新的buffer。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*Flush)(uint32_t devId, uint32_t layerId, LayerBuffer *buffer); + + /** + * @brief 实现等待帧消隐期到来功能 + * + * 该函数会让系统等待,直到帧消隐期到来,用于软件和硬件之间的同步。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param layerId 图层ID,图层的唯一标识,根据图层ID操作图层。 + * @param timeOut 超时时间,在设置的超时时间后,没有等到帧消隐期到来则超时返回。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*WaitForVBlank)(uint32_t devId, uint32_t layerId, int32_t timeOut); + + /** + * @brief 实现抓图功能 + * + * 本函数将显示设备上的图像数据截图保存到buffer中,用于调试、应用截图等场景。 + * + * @param devId 显示设备ID,用于支持多个显示设备,取值从0开始,0表示第一个设备,最大支持5个设备。 + * @param buffer 保存截屏的buffer信息。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * otherwise. + * @since 1.0 + * @version 1.0 + */ + int32_t (*SnapShot)(uint32_t devId, LayerBuffer *buffer); +} LayerFuncs; + +/** + * @brief 实现图层初始化功能,申请图层使用的资源,并获取图层提供的操作接口。 + * + * @param funcs 图层操作接口指针,初始化图层时分配内存,调用者不需要分配内存,调用者获取该指针操作图层。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see LayerUninitialize + * @since 1.0 + * @version 1.0 + */ +int32_t LayerInitialize(LayerFuncs **funcs); + +/** + * @brief 取消图层初始化功能,释放图层使用到的资源,并释放图层操作接口指针 + * + * @param funcs 图层操作接口指针,用于释放图层初始化函数中分配的操作指针内存。 + * + * @return Returns DISPLAY_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link DispErrCode}。 + * + * @see LayerInitialize + * @since 1.0 + * @version 1.0 + */ +int32_t LayerUninitialize(LayerFuncs *funcs); + +#ifdef __cplusplus +} +#endif +#endif +/** @} */ \ No newline at end of file diff --git a/zh-cn/device_api/hdi/display/display_type.h b/zh-cn/device_api/hdi/display/display_type.h new file mode 100644 index 0000000000000000000000000000000000000000..fae2f52df45ab4872f3319d356a55d9624bebd44 --- /dev/null +++ b/zh-cn/device_api/hdi/display/display_type.h @@ -0,0 +1,1044 @@ +/* + * Copyright (c) 2022 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 显示模块驱动接口定义。 + * + * 提供给图形系统使用的驱动接口,包括图层管理、设备控制、图形硬件加速、显示内存管理和回调接口等。 + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file display_type.h + * + * @brief 显示类型定义,定义显示驱动接口所使用的数据类型。 + * + * @since 1.0 + * @version 1.0 + */ + +#ifndef DISPLAY_TYPE_H +#define DISPLAY_TYPE_H +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 返回值类型定义。 + * + */ +typedef enum { + /** + * 成功 + */ + DISPLAY_SUCCESS = 0, + + /** + * 失败 + */ + DISPLAY_FAILURE = -1, + + /** + * fd错误 + */ + DISPLAY_FD_ERR = -2, + + /** + * 参数错误 + */ + DISPLAY_PARAM_ERR = -3, + + /** + * 空指针 + */ + DISPLAY_NULL_PTR = -4, + + /** + * 不支持的特性 + */ + DISPLAY_NOT_SUPPORT = -5, + + /** + * 内存不足 + */ + DISPLAY_NOMEM = -6, + + /** + * 系统繁忙 + */ + DISPLAY_SYS_BUSY = -7, + + /** + * 操作不允许 + */ + DISPLAY_NOT_PERM = -8 +} DispErrCode; + +/** + * @brief 图层类型定义。 + * + */ +typedef enum { + /** + * 图形层 + */ + LAYER_TYPE_GRAPHIC, + + /** + * 视频层 + */ + LAYER_TYPE_OVERLAY, + + /** + * 媒体播放 + */ + LAYER_TYPE_SDIEBAND, + + /** + * 空图层 + */ + LAYER_TYPE_BUTT +} LayerType; + +/** + * @brief 像素格式类型定义。 + * + */ +typedef enum { + /** + * CLUT8 格式 + */ + PIXEL_FMT_CLUT8 = 0, + + /** + * CLUT1 格式 + */ + PIXEL_FMT_CLUT1, + + /** + * CLUT4 格式 + */ + PIXEL_FMT_CLUT4, + + /** + * RGB565 格式 + */ + PIXEL_FMT_RGB_565, + + /** + * RGBA5658 格式 + */ + PIXEL_FMT_RGBA_5658, + + /** + * RGBX4444 格式 + */ + PIXEL_FMT_RGBX_4444, + + /** + * RGBA4444 格式 + */ + PIXEL_FMT_RGBA_4444, + + /** + * RGB444 格式 + */ + PIXEL_FMT_RGB_444, + + /** + * RGBX5551 格式 + */ + PIXEL_FMT_RGBX_5551, + + /** + * RGBA5551 格式 + */ + PIXEL_FMT_RGBA_5551, + + /** + * RGB555 格式 + */ + PIXEL_FMT_RGB_555, + + /** + * RGBX8888 格式 + */ + PIXEL_FMT_RGBX_8888, + + /** + * RGBA8888 格式 + */ + PIXEL_FMT_RGBA_8888, + + /** + * RGB888 格式 + */ + PIXEL_FMT_RGB_888, + + /** + * BGR565 格式 + */ + PIXEL_FMT_BGR_565, + + /** + * BGRX4444 格式 + */ + PIXEL_FMT_BGRX_4444, + + /** + * BGRA4444 格式 + */ + PIXEL_FMT_BGRA_4444, + + /** + * BGRX5551 格式 + */ + PIXEL_FMT_BGRX_5551, + + /** + * BGRA5551 格式 + */ + PIXEL_FMT_BGRA_5551, + + /** + * BGRX8888 格式 + */ + PIXEL_FMT_BGRX_8888, + + /** + * BGRA8888 格式 + */ + PIXEL_FMT_BGRA_8888, + + /** + * YUV422 交错格式 + */ + PIXEL_FMT_YUV_422_I, + + /** + * YCBCR422 半平面格式 + */ + PIXEL_FMT_YCBCR_422_SP, + + /** + * YCRCB422 半平面格式 + */ + PIXEL_FMT_YCRCB_422_SP, + + /** + * YCBCR420 半平面格式 + */ + PIXEL_FMT_YCBCR_420_SP, + + /** + * YCRCB420 半平面格式 + */ + PIXEL_FMT_YCRCB_420_SP, + + /** + * YCBCR422 平面格式 + */ + PIXEL_FMT_YCBCR_422_P, + + /** + * YCRCB422 平面格式 + */ + PIXEL_FMT_YCRCB_422_P, + + /** + * YCBCR420 平面格式 + */ + PIXEL_FMT_YCBCR_420_P, + + /** + * YCRCB420 平面格式 + */ + PIXEL_FMT_YCRCB_420_P, + + /** + * YUYV422 打包格式 + */ + PIXEL_FMT_YUYV_422_PKG, + + /** + * UYVY422 打包格式 + */ + PIXEL_FMT_UYVY_422_PKG, + + /** + * YVYU422 打包格式 + */ + PIXEL_FMT_YVYU_422_PKG, + + /** + * VYUY422 打包格式 + */ + PIXEL_FMT_VYUY_422_PKG, + + /** + * 无效像素格式 + */ + PIXEL_FMT_BUTT +} PixelFormat; + +/** + * @brief 图层变换类型定义。 + * + */ +typedef enum { + /** + * 不旋转 + */ + ROTATE_NONE = 0, + + /** + * 旋转90度 + */ + ROTATE_90, + + /** + * 旋转180度 + */ + ROTATE_180, + + /** + * 旋转270度 + */ + ROTATE_270, + + /** + * 无效操作 + */ + ROTATE_BUTT +} TransformType; + +/** + * @brief 显示内存类型定义。 + * + * 根据图形系统指定的类型进行分配,包括带cache或者不带cache的内存。 + * + */ +typedef enum { + /** + * 常规内存,不带cache + */ + NORMAL_MEM = 0, + + /** + * 带cache内存 + */ + CACHE_MEM, + + /** + * 共享内存 + */ + SHM_MEM +} MemType; + +/** + * @brief 定义图像的压缩类型。 + * + * 在硬件加速时可指定压缩类型,硬件加速按照指定的压缩类型进行压缩图像。 + * + */ +typedef enum { + /** + * No 混合操作 + */ + BLEND_NONE = 0, + + /** + * CLEAR 混合操作 + */ + BLEND_CLEAR, + + /** + * SRC 混合操作 + */ + BLEND_SRC, + + /** + * SRC_OVER 混合操作 + */ + BLEND_SRCOVER, + + /** + * DST_OVER 混合操作 + */ + BLEND_DSTOVER, + + /** + * SRC_IN 混合操作 + */ + BLEND_SRCIN, + + /** + * DST_IN 混合操作 + */ + BLEND_DSTIN, + + /** + * SRC_OUT 混合操作 + */ + BLEND_SRCOUT, + + /** + * DST_OUT 混合操作 + */ + BLEND_DSTOUT, + + /** + * SRC_ATOP 混合操作 + */ + BLEND_SRCATOP, + + /** + * DST_ATOP 混合操作 + */ + BLEND_DSTATOP, + + /** + * ADD 混合操作 + */ + BLEND_ADD, + + /** + * XOR 混合操作 + */ + BLEND_XOR, + + /** + * DST 混合操作 + */ + BLEND_DST, + + /** + * AKS 混合操作 + */ + BLEND_AKS, + + /** + * AKD 混合操作 + */ + BLEND_AKD, + + /** + * 空操作 + */ + BLEND_BUTT +} BlendType; + +/** + * @brief 硬件加速支持的ROP操作类型。 + * + * 硬件加速支持的ROP操作类型,在将前景位图的RGB颜色分量和Alpha分量值与背景位图的RGB颜色 + * 分量值和Alpha分量值进行按位的布尔运算(包括按位与,按位或等),将结果输出。 + * + */ +typedef enum { + /** + * Blackness + */ + ROP_BLACK = 0, + + /** + *~(S2+S1) + */ + ROP_NOTMERGEPEN, + + /** + * ~S2&S1 + */ + ROP_MASKNOTPEN, + + /** + *~S2 + */ + ROP_NOTCOPYPEN, + + /** + * S2&~S1 + */ + ROP_MASKPENNOT, + + /** + * ~S1 + */ + ROP_NOT, + + /** + * S2^S1 + */ + ROP_XORPEN, + + /** + * ~(S2&S1) + */ + ROP_NOTMASKPEN, + + /** + * S2&S1 + */ + ROP_MASKPEN, + + /** + * ~(S2^S1) + */ + ROP_NOTXORPEN, + + /** + * S1 + */ + ROP_NOP, + + /** + * ~S2+S1 + */ + ROP_MERGENOTPEN, + + /** + * S2 + */ + ROP_COPYPE, + + /** + * S2+~S1 + */ + ROP_MERGEPENNOT, + + /** + * S2+S1 + */ + ROP_MERGEPEN, + + /** + * Whiteness + */ + ROP_WHITE, + + /** + * Invalid ROP type + */ + ROP_BUTT +} RopType; + +/** + * @brief Color key操作类型定义,即硬件加速支持的Color key操作类型。 + * + */ +typedef enum { + /** + * 不使用colorkey + */ + CKEY_NONE = 0, + + /** + * 使用源colorkey + */ + CKEY_SRC, + + /** + * 使用目标colorkey + */ + CKEY_DST, + + /** + * 空操作 + */ + CKEY_BUTT +} ColorKey; + +/** + * @brief 硬件加速支持的镜像操作类型定义 + * + */ +typedef enum { + /** + * 不使用镜像 + */ + MIRROR_NONE = 0, + + /** + * 左右镜像 + */ + MIRROR_LR, + + /** + * 上下镜像 + */ + MIRROR_TB, + + /** + * 空操作 + */ + MIRROR_BUTT +} MirrorType; + +/** + * @brief 热插拔连接类型定义 + * + */ +typedef enum { + /** + * 无效类型 + */ + INVALID = 0, + + /** + * 已连接 + */ + CONNECTED, + + /** + * 断开连接 + */ + DISCONNECTED +} Connection; + +/** + * @brief 定义显示信息结构体 + * + */ +typedef struct { + /** + * 显示屏宽度 + */ + uint32_t width; + + /** + * 显示屏高度 + */ + uint32_t height; + + /** + * 显示屏旋转角度 + */ + int32_t rotAngle; +} DisplayInfo; + +/** + * @brief 定义图层信息结构体 + * + * 在创建图层时,需要将LayerInfo传递给创建图层接口,创建图层接口根据图层信息创建相应图层。 + * + */ +typedef struct { + /** + * 图层宽度 + */ + int32_t width; + + /** + * 图层高度 + */ + int32_t height; + + /** + * 图层类型,包括图形层、视频层和媒体播放模式 + */ + LayerType type; + + /** + * 每像素所占bit数 + */ + int32_t bpp; + + /** + * 图层像素格式 + */ + PixelFormat pixFormat; +} LayerInfo; + +/** + * @brief 定义图层Alpha信息的结构体 + * + */ +typedef struct { + /** + * 全局alpha使能标志 + */ + bool enGlobalAlpha; + + /** + * 像素alpha使能标志 + */ + bool enPixelAlpha; + + /** + * alpha0值,取值范围:[0, 255] + */ + uint8_t alpha0; + + /** + * alpha1值,取值范围:[0, 255] + */ + uint8_t alpha1; + + /** + * 全局alpha值,取值范围:[0, 255] + */ + uint8_t gAlpha; +} LayerAlpha; + +/** + * @brief buffer句柄的定义。 + * + * 包括共享内存键值、共享内存标识、物理内存地址。 + * + */ +typedef struct { + /** + * 共享内存键值 + */ + int32_t key; + + /** + * 共享内存唯一标识 + */ + int32_t shmid; + + /** + * 物理内存地址 + */ + uint64_t phyAddr; +} BufferHandle; + +/** + * @brief 显示内存buffer结构体定义,包括内存物理地址,内存虚拟地址等。 + * + */ +typedef struct { + /** + * buffer句柄 + */ + BufferHandle hdl; + + /** + * 申请的内存类型 + */ + MemType type; + + /** + * 申请的内存大小 + */ + uint32_t size; + + /** + * 申请的内存虚拟地址 + */ + void *virAddr; +} GrallocBuffer; + +/** + * @brief 图层buffer结构体定义,包括虚拟内存地址和物理内存地址。 + * + */ +typedef struct { + /** + * 物理内存地址 + */ + uint64_t phyAddr; + + /** + * 虚拟内存地址 + */ + void *virAddr; +} BufferData; + +/** + * @brief 图层Buffer,用于存放图层数据。 + * + */ +typedef struct { + /** + * buffer 的fence号 + */ + int32_t fenceId; + + /** + * buffer宽度 + */ + int32_t width; + + /** + * buffer高度 + */ + int32_t height; + + /** + * 一行数据所占字节数 + */ + int32_t pitch; + + /** + * buffer像素格式 + */ + PixelFormat pixFormat; + + /** + * 图层buffer数据 + */ + BufferData data; +} LayerBuffer; + +/** + * @brief 定义矩形信息 + * + */ +typedef struct { + /** + * 矩形框起始x坐标 + */ + int32_t x; + + /** + * 矩形框起始y坐标 + */ + int32_t y; + + /** + * 矩形框宽度 + */ + int32_t w; + + /** + * 矩形框高度 + */ + int32_t h; +} IRect; + +/** + * @brief 用于存放窗口相关信息的结构体定义,提供给硬件加速使用,例如图像合成,位图搬移等操作。 + */ +typedef struct { + /** + * 图像首地址 + */ + uint64_t phyAddr; + + /** + * 图像高度 + */ + int32_t height; + + /** + * 图像宽度 + */ + int32_t width; + + /** + * 图像跨度 + */ + int32_t stride; + + /** + * 图像格式 + */ + PixelFormat enColorFmt; + + /** + * CLUT表是否位于 YCbCr 空间 + */ + bool bYCbCrClut; + + /** + * 图像alpha最大值为255还是128 + */ + bool bAlphaMax255; + + /** + * 是否使能1555的Alpha扩展 + */ + bool bAlphaExt1555; + + /** + * Alpha0值,取值范围:[0,255] + */ + uint8_t alpha0; + + /** + * Alpha1值,取值范围:[0,255] + */ + uint8_t alpha1; + + /** + * CbCr分量地址 + */ + uint64_t cbcrPhyAddr; + + /** + * CbCr分量跨度 + */ + int32_t cbcrStride; + + /** + * Clut表首地址,用作颜色扩展或颜色校正 + */ + uint64_t clutPhyAddr; +} ISurface; + +/** + * @brief 线条描述结构体定义,用于硬件加速绘制直线。 + * + */ +typedef struct { + /** + * 线条起点的x坐标 + */ + int32_t x0; + + /** + * 线条起点的y坐标 + */ + int32_t y0; + + /** + * 线条终点的x坐标 + */ + int32_t x1; + + /** + * 线条终点的y坐标 + */ + int32_t y1; + + /** + * 线条颜色 + */ + uint32_t color; +} ILine; + +/** + * @brief 圆形描述结构体定义,用于硬件加速绘制圆形。 + * + */ +typedef struct { + /** + * 圆心x坐标 + */ + int32_t x; + + /** + * 圆心y坐标 + */ + int32_t y; + + /** + * 圆的半径 + */ + int32_t r; + + /** + * 圆的颜色 + */ + uint32_t color; +} ICircle; + +/** + * @brief 矩形描述结构体定义,用于硬件加速绘制矩形, + * + */ +typedef struct { + /** + * 矩形区域 + */ + IRect rect; + + /** + * 矩形颜色 + */ + uint32_t color; +} Rectangle; + +/** + * @brief 图像硬件加速相关的操作选项结构体定义,用于图像硬件加速时的操作选项。 + * + */ +typedef struct { + /** + * 全局alpha使能位 + */ + bool enGlobalAlpha; + + /** + * 全局alpha的值 + */ + uint32_t globalAlpha; + + /** + * 像素alpha使能位 + */ + bool enPixelAlpha; + + /** + * 混合方式 + */ + BlendType blendType; + + /** + * 色键模式 + */ + ColorKey colorKeyFrom; + + /** + * Rop功能使能位 + */ + bool enableRop; + + /** + * 颜色的Rop类型 + */ + RopType colorRopType; + + /** + * Alpha的Rop类型 + */ + RopType alphaRopType; + + /** + * 缩放功能使能位 + */ + bool enableScale; + + /** + * 旋转类型 + */ + TransformType rotateType; + + /** + * 镜像类型 + */ + MirrorType mirrorType; +} GfxOpt; + +#ifdef __cplusplus +} +#endif +#endif +/* @} */ \ No newline at end of file diff --git a/zh-cn/device_api/hdi/display/display_vgu.h b/zh-cn/device_api/hdi/display/display_vgu.h new file mode 100644 index 0000000000000000000000000000000000000000..735c7f414fa9a09e86edba3f40e8bd096e933bf1 --- /dev/null +++ b/zh-cn/device_api/hdi/display/display_vgu.h @@ -0,0 +1,1287 @@ +/* + * Copyright (c) 2022 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 定义显示硬件驱动模块。 + * + * 该驱动函数提供给图形系统使用的驱动接口,包括图层管理、设备控制、图形硬件加速、显示内存管理和回调接口等。 + * + * @since 3.0 + */ + +/* * + * @file display_vgu.h + * + * @brief 该文件定义2D矢量硬件加速模块相关驱动函数。 + * + * @since 3.0 + */ + +#ifndef DISPLAY_VGU_H +#define DISPLAY_VGU_H +#include "display_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#undef HDI_VGU_SCALAR_IS_FLOAT +#define HDI_VGU_SCALAR_IS_FLOAT 1 + +#ifdef HDI_VGU_SCALAR_IS_FLOAT +typedef float VGUScalar; +#else +typedef int32_t VGUScalar; +#endif + +/** +* 像素格式 +*/ +typedef PixelFormat VGUPixelFormat; + +/** +* 混合操作类型 +*/ +typedef BlendType VGUBlendType; + +/* * + * @brief 路径坐标数据类型。 + * + */ +typedef enum { + /** + * 整型(2 bytes) + */ + VGU_DATA_TYPE_S16 = 0, + + /** + * 整型(4 bytes) + */ + VGU_DATA_TYPE_S32, + + /** + * 浮点(4 bytes) + */ + VGU_DATA_TYPE_F32 +} VGUPathDataType; + +/** + * @brief 硬件加速能力。 + * + */ +typedef enum { + /** + * 支持Blit能力 + */ + VGU_CAP_BLIT = (1 << 0), + + /** + * 搬移支持图片叠加最大数目 + */ + VGU_CAP_BLIT_NUM = (1 << 1), + + /** + * 支持路径的fill和stroke能力 + */ + VGU_CAP_PATH = (1 << 2), + + /** + * 支持模糊能力 + */ + VGU_CAP_FILTER_BLUR = (1 << 3), +} VGUCapability; + +/** + * @brief 错误码定义。 + * + */ +typedef enum { + /** + * 成功 + */ + VGU_SUCCESS = 0, + + /** + * 不支持 + */ + VGU_NO_SUPPORT = -1, + + /** + * 操作失败 + */ + VGU_OPERATION_FAILED = -2, + + /** + * 内存溢出 + */ + VGU_OUT_OF_MEMORY = -3, + + /** + * 超时 + */ + VGU_TIMEOUT = -4, + + /** + * 无效参数 + */ + VGU_INVALID_PARAMETER = -5, + + /** + * 设备忙 + */ + VGU_BUSY = -6, + + /** + * 无上下文 + */ + VGU_NO_CONTEXT = -7, +} VGUResult; + +/* * + * @brief 线帽。 + * + */ +typedef enum { + /** + * 线条末端为平直线帽(默认) + */ + VGU_LINECAP_BUTT = 0, + + /** + * 线条末端为圆形线帽 + */ + VGU_LINECAP_ROUND, + + /** + * 线条末端为正方向形线帽 + */ + VGU_LINECAP_SQUARE +} VGULineCap; + +/** + * @brief 联接类型。 + * + */ +typedef enum { + /** + * 尖角(默认) + */ + VGU_LINE_JOIN_MITER = 0, + + /** + * 圆角 + */ + VGU_LINE_JOIN_ROUND, + + /** + * 斜角 + */ + VGU_LINE_JOIN_BEVEL, + + /** + * 无效定义 + */ + VGU_LINE_JOIN_BUTT +} VGUJointType; + +/** + * @brief 坐标点对象。 + * + */ +typedef struct { + /** + * 点水平坐标 + */ + VGUScalar x; + + /** + * 点垂直坐标 + */ + VGUScalar y; +} VGUPoint; + +/** + * @brief 矩形对象。 + * + */ +typedef struct { + /** + * 矩形水平起始坐标 + */ + VGUScalar x; + + /** + * 矩形垂直起始坐标 + */ + VGUScalar y; + + /** + * 矩形宽度 + */ + VGUScalar w; + + /** + * 矩形高度 + */ + VGUScalar h; +} VGURect; + +/** + * @brief 图像滤波类型。 + * + */ +typedef enum { + /** + * 双线性插值(默认) + */ + VGU_FILTER_BILINEAR = 0, + + /** + * 无插值 + */ + VGU_FILTER_NEAREST, + + /** + * 线性插值. + */ + VGU_FILTER_LINEAR, + + /** + * 无效定义 + */ + VGU_FILTER_BUTT +} VGUFilter; + +/** + * @brief 填充规则定义。 + * + */ +typedef enum { + /** + * 非0填充(默认) + */ + VGU_RULE_WINDING = 0, + + /** + * 奇偶填充 + */ + VGU_RULE_EVEN_ODD, + + /** + * 无效定义 + */ + VGU_RULE_BUTT +} VGUFillRule; + +/** + * @brief 渐变填充区域外的延展类型。 + * + */ +typedef enum { + /** + * Pad类型(默认) + */ + VGU_SPREAD_PAD = 0, + + /** + * Reflect类型 + */ + VGU_SPREAD_REFLECT, + + /** + * Repeat类型 + */ + VGU_SPREAD_REPEAT, + + /** + * 无效定义 + */ + VGU_SPREAD_BUTT +} VGUFillSpread; + +/** + * @brief 图像模式填充延展类型。 + * + */ +typedef enum { + /** + * 反射类型 + */ + VGU_WRAP_REFLECT = 0, + + /** + * 重复类型 + */ + VGU_WRAP_REPEAT, + + /** + * 无效定义 + */ + VGU_WRAP_BUTT +} VGUWrapType; + +/** + * @brief 路径绘制指令类型。 + * + */ +typedef enum { + /** + * 线段关闭,坐标数据: none + */ + VGU_PATH_CMD_CLOSE = 0, + + /** + * 移动到指定位置,坐标数据: x0, y0 + */ + VGU_PATH_CMD_MOVE, + + /** + * 线条,坐标数据: x0, y0 + */ + VGU_PATH_CMD_LINE, + + /** + * 水平线,坐标数据: x0 + */ + VGU_PATH_CMD_HLINE, + + /** + * 垂直线,坐标数据: y0 + */ + VGU_PATH_CMD_VLINE, + + /** + * 二次贝塞尔曲线,坐标数据: x0, y0, x1, y1 + */ + VGU_PATH_CMD_QUAD, + + /** + * 三次贝塞尔曲线,坐标数据: x0, y0, x1, y1, x2, y2 + */ + VGU_PATH_CMD_CUBIC, + + /** + * 平滑二次贝塞尔曲线,坐标数据: x1, y1 + */ + VGU_PATH_CMD_SQUAD, + + /** + * 平滑三次贝塞尔曲线,坐标数据: x1, y1, x2, y2 + */ + VGU_PATH_CMD_SCUBIC, + + /** + * 无效定义 + */ + VGU_PATH_CMD_BUTT, +} VGUPathCmd; + +/** + * @brief 路径对象,存放路径命令和坐标数据。 + * + */ +typedef struct { + /** + * 存放路径命令数据 + */ + uint8_t *segment; + + /** + * 路径命令总数 + */ + int32_t numSegments; + + /** + * 存放路径命令对应坐标数据 + */ + uint8_t *data; + + /** + * 路径数据存储类型 + */ + VGUPathDataType type; + + /** + * 抗锯齿开关 + */ + bool enAlias; + + /** + * 路径最大边界 + */ + VGURect boundBox; +} VGUPath; + +/** + * @brief 变换类型。 + * + */ +typedef enum { + /** + * 平移变换 + */ + VGU_TRANSFORM_TRANSLATE = (1 << 0), + + /** + * 缩放变换 + */ + VGU_TRANSFORM_SCALE = (1 << 1), + + /** + * 旋转90度 + */ + VGU_TRANSFORM_ROTATE_90 = (1 << 2), + + /** + * 旋转180度 + */ + VGU_TRANSFORM_ROTATE_180 = (1 << 3), + + /** + * 旋转270度 + */ + VGU_TRANSFORM_ROTATE_270 = (1 << 4), + + /** + * 其他变换 + */ + VGU_TRANSFORM_OTHER = (1 << 16) +} VGUTransformType; + +/** + * @brief 变换矩阵。 + * + */ +typedef struct { + /** + * 3x3变换矩阵 + */ + float m[3][3]; + + /** + * 矩阵变换类型,简单变换为缩放,平移,90度倍数旋转 + */ + uint32_t type; +} VGUMatrix3; + +/** + * @brief 硬件加速渲染位图缓存。 + * + */ +typedef struct { + /** + * 像素格式 + */ + VGUPixelFormat pixelFormat; + + /** + * 位图宽度 + */ + uint32_t width; + + /** + * 位图高度 + */ + uint32_t height; + + /** + * 位图stride + */ + uint32_t stride; + + /** + * 位图缓存的虚拟地址 + */ + void *virAddr; + + /** + * 位图缓存的物理地址 + */ + uint64_t phyAddr; +} VGUBuffer; + +/** + * @brief 绘制表面剪切类型。 + * + */ +typedef enum { + /** + * 矩形剪切(默认) + */ + VGU_CLIP_RECT = 0, + + /** + * 路径剪切 + */ + VGU_CLIP_PATH, + + /** + * 无效定义 + */ + VGU_CLIP_BUTT +} VGUClipType; + +/** + * @brief 定义蒙版图层。 + * + */ +typedef struct { + /** + * 蒙版缓存 + */ + VGUBuffer *buffer; + + /** + * 蒙版矩形 + */ + VGURect *rect; +} VGUMaskLayer; + +/** + * @brief 2D硬件加速绘制目标表面。 + * + */ +typedef struct { + /** + * 位图缓存 + */ + VGUBuffer *buffer; + union { + /** + * 矩形剪切域,如果为空,整个表面直接渲染 + */ + VGURect *clipRect; + + /** + * 路径剪切域,如果为空,整个表面直接渲染 + */ + VGUPath *clipPath; + }; + + /** + * 表面剪切类型 + */ + VGUClipType clipType; + + /** + * 蒙版图层, 可以为空 + */ + VGUMaskLayer *mask; + + /** + * 混合叠加模式 + */ + VGUBlendType blend; + + /** + * 图像滤波类型 + */ + VGUFilter filter; +} VGUSurface; + +/** + * @brief 渐变颜色分布位置。 + * + */ +typedef struct { + /** + * 颜色偏移位置, 值范围是 0.0 ~ 1.0 + */ + float stop; + + /** + * 偏移位置对应颜色 + */ + uint32_t color; +} VGUColorStop; + +/** + * @brief 线性渐变。 + * + */ +typedef struct { + /** + * 线性渐变起点水平坐标 + */ + VGUScalar x1; + + /** + * 线性渐变起点垂直坐标 + */ + VGUScalar y1; + + /** + * 线性渐变终点水平坐标 + */ + VGUScalar x2; + + /** + * 线性渐变终点垂直坐标 + */ + VGUScalar y2; +} VGULinear; + +/** + * @brief 辐射渐变。 + * + */ +typedef struct { + /** + * 内圈圆心水平坐标 + */ + VGUScalar x0; + + /** + * 内圈圆心垂直坐标 + */ + VGUScalar y0; + + /** + * 内圈圆半径 + */ + VGUScalar r0; + + /** + * 外圈圆心水平坐标 + */ + VGUScalar x1; + + /** + * 外圈圆心垂直坐标 + */ + VGUScalar y1; + + /** + * 外圈圆半径 + */ + VGUScalar r1; +} VGURadial; + +/** + * @brief 圆锥渐变。 + * + */ +typedef struct { + /** + * 圆弧中心x坐标 + */ + VGUScalar cx; + + /** + * 圆弧中心y坐标 + */ + VGUScalar cy; +} VGUConic; + +/** + * @brief 图像对象。 + * + */ +typedef struct { + /** + * 图像存储缓存 + */ + VGUBuffer *buffer; + + /** + * 图像矩阵变换,该参数为空,则内部使用单位变换矩阵 + */ + VGUMatrix3 *matrix; + + /** + * 图像截取矩形,该参数为空,则截取整个图像 + */ + VGURect *rect; + + /** + * 透明度,范围0~255 + */ + uint8_t opacity; +} VGUImage; + +/** + * @brief 图片模式对象。 + * + */ +typedef struct { + /** + * 图像对象 + */ + VGUImage *image; + + /** + * 图像水平方向平铺类型 + */ + VGUWrapType wrapx; + + /** + * 图像垂直方向平铺类型 + */ + VGUWrapType wrapy; +} VGUPattern; + +/** + * @brief 渐变类型。 + * + */ +typedef enum { + /** + * 线性渐变 + */ + VGU_GRADIENT_LINEAR = 0, + + /** + * 辐射渐变 + */ + VGU_GRADIENT_RADIAL, + + /** + * 圆锥渐变 + */ + VGU_GRADIENT_CONIC, + + /** + * 无效定义 + */ + VGU_GRADIENT_BUTT +} VGUGradientType; + +/** + * @brief 渐变对象。 + * + */ +typedef struct { + /** + * 针对渐变对象的变换矩阵 + */ + VGUMatrix3 *matrix; + + /** + * 渐变停止颜色数组指针 + */ + VGUColorStop *colorStops; + + /** + * 渐变停止颜色个数 + */ + uint16_t stopCount; + union { + /** + * 线性渐变对象 + */ + VGULinear linear; + + /** + * 辐射渐变对象 + */ + VGURadial radial; + + /** + * 圆锥渐变对象 + */ + VGUConic conic; + }; + /** + * 渐变类型 + */ + VGUGradientType type; + + /** + * 渐变延伸模式 + */ + VGUFillSpread spread; + + /** + * 透明度,范围0~255 + */ + uint8_t opacity; +} VGUGradient; + +/** + * @brief 颜色对象 + * + */ +typedef struct { + /** + * 颜色值 + */ + uint32_t color; + + /** + * 透明度. 值范围 0 ~ 255. + */ + uint8_t opacity; +} VGUSolid; + +/** + * @brief 渲染对象 + * + */ +typedef enum { + /** + * 填充颜色 + */ + VGU_PAINT_SOLID = 0, + + /** + * 渲染渐变对象 + */ + VGU_PAINT_GRADIENT, + + /** + * 渲染图片模式 + */ + VGU_PAINT_PATTERN, + + /** + * 无效操作 + */ + VGU_PAINT_BUTT +} VGUPaintType; + +/** + * @brief 填充或描边路径的渲染风格。 + * + */ +typedef struct { + union { + /** + * 渐变对象 + */ + VGUGradient *gradient; + + /** + * 图片模式对象 + */ + VGUPattern *pattern; + + /** + * 颜色对象 + */ + VGUSolid *solid; + }; + /** + * 渲染类型 + */ + VGUPaintType type; +} VGUPaintStyle; + +/** + * @brief 填充路径的属性。 + * + */ +typedef struct { + /** + * 填充规格 + */ + VGUFillRule rule; +} VGUFillAttr; + +/** + * @brief 描边路径的属性。 + * + */ +typedef struct { + /** + * 线帽类型 + */ + VGULineCap cap; + + /** + * 联结类型 + */ + VGUJointType join; + + /** + * 最大斜切长度 + */ + float miterLimit; + + /** + * 线宽 + */ + float width; +} VGUStrokeAttr; + +/** + * @brief 定义2D硬件加速驱动函数。 + */ +typedef struct { + /** + * @brief 初始化硬件加速。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @see DeinitVgu + * @since 3.0 + */ + VGUResult (*InitVgu)(void); + + /** + * @brief 去初始化硬件加速。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @see InitVgu + * @since 3.0 + */ + VGUResult (*DeinitVgu)(void); + + /** + * @brief 查询硬件能力集。 + * + * @param cap 待查询能力。该参数类型定义参考 VGUCapability。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ + int32_t (*QueryCapability)(uint32_t cap); + + /** + * @brief 使用指定的渲染对象来填充路径。 + * + * @param target 渲染目标表面。 + * @param path 路径对象。 + * @param matrix 变换矩阵对象. 如果该参数为空,默认为单位矩阵。 + * @param attr 填充属性。 + * @param style 绘制对象。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ + VGUResult (*RenderFill)(VGUSurface *target, const VGUPath *path, const VGUMatrix3 *matrix, const VGUFillAttr *attr, + const VGUPaintStyle *style); + + /** + * @brief 使用指定的渲染对象来描边路径。 + * + * @param target 渲染目标表面。 + * @param path 路径对象。 + * @param matrix 变换矩阵对象. 如果该参数为空,默认为单位矩阵。 + * @param attr 描边属性。 + * @param style 绘制对象。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ + VGUResult (*RenderStroke)(VGUSurface *target, const VGUPath *path, const VGUMatrix3 *matrix, + const VGUStrokeAttr *attr, const VGUPaintStyle *style); + + /** + * @brief 对目标表面进行模糊处理。 + * + * @param target 渲染目标表面。 + * @param blur 模糊半径。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ + VGUResult (*RenderBlur)(VGUSurface *target, uint16_t blur); + + /** + * @brief 对图像进行搬移操作。 + * + * 搬移过程中同时进行颜色空间转换,矩阵变换操作。 + * + * @param target 渲染目标表面。 + * @param src 待叠加源图像。 + * @param color 参与混合的颜色值。如果颜色值为0,则不参与混合操作 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ + VGUResult (*RenderBlit)(VGUSurface *target, const VGUImage *src, uint32_t color); + + /** + * @brief 对多个源图像进行叠加操作。 + * + * 搬移过程中同时进行颜色空间转换,矩阵变换操作。该接口支持多个源图形同时叠加到目标表面,\n + * 对于硬件支持源图像数目可以通过QueryCapability接口查询 + * + * @param target 渲染目标表面。 + * @param src 待叠加源图像数组。 + * @param count 待叠加源图像个数。 + * @param color 参与混合的颜色值。如果颜色值为0,则不参与混合操作 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ + VGUResult (*RenderBlitN)(VGUSurface *target, const VGUImage *src, uint16_t count, uint32_t color); + + /** + * @brief 对指定矩形进行颜色清除操作。 + * + * @param target 渲染目标表面。 + * @param rect 待填充矩形大小,如果该参数为空,则整个表面清除。 + * @param color 填充颜色。 + * @param opacity 填充透明度。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ + VGUResult (*RenderClearRect)(VGUSurface *target, const VGURect *rect, uint32_t color, uint8_t opacity); + + /** + * @brief 取消硬件加速渲染。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ + VGUResult (*RenderCancel)(); + + /** + * @brief 同步硬件加速模块绘制或搬移操作。 + * + * 该函数将阻塞等待硬件绘制完成后继续运行。 + * + * @param timeOut 该参数表示硬件加速同步等待超时时间。 值为0表示没有等待时间。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ + VGUResult (*RenderSync)(int32_t timeOut); +} VGUFuncs; + +/** + * @brief 初始化路径对象。 + * + * @param path 路径对象。 + * @param type 存储路径的数据类型。 + * @param segments 路径的命令缓存。 + * @param numSegments 路径命令总数。 + * @param data 路径命令对应的坐标缓存。 + * @param enAlias 使能抗锯齿。 + * @param boundBox 路径的边界范围。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUPathInit(VGUPath *path, VGUPathDataType type, const uint8_t *segments, int numSegments, + const uint8_t *data, bool enAlias, VGURect boundBox); + +/** + * @brief 添加子路径到当前路径中。 + * + * @param path 路径对象。 + * @param subpath 存放子路径对象 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUPathAppend(VGUPath *path, const VGUPath *subpath); + +/** + * @brief 清除路径对象内存。 + * + * @param path 路径对象。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUPathClear(VGUPath *path); + +/** + * @brief 初始化矩阵对象为单位矩阵。 + * + * @param matrix 变换矩阵对象。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUMatrixIdentity(VGUMatrix3 *matrix); + +/** + * @brief 矩阵变换缩放。 + * + * @param matrix 变换矩阵对象。 + * @param xScale 水平方向缩放倍数。 + * @param yScale 垂直方向缩放倍数。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUMatrixScale(VGUMatrix3 *matrix, float xScale, float yScale); + +/** + * @brief 矩阵变换旋转。 + * + * @param matrix 变换矩阵对象。 + * @param degree 旋转度数。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUMatrixRotate(VGUMatrix3 *matrix, float degree); + +/** + * @brief 矩阵变换平移。 + * + * @param matrix 变换矩阵对象。 + * @param x 水平方向位置。 + * @param y 垂直方向位置。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUMatrixTranslate(VGUMatrix3 *matrix, float x, float y); + +/** + * @brief 对渐变添加ColorStop。 + * + * @param gradient 渐变对象。 + * @param colorStop ColorStop数组指针。 + * @param count colorStops总数。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUGradientColorStop(VGUGradient *gradient, const VGUColorStop *colorStop, uint32_t count); + +/** + * @brief 清除ColorStop。 + * + * @param gradient 渐变对象。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUGradientClearStop(VGUGradient *gradient); + +/** + * @brief 设置渐变对象的变换矩阵。 + * + * @param gradient 渐变对象。 + * @param matrix 渐变对象变换矩阵。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUGradientMatrix(VGUGradient *gradient, const VGUMatrix3 *matrix); + +/** + * @brief 创建线性渐变对象。 + * + * @param gradient 渐变对象。 + * @param p1 起点坐标。 + * @param p2 终点坐标。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUGradientLinear(VGUGradient *gradient, const VGUPoint *p1, const VGUPoint *p2); + +/** + * @brief 创建辐射渐变对象 + * + * @param gradient 渐变对象。 + * @param p1 内圆圆心坐标。 + * @param r1 内圆半径。 + * @param p2 外圆圆心坐标。 + * @param r2 外圆半径。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUGradientRadial(VGUGradient *gradient, const VGUPoint *p1, VGUScalar r1, const VGUPoint *p2, VGUScalar r2); + +/** + * @brief 创建圆锥渐变对象。 + * + * @param gradient 渐变对象。 + * @param cx 渐变中心水平坐标。 + * @param cy 渐变中心垂直坐标。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUGradientConic(VGUGradient *gradient, VGUScalar cx, VGUScalar cy); + +/** + * @brief 获取硬件加速相关的操作接口指针。 + * + * @param funcs 硬件加速模块操作接口指针,调用者不需要分配内存,调用者获取该指针操作硬件加速。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUInitialize(VGUFuncs **funcs); + +/** + * @brief 去初始化硬件加速模块,同时释放硬件加速模块操作函数指针。 + * + * @param funcs 硬件加速操作接口指针。 + * + * @return Returns VGU_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link VGUResult}。 + * + * @since 3.0 + */ +VGUResult VGUUninitialize(VGUFuncs *funcs); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/zh-cn/device_api/hdi/input/input_controller.h b/zh-cn/device_api/hdi/input/input_controller.h new file mode 100644 index 0000000000000000000000000000000000000000..e3dab93a8f45bc9be45e719f0c7f6d86841962a8 --- /dev/null +++ b/zh-cn/device_api/hdi/input/input_controller.h @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2022 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 Input + * @{ + * + * @brief Input模块驱动接口声明。 + * + * 本模块为Input服务提供相关驱动接口,包括input设备的打开和关闭、input事件获取、设备信息查询、回调函数注册、特性状态控制等接口。 + * + * @since 1.0 + */ + +/** + * @file input_controller.h + * + * @brief 描述input设备业务控制相关的接口声明。 + * + * @since 1.0 + * @version 1.0 + */ + +#ifndef INPUT_CONTROLLER_H +#define INPUT_CONTROLLER_H + +#include "input_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 提供input设备业务控制相关的接口。 + * + * 此类接口包含电源状态的设置、特性的使能、器件信息的获取,以及产线相关的测试功能接口。 + */ +typedef struct { + /** + * @brief 设置电源状态 + * + * 在系统休眠或者唤醒时,input服务或电源管理模块设置电源状态,以使驱动IC能正常进入对应的休眠模式。 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * @param status 设置的电源状态,input服务控制input设备进入resume或者suspend等状态{@link PowerStatus} + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetPowerStatus)(uint32_t devIndex, uint32_t status); + + /** + * @brief 获取电源状态 + * + * 在系统休眠或者唤醒时,input服务或电源管理模块获取电源状态,以便驱动IC能正常进入对应的休眠模式。 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * @param status 获取的对应设备索引的电源状态 {具体参考 @link PowerStatus} + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetPowerStatus)(uint32_t devIndex, uint32_t *status); + + /** + * @brief 获取devIndex对应的input设备的类型 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * @param deviceType 获取的对应设备索引的设备类型 {具体参考 @link InputDevType} + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetDeviceType)(uint32_t devIndex, uint32_t *deviceType); + + /** + * @brief 获取器件对应的编码信息 + * + * 一款产品通常会有多家模组和Driver IC,上层应用如果关注具体器件型号,则通过此接口来获取。 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * @param chipInfo 获取的对应设备索引的器件编码信息 + * @param length 保存器件芯片信息的内存长度 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 * @version 1.0 + */ + int32_t (*GetChipInfo)(uint32_t devIndex, char *chipInfo, uint32_t length); + + /** + * @brief 获取devIndex对应的模组厂商名 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * @param vendorName 获取的对应设备索引的模组厂商名 + * @param length 保存模组厂商名的内存长度 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetVendorName)(uint32_t devIndex, char *vendorName, uint32_t length); + + /** + * @brief 获取devIndex对应的驱动芯片名 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * @param chipName 获取的对应设备索引的驱动芯片名 + * @param length 保存驱动芯片名的内存长度 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetChipName)(uint32_t devIndex, char *chipName, uint32_t length); + + /** + * @brief 设置手势模式 + * + * 上层应用开关手势模式,即设置手势模式的对应使能bit + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * @param gestureMode 手势模式的开关状态 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*SetGestureMode)(uint32_t devIndex, uint32_t gestureMode); + + /** + * @brief 执行容值自检测试 + * + * 启动不同检测场景下的容值自检测试,并获取测试结果,容值自检项由器件厂商自定义, + * 一般包括RawData测试、 * 短路检测、开路检测、干扰检测、行列差检测等测试项。 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * @param testType 容值测试的测试类型 {具体参考@link CapacitanceTest} + * @param result 容值测试的结果,成功则输出“SUCC”,失败则返回对应的错误提示 + * @param length 保存容值测试结果的内存长度 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*RunCapacitanceTest)(uint32_t devIndex, uint32_t testType, char *result, uint32_t length); + + /** + * @brief 执行拓展指令 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * @param cmd 拓展指令数据包,包括指令编码及参数 {具体参考@link InputExtraCmd} + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*RunExtraCommand)(uint32_t devIndex, InputExtraCmd *cmd); +} InputController; + +#ifdef __cplusplus +} +#endif +#endif +/** @} */ \ No newline at end of file diff --git a/zh-cn/device_api/hdi/input/input_manager.h b/zh-cn/device_api/hdi/input/input_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..6370a6583d3b3ba374b87e385af0159181a7cc9e --- /dev/null +++ b/zh-cn/device_api/hdi/input/input_manager.h @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2022 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 Input + * @{ + * + * @brief Input模块驱动接口声明。 + * + * 本模块为Input服务提供相关驱动接口,包括input设备的打开和关闭、input事件获取、设备信息查询、回调函数注册、特性状态控制等接口。 + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file input_manager.h + * + * @brief 描述input设备管理相关的接口声明。 + * + * @since 1.0 + * @version 1.0 + */ + +#ifndef INPUT_MANAGER_H +#define INPUT_MANAGER_H + +#include "input_controller.h" +#include "input_reporter.h" +#include "input_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 提供input设备管理相关的接口。 + * + * 此类接口包含input设备的扫描、打开和关闭、特定设备信息查询,以及所有设备列表信息获取等接口。 + */ +typedef struct { + /** + * @brief input服务用于扫描所有在线设备。 + * + * @param staArr 存放Input设备扫描信息的数组,信息包含设备索引以及设备类型。 + * @param arrLen staArr数组的长度信息。 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * + * @since 1.0 + */ + int32_t (*ScanInputDevice)(DevDesc *staArr, uint32_t arrLen); + + /** + * @brief input服务打开对应设备的设备文件 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备。 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*OpenInputDevice)(uint32_t devIndex); + + /** + * @brief input服务关闭对应设备的设备文件 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*CloseInputDevice)(uint32_t devIndex); + + /** + * @brief input服务获取对应ID的设备信息 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * @param devInfo 即devIndex对应的设备的设备信息{具体参考 @link DeviceInfo} + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetInputDevice)(uint32_t devIndex, DeviceInfo **devInfo); + + /** + * @brief input服务获取所有input设备列表的设备信息 + * + * @param devNum 当前已经注册过的所有input设备的总数 + * @param devInfo input设备列表所对应的设备信息{具体参考 @link DeviceInfo} + * @param size 即指定deviceList数组对应的元素个数 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*GetInputDeviceList)(uint32_t *devNum, DeviceInfo **devList, uint32_t size); +} InputManager; + +/** + * @brief Defines interfaces for providing driver capabilities of input devices. + */ +typedef struct { + InputManager *iInputManager; /**< input设备的设备管理接口 */ + InputController *iInputController; /**< input设备的业务控制接口 */ + InputReporter *iInputReporter; /**< input设备的数据上报接口 */ +} IInputInterface; + +/** + * @brief input服务通过调用此接口获取操作input设备的所有接口。 + * + * @param interface 对input设备进行接口操作的指针,通常在input服务启动后,通过调用此函数获取input设备操作接口 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ +int32_t GetInputInterface(IInputInterface **interface); + +/** + * @brief input服务通过调用此接口释放操作input设备的所有接口。 + * + * @param inputInterface 对input设备进行接口操作的指针 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ +int32_t ReleaseInputInterface(IInputInterface *inputInterface) + +#ifdef __cplusplus +} +#endif +#endif +/** @} */ \ No newline at end of file diff --git a/zh-cn/device_api/hdi/input/input_reporter.h b/zh-cn/device_api/hdi/input/input_reporter.h new file mode 100644 index 0000000000000000000000000000000000000000..07b6a316005b6dbb71a4e4e6c2f1f8f6e5d82c29 --- /dev/null +++ b/zh-cn/device_api/hdi/input/input_reporter.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2022 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 Input + * @{ + * + * @brief Input模块驱动接口声明。 + * + * 本模块为Input服务提供相关驱动接口,包括input设备的打开和关闭、input事件获取、设备信息查询、回调函数注册、特性状态控制等接口。 + * + * @since 1.0 + * @version 1.0 + */ + +/** + * @file input_reporter.h + * + * @brief 描述input设备数据上报相关的接口声明。 + * + * @since 1.0 + * @version 1.0 + */ + +#ifndef INPUT_REPORTER_H +#define INPUT_REPORTER_H + +#include "input_type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 提供input设备数据上报相关的接口。 + * + * 此类接口包含input设备的数据上报回调函数的注册和注销。 + */ +typedef struct { + /** + * @brief 注册对应设备的回调函数 + * + * input服务通过此接口注册数据回调函数到hdi中,hdi通过此回调函数上报input事件 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * @param callback 回调函数的函数指针 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*RegisterReportCallback)(uint32_t devIndex, InputReportEventCb *callback); + + /** + * @brief 注销对应设备的回调函数 + * + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*UnregisterReportCallback)(uint32_t devIndex); + + /** + * @brief 注册Input设备的热插拔回调函数 + * + * input服务通过此接口注册回调函数到hdi中,所有Input设备由此函数进行热插拔事件上报 + * + * @param callback 回调函数的函数指针 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*RegisterHotPlugCallback)(InputReportEventCb *callback); + + /** + * @brief 注销Input设备的热插拔回调函数 + * + * @param 无 + * + * @return Returns INPUT_SUCCESS 表示执行成功。 + * @return Returns 其他值表示执行失败,具体错误码查看{@link RetSatus}。 + * + * @since 1.0 + * @version 1.0 + */ + int32_t (*UnregisterHotPlugCallback)(void); +} InputReporter; + +#ifdef __cplusplus +} +#endif +#endif +/** @} */ \ No newline at end of file diff --git a/zh-cn/device_api/hdi/input/input_type.h b/zh-cn/device_api/hdi/input/input_type.h new file mode 100644 index 0000000000000000000000000000000000000000..6f4a5ab4c525afafe0f56dff54e2359cf428bc8e --- /dev/null +++ b/zh-cn/device_api/hdi/input/input_type.h @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2022 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 Input + * @{ + * + * @brief Input模块驱动接口声明。 + * + * 本模块为Input服务提供相关驱动接口,包括input设备的打开和关闭、input事件获取、设备信息查询、回调函数注册、特性状态控制等接口。 + * + * @since 1.0 + * @version 1.0 + */ + + /** + * @file input_type.h + * + * @brief input设备相关的类型定义,定义了input设备驱动接口所使用的结构体及枚举类型。 + * + * @since 1.0 + * @version 1.0 + */ + +#ifndef INPUT_TYPES_H +#define INPUT_TYPES_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_INPUT_DEV_NUM 32 +#define MAX_NODE_PATH_LEN 64 +#define CHIP_INFO_LEN 10 +#define CHIP_NAME_LEN 10 +#define VENDOR_NAME_LEN 10 +#define SELF_TEST_RESULT_LEN 20 + +/** + * @brief 定义返回值类型 + */ +enum RetStatus { + /** + * 成功。 + */ + INPUT_SUCCESS = 0, + + /** + * 失败。 + */ + INPUT_FAILURE = -1, + + /** + * 无效参数。 + */ + INPUT_INVALID_PARAM = -2, + + /** + * 内存不足。 + */ + INPUT_NOMEM = -3, + + /** + * 空指针。 + */ + INPUT_NULL_PTR = -4, + + /** + * 执行超时。 + */ + INPUT_TIMEOUT = -5, + + /** + * 特性不支持。 + */ + INPUT_UNSUPPORTED = -6, +}; + +/** + * @brief 定义input设备类型 + */ +enum InputDevType { + /** + * 触摸屏。 + */ + INDEV_TYPE_TOUCH, + + /** + * 物理按键。 + */ + INDEV_TYPE_KEY, + + /** + * 键盘。 + */ + INDEV_TYPE_KEYBOARD, + + /** + * 鼠标。 + */ + INDEV_TYPE_MOUSE, + + /** + * 虚拟按键。 + */ + INDEV_TYPE_BUTTON, + + /** + * 表冠。 + */ + INDEV_TYPE_CROWN, + + /** + * 自定义编码的特定功能或者事件。 + */ + INDEV_TYPE_ENCODER, + + /** + * 未知输入设备类型。 + */ + INDEV_TYPE_UNKNOWN, +}; + +/** + * @brief 定义电源状态 + */ +enum PowerStatus { + /** + * 正常唤醒。 + */ + INPUT_RESUME, + + /** + * 休眠下电模式。 + */ + INPUT_SUSPEND, + + /** + * 休眠低功耗模式。 + */ + INPUT_LOW_POWER, + + /** + * 未知电源状态。 + */ + INPUT_POWER_STATUS_UNKNOWN, +}; + +/** + * @brief 定义容值测试类型 + */ +enum CapacitanceTest { + /** + * 基础容值测试 + */ + BASE_TEST, + + /** + * 全量容值自检测试 + */ + FULL_TEST, + + /** + * MMI容值测试 + */ + MMI_TEST, + + /** + * 老化容值测试 + */ + RUNNING_TEST, + + /** + * 未知的测试类型 + */ + TEST_TYPE_UNKNOWN, +}; + +/** + * @brief input事件数据包结构 + */ +typedef struct { + /** + * 输入事件的属性 + */ + uint32_t type; + + /** + * 输入事件的特定编码项 + */ + uint32_t code; + + /** + * 输入事件编码项对应的值 + */ + int32_t value; + + /** + * 输入事件对应的时间戳 + */ + uint64_t timestamp; +} EventPackage; + +/** + * @brief 此结构体定义了输入事件回调函数并提供给input服务使用 + */ +typedef struct { + /** + * @brief 输入事件数据上报的回调函数 + * + * @param eventData 驱动上报的input事件数据 + * @param count Input事件数据包的个数 + * @param devIndex Input设备索引,用于标志多个input设备,取值从0开始,最多支持32个设备 + * + * @since 1.0 + * @version 1.0 + */ + void (*ReportEventPkgCallback)(const EventPackage **pkgs, uint32_t count, uint32_t devIndex); + + /** + * @brief 热插拔事件上报的回调函数 + * + * @param event 上报的热插拔事件数据 + * + * @since 1.0 + * @version 1.0 + */ + void (*ReportHotPlugEventCallback)(const HotPlugEvent* event); +} InputReportEventCb; + +/** + * @brief input设备基础设备信息 + */ +typedef struct { + /** + * 设备索引 + */ + uint32_t devIndex; + + /** + * 设备对应的文件描述符 + */ + int32_t fd; + + /** + * 设备对应的服务 + */ + void *service; + + /** + * 设备对应的事件监听器 + */ + void *listener; + + /** + * 设备类型 + */ + uint32_t devType; + + /** + * 电源状态 + */ + uint32_t powerStatus; + + /** + * 驱动芯片编码信息 + */ + char chipInfo[CHIP_INFO_LEN]; + + /** + * 模组厂商名 + */ + char vendorName[VENDOR_NAME_LEN]; + + /** + * 驱动芯片型号 + */ + char chipName[CHIP_NAME_LEN]; + + /** + * 设备文件路径 + */ + char devNodePath[MAX_NODE_PATH_LEN]; + + /** + * x方向分辨率 + */ + uint32_t solutionX; + + /** + * y方向分辨率 + */ + uint32_t solutionY; + + /** + * 数据上报回调函数 {@link InputReportEventCb} + */ + InputReportEventCb *callback; +} DeviceInfo; + +/** + * @brief 扩展指令的数据结构 + */ +typedef struct { + /** + * 指令对应的编码 + */ + const char *cmdCode; + + /** + * 指令传输的数据 + */ + const char *cmdValue; +} InputExtraCmd; + +#ifdef __cplusplus +} +#endif +#endif +/** @} */