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 HI3516_CODEC_IMPL_H 10 #define HI3516_CODEC_IMPL_H 11 12 #include "audio_codec_if.h" 13 #include "securec.h" 14 #include "audio_control.h" 15 #include "audio_parse.h" 16 #include "osal_mem.h" 17 #include "osal_time.h" 18 19 #define ACODEC_REG_BASE (0x113c0000) 20 #define ACODEC_MAX_REG_SIZE (0x1000) 21 22 typedef enum { 23 ACODEC_I2S_FS_8000 = 0x18, 24 ACODEC_I2S_FS_11025 = 0x18, 25 ACODEC_I2S_FS_12000 = 0x18, 26 ACODEC_I2S_FS_16000 = 0x19, 27 ACODEC_I2S_FS_22050 = 0x19, 28 ACODEC_I2S_FS_24000 = 0x19, 29 ACODEC_I2S_FS_32000 = 0x1a, 30 ACODEC_I2S_FS_44100 = 0x1a, 31 ACODEC_I2S_FS_48000 = 0x1a, 32 ACODEC_I2S_FS_64000 = 0x1b, 33 ACODEC_I2S_FS_96000 = 0x1b, 34 ACODEC_I2S_FS_BUTT = 0x1c, 35 } AcodecI2sFs; 36 37 typedef enum { 38 ACODEC_ADC_MODESEL_6144 = 0x0, 39 ACODEC_ADC_MODESEL_4096 = 0x1, 40 ACODEC_ADC_MODESEL_BUTT = 0xff, 41 } AcodecAdcModeSel; 42 43 typedef enum { 44 AUDIO_CODEC_BIT_WIDTH_16 = 0, /* 16bit width */ 45 AUDIO_CODEC_BIT_WIDTH_18 = 1, /* 18bit width */ 46 AUDIO_CODEC_BIT_WIDTH_20 = 2, /* 20bit width */ 47 AUDIO_CODEC_BIT_WIDTH_24 = 3, /* 24bit width */ 48 AUDIO_CODEC_BIT_WIDTH_BUTT, 49 } AudioCodecBitWidth; 50 51 struct CodecDaiParamsVal { 52 uint32_t frequencyVal; 53 uint32_t formatVal; 54 uint32_t channelVal; 55 }; 56 57 int32_t CodecHalSysInit(struct CodecData *codeData); 58 int32_t CodecRegBitsRead(struct AudioMixerControl *regAttr, uint32_t *regValue); 59 int32_t CodecRegBitsUpdate(struct AudioMixerControl regAttr); 60 int32_t CodecRegDefaultInit(struct AudioRegCfgGroupNode **regCfgGroup); 61 int32_t CodecSetAdcTuneEnable(struct AudioRegCfgGroupNode **regCfgGroup); 62 int32_t CodecDaiParamsUpdate(struct AudioRegCfgGroupNode **regCfgGroup, 63 struct CodecDaiParamsVal codecDaiParamsVal); 64 65 int32_t AudioCodecAiaoSetCtrlOps(const struct AudioKcontrol *kcontrol, 66 const struct AudioCtrlElemValue *elemValue); 67 int32_t AudioCodecAiaoGetCtrlOps(const struct AudioKcontrol *kcontrol, 68 struct AudioCtrlElemValue *elemValue); 69 #endif // __HI3516_ACODEC_H__ 70