xref: /utopia/UTPA2-700.0.x/modules/audio/drv/audio/drvMAD.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
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 //  Copyright (c) 2008-2009 MStar Semiconductor, Inc.
80 //  All rights reserved.
81 //
82 //  [Module Name]:
83 //      drvMAD.c
84 //  [Abstract]:
85 //      This module contains code for Audio 1st Decoder driver
86 //      procedure and subroutin
87 //
88 //  [for Doxygen]
89 /// file drvMAD.c
90 /// @brief Subroutine for DVB
91 /// @author MStarSemi Inc.
92 //*******************************************************************************
93 
94 #ifndef _DRVMAD_C_
95 #define _DRVMAD_C_
96 
97 #include "ULog.h"
98 #include "MsCommon.h"
99 #include "MsIRQ.h"
100 #include "MsOS.h"
101 #include "MsTypes.h"
102 
103 
104 #include "drvAUDIO.h"
105 
106 #include "./internal/drvMAD.h"
107 #include "./internal/drvMAD2.h"
108 #include "./internal/drvSIF.h"
109 #include "./internal/drvAudio_Common.h"
110 #include "./internal/drvAUDIO_internal.h"
111 
112 #include "halAUDIO.h"
113 #include "halMAD.h"
114 #include "regAUDIO.h"
115 #if (defined(CHIP_JANUS) || defined(CHIP_MARIA10) || defined(CHIP_MACAW12) || defined(CHIP_EDEN) || defined(CHIP_EULER))
116 #else
117 #include "halMAD2.h"
118 #endif
119 #include "halSIF.h"
120 
121 //-------------------------------------------------------------------------------------------------
122 //  Driver Compiler Options
123 //-------------------------------------------------------------------------------------------------
124 #define DRVMAD_CHECK_SHM_INIT \
125     do { \
126         if (g_AudioVars2 == NULL) \
127         { \
128             AUDIO_PRINT(AUDIO_DEBUG_LEVEL_ERROR, "%s() : Warning! g_AudioVars2 should not be NULL !!!\n", __FUNCTION__); \
129             AUDIO_PRINT(AUDIO_DEBUG_LEVEL_ERROR, "%s() : Perform SHM Init here !!!\n", __FUNCTION__); \
130             if ( MDrv_AUDIO_SHM_Init() == FALSE) \
131             { \
132                 MS_ASSERT(0); \
133             } \
134         } \
135     } while(0)
136 
137 extern AUDIO_SHARED_VARS2    * g_AudioVars2;
138 //====== STAOS PIP START 2012/02/12 ========
139 
140 pFuncPtr_SetAudioParam2  g_FuncPrt_Hal_SetAudioParam2;
141 pFuncPtr_GetAudioInfo2   g_FuncPrt_Hal_GetAudioInfo2;
142 
143 //====== STAOS PIP END 2012/02/12 ========
144 
145 MS_BOOL (*g_FuncPtr_CheckCapability)(AUDIO_DEC_ID eDecId, AudioDecStatus_t * p_AudioDecStatus) = NULL;
146 //Temp mask by Cathy extern MS_U8 CheckIPControlBit(MS_U8 u8Bit);
147 
148 
149 
150 
151 //=====================================
152 
153 MS_U8  DVB_IP_CONTROL_BIT[] =
154 {
155     255,                         //MPEG
156     11,                          //AC3
157     12,                          //AC3P
158     15,                          //DTSDec
159     255,                         //AAC
160     255,                         //MP3
161     255,                         //WMA
162     255,                         //CDLPCM
163     255,                         //RA8LBR
164     255,                         //XPCM
165     255,                         //AC3BP
166     255,                         //NONE
167 };
168 
169 
170 ///-----------------------------------------------------------------------------
171 ////////////////////////////////////////////////////////////////////////////////
172 ////////////////////////////////////////////////////////////////////////////////
173 ///
174 ///        AUDIO_MAD SYSETM Relational Driver Function
175 ///
176 ////////////////////////////////////////////////////////////////////////////////
177 ////////////////////////////////////////////////////////////////////////////////
178 ///-----------------------------------------------------------------------------
179 
180 
181 ////////////////////////////////////////////////////////////////////////////////
182 /// @brief \b Function \b Name: MDrv_MAD_Init()
183 /// @brief \b Function \b Description:  This routine is the initialization for DVB module
184 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_Init(void)185 void MDrv_MAD_Init(void)
186 {
187 
188 //====== STAOS PIP START 2012/02/12 ========
189 
190     g_FuncPrt_Hal_SetAudioParam2 = NULL;
191     g_FuncPrt_Hal_GetAudioInfo2 = NULL;
192 
193 //====== STAOS PIP END 2012/02/12 ========
194 
195     HAL_MAD_Init();
196 }
197 
198 ////////////////////////////////////////////////////////////////////////////////
199 /// @brief \b Function \b Name: MDrv_MAD_SetMemInfo()
200 /// @brief \b Function \b Description:  This routine is used to set the DEC-DSP memory information
201 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_SetMemInfo(void)202 void MDrv_MAD_SetMemInfo(void)
203 {
204     HAL_MAD_SetMemInfo();
205 }
206 
207 ////////////////////////////////////////////////////////////////////////////////
208 /// @brief \b Function \b Name: MDrv_MAD_DisEn_MIUREQ()
209 /// @brief \b Function \b Description: This routine is to reset DVB1 MIU request command.
210 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_DisEn_MIUREQ(void)211 void MDrv_MAD_DisEn_MIUREQ(void)
212 {
213     HAL_MAD_DisEn_MIUREQ();
214 }
215 
216 ////////////////////////////////////////////////////////////////////////////////
217 /// @brief \b Function \b Name: MDrv_MAD_Dis_MIUREQ()
218 /// @brief \b Function \b Description: This routine is to reset DVB1 MIU request command.
219 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_Dis_MIUREQ(void)220 void MDrv_MAD_Dis_MIUREQ(void)
221 {
222     HAL_MAD_Dis_MIUREQ();
223 }
224 
225 ////////////////////////////////////////////////////////////////////////////////
226 /// @brief \b Function \b Name: MDrv_MAD_RSTMAD_DisEn_MIUREQ()
227 /// @brief \b Function \b Description: This routine is to reset DVB1 MIU request command.
228 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_RSTMAD_DisEn_MIUREQ(void)229 void MDrv_MAD_RSTMAD_DisEn_MIUREQ(void)
230 {
231     HAL_MAD_RSTMAD_DisEn_MIUREQ();
232 }
233 
234 ////////////////////////////////////////////////////////////////////////////////
235 /// @brief \b Function \b Name: MDrv_MAD_LoadCode()
236 /// @brief \b Function \b Description: This routine is used to load the DVB algorithm code
237 /// @param u8Type      \b algorithm type
238 /// @return MS_BOOL    \b TRUE --DSP load code okay
239 ///                       FALSE--DSP load code fail
240 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_LoadCode(AUDIO_DSP_CODE_TYPE dspCodeType)241 MS_BOOL MDrv_MAD_LoadCode(AUDIO_DSP_CODE_TYPE dspCodeType)
242 {
243     return HAL_MAD_LoadCode(dspCodeType);
244 }
245 
246 ////////////////////////////////////////////////////////////////////////////////
247 /// @brief \b Function \b Name: MDrv_MAD_SetAdMixMode()
248 /// @brief \b Function \b Description: This routine is used to set MPEG mixed with AD or AD mixed with MPEG or not.
249 /// @param u8Mix_mode  \b MAIN_MIX_AD 0--main mix to AD
250 ///                       AD_MIX_MAIN 1--AD mix to main
251 /// @param u8EnMix     \b MIX_OFF 0--disable AD mix
252 ///                       MIX_ON 1--enable AD mix
253 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_SetAdMixMode(AD_MIX_MODE u8Mix_mode,MIX_ONOFF u8EnMix)254 void MDrv_MAD_SetAdMixMode (AD_MIX_MODE u8Mix_mode, MIX_ONOFF u8EnMix)
255 {
256     HAL_MAD_SetAdMixMode(u8Mix_mode, (MS_BOOL)u8EnMix);
257 }
258 
259 ////////////////////////////////////////////////////////////////////////////////
260 /// @brief \b Function \b Name: MDrv_AUD_Monitor_SPDIF_NONPCM_SmpRate()
261 /// @brief \b Function \b Description: This routine is used to set reference ADC clock by DD+ dsp code
262 ////////////////////////////////////////////////////////////////////////////////
MDrv_AUD_Monitor_SPDIF_NONPCM_SmpRate(void)263 void MDrv_AUD_Monitor_SPDIF_NONPCM_SmpRate(void)
264 {
265     HAL_MAD_Monitor_DDPlus_SPDIF_Rate();
266 }
267 
268 ////////////////////////////////////////////////////////////////////////////////
269 /// @brief \b Function \b Name: MDrv_AUDIO_SetCertMode()
270 /// @brief \b Function \b Description:
271 /// @param CertType    \b :
272 /// @param enable      \b :
273 ///
274 ////////////////////////////////////////////////////////////////////////////////
MDrv_AUDIO_SetCertMode(Audio_CertMode CertType,Audio_CertEnable enCert)275 MS_BOOL MDrv_AUDIO_SetCertMode( Audio_CertMode CertType, Audio_CertEnable enCert )
276 {
277     return(HAL_AUDIO_SetCertMode(CertType, enCert));
278 }
279 
280 
281 ////////////////////////////////////////////////////////////////////////////////
282 /// @brief \b Function \b Name: MDrv_AUDIO_MM2_initAesInfo()
283 /// @brief \b Function \b Description  : Initialize AES info
284 /// @param <IN>        \b dec_id  : Decoder ID
285 /// @param <OUT>       \b MS_BOOL : return TRUE if ok, else return FALSE
286 /// @param <GLOBAL>    \b NONE    :
287 ////////////////////////////////////////////////////////////////////////////////
MDrv_AUDIO_MM2_initAesInfo(AUDIO_DEC_ID dec_id)288 MS_BOOL MDrv_AUDIO_MM2_initAesInfo( AUDIO_DEC_ID  dec_id )
289 {
290     return HAL_MAD_MM2_initAesInfo( dec_id );
291 }
292 
293 ////////////////////////////////////////////////////////////////////////////////
294 /// @brief \b Function \b Name: MDrv_AUDIO_MM2_checkAesInfo()
295 /// @brief \b Function \b Description  : Get AES info from audio decoder
296 /// @param <IN>        \b dec_id       : Decoder ID
297 /// @param <IN>        \b aes_info     : AES info structure pointer
298 /// @param <OUT>       \b MS_BOOL : return TRUE if ok, else return FALSE
299 /// @param <GLOBAL>    \b NONE    :
300 ////////////////////////////////////////////////////////////////////////////////
MDrv_AUDIO_MM2_checkAesInfo(AUDIO_DEC_ID dec_id,AES_INFO * aes_info)301 MS_BOOL MDrv_AUDIO_MM2_checkAesInfo( AUDIO_DEC_ID  dec_id, AES_INFO *aes_info )
302 {
303     return HAL_MAD_MM2_checkAesInfo( dec_id,  aes_info);
304 }
305 
306 ////////////////////////////////////////////////////////////////////////////////
307 /// @brief \b Function \b Name: MDrv_AUDIO_MM2_inputAesFinished()
308 /// @brief \b Function \b Description  : Inform DSP how much ES data is sent
309 /// @param <IN>        \b dec_id       : Decoder ID
310 /// @param <IN>        \b es_size  : Size of ES data
311 /// @param <IN>        \b ptsExist : Whether ES data contains PTS or not
312 /// @param <IN>        \b pts      : PTS
313 /// @param <OUT>       \b MS_BOOL  : return TRUE if ok, else return FALSE
314 /// @param <GLOBAL>    \b NONE     :
315 ////////////////////////////////////////////////////////////////////////////////
MDrv_AUDIO_MM2_inputAesFinished(AUDIO_DEC_ID dec_id,MS_U32 es_size,MS_BOOL ptsExist,MS_U64 pts)316 MS_BOOL MDrv_AUDIO_MM2_inputAesFinished( AUDIO_DEC_ID dec_id, MS_U32 es_size, MS_BOOL ptsExist, MS_U64 pts )
317 {
318     return HAL_MAD_MM2_inputAesFinished( dec_id,  es_size,  ptsExist,  pts);
319 }
320 
321 
322 ///-----------------------------------------------------------------------------
323 ////////////////////////////////////////////////////////////////////////////////
324 ////////////////////////////////////////////////////////////////////////////////
325 ///
326 ///        AUDIO_MAD Common Relational Driver Function
327 ///
328 ////////////////////////////////////////////////////////////////////////////////
329 ////////////////////////////////////////////////////////////////////////////////
330 ///-----------------------------------------------------------------------------
331 //******************************************************************************
332 /// @brief \b Function \b Name: MDrv_AUDIO_SetMpegInfo()
333 /// @brief \b Function \b Description: This routine is used for adjust MPEG Audio decoder parameters
334 /// @return MS_BOOL    \b : True / False
335 //******************************************************************************
MDrv_AUDIO_SetCommAudioInfo(Audio_COMM_infoType infoType,MS_VIRT param1,MS_VIRT param2)336 MS_BOOL MDrv_AUDIO_SetCommAudioInfo( Audio_COMM_infoType infoType, MS_VIRT param1, MS_VIRT param2 )
337 {
338     MS_BOOL result = TRUE;//UT
339 
340     if (infoType == Audio_Comm_infoType_ADEC1_setAudioDecoder)
341     {
342         switch((MMA_AudioType)param1)
343         {
344             case Audio_DEC_PCM:
345             case Audio_DEC_XPCM:        MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_XPCM);        break;
346             case Audio_DEC_MPEG:        MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_MPEG);        break;
347             case Audio_DEC_MP3:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_MP3);         break;
348             case Audio_DEC_AC3:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_AC3);         break;
349             case Audio_DEC_AC3P:        MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_AC3P);        break;
350             case Audio_DEC_AAC_LC:
351             case Audio_DEC_HEAAC_V1:
352             case Audio_DEC_HEAAC_V2:    MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_AAC);         break;
353             case Audio_DEC_DOLBYPULSE:  MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_MS10_DDT);    break;
354             case Audio_DEC_WMA:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_WMA);         break;
355             case Audio_DEC_WMAPRO:      MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_WMA_PRO);     break;
356             case Audio_DEC_RA8:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_RA8LBR);      break;
357             case Audio_DEC_DTS:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_DTS);         break;
358             case Audio_DEC_FLAC:        MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_FLAC);        break;
359             case Audio_DEC_VORBIS:      MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_VORBIS);      break;
360             case Audio_DEC_AMR_NB:      MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_AMR_NB);      break;
361             case Audio_DEC_AMR_WB:      MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_AMR_WB);      break;
362             case Audio_DEC_DRA:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_DRA);      break;
363             case Audio_DEC_Dolby_TrueHD_Bypass_R2:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_DolbyTrueHDBypass);      break;
364             case Audio_DEC_DTS_HD_ADO_R2:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB_DTSHDADO);      break;
365             case Audio_DEC_KTV:
366             case Audio_DEC_KTV2:
367             default:
368                 AUDIO_PRINT(AUDIO_DEBUG_LEVEL_ERROR, "Unsupported Audio type\n");
369                 result = FALSE;//UT
370                 break;
371         }
372     }
373     else if (infoType == Audio_Comm_infoType_ADEC2_setAudioDecoder)
374     {
375         switch((MMA_AudioType)param1)
376         {
377             case Audio_DEC_PCM:
378             case Audio_DEC_XPCM:        MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB2_XPCM);      break;
379             case Audio_DEC_MPEG:        MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB2_MPEG);      break;
380             case Audio_DEC_MP3:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB2_MP3);       break;
381             case Audio_DEC_AC3:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB2_AC3);       break;
382             case Audio_DEC_AC3P:        MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB2_AC3P);      break;
383             case Audio_DEC_AAC_LC:
384             case Audio_DEC_HEAAC_V1:
385             case Audio_DEC_HEAAC_V2:    MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB2_GAAC);       break;
386             case Audio_DEC_DOLBYPULSE:  MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB2_AAC);    break;
387             case Audio_DEC_WMA:
388             case Audio_DEC_WMAPRO:
389             case Audio_DEC_RA8:
390             case Audio_DEC_DTS:
391             case Audio_DEC_FLAC:
392             case Audio_DEC_KTV:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB2_KTV);       break;
393             case Audio_DEC_KTV2:        MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB2_KTV2);      break;
394             case Audio_DEC_Dolby_TrueHD_Bypass_R2:     MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB2_DolbyTrueHDBypass);      break;
395             case Audio_DEC_DTS_HD_ADO_R2:         MDrv_AUDIO_SetSystem(MSAPI_AUD_DVB2_DTSHDADO);      break;
396             case Audio_DEC_DRA:
397             default:
398                 AUDIO_PRINT(AUDIO_DEBUG_LEVEL_ERROR, "Unsupported Audio type\n");
399                 result = FALSE;//UT
400                 break;
401         }
402     }
403     else if (infoType == Audio_Comm_infoType_ADEC3_setAudioDecoder)
404     {
405         switch((MMA_AudioType)param1)
406         {
407             case Audio_DEC_PCM:
408             case Audio_DEC_XPCM:
409             case Audio_DEC_MPEG:
410             case Audio_DEC_MP3:
411             case Audio_DEC_AC3:
412             case Audio_DEC_AC3P:
413             case Audio_DEC_AAC_LC:
414             case Audio_DEC_HEAAC_V1:
415             case Audio_DEC_HEAAC_V2:
416             case Audio_DEC_DOLBYPULSE:
417             case Audio_DEC_WMA:
418             case Audio_DEC_WMAPRO:
419             case Audio_DEC_RA8:
420             case Audio_DEC_DTS:
421             case Audio_DEC_FLAC:
422             case Audio_DEC_KTV:
423             case Audio_DEC_KTV2:
424             case Audio_DEC_DRA:
425             default:
426                 AUDIO_PRINT(AUDIO_DEBUG_LEVEL_ERROR, "Unsupported Audio type\n");
427                 result = FALSE;//UT
428                 break;
429         }
430     }
431     else if (infoType == Audio_comm_infoType_Set_Input_Path)
432     {
433         MDrv_AUDIO_SetInputPath((AUDIO_INPUT_TYPE)param1, (AUDIO_PATH_TYPE)param2);
434     }
435     else
436     {
437         result = HAL_MAD_SetCommInfo(infoType, param1, param2);
438     }
439 
440     return result;
441 }
442 
443 //******************************************************************************
444 /// @brief \b Function \b Name: MDrv_AUDIO_GetMpegInfo()
445 /// @brief \b Function \b Description: This routine will return the 32bit mpeg info according to info type
446 /// @return MS_U32     \b : 32bit info
447 //******************************************************************************
MDrv_AUDIO_GetCommAudioInfo(Audio_COMM_infoType infoType)448 MS_U64 MDrv_AUDIO_GetCommAudioInfo( Audio_COMM_infoType infoType )
449 {
450     return HAL_MAD_GetCommInfo(infoType);
451 }
452 
453 ////////////////////////////////////////////////////////////////////////////////
454 /// @brief \b Function \b Name: MDrv_MAD_SetEncCmd()    // kochien added for PVR
455 /// @brief \b Function \b Description: This routine is to set encode command.
456 /// @param u8DecCmd    \b command type   :  AU_DVB_ENCCMD_STOP,      //0
457 ///                                         AU_DVB_ENCCMD_PLAY,      //1
458 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_SetEncCmd(AU_DVB_ENCCMD u8EncCmd)459 void MDrv_MAD_SetEncCmd(AU_DVB_ENCCMD u8EncCmd)
460 {
461     HAL_MAD_SetEncCmd(u8EncCmd);
462 }
463 
464 ////////////////////////////////////////////////////////////////////////////////
465 /// @brief \b Function \b Name: MDrv_AUDIO_SetEncodeInit()
466 /// @brief \b Function \b Description           :  This function is used to init ecode parameters
467 /// @param input       \b Encode Quality(Output Bitrate)-- 0:(default) 192kBps,  1:384kB,  2:128kB, 3:64kB
468 ///                    \b Encode Frame Number   :  how many frame number per interrupt
469 ////////////////////////////////////////////////////////////////////////////////
MDrv_AUDIO_SetEncodeInit(AU_DVB_ENCBR EncBitrate,MS_U8 u8EncFrameNum)470 void MDrv_AUDIO_SetEncodeInit(AU_DVB_ENCBR EncBitrate, MS_U8 u8EncFrameNum)
471 {
472     HAL_MAD_EncodeInit(EncBitrate, u8EncFrameNum);
473 }
474 
475 ////////////////////////////////////////////////////////////////////////////////
476 /// @brief \b Function \b Name: MDrv_AUDIO_GetEncodeFrameInfo()
477 /// @brief \b Function \b Description   :  This function is used to get the Encoded frame info
478 /// @param input       \b FrameInfo     :  structure to store encoded frame info
479 ////////////////////////////////////////////////////////////////////////////////
MDrv_AUDIO_GetEncodeFrameInfo(AU_DVB_ENC_FRAME_INFO * FrameInfo)480 void MDrv_AUDIO_GetEncodeFrameInfo(AU_DVB_ENC_FRAME_INFO *FrameInfo)
481 {
482     HAL_AUDIO_GetEncodeFrameInfo(FrameInfo);
483 }
484 
485 ////////////////////////////////////////////////////////////////////////////////
486 /// @brief \b Function \b Name: MDrv_MAD_SetDecCmd()
487 /// @brief \b Function \b Description: This routine is to set  the DVB1 decode command.
488 /// @param u8DecCmd    \b command type   :
489 ///                                AU_DVB_DECCMD_STOP = 0,
490 ///                                AU_DVB_DECCMD_PLAY = 1,
491 ///                                AU_DVB_DECCMD_PLAYFILETSP = 2,
492 ///                                AU_DVB_DECCMD_RESYNC,
493 ///                                    ....etc
494 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_DecoderCmd(AUDIO_DEC_ID DecId,AU_DVB_DECCMD u8DecCmd)495 MS_BOOL MDrv_MAD_DecoderCmd(AUDIO_DEC_ID DecId, AU_DVB_DECCMD u8DecCmd)
496 {
497     DRVMAD_CHECK_SHM_INIT;
498 
499     HAL_MAD_SetDecCmd2(DecId, u8DecCmd);
500 
501     return TRUE;
502 }
503 
504 ////////////////////////////////////////////////////////////////////////////////
505 /// @brief \b Function \b Name: MDrv_MAD_SetDecCmd()
506 /// @brief \b Function \b Description: This routine is to set  the DVB1 decode command.
507 /// @param u8DecCmd    \b command type   :
508 ///                                AU_DVB_DECCMD_STOP = 0,
509 ///                                AU_DVB_DECCMD_PLAY = 1,
510 ///                                AU_DVB_DECCMD_PLAYFILETSP = 2,
511 ///                                AU_DVB_DECCMD_RESYNC,
512 ///                                    ....etc
513 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_SetDecCmd(AU_DVB_DECCMD u8DecCmd)514 void MDrv_MAD_SetDecCmd(AU_DVB_DECCMD u8DecCmd)
515 {
516     HAL_MAD_SetDecCmd(u8DecCmd);
517 }
518 
519 ///////////////////////////////////////////////////////////////////////////////////////
520 /// @brief \b Function      \b Name: MDrv_MAD_GetDecCmd()
521 /// @brief \b Function      \b Description: This routine is to get  the DVB1 decode command.
522 /// @return AU_DVB_DECCMD   \b command type:    AU_DVB_DECCMD_STOP = 0,
523 ///                                             AU_DVB_DECCMD_PLAY = 1,
524 ///                                             AU_DVB_DECCMD_PLAYFILETSP = 2,
525 ///                                             AU_DVB_DECCMD_RESYNC,
526 ///                                             ....etc
527 ///////////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_GetDecCmd(En_DVB_AudioDecoder AdoDecoderNo)528 AU_DVB_DECCMD MDrv_MAD_GetDecCmd(En_DVB_AudioDecoder AdoDecoderNo)
529 {
530     return (AU_DVB_DECCMD) (HAL_MAD_GetDecCmd(AdoDecoderNo)&0xF);
531 }
532 
533 ////////////////////////////////////////////////////////////////////////////////
534 /// @brief \b Function \b Name: MDrv_MAD_Rpt_DTVES()
535 /// @brief \b Function \b Description: This routine is used to report AC3/MPEG stream if exist or not.
536 /// @return MS_U8      \b the decoder status
537 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_Rpt_DTVES(void)538 MS_U8 MDrv_MAD_Rpt_DTVES(void)
539 {
540     return (HAL_MAD_Rpt_DTVES());
541 }
542 
543 ///-----------------------------------------------------------------------------
544 ////////////////////////////////////////////////////////////////////////////////
545 ////////////////////////////////////////////////////////////////////////////////
546 ///
547 ///        AUDIO_MAD MPEG Relational Driver Function
548 ///
549 ////////////////////////////////////////////////////////////////////////////////
550 ////////////////////////////////////////////////////////////////////////////////
551 ///-----------------------------------------------------------------------------
552 //******************************************************************************
553 /// @brief \b Function \b Name: MDrv_AUDIO_SetMpegInfo()
554 /// @brief \b Function \b Description: This routine is used for adjust MPEG Audio decoder parameters
555 /// @return MS_BOOL     \b : True / False
556 //******************************************************************************
MDrv_AUDIO_SetMpegInfo(Audio_MPEG_infoType infoType,MS_VIRT param1,MS_VIRT param2)557 MS_BOOL MDrv_AUDIO_SetMpegInfo( Audio_MPEG_infoType infoType, MS_VIRT param1, MS_VIRT param2 )
558 {
559     return HAL_MAD_SetMpegInfo( infoType, param1, param2 );
560 }
561 
562 //******************************************************************************
563 /// @brief \b Function \b Name: MDrv_AUDIO_GetMpegInfo()
564 /// @brief \b Function \b Description: This routine will return the 32bit mpeg info according to info type
565 /// @return MS_U32     \b : 32bit info
566 //******************************************************************************
MDrv_AUDIO_GetMpegInfo(Audio_MPEG_infoType infoType)567 MS_U32 MDrv_AUDIO_GetMpegInfo( Audio_MPEG_infoType infoType )
568 {
569     return HAL_MAD_GetMpegInfo( infoType);
570 }
571 
572 //******************************************************************************
573 /// @brief \b Function \b Name: MDrv_AUDIO_SetWmaInfo()
574 /// @brief \b Function \b Description: This routine is used for adjust WMA Audio decoder parameters
575 /// @return MS_BOOL    \b : True
576 ///                         False
577 //******************************************************************************
MDrv_AUDIO_SetWmaInfo(Audio_WMA_infoType infoType,MS_VIRT param1,MS_VIRT param2)578 MS_BOOL MDrv_AUDIO_SetWmaInfo( Audio_WMA_infoType infoType, MS_VIRT param1, MS_VIRT param2 )
579 {
580     return HAL_MAD_SetWmaInfo( infoType, param1, param2 );
581 }
582 
583 //******************************************************************************
584 /// @brief \b Function \b Name: MDrv_AUDIO_GetWmaInfo()
585 /// @brief \b Function \b Description: This routine will return the 32bit wma info according to info type
586 /// @return MS_U16     \b : 32bit info
587 //******************************************************************************
MDrv_AUDIO_GetWmaInfo(Audio_WMA_infoType infoType)588 MS_U32 MDrv_AUDIO_GetWmaInfo( Audio_WMA_infoType infoType )
589 {
590     return HAL_MAD_GetWmaInfo(infoType);
591 }
592 
593 //******************************************************************************
594 /// @brief \b Function \b Name: MDrv_AUDIO_SetAC3Info()
595 /// @brief \b Function \b Description: This routine is used for adjust AC3 Audio decoder parameters
596 /// @return MS_BOOL    \b : True
597 ///                         False
598 //******************************************************************************
MDrv_AUDIO_SetAC3Info(Audio_AC3_infoType infoType,MS_VIRT param1,MS_VIRT param2)599 MS_BOOL MDrv_AUDIO_SetAC3Info( Audio_AC3_infoType infoType, MS_VIRT param1, MS_VIRT param2 )
600 {
601     return HAL_MAD_SetAC3Info( infoType, param1, param2 );
602 }
603 
604 //******************************************************************************
605 /// @brief \b Function \b Name: MDrv_AUDIO_GetAC3Info()
606 /// @brief \b Function \b Description: This routine will return the 32bit ac3 info according to info type
607 /// @return MS_U32     \b : 32bit info
608 //******************************************************************************
MDrv_AUDIO_GetAC3Info(Audio_AC3_infoType infoType)609 MS_U32 MDrv_AUDIO_GetAC3Info( Audio_AC3_infoType infoType )
610 {
611     return HAL_MAD_GetAC3Info(infoType);
612 }
613 
614 //******************************************************************************
615 /// @brief \b Function \b Name: MDrv_AUDIO_SetAC3PInfo()
616 /// @brief \b Function \b Description: This routine is used for adjust AC3 Audio decoder parameters
617 /// @return MS_BOOL    \b : True
618 ///                         False
619 //******************************************************************************
MDrv_AUDIO_SetAC3PInfo(Audio_AC3P_infoType infoType,MS_VIRT param1,MS_VIRT param2)620 MS_BOOL MDrv_AUDIO_SetAC3PInfo( Audio_AC3P_infoType infoType, MS_VIRT param1, MS_VIRT param2 )
621 {
622     return HAL_MAD_SetAC3PInfo( infoType, param1, param2 );
623 }
624 
625 //******************************************************************************
626 /// @brief \b Function \b Name: MDrv_AUDIO_GetAC3PInfo()
627 /// @brief \b Function \b Description: This routine will return the 32bit ac3 info according to info type
628 /// @return MS_U32     \b : 32bit info
629 //******************************************************************************
MDrv_AUDIO_GetAC3PInfo(Audio_AC3P_infoType infoType)630 MS_U32 MDrv_AUDIO_GetAC3PInfo( Audio_AC3P_infoType infoType )
631 {
632     return HAL_MAD_GetAC3PInfo( infoType);
633 }
634 
635 //******************************************************************************
636 /// @brief \b Function \b Name: MDrv_AUDIO_SetDTSCommonCtrl()
637 /// @brief \b Function \b Description: This routine is used for adjust DTS CA Control
638 /// @return MS_BOOL     \b : True / False
639 //******************************************************************************
MDrv_AUDIO_SetDTSCommonCtrl(Audio_DTS_infoType infoType,Audio_DTS_CtrlType ctrl_type)640 MS_BOOL MDrv_AUDIO_SetDTSCommonCtrl( Audio_DTS_infoType infoType, Audio_DTS_CtrlType ctrl_type )
641 {
642     return HAL_MAD_SetDTSCommonCtrl( infoType, ctrl_type );
643 }
644 
645 //******************************************************************************
646 /// @brief \b Function \b Name: MDrv_AUDIO_GetDTSInfo()
647 /// @brief \b Function \b Description: This routine will return the 32bit DTS info according to info type
648 /// @return MS_U32     \b : 32bit info
649 //******************************************************************************
MDrv_AUDIO_GetDTSInfo(Audio_DTS_infoType infoType)650 MS_U32 MDrv_AUDIO_GetDTSInfo( Audio_DTS_infoType infoType )
651 {
652     return HAL_MAD_GetDTSInfo( infoType);
653 }
654 
655 //******************************************************************************
656 /// @brief \b Function \b Name: MDrv_AUDIO_SetAACInfo()
657 /// @brief \b Function \b Description: This routine is used for adjust AAC Audio decoder parameters
658 /// @return MS_BOOL    \b : True
659 ///                         False
660 //******************************************************************************
MDrv_AUDIO_SetAACInfo(Audio_AAC_infoType infoType,MS_VIRT param1,MS_VIRT param2)661 MS_U32 MDrv_AUDIO_SetAACInfo( Audio_AAC_infoType infoType, MS_VIRT param1, MS_VIRT param2 )
662 {
663     return HAL_MAD_SetAACInfo( infoType, param1, param2 );
664 }
665 
666 //******************************************************************************
667 /// @brief \b Function \b Name: MDrv_AUDIO_GetAACInfo()
668 /// @brief \b Function \b Description: This routine will return the 32bit AAC info according to info type
669 /// @return MS_U32     \b : 32bit info
670 //******************************************************************************
MDrv_AUDIO_GetAACInfo(Audio_AAC_infoType infoType)671 MS_U32 MDrv_AUDIO_GetAACInfo( Audio_AAC_infoType infoType )
672 {
673     return HAL_MAD_GetAACInfo( infoType );
674 }
675 
676 ///-----------------------------------------------------------------------------
677 ////////////////////////////////////////////////////////////////////////////////
678 ////////////////////////////////////////////////////////////////////////////////
679 ///
680 ///        AUDIO_MAD OTHER Relational Drv Function
681 ///
682 ////////////////////////////////////////////////////////////////////////////////
683 ////////////////////////////////////////////////////////////////////////////////
684 ///-----------------------------------------------------------------------------
685 ////////////////////////////////////////////////////////////////////////////////
686 /// @brief \b Function \b Name: MDrv_MAD_XPCM_setParam()
687 /// @brief \b Function \b Description: This routine configures necessary parameters when playing XPCM data
688 /// @param audioType   \b type:               1--lpcm
689 ///                                           2--MS-ADPCM
690 ///                                           17--IMA-ADPCM
691 /// @param Channels     \b  channel num     : 0-- mono
692 ///                                           1-- stereo
693 /// @param sampleRate   \b  sample rate     : 8, 11.025, 16, 22.05, 44.1, 48 (KHz)
694 /// @param bitsPerSample\b  bit per sample  : 8--8 bits
695 ///                                           16--16 bits
696 /// @param blockSize    \b  block size
697 /// @param samplePerBlock \b samples per block
698 /// @return MS_U8       \b  TRUE--parameters are correct
699 ///                         FALSE--parameters are incorrect
700 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_XPCM_setParam(XPCM_TYPE audioType,MS_U8 channels,MS_U16 sampleRate,MS_U8 bitsPerSample,MS_U16 blockSize,MS_U16 samplePerBlock)701 MS_U8 MDrv_MAD_XPCM_setParam (XPCM_TYPE audioType, MS_U8  channels, MS_U16 sampleRate,
702                                                     MS_U8  bitsPerSample, MS_U16 blockSize, MS_U16 samplePerBlock)
703 {
704      return HAL_MAD_XPCM_setParam(audioType, channels, sampleRate,
705                                                    bitsPerSample, blockSize,  samplePerBlock);
706 }
707 
708 ////////////////////////////////////////////////////////////////////////////////
709 /// @brief \b Function \b Name: MDrv_MAD_RA8_setParam()
710 /// @brief \b Function \b Description: This routine configures necessary parameters when playing RA8 LBR data
711 /// @param mNumCodecs  \b 1--stereo or mono
712 ///                       2~5-- multi channels
713 /// @param mSamples    \b output samples--256, 512, 1024
714 /// @param mSampleRate \b 8, 11.025, 16, 22.05, 44.1, 48 (KHz)
715 /// @param Channels    \b 1-- mono
716 ///                       2-- stereo
717 /// @param cplStart    \b 0 ~ 51
718 /// @param Regions     \b 0 ~ 31
719 /// @param cplQbits    \b 0, 2, 3, 4, 5, 6
720 /// @param FrameSize   \b bitstream size of every NumCodes (bytes)
721 ///                       Range--0 ~ 65535
722 /// @return MS_U8      \b TRUE--parameters are correct
723 ///                       FALSE--parameters are incorrect
724 ////////////////////////////////////////////////////////////////////////////////
MDrv_MAD_RA8_setParam(MS_U16 mNumCodecs,MS_U16 mSamples,MS_U16 mSampleRate,MS_U16 * Channels,MS_U16 * Regions,MS_U16 * cplStart,MS_U16 * cplQbits,MS_U16 * FrameSize)725 MS_U8 MDrv_MAD_RA8_setParam(MS_U16 mNumCodecs, MS_U16 mSamples, MS_U16 mSampleRate,
726                             MS_U16* Channels, MS_U16* Regions, MS_U16* cplStart, MS_U16* cplQbits,
727                             MS_U16* FrameSize)
728 {
729     if((Channels == NULL) || (Regions == NULL )|| (cplStart == NULL) || (cplQbits  == NULL) || (FrameSize == NULL))
730         return FALSE;//UT
731 
732     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_NumCodes,   (MS_U32) mNumCodecs,   0);
733     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_Samples,    (MS_U32) mSamples,     0);
734     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_SampleRate, (MS_U32) mSampleRate,  0);
735 
736     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_Channels1,  (MS_U32) Channels[0],  0);
737     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_Regions1,   (MS_U32) Regions[0],   0);
738     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_cplStart1,  (MS_U32) cplStart[0],  0);
739     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_cplQbits1,  (MS_U32) cplQbits[0],  0);
740     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_FrameSize1, (MS_U32) FrameSize[0], 0);
741 
742     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_Channels2,  (MS_U32) Channels[1],  0);
743     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_Regions2,   (MS_U32) Regions[1],   0);
744     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_cplStart2,  (MS_U32) cplStart[1],  0);
745     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_cplQbits2,  (MS_U32) cplQbits[1],  0);
746     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_FrameSize2, (MS_U32) FrameSize[1], 0);
747 
748     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_Channels3,  (MS_U32) Channels[2],  0);
749     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_Regions3,   (MS_U32) Regions[2],   0);
750     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_cplStart3,  (MS_U32) cplStart[2],  0);
751     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_cplQbits3,  (MS_U32) cplQbits[2],  0);
752     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_FrameSize3, (MS_U32) FrameSize[2], 0);
753 
754     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_Channels4,  (MS_U32) Channels[3],  0);
755     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_Regions4,   (MS_U32) Regions[3],   0);
756     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_cplStart4,  (MS_U32) cplStart[3],  0);
757     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_cplQbits4,  (MS_U32) cplQbits[3],  0);
758     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_FrameSize4, (MS_U32) FrameSize[3], 0);
759 
760     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_Channels5,  (MS_U32) Channels[4],  0);
761     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_Regions5,   (MS_U32) Regions[4],   0);
762     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_cplStart5,  (MS_U32) cplStart[4],  0);
763     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_cplQbits5,  (MS_U32) cplQbits[4],  0);
764     HAL_MAD_SetRA8LBRInfo(Audio_RA8LBR_FrameSize5, (MS_U32) FrameSize[4], 0);
765 
766     return TRUE;
767 }
768 
769 //====== STAOS PIP END 2012/02/01 ========
770 
MDrv_AUDIO_GetAudioInfo2(AUDIO_DEC_ID DecId,Audio_InfoType infoType,void * pInfo)771 MS_BOOL MDrv_AUDIO_GetAudioInfo2( AUDIO_DEC_ID DecId, Audio_InfoType infoType, void * pInfo )
772 {
773     if ( g_FuncPrt_Hal_GetAudioInfo2 )
774     {
775         return g_FuncPrt_Hal_GetAudioInfo2(DecId, infoType, pInfo);
776     }
777 
778     AUDIO_PRINT(AUDIO_DEBUG_LEVEL_ERROR, "%s: g_FuncPrt_Hal_GetAudioInfo2 is NULL !!\r\n", __FUNCTION__);
779     return FALSE;
780 }
781 
782 //====== STAOS PIP END 2012/02/01 ========
783 
MDrv_MAD_GetAudioCapability(AUDIO_DEC_ID eDecId,AudioDecStatus_t * p_AudioDecStatus)784 MS_BOOL MDrv_MAD_GetAudioCapability(AUDIO_DEC_ID eDecId, AudioDecStatus_t * p_AudioDecStatus)
785 {
786     if (g_FuncPtr_CheckCapability != NULL)
787     {
788         return g_FuncPtr_CheckCapability(eDecId, p_AudioDecStatus);
789     }
790     else
791     {
792         return FALSE;
793     }
794 }
795 
796 #endif  //#ifndef _DRVMAD_C_