1 /* 2 * Copyright (c) 2022 Institute of Software, CAS. 3 * Author : huangji@nj.iscas.ac.cn 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef RK809_ACCESSORY_IMPL_H 18 #define RK809_ACCESSORY_IMPL_H 19 20 #include <linux/platform_device.h> 21 #include <linux/types.h> 22 #include "audio_dai_if.h" 23 #include "audio_codec_if.h" 24 #include "osal_mem.h" 25 #include "osal_time.h" 26 #include "osal_io.h" 27 #include "securec.h" 28 29 #ifdef __cplusplus 30 #if __cplusplus 31 extern "C" { 32 #endif 33 #endif /* __cplusplus */ 34 35 struct Rk809ChipData { 36 struct CodecData codec; 37 struct DaiData dai; 38 struct HdfDeviceObject *hdev; 39 struct platform_device *pdev; 40 struct regmap *regmap; 41 }; 42 43 typedef enum { 44 RK809_SRT_00 = 0x00, 45 RK809_SRT_01 = 0x01, 46 RK809_SRT_02 = 0x02, 47 RK809_SRT_03 = 0x03, 48 } RK809SampleRateTimes; 49 50 typedef enum { 51 RK809_PREMODE_1 = 0x03, 52 RK809_PREMODE_2 = 0x06, 53 RK809_PREMODE_3 = 0x0C, 54 RK809_PREMODE_4 = 0x18, 55 } RK809PLLInputCLKPreDIV; 56 57 typedef enum { 58 RK809_VDW_16BITS = 0x0F, 59 RK809_VDW_24BITS = 0x17, 60 } RK809_VDW; 61 62 typedef enum { 63 UPDATE_LREG = 0, 64 UPDATE_RREG = 1, 65 } Update_Dest; 66 67 struct RK809DaiParamsVal { 68 uint32_t frequencyVal; 69 uint32_t DataWidthVal; 70 }; 71 struct Rk809ChipData* GetCodecDevice(void); 72 int32_t Rk809DeviceInit(struct AudioCard *audioCard, const struct CodecDevice *device); 73 int32_t Rk809DeviceRegRead(uint32_t reg, uint32_t *val); 74 int32_t Rk809DeviceRegWrite(uint32_t reg, uint32_t value); 75 int32_t RK809CodecReadReg(unsigned long virtualAddress, uint32_t reg, uint32_t *val); 76 int32_t Rk809CodecWriteReg(unsigned long virtualAddress, uint32_t reg, uint32_t value); 77 int32_t Rk809RegBitsUpdate(struct AudioMixerControl regAttr); 78 int32_t Rk809DaiDeviceInit(struct AudioCard *card, const struct DaiDevice *device); 79 int32_t Rk809DaiStartup(const struct AudioCard *card, const struct DaiDevice *device); 80 int32_t Rk809DaiHwParams(const struct AudioCard *card, const struct AudioPcmHwParams *param); 81 int32_t Rk809NormalTrigger(const struct AudioCard *card, int cmd, const struct DaiDevice *device); 82 83 #ifdef __cplusplus 84 #if __cplusplus 85 } 86 #endif 87 #endif 88 89 #endif 90