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_DAI_IF_H 10 #define AUDIO_DAI_IF_H 11 12 #include "audio_host.h" 13 #include "audio_parse.h" 14 #include "audio_control.h" 15 16 #ifdef __cplusplus 17 #if __cplusplus 18 extern "C" { 19 #endif 20 #endif /* __cplusplus */ 21 22 /** 23 * @brief Defines Dai device name and data. 24 * 25 * @since 1.0 26 * @version 1.0 27 */ 28 struct DaiDevice { 29 const char *devDaiName; /**< Dai device name */ 30 struct DaiData *devData; /**< Dai module private data */ 31 struct HdfDeviceObject *device; /**< HDF device */ 32 struct DListHead list; /**< Dai list */ 33 }; 34 35 /** 36 * @brief Defines Dai operation function set. 37 * 38 * @since 1.0 39 * @version 1.0 40 */ 41 struct AudioDaiOps { 42 /** 43 * @brief Defines Dai device start up function. 44 * 45 * @param audioCard Indicates an audio card device. 46 * @param dai Indicates a dai device. 47 * 48 * @return Returns <b>0</b> if dai device start up success; returns a non-zero value otherwise. 49 * 50 * @since 1.0 51 * @version 1.0 52 */ 53 int32_t (*Startup)(const struct AudioCard *audioCard, const struct DaiDevice *dai); 54 55 /** 56 * @brief Defines Dai device hardware param set function. 57 * 58 * @param audioCard Indicates an audio card device. 59 * @param param Indicates pcm param set. 60 * 61 * @return Returns <b>0</b> if dai pcm param set success; returns a non-zero value otherwise. 62 * 63 * @since 1.0 64 * @version 1.0 65 */ 66 int32_t (*HwParams)(const struct AudioCard *audioCard, const struct AudioPcmHwParams *param); 67 68 /** 69 * @brief Defines Dai device trigger function. 70 * 71 * @param audioCard Indicates an audio card device. 72 * @param cmd Indicates a Command id. 73 * @param dai Indicates a dai device. 74 * 75 * @return Returns <b>0</b> if dai device trigger success; returns a non-zero value otherwise. 76 * 77 * @since 1.0 78 * @version 1.0 79 */ 80 int32_t (*Trigger)(const struct AudioCard *audioCard, int cmd, const struct DaiDevice *dai); 81 82 /** 83 * @brief Defines Dai device shutdown function. 84 * 85 * @param audioCard Indicates an audio card device. 86 * @param dai Indicates a dai device. 87 * 88 * @return Returns <b>0</b> if dai device shutdown success; returns a non-zero value otherwise. 89 * 90 * @since 1.0 91 * @version 1.0 92 */ 93 int32_t (*Shutdown)(const struct AudioCard *audioCard, const struct DaiDevice *dai); 94 95 /** 96 * @brief Defines Dai device digital mute. 97 * 98 * @param audioCard Indicates an audio card device. 99 * @param dai Indicates a dai device. 100 * @param mute Indicates mute enable. 101 * @param direction Indicates render or capture. 102 * 103 * @return Returns <b>0</b> if dai device digital mute success; returns a non-zero value otherwise. 104 * 105 * @since 1.0 106 * @version 1.0 107 */ 108 int32_t (*MuteStream)(const struct AudioCard *audioCard, const struct DaiDevice *dai, 109 bool mute, int32_t direction); 110 }; 111 112 /** 113 * @brief Defines Dai host in audio driver. 114 * 115 * @since 1.0 116 * @version 1.0 117 */ 118 struct DaiHost { 119 struct IDeviceIoService service; /**< Services provided by dai */ 120 struct HdfDeviceObject *device; /**< HDF device */ 121 void *priv; /**< Dai private data interface */ 122 }; 123 124 /** 125 * @brief Defines dai private data. 126 * 127 * @since 1.0 128 * @version 1.0 129 */ 130 struct DaiData { 131 const char *drvDaiName; /**< dai driver name */ 132 133 /** 134 * @brief Defines Dai device init. 135 * 136 * @param audioCard Indicates an audio card device. 137 * @param dai Indicates a dai device. 138 * 139 * @return Returns <b>0</b> if dai device init success; returns a non-zero value otherwise. 140 * 141 * @since 1.0 142 * @version 1.0 143 */ 144 int32_t (*DaiInit)(struct AudioCard *audioCard, const struct DaiDevice *dai); 145 146 /** 147 * @brief Defines Dai device reg read. 148 * 149 * @param dai Indicates a dai device. 150 * @param reg Indicates reg offset. 151 * @param value Indicates read reg value. 152 * 153 * @return Returns <b>0</b> if dai device read reg success; returns a non-zero value otherwise. 154 * 155 * @since 1.0 156 * @version 1.0 157 */ 158 int32_t (*Read)(const struct DaiDevice *dai, uint32_t reg, uint32_t *value); 159 160 /** 161 * @brief Defines Dai device reg write. 162 * 163 * @param dai Indicates a dai device. 164 * @param reg Indicates reg offset. 165 * @param value Indicates write reg value. 166 * 167 * @return Returns <b>0</b> if dai device write reg success; returns a non-zero value otherwise. 168 * 169 * @since 1.0 170 * @version 1.0 171 */ 172 int32_t (*Write)(const struct DaiDevice *dai, uint32_t reg, uint32_t value); 173 174 const struct AudioDaiOps *ops; /**< dai set of operation functions */ 175 struct AudioPortInfo portInfo; /**< dai port info */ 176 struct PcmInfo pcmInfo; /**< dai pcm info */ 177 struct AudioKcontrol *controls; /**< dai control structure array pointer */ 178 int numControls; /**< dai controls the number of structure array elements */ 179 bool daiInitFlag; /**< dai init flag */ 180 unsigned long regVirtualAddr; /**< dai base reg IoRemap address */ 181 struct AudioRegCfgData *regConfig; /**< dai registers configured in HCS */ 182 struct AudioRegCfgGroupNode **regCfgGroup; /**< dai register group configured in HCS */ 183 struct OsalMutex mutex; /**< dai mutex */ 184 void *privateParam; /**< dai private parameter */ 185 }; 186 187 #ifdef __cplusplus 188 #if __cplusplus 189 } 190 #endif 191 #endif /* __cplusplus */ 192 193 #endif 194