1 //<MStar Software> 2 //****************************************************************************** 3 // MStar Software 4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved. 5 // All software, firmware and related documentation herein ("MStar Software") are 6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by 7 // law, including, but not limited to, copyright law and international treaties. 8 // Any use, modification, reproduction, retransmission, or republication of all 9 // or part of MStar Software is expressly prohibited, unless prior written 10 // permission has been granted by MStar. 11 // 12 // By accessing, browsing and/or using MStar Software, you acknowledge that you 13 // have read, understood, and agree, to be bound by below terms ("Terms") and to 14 // comply with all applicable laws and regulations: 15 // 16 // 1. MStar shall retain any and all right, ownership and interest to MStar 17 // Software and any modification/derivatives thereof. 18 // No right, ownership, or interest to MStar Software and any 19 // modification/derivatives thereof is transferred to you under Terms. 20 // 21 // 2. You understand that MStar Software might include, incorporate or be 22 // supplied together with third party`s software and the use of MStar 23 // Software may require additional licenses from third parties. 24 // Therefore, you hereby agree it is your sole responsibility to separately 25 // obtain any and all third party right and license necessary for your use of 26 // such third party`s software. 27 // 28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as 29 // MStar`s confidential information and you agree to keep MStar`s 30 // confidential information in strictest confidence and not disclose to any 31 // third party. 32 // 33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any 34 // kind. Any warranties are hereby expressly disclaimed by MStar, including 35 // without limitation, any warranties of merchantability, non-infringement of 36 // intellectual property rights, fitness for a particular purpose, error free 37 // and in conformity with any international standard. You agree to waive any 38 // claim against MStar for any loss, damage, cost or expense that you may 39 // incur related to your use of MStar Software. 40 // In no event shall MStar be liable for any direct, indirect, incidental or 41 // consequential damages, including without limitation, lost of profit or 42 // revenues, lost or damage of data, and unauthorized system use. 43 // You agree that this Section 4 shall still apply without being affected 44 // even if MStar Software has been modified by MStar in accordance with your 45 // request or instruction for your use, except otherwise agreed by both 46 // parties in writing. 47 // 48 // 5. If requested, MStar may from time to time provide technical supports or 49 // services in relation with MStar Software to you for your use of 50 // MStar Software in conjunction with your or your customer`s product 51 // ("Services"). 52 // You understand and agree that, except otherwise agreed by both parties in 53 // writing, Services are provided on an "AS IS" basis and the warranty 54 // disclaimer set forth in Section 4 above shall apply. 55 // 56 // 6. Nothing contained herein shall be construed as by implication, estoppels 57 // or otherwise: 58 // (a) conferring any license or right to use MStar name, trademark, service 59 // mark, symbol or any other identification; 60 // (b) obligating MStar or any of its affiliates to furnish any person, 61 // including without limitation, you and your customers, any assistance 62 // of any kind whatsoever, or any information; or 63 // (c) conferring any license or right under any intellectual property right. 64 // 65 // 7. These terms shall be governed by and construed in accordance with the laws 66 // of Taiwan, R.O.C., excluding its conflict of law rules. 67 // Any and all dispute arising out hereof or related hereto shall be finally 68 // settled by arbitration referred to the Chinese Arbitration Association, 69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration 70 // Rules of the Association by three (3) arbitrators appointed in accordance 71 // with the said Rules. 72 // The place of arbitration shall be in Taipei, Taiwan and the language shall 73 // be English. 74 // The arbitration award shall be final and binding to both parties. 75 // 76 //****************************************************************************** 77 //<MStar Software> 78 //////////////////////////////////////////////////////////////////////////////// 79 // 80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc. 81 // All rights reserved. 82 // 83 // Unless otherwise stipulated in writing, any and all information contained 84 // herein regardless in any format shall remain the sole proprietary of 85 // MStar Semiconductor Inc. and be kept in strict confidence 86 // ("MStar Confidential Information") by the recipient. 87 // Any unauthorized act including without limitation unauthorized disclosure, 88 // copying, use, reproduction, sale, distribution, modification, disassembling, 89 // reverse engineering and compiling of the contents of MStar Confidential 90 // Information is unlawful and strictly prohibited. MStar hereby reserves the 91 // rights to any and all damages, losses, costs and expenses resulting therefrom. 92 // 93 /// @file drvAUDIO.h 94 /// @author MStar Semiconductor Inc. 95 /// @brief Audio common driver 96 // 97 /////////////////////////////////////////////////////////////////////////////// 98 //////////////////////////////////////////////////////////////////////////////// 99 100 #ifndef _DRVAUDIO_H_ 101 #define _DRVAUDIO_H_ 102 103 //////////////////////////////////////////////////////////////////////////////// 104 // Header Files 105 //////////////////////////////////////////////////////////////////////////////// 106 #include "MsTypes.h" 107 #include "drvAUDIO_if.h" 108 109 #ifdef __cplusplus 110 extern "C" 111 { 112 #endif 113 114 //////////////////////////////////////////////////////////////////////////////// 115 // Define & data type 116 //////////////////////////////////////////////////////////////////////////////// 117 /// Version string. 118 #define MSIF_AUDIO_LIB_CODE {'A','U','D','-'} //Lib code 119 #define MSIF_AUDIO_LIBVER {'0','0'} //LIB version 120 #define MSIF_AUDIO_BUILDNUM {'5','B'} //Build Number 121 #define MSIF_AUDIO_CHANGELIST {'0','0','0','0','0','0','0','0'} //P4 ChangeList Number 122 123 #define AUD_DRV_VERSION /* Character String for DRV/API version */ \ 124 MSIF_TAG, /* 'MSIF' */ \ 125 MSIF_CLASS, /* '00' */ \ 126 MSIF_CUS, /* 0x0000 */ \ 127 MSIF_MOD, /* 0x0000 */ \ 128 MSIF_CHIP, \ 129 MSIF_CPU, \ 130 MSIF_AUDIO_LIB_CODE, /* IP__ */ \ 131 MSIF_AUDIO_LIBVER, /* 0.0 ~ Z.Z */ \ 132 MSIF_AUDIO_BUILDNUM, /* 00 ~ 99 */ \ 133 MSIF_AUDIO_CHANGELIST, /* CL# */ \ 134 MSIF_OS 135 136 #define AU_memcpy( pDstAddr, pSrcAddr, u32Size) \ 137 do { \ 138 register MS_U32 u32I=0; \ 139 register MS_VIRT virtDst = (MS_VIRT)pDstAddr; \ 140 void * pSrc = (void *)pSrcAddr; \ 141 if( (virtDst % 4) || ((MS_VIRT)pSrc % 4) ) \ 142 { \ 143 for( u32I=0; u32I< (MS_U32)(u32Size); u32I++) \ 144 { \ 145 ((volatile MS_U8 *)virtDst)[u32I] = ((volatile MS_U8 *)pSrc)[u32I]; \ 146 } \ 147 } \ 148 else \ 149 { \ 150 for( u32I=0; u32I < ((MS_U32)(u32Size)/4); u32I++) \ 151 { \ 152 ((volatile MS_U32 *)virtDst)[u32I] = ((volatile MS_U32 *)pSrc)[u32I]; \ 153 } \ 154 virtDst += u32I*4; \ 155 pSrc = (void *)((MS_VIRT)pSrc + u32I*4); \ 156 if((u32Size)%4) \ 157 { \ 158 for( u32I=0; u32I<((MS_U32)(u32Size)%4); u32I++) \ 159 { \ 160 ((volatile MS_U8 *)virtDst)[u32I] = ((volatile MS_U8 *)pSrc)[u32I]; \ 161 } \ 162 } \ 163 } \ 164 }while(0) 165 166 #define AU_Memset(pDstAddr, u8value, u32Size) \ 167 do { \ 168 MS_U32 i = 0; \ 169 volatile MS_U8 *dst = (volatile MS_U8 *)(pDstAddr); \ 170 for (i = 0; i < (u32Size); i++) \ 171 { \ 172 dst[i] = (u8value); \ 173 } \ 174 } while (0) 175 176 #define HDMI_NonPCM_Mask 0x01 177 #define HDMI_Input_Path_Mask 0x10 178 179 typedef struct 180 { 181 MS_S32 (*open)(void *pData); 182 MS_S32 (*close)(void); 183 MS_S32 (*start)(void); 184 MS_S32 (*stop)(void); 185 MS_S32 (*set)(MS_U32 u32Cmd, const void *pData); 186 MS_S32 (*get)(MS_U32 u32Cmd, void *pData); 187 MS_U32 (*read)(void *pBuf, MS_U32 u32Size); 188 MS_U32 (*write)(const void *pBuf, MS_U32 u32Size); 189 MS_S32 (*flush)(void); 190 } AUDIO_PCM_OPS_t; 191 192 typedef struct 193 { 194 MS_U8 u8MultiChFlag; 195 MS_U8 u8MixingFlag; 196 MS_U32 u32Channel[16]; 197 MS_U32 u32SampleRate[32]; 198 MS_U32 u32BitWidth[8]; 199 } AUDIO_PCM_CAPS_t; 200 201 typedef struct 202 { 203 MS_U8 u8Name[32]; /* PCM name (only 32 bytes, if change this length, must change u8Name of AUDIO_PCM_INFO_t as well!) */ 204 AUDIO_PCM_OPS_t tPcmOps; /* PCM operators */ 205 AUDIO_PCM_CAPS_t tPcmCaps; /* PCM operators */ 206 AUDIO_PCM_INFO_t *tPcmInfo; /* PCM information */ 207 MS_U8 u8SettingChangeFlag; 208 MS_U32 u32RemainSize; 209 } AUDIO_PCM_t; 210 211 typedef enum 212 { 213 Hdmi_Input_Main = 0x00, 214 Hdmi_Input_Sub = 0x10, 215 216 } Hdmi_Input_Path; 217 218 //================================================================ 219 // AUDIO version informtion functions 220 //================================================================ 221 // extern MS_BOOL MDrv_AUD_GetLibVer(const MSIF_Version **ppVersion); 222 223 //================================================================ 224 // Basic Register read/write function 225 //================================================================ 226 MS_U16 MDrv_AUDIO_ReadReg(MS_U32 u32RegAddr); 227 void MDrv_AUDIO_WriteReg(MS_U32 u32RegAddr, MS_U16 u16Val); 228 void MDrv_AUDIO_WriteMaskReg(MS_U32 u32RegAddr, MS_U16 u16Mask, MS_U16 u16Val); 229 230 MS_U8 MDrv_AUDIO_ReadByte(MS_U32 addr); 231 // MS_U8 MDrv_AUDIO_DecReadByte(MS_U32 addr); 232 MS_U8 MDrv_AUDIO_SeReadByte(MS_U32 addr); 233 234 void MDrv_AUDIO_WriteByte(MS_U32 addr, MS_U8 value); 235 // void MDrv_AUDIO_DecWriteByte(MS_U32 addr, MS_U8 value); 236 // void MDrv_AUDIO_SeWriteByte(MS_U32 addr, MS_U8 value); 237 238 void MDrv_AUDIO_WriteMaskByte(MS_U32 u32RegAddr, MS_U8 u8Mask, MS_U8 u8Val); 239 // void MDrv_AUDIO_DecWriteMaskByte(MS_U32 u32RegAddr, MS_U8 u8Mask, MS_U8 u8Val); 240 void MDrv_AUDIO_SeWriteMaskByte(MS_U32 u32RegAddr, MS_U8 u8Mask, MS_U8 u8Val); 241 242 MS_U16 MDrv_AUDIO_ReadDecMailBox(MS_U8 paramNum); 243 void MDrv_AUDIO_WriteDecMailBox(MS_U8 paramNum, MS_U16 data1); 244 // MS_U16 MDrv_AUDIO_ReadSeMailBox(MS_U8 paramNum); 245 // void MDrv_AUDIO_WriteSeMailBox(MS_U8 paramNum, MS_U16 data1); 246 247 //================================================================ 248 // For Audio initialize 249 //================================================================ 250 void MDrv_AUDIO_InitMMIO(void); 251 // MS_BOOL MDrv_AUDIO_AttachInterrupt(MS_BOOL bEnable); 252 // MS_BOOL MDrv_AUDIO_Mutex_Init(void); 253 // MS_BOOL MDrv_AUDIO_SHM_Init(void); 254 MS_BOOL MDrv_AUDIO_Init(void); 255 MS_BOOL MDrv_AUDIO_Close(void); 256 MS_BOOL MDrv_AUDIO_Open(void); 257 // void MDrv_AUDIO_WriteInitTable(void); 258 // void MDrv_AUDIO_WritePreInitTable(void); //Refine power on sequence for earphone & DAC pop noise issue 259 // void MDrv_AUDIO_EnaEarphone_LowPower_Stage(void); //Refine power on sequence for earphone & DAC pop noise issue 260 // void MDrv_AUDIO_EnaEarphone_HighDriving_Stage(void); //Refine power on sequence for earphone & DAC pop noise issue 261 void MDrv_AUDIO_SwResetMAD(void); 262 void MDrv_AUDIO_SetDspBaseAddr(MS_U8 u8Index, MS_PHY phyBin_Base_Address, MS_PHY phyMad_Base_Buffer_Adr); 263 // MS_PHY MDrv_AUDIO_GetDspBinBaseAddr(MS_U8 u8Iindex); 264 MS_PHY MDrv_AUDIO_GetDspMadBaseAddr(MS_U8 u8Index) ; 265 // void MDrv_AUDIO_DspBootOnDDR(MS_BOOL bEnable); 266 // MS_BOOL MDrv_AUDIO_DecoderLoadCode(void); 267 // MS_BOOL MDrv_AUDIO_SeSystemLoadCode(void); 268 // void MDrv_AUDIO_DspReboot(MS_U8 param); 269 // void MDrv_AUDIO_RebootDecDSP(void); 270 void MDrv_AUDIO_TriggerSifPLL(void); 271 void MDrv_AUDIO_SetPlayFileFlag(MS_BOOL bDspType, MS_BOOL bSet); 272 MS_BOOL MDrv_AUDIO_GetPlayFileFlag(MS_BOOL bDspType); 273 // MS_BOOL MDrv_AUDIO_InitialVars(void); 274 // void MDrv_AUDIO_SET_INIT_FLAG(MS_BOOL bSet); 275 // MS_BOOL MDrv_AUDIO_GET_INIT_FLAG(void); 276 277 //================================================================ 278 // Audio I/O Config. function 279 //================================================================ 280 // AUDIO_PATH_GROUP_TYPE MDrv_AUDIO_GetPathGroup(void); 281 void MDrv_AUDIO_SetNormalPath(AUDIO_PATH_TYPE u8Path, AUDIO_INPUT_TYPE u8Input, AUDIO_OUTPUT_TYPE output); 282 void MDrv_AUDIO_SetInputPath( AUDIO_INPUT_TYPE u8Input, AUDIO_PATH_TYPE u8Path); 283 // void MDrv_AUDIO_SetOutputPath( AUDIO_PATH_TYPE u8Path, AUDIO_OUTPUT_TYPE u8Output); 284 void MDrv_AUDIO_SetInternalPath(AUDIO_INTERNAL_PATH_TYPE u8Path, AUDIO_OUTPUT_TYPE u8Output); 285 286 MS_U8 MDrv_AUDIO_ReadDspCodeType(void); 287 288 // void MDrv_AUDIO_BT_SetUploadRate(MS_BOOL bEnable, MS_U8 u8Samprate); 289 // void MDrv_AUDIO_BT_SetBufferCounter(MS_U32 u32Counter); 290 291 MS_U8 MDrv_AUDIO_ReadDspCounter(AUDIO_DSP_COUNTER_TYPE CounterType); 292 void MDrv_AUDIO_SetPowerDownWait(MS_BOOL bEnable); 293 // MS_BOOL MDrv_AUDIO_IsDTV(void); 294 // void MDrv_AUDIO_SetFading(MS_U32 u32VolFading); 295 296 //===================================================== 297 // AUDIO SPDIF Relational Hal Function 298 //===================================================== 299 // void MDrv_AUDIO_SPDIF_SetMute(MS_U8 mute_en); 300 void MDrv_AUDIO_SPDIF_SetMode(MS_U8 spdif_mode, MS_U8 input_src); 301 // void MDrv_AUDIO_SPDIF_ByPassChannel(MS_BOOL u8Enable); 302 void MDrv_AUDIO_SPDIF_SetChannelStatus(SPDIF_CS_MODE_TYPE eType, SPDIF_CS_MODE_VALUE eValue); 303 // void MDrv_AUDIO_SPDIF_Monitor_SamplingRate(void); 304 //===================================================== 305 // AUDIO HDMI Relational Hal Function 306 //===================================================== 307 // void MDrv_AUDIO_HDMI_Tx_GetStatus(MS_BOOL *onOff, AUDIO_FS_TYPE *hdmi_SmpFreq, HDMI_TX_OUTPUT_TYPE *outType ); 308 MS_U8 MDrv_AUDIO_HDMI_DolbyMonitor(void); 309 // void MDrv_AUDIO_HDMI_AC3_PathCFG(MS_U8 u8Ctrl); 310 // void MDrv_AUDIO_HDMI_TX_SetMode(HDMI_TX_OUTPUT_TYPE outType, AUDIO_SOURCE_INFO_TYPE eSource); 311 //================================================================ 312 // for audio driver internal use function 313 //================================================================ 314 // void MDrv_AUDIO_AdcInit(void); 315 // MS_U8 MDrv_AUDIO_GetDecoderStatus(void); 316 317 // MS_U16 MDrv_AUDIO_GetUniDecodeDoneTag(void); 318 319 // void MDrv_AUDIO_update_DspUsage(AUDIO_SOURCE_INFO_TYPE eSourceType); 320 //================================================================ 321 // Audio ALSA Interface Relational Function 322 //================================================================ 323 // MS_BOOL MDrv_AUDIO_ALSA_Enable(MS_BOOL bEnable); 324 325 // void MDrv_AUDIO_DumpDspInfo(void); 326 327 // MS_U32 MDrv_AUDIO_GetCaps(AUDIO_DEC_ID DecId, MS_U32 *pCaps); 328 329 #ifdef __cplusplus 330 } 331 #endif 332 333 #endif 334 335