1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - include - dsp
3 File: dsp_util.h
4
5 Copyright 2007-2008 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:: 2008-11-26#$
14 $Rev: 9412 $
15 $Author: kitase_hirotake $
16 *---------------------------------------------------------------------------*/
17 #ifndef TWL_DSP_UTIL_H_
18 #define TWL_DSP_UTIL_H_
19
20
21 #include <twl/types.h>
22
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /*---------------------------------------------------------------------------*/
29 /* Constants */
30
31 #define DSP_SLOT_B_COMPONENT_G711 1
32 #define DSP_SLOT_C_COMPONENT_G711 2
33
34 #define DSP_SLOT_B_COMPONENT_JPEGENCODER 3
35 #define DSP_SLOT_C_COMPONENT_JPEGENCODER 4
36
37 #define DSP_SLOT_B_COMPONENT_JPEGDECODER 2
38 #define DSP_SLOT_C_COMPONENT_JPEGDECODER 4
39
40 #define DSP_SLOT_B_COMPONENT_GRAPHICS 1
41 #define DSP_SLOT_C_COMPONENT_GRAPHICS 4
42
43 #define DSP_SLOT_B_COMPONENT_AACDECODER 2
44 #define DSP_SLOT_C_COMPONENT_AACDECODER 4
45
46 /*---------------------------------------------------------------------------*/
47 /* Functions */
48
49 void DSPi_PlaySoundCore(const void *src, u32 len, BOOL stereo);
50 BOOL DSPi_PlayShutterSoundCore(const void *src, u32 len);
51 void DSPi_StopSoundCore(void);
52 BOOL DSPi_IsSoundPlayingCore(void);
53 BOOL DSPi_IsShutterSoundPlayingCore(void);
54 void DSPi_StartSamplingCore(void *buffer, u32 length);
55 void DSPi_StopSamplingCore(void);
56 void DSPi_SyncSamplingBufferCore(void);
57 const u8* DSPi_GetLastSamplingAddressCore(void);
58
59
60 /*---------------------------------------------------------------------------*
61 Name: DSP_PlaySound
62
63 Description: Plays sound directly from the DSP audio output.
64
65 Arguments: src: The original sampling data.
66 This must be PCM 16-bit data at 32,768 kHz, aligned at 4-byte boundaries.
67 len: Number of bytes of sampling data.
68 stereo: TRUE for stereo and FALSE for monaural.
69
70
71 Returns: None.
72 *---------------------------------------------------------------------------*/
DSP_PlaySound(const void * src,u32 len,BOOL stereo)73 SDK_INLINE void DSP_PlaySound(const void *src, u32 len, BOOL stereo)
74 {
75 if (OS_IsRunOnTwl())
76 {
77 DSPi_PlaySoundCore(src, len, stereo);
78 }
79 }
80
81 /*---------------------------------------------------------------------------*
82 Name: DSP_PlayShutterSound
83
84 Description: Plays the shutter sound from the DSP audio output.
85
86 Arguments: src: Shutter sound data, in WAVE format, associated with the SDK.
87 len: Number of bytes in the shutter sound data.
88
89
90 Returns: Returns TRUE if the SDNEX function succeeded.
91 *---------------------------------------------------------------------------*/
DSP_PlayShutterSound(const void * src,u32 len)92 SDK_INLINE BOOL DSP_PlayShutterSound(const void *src, u32 len)
93 {
94 if (OS_IsRunOnTwl())
95 {
96 return DSPi_PlayShutterSoundCore(src, len);
97 }
98 return FALSE;
99 }
100
101 /*---------------------------------------------------------------------------*
102 Name: DSP_IsSoundPlaying
103
104 Description: Determines whether DSP audio output is currently being played back.
105
106 Arguments: None.
107
108 Returns: TRUE if DSP audio output is currently being played back.
109 *---------------------------------------------------------------------------*/
DSP_IsSoundPlaying(void)110 SDK_INLINE BOOL DSP_IsSoundPlaying(void)
111 {
112 BOOL retval = FALSE;
113 if (OS_IsRunOnTwl())
114 {
115 retval = DSPi_IsSoundPlayingCore();
116 }
117 return retval;
118 }
119
120 /*---------------------------------------------------------------------------*
121 Name: DSP_IsShutterSoundPlaying
122
123 Description: Determines whether the shutter sound is currently being played back from the DSP audio output.
124
125 Arguments: None.
126
127 Returns: TRUE if the shutter sound is currently being played back from the DSP audio output.
128 *---------------------------------------------------------------------------*/
DSP_IsShutterSoundPlaying(void)129 SDK_INLINE BOOL DSP_IsShutterSoundPlaying(void)
130 {
131 BOOL retval = FALSE;
132 if (OS_IsRunOnTwl())
133 {
134 retval = DSPi_IsShutterSoundPlayingCore();
135 }
136 return retval;
137 }
138
139 /*---------------------------------------------------------------------------*
140 Name: DSP_StopSound
141
142 Description: Plays sound directly from the DSP audio output.
143
144 Arguments: None.
145
146 Returns: None.
147 *---------------------------------------------------------------------------*/
DSP_StopSound(void)148 SDK_INLINE void DSP_StopSound(void)
149 {
150 if (OS_IsRunOnTwl())
151 {
152 DSPi_StopSoundCore();
153 }
154 }
155
156 /*---------------------------------------------------------------------------*
157 Name: DSP_StartSampling
158
159 Description: Starts DSP microphone sampling.
160
161 Arguments: buffer: The ring buffer to use for sampling.
162 This must be aligned to boundaries at integer multiples of 16 bits.
163 length: The ring buffer size.
164 This must be aligned to boundaries at integer multiples of 16 bits.
165
166 Returns: None.
167 *---------------------------------------------------------------------------*/
DSP_StartSampling(void * buffer,u32 length)168 SDK_INLINE void DSP_StartSampling(void *buffer, u32 length)
169 {
170 if (OS_IsRunOnTwl())
171 {
172 DSPi_StartSamplingCore(buffer, length);
173 }
174 }
175
176 /*---------------------------------------------------------------------------*
177 Name: DSP_StopSampling
178
179 Description: Stops DSP microphone sampling.
180
181 Arguments: None.
182
183 Returns: None.
184 *---------------------------------------------------------------------------*/
DSP_StopSampling(void)185 SDK_INLINE void DSP_StopSampling(void)
186 {
187 if (OS_IsRunOnTwl())
188 {
189 DSPi_StopSamplingCore();
190 }
191 }
192
193 /*---------------------------------------------------------------------------*
194 Name: DSP_SyncSamplingBuffer
195
196 Description: Loads only the updated parts of the internal DSP ring buffer into the ARM9.
197
198 Arguments: None.
199
200 Returns: None.
201 *---------------------------------------------------------------------------*/
DSP_SyncSamplingBuffer(void)202 SDK_INLINE void DSP_SyncSamplingBuffer(void)
203 {
204 if (OS_IsRunOnTwl())
205 {
206 DSPi_SyncSamplingBufferCore();
207 }
208 }
209
210 /*---------------------------------------------------------------------------*
211 Name: DSP_GetLastSamplingAddress
212
213 Description: Gets the most recent sample position in the local ring buffer that was loaded to the ARM9.
214
215
216 Arguments: None.
217
218 Returns: The most recent sample position.
219 *---------------------------------------------------------------------------*/
DSP_GetLastSamplingAddress(void)220 SDK_INLINE const u8* DSP_GetLastSamplingAddress(void)
221 {
222 const u8 *retval = NULL;
223 if (OS_IsRunOnTwl())
224 {
225 retval = DSPi_GetLastSamplingAddressCore();
226 }
227 return retval;
228 }
229
230
231 /*---------------------------------------------------------------------------*
232 * The following are internal functions
233 *---------------------------------------------------------------------------*/
234
235 /*---------------------------------------------------------------------------*
236 Name: DSP_HookPostStartProcess
237
238 Description: This is a hook that occurs immediately after a DSP process image is loaded.
239 This is required for DSP component developers to start the debugger.
240
241 Arguments: None.
242
243 Returns: None.
244 *---------------------------------------------------------------------------*/
245 void DSP_HookPostStartProcess(void);
246
247
248 /*===========================================================================*/
249
250 #ifdef __cplusplus
251 } /* extern "C" */
252 #endif
253
254
255 #endif /* TWL_DSP_UTIL_H_ */
256