1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HDF_I_AUDIO_TYPES_H 17 #define HDF_I_AUDIO_TYPES_H 18 19 #include <string> 20 #include <vector> 21 22 namespace OHOS { 23 namespace DistributedHardware { 24 enum AudioChannelModeHAL { 25 AUDIO_CHANNEL_NORMAL = 0, 26 AUDIO_CHANNEL_BOTH_LEFT, 27 AUDIO_CHANNEL_BOTH_RIGHT, 28 AUDIO_CHANNEL_EXCHANGE, 29 30 AUDIO_CHANNEL_MIX, 31 AUDIO_CHANNEL_LEFT_MUTE, 32 AUDIO_CHANNEL_RIGHT_MUTE, 33 AUDIO_CHANNEL_BOTH_MUTE, 34 }; 35 36 enum AudioDrainNotifyTypeHAL { 37 AUDIO_DRAIN_NORMAL_MODE, 38 AUDIO_DRAIN_EARLY_MODE, 39 }; 40 41 enum AudioPortPassthroughModeHAL { 42 PORT_PASSTHROUGH_LPCM = 0x1, 43 PORT_PASSTHROUGH_RAW = 0x2, 44 PORT_PASSTHROUGH_HBR2LBR = 0x4, 45 PORT_PASSTHROUGH_AUTO = 0x8, 46 }; 47 48 struct AudioDeviceDescriptorHAL { 49 uint32_t portId; 50 uint32_t pins; 51 std::string desc; 52 }; 53 54 struct AudioSceneDescriptorHAL { 55 uint32_t id; 56 AudioDeviceDescriptorHAL desc; 57 }; 58 59 struct AudioPortHAL { 60 uint32_t dir; 61 uint32_t portId; 62 std::string portName; 63 }; 64 65 struct AudioAdapterDescriptorHAL { 66 std::string adapterName; 67 std::vector<AudioPortHAL> ports; 68 }; 69 70 struct AudioTimeStampHAL { 71 uint64_t tvSec; 72 uint64_t tvNSec; 73 }; 74 75 struct AudioSampleAttributesHAL { 76 uint32_t type; 77 uint32_t interleaved; 78 uint32_t format; 79 uint32_t sampleRate; 80 uint32_t channelCount; 81 82 uint32_t period; 83 uint32_t frameSize; 84 uint32_t isBigEndian; 85 uint32_t isSignedData; 86 uint32_t startThreshold; 87 uint32_t stopThreshold; 88 uint32_t silenceThreshold; 89 uint32_t streamId; 90 }; 91 92 struct AudioSubPortCapabilityHAL { 93 uint32_t portId; 94 uint32_t mask; 95 std::string desc; 96 }; 97 98 struct AudioPortCapabilityHAL { 99 uint32_t deviceType; 100 uint32_t deviceId; 101 uint32_t hardwareMode; 102 uint32_t formatNum; 103 std::vector<uint32_t> formats; 104 uint32_t sampleRateMasks; 105 uint32_t channelMasks; 106 uint32_t channelCount; 107 uint32_t subPortsNum; 108 AudioSubPortCapabilityHAL subPorts; 109 }; 110 111 struct AudioDevExtInfoHAL { 112 int32_t moduleId; 113 uint32_t type; 114 uint8_t desc[32]; 115 }; 116 117 struct AudioMixExtInfoHAL { 118 int32_t moduleId; 119 int32_t streamId; 120 }; 121 122 struct AudioSessionInfoHAL { 123 uint32_t sessionType; 124 }; 125 126 struct AudioRouteNodeHAL { 127 int32_t portId; 128 uint32_t role; 129 uint32_t type; 130 struct AudioDevExtInfoHAL device; 131 struct AudioMixExtInfoHAL mix; 132 struct AudioSessionInfoHAL session; 133 }; 134 135 struct AudioRouteHAL { 136 std::vector<AudioRouteNodeHAL> sources; 137 std::vector<AudioRouteNodeHAL> sinks; 138 }; 139 140 struct AudioParameter { 141 uint32_t paramType; 142 uint32_t value; 143 std::string content; 144 }; 145 146 struct AudioMmapBufferDescriptorHAL { 147 int32_t memoryFd; 148 int32_t totalBufferFrames; 149 int32_t transferFrameSize; 150 int32_t isShareable; 151 }; 152 153 } // namespace DistributedHardware 154 } // namespace OHOS 155 #endif