1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef AUDIO_PLATFORM_IF_H 10 #define AUDIO_PLATFORM_IF_H 11 12 #include "audio_host.h" 13 #include "audio_platform_base.h" 14 15 #ifdef __cplusplus 16 #if __cplusplus 17 extern "C" { 18 #endif 19 #endif /* __cplusplus */ 20 21 /** 22 * @brief Defines paltform private data. 23 * 24 * @since 1.0 25 * @version 1.0 26 */ 27 struct PlatformData { 28 const char *drvPlatformName; /**< Platform module name */ 29 30 /** 31 * @brief Defines platform device init. 32 * 33 * @param audioCard Indicates an audio card device. 34 * @param platform Indicates a platform device. 35 * 36 * @return Returns <b>0</b> if Platform device init success; returns a non-zero value otherwise. 37 * 38 * @since 1.0 39 * @version 1.0 40 */ 41 int32_t (*PlatformInit)(const struct AudioCard *audioCard, const struct PlatformDevice *platform); 42 43 struct AudioDmaOps *ops; /**< Platform module private data */ 44 struct CircleBufInfo renderBufInfo; /**< Render pcm stream transfer */ 45 struct CircleBufInfo captureBufInfo; /**< Capture pcm stream transfer */ 46 struct PcmInfo renderPcmInfo; /**< Render pcm stream info */ 47 struct PcmInfo capturePcmInfo; /**< Capture pcm stream info */ 48 bool platformInitFlag; /**< Platform init flag */ 49 struct AudioMmapData mmapData; /**< Mmap mode transfer data */ 50 uint32_t mmapLoopCount; /**< Loop count for mmap mode pcm stream */ 51 void *dmaPrv; /**< Platform dma private data */ 52 struct AudioRegCfgData *regConfig; /**< Codec registers configured in HCS */ 53 struct AudioRegCfgGroupNode **regCfgGroup; /**< Codec register group configured in HCS */ 54 }; 55 56 /** 57 * @brief Defines Dma operation function set. 58 * 59 * @since 1.0 60 * @version 1.0 61 */ 62 struct AudioDmaOps { 63 /** 64 * @brief Defines Dma buff alloc. 65 * 66 * @param platformData Indicates dma device. 67 * @param streamType Indicates capture or render. 68 * 69 * @return Returns <b>0</b> if dma buffer alloc success; returns a non-zero value otherwise. 70 * 71 * @since 1.0 72 * @version 1.0 73 */ 74 int32_t (*DmaBufAlloc)(struct PlatformData *platformData, const enum AudioStreamType streamType); 75 76 /** 77 * @brief Defines dma buffer free. 78 * 79 * @param platformData Indicates dma device. 80 * @param streamType Indicates capture or render. 81 * 82 * @return Returns <b>0</b> if dma buffer free success; returns a non-zero value otherwise. 83 * 84 * @since 1.0 85 * @version 1.0 86 */ 87 int32_t (*DmaBufFree)(struct PlatformData *platformData, const enum AudioStreamType streamType); 88 89 /** 90 * @brief Defines dma request channel. 91 * 92 * @param platformData Indicates dma device. 93 * 94 * @return Returns <b>0</b> if dma request channel success; returns a non-zero value otherwise. 95 * 96 * @since 1.0 97 * @version 1.0 98 */ 99 int32_t (*DmaRequestChannel)(const struct PlatformData *platformData, const enum AudioStreamType streamType); 100 101 /** 102 * @brief Defines dma channel config. 103 * 104 * @param platformData Indicates dma device. 105 * 106 * @return Returns <b>0</b> if dma channel config set success; returns a non-zero value otherwise. 107 * 108 * @since 1.0 109 * @version 1.0 110 */ 111 int32_t (*DmaConfigChannel)(const struct PlatformData *platformData, const enum AudioStreamType streamType); 112 113 /** 114 * @brief Defines dma prepare function. 115 * 116 * @param platformData Indicates dma device. 117 * 118 * @return Returns <b>0</b> if dma device prep set success; returns a non-zero value otherwise. 119 * 120 * @since 1.0 121 * @version 1.0 122 */ 123 int32_t (*DmaPrep)(const struct PlatformData *platformData, const enum AudioStreamType streamType); 124 125 /** 126 * @brief Defines dma submit function. 127 * 128 * @param platformData Indicates dma device. 129 * 130 * @return Returns <b>0</b> if dma device submit success; returns a non-zero value otherwise. 131 * 132 * @since 1.0 133 * @version 1.0 134 */ 135 int32_t (*DmaSubmit)(const struct PlatformData *platformData, const enum AudioStreamType streamType); 136 137 /** 138 * @brief Defines dma pending function. 139 * 140 * @param platformData Indicates dma device. 141 * 142 * @return Returns <b>0</b> if dma pending success; returns a non-zero value otherwise. 143 * 144 * @since 1.0 145 * @version 1.0 146 */ 147 int32_t (*DmaPending)(struct PlatformData *platformData, const enum AudioStreamType streamType); 148 149 /** 150 * @brief Defines pcm stream transfer pause. 151 * 152 * @param platformData Indicates dma device. 153 * 154 * @return Returns <b>0</b> if pcm stream transfer pause success; returns a non-zero value otherwise. 155 * 156 * @since 1.0 157 * @version 1.0 158 */ 159 int32_t (*DmaPause)(struct PlatformData *platformData, const enum AudioStreamType streamType); 160 161 /** 162 * @brief Defines pcm stream transfer resume. 163 * 164 * @param platformData Indicates dma device. 165 * 166 * @return Returns <b>0</b> if pcm stream transfer resume success; returns a non-zero value otherwise. 167 * 168 * @since 1.0 169 * @version 1.0 170 */ 171 int32_t (*DmaResume)(const struct PlatformData *platformData, const enum AudioStreamType streamType); 172 173 /** 174 * @brief Defines Get the function of the current playback or recording position. 175 * 176 * @param platformData Indicates dma device. 177 * @param pointer Indicates dma pointer. 178 * 179 * @return Returns <b>0</b> if dma device pointer position get success; returns a non-zero value otherwise. 180 * 181 * @since 1.0 182 * @version 1.0 183 */ 184 int32_t (*DmaPointer)(struct PlatformData *platformData, const enum AudioStreamType streamType, uint32_t *pointer); 185 }; 186 187 /** 188 * @brief Defines Platform host in audio driver. 189 * 190 * @since 1.0 191 * @version 1.0 192 */ 193 struct PlatformHost { 194 struct IDeviceIoService service; /**< Services provided by patform */ 195 struct HdfDeviceObject *device; /**< HDF device */ 196 void *priv; /**< Platform private data interface */ 197 }; 198 199 /** 200 * @brief Defines Dai device name and data. 201 * 202 * @since 1.0 203 * @version 1.0 204 */ 205 struct PlatformDevice { 206 const char *devPlatformName; /**< Platform device name */ 207 struct PlatformData *devData; /**< Platform module private data */ 208 struct HdfDeviceObject *device; /**< HDF device */ 209 struct DListHead list; /**< Platform list */ 210 }; 211 212 #ifdef __cplusplus 213 #if __cplusplus 214 } 215 #endif 216 #endif /* __cplusplus */ 217 218 #endif 219