1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - snd - include
3   File:     sndex.h
4 
5   Copyright 2008-2009 Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law. They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Date:: 2011-11-01#$
14   $Rev: 11432 $
15   $Author: yada $
16  *---------------------------------------------------------------------------*/
17 #ifndef TWL_SND_ARM9_SNDEX_H_
18 #define TWL_SND_ARM9_SNDEX_H_
19 #ifdef  __cplusplus
20 extern  "C" {
21 #endif
22 /*---------------------------------------------------------------------------*/
23 
24 #include <twl/snd/common/sndex_common.h>
25 
26 /*---------------------------------------------------------------------------*
27     Constant Definitions
28  *---------------------------------------------------------------------------*/
29 /* Processing result */
30 typedef enum SNDEXResult
31 {
32     SNDEX_RESULT_SUCCESS        =   0,
33     SNDEX_RESULT_BEFORE_INIT    =   1,
34     SNDEX_RESULT_INVALID_PARAM  =   2,
35     SNDEX_RESULT_EXCLUSIVE      =   3,
36     SNDEX_RESULT_ILLEGAL_STATE  =   4,
37     SNDEX_RESULT_PXI_SEND_ERROR =   5,
38     SNDEX_RESULT_DEVICE_ERROR   =   6,
39     SNDEX_RESULT_FATAL_ERROR    =   7,
40     SNDEX_RESULT_ILLEGAL_TARGET =   8,
41     SNDEX_RESULT_MAX
42 
43 } SNDEXResult;
44 
45 /* Mute settings */
46 typedef enum SNDEXMute
47 {
48     SNDEX_MUTE_OFF  =   0,
49     SNDEX_MUTE_ON   =   1,
50     SNDEX_MUTE_MAX
51 
52 } SNDEXMute;
53 
54 /* I2S frequency settings */
55 typedef enum SNDEXFrequency
56 {
57     SNDEX_FREQUENCY_32730   =   0,
58     SNDEX_FREQUENCY_47610   =   1,
59     SNDEX_FREQUENCY_MAX
60 
61 } SNDEXFrequency;
62 
63 /* IIR filter parameter structure */
64 typedef struct _SNDEXIirFilterParam
65 {
66     u16 n0;
67     u16 n1;
68     u16 n2;
69     u16 d1;
70     u16 d2;
71 } SNDEXIirFilterParam;
72 
73 /* Enumerated type for the IIR filter target */
74 typedef enum _SNDEXIirFilterTarget
75 {
76     SNDEX_IIR_FILTER_ADC_1 = 0,
77     SNDEX_IIR_FILTER_ADC_2,
78     SNDEX_IIR_FILTER_ADC_3,
79     SNDEX_IIR_FILTER_ADC_4,
80     SNDEX_IIR_FILTER_ADC_5,
81     SNDEX_IIR_FILTER_TARGET_AVAILABLE_MAX,
82     SNDEX_IIR_FILTER_RESERVED_1 = SNDEX_IIR_FILTER_TARGET_AVAILABLE_MAX,
83     SNDEX_IIR_FILTER_RESERVED_2,
84     SNDEX_IIR_FILTER_RESERVED_3,
85     SNDEX_IIR_FILTER_RESERVED_4,
86     SNDEX_IIR_FILTER_RESERVED_5,
87     SNDEX_IIR_FILTER_RESERVED_6,
88     SNDEX_IIR_FILTER_RESERVED_7,
89     SNDEX_IIR_FILTER_RESERVED_8,
90     SNDEX_IIR_FILTER_RESERVED_9,
91     SNDEX_IIR_FILTER_RESERVED_10,
92     SNDEX_IIR_FILTER_RESERVED_11,
93     SNDEX_IIR_FILTER_RESERVED_12,
94     SNDEX_IIR_FILTER_RESERVED_13,
95     SNDEX_IIR_FILTER_RESERVED_14,
96     SNDEX_IIR_FILTER_RESERVED_15,
97     SNDEX_IIR_FILTER_TARGET_MAX
98 } SNDEXIirFilterTarget;
99 
100 /* Whether there are headphones connected */
101 typedef enum SNDEXHeadphone
102 {
103     SNDEX_HEADPHONE_UNCONNECT   =   0,
104     SNDEX_HEADPHONE_CONNECT     =   1,
105     SNDEX_HEADPHONE_MAX
106 } SNDEXHeadphone;
107 
108 /* DSP mix rate settings */
109 #define SNDEX_DSP_MIX_RATE_MIN  0
110 #define SNDEX_DSP_MIX_RATE_MAX  8
111 
112 /* Volume settings */
113 #define SNDEX_VOLUME_MIN        0
114 #define SNDEX_VOLUME_MAX        7
115 #define SNDEX_VOLUME_MAX_EX     31
116 
117 /*---------------------------------------------------------------------------*
118     Structure Definitions
119  *---------------------------------------------------------------------------*/
120 /* Callback function type definitions */
121 typedef void    (*SNDEXCallback)    (SNDEXResult result, void* arg);
122 
123 #define SNDEXVolumeSwitchCallbackInfo SNDEXWork
124 
125 /*---------------------------------------------------------------------------*
126     Definitions of Private Functions
127  *---------------------------------------------------------------------------*/
128 void    SNDEXi_Init (void);
129 
130 SNDEXResult SNDEXi_GetMuteAsync            (SNDEXMute* mute, SNDEXCallback callback, void* arg);
131 SNDEXResult SNDEXi_GetMute                 (SNDEXMute* mute);
132 SNDEXResult SNDEXi_GetI2SFrequencyAsync    (SNDEXFrequency* freq, SNDEXCallback callback, void* arg);
133 SNDEXResult SNDEXi_GetI2SFrequency         (SNDEXFrequency* freq);
134 SNDEXResult SNDEXi_GetDSPMixRateAsync      (u8* rate, SNDEXCallback callback, void* arg);
135 SNDEXResult SNDEXi_GetDSPMixRate           (u8* rate);
136 SNDEXResult SNDEXi_GetVolumeAsync          (u8* volume, SNDEXCallback callback, void* arg, BOOL eightlv, BOOL keep);
137 SNDEXResult SNDEXi_GetVolume               (u8* volume, BOOL eightlv, BOOL keep);
138 SNDEXResult SNDEXi_GetVolumeExAsync        (u8* volume, SNDEXCallback callback, void* arg);
139 SNDEXResult SNDEXi_GetVolumeEx             (u8* volume);
140 SNDEXResult SNDEXi_GetCurrentVolumeExAsync (u8* volume, SNDEXCallback callback, void* arg);
141 SNDEXResult SNDEXi_GetCurrentVolumeEx      (u8* volume);
142 
143 SNDEXResult SNDEXi_SetMuteAsync         (SNDEXMute mute, SNDEXCallback callback, void* arg);
144 SNDEXResult SNDEXi_SetMute              (SNDEXMute mute);
145 SNDEXResult SNDEXi_SetI2SFrequencyAsync (SNDEXFrequency freq, SNDEXCallback callback, void* arg);
146 SNDEXResult SNDEXi_SetI2SFrequency      (SNDEXFrequency freq);
147 SNDEXResult SNDEXi_SetDSPMixRateAsync   (u8 rate, SNDEXCallback callback, void* arg);
148 SNDEXResult SNDEXi_SetDSPMixRate        (u8 rate);
149 SNDEXResult SNDEXi_SetVolumeAsync       (u8 volume, SNDEXCallback callback, void* arg, BOOL eightlv);
150 SNDEXResult SNDEXi_SetVolume            (u8 volume, BOOL eightlv);
151 SNDEXResult SNDEXi_SetVolumeExAsync     (u8 volume, SNDEXCallback callback, void* arg);
152 SNDEXResult SNDEXi_SetVolumeEx          (u8 volume);
153 
154 SNDEXResult SNDEXi_SetIirFilterAsync    (SNDEXIirFilterTarget target, const SNDEXIirFilterParam* pParam, SNDEXCallback callback, void* arg);
155 SNDEXResult SNDEXi_SetIirFilter         (SNDEXIirFilterTarget target, const SNDEXIirFilterParam* pParam);
156 
157 SNDEXResult SNDEXi_IsConnectedHeadphoneAsync (SNDEXHeadphone *hp, SNDEXCallback callback, void* arg);
158 SNDEXResult SNDEXi_IsConnectedHeadphone      (SNDEXHeadphone *hp);
159 
160 void        SNDEXi_SetVolumeSwitchCallback   (SNDEXCallback callback, void* arg);
161 
162 SNDEXResult SNDEXi_SetIgnoreHWVolume       (u8 volume, BOOL eightlv);
163 SNDEXResult SNDEXi_ResetIgnoreHWVolume     (void);
164 
165 SNDEXResult SNDEXi_PreProcessForShutterSound  (void);
166 SNDEXResult SNDEXi_PostProcessForShutterSound (SNDEXCallback callback, void* arg);
167 
168 /*---------------------------------------------------------------------------*
169   Name:         SNDEX_Init
170 
171   Description:  Initializes the extended sound features library.
172 
173   Arguments:    None.
174 
175   Returns:      None.
176  *---------------------------------------------------------------------------*/
177 static inline void
SNDEX_Init(void)178 SNDEX_Init (void)
179 {
180     if (OS_IsRunOnTwl() == TRUE)
181     {
182         SNDEXi_Init();
183     }
184 }
185 
186 /*---------------------------------------------------------------------------*
187   Name:         SNDEX_GetMuteAsync
188 
189   Description:  Asynchronously gets the mute status of the audio output.
190                 Because the writing of results to the results buffer is asynchronous compared to the function call, the buffer should not be used for other purposes until the asynchronous process completes.
191 
192 
193   Arguments:    mute: Specifies the buffer used to get the mute status.
194                 callback: Specifies the callback function that notifies of the results when the asynchronous process is completed.
195 
196                 arg: Specifies parameter passed to the callback function.
197 
198   Returns:      SNDEXResult: Returns processing results.
199                                 When returning SNDEX_RESULT_SUCCESS, the actual processing results are notified to the function registered to the callback after the asynchronous process is complete.
200 
201  *---------------------------------------------------------------------------*/
202 static inline SNDEXResult
SNDEX_GetMuteAsync(SNDEXMute * mute,SNDEXCallback callback,void * arg)203 SNDEX_GetMuteAsync (SNDEXMute* mute, SNDEXCallback callback, void* arg)
204 {
205     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
206             SNDEXi_GetMuteAsync(mute, callback, arg) :
207             SNDEX_RESULT_ILLEGAL_STATE);
208 }
209 
210 /*---------------------------------------------------------------------------*
211   Name:         SNDEX_GetMute
212 
213   Description:  Gets the mute status of the audio output.
214                 This is a synchronous function, so calling from within an interrupt handler is prohibited.
215 
216   Arguments:    mute: Specifies the buffer used to get the mute status.
217 
218   Returns:      SNDEXResult: Returns processing results.
219  *---------------------------------------------------------------------------*/
220 static inline SNDEXResult
SNDEX_GetMute(SNDEXMute * mute)221 SNDEX_GetMute (SNDEXMute* mute)
222 {
223     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
224             SNDEXi_GetMute(mute) :
225             SNDEX_RESULT_ILLEGAL_STATE);
226 }
227 
228 /*---------------------------------------------------------------------------*
229   Name:         SNDEX_GetI2SFrequencyAsync
230 
231   Description:  Asynchronously gets the I2S frequency information.
232                 Because the writing of results to the results buffer is asynchronous compared to the function call, the buffer should not be used for other purposes until the asynchronous process completes.
233 
234 
235   Arguments:    freq: Specifies the buffer used to get the frequency information.
236                 callback: Specifies the callback function that notifies of the results when the asynchronous process is completed.
237 
238                 arg: Specifies parameter passed to the callback function.
239 
240   Returns:      SNDEXResult: Returns processing results.
241                                 When returning SNDEX_RESULT_SUCCESS, the actual processing results are notified to the function registered to the callback after the asynchronous process is complete.
242 
243  *---------------------------------------------------------------------------*/
244 static inline SNDEXResult
SNDEX_GetI2SFrequencyAsync(SNDEXFrequency * freq,SNDEXCallback callback,void * arg)245 SNDEX_GetI2SFrequencyAsync (SNDEXFrequency* freq, SNDEXCallback callback, void* arg)
246 {
247     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
248             SNDEXi_GetI2SFrequencyAsync(freq, callback, arg) :
249             SNDEX_RESULT_ILLEGAL_STATE);
250 }
251 
252 /*---------------------------------------------------------------------------*
253   Name:         SNDEX_GetI2SFrequency
254 
255   Description:  Gets I2S frequency information.
256                 This is a synchronous function, so calling from within an interrupt handler is prohibited.
257 
258   Arguments:    freq: Specifies the buffer used to get the frequency information.
259 
260   Returns:      SNDEXResult: Returns processing results.
261  *---------------------------------------------------------------------------*/
262 static inline SNDEXResult
SNDEX_GetI2SFrequency(SNDEXFrequency * freq)263 SNDEX_GetI2SFrequency (SNDEXFrequency* freq)
264 {
265     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
266             SNDEXi_GetI2SFrequency(freq) :
267             SNDEX_RESULT_ILLEGAL_STATE);
268 }
269 
270 /*---------------------------------------------------------------------------*
271   Name:         SNDEX_GetDSPMixRateAsync
272 
273   Description:  Gets the audio output mix rate information for the CPU and DSP.
274                 Minimum mix rate: 0 (DSP 100%), maximum: 8 (CPU 100%).
275                 Because the writing of results to the results buffer is asynchronous compared to the function call, the buffer should not be used for other purposes until the asynchronous process completes.
276 
277 
278   Arguments:    rate: Specifies the buffer used to get the mix rate information.
279                 callback: Specifies the callback function that notifies of the results when the asynchronous process is completed.
280 
281                 arg: Specifies parameter passed to the callback function.
282 
283   Returns:      SNDEXResult: Returns processing results.
284                                 When returning SNDEX_RESULT_SUCCESS, the actual processing results are notified to the function registered to the callback after the asynchronous process is complete.
285 
286  *---------------------------------------------------------------------------*/
287 static inline SNDEXResult
SNDEX_GetDSPMixRateAsync(u8 * rate,SNDEXCallback callback,void * arg)288 SNDEX_GetDSPMixRateAsync (u8* rate, SNDEXCallback callback, void* arg)
289 {
290     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
291             SNDEXi_GetDSPMixRateAsync(rate, callback, arg) :
292             SNDEX_RESULT_ILLEGAL_STATE);
293 }
294 
295 /*---------------------------------------------------------------------------*
296   Name:         SNDEX_GetDSPMixRate
297 
298   Description:  Gets the audio output mix rate information for the CPU and DSP.
299                 Minimum mix rate: 0 (DSP 100%), maximum: 8 (CPU 100%).
300                 This is a synchronous function, so calling from within an interrupt handler is prohibited.
301 
302   Arguments:    rate: Specifies the buffer used to get the mix rate information.
303 
304   Returns:      SNDEXResult: Returns processing results.
305  *---------------------------------------------------------------------------*/
306 static inline SNDEXResult
SNDEX_GetDSPMixRate(u8 * rate)307 SNDEX_GetDSPMixRate (u8* rate)
308 {
309     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
310             SNDEXi_GetDSPMixRate(rate) :
311             SNDEX_RESULT_ILLEGAL_STATE);
312 }
313 
314 /*---------------------------------------------------------------------------*
315   Name:         SNDEX_GetVolumeAsync
316 
317   Description:  Gets the audio output volume information. Minimum volume: 0, maximum: 31.
318                 Because the writing of results to the results buffer is asynchronous compared to the function call, the buffer should not be used for other purposes until the asynchronous process completes.
319 
320 
321   Arguments:    volume: Specifies the buffer used to get the volume information.
322                 callback: Specifies the callback function that notifies of the results when the asynchronous process is completed.
323 
324                 arg: Specifies parameter passed to the callback function.
325 
326   Returns:      SNDEXResult: Returns processing results.
327                                 When returning SNDEX_RESULT_SUCCESS, the actual processing results are notified to the function registered to the callback after the asynchronous process is complete.
328 
329  *---------------------------------------------------------------------------*/
330 static inline SNDEXResult
SNDEX_GetVolumeAsync(u8 * volume,SNDEXCallback callback,void * arg)331 SNDEX_GetVolumeAsync (u8* volume, SNDEXCallback callback, void* arg)
332 {
333     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
334             SNDEXi_GetVolumeAsync(volume, callback, arg, TRUE, TRUE) :
335             SNDEX_RESULT_ILLEGAL_STATE);
336 }
337 
338 /*---------------------------------------------------------------------------*
339   Name:         SNDEX_GetCurrentVolumeAsync
340 
341   Description:  Gets the audio output volume information. Minimum volume: 0, maximum: 31.
342                 Because the writing of results to the results buffer is asynchronous compared to the function call, the buffer should not be used for other purposes until the asynchronous process completes.
343 
344 
345   Arguments:    volume: Specifies the buffer used to get the volume information.
346                 callback: Specifies the callback function that notifies of the results when the asynchronous process is completed.
347 
348                 arg: Specifies parameter passed to the callback function.
349 
350   Returns:      SNDEXResult: Returns processing results.
351                                 When returning SNDEX_RESULT_SUCCESS, the actual processing results are notified to the function registered to the callback after the asynchronous process is complete.
352                                 However, the volume available with this function is the value that has actually been set, not the retained value that is updated by the SNDEX_SetVolume[Async] functions.
353 
354 
355  *---------------------------------------------------------------------------*/
356 static inline SNDEXResult
SNDEX_GetCurrentVolumeAsync(u8 * volume,SNDEXCallback callback,void * arg)357 SNDEX_GetCurrentVolumeAsync (u8* volume, SNDEXCallback callback, void* arg)
358 {
359     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
360             SNDEXi_GetVolumeAsync(volume, callback, arg, TRUE, FALSE) :
361             SNDEX_RESULT_ILLEGAL_STATE);
362 }
363 
364 /*---------------------------------------------------------------------------*
365   Name:         SNDEX_GetVolume
366 
367   Description:  Gets the audio output volume information. Minimum volume: 0, maximum: 31.
368                 This is a synchronous function, so calling from within an interrupt handler is prohibited.
369 
370   Arguments:    volume: Specifies the buffer used to get the volume information.
371 
372   Returns:      SNDEXResult: Returns processing results.
373  *---------------------------------------------------------------------------*/
374 static inline SNDEXResult
SNDEX_GetVolume(u8 * volume)375 SNDEX_GetVolume (u8* volume)
376 {
377     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
378             SNDEXi_GetVolume(volume, TRUE, TRUE) :
379             SNDEX_RESULT_ILLEGAL_STATE);
380 }
381 
382 /*---------------------------------------------------------------------------*
383   Name:         SNDEX_GetCurrentVolume
384 
385   Description:  Gets the audio output volume information. Minimum volume: 0, maximum: 31.
386                 This is a synchronous function, so calling from within an interrupt handler is prohibited.
387 
388   Arguments:    volume: Specifies the buffer used to get the volume information.
389 
390   Returns:      SNDEXResult: Returns processing results.
391                                 However, the volume available with this function is the value that has actually been set, not the retained value that is updated by the SNDEX_SetVolume[Async] functions.
392 
393  *---------------------------------------------------------------------------*/
394 static inline SNDEXResult
SNDEX_GetCurrentVolume(u8 * volume)395 SNDEX_GetCurrentVolume (u8* volume)
396 {
397     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
398             SNDEXi_GetVolume(volume, TRUE, FALSE) :
399             SNDEX_RESULT_ILLEGAL_STATE);
400 }
401 
402 /*---------------------------------------------------------------------------*
403   Name:         SNDEX_SetMuteAsync
404 
405   Description:  Changes the mute status of the audio output.
406 
407   Arguments:    mute: Specifies mute setting status.
408                 callback: Specifies the callback function that notifies of the results when the asynchronous process is completed.
409 
410                 arg: Specifies parameter passed to the callback function.
411 
412   Returns:      SNDEXResult: Returns processing results.
413                                 When returning SNDEX_RESULT_SUCCESS, the actual processing results are notified to the function registered to the callback after the asynchronous process is complete.
414 
415  *---------------------------------------------------------------------------*/
416 static inline SNDEXResult
SNDEX_SetMuteAsync(SNDEXMute mute,SNDEXCallback callback,void * arg)417 SNDEX_SetMuteAsync (SNDEXMute mute, SNDEXCallback callback, void* arg)
418 {
419     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
420             SNDEXi_SetMuteAsync(mute, callback, arg) :
421             SNDEX_RESULT_ILLEGAL_STATE);
422 }
423 
424 /*---------------------------------------------------------------------------*
425   Name:         SNDEX_SetMute
426 
427   Description:  Changes the mute status of the audio output.
428                 This is a synchronous function, so calling from within an interrupt handler is prohibited.
429 
430   Arguments:    mute: Specifies mute setting status.
431 
432   Returns:      SNDEXResult: Returns processing results.
433  *---------------------------------------------------------------------------*/
434 static inline SNDEXResult
SNDEX_SetMute(SNDEXMute mute)435 SNDEX_SetMute (SNDEXMute mute)
436 {
437     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
438             SNDEXi_SetMute(mute) :
439             SNDEX_RESULT_ILLEGAL_STATE);
440 }
441 
442 /*---------------------------------------------------------------------------*
443   Name:         SNDEX_SetI2SFrequencyAsync
444 
445   Description:  Changes the I2S frequency.
446 
447   Arguments:    freq: Specifies the frequency.
448                 callback: Specifies the callback function that notifies of the results when the asynchronous process is completed.
449 
450                 arg: Specifies parameter passed to the callback function.
451 
452   Returns:      SNDEXResult: Returns processing results.
453                                 When returning SNDEX_RESULT_SUCCESS, the actual processing results are notified to the function registered to the callback after the asynchronous process is complete.
454 
455  *---------------------------------------------------------------------------*/
456 static inline SNDEXResult
SNDEX_SetI2SFrequencyAsync(SNDEXFrequency freq,SNDEXCallback callback,void * arg)457 SNDEX_SetI2SFrequencyAsync (SNDEXFrequency freq, SNDEXCallback callback, void* arg)
458 {
459     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
460             SNDEXi_SetI2SFrequencyAsync(freq, callback, arg) :
461             SNDEX_RESULT_ILLEGAL_STATE);
462 }
463 
464 /*---------------------------------------------------------------------------*
465   Name:         SNDEX_SetI2SFrequency
466 
467   Description:  Changes the I2S frequency.
468                 This is a synchronous function, so calling from within an interrupt handler is prohibited.
469 
470   Arguments:    freq: Specifies the frequency.
471 
472   Returns:      SNDEXResult: Returns processing results.
473  *---------------------------------------------------------------------------*/
474 static inline SNDEXResult
SNDEX_SetI2SFrequency(SNDEXFrequency freq)475 SNDEX_SetI2SFrequency (SNDEXFrequency freq)
476 {
477     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
478             SNDEXi_SetI2SFrequency(freq) :
479             SNDEX_RESULT_ILLEGAL_STATE);
480 }
481 
482 /*---------------------------------------------------------------------------*
483   Name:         SNDEX_SetDSPMixRateAsync
484 
485   Description:  Changes the audio output mix rate for the CPU and DSP.
486                 Minimum mix rate: 0 (DSP 100%), maximum: 8 (CPU 100%).
487 
488   Arguments:    rate: Specifies the mix rate with a numeral from 0 to 8.
489                 callback: Specifies the callback function that notifies of the results when the asynchronous process is completed.
490 
491                 arg: Specifies parameter passed to the callback function.
492 
493   Returns:      SNDEXResult: Returns processing results.
494                                 When returning SNDEX_RESULT_SUCCESS, the actual processing results are notified to the function registered to the callback after the asynchronous process is complete.
495 
496  *---------------------------------------------------------------------------*/
497 static inline SNDEXResult
SNDEX_SetDSPMixRateAsync(u8 rate,SNDEXCallback callback,void * arg)498 SNDEX_SetDSPMixRateAsync (u8 rate, SNDEXCallback callback, void* arg)
499 {
500     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
501             SNDEXi_SetDSPMixRateAsync(rate, callback, arg) :
502             SNDEX_RESULT_ILLEGAL_STATE);
503 }
504 
505 /*---------------------------------------------------------------------------*
506   Name:         SNDEX_SetDSPMixRate
507 
508   Description:  Changes the audio output mix rate for the CPU and DSP.
509                 Minimum mix rate: 0 (DSP 100%), maximum: 8 (CPU 100%).
510                 This is a synchronous function, so calling from within an interrupt handler is prohibited.
511 
512   Arguments:    rate: Specifies the mix rate with a numeral from 0 to 8.
513 
514   Returns:      SNDEXResult: Returns processing results.
515  *---------------------------------------------------------------------------*/
516 static inline SNDEXResult
SNDEX_SetDSPMixRate(u8 rate)517 SNDEX_SetDSPMixRate (u8 rate)
518 {
519     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
520             SNDEXi_SetDSPMixRate(rate) :
521             SNDEX_RESULT_ILLEGAL_STATE);
522 }
523 
524 /*---------------------------------------------------------------------------*
525   Name:         SNDEX_SetVolumeAsync
526 
527   Description:  Changes the audio output volume. Minimum volume: 0, maximum: 31.
528 
529   Arguments:    volume: Specifies the volume as a numeral from 0 to 31.
530                 callback: Specifies the callback function that notifies of the results when the asynchronous process is completed.
531 
532                 arg: Specifies parameter passed to the callback function.
533 
534   Returns:      SNDEXResult: Returns processing results.
535                                 When returning SNDEX_RESULT_SUCCESS, the actual processing results are notified to the function registered to the callback after the asynchronous process is complete.
536 
537  *---------------------------------------------------------------------------*/
538 static inline SNDEXResult
SNDEX_SetVolumeAsync(u8 volume,SNDEXCallback callback,void * arg)539 SNDEX_SetVolumeAsync (u8 volume, SNDEXCallback callback, void* arg)
540 {
541     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
542             SNDEXi_SetVolumeAsync(volume, callback, arg, TRUE) :
543             SNDEX_RESULT_ILLEGAL_STATE);
544 }
545 
546 /*---------------------------------------------------------------------------*
547   Name:         SNDEX_SetVolume
548 
549   Description:  Changes the audio output volume. Minimum volume: 0, maximum: 31.
550                 This is a synchronous function, so calling from within an interrupt handler is prohibited.
551 
552   Arguments:    volume: Specifies the volume as a numeral from 0 to 31.
553 
554   Returns:      SNDEXResult: Returns processing results.
555  *---------------------------------------------------------------------------*/
556 static inline SNDEXResult
SNDEX_SetVolume(u8 volume)557 SNDEX_SetVolume (u8 volume)
558 {
559     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
560             SNDEXi_SetVolume(volume, TRUE) :
561             SNDEX_RESULT_ILLEGAL_STATE);
562 }
563 
564 /*---------------------------------------------------------------------------*
565   Name:         SNDEX_SetIirFilterAsync
566 
567   Description:  Asynchronously sets the IIR filter (Biquad) parameters.
568 
569   Arguments:    target: An SNDEXIirFilterTarget enumerated type indicating where to apply IIR filters
570                 pParam: A SNDEXIirFilterParam structure with IIR filter coefficients
571                 callback: The callback function that will be invoked after the IIR filters are configured
572                 arg: Arguments to pass to the callback function
573 
574   Returns:      SNDEX_RESULT_SUCCESS on normal completion.
575  *---------------------------------------------------------------------------*/
576 static inline SNDEXResult
SNDEX_SetIirFilterAsync(SNDEXIirFilterTarget target,const SNDEXIirFilterParam * pParam,SNDEXCallback callback,void * arg)577 SNDEX_SetIirFilterAsync(SNDEXIirFilterTarget target, const SNDEXIirFilterParam* pParam, SNDEXCallback callback, void* arg)
578 {
579     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
580             SNDEXi_SetIirFilterAsync(target, pParam, callback, arg) : SNDEX_RESULT_ILLEGAL_STATE);
581 }
582 
583 /*---------------------------------------------------------------------------*
584   Name:         SNDEX_SetIirFilter
585 
586   Description:  Sets the IIR filter (Biquad) parameters.
587 
588   Arguments:    target: An SNDEXIirFilterTarget enumerated type indicating where to apply IIR filters
589                 pParam: A SNDEXIirFilterParam structure with IIR filter coefficients
590 
591   Returns:      SNDEX_RESULT_SUCCESS on normal completion.
592  *---------------------------------------------------------------------------*/
593 static inline SNDEXResult
SNDEX_SetIirFilter(SNDEXIirFilterTarget target,const SNDEXIirFilterParam * pParam)594 SNDEX_SetIirFilter(SNDEXIirFilterTarget target, const SNDEXIirFilterParam* pParam)
595 {
596     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
597             SNDEXi_SetIirFilter(target, pParam) : SNDEX_RESULT_ILLEGAL_STATE);
598 }
599 
600 /*---------------------------------------------------------------------------*
601   Name:         SNDEX_IsConnectedHeadphoneAsync
602 
603   Description:  Gets whether headphones are connected.
604 
605   Arguments:    hp: Specifies the buffer used to get headphone connection status.
606                 callback: Specifies the callback function that notifies of the results when the asynchronous process is completed.
607 
608                 arg: Specifies parameter passed to the callback function.
609 
610   Returns:      SNDEXResult: Returns processing results.
611                                 When returning SNDEX_RESULT_SUCCESS, the actual processing results are notified to the function registered to the callback after the asynchronous process is complete.
612 
613  *---------------------------------------------------------------------------*/
614 static inline SNDEXResult
SNDEX_IsConnectedHeadphoneAsync(SNDEXHeadphone * hp,SNDEXCallback callback,void * arg)615 SNDEX_IsConnectedHeadphoneAsync (SNDEXHeadphone *hp, SNDEXCallback callback, void* arg)
616 {
617     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
618             SNDEXi_IsConnectedHeadphoneAsync(hp, callback, arg) :
619             SNDEX_RESULT_ILLEGAL_STATE);
620 }
621 
622 /*---------------------------------------------------------------------------*
623   Name:         SNDEX_IsConnectedHeadphone
624 
625   Description:  Gets whether headphones are connected.
626 
627   Arguments:    hp: Specifies the buffer used to get headphone connection status.
628 
629   Returns:      SNDEXResult: Returns processing results.
630                                 When returning SNDEX_RESULT_SUCCESS, the actual processing results are notified to the function registered to the callback after the asynchronous process is complete.
631 
632  *---------------------------------------------------------------------------*/
633 static inline SNDEXResult
SNDEX_IsConnectedHeadphone(SNDEXHeadphone * hp)634 SNDEX_IsConnectedHeadphone (SNDEXHeadphone *hp)
635 {
636     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
637             SNDEXi_IsConnectedHeadphone(hp) :
638             SNDEX_RESULT_ILLEGAL_STATE);
639 }
640 
641 /*---------------------------------------------------------------------------*
642   Name:         SNDEX_SetVolumeSwitchCallback
643 
644   Description:  Sets the callback function that is called when the volume button is pressed.
645 
646   Arguments:    callback: Specifies the callback function called when the volume button is pressed.
647                 arg: Specifies parameter passed to the callback function.
648 
649   Returns:      None.
650  *---------------------------------------------------------------------------*/
651 static inline void
SNDEX_SetVolumeSwitchCallback(SNDEXCallback callback,void * arg)652 SNDEX_SetVolumeSwitchCallback (SNDEXCallback callback, void* arg)
653 {
654     if (OS_IsRunOnTwl() == TRUE)
655     {
656         SNDEXi_SetVolumeSwitchCallback(callback, arg);
657     }
658 }
659 
660 /*---------------------------------------------------------------------------*
661   Name:         SNDEX_SetIgnoreHWVolume
662 
663   Description:  If you need to play a sound (such as the clock's alarm tone) at a specified volume regardless of the value set for the system volume at the time, you must change the volume without user input.
664                 This function saves the volume before changing it.
665                 A termination callback function is registered to restore the original volume when the system is reset or shut down at a time that is unintended by the application.
666                 By calling SNDEX_ResetIgnoreHWVolume, the original volume will be restored and the registered termination callback will be removed.
667 
668 
669 
670 
671 
672   Arguments:    volume: The value to change the volume to.
673 
674   Returns:      SNDEXResult: Returns processing results.
675  *---------------------------------------------------------------------------*/
676 static inline SNDEXResult
SNDEX_SetIgnoreHWVolume(u8 volume)677 SNDEX_SetIgnoreHWVolume (u8 volume)
678 {
679     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
680             SNDEXi_SetIgnoreHWVolume(volume, TRUE) :
681             SNDEX_RESULT_ILLEGAL_STATE);
682 }
683 
684 /*---------------------------------------------------------------------------*
685   Name:         SNDEX_ResetIgnoreHWVolume
686 
687   Description:  Restores the volume to its value before changed by SNDEX_SetIgnoreHWVolume.
688                 This removes the registered termination callback at the same time.
689 
690   Arguments:    None.
691 
692   Returns:      SNDEXResult: Returns processing results.
693  *---------------------------------------------------------------------------*/
694 static inline SNDEXResult
SNDEX_ResetIgnoreHWVolume(void)695 SNDEX_ResetIgnoreHWVolume (void)
696 {
697     return (SNDEXResult)((OS_IsRunOnTwl() == TRUE) ?
698             SNDEXi_ResetIgnoreHWVolume() :
699             SNDEX_RESULT_ILLEGAL_STATE);
700 }
701 /*---------------------------------------------------------------------------*/
702 #ifdef __cplusplus
703 }   // extern "C"
704 #endif
705 #endif  // TWL_SND_ARM9_SNDEX_H_
706