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_CODEC_IF_H 10 #define AUDIO_CODEC_IF_H 11 12 #include "audio_host.h" 13 #include "audio_control.h" 14 15 #ifdef __cplusplus 16 #if __cplusplus 17 extern "C" { 18 #endif 19 #endif /* __cplusplus */ 20 21 /** 22 * @brief Defines Codec device name and data. 23 * 24 * @since 1.0 25 * @version 1.0 26 */ 27 struct CodecDevice { 28 const char *devCodecName; /**< Codec device name */ 29 struct CodecData *devData; /**< Codec module private data */ 30 struct HdfDeviceObject *device; /**< HDF device */ 31 struct DListHead list; /**< Codec list */ 32 }; 33 34 /** 35 * @brief Defines Codec host in audio driver. 36 * 37 * @since 1.0 38 * @version 1.0 39 */ 40 struct CodecHost { 41 struct IDeviceIoService service; /**< Services provided by codec */ 42 struct HdfDeviceObject *device; /**< HDF device */ 43 void *priv; /**< Codec private data interface */ 44 }; 45 46 /** 47 * @brief Defines Codec private data. 48 * 49 * @since 1.0 50 * @version 1.0 51 */ 52 struct CodecData { 53 const char *drvCodecName; /**< Codec driver name */ 54 55 /** 56 * @brief Defines Codec device init. 57 * 58 * @param audioCard Indicates an audio card device. 59 * @param codec Indicates a codec device. 60 * 61 * @return Returns <b>0</b> if codec device init success; returns a non-zero value otherwise. 62 * 63 * @since 1.0 64 * @version 1.0 65 */ 66 int32_t (*Init)(struct AudioCard *audioCard, const struct CodecDevice *codec); 67 68 /** 69 * @brief Defines Codec device reg read. 70 * 71 * @param codec Indicates a codec device. 72 * @param reg Indicates reg offset. 73 * @param value Indicates read reg value. 74 * 75 * @return Returns <b>0</b> if codec device read reg success; returns a non-zero value otherwise. 76 * 77 * @since 1.0 78 * @version 1.0 79 */ 80 int32_t (*Read)(const struct CodecDevice *codec, uint32_t reg, uint32_t *value); 81 82 /** 83 * @brief Defines Codec device reg write. 84 * 85 * @param codec Indicates a codec device. 86 * @param reg Indicates reg offset. 87 * @param value Indicates write reg value. 88 * 89 * @return Returns <b>0</b> if codec device write reg success; returns a non-zero value otherwise. 90 * 91 * @since 1.0 92 * @version 1.0 93 */ 94 int32_t (*Write)(const struct CodecDevice *codec, uint32_t reg, uint32_t value); 95 96 struct AudioKcontrol *controls; /**< Codec control structure array pointer */ 97 int numControls; /**< Number of array elements of Codec controls */ 98 struct AudioSapmComponent *sapmComponents; /**< Codec power management component array pointer */ 99 int numSapmComponent; /**< Number of array elements of codec power management component */ 100 const struct AudioSapmRoute *sapmRoutes; /**< Codec power management route array pointer */ 101 int numSapmRoutes; /**< Number of power management route array elements */ 102 unsigned long virtualAddress; /**< Codec base reg IoRemap address */ 103 struct AudioRegCfgData *regConfig; /**< Codec registers configured in HCS */ 104 struct AudioRegCfgGroupNode **regCfgGroup; /**< Codec register group configured in HCS */ 105 struct OsalMutex mutex; /**< Codec mutex */ 106 void *privateParam; /**< Codec private parameter */ 107 }; 108 109 #ifdef __cplusplus 110 #if __cplusplus 111 } 112 #endif 113 #endif /* __cplusplus */ 114 115 #endif /* CODEC_CORE_H */ 116