diff --git a/activity_recognition/bundle.json b/activity_recognition/bundle.json index 8ce7dcb6877cfee4662ab26a3c6222b2426247d2..1acb673ac996703a331a7ec1c2a5a8328c769131 100644 --- a/activity_recognition/bundle.json +++ b/activity_recognition/bundle.json @@ -12,7 +12,7 @@ "component": { "name": "drivers_interface_act_recg", "subsystem": "hdf", - "adapted_system_type": ["standard"], + "adapted_system_type": ["small", "standard"], "rom": "150KB", "ram": "200KB", "deps": { diff --git a/activity_recognition/v1_0/BUILD.gn b/activity_recognition/v1_0/BUILD.gn index 224e521c503c4e3ca1ffa350f434539ae2877b05..bf076fbf7ca7949bc4874480f730e4aeb8ef0f6e 100644 --- a/activity_recognition/v1_0/BUILD.gn +++ b/activity_recognition/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("ar") { module_name = "ar_service" diff --git a/audio/bundle.json b/audio/bundle.json index 628cd2e92be04e438d04b1ecbf52009d6859c152..6dd6f4e7fed9dca7c290049a549202562753665a 100644 --- a/audio/bundle.json +++ b/audio/bundle.json @@ -12,7 +12,10 @@ "component": { "name": "drivers_interface_audio", "subsystem": "hdf", - "adapted_system_type": ["standard"], + "adapted_system_type": [ + "small", + "standard" + ], "rom": "675KB", "ram": "1024KB", "deps": { diff --git a/audio/effect/v1_0/BUILD.gn b/audio/effect/v1_0/BUILD.gn index 7c9f1a81a278856ef2e5cea42a0f3e5279a1ac55..d6d244d57123440331e5e8f059b40737f7139579 100644 --- a/audio/effect/v1_0/BUILD.gn +++ b/audio/effect/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("../../../../hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") if (defined(ohos_lite)) { group("libeffect_proxy_1.0") { @@ -27,6 +27,8 @@ if (defined(ohos_lite)) { "IEffectModel.idl", ] + branch_protector_ret = "pac_ret" + language = "c" subsystem_name = "hdf" part_name = "drivers_interface_audio" diff --git a/audio/v1_0/AudioTypes.idl b/audio/v1_0/AudioTypes.idl index 636678790a58936d3752b1a53ca98d345a9e8d9b..fa171d32a665dc76c2e8bb94b87a63aa83607e69 100644 --- a/audio/v1_0/AudioTypes.idl +++ b/audio/v1_0/AudioTypes.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v1_0/IAudioAdapter.idl b/audio/v1_0/IAudioAdapter.idl index 5ad64a6be273da59b9aeeddc7f31cb0db83bf821..cbc3bcf1ba1150104277a002a739973220605126 100644 --- a/audio/v1_0/IAudioAdapter.idl +++ b/audio/v1_0/IAudioAdapter.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v1_0/IAudioCallback.idl b/audio/v1_0/IAudioCallback.idl index c9a260f0e8fb81bc7867c0aec8cbdb432509d18c..d030c2e10a412e73ce3dcdd225e5b088133098eb 100644 --- a/audio/v1_0/IAudioCallback.idl +++ b/audio/v1_0/IAudioCallback.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v1_0/IAudioCapture.idl b/audio/v1_0/IAudioCapture.idl index 8a0b5c223be2d992c12ead4e6c1e6425051d8e0c..0f44786209baaaa6db6d7e47f8c25a309da1e558 100644 --- a/audio/v1_0/IAudioCapture.idl +++ b/audio/v1_0/IAudioCapture.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v1_0/IAudioManager.idl b/audio/v1_0/IAudioManager.idl index 069af9f0f940b1c34c5247ac1e8fde92bcb554c7..8ea83c8fcee79f53bade7b4f889fa8a32ebf5032 100644 --- a/audio/v1_0/IAudioManager.idl +++ b/audio/v1_0/IAudioManager.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v1_0/IAudioRender.idl b/audio/v1_0/IAudioRender.idl index 52b1c9cece9b5f44abd9debcf21bf2b9bcaab4b2..edb991e391635063ba491e95d58152afbacd2540 100644 --- a/audio/v1_0/IAudioRender.idl +++ b/audio/v1_0/IAudioRender.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v2_0/AudioTypes.idl b/audio/v2_0/AudioTypes.idl index 04614cb8122069a48abdb792ee65043a54c449ef..befdc31ecbb51218811857cd0bf7cd4a4c47aea3 100644 --- a/audio/v2_0/AudioTypes.idl +++ b/audio/v2_0/AudioTypes.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * @@ -366,7 +365,7 @@ enum AudioInputType { */ struct AudioOffloadInfo { - unsigned int sampleRate; /**< Audio sampling rate */ + unsigned int sampleRate; /**< Audio sampling rate */ unsigned int channelCount; /**< Number of audio channels */ unsigned long channelLayout; /**< Audio channel layout */ unsigned int bitRate; /**< bitRate of compressed audio data */ diff --git a/audio/v2_0/IAudioAdapter.idl b/audio/v2_0/IAudioAdapter.idl index 218e50b44937d7bf27453041293efc4d3f3299dd..2db00c46c0305a06d4f6703b8b1ca08e75e7a441 100644 --- a/audio/v2_0/IAudioAdapter.idl +++ b/audio/v2_0/IAudioAdapter.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v2_0/IAudioCallback.idl b/audio/v2_0/IAudioCallback.idl index 10e4c400790b56a2bd28818d354ffff5d7bc57a4..7b88c890c50c7c1c01c943648b97884ec8c1172d 100644 --- a/audio/v2_0/IAudioCallback.idl +++ b/audio/v2_0/IAudioCallback.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v2_0/IAudioCapture.idl b/audio/v2_0/IAudioCapture.idl index 4e1832e62b5d00448327900ca0169f92f324fc7d..1e13e1d33c17dac4a53a9b784708650f6f7c0b59 100644 --- a/audio/v2_0/IAudioCapture.idl +++ b/audio/v2_0/IAudioCapture.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v2_0/IAudioManager.idl b/audio/v2_0/IAudioManager.idl index f64bf01a4739023903f5b3c891a8f472f99c6626..85ada7fe325cc9c77fa3813f17b67a092ea84a67 100644 --- a/audio/v2_0/IAudioManager.idl +++ b/audio/v2_0/IAudioManager.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v2_0/IAudioRender.idl b/audio/v2_0/IAudioRender.idl index 92ef5f1274ffe9580611c769d71d74a25ae0a54f..588a1fce99d1caf2d1372a69529e5da611b73830 100644 --- a/audio/v2_0/IAudioRender.idl +++ b/audio/v2_0/IAudioRender.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v3_0/AudioTypes.idl b/audio/v3_0/AudioTypes.idl index e99b95f210eb233fe41ca331fb9ce144fca03c9a..df539133cff057bead6ab901caea4b96c22c7d12 100644 --- a/audio/v3_0/AudioTypes.idl +++ b/audio/v3_0/AudioTypes.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v3_0/BUILD.gn b/audio/v3_0/BUILD.gn index e7f3a018963e6a63d00429ed79c79d33e3962403..baaf34b82b4111be034576d1c549a08a588d02b7 100644 --- a/audio/v3_0/BUILD.gn +++ b/audio/v3_0/BUILD.gn @@ -31,6 +31,8 @@ if (defined(ohos_lite)) { "IAudioRender.idl", ] + branch_protector_ret = "pac_ret" + language = "c" subsystem_name = "hdf" part_name = "drivers_interface_audio" diff --git a/audio/v3_0/IAudioAdapter.idl b/audio/v3_0/IAudioAdapter.idl index c37a455b011b58d080e4b63bc0203f4fe387a2ec..85f5b75f74eb54afb42e43e466a12662388e64ef 100644 --- a/audio/v3_0/IAudioAdapter.idl +++ b/audio/v3_0/IAudioAdapter.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v3_0/IAudioCallback.idl b/audio/v3_0/IAudioCallback.idl index 7d8135c789314476ae972d7547f3779530e6d34f..bae07091ce3583a6c708d8f773ec12c54990ce76 100644 --- a/audio/v3_0/IAudioCallback.idl +++ b/audio/v3_0/IAudioCallback.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v3_0/IAudioCapture.idl b/audio/v3_0/IAudioCapture.idl index 0f6ec51dca99382f6f93175f883e8dd929b52347..c03477327aaf5a748cbed2797e0103bbe4176663 100644 --- a/audio/v3_0/IAudioCapture.idl +++ b/audio/v3_0/IAudioCapture.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v3_0/IAudioManager.idl b/audio/v3_0/IAudioManager.idl index 462a7b65e1aa59b52aaedf59c38e23abc5a6cdc5..a954c9f2428d976bd66bfab093184f08900fed38 100644 --- a/audio/v3_0/IAudioManager.idl +++ b/audio/v3_0/IAudioManager.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v3_0/IAudioRender.idl b/audio/v3_0/IAudioRender.idl index 89723db15a62c2cc2a16d95108549025af915028..f27a5e75b0a37d1633b0fd66c8a9e8cc8466d3ae 100644 --- a/audio/v3_0/IAudioRender.idl +++ b/audio/v3_0/IAudioRender.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v4_0/AudioTypes.idl b/audio/v4_0/AudioTypes.idl index 668ecc10e02302b883b201bb8d6854712cdcee4b..e6d834ca12fc66c7c0c653f609564b03bc159a57 100644 --- a/audio/v4_0/AudioTypes.idl +++ b/audio/v4_0/AudioTypes.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * @@ -425,7 +424,7 @@ struct AudioSceneDescriptor { * @brief Defines audio input type. * * @since 4.1 - * @version 3.0 + * @version 3.1 */ enum AudioInputType { AUDIO_INPUT_DEFAULT_TYPE = 0, /**< Assigned default input type */ @@ -439,6 +438,7 @@ enum AudioInputType { AUDIO_INPUT_CAMCORDER_TYPE = 1 << 7, /**< Assigned camcorder input type */ AUDIO_INPUT_EC_TYPE = 1 << 8, /**< Assigned EC input type */ AUDIO_INPUT_NOISE_REDUCTION_TYPE = 1 << 9, /**< Assigned noise reduction input type */ + AUDIO_INPUT_RAW_TYPE = 1 << 10, /**< Assigned raw input type */ }; /** diff --git a/audio/v4_0/BUILD.gn b/audio/v4_0/BUILD.gn index a558ef9360584e23c17ffdebd1de255307caaa48..bf024567a1f34faf6549f1e205a36428aa438029 100644 --- a/audio/v4_0/BUILD.gn +++ b/audio/v4_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("../../../hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") if (defined(ohos_lite)) { group("libaudio_proxy_4.0") { @@ -31,6 +31,8 @@ if (defined(ohos_lite)) { "IAudioRender.idl", ] + branch_protector_ret = "pac_ret" + language = "c" subsystem_name = "hdf" part_name = "drivers_interface_audio" diff --git a/audio/v4_0/IAudioAdapter.idl b/audio/v4_0/IAudioAdapter.idl index 4f762442d1569f64ff718f2f9db5becb6982dba8..1145659bdea91c2221941ddca01169cfbef279e2 100644 --- a/audio/v4_0/IAudioAdapter.idl +++ b/audio/v4_0/IAudioAdapter.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v4_0/IAudioCallback.idl b/audio/v4_0/IAudioCallback.idl index e5ceda8537fe6f4fc71b59a2146a74701fd96acf..c6d734e3b18891f06b20c0c0d69db731c49d4e8b 100644 --- a/audio/v4_0/IAudioCallback.idl +++ b/audio/v4_0/IAudioCallback.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v4_0/IAudioCapture.idl b/audio/v4_0/IAudioCapture.idl index d188b96b9cc61cd4aa2046b7baeb5cce1ee5886d..aa9954ed5b93cf8227af82f6cc8203eac50c197c 100644 --- a/audio/v4_0/IAudioCapture.idl +++ b/audio/v4_0/IAudioCapture.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v4_0/IAudioManager.idl b/audio/v4_0/IAudioManager.idl index aff6facd1687517bb884e27711f62c88afd5a6f6..56e54b2beba6ce28367870ca943b899c95825d69 100644 --- a/audio/v4_0/IAudioManager.idl +++ b/audio/v4_0/IAudioManager.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/audio/v4_0/IAudioRender.idl b/audio/v4_0/IAudioRender.idl index b45eecd5e68cc6573d16e40e27c2e3bd55303374..b38bd64b3041e5b5ea77868a60978e8287ab3d72 100644 --- a/audio/v4_0/IAudioRender.idl +++ b/audio/v4_0/IAudioRender.idl @@ -15,7 +15,6 @@ /** * @addtogroup HdiAudio - * @{ * * @brief Provides unified APIs for audio services to access audio drivers. * diff --git a/camera/bundle.json b/camera/bundle.json index 6e96ddaffe3cacc885d4bb206587cf524039d720..069728d6987029ea939df40be6efa5993ce55932 100644 --- a/camera/bundle.json +++ b/camera/bundle.json @@ -48,6 +48,8 @@ "//drivers/interface/camera/v1_0:libcamera_stub_1.0" ], "test": [ + "//drivers/peripheral/camera/test/hdi/metadata_test:camera_metadata_operator_ut", + "//drivers/peripheral/camera/test/hdi/sequenceable_test:camera_hdi_sequenceable_ut" ], "inner_kits": [ { diff --git a/camera/metadata/BUILD.gn b/camera/metadata/BUILD.gn index 0e327f2e7e9273e801930cbfa78094714c94a26a..a2e2bf700bcd9891d2fe6b502269ceb7d31dbb40 100644 --- a/camera/metadata/BUILD.gn +++ b/camera/metadata/BUILD.gn @@ -19,17 +19,20 @@ config("camera_metadata_config") { } ohos_shared_library("metadata") { + branch_protector_ret = "pac_ret" + install_enable = true cflags = [ "-fPIC", "-Wall", ] + cflags_cc = cflags + cflags_cc += [ "-fstack-protector-strong" ] + if (drivers_interface_camera_feature_coverage) { cflags += [ "--coverage" ] - ldflags = [ "--coverage" ] - cflags_cc = cflags + ldflags += [ "--coverage" ] } - all_dependent_configs = [ ":camera_metadata_config" ] if (defined(ohos_lite)) { sources = [ "src/camera_metadata_info.cpp", diff --git a/camera/metadata/include/camera_device_ability_items.h b/camera/metadata/include/camera_device_ability_items.h index 0ca0aa4527ba22ac8681fd9621a751244de94be2..bf58a463db1da36fda2d0a9c06747996bf144edc 100644 --- a/camera/metadata/include/camera_device_ability_items.h +++ b/camera/metadata/include/camera_device_ability_items.h @@ -323,38 +323,38 @@ typedef enum camera_device_metadata_tag { */ OHOS_ABILITY_AVAILABLE_EXTENDED_STREAM_INFO_TYPES, /** - * ohos.ability.autoDeferedVideoEnhance [static, enum, public] + * ohos.ability.autoDeferredVideoEnhance [static, enum, public] * - * camera device property, report current camera whether support auto defered video enhance + * camera device property, report current camera whether support auto deferred video enhance * (i.e. enum: OHOS_CAMERA_NOT_SUPPORTED/OHOS_CAMERA_SUPPORTED ...) */ - OHOS_ABILITY_AOTU_DEFERRED_VIDEO_ENHANCE, + OHOS_ABILITY_AUTO_DEFERRED_VIDEO_ENHANCE, /** - * ohos.control.autoDeferedVideoEnhance [static, enum, public] + * ohos.control.autoDeferredVideoEnhance [static, enum, public] * - * camera device property, set current camera whether support auto defered video enhance + * camera device property, set current camera whether support auto deferred video enhance * (i.e. enum: OHOS_CAMERA_NOT_SUPPORTED/OHOS_CAMERA_SUPPORTED ...) */ - OHOS_CONTROL_AOTU_DEFERRED_VIDEO_ENHANCE, + OHOS_CONTROL_AUTO_DEFERRED_VIDEO_ENHANCE, /** * ohos.ability.autoCloudImageEnhance [static, int32[], public] * * camera device property, report current camera whether support auto cloud image enhance by mode * (i.e. int32[]: [mode, OHOS_CAMERA_NOT_SUPPORTED/OHOS_CAMERA_SUPPORTED, mode ...] ...) */ - OHOS_ABILITY_AOTU_CLOUD_IMAGE_ENHANCE, + OHOS_ABILITY_AUTO_CLOUD_IMAGE_ENHANCE, /** * ohos.control.autoCloudImageEnhance [static, enum, public] * * camera device property, set current camera whether support auto cloud image enhance * (i.e. enum: OHOS_CAMERA_NOT_SUPPORTED/OHOS_CAMERA_SUPPORTED ...) */ - OHOS_CONTROL_AOTU_CLOUD_IMAGE_ENHANCE, + OHOS_CONTROL_AUTO_CLOUD_IMAGE_ENHANCE, /** * ohos.ability.tripodDetection [static, int32[], public] * - * camera device property, report current camera whether supporttripod detection by mode - * (i.e. int32[]: [mode, OHOS_CAMERA_NOT_SUPPORTED/OHOS_CAMERA_SUPPORTED, mode ...] ...) + * camera device property, report current camera what mode support tripod detection + * (i.e. int32[]: [mode, mode ...] ...) */ OHOS_ABILITY_TRIPOD_DETECTION, /** @@ -407,12 +407,116 @@ typedef enum camera_device_metadata_tag { */ OHOS_CONTROL_LOW_LIGHT_BOOST, /** - * ohos.control.lowLightDetection [static, byte, public] + * ohos.status.lowLightDetection [static, byte, public] * * camera device property, query current camera low light detection status * (i.e. byte: 0-false/1-true ...) */ OHOS_STATUS_LOW_LIGHT_DETECTION, + /** + * ohos.status.cameraLensDirtyDetection [static, byte, public] + * + * camera device property, query current camera lens dirty detection + * (i.e. byte: 0-false/1-true ...) + */ + OHOS_STATUS_CAMERA_LENS_DIRTY_DETECTION, + /** + * ohos.device.protectionState [static, enum, public] + * + * camera device property, query current camera device protection state + * (i.e. enum: DeviceProtectionStatus ...) + */ + OHOS_DEVICE_PROTECTION_STATE, + /** + * ohos.device.tofsensorabnormal [static, int32, public] + * + * camera device property, query current camera tof sensor abnormal state + * (i.e. int32 ...) + */ + OHOS_STATUS_TOF_SENSOR_ABNORMAL, + /** + * ohos.ability.sunBlockPreviewTypes [static, byte[], public] + * + * camera device property, report current camera sun block types supported in proview + * (i.e. byte[]: [0-notSupport|1-RGB|2-UV|...]) + */ + OHOS_ABILITY_SUN_BLOCK_PREVIEW_TYPES, + /** + * ohos.ability.sunBlockBlendColors [static, byte[], public] + * + * camera device property, report current camera sun block supports blend colors + * (i.e. byte[]: [0-notSupport|1-purple|2-silver|3-gold|...]) + */ + OHOS_ABILITY_SUN_BLOCK_BLEND_COLORS, + /** + * ohos.ability.sunBlockRgbCropRegion [static, float[], public] + * + * camera device property, report current camera RGB image cropping coefficient, which is the normalized coordinate + * (i.e. float[] ...) + */ + OHOS_ABILITY_SUN_BLOCK_RGB_CROP_REGION, + /** + * ohos.ability.sunBlockRgbUvRegion [static, float[], public] + * + * camera device property, report current camera UV image cropping coefficient, which is the normalized coordinate + * (i.e. float[] ...) + */ + OHOS_ABILITY_SUN_BLOCK_RGB_UV_REGION, + /** + * ohos.status.sunBlockHint [static, byte, public] + * + * camera device property, queries the status returned by the current camera running the sun protection detection + * (i.e. byte ...) + */ + OHOS_STATUS_SUN_BLOCK_HINT, + /** + * ohos.ability.cameraLimitedCapabilityes [static, double[], public] + * + * Camera capability set for limited concurrent scenarios. + * This item contains other capability items for device capability control, + * such as OHOS_ABILITY_FLASH_MODES or other 3A capabilities. + * Resolution is reported through OHOS_ABLE_AVAILABLE_PROFILE_LEVEL. + * (i.e. OHOS_ABILITY_FLASH_MODES, length, flashMode, flashMode, ...) + * @since 5.1 + * @version 1.0 + */ + OHOS_ABILITY_CAMERA_LIMITED_CAPABILITIES, + /** + * ohos.ability.cameraConcurrentType [static, byte, public] + * + * Indicates whether the current camera is in full concurrency mode or limited concurrency mode. + * (i.e. byte) + * @since 5.1 + * @version 1.0 + */ + OHOS_ABILITY_CAMERA_CONCURRENT_TYPE, + /** + * ohos.ability.cameraConcurrentType [static, int32, public] + * + * Concurrent camera combinations are supported. The camera combinations are separated by - 1. + * (i.e. int32[] [2, 3, -1, 1, 2]) + * @since 5.1 + * @version 1.0 + */ + OHOS_ABILITY_CONCURRENT_SUPPORTED_CAMERAS, + /** + * ohos.ability.autoAigcPhoto [static, int32[], public] + * + * camera device property, report current camera whether support auto auto aigc photo by mode + * (i.e. int32[]: [mode, OHOS_CAMERA_NOT_SUPPORTED/OHOS_CAMERA_SUPPORTED, mode ...] ...) + * @since 5.1 + * @version 1.0 + */ + OHOS_ABILITY_AUTO_AIGC_PHOTO, + /** + * ohos.control.autoAigcPhoto [static, enum, public] + * + * camera device property, set current camera whether support auto aigc photo + * (i.e. byte: 0-false/1-true ...) + * @since 5.1 + * @version 1.0 + */ + OHOS_CONTROL_AUTO_AIGC_PHOTO, /** * ohos.camera.propertiesEnd * @@ -623,6 +727,13 @@ typedef enum camera_device_metadata_tag { * (i.e. int32[] ...) */ OHOS_STATISTICS_DETECT_BAR_CODE_INFOS, + /** + * ohos.statistics.baseFaceInfo [static, int32[], public] + * + * camera device property, query current camera detect base face information + * (i.e. int32[] ...) + */ + OHOS_STATISTICS_DETECT_BASE_FACE_INFO, /** * ohos.camera.statisticsEnd * @@ -945,6 +1056,55 @@ typedef enum camera_device_metadata_tag { * (i.e. enum: begin/end ...) */ OHOS_CONTROL_BURST_CAPTURE, + /** + * ohos.control.cameraUsedAsPosition [static, byte, public] + * + * camera device property, set current camera used as position + * (i.e. byte ...) + */ + OHOS_CONTROL_CAMERA_USED_AS_POSITION, + /** + * ohos.control.cameraSessionUsage [static, enum[], public] + * + * camera device property, set current camera session usage type whether enable + * (i.e. enum[]: [CameraSessionUsageType, CameraSessionUsageControlType] ...) + */ + OHOS_CONTROL_CAMERA_SESSION_USAGE, + /** + * ohos.control.ejectRetry [static, byte, public] + * + * camera device property, set current camera lens retry eject + * (i.e. byte: 0-false/1true ...) + */ + OHOS_CONTROL_EJECT_RETRY, + /** + * ohos.control.fallProtection [static, byte, public] + * + * camera device property, set current camera lens fall protection + * (i.e. byte: 0-false/1true ...) + */ + OHOS_CONTROL_FALL_PROTECTION, + /** + * ohos.control.sunBlockPreviewType [static, byte, public] + * + * camera device property, sets the sun protection detection type under the current camera preview + * (i.e. byte: 0-RGB/1-UV/2-RGB+UV) + */ + OHOS_CONTROL_SUN_BLOCK_PREVIEW_TYPE, + /** + * ohos.control.sunBlockBlendColor [static, byte, public] + * + * camera device property, sets the sun protection detection blend color for the current camera + * (i.e. byte: 0-none/1-purple/2-silver/3-gold) + */ + OHOS_CONTROL_SUN_BLOCK_BLEND_COLOR, + /** + * ohos.ability.qualityPrioritization [static, byte, public] + * + * camera device property, set current camera quality prioritization + * (i.e. byte ...) + */ + OHOS_CONTROL_QUALITY_PRIORITIZATION, /** * ohos.device.controlEnd * @@ -1101,6 +1261,48 @@ typedef enum camera_device_metadata_tag { * (i.e. float ...) */ OHOS_CONTROL_FOCUS_DISTANCE, + /** + * ohos.ability.focusRangeTypes [static, enum[], public] + * + * camera device property, report current camera support focus range types + * (i.e. enum[]: AUTO, NEAR ...) + */ + OHOS_ABILITY_FOCUS_RANGE_TYPES, + /** + * ohos.control.focusRangeType [static, enum, public] + * + * camera device property, set current camera focus range type + * (i.e. enum: AUTO/NEAR ...) + */ + OHOS_CONTROL_FOCUS_RANGE_TYPE, + /** + * ohos.control.focusTrackingMode [static, enum, public] + * + * camera device property, set current camera focus tracking mode + * (i.e. enum: AUTO ...) + */ + OHOS_CONTROL_FOCUS_TRACKING_MODE, + /** + * ohos.ability.focusTrackingRegion [static, int32[], public] + * + * camera device property, report current camera focus tracking region + * (i.e. int32[] ...) + */ + OHOS_ABILITY_FOCUS_TRACKING_REGION, + /** + * ohos.ability.focusDrivenTypes [static, enum[], public] + * + * camera device property, report current camera support focus driven types + * (i.e. enum[]: AUTO, FACE ...) + */ + OHOS_ABILITY_FOCUS_DRIVEN_TYPES, + /** + * ohos.control.focusDrivenType [static, enum, public] + * + * camera device property, set current camera focus driven type + * (i.e. enum: AUTO/FACE ...) + */ + OHOS_CONTROL_FOCUS_DRIVEN_TYPE, /** * ohos.device.focusEnd * @@ -1249,7 +1451,14 @@ typedef enum camera_device_metadata_tag { * (i.e. byte ...) */ OHOS_ABILITY_CAMERA_ZOOM_PERFORMANCE, - /** + /** + * ohos.control.zoomBezierCurvePoint [static, byte, public] + * + * camera device property, set current camera support camera BEZIER_CURVC_POINT + * (i.e. byte ...) + */ + OHOS_ABILITY_CAMERA_ZOOM_BEZIER_CURVC_POINT, + /** * ohos.device.zoomEnd * * camera device zoomEnd @@ -1315,6 +1524,36 @@ typedef enum camera_device_metadata_tag { * (i.e. byte[] ...) */ OHOS_CONTROL_DEFERRED_IMAGE_DELIVERY, + /** + * ohos.ability.autoVideoFrameRate [static, byte[], public] + * + * Camera device property, reporting that the camera supports automatic frame rate adjustment + * (i.e. byte[] ...) + * @since 5.1 + * @version 1.0 + */ + OHOS_ABILITY_AUTO_VIDEO_FRAME_RATE, + /* + * ohos.ability.changeToOfflineStreamOpeator [static, byte[], public] + * + * camera stream property, get camera support offline stream + * (i.e. byte[] ...) + */ + OHOS_ABILITY_CHANGETO_OFFLINE_STREAM_OPEATOR, + /** + * ohos.control.changeToOfflineStreamOpeator [static, byte[], public] + * + * camera stream property, set camera support offline stream + * (i.e. byte[] ...) + */ + OHOS_CONTROL_CHANGETO_OFFLINE_STREAM_OPEATOR, + /** + * ohos.ability.prerecord [static, int32[], public] + * + * camera device property, query camera support prerecord and duration + * (i.e. int32[] ...) + */ + OHOS_ABILITY_PRERECORD, /** * ohos.stream.abilityEnd * @@ -1322,6 +1561,36 @@ typedef enum camera_device_metadata_tag { */ OHOS_STREAM_ABILITY_END, + /** + * ohos.control.autoVideoFrameRate [static, byte[], public] + * + * camera stream property, set camera support automatic frame rate adjustment + * (i.e. byte[] ...) + * @since 5.1 + * @version 1.0 + */ + OHOS_CONTROL_AUTO_VIDEO_FRAME_RATE = OHOS_STREAM_CONTROL_START, + /** + * ohos.control.prerecord.mode [static, enum, public] + * + * camera stream property, set current camera prerecord mode + * (i.e. enum: ON/OFF ...) + */ + OHOS_CONTROL_PRERECORD_MODE, + /** + * ohos.control.record.state [static, enum, public] + * + * camera stream property, set current camera record state + * (i.e. enum: PRERECORD_START/RECORD_START/RECORD_END ...) + */ + OHOS_CONTROL_RECORD_STATE, + /** + * ohos.stream.controlEnd + * + * camera stream controlEnd + */ + OHOS_STREAM_CONTROL_END, + /** * ohos.jpeg.gpsCoordinates [static, double[], public] * @@ -1827,6 +2096,174 @@ typedef enum camera_device_metadata_tag { * (i.e. uint32_t[] ...) */ OHOS_ABILITY_TIME_LAPSE_INTERVAL_RANGE, + /** + * ohos.ability.lcdFlash [static, int32_t[], public] + * + * camera device property, report current camera lcd flash + * (i.e. int32_t[] ...) + */ + OHOS_ABILITY_LCD_FLASH, + /** + * ohos.control.lcdFlashDetection [static, byte[], public] + * + * camera device property, set current camera lcd flash detection + * (i.e. byte[] ...) + */ + OHOS_CONTROL_LCD_FLASH_DETECTION, + /** + * ohos.control.lcdFlash [static, byte[], public] + * + * camera device property, set current camera lcd flash + * (i.e. byte[] ...) + */ + OHOS_CONTROL_LCD_FLASH, + /** + * ohos.status.lcdFlashStatus [static, int32_t[], public] + * + * camera device property, quiry current camera lcd flash status + * (i.e. int32_t[] ...) + */ + OHOS_STATUS_LCD_FLASH_STATUS, + /** + * ohos.ability.depthDataDelivery [static, int32_t[], public] + * + * camera device property, report current camera depth data delivery + * (i.e. int32_t[] ...) + */ + OHOS_ABILITY_DEPTH_DATA_DELIVERY, + /** + * ohos.control.depthDataDeliverySwitch [static, byte[], public] + * + * camera device property, set current camera depth data delivery switch + * (i.e. byte[] ...) + */ + OHOS_CONTROL_DEPTH_DATA_DELIVERY_SWITCH, + /** + * ohos.ability.depthDataProfiles [static, int32_t[], public] + * + * camera device property, report current camera depth data profiles + * (i.e. int32_t[] ...) + */ + OHOS_ABILITY_DEPTH_DATA_PROFILES, + /** + * ohos.control.depthDataAccuracy [static, int32_t[], public] + * + * camera device property, set current camera depth data accuracy + * (i.e. int32_t[] ...) + */ + OHOS_CONTROL_DEPTH_DATA_ACCURACY, + /** + * ohos.ability.cameraIsRetractable [static, byte, public] + * + * camera device property, report current camera retractable + * (i.e. byte ...) + */ + OHOS_ABILITY_CAMERA_IS_RETRACTABLE, + /** + * ohos.control.closeAfterSeconds [static, uint32, public] + * + * camera device property, set current camera close after seconds + * (i.e. uint32 ...) + */ + OHOS_CONTROL_CAMERA_CLOSE_AFTER_SECONDS, + /** + * ohos.status.movingPhotoBufferDuration [static, uint32[], public] + * + * camera device property, report current moving photo buffer duration + * (i.e. uint32[] ...) + */ + OHOS_MOVING_PHOTO_BUFFER_DURATION, + /** + * ohos.movingPhotoStart [static, uint32[], public] + * + * camera device property, report current moving photo start time + * (i.e. uint32[] ...) + */ + OHOS_MOVING_PHOTO_START, + /** + * ohos.movingPhotoEnd [static, int64[], public] + * + * camera device property, report current moving photo end time + * (i.e. int64[] ...) + */ + OHOS_MOVING_PHOTO_END, + /** + * ohos.ability.captureMacroDepthFusionSupported [static, byte, public] + * + * camera device property, report current capture macro depth fusion supported + * (i.e. byte ...) + */ + OHOS_ABILITY_CAPTURE_MACRO_DEPTH_FUSION_SUPPORTED, + /** + * ohos.ability.captureMacroDepthFusionZoomRange [static, float[], public] + * + * camera device property, report current capture macro depth fusion zoom range + * (i.e. float[] ...) + */ + OHOS_ABILITY_CAPTURE_MACRO_DEPTH_FUSION_ZOOM_RANGE, + /** + * ohos.control.captureMacroDepthFusion [static, byte, public] + * + * camera device property, set current capture macro depth fusion + * (i.e. byte ...) + */ + OHOS_CONTROL_CAPTURE_MACRO_DEPTH_FUSION, + /** + * ohos.ability.cameraPortraitThemeSupported [static, byte, public] + * + * camera device property, report current camera portrait theme supported + * (i.e. byte ...) + */ + OHOS_ABILITY_CAMERA_PORTRAIT_THEME_SUPPORTED, + /** + * ohos.ability.cameraPortraitThemeTypes [static, byte[], public] + * + * camera device property, report current camera supported portrait theme types + * (i.e. byte[] ...) + */ + OHOS_ABILITY_CAMERA_PORTRAIT_THEME_TYPES, + /** + * ohos.control.cameraPortraitThemeType [static, byte, public] + * + * camera device property, set current camera portrait theme type + * (i.e. byte ...) + */ + OHOS_CONTROL_CAMERA_PORTRAIT_THEME_TYPE, + /** + * ohos.ability.cameraVideoRotationSupported [static, byte, public] + * + * camera device property, report current camera video rotation supported + * (i.e. byte ...) + */ + OHOS_ABILITY_CAMERA_VIDEO_ROTATION_SUPPORTED, + /** + * ohos.ability.cameraVideoRotation [static, int32[], public] + * + * camera device property, report current camera supported video rotation + * (i.e. int32[] ...) + */ + OHOS_ABILITY_CAMERA_VIDEO_ROTATION, + /** + * ohos.control.cameraVideoRotation [static, int32, public] + * + * camera device property, set current camera video rotation + * (i.e. int32 ...) + */ + OHOS_CONTROL_CAMERA_VIDEO_ROTATION, + /** + * ohos.ability.colorReservationTypes [static, enum[], public] + * + * camera device property, report current camera support color reservation types + * (i.e. enum[]: NONE, PORTRAIT ...) + */ + OHOS_ABILITY_COLOR_RESERVATION_TYPES, + /** + * ohos.control.colorReservationType [static, enum, public] + * + * camera device property, set current camera color reservation type + * (i.e. enum: NONE/PORTRAIT ...) + */ + OHOS_CONTROL_COLOR_RESERVATION_TYPE, /** * ohos.camera.effectEnd * @@ -1913,6 +2350,7 @@ typedef enum camera_switch_enum { OHOS_CAMERA_SWTICH_ON, } camera_switch_enum_t; +// OHOS_ABILITY_CAMERA_USED_AS_POSITION enumeration values // OHOS_ABILITY_CAMERA_POSITION enumeration values typedef enum camera_position_enum { OHOS_CAMERA_POSITION_FRONT = 0, @@ -2077,6 +2515,9 @@ typedef enum camera_format { OHOS_CAMERA_FORMAT_YCRCB_P010, OHOS_CAMERA_FORMAT_DNG, OHOS_CAMERA_FORMAT_422_YUYV, + OHOS_CAMERA_FORMAT_DEPTH_16, + OHOS_CAMERA_FORMAT_DEPTH_32, + OHOS_CAMERA_FORMAT_HEIC, OHOS_CAMERA_FORMAT_IMPLEMENTATION_DEFINED = 0x1000, } camera_format_t; @@ -2317,7 +2758,7 @@ enum CameraLightPaintingType { OHOS_CAMERA_LIGHT_PAINTING_LIGHT, }; -//OHOS_CONTRAL_TIME_LAPSE_TRYAE_STATE +//OHOS_CONTROL_TIME_LAPSE_TRYAE_STATE enum TimeLapseRecordState { TIME_LAPSE_IDLE = 0, TIME_LAPSE_RECORDING = 1, @@ -2339,6 +2780,7 @@ enum StatisticsDetectType { OHOS_CAMERA_DOG_BODY_DETECT = 5, OHOS_CAMERA_SALIENT_DETECT = 6, OHOS_CAMERA_BAR_CODE_DETECT = 7, + OHOS_CAMERA_BASE_FACE_DETECT = 8, }; // OHOS_STATUS_TRIPOD_DETECTION_STATUS @@ -2349,4 +2791,143 @@ enum TripodStatus { TRIPOD_STATUS_EXITING = 3, }; +// OHOS_CONTROL_DEPTH_DATA_ACCURACY +enum DepthDataAccuracyType { + OHOS_DEPTH_DATA_ACCURACY_RELATIVE = 1, + OHOS_DEPTH_DATA_ACCURACY_ABSOLUTE, +}; + +// OHOS_CONTROL_CAMERA_SESSION_USAGE +enum CameraSessionUsageType { + OHOS_CAMERA_SESSION_USAGE_BOKEH = 0, +}; + +// OHOS_CONTROL_CAMERA_SESSION_USAGE +enum CameraSessionUsageControlType { + OHOS_CAMERA_SESSION_USAGE_DISABLE = 0, + OHOS_CAMERA_SESSION_USAGE_ENABLE = 1, +}; + +// OHOS_DEVICE_PROTECTION_STATE +enum DeviceProtectionStatus { + OHOS_DEVICE_SWITCH_FREQUENT = 0, + OHOS_DEVICE_EXTERNAL_PRESS = 1, + OHOS_DEVICE_EJECT_BLOCK = 2, + OHOS_DEVICE_FALL_PROTECTION = 3, +}; + +enum StatisticsDetectEmotion { + OHOS_EMOTION_NEUTRAL = 0, + OHOS_EMOTION_SADNESS = 1, + OHOS_EMOTION_SMILE = 2, + OHOS_EMOTION_SURPRISE = 3, +}; + +// OHOS_ABILITY_CAMERA_PORTRAIT_THEME_SUPPORTED +enum CameraPortraitThemeSupportedType { + OHOS_CAMERA_PORTRAIT_THEME_NOT_SUPPORTED = 0, + OHOS_CAMERA_PORTRAIT_THEME_SUPPORTED, +}; + +// OHOS_ABILITY_CAMERA_PORTRAIT_THEME_TYPES +enum CameraPortraitThemeTypes { + OHOS_CAMERA_PORTRAIT_THEME_TYPE_NATURAL = 0, + OHOS_CAMERA_PORTRAIT_THEME_TYPE_DELICATE, + OHOS_CAMERA_PORTRAIT_THEME_TYPE_STYLISH, +}; + +// OHOS_ABILITY_CAMERA_VIDEO_ROTATION_SUPPORTED +enum CameraVideoRotationSupportedType { + OHOS_CAMERA_VIDEO_ROTATION_NOT_SUPPORTED = 0, + OHOS_CAMERA_VIDEO_ROTATION_SUPPORTED, +}; + +// OHOS_ABILITY_SUN_BLOCK_PREVIEW_TYPES +// OHOS_CONTROL_SUN_BLOCK_PREVIEW_TYPE +enum CameraSunBlockPreviewType { + OHOS_PREVIEW_TYPE_NOT_SUPPORTED = 0, + OHOS_PREVIEW_TYPE_RGB, + OHOS_PREVIEW_TYPE_UV, + OHOS_PREVIEW_TYPE_RGB_UV, +}; + +// OHOS_ABILITY_SUN_BLOCK_BLEND_COLORS +// OHOS_CONTROL_SUN_BLOCK_BLEND_COLOR +enum CameraSunBlockBlendColor { + OHOS_BLEND_COLOR_NOT_SUPPORTED = 0, + OHOS_BLEND_COLOR_NONE = 0, + OHOS_BLEND_COLOR_PURPLE = 1, + OHOS_BLEND_COLOR_SILVER = 2, + OHOS_BLEND_COLOR_GOLD = 3, +}; + +// OHOS_STATUS_SUN_BLOCK_HINT +enum CameraSunBlockHint { + OHOS_HINT_NO_FACE_DETECTED = 2, + OHOS_HINT_FACE_OUT_OF_BOUND = 3, + OHOS_HINT_MOBILEPHONE_TOO_FAR = 4, + OHOS_HINT_MOBILEPHONE_TOO_NEAR = 5, + OHOS_HINT_FACE_TOO_RIGHT = 6, + OHOS_HINT_FACE_TOO_LEFT = 7, + OHOS_HINT_FACE_TOO_LOWER = 8, + OHOS_HINT_FACE_TOO_TOP = 9, + OHOS_HINT_SUNSCREEN_NO_FULL_COVERAGE = 20, +}; + +// OHOS_ABILITY_CAMERA_QUALITY_PRIORITIZATION +enum CameraQualityPrioritization { + OHOS_CAMERA_QUALITY_PRIORITIZATION_HIGH_QUALITY = 0, + OHOS_CAMERA_QUALITY_PRIORITIZATION_POWER_BALANCE, +}; + +// OHOS_ABILITY_AUTO_VIDEO_FRAME_RATE +enum CameraStreamAutoFpsControl { + OHOS_STREAM_AUTO_FPS_DISABLE = 0, + OHOS_STREAM_AUTO_FPS_ENABLE, +}; + +// OHOS_ABILITY_FOCUS_RANGE_TYPES +// OHOS_CONTROL_FOCUS_RANGE_TYPE +typedef enum camera_focus_range_type { + OHOS_CAMERA_FOCUS_RANGE_AUTO = 0, + OHOS_CAMERA_FOCUS_RANGE_NEAR +} camera_focus_range_type_t; + +// OHOS_ABILITY_FOCUS_DRIVEN_TYPES +// OHOS_CONTROL_FOCUS_DRIVEN_TYPE +typedef enum camera_focus_driven_type { + OHOS_CAMERA_FOCUS_DRIVEN_AUTO = 0, + OHOS_CAMERA_FOCUS_DRIVEN_FACE +} camera_focus_driven_type_t; + +// OHOS_CONTROL_FOCUS_TRACKING_MODE +typedef enum camera_focus_tracking_mode { + OHOS_CAMERA_FOCUS_TRACKING_AUTO = 0, +} camera_focus_tracking_mode_t; + +// OHOS_ABILITY_COLOR_RESERVATION_TYPES +// OHOS_CONTROL_COLOR_RESERVATION_TYPE +typedef enum camera_color_reservation_type { + OHOS_CAMERA_COLOR_RESERVATION_NONE = 0, + OHOS_CAMERA_COLOR_RESERVATION_PORTRAIT +} camera_color_reservation_type_t; + +// OHOS_CONTROL_PRERECORD_MODE +enum CameraPrerecordMode { + OHOS_CAMERA_PRERECORD_MODE_ON = 1, + OHOS_CAMERA_PRERECORD_MODE_OFF = 2, +}; + +// OHOS_CONTROL_RECORD_STATE +enum CameraRecordState { + OHOS_CAMERA_RECORD_STATE_PRERECORD_START = 1, + OHOS_CAMERA_RECORD_STATE_RECORD_START = 2, + OHOS_CAMERA_RECORD_STATE_RECORD_STOP = 3, +}; + +// OHOS_ABILITY_CAMERA_CONCURRENT_TYPE +enum CameraConcurrentType { + OHOS_CAMERA_COCURRENT_FULL = 0, + OHOS_CAMERA_COCURRENT_LIIMITED, +}; #endif diff --git a/camera/metadata/include/camera_metadata_info.h b/camera/metadata/include/camera_metadata_info.h index dd0e43044fc709e602c696d76e0022823b298ee7..be3c3275224f14d8643339a48c6a8fb48b9f6ee7 100644 --- a/camera/metadata/include/camera_metadata_info.h +++ b/camera/metadata/include/camera_metadata_info.h @@ -25,6 +25,7 @@ static constexpr uint32_t MAX_SUPPORTED_TAGS = 1000; static constexpr uint32_t MAX_SUPPORTED_ITEMS = (12000 * 2 * 2); static constexpr uint32_t MAX_ITEM_CAPACITY = (1000 * 10); static constexpr uint32_t MAX_DATA_CAPACITY = (1000 * 10 * 10 * 10); +static constexpr uint32_t MIN_VEC_SIZE = 12; #define METADATA_PACKET_ALIGNMENT \ MaxAlignment(MaxAlignment(DATA_ALIGNMENT, METADATA_ALIGNMENT), ITEM_ALIGNMENT) @@ -49,7 +50,7 @@ private: static uint32_t AlignTo(uint32_t val, uint32_t alignment); static uint32_t MaxAlignment(uint32_t dataAlignment, uint32_t metadataAlignment); static size_t CalculateCameraMetadataMemoryRequired(uint32_t itemCount, uint32_t dataCount); - static int UpdateameraMetadataItemSize(camera_metadata_item_entry_t *item, uint32_t dataCount, + static int UpdateCameraMetadataItemSize(camera_metadata_item_entry_t *item, uint32_t dataCount, common_metadata_header_t *dst, const void *data); static int AddCameraMetadataItemVerify(common_metadata_header_t *dst, uint32_t item, const void *data, size_t dataCount, uint32_t *dataType); @@ -109,7 +110,7 @@ public: static uint32_t GetCameraMetadataDataSize(const common_metadata_header_t *metadata_header); static int32_t CopyCameraMetadataItems(common_metadata_header_t *newMetadata, const common_metadata_header_t *oldMetadata); - static size_t CalculateCameraMetadataItemDataSize(uint32_t type, size_t data_count); + static int32_t CalculateCameraMetadataItemDataSize(uint32_t type, size_t data_count); static int32_t GetCameraMetadataItemType(uint32_t item, uint32_t *data_type); static common_metadata_header_t *FillCameraMetadata(common_metadata_header_t *buffer, size_t memoryRequired, uint32_t itemCapacity, uint32_t dataCapacity); diff --git a/camera/metadata/include/camera_metadata_item_info.h b/camera/metadata/include/camera_metadata_item_info.h index 7a2ae0ee70169fa0f7efca5db5f2a4e0dcbfb8b1..2f34a9c8018f9c0269c1901dd7f7b4294884df2a 100644 --- a/camera/metadata/include/camera_metadata_item_info.h +++ b/camera/metadata/include/camera_metadata_item_info.h @@ -16,6 +16,7 @@ #ifndef CAMERA_METADATA_ITEM_INFO_H #define CAMERA_METADATA_ITEM_INFO_H +#include "camera_device_ability_items.h" #include "camera_metadata_operator.h" namespace OHOS::Camera { @@ -46,6 +47,7 @@ static uint32_t g_ohosCameraSectionBounds[OHOS_SECTION_COUNT][2] = { [OHOS_SECTION_CAMERA_EFFECT] = {OHOS_CAMERA_EFFECT_START, OHOS_CAMERA_EFFECT_END }, [OHOS_SECTION_CAMERA_SECURE] = {OHOS_CAMERA_SECURE_START, OHOS_CAMERA_SECURE_END }, [OHOS_SECTION_CAMERA_XMAGE] = {OHOS_XMAGE_COLOR_MODES_START, OHOS_XMAGE_COLOR_MODES_END }, + [OHOS_SECTION_STREAM_CONTROL] = {OHOS_STREAM_CONTROL_START, OHOS_STREAM_CONTROL_END }, }; static item_info_t g_ohosCameraProperties[OHOS_CAMERA_PROPERTIES_END - OHOS_CAMERA_PROPERTIES_START] = { @@ -106,13 +108,13 @@ static item_info_t g_ohosCameraProperties[OHOS_CAMERA_PROPERTIES_END - OHOS_CAME OHOS_CAMERA_PROPERTIES_START] = {"statisticsDetectSetting", META_TYPE_BYTE, -1}, [OHOS_ABILITY_AVAILABLE_EXTENDED_STREAM_INFO_TYPES - OHOS_CAMERA_PROPERTIES_START] = {"availableExtendedStreamInfoTypes", META_TYPE_INT32, -1}, - [OHOS_ABILITY_AOTU_DEFERRED_VIDEO_ENHANCE - - OHOS_CAMERA_PROPERTIES_START] = {"autoDeferedVideoEnhance", META_TYPE_BYTE, 1}, - [OHOS_CONTROL_AOTU_DEFERRED_VIDEO_ENHANCE - - OHOS_CAMERA_PROPERTIES_START] = {"controlAutoDeferedVideoEnhance", META_TYPE_BYTE, 1}, - [OHOS_ABILITY_AOTU_CLOUD_IMAGE_ENHANCE - + [OHOS_ABILITY_AUTO_DEFERRED_VIDEO_ENHANCE - + OHOS_CAMERA_PROPERTIES_START] = {"autoDeferredVideoEnhance", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_AUTO_DEFERRED_VIDEO_ENHANCE - + OHOS_CAMERA_PROPERTIES_START] = {"controlAutoDeferredVideoEnhance", META_TYPE_BYTE, 1}, + [OHOS_ABILITY_AUTO_CLOUD_IMAGE_ENHANCE - OHOS_CAMERA_PROPERTIES_START] = {"autoCloudImageEnhance", META_TYPE_INT32, -1}, - [OHOS_CONTROL_AOTU_CLOUD_IMAGE_ENHANCE - + [OHOS_CONTROL_AUTO_CLOUD_IMAGE_ENHANCE - OHOS_CAMERA_PROPERTIES_START] = {"controlAutoCloudImageEnhance", META_TYPE_BYTE, 1}, [OHOS_ABILITY_TRIPOD_DETECTION - OHOS_CAMERA_PROPERTIES_START] = {"tripodDetection", META_TYPE_INT32, -1}, @@ -132,6 +134,32 @@ static item_info_t g_ohosCameraProperties[OHOS_CAMERA_PROPERTIES_END - OHOS_CAME OHOS_CAMERA_PROPERTIES_START] = {"lowLightBoost", META_TYPE_BYTE, 1}, [OHOS_STATUS_LOW_LIGHT_DETECTION - OHOS_CAMERA_PROPERTIES_START] = {"lowLightDetection", META_TYPE_BYTE, 1}, + [OHOS_STATUS_CAMERA_LENS_DIRTY_DETECTION - + OHOS_CAMERA_PROPERTIES_START] = {"cameraLensDirtyDetection", META_TYPE_BYTE, 1}, + [OHOS_DEVICE_PROTECTION_STATE - + OHOS_CAMERA_PROPERTIES_START] = {"protectionState", META_TYPE_BYTE, 1}, + [OHOS_STATUS_TOF_SENSOR_ABNORMAL - + OHOS_CAMERA_PROPERTIES_START] = {"tofSensorAbnormal", META_TYPE_INT32, 1}, + [OHOS_ABILITY_SUN_BLOCK_PREVIEW_TYPES - + OHOS_CAMERA_PROPERTIES_START] = {"sunBlockPreviewTypes", META_TYPE_BYTE, -1}, + [OHOS_ABILITY_SUN_BLOCK_BLEND_COLORS - + OHOS_CAMERA_PROPERTIES_START] = {"sunBlockBlendColors", META_TYPE_BYTE, -1}, + [OHOS_ABILITY_SUN_BLOCK_RGB_CROP_REGION - + OHOS_CAMERA_PROPERTIES_START] = {"sunBlockRgbCropRegion", META_TYPE_FLOAT, -1}, + [OHOS_ABILITY_SUN_BLOCK_RGB_UV_REGION - + OHOS_CAMERA_PROPERTIES_START] = {"sunBlockRgbUvRegion", META_TYPE_FLOAT, -1}, + [OHOS_STATUS_SUN_BLOCK_HINT - + OHOS_CAMERA_PROPERTIES_START] = {"sunBlockHint", META_TYPE_BYTE, -1}, + [OHOS_ABILITY_AUTO_AIGC_PHOTO - + OHOS_CAMERA_PROPERTIES_START] = {"autoAigcPhoto", META_TYPE_INT32, -1}, + [OHOS_CONTROL_AUTO_AIGC_PHOTO - + OHOS_CAMERA_PROPERTIES_START] = {"controlAutoAigcPhoto", META_TYPE_BYTE, 1}, + [OHOS_ABILITY_CAMERA_LIMITED_CAPABILITIES - + OHOS_CAMERA_PROPERTIES_START] = {"cameraLimitedCapability", META_TYPE_DOUBLE, -1}, + [OHOS_ABILITY_CAMERA_CONCURRENT_TYPE - + OHOS_CAMERA_PROPERTIES_START] = {"cameraConcurrentType", META_TYPE_BYTE, 1}, + [OHOS_ABILITY_CONCURRENT_SUPPORTED_CAMERAS - + OHOS_CAMERA_PROPERTIES_START] = {"cameraConcurrentSupportedCameras", META_TYPE_INT32, 1}, }; static item_info_t g_ohosCameraSensor[OHOS_CAMERA_SENSOR_END - OHOS_CAMERA_SENSOR_START] = { @@ -180,6 +208,8 @@ static item_info_t g_ohosCameraStatistics[OHOS_CAMERA_STATISTICS_END - OHOS_CAME OHOS_CAMERA_STATISTICS_START] = {"detectSalientInfos", META_TYPE_INT32, -1}, [OHOS_STATISTICS_DETECT_BAR_CODE_INFOS - OHOS_CAMERA_STATISTICS_START] = {"detectBarCodeInfos", META_TYPE_INT32, -1}, + [OHOS_STATISTICS_DETECT_BASE_FACE_INFO - + OHOS_CAMERA_STATISTICS_START] = {"baseFaceInfo", META_TYPE_INT32, -1}, }; static item_info_t g_ohosCameraControl[OHOS_DEVICE_CONTROL_END - OHOS_DEVICE_CONTROL_START] = { @@ -245,6 +275,20 @@ static item_info_t g_ohosCameraControl[OHOS_DEVICE_CONTROL_END - OHOS_DEVICE_CON [OHOS_CONTROL_HIGH_QUALITY_MODE - OHOS_DEVICE_CONTROL_START] = {"highQualityMode", META_TYPE_BYTE, 1}, [OHOS_CONTROL_BURST_CAPTURE - OHOS_DEVICE_CONTROL_START] = {"cameraControlBurstCapture", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_CAMERA_USED_AS_POSITION - + OHOS_DEVICE_CONTROL_START] = {"cameraUsedAsPosition", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_CAMERA_SESSION_USAGE - + OHOS_DEVICE_CONTROL_START] = {"cameraSessionUsage", META_TYPE_INT32, -1}, + [OHOS_CONTROL_EJECT_RETRY - + OHOS_DEVICE_CONTROL_START] = {"ejectRetry", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_FALL_PROTECTION - + OHOS_DEVICE_CONTROL_START] = {"fallProtection", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_SUN_BLOCK_PREVIEW_TYPE - + OHOS_DEVICE_CONTROL_START] = {"sunBlockPreviewType", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_SUN_BLOCK_BLEND_COLOR - + OHOS_DEVICE_CONTROL_START] = {"sunBlockBlendColor", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_QUALITY_PRIORITIZATION - + OHOS_DEVICE_CONTROL_START] = {"qualityPrioritization", META_TYPE_BYTE, 1}, }; static item_info_t g_ohosDeviceExposure[OHOS_DEVICE_EXPOSURE_END - OHOS_DEVICE_EXPOSURE_START] = { @@ -278,6 +322,12 @@ static item_info_t g_ohosDeviceFocus[OHOS_DEVICE_FOCUS_END - OHOS_DEVICE_FOCUS_S [OHOS_ABILITY_EQUIVALENT_FOCUS - OHOS_DEVICE_FOCUS_START] = {"equivalentFocus", META_TYPE_INT32, -1}, [OHOS_CONTROL_FOCUS_DISTANCE - OHOS_DEVICE_FOCUS_START] = {"controlFocusDistance", META_TYPE_FLOAT, 1}, + [OHOS_ABILITY_FOCUS_RANGE_TYPES - OHOS_DEVICE_FOCUS_START] = {"focusRangeTypes", META_TYPE_BYTE, -1}, + [OHOS_CONTROL_FOCUS_RANGE_TYPE - OHOS_DEVICE_FOCUS_START] = {"focusRangeType", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_FOCUS_TRACKING_MODE - OHOS_DEVICE_FOCUS_START] = {"focusTrackingMode", META_TYPE_BYTE, 1}, + [OHOS_ABILITY_FOCUS_TRACKING_REGION - OHOS_DEVICE_FOCUS_START] = {"focusTrackingRegion", META_TYPE_INT32, -1}, + [OHOS_ABILITY_FOCUS_DRIVEN_TYPES - OHOS_DEVICE_FOCUS_START] = {"focusDrivenTypes", META_TYPE_BYTE, -1}, + [OHOS_CONTROL_FOCUS_DRIVEN_TYPE - OHOS_DEVICE_FOCUS_START] = {"focusDrivenType", META_TYPE_BYTE, 1}, }; static item_info_t g_ohosDeviceWhite[OHOS_DEVICE_WHITE_BLANCE_END - OHOS_DEVICE_WHITE_BLANCE_START] = { @@ -305,6 +355,8 @@ static item_info_t g_ohosDeviceZoom[OHOS_DEVICE_ZOOM_END - OHOS_DEVICE_ZOOM_STAR [OHOS_CONTROL_SMOOTH_ZOOM_RATIOS - OHOS_DEVICE_ZOOM_START] = {"controlZoomRatios", META_TYPE_UINT32, -1}, [OHOS_CONTROL_PREPARE_ZOOM - OHOS_DEVICE_ZOOM_START] = {"controlPreZoom", META_TYPE_BYTE, 1}, [OHOS_ABILITY_CAMERA_ZOOM_PERFORMANCE - OHOS_DEVICE_ZOOM_START] = {"zoomPerformance", META_TYPE_UINT32, -1}, + [OHOS_ABILITY_CAMERA_ZOOM_BEZIER_CURVC_POINT - + OHOS_DEVICE_ZOOM_START] = {"zoomBezierCurvePoint", META_TYPE_FLOAT, -1}, }; @@ -325,6 +377,23 @@ static item_info_t g_ohosStreamAbility[OHOS_STREAM_ABILITY_END - OHOS_STREAM_ABI OHOS_STREAM_ABILITY_START] = {"deferredImageDeliverySupportModes", META_TYPE_BYTE, -1}, [OHOS_CONTROL_DEFERRED_IMAGE_DELIVERY - OHOS_STREAM_ABILITY_START] = {"deferredImageDeliveryMode", META_TYPE_BYTE, -1}, + [OHOS_ABILITY_AUTO_VIDEO_FRAME_RATE - + OHOS_STREAM_ABILITY_START] = {"streamAutoFpsSupportedMode", META_TYPE_BYTE, -1}, + [OHOS_ABILITY_PRERECORD - + OHOS_STREAM_ABILITY_START] = {"prerecord", META_TYPE_INT32, -1}, + [OHOS_ABILITY_CHANGETO_OFFLINE_STREAM_OPEATOR - + OHOS_STREAM_ABILITY_START] = {"offlineSupportedValue", META_TYPE_BYTE, -1}, + [OHOS_CONTROL_CHANGETO_OFFLINE_STREAM_OPEATOR - + OHOS_STREAM_ABILITY_START] = {"offlineControlValue", META_TYPE_BYTE, -1}, +}; + +static item_info_t g_ohosStreamControl[OHOS_STREAM_CONTROL_END - OHOS_STREAM_CONTROL_START] = { + [OHOS_CONTROL_AUTO_VIDEO_FRAME_RATE - + OHOS_STREAM_CONTROL_START] = {"streamAutoFpsControl", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_PRERECORD_MODE - + OHOS_STREAM_CONTROL_START] = {"prerecordMode", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_RECORD_STATE - + OHOS_STREAM_CONTROL_START] = {"recordState", META_TYPE_BYTE, 1}, }; static item_info_t g_ohosStreamJpeg[OHOS_STREAM_JPEG_END - OHOS_STREAM_JPEG_START] = { @@ -460,6 +529,54 @@ static item_info_t g_ohosPostProcess[OHOS_CAMERA_EFFECT_END - OHOS_CAMERA_EFFECT OHOS_CAMERA_EFFECT_START] = {"controlTimeLapsePreviewType", META_TYPE_BYTE, 1}, [OHOS_ABILITY_TIME_LAPSE_INTERVAL_RANGE - OHOS_CAMERA_EFFECT_START] = {"timeLapseIntervalRange", META_TYPE_UINT32, 1}, + [OHOS_ABILITY_LCD_FLASH - + OHOS_CAMERA_EFFECT_START] = {"lcdFlash", META_TYPE_INT32, -1}, + [OHOS_CONTROL_LCD_FLASH_DETECTION - + OHOS_CAMERA_EFFECT_START] = {"lcdFlashDetection", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_LCD_FLASH - + OHOS_CAMERA_EFFECT_START] = {"controlLcdFlash", META_TYPE_BYTE, 1}, + [OHOS_STATUS_LCD_FLASH_STATUS - + OHOS_CAMERA_EFFECT_START] = {"lcdFlashStatus", META_TYPE_INT32, 1}, + [OHOS_ABILITY_DEPTH_DATA_DELIVERY - + OHOS_CAMERA_EFFECT_START] = {"depthDataDelivery", META_TYPE_INT32, -1}, + [OHOS_CONTROL_DEPTH_DATA_DELIVERY_SWITCH - + OHOS_CAMERA_EFFECT_START] = {"depthDataDeliverySwitch", META_TYPE_BYTE, 1}, + [OHOS_ABILITY_DEPTH_DATA_PROFILES - + OHOS_CAMERA_EFFECT_START] = {"depthDataProfiles", META_TYPE_INT32, -1}, + [OHOS_CONTROL_DEPTH_DATA_ACCURACY - + OHOS_CAMERA_EFFECT_START] = {"depthDataAccuracy", META_TYPE_INT32, -1}, + [OHOS_ABILITY_CAMERA_IS_RETRACTABLE - + OHOS_CAMERA_EFFECT_START] = {"cameraIsRetractable", META_TYPE_BYTE, 1}, + [OHOS_CONTROL_CAMERA_CLOSE_AFTER_SECONDS - + OHOS_CAMERA_EFFECT_START] = {"cameraCloseAfterSeconds", META_TYPE_UINT32, 1}, + [OHOS_ABILITY_CAPTURE_MACRO_DEPTH_FUSION_SUPPORTED - + OHOS_CAMERA_EFFECT_START] = {"captureMacroDepthFusionSupported", META_TYPE_BYTE, 1}, + [OHOS_ABILITY_CAPTURE_MACRO_DEPTH_FUSION_ZOOM_RANGE - + OHOS_CAMERA_EFFECT_START] = {"captureMacroDepthFussionZoomRange", META_TYPE_FLOAT, -1}, + [OHOS_CONTROL_CAPTURE_MACRO_DEPTH_FUSION - + OHOS_CAMERA_EFFECT_START] = {"captureMacroDepthFusion", META_TYPE_BYTE, 1}, + [OHOS_ABILITY_CAMERA_PORTRAIT_THEME_SUPPORTED - + OHOS_CAMERA_EFFECT_START] = {"isPortraitThemeTypesSupported", META_TYPE_BYTE, 1}, + [OHOS_ABILITY_CAMERA_PORTRAIT_THEME_TYPES - + OHOS_CAMERA_EFFECT_START] = {"supportedPortraitThemeTypes", META_TYPE_BYTE, -1}, + [OHOS_CONTROL_CAMERA_PORTRAIT_THEME_TYPE - + OHOS_CAMERA_EFFECT_START] = {"portraitThemeType", META_TYPE_BYTE, 1}, + [OHOS_ABILITY_CAMERA_VIDEO_ROTATION_SUPPORTED - + OHOS_CAMERA_EFFECT_START] = {"isVideoRotationSupported", META_TYPE_BYTE, 1}, + [OHOS_ABILITY_CAMERA_VIDEO_ROTATION - + OHOS_CAMERA_EFFECT_START] = {"supportedVideoRotation", META_TYPE_INT32, -1}, + [OHOS_CONTROL_CAMERA_VIDEO_ROTATION - + OHOS_CAMERA_EFFECT_START] = {"videoRotation", META_TYPE_INT32, 1}, + [OHOS_MOVING_PHOTO_BUFFER_DURATION - + OHOS_CAMERA_EFFECT_START] = {"movingPhotoBufferDuration", META_TYPE_UINT32, 1}, + [OHOS_MOVING_PHOTO_START - + OHOS_CAMERA_EFFECT_START] = {"movingPhotoStart", META_TYPE_INT64, 1}, + [OHOS_MOVING_PHOTO_END - + OHOS_CAMERA_EFFECT_START] = {"movingPhotoEnd", META_TYPE_INT64, 1}, + [OHOS_ABILITY_COLOR_RESERVATION_TYPES - + OHOS_CAMERA_EFFECT_START] = {"colorReservationTypes", META_TYPE_BYTE, -1}, + [OHOS_CONTROL_COLOR_RESERVATION_TYPE - + OHOS_CAMERA_EFFECT_START] = {"colorReservationType", META_TYPE_BYTE, 1}, }; static item_info_t g_ohosCameraSecure[OHOS_CAMERA_SECURE_END - OHOS_CAMERA_SECURE_START] = { @@ -502,6 +619,7 @@ const static item_info_t *g_ohosItemInfo[OHOS_SECTION_COUNT] = { g_ohosPostProcess, g_ohosCameraSecure, g_ohosCameraXmage, + g_ohosStreamControl, }; } // namespace Camera #endif /* CAMERA_METADATA_ITEM_INFO_H */ diff --git a/camera/metadata/include/camera_metadata_operator.h b/camera/metadata/include/camera_metadata_operator.h index 3b1e4e65fe1446f5ff3c61e1025a3d0a2c616fae..08b22b7dc3a82417505a74cce656cf3aa292a578 100644 --- a/camera/metadata/include/camera_metadata_operator.h +++ b/camera/metadata/include/camera_metadata_operator.h @@ -33,6 +33,7 @@ #define INDEX_COUNTER 2 #define WRAP_LENGTH 4 +#define ENTRY_DATA_SIZE 4 // data type enum { @@ -131,6 +132,7 @@ typedef enum camera_metadata_sec { OHOS_SECTION_CAMERA_EFFECT, OHOS_SECTION_CAMERA_SECURE, OHOS_SECTION_CAMERA_XMAGE, + OHOS_SECTION_STREAM_CONTROL, OHOS_SECTION_COUNT, } camera_metadata_sec_t; @@ -201,7 +203,7 @@ uint32_t GetCameraMetadataItemCapacity(const common_metadata_header_t *metadata_ uint32_t GetCameraMetadataDataSize(const common_metadata_header_t *metadata_header); int32_t CopyCameraMetadataItems(common_metadata_header_t *newMetadata, const common_metadata_header_t *oldMetadata); -size_t CalculateCameraMetadataItemDataSize(uint32_t type, size_t data_count); +int32_t CalculateCameraMetadataItemDataSize(uint32_t type, size_t data_count); int32_t GetCameraMetadataItemType(uint32_t item, uint32_t *data_type); common_metadata_header_t *FillCameraMetadata(common_metadata_header_t *buffer, size_t memoryRequired, uint32_t itemCapacity, uint32_t dataCapacity); diff --git a/camera/metadata/include/metadata_utils.h b/camera/metadata/include/metadata_utils.h index e0203426acb0b506205329a7458437d41ef950a3..0c33995daf968beab260420cf877dcc5d75b13f4 100644 --- a/camera/metadata/include/metadata_utils.h +++ b/camera/metadata/include/metadata_utils.h @@ -23,6 +23,7 @@ #include "camera_metadata_info.h" #include "message_parcel.h" +#include "camera_metadata_item_info.h" namespace OHOS::Camera { class MetadataUtils { diff --git a/camera/metadata/src/camera_metadata_info.cpp b/camera/metadata/src/camera_metadata_info.cpp index c78abd0a0e0e371b9b16ed0b2be05a4222194c69..f9417628c9b05752f8042928ed7ad8061c819007 100644 --- a/camera/metadata/src/camera_metadata_info.cpp +++ b/camera/metadata/src/camera_metadata_info.cpp @@ -20,10 +20,12 @@ #include #include #include +#include #include "camera_metadata_item_info.h" #include "camera_vendor_tag.h" namespace OHOS::Camera { +static std::mutex mtx_; static CameraVendorTag* g_vendorTagImpl = nullptr; const char* g_exampleVendorTagLib = "libcamera_example_vendor_tag_impl.z.so"; const char* g_vendorTagLib = "libcamera_vendor_tag_impl.z.so"; @@ -63,10 +65,10 @@ const std::vector g_metadataTags = { OHOS_ABILITY_STATISTICS_DETECT_TYPE, OHOS_CONTROL_STATISTICS_DETECT_SETTING, OHOS_ABILITY_AVAILABLE_EXTENDED_STREAM_INFO_TYPES, - OHOS_ABILITY_AOTU_DEFERRED_VIDEO_ENHANCE, - OHOS_CONTROL_AOTU_DEFERRED_VIDEO_ENHANCE, - OHOS_ABILITY_AOTU_CLOUD_IMAGE_ENHANCE, - OHOS_CONTROL_AOTU_CLOUD_IMAGE_ENHANCE, + OHOS_ABILITY_AUTO_DEFERRED_VIDEO_ENHANCE, + OHOS_CONTROL_AUTO_DEFERRED_VIDEO_ENHANCE, + OHOS_ABILITY_AUTO_CLOUD_IMAGE_ENHANCE, + OHOS_CONTROL_AUTO_CLOUD_IMAGE_ENHANCE, OHOS_ABILITY_TRIPOD_DETECTION, OHOS_CONTROL_TRIPOD_DETECTION, OHOS_CONTROL_TRIPOD_STABLITATION, @@ -76,6 +78,19 @@ const std::vector g_metadataTags = { OHOS_CONTROL_LOW_LIGHT_DETECT, OHOS_CONTROL_LOW_LIGHT_BOOST, OHOS_STATUS_LOW_LIGHT_DETECTION, + OHOS_STATUS_CAMERA_LENS_DIRTY_DETECTION, + OHOS_DEVICE_PROTECTION_STATE, + OHOS_STATUS_TOF_SENSOR_ABNORMAL, + OHOS_ABILITY_SUN_BLOCK_PREVIEW_TYPES, + OHOS_ABILITY_SUN_BLOCK_BLEND_COLORS, + OHOS_ABILITY_SUN_BLOCK_RGB_CROP_REGION, + OHOS_ABILITY_SUN_BLOCK_RGB_UV_REGION, + OHOS_STATUS_SUN_BLOCK_HINT, + OHOS_ABILITY_AUTO_AIGC_PHOTO, + OHOS_CONTROL_AUTO_AIGC_PHOTO, + OHOS_ABILITY_CAMERA_LIMITED_CAPABILITIES, + OHOS_ABILITY_CAMERA_CONCURRENT_TYPE, + OHOS_ABILITY_CONCURRENT_SUPPORTED_CAMERAS, OHOS_SENSOR_EXPOSURE_TIME, OHOS_SENSOR_COLOR_CORRECTION_GAINS, @@ -106,6 +121,7 @@ const std::vector g_metadataTags = { OHOS_STATISTICS_DETECT_DOG_BODY_INFOS, OHOS_STATISTICS_DETECT_SALIENT_INFOS, OHOS_STATISTICS_DETECT_BAR_CODE_INFOS, + OHOS_STATISTICS_DETECT_BASE_FACE_INFO, OHOS_CONTROL_AE_ANTIBANDING_MODE, OHOS_CONTROL_AE_EXPOSURE_COMPENSATION, @@ -152,6 +168,15 @@ const std::vector g_metadataTags = { OHOS_CONTROL_SENSOR_WB_VALUE, OHOS_CONTROL_HIGH_QUALITY_MODE, OHOS_CONTROL_BURST_CAPTURE, + OHOS_CONTROL_CAMERA_USED_AS_POSITION, + OHOS_CONTROL_CAMERA_SESSION_USAGE, + OHOS_CONTROL_EJECT_RETRY, + OHOS_CONTROL_FALL_PROTECTION, + OHOS_CONTROL_SUN_BLOCK_PREVIEW_TYPE, + OHOS_CONTROL_SUN_BLOCK_BLEND_COLOR, + OHOS_CONTROL_QUALITY_PRIORITIZATION, + OHOS_CONTROL_AUTO_VIDEO_FRAME_RATE, + OHOS_ABILITY_AUTO_VIDEO_FRAME_RATE, // Camera device image acquisition related OHOS_ABILITY_DEVICE_AVAILABLE_EXPOSUREMODES, @@ -175,6 +200,12 @@ const std::vector g_metadataTags = { OHOS_CONTROL_LENS_FOCUS_DISTANCE, OHOS_ABILITY_EQUIVALENT_FOCUS, OHOS_CONTROL_FOCUS_DISTANCE, + OHOS_ABILITY_FOCUS_RANGE_TYPES, + OHOS_CONTROL_FOCUS_RANGE_TYPE, + OHOS_CONTROL_FOCUS_TRACKING_MODE, + OHOS_ABILITY_FOCUS_TRACKING_REGION, + OHOS_ABILITY_FOCUS_DRIVEN_TYPES, + OHOS_CONTROL_FOCUS_DRIVEN_TYPE, OHOS_ABILITY_DEVICE_AVAILABLE_AWBMODES, OHOS_ABILITY_AWB_MODES, @@ -195,6 +226,7 @@ const std::vector g_metadataTags = { OHOS_CONTROL_SMOOTH_ZOOM_RATIOS, OHOS_CONTROL_PREPARE_ZOOM, OHOS_ABILITY_CAMERA_ZOOM_PERFORMANCE, + OHOS_ABILITY_CAMERA_ZOOM_BEZIER_CURVC_POINT, // Camera flow control related OHOS_ABILITY_STREAM_AVAILABLE_BASIC_CONFIGURATIONS, @@ -205,6 +237,11 @@ const std::vector g_metadataTags = { OHOS_ABILITY_SCENE_STREAM_QUICK_THUMBNAIL_AVAILABLE, OHOS_ABILITY_DEFERRED_IMAGE_DELIVERY, OHOS_CONTROL_DEFERRED_IMAGE_DELIVERY, + OHOS_ABILITY_PRERECORD, + OHOS_CONTROL_PRERECORD_MODE, + OHOS_CONTROL_RECORD_STATE, + OHOS_ABILITY_CHANGETO_OFFLINE_STREAM_OPEATOR, + OHOS_CONTROL_CHANGETO_OFFLINE_STREAM_OPEATOR, OHOS_JPEG_GPS_COORDINATES, OHOS_JPEG_GPS_PROCESSING_METHOD, @@ -279,6 +316,30 @@ const std::vector g_metadataTags = { OHOS_CONTROL_TIME_LAPSE_RECORD_STATE, OHOS_CONTROL_TIME_LAPSE_PREVIEW_TYPE, OHOS_ABILITY_TIME_LAPSE_INTERVAL_RANGE, + OHOS_ABILITY_LCD_FLASH, + OHOS_CONTROL_LCD_FLASH_DETECTION, + OHOS_CONTROL_LCD_FLASH, + OHOS_STATUS_LCD_FLASH_STATUS, + OHOS_ABILITY_DEPTH_DATA_DELIVERY, + OHOS_CONTROL_DEPTH_DATA_DELIVERY_SWITCH, + OHOS_ABILITY_DEPTH_DATA_PROFILES, + OHOS_CONTROL_DEPTH_DATA_ACCURACY, + OHOS_ABILITY_CAMERA_IS_RETRACTABLE, + OHOS_CONTROL_CAMERA_CLOSE_AFTER_SECONDS, + OHOS_ABILITY_CAPTURE_MACRO_DEPTH_FUSION_SUPPORTED, + OHOS_ABILITY_CAPTURE_MACRO_DEPTH_FUSION_ZOOM_RANGE, + OHOS_CONTROL_CAPTURE_MACRO_DEPTH_FUSION, + OHOS_ABILITY_CAMERA_PORTRAIT_THEME_SUPPORTED, + OHOS_ABILITY_CAMERA_PORTRAIT_THEME_TYPES, + OHOS_CONTROL_CAMERA_PORTRAIT_THEME_TYPE, + OHOS_ABILITY_CAMERA_VIDEO_ROTATION_SUPPORTED, + OHOS_ABILITY_CAMERA_VIDEO_ROTATION, + OHOS_CONTROL_CAMERA_VIDEO_ROTATION, + OHOS_MOVING_PHOTO_BUFFER_DURATION, + OHOS_MOVING_PHOTO_START, + OHOS_MOVING_PHOTO_END, + OHOS_ABILITY_COLOR_RESERVATION_TYPES, + OHOS_CONTROL_COLOR_RESERVATION_TYPE, // camera secure related OHOS_CONTROL_SECURE_FACE_MODE, @@ -309,7 +370,8 @@ std::map g_metadataSectionMap = { {OHOS_STREAM_VIDEO, OHOS_SECTION_STREAM_VIDEO}, {OHOS_CAMERA_EFFECT, OHOS_SECTION_CAMERA_EFFECT}, {OHOS_CAMERA_SECURE, OHOS_SECTION_CAMERA_SECURE}, - {OHOS_XMAGE_COLOR_ABILITY, OHOS_SECTION_CAMERA_XMAGE} + {OHOS_XMAGE_COLOR_ABILITY, OHOS_SECTION_CAMERA_XMAGE}, + {OHOS_STREAM_CONTROL, OHOS_SECTION_STREAM_CONTROL}, }; CameraMetadata::CameraMetadata(size_t itemCapacity, size_t dataCapacity) @@ -319,6 +381,7 @@ CameraMetadata::CameraMetadata(size_t itemCapacity, size_t dataCapacity) CameraMetadata::~CameraMetadata() { + std::lock_guard lockGuard(mtx_); if (metadata_) { FreeCameraMetadataBuffer(metadata_); metadata_ = nullptr; @@ -363,7 +426,11 @@ bool CameraMetadata::resize_add_metadata(uint32_t item, const void *data, size_t METADATA_ERR_LOG("GetCameraMetadataItemType invalid item type"); return false; } - size_t size = CalculateCameraMetadataItemDataSize(data_type, data_count); + int32_t size = CalculateCameraMetadataItemDataSize(data_type, data_count); + if (size == CAM_META_FAILURE) { + METADATA_ERR_LOG("CalculateCameraMetadataItemDataSize invalid datatype:%{public}d", data_type); + return false; + } common_metadata_header_t *newMetadata = AllocateCameraMetadataBuffer((itemCapacity + 1) * INDEX_COUNTER, AlignTo((data_capacity + size) * INDEX_COUNTER, DATA_ALIGNMENT)); @@ -377,6 +444,7 @@ bool CameraMetadata::resize_add_metadata(uint32_t item, const void *data, size_t if (result != CAM_META_SUCCESS) { METADATA_ERR_LOG("Failed to copy the old metadata to new metadata"); FreeCameraMetadataBuffer(newMetadata); + newMetadata = nullptr; return false; } @@ -384,6 +452,7 @@ bool CameraMetadata::resize_add_metadata(uint32_t item, const void *data, size_t if (result != CAM_META_SUCCESS) { METADATA_ERR_LOG("Failed to add new entry"); FreeCameraMetadataBuffer(newMetadata); + newMetadata = nullptr; return false; } replace_metadata(newMetadata); @@ -397,7 +466,10 @@ void CameraMetadata::replace_metadata(common_metadata_header_t *newMetadata) return; } - FreeCameraMetadataBuffer(metadata_); + std::lock_guard lockGuard(mtx_); + if (metadata_ != nullptr) { + FreeCameraMetadataBuffer(metadata_); + } metadata_ = newMetadata; } @@ -465,6 +537,10 @@ uint8_t *CameraMetadata::GetMetadataData(const common_metadata_header_t *metadat camera_metadata_item_entry_t *CameraMetadata::GetMetadataItems(const common_metadata_header_t *metadataHeader) { + if (metadataHeader == nullptr) { + METADATA_ERR_LOG("GetMetadataItems metadataHeader is null"); + return nullptr; + } return reinterpret_cast( (reinterpret_cast(const_cast(metadataHeader)) + metadataHeader->items_start)); @@ -487,11 +563,16 @@ common_metadata_header_t *CameraMetadata::FillCameraMetadata(common_metadata_hea metadataHeader->items_start = AlignTo(sizeof(common_metadata_header_t), ITEM_ALIGNMENT); metadataHeader->data_count = 0; metadataHeader->data_capacity = dataCapacity; - size_t dataUnaligned = reinterpret_cast(GetMetadataItems(metadataHeader) + - metadataHeader->item_capacity) - reinterpret_cast(metadataHeader); + camera_metadata_item_entry_t *pItem = GetMetadataItems(metadataHeader); + if (pItem == nullptr) { + METADATA_ERR_LOG("FillCameraMetadata pItem is null"); + return nullptr; + } + size_t dataUnaligned = reinterpret_cast(pItem + metadataHeader->item_capacity) - + reinterpret_cast(metadataHeader); metadataHeader->data_start = AlignTo(dataUnaligned, DATA_ALIGNMENT); - METADATA_INFO_LOG("MetadataHeader ItemCapacity Size = %{public}u, DataCapacity Size = %{public}u", + METADATA_DEBUG_LOG("MetadataHeader ItemCapacity Size = %{public}u, DataCapacity Size = %{public}u", metadataHeader->item_capacity, metadataHeader->data_capacity); METADATA_DEBUG_LOG("FillCameraMetadata end"); return metadataHeader; @@ -584,6 +665,11 @@ int32_t CameraMetadata::GetMetadataSection(uint32_t itemSection, uint32_t *secti return CAM_META_FAILURE; } + if (section == nullptr) { + METADATA_ERR_LOG("GetMetadataSection section is nullptr"); + return CAM_META_FAILURE; + } + int32_t ret = CAM_META_SUCCESS; auto iter = g_metadataSectionMap.find(itemSection); if (iter != g_metadataSectionMap.end()) { @@ -669,12 +755,12 @@ const char *CameraMetadata::GetCameraMetadataItemName(uint32_t item) return g_ohosItemInfo[section][itemIndex].item_name; } -size_t CameraMetadata::CalculateCameraMetadataItemDataSize(uint32_t type, size_t dataCount) +int32_t CameraMetadata::CalculateCameraMetadataItemDataSize(uint32_t type, size_t dataCount) { METADATA_DEBUG_LOG("CalculateCameraMetadataItemDataSize start"); if (type < META_TYPE_BYTE || type >= META_NUM_TYPES) { METADATA_ERR_LOG("CalculateCameraMetadataItemDataSize invalid type"); - return 0; + return CAM_META_FAILURE; } size_t dataBytes = dataCount * OHOS_CAMERA_METADATA_TYPE_SIZE[type]; @@ -716,6 +802,11 @@ int CameraMetadata::AddCameraMetadataItemVerify(common_metadata_header_t *dst, return CAM_META_INVALID_PARAM; } + if (*dataType < META_TYPE_BYTE || *dataType >= META_NUM_TYPES) { + METADATA_ERR_LOG("AddCameraMetadataItemVerify invalid type"); + return CAM_META_INVALID_PARAM; + } + return CAM_META_SUCCESS; } @@ -733,14 +824,19 @@ int CameraMetadata::AddCameraMetadataItem(common_metadata_header_t *dst, uint32_ return CAM_META_INVALID_PARAM; } - size_t dataBytes = CalculateCameraMetadataItemDataSize(dataType, dataCount); + int32_t dataBytes = CalculateCameraMetadataItemDataSize(dataType, dataCount); if (dataBytes + dst->data_count > dst->data_capacity) { METADATA_ERR_LOG("AddCameraMetadataItem data_capacity limit reached"); return CAM_META_DATA_CAP_EXCEED; } size_t dataPayloadBytes = dataCount * OHOS_CAMERA_METADATA_TYPE_SIZE[dataType]; - camera_metadata_item_entry_t *metadataItem = GetMetadataItems(dst) + dst->item_count; + camera_metadata_item_entry_t *pItem = GetMetadataItems(dst); + if (pItem == nullptr) { + METADATA_ERR_LOG("AddCameraMetadataItem pItem is null"); + return CAM_META_INVALID_PARAM; + } + camera_metadata_item_entry_t *metadataItem = pItem + dst->item_count; ret = memset_s(metadataItem, sizeof(camera_metadata_item_entry_t), 0, sizeof(camera_metadata_item_entry_t)); if (ret != EOK) { METADATA_ERR_LOG("AddCameraMetadataItem: memset_s failed"); @@ -791,21 +887,28 @@ int CameraMetadata::GetCameraMetadataItem(const common_metadata_header_t *src, u METADATA_ERR_LOG("GetCameraMetadataItem: memset_s failed"); return CAM_META_FAILURE; } - if (index >= src->item_count) { + if (index >= src->item_count || index >= src->item_capacity) { METADATA_ERR_LOG("GetCameraMetadataItem index is greater than item count"); return CAM_META_INVALID_PARAM; } - - camera_metadata_item_entry_t *localItem = GetMetadataItems(src) + index; + camera_metadata_item_entry_t *pItem = GetMetadataItems(src); + if (pItem == nullptr) { + METADATA_ERR_LOG("GetCameraMetadataItem pItem is null"); + return CAM_META_INVALID_PARAM; + } + camera_metadata_item_entry_t *localItem = pItem + index; item->index = index; item->item = localItem->item; item->data_type = localItem->data_type; item->count = localItem->count; - size_t dataBytes = CalculateCameraMetadataItemDataSize(localItem->data_type, localItem->count); + int32_t dataBytes = CalculateCameraMetadataItemDataSize(localItem->data_type, localItem->count); if (dataBytes == 0) { item->data.u8 = localItem->data.value; + } else if (dataBytes == CAM_META_FAILURE) { + METADATA_ERR_LOG("GetCameraMetadataItem invalid datatype:%{public}d", localItem->data_type); + return CAM_META_FAILURE; } else { uint8_t *srcMetadataData = GetMetadataData(src); if (srcMetadataData == nullptr) { @@ -898,6 +1001,12 @@ int CameraMetadata::MetadataExpandItemMem(common_metadata_header_t *dst, camera_ METADATA_ERR_LOG("MetadataExpandItemMem GetMetadataData failed"); return CAM_META_FAILURE; } + if (item->data.offset > UINT32_MAX - (uint32_t)oldItemSize || + item->data.offset + (uint32_t)oldItemSize > dst->data_count) { + METADATA_ERR_LOG("MetadataExpandItemMem data.offset:%{public}u, oldItemSize:%{public}zu, " + "dst->data_count:%{public}u", item->data.offset, oldItemSize, dst->data_count); + return CAM_META_FAILURE; + } uint8_t *start = dstMetadataData + item->data.offset; uint8_t *end = start + oldItemSize; size_t length = dst->data_count - item->data.offset - oldItemSize; @@ -924,7 +1033,7 @@ int CameraMetadata::copyMetadataMemory(common_metadata_header_t *dst, camera_met uint8_t *dstMetadataData = GetMetadataData(dst); int32_t ret = CAM_META_SUCCESS; if (dstMetadataData == nullptr) { - METADATA_ERR_LOG("UpdateameraMetadataItemSize GetMetadataData failed"); + METADATA_ERR_LOG("UpdateCameraMetadataItemSize GetMetadataData failed"); return CAM_META_FAILURE; } ret = memcpy_s(dstMetadataData + item->data.offset, dataPayloadSize, data, dataPayloadSize); @@ -935,19 +1044,22 @@ int CameraMetadata::copyMetadataMemory(common_metadata_header_t *dst, camera_met return CAM_META_SUCCESS; } -int CameraMetadata::UpdateameraMetadataItemSize(camera_metadata_item_entry_t *item, uint32_t dataCount, +int CameraMetadata::UpdateCameraMetadataItemSize(camera_metadata_item_entry_t *item, uint32_t dataCount, common_metadata_header_t *dst, const void *data) { if (item == nullptr) { - METADATA_ERR_LOG("UpdateameraMetadataItemSize item is null"); + METADATA_ERR_LOG("UpdateCameraMetadataItemSize item is null"); + return CAM_META_FAILURE; + } else if (item->data_type < META_TYPE_BYTE || item->data_type >= META_NUM_TYPES) { + METADATA_ERR_LOG("UpdateCameraMetadataItemSize invalid datatype:%{public}d", item->data_type); return CAM_META_FAILURE; } - size_t dataSize = CalculateCameraMetadataItemDataSize(item->data_type, dataCount); + int32_t dataSize = CalculateCameraMetadataItemDataSize(item->data_type, dataCount); size_t dataPayloadSize = dataCount * OHOS_CAMERA_METADATA_TYPE_SIZE[item->data_type]; - size_t oldItemSize = CalculateCameraMetadataItemDataSize(item->data_type, item->count); + int32_t oldItemSize = CalculateCameraMetadataItemDataSize(item->data_type, item->count); int32_t ret = CAM_META_SUCCESS; if (item == nullptr || dst == nullptr) { - METADATA_ERR_LOG("UpdateameraMetadataItemSize item is null or dst is null"); + METADATA_ERR_LOG("UpdateCameraMetadataItemSize item is null or dst is null"); return CAM_META_FAILURE; } if (dataSize != oldItemSize) { @@ -955,14 +1067,12 @@ int CameraMetadata::UpdateameraMetadataItemSize(camera_metadata_item_entry_t *it METADATA_ERR_LOG("UpdateCameraMetadataItemByIndex data_capacity limit reached"); return CAM_META_DATA_CAP_EXCEED; } - if (oldItemSize != 0) { ret = MetadataExpandItemMem(dst, item, oldItemSize); if (ret != CAM_META_SUCCESS) { return ret; } } - if (dataSize != 0) { item->data.offset = dst->data_count; ret = copyMetadataMemory(dst, item, dataPayloadSize, data); @@ -977,7 +1087,6 @@ int CameraMetadata::UpdateameraMetadataItemSize(camera_metadata_item_entry_t *it return ret; } } - if (dataSize == 0) { ret = memcpy_s(item->data.value, dataPayloadSize, data, dataPayloadSize); if (ret != EOK) { @@ -1006,7 +1115,7 @@ int CameraMetadata::UpdateCameraMetadataItemByIndex(common_metadata_header_t *ds int32_t ret = CAM_META_SUCCESS; camera_metadata_item_entry_t *item = GetMetadataItems(dst) + index; - ret = UpdateameraMetadataItemSize(item, dataCount, dst, data); + ret = UpdateCameraMetadataItemSize(item, dataCount, dst, data); if (ret != CAM_META_SUCCESS) { return ret; } @@ -1051,9 +1160,13 @@ int CameraMetadata::UpdateCameraMetadataItem(common_metadata_header_t *dst, uint int CameraMetadata::moveMetadataMemery(common_metadata_header_t *dst, camera_metadata_item_entry_t *itemToDelete, size_t dataBytes) { + if (itemToDelete == nullptr) { + METADATA_ERR_LOG("UpdateCameraMetadataItemSize itemToDelete is null"); + return CAM_META_INVALID_PARAM; + } uint8_t *dstMetadataData = GetMetadataData(dst); if (dstMetadataData == nullptr) { - METADATA_ERR_LOG("UpdateameraMetadataItemSize GetMetadataData failed"); + METADATA_ERR_LOG("UpdateCameraMetadataItemSize GetMetadataData failed"); return CAM_META_FAILURE; } int32_t ret = CAM_META_SUCCESS; @@ -1084,8 +1197,13 @@ int CameraMetadata::DeleteCameraMetadataItemByIndex(common_metadata_header_t *ds } int32_t ret = CAM_META_SUCCESS; - camera_metadata_item_entry_t *itemToDelete = GetMetadataItems(dst) + index; - size_t dataBytes = CalculateCameraMetadataItemDataSize(itemToDelete->data_type, itemToDelete->count); + camera_metadata_item_entry_t *pItem = GetMetadataItems(dst); + if (pItem == nullptr) { + METADATA_ERR_LOG("DeleteCameraMetadataItemByIndex pItem is null"); + return CAM_META_INVALID_PARAM; + } + camera_metadata_item_entry_t *itemToDelete = pItem + index; + int32_t dataBytes = CalculateCameraMetadataItemDataSize(itemToDelete->data_type, itemToDelete->count); if (dataBytes > 0) { ret = moveMetadataMemery(dst, itemToDelete, dataBytes); if (ret != CAM_META_SUCCESS) { @@ -1101,6 +1219,9 @@ int CameraMetadata::DeleteCameraMetadataItemByIndex(common_metadata_header_t *ds metadataItems->data.offset -= dataBytes; } } + } else if (dataBytes == CAM_META_FAILURE) { + METADATA_ERR_LOG("DeleteCameraMetadataItemByIndex invalid datatype:%{public}d", itemToDelete->data_type); + return CAM_META_FAILURE; } uint64_t length = sizeof(camera_metadata_item_entry_t) * (dst->item_count - index - 1); @@ -1184,7 +1305,7 @@ int32_t CameraMetadata::CopyCameraMetadataItems(common_metadata_header_t *newMet uint8_t *newMetadataData = GetMetadataData(newMetadata); uint8_t *oldMetadataData = GetMetadataData(oldMetadata); if (newMetadataData == nullptr || oldMetadataData == nullptr) { - METADATA_ERR_LOG("UpdateameraMetadataItemSize GetMetadataData failed"); + METADATA_ERR_LOG("UpdateCameraMetadataItemSize GetMetadataData failed"); return CAM_META_FAILURE; } ret = memcpy_s(newMetadataData, sizeof(uint8_t[newMetadata->data_capacity]), oldMetadataData, @@ -1470,7 +1591,7 @@ std::string CameraMetadata::FormatCameraMetadataToString(const common_metadata_h for (auto it = g_metadataTags.begin(); it != g_metadataTags.end(); it++) { metaStr += MetadataItemDump(metadataHeader, *it); } - METADATA_INFO_LOG("metadataHeader item = %{public}s", metaStr.c_str()); + METADATA_DEBUG_LOG("metadataHeader item = %{public}s", metaStr.c_str()); return metaStr; } diff --git a/camera/metadata/src/camera_metadata_operator.cpp b/camera/metadata/src/camera_metadata_operator.cpp index 26dee9218223d05ea9418d207122558dc42e508e..5a7056a06e5eb7d6c1f507e1873449da0dca5d15 100644 --- a/camera/metadata/src/camera_metadata_operator.cpp +++ b/camera/metadata/src/camera_metadata_operator.cpp @@ -52,7 +52,7 @@ const char *GetCameraMetadataItemName(uint32_t item) return CameraMetadata::GetCameraMetadataItemName(item); } -size_t CalculateCameraMetadataItemDataSize(uint32_t type, size_t dataCount) +int32_t CalculateCameraMetadataItemDataSize(uint32_t type, size_t dataCount) { return CameraMetadata::CalculateCameraMetadataItemDataSize(type, dataCount); } diff --git a/camera/metadata/src/metadata_utils.cpp b/camera/metadata/src/metadata_utils.cpp index 40cb21571a56703971c6da5aafea55f1f4db5a13..576fc97e947541aa5d39112d07b4ccd5ba9edff4 100644 --- a/camera/metadata/src/metadata_utils.cpp +++ b/camera/metadata/src/metadata_utils.cpp @@ -69,12 +69,6 @@ bool MetadataUtils::ConvertMetadataToVec(const std::shared_ptr & } common_metadata_header_t *meta = metadata->get(); - if (meta == nullptr) { - WriteData(0, cameraAbility); - METADATA_WARNING_LOG("ConvertMetadataToVec tagCount is 0!"); - return true; - } - uint32_t tagCount = GetCameraMetadataItemCount(meta); if (tagCount > MAX_SUPPORTED_TAGS) { METADATA_ERR_LOG("ConvertMetadataToVec tagCount out of range:%{public}d", tagCount); @@ -108,8 +102,13 @@ bool MetadataUtils::ConvertMetadataToVec(const std::shared_ptr & WriteData(item.data_type, cameraAbility); WriteData(item.count, cameraAbility); if (item.count > MAX_SUPPORTED_ITEMS) { - METADATA_ERR_LOG("ConvertMetadataToVec item.count out of range:%{public}d item:%{public}d", - item.count, item.item); + METADATA_ERR_LOG("ConvertMetadataToVec item.count out of range:%{public}d", item.count); + return false; + } + uint32_t dataPayloadBytes = item.count * OHOS_CAMERA_METADATA_TYPE_SIZE[item.data_type]; + if (item.count > ENTRY_DATA_SIZE && + ((item.data.u8 + dataPayloadBytes) > (GetMetadataData(meta) + dataCapacity))) { + METADATA_ERR_LOG("ConvertMetadataToVec get meta item failed!"); return false; } WriteMetadataDataToVec(item, cameraAbility); @@ -265,6 +264,10 @@ void MetadataUtils::ConvertVecToMetadata(const std::vector& cameraAbili uint32_t itemCapacity = 0; uint32_t dataCapacity = 0; + if (cameraAbility.size() < MIN_VEC_SIZE) { + METADATA_ERR_LOG("ConvertVecToMetadata cameraAbility size:%{public}d", static_cast(cameraAbility.size())); + return; + } ReadData(tagCount, index, cameraAbility); if (tagCount > MAX_SUPPORTED_TAGS) { METADATA_ERR_LOG("ConvertVecToMetadata tagCount out of range:%{public}d", tagCount); @@ -358,41 +361,17 @@ bool MetadataUtils::WriteMetadata(const camera_metadata_item_t &item, MessagePar bool bRet = false; size_t i; if (item.data_type == META_TYPE_BYTE) { - std::vector byteBuffers; - for (i = 0; i < item.count; i++) { - byteBuffers.push_back(*(item.data.u8 + i)); - } - bRet = data.WriteUInt8Vector(byteBuffers); + bRet = data.WriteUnpadBuffer(item.data.u8, item.count * sizeof(uint8_t)); } else if (item.data_type == META_TYPE_INT32) { - std::vector int32Buffers; - for (i = 0; i < item.count; i++) { - int32Buffers.push_back(*(item.data.i32 + i)); - } - bRet = data.WriteInt32Vector(int32Buffers); + bRet = data.WriteUnpadBuffer(item.data.i32, item.count * sizeof(int32_t)); } else if (item.data_type == META_TYPE_FLOAT) { - std::vector floatBuffers; - for (i = 0; i < item.count; i++) { - floatBuffers.push_back(*(item.data.f + i)); - } - bRet = data.WriteFloatVector(floatBuffers); + bRet = data.WriteUnpadBuffer(item.data.f, item.count * sizeof(float)); } else if (item.data_type == META_TYPE_UINT32) { - std::vector uInt32Buffers; - for (i = 0; i < item.count; i++) { - uInt32Buffers.push_back(*(item.data.ui32 + i)); - } - bRet = data.WriteUInt32Vector(uInt32Buffers); + bRet = data.WriteUnpadBuffer(item.data.ui32, item.count * sizeof(uint32_t)); } else if (item.data_type == META_TYPE_INT64) { - std::vector int64Buffers; - for (i = 0; i < item.count; i++) { - int64Buffers.push_back(*(item.data.i64 + i)); - } - bRet = data.WriteInt64Vector(int64Buffers); + bRet = data.WriteUnpadBuffer(item.data.i64, item.count * sizeof(int64_t)); } else if (item.data_type == META_TYPE_DOUBLE) { - std::vector doubleBuffers; - for (i = 0; i < item.count; i++) { - doubleBuffers.push_back(*(item.data.d + i)); - } - bRet = data.WriteDoubleVector(doubleBuffers); + bRet = data.WriteUnpadBuffer(item.data.d, item.count * sizeof(double)); } else if (item.data_type == META_TYPE_RATIONAL) { std::vector rationalBuffers; for (i = 0; i < item.count; i++) { @@ -566,73 +545,61 @@ int MetadataUtils::copyDecodeFromStringMem(common_metadata_header_t *meta, char static void ReadMetadataUInt8(camera_metadata_item_t &entry, MessageParcel &data) { - std::vector buffers; - data.ReadUInt8Vector(&buffers); entry.data.u8 = new(std::nothrow) uint8_t[entry.count]; if (entry.data.u8 != nullptr) { - for (size_t i = 0; i < entry.count && i < buffers.size(); i++) { - entry.data.u8[i] = buffers.at(i); - } + size_t dataSize = entry.count * sizeof(uint8_t); + const uint8_t* ptr = data.ReadUnpadBuffer(dataSize); + memcpy_s(entry.data.u8, dataSize, ptr, dataSize); } } static void ReadMetadataInt32(camera_metadata_item_t &entry, MessageParcel &data) { - std::vector buffers; - data.ReadInt32Vector(&buffers); entry.data.i32 = new(std::nothrow) int32_t[entry.count]; if (entry.data.i32 != nullptr) { - for (size_t i = 0; i < entry.count && i < buffers.size(); i++) { - entry.data.i32[i] = buffers.at(i); - } + size_t dataSize = entry.count * sizeof(int32_t); + const uint8_t* ptr = data.ReadUnpadBuffer(dataSize); + memcpy_s(entry.data.i32, dataSize, ptr, dataSize); } } static void ReadMetadataUInt32(camera_metadata_item_t &entry, MessageParcel &data) { - std::vector buffers; - data.ReadUInt32Vector(&buffers); entry.data.ui32 = new(std::nothrow) uint32_t[entry.count]; if (entry.data.ui32 != nullptr) { - for (size_t i = 0; i < entry.count && i < buffers.size(); i++) { - entry.data.ui32[i] = buffers.at(i); - } + size_t dataSize = entry.count * sizeof(uint32_t); + const uint8_t* ptr = data.ReadUnpadBuffer(dataSize); + memcpy_s(entry.data.ui32, dataSize, ptr, dataSize); } } static void ReadMetadataFloat(camera_metadata_item_t &entry, MessageParcel &data) { - std::vector buffers; - data.ReadFloatVector(&buffers); entry.data.f = new(std::nothrow) float[entry.count]; if (entry.data.f != nullptr) { - for (size_t i = 0; i < entry.count && i < buffers.size(); i++) { - entry.data.f[i] = buffers.at(i); - } + size_t dataSize = entry.count * sizeof(float); + const uint8_t* ptr = data.ReadUnpadBuffer(dataSize); + memcpy_s(entry.data.f, dataSize, ptr, dataSize); } } static void ReadMetadataInt64(camera_metadata_item_t &entry, MessageParcel &data) { - std::vector buffers; - data.ReadInt64Vector(&buffers); entry.data.i64 = new(std::nothrow) int64_t[entry.count]; if (entry.data.i64 != nullptr) { - for (size_t i = 0; i < entry.count && i < buffers.size(); i++) { - entry.data.i64[i] = buffers.at(i); - } + size_t dataSize = entry.count * sizeof(int64_t); + const uint8_t* ptr = data.ReadUnpadBuffer(dataSize); + memcpy_s(entry.data.i64, dataSize, ptr, dataSize); } } static void ReadMetadataDouble(camera_metadata_item_t &entry, MessageParcel &data) { - std::vector buffers; - data.ReadDoubleVector(&buffers); entry.data.d = new(std::nothrow) double[entry.count]; if (entry.data.d != nullptr) { - for (size_t i = 0; i < entry.count && i < buffers.size(); i++) { - entry.data.d[i] = buffers.at(i); - } + size_t dataSize = entry.count * sizeof(double); + const uint8_t* ptr = data.ReadUnpadBuffer(dataSize); + memcpy_s(entry.data.d, dataSize, ptr, dataSize); } } diff --git a/camera/sequenceable/buffer_handle/BUILD.gn b/camera/sequenceable/buffer_handle/BUILD.gn index 6f6f455990715117920a14dc33288a38aa4571e9..ecff4cfccca197bf1557c6221d18d5696266a692 100644 --- a/camera/sequenceable/buffer_handle/BUILD.gn +++ b/camera/sequenceable/buffer_handle/BUILD.gn @@ -12,7 +12,6 @@ # limitations under the License. import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") import("//drivers/interface/camera/camera.gni") config("buffer_handle_sequenceable_config") { @@ -25,8 +24,6 @@ config("buffer_handle_sequenceable_config") { ohos_shared_library("libbuffer_handle_sequenceable_1.0") { sources = [ "buffer_handle_sequenceable.cpp" ] - all_dependent_configs = [ ":buffer_handle_sequenceable_config" ] - external_deps = [ "c_utils:utils", "hdf_core:libhdf_utils", @@ -35,9 +32,12 @@ ohos_shared_library("libbuffer_handle_sequenceable_1.0") { "hilog:libhilog", "ipc:ipc_single", ] + public_external_deps = [ "graphic_surface:buffer_handle" ] + cflags_cc = [ "-fstack-protector-strong" ] + if (drivers_interface_camera_feature_coverage) { - cflags_cc = [ "--coverage" ] - ldflags = [ "--coverage" ] + cflags_cc += [ "--coverage" ] + ldflags += [ "--coverage" ] } install_images = [ system_base_dir ] relative_install_dir = "chipset-sdk" diff --git a/camera/sequenceable/buffer_producer/BUILD.gn b/camera/sequenceable/buffer_producer/BUILD.gn index 5225a000dadc991b0b1e7ba509b3d905abcc0ba6..e730e9140ac569bda656c865beacd6eed5569650 100644 --- a/camera/sequenceable/buffer_producer/BUILD.gn +++ b/camera/sequenceable/buffer_producer/BUILD.gn @@ -12,7 +12,6 @@ # limitations under the License. import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") import("//drivers/interface/camera/camera.gni") config("camera_sequenceable_config") { @@ -26,19 +25,22 @@ config("camera_sequenceable_config") { ohos_shared_library("libbuffer_producer_sequenceable_1.0") { sources = [ "buffer_producer_sequenceable.cpp" ] - all_dependent_configs = [ ":camera_sequenceable_config" ] public_configs = [ ":camera_sequenceable_config" ] external_deps = [ "c_utils:utils", + "graphic_surface:buffer_handle", "graphic_surface:surface", "hdf_core:libpub_utils", "hilog:libhilog", "ipc:ipc_single", ] + public_external_deps = [ "graphic_surface:buffer_handle" ] + cflags_cc = [ "-fstack-protector-strong" ] + if (drivers_interface_camera_feature_coverage) { - cflags_cc = [ "--coverage" ] - ldflags = [ "--coverage" ] + cflags_cc += [ "--coverage" ] + ldflags += [ "--coverage" ] } install_images = [ system_base_dir ] relative_install_dir = "chipset-sdk" diff --git a/camera/sequenceable/map_data/BUILD.gn b/camera/sequenceable/map_data/BUILD.gn index 4016d891a99e9fd39520b3fd02f1f66ad678985a..06e9f68b98ed20bb590098c41947cd9d0c913f7d 100644 --- a/camera/sequenceable/map_data/BUILD.gn +++ b/camera/sequenceable/map_data/BUILD.gn @@ -12,7 +12,6 @@ # limitations under the License. import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") import("//drivers/interface/camera/camera.gni") config("map_data_sequenceable_config") { @@ -25,7 +24,6 @@ config("map_data_sequenceable_config") { ohos_shared_library("libmap_data_sequenceable_1.0") { sources = [ "map_data_sequenceable.cpp" ] - all_dependent_configs = [ ":map_data_sequenceable_config" ] public_configs = [ ":map_data_sequenceable_config" ] external_deps = [ @@ -35,9 +33,11 @@ ohos_shared_library("libmap_data_sequenceable_1.0") { "hilog:libhilog", "ipc:ipc_single", ] + cflags_cc = [ "-fstack-protector-strong" ] + if (drivers_interface_camera_feature_coverage) { - cflags_cc = [ "--coverage" ] - ldflags = [ "--coverage" ] + cflags_cc += [ "--coverage" ] + ldflags += [ "--coverage" ] } install_images = [ system_base_dir ] relative_install_dir = "chipset-sdk" diff --git a/camera/sequenceable/map_data/map_data_sequenceable.cpp b/camera/sequenceable/map_data/map_data_sequenceable.cpp index 72ca98480a3bbcb4bdba19e1fc0e3f88d13a6bd8..31cd7b670381ab71816e90e3aa4a5889be9cdf34 100644 --- a/camera/sequenceable/map_data/map_data_sequenceable.cpp +++ b/camera/sequenceable/map_data/map_data_sequenceable.cpp @@ -46,8 +46,8 @@ sptr MapDataSequenceable::Unmarshalling(Parcel &parcel) } int32_t size = parcel.ReadInt32(); - if (size > BUFFER_MAX_USER_DATA_COUNT) { - HDI_CAMERA_LOGE("Too much data obtained from Parcel"); + if (size <= 0 || size > BUFFER_MAX_USER_DATA_COUNT) { + HDI_CAMERA_LOGE("invalid size: %{public}d obtained from Parcel", size); return nullptr; } sptr sequenceData(new MapDataSequenceable()); @@ -73,6 +73,10 @@ sptr MapDataSequenceable::Unmarshalling(Parcel &parcel) ret = sequenceData->Set(key, type, parcel.ReadString()); break; } + case MapDataType::U32: { + ret = sequenceData->Set(key, type, parcel.ReadUint32()); + break; + } default: break; } @@ -122,6 +126,13 @@ bool MapDataSequenceable::Marshalling(Parcel &parcel) const dataParcel.WriteString(string); break; } + case MapDataType::U32: { + uint32_t u32 = 0; + auto pVal = std::any_cast(&data.val); + SET_DATA_FROM_POINTER(u32, pVal); + dataParcel.WriteUint32(u32); + break; + } default: break; } @@ -134,6 +145,11 @@ int32_t MapDataSequenceable::Get(const std::string &key, int32_t &value) const return Get(key, MapDataType::I32, value); } +int32_t MapDataSequenceable::Get(const std::string &key, uint32_t &value) const +{ + return Get(key, MapDataType::U32, value); +} + int32_t MapDataSequenceable::Get(const std::string &key, int64_t &value) const { return Get(key, MapDataType::I64, value); @@ -154,6 +170,11 @@ int32_t MapDataSequenceable::Set(const std::string &key, int32_t value) return Set(key, MapDataType::I32, value); } +int32_t MapDataSequenceable::Set(const std::string &key, uint32_t value) +{ + return Set(key, MapDataType::U32, value); +} + int32_t MapDataSequenceable::Set(const std::string &key, int64_t value) { return Set(key, MapDataType::I64, value); diff --git a/camera/sequenceable/map_data/map_data_sequenceable.h b/camera/sequenceable/map_data/map_data_sequenceable.h index 1f6296782e8819d3fb46156ca1955a402dc0d2b3..2a4998a47bce2fde219beb123f0d374f1a0826d5 100644 --- a/camera/sequenceable/map_data/map_data_sequenceable.h +++ b/camera/sequenceable/map_data/map_data_sequenceable.h @@ -36,10 +36,12 @@ public: virtual ~MapDataSequenceable() = default; int32_t Get(const std::string &key, int32_t &value) const; + int32_t Get(const std::string &key, uint32_t &value) const; int32_t Get(const std::string &key, int64_t &value) const; int32_t Get(const std::string &key, double &value) const; int32_t Get(const std::string &key, std::string &value) const; int32_t Set(const std::string &key, int32_t value); + int32_t Set(const std::string &key, uint32_t value); int32_t Set(const std::string &key, int64_t value); int32_t Set(const std::string &key, double value); int32_t Set(const std::string &key, const std::string& value); @@ -54,6 +56,7 @@ private: I64, F64, STRING, + U32, }; template int32_t Get(const std::string &key, MapDataType type, T &value) const; diff --git a/camera/v1_0/BUILD.gn b/camera/v1_0/BUILD.gn index 043bff2925f74f3880d25a91a0bd67196384e0a0..b3b14430f15c6f77af4733113fd2256a356b907f 100644 --- a/camera/v1_0/BUILD.gn +++ b/camera/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("../../../hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") if (defined(ohos_lite)) { group("libcamera_proxy_1.0") { deps = [] @@ -35,7 +35,10 @@ if (defined(ohos_lite)) { sequenceable_pub_deps = [ "../sequenceable/buffer_producer:libbuffer_producer_sequenceable_1.0", ] - sequenceable_ext_deps = [ "graphic_surface:surface" ] + sequenceable_ext_deps = [ + "graphic_surface:buffer_handle", + "graphic_surface:surface", + ] language = "cpp" subsystem_name = "hdf" diff --git a/camera/v1_1/BUILD.gn b/camera/v1_1/BUILD.gn index c3c9a2af7f4d27fc0e3122fa757750014a477347..f90c2bc81077af664ec0259b8b67b70f01eeabc0 100644 --- a/camera/v1_1/BUILD.gn +++ b/camera/v1_1/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") if (defined(ohos_lite)) { group("libcamera_proxy_1.1") { deps = [] @@ -32,7 +32,10 @@ if (defined(ohos_lite)) { sequenceable_pub_deps = [ "../sequenceable/buffer_producer:libbuffer_producer_sequenceable_1.0", ] - sequenceable_ext_deps = [ "graphic_surface:surface" ] + sequenceable_ext_deps = [ + "graphic_surface:buffer_handle", + "graphic_surface:surface", + ] language = "cpp" subsystem_name = "hdf" diff --git a/camera/v1_2/BUILD.gn b/camera/v1_2/BUILD.gn index 003c639657ee8f92524091a5753df488d612ed53..f0bed38eb6f41c4b8dcc1afd4aa7dd76e2b35cb3 100644 --- a/camera/v1_2/BUILD.gn +++ b/camera/v1_2/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") if (defined(ohos_lite)) { group("libcamera_proxy_1.2") { deps = [] @@ -39,7 +39,10 @@ if (defined(ohos_lite)) { "../sequenceable/buffer_producer:libbuffer_producer_sequenceable_1.0", "../sequenceable/map_data:libmap_data_sequenceable_1.0", ] - sequenceable_ext_deps = [ "graphic_surface:surface" ] + sequenceable_ext_deps = [ + "graphic_surface:buffer_handle", + "graphic_surface:surface", + ] language = "cpp" subsystem_name = "hdf" diff --git a/camera/v1_3/BUILD.gn b/camera/v1_3/BUILD.gn index 16d70e862e7c654bb76b5f5aead2043b32b234ec..043b0ad4d8aa10cd9a7bb8303cd12ceb517f17c9 100644 --- a/camera/v1_3/BUILD.gn +++ b/camera/v1_3/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") if (defined(ohos_lite)) { group("libcamera_proxy_1.3") { deps = [] @@ -25,6 +25,9 @@ if (defined(ohos_lite)) { sources = [ "ICameraDevice.idl", "ICameraHost.idl", + "IImageProcessCallback.idl", + "IImageProcessService.idl", + "IStreamOperator.idl", "IStreamOperatorCallback.idl", "IVideoProcessCallback.idl", "IVideoProcessService.idl", @@ -37,7 +40,10 @@ if (defined(ohos_lite)) { "../sequenceable/buffer_producer:libbuffer_producer_sequenceable_1.0", "../sequenceable/map_data:libmap_data_sequenceable_1.0", ] - sequenceable_ext_deps = [ "graphic_surface:surface" ] + sequenceable_ext_deps = [ + "graphic_surface:buffer_handle", + "graphic_surface:surface", + ] language = "cpp" subsystem_name = "hdf" diff --git a/camera/v1_3/ICameraDevice.idl b/camera/v1_3/ICameraDevice.idl index fe92417d1a8462caa992e4800ba515808bedce93..39ac48e2a9c13cc78919af0fda8405c7a86d391e 100644 --- a/camera/v1_3/ICameraDevice.idl +++ b/camera/v1_3/ICameraDevice.idl @@ -26,7 +26,7 @@ package ohos.hdi.camera.v1_3; import ohos.hdi.camera.v1_2.ICameraDevice; import ohos.hdi.camera.v1_3.IStreamOperatorCallback; -import ohos.hdi.camera.v1_2.IStreamOperator; +import ohos.hdi.camera.v1_3.IStreamOperator; interface ICameraDevice extends ohos.hdi.camera.v1_2.ICameraDevice { /** diff --git a/camera/v1_3/IImageProcessCallback.idl b/camera/v1_3/IImageProcessCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..94f71b8c7034d8f25df6415e49597a061ff4b5bf --- /dev/null +++ b/camera/v1_3/IImageProcessCallback.idl @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 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. + */ + +/** + * @file iimage_process_callback.h + * + * @brief Declares callbacks for image process. + * + * @since 5.0 + * @version 1.0 + */ + +package ohos.hdi.camera.v1_3; +import ohos.hdi.camera.v1_3.Types; +import ohos.hdi.camera.v1_2.IImageProcessCallback; + +[callback] interface IImageProcessCallback extends ohos.hdi.camera.v1_2.IImageProcessCallback { + /** + * @brief Called when the process done. + * For details about the reporting mode, see {@link SetResultMode}. + * + * @param imageId Indicates the image ID. + * @param buffer Indicates buffer. + * + * @since 5.0 + * @version 1.0 + */ + OnProcessDoneExt([in] String imageId, [in] ImageBufferInfoExt buffer); +} \ No newline at end of file diff --git a/camera/v1_3/IImageProcessService.idl b/camera/v1_3/IImageProcessService.idl new file mode 100644 index 0000000000000000000000000000000000000000..af3b651426c67d51760c074760e6d4cf5094c872 --- /dev/null +++ b/camera/v1_3/IImageProcessService.idl @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 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. + */ + +/** + * @file iimage_process_session.h + * + * @brief Declares APIs for image process service. + * + * @since 5.0 + * @version 1.0 + */ + +package ohos.hdi.camera.v1_3; + +import ohos.hdi.camera.v1_2.IImageProcessSession; +import ohos.hdi.camera.v1_3.IImageProcessCallback; +import ohos.hdi.camera.v1_2.IImageProcessService; + +interface IImageProcessService extends ohos.hdi.camera.v1_2.IImageProcessService { + /** + * @brief Create image process session. + * + * @param userId Indicates user ID. + * @param imageProcessCallback Indicates the image process callback. For details, see {@link IImageProcessCallback}. + * @param imageProcessSession Indicates the image process session. For details, see {@link IImageProcessSession} + * + * @since 5.0 + * @version 1.0 + */ + CreateImageProcessSessionExt([in] int userId, + [in] IImageProcessCallback imageProcessCallback, + [out] IImageProcessSession imageProcessSession); +} \ No newline at end of file diff --git a/camera/v1_3/IStreamOperator.idl b/camera/v1_3/IStreamOperator.idl new file mode 100644 index 0000000000000000000000000000000000000000..17b2e00032dc04b62f92e39e552ed12e590652e4 --- /dev/null +++ b/camera/v1_3/IStreamOperator.idl @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 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. + */ + +/** + * @file istream_operator.h + * + * @brief Declares APIs for stream operations. + * + * @since 5.0 + * @version 1.3 + */ + +package ohos.hdi.camera.v1_3; + +import ohos.hdi.camera.v1_2.IStreamOperator; + +interface IStreamOperator extends ohos.hdi.camera.v1_2.IStreamOperator { + + /** + * @brief Enables metadata reporting and other information. + * + * Only metadata that is enabled can be reported by using {@link OnResult}. + * + * @param results Indicates the metadata and other information for which reporting are to be enabled. + * @param streamId Indicates the ID of the stream to enable metadata reporting. + * + * @return Returns NO_ERROR if the operation is successful; returns an error code defined + * in {@link CamRetCode} otherwise. + * + * @since 5.0 + * @version 1.0 + */ + EnableResult([in] int streamId, [in] unsigned char[] results); + + /** + * @brief Disable metadata reporting and other information. + * + * After metadata reporting is disabled, the metadata is not reported by calling {@link OnResult}. + * To enable metadata reporting, you must call {@link EnableResult}. + * + * @param results Indicates the metadata and other information for which reporting are to be disabled. + * @param streamId Indicates the ID of the stream to disable metadata reporting. + * + * @return Returns NO_ERROR if the operation is successful; returns an error code defined + * in {@link CamRetCode} otherwise. + * + * @since 5.0 + * @version 1.0 + */ + DisableResult([in] int streamId, [in] unsigned char[] results); +} \ No newline at end of file diff --git a/camera/v1_3/IStreamOperatorCallback.idl b/camera/v1_3/IStreamOperatorCallback.idl index 35993c76ab5d911f9daeb58689b6ee10c1c53b73..0bb3ebddd676579ddb9261df80ec60c3ab1ed76a 100644 --- a/camera/v1_3/IStreamOperatorCallback.idl +++ b/camera/v1_3/IStreamOperatorCallback.idl @@ -61,4 +61,18 @@ import ohos.hdi.camera.v1_3.Types; * @version 1.0 */ OnCaptureEndedExt([in] int captureId, [in] struct CaptureEndedInfoExt[] infos); + + /** + * @brief Called to report metadata and other information related to the stream. + * For details about the reporting mode, see {@link SetResultMode}. + * + * @param streamId Indicates the ID of the stream related to metadata is reported. + * @param result Indicates the metadata and other information reported. + * The reported metadata and other information are specified by {@link EnableResult}. + * You can call {@link DisableResult} to disable metadata and other information reporting. + * + * @since 5.0 + * @version 1.0 + */ + OnResult([in] int streamId, [in] unsigned char[] result); } \ No newline at end of file diff --git a/camera/v1_3/Types.idl b/camera/v1_3/Types.idl index 3ea45f91875d18e258b1397146cf4770ecd5b6c8..6ea4940bb7562275e5a78b3c041fe6f3cb18ac23 100644 --- a/camera/v1_3/Types.idl +++ b/camera/v1_3/Types.idl @@ -127,6 +127,13 @@ enum OperationMode : ohos.hdi.camera.v1_2.OperationMode_V1_2 { * @version 1.0 */ FLUORESCENCE_PHOTO = 21, + + /** + * sun block mode, which dedicated to uv sunscreen detection mode + * @since 5.0 + * @version 1.0 + */ + SUN_BLOCK = 22, }; /** @@ -138,28 +145,80 @@ enum ExtendedStreamInfoType : ohos.hdi.camera.v1_2.ExtendedStreamInfoType_V1_2 { /** * Extended stream information of raw. + * @since 5.0 + * @version 1.0 */ EXTENDED_STREAM_INFO_RAW = 2, /** * Extended stream information of depth. + * @since 5.0 + * @version 1.0 */ EXTENDED_STREAM_INFO_DEPTH = 3, /** * Extended stream information of meta. + * @since 5.0 + * @version 1.0 */ EXTENDED_STREAM_INFO_META = 4, /** * Extended stream information of secure. + * @since 5.0 + * @version 1.0 */ EXTENDED_STREAM_INFO_SECURE = 5, /** * Extended stream information of maker. + * @since 5.0 + * @version 1.0 */ EXTENDED_STREAM_INFO_MAKER_INFO = 6, + + /** + * Extended stream information of exif. + * @since 5.0 + * @version 1.0 + */ + EXTENDED_STREAM_INFO_EXIF = 7, + + /** + * Extended stream information of gainmap. + * @since 5.0 + * @version 1.0 + */ + EXTENDED_STREAM_INFO_GAINMAP = 8, + + /** + * Extended stream information of unrefocus. + * @since 5.0 + * @version 1.0 + */ + EXTENDED_STREAM_INFO_UNREFOCUS = 9, + + /** + * Extended stream information of linear. + * @since 5.0 + * @version 1.0 + */ + EXTENDED_STREAM_INFO_LINEAR = 10, + + /** + * Extended stream information of fragment. + * @since 5.0 + * @version 1.0 + */ + EXTENDED_STREAM_INFO_FRAGMENT =11, + + /** + * Extended stream information of uv sunscreen detection + * @since 5.0 + * @version 1.0 + */ + EXTENDED_STREAM_INFO_UV = 12, }; /** @@ -346,4 +405,136 @@ struct CaptureEndedInfoExt { * @version 1.0 */ String videoId_; +}; + +/** + * @brief Defines the ImageBufferInfo, which is used by {@link IImageProcessCallback::OnProcessDoneExt}. + * @since 5.0 + * @version 1.0 + */ +struct ImageBufferInfoExt { + /** + * @brief The information of metadata. + * @since 5.0 + * @version 1.0 + */ + MapDataSequenceable metadata; + + /** + * @brief The information of imageHandle. + * @since 5.0 + * @version 1.0 + */ + BufferHandleSequenceable imageHandle; + + /** + * @brief If the gain map reported. + * @since 5.0 + * @version 1.0 + */ + boolean isGainMapValid; + + /** + * @brief The gain map information. + * @since 5.0 + * @version 1.0 + */ + BufferHandleSequenceable gainMapHandle; + + /** + * @brief Is depthMapHandle valid. + * @since 5.0 + * @version 1.0 + */ + boolean isDepthMapValid; + + /** + * @brief Data of metadata. + * @since 5.0 + * @version 1.0 + */ + BufferHandleSequenceable depthMapHandle; + + /** + * @brief If the unrefocus image of portrait mode reported. + * @since 5.0 + * @version 1.0 + */ + boolean isUnrefocusImageValid; + + /** + * @brief The unrefocus image of portrait mode. + * @since 5.0 + * @version 1.0 + */ + BufferHandleSequenceable unrefocusImageHandle; + + /** + * @brief If the high bit depth linear image reported. + * @since 5.0 + * @version 1.0 + */ + boolean isHighBitDepthLinearImageValid; + + /** + * @brief The high bit depth linear image. + * @since 5.0 + * @version 1.0 + */ + BufferHandleSequenceable highBitDepthLinearImageHandle; + + /** + * @brief If the exif information reported. + * @since 5.0 + * @version 1.0 + */ + boolean isExifValid; + + /** + * @brief The exif information. + * @since 5.0 + * @version 1.0 + */ + BufferHandleSequenceable exifHandle; + + /** + * @brief If the maker information reported. + * @since 5.0 + * @version 1.0 + */ + boolean isMakerInfoValid; + + /** + * @brief The maker information. + * @since 5.0 + * @version 1.0 + */ + BufferHandleSequenceable makerInfoHandle; +}; + +/** + * @brief Enumerates encoding types of stream data. + * @since 5.0 + * @version 1.0 + */ +enum EncodeType : ohos.hdi.camera.v1_0.EncodeType { + /** + * HEIC + */ + ENCODE_TYPE_HEIC = 4, +}; + +/** + * @brief Enumerates stream error types, which are used by {@link CaptureErrorInfo}. + * @since 3.2 + * @version 1.1 + */ +enum StreamError : ohos.hdi.camera.v1_0.StreamError { + /** + * When the sensor temperature is higher than the threshold, the cameraHal will stop the sketch stream + * and report the high temperature error through by {@link OnCaptureError}. + * @since 5.0 + * @version 1.0 + */ + HIGH_TEMPERATURE_ERROR = 2, }; \ No newline at end of file diff --git a/codec/bundle.json b/codec/bundle.json index 7590f6734d6f448a153014ab0a7de0778b3681a6..5a09c82a8dfd930a375ac6360ef2617fb29bf9e3 100644 --- a/codec/bundle.json +++ b/codec/bundle.json @@ -28,7 +28,7 @@ "build": { "sub_component": [ "//drivers/interface/codec/v3_0:codec_idl_target", - "//drivers/interface/codec/image/v1_0:image_idl_target" + "//drivers/interface/codec/image/v2_0:image_idl_target" ], "test": [ ], @@ -58,7 +58,7 @@ } }, { - "name": "//drivers/interface/codec/image/v1_0:libimage_proxy_1.0", + "name": "//drivers/interface/codec/image/v2_0:libimage_proxy_2.0", "header": { "header_files": [ ], @@ -66,7 +66,7 @@ } }, { - "name": "//drivers/interface/codec/image/v1_0:image_idl_headers", + "name": "//drivers/interface/codec/image/v2_0:image_idl_headers", "header": { "header_files": [ ], @@ -74,7 +74,7 @@ } }, { - "name": "//drivers/interface/codec/image/v1_0:libimage_stub_1.0", + "name": "//drivers/interface/codec/image/v2_0:libimage_stub_2.0", "header": { "header_files": [ ], diff --git a/codec/image/v2_0/BUILD.gn b/codec/image/v2_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a731683bf0ea04dea36d06afa86aa5b988d489a4 --- /dev/null +++ b/codec/image/v2_0/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2024 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. + +import("//build/config/components/hdi/hdi.gni") +if (defined(ohos_lite)) { + group("libimage_proxy_2.0") { + deps = [] + public_configs = [] + } +} else { + hdi("image") { + module_name = "codec_service" + + sources = [ + "CodecImageType.idl", + "ICodecImage.idl", + ] + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_codec" + } +} diff --git a/codec/image/v2_0/CodecImageType.idl b/codec/image/v2_0/CodecImageType.idl new file mode 100644 index 0000000000000000000000000000000000000000..5ca20e3c5853f724494302904bee60d89559cda9 --- /dev/null +++ b/codec/image/v2_0/CodecImageType.idl @@ -0,0 +1,411 @@ +/* + * Copyright (c) 2024 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 Codec + * @{ + * + * @brief Defines APIs of the image Codec module. + * + * The Codec module provides APIs for image codec, setting codec parameters, + * and controlling and transferring image data. + * + * @since 4.0 + * @version 2.0 + */ + +/** + * @file CodecImageTypes.idl + * + * @brief Defines custom data types used in the image Codec module APIs, + * including the codec image parameters, types and buffers. + * + * + * @since 4.0 + * @version 2.0 + */ + +/** + * @brief Defines the path for the package of the image Codec module APIs. + * + * @since 4.0 + * @version 2.0 + */ +package ohos.hdi.codec.image.v2_0; + +/** + * @brief Defines the image region information. + * + * @since 4.0 + * @version 1.0 + */ +struct CodecImageRegion { + unsigned int left; /**< Distance to the left of the image. */ + unsigned int right; /**< Distance to the right of the image. */ + unsigned int top; /**< Distance to the top of the image. */ + unsigned int bottom; /**< Distance to the bottom of the image. */ + unsigned int flag; /**< True is use regionInfo. */ + unsigned int rsv; /**< Reserved for extend. */ +}; + +/** + * @brief Enumerates the types of image that can be encoded or decoded + * + * @since 4.0 + * @version 1.0 + */ +enum CodecImageRole { + CODEC_IMAGE_JPEG = 0, /**< Jpeg image. */ + CODEC_IMAGE_HEIF, /**< Heif image. */ + CODEC_IMAGE_INVALID, /**< Invalid image type. */ +}; + +/** + * @brief Defines the codec image buffer information. + * + * @since 4.0 + * @version 1.0 + */ +struct CodecImageBuffer { + unsigned int id; /**< Buffer ID. */ + unsigned int size; /**< Size of buffer. */ + NativeBuffer buffer; /**< Buffer handle used for encoding or decoding. For details, + see {@link NativeBuffer}. */ + FileDescriptor fenceFd; /**< Fence file descriptor. */ + CodecImageRole bufferRole; /**< Image buffer role, see {@link CodecImageRole}. */ +}; + +/** + * @brief Defines the image codec type. + * + * @since 4.0 + * @version 1.0 + */ +enum CodecImageType { + CODEC_IMAGE_TYPE_DECODER = 0, /**< Image decoder. */ + CODEC_IMAGE_TYPE_ENCODER, /**< Image encoder. */ + CODEC_IMAGE_TYPE_INVALID, /**< Invalid type. */ +}; + +/** + * @brief Defines the image codec capabilities. + * + * @since 4.0 + * @version 1.0 + */ +struct CodecImageCapability { + String name; /**< Name of the image codec. */ + enum CodecImageRole role; /**< Role of the image codec. */ + enum CodecImageType type; /**< Type of the image codec. */ + unsigned int widthAlignment; /**< Alignment value of the width. */ + unsigned int heightAlignment; /**< Alignment value of the height. */ + unsigned int maxSample; /**< Maximum sample. */ + unsigned int maxWidth; /**< Maximum width. */ + unsigned int maxHeight; /**< Maximum height. */ + unsigned int minWidth; /**< Minimum width. */ + unsigned int minHeight; /**< Minimum height. */ + unsigned int maxInst; /**< Maximum instance. */ + unsigned int[] supportPixFmts; /**< Supported PixFormat. For details, see {@link PixFormat}. */ + boolean isSoftwareCodec; /**< Whether it is a software codec. */ +}; + +/** + * @brief Defines the jpeg image quant table information. + * + * @since 4.0 + * @version 1.0 + */ +struct CodecJpegQuantTable { + unsigned short[] quantVal; /**< Quant table value. */ + boolean tableFlag; /**< True when quant has been output. */ +}; + +/** + * @brief Defines the jpeg image huff table information. + * + * @since 4.0 + * @version 1.0 + */ +struct CodecJpegHuffTable { + unsigned char[] bits; /**< Bits value, bits[0] is unused. */ + unsigned char[] huffVal; /**< Huff table value. */ + boolean tableFlag; /**< True when huff table valid. */ +}; + +/** + * @brief Defines the jpeg image huff table information. + * + * @since 4.0 + * @version 1.0 + */ +struct CodecJpegCompInfo { + unsigned int componentId; /**< CompInfo index in JpegDecInfo. */ + unsigned int componentIndex; /**< CompInfo index in JpegDecInfo. */ + unsigned int hSampFactor; /**< Horizontal sample factor. */ + unsigned int vSampFactor; /**< vertical sample factor. */ + unsigned int quantTableNo; /**< Quant table value. */ + unsigned int dcTableNo; /**< Dc table index. */ + unsigned int acTableNo; /**< Ac table index. */ + boolean infoFlag; +}; + +/** + * @brief Defines the jpeg image decode information. + * + * @since 4.0 + * @version 1.0 + */ +struct CodecJpegDecInfo { + unsigned int imageWidth; /**< Image width. */ + unsigned int imageHeight; /**< Image height. */ + unsigned int dataPrecision; /**< Bit height. */ + unsigned int numComponents; /**< Num of color component in jpeg image. */ + unsigned int restartInterval; /**< MCUs per restart. */ + boolean arithCode; /**< False is Huff coding, + true is arithmetic coding. */ + boolean progressiveMode; /**< If SOF specifiy progressive mode. */ + struct CodecJpegCompInfo[] compInfo; /**< Jpeg compress information. */ + struct CodecJpegHuffTable[] dcHuffTbl; /**< Dc huffman table information. */ + struct CodecJpegHuffTable[] acHuffTbl; /**< Ac huffman table information. */ + struct CodecJpegQuantTable[] quantTbl; /**< Quant table information. */ + struct CodecImageRegion region; /**< Image region information. */ + unsigned int sampleSize; /**< Image sample size. */ + unsigned int compressPos; /**< The offset of Jpeg compressed data. */ +}; + +/** + * @brief Defines the supported property type for heif image encode. + * + * @since 5.0 + * @version 2.0 + */ +enum PropertyType { + MIRROR_INFO, /**< True means the image is displayed as a vertical mirror, + false means the image is displayed as a horizontal mirror. */ + ROTATE_INFO, /**< Determines how many degrees the image is rotated to display, + valid value is 0/90/180/270. */ + COLOR_TYPE, /**< Image color type. */ + COLOR_INFO, /**< Detailed color info when color type is set to NCLX. */ + ICC_PROFILE, /**< Detailed color info when color type is set to RICC or PROF. */ + CONTENT_LIGHT_LEVEL, /**< Clli info for HDR. */ + MASTER_DISPLAY_COLOR_VOLUME, /**< Mdcv info for HDR. */ + TONE_MAP_METADATA, /**< Tone map meta data for HDR. */ + USER_DATA_DO_COMPRESS, /**< Determines whether user data is compressed. */ + IT35_INFO, /**< It35 info for HDR. */ + AUX_TYPE, /**< URN for auxiliary image. */ + IMG_RESOLUTION, /**< Resolution for uncoded auxiliary image. */ + RLOC_INFO, /**< Rloc info for fragmentmap. */ +}; + +/** + * @brief Defines the color type of the output heif image. + * + * @since 5.0 + * @version 2.0 + */ +enum ColorType { + NCLX, /**< NCLX color type. */ + RICC, /**< RICC color type. */ + PROF, /**< PROF color type. */ +}; + +/** + * @brief Defines the color info when ColorType is set to NCLX. + * + * @since 5.0 + * @version 2.0 + */ +struct ColourInfo { + unsigned short colourPrimaries; /**< Gamut triangle, and white point coordinates. */ + unsigned short transferCharacteristics; /**< Transfer function/OETF. */ + unsigned short matrixCoefficients; /**< Specifies the matrix coefficient for YUV-RGB conversion. */ + boolean fullRangeFlag; /**< Specifies the YUV value range during the conversion + between YUV and RGB. */ +}; + +/** + * @brief Defines details for Clli info of HDR heif image. + * + * @since 5.0 + * @version 2.0 + */ +struct ContentLightLevel { + unsigned short maxContentLightLevel; /**< Max value of content light level. */ + unsigned short maxPicAverageLightLevel; /**< Max value of average light level. */ +}; + +/** + * @brief Defines details for Mdcv info of HDR heif image. + * + * @since 5.0 + * @version 2.0 + */ +struct MasteringDisplayColourVolume { + unsigned short displayPrimariesRX; /**< Display primaries for X-plane of red. */ + unsigned short displayPrimariesRY; /**< Display primaries for Y-plane of red. */ + unsigned short displayPrimariesGX; /**< Display primaries for X-plane of green. */ + unsigned short displayPrimariesGY; /**< Display primaries for Y-plane of green. */ + unsigned short displayPrimariesBX; /**< Display primaries for X-plane of blue. */ + unsigned short displayPrimariesBY; /**< Display primaries for Y-plane of blue. */ + unsigned short whitePointX; /**< White point for X-plane. */ + unsigned short whitePointY; /**< White point for Y-plane. */ + unsigned int maxDisplayMasteringLuminance; /**< Max display mastering luminance. */ + unsigned int minDisplayMasteringLuminance; /**< Min display mastering luminance. */ +}; + +/** + * @brief Defines a struct to describe the relative position of the auxiliary image to the associated image. + * + * @since 5.0 + * @version 1.0 + */ +struct RelativeLocation { + unsigned int horizontalOffset; /**< Horizontal offset in pixels of the left-most pixel column. */ + unsigned int verticalOffset; /**< Vertical offset in pixels of the top-most pixel row. */ +}; + +/** + * @brief Defines a struct to describe resolution for image. + * + * @since 5.0 + * @version 1.0 + */ +struct Resolution { + unsigned int width; + unsigned int height; +}; + +/** + * @brief Defines a struct to describe a signed rational number. + * + * @since 5.0 + * @version 2.0 + */ +struct SignedRational { + int numerator; /**< Numerator of a signed rational number. */ + unsigned int denominator; /**< Denominator of a signed rational number. */ +}; + +/** + * @brief Defines a struct to describe an unsigned rational number. + * + * @since 5.0 + * @version 2.0 + */ +struct UnsignedRational { + unsigned int numerator; /**< Numerator of an unsigned rational number. */ + unsigned int denominator; /**< Denominator of an unsigned rational number. */ +}; + +/** + * @brief Defines details for gain map channel info of HDR heif image. + * + * @since 5.0 + * @version 2.0 + */ +struct ToneMapChannel { + SignedRational gainMapMin; /**< Per-component min gain map values. */ + SignedRational gainMapMax; /**< Per-component max gain map values. */ + UnsignedRational gamma; /**< Per-component gamma values. */ + SignedRational baseOffset; /**< Baseline image offset. */ + SignedRational alternateOffset; /**< Alternate image offset. */ +}; + +/** + * @brief Defines details for gain map metadata of HDR heif image. + * + * @since 5.0 + * @version 2.0 + */ +struct ToneMapMetadata { + unsigned short channelCnt; /**< The number of channels, it is either 1 or 3. */ + boolean useBaseColorSpace; /**< Determine whether to use base color space. */ + UnsignedRational baseHdrHeadroom; /**< Value of base hdr headroom. */ + UnsignedRational alternateHdrHeadroom; /**< Value of alternate hdr headroom. */ + ToneMapChannel channels1; /**< Detail info of channel 1. */ + ToneMapChannel channels2; /**< Detail info of channel 2. */ + ToneMapChannel channels3; /**< Detail info of channel 3. */ +}; + +/** + * @brief Defines buffer that store non-pixel data for heif encode. + * + * @since 5.0 + * @version 2.0 + */ +struct SharedBuffer { + FileDescriptor fd; /**< Fd related to the buffer. */ + unsigned int filledLen; /**< Used size of the buffer. */ + unsigned int capacity; /**< Total size of the buffer. */ +}; + +/** + * @brief Defines how to store pixel data for heif encode. + * + * @since 5.0 + * @version 2.0 + */ +struct ImageItem { + String itemName; /**< Item name. */ + unsigned int id; /**< Item id. */ + NativeBuffer pixelBuffer; /**< Buffer to store pixel data. */ + SharedBuffer pixelSharedBuffer; /**< Buffer to store pixel data which cannot be stored in NativeBuffer. */ + boolean isPrimary; /**< Primary image flag. */ + boolean isHidden; /**< Determines whether to display this image. */ + String compressType; /**< Determines how to compress the pixel data. */ + unsigned int quality; /**< Compress quality, value range: [0, 100]. */ + unsigned char[] liteProperties; /**< Store smaller propety data, (enum + struct)|(enum + strlen + str)...*/ + SharedBuffer sharedProperties; /**< Store larger data, (enum + buffersize + buffer)... */ +}; + +/** + * @brief Defines how to store meta data for heif encode. + * + * @since 5.0 + * @version 2.0 + */ +struct MetaItem { + String itemName; /**< Name of the item. */ + unsigned int id; /**< Id of the item. */ + SharedBuffer data; /**< Data of the item. */ + unsigned char[] properties; /**< Extra properties of the item. */ +}; + +/** + * @brief Defines reference type for heif encode. + * + * @since 5.0 + * @version 2.0 + */ +enum ReferenceType { + DIMG, /**< Describe relation between base map and gain map for HDR. */ + THMB, /**< Describe relation between primary image and thumbnail. */ + AUXL, /**< Describe relation between primary image and auxilary image. */ + CDSC, /**< Describe relation between primary image and meta data. */ +}; + +/** + * @brief Defines the relation between different items for heif encode. + * + * @since 5.0 + * @version 2.0 + */ +struct ItemRef { + ReferenceType type; /**< Relation between two items. */ + String auxType; /**< Extra info for auxilary image, only valid when type is set to AUXL. */ + unsigned int from; /**< One party to a relation. */ + unsigned int[] to; /**< The other party to a relation. */ +}; + diff --git a/codec/image/v2_0/ICodecImage.idl b/codec/image/v2_0/ICodecImage.idl new file mode 100644 index 0000000000000000000000000000000000000000..2a9161f828edbac8b78e5a08e5d91ae0455833f1 --- /dev/null +++ b/codec/image/v2_0/ICodecImage.idl @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2024 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 Codec + * @{ + * + * @brief Defines APIs of the image Codec module. + * + * The Codec module provides APIs for image codec, setting codec parameters, + * and controlling and transferring image data. + * + * @since 4.0 + * @version 2.0 + */ + +/** + * @file ICodecImage.idl + * + * @brief Declares the APIs for image codec. + * + *You can use these APIs to allocate input buffer, and decode image + * + * @since 4.0 + * @version 2.0 + */ + +/** + * @brief Defines the path for the package of the image Codec module APIs. + * + * @since 4.0 + * @version 2.0 + */ +package ohos.hdi.codec.image.v2_0; + +import ohos.hdi.codec.image.v2_0.CodecImageType; + +interface ICodecImage { + + /** + * @brief Obtains image codec capabilities. + * + * You can use this API to obtain the encoding and decoding capabilities provided by the image Codec module. + * For details, see {@link CodecImageCapability}. + * + * @param capList Indicates the image codec capabilities {@link CodecImageCapability} obtained. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_FAILURE if the execution fails. + * + * @since 4.0 + * @version 1.0 + */ + GetImageCapability([out] struct CodecImageCapability[] capList); + + /** + * @brief Image codec module init. + * + * You can use this API to init the Image Codec module. + * + * @param role Indicates the image codec role {@link CodecImageRole} obtained. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see HDF_STATUS defined by HDF. + * + * @since 4.0 + * @version 1.0 + */ + Init([in] enum CodecImageRole role); + + /** + * @brief Image codec module deinit. + * + * You can use this API to deinit the Image Codec module. + * + * @param role Indicates the image codec role {@link CodecImageRole} obtained. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see HDF_STATUS defined by HDF. + * + * @since 4.0 + * @version 1.0 + */ + DeInit([in] enum CodecImageRole role); + + /** + * @brief Start jpeg image decode. + * + * You can use this API to start jpeg image decode. + * + * @param inBuffer Indicates input buffer of the jpeg image decode {@link CodecImageBuffer} obtained. + * @param outBuffer Indicates output buffer of the jpeg image decode {@link CodecImageBuffer} obtained. + * @param decInfo Indicates decode information of the image decode {@link JpegDecInfo} obtained. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see HDF_STATUS defined by HDF. + * + * @since 4.0 + * @version 1.0 + */ + DoJpegDecode([in] struct CodecImageBuffer inBuffer, [in] struct CodecImageBuffer outBuffer, + [in] struct CodecJpegDecInfo decInfo); + + /** + * @brief Allocate input buffer. + * + * You can use this API to allocate input buffer for image codec. + * After input buffer is duplicated to proxy, stub will automatically free its own reference to input buffer. + * + * @param inBuffer Indicates input buffer of the image codec {@link CodecImageBuffer} obtained. + * @param size Indicates size of input buffer {@link CodecImageBuffer} obtained. + * @param role Indicates image codec role of input buffer {@link CodecImageRole} obtained. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_ERR_INVALID_PARAM if the operation fails due to invalid parameters. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see HDF_STATUS defined by HDF. + * + * @since 4.0 + * @version 1.0 + */ + AllocateInBuffer([out] struct CodecImageBuffer inBuffer, [in] unsigned int size, [in] CodecImageRole role); + + /** + * @brief Free input buffer. + * + * You can use this API to free input buffer for image decode. + * + * @param buffer Indicates input buffer of the image codec {@link CodecImageBuffer} obtained. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see HDF_STATUS defined by HDF. + * + * @since 4.0 + * @version 1.0 + * @deprecated + * @stub no longer hold reference to input buffer, no need to free. + */ + FreeInBuffer([in] struct CodecImageBuffer inBuffer); + + /** + * @brief Start heif image encode. + * + * You can use this API to start heif image encode. + * + * @param inputImgs Indicates input images for the heif image encode {@link ImageItem} obtained. + * @param inputMetas Indicates encode parameters of the image encode {@link MetaItem} obtained. + * @param refs Indicates reference relations of the heif image encode {@link ItemRef} obtained. + * @param output Indicates output buffer of the heif image encode {@link SharedBuffer} obtained. + * @param filledLen Indicates filled length of output buffer if heif image encode succeed. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * @return Returns HDF_FAILURE if the execution fails. + * @return Returns other values if the underlying layer returns a failure. For details about the error codes, + * see HDF_STATUS defined by HDF. + * + * @since 5.0 + * @version 2.0 + */ + DoHeifEncode([in] ImageItem[] inputImgs, [in] MetaItem[] inputMetas, + [in] ItemRef[] refs, [in] SharedBuffer output, [out] unsigned int filledLen); +} diff --git a/codec/v1_0/BUILD.gn b/codec/v1_0/BUILD.gn index 6de4ce0977a5043866be0c9c6603caf214b8707f..bd36cda539c35f6e657cf10bcbb5a95ece5774fc 100644 --- a/codec/v1_0/BUILD.gn +++ b/codec/v1_0/BUILD.gn @@ -27,6 +27,7 @@ if (defined(ohos_lite)) { "ICodecComponent.idl", "ICodecComponentManager.idl", ] + branch_protector_ret = "pac_ret" language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_codec" diff --git a/codec/v2_0/BUILD.gn b/codec/v2_0/BUILD.gn index d2112592a5dfdcc750dccbb58075a247c6a3e5e7..32499b3623a81dedf01481106be994d9ef483de0 100644 --- a/codec/v2_0/BUILD.gn +++ b/codec/v2_0/BUILD.gn @@ -28,6 +28,7 @@ if (defined(ohos_lite)) { "ICodecComponent.idl", "ICodecComponentManager.idl", ] + branch_protector_ret = "pac_ret" language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_codec" diff --git a/codec/v3_0/BUILD.gn b/codec/v3_0/BUILD.gn index 239c7676356949b7de337f29d3287935ce94f455..7be386e98ec5b85d101f36f34451feae402325f2 100644 --- a/codec/v3_0/BUILD.gn +++ b/codec/v3_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("../../../hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") if (defined(ohos_lite)) { group("libcodec_proxy_3.0") { deps = [] @@ -28,6 +28,7 @@ if (defined(ohos_lite)) { "ICodecComponent.idl", "ICodecComponentManager.idl", ] + branch_protector_ret = "pac_ret" language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_codec" diff --git a/codec/v3_0/CodecTypes.idl b/codec/v3_0/CodecTypes.idl index dd558abc75b414df51f2cbb8ba9a4b50e9cfbc91..4f8b8e8f22e4d9232f1c5f2569e4f11217e43a5b 100644 --- a/codec/v3_0/CodecTypes.idl +++ b/codec/v3_0/CodecTypes.idl @@ -324,7 +324,7 @@ struct RangeValue { * @brief Defines the video encoding and decoding capabilities. * @since 4.1 - * @version 4.0 + * @version 6.0 */ struct CodecVideoPortCap { struct Rect minSize; /**< Minimum resolution supported. */ @@ -345,6 +345,8 @@ struct CodecVideoPortCap { boolean isSupportLTR; /**< Whether supports long-term reference feature */ int maxLTRFrameNum; /**< Maximum long-term reference frame numbers supported */ boolean isSupportWaterMark; /**< Whether supports WaterMark feature */ + boolean isSupportQPMap; /**< Whether supports frame qp map feature */ + boolean isSupportSeekWithoutFlush; /**< Whether supports seek without flush feature */ }; /** diff --git a/connected_nfc_tag/v1_0/BUILD.gn b/connected_nfc_tag/v1_0/BUILD.gn index a4f5a8c411802ca315bc771fabdc43f2e06bb749..aeea1266603137a7bb80c70f8fcf74023bcd8b0a 100644 --- a/connected_nfc_tag/v1_0/BUILD.gn +++ b/connected_nfc_tag/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("connected_nfc_tag") { module_name = "connected_nfc_tag_service" diff --git a/connected_nfc_tag/v1_1/BUILD.gn b/connected_nfc_tag/v1_1/BUILD.gn index d60f8e6b842b28840a967b76df69b8eec40cdd26..557b0e8b5b075c3e04b785b343fe31cc2f48ec3d 100644 --- a/connected_nfc_tag/v1_1/BUILD.gn +++ b/connected_nfc_tag/v1_1/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("connected_nfc_tag") { module_name = "connected_nfc_tag_service" imports = [ "ohos.hdi.connected_nfc_tag.v1_0:connected_nfc_tag" ] diff --git a/display/buffer/v1_0/BUILD.gn b/display/buffer/v1_0/BUILD.gn index f6cddedd9c788a7d10a8ea617217f3e4a9278f5c..ff5d1fbe620ec5798076bd6c824fb8122dfce733 100644 --- a/display/buffer/v1_0/BUILD.gn +++ b/display/buffer/v1_0/BUILD.gn @@ -27,6 +27,8 @@ hdi("display_buffer") { "platformsdk_indirect", ] + branch_protector_ret = "pac_ret" + language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_display" @@ -49,6 +51,7 @@ ohos_shared_library("libdisplay_buffer_hdi_impl") { "hdf_core:libhdi", "hdf_core:libpub_utils", "hilog:libhilog", + "hitrace:hitrace_meter", "ipc:ipc_single", ] @@ -58,5 +61,8 @@ ohos_shared_library("libdisplay_buffer_hdi_impl") { "chipsetsdk_indirect", "platformsdk_indirect", ] + + branch_protector_ret = "pac_ret" + part_name = "drivers_interface_display" } diff --git a/display/buffer/v1_0/hdi_impl/display_buffer_hdi_impl.h b/display/buffer/v1_0/hdi_impl/display_buffer_hdi_impl.h index 925dd06f12e888e7724a4c9025c72286b125f945..a7db5c20e921175ef6862009fe8d28e5409d42c2 100644 --- a/display/buffer/v1_0/hdi_impl/display_buffer_hdi_impl.h +++ b/display/buffer/v1_0/hdi_impl/display_buffer_hdi_impl.h @@ -26,11 +26,13 @@ #include "v1_0/iallocator.h" #include "v1_0/imapper.h" #include "v1_0/include/idisplay_buffer.h" +#include "hdf_trace.h" #undef LOG_TAG #define LOG_TAG "DISP_HDI_BUFF" #undef LOG_DOMAIN #define LOG_DOMAIN 0xD002515 +#define DISPLAY_TRACE HdfTrace trace(__func__, "HDI:DISP:IMPL:") #ifndef BUFFER_HDI_IMPL_LOGE #define BUFFER_HDI_IMPL_LOGE(format, ...) \ @@ -123,6 +125,7 @@ public: int32_t AllocMem(const AllocInfo& info, BufferHandle*& handle) const override { + DISPLAY_TRACE; CHECK_NULLPOINTER_RETURN_VALUE(allocator_, HDF_FAILURE); sptr hdiBuffer; int32_t ret = allocator_->AllocMem(info, hdiBuffer); diff --git a/display/buffer/v1_1/BUILD.gn b/display/buffer/v1_1/BUILD.gn index e9dde5004f9fbdda27d7dc4f6b6d8c6173bde739..ff4b53d7e87f3e30f7d49eb0b88c708254cb4b11 100644 --- a/display/buffer/v1_1/BUILD.gn +++ b/display/buffer/v1_1/BUILD.gn @@ -21,6 +21,9 @@ hdi("display_buffer") { "chipsetsdk_indirect", "platformsdk_indirect", ] + + branch_protector_ret = "pac_ret" + language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_display" @@ -49,6 +52,7 @@ ohos_shared_library("libdisplay_buffer_hdi_impl_v1_1") { "hdf_core:libhdi", "hdf_core:libpub_utils", "hilog:libhilog", + "hitrace:hitrace_meter", "ipc:ipc_single", ] @@ -58,5 +62,8 @@ ohos_shared_library("libdisplay_buffer_hdi_impl_v1_1") { "chipsetsdk_indirect", "platformsdk_indirect", ] + + branch_protector_ret = "pac_ret" + part_name = "drivers_interface_display" } diff --git a/display/buffer/v1_2/BUILD.gn b/display/buffer/v1_2/BUILD.gn index 436b6843c80556975ca2c6f23f00cc3cb5f22937..0e6530855c1e46acbc568ba3b039b4fd0dfd160c 100644 --- a/display/buffer/v1_2/BUILD.gn +++ b/display/buffer/v1_2/BUILD.gn @@ -25,6 +25,9 @@ hdi("display_buffer") { "chipsetsdk_indirect", "platformsdk_indirect", ] + + branch_protector_ret = "pac_ret" + language = "cpp" subsystem_name = "hdf" part_name = "drivers_interface_display" @@ -55,6 +58,7 @@ ohos_shared_library("libdisplay_buffer_hdi_impl_v1_2") { "hdf_core:libhdi", "hdf_core:libpub_utils", "hilog:libhilog", + "hitrace:hitrace_meter", "ipc:ipc_single", ] @@ -64,5 +68,8 @@ ohos_shared_library("libdisplay_buffer_hdi_impl_v1_2") { "chipsetsdk_indirect", "platformsdk_indirect", ] + + branch_protector_ret = "pac_ret" + part_name = "drivers_interface_display" } diff --git a/display/bundle.json b/display/bundle.json index fc2d6147ab3ac8bf9bf73d638133a505cdc1933a..76a2a3b4904b94c1af2d7b4ba17a6afe01e7da01 100644 --- a/display/bundle.json +++ b/display/bundle.json @@ -48,14 +48,14 @@ "//drivers/interface/display/buffer/v1_2:libdisplay_buffer_hdi_impl_v1_2", "//drivers/interface/display/composer/cache_manager:libcomposer_buffer_cache", "//drivers/interface/display/composer/v1_0:display_composer_idl_target", - "//drivers/interface/display/composer/v1_0:libdisplay_composer_hdi_impl", "//drivers/interface/display/composer/v1_1:display_composer_idl_target", "//drivers/interface/display/composer/v1_1:libdisplay_composer_hdi_impl_1.1", "//drivers/interface/display/composer/v1_2:display_composer_idl_target", "//drivers/interface/display/composer/v1_2:libdisplay_composer_hdi_impl_1.2", "//drivers/interface/display/graphic/common/v1_0:display_commontype_idl_target", "//drivers/interface/display/graphic/common/v1_1:display_commontype_idl_target", - "//drivers/interface/display/graphic/common/v2_0:display_commontype_idl_target" + "//drivers/interface/display/graphic/common/v2_0:display_commontype_idl_target", + "//drivers/interface/display/graphic/common/v2_1:display_commontype_idl_target" ], "inner_kits": [ { @@ -202,14 +202,6 @@ "header_base": "//drivers/interface/display/composer" } }, - { - "name": "//drivers/interface/display/composer/v1_0:libdisplay_composer_hdi_impl", - "header": { - "header_files": [ - ], - "header_base": "//drivers/interface/display/composer" - } - }, { "name": "//drivers/interface/display/composer/v1_1:libdisplay_composer_proxy_1.1", "header": { @@ -330,6 +322,22 @@ "header_base": "//drivers/interface/display/graphic/common" } }, + { + "name": "//drivers/interface/display/graphic/common/v2_1:libdisplay_commontype_proxy_2.1", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/display/graphic/common" + } + }, + { + "name": "//drivers/interface/display/graphic/common/v2_1:display_commontype_idl_headers_2.1", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/display/graphic/common" + } + }, { "name": "//drivers/interface/display/v1_0:libdisplay_gralloc", "header": { @@ -338,6 +346,9 @@ ], "header_base": "//drivers/interface/display/v1_0/stub" } + }, + { + "name": "//drivers/interface/display/composer/hdifd_parcelable:display_composer_common_config" } ] } diff --git a/display/composer/cache_manager/BUILD.gn b/display/composer/cache_manager/BUILD.gn index 42b6afff8fe0e3d069cf96955233b79679bf8672..a83df8816a8c55694788a75fd5c74b0fbd285005 100644 --- a/display/composer/cache_manager/BUILD.gn +++ b/display/composer/cache_manager/BUILD.gn @@ -27,7 +27,9 @@ ohos_shared_library("libcomposer_buffer_cache") { deps = [ "//drivers/interface/display/buffer/v1_0:libdisplay_buffer_stub_1.0", + "//drivers/interface/display/buffer/v1_1:libdisplay_buffer_stub_1.1", "//drivers/interface/display/buffer/v1_2:libdisplay_buffer_stub_1.2", + "//drivers/interface/display/composer/v1_0:libdisplay_composer_proxy_1.0", ] external_deps = [ diff --git a/display/composer/cache_manager/cache_manager.h b/display/composer/cache_manager/cache_manager.h index d8b5b002b268a04605671f22e51cb118aa200810..51f95f58e594a61d27984dd5e0d4847633797272 100644 --- a/display/composer/cache_manager/cache_manager.h +++ b/display/composer/cache_manager/cache_manager.h @@ -22,6 +22,9 @@ #include "hdf_log.h" #include "nocopyable.h" #include +#include "hdf_base.h" +#include "hilog/log.h" +#include "base/native_buffer.h" #undef LOG_TAG #define LOG_TAG "DISP_CACHE_MGR" @@ -82,6 +85,9 @@ public: auto cacheItem = caches_.find(id); if (cacheItem != caches_.end()) { HDF_LOGI("%{public}s: intend to insert a existing cache, SeqNo=%{public}d", __func__, id); + if (cleanUpFunc_ && cacheItem->second != nullptr) { + cleanUpFunc_(cacheItem->second); + } cacheItem->second.reset(cache); } else { if (cacheCountMax_ != 0 && caches_.size() >= cacheCountMax_) { @@ -148,6 +154,126 @@ private: void (*initFunc_)(std::unique_ptr&); std::mutex mutex_; }; + +template +class CacheManager : public NoCopyable { +public: + CacheManager() + : cacheCountMax_ { 0 }, + cleanUpFunc_ { nullptr }, + initFunc_ { nullptr } + {} + + virtual ~CacheManager() + { + std::lock_guard lock(mutex_); + if (cleanUpFunc_) { + for (auto& cache : caches_) { + cleanUpFunc_(cache.second); + } + } + caches_.clear(); + } + + bool SetCacheMaxCount(uint32_t count) + { + bool ret = true; + uint32_t originalMaxCount = cacheCountMax_; + if (count >= cacheCountMax_) { + cacheCountMax_ = count; + } else if (Size() <= count) { + cacheCountMax_ = count; + } else { + HDF_LOGE("%{public}s error: clientCacheCount can't be set, because cacheCountMax_ > count", __func__); + ret = false; + } + HDF_LOGI("%{public}s: set cache max count from %{public}u to %{public}u", + __func__, originalMaxCount, cacheCountMax_); + return ret; + } + + uint32_t Size() + { + std::lock_guard lock(mutex_); + return caches_.size(); + } + + bool InsertCache(IdType id, Base::NativeBuffer* cache) + { + std::lock_guard lock(mutex_); + auto cacheItem = caches_.find(id); + if (cacheItem != caches_.end()) { + HDF_LOGI("%{public}s: intend to insert a existing cache, SeqNo=%{public}d", __func__, id); + if (cleanUpFunc_ && cacheItem->second != nullptr) { + cleanUpFunc_(cacheItem->second); + } + cacheItem->second = OHOS::sptr(cache); + } else { + if (cacheCountMax_ != 0 && caches_.size() >= cacheCountMax_) { + HDF_LOGE("%{public}s: Caches is full, new seqNo:%{public}d can't be inserted", __func__, id); + return false; + } + caches_[id] = OHOS::sptr(cache); + } + if (initFunc_) { + initFunc_(caches_[id]); + } + return true; + } + + bool EraseCache(IdType id) + { + std::lock_guard lock(mutex_); + auto cacheItem = caches_.find(id); + if (cacheItem == caches_.end()) { + HDF_LOGE("%{public}s: Cache %{public}d is not existing", __func__, id); + return false; + } + + if (cleanUpFunc_ && cacheItem->second != nullptr) { + cleanUpFunc_(cacheItem->second); + } + + caches_.erase(cacheItem); + return true; + } + + Base::NativeBuffer* SearchCache(IdType id) + { + std::lock_guard lock(mutex_); + auto cacheItem = caches_.find(id); + if (cacheItem == caches_.end()) { + return nullptr; + } + + return cacheItem->second.GetRefPtr(); + } + + void TravelCaches(std::function func) + { + std::lock_guard lock(mutex_); + for (auto const& [key, value] : caches_) { + func(key, *value.GetRefPtr()); + } + } + + void SetCleanUpFunc(void (*func)(OHOS::sptr&)) + { + cleanUpFunc_ = func; + } + + void SetInitFunc(void (*func)(OHOS::sptr&)) + { + initFunc_ = func; + } + +private: + uint32_t cacheCountMax_; + std::unordered_map> caches_; + void (*cleanUpFunc_)(OHOS::sptr&); + void (*initFunc_)(OHOS::sptr&); + std::mutex mutex_; +}; } // namespace Composer } // namespace Display } // namespace HDI diff --git a/display/composer/cache_manager/device_cache.cpp b/display/composer/cache_manager/device_cache.cpp index b339b94688ee97c6fe5336812f1c0a106a2343f0..53667a9399b51588263d937955658c809e928f17 100644 --- a/display/composer/cache_manager/device_cache.cpp +++ b/display/composer/cache_manager/device_cache.cpp @@ -86,11 +86,20 @@ int32_t DeviceCache::AddLayerCache(uint32_t id, uint32_t bufferCacheCount) DISPLAY_CHK_RETURN(layer == nullptr, HDF_FAILURE, HDF_LOGE("%{public}s: Create cache failed", __func__)); int32_t retResult = layer->SetBufferCacheMaxCount(bufferCacheCount); - DISPLAY_CHK_RETURN(retResult != HDF_SUCCESS, retResult, - HDF_LOGE("%{public}s: set buffer cache max count failed", __func__)); + if (retResult != HDF_SUCCESS) { + delete layer; + layer = nullptr; + HDF_LOGE("%{public}s: set buffer cache max count failed", __func__); + return retResult; + } bool ret = layerCaches_->InsertCache(id, layer); - DISPLAY_CHK_RETURN(ret != true, HDF_FAILURE, HDF_LOGE("%{public}s: insert cache failed", __func__)); + if (ret != true) { + delete layer; + layer = nullptr; + HDF_LOGE("%{public}s: insert cache failed", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } @@ -142,8 +151,6 @@ int32_t DeviceCache::SetDisplayClientBuffer(BufferHandle*& buffer, uint32_t seqN HDF_LOGE("%{public}s: call NativeBufferCache fail", __func__)); auto ret = realFunc(*handle); if (ret != HDF_SUCCESS) { - clientBufferCaches_->EraseCache(seqNo); - buffer = nullptr; HDF_LOGE("%{public}s: call realFunc fail", __func__); } @@ -161,8 +168,6 @@ int32_t DeviceCache::SetVirtualDisplayBuffer(BufferHandle*& buffer, uint32_t seq HDF_LOGE("%{public}s: call NativeBufferCache fail", __func__)); ret = realFunc(*handle); if (ret != HDF_SUCCESS) { - outputBufferCaches_->EraseCache(seqNo); - buffer = nullptr; HDF_LOGE("%{public}s: call realFunc fail", __func__); } } else { diff --git a/display/composer/cache_manager/device_cache_manager.cpp b/display/composer/cache_manager/device_cache_manager.cpp index 28d94f4b4ec735387c37ff17ee6b61d9e2db8606..c696d5392bb98d75b5fe1c64bcdf10afc98afeb0 100644 --- a/display/composer/cache_manager/device_cache_manager.cpp +++ b/display/composer/cache_manager/device_cache_manager.cpp @@ -135,12 +135,18 @@ void DeviceCacheManager::Dump() const int32_t DeviceCacheManager::AddCacheInternal(uint32_t deviceId, DeviceCache::DeviceType type) { + auto devCache = deviceCaches_->SearchCache(deviceId); + if (devCache != nullptr && devCache->CacheType() == type) { + HDF_LOGI("AddCacheInternal deviceId:%{public}u, type:%{public}u already exist", deviceId, type); + return HDF_SUCCESS; + } DeviceCache* device = DeviceCache::Create(deviceId, type); DISPLAY_CHK_RETURN(device == nullptr, HDF_FAILURE, HDF_LOGE("%{public}s: Create cache failed", __func__)); bool ret = deviceCaches_->InsertCache(deviceId, device); DISPLAY_CHK_RETURN(ret == false, HDF_FAILURE, HDF_LOGE("%{public}s: insert device cache failed", __func__)); + HDF_LOGI("AddCacheInternal deviceId:%{public}u, type:%{public}u success", deviceId, type); return HDF_SUCCESS; } diff --git a/display/composer/cache_manager/device_cache_manager.h b/display/composer/cache_manager/device_cache_manager.h index 15452cb95c95b4003a5bb0e5fdacc74a9caf691e..faa70240ddd15316d8b7ac32f16de50d3104cfdd 100644 --- a/display/composer/cache_manager/device_cache_manager.h +++ b/display/composer/cache_manager/device_cache_manager.h @@ -38,6 +38,10 @@ public: int32_t CreateVirtualDisplayCache(uint32_t deviceId); int32_t DestroyVirtualDisplayCache(uint32_t deviceId); int32_t DestroyCaches(); + void SetNeedMap(bool needMap) + { + LayerCache::needMap_ = needMap; + } DeviceCache* DeviceCacheInstance(uint32_t deviceId) const; LayerCache* LayerCacheInstance(uint32_t deviceId, uint32_t layerId) const; void Dump() const; diff --git a/display/composer/cache_manager/layer_cache.cpp b/display/composer/cache_manager/layer_cache.cpp index 8ed30178fb003dd9e608f747c11531efd73a104a..bd0ffd25ad204673d1f736dcb0d383fe753ab795 100644 --- a/display/composer/cache_manager/layer_cache.cpp +++ b/display/composer/cache_manager/layer_cache.cpp @@ -19,12 +19,14 @@ #include "common/include/display_interface_utils.h" #include "hdf_base.h" #include "hdf_log.h" +#include "v1_0/display_composer_type.h" namespace OHOS { namespace HDI { namespace Display { namespace Composer { +bool LayerCache::needMap_ = false; LayerCache* LayerCache::Create(uint32_t id) { LayerCache* layer = new LayerCache(id); @@ -48,6 +50,14 @@ LayerCache::~LayerCache() { } +bool LayerCache::IsBufferCacheNotExist() +{ + if (bufferCaches_ == nullptr) { + return true; + } + return bufferCaches_->Size() == 0; +} + int32_t LayerCache::Init() { bufferCaches_.reset(new CacheManager()); @@ -69,6 +79,10 @@ int32_t LayerCache::SetBufferCacheMaxCount(uint32_t cacheCount) int32_t LayerCache::SetLayerBuffer(BufferHandle*& buffer, uint32_t seqNo, bool &needFreeBuffer, const std::vector& deletingList, std::function realFunc) { + if (buffer != nullptr) { + HDF_LOGI("%{public}s, seqNo %{public}u, fd %{public}d, size %{public}d", __func__, seqNo, buffer->fd, + buffer->size); + } for (auto num : deletingList) { (void)bufferCaches_->EraseCache(num); } @@ -78,8 +92,6 @@ int32_t LayerCache::SetLayerBuffer(BufferHandle*& buffer, uint32_t seqNo, bool & HDF_LOGE("%{public}s: call NativeBufferCache fail", __func__)); int32_t ret = realFunc(*handle); if (ret != HDF_SUCCESS) { - bufferCaches_->EraseCache(seqNo); - buffer = nullptr; HDF_LOGE("%{public}s: call realFunc fail", __func__); } @@ -92,79 +104,110 @@ int32_t LayerCache::ResetLayerBuffer() return Init(); } -void LayerCache::NativeBufferInit(std::unique_ptr& buffer) +void LayerCache::NativeBufferInit(sptr& buffer) { -#ifdef DISPLAY_COMUNITY if (buffer == nullptr) { HDF_LOGW("NativeBufferInit buffer nullptr!"); return; } - int32_t ret = Mmap(buffer); + int32_t ret = RegisterBuffer(buffer); if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s: Mmap failed with %{public}d!", __func__, ret); + HDF_LOGE("%{public}s: RegisterBuffer failed with %{public}d!", __func__, ret); } -#endif } -void LayerCache::NativeBufferCleanUp(std::unique_ptr& buffer) +void LayerCache::NativeBufferCleanUp(sptr& buffer) { -#ifdef DISPLAY_COMUNITY if (buffer == nullptr) { HDF_LOGW("NativeBufferCleanUp buffer nullptr!"); return; } - int32_t ret = Unmap(buffer); + int32_t ret = FreeMem(buffer); if (ret != HDF_SUCCESS) { - HDF_LOGE("%{public}s: Unmap failed with %{public}d!", __func__, ret); + HDF_LOGE("%{public}s: FreeMem failed with %{public}d!", __func__, ret); } -#endif +} + +sptr LayerCache::GetMetaService() +{ + static sptr metaService = nullptr; + if (metaService == nullptr) { + metaService = Buffer::V1_1::IMetadata::Get(true); + } + return metaService; } sptr LayerCache::GetMapperService() { - static sptr mapperService; + static sptr mapperService = nullptr; if (mapperService == nullptr) { mapperService = Buffer::V1_2::IMapper::Get(true); } return mapperService; } -int32_t LayerCache::Mmap(std::unique_ptr& buffer) +int32_t LayerCache::Mmap(sptr& buffer) { auto mapperService = GetMapperService(); if (mapperService == nullptr) { HDF_LOGE("GetMapperService failed!"); return HDF_FAILURE; } + return mapperService->Mmap(buffer); +} - sptr nativeBuffer(new NativeBuffer); - if (nativeBuffer == nullptr) { - HDF_LOGE("new NativeBuffer failed!"); +int32_t LayerCache::Unmap(sptr& buffer) +{ + auto mapperService = GetMapperService(); + if (mapperService == nullptr) { + HDF_LOGE("GetMapperService failed!"); return HDF_FAILURE; } - - nativeBuffer->SetBufferHandle(buffer->GetBufferHandle(), false); - - return mapperService->Mmap(nativeBuffer); + return mapperService->Unmap(buffer); } -int32_t LayerCache::Unmap(std::unique_ptr& buffer) +int32_t LayerCache::FreeMem(sptr& buffer) { auto mapperService = GetMapperService(); if (mapperService == nullptr) { HDF_LOGE("GetMapperService failed!"); return HDF_FAILURE; } + if (needMap_) { + if (buffer != nullptr && buffer->GetBufferHandle() != nullptr && + ((buffer->GetBufferHandle()->usage & V1_0::HBM_USE_PROTECTED) != V1_0::HBM_USE_PROTECTED)) { + int32_t ret = Unmap(buffer); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Unmap failed!"); + } + } + } + + return mapperService->FreeMem(buffer); +} - sptr nativeBuffer(new NativeBuffer); - if (nativeBuffer == nullptr) { - HDF_LOGE("new NativeBuffer failed!"); +int32_t LayerCache::RegisterBuffer(sptr& buffer) +{ + auto metaService = GetMetaService(); + if (metaService == nullptr) { return HDF_FAILURE; } - - nativeBuffer->SetBufferHandle(buffer->GetBufferHandle(), false); - - return mapperService->Unmap(nativeBuffer); + int32_t ret = metaService->RegisterBuffer(buffer); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Register Buffer failed!"); + return ret; + } + + if (needMap_) { + if (buffer != nullptr && buffer->GetBufferHandle() != nullptr && + ((buffer->GetBufferHandle()->usage & V1_0::HBM_USE_PROTECTED) != V1_0::HBM_USE_PROTECTED)) { + ret = Mmap(buffer); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Mmap failed!"); + } + } + } + return HDF_SUCCESS; } void LayerCache::Dump() const diff --git a/display/composer/cache_manager/layer_cache.h b/display/composer/cache_manager/layer_cache.h index 03b9190e271511cbb3af85ca2b04c9e581783382..c850d6d6d8bdf74a5a3ba80106d2ab87c2efb8a9 100644 --- a/display/composer/cache_manager/layer_cache.h +++ b/display/composer/cache_manager/layer_cache.h @@ -23,6 +23,7 @@ #include "cache_manager.h" #include "nocopyable.h" #include "v1_2/mapper_stub.h" +#include "v1_1/imetadata.h" namespace OHOS { namespace HDI { @@ -37,16 +38,20 @@ public: const std::vector& deletingList, std::function realFunc); int32_t SetBufferCacheMaxCount(uint32_t cacheCount); int32_t ResetLayerBuffer(); + bool IsBufferCacheNotExist(); void Dump() const; - static void NativeBufferInit(std::unique_ptr& buffer); - static void NativeBufferCleanUp(std::unique_ptr& buffer); + static void NativeBufferInit(sptr& buffer); + static void NativeBufferCleanUp(sptr& buffer); + static bool needMap_; private: explicit LayerCache(uint32_t id); int32_t Init(); static sptr GetMapperService(); - static int32_t Mmap(std::unique_ptr& buffer); - static int32_t Unmap(std::unique_ptr& buffer); - + static sptr GetMetaService(); + static int32_t Mmap(sptr& buffer); + static int32_t Unmap(sptr& buffer); + static int32_t FreeMem(sptr& buffer); + static int32_t RegisterBuffer(sptr& buffer); uint32_t layerId_; std::shared_ptr> bufferCaches_; }; diff --git a/display/composer/command_pack/command_data_packer.h b/display/composer/command_pack/command_data_packer.h index 7dd34fe606585ac4a3e5740a911a515e1132f09b..c3c7b36bf78f5dd220dd2a89229c20b39dcb36c2 100644 --- a/display/composer/command_pack/command_data_packer.h +++ b/display/composer/command_pack/command_data_packer.h @@ -104,6 +104,11 @@ public: return data_; } + void RollBack(size_t writePos) + { + writePos_ = writePos; + } + bool PackBegin(int32_t beginCmd) { writePos_ = 0; diff --git a/display/composer/common/include/display_interface_utils.h b/display/composer/common/include/display_interface_utils.h index 6bb3d62039db62bdc5e16c4a5054774c3c941073..f9ebf4416d2bce348345819a017b35f19b613dff 100644 --- a/display/composer/common/include/display_interface_utils.h +++ b/display/composer/common/include/display_interface_utils.h @@ -44,4 +44,10 @@ } \ } while (0) +#define DISPLAY_CHK_BREAK(val, ...) \ + if (val) { \ + __VA_ARGS__; \ + break; \ + } \ + #endif // DISPLAY_INTERFACE_UTILS_H diff --git a/display/composer/common/include/display_vdi_adapter_interface.h b/display/composer/common/include/display_vdi_adapter_interface.h new file mode 100644 index 0000000000000000000000000000000000000000..d34b5812362ab82303263dd8bbcec6ca9ed5337f --- /dev/null +++ b/display/composer/common/include/display_vdi_adapter_interface.h @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2024 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 OHOS_HDI_VDI_ADAPTER_INTERFACE_H +#define OHOS_HDI_VDI_ADAPTER_INTERFACE_H + +#include +#include +#include "base/buffer_handle.h" +#include "v1_0/include/idisplay_composer_interface.h" +#include "v1_0/display_composer_type.h" +#include "v1_2/display_composer_type.h" +#include "v1_1/imode_callback.h" +#include "v1_1/iseamless_change_callback.h" + +namespace OHOS { +namespace HDI { +namespace Display { +namespace Composer { +using namespace OHOS::HDI::Display::Composer::V1_0; +using namespace OHOS::HDI::Display::Composer::V1_1; +using namespace OHOS::HDI::Display::Composer::V1_2; +struct DisplayComposerVdiAdapter { + int32_t (*LoadVdiImpl)(); + int32_t (*DestroyVdiImpl)(); + int32_t (*RegHotPlugCallback)(HotPlugCallback cb, void* data); + int32_t (*GetDisplayCapability)(uint32_t devId, DisplayCapability& info); + int32_t (*GetDisplaySupportedModes)(uint32_t devId, std::vector& modes); + int32_t (*GetDisplayMode)(uint32_t devId, uint32_t& modeId); + int32_t (*SetDisplayMode)(uint32_t devId, uint32_t modeId); + int32_t (*GetDisplayPowerStatus)(uint32_t devId, V1_0::DispPowerStatus& status); + int32_t (*SetDisplayPowerStatus)(uint32_t devId, V1_0::DispPowerStatus status); + int32_t (*GetDisplayBacklight)(uint32_t devId, uint32_t& level); + int32_t (*SetDisplayBacklight)(uint32_t devId, uint32_t level); + int32_t (*GetDisplayProperty)(uint32_t devId, uint32_t id, uint64_t& value); + int32_t (*GetDisplayCompChange)(uint32_t devId, std::vector& layers, std::vector& types); + int32_t (*SetDisplayClientCrop)(uint32_t devId, const IRect& rect); + int32_t (*SetDisplayClientBuffer)(uint32_t devId, const BufferHandle& buffer, int32_t fence); + int32_t (*SetDisplayClientDamage)(uint32_t devId, std::vector& rects); + int32_t (*SetDisplayVsyncEnabled)(uint32_t devId, bool enabled); + int32_t (*RegDisplayVBlankCallback)(uint32_t devId, VBlankCallback cb, void* data); + int32_t (*GetDisplayReleaseFence)(uint32_t devId, std::vector& layers, std::vector& fences); + int32_t (*CreateVirtualDisplay)(uint32_t width, uint32_t height, int32_t& format, uint32_t& devId); + int32_t (*DestroyVirtualDisplay)(uint32_t devId); + int32_t (*SetVirtualDisplayBuffer)(uint32_t devId, const BufferHandle& buffer, const int32_t fence); + int32_t (*SetDisplayProperty)(uint32_t devId, uint32_t id, uint64_t value); + int32_t (*Commit)(uint32_t devId, int32_t& fence); + int32_t (*CreateLayer)(uint32_t devId, const LayerInfo& layerInfo, uint32_t& layerId); + int32_t (*DestroyLayer)(uint32_t devId, uint32_t layerId); + int32_t (*PrepareDisplayLayers)(uint32_t devId, bool& needFlushFb); + int32_t (*SetLayerAlpha)(uint32_t devId, uint32_t layerId, const LayerAlpha& alpha); + int32_t (*SetLayerRegion)(uint32_t devId, uint32_t layerId, const IRect& rect); + int32_t (*SetLayerCrop)(uint32_t devId, uint32_t layerId, const IRect& rect); + int32_t (*SetLayerZorder)(uint32_t devId, uint32_t layerId, uint32_t zorder); + int32_t (*SetLayerPreMulti)(uint32_t devId, uint32_t layerId, bool preMul); + int32_t (*SetLayerTransformMode)(uint32_t devId, uint32_t layerId, TransformType type); + int32_t (*SetLayerDirtyRegion)(uint32_t devId, uint32_t layerId, const std::vector& rects); + int32_t (*SetLayerVisibleRegion)(uint32_t devId, uint32_t layerId, std::vector& rects); + int32_t (*SetLayerBuffer)(uint32_t devId, uint32_t layerId, const BufferHandle& buffer, int32_t fence); + int32_t (*SetLayerCompositionType)(uint32_t devId, uint32_t layerId, V1_0::CompositionType type); + int32_t (*SetLayerBlendType)(uint32_t devId, uint32_t layerId, BlendType type); + int32_t (*SetLayerMaskInfo)(uint32_t devId, uint32_t layerId, const MaskInfo maskInfo); + int32_t (*SetLayerColor)(uint32_t devId, uint32_t layerId, const LayerColor& layerColor); + int32_t (*RegSeamlessChangeCallback)(SeamlessChangeCallback cb, void* data); + int32_t (*GetDisplaySupportedModesExt)(uint32_t devId, std::vector& modes); + int32_t (*SetDisplayModeAsync)(uint32_t devId, uint32_t modeId, ModeCallback cb, void *data); + int32_t (*GetDisplayVBlankPeriod)(uint32_t devId, uint64_t& period); + int32_t (*SetLayerPerFrameParameter)( + uint32_t devId, uint32_t layerId, const std::string& key, const std::vector& value); + int32_t (*SetDisplayPerFrameParameter)( + uint32_t devId, const std::string& key, const std::vector& value); + int32_t (*GetSupportedLayerPerFrameParameterKey)(std::vector& keys); + int32_t (*SetDisplayOverlayResolution)(uint32_t devId, uint32_t width, uint32_t height); + int32_t (*RegRefreshCallback)(RefreshCallback cb, void* data); + int32_t (*GetDisplaySupportedColorGamuts)(uint32_t devId, std::vector& gamuts); + int32_t (*GetHDRCapabilityInfos)(uint32_t devId, HDRCapability& info); + int32_t (*RegDisplayVBlankIdleCallback)(VBlankIdleCallback cb, void* data); + int32_t (*SetDisplayConstraint)(uint32_t devId, uint64_t frameID, uint64_t ns, uint32_t type); + int32_t (*UpdateHardwareCursor)(uint32_t devId, int32_t x, int32_t y, BufferHandle* buffer); + int32_t (*EnableHardwareCursorStats)(uint32_t devId, bool enable); + int32_t (*GetHardwareCursorStats)(uint32_t devId, uint32_t& frameCount, uint32_t& vsyncCount); + int32_t (*SetDisplayActiveRegion)(uint32_t devId, const IRect& rect); + int32_t (*FastPresent)(uint32_t devId, const PresentParam& param, + const std::vector& inHandles); + int32_t (*ClearDisplayClientBuffer)(uint32_t devId); + int32_t (*ClearLayerBuffer)(uint32_t devId, uint32_t layerId); + int32_t (*GetDisplayIdentificationData)(uint32_t devId, uint8_t& portId, std::vector& edidData); +}; + +using LoadVdiImplFunc = int32_t (*)(); +using DestroyVdiImplFunc = int32_t (*)(); +using RegHotPlugCallbackFunc = int32_t (*)(HotPlugCallback cb, void* data); +using GetDisplayCapabilityFunc = int32_t (*)(uint32_t devId, DisplayCapability& info); +using GetDisplaySupportedModesFunc = int32_t (*)(uint32_t devId, std::vector& modes); +using GetDisplayModeFunc = int32_t (*)(uint32_t devId, uint32_t& modeId); +using SetDisplayModeFunc = int32_t (*)(uint32_t devId, uint32_t modeId); +using GetDisplayPowerStatusFunc = int32_t (*)(uint32_t devId, V1_0::DispPowerStatus& status); +using SetDisplayPowerStatusFunc = int32_t (*)(uint32_t devId, V1_0::DispPowerStatus status); +using GetDisplayBacklightFunc = int32_t (*)(uint32_t devId, uint32_t& level); +using SetDisplayBacklightFunc = int32_t (*)(uint32_t devId, uint32_t level); +using GetDisplayPropertyFunc = int32_t (*)(uint32_t devId, uint32_t id, uint64_t& value); +using GetDisplayCompChangeFunc = int32_t (*)( + uint32_t devId, std::vector& layers, std::vector& types); +using SetDisplayClientCropFunc = int32_t (*)(uint32_t devId, const IRect& rect); +using SetDisplayClientBufferFunc = int32_t (*)(uint32_t devId, const BufferHandle& buffer, int32_t fence); +using SetDisplayClientDamageFunc = int32_t (*)(uint32_t devId, std::vector& rects); +using SetDisplayVsyncEnabledFunc = int32_t (*)(uint32_t devId, bool enabled); +using RegDisplayVBlankCallbackFunc = int32_t (*)(uint32_t devId, VBlankCallback cb, void* data); +using GetDisplayReleaseFenceFunc = int32_t (*)( + uint32_t devId, std::vector& layers, std::vector& fences); +using CreateVirtualDisplayFunc = int32_t (*)(uint32_t width, uint32_t height, int32_t& format, uint32_t& devId); +using DestroyVirtualDisplayFunc = int32_t (*)(uint32_t devId); +using SetVirtualDisplayBufferFunc = int32_t (*)(uint32_t devId, const BufferHandle& buffer, const int32_t fence); +using SetDisplayPropertyFunc = int32_t (*)(uint32_t devId, uint32_t id, uint64_t value); +using CommitFunc = int32_t (*)(uint32_t devId, int32_t& fence); +using CreateLayerFunc = int32_t (*)(uint32_t devId, const LayerInfo& layerInfo, uint32_t& layerId); +using DestroyLayerFunc = int32_t (*)(uint32_t devId, uint32_t layerId); +using PrepareDisplayLayersFunc = int32_t (*)(uint32_t devId, bool& needFlushFb); +using SetLayerAlphaFunc = int32_t (*)(uint32_t devId, uint32_t layerId, const LayerAlpha& alpha); +using SetLayerRegionFunc = int32_t (*)(uint32_t devId, uint32_t layerId, const IRect& rect); +using SetLayerCropFunc = int32_t (*)(uint32_t devId, uint32_t layerId, const IRect& rect); +using SetLayerZorderFunc = int32_t (*)(uint32_t devId, uint32_t layerId, uint32_t zorder); +using SetLayerPreMultiFunc = int32_t (*)(uint32_t devId, uint32_t layerId, bool preMul); +using SetLayerTransformModeFunc = int32_t (*)(uint32_t devId, uint32_t layerId, TransformType type); +using SetLayerDirtyRegionFunc = int32_t (*)(uint32_t devId, uint32_t layerId, const std::vector& rects); +using SetLayerVisibleRegionFunc = int32_t (*)(uint32_t devId, uint32_t layerId, std::vector& rects); +using SetLayerBufferFunc = int32_t (*)(uint32_t devId, uint32_t layerId, const BufferHandle& buffer, int32_t fence); +using SetLayerCompositionTypeFunc = int32_t (*)(uint32_t devId, uint32_t layerId, V1_0::CompositionType type); +using SetLayerBlendTypeFunc = int32_t (*)(uint32_t devId, uint32_t layerId, BlendType type); +using SetLayerMaskInfoFunc = int32_t (*)(uint32_t devId, uint32_t layerId, const MaskInfo maskInfo); +using SetLayerColorFunc = int32_t (*)(uint32_t devId, uint32_t layerId, const LayerColor& layerColor); +using RegSeamlessChangeCallbackFunc = int32_t (*)(SeamlessChangeCallback cb, void* data); +using GetDisplaySupportedModesExtFunc = int32_t (*)(uint32_t devId, std::vector& modes); +using SetDisplayModeAsyncFunc = int32_t (*)(uint32_t devId, uint32_t modeId, ModeCallback cb, void *data); +using GetDisplayVBlankPeriodFunc = int32_t (*)(uint32_t devId, uint64_t& period); +using SetLayerPerFrameParameterFunc = int32_t (*)( + uint32_t devId, uint32_t layerId, const std::string& key, const std::vector& value); +using SetDisplayPerFrameParameterFunc = int32_t (*)( + uint32_t devId, const std::string& key, const std::vector& value); +using GetSupportedLayerPerFrameParameterKeyFunc = int32_t (*)(std::vector& keys); +using SetDisplayOverlayResolutionFunc = int32_t (*)(uint32_t devId, uint32_t width, uint32_t height); +using RegRefreshCallbackFunc = int32_t (*)(RefreshCallback cb, void* data); +using GetDisplaySupportedColorGamutsFunc = int32_t (*)(uint32_t devId, std::vector& gamuts); +using GetHDRCapabilityInfosFunc = int32_t (*)(uint32_t devId, HDRCapability& info); +using RegDisplayVBlankIdleCallbackFunc = int32_t (*)(VBlankIdleCallback cb, void* data); +using SetDisplayConstraintFunc = int32_t (*)(uint32_t devId, uint64_t frameID, uint64_t ns, uint32_t type); +using UpdateHardwareCursorFunc = int32_t (*)(uint32_t devId, int32_t x, int32_t y, BufferHandle* buffer); +using EnableHardwareCursorStatsFunc = int32_t (*)(uint32_t devId, bool enable); +using GetHardwareCursorStatsFunc = int32_t (*)(uint32_t devId, uint32_t& frameCount, uint32_t& vsyncCount); +using SetDisplayActiveRegionFunc = int32_t (*)(uint32_t devId, const IRect& rect); +using FastPresentFunc = int32_t (*)(uint32_t devId, const PresentParam& param, + const std::vector& inHandles); +using ClearDisplayClientBufferFunc = int32_t (*)(uint32_t devId); +using ClearLayerBufferFunc = int32_t (*)(uint32_t devId, uint32_t layerId); +using GetDisplayIdentificationDataFunc = int32_t (*)(uint32_t devId, uint8_t& portId, std::vector& edidData); + + +} // namespace Composer +} // namespace Display +} // namespace HDI +} // namespace OHOS +#endif // OHOS_HDI_VDI_ADAPTER_INTERFACE_H diff --git a/display/composer/hdifd_parcelable/BUILD.gn b/display/composer/hdifd_parcelable/BUILD.gn index 91714ec95b58a769c5e27a4fba2e23c1fccb44a2..7890e1a7f710db3315cae2a056ef74a60e8b082c 100644 --- a/display/composer/hdifd_parcelable/BUILD.gn +++ b/display/composer/hdifd_parcelable/BUILD.gn @@ -35,3 +35,14 @@ ohos_shared_library("libhdifd_parcelable") { subsystem_name = "hdf" part_name = "drivers_interface_display" } + +config("composer_common_config") { + include_dirs = [ + ".", + "../common/include", + ] +} + +ohos_static_library("display_composer_common_config") { + public_configs = [ ":composer_common_config" ] +} diff --git a/display/composer/v1_0/BUILD.gn b/display/composer/v1_0/BUILD.gn index 86c0c6f1363573d2157fdbb754e21dc20d5be7ba..43414a19c4ff02c9c62dac44ff953e31caa35da3 100644 --- a/display/composer/v1_0/BUILD.gn +++ b/display/composer/v1_0/BUILD.gn @@ -30,36 +30,3 @@ hdi("display_composer") { subsystem_name = "hdf" part_name = "drivers_interface_display" } - -config("libdisplay_composer_hdi_impl_config") { - include_dirs = [ - "../", - "../hdifd_parcelable", - ] -} - -ohos_shared_library("libdisplay_composer_hdi_impl") { - sources = [ "hdi_impl/display_composer_interface.cpp" ] - - public_configs = [ ":libdisplay_composer_hdi_impl_config" ] - - deps = [ - ":libdisplay_composer_proxy_1.0", - "../hdifd_parcelable:libhdifd_parcelable", - ] - - external_deps = [ - "c_utils:utils", - "graphic_surface:buffer_handle", - "hdf_core:libhdi", - "hdf_core:libpub_utils", - "hilog:libhilog", - "hitrace:hitrace_meter", - "init:libbegetutil", - "ipc:ipc_single", - ] - - install_images = [ "system" ] - subsystem_name = "hdf" - part_name = "drivers_interface_display" -} diff --git a/display/composer/v1_0/display_command/display_cmd_requester.h b/display/composer/v1_0/display_command/display_cmd_requester.h index b194f3bcf02d8c47a94406ca2f200b47ac75ad3b..327b3e53840314ffdb8a70741a321f507c2151f8 100755 --- a/display/composer/v1_0/display_command/display_cmd_requester.h +++ b/display/composer/v1_0/display_command/display_cmd_requester.h @@ -126,58 +126,82 @@ EXIT: int32_t SetDisplayClientBuffer(uint32_t devId, const BufferHandle* buffer, uint32_t seqNo, int32_t fence) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_DISPLAY_CLIENT_BUFFER, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); - - bool retBool = requestPacker_.WriteUint32(devId); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write devId failed", __func__)); - - ret = CmdUtils::BufferHandlePack(buffer, requestPacker_, requestHdiFds_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: BufferHandlePack failed", __func__)); - - retBool = requestPacker_.WriteUint32(seqNo); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write seqNo failed", __func__)); - - ret = CmdUtils::FileDescriptorPack(fence, requestPacker_, requestHdiFds_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: FileDescriptorPack failed", __func__)); - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); - + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_DISPLAY_CLIENT_BUFFER, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + retBool = requestPacker_.WriteUint32(devId); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write devId failed", __func__)); + + ret = CmdUtils::BufferHandlePack(buffer, requestPacker_, requestHdiFds_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: BufferHandlePack failed", __func__)); + + retBool = requestPacker_.WriteUint32(seqNo); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write seqNo failed", __func__)); + + ret = CmdUtils::FileDescriptorPack(fence, requestPacker_, requestHdiFds_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: FileDescriptorPack failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } int32_t SetDisplayClientDamage(uint32_t devId, std::vector &rects) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_DISPLAY_CLIENT_DAMAGE, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); - - ret = requestPacker_.WriteUint32(devId) ? HDF_SUCCESS : HDF_FAILURE; - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: write devId failed", __func__)); + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_DISPLAY_CLIENT_DAMAGE, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + ret = requestPacker_.WriteUint32(devId) ? HDF_SUCCESS : HDF_FAILURE; + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: write devId failed", __func__)); + + uint32_t vectSize = static_cast(rects.size()); + retBool = requestPacker_.WriteUint32(vectSize); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write damage vector size failed", __func__)); + + for (uint32_t i = 0; i < vectSize; i++) { + ret = CmdUtils::RectPack(rects[i], requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: RectPack failed", __func__)); + } + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: RectPack failed, break!", __func__)); - uint32_t vectSize = static_cast(rects.size()); - bool retBool = requestPacker_.WriteUint32(vectSize); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write damage vector size failed", __func__)); + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); - for (uint32_t i = 0; i < vectSize; i++) { - ret = CmdUtils::RectPack(rects[i], requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: RectPack failed", __func__)); + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; } - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); - return HDF_SUCCESS; } @@ -216,322 +240,470 @@ EXIT: int32_t SetLayerAlpha(uint32_t devId, uint32_t layerId, const LayerAlpha &alpha) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_ALPHA, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); - - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: write devId failed", __func__)); - - bool retBool = requestPacker_.WriteBool(alpha.enGlobalAlpha); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write enGlobalAlpha failed", __func__)); - - retBool = requestPacker_.WriteBool(alpha.enPixelAlpha); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write enPixelAlpha failed", __func__)); - - retBool = requestPacker_.WriteUint8(alpha.alpha0); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write alpha0 failed", __func__)); - - retBool = requestPacker_.WriteUint8(alpha.alpha1); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write alpha1 failed", __func__)); - - retBool = requestPacker_.WriteUint8(alpha.gAlpha); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write gAlpha failed", __func__)); - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); - + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_ALPHA, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: write devId failed", __func__)); + + retBool = requestPacker_.WriteBool(alpha.enGlobalAlpha); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write enGlobalAlpha failed", __func__)); + + retBool = requestPacker_.WriteBool(alpha.enPixelAlpha); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write enPixelAlpha failed", __func__)); + + retBool = requestPacker_.WriteUint8(alpha.alpha0); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write alpha0 failed", __func__)); + + retBool = requestPacker_.WriteUint8(alpha.alpha1); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write alpha1 failed", __func__)); + + retBool = requestPacker_.WriteUint8(alpha.gAlpha); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write gAlpha failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } int32_t SetLayerRegion(uint32_t devId, uint32_t layerId, const IRect &rect) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_REGION, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); + int32_t ret = 0; + size_t writePos = requestPacker_.ValidSize(); - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_REGION, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); - ret = CmdUtils::RectPack(rect, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: RectPack failed", __func__)); + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); + ret = CmdUtils::RectPack(rect, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: RectPack failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + if (ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } int32_t SetLayerCrop(uint32_t devId, uint32_t layerId, const IRect &rect) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_CROP, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); + int32_t ret = 0; + size_t writePos = requestPacker_.ValidSize(); - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_CROP, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); - ret = CmdUtils::RectPack(rect, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: RectPack failed", __func__)); + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); + ret = CmdUtils::RectPack(rect, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: RectPack failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + if (ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } int32_t SetLayerZorder(uint32_t devId, uint32_t layerId, uint32_t zorder) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_ZORDER, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); - - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); - - bool retBool = requestPacker_.WriteUint32(zorder); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write zorder failed", __func__)); - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); - + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_ZORDER, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + + retBool = requestPacker_.WriteUint32(zorder); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write zorder failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } int32_t SetLayerPreMulti(uint32_t devId, uint32_t layerId, bool preMul) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_PREMULTI, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); - - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); - - bool retBool = requestPacker_.WriteBool(preMul); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write preMul failed", __func__)); - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_PREMULTI, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + + retBool = requestPacker_.WriteBool(preMul); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write preMul failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } int32_t SetLayerTransformMode(uint32_t devId, uint32_t layerId, TransformType type) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_TRANSFORM_MODE, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); - - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); - - bool retBool = requestPacker_.WriteInt32(type); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write transform-type failed", __func__)); - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); - + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_TRANSFORM_MODE, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + + retBool = requestPacker_.WriteInt32(type); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write transform-type failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } int32_t SetLayerDirtyRegion(uint32_t devId, uint32_t layerId, const std::vector &rects) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_DIRTY_REGION, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_DIRTY_REGION, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + + uint32_t vSize = rects.size(); + retBool = requestPacker_.WriteUint32(vSize); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write vSize failed", __func__)); + for (uint32_t i = 0; i < vSize; i++) { + ret = CmdUtils::RectPack(rects[i], requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: RectPack failed", __func__)); + } + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: RectPack failed, break", __func__)); - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); - uint32_t vSize = rects.size(); - bool retBool = requestPacker_.WriteUint32(vSize); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write vSize failed", __func__)); - for (uint32_t i = 0; i < vSize; i++) { - ret = CmdUtils::RectPack(rects[i], requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: RectPack failed", __func__)); + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; } - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); - return HDF_SUCCESS; } int32_t SetLayerVisibleRegion(uint32_t devId, uint32_t layerId, std::vector &rects) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_VISIBLE_REGION, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_VISIBLE_REGION, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + + uint32_t vSize = rects.size(); + retBool = requestPacker_.WriteUint32(vSize); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write vSize failed", __func__)); + for (uint32_t i = 0; i < vSize; i++) { + ret = CmdUtils::RectPack(rects[i], requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: RectPack failed", __func__)); + } + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: RectPack failed, break", __func__)); - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); - uint32_t vSize = rects.size(); - bool retBool = requestPacker_.WriteUint32(vSize); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write vSize failed", __func__)); - for (uint32_t i = 0; i < vSize; i++) { - ret = CmdUtils::RectPack(rects[i], requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: RectPack failed", __func__)); + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; } - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); - return HDF_SUCCESS; } int32_t SetLayerBuffer(uint32_t devId, uint32_t layerId, const BufferHandle* buffer, uint32_t seqNo, int32_t fence, const std::vector& deletingList) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_BUFFER, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); - - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); - - ret = CmdUtils::BufferHandlePack(buffer, requestPacker_, requestHdiFds_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: BufferHandlePack failed", __func__)); - - bool result = requestPacker_.WriteUint32(seqNo); - DISPLAY_CHK_RETURN(result == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write seqNo failed", __func__)); + int32_t ret = 0; + bool retBool = false; + bool result = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_BUFFER, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + + ret = CmdUtils::BufferHandlePack(buffer, requestPacker_, requestHdiFds_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: BufferHandlePack failed", __func__)); + + result = requestPacker_.WriteUint32(seqNo); + DISPLAY_CHK_BREAK(result == false, + HDF_LOGE("%{public}s: write seqNo failed", __func__)); + + ret = CmdUtils::FileDescriptorPack(fence, requestPacker_, requestHdiFds_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: FileDescriptorPack failed", __func__)); + // write deletingList + uint32_t vectSize = static_cast(deletingList.size()); + retBool = requestPacker_.WriteUint32(vectSize); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write vector size failed", __func__)); + + for (uint32_t i = 0; i < vectSize; i++) { + bool result = requestPacker_.WriteUint32(deletingList[i]); + DISPLAY_CHK_BREAK(result == false, + HDF_LOGE("%{public}s: write deletingList failed", __func__)); + } + DISPLAY_CHK_BREAK(result == false, + HDF_LOGE("%{public}s: write deletingList failed, break!", __func__)); - ret = CmdUtils::FileDescriptorPack(fence, requestPacker_, requestHdiFds_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: FileDescriptorPack failed", __func__)); - // write deletingList - uint32_t vectSize = static_cast(deletingList.size()); - bool retBool = requestPacker_.WriteUint32(vectSize); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write vector size failed", __func__)); + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); - for (uint32_t i = 0; i < vectSize; i++) { - bool result = requestPacker_.WriteUint32(deletingList[i]); - DISPLAY_CHK_RETURN(result == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write deletingList failed", __func__)); + if (retBool == false || result == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; } - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); - return HDF_SUCCESS; } int32_t SetLayerCompositionType(uint32_t devId, uint32_t layerId, CompositionType type) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_COMPOSITION_TYPE, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); - - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); - - int32_t retBool = requestPacker_.WriteInt32(type); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write composition type failed", __func__)); - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); - + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_COMPOSITION_TYPE, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + + retBool = requestPacker_.WriteInt32(type); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write composition type failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } int32_t SetLayerBlendType(uint32_t devId, uint32_t layerId, BlendType type) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_BLEND_TYPE, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); - - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); - - bool retBool = requestPacker_.WriteInt32(type); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write blend type failed", __func__)); - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); - + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_BLEND_TYPE, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + + retBool = requestPacker_.WriteInt32(type); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write blend type failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } int32_t SetLayerMaskInfo(uint32_t devId, uint32_t layerId, const MaskInfo maskInfo) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_MASK_INFO, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); - - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); - - bool retBool = requestPacker_.WriteUint32(maskInfo); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write maskInfo failed", __func__)); - - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); - + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_MASK_INFO, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + + retBool = requestPacker_.WriteUint32(maskInfo); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write maskInfo failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } int32_t SetLayerColor(uint32_t devId, uint32_t layerId, const LayerColor& layerColor) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_COLOR, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); + int32_t ret = 0; + size_t writePos = requestPacker_.ValidSize(); - ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: SetupDevice failed", __func__)); + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_COLOR, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); - ret = CmdUtils::LayerColorPack(layerColor, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: RectPack failed", __func__)); + ret = CmdUtils::SetupDevice(devId, layerId, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: SetupDevice failed", __func__)); - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); + ret = CmdUtils::LayerColorPack(layerColor, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: RectPack failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + if (ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } return HDF_SUCCESS; } diff --git a/display/composer/v1_0/display_command/display_cmd_responser.h b/display/composer/v1_0/display_command/display_cmd_responser.h index 82d1f7cd1678e7d74b3e17386594e49df7a85fd3..bf387c2ff645dc88cf9ca261b9aa9184e4d240e3 100755 --- a/display/composer/v1_0/display_command/display_cmd_responser.h +++ b/display/composer/v1_0/display_command/display_cmd_responser.h @@ -39,6 +39,7 @@ #include "parameter.h" #include "v1_0/display_composer_type.h" #include "v1_0/mapper_stub.h" +#include "common/include/display_vdi_adapter_interface.h" #define DISPLAY_TRACE HdfTrace trace(__func__, "HDI:DISP:") @@ -55,6 +56,7 @@ using HdifdSet = std::vector>; static constexpr uint32_t TIME_BUFFER_MAX_LEN = 15; static constexpr uint32_t BUFFER_QUEUE_MAX_SIZE = 6; static constexpr unsigned int REDUCE_COUNT = 50; +static constexpr int32_t ERROR_FENCE_COUNT = 500; static sptr g_bufferServiceImpl = nullptr; static constexpr uint32_t COMMIT_PRINT_INTERVAL = 1200; @@ -93,6 +95,7 @@ public: { DISPLAY_CHK_RETURN(request == nullptr, HDF_FAILURE, HDF_LOGE("%{public}s: error, request is nullptr", __func__)); + std::lock_guard lock(requestMutex_); if (request_ != nullptr) { request_.reset(); } @@ -103,6 +106,7 @@ public: int32_t GetCmdReply(std::shared_ptr& reply) { + std::lock_guard lock(replyMutex_); int32_t ret = HDF_SUCCESS; if (isReplyUpdated_ == false) { ret = InitReply(CmdUtils::INIT_ELEMENT_COUNT); @@ -161,9 +165,7 @@ public: return HDF_FAILURE; } std::shared_ptr requestData(new char[inEleCnt * CmdUtils::ELEMENT_SIZE], std::default_delete()); - int32_t ret = request_->Read(reinterpret_cast(requestData.get()), inEleCnt, - CmdUtils::TRANSFER_WAIT_TIME); - + int32_t ret = CmdRequestDataRead(requestData, inEleCnt); CommandDataUnpacker unpacker; unpacker.Init(requestData.get(), inEleCnt << CmdUtils::MOVE_SIZE); #ifdef DEBUG_DISPLAY_CMD_RAW_DATA @@ -180,15 +182,14 @@ public: while (ret == HDF_SUCCESS && unpacker.NextSection()) { if (!unpacker.BeginSection(unpackCmd)) { - HDF_LOGE("error: PackSection failed, unpackCmd=%{public}s.", - CmdUtils::CommandToString(unpackCmd)); + HDF_LOGE("error: PackSection failed, unpackCmd=%{public}s.", CmdUtils::CommandToString(unpackCmd)); ret = HDF_FAILURE; + break; } ret = ProcessRequestCmd(unpacker, unpackCmd, inFds, outFds); } - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: ProcessRequestCmd failed", __func__)); + DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, HDF_LOGE("%{public}s:ProcessRequestCmd failed", __func__)); /* pack request end commands */ replyPacker_.PackEnd(CONTROL_CMD_REPLY_END); @@ -200,8 +201,7 @@ public: /* Write reply pack */ outEleCnt = replyPacker_.ValidSize() >> CmdUtils::MOVE_SIZE; - ret = reply_->Write(reinterpret_cast(replyPacker_.GetDataPtr()), outEleCnt, - CmdUtils::TRANSFER_WAIT_TIME); + ret = CmdRequestDataWrite(outEleCnt); if (ret != HDF_SUCCESS) { HDF_LOGE("Reply write failure, ret=%{public}d", ret); outEleCnt = 0; @@ -211,13 +211,34 @@ public: } protected: + int32_t CmdRequestDataRead(std::shared_ptr requestData, uint32_t inEleCnt) + { + std::lock_guard lock(requestMutex_); + if (request_ == nullptr || requestData == nullptr) { + HDF_LOGE("%{public}s: inEleCnt: %{public}u request_ is nullptr", __func__, inEleCnt); + return HDF_FAILURE; + } + return request_->Read(reinterpret_cast(requestData.get()), inEleCnt, + CmdUtils::TRANSFER_WAIT_TIME); + } + + int32_t CmdRequestDataWrite(uint32_t outEleCnt) + { + std::lock_guard lock(replyMutex_); + if (reply_ == nullptr) { + HDF_LOGE("%{public}s: reply_ is nullptr", __func__); + return HDF_FAILURE; + } + return reply_->Write(reinterpret_cast(replyPacker_.GetDataPtr()), outEleCnt, + CmdUtils::TRANSFER_WAIT_TIME); + } + int32_t InitReply(uint32_t size) { if (size > CmdUtils::MAX_MEMORY) { HDF_LOGE("%{public}s: size:%{public}u is too large", __func__, size); return HDF_FAILURE; } - reply_ = std::make_shared(size, SmqType::SYNCED_SMQ); DISPLAY_CHK_RETURN(reply_ == nullptr, HDF_FAILURE, HDF_LOGE("%{public}s: reply_ construct failed", __func__)); @@ -370,7 +391,21 @@ EXIT: #ifdef DISPLAY_COMSPOER_DEBUG_DUMP DumpLayerBuffer(data.devId, data.seqNo, data.fence, handle, "client_"); #endif - HdfTrace traceVdi("SetDisplayClientBuffer", "HDI:DISP:HARDWARE"); + std::string traceMsg = ""; + if (data.buffer == nullptr) { + traceMsg = "data.buffer is nullptr! seqNo:" + std::to_string(data.seqNo); + } else { + traceMsg = "HDI:DISP:HARDWARE " + "height:" + std::to_string(data.buffer->height) + + " width:" + std::to_string(data.buffer->width) + + " data.buffer->fd:" + std::to_string(data.buffer->fd) + + " seqNo:" + std::to_string(data.seqNo); + } + traceMsg += " fd:" + std::to_string(fd); + if (data.fence > ERROR_FENCE_COUNT) { + HDF_LOGI("SetDisplayClientBuffer: %{public}s", traceMsg.c_str()); + } + HdfTrace traceVdi("SetDisplayClientBuffer", traceMsg); needMoveFd = true; int rc = impl_->SetDisplayClientBuffer(data.devId, handle, fd); DISPLAY_CHK_RETURN(rc != HDF_SUCCESS, HDF_FAILURE, HDF_LOGE(" fail")); @@ -405,10 +440,6 @@ EXIT: #endif // DISPLAY_COMMUNITY if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s, SetDisplayClientBuffer error", __func__); - if (data.isValidBuffer && data.buffer != nullptr) { - FreeBufferHandle(data.buffer); - data.buffer = nullptr; - } errMaps_.emplace(REQUEST_CMD_SET_DISPLAY_CLIENT_BUFFER, ret); } } @@ -600,6 +631,37 @@ EXIT: return; } + int32_t CheckBufferNotExist(uint32_t devId, uint32_t layerId) + { + if (cacheMgr_ == nullptr) { + HDF_LOGE("%{public}s, cacheMgr_ is null, devId:%{public}d, layerId:%{public}d", + __func__, devId, layerId); + return HDF_FAILURE; + } + + std::lock_guard lock(cacheMgr_->GetCacheMgrMutex()); + DeviceCache* devCache = cacheMgr_->DeviceCacheInstance(devId); + if (devCache == nullptr) { + HDF_LOGE("%{public}s, devCache is null, devId:%{public}d, layerId:%{public}d", + __func__, devId, layerId); + return HDF_FAILURE; + } + + LayerCache* layerCache = devCache->LayerCacheInstance(layerId); + if (layerCache == nullptr) { + HDF_LOGE("%{public}s, layerCache is null, devId:%{public}d, layerId:%{public}d", + __func__, devId, layerId); + return HDF_FAILURE; + } + + if (layerCache->IsBufferCacheNotExist()) { + HDF_LOGE("%{public}s, no buffer in devId:%{public}d, layerId:%{public}d", + __func__, devId, layerId); + return HDF_FAILURE; + } + return HDF_SUCCESS; + } + void OnSetLayerZorder(CommandDataUnpacker& unpacker) { DISPLAY_TRACE; @@ -809,7 +871,25 @@ EXIT: #ifdef DISPLAY_COMSPOER_DEBUG_DUMP DumpLayerBuffer(data.devId, data.layerId, data.fence, handle, "layer_"); #endif - HdfTrace traceVdi("SetLayerBuffer", "HDI:DISP:HARDWARE"); + std::string traceMsg = ""; + if (data.buffer == nullptr) { + traceMsg = "data.buffer is nullptr! seqNo:" + std::to_string(data.seqNo); + } else { + traceMsg = "HDI:DISP:HARDWARE" + "height:" + std::to_string(data.buffer->height) + + " width:" + std::to_string(data.buffer->width) + + " data.buffer->fd:" + std::to_string(data.buffer->fd) + + " seqNo:" + std::to_string(data.seqNo); + } + traceMsg += " fd:" + std::to_string(fd); + if (data.fence > ERROR_FENCE_COUNT || fd > ERROR_FENCE_COUNT || handle.fd > ERROR_FENCE_COUNT) { + HDF_LOGI("SetLayerBuffer: %{public}s data.devId: %{public}d data.layerId: %{public}d, " + "data.buffer->fd:%{public}d, data.seqNo:%{public}d handle.fd:%{public}d, fd:%{public}d", + data.buffer == nullptr ? "data.buffer is nullptr!" : "", + data.devId, data.layerId, data.buffer == nullptr ? -1 : data.buffer->fd, data.seqNo, handle.fd, fd); + cacheMgr_->Dump(); + } + HdfTrace traceVdi("SetLayerBuffer", traceMsg); needMoveFd = true; int rc = impl_->SetLayerBuffer(data.devId, data.layerId, handle, fd); DISPLAY_CHK_RETURN(rc != HDF_SUCCESS, HDF_FAILURE, HDF_LOGE(" fail")); @@ -846,10 +926,6 @@ EXIT: #endif // DISPLAY_COMMUNITY if (ret != HDF_SUCCESS) { HDF_LOGE("%{public}s, SetLayerBuffer error", __func__); - if (data.isValidBuffer && data.buffer != nullptr) { - FreeBufferHandle(data.buffer); - data.buffer = nullptr; - } errMaps_.emplace(REQUEST_CMD_SET_DISPLAY_CLIENT_BUFFER, ret); } @@ -1097,8 +1173,10 @@ protected: std::unordered_map errMaps_; /* fix fd leak */ std::queue delayFreeQueue_; + std::mutex requestMutex_; + std::mutex replyMutex_; }; -using HdiDisplayCmdResponser = DisplayCmdResponser, IDisplayComposerVdi>; +using HdiDisplayCmdResponser = DisplayCmdResponser, DisplayComposerVdiAdapter>; } // namespace V1_0 } // namespace Composer } // namespace Display diff --git a/display/composer/v1_0/display_command/display_cmd_utils.h b/display/composer/v1_0/display_command/display_cmd_utils.h index db512bbb48a66c9fc093056fd19ce2af7355bce7..f9c1f76362396c4114edbfce4539cd17447f6d4a 100644 --- a/display/composer/v1_0/display_command/display_cmd_utils.h +++ b/display/composer/v1_0/display_command/display_cmd_utils.h @@ -27,6 +27,8 @@ #undef LOG_DOMAIN #define LOG_DOMAIN 0xD002515 +#define INVALID_FD (-1) + namespace OHOS { namespace HDI { namespace Display { @@ -270,9 +272,16 @@ public: int32_t fdId = -1; DISPLAY_CHK_RETURN(unpacker.ReadInt32(fdId) == false, HDF_FAILURE, HDF_LOGE("%{public}s, read fdId failed", __func__)); - if (fdId < 0 || MatchHdiFd(fdId, hdiFds, fd) == false) { + if (fdId < 0) { + fd = INVALID_FD; + return HDF_SUCCESS; + } + if (!(MatchHdiFd(fdId, hdiFds, fd))) { // If matching failure, the illegal fd is transfered by smq directly, not by binder IPC. - fd = fdId; + HDF_LOGE("%{public}s, matching failure, fd %{public}d, fdId %{public}d, hdiFds.size %{public}zu", + __func__, fd, fdId, hdiFds.size()); + fd = INVALID_FD; + return HDF_FAILURE; } return HDF_SUCCESS; } diff --git a/display/composer/v1_0/hdi_impl/display_composer_hdi_impl.h b/display/composer/v1_0/hdi_impl/display_composer_hdi_impl.h index 6d236e3db5e42c8eee85ed285139d3fb64d906a9..ef0d059be2630e4107bb929e1a8befade1906d6b 100644 --- a/display/composer/v1_0/hdi_impl/display_composer_hdi_impl.h +++ b/display/composer/v1_0/hdi_impl/display_composer_hdi_impl.h @@ -30,6 +30,7 @@ #define LOG_TAG "DISP_HDI_COMP" #undef LOG_DOMAIN #define LOG_DOMAIN 0xD002515 +#define MAX_COUNT 10 namespace OHOS { namespace HDI { @@ -165,7 +166,9 @@ public: virtual int32_t SetDisplayPowerStatus(uint32_t devId, DispPowerStatus status) override { COMPOSER_CHECK_NULLPTR_RETURN(hdi_); - return ToDispErrCode(hdi_->SetDisplayPowerStatus(devId, status)); + int32_t ret = hdi_->SetDisplayPowerStatus(devId, status); + HDF_LOGI("devId: %{public}u, status: %{public}u", devId, status); + return ToDispErrCode(ret); } virtual int32_t GetDisplayBacklight(uint32_t devId, uint32_t& level) override @@ -217,7 +220,7 @@ public: COMPOSER_CHECK_NULLPTR_RETURN(hdi_); /* Already enabled, return success */ - if (enabled && vsyncEnableCount_[devId] > 0) { + if (enabled && vsyncEnableCount_[devId] > 0 && vsyncEnableCount_[devId] < MAX_COUNT) { HDF_LOGD("%{public}s: Count[%{public}u] = %{public}u, Skip", __func__, devId, vsyncEnableCount_[devId]); ++vsyncEnableCount_[devId]; return DISPLAY_SUCCESS; @@ -225,6 +228,7 @@ public: int32_t ret = ToDispErrCode(hdi_->SetDisplayVsyncEnabled(devId, enabled)); if (ret != DISPLAY_SUCCESS) { + vsyncEnableCount_[devId] = 0; return ret; } diff --git a/display/composer/v1_1/display_command/display_cmd_responser.h b/display/composer/v1_1/display_command/display_cmd_responser.h index 63bc8c5b2a1f7fb77c541510beeaf92dacf29e2a..e8dc17d6bf084b789a7ddad29e39e2cf672eb7c8 100644 --- a/display/composer/v1_1/display_command/display_cmd_responser.h +++ b/display/composer/v1_1/display_command/display_cmd_responser.h @@ -47,7 +47,7 @@ public: private: using BaseType1_0 = V1_0::DisplayCmdResponser; }; -using HdiDisplayCmdResponser = DisplayCmdResponser, IDisplayComposerVdi>; +using HdiDisplayCmdResponser = DisplayCmdResponser, DisplayComposerVdiAdapter>; } // namespace V1_1 } // namespace Composer } // namespace Display diff --git a/display/composer/v1_2/DisplayComposerType.idl b/display/composer/v1_2/DisplayComposerType.idl index f109352542bbe161bb489148d5c72ae52332aa1e..0115dc988875db86cce7fe9480c1ac0dcf0d7120 100644 --- a/display/composer/v1_2/DisplayComposerType.idl +++ b/display/composer/v1_2/DisplayComposerType.idl @@ -50,6 +50,8 @@ import ohos.hdi.display.composer.v1_1.DisplayComposerType; enum DispPowerStatus : ohos.hdi.display.composer.v1_1.DispPowerStatus { POWER_STATUS_PRE_ON = 5, /**< The power status is Enter pre-lit screen state */ POWER_STATUS_PRE_OFF = 6, /**< The power status is Exit pre-lit sreen state */ + POWER_STATUS_DOZE = 7, /**< The power status is doze and prepare to present */ + POWER_STATUS_DOZE_SUSPEND = 8, /**< The power status is doze and ended present */ POWER_STATUS_BUTT_V1_2, /**< The power status is invalid */ }; @@ -61,6 +63,12 @@ enum BufferUsage : ohos.hdi.display.composer.v1_0.BufferUsage { HBM_USE_CPU_HW_BOTH = (1ULL << 17), /**< For support cpu and hardware */ HBM_USAGE_GPU_PERFORMANCE = (1ULL << 18), /**< Prefer performance over memory consumption: */ HBM_USE_RGB_TO_YUV_CONVERSION = (1ULL << 19), /**< For identify RGB to YUV conversion */ + HBM_USE_AUXILLARY_BUFFER0 = (1ULL << 20), /**< reserved for individual meta size */ + HBM_USE_AUXILLARY_BUFFER1 = (1ULL << 21), /**< ref to VIDEO_MV */ + HBM_USE_AUXILLARY_BUFFER2 = (1ULL << 22), /**< combine with main usage for specific meta feature */ + HBM_USE_AUXILLARY_BUFFER3 = (1ULL << 23), /**< combine with main usage for specific meta feature */ + HBM_USE_VIDEO_DEC_MV = HBM_USE_VIDEO_DECODER | HBM_USE_AUXILLARY_BUFFER2, /**< ref to VIDEO_DEC */ + HBM_USE_DRM_REDRAW = (1ULL << 24), /**< For DRM redraw framebuffer allocate */ }; @@ -77,6 +85,8 @@ enum PixelFormat : ohos.hdi.display.composer.v1_1.PixelFormat { enum DispCmd : ohos.hdi.display.composer.v1_0.DispCmd { REQUEST_CMD_COMMIT_AND_GET_RELEASE_FENCE = 82, /**< Request cmd */ REQUEST_CMD_SET_DISPLAY_CONSTRAINT = 83, /**< LTPO cmd> */ + REQUEST_CMD_SET_LAYER_PERFRAME_PARAM = 84, /**< SetLayer cmd> */ + REQUEST_CMD_SET_DISPLAY_PERFRAME_PARAM = 85, /**< SetDisplay cmd> */ REQUEST_CMD_BUTT_V1_2, REPLY_CMD_COMMIT_AND_GET_RELEASE_FENCE = 515, /**< Reply cmd */ REPLY_CMD_BUTT_V1_2, @@ -92,4 +102,19 @@ enum DispCmd : ohos.hdi.display.composer.v1_0.DispCmd { enum DisplayPropertyID { DISPLAY_PROPERTY_ID_SKIP_VALIDATE = 1, DISPLAY_CAPBILITY_HARDWARE_CURSOR = 2, -}; \ No newline at end of file + DISPLAY_PROPERTY_ID_ADAPTIVE_SYNC = 3, /**< Indicates whether to support adaptive sync(display in advance) */ +}; + +/** + * @brief Defines the data structure of present param. + * + * @since 5.0 + * @version 1.0 + */ +struct PresentParam { + unsigned int isLowLatency; /**< flag of low latency display */ + unsigned int sliceHeight; /**< height of slice */ + unsigned int sliceNum; /**< slice nums of current frame */ + unsigned int imageDimension; /**< low 16 bits: image width, high 16 bits: image height */ + int reserve; /**< reserve */ +}; diff --git a/display/composer/v1_2/IDisplayComposer.idl b/display/composer/v1_2/IDisplayComposer.idl index 7a86fe6f6dfed151ffe83d2ff70e79721d472674..73b2619856ea3924050be47ab1fe151ea5002a5a 100644 --- a/display/composer/v1_2/IDisplayComposer.idl +++ b/display/composer/v1_2/IDisplayComposer.idl @@ -16,6 +16,7 @@ package ohos.hdi.display.composer.v1_2; import ohos.hdi.display.composer.v1_1.IDisplayComposer; +import ohos.hdi.display.composer.v1_0.DisplayComposerType; import ohos.hdi.display.composer.v1_2.DisplayComposerType; import ohos.hdi.display.composer.v1_2.IVBlankIdleCallback; @@ -59,16 +60,17 @@ interface IDisplayComposer extends ohos.hdi.display.composer.v1_1.IDisplayCompos ClearLayerBuffer([in] unsigned int devId, [in] unsigned int layerId); /** - * @brief Set Hardware Cursor Position. + * @brief Update Hardware Cursor Position and Style. * * @param devId Indicates which device, x and y Indicates the position of hardware cursor. + * buffer Indicates input buffer handle. * * @return Returns 0 if the operation is successful; returns an error code defined * in {@link DispErrCode} otherwise. * @since 5.0 * @version 1.0 */ - SetHardwareCursorPosition([in] unsigned int devId, [in] int x, [in] int y); + UpdateHardwareCursor([in] unsigned int devId, [in] int x, [in] int y, [in] NativeBuffer buffer); /** * @brief Enable Hardware Cursor. @@ -94,4 +96,43 @@ interface IDisplayComposer extends ohos.hdi.display.composer.v1_1.IDisplayCompos * @version 1.0 */ GetHardwareCursorStats([in] unsigned int devId, [out] unsigned int frameCount, [out] unsigned int vsyncCount); + + /** + * @brief Set Display Active Region. + * + * @param devId Indicates the ID of the display device. + * @param rect Indicates the pointer to the cropped region of the client buffer. + * + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link DispErrCode} otherwise. + * @since 5.0 + * @version 1.0 + */ + SetDisplayActiveRegion([in] unsigned int devId, [in] struct IRect rect); + + /** + * @brief the function to fast present. + * + * @param devId Indicates which device, param Indicates data structure of present param, + * inHandles Indicates input buffer handles. + * + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link DispErrCode} otherwise. + * @since 5.0 + * @version 1.0 + */ + FastPresent([in] unsigned int devId, [in] struct PresentParam param, [in] NativeBuffer[] inHandles); + + /** + * @brief the function to GetDisplayIdentificationData. + * + * @param devId Indicates which device, portId Indicates which port, + * edidData Indicates the edid value. + * + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link DispErrCode} otherwise. + * @since 5.0 + * @version 1.0 + */ + GetDisplayIdentificationData([in] unsigned int devId, [out] unsigned char portId, [out] unsigned char[] edidData); } diff --git a/display/composer/v1_2/display_command/display_cmd_requester.h b/display/composer/v1_2/display_command/display_cmd_requester.h index 775ea7dbbd920991de6d3c9b05b0f3822804f465..0d6bb089efa32e4ce866a0762bbe2599505f4a53 100644 --- a/display/composer/v1_2/display_command/display_cmd_requester.h +++ b/display/composer/v1_2/display_command/display_cmd_requester.h @@ -115,6 +115,10 @@ EXIT: DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, HDF_LOGE("%{public}s: HDI 1.2 read vect size failed", __func__)); + if (vectSize > CmdUtils::MAX_MEMORY) { + HDF_LOGE("%{public}s: layers vectSize:%{public}u is too large", __func__, vectSize); + return HDF_FAILURE; + } compChangeLayers_[devId].resize(vectSize); for (uint32_t i = 0; i < vectSize; i++) { DISPLAY_CHK_RETURN(replyUnpacker.ReadUint32(compChangeLayers_[devId][i]) == false, HDF_FAILURE, @@ -126,6 +130,10 @@ EXIT: DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, HDF_LOGE("%{public}s: HDI 1.2 read vect size failed", __func__)); + if (vectSize > CmdUtils::MAX_MEMORY) { + HDF_LOGE("%{public}s: layers vectSize:%{public}u is too large", __func__, vectSize); + return HDF_FAILURE; + } compChangeTypes_[devId].resize(vectSize); for (uint32_t i = 0; i < vectSize; i++) { DISPLAY_CHK_RETURN(replyUnpacker.ReadInt32(compChangeTypes_[devId][i]) == false, HDF_FAILURE, @@ -154,6 +162,10 @@ EXIT: DISPLAY_CHK_RETURN(true != replyUnpacker.ReadUint32(vectSize), HDF_FAILURE, HDF_LOGE("%{public}s: HDI 1.2 read vect size failed", __func__)); + if (vectSize > CmdUtils::MAX_MEMORY) { + HDF_LOGE("%{public}s: layers vectSize:%{public}u is too large", __func__, vectSize); + return HDF_FAILURE; + } layers.resize(vectSize); for (uint32_t i = 0; i < vectSize; i++) { DISPLAY_CHK_RETURN(replyUnpacker.ReadUint32(layers[i]) == false, HDF_FAILURE, @@ -165,6 +177,10 @@ EXIT: DISPLAY_CHK_RETURN(true != replyUnpacker.ReadUint32(vectSize), HDF_FAILURE, HDF_LOGE("%{public}s: HDI 1.2 read vect size failed", __func__)); + if (vectSize > CmdUtils::MAX_MEMORY) { + HDF_LOGE("%{public}s: layers vectSize:%{public}u is too large", __func__, vectSize); + return HDF_FAILURE; + } fences.resize(vectSize); for (uint32_t i = 0; i < vectSize; i++) { ret = CmdUtils::FileDescriptorUnpack(replyUnpacker, replyFds, fences[i]); @@ -241,30 +257,155 @@ EXIT: // LTPO新增接口 int32_t SetDisplayConstraint(uint32_t devId, uint64_t frameID, uint64_t ns, uint32_t type) { - int32_t ret = CmdUtils::StartSection(REQUEST_CMD_SET_DISPLAY_CONSTRAINT, requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: StartSection failed", __func__)); + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_DISPLAY_CONSTRAINT, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + retBool = requestPacker_.WriteUint32(devId); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write devId failed", __func__)); + + retBool = requestPacker_.WriteUint64(frameID); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write frameID failed", __func__)); + + retBool = requestPacker_.WriteUint64(ns); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write ns failed", __func__)); + + retBool = requestPacker_.WriteUint32(type); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write type failed", __func__)); + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("%{public}s: writePos_ rollback", __func__); + return HDF_FAILURE; + } + return HDF_SUCCESS; + } - bool retBool = requestPacker_.WriteUint32(devId); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write devId failed", __func__)); + int32_t SetLayerPerFrameParameterSmq(uint32_t devId, uint32_t layerId, const std::string& key, + const std::vector& value) + { + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_LAYER_PERFRAME_PARAM, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + retBool = requestPacker_.WriteUint32(devId); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write devId failed", __func__)); + + retBool = requestPacker_.WriteUint32(layerId); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write layerId failed", __func__)); + + uint32_t vectStrSize = key.size(); + retBool = requestPacker_.WriteUint32(vectStrSize); + if (vectStrSize > CmdUtils::MAX_MEMORY) { + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write vectStr failed", __func__)); + } + for (uint32_t i = 0; i < vectStrSize; i++) { + retBool = requestPacker_.WriteInt32(static_cast(key[i])); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write vectStr failed", __func__)); + } - retBool = requestPacker_.WriteUint64(frameID); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write frameID failed", __func__)); + uint32_t vectSize = value.size(); + retBool = requestPacker_.WriteUint32(vectSize); + if (vectSize > CmdUtils::MAX_MEMORY) { + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write vect failed", __func__)); + } + for (uint32_t i = 0; i < vectSize; i++) { + retBool = requestPacker_.WriteUint8(static_cast(value[i])); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write vect failed", __func__)); + } - retBool = requestPacker_.WriteUint64(ns); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write ns failed", __func__)); + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); - retBool = requestPacker_.WriteUint32(type); - DISPLAY_CHK_RETURN(retBool == false, HDF_FAILURE, - HDF_LOGE("%{public}s: write type failed", __func__)); + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("SetLayerPerFrameParameterSmq writePos_ rollback %{public}s, %{public}d, %{public}d", + key.c_str(), devId, layerId); - ret = CmdUtils::EndSection(requestPacker_); - DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, ret, - HDF_LOGE("%{public}s: EndSection failed", __func__)); + return HDF_FAILURE; + } + return HDF_SUCCESS; + } + + int32_t SetDisplayPerFrameParameterSmq(uint32_t devId, const std::string& key, + const std::vector& value) + { + int32_t ret = 0; + bool retBool = false; + size_t writePos = requestPacker_.ValidSize(); + + do { + ret = CmdUtils::StartSection(REQUEST_CMD_SET_DISPLAY_PERFRAME_PARAM, requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: StartSection failed", __func__)); + + retBool = requestPacker_.WriteUint32(devId); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write devId failed", __func__)); + + uint32_t vectStrSize = key.size(); + retBool = requestPacker_.WriteUint32(vectStrSize); + if (vectStrSize > CmdUtils::MAX_MEMORY) { + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write vectStr failed", __func__)); + } + for (uint32_t i = 0; i < vectStrSize; i++) { + retBool = requestPacker_.WriteInt32(static_cast(key[i])); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write vectStr failed", __func__)); + } + + uint32_t vectSize = value.size(); + retBool = requestPacker_.WriteUint32(vectSize); + if (vectSize > CmdUtils::MAX_MEMORY) { + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write vect failed", __func__)); + } + for (uint32_t i = 0; i < vectSize; i++) { + retBool = requestPacker_.WriteUint8(static_cast(value[i])); + DISPLAY_CHK_BREAK(retBool == false, + HDF_LOGE("%{public}s: write vect failed", __func__)); + } + + ret = CmdUtils::EndSection(requestPacker_); + DISPLAY_CHK_BREAK(ret != HDF_SUCCESS, + HDF_LOGE("%{public}s: EndSection failed", __func__)); + } while (0); + + if (retBool == false || ret != HDF_SUCCESS) { + requestPacker_.RollBack(writePos); + HDF_LOGE("SetDisplayPerFrameParameterSmq writePos_ rollback %{public}s, %{public}d", + key.c_str(), devId); + return HDF_FAILURE; + } return HDF_SUCCESS; } diff --git a/display/composer/v1_2/display_command/display_cmd_responser.h b/display/composer/v1_2/display_command/display_cmd_responser.h index c2141f01eed4dc0cbc06dddfb897a037c6712637..c9d51f1df41d04478415f0d6b779b661e92a0299 100644 --- a/display/composer/v1_2/display_command/display_cmd_responser.h +++ b/display/composer/v1_2/display_command/display_cmd_responser.h @@ -20,6 +20,7 @@ #include "v1_1/display_command/display_cmd_responser.h" #include "v1_2/display_composer_type.h" #include "v1_2/display_command/display_cmd_utils.h" +#include "hdf_trace.h" #define DISPLAY_TRACE HdfTrace trace(__func__, "HDI:DISP:") @@ -40,7 +41,7 @@ typedef struct CommitInfo { std::vector fences; } CommitInfo; -template +template class DisplayCmdResponser : public V1_1::DisplayCmdResponser { public: static std::unique_ptr Create(VdiImpl* impl, std::shared_ptr cacheMgr) @@ -52,23 +53,8 @@ public: return std::make_unique(impl, cacheMgr); } - static std::unique_ptr CreateV1_1( - VdiImpl1_1* impl, std::shared_ptr cacheMgr) - { - DISPLAY_CHK_RETURN(impl == nullptr, nullptr, - HDF_LOGE("%{public}s: error, VdiImpl is nullptr", __func__)); - DISPLAY_CHK_RETURN(cacheMgr == nullptr, nullptr, - HDF_LOGE("%{public}s: error, VdiImpl is nullptr", __func__)); - return std::make_unique(cacheMgr, impl); - } - DisplayCmdResponser(VdiImpl* impl, std::shared_ptr cacheMgr) : BaseType1_1(impl, cacheMgr) {} - DisplayCmdResponser(std::shared_ptr cacheMgr, VdiImpl1_1* impl) - : BaseType1_1(impl, cacheMgr), - vdiImpl1_1_(impl) - {} - virtual ~DisplayCmdResponser() {} int32_t ProcessRequestCmd(CommandDataUnpacker& unpacker, int32_t cmd, @@ -80,6 +66,10 @@ public: OnCommitAndGetReleaseFence(unpacker, outFds); } else if (cmd == REQUEST_CMD_SET_DISPLAY_CONSTRAINT) { OnSetDisplayConstraint(unpacker); + } else if (cmd == REQUEST_CMD_SET_LAYER_PERFRAME_PARAM) { + OnSetLayerPerFrameParam(unpacker); + } else if (cmd == REQUEST_CMD_SET_DISPLAY_PERFRAME_PARAM) { + OnSetDisplayPerFrameParam(unpacker); } else { return V1_0::DisplayCmdResponser::ProcessRequestCmd(unpacker, cmd, inFds, outFds); } @@ -94,7 +84,7 @@ public: DISPLAY_CHECK(replyPacker_.WriteBool(commitInfo.needFlush) == false, HDF_LOGE("%{public}s, write needFlush error", __func__)); - // Write compLayers vector + // Write compLayers vector uint32_t vectSize = static_cast(commitInfo.compLayers.size()); DISPLAY_CHECK(replyPacker_.WriteUint32(vectSize) == false, HDF_LOGE("%{public}s, write compLayers.size error", __func__)); @@ -103,7 +93,7 @@ public: DISPLAY_CHECK(replyPacker_.WriteUint32(commitInfo.compLayers[i]) == false, HDF_LOGE("%{public}s, write compLayers error", __func__)); } - // Write compTypes vector + // Write compTypes vector vectSize = static_cast(commitInfo.compTypes.size()); DISPLAY_CHECK(replyPacker_.WriteUint32(vectSize) == false, HDF_LOGE("%{public}s, write compTypes.size error", __func__)); @@ -237,8 +227,7 @@ REPLY: std::vector& outFds) { std::shared_ptr requestData(new char[inEleCnt * CmdUtils::ELEMENT_SIZE], std::default_delete()); - int32_t ret = request_->Read(reinterpret_cast(requestData.get()), inEleCnt, - CmdUtils::TRANSFER_WAIT_TIME); + int32_t ret = CmdRequestDataRead(requestData, inEleCnt); CommandDataUnpacker unpacker; unpacker.Init(requestData.get(), inEleCnt << CmdUtils::MOVE_SIZE); @@ -254,11 +243,14 @@ REPLY: HDF_LOGI("error: unpacker PackBegin cmd not match, cmd(%{public}d)=%{public}s.", unpackCmd, CmdUtils::CommandToString(unpackCmd))); + DISPLAY_CHK_RETURN(PeriodDataReset() == HDF_FAILURE, HDF_FAILURE, + HDF_LOGE("%{public}s: error: PeriodDataReset failed", __func__)); while (ret == HDF_SUCCESS && unpacker.NextSection()) { if (!unpacker.BeginSection(unpackCmd)) { HDF_LOGE("error: PackSection failed, unpackCmd=%{public}s.", CmdUtils::CommandToString(unpackCmd)); ret = HDF_FAILURE; + break; } ret = ProcessRequestCmd(unpacker, unpackCmd, inFds, outFds); } @@ -276,14 +268,12 @@ REPLY: /* Write reply pack */ outEleCnt = replyPacker_.ValidSize() >> CmdUtils::MOVE_SIZE; - ret = reply_->Write(reinterpret_cast(replyPacker_.GetDataPtr()), outEleCnt, - CmdUtils::TRANSFER_WAIT_TIME); + ret = CmdRequestDataWrite(outEleCnt); if (ret != HDF_SUCCESS) { HDF_LOGE("Reply write failure, ret=%{public}d", ret); outEleCnt = 0; } - int32_t ec = PeriodDataReset(); - return (ret == HDF_SUCCESS ? ec : ret); + return ret; } int32_t OnSetDisplayConstraint(CommandDataUnpacker& unpacker) @@ -305,10 +295,14 @@ REPLY: ret = unpacker.ReadUint32(type) ? HDF_SUCCESS : HDF_FAILURE; DISPLAY_CHECK(ret != HDF_SUCCESS, goto EXIT); - if (vdiImpl1_1_ != nullptr) { - ret = vdiImpl1_1_->SetDisplayConstraint(devId, frameID, ns, type); + + if (impl_ != nullptr && impl_->SetDisplayConstraint != nullptr) { + ret = impl_->SetDisplayConstraint(devId, frameID, ns, type); + } + + if (ret != HDF_SUCCESS && ret != DISPLAY_NOT_SUPPORT && ret != HDF_ERR_NOT_SUPPORT) { + HDF_LOGE("SetDisplayConstraint failed with ret = %{public}d", ret); } - DISPLAY_CHECK(ret != HDF_SUCCESS && ret != DISPLAY_NOT_SUPPORT && ret != HDF_ERR_NOT_SUPPORT, goto EXIT); EXIT: if (ret != HDF_SUCCESS) { errMaps_.emplace(REQUEST_CMD_SET_DISPLAY_CONSTRAINT, ret); @@ -316,6 +310,122 @@ EXIT: return ret; } + int32_t OnSetLayerPerFrameParam(CommandDataUnpacker& unpacker) + { + DISPLAY_TRACE; + uint32_t devId = 0; + uint32_t layerId = 0; + std::string key; + std::vector value; + uint32_t vectSize = 0; + uint32_t vectStrSize = 0; + + int32_t ret = unpacker.ReadUint32(devId) ? HDF_SUCCESS : HDF_FAILURE; + DISPLAY_CHECK(ret != HDF_SUCCESS, goto UNPACKER_EXIT); + + ret = unpacker.ReadUint32(layerId) ? HDF_SUCCESS : HDF_FAILURE; + DISPLAY_CHECK(ret != HDF_SUCCESS, goto UNPACKER_EXIT); + + ret = unpacker.ReadUint32(vectStrSize) ? HDF_SUCCESS : HDF_FAILURE; + DISPLAY_CHECK(ret != HDF_SUCCESS, goto UNPACKER_EXIT); + + for (uint32_t i = 0; i < vectStrSize; i++) { + int32_t tmpChar; + ret = unpacker.ReadInt32(tmpChar) ? HDF_SUCCESS : HDF_FAILURE; + if (ret != HDF_SUCCESS) { + break; + } + key.push_back(static_cast(tmpChar)); + } + DISPLAY_CHECK(ret != HDF_SUCCESS, goto UNPACKER_EXIT); + + ret = unpacker.ReadUint32(vectSize) ? HDF_SUCCESS : HDF_FAILURE; + DISPLAY_CHECK(ret != HDF_SUCCESS, goto UNPACKER_EXIT); + + for (uint32_t i = 0; i < vectSize; i++) { + uint8_t tmpValue; + ret = unpacker.ReadUint8(tmpValue) ? HDF_SUCCESS : HDF_FAILURE; + if (ret != HDF_SUCCESS) { + break; + } + value.push_back(static_cast(tmpValue)); + } + DISPLAY_CHECK(ret != HDF_SUCCESS, goto UNPACKER_EXIT); + + HDF_LOGD("OnSetLayerPerFrameParam %{public}s, %{public}d, %{public}d", + key.c_str(), devId, layerId); + + if (impl_ != nullptr && impl_->SetLayerPerFrameParameter != nullptr) { + ret = impl_->SetLayerPerFrameParameter(devId, layerId, key, value); + } + + if (ret != HDF_SUCCESS && ret != DISPLAY_NOT_SUPPORT && ret != HDF_ERR_NOT_SUPPORT) { + HDF_LOGE("OnSetLayerPerFrameParam %{public}s, %{public}d, %{public}d, %{public}d", + key.c_str(), devId, layerId, ret); + } +UNPACKER_EXIT: + if (ret != HDF_SUCCESS) { + errMaps_.emplace(REQUEST_CMD_SET_LAYER_PERFRAME_PARAM, ret); + } + return ret; + } + + int32_t OnSetDisplayPerFrameParam(CommandDataUnpacker& unpacker) + { + DISPLAY_TRACE; + uint32_t devId = 0; + std::string key; + std::vector value; + uint32_t vectSize = 0; + uint32_t vectStrSize = 0; + + int32_t ret = unpacker.ReadUint32(devId) ? HDF_SUCCESS : HDF_FAILURE; + DISPLAY_CHECK(ret != HDF_SUCCESS, goto UNPACKER_EXIT); + + ret = unpacker.ReadUint32(vectStrSize) ? HDF_SUCCESS : HDF_FAILURE; + DISPLAY_CHECK(ret != HDF_SUCCESS, goto UNPACKER_EXIT); + + for (uint32_t i = 0; i < vectStrSize; i++) { + int32_t tmpChar; + ret = unpacker.ReadInt32(tmpChar) ? HDF_SUCCESS : HDF_FAILURE; + if (ret != HDF_SUCCESS) { + break; + } + key.push_back(static_cast(tmpChar)); + } + DISPLAY_CHECK(ret != HDF_SUCCESS, goto UNPACKER_EXIT); + + ret = unpacker.ReadUint32(vectSize) ? HDF_SUCCESS : HDF_FAILURE; + DISPLAY_CHECK(ret != HDF_SUCCESS, goto UNPACKER_EXIT); + + for (uint32_t i = 0; i < vectSize; i++) { + uint8_t tmpValue; + ret = unpacker.ReadUint8(tmpValue) ? HDF_SUCCESS : HDF_FAILURE; + if (ret != HDF_SUCCESS) { + break; + } + value.push_back(static_cast(tmpValue)); + } + DISPLAY_CHECK(ret != HDF_SUCCESS, goto UNPACKER_EXIT); + + HDF_LOGD("OnSetDisplayPerFrameParam %{public}s, %{public}d", + key.c_str(), devId); + + if (impl_ != nullptr && impl_->SetDisplayPerFrameParameter != nullptr) { + ret = impl_->SetDisplayPerFrameParameter(devId, key, value); + } + + if (ret != HDF_SUCCESS && ret != DISPLAY_NOT_SUPPORT && ret != HDF_ERR_NOT_SUPPORT) { + HDF_LOGE("OnSetDisplayPerFrameParam %{public}s, %{public}d, %{public}d", + key.c_str(), devId, ret); + } +UNPACKER_EXIT: + if (ret != HDF_SUCCESS) { + errMaps_.emplace(REQUEST_CMD_SET_DISPLAY_PERFRAME_PARAM, ret); + } + return ret; + } + private: using BaseType1_1 = V1_1::DisplayCmdResponser; using BaseType1_1::replyPacker_; @@ -344,14 +454,13 @@ private: using BaseType1_1::OnSetLayerMaskInfo; using BaseType1_1::OnRequestEnd; using BaseType1_1::OnSetLayerColor; - VdiImpl1_1* vdiImpl1_1_ = nullptr; + using BaseType1_1::CmdRequestDataRead; + using BaseType1_1::CmdRequestDataWrite; + using BaseType1_1::requestMutex_; + using BaseType1_1::replyMutex_; }; -using HdiDisplayCmdResponser = - DisplayCmdResponser, IDisplayComposerVdi, IDisplayComposerVdiV1_1>; - -using HdiDisplayCmdResponser_1_1 = - DisplayCmdResponser, IDisplayComposerVdi, IDisplayComposerVdiV1_1>; +using HdiDisplayCmdResponser = DisplayCmdResponser, DisplayComposerVdiAdapter>; } // namespace V1_2 } // namespace Composer diff --git a/display/composer/v1_2/hdi_impl/display_composer_hdi_impl.h b/display/composer/v1_2/hdi_impl/display_composer_hdi_impl.h index b6201f87a0be76b3cad1014ddcd4f45b356e9deb..2b0042e48312e0f423c2dc2cf9cae47dd33a512d 100644 --- a/display/composer/v1_2/hdi_impl/display_composer_hdi_impl.h +++ b/display/composer/v1_2/hdi_impl/display_composer_hdi_impl.h @@ -82,7 +82,7 @@ public: COMPOSER_CHECK_NULLPTR_RETURN(hdi_v1_2_); value = 0; int32_t ret = ToDispErrCode(hdi_v1_2_->GetDisplayProperty(devId, id, value)); - if (ret == DISPLAY_SUCCESS) { + if (ret == DISPLAY_SUCCESS && id == V1_2::DisplayPropertyID::DISPLAY_PROPERTY_ID_SKIP_VALIDATE) { isSupportSkipValidate_ = value; } @@ -116,20 +116,24 @@ public: } virtual int32_t ClearClientBuffer(uint32_t devId) override { - COMPOSER_CHECK_NULLPTR_RETURN(req_v1_2_); + COMPOSER_CHECK_NULLPTR_RETURN(hdi_v1_2_); return ToDispErrCode(hdi_v1_2_->ClearClientBuffer(devId)); } virtual int32_t ClearLayerBuffer(uint32_t devId, uint32_t layerId) override { - COMPOSER_CHECK_NULLPTR_RETURN(req_v1_2_); + COMPOSER_CHECK_NULLPTR_RETURN(hdi_v1_2_); return ToDispErrCode(hdi_v1_2_->ClearLayerBuffer(devId, layerId)); } - virtual int32_t SetHardwareCursorPosition(uint32_t devId, int32_t x, int32_t y) override + virtual int32_t UpdateHardwareCursor(uint32_t devId, int32_t x, int32_t y, BufferHandle* buffer) override { COMPOSER_CHECK_NULLPTR_RETURN(hdi_v1_2_); - int32_t ret = ToDispErrCode(hdi_v1_2_->SetHardwareCursorPosition(devId, x, y)); + COMPOSER_CHECK_NULLPTR_RETURN(buffer); + sptr hdiBuffer = new NativeBuffer(buffer); + COMPOSER_CHECK_NULLPTR_RETURN(hdiBuffer); + + int32_t ret = ToDispErrCode(hdi_v1_2_->UpdateHardwareCursor(devId, x, y, hdiBuffer)); return ret; } @@ -147,6 +151,48 @@ public: return ret; } + virtual int32_t SetDisplayActiveRegion(uint32_t devId, const IRect& rect) override + { + COMPOSER_CHECK_NULLPTR_RETURN(hdi_v1_2_); + int32_t ret = ToDispErrCode(hdi_v1_2_->SetDisplayActiveRegion(devId, rect)); + return ret; + } + + virtual int32_t FastPresent(uint32_t devId, const PresentParam& param, + const std::vector inHandles) override + { + COMPOSER_CHECK_NULLPTR_RETURN(hdi_v1_2_); + std::vector> outHandles; + for (auto inHandle : inHandles) { + sptr nativeBuffer = new NativeBuffer(inHandle); + if (nativeBuffer == nullptr) { + HDF_LOGE("failed to alloc mem for NativeBuffer"); + return DISPLAY_FAILURE; + } + outHandles.emplace_back(nativeBuffer); + } + return ToDispErrCode(hdi_v1_2_->FastPresent(devId, param, outHandles)); + } + + virtual int32_t SetLayerPerFrameParameterSmq(uint32_t devId, uint32_t layerId, const std::string& key, + const std::vector& value) override + { + return ToDispErrCode(req_v1_2_->SetLayerPerFrameParameterSmq(devId, layerId, key, value)); + } + + virtual int32_t SetDisplayPerFrameParameterSmq(uint32_t devId, const std::string& key, + const std::vector& value) override + { + return ToDispErrCode(req_v1_2_->SetDisplayPerFrameParameterSmq(devId, key, value)); + } + + virtual int32_t GetDisplayIdentificationData(uint32_t devId, uint8_t& portId, + std::vector& edidData) override + { + COMPOSER_CHECK_NULLPTR_RETURN(hdi_v1_2_); + return ToDispErrCode(hdi_v1_2_->GetDisplayIdentificationData(devId, portId, edidData)); + } + protected: using BaseType1_1 = V1_1::DisplayComposerHdiImpl; using BaseType1_1::WAIT_TIME_INTERVAL; diff --git a/display/composer/v1_2/include/idisplay_composer_interface.h b/display/composer/v1_2/include/idisplay_composer_interface.h index 5a6252b19b5e2446e92fc4d5f4315995f0683750..77ef2d21b334ea73917cbbea59393ac5c24e0d50 100644 --- a/display/composer/v1_2/include/idisplay_composer_interface.h +++ b/display/composer/v1_2/include/idisplay_composer_interface.h @@ -66,11 +66,24 @@ public: virtual int32_t ClearLayerBuffer(uint32_t devId, uint32_t layerId) = 0; - virtual int32_t SetHardwareCursorPosition(uint32_t devId, int32_t x, int32_t y) = 0; + virtual int32_t UpdateHardwareCursor(uint32_t devId, int32_t x, int32_t y, BufferHandle* buffer) = 0; virtual int32_t EnableHardwareCursorStats(uint32_t devId, bool enable) = 0; virtual int32_t GetHardwareCursorStats(uint32_t devId, uint32_t& frameCount, uint32_t& vsyncCount) = 0; + + virtual int32_t SetDisplayActiveRegion(uint32_t devId, const IRect& rect) = 0; + + virtual int32_t FastPresent(uint32_t devId, const PresentParam& param, + const std::vector inHandles) = 0; + + virtual int32_t GetDisplayIdentificationData(uint32_t devId, uint8_t& portId, std::vector& edidData) = 0; + + virtual int32_t SetLayerPerFrameParameterSmq(uint32_t devId, uint32_t layerId, const std::string& key, + const std::vector& value) = 0; + + virtual int32_t SetDisplayPerFrameParameterSmq(uint32_t devId, const std::string& key, + const std::vector& value) = 0; }; } // V1_2 } // Composer diff --git a/display/graphic/common/v1_1/BUILD.gn b/display/graphic/common/v1_1/BUILD.gn index 8e4ea03f23c19882c3bc84134547d024416b73d5..4b4478c88da19a364a8ade79bb2142c636004302 100644 --- a/display/graphic/common/v1_1/BUILD.gn +++ b/display/graphic/common/v1_1/BUILD.gn @@ -16,6 +16,11 @@ import("//build/config/components/hdi/hdi.gni") hdi("display_commontype") { module_name = "display_commontype" + deps = [ + "//drivers/interface/display/graphic/common/v1_0:libdisplay_commontype_proxy_1.0", + "//drivers/interface/display/graphic/common/v1_0:libdisplay_commontype_stub_1.0", + ] + sources = [ "BufferHandleMetaKeyType.idl" ] language = "cpp" diff --git a/display/graphic/common/v2_0/BufferHandleMetaKeyType.idl b/display/graphic/common/v2_0/BufferHandleMetaKeyType.idl index eefca05d94936a611770bce607822483e8547313..a6b5d2826f6da5d6792b3ad77c20745ae37b922e 100644 --- a/display/graphic/common/v2_0/BufferHandleMetaKeyType.idl +++ b/display/graphic/common/v2_0/BufferHandleMetaKeyType.idl @@ -46,6 +46,7 @@ enum BufferHandleAttrKey { ATTRKEY_REQUEST_ACCESS_TYPE = 10, // value: current request frame mode ATTRKEY_ACCESS_TYPE = 11, // value: current data frame mode ATTRKEY_FORCE_GLOBAL_ALPHA = 12, // 0~255, pixel alpha value, default to -1, don't take effect. + ATTRKEY_VIDEO_DECODER_MV = 13, // value BlobDataType /* vendor internal extended meta type */ ATTRKEY_VENDOR_EXT_START = 2048, @@ -64,3 +65,29 @@ enum HebcAccessType { HEBC_ACCESS_CPU_ACCESS, // cpu is accessible; hebc is not accessible HEBC_ACCESS_HW_ONLY, // hardware_only: cpu is not accessible; hebc is accessible }; + +/** + * @brief Enumerates the CacheOption types. + * + * @since 5.0 + * @version 2.0 + */ +enum CacheOption { + CACHE_NOOP = 0x0, // Do nothing + CACHE_INVALIDATE, // Hardware writing aux buffer to disable cache + CACHE_FLUSH, // Write aux buffer on CPU and flash cache to DDR +}; + +/** + * @brief BlobDataType of [value] in GetMetadata/SetMetaData, to avoid data copy. + * + * @since 5.0 + * @version 2.0 + */ +struct BlobDataType { + unsigned long vaddr; // virtual address, direct accessed w/o copy + unsigned int offset; // field offset in dmabuf, support dma access + unsigned int length; // data length set by previous SetMetadata(), default to 0 + unsigned int capacity; // reserved data size + enum CacheOption cacheOp; // effective in SetMetaData() +}; \ No newline at end of file diff --git a/display/graphic/common/v2_1/BUILD.gn b/display/graphic/common/v2_1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8a6bb051ce3adcf1fe5a69fe628418c70cb17199 --- /dev/null +++ b/display/graphic/common/v2_1/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2024 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. + +import("//build/config/components/hdi/hdi.gni") + +hdi("display_commontype") { + module_name = "display_commontype" + + deps = [ + "//drivers/interface/display/graphic/common/v2_0:libdisplay_commontype_proxy_2.0", + "//drivers/interface/display/graphic/common/v2_0:libdisplay_commontype_stub_2.0", + ] + + sources = [ + "BufferHandleMetaKeyType.idl", + "CMColorSpace.idl", + ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_display" +} diff --git a/display/graphic/common/v2_1/BufferHandleMetaKeyType.idl b/display/graphic/common/v2_1/BufferHandleMetaKeyType.idl new file mode 100644 index 0000000000000000000000000000000000000000..0d810c022093175476ee656eac60da37307ec0fa --- /dev/null +++ b/display/graphic/common/v2_1/BufferHandleMetaKeyType.idl @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 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 HdiDisplay + * + * @since 5.1 + * @version 2.1 + */ + +package ohos.hdi.display.graphic.common.v2_1; +import ohos.hdi.display.graphic.common.v2_0.BufferHandleMetaKeyType; + +/** + * @ brief Enumerates buffer handle attribution keys. + * + */ +enum BufferHandleAttrKey : ohos.hdi.display.graphic.common.v2_0.BufferHandleAttrKey { + ATTRKEY_VIDEO_TV_PQ = 2049, // value: TvPQMetadata + ATTRKEY_ADAPTIVE_FOV_METADATA = 2050, // value: byte stream of look up table +}; \ No newline at end of file diff --git a/display/graphic/common/v2_1/CMColorSpace.idl b/display/graphic/common/v2_1/CMColorSpace.idl new file mode 100644 index 0000000000000000000000000000000000000000..7692c2ca181a20427cb19691176d622afab64ba1 --- /dev/null +++ b/display/graphic/common/v2_1/CMColorSpace.idl @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 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 HdiDisplay + * + * @brief Define the clolor space Key interface of the display module. + * + * This module provides the clolor space types used by the driver interface for the upper-level graphics service. + * + * @since 5.1 + * @version 2.1 + */ + +/** + * @file CMColorSpace.idl + * @brief Declares the clolor space types used by the interfaces related to clolor space Meta Key operations. + * + */ + +package ohos.hdi.display.graphic.common.v2_1; +import ohos.hdi.display.graphic.common.v2_0.CMColorSpace; + +/** + * @brief Enumerates the HDR metadata Attr Key types. + * + */ +enum CM_HDR_Metadata_Type : ohos.hdi.display.graphic.common.v2_0.CM_HDR_Metadata_Type { + /* Video AIHDR metadata type */ + CM_VIDEO_AI_HDR = 60, // video AIHDR +}; \ No newline at end of file diff --git a/distributed_audio/audio/v1_0/BUILD.gn b/distributed_audio/audio/v1_0/BUILD.gn index aa170b3e00eaeeaaba42a4d429c47dafb6e735f6..487b8b88b1b4d2a48bb882a07cd916aaf1727761 100644 --- a/distributed_audio/audio/v1_0/BUILD.gn +++ b/distributed_audio/audio/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("daudio") { module_name = "daudio" sources = [ @@ -22,6 +22,7 @@ hdi("daudio") { "IAudioManager.idl", "IAudioRender.idl", ] + branch_protector_ret = "pac_ret" language = "cpp" root = "ohos.hdi://drivers/interface/" subsystem_name = "hdf" diff --git a/distributed_audio/audioext/v1_0/BUILD.gn b/distributed_audio/audioext/v1_0/BUILD.gn index d75300da1f7ee9fe1ac4d3006477a441eecb27b8..d895b5c2776dadd31c4b732394f4a59adda04862 100644 --- a/distributed_audio/audioext/v1_0/BUILD.gn +++ b/distributed_audio/audioext/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("daudioext") { module_name = "daudioext" sources = [ diff --git a/distributed_audio/audioext/v2_0/BUILD.gn b/distributed_audio/audioext/v2_0/BUILD.gn index a5d1b9658fdd41356870d064149124eaa0035806..b5adde5cb4207b9a0371c7671413eb2732f2ac61 100644 --- a/distributed_audio/audioext/v2_0/BUILD.gn +++ b/distributed_audio/audioext/v2_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("daudioext") { module_name = "daudioext" sources = [ diff --git a/distributed_camera/bundle.json b/distributed_camera/bundle.json index 90cb385afc5fbfcea0b8bc1680efcb3f31cd2826..d6f5e70f1c39777e3d7e3bebbc8ed7612b2fc61b 100644 --- a/distributed_camera/bundle.json +++ b/distributed_camera/bundle.json @@ -22,8 +22,7 @@ "hdf_core", "hilog", "c_utils" - ], - "third_party": [] + ] }, "build": { "sub_component": [ diff --git a/distributed_camera/v1_0/BUILD.gn b/distributed_camera/v1_0/BUILD.gn index feaf504da2d07396336f02874fab504c2f1d2d1f..f453ba8f37578f150a6b0486db97ca8592cd9038 100644 --- a/distributed_camera/v1_0/BUILD.gn +++ b/distributed_camera/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("distributed_camera_provider") { module_name = "distributed_camera_provider_service" sources = [ diff --git a/distributed_camera/v1_1/BUILD.gn b/distributed_camera/v1_1/BUILD.gn index a9989d0b17f4633fefcfd14db5de2942e90b768e..6d435160cb4f6606b5cb3838c91f0d466df02357 100644 --- a/distributed_camera/v1_1/BUILD.gn +++ b/distributed_camera/v1_1/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("distributed_camera_provider") { module_name = "distributed_camera_provider_service" sources = [ diff --git a/drm/v1_0/BUILD.gn b/drm/v1_0/BUILD.gn index 88a1b6f3785d42c6d4d0a103de125b489ccbd36c..e27710e7f96f8ed5bd678ef9d818f77d4b8ab542 100644 --- a/drm/v1_0/BUILD.gn +++ b/drm/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("../../../hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") if (defined(ohos_lite)) { group("libdrm_proxy_1.0") { deps = [] diff --git a/face_auth/v1_0/BUILD.gn b/face_auth/v1_0/BUILD.gn index 576da45176707a0b1cf85ec0509897470500d39b..1acd69536c8b3b3b13c3e9d0e4c4076d89e615e9 100644 --- a/face_auth/v1_0/BUILD.gn +++ b/face_auth/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") import("../config.gni") hdi("face_auth") { diff --git a/face_auth/v1_1/BUILD.gn b/face_auth/v1_1/BUILD.gn index acdd43e802183da0993787df619593582dcd8251..cf58c99e7a2b4708d73177a544378a6985b63daf 100644 --- a/face_auth/v1_1/BUILD.gn +++ b/face_auth/v1_1/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") import("../config.gni") hdi("face_auth") { diff --git a/face_auth/v2_0/BUILD.gn b/face_auth/v2_0/BUILD.gn index 37dc021421ebf948f1a489a6e7e377d33b367f2d..aff796966628952a560fe2db27a0864f9025c5d3 100644 --- a/face_auth/v2_0/BUILD.gn +++ b/face_auth/v2_0/BUILD.gn @@ -25,6 +25,7 @@ hdi("face_auth") { ] sequenceable_ext_deps = [ "drivers_interface_camera:libbuffer_producer_sequenceable_1.0", + "graphic_surface:buffer_handle", "graphic_surface:surface", ] language = "cpp" diff --git a/huks/bundle.json b/huks/bundle.json index 6e795ca296fe604befdb9e28d7d953d62966fbf9..09c443648a1b66165d073275e19afbc4c9fcd66f 100755 --- a/huks/bundle.json +++ b/huks/bundle.json @@ -29,13 +29,13 @@ }, "build": { "sub_component": [ - "//drivers/interface/huks/v1_0:huks_idl_target" + "//drivers/interface/huks/v1_1:huks_idl_target" ], "test": [ ], "inner_kits": [ { - "name": "//drivers/interface/huks/v1_0:libhuks_proxy_1.0", + "name": "//drivers/interface/huks/v1_1:libhuks_proxy_1.1", "header": { "header_files": [ ], @@ -43,7 +43,7 @@ } }, { - "name": "//drivers/interface/huks/v1_0:huks_idl_headers", + "name": "//drivers/interface/huks/v1_1:huks_idl_headers", "header": { "header_files": [ ], diff --git a/huks/v1_1/BUILD.gn b/huks/v1_1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8dc7e0fad151495636a0e106390d4d832417f753 --- /dev/null +++ b/huks/v1_1/BUILD.gn @@ -0,0 +1,26 @@ +# Copyright (c) 2024 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. + +import("//build/config/components/hdi/hdi.gni") +hdi("huks") { + module_name = "drivers_peripheral_huks" + + sources = [ + "IHuks.idl", + "IHuksTypes.idl", + ] + language = "c" + subsystem_name = "hdf" + part_name = "drivers_interface_huks" + mode = "passthrough" +} diff --git a/huks/v1_1/IHuks.idl b/huks/v1_1/IHuks.idl new file mode 100644 index 0000000000000000000000000000000000000000..ca7ee8acd4c4821b15b5f61238cd529de600973e --- /dev/null +++ b/huks/v1_1/IHuks.idl @@ -0,0 +1,520 @@ +/* + * Copyright (c) 2024 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 HdfHuks + * @{ + * + * @brief Provides standard driver APIs for OpenHarmony Universal KeyStore (HUKS). + * + * The HUKS driver APIs define standard interfaces of the HUKS Core and provide + * a unified driver interface for the HUKS service. + * You can use these APIs to implement key lifecycle management, including + * key generation, key import and export, key operations, key access control, + * and key attestation. + * + * @since 4.0 + */ + + /** + * @file IHuks.idl + * + * @brief Defines the HUKS driver interfaces for key management. + * + * @since 4.0 + */ + +package ohos.hdi.huks.v1_1; + +import ohos.hdi.huks.v1_1.IHuksTypes; + +/** + * @brief Defines the HUKS driver interfaces for key management. + * + * @since 4.0 + * @version 1.0 + */ +interface IHuks { + /** + * @brief Initializes the HUKS driver. + * + * @return Returns 0 if the initialization is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + ModuleInit(); + + /** + * @brief Destroy the HUKS driver, including clear memory, temp key, etc. + * + * @return Returns 0 if the destory is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + ModuleDestroy(); + + /** + * @brief Generates a key and returns the key in ciphertext. + * + * @param keyAlias Indicates the alias {@link HuksBlob} of the key + * to generate. + * @param paramSet Indicates the property set {@link HuksParamSet} of the + * key to generate. For details about the key property set struct, + * see the HUKS Device Development. + * @param keyIn Indicates the material {@link HuksBlob} of the key + * to generate. This parameter is optional. + * @param encKeyOut Indicates the key {@link HuksBlob} generated in + * ciphertext. For details about the key material struct, see the + * HUKS Device Development. + * + * @return Returns 0 if the key is generated. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + GenerateKey([in] struct HuksBlob keyAlias,[in] struct HuksParamSet paramSet, + [in] struct HuksBlob keyIn, [out] struct HuksBlob encKeyOut); + + /** + * @brief Imports a key in plaintext. + * + * @param keyAlias Indicates the alias {@link HuksBlob} of the key to import. + * @param key Indicates the material {@link HuksBlob} in plaintext of the + * key to import. For details about the key material struct, see the + * HUKS Device Development. + * @param paramSet Indicates the property set {@link HuksParamSet} of the + * key to import. For details about the key property set struct, see the + * HUKS Device Development. + * @param encKeyOut Indicates the key {@link HuksBlob} in ciphertext + * imported. For details about the key material struct, see the + * HUKS Device Development. + * + * @return Returns 0 if the key is imported. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + ImportKey([in] struct HuksBlob keyAlias, [in] struct HuksBlob key, + [in] struct HuksParamSet paramSet, [out] struct HuksBlob encKeyOut); + + /** + * @brief Imports an encrypted key. + * + * @param wrappingKeyAlias Indicates the alias of an intermediate key used + * to wrap the key to import. For details, see {@link HuksBlob}. + * @param wrappingEncKey Indicates the encrypted intermediate + * key {@link HuksBlob}. For details about the key material struct, see the + * HUKS Device Development. + * @param wrappedKeyData Indicates the encrypted key + * material {@link HuksBlob} of the key to import. For details about the + * key material struct, see the HUKS Device Development. + * @param paramSet Indicates the property set {@link HuksParamSet} of the + * key to import. For details about the key property set struct, see the + * HUKS Device Development. + * @param encKeyOut Indicates the key {@link HuksBlob} in ciphertext + * imported. For details about the key material struct, see the + * HUKS Device Development. + * + * @return Returns 0 if the key is imported. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + ImportWrappedKey([in] struct HuksBlob wrappingKeyAlias, [in] struct HuksBlob wrappingEncKey, + [in] struct HuksBlob wrappedKeyData, [in] struct HuksParamSet paramSet, [out] struct HuksBlob encKeyOut); + + /** + * @brief Exports the public key of a key pair. + * + * @param encKey Indicates the key pair material {@link HuksBlob} + * in ciphertext. For details about the key material struct, see the + * HUKS Device Development. + * @param paramSet Indicates the property set {@link HuksParamSet} of the + * key to export. For details about the key property set struct, see the + * HUKS Device Development. + * @param keyOut Indicates the public key material {@link HuksBlob} + * exported. For details about the key material struct, see the + * HUKS Device Development. + * + * @return Returns 0 if the public key is exported. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + ExportPublicKey([in] struct HuksBlob encKey, [in] struct HuksParamSet paramSet, [out] struct HuksBlob keyOut); + + /** + * @brief Initializes a key session, decrypts the key material into memory, + * and returns a handle and a token. + * + * @param encKey Indicates the key material {@link HuksBlob} in ciphertext. + * For details about the key material struct, see the HUKS Device Development. + * @param paramSet Indicates the parameter set {@link HuksParamSet} used + * for the key operation. It contains parameters for the key operation. + * @param handle Indicates the key session handle {@link HuksBlob} returned + * for subsequent key session operations. + * @param token Indicates the key session token {@link HuksBlob}, + * which is used for key access control. + * + * @see Init | Update| Finish + * + * @return Returns 0 if the session initialization is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + Init([in] struct HuksBlob encKey, [in] struct HuksParamSet paramSet, [out]struct HuksBlob handle, + [out] struct HuksBlob token); + + /** + * @brief Updates (processes or passes in) data by segment based on + * the cryptographic algorithm used (for example, in key agreement). + * + * @param handle Indicates the key session handle {@link HuksBlob}, + * which is obtained by {@Init()}. + * @param paramSet Indicates the parameter set {@link HuksParamSet} + * used for the key operation. For details about the key property set + * struct, see the HUKS Device Development. + * @param inData Indicates the data segment or parameters {@link HuksBlob}. + * @param outData Indicates the output data {@link HuksBlob}. + * + * @see Init | Finish | Abort + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + Update([in] struct HuksBlob handle, [in] struct HuksParamSet paramSet, + [in] struct HuksBlob inData, [out] struct HuksBlob outData); + + /** + * @brief Finishes the key session operation. + * + * @param handle Indicates the key session handle {@link HuksBlob}. + * @param paramSet Indicates the parameter set {@link HuksParamSet} used + * for the key operation. For details about the key property set struct, + * see the HUKS Device Development. + * @param inData Indicates the data segment or parameters {@link HuksBlob}. + * @param outData Indicates the output data {@link HuksBlob}. + * + * @see Init | Update | Abort + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + Finish([in] struct HuksBlob handle, [in] struct HuksParamSet paramSet, + [in] struct HuksBlob inData, [out] struct HuksBlob outData); + + /** + * @brief Aborts a key session and releases the data used in the session. + * The aborted session cannot be operated. + * + * @param handle Indicates the key session handle {@link HuksBlob}. + * @param paramSet Indicates the parameter set {@link HuksParamSet} used + * for the key operation. For details about the key property set struct, + * see the HUKS Device Development. + * + * @see Init | Update | Finish + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + Abort([in] struct HuksBlob handle, [in] struct HuksParamSet paramSet); + + /** + * @brief Checks the key validity (integrity of the key and its properties). + * + * @param paramSet Indicates the parameter set {@link HuksParamSet} for + * checking the key validity. For details about the key property set struct, + * see the HUKS Device Development. + * @param encKey Indicates the key material {@link HuksBlob} in ciphertext + * to check. For details about the key material struct, see + * the HUKS Device Development. + * + * @return Returns 0 if the key material is valid. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + CheckKeyValidity([in] struct HuksParamSet paramSet, [in] struct HuksBlob encKey); + + /** + * @brief Obtains the certificate chain for the given key. + * + * @param encKey Indicates the key material {@link HuksBlob} in ciphertext. + * For details about the key material struct, see the HUKS Device Development. + * @param paramSet Indicates the parameters {@link HuksParamSet} used to + * obtain the certificate chain. For details about the key property + * set struct, see the HUKS Device Development. + * @param certChain Indicates the certificate chain {@link HuksBlob} + * obtained. For details about the certificate chain struct, see the + * HUKS Device Development. + * + * @return Returns 0 if the certificate chain is obtained. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + AttestKey([in] struct HuksBlob encKey, [in] struct HuksParamSet paramSet, [out] struct HuksBlob certChain); + + /** + * @brief Generates a random number. + * + * @param paramSet Indicates the parameters {@link HuksParamSet} used to + * generate a random number. For details about the key property set struct, + * see the HUKS Device Development. + * @param random Indicates the random number {@link HuksBlob} generated. + * + * @return Returns 0 if a random number is generated. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + GenerateRandom([in] struct HuksParamSet paramSet, [out]struct HuksBlob random); + + /** + * @brief Generates a signature for data using a key. + * + * @param encKey Indicates the key material {@link HuksBlob} in ciphertext. + * For details about the key material struct, see the HUKS Device Development. + * @param paramSet Indicates the parameters {@link HuksParamSet} used for signing. + * For details about the key property set struct, see the HUKS Device Development. + * @param srcData Indicates the data {@link HuksBlob} to be signed. + * @param signature Indicates the signature {@link HuksBlob} generated. + * + * @return Returns 0 if a signature is generated. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + Sign([in] struct HuksBlob encKey, [in] struct HuksParamSet paramSet, [in] struct HuksBlob srcData, + [out]struct HuksBlob signature); + + /** + * @brief Verifies a signature. + * + * @param encKey Indicates the key material {@link HuksBlob} in ciphertext. + * For details about the key material struct, see the HUKS Device Development. + * @param paramSet Indicates the parameters {@link HuksParamSet} used for + * signature verification. For details about the key property set struct, + * see the HUKS Device Development. + * @param srcData Indicates the data {@link HuksBlob} whose signature is + * to be verified. + * @param signature Indicates the signature {@link HuksBlob} to verify. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + Verify([in] struct HuksBlob encKey, [in] struct HuksParamSet paramSet, [in] struct HuksBlob srcData, + [in] struct HuksBlob signature); + + /** + * @brief Encrypts data using a key. + * + * @param encKey Indicates the key material {@link HuksBlob} in ciphertext. + * For details about the key material struct, see the HUKS Device Development. + * @param paramSet Indicates the parameters {@link HuksParamSet} used for + * encryption. For details about the key property set struct, see the + * HUKS Device Development. + * @param plainText Indicates the data {@link HuksBlob} to encrypt. + * @param cipherText indicates the data {@link HuksBlob} in ciphertext. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + Encrypt([in] struct HuksBlob encKey, [in] struct HuksParamSet paramSet, [in] struct HuksBlob plainText, + [out] struct HuksBlob cipherText); + + /** + * @brief Decrypts data using a key. + * + * @param encKey Indicates the key material {@link HuksBlob} in ciphertext. + * For details about the key material struct, see the HUKS Device Development. + * @param paramSet Indicates the parameters {@link HuksParamSet} used for + * decryption. For details about the key property set struct, see the + * HUKS Device Development. + * @param cipherText indicates the data {@link HuksBlob} in ciphertext to decrypt. + * @param plainText Indicates the decrypted data {@link HuksBlob} in plaintext. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + Decrypt([in] struct HuksBlob encKey, [in] struct HuksParamSet paramSet, [in] struct HuksBlob cipherText, + [out] struct HuksBlob plainText); + + /** + * @brief Performs key agreement using a private key stored in the HUKS + * and the public key of the service. + * + * @param paramSet Indicates the parameters {@link HuksParamSet} used + * for key agreement. + * @param encPrivateKey Indicates the key pair material {@link HuksBlob} + * stored in the HUKS. For details about the key material struct, see the + * HUKS Device Development. + * @param peerPublicKey Indicates the public key {@link HuksBlob} used + * for key agreement. + * @param agreedKey Indicates the key {@link HuksBlob} in plaintext obtained + * after key agreement. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + AgreeKey([in] struct HuksParamSet paramSet, [in] struct HuksBlob encPrivateKey, [in] struct HuksBlob peerPublicKey, + [out] struct HuksBlob agreedKey); + + /** + * @brief Derives a key from a key stored in the HUKS. + * + * @param paramSet Indicates the parameters {@link HuksParamSet} used for + * key derivation. For details about the key property set struct, see the + * HUKS Device Development. + * @param encKdfKey Indicates the key material {@link HuksBlob} stored + * in the HUKS. For details about the key material struct, see the + * HUKS Device Development. + * @param derivedKey Indicates the derived key {@link HuksBlob} in plaintext. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + DeriveKey([in] struct HuksParamSet paramSet, [in] struct HuksBlob encKdfKey, [out] struct HuksBlob derivedKey); + + /** + * @brief Generates a message authentication code (MAC) using a key + * stored in the HUKS. + * + * @param encKey Indicates the key material {@link HuksBlob} in ciphertext. + * For details about the key material struct, see the HUKS Device Development. + * @param paramSet Indicates the parameters {@link HuksParamSet} used for + * generating a MAC. For details about the key property set struct, see the + * HUKS Device Development. + * @param srcData Indicates the data {@link HuksBlob} used to generate a MAC. + * @param mac Indicates the MAC {@link HuksBlob} generated. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + Mac([in] struct HuksBlob encKey, [in] struct HuksParamSet paramSet, [in] struct HuksBlob srcData, + [out] struct HuksBlob mac); + + /** + * @brief Upgrades a key, including its encryption mode and encryption + * material. The HUKS service triggers the upgrade when the key file version + * is earlier than the latest version. + * + * @param encOldKey Indicates the key material {@link HuksBlob} in + * ciphertext to upgrade. For details about the key material struct, see the + * HUKS Device Development. + * @param paramSet Indicates the parameters {@link HuksParamSet} used for + * the upgrade. For details about the key property set struct, see the + * HUKS Device Development. + * @param encNewKey Indicates the key material {@link HuksBlob} in + * ciphertext after the upgrade. For details about the key material struct, + * see the HUKS Device Development. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + UpgradeKey([in] struct HuksBlob encOldKey, [in] struct HuksParamSet paramSet, [out] struct HuksBlob encNewKey); + + /** + * @brief Exports the public key of a chipset key pair. + * + * @param salt Indicates the salt {@link HuksBlob} used to derive the key + * pair of the chipset. + * @param scene Indicates the expected chipset decryption + * scenario {@link HuksParamSet} of the service. For details about the + * key property set struct, see the HUKS Device Development. + * @param publicKey Indicates the public key material {@link HuksBlob} + * exported, for example, the raw data (32 bytes) of the x-axis and y-axis + * values of ECC-P256. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 4.0 + * @version 1.0 + */ + ExportChipsetPlatformPublicKey([in] struct HuksBlob salt, [in] enum HuksChipsetPlatformDecryptScene scene, + [out] struct HuksBlob publicKey); + + /** + * @brief Get the detailed error information of the last called function. + * + * @param errorInfo Indicates the detailed error information {@link HuksBlob. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 5.1 + * @version 1.0 + */ + GetErrorInfo([out] struct HuksBlob errorInfo); + + /** + * @brief Get the runtime statistics of driver layer of the last called function. + * + * @param statInfo Indicates the runtime statistics information {@link HuksBlob}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value otherwise. + * + * @since 5.1 + * @version 1.0 + */ + GetStatInfo([out] struct HuksBlob statInfo); +} +/** @} */ \ No newline at end of file diff --git a/huks/v1_1/IHuksTypes.idl b/huks/v1_1/IHuksTypes.idl new file mode 100755 index 0000000000000000000000000000000000000000..bab3501884ba06f376ed149280e649fab40da435 --- /dev/null +++ b/huks/v1_1/IHuksTypes.idl @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024 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 HdfHuks + * @{ + * + * @brief Provides standard driver APIs for the OpenHarmony Universal KeyStore (HUKS). + * + * The HUKS driver APIs define standard interfaces of the HUKS Core and provide + * a unified driver interface for the HUKS service. + * You can use these APIs to implement key lifecycle management, including key + * generation, key import and export, key operations, key access control, and + * key attestation. + * + * @since 4.0 + */ + + /** + * @file IHuksTypes.idl + * + * @brief Defines the structs used in HUKS driver interfaces. + * + * @since 4.0 + */ + +package ohos.hdi.huks.v1_1; + +/** + * @brief Defines the HUKS binary data struct, which encapsulates parameters + * such as the key material and key properties. + * + * @since 4.0 + * @version 1.0 + */ +struct HuksBlob { + /** + * Binary data + */ + unsigned char[] data; +}; + +/** + * @brief Defines the struct for the parameter set of HUKS key management interfaces. + * + * @since 4.0 + * @version 1.0 + */ +struct HuksParamSet { + /** + * Serialized parameter set. For details about the property set struct, + * see the HUKS Device Development. + */ + unsigned char[] data; +}; + +/** + * @brief Enumerates the decryption scenarios using the chipset key. + * + * @since 4.0 + * @version 1.0 + */ +enum HuksChipsetPlatformDecryptScene { + /** + * Chipset key decryption for trusted applications in a Trusted Execution + * Environment (TEE). + */ + HUKS_CHIPSET_PLATFORM_DECRYPT_SCENCE_TA_TO_TA = 1, +}; +/** @} */ \ No newline at end of file diff --git a/input/bundle.json b/input/bundle.json index 0f996a41586fd4a80635756b744aa14882727a2f..cd050d0acfcf46d345faa66f66c52711d0c55443 100644 --- a/input/bundle.json +++ b/input/bundle.json @@ -28,7 +28,8 @@ "build": { "sub_component": [ "//drivers/interface/input/v1_0:input_idl_target", - "//drivers/interface/input/ddk/v1_0:hid_ddk_idl_target" + "//drivers/interface/input/ddk/v1_0:hid_ddk_idl_target", + "//drivers/interface/input/ddk/v1_1:hid_ddk_idl_target" ], "test": [ ], @@ -72,6 +73,30 @@ ], "header_base": "//drivers/interface/input/ddk" } + }, + { + "name": "//drivers/interface/input/ddk/v1_1:libhid_ddk_proxy_1.1", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/input/ddk" + } + }, + { + "name": "//drivers/interface/input/ddk/v1_1:libhid_ddk_stub_1.1", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/input/ddk" + } + }, + { + "name": "//drivers/interface/input/ddk/v1_1:hid_ddk_idl_headers", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/input/ddk" + } } ] } diff --git a/input/ddk/v1_1/BUILD.gn b/input/ddk/v1_1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..cf55b1f67869cdb166c18e5b7040114f49f5a15a --- /dev/null +++ b/input/ddk/v1_1/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2025 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. + +import("//build/config/components/hdi/hdi.gni") +hdi("hid_ddk") { + module_name = "hid_ddk" + imports = [ "ohos.hdi.input.ddk.v1_0:hid_ddk" ] + + sources = [ + "HidDdkTypes.idl", + "IHidDdk.idl", + ] + + language = "cpp" + mode = "ipc" + subsystem_name = "hdf" + part_name = "drivers_interface_input" +} diff --git a/input/ddk/v1_1/HidDdkTypes.idl b/input/ddk/v1_1/HidDdkTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..2be5bca89d41f3316172b768c22623ae697c77b9 --- /dev/null +++ b/input/ddk/v1_1/HidDdkTypes.idl @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2025 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 HdiHidDdk + * @{ + * + * @brief Provides HID DDK APIs, including open device, get an input report, send an output report, etc. + * + * @since 5.1 + * @version 1.1 + */ + + /** + * @file HidDdkTypes.idl + * + * @brief Provides definitions of enum variables and structs in the HID DDK. + * + * @since 5.1 + * @version 1.1 + */ + +package ohos.hdi.input.ddk.v1_1; + +import ohos.hdi.input.ddk.v1_0.HidDdkTypes; + +/** + * @brief Defines the basic device handle. + * + * @since 5.1 + * @version 1.0 + */ +struct HidDeviceHandle { + /** Device file descriptor */ + int fd; + /** Enable or not the nonblocking reads */ + int nonBlock; +}; + +/** + * @brief Defines the report type. + * + * @since 5.1 + * @version 1.0 + */ +enum HidReportType { + /** Input report */ + HID_INPUT_REPORT = 0, + /** Output report */ + HID_OUTPUT_REPORT = 1, + /** Feature report */ + HID_FEATURE_REPORT = 2 +}; + +/** + * @brief Defines the raw dev info. + * + * @since 5.1 + * @version 1.0 + */ +struct HidRawDevInfo { + /** Bus type */ + unsigned int busType; + /** Vendor ID */ + unsigned short vendor; + /** Product ID */ + unsigned short product; +}; + +/** + * @brief Defines the error codes used in the HID DDK. + * + * @since 5.1 + * @version 1.0 + */ +enum HidDdkErrCode { + /** @error Operation successful */ + HID_DDK_SUCCESS = 0, + /** @error Permission denied */ + HID_DDK_NO_PERM = 201, + /** @error Invalid parameter */ + HID_DDK_INVALID_PARAMETER = 401, + /** @error Operation failed */ + HID_DDK_FAILURE = 27300001, + /** @error Null pointer exception */ + HID_DDK_NULL_PTR = 27300002, + /** @error Invalid operation */ + HID_DDK_INVALID_OPERATION = 27300003, + /** @error Timeout */ + HID_DDK_TIMEOUT = 27300004, + /** @error Init operation */ + HID_DDK_INIT_ERROR = 27300005, + /** @error Service error operation */ + HID_DDK_SERVICE_ERROR = 27300006, + /** @error Buff is outside accessible address space */ + HID_DDK_MEMORY_ERROR = 27300007, + /** @error Physical I/O error has occurred. */ + HID_DDK_IO_ERROR = 27300008, + /** @error Device not found. */ + HID_DDK_DEVICE_NOT_FOUND = 27300009 +}; + +/** @} */ \ No newline at end of file diff --git a/input/ddk/v1_1/IHidDdk.idl b/input/ddk/v1_1/IHidDdk.idl new file mode 100644 index 0000000000000000000000000000000000000000..61959d14a775cd8c6d1e4c4bc56bce1f310aca38 --- /dev/null +++ b/input/ddk/v1_1/IHidDdk.idl @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2025 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 HdiHidDdk + * @{ + * + * @brief Provides HID DDK APIs, including open device, get an input report, send an output report, etc. + * + * @since 5.1 + * @version 1.1 + */ + + /** + * @file IHidDdk.idl + * + * @brief Declares the HID DDK interfaces for the host to access an input device. + * + * @since 5.1 + * @version 1.1 + */ + +package ohos.hdi.input.ddk.v1_1; + +import ohos.hdi.input.ddk.v1_1.HidDdkTypes; +import ohos.hdi.input.ddk.v1_0.HidDdkTypes; +import ohos.hdi.input.ddk.v1_0.IHidDdk; + +/** + * @brief Declares the HID DDK interfaces for the host to access an input device. + * + * @since 5.1 + * @version 1.1 + */ +interface IHidDdk extends ohos.hdi.input.ddk.v1_0.IHidDdk { + /** + * @brief Initializes the HID DDK. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Init(); + + /** + * @brief Releases the HID DDK. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Release(); + + /** + * @brief Open HID device by deviceId in blocking mode. + * + * @param deviceId ID of the device to be operated. + * @param interfaceIndex Interface index, which corresponds to interface which supports USB protocol HID. + * @param dev Device operation handle. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Open([in] unsigned long deviceId, [in] unsigned char interfaceIndex, [out] struct HidDeviceHandle dev); + + /** + * @brief Close HID device by dev. + * + * @param dev Device operation handle. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Close([in] struct HidDeviceHandle dev); + + /** + * @brief Write an Output report to a HID device. + * + * @param dev Device operation handle. + * @param data The data to be sent. + * @param bytesWritten The acture bytes of the data be sent. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Write([in] struct HidDeviceHandle dev, [in] unsigned char[] data, [out] unsigned int bytesWritten); + + /** + * @brief Read an input report from the device with timeout. + * + * @param dev Device operation handle. + * @param data A buffer to put the read data into. + * @param buffSize A buffer size to put the read data into. + * @param timeout Timeout in milliseconds or -1 for blocking wait. + * @param bytesRead The number of bytes to read. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + ReadTimeout([in] struct HidDeviceHandle dev, [out] unsigned char[] data, [in] unsigned int buffSize, [in] int timeout, [out] unsigned int bytesRead); + + /** + * @brief Set the device handle to be non-blocking. + * + * @param dev Device operation handle. + * @param nonBlock Enable or not the nonblocking reads + * - 1 to enable nonblocking + * - 0 to disable nonblocking. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + SetNonBlocking([in] struct HidDeviceHandle dev, [in] int nonBlock); + + /** + * @brief Get a raw info from the device. + * + * @param dev Device operation handle. + * @param rawDevInfo Vendor id, product id and bus type get from the device. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + GetRawInfo([in] struct HidDeviceHandle dev, [out] struct HidRawDevInfo rawDevInfo); + + /** + * @brief Get a raw name from the device. + * + * @param dev Device operation handle. + * @param data A buffer to put the read data into. + * @param buffSize A buffer size to put the read data into. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + GetRawName([in] struct HidDeviceHandle dev, [out] unsigned char[] data, [in] unsigned int buffSize); + + /** + * @brief Get a physical address from the device. + * + * @param dev Device operation handle. + * @param data A buffer to put the read data into. + * @param buffSize A buffer size to put the read data into. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + GetPhysicalAddress([in] struct HidDeviceHandle dev, [out] unsigned char[] data, [in] unsigned int buffSize); + + /** + * @brief Get a raw unique id from the device. + * + * @param dev Device operation handle. + * @param data A buffer to put the read data into. + * @param buffSize A buffer size to put the read data into. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + GetRawUniqueId([in] struct HidDeviceHandle dev, [out] unsigned char[] data, [in] unsigned int buffSize); + + /** + * @brief Send a report to the device. + * + * @param dev Device operation handle. + * @param reportType Report type will be sent. + * @param data The data to be sent. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + SendReport([in] struct HidDeviceHandle dev, [in] HidReportType reportType, [in] unsigned char[] data); + + /** + * @brief Get a report from the device. + * + * @param dev Device operation handle. + * @param reportType Report type get from device. + * @param reportNumber The specified report number. + * @param data A buffer to put the read data into. + * @param buffSize A buffer size to put the read data into. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + GetReport([in] struct HidDeviceHandle dev, [in] HidReportType reportType, [in] unsigned char reportNumber, [out] unsigned char[] data, [in] unsigned int buffSize); + + /** + * @brief Get a report descriptor from the device. + * + * @param dev Device operation handle. + * @param buf The buffer to copy descriptor into. + * @param buffSize A buffer size to put the read data into. + * @param bytesRead The number of bytes to read. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + GetReportDescriptor([in] struct HidDeviceHandle dev, [out] unsigned char[] buf, [in] unsigned int buffSize, [out] unsigned int bytesRead); +} + +/** @} */ \ No newline at end of file diff --git a/intelligent_voice/engine/v1_0/BUILD.gn b/intelligent_voice/engine/v1_0/BUILD.gn index 411b4e326cad17160c3b4e495d9ac8893dcbd48d..73eafc8ed06e671b4e5e35c3eca73f4bd7cc1c87 100644 --- a/intelligent_voice/engine/v1_0/BUILD.gn +++ b/intelligent_voice/engine/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("../../../../hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("intell_voice_engine") { module_name = "intell_voice_engine_service" diff --git a/intelligent_voice/engine/v1_1/BUILD.gn b/intelligent_voice/engine/v1_1/BUILD.gn index 81d020431270d33308460434958cac625dc14477..1325d3a1a23b16e0f35114732fcd67d37fd3879e 100644 --- a/intelligent_voice/engine/v1_1/BUILD.gn +++ b/intelligent_voice/engine/v1_1/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("../../../../hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("intell_voice_engine") { module_name = "intell_voice_engine_service" diff --git a/intelligent_voice/engine/v1_2/BUILD.gn b/intelligent_voice/engine/v1_2/BUILD.gn index 1e19d20e33b6706bc4f60f378dd3e352049c965e..f03071e308fd27d8da8143964b4026f41b293c34 100644 --- a/intelligent_voice/engine/v1_2/BUILD.gn +++ b/intelligent_voice/engine/v1_2/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("intell_voice_engine") { module_name = "intell_voice_engine_service" diff --git a/intelligent_voice/trigger/v1_0/BUILD.gn b/intelligent_voice/trigger/v1_0/BUILD.gn index 4b120e9aab23ec6ebad57a6671cd1efb180bf36a..dd58ff41b00ba1b810378627095d754998cfaeba 100644 --- a/intelligent_voice/trigger/v1_0/BUILD.gn +++ b/intelligent_voice/trigger/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("../../../../hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("intell_voice_trigger") { module_name = "intell_voice_trigger_service" diff --git a/intelligent_voice/trigger/v1_1/BUILD.gn b/intelligent_voice/trigger/v1_1/BUILD.gn index c102ced3ff569bcef3ffdbf38d013a26afab6a7c..708956bebe26cbe8bce13663f46db385c3e322b2 100644 --- a/intelligent_voice/trigger/v1_1/BUILD.gn +++ b/intelligent_voice/trigger/v1_1/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("../../../../hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("intell_voice_trigger") { module_name = "intell_voice_trigger_service" diff --git a/intelligent_voice/trigger/v1_2/BUILD.gn b/intelligent_voice/trigger/v1_2/BUILD.gn index 3132ecb76e2adcee619b6c43e9da4c86f537dbdf..008e36c594acb54f63daa39dcb1070683aa247ea 100644 --- a/intelligent_voice/trigger/v1_2/BUILD.gn +++ b/intelligent_voice/trigger/v1_2/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("intell_voice_trigger") { module_name = "intell_voice_trigger_service" diff --git a/location/lpfence/cellbatching/v1_0/BUILD.gn b/location/lpfence/cellbatching/v1_0/BUILD.gn index 9c41468ad4a9822b0514510305380c3376580e66..a7f07b9ca5a4c6c33a50e3699b681e7aaf81e128 100644 --- a/location/lpfence/cellbatching/v1_0/BUILD.gn +++ b/location/lpfence/cellbatching/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("lpfence_cellbatching") { module_name = "lpfence_cellbatching" diff --git a/location/lpfence/cellfence/v1_0/BUILD.gn b/location/lpfence/cellfence/v1_0/BUILD.gn index 18f0a63b1ee225b27ae2f1fc64c9e6317ada0857..0dd6f02dfcc41ec0bacf8bf11ca21ba504ca3591 100644 --- a/location/lpfence/cellfence/v1_0/BUILD.gn +++ b/location/lpfence/cellfence/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("lpfence_cellfence") { module_name = "lpfence_cellfence" diff --git a/location/lpfence/geofence/v1_0/BUILD.gn b/location/lpfence/geofence/v1_0/BUILD.gn index 7bbf9e190a8912023012ce31631efaf62bc0e275..ac6147a7244d9e3f94688345a38450e3d6ea2fc9 100644 --- a/location/lpfence/geofence/v1_0/BUILD.gn +++ b/location/lpfence/geofence/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("lpfence_geofence") { module_name = "lpfence_geofence" diff --git a/location/lpfence/safe_location/v1_0/BUILD.gn b/location/lpfence/safe_location/v1_0/BUILD.gn index e38dbe2d41087531accdbff6796974328772a9f2..48be23f7fa35e899be5108445bacf43fa9a8193e 100644 --- a/location/lpfence/safe_location/v1_0/BUILD.gn +++ b/location/lpfence/safe_location/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("lpfence_safe_location") { module_name = "lpfence_safe_location" diff --git a/location/lpfence/wififence/v1_0/BUILD.gn b/location/lpfence/wififence/v1_0/BUILD.gn index 45ff950a85a1715b5094d7803d8f962db74d75cb..ff292d04970f6778d5c345a4164d14922fcd7766 100644 --- a/location/lpfence/wififence/v1_0/BUILD.gn +++ b/location/lpfence/wififence/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("lpfence_wififence") { module_name = "lpfence_wififence" diff --git a/memorytracker/v1_0/BUILD.gn b/memorytracker/v1_0/BUILD.gn index cc8817ac7bc168761920d22d7a60a922183fe09a..88c89ffafca9b10dd2066d96bbce52dd644f1681 100644 --- a/memorytracker/v1_0/BUILD.gn +++ b/memorytracker/v1_0/BUILD.gn @@ -11,8 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("memorytracker") { + branch_protector_ret = "pac_ret" module_name = "memory_tracker_interface_service" sources = [ "IMemoryTrackerInterface.idl", diff --git a/nfc/bundle.json b/nfc/bundle.json index 25512d4de4516dd174f2bd824556ba5fe8dcaf24..d1c910ea28eb263b50017e206254b65ea537694a 100644 --- a/nfc/bundle.json +++ b/nfc/bundle.json @@ -28,21 +28,11 @@ "build": { "sub_component": [ "//drivers/interface/nfc/v1_1:nfc_idl_target", - "//drivers/interface/nfc/v1_0:nfc_idl_target", - "//drivers/interface/nfc/v1_1:libnfc_stub_1.1", - "//drivers/interface/nfc/v1_0:libnfc_stub_1.0" + "//drivers/interface/nfc/v1_1:libnfc_stub_1.1" ], "test": [ ], "inner_kits": [ - { - "name": "//drivers/interface/nfc/v1_0:libnfc_proxy_1.0", - "header": { - "header_files": [ - ], - "header_base": "//drivers/interface/nfc" - } - }, { "name": "//drivers/interface/nfc/v1_1:libnfc_proxy_1.1", "header": { @@ -51,14 +41,6 @@ "header_base": "//drivers/interface/nfc" } }, - { - "name": "//drivers/interface/nfc/v1_0:libnfc_stub_1.0", - "header": { - "header_files": [ - ], - "header_base": "//drivers/interface/nfc" - } - }, { "name": "//drivers/interface/nfc/v1_1:libnfc_stub_1.1", "header": { @@ -67,14 +49,6 @@ "header_base": "//drivers/interface/nfc" } }, - { - "name": "//drivers/interface/nfc/v1_0:nfc_idl_headers", - "header": { - "header_files": [ - ], - "header_base": "//drivers/interface/nfc" - } - }, { "name": "//drivers/interface/nfc/v1_1:nfc_idl_headers", "header": { diff --git a/nnrt/v1_0/BUILD.gn b/nnrt/v1_0/BUILD.gn index e68e1f3a610fd9a401346267f1734c879df6dfe8..a62afba75f260d2777a051b814809f4f8c85fee7 100644 --- a/nnrt/v1_0/BUILD.gn +++ b/nnrt/v1_0/BUILD.gn @@ -11,9 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("nnrt") { module_name = "nnrt" + branch_protector_ret = "pac_ret" sources = [ "INnrtDevice.idl", "IPreparedModel.idl", diff --git a/nnrt/v2_0/BUILD.gn b/nnrt/v2_0/BUILD.gn index 140d143d2020efd5b68e0ae42f21b44d7666e431..ae6b9d8340e105dd3cab6a0226c11a29787cb60f 100644 --- a/nnrt/v2_0/BUILD.gn +++ b/nnrt/v2_0/BUILD.gn @@ -11,9 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("nnrt") { module_name = "nnrt" + branch_protector_ret = "pac_ret" sources = [ "INnrtDevice.idl", "IPreparedModel.idl", diff --git a/nnrt/v2_1/BUILD.gn b/nnrt/v2_1/BUILD.gn index 1cfe5f26f25bbd6096e18fabaf85dddac17e82c6..0557cff9de17fe9f9f74ba8b9588cbdd83a22cfe 100644 --- a/nnrt/v2_1/BUILD.gn +++ b/nnrt/v2_1/BUILD.gn @@ -11,9 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("nnrt") { module_name = "nnrt" + branch_protector_ret = "pac_ret" sources = [ "INnrtDevice.idl", "IPreparedModel.idl", diff --git a/pin_auth/bundle.json b/pin_auth/bundle.json index a21331353d4ff193a70fb700cc3dbe28457f717b..bfb9cb4ceea35e4c7bdd1ec96a0e17b108ba7d1d 100644 --- a/pin_auth/bundle.json +++ b/pin_auth/bundle.json @@ -1,7 +1,7 @@ { "name":"@ohos/drivers_interface_pin_auth", "description":"pinauth device driver interface", - "version":"5.0", + "version":"5.1", "license":"Apache License 2.0", "publishAs":"code-segment", "segment":{ @@ -35,14 +35,14 @@ }, "build":{ "sub_component":[ - "//drivers/interface/pin_auth/v2_0:pin_auth_idl_target" + "//drivers/interface/pin_auth/v2_1:pin_auth_idl_target" ], "test":[ ], "inner_kits":[ { - "name":"//drivers/interface/pin_auth/v2_0:libpin_auth_proxy_2.0", + "name":"//drivers/interface/pin_auth/v2_1:libpin_auth_proxy_2.1", "header":{ "header_files":[ @@ -51,7 +51,7 @@ } }, { - "name":"//drivers/interface/pin_auth/v2_0:libpin_auth_stub_2.0", + "name":"//drivers/interface/pin_auth/v2_1:libpin_auth_stub_2.1", "header":{ "header_files":[ @@ -60,7 +60,7 @@ } }, { - "name":"//drivers/interface/pin_auth/v2_0:pin_auth_idl_headers", + "name":"//drivers/interface/pin_auth/v2_1:pin_auth_idl_headers", "header":{ "header_files":[ diff --git a/pin_auth/v1_0/BUILD.gn b/pin_auth/v1_0/BUILD.gn index c36d14374d7a7a9b74c328545a9b2e6bd4e22714..04f0d4e03a6842b4fabee4abe99c1af53cbbccab 100644 --- a/pin_auth/v1_0/BUILD.gn +++ b/pin_auth/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") import("../config.gni") hdi("pin_auth") { diff --git a/pin_auth/v1_1/BUILD.gn b/pin_auth/v1_1/BUILD.gn index 94371fbe1c89967da6474a963f3236c1bf8ceb40..04ad0effc1c99e9afc468442e0722db056ae5787 100644 --- a/pin_auth/v1_1/BUILD.gn +++ b/pin_auth/v1_1/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") import("../config.gni") hdi("pin_auth") { diff --git a/pin_auth/v2_0/IExecutorCallback.idl b/pin_auth/v2_0/IExecutorCallback.idl index 50054e9a78c5c44350437483a3a50a5eac243b58..93a8a21d1bc13a41f9f77f39380ce884795bf73e 100644 --- a/pin_auth/v2_0/IExecutorCallback.idl +++ b/pin_auth/v2_0/IExecutorCallback.idl @@ -83,6 +83,7 @@ import ohos.hdi.pin_auth.v2_0.PinAuthTypes; * @param authSubType Indicates the pin sub type. * @param algoVersion is the version of the algorithm. * @param challenge is challenge. + * @param complexityReg Indicates the complexity reg. * * @return Returns 0 if the operation is successful. * @return Returns a non-zero value if the operation fails. @@ -91,7 +92,7 @@ import ohos.hdi.pin_auth.v2_0.PinAuthTypes; * @version 2.0 */ OnGetData([in] unsigned char[] algoParameter, [in] unsigned long authSubType, [in] unsigned int algoVersion, - [in] unsigned char[] challenge); + [in] unsigned char[] challenge, [in] String complexityReg); /** * @brief Defines the function for reporting message. * diff --git a/pin_auth/v2_1/BUILD.gn b/pin_auth/v2_1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b332167fed0a8ea68d33b7e0705e80ce16078aa8 --- /dev/null +++ b/pin_auth/v2_1/BUILD.gn @@ -0,0 +1,30 @@ +# Copyright (c) 2024 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. + +import("//build/config/components/hdi/hdi.gni") +import("../config.gni") + +hdi("pin_auth") { + module_name = "drivers_peripheral_pin_auth" + sources = [ + "IAllInOneExecutor.idl", + "ICollector.idl", + "IExecutorCallback.idl", + "IPinAuthInterface.idl", + "IVerifier.idl", + "PinAuthTypes.idl", + ] + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_pin_auth" +} diff --git a/pin_auth/v2_1/IAllInOneExecutor.idl b/pin_auth/v2_1/IAllInOneExecutor.idl new file mode 100644 index 0000000000000000000000000000000000000000..e483337ba885f8d95febb70dd9f53ccb6e26ec8d --- /dev/null +++ b/pin_auth/v2_1/IAllInOneExecutor.idl @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2024 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 HdfPinAuth + * @{ + * + * @brief Provides APIs for the pin auth driver. + * + * The pin auth driver provides a unified interface for the pin auth service to access the pin auth driver. + * After obtaining the pin auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the pin auth executors, the service can call related APIs to get executor information, get + * template information, and enroll, authenticate, and delete templates, etc. + * + * @since 5.0 + * @version 1.1 + */ + +/** + * @file IAllInOneExecutor.idl + * + * @brief Defines the APIs of the all-in-one executors. These APIs can be used to get executor information, get property, + * enroll, authenticate, and delete templates, etc. + * + * @since 5.0 + * @version 1.1 + */ + +package ohos.hdi.pin_auth.v2_1; + +import ohos.hdi.pin_auth.v2_1.PinAuthTypes; +import ohos.hdi.pin_auth.v2_1.IExecutorCallback; + +/** + * @brief Defines the APIs of the all-in-one executors. These APIs can be used to get executor information, get property, + * enroll, authenticate, and delete templates, etc. + * + * @since 5.0 + * @version 1.1 + */ + +interface IAllInOneExecutor { + /** + * @brief Gets executor information. + * + * @param executorInfo Indicates executor information. See {@link ExecutorInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetExecutorInfo([out] struct ExecutorInfo executorInfo); + /** + * @brief Sends parameters to the driver when executor registration is finished. + * + * @param templateIdList Indicates the templates previously registered to the user auth framework. + * @param frameworkPublicKey Indicates the framework public key. + * @param extraInfo Indicates the extra information that is sent to the executors. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + OnRegisterFinish([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, + [in] unsigned char[] extraInfo); + /** + * @brief Cancels an operation. + * + * @param scheduleId Indicates the schedule ID of the operation to cancel. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + Cancel([in] unsigned long scheduleId); + /** + * @brief Send message. + * + * @param scheduleId Indicates the schedule ID of the message. + * @param srcRole is the role of source. + * @param msg is the message content. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + SendMessage([in] unsigned long scheduleId, [in] int srcRole, [in] unsigned char[] msg); + /** + * @brief Sets pin data. + * + * @param scheduleId Indicates the schedule ID of enrollment. + * @param authSubType Indicates the pin sub type. + * @param data Indicates the pin data. + * @param resultCode Indicates the result code. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + SetData([in] unsigned long scheduleId, [in] unsigned long authSubType, [in] unsigned char[] data, + [in] int resultCode); + /** + * @brief Enrolls templates. + * + * @param scheduleId Indicates the schedule ID of enrollment. + * @param extraInfo Indicates the extra information of enrollment. + * @param callbackObj Indicates the callback object of enrollment. See {@link IExecutorCallback}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + Enroll([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj); + /** + * @brief Authenticates templates. + * + * @param scheduleId Indicates the schedule ID of authentication. + * @param templateIdList Indicates the templates to authenticate. + * @param extraInfo Indicates the extra information of authentication. + * @param callbackObj Indicates the callback object of authentication. See {@link IExecutorCallback}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + Authenticate([in] unsigned long scheduleId, [in] unsigned long[] templateIdList, [in] unsigned char[] extraInfo, + [in] IExecutorCallback callbackObj); + /** + * @brief Deletes templates. + * + * @param templateId Indicates the templates to delete. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + Delete([in] unsigned long templateId); + /** + * @brief Get property. + * + * @param templateIdList Indicates the templates to process. + * @param propertyTypes Indicates the property types to get. See {@link GetPropertyType}. + * @param property Indicates property. See {@link Property}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetProperty([in] unsigned long[] templateIdList, [in] int[] propertyTypes, [out] struct Property property); + /** + * @brief Sends a command to the driver. + * + * @param commandId Indicates the command ID. See {@link CommandId}. + * @param extraInfo Indicates the extra information of the command. + * @param callbackObj Indicates the callback object of the command. See {@link IExecutorCallback}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + SendCommand([in] int commandId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj); +} + +/** @} */ \ No newline at end of file diff --git a/pin_auth/v2_1/ICollector.idl b/pin_auth/v2_1/ICollector.idl new file mode 100644 index 0000000000000000000000000000000000000000..26e469706edf5ca1b5939baf049f578b249028e2 --- /dev/null +++ b/pin_auth/v2_1/ICollector.idl @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2024 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 HdfPinAuth + * @{ + * + * @brief Provides APIs for the pin auth driver. + * + * The pin auth driver provides a unified interface for the pin auth service to access the pin auth driver. + * After obtaining the pin auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the pin auth executors, the service can call related APIs to get executor information, get + * template information, and enroll, authenticate, and delete templates, etc. + * + * @since 5.0 + * @version 1.0 + */ + +/** + * @file ICollector.idl + * + * @brief Defines the APIs of the collectors. These APIs can be used to get executor information, + * cancel, collect data, and send message, etc. + * + * @since 5.0 + * @version 1.0 + */ + +package ohos.hdi.pin_auth.v2_1; + +import ohos.hdi.pin_auth.v2_1.PinAuthTypes; +import ohos.hdi.pin_auth.v2_1.IExecutorCallback; + +/** + * @brief Defines the APIs of the collectors. These APIs can be used to get executor information, + * cancel, collect data, and send message, etc. + * + * @since 5.0 + * @version 1.0 + */ + +interface ICollector { + /** + * @brief Gets executor information. + * + * @param executorInfo Indicates executor information. See {@link ExecutorInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetExecutorInfo([out] struct ExecutorInfo executorInfo); + /** + * @brief Sends parameters to the driver when executor registration is finished. + * + * @param templateIdList Indicates the templates previously registered to the user auth framework. + * @param frameworkPublicKey Indicates the framework public key. + * @param extraInfo Indicates the extra information that is sent to the executors. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + OnRegisterFinish([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, [in] unsigned char[] extraInfo); + /** + * @brief Cancels an operation. + * + * @param scheduleId Indicates the schedule ID of the operation to cancel. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + Cancel([in] unsigned long scheduleId); + /** + * @brief Send message. + * + * @param scheduleId Indicates the schedule ID of the message. + * @param srcRole is the role of source. + * @param msg is the message content. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + SendMessage([in] unsigned long scheduleId, [in] int srcRole, [in] unsigned char[] msg); + /** + * @brief Sets pin data. + * + * @param scheduleId Indicates the schedule ID of enrollment. + * @param authSubType Indicates the pin sub type. + * @param data Indicates the pin data. + * @param resultCode Indicates the result code. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + SetData([in] unsigned long scheduleId, [in] unsigned long authSubType, [in] unsigned char[] data, + [in] int resultCode); + /** + * @brief Collect template data. + * + * @param scheduleId Indicates the schedule ID of collection. + * @param extraInfo Indicates the extra information of collection. + * @param callbackObj Indicates the callback object of authentication. See {@link IExecutorCallback}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + Collect([in] unsigned long scheduleId, [in] unsigned char[] extraInfo, + [in] IExecutorCallback callbackObj); +} +/** @} */ \ No newline at end of file diff --git a/pin_auth/v2_1/IExecutorCallback.idl b/pin_auth/v2_1/IExecutorCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..c59f7b29f76bde171183e67cafb50a8709f851f6 --- /dev/null +++ b/pin_auth/v2_1/IExecutorCallback.idl @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 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 HdfPinAuth + * @{ + * + * @brief Provides APIs for the pin auth driver. + * + * The pin auth driver provides a unified interface for the pin auth service to access the pin auth driver. + * After obtaining the pin auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the pin auth executors, the service can call related APIs to get executor information, get + * template information, and enroll, authenticate, and delete templates, etc. + * + * @since 3.2 + * @version 1.0 + */ + +/** + * @file IExecutorCallback.idl + * + * @brief Defines the callback for an async API, which can be used to report operation results or + * get information of the async API. + * + * @since 3.2 + * @version 1.0 + */ + +package ohos.hdi.pin_auth.v2_1; + +import ohos.hdi.pin_auth.v2_1.PinAuthTypes; + +/** + * @brief Defines the callback for an async API, which can be used to report operation results or + * get information of the async API. See {@link IExecutor}. + * + * @since 3.2 + * @version 1.0 + */ +[callback] interface IExecutorCallback { + /** + * @brief Defines the function for reporting operation results. + * + * @param result Indicates the result code. + * @param extraInfo Indicates extra information to report. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + OnResult([in] int result, [in] unsigned char[] extraInfo); + /** + * @brief Defines the function for reporting information in process. + * + * @param tip Indicates tip code. See {@link FaceTipsCode}. + * @param extraInfo Indicates extra information to report. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + OnTip([in] int tip, [in] unsigned char[] extraInfo); + /** + * @brief Defines the function for getting pin data. + * + * @param algoParameter is the parameter of the algorithm. + * @param authSubType Indicates the pin sub type. + * @param algoVersion is the version of the algorithm. + * @param challenge is challenge. + * @param complexityReg Indicates the complexity reg. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 2.0 + */ + OnGetData([in] unsigned char[] algoParameter, [in] unsigned long authSubType, [in] unsigned int algoVersion, + [in] unsigned char[] challenge, [in] String complexityReg); + /** + * @brief Defines the function for reporting message. + * + * @param destRole is the role of destination. + * @param msg is the message content. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + OnMessage([in] int destRole, [in] unsigned char[] msg); +} +/** @} */ \ No newline at end of file diff --git a/pin_auth/v2_1/IPinAuthInterface.idl b/pin_auth/v2_1/IPinAuthInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..9f1a6850b5b978afb262af8aa4cf896a1fc59be0 --- /dev/null +++ b/pin_auth/v2_1/IPinAuthInterface.idl @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 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 HdfPinAuth + * @{ + * + * @brief Provides APIs for the pin auth driver. + * + * The pin auth driver provides a unified interface for the pin auth service to access the pin auth driver. + * After obtaining the pin auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the pin auth executors, the service can call related APIs to get executor information, get + * template information, and enroll, authenticate, and delete templates, etc. + * + * @since 3.2 + * @version 1.0 + */ + +/** + * @file IPinAuthInterface.idl + * + * @brief Defines the API for getting the executor list of the pin auth driver. + * of driver. + * + * @since 3.2 + * @version 1.0 + */ + +package ohos.hdi.pin_auth.v2_1; + +import ohos.hdi.pin_auth.v2_1.IAllInOneExecutor; +import ohos.hdi.pin_auth.v2_1.ICollector; +import ohos.hdi.pin_auth.v2_1.IVerifier; + +/** + * @brief Defines the API for getting the executor list of the pin auth driver. + * + * @since 3.2 + * @version 1.0 + */ +interface IPinAuthInterface { + /** + * @brief Obtains the executor list of the driver. + * + * @param allInOneExecutors Indicates the all-in-one executor list of the driver. + * See {@link IAllInOneExecutor}. + * @param verifiers Indicates the verifier list of the driver. See {@link IVerifier}. + * @param collectors Indicates the collector list of the driver. See {@link ICollector}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 2.0 + */ + GetExecutorList([out] IAllInOneExecutor[] allInOneExecutors, [out] IVerifier[] verifiers, + [out] ICollector[] collectors); +} +/** @} */ \ No newline at end of file diff --git a/pin_auth/v2_1/IVerifier.idl b/pin_auth/v2_1/IVerifier.idl new file mode 100644 index 0000000000000000000000000000000000000000..a07ff61de827c929663fe67b862b327d60e69a0c --- /dev/null +++ b/pin_auth/v2_1/IVerifier.idl @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2024 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 HdfPinAuth + * @{ + * + * @brief Provides APIs for the pin auth driver. + * + * The pin auth driver provides a unified interface for the pin auth service to access the pin auth driver. + * After obtaining the pin auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the pin auth executors, the service can call related APIs to get executor information, get + * template information, and enroll, authenticate, and delete templates, etc. + * + * @since 5.0 + * @version 1.0 + */ + +/** + * @file IVerifier.idl + * + * @brief Defines the APIs of the verifiers. These APIs can be used to get executor information, + * cancel, authenticate, and send message, etc. + * + * @since 5.0 + * @version 1.0 + */ + +package ohos.hdi.pin_auth.v2_1; + +import ohos.hdi.pin_auth.v2_1.PinAuthTypes; +import ohos.hdi.pin_auth.v2_1.IExecutorCallback; + +/** + * @brief Defines the APIs of the verifiers. These APIs can be used to get executor information, + * cancel, authenticate, and send message, etc. + * + * @since 5.0 + * @version 1.0 + */ + +interface IVerifier { + /** + * @brief Gets executor information. + * + * @param executorInfo Indicates executor information. See {@link ExecutorInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetExecutorInfo([out] struct ExecutorInfo executorInfo); + /** + * @brief Sends parameters to the driver when executor registration is finished. + * + * @param templateIdList Indicates the templates previously registered to the user auth framework. + * @param frameworkPublicKey Indicates the framework public key. + * @param extraInfo Indicates the extra information that is sent to the executors. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + OnRegisterFinish([in] unsigned long[] templateIdList, [in] unsigned char[] frameworkPublicKey, + [in] unsigned char[] extraInfo); + /** + * @brief Cancels an operation. + * + * @param scheduleId Indicates the schedule ID of the operation to cancel. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + Cancel([in] unsigned long scheduleId); + /** + * @brief Send message. + * + * @param scheduleId Indicates the schedule ID of the message. + * @param srcRole is the role of source. + * @param msg is the message content. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + SendMessage([in] unsigned long scheduleId, [in] int srcRole, [in] unsigned char[] msg); + /** + * @brief Authenticates templates. + * + * @param scheduleId Indicates the schedule ID of authentication. + * @param templateIdList Indicates the templates to authenticate. + * @param extraInfo Indicates the extra information of authentication. + * @param callbackObj Indicates the callback object of authentication. See {@link IExecutorCallback}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + Authenticate([in] unsigned long scheduleId, [in] unsigned long[] templateIdList, [in] unsigned char[] extraInfo, + [in] IExecutorCallback callbackObj); + /** + * @brief Notify collector ready. + * + * @param scheduleId Indicates the schedule ID of the message. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + NotifyCollectorReady([in] unsigned long scheduleId); +} +/** @} */ \ No newline at end of file diff --git a/pin_auth/v2_1/PinAuthTypes.idl b/pin_auth/v2_1/PinAuthTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..bd0166c5b88dac24012addcc27aa4aabf7bf9e80 --- /dev/null +++ b/pin_auth/v2_1/PinAuthTypes.idl @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2024 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 HdfPinAuth + * @{ + * + * @brief Provides APIs for the pin auth driver. + * + * The pin auth driver provides a unified interface for the pin auth service to access the pin auth driver. + * After obtaining the pin auth driver proxy, the service can call related APIs to obtain executors. + * After obtaining the pin auth executors, the service can call related APIs to get executor information, get + * template information, and enroll, authenticate, and delete templates, etc. + * + * @since 3.2 + * @version 1.0 + */ + +/** + * @fiPinTypes.idl + * + * @brief Defines the enumeration and data structure of the pin auth driver, including AuthType, ExecutorRole, + * ExecutorSecureLevel, + * CommandId, ResultCode, ExecutorInfo, and TemplateInfo. + * + * @since 3.2 + * @version 1.0 + */ + +package ohos.hdi.pin_auth.v2_1; + +/** + * @brief Enumerates the credential types for authentication. + * + * @since 3.2 + * @version 1.1 + */ +enum AuthType : int { + /**< Indicates that the authentication type is PIN. */ + PIN = 1, + /**< Indicates that the authentication type is face. */ + FACE = 2, + /**< Indicates that the authentication type is fingerprint. */ + FINGERPRINT = 4, + /**< Indicates that the authentication type is recovery key. */ + RECOVERY_KEY = 8, + /**< Indicates that the authentication type is private pin. */ + PRIVATE_PIN = 16, +}; + +/** + * @brief Enumerates executor roles. + * + * @since 3.2 + * @version 2.0 + */ +enum ExecutorRole : int { + /**< Indicates that the executor role is scheduler. */ + SCHEDULER = 0, + /**< Indicates that the executor role is collector. */ + COLLECTOR = 1, + /**< Indicates that the executor role is verifier. */ + VERIFIER = 2, + /**< Indicates that the executor role is the combination of collector and verifier. */ + ALL_IN_ONE = 3, +}; + +/** + * @brief Enumerates executor secure levels. + * + * @since 3.2 + * @version 1.0 + */ +enum ExecutorSecureLevel : int { + /**< Indicates that the executor secure level is ESL0. */ + ESL0 = 0, + /**< Indicates that the executor secure level is ESL1. */ + ESL1 = 1, + /**< Indicates that the executor secure level is ESL2. */ + ESL2 = 2, + /**< Indicates that the executor secure level is ESL3. */ + ESL3 = 3, +}; + +/** + * @brief Indicates executor information. + * + * @since 3.2 + * @version 2.0 + */ +struct ExecutorInfo { + /**< Indicates the sensor ID, which must be unique within the driver. */ + unsigned short sensorId; + /**< Indicates the executor matcher. */ + unsigned int executorMatcher; + /**< Indicates the executor role. See @{ExecutorRole}. */ + int executorRole; + /**< Indicates the auth type. See @{AuthType}. */ + int authType; + /**< Indicates the executor secure level. See @{ExecutorSecureLevel}. */ + int esl; + /**< Indicates the public key of the executor. */ + unsigned char[] publicKey; + /**< Indicates extra information. */ + unsigned char[] extraInfo; + /**< Indicates the max acl of template. */ + unsigned int maxTemplateAcl; +}; + +/** + * @brief Enumerates get Property types. + * + * @since 4.0 + * @version 2.0 + */ +enum GetPropertyType : int { + /**< Indicates that the property to get is auth sub type. */ + AUTH_SUB_TYPE = 1, + /**< Indicates that the property to get is lockout duration. */ + LOCKOUT_DURATION = 2, + /**< Indicates that the property to get is remain attempts. */ + REMAIN_ATTEMPTS = 3, + /**< Indicates that the property to get is lockout duration after next fail. */ + NEXT_FAIL_LOCKOUT_DURATION = 6 +}; + +/** + * @brief Indicates executor property. + * + * @since 4.0 + * @version 2.0 + */ +struct Property { + /**< Indicates auth sub type. */ + unsigned long authSubType; + /**< Indicates lockout duration. */ + int lockoutDuration; + /**< Indicates remain attempts. */ + int remainAttempts; + /**< Indicates next fail lockout duration. */ + int nextFailLockoutDuration; +}; + +/** + * @brief Enumerates command IDs. + * + * @since 5.0 + * @version 1.0 + */ +enum CommandId : int { + /**< The vendor may add a custom command ID after this. */ + VENDOR_COMMAND_BEGIN = 10000 +}; + +/** @} */ \ No newline at end of file diff --git a/power/v1_2/IPowerInterface.idl b/power/v1_2/IPowerInterface.idl index cd773c06e00a6a9a250a543885e8c00aef81a0e2..41d99470e0e2fce81c8365a14076e7613c286a92 100755 --- a/power/v1_2/IPowerInterface.idl +++ b/power/v1_2/IPowerInterface.idl @@ -235,5 +235,35 @@ interface IPowerInterface { * @version 1.0 */ SetSuspendTag([in] String tag); + + /** + * @brief Set the set-path file value related to the scene name. + * + * @param scene The scene name defined in power config json file. + * + * @param value Value of the set-path file. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 5.0 + * + * @version 1.0 + */ + SetPowerConfig([in] String scene, [in] String value); + + /** + * @brief Get the get-path file value related to the scene name. + * + * @param scene The scene name defined in power config json file. + * + * @param value Value of the get-path file. + * + * @return Returns HDF_SUCCESS if the operation is successful. + * + * @since 5.0 + * + * @version 1.0 + */ + GetPowerConfig([in] String scene, [out] String value); } /** @} */ diff --git a/ril/bundle.json b/ril/bundle.json index de1338feaa70d0fbae7f183e7889020bff2c7674..4b8fe43b6f8403403b936826f989a3c18a3d21c1 100644 --- a/ril/bundle.json +++ b/ril/bundle.json @@ -29,7 +29,8 @@ "sub_component": [ "//drivers/interface/ril/v1_1:ril_idl_target", "//drivers/interface/ril/v1_2:ril_idl_target", - "//drivers/interface/ril/v1_3:ril_idl_target" + "//drivers/interface/ril/v1_3:ril_idl_target", + "//drivers/interface/ril/v1_4:ril_idl_target" ], "test": [ ], @@ -96,6 +97,27 @@ "header_files": [], "header_base": "//drivers/interface/ril" } + }, + { + "name": "//drivers/interface/ril/v1_4:libril_proxy_1.4", + "header": { + "header_files": [], + "header_base": "//drivers/interface/ril" + } + }, + { + "name": "//drivers/interface/ril/v1_4:libril_stub_1.4", + "header": { + "header_files": [], + "header_base": "//drivers/interface/ril" + } + }, + { + "name": "//drivers/interface/ril/v1_4:ril_idl_headers_1.4", + "header": { + "header_files": [], + "header_base": "//drivers/interface/ril" + } } ] } diff --git a/ril/v1_2/BUILD.gn b/ril/v1_2/BUILD.gn index 776d7b11e36d77c3773c9add9349a4d494c655b3..5e0ad2e7b87866611764d72e87be9e1949ba4219 100644 --- a/ril/v1_2/BUILD.gn +++ b/ril/v1_2/BUILD.gn @@ -20,6 +20,7 @@ if (defined(ohos_lite)) { } } else { hdi("ril") { + branch_protector_ret = "pac_ret" module_name = "ril_service" imports = [ "ohos.hdi.ril.v1_1:ril" ] sources = [ diff --git a/ril/v1_3/BUILD.gn b/ril/v1_3/BUILD.gn index 6913ad6ca96319d4f8d8953985147f62f09a52e8..b7364167ae545f8ec075f0ab2c49ad31ad893440 100644 --- a/ril/v1_3/BUILD.gn +++ b/ril/v1_3/BUILD.gn @@ -20,6 +20,7 @@ if (defined(ohos_lite)) { } } else { hdi("ril") { + branch_protector_ret = "pac_ret" module_name = "ril_service" imports = [ "ohos.hdi.ril.v1_2:ril" ] sources = [ diff --git a/ril/v1_3/IRilCallback.idl b/ril/v1_3/IRilCallback.idl index b655ec711ec1abc7ce708b2dbe3af16156349b57..db813dd2630185bb8e9d54992b95ffc6fe7ca0ff 100644 --- a/ril/v1_3/IRilCallback.idl +++ b/ril/v1_3/IRilCallback.idl @@ -79,5 +79,29 @@ import ohos.hdi.ril.v1_3.Types; * @version 1.1 */ [oneway] GetSimCardStatusResponse([in] struct RilRadioResponseInfo responseInfo, [in] struct SimCardStatusInfo result); + + /** + * @brief Reporting NV refresh result. + * + * @param responseInfo Common response information, such as the card slot ID and request sequence ID. For details, + * see {@link RilRadioResponseInfo}. + * @param state NV refresh result. + * + * @since 5.0 + * @version 1.0 + */ + [oneway] NcfgFinishedResult([in] struct RilRadioResponseInfo responseInfo, [in] int state); + + /** + * @brief Reporting restart rild Nv match state. + * + * @param responseInfo Common response information, such as the card slot ID and request sequence ID. For details, + * see {@link RilRadioResponseInfo}. + * @param state restart rild Nv match state. + * + * @since 5.0 + * @version 1.0 + */ + [oneway] RestartRildNvMatch([in] struct RilRadioResponseInfo responseInfo, [in] int state); } /** @} */ diff --git a/ril/v1_4/BUILD.gn b/ril/v1_4/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..055f6b3907c82da49a17691d7c7219fe323f49e9 --- /dev/null +++ b/ril/v1_4/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (c) 2025 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. + +import("//build/config/components/hdi/hdi.gni") +if (defined(ohos_lite)) { + group("libril_proxy_1.4") { + deps = [] + public_configs = [] + } +} else { + hdi("ril") { + branch_protector_ret = "pac_ret" + module_name = "ril_service" + proxy_deps = [ "../v1_3:libril_proxy_1.3" ] + stub_deps = [ "../v1_3:libril_stub_1.3" ] + sources = [ + "IRil.idl", + "IRilCallback.idl", + "Types.idl", + ] + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_ril" + } +} diff --git a/ril/v1_4/IRil.idl b/ril/v1_4/IRil.idl new file mode 100644 index 0000000000000000000000000000000000000000..d20470ee511b48ec1cf8e5c56df3fb7b746a2c4e --- /dev/null +++ b/ril/v1_4/IRil.idl @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2025 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 Ril + * @{ + * + * @brief Defines Ril-related APIs. + * + * The radio interface layer (RIL) module provides APIs and callbacks for upper-layer + * telephony services, including call, SMS, MMS, network search, and SIM card services. + * + * @since 5.1 + * @version 1.0 + */ + +/** + * @file IRil.idl + * + * @brief Declares the request API of the RIL module. + * + * @since 5.1 + * @version 1.0 + */ + +/** + * @brief Defines the path for the package of the RIL module APIs. + * + * @since 5.1 + * @version 1.0 + */ +package ohos.hdi.ril.v1_4; + +import ohos.hdi.ril.v1_4.IRilCallback; +import ohos.hdi.ril.v1_3.IRil; + +/** + * @brief Declares the request API of the RIL module. + * + * Request APIs are called to make calls, send SMS and MMS messages, activate SIM cards, + * and access the Internet. + * + * @since 5.1 + * @version 1.0 + */ +interface IRil extends ohos.hdi.ril.v1_3.IRil { + /** + * @brief Sets an IRil callback. + * + * @param rilCallback Callback to set. For details, see {@link IRilCallback}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-0 value if the operation fails. + * + * @since 5.1 + * @version 1.0 + */ + [oneway] SetCallback1_4([in] IRilCallback rilCallback); +} +/** @} */ diff --git a/ril/v1_4/IRilCallback.idl b/ril/v1_4/IRilCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..be2dc165a0720f7bc09bbc7fd5905027968f27fb --- /dev/null +++ b/ril/v1_4/IRilCallback.idl @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2025 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 Ril + * @{ + * + * @brief Defines Ril-related APIs. + * + * The radio interface layer (RIL) module provides APIs and callbacks for upper-layer telephony services, + * including call, SMS, MMS, network search, and SIM card services. + * + * @since 5.1 + * @version 1.0 + */ + +/** + * @file IRilCallback.idl + * + * @brief Declares callback APIs of the RIL module. + * + * @since 5.1 + * @version 1.0 + */ + +/** + * @brief Defines the path for the package of the RIL module APIs. + * + * @since 5.1 + * @version 1.0 + */ +package ohos.hdi.ril.v1_4; + +import ohos.hdi.ril.v1_3.IRilCallback; +import ohos.hdi.ril.v1_4.Types; + +/** + * @brief Declares callback APIs of the RIL module. + * + * These APIs provide the callback functions for making calls, sending SMS and MMS messages, + * activating SIM cards, and accessing the Internet. The caller needs to implement these callbacks. + * + * @since 5.1 + * @version 1.0 + */ +[callback] interface IRilCallback extends ohos.hdi.ril.v1_3.IRilCallback { + /** + * @brief Callback for the response of querying the call status information list. + * + * @param responseInfo Common response information, such as the card slot ID and request sequence ID. + * For details, see {@link RilRadioResponseInfo}. + * @param callList Call status information list. For details, see {@link CallInfoExtList}. + * + * @since 5.1 + * @version 1.0 + */ + [oneway] GetCallListResponseExt([in] struct RilRadioResponseInfo responseInfo, + [in] struct CallInfoExtList callList); +} +/** @} */ \ No newline at end of file diff --git a/ril/v1_4/Types.idl b/ril/v1_4/Types.idl new file mode 100644 index 0000000000000000000000000000000000000000..6b52bd799c1d49ea524edf7c161a3fcb2439a45d --- /dev/null +++ b/ril/v1_4/Types.idl @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2025 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 Ril + * + * @brief Defines Ril-related APIs. + * + * The radio interface layer (RIL) module provides APIs and callbacks for upper-layer telephony services, + * including call, SMS, MMS, network search, and SIM card services. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.ril.v1_4; + +import ohos.hdi.ril.v1_1.Types; +import ohos.hdi.ril.v1_2.Types; +import ohos.hdi.ril.v1_3.Types; + +/** + * @brief Defines the call status information. + */ +struct CallInfoExt { + /** + * Call ID + */ + int index; + + /** + * Call direction. The value 0 indicates the calling party, and the value 1 indicates the called party. + */ + int dir; + + /** + * Call status: + *- 0: activated state + *- 1: call hold state + *- 2: calling party, dialing state + *- 3: calling party, ringback tone state + *- 4: called party, incoming call state + *- 5: called party, call waiting state + *- 6: disconnected state + *- 7: disconnecting state + *- 8: idle state + */ + int state; + + /** + * Call mode: + *- 0: voice call + *- 1: data call + *- 2: fax + */ + int mode; + + /** + * Multi-party call status: + *- 0: not a multi-party call + *- 1: a multi-party call + */ + int mpty; + + /** + * Call domain of the voice call: + *- 0: CS domain + *- 1: IP multimedia system (IMS) domain + */ + int voiceDomain; + + /** + * Call type. Currently, the value can only be 0, indicating a voice call. + */ + int callType; + + /** + * Code address type: + *-129: common number + *- 145: international number + */ + int type; + + /** + * Phone number + */ + String number; + + /** + * Name of a phone number in the phonebook + */ + String alpha; + + /** + * Indicates remote party name. + */ + String name; + + /** + * Identifies the CNAP display name; + * - 0:Allowed + * - 1:Restricted + * - 2:Not Specified/Unknown + * - 3:Payphone + */ + int namePresentation; +}; + +/** + * @brief Defines the call status information list. + */ +struct CallInfoExtList { + /** + * Total number + */ + int callSize; + + /** + * ID of the call status information list + */ + int flag; + + /** + * Call status information list + */ + List calls; +}; \ No newline at end of file diff --git a/sensor/bundle.json b/sensor/bundle.json index 1394cdea28b9ed03a0701e797769b0f87fedee9f..34857b186c3c8be643732cd891f50d51a1c2407f 100644 --- a/sensor/bundle.json +++ b/sensor/bundle.json @@ -27,7 +27,8 @@ }, "build": { "sub_component": [ - "//drivers/interface/sensor/v2_0:sensor_idl_target" + "//drivers/interface/sensor/v2_0:sensor_idl_target", + "//drivers/interface/sensor/v2_1:sensor_idl_target" ], "test": [ ], @@ -55,6 +56,22 @@ ], "header_base": "//drivers/interface/sensor" } + }, + { + "name": "//drivers/interface/sensor/v2_1:libsensor_proxy_2.1", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/sensor" + } + }, + { + "name": "//drivers/interface/sensor/v2_1:libsensor_stub_2.1", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/sensor" + } } ] } diff --git a/sensor/v2_1/BUILD.gn b/sensor/v2_1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b986b750002a5cecadad612cbc0df4f89deda804 --- /dev/null +++ b/sensor/v2_1/BUILD.gn @@ -0,0 +1,38 @@ +# Copyright (c) 2024 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. + +import("//build/config/components/hdi/hdi.gni") +if (defined(ohos_lite)) { + group("libsensor_proxy_2.1") { + deps = [] + public_configs = [] + } +} else { + hdi("sensor") { + module_name = "sensor_service" + + sources = [ + "ISensorCallback.idl", + "ISensorInterface.idl", + "SensorTypes.idl", + ] + + proxy_deps = [ "../v2_0:libsensor_proxy_2.0" ] + + stub_deps = [ "../v2_0:libsensor_stub_2.0" ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_sensor" + } +} diff --git a/sensor/v2_1/ISensorCallback.idl b/sensor/v2_1/ISensorCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..c06a2391a3e44219a14bfb369ee14a08bfb9400d --- /dev/null +++ b/sensor/v2_1/ISensorCallback.idl @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 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 HdiSensor + * @{ + * + * @brief Provides unified APIs for sensor services to access sensor drivers. + * + * A sensor service can obtain a sensor driver object or agent and then call APIs provided by this object or agent to + * access different types of sensor devices based on the sensor IDs, thereby obtaining sensor information, + * subscribing to or unsubscribing from sensor data, enabling or disabling a sensor, + * setting the sensor data reporting mode, and setting sensor options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 2.0 + */ + +package ohos.hdi.sensor.v2_1; + +import ohos.hdi.sensor.v2_0.SensorTypes; +import ohos.hdi.sensor.v2_0.ISensorCallback; + +/** + * @brief Defines the callback for reporting sensor data. This callback needs to be registered when + * a sensor user subscribes to sensor data. Only after the sensor is enabled, the sensor data subscriber can receive + * sensor data. For details, see {@link ISensorInterface}. + * + * @since 5.1 + * @version 1.1 + */ +[callback] interface ISensorCallback extends ohos.hdi.sensor.v2_0.ISensorCallback { + /** + * @brief Defines the function for reporting sensor data. + * @param event Indicates the information about sensor event in the system. + * + * @since 1.0 + * @version 1.0 + */ + [oneway] OnDataEventAsync([in] struct HdfSensorEvents[] events); +} diff --git a/sensor/v2_1/ISensorInterface.idl b/sensor/v2_1/ISensorInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..9b97ee06623ae4c6b2f45487588f9fb64954fa4f --- /dev/null +++ b/sensor/v2_1/ISensorInterface.idl @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 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 HdiSensor + * @{ + * + * @brief Provides unified APIs for sensor services to access sensor drivers. + * + * A sensor service can obtain a sensor driver object or agent and then call APIs provided by this object or agent to + * access different types of sensor devices based on the sensor IDs, thereby obtaining sensor information, + * subscribing to or unsubscribing from sensor data, enabling or disabling a sensor, + * setting the sensor data reporting mode, and setting sensor options such as the accuracy and measurement range. + * + * @since 5.1 + */ + +/** + * @file ISensorInterface.idl + * + * @brief Declares the APIs provided by the sensor module for obtaining sensor information, subscribing to or + * unsubscribing from sensor data, enabling or disabling a sensor, setting the sensor data reporting mode, + * and setting sensor options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.1 + */ + +package ohos.hdi.sensor.v2_1; + +import ohos.hdi.sensor.v2_0.SensorTypes; +import ohos.hdi.sensor.v2_1.ISensorCallback; +import ohos.hdi.sensor.v2_0.ISensorInterface; + +/** + * @brief Defines the functions for performing basic operations on sensors. + * + * The operations include obtaining sensor information, subscribing to or unsubscribing from sensor data, + * enabling or disabling a sensor, setting the sensor data reporting mode, and setting sensor options such as + * the accuracy and measurement range. + */ + +interface ISensorInterface extends ohos.hdi.sensor.v2_0.ISensorInterface { + /** + * @brief Registers the callback for reporting sensor data to the subscriber. + * + * @param groupId Indicates the sensor group ID. + * The sensorId enumeration value range is 128-160, which means that the medical sensor service is subscribed. + * It only needs to be subscribed once successfully, and there is no need to subscribe repeatedly. + * The sensorId enumeration value range is not within 128-160, which means that the traditional sensor + * is subscribed, and the subscription is successful once. + * @param callbackObj Indicates the callback to register. For details, see {@link ISensorCallback}. + * @return Returns 0 if the callback is successfully registered; returns a negative value otherwise. + * + * @since 5.1 + * @version 1.0 + */ + RegisterAsync([in] int groupId, [in] ISensorCallback callbackObj); + + /** + * @brief Deregisters the callback for reporting sensor data. + * + * @param groupId Indicates the sensor group ID. + * The sensorId enumeration value range is 128-160, which means that the medical sensor service is subscribed. + * It only needs to cancel the subscription once successfully, and there is no need to + * cancel the subscription repeatedly. The sensorId enumeration value range is not within 128-160, + * which means that the traditional sensor is subscribed. You can cancel the subscription once successfully. + * @param callbackObj Indicates the callback to deregister. For details, see {@link ISensorCallback}. + * @return Returns 0 if the callback is successfully deregistered; returns a negative value otherwise. + * + * @since 5.1 + * @version 1.0 + */ + UnregisterAsync([in] int groupId, [in] ISensorCallback callbackObj); +} diff --git a/sensor/v2_1/SensorTypes.idl b/sensor/v2_1/SensorTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..9606c9933aaaadc815260ae5ebe74f284e58588e --- /dev/null +++ b/sensor/v2_1/SensorTypes.idl @@ -0,0 +1,53 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 1.1 (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 HdiSensor + * @{ + * + * @brief Provides unified APIs for sensor services to access sensor drivers. + * + * A sensor service can obtain a sensor driver object or agent and then call APIs provided by this object or agent to + * access different types of sensor devices based on the sensor IDs, thereby obtaining sensor information, + * subscribing to or unsubscribing from sensor data, enabling or disabling a sensor, + * setting the sensor data reporting mode, and setting sensor options such as the accuracy and measurement range. + * + * @version 1.1 + */ + +/** + * @file SensorTypes.idl + * + * @brief Defines the data used by the sensor module, including the sensor information, + * and reported sensor data. + * + * @since 5.1 + * @version 1.1 + */ + +package ohos.hdi.sensor.v2_1; +import ohos.hdi.sensor.v2_0.SensorTypes; + +/** + * @brief Enumerates sensor types. + * + * @since 5.1 + * @version 1.1 + */ +enum HdfSensorTypeTag : ohos.hdi.sensor.v2_0.HdfSensorTypeTag { + HDF_SENSOR_TYPE_FUSION_PRESSURE = 283, /**< fusion pressure sensor */ +}; + diff --git a/usb/bundle.json b/usb/bundle.json index 8fdca89e462c86820fdfaabe810191152b625471..00a7db61d29f3e04588955e75a3b6bd1255e1277 100644 --- a/usb/bundle.json +++ b/usb/bundle.json @@ -32,8 +32,12 @@ "sub_component": [ "//drivers/interface/usb/v1_0:usb_idl_target", "//drivers/interface/usb/v1_1:usb_idl_target", + "//drivers/interface/usb/v1_2:usb_idl_target", + "//drivers/interface/usb/v2_0:usb_idl_target", + "//drivers/interface/usb/serial/v1_0:serial_idl_target", "//drivers/interface/usb/gadget/mtp/v1_0:usbfn_mtp_idl_target", - "//drivers/interface/usb/ddk/v1_0:usb_ddk_idl_target" + "//drivers/interface/usb/ddk/v1_0:usb_ddk_idl_target", + "//drivers/interface/usb/ddk/v1_1:usb_ddk_idl_target" ], "test": [], "inner_kits": [ @@ -120,8 +124,113 @@ "header_files": [], "header_base": "//drivers/interface/usb" } + }, + { + "name": "//drivers/interface/usb/v1_2:libusb_proxy_1.2", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb" + } + }, + { + "name": "//drivers/interface/usb/v1_2:libusb_stub_1.2", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb" + } + }, + { + "name": "//drivers/interface/usb/v1_2:usb_idl_headers_1.2", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb" + } + }, + { + "name": "//drivers/interface/usb/v2_0:libusb_proxy_2.0", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb" + } + }, + { + "name": "//drivers/interface/usb/v2_0:libusb_stub_2.0", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb" + } + }, + { + "name": "//drivers/interface/usb/v2_0:usb_idl_headers_2.0", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb" + } + }, + { + "name": "//drivers/interface/usb/ddk/v1_1:libusb_ddk_proxy_1.1", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb/ddk" + } + }, + { + "name": "//drivers/interface/usb/ddk/v1_1:libusb_ddk_stub_1.1", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb/ddk" + } + }, + { + "name": "//drivers/interface/usb/ddk/v1_1:usb_ddk_idl_headers", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb/ddk" + } + }, + { + "name": "//drivers/interface/usb/usb_serial_ddk/v1_0:libusb_serial_ddk_proxy_1.0", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb/usb_serial_ddk" + } + }, + { + "name": "//drivers/interface/usb/usb_serial_ddk/v1_0:libusb_serial_ddk_stub_1.0", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb/usb_serial_ddk" + } + }, + { + "name": "//drivers/interface/usb/scsi_ddk/v1_0:libscsi_ddk_proxy_1.0", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb/scsi_ddk" + } + }, + { + "name": "//drivers/interface/usb/scsi_ddk/v1_0:libscsi_ddk_stub_1.0", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb/scsi_ddk" + } + }, + { + "name": "//drivers/interface/usb/serial/v1_0:libserial_proxy_1.0", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb/serial" + } + }, + { + "name": "//drivers/interface/usb/serial/v1_0:libserial_stub_1.0", + "header": { + "header_files": [], + "header_base": "//drivers/interface/usb/serial" + } } ] } } -} \ No newline at end of file +} diff --git a/usb/ddk/v1_0/BUILD.gn b/usb/ddk/v1_0/BUILD.gn index 94b53ba9ad51a344a607bb33bff9049cafac9260..e391f0b17fabc9d1ed5ceb2a15cba6dd06537415 100644 --- a/usb/ddk/v1_0/BUILD.gn +++ b/usb/ddk/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("usb_ddk") { module_name = "usb_ddk" diff --git a/usb/ddk/v1_1/BUILD.gn b/usb/ddk/v1_1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a272b2a0d1b28ec0e8e4f6e4b9ab0f1b032fcc1e --- /dev/null +++ b/usb/ddk/v1_1/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2025 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. + +import("//build/config/components/hdi/hdi.gni") +hdi("usb_ddk") { + module_name = "usb_ddk" + imports = [ "ohos.hdi.usb.ddk.v1_0:usb_ddk" ] + + sources = [ + "IUsbDdk.idl", + "UsbDdkTypes.idl", + ] + + language = "cpp" + mode = "ipc" + subsystem_name = "hdf" + part_name = "drivers_interface_usb" +} diff --git a/usb/ddk/v1_1/IUsbDdk.idl b/usb/ddk/v1_1/IUsbDdk.idl new file mode 100644 index 0000000000000000000000000000000000000000..96968723b4e6fc06e76fdcc4961278b8a7aa5e45 --- /dev/null +++ b/usb/ddk/v1_1/IUsbDdk.idl @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 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 HdiUsbDdk + * @{ + * + * @brief Provides USB DDK APIs to open and close USB interfaces, perform non-isochronous and isochronous\n + * data transfer over USB pipes, and implement control transfer and interrupt transfer, etc. + * @since 5.1 + * @version 1.1 + */ + +/** + * @file IUsbDdk.idl + * + * @brief Declares the USB DDK APIs used by the USB host to access USB devices. + * + * @since 5.1 + * @version 1.1 + */ + +package ohos.hdi.usb.ddk.v1_1; + +import ohos.hdi.usb.ddk.v1_1.UsbDdkTypes; +import ohos.hdi.usb.ddk.v1_0.IUsbDdk; + +/** + * @brief Declares the USB DDK APIs used by the USB host to access USB devices. + * @since 5.1 + * @version 1.1 + */ +interface IUsbDdk extends ohos.hdi.usb.ddk.v1_0.IUsbDdk +{ + /** + * @brief Obtains usb devices. + * + * @param devices USB device array. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + GetDevices([out] List deviceIds); + + /** + * @brief Updates peripheral driver information. + * + * @param driverInfo Driver ability information. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + UpdateDriverInfo([in] struct DriverAbilityInfo driverInfo); + + /** + * @brief Removes Driver information. + * + * @param driverUid Driver Uid. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + RemoveDriverInfo([in] String driverUid); +} diff --git a/usb/ddk/v1_1/UsbDdkTypes.idl b/usb/ddk/v1_1/UsbDdkTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..53fecea08d2765be236432bfcbf3983eced58909 --- /dev/null +++ b/usb/ddk/v1_1/UsbDdkTypes.idl @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 HdiUsbDdk + * @{ + * + * @brief Provides USB DDK types and declares the macros, enumerated variables, and\n + * data structures required by the USB DDK APIs. + * + * @since 5.1 + * @version 1.1 + */ + +/** + * @file UsbDdkTypes.idl + * + * @brief Provides the enumerated variables, structures, and macros used in USB DDK APIs. + * + * @since 5.1 + * @version 1.1 + */ + +package ohos.hdi.usb.ddk.v1_1; + +import ohos.hdi.usb.ddk.v1_0.UsbDdkTypes; + +/** + * @brief Defines driver info. + * + * @since 5.1 + * @version 1.0 + */ +struct DriverAbilityInfo { + /** Driver uid */ + String driverUid; + /** Vendor id array */ + unsigned short[] vids; +}; \ No newline at end of file diff --git a/usb/gadget/mtp/v1_0/BUILD.gn b/usb/gadget/mtp/v1_0/BUILD.gn index b2606307015941da216f055459045ec7d25ae3aa..6712c204d18a9e32888406caa46fb5e0b14cc489 100644 --- a/usb/gadget/mtp/v1_0/BUILD.gn +++ b/usb/gadget/mtp/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") hdi("usbfn_mtp") { module_name = "usbfn_mtp" diff --git a/usb/gadget/mtp/v1_0/IUsbfnMtpInterface.idl b/usb/gadget/mtp/v1_0/IUsbfnMtpInterface.idl index 75ee4e95416b732a399313d4f4ba5ed35a2d9696..54ec9555eecf8e8139f15a24ee5bd56d538ca805 100644 --- a/usb/gadget/mtp/v1_0/IUsbfnMtpInterface.idl +++ b/usb/gadget/mtp/v1_0/IUsbfnMtpInterface.idl @@ -50,7 +50,7 @@ import ohos.hdi.usb.gadget.mtp.v1_0.UsbfnMtpTypes; interface IUsbfnMtpInterface { /* * - * @brief Opens a USB MTP/PTP driver. + * @brief Open a USB MTP/PTP driver and init resources. * * @param None No parameter needed. * @@ -61,7 +61,7 @@ interface IUsbfnMtpInterface { Start(); /* * - * @brief Closes a USB MTP/PTP driver. + * @brief Close a USB MTP/PTP driver and release resources. * * @param None No parameter needed. * @@ -72,7 +72,7 @@ interface IUsbfnMtpInterface { Stop(); /* * - * @brief Read data by USB MTP/PTP driver. + * @brief Read data by adding a task to read queue. * * @param data Indicates the data read by USB MTP/PTP driver. * @@ -83,7 +83,7 @@ interface IUsbfnMtpInterface { Read([out] unsigned char[] data); /* * - * @brief Write data by USB MTP/PTP driver. + * @brief Write data by adding a task to write queue. * * @param data Indicates the data write to USB MTP/PTP driver. * @@ -131,7 +131,7 @@ interface IUsbfnMtpInterface { SendEvent([in] unsigned char[] eventData); /* * - * @brief Init a USB MTP/PTP driver. Used by usb_host. + * @brief Init a USB MTP/PTP port. Used by usb_host. * * @param None No parameter needed. * @@ -142,7 +142,7 @@ interface IUsbfnMtpInterface { Init(); /* * - * @brief Release a USB MTP/PTP driver. Used by usb_host. + * @brief Release a USB MTP/PTP port. Used by usb_host. * * @param None No parameter needed. * diff --git a/usb/scsi_ddk/v1_0/BUILD.gn b/usb/scsi_ddk/v1_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7a8c304b33eed63ac0c1135974a7290ebe081aff --- /dev/null +++ b/usb/scsi_ddk/v1_0/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2025 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. + +import("//build/config/components/hdi/hdi.gni") + +hdi("scsi_ddk") { + module_name = "scsi_ddk" + + sources = [ + "IScsiPeripheralDdk.idl", + "ScsiPeripheralDdkTypes.idl", + ] + + language = "cpp" + mode = "ipc" + subsystem_name = "hdf" + part_name = "drivers_interface_usb" +} diff --git a/usb/scsi_ddk/v1_0/IScsiPeripheralDdk.idl b/usb/scsi_ddk/v1_0/IScsiPeripheralDdk.idl new file mode 100644 index 0000000000000000000000000000000000000000..b96cc58a6ee3b1fa8331246ebbb2d116b19a3d1a --- /dev/null +++ b/usb/scsi_ddk/v1_0/IScsiPeripheralDdk.idl @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2025 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 HdiScsiDdk + * @{ + * + * @brief Provides SCSI DDK APIs to open and close SCSI interfaces. + * @since 5.1 + * @version 1.0 + */ + +/* * + * @file IScsiPeripheralDdk.idl + * + * @brief Declares the SCSI DDK APIs used by the SCSI host to access SCSI devices. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.scsi_ddk.v1_0; + +import ohos.hdi.usb.scsi_ddk.v1_0.ScsiPeripheralDdkTypes; + +/* * + * @brief Declares the SCSI DDK APIs used by the SCSI host to access SCSI devices. + */ +interface IScsiPeripheralDdk +{ + /* * + * @brief Initializes the DDK. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Init(); + + /* * + * @brief Releases the DDK. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Release(); + + /* * + * @brief Open SCSI device by deviceId. + * + * @param deviceId ID of the device to be operated. + * @param interfaceIndex Interface index, which corresponds to interface which supports USB Protocol UAS. + * @param dev Device handle. + * @param fd The file descriptor obtained for memory mapping. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Open([in] unsigned long deviceId, [in] unsigned char interfaceIndex, [out] struct ScsiPeripheralDevice dev, [out] FileDescriptor fd); + + /* * + * @brief Close SCSI device. + * + * @param dev Device handle. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Close([in] struct ScsiPeripheralDevice dev); + + /* * + * @brief Get the device capacity. + * + * @param dev Device handle. + * @param request ReadCapacity request information. + * @param capacityInfo The data of read capacity command. + * @param response The response parameters. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + ReadCapacity10([in] struct ScsiPeripheralDevice dev, [in] struct ScsiPeripheralReadCapacityRequest request, [out] struct ScsiPeripheralCapacityInfo capacityInfo, [out] struct ScsiPeripheralResponse response); + + /* * + * @brief Check if the logical unit is ready. + * + * @param dev Device handle. + * @param request Test unit ready request information. + * @param response The response parameters. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + TestUnitReady([in] struct ScsiPeripheralDevice dev, [in] struct ScsiPeripheralTestUnitReadyRequest request, [out] struct ScsiPeripheralResponse response); + + /* * + * @brief Get the information regarding the logical unit and SCSI target device. + * + * @param dev Device handle. + * @param request Inquiry request information. + * @param inquiryInfo The data of inquiry command. + * @param response The response parameters. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Inquiry([in] struct ScsiPeripheralDevice dev, [in] struct ScsiPeripheralInquiryRequest request, [out] struct ScsiPeripheralInquiryInfo inquiryInfo, [out] struct ScsiPeripheralResponse response); + + /* * + * @brief Get the sense data. + * + * @param dev Device handle. + * @param request RequestSense request information. + * @param response The response parameters. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + RequestSense([in] struct ScsiPeripheralDevice dev, [in] struct ScsiPeripheralRequestSenseRequest request, [out] struct ScsiPeripheralResponse response); + + /* * + * @brief Read from the specified logical block(s). + * + * @param dev Device handle. + * @param request The request parameters. + * @param response The response parameters. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Read10([in] struct ScsiPeripheralDevice dev, [in] struct ScsiPeripheralIORequest request, [out] struct ScsiPeripheralResponse response); + + /* * + * @brief Write data to the specified logical block(s). + * + * @param dev Device handle. + * @param request The request parameters. + * @param response The response parameters. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Write10([in] struct ScsiPeripheralDevice dev, [in] struct ScsiPeripheralIORequest request, [out] struct ScsiPeripheralResponse response); + + /* * + * @brief Verify the specified logical block(s) on the medium. + * + * @param dev Device handle. + * @param request The request parameters. + * @param request Verify request information. + * @param response The response parameters. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Verify10([in] struct ScsiPeripheralDevice dev, [in] struct ScsiPeripheralVerifyRequest request, [out] struct ScsiPeripheralResponse response); + + /* * + * @brief Send SCSI command that specified by CDB. + * + * @param dev Device handle. + * @param request The request parameters. + * @param response The response parameters. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + SendRequestByCDB([in] struct ScsiPeripheralDevice dev, [in] struct ScsiPeripheralRequest request, [out] struct ScsiPeripheralResponse response); +} diff --git a/usb/scsi_ddk/v1_0/ScsiPeripheralDdkTypes.idl b/usb/scsi_ddk/v1_0/ScsiPeripheralDdkTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..796056aaff1f2f72174e45836267da99259fccae --- /dev/null +++ b/usb/scsi_ddk/v1_0/ScsiPeripheralDdkTypes.idl @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2025 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 HdiScsiDdk + * @{ + * + * @brief Provides SCSI DDK types and declares the macros, enumerated variables, and\n + * data structures required by the SCSI DDK APIs. + * + * @since 5.1 + * @version 1.0 + */ + +/** + * @file ScsiPeripheralDdkTypes.idl + * + * @brief Provides the enumerated variables, structures, and macros used in SCSI DDK APIs. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.scsi_ddk.v1_0; + +/** + * @brief Opaque SCSI device structure. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralDevice { + /** File descriptor for device. */ + int devFd; + /** File descriptor for mmap. */ + int memMapFd; + /** Logical block length in bytes. */ + unsigned int lbLength; +}; + +/** + * @brief Request parameters. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralRequest { + /** Command descriptor block. */ + unsigned char[] commandDescriptorBlock; + /** Data transfer direction. */ + int dataTransferDirection; + /** Buffer size. */ + unsigned int memMapSize; + /** Timeout(unit: millisec). */ + unsigned int timeout; +}; + +/** + * @brief Response parameters. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralResponse { + /** Sense data. */ + unsigned char[] senseData; + /** The status at completion of the call, such as good, busy, or timeout. */ + unsigned char status; + /** Shifted, masked scsi status. */ + unsigned char maskedStatus; + /** Messaging level data (optional). */ + unsigned char msgStatus; + /** Byte count actually written to sbp. */ + unsigned char sbLenWr; + /** Errors from host adapter. */ + unsigned short hostStatus; + /** Errors from software driver. */ + unsigned short driverStatus; + /** Dxfer_len - actual_transferred. */ + int resId; + /** Time taken by cmd (unit: millisec). */ + unsigned int duration; + /** byte length of actual transferred data. */ + int transferredLength; +}; + +/** + * @brief Request parameters for read/write. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralIORequest { + /** Starting with the logical block. */ + unsigned int lbAddress; + /** Number of contiguous logical blocks that shall be read. */ + unsigned short transferLength; + /** Control byte. */ + unsigned char control; + /** Byte 1 of the CDB. */ + unsigned char byte1; + /** Byte 6 of the CDB. */ + unsigned char byte6; + /** Buffer size. */ + unsigned int memMapSize; + /** Timeout(unit: millisec). */ + unsigned int timeout; +}; + +/** + * @brief SCSI test unit ready request. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralTestUnitReadyRequest { + /** Control byte. */ + unsigned char control; + /** Timeout(unit: millisec). */ + unsigned int timeout; +}; + +/** + * @brief SCSI inquiry request. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralInquiryRequest { + /** Page code. */ + unsigned char pageCode; + /** Allocation length. */ + unsigned short allocationLength; + /** Control byte. */ + unsigned char control; + /** Byte 1 of the CDB. */ + unsigned char byte1; + /** Buffer size. */ + unsigned int memMapSize; + /** Timeout(unit: millisec). */ + unsigned int timeout; +}; + +/** + * @brief SCSI inquiry data. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralInquiryInfo { + /** Peripheral device type. */ + unsigned char deviceType; + /** Vendor identification. */ + unsigned char[] idVendor; + /** Product identification. */ + unsigned char[] idProduct; + /** Product revision. */ + unsigned char[] revProduct; +}; + +/** + * @brief SCSI read capacity request. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralReadCapacityRequest { + /** Logical block address. */ + unsigned int lbAddress; + /** Control byte. */ + unsigned char control; + /** Byte 8 of the CDB. */ + unsigned char byte8; + /** Timeout(unit: millisec). */ + unsigned int timeout; +}; + +/** + * @brief SCSI read capacity data. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralCapacityInfo { + /** Returned logical block address. */ + unsigned int lbAddress; + /** Logical block length in bytes. */ + unsigned int lbLength; +}; + +/** + * @brief SCSI request sense request. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralRequestSenseRequest { + /** Allocation length. */ + unsigned char allocationLength; + /** Control byte. */ + unsigned char control; + /** Byte 1 of the CDB. */ + unsigned char byte1; + /** Timeout(unit: millisec). */ + unsigned int timeout; +}; + +/** + * @brief Basic sense data of Information、Command-specific information、Sense key specific. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralBasicSenseInfo { + /** Response code. */ + unsigned char responseCode; + /** Information valid bit. */ + boolean valid; + /** Information sense data descriptor. */ + unsigned long information; + /** Command-specific information sense data descriptor. */ + unsigned long commandSpecific; + /** Sense key specific valid bit. */ + boolean sksv; + /** Sense key specific sense data descriptor. */ + unsigned int senseKeySpecific; +}; + +/** + * @brief SCSI verify request. + * + * @since 5.1 + * @version 1.0 + */ +struct ScsiPeripheralVerifyRequest { + /** Starting with the logical block. */ + unsigned int lbAddress; + /** Number of contiguous logical blocks that shall be verify. */ + unsigned short verificationLength; + /** Control byte. */ + unsigned char control; + /** Byte 1 of the CDB. */ + unsigned char byte1; + /** Byte 6 of the CDB. */ + unsigned char byte6; + /** Timeout(unit: millisec). */ + unsigned int timeout; +}; diff --git a/usb/serial/v1_0/BUILD.gn b/usb/serial/v1_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..521b7f489c6da3df6d8863b0dbe9104c911dc37a --- /dev/null +++ b/usb/serial/v1_0/BUILD.gn @@ -0,0 +1,27 @@ +# Copyright (c) 2025 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. + +import("//build/config/components/hdi/hdi.gni") +hdi("serial") { + module_name = "serial" + + sources = [ + "ISerialInterface.idl", + "SerialTypes.idl", + ] + + language = "cpp" + mode = "ipc" + subsystem_name = "hdf" + part_name = "drivers_interface_usb" +} diff --git a/usb/serial/v1_0/ISerialInterface.idl b/usb/serial/v1_0/ISerialInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..f312b60fb6fb360a7bbbefd22529c39ee6490581 --- /dev/null +++ b/usb/serial/v1_0/ISerialInterface.idl @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2025 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 HdiSerial + * + * + * @brief Provides unified APIs for serial services to access serial drivers. + * + * A serial service can obtain a serial driver object or agent and then call APIs provided by this object or agent to + * access different types of serial devices based on the serial IDs, thereby obtaining serial information, + * subscribing to or unsubscribing from serial data, enabling or disabling a serial, + * setting the serial data reporting mode, and setting serial options such as the accuracy and measurement range. + * + * @since 5.1 + */ + +/* * + * @file ISerialInterface.idl + * + * @brief Declares the APIs provided by the serial module for obtaining serial information, subscribing to or + * unsubscribing from serial data, enabling or disabling a serial, setting the serial data reporting mode, + * and setting serial options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.serial.v1_0; +import ohos.hdi.usb.serial.v1_0.SerialTypes; + +/* * + * @brief Defines the functions for performing basic operations on serial. + * + * The operations include obtaining serial port list information, opening and closing serial port, + * reading or writing serial port data, and setting or obtaining serial port properties. + */ +interface ISerialInterface { + + /** + * @brief Open and configure the serial port. + * + * Initializes and opens a serial communication port and sets communication parameters such as baud rate and parity. + * + * @param portId Indicates the Serial port device portId. + * + * @return Returns 0 if the setting is successful; returns a negative number otherwise. + * + * @since 5.1 + * + * @version 1.0 + */ + SerialOpen([in]int portId); + + /** + * @brief Close the serial port and release resources. + * + * Terminate the connection to the serial port, ensuring that the port and associated resources are released + * after all data transfers are complete. + * + * @param portId Indicates the Serial port device portId. + * + * @return Returns 0 if the setting is successful; returns a negative number otherwise. + * + * @since 5.1 + * + * @version 1.0 + */ + SerialClose([in]int portId); + + /** + * @brief Read data from the serial port. + * + * @param portId Indicates the Serial port device portId + * @param data Indicates the pointer to the buffer for receiving the data. + * + * @return Returns the size of the data that is successfully read; returns a negative number if the reading fails. + * + * @since 5.1 + * + * @version 1.0 + */ + SerialRead([in] int portId, [out] unsigned char []data, [in] unsigned int size, [in] unsigned int timeout); + + /** + * @brief Read data from the serial port. + * + * @param portId Indicates the Serial port device portId + * @param data Indicates the pointer to the data to write. + * + * @return Returns the size of the data that is successfully write; returns a negative number if the reading fails. + * + * @since 5.1 + * + * @version 1.0 + */ + SerialWrite([in] int portId, [in] unsigned char []data, [in] unsigned int size, [in] unsigned int timeout); + + /** + * @brief Sets the SERIAL attribute. + * + * SERIAL attributes include data bits, stop bits, parity bit, CTS, RTS, and receiving and transmitting FIFO. + * + * @param portId Indicates the Serial port device portId + * @param attribute Indicates the pointer to the SERIAL attribute to set. + * + * @return Returns 0 if the setting is successful; returns a negative number otherwise. + * + * @since 5.1 + * + * @version 1.0 + */ + SerialSetAttribute([in] int portId, [in] struct SerialAttribute attribute); + + /** + * @brief Obtains the SERIAL attribute. + * + * SERIAL attributes include data bits, stop bits, parity bit, CTS, RTS, and receiving and transmitting FIFO. + * + * @param portId Indicates the Serial port device portId + * @param attribute Indicates the pointer to the obtained SERIAL attribute. + * + * @return Returns 0 if the setting is successful; returns a negative number otherwise. + * + * @since 5.1 + * + * @version 1.0 + */ + SerialGetAttribute([in] int portId, [out] struct SerialAttribute attribute); + + /** + * @brief Obtains the SERIAL Port list. + * + * @param portId Indicates the Serial port device portId + * + * @return Returns 0 if the setting is successful; returns a negative number otherwise. + * + * @since 5.1 + * + * @version 1.0 + */ + SerialGetPortList([out] struct SerialPort[] portList); +} + + diff --git a/usb/serial/v1_0/SerialTypes.idl b/usb/serial/v1_0/SerialTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..72f7569ec2c89212b716cf7815b1673007a60a26 --- /dev/null +++ b/usb/serial/v1_0/SerialTypes.idl @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2025 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 HdiSerial + * + * + * @brief Provides unified APIs for serial services to access serial drivers. + * + * A serial service can obtain a serial driver object or agent and then call APIs provided by this object or agent to + * access different types of serial devices based on the serial IDs, thereby obtaining serial information, + * subscribing to or unsubscribing from serial data, enabling or disabling a serial, + * setting the serial data reporting mode, and setting serial options such as the accuracy and measurement range. + * + * @since 5.1 + */ + + /** + * @file UsbTypes.idl + * + * @brief Defines the data used by the serial module, including the serial information, + * and reported serial data. + * + * @since 5.1 + * @version 1.0 + */ + + +package ohos.hdi.usb.serial.v1_0; + +enum SerialBaudrate : unsigned int { + BAUDRATE_50 = 50, + BAUDRATE_75 = 75, + BAUDRATE_110 = 110, + BAUDRATE_134 = 134, + BAUDRATE_150 = 150, + BAUDRATE_200 = 200, + BAUDRATE_300 = 300, + BAUDRATE_600 = 600, + BAUDRATE_1200 = 1200, + BAUDRATE_1800 = 1800, + BAUDRATE_2400 = 2400, + BAUDRATE_4800 = 4800, + BAUDRATE_9600 = 9600, + BAUDRATE_19200 = 19200, + BAUDRATE_38400 = 38400, + BAUDRATE_57600 = 57600, + BAUDRATE_115200 = 115200, + BAUDRATE_230400 = 230400, + BAUDRATE_460800 = 460800, + BAUDRATE_500000 = 500000, + BAUDRATE_576000 = 576000, + BAUDRATE_921600 = 921600, + BAUDRATE_1000000 = 1000000, + BAUDRATE_1152000 = 1152000, + BAUDRATE_1500000 = 1500000, + BAUDRATE_2000000 = 2000000, + BAUDRATE_2500000 = 2500000, + BAUDRATE_3000000 = 3000000, + BAUDRATE_3500000 = 3500000, + BAUDRATE_4000000 = 4000000 +}; + +enum SerialDataBits : unsigned char { + /* Indicates the USB word length, which is 8 data bits per frame. */ + USB_ATTR_DATABIT_8 = 0, + /* Indicates the USB word length, which is 7 data bits per frame. */ + USB_ATTR_DATABIT_7, + /* Indicates the USB word length, which is 6 data bits per frame. */ + USB_ATTR_DATABIT_6, + /* Indicates the USB word length, which is 5 data bits per frame. */ + USB_ATTR_DATABIT_5, + /* Indicates the USB word length, which is 4 data bits per frame. */ + USB_ATTR_DATABIT_4 +}; + +enum SerialParity : unsigned char { + /* Indicates that the USB device has no parity bit. */ + USB_ATTR_PARITY_NONE = 0, + /* Indicates that the USB device has an odd parity bit. */ + USB_ATTR_PARITY_ODD, + /* Indicates that the USB device has an even parity bit. */ + USB_ATTR_PARITY_EVEN, + /* Indicates that the parity bit is 1. */ + USB_ATTR_PARITY_MARK, + /* Indicates that the parity bit is 0. */ + USB_ATTR_PARITY_SPACE +}; + +enum SerialStopBits : unsigned char { + /* that the USB device has 1 stop bit. */ + USB_ATTR_STOPBIT_1 = 0, + /* Indicates that the USB device has 1.5 stop bits. */ + USB_ATTR_STOPBIT_1P5, + /* Indicates that the USB device has 2 stop bits. */ + USB_ATTR_STOPBIT_2 +}; + +struct DeviceInfo { + unsigned char busNum; + unsigned char devAddr; + int vid; + int pid; + String serialNum; +}; + +/** + * @brief Defines basic attributes of the USB to serial port. + * + * You can configure the attributes via {@link SerialSetAttribute}. If the parameters are not set, + * default attributes are used. + * + * @attention The USB controller determines which USB attribute parameters are supported. + * + */ +struct SerialAttribute { + unsigned int baudrate; + unsigned char stopBits; + unsigned char parity; + unsigned char dataBits; +}; + +struct SerialPort { + int portId; + DeviceInfo deviceInfo; +}; + +/** + * @brief Enumerates USB Serial commands. + * + */ +enum SerialIoCmd { + USB_SERIAL_GET_PORT_LIST = 0, /**< Get the serial port list. */ + USB_SERIAL_OPEN, /**< Reference count management and initialize the USB device. */ + USB_SERIAL_CLOSE, /**< Reference count management and deinitialize the USB device. */ + USB_SERIAL_READ, /**< Read data. */ + USB_SERIAL_WRITE, /**< Write data. */ + USB_SERIAL_GET_ATTRIBUTE, /**< Obtain the device attributes. */ + USB_SERIAL_SET_ATTRIBUTE /**< Set the device attributes. */ +}; \ No newline at end of file diff --git a/usb/usb_serial_ddk/v1_0/BUILD.gn b/usb/usb_serial_ddk/v1_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..57ce74cba9647b73a620095295c905d89da60d3c --- /dev/null +++ b/usb/usb_serial_ddk/v1_0/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2025 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. + +import("//build/config/components/hdi/hdi.gni") + +hdi("usb_serial_ddk") { + module_name = "usb_serial_ddk" + + sources = [ + "IUsbSerialDdk.idl", + "UsbSerialDdkTypes.idl", + ] + + language = "cpp" + mode = "ipc" + subsystem_name = "hdf" + part_name = "drivers_interface_usb" +} diff --git a/usb/usb_serial_ddk/v1_0/IUsbSerialDdk.idl b/usb/usb_serial_ddk/v1_0/IUsbSerialDdk.idl new file mode 100644 index 0000000000000000000000000000000000000000..735eb7ce4f8d6aa83e2172c574626fdbded83cd8 --- /dev/null +++ b/usb/usb_serial_ddk/v1_0/IUsbSerialDdk.idl @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2025 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 HdiUsbUsbSerialDdk + * @{ + * + * @brief Provides USB SERIAL DDK types and declares the macros, enumerated variables, and\n + * data structures required by the USB SERIAL DDK APIs. + * + * @syscap SystemCapability.Driver.UsbSerial.Extension + * @since 5.1 + * @version 1.0 + */ + +/** + * @file IUsbSerialDdk.idl + * + * @brief Declares the USB SERIAL DDK APIs used by the USB serial host to access USB serial devices. + * + * @since 5.1 + * @version 1.0 + */ +package ohos.hdi.usb.usb_serial_ddk.v1_0; + +import ohos.hdi.usb.usb_serial_ddk.v1_0.UsbSerialDdkTypes; + +/* * + * @brief Declares the USB DDK APIs used by the USB host to access USB devices. + */ +interface IUsbSerialDdk +{ + + /* * + * @brief Initializes the USB serial DDK. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Init(); + + /* * + * @brief Releases the DDK. + * + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Release(); + + /** + * @brief Open USB serial device by deviceId. + * + * @param deviceId ID of the device to be operated. + * @param interfaceIndex Interface index, which corresponds to interface which supports USB Protocol ACM. + * @param dev Device handle. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Open([in] unsigned long deviceId, [in] unsigned long interfaceIndex, [out] struct UsbSerialDeviceHandle dev); + + /** + * @brief Close USB serial device. + * + * @param dev Device handle. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Close([in] struct UsbSerialDeviceHandle dev); + + /** + * @brief Read bytesRead into buff from UsbSerial device. + * + * @param dev Device handle. + * @param bufferSize Max buff size. + * @param buff Received data from a serial device. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Read([in] struct UsbSerialDeviceHandle dev, [in] unsigned int bufferSize, [out] List buff); + + /** + * @brief Write bytesWritten from buff to UsbSerial device. + * + * @param dev Device handle. + * @param buff Serial information write to device. + * @param bytesWritten Actual bytes written. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Write([in] struct UsbSerialDeviceHandle dev, [in] List buff, [out] unsigned int bytesWritten); + + /** + * @brief Set the serial port baud rate. + * + * @param dev Device handle. + * @param baudRate Serial port baud rate set to connect device. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + SetBaudRate([in] struct UsbSerialDeviceHandle dev, [in] unsigned int baudRate); + + /** + * @brief Set the serial port parameters. + * + * @param dev Device handle. + * @param params Serial port params set to connect device. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + SetParams([in] struct UsbSerialDeviceHandle dev, [in] struct UsbSerialParams params); + + /** + * @brief Sets the read timeout (in milliseconds)/blocking mode + * + * @param dev Device handle. + * @param timeout Set to -1 to infinite timeout, 0 to return immediately with any data (non + blocking, or >0 to wait for data for a specified number of milliseconds). Timeout will + be rounded to the nearest 100ms (a Linux API restriction). Maximum value limited to + 25500ms (another Linux API restriction). + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + SetTimeout([in] struct UsbSerialDeviceHandle dev, [in] int timeout); + + /** + * @brief Sets FlowControl params. + * + * @param dev Device handle. + * @param flowControl flow control mode. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + SetFlowControl([in] struct UsbSerialDeviceHandle dev, [in] enum UsbSerialFlowControl flowControl); + + /** + * @brief flush buffers after write. + * + * @param dev Device handle. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + Flush([in] struct UsbSerialDeviceHandle dev); + + /** + * @brief flush read buffers. + * + * @param dev Device handle. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + FlushInput([in] struct UsbSerialDeviceHandle dev); + + /** + * @brief flush write buffers. + * + * @param dev Device handle. + * @return 0 if the operation is successful; a negative value otherwise. + * @since 5.1 + * @version 1.0 + */ + FlushOutput([in] struct UsbSerialDeviceHandle dev); +} diff --git a/usb/usb_serial_ddk/v1_0/UsbSerialDdkTypes.idl b/usb/usb_serial_ddk/v1_0/UsbSerialDdkTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..cca5b4cd61db3d0588a1d8b26c3de03f9e02e35a --- /dev/null +++ b/usb/usb_serial_ddk/v1_0/UsbSerialDdkTypes.idl @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2025 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 HdiUsbSerialDdk + * @{ + * + * @brief Provides USB SERIAL DDK types and declares the macros, enumerated variables, and\n + * data structures required by the USB SERIAL DDK APIs. + * + * @syscap SystemCapability.Driver.UsbSerial.Extension + * @since 5.1 + * @version 1.0 + */ + + /** + * @file UsbSerialDdkTypes.idl + * + * @brief Defines the enumeration values and data structures of the user_auth driver. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.usb_serial_ddk.v1_0; + + /** + * @brief Defines USB Serial UsbSerialDeviceHandle for USB SERIAL DDK. + * + * @since 5.1 + * @version 1.0 + */ +struct UsbSerialDeviceHandle { + /** The usb serial device fd */ + unsigned int fd; +}; + +/** + * @brief Defines flow control for USB SERIAL DDK. + * + * @since 5.1 + * @version 1.0 + */ +enum UsbSerialFlowControl { + /** No flow control */ + USB_SERIAL_NO_FLOW_CONTROL = 0, + /** Software flow control */ + USB_SERIAL_SOFTWARE_FLOW_CONTROL = 1, + /** Hardware flow control */ + USB_SERIAL_HARDWARE_FLOW_CONTROL = 2, +}; + +/** + * @brief Defines parity for USB SERIAL DDK. + * + * @since 5.1 + * @version 1.0 + */ +enum UsbSerialParity { + /** No parity */ + USB_SERIAL_PARITY_NONE = 0, + /** Odd parity */ + USB_SERIAL_PARITY_ODD = 1, + /** Even parity */ + USB_SERIAL_PARITY_EVEN = 2, +}; + + /** + * @brief Defines USB Serial Port Params for USB SERIAL DDK. + * + * @since 5.1 + * @version 1.0 + */ +struct UsbSerialParams { + /** The baud rate requested by the system */ + unsigned int baudRate; + /** The number of data bits to transmit */ + unsigned char nDataBits; + /** The number of half stop bits. */ + unsigned char nStopBits; + /** The parity setting to use during communication */ + enum UsbSerialParity parity; +}; +/** @} */ diff --git a/usb/v1_0/BUILD.gn b/usb/v1_0/BUILD.gn index 2a100a0d1b90c5b71b3d03d56cbf4bfee14608f0..30d2ad76bb9a684186fb69d5ae5f3d3aa6483065 100644 --- a/usb/v1_0/BUILD.gn +++ b/usb/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") if (defined(ohos_lite)) { group("libusb_proxy_1.0") { deps = [] diff --git a/usb/v1_0/IUsbInterface.idl b/usb/v1_0/IUsbInterface.idl index 7f37f1eeec46d8714c78e231b87bb13129888caa..e3d63786bf33b295b4b812c7fdbca3608f645337 100644 --- a/usb/v1_0/IUsbInterface.idl +++ b/usb/v1_0/IUsbInterface.idl @@ -245,6 +245,8 @@ interface IUsbInterface { * * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. * @since 3.2 + * @deprecated since 5.0 + * @useinstead ohos.hdi.usb.v1_1.IUsbInterface.ControlTransferReadwithLength */ ControlTransferRead([in] struct UsbDev dev, [in] struct UsbCtrlTransfer ctrl, [out] unsigned char[] data); diff --git a/usb/v1_1/BUILD.gn b/usb/v1_1/BUILD.gn index f3193765106ac296317c3b6835a906d9ade390a3..346d59b727c7f321579d55d7b26e92665534d87c 100644 --- a/usb/v1_1/BUILD.gn +++ b/usb/v1_1/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") if (defined(ohos_lite)) { group("libusb_proxy_1.1") { deps = [] @@ -22,7 +22,14 @@ if (defined(ohos_lite)) { module_name = "usbd" imports = [ "ohos.hdi.usb.v1_0:usb" ] - sources = [ "IUsbInterface.idl" ] + sources = [ + "IUsbInterface.idl", + "UsbTypes.idl", + ] + + proxy_deps = [ "../v1_0:libusb_proxy_1.0" ] + + stub_deps = [ "../v1_0:libusb_stub_1.0" ] language = "cpp" subsystem_name = "hdf" diff --git a/usb/v1_1/IUsbInterface.idl b/usb/v1_1/IUsbInterface.idl index c68594f3ed6fa23c78dbc5bea460894f74dc4c1d..268f865d5b3a07ddfa756debbc0a88ff5b91a1b1 100644 --- a/usb/v1_1/IUsbInterface.idl +++ b/usb/v1_1/IUsbInterface.idl @@ -40,6 +40,7 @@ package ohos.hdi.usb.v1_1; +import ohos.hdi.usb.v1_1.UsbTypes; import ohos.hdi.usb.v1_0.UsbTypes; import ohos.hdi.usb.v1_0.IUsbdSubscriber; import ohos.hdi.usb.v1_0.IUsbdBulkCallback; @@ -104,4 +105,76 @@ interface IUsbInterface extends ohos.hdi.usb.v1_0.IUsbInterface{ * @version 1.0 */ BulkTransferReadwithLength([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] int length, [out] unsigned char[] data); + + /* * + * @brief Clear the halt status for an endpoint. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.0 + * @version 1.0 + */ + ClearHalt([in] struct UsbDev dev, [in] struct UsbPipe pipe); + + /* * + * @brief Performs control transfer for endpoint 0 of the device. The data transfer direction is determined by the + * request type. If the result of requestType& + * USB_ENDPOINT_DIR_MASK is USB_DIR_OUT, the endpoint is in the data writing direction; if the result + * is USB_DIR_IN, the endpoint is in the data reading direction. + * + * @param dev Indicates the USB device address. + * @param ctrl Indicates the control data packet structure. + * @param data Indicates the read data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.0 + * @version 1.0 + */ + ControlTransferReadwithLength([in] struct UsbDev dev, [in] struct UsbCtrlTransferParams ctrl, [out] unsigned char[] data); + + /* * + * @brief Reset device. + * + * @param dev Indicates the USB device address. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.0 + * @version 1.0 + */ + ResetDevice([in] struct UsbDev dev); + + /* * + * @brief Get Accessory Info. + * + * @param accessoryInfo Indicates the accessory information. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.0 + * @version 1.0 + */ + GetAccessoryInfo([out] String[] accessoryInfo); + + /* * + * @brief Open the Accessory descriptor. + * + * @param fd accessory file descriptor. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.0 + * @version 1.0 + */ + OpenAccessory([out] FileDescriptor fd); + + /* * + * @brief Close the Accessory descriptor. + * + * @param fd accessory file descriptor. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.0 + * @version 1.0 + */ + CloseAccessory([in] FileDescriptor fd); } \ No newline at end of file diff --git a/usb/v1_1/UsbTypes.idl b/usb/v1_1/UsbTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..ea42e245876d7a3bb1af33843b1a5243b27d9167 --- /dev/null +++ b/usb/v1_1/UsbTypes.idl @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2024 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 HdiUsb + * @ + * + * @brief Provides unified APIs for usb services to access usb drivers. + * + * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to + * access different types of usb devices based on the usb IDs, thereby obtaining usb information, + * subscribing to or unsubscribing from usb data, enabling or disabling a usb, + * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. + * + * @since 5.0 + */ + +/** + * @file UsbTypes.idl + * + * @brief Defines the data used by the usb module, including the usb information, + * and reported usb data. + * + * @since 5.0 + * @version 1.0 + */ + +package ohos.hdi.usb.v1_1; + +import ohos.hdi.usb.v1_0.UsbTypes; + +/** + * @brief Defines the ControlTransfer Params, which is used by {@link IUsbInterface::ControlTransferReadwithLength}. + * @since 5.0 + * @version 1.0 + */ +struct UsbCtrlTransferParams { + /** + * request type + * @since 5.0 + * @version 1.0 + */ + int requestType; + /** + * request cmd + * @since 5.0 + * @version 1.0 + */ + int requestCmd; + /** + * value + * @since 5.0 + * @version 1.0 + */ + int value; + /** + * index + * @since 5.0 + * @version 1.0 + */ + int index; + /** + * length + * @since 5.0 + * @version 1.0 + */ + int length; + /** + * timeout + * @since 5.0 + * @version 1.0 + */ + int timeout; +}; diff --git a/usb/v1_2/BUILD.gn b/usb/v1_2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..243297f42227754250d44eb8147e377dafe2d1d6 --- /dev/null +++ b/usb/v1_2/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (c) 2025 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. + +import("//build/config/components/hdi/hdi.gni") +if (defined(ohos_lite)) { + group("libusb_proxy_1.2") { + deps = [] + public_configs = [] + } +} else { + hdi("usb") { + module_name = "usbd" + imports = [ "ohos.hdi.usb.v1_1:usb" ] + + sources = [ + "IUsbInterface.idl", + "IUsbdTransferCallback.idl", + "UsbTypes.idl", + ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_usb" + } +} diff --git a/usb/v1_2/IUsbInterface.idl b/usb/v1_2/IUsbInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..3618d5cc42498f470d16d5e12345fced54cb06cf --- /dev/null +++ b/usb/v1_2/IUsbInterface.idl @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2025 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 HdiUsb + * + * @brief Provides unified APIs for usb services to access usb drivers. + * + * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to + * access different types of usb devices based on the usb IDs, thereby obtaining usb information, + * subscribing to or unsubscribing from usb data, enabling or disabling a usb, + * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + */ + +/* * + * @file IUsbInterface.idl + * + * @brief Declares the APIs provided by the usb module for obtaining usb information, subscribing to or + * unsubscribing from usb data, enabling or disabling a usb, setting the usb data reporting mode, + * and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.v1_2; + +import ohos.hdi.usb.v1_2.UsbTypes; +import ohos.hdi.usb.v1_2.IUsbdTransferCallback; +import ohos.hdi.usb.v1_1.UsbTypes; +import ohos.hdi.usb.v1_1.IUsbInterface; + +/* * + * @brief Defines the functions for performing basic operations on usb. + * + * The operations include obtaining usb information, subscribing to or unsubscribing from usb data, + * enabling or disabling a usb, setting the usb data reporting mode, and setting usb options such as + * the accuracy and measurement range. + */ +interface IUsbInterface extends ohos.hdi.usb.v1_1.IUsbInterface{ + + /* * + * @brief Submit usb async transfer. + * + * @param dev Indicates the USB device address. + * @param info Indicates the param info of the USB transfer. + * @param cb Indicates the callback function of base. + * @param ashmem Indicates the object of share memory + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + UsbSubmitTransfer([in] struct UsbDev dev, [in] USBTransferInfo info, [in] IUsbdTransferCallback cb, [in] Ashmem ashmem); + + /* * + * @brief Cancels the usb async transfer by endpoint. + * + * @param dev Indicates the USB device address. + * @param endpoint Indicates the endpoint address. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + UsbCancelTransfer([in] struct UsbDev dev, [in] int endpoint); +} \ No newline at end of file diff --git a/usb/v1_2/IUsbdTransferCallback.idl b/usb/v1_2/IUsbdTransferCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..b0eff187c4f7cd26905ded6763d9d8240e3dcac6 --- /dev/null +++ b/usb/v1_2/IUsbdTransferCallback.idl @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 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 HdiUsb + * + * @brief Provides unified APIs for usb services to access usb drivers. + * + * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to + * access different types of usb devices based on the usb IDs, thereby obtaining usb information, + * subscribing to or unsubscribing from usb data, enabling or disabling a usb, + * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. + * + * @version 1.0 + */ + +package ohos.hdi.usb.v1_2; + +import ohos.hdi.usb.v1_2.UsbTypes; + +/** + * @brief Defines the callback for reporting usb data. This callback needs to be registered when + * a usb user subscribes to usb data. Only after the usb is enabled, the usb data subscriber can receive + * usb data. For details, see {@link IUsbInterface}. + * + * @since 5.1 + */ +[callback] interface IUsbdTransferCallback { + + OnTransferWriteCallback([in] int status, [in] int actLength, [in] UsbIsoPacketDescriptor[] descs, [in] unsigned long userData); + + OnTransferReadCallback([in] int status, [in] int actLength, [in] UsbIsoPacketDescriptor[] descs, [in] unsigned long userData); + +} \ No newline at end of file diff --git a/usb/v1_2/UsbTypes.idl b/usb/v1_2/UsbTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..5fd57896b8b4b2b12fb0a200bd81346d13dff9ab --- /dev/null +++ b/usb/v1_2/UsbTypes.idl @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 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 HdiUsb + * + * @brief Provides unified APIs for usb services to access usb drivers. + * + * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to + * access different types of usb devices based on the usb IDs, thereby obtaining usb information, + * subscribing to or unsubscribing from usb data, enabling or disabling a usb, + * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + */ + +/** + * @file UsbTypes.idl + * + * @brief Defines the data used by the usb module, including the usb information, + * and reported usb data. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.v1_2; + +import ohos.hdi.usb.v1_1.UsbTypes; + +struct UsbIsoPacketDescriptor { + int isoLength; + int isoActualLength; + int isoStatus; +}; + +struct USBTransferInfo { + int endpoint; + int flags; + int type; + int timeOut; + int length; + unsigned long userData; + unsigned int numIsoPackets; +}; \ No newline at end of file diff --git a/usb/v2_0/BUILD.gn b/usb/v2_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4cec6d1612d169a40033692908b1141139970c0f --- /dev/null +++ b/usb/v2_0/BUILD.gn @@ -0,0 +1,38 @@ +# Copyright (c) 2025 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. + +import("//build/config/components/hdi/hdi.gni") +if (defined(ohos_lite)) { + group("libusb_proxy_2.0") { + deps = [] + public_configs = [] + } +} else { + hdi("usb") { + module_name = "usbd" + + sources = [ + "IUsbDeviceInterface.idl", + "IUsbHostInterface.idl", + "IUsbPortInterface.idl", + "IUsbdBulkCallback.idl", + "IUsbdSubscriber.idl", + "IUsbdTransferCallback.idl", + "UsbTypes.idl", + ] + + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_usb" + } +} diff --git a/usb/v2_0/IUsbDeviceInterface.idl b/usb/v2_0/IUsbDeviceInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..1b3c9244d04a6b3721aaefb9c9fb6d022fbf87c8 --- /dev/null +++ b/usb/v2_0/IUsbDeviceInterface.idl @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2025 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 HdiUsb + * @{ + * + * @brief Provides unified APIs for usb services to access usb drivers. + * + * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to + * access different types of usb devices based on the usb IDs, thereby obtaining usb information, + * subscribing to or unsubscribing from usb data, enabling or disabling a usb, + * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.v2_0; + +import ohos.hdi.usb.v2_0.IUsbdSubscriber; + +interface IUsbDeviceInterface { + + /* * + * @brief Obtains the list of functions (represented by bit field) supported by the current device. + * + * @param funcs Indicates the list of functions supported by the current device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + GetCurrentFunctions([out] int funcs); + + /* * + * @brief Sets the list of functions (represented by bit field) supported by the current device. + * + * @param funcs Indicates the list of functions supported by the current device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + SetCurrentFunctions([in] int funcs); + + /* * + * @brief Get Accessory Strings. + * + * @param accessoryInfo Indicates the accessory information. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + GetAccessoryInfo([out] String[] accessoryInfo); + + /* * + * @brief open the accessory. + * + * @param fd accessory file descriptor + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + OpenAccessory([out] FileDescriptor fd); + + /* * + * @brief close the accessory. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + CloseAccessory([in] FileDescriptor fd); + + /* * + * @brief Binds a subscriber. + * + * @param subscriber Indicates the subscriber. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + BindUsbdDeviceSubscriber([in] IUsbdSubscriber subscriber); + + /* * + * @brief Unbinds a subscriber. + * + * @param subscriber Indicates the subscriber. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + UnbindUsbdDeviceSubscriber([in] IUsbdSubscriber subscriber); +} \ No newline at end of file diff --git a/usb/v2_0/IUsbHostInterface.idl b/usb/v2_0/IUsbHostInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..451e9c9739c39b82aff1962aaf0f399d58979812 --- /dev/null +++ b/usb/v2_0/IUsbHostInterface.idl @@ -0,0 +1,591 @@ +/* + * Copyright (c) 2025 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 HdiUsb + * @{ + * + * @brief Provides unified APIs for usb services to access usb drivers. + * + * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to + * access different types of usb devices based on the usb IDs, thereby obtaining usb information, + * subscribing to or unsubscribing from usb data, enabling or disabling a usb, + * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.0 + */ + +/* * + * @file IUsbHostInterface.idl + * + * @brief Declares the APIs provided by the usb module for obtaining usb information, subscribing to or + * unsubscribing from usb data, enabling or disabling a usb, setting the usb data reporting mode, + * and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.v2_0; + +import ohos.hdi.usb.v2_0.UsbTypes; +import ohos.hdi.usb.v2_0.IUsbdSubscriber; +import ohos.hdi.usb.v2_0.IUsbdBulkCallback; +import ohos.hdi.usb.v2_0.IUsbdTransferCallback; + +/* * + * @brief Defines the functions for performing basic operations on usb. + * + * The operations include obtaining usb information, subscribing to or unsubscribing from usb data, + * enabling or disabling a usb, setting the usb data reporting mode, and setting usb options such as + * the accuracy and measurement range. + */ +interface IUsbHostInterface { + + /* * + * @brief Opens a USB device to set up a connection. + * + * @param dev Indicates the USB device address. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + OpenDevice([in] struct UsbDev dev); + + /* * + * @brief Closes a USB device to release all system resources related to the device. + * + * @param dev Indicates the USB device address. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + CloseDevice([in] struct UsbDev dev); + + /* * + * @brief Reset device. + * + * @param dev Indicates the USB device address. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + ResetDevice([in] struct UsbDev dev); + + /* * + * @brief Claims a USB interface exclusively. This must be done before data transfer. + * + * @param dev Indicates the USB device address. + * @param interfaceid Indicates the interface ID of the USB device. + * @param force Indicates whether to enable the force mode. The value 1 indicates that the force mode is + * enabled, and value 0 indicates the opposite. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + ClaimInterface([in] struct UsbDev dev, [in] unsigned char interfaceid, [in] unsigned char force); + + /* * + * @brief Sets the alternate settings for the specified USB interface. This allows you to switch between two + * interfaces with the same ID but different alternate settings. + * + * @param dev Indicates the USB device address. + * @param interfaceid Indicates the interface ID of the USB device. + * @param altIndex Indicates the alternate settings of the USB interface. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + SetInterface([in] struct UsbDev dev, [in] unsigned char interfaceid, [in] unsigned char altIndex); + + /* * + * @brief Releases a USB interface. This is usually done after data transfer. + * + * @param dev Indicates the USB device address. + * @param interfaceid Indicates the interface ID of the USB device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + ReleaseInterface([in] struct UsbDev dev, [in] unsigned char interfaceid); + + /* * + * @brief Sets the configuration information of a USB device. + * + * @param dev Indicates the USB device address. + * @param configIndex Indicates the configuration information of the USB device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + SetConfig([in] struct UsbDev dev, [in] unsigned char configIndex); + + /* * + * @brief Manage a USB interface exclusively. Detach or attach the interface. + * + * @param dev Indicates the USB device address. + * @param interfaceid Indicates the interface ID of the USB device. + * @param disable Indicates whether to disable the interface. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + ManageInterface([in] struct UsbDev dev, [in] unsigned char interfaceid, [in] boolean disable); + + /* * + * @brief Clear the halt status for an endpoint. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + ClearHalt([in] struct UsbDev dev, [in] struct UsbPipe pipe); + + /* * + * @brief Obtains USB device speed. + * + * @param dev Indicates the USB device address. + * @param speed Indicates the USB device speed. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + GetDeviceSpeed([in] struct UsbDev dev, [out] unsigned char speed); + + /* * + * @brief Obtains the file descriptor. + * + * @param dev Indicates the USB device address. + * @param fd USB device file descriptor + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + GetDeviceFileDescriptor([in] struct UsbDev dev, [out] FileDescriptor fd); + + /* * + * @brief Obtains the string descriptor of a USB device based on the specified string ID. + * + * @param dev Indicates the USB device address. + * @param descId Indicates string descriptor ID. + * @param descriptor Indicates the configuration descriptor of the USB device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + GetStringDescriptor([in] struct UsbDev dev, [in] unsigned char descId, [out] unsigned char[] descriptor); + + /* * + * @brief Obtains the raw descriptor. + * + * @param dev Indicates the USB device address. + * @param descriptor Indicates the raw descriptor of the USB device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + GetRawDescriptor([in] struct UsbDev dev, [out] unsigned char[] descriptor); + + /* * + * @brief Obtains the configuration information of a USB device. + * + * @param dev Indicates the USB device address. + * @param configIndex Indicates the configuration information of the USB device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + GetConfig([in] struct UsbDev dev, [out] unsigned char configIndex); + + /* * + * @brief Obtain the activation information of the USB device interface. + * + * @param dev Indicates the USB device address. + * @param interfaceid Indicates the interface ID of the USB device. + * @param unactivated Indicates whether the interface unactivated. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + GetInterfaceActiveStatus([in] struct UsbDev dev, [in] unsigned char interfaceid, [out] boolean unactivated ); + + /* * + * @brief Obtains the USB device descriptor. + * + * @param dev Indicates the USB device address. + * @param descriptor Indicates the USB device descriptor. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + GetDeviceDescriptor([in] struct UsbDev dev, [out] unsigned char[] descriptor); + + /* * + * @brief Obtains the configuration descriptor of a USB device based on the specified config ID. + * + * @param dev Indicates the USB device address. + * @param descId Indicates configuration descriptor ID. + * @param descriptor Indicates the configuration descriptor of the USB device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + GetConfigDescriptor([in] struct UsbDev dev, [in] unsigned char descId, [out] unsigned char[] descriptor); + + /* * + * @brief Obtains the file descriptor. + * + * @param dev Indicates the USB device address. + * @param fd USB device file descriptor + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + * @deprecated since 5.1 + * @useinstead ohos.hdi.usb.v2_0.IUsbInterface.GetDeviceFileDescriptor + */ + GetFileDescriptor([in] struct UsbDev dev, [out] int fd); + + /* * + * @brief Sends or receives requests for isochronous transfer on a specified endpoint. The data transfer direction + * is determined by the endpoint direction. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * @param clientData Indicates the client data. + * @param buffer Indicates the transferred data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + RequestQueue([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] unsigned char[] clientData, [in] unsigned char[] buffer); + + /* * + * @brief Waits for the operation result of the isochronous transfer request in RequestQueue. + * + * @param dev Indicates the USB device address. + * @param clientData Indicates the client data. + * @param buffer Indicates the transferred data. + * @param timeout Indicates the timeout duration. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + RequestWait([in] struct UsbDev dev, [out] unsigned char[] clientData, [out] unsigned char[] buffer, [in] int timeout); + + /* * + * @brief Cancels the data transfer requests to be processed. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + RequestCancel([in] struct UsbDev dev, [in] struct UsbPipe pipe); + + /* * + * @brief Reads data on a specified endpoint during bulk transfer. The endpoint must be in the data reading + * direction. You can specify a timeout duration if needed. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * @param timeout Indicates the timeout duration. + * @param data Indicates the read data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + * @deprecated since 5.1 + * @useinstead ohos.hdi.usb.v2_0.IUsbInterface.BulkTransferReadwithLength + */ + BulkTransferRead([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [out] unsigned char[] data); + + /* * + * @brief Writes data on a specified endpoint during bulk transfer. The endpoint must be in the data writing + * direction. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * @param timeout Indicates the timeout duration. + * @param data Indicates the written data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + BulkTransferWrite([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] unsigned char[] data); + + /* * + * @brief Reads data on a specified endpoint during bulk transfer. The endpoint must be in the data reading + * direction. You can specify a timeout duration if needed. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * @param timeout Indicates the timeout duration. + * @param length the maximum number of bytes to receive into the data buffer. + * @param data Indicates the read data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + BulkTransferReadwithLength([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] int length, [out] unsigned char[] data); + + /* * + * @brief Registers a callback for isochronous bulk transfer. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * @param cb Indicates the reference to the callback. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + RegBulkCallback([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] IUsbdBulkCallback cb); + + /* * + * @brief Unregisters the callback for isochronous bulk transfer. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + UnRegBulkCallback([in] struct UsbDev dev, [in] struct UsbPipe pipe); + + /* * + * @brief Reads data during isochronous bulk transfer. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * @param ashmem Indicates the shared memory, which is used to store the read data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + BulkRead([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] Ashmem ashmem); + + /* * + * @brief Writes data during isochronous bulk transfer. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * @param ashmem Indicates the shared memory, which is used to store the written data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + BulkWrite([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] Ashmem ashmem); + + /* * + * @brief Cancels the isochronous bulk transfer. The read and write operations on the current USB interface will + * be cancelled. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + BulkCancel([in] struct UsbDev dev, [in] struct UsbPipe pipe); + + /* * + * @brief Performs control transfer for endpoint 0 of the device. The data transfer direction is determined by the + * request type. If the result of requestType& + * USB_ENDPOINT_DIR_MASK is USB_DIR_OUT, the endpoint is in the data writing direction; if the result + * is USB_DIR_IN, the endpoint is in the data reading direction. + * + * @param dev Indicates the USB device address. + * @param ctrl Indicates the control data packet structure. + * @param data Indicates the read data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + * @deprecated since 5.1 + * @useinstead ohos.hdi.usb.v2_0.IUsbInterface.ControlTransferReadwithLength + */ + ControlTransferRead([in] struct UsbDev dev, [in] struct UsbCtrlTransfer ctrl, [out] unsigned char[] data); + + /* * + * @brief Performs control transfer for endpoint 0 of the device. The data transfer direction is determined by the + * request type. If the result of requestType& + * USB_ENDPOINT_DIR_MASK is USB_DIR_OUT, the endpoint is in the data writing direction; if the result + * is USB_DIR_IN, the endpoint is in the data writing direction. + * + * @param dev Indicates the USB device address. + * @param ctrl Indicates the control data packet structure. + * @param data Indicates the write data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + ControlTransferWrite([in] struct UsbDev dev, [in] struct UsbCtrlTransfer ctrl, [in] unsigned char[] data); + + /* * + * @brief Performs control transfer for endpoint 0 of the device. The data transfer direction is determined by the + * request type. If the result of requestType& + * USB_ENDPOINT_DIR_MASK is USB_DIR_OUT, the endpoint is in the data writing direction; if the result + * is USB_DIR_IN, the endpoint is in the data reading direction. + * + * @param dev Indicates the USB device address. + * @param ctrl Indicates the control data packet structure. + * @param data Indicates the read data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + ControlTransferReadwithLength([in] struct UsbDev dev, [in] struct UsbCtrlTransferParams ctrl, [out] unsigned char[] data); + + /* * + * @brief Reads data on a specified endpoint during interrupt transfer. The endpoint must be in the data reading + * direction. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * @param timeout Indicates the timeout duration. + * @param data Indicates the read data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + InterruptTransferRead([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [out] unsigned char[] data); + + /* * + * @brief Writes data on a specified endpoint during interrupt transfer. The endpoint must be in the data writing + * direction. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * @param timeout Indicates the timeout duration. + * @param data Indicates the read data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + InterruptTransferWrite([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] unsigned char[] data); + + /* * + * @brief Reads data on a specified endpoint during isochronous transfer. The endpoint must be in the data reading + * direction. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * @param timeout Indicates the timeout duration. + * @param data Indicates the read data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + IsoTransferRead([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [out] unsigned char[] data); + + /* * + * @brief Writes data on a specified endpoint during isochronous transfer. The endpoint must be in the data writing + * direction. + * + * @param dev Indicates the USB device address. + * @param pipe Indicates the pipe of the USB device. + * @param timeout Indicates the timeout duration. + * @param data Indicates the read data. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + IsoTransferWrite([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, [in] unsigned char[] data); + + /* * + * @brief Binds a subscriber. + * + * @param subscriber Indicates the subscriber. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + BindUsbdHostSubscriber([in] IUsbdSubscriber subscriber); + + /* * + * @brief Unbinds a subscriber. + * + * @param subscriber Indicates the subscriber. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + UnbindUsbdHostSubscriber([in] IUsbdSubscriber subscriber); + + /* * + * @brief Submit usb async transfer. + * + * @param dev Indicates the USB device address. + * @param info Indicates the param info of the USB transfer. + * @param cb Indicates the callback function of base. + * @param ashmem Indicates the object of share memory + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + UsbSubmitTransfer([in] struct UsbDev dev, [in] USBTransferInfo info, [in] IUsbdTransferCallback cb, [in] Ashmem ashmem); + + /* * + * @brief Cancels the usb async transfer by endpoint. + * + * @param dev Indicates the USB device address. + * @param endpoint Indicates the endpoint address. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + UsbCancelTransfer([in] struct UsbDev dev, [in] int endpoint); +} \ No newline at end of file diff --git a/usb/v2_0/IUsbPortInterface.idl b/usb/v2_0/IUsbPortInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..b647ddfcab531197f14f0e7ba6a4500f5335bcbf --- /dev/null +++ b/usb/v2_0/IUsbPortInterface.idl @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2025 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 HdiUsb + * @{ + * + * @brief Provides unified APIs for usb services to access usb drivers. + * + * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to + * access different types of usb devices based on the usb IDs, thereby obtaining usb information, + * subscribing to or unsubscribing from usb data, enabling or disabling a usb, + * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.0 + */ + +/* * + * @file IUsbPortInterface.idl + * + * @brief Declares the APIs provided by the usb module for obtaining usb information, subscribing to or + * unsubscribing from usb data, enabling or disabling a usb, setting the usb data reporting mode, + * and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.v2_0; + +import ohos.hdi.usb.v2_0.UsbTypes; +import ohos.hdi.usb.v2_0.IUsbdSubscriber; + +interface IUsbPortInterface { + + /* * + * @brief Set the USB port role and data role. + * + * @param portId Indicates the port ID of the USB interface. + * @param powerRole Indicates the power role. + * @param dataRole Indicates the data role. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + SetPortRole([in] int portId, [in] int powerRole, [in] int dataRole); + + /* * + * @brief Queries the current settings of a port. + * + * @param portId Indicates the port ID of the USB interface. + * @param powerRole Indicates the power role. + * @param dataRole Indicates the data role. + * @param mode Indicates the mode. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + QueryPort([out] int portId, [out] int powerRole, [out] int dataRole, [out] int mode); + + /* * + * @brief Queries the current settings of all ports. + * + * @param portList Indicates the ports ID of the USB interface. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + QueryPorts([out] struct UsbPort[] portList); + + /* * + * @brief Binds a subscriber. + * + * @param subscriber Indicates the subscriber. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + BindUsbdPortSubscriber([in] IUsbdSubscriber subscriber); + + /* * + * @brief Unbinds a subscriber. + * + * @param subscriber Indicates the subscriber. + * + * @return Returns 0 if the operation is successful; returns a non-0 value if the operation fails. + * @since 5.1 + * @version 1.0 + */ + UnbindUsbdPortSubscriber([in] IUsbdSubscriber subscriber); +} \ No newline at end of file diff --git a/usb/v2_0/IUsbdBulkCallback.idl b/usb/v2_0/IUsbdBulkCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..7731c0f6169802c0af21786dab6a8f8631318133 --- /dev/null +++ b/usb/v2_0/IUsbdBulkCallback.idl @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 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 HdiUsb + * @{ + * + * @brief Provides unified APIs for usb services to access usb drivers. + * + * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to + * access different types of usb devices based on the usb IDs, thereby obtaining usb information, + * subscribing to or unsubscribing from usb data, enabling or disabling a usb, + * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.v2_0; + +/** + * @brief Defines the callback for reporting usb data. This callback needs to be registered when + * a usb user subscribes to usb data. Only after the usb is enabled, the usb data subscriber can receive + * usb data. For details, see {@link IUsbHostInterface}. + * + * @since 5.1 + * @version 1.0 + */ +[callback] interface IUsbdBulkCallback { + + OnBulkWriteCallback([in] int status, [in] int actLength); + + OnBulkReadCallback([in] int status, [in] int actLength); + +} \ No newline at end of file diff --git a/usb/v2_0/IUsbdSubscriber.idl b/usb/v2_0/IUsbdSubscriber.idl new file mode 100644 index 0000000000000000000000000000000000000000..a78a953e0ced36877e9353bf9d30bef6faa0abed --- /dev/null +++ b/usb/v2_0/IUsbdSubscriber.idl @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 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 HdiUsb + * @{ + * + * @brief Provides unified APIs for usb services to access usb drivers. + * + * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to + * access different types of usb devices based on the usb IDs, thereby obtaining usb information, + * subscribing to or unsubscribing from usb data, enabling or disabling a usb, + * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.v2_0; + +import ohos.hdi.usb.v2_0.UsbTypes; + +/** + * @brief Defines the callback for reporting usb data. This callback needs to be registered when + * a usb user subscribes to usb data. Only after the usb is enabled, the usb data subscriber can receive + * usb data. For details, see {@link IUsbInterface}. + * + * @since 5.1 + * @version 1.0 + */ +[callback] interface IUsbdSubscriber { + + DeviceEvent([in] struct USBDeviceInfo info); + + PortChangedEvent([in] struct PortInfo info); + +} \ No newline at end of file diff --git a/usb/v2_0/IUsbdTransferCallback.idl b/usb/v2_0/IUsbdTransferCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..2e91aff5ede33b70b439ea7c45204f9cd75ef5a4 --- /dev/null +++ b/usb/v2_0/IUsbdTransferCallback.idl @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 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 HdiUsb + * + * @brief Provides unified APIs for usb services to access usb drivers. + * + * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to + * access different types of usb devices based on the usb IDs, thereby obtaining usb information, + * subscribing to or unsubscribing from usb data, enabling or disabling a usb, + * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.v2_0; + +import ohos.hdi.usb.v2_0.UsbTypes; + +/** + * @brief Defines the callback for reporting usb data. This callback needs to be registered when + * a usb user subscribes to usb data. Only after the usb is enabled, the usb data subscriber can receive + * usb data. For details, see {@link IUsbInterface}. + * + * @since 5.1 + * @version 1.0 + */ +[callback] interface IUsbdTransferCallback { + + OnTransferWriteCallback([in] int status, [in] int actLength, [in] UsbIsoPacketDescriptor[] descs, [in] unsigned long userData); + + OnTransferReadCallback([in] int status, [in] int actLength, [in] UsbIsoPacketDescriptor[] descs, [in] unsigned long userData); + +} \ No newline at end of file diff --git a/usb/v2_0/UsbTypes.idl b/usb/v2_0/UsbTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..a124a0316ee2b7d10a939d88dbcbfa92f8af5775 --- /dev/null +++ b/usb/v2_0/UsbTypes.idl @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2025 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 HdiUsb + * @ + * + * @brief Provides unified APIs for usb services to access usb drivers. + * + * A usb service can obtain a usb driver object or agent and then call APIs provided by this object or agent to + * access different types of usb devices based on the usb IDs, thereby obtaining usb information, + * subscribing to or unsubscribing from usb data, enabling or disabling a usb, + * setting the usb data reporting mode, and setting usb options such as the accuracy and measurement range. + * + * @since 5.1 + * @version 1.0 + */ + +/** + * @file UsbTypes.idl + * + * @brief Defines the data used by the usb module, including the usb information, + * and reported usb data. + * + * @since 5.1 + * @version 1.0 + */ + +package ohos.hdi.usb.v2_0; + +/** + * @brief Defines the ControlTransfer Params, which is used by {@link IUsbHostInterface::ControlTransferReadwithLength}. + * @since 5.1 + * @version 1.0 + */ +struct UsbCtrlTransferParams { + int requestType; + int requestCmd; + int value; + int index; + int length; + int timeout; +}; + +/** + * @brief Defines the UsbDev Params. + * @since 5.1 + * @version 1.0 + */ +struct UsbDev { + unsigned char busNum; + unsigned char devAddr; +}; + +/** + * @brief Defines the UsbPipe Params. + * @since 5.1 + * @version 1.0 + */ +struct UsbPipe { + unsigned char intfId; + unsigned char endpointId; +}; + +/** + * @brief Defines the UsbCtrlTransfer Params. + * @since 5.1 + * @version 1.0 + */ +struct UsbCtrlTransfer { + int requestType; + int requestCmd; + int value; + int index; + int timeout; +}; + +/** + * @brief Defines the USBDeviceInfo Params. + * @since 5.1 + * @version 1.0 + */ +struct USBDeviceInfo { + int status; + int busNum; + int devNum; +}; + +/** + * @brief Defines the RoleCombinations Params. + * @since 5.1 + * @version 1.0 + */ +struct RoleCombinations { + int powerRole; + int dataRole; +}; + +/** + * @brief Defines the PortInfo Params. + * @since 5.1 + * @version 1.0 + */ +struct PortInfo { + int portId; + int powerRole; + int dataRole; + int mode; +}; + +/** + * @brief Defines the UsbPortStatus Params. + * @since 5.1 + * @version 1.0 + */ +struct UsbPortStatus { + int currentMode; + int currentPowerRole; + int currentDataRole; + int isConnected; + RoleCombinations[] supportedRoleCombinations; +}; + +/** + * @brief Defines the UsbPort Params. + * @since 5.1 + * @version 1.0 + */ +struct UsbPort { + int id; + int supportedModes; + UsbPortStatus usbPortStatus; +}; + +/** + * @brief Defines the USB iso packet descriptor params. + * @since 5.1 + * @version 1.0 + */ +struct UsbIsoPacketDescriptor { + int isoLength; + int isoActualLength; + int isoStatus; +}; + +/** + * @brief Defines the USB transferInfo Params. + * @since 5.1 + * @version 1.0 + */ +struct USBTransferInfo { + int endpoint; + int flags; + int type; + int timeOut; + int length; + unsigned long userData; + unsigned int numIsoPackets; +}; diff --git a/user_auth/bundle.json b/user_auth/bundle.json index 76397b4e7cf755cd127963112e5bb025d0c4b99f..be38876309be1f1aa4074303622ae6dbaea7171c 100644 --- a/user_auth/bundle.json +++ b/user_auth/bundle.json @@ -1,7 +1,7 @@ { "name":"@ohos/drivers_interface_user_auth", "description":"user_auth device driver", - "version":"5.0", + "version":"5.1", "license":"Apache License 2.0", "publishAs":"code-segment", "segment":{ @@ -35,14 +35,14 @@ }, "build":{ "sub_component":[ - "//drivers/interface/user_auth/v2_0:user_auth_idl_target" + "//drivers/interface/user_auth/v3_0:user_auth_idl_target" ], "test":[ ], "inner_kits":[ { - "name":"//drivers/interface/user_auth/v2_0:libuser_auth_proxy_2.0", + "name":"//drivers/interface/user_auth/v3_0:libuser_auth_proxy_3.0", "header":{ "header_files":[ @@ -51,16 +51,16 @@ } }, { - "name":"//drivers/interface/user_auth/v2_0:user_auth_idl_headers", + "name":"//drivers/interface/user_auth/v3_0:user_auth_idl_headers", "header":{ "header_files":[ ], - "header_base":"//drivers/interfaces/user_auth" + "header_base":"//drivers/interface/user_auth" } }, { - "name":"//drivers/interface/user_auth/v2_0:libuser_auth_stub_2.0", + "name":"//drivers/interface/user_auth/v3_0:libuser_auth_stub_3.0", "header":{ "header_files":[ diff --git a/user_auth/v1_0/BUILD.gn b/user_auth/v1_0/BUILD.gn index 3d074099997fcf50831ed4f24e14620597f28147..d069cc08d1a70f3bdf0d0a941649797dbf0c1d7f 100644 --- a/user_auth/v1_0/BUILD.gn +++ b/user_auth/v1_0/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") import("../config.gni") hdi("user_auth") { diff --git a/user_auth/v1_1/BUILD.gn b/user_auth/v1_1/BUILD.gn index bba7ef617c2120609e3e08f45f6ce730eaea7ed0..76961d43d76be76e64d4b0120457e8c9f005be93 100644 --- a/user_auth/v1_1/BUILD.gn +++ b/user_auth/v1_1/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") import("../config.gni") hdi("user_auth") { diff --git a/user_auth/v1_2/BUILD.gn b/user_auth/v1_2/BUILD.gn index 06eb6782d41ed297b02c255da55222a95e8fce59..f5d7ccbc24b2ba8714f2ff5ebeb1a020f0247124 100644 --- a/user_auth/v1_2/BUILD.gn +++ b/user_auth/v1_2/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") import("../config.gni") hdi("user_auth") { diff --git a/user_auth/v1_3/BUILD.gn b/user_auth/v1_3/BUILD.gn index 2d2d577ac44dc92c43d815437c5e4dfaa3a1a4a9..961120384e4b13b14e38947e3a68cfc6c63445e0 100644 --- a/user_auth/v1_3/BUILD.gn +++ b/user_auth/v1_3/BUILD.gn @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +import("//build/config/components/hdi/hdi.gni") import("../config.gni") hdi("user_auth") { diff --git a/user_auth/v2_0/UserAuthTypes.idl b/user_auth/v2_0/UserAuthTypes.idl index 4dd0de81b760bfeff422ec82029e5ce78765ce67..793504a643abe187cfaa73ad5b55abff3a41e3f4 100644 --- a/user_auth/v2_0/UserAuthTypes.idl +++ b/user_auth/v2_0/UserAuthTypes.idl @@ -247,6 +247,8 @@ struct AuthResultInfo { long pinExpiredInfo; /**< Remote auth result message. */ unsigned char[] remoteAuthResultMsg; + /**< Re-enroll flag. */ + boolean reEnrollFlag; }; /** diff --git a/user_auth/v3_0/BUILD.gn b/user_auth/v3_0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..093bd01bfe2ac20c01de3c9c5e1ee17a9aaa18d5 --- /dev/null +++ b/user_auth/v3_0/BUILD.gn @@ -0,0 +1,27 @@ +# Copyright (c) 2024 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. + +import("//build/config/components/hdi/hdi.gni") +import("../config.gni") + +hdi("user_auth") { + module_name = "drivers_peripheral_user_auth" + sources = [ + "IMessageCallback.idl", + "IUserAuthInterface.idl", + "UserAuthTypes.idl", + ] + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_user_auth" +} diff --git a/user_auth/v3_0/IMessageCallback.idl b/user_auth/v3_0/IMessageCallback.idl new file mode 100644 index 0000000000000000000000000000000000000000..83d48783d394c64277fcee3f3928a21138979cc7 --- /dev/null +++ b/user_auth/v3_0/IMessageCallback.idl @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 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 HdfUserAuth + * @{ + * + * @brief Provides APIs for the user_auth driver. + * + * The user_auth driver provides a unified interface for the user_auth service to access the user_auth driver. + * After obtaining the user_auth driver proxy, the service can call related APIs to register executors, + * manage credentials, and complete password and biometric authentication. + * @since 5.0 + * @version 1.0 + */ + +/** + * @file IMessageCallback.idl + * + * @brief Defines the callback for an async API, which can be used to send message to framework. + * + * @since 5.0 + * @version 1.0 + */ + +package ohos.hdi.user_auth.v3_0; + +/** + * @brief Defines the callback for an async API, which can be used to send message to framework. + * + * @since 5.0 + * @version 1.0 + */ +[callback] interface IMessageCallback { + /** + * @brief Defines the function for reporting message. + * + * @param scheduleId Indicates the schedule ID of the message. + * @param destRole is the role of destination. + * @param msg is the message content. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + */ + OnMessage([in] unsigned long scheduleId, [in] int destRole, [in] unsigned char[] msg); +} +/** @} */ \ No newline at end of file diff --git a/user_auth/v3_0/IUserAuthInterface.idl b/user_auth/v3_0/IUserAuthInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..6feacf88f3e3a8790d89fd59d8f8945d9dd1dd41 --- /dev/null +++ b/user_auth/v3_0/IUserAuthInterface.idl @@ -0,0 +1,529 @@ +/* + * Copyright (c) 2024 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 HdfUserAuth + * @{ + * + * @brief Provides APIs for the user_auth driver. + * + * The user_auth driver provides a unified interface for the user_auth service to access the user_auth driver. + * After obtaining the user_auth driver proxy, the service can call related APIs to register executors, + * manage credentials, and complete password and biometric authentication. + * @since 3.2 + * @version 1.0 + */ + +/** + * @file IUserAuthInterface.idl + * + * @brief Declares the user_auth driver APIs, which can be used to register executors, + * manage credentials, and complete password and biometric authentication. + * + * @since 3.2 + * @version 1.0 + */ + +package ohos.hdi.user_auth.v3_0; + +import ohos.hdi.user_auth.v3_0.UserAuthTypes; +import ohos.hdi.user_auth.v3_0.IMessageCallback; + +/** + * @brief Declares the APIs of the user_auth driver. + * + * @since 3.2 + * @version 1.0 + */ +interface IUserAuthInterface { + /** + * @brief Initializes the cache information of the user_auth driver. + * + * @param deviceUdid Indicates the device udid. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 2.0 + */ + Init([in] String deviceUdid); + /** + * @brief Adds an authentication executor to obtain the authentication capability. + * + * @param info Indicates executor registration information. See {@link ExecutorRegisterInfo}. + * @param index Indicates the executor index under the authentication framework. + * @param publicKey Indicates the public key of the authentication framework. + * @param templateIds Indicates template IDs enrolled by the executors. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + AddExecutor([in] struct ExecutorRegisterInfo info, [out] unsigned long index, + [out] unsigned char[] publicKey, [out] unsigned long[] templateIds); + /** + * @brief Deletes an executor. + * + * @param index Indicates the executor index under the authentication framework. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + DeleteExecutor([in] unsigned long index); + /** + * @brief Opens a session for authentication credential management. + * + * @param userId Indicates the user ID. + * @param challenge Indicates the random number, which is used to generate an authentication token. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + OpenSession([in] int userId, [out] unsigned char[] challenge); + /** + * @brief Closes the authentication credential management session. + * + * @param userId Indicates the user ID. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + CloseSession([in] int userId); + /** + * @brief Updates the enrollment result and completes the enrollment. + * + * @param userId Indicates the user ID. + * @param scheduleResult Indicates the enrollment result issued by the executor. + * @param info Indicates the enrollment result. See {@link EnrollResultInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + UpdateEnrollmentResult([in] int userId, [in] unsigned char[] scheduleResult, [out] struct EnrollResultInfo info); + /** + * @brief Cancels an enrollment. + * + * @param userId Indicates the user ID. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + CancelEnrollment([in] int userId); + /** + * @brief Deletes credential information. + * + * @param userId Indicates the user ID. + * @param credentialId Indicates the credential index. + * @param authToken Indicates the authentication token of the user password. + * @param info Indicates the credential information to delete. See {@link CredentialInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + DeleteCredential([in] int userId, [in] unsigned long credentialId, [in] unsigned char[] authToken, + [out] struct CredentialInfo info); + /** + * @brief Obtains credential information. + * + * @param userId Indicates the user ID. + * @param authType Indicates the authentication type. See {@link AuthType}. + * @param infos Indicates credential information. See {@link CredentialInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 2.0 + */ + GetCredential([in] int userId, [in] int authType, [out] struct CredentialInfo[] infos); + /** + * @brief Obtains user information. + * + * @param userId Indicates the user ID. + * @param secureUid Indicates the secure user ID. + * @param pinSubType Indicates the sub type of PIN authentication. See {@link PinSubType}. + * @param infos Indicates enrolled information. See {@link EnrolledInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 2.0 + */ + GetUserInfo([in] int userId, [out] unsigned long secureUid, [out] int pinSubType, + [out] struct EnrolledInfo[] infos); + /** + * @brief Deletes a pin and a user from the IAM subsystem. + * + * @param userId Indicates the user ID. + * @param authToken Indicates the authentication token of the user password. + * @param deletedInfos Indicates the credential information to delete. See {@link CredentialInfo}. + * @param rootSecret protection key for the user file key. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 2.0 + */ + DeleteUser([in] int userId, [in] unsigned char[] authToken, [out] struct CredentialInfo[] deletedInfos, + [out] unsigned char[] rootSecret); + /** + * @brief Forcibly deletes a user. + * + * @param userId Indicates the user ID. + * @param deletedInfos Indicates the credential information to delete. See {@link CredentialInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + EnforceDeleteUser([in] int userId, [out] struct CredentialInfo[] deletedInfos); + /** + * @brief Updates the authentication result, and evaluates the result of the authentication solution. + * + * @param contextId Indicates the context index. + * @param scheduleResult Indicates the authentication result issued by the executor. + * @param info Indicates authentication result information. See {@link AuthResultInfo}. + * @param enrolledState EnrolledID information. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 2.0 + */ + UpdateAuthenticationResult([in] unsigned long contextId, [in] unsigned char[] scheduleResult, + [out] struct AuthResultInfo info, [out] EnrolledState enrolledState); + /** + * @brief Cancels authentication. + * + * @param contextId Indicates the context index. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + CancelAuthentication([in] unsigned long contextId); + /** + * @brief Updates the identification result, and evaluates the result of the identification solution. + * + * @param contextId Indicates the context index. + * @param scheduleResult Indicates the identification result issued by the executor. + * @param info Indicates identification result information. See {@link IdentifyResultInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + UpdateIdentificationResult([in] unsigned long contextId, [in] unsigned char[] scheduleResult, + [out] struct IdentifyResultInfo info); + /** + * @brief Cancels identification. + * + * @param contextId Indicates the context index. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 1.0 + */ + CancelIdentification([in] unsigned long contextId); + /** + * @brief Check whether the authentication capability is avaliable. + * + * @param userId Indicates the user ID. + * @param authType Indicates the authentication type. See {@link AuthType}. + * @param authTrustLevel Indicates the authentication trust level. + * @param checkResult Indicates check result. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetAvailableStatus([in] int userId, [in] int authType, [in] unsigned int authTrustLevel, [out] int checkResult); + /** + * @brief Obtains the valid authentication methods under the current authentication trust level. + * + * @param userId Indicates the user ID. + * @param authTypes Indicates the authentication types to be filtered. See {@link AuthType}. + * @param authTrustLevel Indicates the authentication trust level. + * @param validTypes Indicates the valid authentication types. See {@link AuthType}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 2.0 + */ + GetValidSolution([in] int userId, [in] int[] authTypes, [in] unsigned int authTrustLevel, + [out] int[] validTypes); + /** + * @brief Begins authentication, and generates the authentication solution. + * + * @param contextId Indicates the context index. + * @param param Indicates input parameters. See {@link AuthParam}. + * @param scheduleInfos Indicates scheduling information. See {@link ScheduleInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 2.0 + */ + BeginAuthentication([in] unsigned long contextId, [in] struct AuthParam param, + [out] struct ScheduleInfo[] scheduleInfos); + /** + * @brief Begins the enrollment of authentication credentials. + * If the authentication type is PIN, this method updates the existing PIN credential. + * + * @param userId Indicates the user ID. + * @param authToken Indicates the authentication token of the user password. + * @param param Indicates input parameters. See {@link EnrollParam}. + * @param info Indicates scheduling information. See {@link ScheduleInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 2.0 + */ + BeginEnrollment([in] unsigned char[] authToken, [in] struct EnrollParam param, + [out] struct ScheduleInfo info); + /** + * @brief Begins identification, and generates the identification solution. + * + * @param contextId Indicates the context index. + * @param authType Indicates the identification type. See @{AuthType}. + * @param challenge Indicates the identification challenge. + * @param executorSensorHint Indicates the executor sensor hint. + * The value 0 indicates that no value is specified. + * @param scheduleInfo Indicates scheduling information. See {@link ScheduleInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 3.2 + * @version 2.0 + */ + BeginIdentification([in] unsigned long contextId, [in] int authType, [in] unsigned char[] challenge, + [in] unsigned int executorSensorHint, [out] struct ScheduleInfo scheduleInfo); + /** + * @brief Get all enrolled user information. + * + * @param userInfos List of all userInfo. See @{UserInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 4.0 + * @version 1.0 + */ + GetAllUserInfo([out] UserInfo[] userInfos); + /** + * @brief Get all credential of enrolled users. + * + * @param userInfos List of all users. See @{ExtUserInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 4.0 + * @version 1.0 + */ + GetAllExtUserInfo([out] ExtUserInfo[] userInfos); + + /** + * @brief Querying EnrolledId information. + * + * @param userId Indicates the user ID. + * @param authType Indicates the identification type. See @{AuthType}. + * @param enrolledState Enrolled state. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetEnrolledState([in] int userId, [in] int authType, [out] struct EnrolledState enrolledState); + + /** + * @brief Check if unlock result can be reused and return token. + * + * @param info Request information of reused unLock result. See {@link ReuseUnlockParam}. + * @param reuseInfo Reuse unlock info. See {@link ReuseUnlockInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + CheckReuseUnlockResult([in] struct ReuseUnlockParam reuseParam, [out] ReuseUnlockInfo reuseInfo); + /** + * @brief Send message. + * + * @param scheduleId Indicates the schedule ID of the message. + * @param srcRole is the role of source. See {@link ExecutorRole}. + * @param msg is the message content. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + SendMessage([in] unsigned long scheduleId, [in] int srcRole, [in] unsigned char[] msg); + /** + * @brief Register message callback. + * + * @param messageCallback Indicates the message callback. See {@link IMessageCallback}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + RegisterMessageCallback([in] IMessageCallback messageCallback); + /** + * @brief Prepare remote auth. + * + * @param remoteUdid Indicates the remote device udid. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + PrepareRemoteAuth([in] String remoteUdid); + /** + * @brief Get local schedule from message. + * + * @param remoteUdid Indicates the remote device udid. + * @param message is message received. + * @param scheduleInfo is schedule info. See {@link ScheduleInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetLocalScheduleFromMessage([in] String remoteUdid, [in] unsigned char[] message, [out] ScheduleInfo scheduleInfo); + /** + * @brief Get signed executor info. + * + * @param authTypes Indicates the auth types. See @{AuthType}. + * @param executorRole Indicates the role of executor. See {@link ExecutorRole}. + * @param remoteUdid Indicates the remote device udid. + * @param signedExecutorInfo Indicates the signed executor info. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetSignedExecutorInfo([in] int[] authTypes, [in] int executorRole, [in] String remoteUdid, + [out] unsigned char[] signedExecutorInfo); + /** + * @brief Get auth result from message. + * + * @param remoteUdid Indicates the remote device udid. + * @param message is message received. + * @param authResultInfo Indicates authentication result information. See {@link AuthResultInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetAuthResultFromMessage([in] String remoteUdid, [in] unsigned char[] message, [out] struct AuthResultInfo authResultInfo); + /** + * @brief Set global config param. + * + * @param param The value of global config parameter. See @{GlobalConfigParam}. + * @return Return set result(0:success; other:failed). + * + * @since 5.0 + * @version 1.0 + */ + SetGlobalConfigParam([in] GlobalConfigParam param); + /** + * @brief Obtains credential information. + * + * @param credentialId Indicates the credential ID. + * @param infos Indicates credential information. See {@link CredentialInfo}. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetCredentialById([in] unsigned long credentialId, [out] struct CredentialInfo info); + /** + * @brief Verify token and return the plainText. + * + * @param tokenIn Token signed by userAuth. + * @param allowableDuration Allowable duration of token. + * @param tokenPlainOut Token plainText. + * @param rootSecret protection key for the user file key. + * + * @return Returns 0 if the operation is successful. + * @return Returns a non-zero value if the operation fails. + * + * @since 5.1 + * @version 1.0 + */ + VerifyAuthToken([in] unsigned char[] tokenIn, [in] unsigned long allowableDuration, + [out] struct UserAuthTokenPlain tokenPlainOut, [out] unsigned char[] rootSecret); + +} +/** @} */ diff --git a/user_auth/v3_0/UserAuthTypes.idl b/user_auth/v3_0/UserAuthTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..f82a50bed9f7d60e8535965765074bdb455fee62 --- /dev/null +++ b/user_auth/v3_0/UserAuthTypes.idl @@ -0,0 +1,576 @@ +/* + * Copyright (c) 2024 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 HdfUserAuth + * @{ + * + * @brief Provides APIs for the user_auth driver. + * + * The user_auth driver provides a unified interface for the user_auth service to access the user_auth driver. + + * + * @since 4.0 + * @version 1.0 + */ + + /** + * @file UserAuthTypes.idl + * + * @brief Defines the enumeration values and data structures of the user_auth driver. + * + * @since 4.0 + * @version 1.0 + */ + +package ohos.hdi.user_auth.v3_0; + + /** + * @brief Enumerates the credential types for authentication. + * + * @since 3.2 + * @version 3.0 + */ +enum AuthType : int { + /**< All types. */ + ALL = 0, + /**< PIN authentication. */ + PIN = 1, + /**< Facial authentication. */ + FACE = 2, + /**< Fingerprint authentication. */ + FINGERPRINT = 4, + /**< Recovery key. */ + RECOVERY_KEY = 8, + /** Private pin authentication. */ + PRIVATE_PIN = 16, +}; + +/** + * @brief Enumerates executor roles. + * + * @since 3.2 + * @version 1.0 + */ +enum ExecutorRole : int { + /**< The executor acts as a collector. */ + COLLECTOR = 1, + /**< The executor acts as a verifier. */ + VERIFIER = 2, + /**< The executor acts as a collector and verifier. */ + ALL_IN_ONE = 3, +}; + +/** + * @brief Enumerates executor security levels. + * + * @since 4.0 + * @version 1.0 + */ +enum ExecutorSecureLevel : int { + /**< ESL0. */ + ESL0 = 0, + /**< ESL1. */ + ESL1 = 1, + /**< ESL2. */ + ESL2 = 2, + /**< ESL3. */ + ESL3 = 3, +}; + +/** + * @brief Defines pin auth's subtype. + * + * @since 3.2 + * @version 3.0 + */ +enum PinSubType : int { + /**< Six digit pin. */ + PIN_SIX = 10000, + /**< Digit pin. */ + PIN_NUMBER = 10001, + /**< Mixing pin. */ + PIN_MIX = 10002, + /**< Four digit pin. */ + PIN_FOUR = 10003, + /**< Pattern. */ + PATTERN = 10004, + /** Password protection question */ + PIN_QUESTION = 10005, +}; + +/** + * Schedule mode. + * + * @since 3.2 + * @version 1.0 + */ +enum ScheduleMode : int { + /**< The schedule mode is enrollment. */ + ENROLL = 0, + /**< The schedule mode is authentication. */ + AUTH = 1, + /**< The schedule mode is identification. */ + IDENTIFY = 2, +}; + +/** + * Auth intent. + * + * @since 5.0 + * @version 2.0 + */ +enum AuthIntent : int { + /**< The auth intent is default. */ + DEFUALT = 0, + /**< The auth intent is unlock. */ + UNLOCK = 1, + /**< The auth intent silent auth. */ + SILENT_AUTH = 2, + /**< The auth intention is question auth. */ + QUESTION_AUTH = 3, +}; + +/** + * @brief User type. + * + * @since 5.0 + * @version 1.0 + */ +enum UserType : int { + /**< main user. */ + MAIN = 0, + /**< sub user. */ + SUB = 1, + /**< private user. */ + PRIVATE = 2, +}; + +/** + * @brief Reuse mode. + * + * @since 5.0 + * @version 2.0 + */ +enum ReuseMode : int { + /**< auth type relevant. */ + AUTH_TYPE_RELEVANT = 1, + /**< auth type irrelevant. */ + AUTH_TYPE_IRRELEVANT = 2, + /**< caller irrelevant and auth type relevant */ + CALLER_IRRELEVANT_AUTH_TYPE_RELEVANT = 3, + /**< caller irrelevant and auth type irrelevant */ + CALLER_IRRELEVANT_AUTH_TYPE_IRRELEVANT = 4, +}; + +/** + * @brief Defines executor registration information. + * + * @since 4.0 + * @version 2.0 + */ +struct ExecutorRegisterInfo { + /**< Authentication type. See @{AuthType}. */ + int authType; + /**< Executor role. See @{ExecutorRole}. */ + int executorRole; + /**< Executor sensor hint under the same authentication type, 0 is not allowed. */ + unsigned int executorSensorHint; + /**< Executor matcher. */ + unsigned int executorMatcher; + /**< Executor secure level. See @{ExecutorSecureLevel}. */ + int esl; + /**< Indicates the max acl of template.*/ + unsigned int maxTemplateAcl; + /**< Public key of the executor. */ + unsigned char[] publicKey; + /**< Device udid. */ + String deviceUdid; + /**< signed remote executor info. */ + unsigned char[] signedRemoteExecutorInfo; +}; + +/** + * @brief Defines executor information. + * + * @since 4.0 + * @version 1.0 + */ +struct ExecutorInfo { + /**< Executor index under the authentication framework. */ + unsigned long executorIndex; + /**< Executor registration information. See @{ExecutorRegisterInfo}. */ + struct ExecutorRegisterInfo info; +}; + +/** + * @brief Defines executor messages. + * + * @since 4.0 + * @version 1.0 + */ +struct ExecutorSendMsg { + /**< Executor index under the authentication framework. */ + unsigned long executorIndex; + /**< Indicates command ID. */ + int commandId; + /**< Executor message to send. */ + unsigned char[] msg; +}; + +/** + * @brief Defines authentication result information. + * + * @since 4.0 + * @version 2.0 + */ +struct AuthResultInfo { + /**< Authentication result. */ + int result; + /**< Lockout duration, in millisecond. */ + int lockoutDuration; + /**< Remaining authentication attempts before a lockout. */ + int remainAttempts; + /**< Executor messages. See @{ExecutorSendMsg}. */ + struct ExecutorSendMsg[] msgs; + /**< Authentication token. */ + unsigned char[] token; + /**< Protection key for the user file key. */ + unsigned char[] rootSecret; + /**< User ID. */ + int userId; + /**< Credential ID. */ + unsigned long credentialId; + /**< Pin expired info. */ + long pinExpiredInfo; + /**< Remote auth result message. */ + unsigned char[] remoteAuthResultMsg; + /**< Re-enroll flag. */ + boolean reEnrollFlag; +}; + +/** + * @brief Defines identification result information. + * + * @since 4.0 + * @version 1.0 + */ +struct IdentifyResultInfo { + /**< iIdentification result. */ + int result; + /**< User ID. */ + int userId; + /**< Identification token. */ + unsigned char[] token; +}; + +/** + * @brief Defines credential information. + * + * @since 4.0 + * @version 2.0 + */ +struct CredentialInfo { + /**< Credential ID. */ + unsigned long credentialId; + /**< Executor index under the authentication framework. */ + unsigned long executorIndex; + /**< Template ID. */ + unsigned long templateId; + /**< Authentication type. See @{AuthType}. */ + int authType; + /**< Executor matcher. */ + unsigned int executorMatcher; + /**< Executor sensor hint under the same authentication type. 0 is not allowed. */ + unsigned int executorSensorHint; + /**< Auth sub type. */ + int authSubType; +}; + +/** + * @brief Defines credential enrollment information. + * + * @since 4.0 + * @version 1.0 + */ +struct EnrolledInfo { + /**< Enrollment ID. */ + unsigned long enrolledId; + /**< Authentication type. See @{AuthType}. */ + int authType; +}; + +/** + * @brief Defines enrollment result information. + * + * @since 4.0 + * @version 1.0 + */ +struct EnrollResultInfo { + /**< Credential ID. */ + unsigned long credentialId; + /**< Old credential information. See {@link CredentialInfo}. */ + struct CredentialInfo oldInfo; + /**< Protection key for the user file key. */ + unsigned char[] rootSecret; + /**< Old protection key for the user file key. */ + unsigned char[] oldRootSecret; + /**< Indicates the authentication token of the user password. */ + unsigned char[] authToken; +}; + +/** + * @brief Defines scheduling information. + * + * @since 3.2 + * @version 2.0 + */ +struct ScheduleInfo { + /**< Schedule index of authentication. */ + unsigned long scheduleId; + /**< Templates to authenticate. */ + unsigned long[] templateIds; + /**< Authentication type. See @{AuthType}. */ + int authType; + /**< Executor matcher. */ + unsigned int executorMatcher; + /**< Operation to perform. See @{scheduleMode}*/ + int scheduleMode; + /**< Executor indexes. */ + unsigned long [] executorIndexes; + /**< Executor messages. */ + unsigned char[][] executorMessages; +}; + +/** + * @brief Defines enrolled users information. + * + * @since 4.0 + * @version 1.1 + */ +struct UserInfo { + /**< SecureUid of this user. */ + unsigned long secureUid; + /**< PinSubType of this user. See @{@PinSubType}. */ + int pinSubType; + /**< Related enrolled information list. See @{EnrolledInfo}. */ + struct EnrolledInfo[] enrolledInfos; +}; + +/** + * @brief Defines enrolled users information. + * + * @since 4.1 + * @version 1.2 + */ +struct ExtUserInfo { + /**< User ID. */ + int userId; + /**< info of this user. */ + struct UserInfo userInfo; +}; + +/** + * @brief Defines the authentication param. + * + * @since 5.0 + * @version 1.0 + */ +struct AuthParamBase { + /**< User ID. */ + int userId; + /**< Authentication trust level. */ + unsigned int authTrustLevel; + /**< Executor sensor hint under the same authentication type, 0 is not allowed. */ + unsigned int executorSensorHint; + /**< Challenge of the authentication. */ + unsigned char[] challenge; + /**< Caller name. */ + String callerName; + /**< Caller Type. */ + int callerType; + /**< Calling napi or innerkit api version. */ + int apiVersion; +}; + +/** + * @brief Defines the authentication parameter. + * + * @since 5.0 + * @version 1.0 + */ +struct AuthParam { + /**< Authentication parameter. See @{AuthParamBase}. */ + AuthParamBase baseParam; + /**< Authentication type. See @{AuthType}. */ + int authType; + /**< Authentication intent. See @{AuthIntent}. */ + int authIntent; + /**< Is os account verified. */ + boolean isOsAccountVerified; + /**< Collector udid. */ + String collectorUdid; +}; + +/** + * @brief Request information of reused unlock result. + * + * @since 5.0 + * @version 1.0 + */ +struct ReuseUnlockParam { + /**< Authentication parameter. See @{AuthParam}. */ + AuthParamBase baseParam; + /** Authentication type. See @{AuthType}. */ + int[] authTypes; + /** The allowable reuse duration. */ + unsigned long reuseUnlockResultDuration; + /** Reuse unlock result mode. See @{ReuseMode}. */ + int reuseUnlockResultMode; +}; + +/** + * @brief Defines credential enrollment parameters. + * + * @since 3.2 + * @version 3.0 + */ +struct EnrollParam { + /**< Authentication type. See @{AuthType}. */ + int authType; + /**< Executor sensor hint under the same authentication type. 0 is not allowed. */ + unsigned int executorSensorHint; + /**< Caller name. */ + String callerName; + /** Caller Type. */ + int callerType; + /**< Calling napi or innerkit api version. */ + int apiVersion; + /**< User ID. */ + int userId; + /**< User Type. */ + int userType; + /**< Auth sub type. */ + int authSubType; +}; + +/** +* @brief Define credential enrollment ID information. +* + * @since 5.0 + * @version 1.0 +*/ +struct EnrolledState { + /** Desensitization Enrolled ID. */ + unsigned long credentialDigest; + /** Number of Credential. */ + unsigned short credentialCount; +}; + +/** + * @brief The reuse result of unlock device. + * + * @since 5.0 + * @version 1.0 + */ +struct ReuseUnlockInfo { + /**< Authentication type. See @{AuthType}. */ + int authType; + /**< Authentication token. */ + unsigned char[] token; + /**< Enrolled state. See @{EnrolledState}. */ + EnrolledState enrolledState; +}; + +/** + * @brief Global config type. + * + * @since 5.0 + * @version 1.0 + */ +enum GlobalConfigType : int { + /** Pin expired period */ + PIN_EXPIRED_PERIOD = 1, + /** Enable specified authType capability. */ + ENABLE_STATUS = 2, +}; + +/** + * @brief Global config value. + * + * @since 5.0 + * @version 1.0 + */ +union GlobalConfigValue { + /** Pin expired period value. When pinExpiredPeriod equals to 0, userAuth won't check pin expired period. */ + long pinExpiredPeriod; + /** Enable specified authType capability.*/ + boolean enableStatus; +}; + +/** + * @brief Global config param. + * + * @since 5.0 + * @version 1.0 + */ +struct GlobalConfigParam { + /** Global config type. See @{GlobalConfigType}*/ + int type; + /** Global config value. See @{GlobalConfigValue}*/ + GlobalConfigValue value; + /** Specified userIds. GlobalConfigParam will be effect for all userspaces when the array is empty. */ + int[] userIds; + /** Specified authTypes, shouldn't empty. See @{AuthType}.*/ + int[] authTypes; +}; + +/** + * @brief User auth token plain. + * + * @since 5.1 + * @version 1.0 + */ +struct UserAuthTokenPlain { + /** Token version. */ + unsigned int version; + /** User ID. */ + int userId; + /** Challenge of the token. */ + unsigned char[] challenge; + /** Time interval between token signed and verified. */ + unsigned long timeInterval; + /** Authentication trust level. */ + unsigned int authTrustLevel; + /** Authentication type. See @{AuthType}. */ + int authType; + /** Auth mode. */ + int authMode; + /** Security level. */ + unsigned int securityLevel; + /** Token type. */ + int tokenType; + /** SecureUid of the user. */ + unsigned long secureUid; + /** Enrollment ID. */ + unsigned long enrolledId; + /** Credential ID. */ + unsigned long credentialId; + /** Collector udid. */ + String collectorUdid; + /** Verifier udid. */ + String verifierUdid; +}; +/** @} */ \ No newline at end of file diff --git a/wlan/bundle.json b/wlan/bundle.json index af29ce5aa03e60ce619b52273eac0768099d0772..278edefde957e41631f18371dc4ebc05d3a7280f 100644 --- a/wlan/bundle.json +++ b/wlan/bundle.json @@ -31,6 +31,7 @@ "//drivers/interface/wlan/v1_3:wlan_idl_target", "//drivers/interface/wlan/wpa/v1_0:wpa_idl_target", "//drivers/interface/wlan/wpa/v1_1:wpa_idl_target", + "//drivers/interface/wlan/wpa/v1_2:wpa_idl_target", "//drivers/interface/wlan/hostapd/v1_0:hostapd_idl_target", "//drivers/interface/wlan/chip/v1_0:chip_idl_target" ], @@ -157,6 +158,30 @@ "header_base": "//drivers/interface/wlan/wpa" } }, + { + "name": "//drivers/interface/wlan/wpa/v1_2:libwpa_proxy_1.2", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/wlan/wpa" + } + }, + { + "name": "//drivers/interface/wlan/wpa/v1_2:wpa_idl_headers", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/wlan/wpa" + } + }, + { + "name": "//drivers/interface/wlan/wpa/v1_2:libwpa_stub_1.2", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/wlan/wpa" + } + }, { "name": "//drivers/interface/wlan/hostapd/v1_0:libhostapd_proxy_1.0", "header": { diff --git a/wlan/chip/v1_0/ChipTypes.idl b/wlan/chip/v1_0/ChipTypes.idl index a9c923198f1e4e42d7d4924da98577fb674c4ffd..b4b209fb822e37a3256e65ac44e1d5c34a3af7a5 100644 --- a/wlan/chip/v1_0/ChipTypes.idl +++ b/wlan/chip/v1_0/ChipTypes.idl @@ -183,4 +183,17 @@ struct SignalPollResult { int c1Rssi; unsigned char[] ext; }; + +/** + * @brief Defines the projection parameters, This interface is preferentially used to communicate with the Wi-Fi service. + * + * @since 5.0 + * @version 1.0 + */ +struct ProjectionScreenCmdParam { + /** ID of the projection command. */ + int cmdId; + /** Content of the projection command. */ + byte[] buf; +}; /** @} */ \ No newline at end of file diff --git a/wlan/chip/v1_0/IChipIface.idl b/wlan/chip/v1_0/IChipIface.idl index 678bc36a55ac04e816038de7bb42124498301a91..089a6f7e14f3da8a95dd04ec3e0832a906ae23b9 100644 --- a/wlan/chip/v1_0/IChipIface.idl +++ b/wlan/chip/v1_0/IChipIface.idl @@ -282,5 +282,90 @@ interface IChipIface { * @version 1.0 */ SetTxPower([in] int power); + + /** + * @brief Set interface up or down, This interface is preferentially used to communicate with the Wi-Fi service. + * + * @param state Indicates the iface state. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + SetIfaceState([in] boolean state); + + /** + * @brief Send private commond to driver, This interface is preferentially used to communicate with the Wi-Fi service. + * + * @param uid Indicates the current uid. + * @param protocol Indicates the rule. + * @param enable Indicates the mode. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + SendCmdToDriver([in] String ifName, [in] int cmdId, [in] byte[] paramBuf); + + /** + * @brief send action frame to driver, This interface is preferentially used to communicate with the Wi-Fi service. + * + * @param ifName Indicates the NIC name. + * @param freq Indicates the send channel frequency. + * @param ifName Indicates the action frame data. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + SendActionFrame([in] String ifName, [in] unsigned int freq, [in] unsigned char[] frameData); + + /** + * @brief register action frame receiver, This interface is preferentially used to communicate with the Wi-Fi service. + * + * @param ifName Indicates the NIC name. + * @param txChannel Indicates the data matching action frame. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + RegisterActionFrameReceiver([in] String ifName, [in] unsigned char[] match); + + /** + * @brief get coex channel list, This interface is preferentially used to communicate with the Wi-Fi service. + * + * @param ifName Indicates the NIC name. + * @param paramBuf coex channel list. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetCoexictenceChannelList([in] String ifName, [out] unsigned char[] paramBuf); + + /** + * @brief Sets the projection parameters, This interface is preferentially used to communicate with the Wi-Fi service. + * + * @param ifName Indicates the NIC name. + * @param param Indicates the projection parameters to set. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + SetProjectionScreenParam([in] String ifName, [in] struct ProjectionScreenCmdParam param); }; /** @} */ \ No newline at end of file diff --git a/wlan/chip/v1_0/IChipIfaceCallback.idl b/wlan/chip/v1_0/IChipIfaceCallback.idl index 11237a5e2b171987cffb8c61e5adc6e29b911efb..3b9f9bed684e8ab8452c51f6598baed8128bbf81 100644 --- a/wlan/chip/v1_0/IChipIfaceCallback.idl +++ b/wlan/chip/v1_0/IChipIfaceCallback.idl @@ -72,5 +72,17 @@ import ohos.hdi.wlan.chip.v1_0.ChipTypes; * @version 1.0 */ [oneway] OnRssiReport([in] int index, [in] int c0Rssi, [in] int c1Rssi); + + /** + * @brief Called to process the Netlink message received, This interface is preferentially used to + * communicate with the Wi-Fi service. + * + * @param type Indicates the Netlink message type (Action Message, Action Status, Ext Message). + * @param recvMsg Indicates the Netlink message received. + * + * @since 5.0 + * @version 1.0 + */ + [oneway] OnWifiNetlinkMessage([in] unsigned int type, [in] unsigned char[] recvMsg); }; /** @} */ \ No newline at end of file diff --git a/wlan/chip/v1_0/IConcreteChip.idl b/wlan/chip/v1_0/IConcreteChip.idl index 1ed02e8a00e31f94ad7b7b98728ba425572ea242..4ce8be97943021b64b14f18fab90c6fa3142e608 100644 --- a/wlan/chip/v1_0/IConcreteChip.idl +++ b/wlan/chip/v1_0/IConcreteChip.idl @@ -285,5 +285,49 @@ interface IConcreteChip { * @version 1.0 */ SetChipMode([in] unsigned int modeId); + + /** + * @brief Creates the extend private interface service, This interface is preferentially used to communicate with + * the Wi-Fi service. + * + * @param ifName Indicates extend interface service name. + * @param iface Indicates extend interface service object. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + CreateExtService([in] String ifName, [out] IChipIface iface); + + /** + * @brief Obtains the service of the extend interface, This interface is preferentially used to communicate + * with the Wi-Fi service. + * + * @param ifName Indicates extend interface service name. + * @param iface Indicates the extend interface service object. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + GetExtService([in] String ifName, [out] IChipIface iface); + + /** + * @brief Deletes the service of the extend interface, This interface is preferentially used to + * communicate with the Wi-Fi service. + * + * @param ifName Indicates extend interface service name. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 5.0 + * @version 1.0 + */ + RemoveExtService([in] String ifName); }; /** @} */ \ No newline at end of file diff --git a/wlan/v1_1/BUILD.gn b/wlan/v1_1/BUILD.gn index 58145e5d0485a5b461db7130e023fd077e3ced9a..698ab2b85773fee0015075a40968f8b996a4aa4b 100644 --- a/wlan/v1_1/BUILD.gn +++ b/wlan/v1_1/BUILD.gn @@ -19,6 +19,7 @@ if (defined(ohos_lite)) { } } else { hdi("wlan") { + branch_protector_ret = "pac_ret" module_name = "wlan_service" sources = [ diff --git a/wlan/wpa/v1_2/BUILD.gn b/wlan/wpa/v1_2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7b5dbfaf575767791f00b66620a1f317113b462e --- /dev/null +++ b/wlan/wpa/v1_2/BUILD.gn @@ -0,0 +1,30 @@ +# Copyright (c) 2024 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. + +import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") +if (defined(ohos_lite)) { + group("libwpa_proxy_1.2") { + deps = [] + public_configs = [] + } +} else { + hdi("wpa") { + module_name = "wpa_service" + + sources = [ "IWpaInterface.idl" ] + + language = "c" + subsystem_name = "hdf" + part_name = "drivers_interface_wlan" + } +} diff --git a/wlan/wpa/v1_2/IWpaInterface.idl b/wlan/wpa/v1_2/IWpaInterface.idl new file mode 100644 index 0000000000000000000000000000000000000000..044185773d6090a91b3227d03b0cff83939603c4 --- /dev/null +++ b/wlan/wpa/v1_2/IWpaInterface.idl @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 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. + */ + +/** + * @file IWpaInterface.idl + * + * @brief Provides APIs to enable or disable a WLAN hotspot, scan for hotspots, connect to or disconnect from a WLAN hotspot, + * set the country code, and manage network devices. + * + * @since 5.1 + * @version 1.2 + */ + +package ohos.hdi.wlan.wpa.v1_2; + +import ohos.hdi.wlan.wpa.v1_1.IWpaInterface; + +interface IWpaInterface extends ohos.hdi.wlan.wpa.v1_1.IWpaInterface { + /** + * @brief Get Sta data from wpa_supplicant + * + * @param ifName Indicates the NIC name. + * @param staParam Indicates the param of sta to get data. + * @param staData Indicates the data obtained. + * + * @return Returns 0 if the operation is successful. + * @return Returns a negative value if the operation fails. + * + * @since 5.1 + * @version 1.0 + */ + GetWpaStaData([in] String ifName, [in] String staParam, [out] String staData); +}