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