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 // drvSOUND.c
84 // [Abstract]:
85 // This module contains code for Audio Processor driver
86 // procedure and subroutin
87 // [Reversion History]:
88 // Initial release: 15 July, 2005
89 //
90 // [Doxygen]
91 /// file drvSOUND.c
92 /// @brief Subroutine for sound effect
93 /// @author MStarSemi Inc.
94 //*******************************************************************************
95
96 #define _DRVSOUND_C_
97
98 // Internal
99 #include "drvAUDIO.h"
100 #include "drvAUDIO_if.h"
101
102 #include "./internal/drvSOUND.h"
103
104 #include "halSOUND.h"
105 #include "halAUDIO.h"
106
107 #define GET_MAP_VALUE(_X_,_Y_,_Z_) ((MS_U16)(_X_) * (_Y_) / (_Z_))
108
109
110 //====================================================================
111
112 ////////////////////////////////////////////////////////////////////////////////
113 /// @brief \b Function \b Name: MDrv_SOUND_Init()
114 /// @brief \b Function \b Description: This routine is the initialization for Audio sound effect module.
115 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_Init(void)116 void MDrv_SOUND_Init(void)
117 {
118 HAL_SOUND_Init2();
119 }
120
121 ////////////////////////////////////////////////////////////////////////////////
122 /// @brief \b Function \b Name: MDrv_SOUND_SetMute()
123 /// @brief \b Function \b Description: This routine is used to set audio u8Path S/W mute.
124 /// @param u8Path \b : for audio u8Path0 ~ u8Path6
125 /// @param bEnable \b : TRUE --Mute
126 /// FALSE--Unmute
127 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetMute(MS_U8 u8Path,MS_BOOL bEnable)128 void MDrv_SOUND_SetMute(MS_U8 u8Path, MS_BOOL bEnable)
129 {
130 AUDIO_PATH_GROUP_TYPE PathGroup = AUDIO_PATH_GROUP_1;
131
132 PathGroup = MDrv_AUDIO_GetPathGroup();
133
134 if (((PathGroup == AUDIO_PATH_GROUP_1) && (u8Path == AUDIO_PATH_3)) ||
135 ((PathGroup == AUDIO_PATH_GROUP_2) && (u8Path == AUDIO_T3_PATH_SPDIF)))
136 {
137 MDrv_AUDIO_SPDIF_SetMute((MS_U8)bEnable);
138 }
139 else
140 {
141 HAL_SOUND_SetMute(u8Path, bEnable);
142 }
143 }
144
145 ////////////////////////////////////////////////////////////////////////////////
146 /// @brief \b Function \b Name: MDrv_SOUND_AbsoluteVolume()
147 /// @brief \b Function \b Description: This routine is used to set the absolute u8Volume of audio u8Path.
148 /// @param u8Path \b : for audio u8Path0 ~ u8Path6
149 /// @param u8Vol1 \b : MSB 7-bit register value of 10-bit u8Volume
150 /// range from 0x00 to 0x7E , gain: +12db to -114db (-1 db per step)
151 /// @param u8Vol2 \b : LSB 3-bit register value of 10-bit u8Volume
152 /// range from 0x00 to 0x07 , gain: -0db to -0.875db (-0.125 db per step)
153 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_AbsoluteVolume(MS_U8 u8Path,MS_U8 u8Vol1,MS_U8 u8Vol2)154 void MDrv_SOUND_AbsoluteVolume(MS_U8 u8Path, MS_U8 u8Vol1, MS_U8 u8Vol2)
155 {
156 HAL_SOUND_AbsoluteVolume(u8Path, u8Vol1, u8Vol2);
157 }
158
159 ////////////////////////////////////////////////////////////////////////////////
160 /// @brief \b Function \b Name: MDrv_SOUND_SetPreScale()
161 /// @brief \b Function \b Description: This routine is used to set the prescale of audio u8Path.
162 /// @param u8Path \b : for audio u8Path0 ~ u8Path5
163 /// @param u8Prescale \b : range from 0x01 to 0xFF , gain: -13.75db to +18db (0.125 db per step)
164 /// 0x00: disable pre-scale
165 /// 0x6F: gain = 0db
166 /// 0xFF: gain = +18db
167 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetPreScale(MS_U8 u8Path,MS_U8 u8Prescale)168 void MDrv_SOUND_SetPreScale(MS_U8 u8Path, MS_U8 u8Prescale)
169 {
170 HAL_SOUND_SetPreScale(u8Path, u8Prescale);
171 }
172
173 ////////////////////////////////////////////////////////////////////////////////
174 /// @brief \b Function \b Name: MDrv_SOUND_SetBalance()
175 /// @brief \b Function \b Description: This routine is used to set the balance of main u8Path.
176 /// @param u8Balance \b : balance level (from 0~100)
177 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetBalance(MS_U8 u8Balance)178 void MDrv_SOUND_SetBalance(MS_U8 u8Balance)
179 {
180 HAL_SOUND_SetBalance(u8Balance);
181 }
182
183 ////////////////////////////////////////////////////////////////////////////////
184 /// @brief \b Function \b Name: MDrv_SOUND_SetBalance_L()
185 /// @brief \b Function \b Description: This routine is used to set absolute balance value of main u8Path L-channel.
186 /// @param u8Balance_L \b : balance register value (0x00~0xFF)
187 /// Left channel attenuation level (0.25dB/step).
188 /// 0000-0000: 0 db.
189 /// 0000-0001: -0.25 db.
190 /// 1111-1110: -63.5 db.
191 /// 1111-1111: Mute.
192 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetBalance_L(MS_U8 u8Balance_L)193 void MDrv_SOUND_SetBalance_L(MS_U8 u8Balance_L)
194 {
195 HAL_SOUND_SetBalance_L(u8Balance_L);
196 }
197
198 ////////////////////////////////////////////////////////////////////////////////
199 /// @brief \b Function \b Name: MDrv_SOUND_SetBalance_R()
200 /// @brief \b Function \b Description: This routine is used to set absolute balance value of main u8Path R-channel.
201 /// @param u8Balance_R \b : balance register value (0x00~0xFF)
202 /// Right channel attenuation level (0.25dB/step).
203 /// 0000-0000: 0 db.
204 /// 0000-0001: -0.25 db.
205 /// 1111-1110: -63.5 db.
206 /// 1111-1111: Mute.
207 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetBalance_R(MS_U8 u8Balance_R)208 void MDrv_SOUND_SetBalance_R(MS_U8 u8Balance_R)
209 {
210 HAL_SOUND_SetBalance_R(u8Balance_R);
211 }
212
213 ////////////////////////////////////////////////////////////////////////////////
214 /// @brief \b Function \b Name: MDrv_SOUND_SetBass()
215 /// @brief \b Function \b Description: This routine is used to set the Bass level of main u8Path .
216 /// @param u8Level \b : Bass level (0~100) mapping to -16~+15dB
217 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetBass(MS_U8 u8Level)218 void MDrv_SOUND_SetBass(MS_U8 u8Level)
219 {
220 HAL_SOUND_SetBass(u8Level);
221 }
222
223 ////////////////////////////////////////////////////////////////////////////////
224 /// @brief \b Function \b Name: MDrv_SOUND_SetDynamicBass()
225 /// @brief \b Function \b Description: This routine is used to set the DynamicBass level of main u8Path .
226 /// @param u8Level \b :
227 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetDynamicBass(MS_U8 u8Level)228 void MDrv_SOUND_SetDynamicBass(MS_U8 u8Level)
229 {
230 HAL_SOUND_SetDynamicBass(u8Level);
231 }
232
233 ////////////////////////////////////////////////////////////////////////////////
234 /// @brief \b Function \b Name: MDrv_SOUND_AbsoluteBass()
235 /// @brief \b Function \b Description: This routine is used to set the absolute Bass value of main u8Path .
236 /// @param u8Bass \b : -16~+15dB ; 1dB/step
237 /// 0-0000: +00db.
238 /// 0-0001: +01db.
239 /// 0-1111: +15db. (Max.)
240 /// 1-1111: -1db.
241 /// 1-1110: -2db.
242 /// 1-0000: -16db. (Min.)
243 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_AbsoluteBass(MS_U8 u8Bass)244 void MDrv_SOUND_AbsoluteBass(MS_U8 u8Bass)
245 {
246 HAL_SOUND_AbsoluteBass(u8Bass);
247 }
248
249 ////////////////////////////////////////////////////////////////////////////////
250 /// @brief \b Function \b Name: MDrv_SOUND_SetTreble()
251 /// @brief \b Function \b Description: This routine is used to set the Treble level of main u8Path.
252 /// @param u8Level \b : Treble level (0~100) mapping to -16~+15dB
253 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetTreble(MS_U8 u8Level)254 void MDrv_SOUND_SetTreble(MS_U8 u8Level)
255 {
256 HAL_SOUND_SetTreble(u8Level);
257 }
258
259 ////////////////////////////////////////////////////////////////////////////////
260 /// @brief \b Function \b Name: MDrv_SOUND_AbsoluteTreble()
261 /// @brief \b Function \b Description: This routine is used to set the absolute Treble value of main u8Path .
262 /// @param u8Treble \b : -16~+15dB ; 1dB/step
263 /// 0-0000: +00db.
264 /// 0-0001: +01db.
265 /// 0-1111: +15db. (Max.)
266 /// 1-1111: -1db.
267 /// 1-1110: -2db.
268 /// 1-0000: -16db. (Min.)
269 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_AbsoluteTreble(MS_U8 u8Treble)270 void MDrv_SOUND_AbsoluteTreble(MS_U8 u8Treble)
271 {
272 HAL_SOUND_AbsoluteTreble(u8Treble);
273 }
274
275 ////////////////////////////////////////////////////////////////////////////////
276 /// @brief \b Function \b Name: MDrv_SOUND_SetEq()
277 /// @brief \b Function \b Description: This routine is used to set the the 5-band EQ level .
278 /// @param u8Band \b : EQ band 0~4
279 /// @param u8Level \b : Absolute EQ register value ;
280 /// 0011-0000: +12.00db. (Max)
281 /// 0000-0001: +0.25db.
282 /// 0000-0000: +0.00db.
283 /// 1111-1111: -0.25db.
284 /// 1101-0000: -12.00db. (Min)
285 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetEq(MS_U8 u8Band,MS_U8 u8Level)286 void MDrv_SOUND_SetEq(MS_U8 u8Band, MS_U8 u8Level)
287 {
288 HAL_SOUND_SetEq(u8Band, u8Level);
289 }
290
291 ////////////////////////////////////////////////////////////////////////////////
292 /// @brief \b Function \b Name: MDrv_SOUND_SetEq7()
293 /// @brief \b Function \b Description: This routine is used to set the the 7-band EQ level .
294 /// @param u8Band \b : EQ band 0~6
295 /// @param u8Level \b : Absolute EQ register value ;
296 /// 0011-0000: +12.00db. (Max)
297 /// 0000-0001: +0.25db.
298 /// 0000-0000: +0.00db.
299 /// 1111-1111: -0.25db.
300 /// 1101-0000: -12.00db. (Min)
301 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetEq7(MS_U8 u8Band,MS_U8 u8Level)302 void MDrv_SOUND_SetEq7(MS_U8 u8Band, MS_U8 u8Level)
303 {
304 HAL_SOUND_SetEq7(u8Band, u8Level);
305 }
306
307 ////////////////////////////////////////////////////////////////////////////////
308 /// @brief \b Function \b Name: MDrv_SOUND_SetADCThreshold()
309 /// @brief \b Function \b Description: This routine is used to set the ADC input energy threshold to reduce the background noise .
310 /// @param u8Threshold \b : NR threshold level
311 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetADCThreshold(MS_U8 u8Threshold)312 void MDrv_SOUND_SetADCThreshold(MS_U8 u8Threshold)
313 {
314 HAL_SOUND_SetADCThreshold(u8Threshold);
315 }
316
317 ////////////////////////////////////////////////////////////////////////////////
318 /// @brief \b Function \b Name: MDrv_SOUND_SetAVCThreshold()
319 /// @brief \b Function \b Description: This routine is used to set the AVC threshold level.
320 /// @param u8Level \b : AVC threshold level
321 /// 0x00-- 0 dBFS
322 /// 0x01-- -0.5 dBFS
323 /// 0x20-- -16 dBFS
324 /// 0x50-- -40 dBFS
325 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetAVCThreshold(MS_U8 u8Level)326 void MDrv_SOUND_SetAVCThreshold(MS_U8 u8Level)
327 {
328 HAL_SOUND_SetAVCThreshold(u8Level);
329 }
330
331
332 ////////////////////////////////////////////////////////////////////////////////
333 /// @brief \b Function \b Name: MDrv_SOUND_SetAvcMode()
334 /// @brief \b Function \b Description: This routine is used to set the AVC u8Mode.
335 /// @param u8AvcMode \b : AVC threshold level
336 /// 0: L u8Mode
337 /// 1: S u8Mode
338 /// 2: M u8Mode
339 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetAvcMode(MS_U8 u8AvcMode)340 void MDrv_SOUND_SetAvcMode(MS_U8 u8AvcMode)
341 {
342 HAL_SOUND_SetAvcMode(u8AvcMode);
343 }
344
345 ////////////////////////////////////////////////////////////////////////////////
346 /// @brief \b Function \b Name: MDrv_SOUND_SetAvcAT()
347 /// @brief \b Function \b Description: This routine is used to set the AVC attack time .
348 /// @param u8AvcAT \b : AVC attack time
349 /// AvcAT = 0 --> 20 ms
350 /// AvcAT = 1 --> 100 ms
351 /// AvcAT = 2 --> 200 ms
352 /// AvcAT = 3 --> 1 sec
353 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetAvcAT(MS_U8 u8AvcAT)354 void MDrv_SOUND_SetAvcAT(MS_U8 u8AvcAT)
355 {
356 HAL_SOUND_SetAvcAT(u8AvcAT);
357 }
358
359 ////////////////////////////////////////////////////////////////////////////////
360 /// @brief \b Function \b Name: MDrv_SOUND_SetAvcRT()
361 /// @brief \b Function \b Description: This routine is used to set the AVC release time .
362 /// @param u8AvcRT \b : AVC release time
363 /// AvcRT = 0 --> 1 sec
364 /// AvcRT = 1 --> 2 sec
365 /// AvcRT = 2 --> 100 ms
366 /// AvcRT = 3 --> 200 ms
367 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetAvcRT(MS_U8 u8AvcRT)368 void MDrv_SOUND_SetAvcRT(MS_U8 u8AvcRT )
369 {
370 HAL_SOUND_SetAvcRT(u8AvcRT );
371 }
372
373 ////////////////////////////////////////////////////////////////////////////////
374 /// @brief \b Function \b Name: MDrv_SOUND_EnableEQ()
375 /// @brief \b Function \b Description: This routine is used to bEnable/disable EQ featue.
376 /// @param bEnable \b : TRUE --Enable EQ
377 /// FALSE--Disable EQ
378 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_EnableEQ(MS_BOOL bEnable)379 void MDrv_SOUND_EnableEQ(MS_BOOL bEnable)
380 {
381 HAL_SOUND_EnableEQ(bEnable);
382 }
383
384 ////////////////////////////////////////////////////////////////////////////////
385 /// @brief \b Function \b Name: MDrv_SOUND_EnableSurround()
386 /// @brief \b Function \b Description: This routine is used to bEnable/disable Surround featue.
387 /// @param bEnable \b : TRUE --Enable Surround
388 /// FALSE--Disable Surround
389 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_EnableSurround(MS_BOOL bEnable)390 void MDrv_SOUND_EnableSurround(MS_BOOL bEnable)
391 {
392 HAL_SOUND_EnableSurround(bEnable);
393 }
394
395 ////////////////////////////////////////////////////////////////////////////////
396 /// @brief \b Function \b Name: MDrv_SOUND_EnableTone()
397 /// @brief \b Function \b Description: This routine is used to bEnable/disable the treble & Bass featue.
398 /// @param bEnable \b : TRUE --Enable Tone
399 /// FALSE--Disable Tone
400 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_EnableTone(MS_BOOL bEnable)401 void MDrv_SOUND_EnableTone(MS_BOOL bEnable)
402 {
403 HAL_SOUND_EnableTone(bEnable);
404 }
405
406 ////////////////////////////////////////////////////////////////////////////////
407 /// @brief \b Function \b Name: MDrv_SOUND_EnableAutoVolume()
408 /// @brief \b Function \b Description: This routine is used to bEnable/disable the AVC featue.
409 /// @param bEnable \b : TRUE --Enable AutoVolume
410 /// FALSE--Disable AutoVolume
411 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_EnableAutoVolume(MS_BOOL bEnable)412 void MDrv_SOUND_EnableAutoVolume(MS_BOOL bEnable)
413 {
414 HAL_SOUND_EnableAutoVolume(bEnable);
415 }
416
417
418 ////////////////////////////////////////////////////////////////////////////////
419 /// @brief \b Function \b Name: MDrv_SOUND_EnableNR()
420 /// @brief \b Function \b Description: This routine is used to bEnable/disable the Noise Reduction featue.
421 /// @param u8Level \b : TRUE --Enable NR
422 /// FALSE--Disable NR
423 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_EnableNR(MS_U8 u8Level)424 void MDrv_SOUND_EnableNR(MS_U8 u8Level)
425 {
426 HAL_SOUND_EnableNR(u8Level);
427 }
428
429 ////////////////////////////////////////////////////////////////////////////////
430 /// @brief \b Function \b Name: MDrv_SOUND_EnableBalance()
431 /// @brief \b Function \b Description: This routine is used to bEnable/disable Balance featue.
432 /// @param u8Enable \b : Balanc Enable bits
433 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_EnableBalance(MS_U8 u8Enable)434 void MDrv_SOUND_EnableBalance(MS_U8 u8Enable)
435 {
436 HAL_SOUND_EnableBalance(u8Enable);
437 }
438
439 ////////////////////////////////////////////////////////////////////////////////
440 /// @brief \b Function \b Name: MDrv_SOUND_SetNRAttenuate()
441 /// @brief \b Function \b Description: This routine is used to set the attenuate level while NR is bEnabled.
442 /// @param u8Mode \b : 0 : Auto fading to -24 dB
443 /// 1 : Auto fading to -24 dB
444 /// 2 : Auto fading to -24 dB
445 /// 3 : Auto fading to -24 dB
446 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetNRAttenuate(MS_U8 u8Mode)447 void MDrv_SOUND_SetNRAttenuate(MS_U8 u8Mode)
448 {
449 u8Mode = u8Mode;
450 }
451
452 ////////////////////////////////////////////////////////////////////////////////
453 /// @brief \b Function \b Name: MDrv_SOUND_PowerDown_Wait()
454 /// @brief \b Function \b Description: This routine is used to DSP power-down wait function.
455 /// @param bEnable \b : TRUE --Not wait
456 /// FALSE--wait
457 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_PowerDown_Wait(MS_BOOL bEnable)458 void MDrv_SOUND_PowerDown_Wait(MS_BOOL bEnable)
459 {
460 HAL_SOUND_PowerDown_Wait(bEnable);
461 }
462
463 ////////////////////////////////////////////////////////////////////////////////
464 /// @brief \b Function \b Name: MDrv_SOUND_SetAdAbsoluteVolume()
465 /// @brief \b Function \b Description: This routine is used to set the absolute u8Volume of AD.
466 /// @param u8Vol1 \b : MSB 7-bit register value of 10-bit u8Volume
467 /// range from 0x00 to 0x7E , gain: +12db to -114db (-1 db per step)
468 /// @param u8Vol2 \b : LSB 3-bit register value of 10-bit u8Volume
469 /// range from 0x00 to 0x07 , gain: -0db to -0.875db (-0.125 db per step)
470 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetAdAbsoluteVolume(MS_U8 u8Vol1,MS_U8 u8Vol2)471 void MDrv_SOUND_SetAdAbsoluteVolume(MS_U8 u8Vol1, MS_U8 u8Vol2)
472 {
473 HAL_SOUND_SetAdAbsoluteVolume(u8Vol1, u8Vol2);
474 }
475
476 ////////////////////////////////////////////////////////////////////////////////
477 /// @brief \b Function \b Name: MDrv_SOUND_SetAdMute()
478 /// @brief \b Function \b Description: This routine is used to set AD mute.
479 /// @param bEnable \b : TRUE --Mute AD
480 /// FALSE--Unmute AD
481 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetAdMute(MS_BOOL bEnable)482 void MDrv_SOUND_SetAdMute(MS_BOOL bEnable)
483 {
484 HAL_SOUND_SetAdMute(bEnable);
485 }
486
487 ////////////////////////////////////////////////////////////////////////////////
488 /// @brief \b Function \b Name: MDrv_SOUND_SetCH1AudioDelay()
489 /// @brief \b Function \b Description: This routine is used to set the value of audio delay.
490 /// @param u8Delay \b : 0x14~0xC8(20~200), in ms unit
491 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetCH1AudioDelay(MS_U8 u8Delay)492 void MDrv_SOUND_SetCH1AudioDelay(MS_U8 u8Delay)
493 {
494 HAL_SOUND_SetCH1AudioDelay(u8Delay);
495 }
496
497 ////////////////////////////////////////////////////////////////////////////////
498 /// @brief \b Function \b Name: MDrv_SOUND_SetMenuSound()
499 /// @brief \b Function \b Description: This routine is used to Play Menu Sound.
500 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_PlayMenuSound(void)501 void MDrv_SOUND_PlayMenuSound(void)
502 {
503 HAL_SOUND_PlayMenuSound();
504 }
505
506 ////////////////////////////////////////////////////////////////////////////////
507 /// @brief \b Function \b Name: MDrv_SOUND_SetSurroundXA()
508 /// @brief \b Function \b Description: This routine is used to set the Surround xA Gain.
509 /// @param u8Mode \b : 0 : 0.1 xA : 0x2D8A[3:2] 00: 0.1
510 /// 1 : 0.15 01: 0.15
511 /// 2 : 0.2 10: 0.2
512 /// 3 : 0.25 11: 0.25
513 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetSurroundXA(MS_U8 u8Mode)514 void MDrv_SOUND_SetSurroundXA(MS_U8 u8Mode)
515 {
516 HAL_SOUND_SetSurroundXA(u8Mode);
517 }
518
519 ////////////////////////////////////////////////////////////////////////////////
520 /// @brief \b Function \b Name: MDrv_SOUND_SetSurroundXB()
521 /// @brief \b Function \b Description: This routine is used to set the Surround xB Gain.
522 /// @param u8Mode \b : 0 : 0.25 xB : 0x2D8A[5:4] 00: 0.25
523 /// 1 : 0.3 01: 0.3
524 /// 2 : 0.35 10: 0.35
525 /// 3 : 0.45 11: 0.45
526 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetSurroundXB(MS_U8 u8Mode)527 void MDrv_SOUND_SetSurroundXB(MS_U8 u8Mode)
528 {
529 HAL_SOUND_SetSurroundXB(u8Mode);
530 }
531
532 ////////////////////////////////////////////////////////////////////////////////
533 /// @brief \b Function \b Name: MDrv_SOUND_SetSurroundXK()
534 /// @brief \b Function \b Description: This routine is used to set the Surround xK Gain.
535 /// @param u8Mode \b : 0 : 0.1 xK : 0x2D8A[7:6] 00: 0.1
536 /// 1 : 0.2 01: 0.2
537 /// 2 : 0.3 10: 0.3
538 /// 3 : 0.4 11: 0.4
539 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetSurroundXK(MS_U8 u8Mode)540 void MDrv_SOUND_SetSurroundXK(MS_U8 u8Mode)
541 {
542 HAL_SOUND_SetSurroundXK(u8Mode);
543 }
544
545 ////////////////////////////////////////////////////////////////////////////////
546 /// @brief \b Function \b Name: MDrv_SOUND_SetSurroundLPFGain()
547 /// @brief \b Function \b Description: This routine is used to set the Surround LPF Gain.
548 /// @param u8Mode \b : 0 : 0 dB LPF Gain : 0x2DA0[7:6] 00: 0 dB
549 /// 1 : 2 dB 01: 2 dB
550 /// 2 : 4 dB 10: 4 dB
551 /// 3 : un-support 11: un-support
552 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetSurroundLPFGain(MS_U8 u8Mode)553 void MDrv_SOUND_SetSurroundLPFGain(MS_U8 u8Mode)
554 {
555 HAL_SOUND_SetSurroundLPFGain(u8Mode);
556 }
557
558 ////////////////////////////////////////////////////////////////////////////////
559 /// @brief \b Function \b Name: MDrv_SOUND_SetPEQCoef()
560 /// @brief \b Function \b Description: This routine is used to set PEQ Coefficient.
561 /// @param <IN> \b peq_coef
562 /// @param <OUT> \b NONE :
563 /// @param <RET> \b NONE :
564 /// @param <GLOBAL> \b NONE
565 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetPEQCoef(AUDIO_PEQ_COEF * peq_coef)566 void MDrv_SOUND_SetPEQCoef(AUDIO_PEQ_COEF *peq_coef)
567 {
568 HAL_SOUND_SetPEQCoef(peq_coef);
569 }
570
571 ////////////////////////////////////////////////////////////////////////////////
572 /// @brief \b Function \b Name: MDrv_SOUND_EnablePEQ()
573 /// @brief \b Function \b Description: This routine is used to eable PEQ.
574 /// @param <IN> \b Enpeq
575 /// @param <OUT> \b NONE :
576 /// @param <RET> \b NONE :
577 /// @param <GLOBAL> \b NONE
578 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_EnablePEQ(MS_BOOL Enpeq)579 void MDrv_SOUND_EnablePEQ(MS_BOOL Enpeq)
580 {
581 HAL_SOUND_EnablePEQ(Enpeq);
582 }
583
584 ////////////////////////////////////////////////////////////////////////////////
585 /// @brief \b Function \b Name: MDrv_SOUND_EnableDcRemove()
586 /// @brief \b Function \b Description: This routine is used to eable DC remove.
587 /// @param <IN> \b EnDcRemove
588 /// @param <OUT> \b True / False
589 /// @param <RET> \b NONE :
590 /// @param <GLOBAL> \b NONE
591 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_EnableDcRemove(MS_BOOL EnDcRemove)592 MS_BOOL MDrv_SOUND_EnableDcRemove(MS_BOOL EnDcRemove)
593 {
594 return HAL_SOUND_EnableDcRemove(EnDcRemove);
595 }
596
597 ////////////////////////////////////////////////////////////////////////////////
598 /// @brief \b Function \b Name: MDrv_SOUND_SetMixModeMute()
599 /// @brief \b Function \b Description: This routine is used to set audio mix mode mute
600 /// @param eSourceType \b : for audio source
601 /// @param VolType \b : for audio vol type
602 /// @param bEnable \b : TRUE --Mute
603 /// FALSE--Unmute
604 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetMixModeMute(AUDIO_SOURCE_INFO_TYPE eSourceType,AUDIO_MIX_VOL_TYPE VolType,MS_BOOL EnMute)605 void MDrv_SOUND_SetMixModeMute(AUDIO_SOURCE_INFO_TYPE eSourceType, AUDIO_MIX_VOL_TYPE VolType, MS_BOOL EnMute )
606 {
607 HAL_SOUND_SetMixModeMute(eSourceType, VolType, EnMute);
608 }
609
610 ////////////////////////////////////////////////////////////////////////////////
611 /// @brief \b Function \b Name: MDrv_SOUND_SetMixModeVolume()
612 /// @brief \b Function \b Description: This routine is used to set the absolute u8Volume of audio mix mode
613 /// @param eSourceType \b : for audio source
614 /// @param VolType \b : for audio vol type
615 /// @param u8Vol1 \b : MSB 7-bit register value of 10-bit u8Volume
616 /// range from 0x00 to 0x7E , gain: +12db to -114db (-1 db per step)
617 /// @param u8Vol2 \b : LSB 3-bit register value of 10-bit u8Volume
618 /// range from 0x00 to 0x07 , gain: -0db to -0.875db (-0.125 db per step)
619 ////////////////////////////////////////////////////////////////////////////////
MDrv_SOUND_SetMixModeVolume(AUDIO_SOURCE_INFO_TYPE eSourceType,AUDIO_MIX_VOL_TYPE VolType,MS_U8 u8Vol1,MS_U8 u8Vol2)620 void MDrv_SOUND_SetMixModeVolume(AUDIO_SOURCE_INFO_TYPE eSourceType, AUDIO_MIX_VOL_TYPE VolType, MS_U8 u8Vol1, MS_U8 u8Vol2 )
621 {
622 HAL_SOUND_SetMixModeVolume(eSourceType, VolType, u8Vol1, u8Vol2);
623 }
624
625 //******************************************************************************
626 /// @brief \b Function \b Name: MDrv_SOUND_SetParam()
627 /// @brief \b Function \b Description: This routine is used for adjust Common Sound parameters
628 /// @return MS_BOOL \b : True / False
629 //******************************************************************************
MDrv_SOUND_SetParam(Sound_SET_Type Type,MS_U32 * p_param)630 MS_BOOL MDrv_SOUND_SetParam( Sound_SET_Type Type, MS_U32 *p_param )
631 {
632 MS_BOOL RET = FALSE;
633 MS_U8 param1 = (MS_U8)(p_param[0]);
634 MS_U8 param2 = (MS_U8)(p_param[1]);
635 AUDIO_PATH_GROUP_TYPE PathGroup = AUDIO_PATH_GROUP_1;
636
637 PathGroup = MDrv_AUDIO_GetPathGroup();
638
639 if ((Type == Sound_SET_Type_SetMute) &&
640 (((PathGroup == AUDIO_PATH_GROUP_1) && (param1 == AUDIO_PATH_3)) ||
641 ((PathGroup == AUDIO_PATH_GROUP_2) && (param1 == AUDIO_T3_PATH_SPDIF))))
642 {
643 MDrv_AUDIO_SPDIF_SetMute(param2);
644 RET= TRUE;
645 }
646 else
647 {
648 RET = HAL_SOUND_SetParam(Type, p_param);
649 }
650
651 return RET;
652 }
653
654 //******************************************************************************
655 /// @brief \b Function \b Name: MDrv_SND_ProcessEnable()
656 /// @brief \b Function \b Description: This routine is used for adjust Common Sound parameters
657 //******************************************************************************
MDrv_SND_ProcessEnable(Sound_ENABLE_Type Type,MS_BOOL enable)658 MS_BOOL MDrv_SND_ProcessEnable(Sound_ENABLE_Type Type, MS_BOOL enable)
659 {
660 return(HAL_SND_ProcessEnable(Type, enable));
661 }
662
663 //******************************************************************************
664 /// @brief \b Function \b Name: MDrv_SND_SetParam()
665 /// @brief \b Function \b Description: This routine is used for adjust Common Sound parameters
666 /// @return MS_BOOL \b : True / False
667 //******************************************************************************
MDrv_SND_SetParam(Sound_SET_PARAM_Type Type,MS_U16 param1,MS_U16 param2)668 MS_BOOL MDrv_SND_SetParam( Sound_SET_PARAM_Type Type, MS_U16 param1, MS_U16 param2)
669 {
670 return(HAL_SND_SetParam(Type, param1, param2));
671 }
672
673
674 //******************************************************************************
675 /// @brief \b Function \b Name: MDrv_SOUND_GetParam()
676 /// @brief \b Function \b Description: This routine is used for adjust Common Sound parameters
677 /// @return MS_BOOL \b : True / False
678 //******************************************************************************
MDrv_SND_GetParam(Sound_GET_PARAM_Type Type,MS_U16 param1)679 MS_U16 MDrv_SND_GetParam( Sound_GET_PARAM_Type Type, MS_U16 param1)
680 {
681 return HAL_SND_GetParam(Type, param1);
682 }
683
684
685